Commit Graph

57419 Commits

Author SHA1 Message Date
Lukas Tönne
c01ed4875b New hair editing feature "Shape Cut", for cutting hair based on a mesh
shape instead of a brush tool.

The brush cutting tool for hair, while useful, is not very accurate and
often requires rotating the model constantly to get the right trimming
on every side. This makes adjustments to a hair shape a very tedious
process.

On the other hand, making proxy meshes for hair shapes is a common
workflow. The new operator allows using such rough meshes as boundaries
for hair. All hairs that are outside the shape mesh are removed, while
those cutting it at some length are shortened accordingly.

The operator can be accessed in the particle edit mode toolbar via the
"Shape Cut" button. The "Shape Object" must be set first and stays
selected as a tool setting for repeatedly applying the shape.
2015-01-20 09:30:04 +01:00
Lukas Tönne
117f4bbe66 Switched back to blender implicit solver for merge. 2015-01-20 09:30:04 +01:00
Lukas Tönne
4cdf0ab5cf Unified the main Eigen solver function a bit for constrained/unconstrained
solver variants.
2015-01-20 09:30:04 +01:00
Lukas Tönne
2356264ca9 Ported the remaining implicit solver functions for Eigen.
Also added a couple of utility wrapper functions for Eigen types to make
interfacing with plain float arrays and blenlib math easier.
2015-01-20 09:30:04 +01:00
Lukas Tönne
4eac83da66 Updating Eigen implicit dynamics solver implementation to adhere to the
new mass-spring solver API.

Conflicts:
	source/blender/physics/intern/implicit_eigen.cpp
2015-01-20 09:30:04 +01:00
Lukas Tönne
35d09c7ab6 Fix for inverted condition: hair data needs to be rebuilt when the
cloth DM does not exist.
2015-01-20 09:30:04 +01:00
Lukas Tönne
4a16242e60 Cleanup: Removed the unnecessary cloth solver abstraction (there is only
one solver anyway), and split some particle cloth functions for clarity.

Conflicts:
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/particle_system.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/makesdna/DNA_particle_types.h
	source/blender/makesrna/intern/rna_particle.c
2015-01-20 09:30:04 +01:00
Lukas Tönne
0b0acb6124 enum instead of #define for cloth vertex flags. 2015-01-20 09:30:04 +01:00
Lukas Tönne
ce53303f61 Removed accidentally committed debug print. 2015-01-20 09:30:04 +01:00
Lukas Tönne
fe8fad54b1 Use the generic task scheduler for threaded particle tasks, i.e.
distribution and path caching for child particles.

This gives a significant improvement of viewport playback performance
with higher child particle counts. Particles previously used their own
threads and had a rather high limit for threading. Also threading
apparently was disabled because only 1 thread was being used ...
2015-01-20 09:30:03 +01:00
Lukas Tönne
c1f4542f0f Removed block matrix indices storage from ClothSpring struct.
This is not necessary: the implicit solver data can keep track instead
of how many off-diagonal matrix blocks are in use (provided the
allocation limit is calculated correctly). Every time a spring is
created it then simply increments this counter and uses the block index
locally - no need to store this persistently.
2015-01-20 09:30:03 +01:00
Lukas Tönne
a5f207de79 Removed unused force arguments for angular bending springs and avoid
redundant calculation for counterforces.
2015-01-20 09:30:03 +01:00
Lukas Tönne
173bdfe05e Guide hair drawing for hair particles.
Without this the particle system only shows the actual non-simulated
hairs ("guide hairs") during edit mode. These hairs are used for goals
as well, so showing them in the regular viewport is pretty important.

Also the usual hair curves are interpolated along the entire length,
which makes it very difficult to see exact vertex positions, unless
using exact powers of 2 for the segment number and match the display
steps.

Conflicts:
	source/blender/blenkernel/intern/particle.c
2015-01-20 09:30:03 +01:00
Lukas Tönne
acf4506299 Improved child hair curling for interpolated child particles.
The curl radius for children in interpolated mode was calculated using
the total offset from the parent particle. This leads to very large
radii when the distance is large due to sparse parents. Such behavior is
also very unrealistic because the curl radius is mostly constant and
defined by the material properties.

