Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_simpledeform.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| #include "depsgraph_private.h" | #include "depsgraph_private.h" | ||||
| #include "MOD_util.h" | #include "MOD_util.h" | ||||
| #define BEND_EPS 0.000001f | #define BEND_EPS 0.000001f | ||||
| /* Re-maps the indicies for X Y Z by shifting them up and wrapping, such that | /* Re-maps the indices for X Y Z by shifting them up and wrapping, such that | ||||
| * X = Y, Y = Z, Z = X (for X axis), and X = Z, Y = X, Z = Y (for Y axis). This | * X = Y, Y = Z, Z = X (for X axis), and X = Z, Y = X, Z = Y (for Y axis). This | ||||
| * exists because the deformations (excluding bend) are based on the Z axis. | * exists because the deformations (excluding bend) are based on the Z axis. | ||||
| * Having this helps avoid long, drawn out switches. */ | * Having this helps avoid long, drawn out switches. */ | ||||
| static const uint axis_map_table[3][3] = { | static const uint axis_map_table[3][3] = { | ||||
| {1, 2, 0}, | {1, 2, 0}, | ||||
| {2, 0, 1}, | {2, 0, 1}, | ||||
| {0, 1, 2}, | {0, 1, 2}, | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | static void SimpleDeformModifier_do( | ||||
| SpaceTransform *transf = NULL, tmp_transf; | SpaceTransform *transf = NULL, tmp_transf; | ||||
| void (*simpleDeform_callback)(const float factor, const int axis, const float dcut[3], float co[3]) = NULL; /* Mode callback */ | void (*simpleDeform_callback)(const float factor, const int axis, const float dcut[3], float co[3]) = NULL; /* Mode callback */ | ||||
| int vgroup; | int vgroup; | ||||
| MDeformVert *dvert; | MDeformVert *dvert; | ||||
| /* This is historically the lock axis, _not_ the deform axis as the name would imply */ | /* This is historically the lock axis, _not_ the deform axis as the name would imply */ | ||||
| const int deform_axis = smd->deform_axis; | const int deform_axis = smd->deform_axis; | ||||
| int lock_axis = smd->axis; | int lock_axis = smd->axis; | ||||
| if (smd->mode == MOD_SIMPLEDEFORM_MODE_BEND) { /* Bend mode shouln't have any lock axis */ | if (smd->mode == MOD_SIMPLEDEFORM_MODE_BEND) { /* Bend mode shouldn't have any lock axis */ | ||||
| lock_axis = 0; | lock_axis = 0; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Don't lock axis if it is the chosen deform axis, as this flattens | /* Don't lock axis if it is the chosen deform axis, as this flattens | ||||
| * the geometry */ | * the geometry */ | ||||
| if (deform_axis == 0) { | if (deform_axis == 0) { | ||||
| lock_axis &= ~MOD_SIMPLEDEFORM_LOCK_AXIS_X; | lock_axis &= ~MOD_SIMPLEDEFORM_LOCK_AXIS_X; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | for (i = 0; i < numVerts; i++) { | ||||
| BLI_space_transform_apply(transf, tmp); | BLI_space_transform_apply(transf, tmp); | ||||
| } | } | ||||
| lower = min_ff(lower, tmp[limit_axis]); | lower = min_ff(lower, tmp[limit_axis]); | ||||
| upper = max_ff(upper, tmp[limit_axis]); | upper = max_ff(upper, tmp[limit_axis]); | ||||
| } | } | ||||
| /* SMD values are normalized to the BV, calculate the absolut values */ | /* SMD values are normalized to the BV, calculate the absolute values */ | ||||
| smd_limit[1] = lower + (upper - lower) * smd->limit[1]; | smd_limit[1] = lower + (upper - lower) * smd->limit[1]; | ||||
| smd_limit[0] = lower + (upper - lower) * smd->limit[0]; | smd_limit[0] = lower + (upper - lower) * smd->limit[0]; | ||||
| smd_factor = smd->factor / max_ff(FLT_EPSILON, smd_limit[1] - smd_limit[0]); | smd_factor = smd->factor / max_ff(FLT_EPSILON, smd_limit[1] - smd_limit[0]); | ||||
| } | } | ||||
| switch (smd->mode) { | switch (smd->mode) { | ||||
| case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_callback = simpleDeform_twist; break; | case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_callback = simpleDeform_twist; break; | ||||
| ▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines | |||||