From c5e469a3e4ecda47932cc002aa53db662748bbec Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Wed, 12 Aug 2020 18:03:12 -0300 Subject: Cleanup: Move definitions of some variables closer to their use --- source/blender/blenkernel/intern/collision.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern/collision.c') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 467f15201fc..0ba0447bc3e 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -681,9 +681,6 @@ static int cloth_collision_response_static(ClothModifierData *clmd, { int result = 0; Cloth *cloth = clmd->clothObject; - float w1, w2, w3, u1, u2, u3; - float v1[3], v2[3], relativeVelocity[3]; - float magrelVel; const float clamp_sq = square_f(clmd->coll_parms->self_clamp * dt); const float time_multiplier = 1.0f / (clmd->sim_parms->dt * clmd->sim_parms->timescale); const float epsilon2 = BLI_bvhtree_get_epsilon(collmd->bvhtree); @@ -692,6 +689,8 @@ static int cloth_collision_response_static(ClothModifierData *clmd, const bool is_hair = (clmd->hairdata != NULL); for (int i = 0; i < collision_count; i++, collpair++) { float i1[3], i2[3], i3[3]; + float w1, w2, w3, u1, u2, u3; + float v1[3], v2[3], relativeVelocity[3]; zero_v3(i1); zero_v3(i2); zero_v3(i3); @@ -748,7 +747,7 @@ static int cloth_collision_response_static(ClothModifierData *clmd, /* Calculate the normal component of the relative velocity * (actually only the magnitude - the direction is stored in 'normal'). */ - magrelVel = dot_v3v3(relativeVelocity, collpair->normal); + const float magrelVel = dot_v3v3(relativeVelocity, collpair->normal); const float d = min_distance - collpair->distance; /* If magrelVel < 0 the edges are approaching each other. */ @@ -845,9 +844,6 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd, { int result = 0; Cloth *cloth = clmd->clothObject; - float w1, w2, w3, u1, u2, u3; - float v1[3], v2[3], relativeVelocity[3]; - float magrelVel; const float clamp_sq = square_f(clmd->coll_parms->self_clamp * dt); const float time_multiplier = 1.0f / (clmd->sim_parms->dt * clmd->sim_parms->timescale); const float min_distance = (2.0f * clmd->coll_parms->selfepsilon) * (8.0f / 9.0f); @@ -855,6 +851,8 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd, for (int i = 0; i < collision_count; i++, collpair++) { float ia[3][3] = {{0.0f}}; float ib[3][3] = {{0.0f}}; + float w1, w2, w3, u1, u2, u3; + float v1[3], v2[3], relativeVelocity[3]; /* Only handle static collisions here. */ if (collpair->flag & (COLLISION_IN_FUTURE | COLLISION_INACTIVE)) { @@ -899,7 +897,7 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd, /* Calculate the normal component of the relative velocity * (actually only the magnitude - the direction is stored in 'normal'). */ - magrelVel = dot_v3v3(relativeVelocity, collpair->normal); + const float magrelVel = dot_v3v3(relativeVelocity, collpair->normal); const float d = min_distance - collpair->distance; /* TODO: Impulses should be weighed by mass as this is self col, -- cgit v1.2.3