All the child hairs are roughly parallel by default. To simulate the
agglomeration of children into hair wisps the "flatness" parameter is
now used to clump them together.
2015-01-20 09:30:03 +01:00
Lukas Tönne
64b9ba06a7 Cloth solver data for edit mode is unused, removed it. 2015-01-20 09:30:03 +01:00
Lukas Tönne
6097de2db9 Fix for scons files missing physics include folder. 2015-01-20 09:30:03 +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
e694b7c04b Set the length threshold for hair simulation to 10% again (from 1%).
With the default 5 substeps the simulation can otherwise still become
unstable. This is just a preliminary measure anyway until the length
variance can be fixed properly.
2015-01-20 09:30:03 +01:00
Lukas Tönne
43424a639b Fix for outdated root array size when changing the particle amount
during simulation.
2015-01-20 09:30:03 +01:00
Lukas Tönne
d613c38171 Fix for hair chain testing in the cloth modifier.
Bending springs are en-bloc and not interleaved with other springs, so
this can't be used as a test for hair roots. Use consecutive indices
instead.
2015-01-20 09:30:03 +01:00
Lukas Tönne
577150c635 Completed the implementation of bent rest shapes for hair.
Basically follows the Pixar approach from "Artistic Simulation of Curly
Hair".
2015-01-20 09:30:03 +01:00
Lukas Tönne
520922876a Target calculation for local non-straight rest shapes.
This is more involved than using simple straight bending targets
constructed from the neighboring segments, but necessary for restoring
groomed rest shapes.

The targets are defined by parallel-transporting a coordinate frame
along the hair, which smoothly rotates to avoid sudden twisting (Frenet
frame problem). The rest positions of hair vertices defines the target
vectors relative to the frame. In the deformed motion state the frame
is then recalculated and the targets constructed in world/root space.
2015-01-20 09:30:03 +01:00
Lukas Tönne
7d4799b41d Have to include BLI_utildefines before BKE_collision now to have bool
defined.
2015-01-20 09:30:02 +01:00
Lukas Tönne
6394189e68 Clear forces and constraints together at the start of the time step,
easier to verify.
2015-01-20 09:30:02 +01:00
Lukas Tönne
e44187cd5f Fix for missing initialization of local cloth modifier inside particle
systems.
2015-01-20 09:30:02 +01:00
Lukas Tönne
c036c72284 Proper implementation of angular bending springs including jacobian
derivatives for stabilization.

The bending forces are based on a simplified torsion model where each
neighboring point of a vertex creates a force toward a local goal. This
can be extended later by defining the goals in a local curve frame, so
that natural hair shapes other than perfectly straight hair are
supported.

