Commit Graph

11497 Commits

Author SHA1 Message Date
Lukas Tönne ace1b5050b Reenabled goal springs and removed the arbitrary structural scaling
factor.
2015-01-20 09:29:59 +01:00
Lukas Tönne c7932e93fa Fixed bending forces for cloth springs. 2015-01-20 09:29:58 +01:00
Lukas Tönne 6d4c704f17 Correctly implemented and verified gravity, drag, structural springs. 2015-01-20 09:29:58 +01:00
Lukas Tönne f336ca5952 Minor fix in debug print, so solver prints can be diff'ed. 2015-01-20 09:29:58 +01:00
Lukas Tönne b241f23b19 A couple of defines to disable various influences on the cloth sim for
debugging.
2015-01-20 09:29:58 +01:00
Lukas Tönne 1819cbd02c Debug printing code for large sparse vectors and matrices, to compare
solver input/output of the old and new methods.
2015-01-20 09:29:58 +01:00
Lukas Tönne 8283122cda Added a new internal header for implicit solver defines.
Should become its own intern wrapper library eventually.
2015-01-20 09:29:58 +01:00
Lukas Tönne 7896827f75 Reenabled air drag force for cloth sim. 2015-01-20 09:29:58 +01:00
Lukas Tönne e0b46b136e Arbitrary scaling factor for the structural spring forces (stretching).
This is not nice at all, but for some reason (possibly time scale) the
old force values are much too high and cause the solver to become
unstable. These will be revisited later anyway, so for now such scaling
should be fine.
2015-01-20 09:29:58 +01:00
Lukas Tönne 8163fca264 Switched to the modified CG method that supports constraints, and
added back structural stretch springs.
2015-01-20 09:29:58 +01:00
Lukas Tönne c6a65ff5b8 Implemented a modifier conjugate gradient algorithm to support stable
constraining.

The algorithm is described in the paper "Large Steps in Cloth Simulation"
(Baraff/Witkin 1998). The same method was (incorrectly) implemented in
the old cloth solver.

It is based on restricting the degrees of freedom (ndof) of vertices
using a block matrix and a vector of target velocity deltas.
See chapter 5 of the paper for details.
2015-01-20 09:29:58 +01:00
Lukas Tönne 722fd30a9f Reimplemented Goal springs for the Eigen CG solver method.
Note that goal springs currently are really bad ... They have a factor
on hairs that "fades" goal influence from the root to the tip. The last
point on the hair is completely free, which makes the goal springs
pretty much useless on their own without supporting bend stiffness.
Can only assume this was added to compensate unphysical behavior of
goal springs when using uniform weight, but it's a poor replacement for
true localized bending forces ...
2015-01-20 09:29:58 +01:00
Lukas Tönne d2c0503f19 To make gravity a true force vector, multiply by the mass. 2015-01-20 09:29:58 +01:00
Lukas Tönne 83137358c0 Alternative new solver for cloth using the Eigen CG solver instead of
a custom built solver.

The old cloth solver is broken unfortunately. Eigen is a designated
linear algebra library and very likely their implementation is a lot
better (can't compare until it's implemented though).

Only basic gravity is active atm, spring forces, external force fields,
damping and volumetric friction have to be added back by converting
the data into the Eigen format.
2015-01-20 09:29:58 +01:00
Lukas Tönne 396f7ea158 Don't try to enforce a velocity change for pinned vertices; their
velocity is defined externally by hair root motion.
2015-01-20 09:29:58 +01:00
Lukas Tönne d1cb8b08bd Use squareroot of the current epsilon error target for CG, since we
square this value anyway.
2015-01-20 09:29:57 +01:00
Lukas Tönne 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
Lukas Tönne 4bfd3c8f0c Fix for collision response, the impulse response was far too small. 2015-01-20 09:29:57 +01:00
Lukas Tönne 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
Lukas Tönne 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
Lukas Tönne 93194eb0e9 Fixed for hair collision detection, old/new positions were swapped. 2015-01-20 09:29:57 +01:00
Lukas Tönne b8a9579954 Removed own debug print. 2015-01-20 09:29:57 +01:00
Lukas Tönne ae162f61e7 Added a comment and use the new CG solver as the "official" version now. 2015-01-20 09:29:57 +01:00
Lukas Tönne 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
Lukas Tönne b38663338e Hair collision: Use the S matrix for enforcing contact constraints.
This is a first test, the contacts are very explosive atm because they
basically pin hair vertices globally on collision, which leads to
stretching of the springs which is then suddenly released in the next
frame.
2015-01-20 09:29:57 +01:00
Lukas Tönne 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
Lukas Tönne 0f45f4a3e2 Cleanup: added some comments to the members of Implicit_Data. 2015-01-20 09:29:57 +01:00
Lukas Tönne c6db1d0858 Cleanup: No point in passing all the implicit solver arguments
individually.
2015-01-20 09:29:56 +01:00
Lukas Tönne e9849bdf17 Cleanup: removed the unused olddV vectors from implicit solver data. 2015-01-20 09:29:56 +01:00
Lukas Tönne ccad968e26 Some more debug elements for hair collisions. 2015-01-20 09:29:56 +01:00
Lukas Tönne 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
Lukas Tönne dbf7840643 Fix bounce/repulse calculation. 2015-01-20 09:29:56 +01:00
Lukas Tönne d43f760892 Hair debugging: use "categories" (strings) for grouping debug elements
and support clearing for categories.
2015-01-20 09:29:56 +01:00
Lukas Tönne 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
Lukas Tönne a580be6399 Use repulsion forces in combination with the one-time penalty forces
in collision.
2015-01-20 09:29:56 +01:00
Lukas Tönne 67fdd5e01a Fix for crash when going into particle edit mode with baked hair
simulation.

