Commit Graph

42 Commits

Author SHA1 Message Date
Lukas Tönne 47bf0934f5 Removed generic debug1..4 values from the cloth data.
These were used as UI buttons during development. If such parameters are
needed again later they should instead be added in the (now global)
SimDebugData and made accessible with a dev addon or so.
2015-01-21 10:07:11 +01:00
Lukas Tönne 325990ff6e Use dedicated debug values in cloth settings instead of abusing unused
other values.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:08 +01:00
Lukas Tönne b3cbafb966 Implementation of a target density feature for the hair simulation.
This allows setting a target density which the fluid simulation will
take into account as an additional term in the pressure Poisson
equation. Based on two papers
"Detail Preserving Continuum Simulation of Straight Hair" (McAdams et al. 2009)
and
"Two-way Coupled SPH and Particle Level Set Fluid Simulation" (Losasso et al. 2008)

Currently the target pressure is specified directly, but it will be
a lot more convenient to define this in terms of a geometric value such
as "number of hairs per area" (combined with hair "thickness").

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:07 +01:00
Lukas Tönne bf96400558 Use a fixed, uniform cell size for hair continuum grids.
This is a bit more awkward for artists to use, but necessary for
a stable solution of the hair continuum calculation. The grid size is
defined by the user, the extent of the grid is then calculated based on
the hair geometry. A hard upper limit prevents bad memory allocation
in case too small values are entered.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne 8dbb6f0d5d Removed unused voxel_filter_size DNA property.
This is an artifact of earlier attempts to implement velocity smoothing,
but doesn't work anyway.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne 48e67c49a5 Added separate damping for bending springs.
The bend damping factor was hardcoded to the same value as the stiffness.
Now it has its own factor in the settings and button in hair dynamics.
2015-01-20 09:30:03 +01:00
Lukas Tönne 226beb9866 Added basic filtering feature for velocity smoothing.
This is part of the original method from "Volumetric Methods for
Simulation and Rendering of Hair". The current filter is a simple box
filter. Other energy-preserving filters such as gaussian filtering
can be implemented later.