Calculating the jacobians for the bending forces analytically proved
quite difficult and doesn't work yet, so the fallback method for now
is a straightforward finite difference method. This works very well and
is not too costly. Even the original paper ("Artistic Simulation of
Curly Hair") suggests this approach.
2015-01-20 09:30:02 +01:00
Lukas Tönne
3a8ef0ef6c Unused function declaration. 2015-01-20 09:30:02 +01:00
Lukas Tönne
491e7493c7 Basic solver result feedback from the mass-spring (cloth/hair) solver.
This returns a general status (success/no-convergence/other) along with
basic statistics (min/max/average) for the error value and the number
of iterations. It allows some general estimation of the simulation
quality and detection of critical settings that could become a problem.
Better visualization and extended feedback can follow later.
2015-01-20 09:30:02 +01:00
Lukas Tönne
00bb836e17 Calculate bending targets based on the direction of previous segments.
This makes the bending a truely local effect. Eventually target
directions should be based in a local coordinate frame that gets
parallel transported along the curve. This will allow non-straight
rest shapes for hairs as well as supporting twist forces. However,
calculating locally transformed spring forces is more complicated.
2015-01-20 09:30:02 +01:00
Lukas Tönne
e5ae13b809 Simple debug drawing support inside the implicit solver. 2015-01-20 09:30:02 +01:00
Lukas Tönne
14bd99b0f3 Added a damping term for angular bending springs. 2015-01-20 09:30:02 +01:00
Lukas Tönne
7a7778d003 Simple initial implementation of angular bending springs.
These are much better suited for creating stiff hair. The previous
bending springs are based on "push" type spring along the hypothenuse
of 3 hair vertices. This sort of spring requires a very large force
in the direction of the spring for any angular effect, and is still
unstable in the equilibrium.

The new bending spring model is based on "target" vectors defined in a
local hair frame, which generates a force perpendicular to the hair
segment. For further details see
"Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a)
or
"A Mass Spring Model for Hair Simulation" (Selle, Lentine, Fedkiw 2008)

Currently the implementation uses a single root frame that is not yet
propagated along the hair, so the resulting rest shape is not very
natural. Also damping and derivatives are still missing.
2015-01-20 09:30:02 +01:00
Lukas Tönne
86a4da1c54 Replace the dynamic root transform in the implicit solver data with a
single transform matrix.

Dynamic properties of the transformation are only needed during the
setup phase when they should be read from external data (hair system
roots) and generate fictitious forces on each point.
2015-01-20 09:30:02 +01:00
Lukas Tönne
fa1c2ba7c6 More scons fixes for physics lib. 2015-01-20 09:30:02 +01:00
Lukas Tönne
09ad433179 Fixed scons build files for new physics subfolder. 2015-01-20 09:30:02 +01:00
Lukas Tönne
f03d253f55 Disabled the velocity filtering feature for now, since the weighting is
incorrect.

The voxel grid needs better tool support to make it usable, so fixing
the filtering is not high priority right now.
2015-01-20 09:30:02 +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
be016daf15 Reduced the length threshold for disabling short hairs from 0.1 to 0.01. 2015-01-20 09:30:01 +01:00
Lukas Tönne
0ddea77b1a Fix for rB71271bb, was replacing the force vectors entirely instead of
adding.
2015-01-20 09:30:01 +01:00
Lukas Tönne
59d76a406e Fix for effector force fields on hair, using the world-to-root
transformation.
2015-01-20 09:30:01 +01:00
Lukas Tönne
d43170d09d Add weak repulsion forces to hair collision response to keep the hair
at a the margin distance ("outer" softbody margin).

This has to be clamped arbitrarily unfortunately, otherwise the
repulsion force can add too much energy into the system. A factor of
4 * restitution impulse seems to give good results for now, this can
be refined later on if necessary.
2015-01-20 09:30:01 +01:00
Lukas Tönne
8876429edd Added back the velocity smoothing implementation.
This is now also decoupled from the internal solver data. The grid is
created as an opaque structure, filled with vertex or collider data
(todo), and then forces can be calculated by interpolating the grid at
random locations. These forces and derivatives are then fed into the
solver.
2015-01-20 09:30:01 +01:00
Lukas Tönne
a8cf092160 Fix for Sintel hair bug.
The hair solver needs sane input to converge within reasonable time
steps. In particular the spring lengths must not be too difference
(factor 0.01..100 or so max, this is comparable to rigid body simulation
of vastly different masses, which is also unstable).

The basic hair system generate strands with equally spaced points, which
is good solver material. However, the hair edit operators, specifically
the cutting tool, can move points along the strands, creating tightly
packed hair points. This puts the solver under enormous stress and
causes the "explosions" observed already during the Sintel project.

The simple solution for now is to exclude very short hairs from the
simulation. Later the cutting tool should be modified such that it
keeps the segments roughly at the same length and throws away vertices
when the hair gets too short (same goes for the extension tool).

The hair system should have a general mechanism for making sure that
situations such as this don't occur. This will have to be a design
consideration for replacements in any future hair system.
2015-01-20 09:30:01 +01:00
Lukas Tönne
6623395638 Minor fix when gravity code is disabled. 2015-01-20 09:30:01 +01:00
Lukas Tönne
58e33ab279 Removed unused code.
Conflicts:
	source/blender/physics/intern/implicit_blender.c
2015-01-20 09:30:01 +01:00
Lukas Tönne
d0379f82d1 Added a calculation function for the fictitious forces introduced by
moving hair root reference frames.

This calculates Euler, Coriolis and Centrifugal forces which result
from describing hair in a moving reference frame.
http://en.wikipedia.org/wiki/Fictitious_force
2015-01-20 09:30:01 +01:00
Lukas Tönne
a49b170b27 Fix for own misconception of fictitious forces in the moving hair root
frames.

These forces don't have to be calculated for each individual
contribution. Rather they can be split off and be calculated on top of
the basic force vector rotation (todo).
2015-01-20 09:30:01 +01:00
Lukas Tönne
02c8bf99c9 Added back spring force definitions outside the implicit solver.
There are currently 3 types of springs: basic linear springs, goal
springs toward a fixed global target (not recommended, but works) and
bending springs.

These are agnostic to the specific spring definition in the cloth system
so hair systems can use the same API without converting everything to
cloth first.

Conflicts:
	source/blender/physics/intern/implicit_blender.c
2015-01-20 09:30:01 +01:00
Lukas Tönne
dd0a7444d8 Main cloth force calculation function outside of implicit core code.
Still misses spring forces.
2015-01-20 09:30:00 +01:00