Note that this currently generates an extreme amount of points, by
making a edit pathcache curve for each hair in every frame! But at least
doesn't simply crash now.
2015-01-20 09:29:56 +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 d8cf12fe5a Debug drawing for simulations, to aid in visualizing abstract data such
as forces, velocities, contact points etc.

This uses a hash table to store debug elements (dots, lines, vectors at
this point). The hash table allows continuous display of elements that
are generated only in certain time steps, e.g. contact points, while
avoiding massive memory allocation. In any case, this system is really
a development feature, but very helpful in finding issues with the
internal solver data.
2015-01-20 09:29:56 +01:00
Lukas Tönne 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
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
Lukas Tönne 345c7b144d Fixed hair velocity smoothing.
This is an important hair interaction feature that simulates friction
between hairs in an efficient way. The method is based on the paper
"Volumetric Methods for Simulation and Rendering of Hair"
( http://graphics.pixar.com/library/Hair/paper.pdf )

It was partially implemented already, but didn't work in this simplified
version. The same voxel structure can be used for implemeting repelling
forces on hair based on density, which can help a hair system maintain
volume instead of collapsing in on itself.
2015-01-20 09:29:21 +01:00
Lukas Tönne b331a82910 Support for various data properties of the hair grid in the voxel
texture.
2015-01-20 09:29:21 +01:00
Lukas Tönne efc0cd1658 Fixed voxel grid initialization from hair points and colliders by using
the suggested tent function from the original paper.

Plain float->int conversion for the grid location otherwise leads to
skewed data and unnecessary loss of information.
2015-01-20 09:29:21 +01:00
Lukas Tönne 5f41b19463 New voxel texture mode "Hair", for displaying the internal hair volume
structure as a texture.

This is mostly a debugging feature that may be removed again later.
2015-01-20 09:29:21 +01:00
Lukas Tönne 4cd6111159 Code cleanup: Use a variable-sized array for the hair volume velocity
smoothing and collision code, split into multiple functions.
2015-01-20 09:29:21 +01:00
Bastien Montagne 50cbff1851 Fix a crasher in recent own mesh remap code ('island' area... :/ ). 2015-01-19 15:51:21 +01:00
Bastien Montagne 0af11a1742 Make use/computation of lnors consistant.
Issue was, when requesting (building) lnors for a mesh that has
autosmooth disabled, one would expect to simply get vnors as lnors.

Until now, it wasn't the case, which was bad e.g. for normal projections
of loops in recent remap code (projecting along split loop normals
when you would expect projection along vertex normals...).

Also, removed the 'angle' parameter from RNA's `mesh.calc_normals_split`.
This should *always* use mesh settings (both autosmooth and smoothresh),
otherwise once again we'd get inconsistencies in some cases.
Will update fbx and obj addons too.
2015-01-19 15:51:20 +01:00
Campbell Barton 18ae259cc4 Cleanup: unused Global flags. 2015-01-20 01:07:12 +11:00
Campbell Barton 45dfb3b742 Fix for security issue loading blend's
Auto-Execute option could be overridden by opening a startup.blend
2015-01-20 00:58:32 +11:00
Campbell Barton 09c83d6fea Viewport: Add adjustable safe areas, 3d-view & VSE
Also adds safe-area presets.

D325 by Diego Gangl with own edits.
2015-01-19 16:47:57 +11:00