The filter size is currently given as a cell count. This is not ideal,
rather it should use a geometrical length value, but this is too
abstract for proper artistical use. Eventually defining the whole grid
in terms of spatial size might work better (possibly using an external
object).
2015-01-20 09:30:01 +01:00
Lukas Tönne bbae8f88b8 Made the voxel grid size for hair interaction configurable and increased
the default to 32.

Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2015-01-20 09:30:01 +01:00
Lukas Tönne 1ed88bb24e Partial response force for hair collisions.
This implements a penalty force as well as a repulsion force to avoid
further penetration, as suggested in
"Simulating Complex Hair with Robust Collision Handling"
(http://graphics.snu.ac.kr/publications/2005-choe-HairSim/Choe_2005_SCA.pdf)

Friction forces are still missing. More problematic is handling of
moving colliders, when face swap places with the hair vertex and a
collision is missed, putting the vertex inside the mesh volume. Larger
margins might help, but ultimately using Bullet collision detection is
probably more reliable and failsafe.
2015-01-20 09:29:56 +01:00
Lukas Tönne ba8b8ec998 Implemented internal hair pressure to prevent hair from collapsing in
on itself.

This uses the same voxel structure as the hair smoothing algorithm.
A slightly different method was suggested in the original paper
(Volumetric Methods for Simulation and Rendering of Hair), but this is
based on directing hair based on a target density, which is another
way of implementing global goals. Our own approach is to define a
pressure threshold above which the hair is repelled in the density
gradient direction to simulate internal pressure from collisions.
2015-01-20 09:29:21 +01:00
Daniel Genrich 28936a4150 Patch T31269: Add sewing seams to cloth simulation
Description:
--------------------------
Use loose edges marked as seams as sewing springs.

Usage:
-------------------------
All this patch does is set the rest length to 0 and the stiffness to 1 for springs for loose edges marked as seams so that during the cloth simulation they will be brought together.

Example Video:
-------------------------
http://www.youtube.com/watch?v=-Y_bC0gjoM0

Original Patch by thesleepless (+ git patch by codemanx)

Thank you!
2014-02-06 18:55:08 +01:00
Campbell Barton f3ece5a108 style cleanup: trailing tabs & expand some non prefix tabs into spaces. 2012-10-21 05:46:41 +00:00
Campbell Barton d5032657ed style cleanup 2012-06-06 22:38:39 +00:00
Daniel Genrich 0499200e39 Cloth: Add support for "Self Collision Vertex Group".
Self collision vertex groups enable artists to exclude selected vertices from getting involved in self collisions. This speeds simulations and it also resolves some self collision issues.
2012-06-06 13:30:05 +00:00
Campbell Barton 89a963fb7f style cleanup: comment blocks 2012-03-09 18:28:30 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Daniel Genrich 37e1285042 Cloth: Add "velocity damping" to damping options. This will help with the "cloth wobbling" problem which accurs quite often when having animated characters with cloth. 2012-01-23 01:35:14 +00:00
Campbell Barton ca629d5ccc minor dna header cleanup 2011-12-30 07:25:49 +00:00
Campbell Barton 4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Campbell Barton 274b9c8fb8 whitespace cleanup 2011-09-25 12:31:21 +00:00
Joseph Eagar 088899236b =trunk=
Recommitted eltopo collision code (but disabled by default)
with Genscher's permission.

To use, you need to install liblapack and libblas
2011-05-01 21:39:13 +00:00
Nathan Letwory 22dbae84e5 DNA header files are now grouped under the same module. No further documentation done. 2011-02-17 20:48:12 +00:00
Brecht Van Lommel 052cb2afd2 Rest shape key for cloth option, this makes it possible
to specify different spring lengths.

Implementation is quite ugly because the shape key has to be pulled
through the modifier stack somehow, need a more flexible data mask
system to solve this properly.

(commits 27773,27775,27778 by Brecht from render25 branch)
2010-03-30 11:49:07 +00:00
Brecht Van Lommel 666cca69e9 Cloth simulation can now use a group to specify which objects
to collide with, in addition to the effectors group.
(commit 27746 by Brecht from render25 branch)
2010-03-26 10:52:55 +00:00
Campbell Barton 1e9bf0cfdb spaces -> tabs, (4 spaces == 1 tab, only for white space preceding text) 2010-03-22 09:30:00 +00:00
Janne Karhu cf4ba30f79 Few small hair dynamics goodies:
* Effectors now work with hair dynamics.
* Hair dynamics has a new "Collider Friction" parameter that works similarly to internal friction except now all collision objects effect the hair velocity. Useful for quick'n'dirty interaction with objects as the calculations are really fast, but doesn't really take away the need for proper hair-object collisions.
2010-02-26 03:24:21 +00:00
Brecht Van Lommel d0d47c70a9 Avoid a DNA parsing bug that would parse "float gravity [3];" as two
struct members "gravity" and "[3]". Now it throws an error in this case,
safer than trying to fix the parsing code. Also patches the old DNA of
ClothSimSettings which had this problem .. very ugly code.

Fixes #20330: cloth sim settings getting corrupted when read from 2.49.
2010-02-13 23:18:28 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Daniel Genrich 6a357cabbf Durian request: Cloth
* structural can be set to 0

* pre-roll now available through GUI and works like following:
a) Pre rolled frames are NOT cached
b) reset cache + cloth on pre roll setting change
2009-11-18 13:33:52 +00:00
Janne Karhu bff893a420 Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons) 
  instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group 
  setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
	- "Point" is most like the old effectors and uses the 
	  effector location as the effector point.
	- "Plane" uses the closest point on effectors local xy-plane 
	  as the effector point.
	- "Surface" uses the closest point on an effector object's 
	  surface as the effector point.
	- "Every Point" uses every point in a mesh effector object 
	  as an effector point.
	- The falloff is calculated from this point, so for example 
	  with "surface" shape and "use only negative z axis" it's 
	  possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer 
  just spherical.
* New effector parameter "flow", which makes the effector act as 
  surrounding air velocity, so the resulting force is 
  proportional to the velocity difference of the point and "air 
  velocity". For example a wind field with flow=1.0 results in 
  proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random 
  flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force 
  (note. the z-axis is the surface normal in the case of 
  effector shape "surface")
* New "force field" submenu in add menu, which adds an empty 
  with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector 
  system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for 
  particles, softbody & cloth, since their final effect depends on many external 
  factors, like for example the surface area of the effected faces.

Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through 
  DAG_id_flush_update(..).
  
Known issues
* Curve guides don't yet have all ui buttons in place, but they 
  should work none the less.
* Hair dynamics don't yet respect force fields.

Other changes
* Particle emission defaults now to frames 1-200 with life of 50 
  frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to 
  free pidlists after use :).
