Commit Graph

57443 Commits

Author SHA1 Message Date
Lukas Tönne
46db288832 Minor debug code fix.
Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +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
e3dcbc3679 Renamed HairVertexGrid to HairGrid, since it's not actually storing
hair vertex data.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne
dddf088375 Removed unused "collider grid" struct from hair volumetrics.
This is a leftover from previous approach of hair collisions (with
insufficient results). The hair volumetrics actually implements
"collision" with solid objects as well, but uses a Neumann boundary
condition on the main grid for this purpose.
2015-01-20 09:30:06 +01:00
Lukas Tönne
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
Lukas Tönne
c37de38716 New debug element "circle" for simulations, which is quite useful for
visualizing scalar fields.
2015-01-20 09:30:06 +01:00
Lukas Tönne
7dda1ea396 Debug grid drawing for hair volume was drawing one subdivision too many. 2015-01-20 09:30:06 +01:00
Lukas Tönne
211be0ae6e Unused leftover debug variable. 2015-01-20 09:30:06 +01:00
Lukas Tönne
d42525a9b5 Reimplemented the voxel texture type for displaying hair continuum grids.
Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:05 +01:00
Lukas Tönne
cd717f145d Expose hair grid info in the RNA (read-only); it can be useful for
debugging purposes.
2015-01-20 09:30:05 +01:00
Lukas Tönne
9d27b53d41 Debug visualization code of a slice of the hair velocity vector field. 2015-01-20 09:30:05 +01:00
Lukas Tönne
9be290c92e Removed arbitrary factor 2.0 on volumetric hair friction factor.
This was introducing energy into the system for any factor beyond 0.5
and caused major instability.
2015-01-20 09:30:05 +01:00
Lukas Tönne
54c69c4ed8 Fill the hair volume grid with the _new_ velocities from the first
solver step, instead of using the previous step's velocities.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:05 +01:00
Lukas Tönne
c3968861b3 Debug drawing feature to visualize the hair continuum grid. 2015-01-20 09:30:05 +01:00
Lukas Tönne
aea309779f Perform grid-based velocity smoothing for hair outside of the implicit
solver step.

Calculating forces and jacobians from linearly interpolated grid values
is problematic due to discontinuities at the grid boundaries. The new
approach of modifying velocities after the backward euler solver step
was suggested in a newer paper

"Detail Preserving Continuum Simulation of Straight Hair"
(McAdams, Selle 2009)

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:05 +01:00
Lukas Tönne
4381fa3157 Minor fix for lost variable declaration during cherry-picking. 2015-01-20 09:30:05 +01:00
Lukas Tönne
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
Lukas Tönne
a351e8b6ef Reorganizing hair dynamics UI layout a bit to make settings slightly
more intuitive.

Also removed a couple of unused or useless features from the UI:
* collider friction is unused and replaced in favor of true collision
* spring damping refers to structural springs (stretch), which is
  not noticable in hair due to extreme stiffness atm.
* pressure factors are not sure since this feature is too unstable atm.

Conflicts:
	release/scripts/startup/bl_ui/properties_particle.py
2015-01-20 09:30:05 +01:00
Lukas Tönne
edc9baaae4 Moved render simplification function for particle distribution into the
distribution code.
2015-01-20 09:30:05 +01:00
Lukas Tönne
34762de38f Removed unused variable. 2015-01-20 09:30:05 +01:00
Lukas Tönne
09f171c525 A little bit of code sanity by splitting particle distribution function
by type.

Instead of squashing totally unrelated code into the same monster
function.
2015-01-20 09:30:04 +01:00
Lukas Tönne
0f43ba8235 Moved particle code for distributions into own file to make hacking
easier.

This code is badly broken and needs to be replaced, but at least having
a workable code structure might help with quick hacks to fix the worst
cases.
2015-01-20 09:30:04 +01:00
Lukas Tönne
f03fc27bf7 Removed unused line. 2015-01-20 09:30:04 +01:00
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