Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/curve_deform.c
| Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | static bool calc_curve_deform( | ||||
| if (ob_curve->runtime.curve_cache->path == NULL) { | if (ob_curve->runtime.curve_cache->path == NULL) { | ||||
| return false; /* happens on append, cyclic dependencies and empty curves */ | return false; /* happens on append, cyclic dependencies and empty curves */ | ||||
| } | } | ||||
| /* options */ | /* options */ | ||||
| if (is_neg_axis) { | if (is_neg_axis) { | ||||
| index = axis - 3; | index = axis - 3; | ||||
| if (cu->flag & CU_STRETCH) { | if (cu->flag & CU_STRETCH) { | ||||
| fac = -(co[index] - cd->dmax[index]) / (cd->dmax[index] - cd->dmin[index]); | float divisor = cd->dmax[index] - cd->dmin[index]; | ||||
mont29: `const float` ;) | |||||
| if (LIKELY(divisor > FLT_EPSILON)) { | |||||
| fac = -(co[index] - cd->dmax[index]) / divisor; | |||||
| } | |||||
| else { | |||||
| fac = 0.0f; | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| fac = -(co[index] - cd->dmax[index]) / (ob_curve->runtime.curve_cache->path->totdist); | fac = -(co[index] - cd->dmax[index]) / (ob_curve->runtime.curve_cache->path->totdist); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| index = axis; | index = axis; | ||||
| if (cu->flag & CU_STRETCH) { | if (cu->flag & CU_STRETCH) { | ||||
| fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]); | float divisor = cd->dmax[index] - cd->dmin[index]; | ||||
mont29Unsubmitted Done Inline Actionsconst float ;) mont29: `const float` ;) | |||||
rjgAuthorUnsubmitted Done Inline ActionsObviously :) rjg: Obviously :) | |||||
| if (LIKELY(divisor > FLT_EPSILON)) { | |||||
| fac = (co[index] - cd->dmin[index]) / divisor; | |||||
| } | |||||
| else { | |||||
| fac = 0.0f; | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| if (LIKELY(ob_curve->runtime.curve_cache->path->totdist > FLT_EPSILON)) { | if (LIKELY(ob_curve->runtime.curve_cache->path->totdist > FLT_EPSILON)) { | ||||
| fac = +(co[index] - cd->dmin[index]) / (ob_curve->runtime.curve_cache->path->totdist); | fac = +(co[index] - cd->dmin[index]) / (ob_curve->runtime.curve_cache->path->totdist); | ||||
| } | } | ||||
| else { | else { | ||||
| fac = 0.0f; | fac = 0.0f; | ||||
| } | } | ||||
mont29Unsubmitted Done Inline ActionsThis check should also be done in similar case just above? mont29: This check should also be done in similar case just above? | |||||
rjgAuthorUnsubmitted Done Inline ActionsGood eye. Not sure why this was only checked here before. rjg: Good eye. Not sure why this was only checked here before. | |||||
mont29Unsubmitted Not Done Inline ActionsI would guess because this was the only case that failed in a previous bug report? ;) mont29: I would guess because this was the only case that failed in a previous bug report? ;) | |||||
| } | } | ||||
| } | } | ||||
| if (where_on_path_deform(ob_curve, fac, loc, dir, new_quat, &radius)) { /* returns OK */ | if (where_on_path_deform(ob_curve, fac, loc, dir, new_quat, &radius)) { /* returns OK */ | ||||
| float quat[4], cent[3]; | float quat[4], cent[3]; | ||||
| if (cd->no_rot_axis) { /* set by caller */ | if (cd->no_rot_axis) { /* set by caller */ | ||||
| ▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines | |||||
const float ;)