diff options
author | Luca Rood <dev@lucarood.com> | 2017-01-25 08:24:51 +0300 |
---|---|---|
committer | Luca Rood <dev@lucarood.com> | 2017-01-25 09:05:52 +0300 |
commit | 96f6ec07fb1041dfbc6a90dba0b10cdfac14a86e (patch) | |
tree | 23cc447dd8db06056e72ba4a2655e9fcdfd4c295 | |
parent | c38e19ca67b4e49a3da1f4161593b014236af11d (diff) |
Review: Add infinite weight flags enum
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index 34b6b99dbad..877b888a0e7 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -90,6 +90,13 @@ enum { MOD_SDEF_BIND_RESULT_OVERLAP_ERR = -4, }; +/* Infinite weight flags */ +enum { + MOD_SDEF_INFINITE_WEIGHT_ANGULAR = 1 << 0, + MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ = 1 << 1, + MOD_SDEF_INFINITE_WEIGHT_DIST = 1 << 2, +} + static void initData(ModifierData *md) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; @@ -520,11 +527,11 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData * const data, /* Check for inifnite weights, and compute angular data otherwise */ if (bpoly->weight_dist < FLT_EPSILON) { - inf_weight_flags |= 1 << 1; - inf_weight_flags |= 1 << 2; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST; } else if (bpoly->weight_dist_proj < FLT_EPSILON) { - inf_weight_flags |= 1 << 1; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ; } else { float cent_point_vec[2]; @@ -641,18 +648,18 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData * const data, /* Re-check for infinite weights, now that all scalings and interpolations are computed */ if (bpoly->weight_dist < FLT_EPSILON) { - inf_weight_flags |= 1 << 1; - inf_weight_flags |= 1 << 2; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST; } else if (bpoly->weight_dist_proj < FLT_EPSILON) { - inf_weight_flags |= 1 << 1; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ; } else if (bpoly->weight_angular < FLT_EPSILON) { - inf_weight_flags |= 1 << 0; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_ANGULAR; } } } - else if (!(inf_weight_flags & (1 << 2))) { + else if (!(inf_weight_flags & MOD_SDEF_INFINITE_WEIGHT_DIST)) { bpoly = bwdata->bind_polys; for (int i = 0; i < bwdata->numpoly; bpoly++, i++) { @@ -662,7 +669,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData * const data, /* Re-check for infinite weights, now that all scalings and interpolations are computed */ if (bpoly->weight_dist < FLT_EPSILON) { - inf_weight_flags |= 1 << 2; + inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST; } } } @@ -672,14 +679,14 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData * const data, for (int i = 0; i < bwdata->numpoly; bpoly++, i++) { /* Weight computation from components */ - if (inf_weight_flags & 1 << 2) { + if (inf_weight_flags & MOD_SDEF_INFINITE_WEIGHT_DIST) { bpoly->weight = bpoly->weight_dist < FLT_EPSILON ? 1.0f : 0.0f; } - else if (inf_weight_flags & 1 << 1) { + else if (inf_weight_flags & MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ) { bpoly->weight = bpoly->weight_dist_proj < FLT_EPSILON ? 1.0f / bpoly->weight_dist : 0.0f; } - else if (inf_weight_flags & 1 << 0) { + else if (inf_weight_flags & MOD_SDEF_INFINITE_WEIGHT_ANGULAR) { bpoly->weight = bpoly->weight_angular < FLT_EPSILON ? 1.0f / bpoly->weight_dist_proj / bpoly->weight_dist : 0.0f; } |