Commit Graph

217 Commits

Author SHA1 Message Date
d05c653ade Better grid rasterization method for hair volumetric grids.
This is based on the paper
"Detail Preserving Continuum Simulation of Straight Hair"
(McAdams, Selle, Ward, 2009)

The main difference is that hair line segments are used rather than only
rasterizing velocity at the vertices. This gives a much better coverage
of the hair volume grid, otherwise gaps can be produced at smaller grid
cell sizes and the distribution is uneven along the hair curve.

The algorithm for rasterizing is a variation of Bresenham's algorithm
extended onto 3D grids.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
4ff68d031d Fix for warnings/errors
Conflicts:
	source/blender/blenkernel/intern/key.c
	source/blender/blenkernel/intern/particle_system.c
	source/blender/makesrna/intern/rna_particle.c
2015-01-20 09:30:05 +01:00
3119d718f8 Moved collision response into the main cloth sim source file and fixed
some coordinate transform issues.

Collision response should be regarded as part of the dynamics system
instead of the basic collision detection.
2015-01-20 09:30:00 +01:00
8ec4c31d9c Disabled collision culling on the inside of the collider faces for now,
this seems to remove too many contact points somehow ...
2015-01-20 09:29:57 +01:00
4bfd3c8f0c Fix for collision response, the impulse response was far too small. 2015-01-20 09:29:57 +01:00
27ecda9995 Use the S matrix of the modifier CG algorithm for implementing collision
responses.

The S matrix together with the z Vector encodes the degrees of freedom
of a colliding hair point and the target velocity change. In a collision
the hair vertex is restricted in the normal direction (when moving
toward the collider) and the collision dynamics define target velocity.
2015-01-20 09:29:57 +01:00
02ab74eb55 Better contact point near-test for hair.
This simply uses the position above the triangle instead of the
intersection point of the vertex path. The other method was broken
anyway, but also has a problem catching all the contacts reliably. The
new method might have a few false positives but that is acceptable.
2015-01-20 09:29:57 +01:00
93194eb0e9 Fixed for hair collision detection, old/new positions were swapped. 2015-01-20 09:29:57 +01:00
c6e5f6afe0 Fixed implementation of the Conjugate Gradient method for the cloth
solver that properly supports constraints with some degrees-of-freedom.

The previous solver implementation only used the S matrix (constraint
filter matrix) for pinning vertices, in which case all elements are
zero and the error doesn't show up. With partial constraints (useful for
collision contacts) the matrix has non-zero off-diagonal elements and
the algorithm easily diverges.

