Cleanup: Move definitions of some variables closer to their use

This commit is contained in:
Germano Cavalcante 2020-08-12 18:03:12 -03:00
parent 7d16db417b
commit c5e469a3e4
1 changed files with 6 additions and 8 deletions

View File

@ -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,