diff options
author | Campbell Barton <campbell@blender.org> | 2022-04-26 07:24:44 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-04-26 07:24:44 +0300 |
commit | a9d1b3d7e3e9fa52c811d9807c8a26aa1c64b327 (patch) | |
tree | d3a773b4af0eea2237590829cd055d72e5499813 /source/blender | |
parent | a32f447c54255fd1b283757fa6b2c6ec90212f4e (diff) |
Cleanup: replace in-line swapping with SWAP macro
Also use bool array for true/false values.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a58ffa4e0a6..1ad722d4fdc 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1344,13 +1344,13 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph, float *dists = MEM_mallocN(sizeof(float) * totweight, "distance"); /* track if up or down moved it closer for each bone */ - int *upDown = MEM_callocN(sizeof(int) * totweight, "upDownTracker"); + bool *upDown = MEM_callocN(sizeof(bool) * totweight, "upDownTracker"); int *dwIndices = MEM_callocN(sizeof(int) * totweight, "dwIndexTracker"); float distToStart; int bestIndex = 0; bool wasChange; - char wasUp; + bool wasUp; int lastIndex = -1; float originalDistToBe = distToBe; do { @@ -1410,13 +1410,13 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph, } else { if (fabsf(dist - distToBe) < fabsf(dists[i] - distToBe)) { - upDown[i] = 0; + upDown[i] = false; changes[i][0] = vc; changes[i][1] = hc; dists[i] = dist; } else { - upDown[i] = 1; + upDown[i] = true; } if (fabsf(dists[i] - distToBe) > fabsf(distToStart - distToBe)) { changes[i][0] = 0; @@ -1428,8 +1428,6 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph, } /* sort the changes by the vertical change */ for (k = 0; k < totweight; k++) { - float tf; - int ti; bestIndex = k; for (i = k + 1; i < totweight; i++) { dist = dists[i]; @@ -1440,25 +1438,10 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph, } /* switch with k */ if (bestIndex != k) { - ti = upDown[k]; - upDown[k] = upDown[bestIndex]; - upDown[bestIndex] = ti; - - ti = dwIndices[k]; - dwIndices[k] = dwIndices[bestIndex]; - dwIndices[bestIndex] = ti; - - tf = changes[k][0]; - changes[k][0] = changes[bestIndex][0]; - changes[bestIndex][0] = tf; - - tf = changes[k][1]; - changes[k][1] = changes[bestIndex][1]; - changes[bestIndex][1] = tf; - - tf = dists[k]; - dists[k] = dists[bestIndex]; - dists[bestIndex] = tf; + SWAP(bool, upDown[k], upDown[bestIndex]); + SWAP(int, dwIndices[k], dwIndices[bestIndex]); + swap_v2_v2(changes[k], changes[bestIndex]); + SWAP(float, dists[k], dists[bestIndex]); } } bestIndex = -1; |