2009-09-30 22:10:14 +00:00
Janne Karhu e9587a89fa Hair dynamics with cloth simulation
- Hair dynamics have their own panel in particle settings with the settings from cloth panel that apply to hair.
- Basic internal friction force to quickly emulate self collisions and volume preservation. (Still very early code, but gives some idea of what's possible).
- Softbody simulation is no longer used for hair.
	* Old files with sb dynamics should just load the hair without dynamics so new dynamics can be applied.
	* Invasion of particles exceptions in sb code is finally over.
- Collisions with other objects are disabled for now and will be worked out in the future.

Other changes/fixes:
- Particle mode editing flag wasn't saved properly.
- Some old files with edited hair didn't load correctly.
- Disabled delete & specials menu in particle mode for non-hair editing.
- Fixed yet one more cloth & softbody pointcache update issue.
- Disconnect/connect hair now uses only the deformed mesh so it works correctly also for subsurfed emitters.
- Hair editing now updates correctly with a moving emitter.
2009-09-10 22:32:33 +00:00
Brecht Van Lommel 874c29cea8 2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323:HEAD
Notes:
* blenderbuttons and ICON_SNAP_PEEL_OBJECT were not merged.
2009-04-20 15:06:46 +00:00
Brecht Van Lommel 6ec52fc1b5 RNA
* DNA_cloth_types.h, patch by Roelf de Kock. The gravity[3] member
  is not being parsed correct by makesdna.c and will give issues
  even when trying to fix it. Worked around it for now in RNA by
  wrapping it manually, but this should really be fixed in the DNA
  genetics code, added a comment about it in DNA_cloth_types.h.

* Handle vertex groups and uv layers more consistent now. They are
  all exposed as strings now. Reason is that indices don't really
  say much, and a direct pointer is not always possible because for
  example a uv layer in a material can be used for multiple objects
  and so there is no single pointer. In python it is not too hard
  to use either since the strings works as a key for lookups.

  For the user interface we can later think of some method to
  generate popup menus in a way that works for vertex groups,
  uv layers, bones etc.

* This also fixes the XXX's in rna_modifier.c, I think that can be
  marked done.
2009-01-04 19:25:24 +00:00
Daniel Genrich 3a3ff9c9dc Bugfix: 32bit cloth files were loaded bad in 64bit blenders and the way arround. The e.g. GUI-only variable 'mass' was reseted to 0. Problem: makesdna doesn't cry out on compile - I wonder why this differences could happen. Solution: Rearange cloth DNA, resort things, clear up and bug was gone - weird. Problem left: Every file having cloth enabled before this revision is incompatible with this version. If anyone know a better solution, please go ahead 2008-04-27 22:04:47 +00:00
Chris Want 5d0a207ecb Patch from GSR that a) fixes a whole bunch of GPL/BL license
blocks that were previously missed; and b) greatly increase my
ohloh stats!
2008-04-16 22:40:48 +00:00
Brecht Van Lommel 1fe5302cce Point Cache Refactoring
=======================

Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.

Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).

Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.

Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.

Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.

Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
Daniel Genrich 906666a4d8 Cloth enhancement for upcomming cache changes: support different speed using clmd->sim_parms->timescale 2008-04-09 16:38:26 +00:00
Daniel Genrich af8c68ddc4 Cloth structure names update: Sorry about this commit, it will kill all your cloth settings in old files but I had to do it before release because naming convention was really bad in cloth (e.g. using SimulationSettings instead of ClothSimSettings in DNA). Same for some structure in CollisionModifier but with no sideeffects. 2008-03-20 18:28:40 +00:00
Daniel Genrich 905a2d374a Cloth: 1. Bugfix for possible memory leak reported by Kenneth Styrberg (via mailing list), 2. Bugfix for friction again, 3. Preset menu on GUI (thanks to help from nudelZ (#blendercoders), 4. Possibility to disable autoprotect cache, 5. Some cache bugs fixed, 6. Some speedup in generating cloth 2008-02-28 00:01:19 +00:00
Daniel Genrich e82484b0bb Cloth: New: *simple* (OpenMP enabled) Selfcollisions available 2008-02-12 11:04:58 +00:00
Daniel Genrich 7a70e5c0c0 Cloth: 1. Fix for deflection being enabled thourgh softbody interface, 2. Fix for wrong calculated friction, 3. Fix for some header which was accitently blown up by my editor 2008-02-05 14:11:48 +00:00
Daniel Genrich 77685023ca Initial commit of cloth modifier from branch rev 13453 2008-01-29 21:01:12 +00:00