diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_cloth.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 1 | ||||
-rw-r--r-- | source/blender/physics/intern/BPH_mass_spring.cpp | 49 |
5 files changed, 25 insertions, 30 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index beb4f226aea..a7fad85ed42 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -181,7 +181,6 @@ typedef enum { typedef enum { CLOTH_COLLSETTINGS_FLAG_ENABLED = ( 1 << 1 ), /* enables cloth - object collisions */ CLOTH_COLLSETTINGS_FLAG_SELF = ( 1 << 2 ), /* enables selfcollisions */ - CLOTH_COLLSETTINGS_FLAG_POINTS = ( 1 << 3 ), /* enables point collisions (hair) */ } CLOTH_COLLISIONSETTINGS_FLAGS; /* Spring types as defined in the paper.*/ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index cacaea39877..b7ebcfa9b0b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3128,7 +3128,6 @@ static void do_hair_dynamics(ParticleSimulationData *sim) psys->clmd->sim_parms->vel_damping = 1.0f; psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS; psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF; - psys->clmd->coll_parms->flags |= CLOTH_COLLSETTINGS_FLAG_POINTS; } /* count simulated points */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9468593f615..69e0613a2ac 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3949,9 +3949,6 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) if (psys->clmd->sim_parms->presets > 10) psys->clmd->sim_parms->presets = 0; } - if (psys->clmd->coll_parms) { - psys->clmd->coll_parms->flags |= CLOTH_COLLSETTINGS_FLAG_POINTS; - } psys->hair_in_dm = psys->hair_out_dm = NULL; psys->clmd->solver_result = NULL; diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 36444b2642c..029563ad9c3 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -728,7 +728,6 @@ static void rna_Particle_hair_dynamics(Main *bmain, Scene *scene, PointerRNA *pt psys->clmd->sim_parms->goalspring = 0.0f; psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL | CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS; psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF; - psys->clmd->coll_parms->flags |= CLOTH_COLLSETTINGS_FLAG_POINTS; rna_Particle_redo(bmain, scene, ptr); } else diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index 483dfd08abd..1387f633c20 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -51,11 +51,6 @@ extern "C" { #include "BPH_mass_spring.h"
#include "implicit.h"
-/* old collision stuff for cloth, use for continuity
- * until a good replacement is ready
- */
-#define USE_COLLISION_DOUBLE_SOLVE
-
static float I3[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
/* Number of off-diagonal non-zero matrix blocks.
@@ -855,6 +850,9 @@ static void cloth_calc_volume_force(ClothModifierData *clmd) }
#endif
+/* old collision stuff for cloth, use for continuity
+ * until a good replacement is ready
+ */
static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, ListBase *effectors, float frame, float step, float dt)
{
Cloth *cloth = clmd->clothObject;
@@ -977,6 +975,12 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors)
{
+ /* Hair currently is a cloth sim in disguise ...
+ * Collision detection and volumetrics work differently then.
+ * Bad design, TODO
+ */
+ const bool is_hair = (clmd->hairdata != NULL);
+
unsigned int i=0;
float step=0.0f, tf=clmd->sim_parms->timescale;
Cloth *cloth = clmd->clothObject;
@@ -984,10 +988,8 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * unsigned int numverts = cloth->numverts;
float dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
Implicit_Data *id = cloth->implicit;
-#ifndef USE_COLLISION_DOUBLE_SOLVE
ColliderContacts *contacts = NULL;
int totcolliders = 0;
-#endif
BKE_sim_debug_data_clear_category("collision");
@@ -1016,20 +1018,19 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * copy_v3_v3(verts[i].v, verts[i].tv);
}
-#ifndef USE_COLLISION_DOUBLE_SOLVE
- /* determine contact points */
- if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
- if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_POINTS) {
+ if (is_hair) {
+ /* determine contact points */
+ if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
cloth_find_point_contacts(ob, clmd, 0.0f, tf, &contacts, &totcolliders);
}
+
+ /* setup vertex constraints for pinned vertices and contacts */
+ cloth_setup_constraints(clmd, contacts, totcolliders, dt);
+ }
+ else {
+ /* setup vertex constraints for pinned vertices */
+ cloth_setup_constraints(clmd, NULL, 0, dt);
}
-
- /* setup vertex constraints for pinned vertices and contacts */
- cloth_setup_constraints(clmd, contacts, totcolliders, dt);
-#else
- /* setup vertex constraints for pinned vertices */
- cloth_setup_constraints(clmd, NULL, 0, dt);
-#endif
/* initialize forces to zero */
BPH_mass_spring_clear_forces(id);
@@ -1052,13 +1053,15 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * BPH_mass_spring_solve_velocities(id, dt, &result);
cloth_record_result(clmd, &result, clmd->sim_parms->stepsPerFrame);
- cloth_continuum_step(clmd, dt);
+ if (is_hair) {
+ cloth_continuum_step(clmd, dt);
+ }
BPH_mass_spring_solve_positions(id, dt);
-#ifdef USE_COLLISION_DOUBLE_SOLVE
- cloth_collision_solve_extra(ob, clmd, effectors, frame, step, dt);
-#endif
+ if (!is_hair) {
+ cloth_collision_solve_extra(ob, clmd, effectors, frame, step, dt);
+ }
BPH_mass_spring_apply_result(id);
@@ -1075,12 +1078,10 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * BPH_mass_spring_get_motion_state(id, i, verts[i].txold, NULL);
}
-#ifndef USE_COLLISION_DOUBLE_SOLVE
/* free contact points */
if (contacts) {
cloth_free_contacts(contacts, totcolliders);
}
-#endif
step += dt;
}
|