Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-06-18 12:34:24 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-06-22 16:12:03 +0300
commitfffe34531d0ed4b858afcabe4ab38b1b9698ed70 (patch)
tree5ef9cb2189d339cb1522b0e9ebebc17ec354beb0
parentc2fa82e7a417ad98d0dd2ccd7aa084cb03ed11a1 (diff)
Cloth: Move away from scene stored in cloth modifier data
-rw-r--r--source/blender/blenkernel/BKE_cloth.h6
-rw-r--r--source/blender/blenkernel/intern/cloth.c9
-rw-r--r--source/blender/blenkernel/intern/collision.c12
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h1
-rw-r--r--source/blender/physics/BPH_mass_spring.h3
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp25
6 files changed, 29 insertions, 27 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index f0d8e1a1d84..154875e5745 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -210,10 +210,10 @@ typedef struct ColliderContacts {
} ColliderContacts;
// needed for implicit.c
-int cloth_bvh_objcollision (struct Object *ob, struct ClothModifierData *clmd, float step, float dt );
-int cloth_points_objcollision(struct Object *ob, struct ClothModifierData *clmd, float step, float dt);
+int cloth_bvh_objcollision (struct Scene *scene, struct Object *ob, struct ClothModifierData *clmd, float step, float dt );
+int cloth_points_objcollision(struct Scene *scene, struct Object *ob, struct ClothModifierData *clmd, float step, float dt);
-void cloth_find_point_contacts(struct Object *ob, struct ClothModifierData *clmd, float step, float dt,
+void cloth_find_point_contacts(struct Scene *scene, struct Object *ob, struct ClothModifierData *clmd, float step, float dt,
ColliderContacts **r_collider_contacts, int *r_totcolliders);
void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index c5d9472ca4b..f8ea7e8b1d1 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -350,7 +350,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int
return 1;
}
-static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr)
+static int do_step_cloth(struct Depsgraph *depsgraph, Scene *scene, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr)
{
ClothVertex *verts = NULL;
Cloth *cloth;
@@ -375,7 +375,7 @@ static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierD
mul_m4_v3(ob->obmat, verts->xconst);
}
- effectors = pdInitEffectors(depsgraph, clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
+ effectors = pdInitEffectors(depsgraph, scene, ob, NULL, clmd->sim_parms->effector_weights, true);
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH )
cloth_update_verts ( ob, clmd, result );
@@ -391,7 +391,7 @@ static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierD
// TIMEIT_START(cloth_step)
/* call the solver. */
- ret = BPH_cloth_solve(ob, framenr, clmd, effectors);
+ ret = BPH_cloth_solve(scene, ob, framenr, clmd, effectors);
// TIMEIT_END(cloth_step)
@@ -413,7 +413,6 @@ void clothModifier_do(ClothModifierData *clmd, struct Depsgraph *depsgraph, Scen
int framenr, startframe, endframe;
int cache_result;
- clmd->scene= scene; /* nice to pass on later :) */
framenr = DEG_get_ctime(depsgraph);
cache= clmd->point_cache;
@@ -493,7 +492,7 @@ void clothModifier_do(ClothModifierData *clmd, struct Depsgraph *depsgraph, Scen
/* do simulation */
BKE_ptcache_validate(cache, framenr);
- if (!do_step_cloth(depsgraph, ob, clmd, mesh, framenr)) {
+ if (!do_step_cloth(depsgraph, scene, ob, clmd, mesh, framenr)) {
BKE_ptcache_invalidate(cache);
}
else
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 38cb1a1de16..b41c4633ccb 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -686,7 +686,7 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
}
// cloth - object collisions
-int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, float dt )
+int cloth_bvh_objcollision(Scene *scene, Object *ob, ClothModifierData *clmd, float step, float dt )
{
Cloth *cloth= clmd->clothObject;
BVHTree *cloth_bvh= cloth->bvhtree;
@@ -712,7 +712,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function)
bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function)
- collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
+ collobjs = get_collisionobjects(scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
if (!collobjs)
return 0;
@@ -1207,7 +1207,7 @@ static int cloth_points_objcollisions_resolve(
}
// cloth - object collisions
-int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, float dt)
+int cloth_points_objcollision(Scene *scene, Object *ob, ClothModifierData *clmd, float step, float dt)
{
Cloth *cloth= clmd->clothObject;
BVHTree *cloth_bvh;
@@ -1240,7 +1240,7 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f
/* balance tree */
BLI_bvhtree_balance(cloth_bvh);
- collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
+ collobjs = get_collisionobjects(scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
if (!collobjs)
return 0;
@@ -1329,7 +1329,7 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f
return 1|MIN2 ( ret, 1 );
}
-void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step, float dt,
+void cloth_find_point_contacts(Scene *scene, Object *ob, ClothModifierData *clmd, float step, float dt,
ColliderContacts **r_collider_contacts, int *r_totcolliders)
{
Cloth *cloth= clmd->clothObject;
@@ -1363,7 +1363,7 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step,
/* balance tree */
BLI_bvhtree_balance(cloth_bvh);
- collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
+ collobjs = get_collisionobjects(scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
if (!collobjs) {
*r_collider_contacts = NULL;
*r_totcolliders = 0;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index d9792faf0cb..eb7fc3f4bf5 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -607,7 +607,6 @@ typedef struct SoftbodyModifierData {
typedef struct ClothModifierData {
ModifierData modifier;
- struct Scene *scene; /* the context is here */
struct Cloth *clothObject; /* The internal data structure for cloth. */
struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */
struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */
diff --git a/source/blender/physics/BPH_mass_spring.h b/source/blender/physics/BPH_mass_spring.h
index e89aec1456e..fd648222174 100644
--- a/source/blender/physics/BPH_mass_spring.h
+++ b/source/blender/physics/BPH_mass_spring.h
@@ -40,6 +40,7 @@ struct Implicit_Data;
struct Object;
struct ClothModifierData;
struct ListBase;
+struct Scene;
struct VoxelData;
typedef enum eMassSpringSolverStatus {
@@ -55,7 +56,7 @@ int BPH_mass_spring_solver_numvert(struct Implicit_Data *id);
int BPH_cloth_solver_init(struct Object *ob, struct ClothModifierData *clmd);
void BPH_cloth_solver_free(struct ClothModifierData *clmd);
-int BPH_cloth_solve(struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors);
+int BPH_cloth_solve(struct Scene *scene, struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors);
void BKE_cloth_solver_set_positions(struct ClothModifierData *clmd);
#ifdef __cplusplus
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index c8932045c52..738673b0b37 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -433,7 +433,7 @@ static void hair_get_boundbox(ClothModifierData *clmd, float gmin[3], float gmax
}
}
-static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListBase *effectors, float time)
+static void cloth_calc_force(Scene *scene, ClothModifierData *clmd, float UNUSED(frame), ListBase *effectors, float time)
{
/* Collect forces and derivatives: F, dFdX, dFdV */
Cloth *cloth = clmd->clothObject;
@@ -447,9 +447,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
#ifdef CLOTH_FORCE_GRAVITY
/* global acceleration (gravitation) */
- if (clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
+ if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
/* scale gravity force */
- mul_v3_v3fl(gravity, clmd->scene->physics_settings.gravity, 0.001f * clmd->sim_parms->effector_weights->global_gravity);
+ mul_v3_v3fl(gravity, scene->physics_settings.gravity, 0.001f * clmd->sim_parms->effector_weights->global_gravity);
}
vert = cloth->verts;
@@ -487,7 +487,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
EffectedPoint epoint;
BPH_mass_spring_get_motion_state(data, i, x, v);
- pd_point_from_loc(clmd->scene, x, v, i, &epoint);
+ pd_point_from_loc(scene, x, v, i, &epoint);
pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
}
@@ -847,7 +847,9 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
/* 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)
+static void cloth_collision_solve_extra(
+ Scene *scene, Object *ob, ClothModifierData *clmd, ListBase *effectors,
+ float frame, float step, float dt)
{
Cloth *cloth = clmd->clothObject;
Implicit_Data *id = cloth->implicit;
@@ -879,7 +881,8 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis
// call collision function
// TODO: check if "step" or "step+dt" is correct - dg
- do_extra_solve = cloth_bvh_objcollision(ob, clmd, step / clmd->sim_parms->timescale, dt / clmd->sim_parms->timescale);
+ do_extra_solve = cloth_bvh_objcollision(
+ scene, ob, clmd, step / clmd->sim_parms->timescale, dt / clmd->sim_parms->timescale);
// copy corrected positions back to simulation
for (i = 0; i < mvert_num; i++) {
@@ -915,7 +918,7 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis
BPH_mass_spring_clear_forces(id);
// calculate forces
- cloth_calc_force(clmd, frame, effectors, step);
+ cloth_calc_force(scene, clmd, frame, effectors, step);
// calculate new velocity and position
BPH_mass_spring_solve_velocities(id, dt, &result);
@@ -967,7 +970,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
sres->status |= result->status;
}
-int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors)
+int BPH_cloth_solve(Scene *scene, Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors)
{
/* Hair currently is a cloth sim in disguise ...
* Collision detection and volumetrics work differently then.
@@ -1017,7 +1020,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
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);
+ cloth_find_point_contacts(scene, ob, clmd, 0.0f, tf, &contacts, &totcolliders);
}
/* setup vertex constraints for pinned vertices and contacts */
@@ -1043,7 +1046,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
}
// calculate forces
- cloth_calc_force(clmd, frame, effectors, step);
+ cloth_calc_force(scene, clmd, frame, effectors, step);
// calculate new velocity and position
BPH_mass_spring_solve_velocities(id, dt, &result);
@@ -1056,7 +1059,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
BPH_mass_spring_solve_positions(id, dt);
if (!is_hair) {
- cloth_collision_solve_extra(ob, clmd, effectors, frame, step, dt);
+ cloth_collision_solve_extra(scene, ob, clmd, effectors, frame, step, dt);
}
BPH_mass_spring_apply_result(id);