There are also initial steps for implementing collision prevention as
described in the Baraff/Witkin paper "Large Steps in Cloth Simulation"
(http://www.cs.cmu.edu/~baraff/papers/sig98.pdf).
2015-01-20 09:29:57 +01:00
fc083b4e5b Preparation for collision code fixing.
Instead of handling contact tests and collision response in the same
function in collision.c, first generate contact points and return them
as a list, then free at the end of the stepping function. This way the
contact response can be integrated into the conjugate gradient method
properly instead of using the hackish and unstable double evaluation
that is currently used.
2015-01-20 09:29:57 +01:00
ccad968e26 Some more debug elements for hair collisions. 2015-01-20 09:29:56 +01:00
f98d388fd3 Extended line/face collision near-check, to allow for distance margins.
The original BLI method for line/triangle intersection returns false
in case the line does not actually intersect, but in order to generate
repulsion forces we need to also handle contacts inside the margin.
2015-01-20 09:29:56 +01:00
dbf7840643 Fix bounce/repulse calculation. 2015-01-20 09:29:56 +01:00
d43f760892 Hair debugging: use "categories" (strings) for grouping debug elements
and support clearing for categories.
2015-01-20 09:29:56 +01:00
70df8f8dd6 Fix for hair collision detection: need to use the second point of the
timestep segment.

This ensures the distance for a collision pair is the one of the current
point position, and the response gets calculated accordingly.
2015-01-20 09:29:56 +01:00
a580be6399 Use repulsion forces in combination with the one-time penalty forces
in collision.
2015-01-20 09:29:56 +01:00
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
5a43e8493e Some initial collision code, without actual response forces still.
This is still using the old BVH tree collision methods to generate
contact points, similar to what cloth does. This should be replaced
by a Bullet collision check, but generating contacts in this way is
easier for now, and lets us test responses and stability (although in
more complex collision cases the BVH method fails utterly, beside being
terribly inefficient with many colliders).
2015-01-20 09:29:21 +01:00
9c15439c5c cloth: Fix overallocation for collisions
This was introduced when eltopo was added, but not reverted when it was
removed.
2014-11-11 18:05:00 +01:00
e7f495d8a0 Cleanup: bool 2014-09-24 14:55:01 +10:00
4ca67869cc Code cleanup: remove unused includes
Opted to keep includes if they are used indirectly (even if removing is possible).
2014-05-01 04:47:51 +10:00
2bba04f1b0 Cloth: replace EdgeHash with EdgeSet 2014-04-04 14:15:57 +11:00
5621e63d36 Code cleanup: duplicate headers 2014-02-14 10:55:38 +11:00
9467d99405 replace sqrt(dot()) with length functions. 2013-09-03 22:32:03 +00:00
585272fbcf cloth was using edgehash not quite correctly:
- was ordering vertex args unnecessarily.
- was adding the same edges multiple times into the edgehash.
2013-08-24 16:06:18 +00:00
7fac200080 remove unused define CLAMPTEST, move INPR to
collision_compute_barycentric(), only place its used.
2013-05-08 12:56:02 +00:00
93ac968db3 code cleanup: include order 2013-04-05 17:56:54 +00:00
c36f20a7d2 style cleanup 2013-03-08 04:00:06 +00:00
f2bb536994 code cleanup: also change BKE_blender.h BLENDER_VERSION_CHAR to 'a' so as not to confuse things. 2013-03-05 14:47:49 +00:00
69ddc5eb99 make bullet optional again 2013-01-23 07:26:39 +00:00
857df8065f style cleanup 2012-12-28 14:19:05 +00:00
b5ce1b1a23 Fix for cloth/smoke: Collision and flow objects always had to be on the same layer.
Reported and patch by MiikaH
2012-12-11 20:39:54 +00:00
1b32f258e7 ifdef'd gcc diagnostic pragma's to quiet msvc and others. 2012-11-23 10:03:50 +00:00
fae6c35ca7 code cleanup: quiet -Wdouble-promotion, disabled this warnings for a few files since its done throughout the code in some places. 2012-11-04 07:18:29 +00:00
9fc95bd7ee use min/max inline functions where MIN2/MAX2 were doing type conversion. 2012-10-27 11:18:54 +00:00
f70d2c65d8 rename api functions...
- minf, maxf, mini, maxi --> min_ff, max_ff, min_ii, max_ii
2012-10-23 13:28:22 +00:00
f3ece5a108 style cleanup: trailing tabs & expand some non prefix tabs into spaces. 2012-10-21 05:46:41 +00:00
7e620f04a1 Fix #32920: cloth physics with collision exploding in some cases, due to
uninitialized memory usage.
2012-10-19 16:44:08 +00:00
25c96bc9f3 code cleanup: remove unused macros, commet some which may be useful later - or good to keep for completeness. quieted some warnings and add flags -Wmissing-include-dirs and -Wno-div-by-zero to cmake/gcc 2012-09-20 01:02:39 +00:00
9b51503307 style cleanup 2012-07-21 22:58:08 +00:00
84bf3e48c0 style cleanup: use c style comments in C code 2012-07-06 23:56:59 +00:00
3a0593cc3d code cleanup: dont use function calls like dot_v3v3, pow and sqrt within macros which results in calling the function multiple times needlessly.
also added some comments.
2012-07-06 22:48:28 +00:00
32478997ec style cleanup 2012-06-27 18:29:47 +00:00
74c9c24d27 style cleanyp 2012-06-23 23:22:19 +00:00
f5f25b81e8 style cleanup:
also fix for building ghost test and fix double free in one of the tests
2012-06-17 09:58:26 +00:00
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
f69cec4596 Compile fix - "spf" was undefined 2012-06-02 22:47:33 +00:00
76af5fb50d Cloth collisions: Revert 47335. 2012-06-02 22:01:04 +00:00
4fa34b5cf7 Commenting out unused var, prevents my debug Blender to build... ;) 2012-06-01 17:47:05 +00:00
9efc294d45 Followup fix Bugfix [#31629]: Cloth simulation collisions used still too high repulsions. 2012-06-01 16:50:12 +00:00