Fix for a bug where the Array modifier would freeze if it was set to "Fit To

Curve Length" or "Fixed Count" and the base mesh was scaled to 0 in edit mode
(could also happen while entering a numerical scale value like 0.25).

The problem was that the dist value could be almost 0, leading to a
ridiculously large duplicate count which would then cause memory allocation
to fail and the array modifier to get stuck in an almost infinite loop trying
to calculate the offset of the final copy. This commit fixes the problem
by checking that dist is greater than FLT_EPSILON before continuing.
This commit is contained in:
2006-08-30 11:10:04 +00:00
parent cc6f92cb1a
commit 090a010988

View File

@@ -39,6 +39,7 @@
#include "string.h"
#include "stdarg.h"
#include "math.h"
#include "float.h"
#include "BLI_blenlib.h"
#include "BLI_rand.h"
@@ -800,10 +801,10 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
|| amd->fit_type == MOD_ARR_FITCURVE) {
float dist = sqrt(MTC_dot3Float(offset[3], offset[3]));
if(dist != 0)
if(dist > FLT_EPSILON)
/* this gives length = first copy start to last copy end
add a tiny offset for floating point rounding errors */
count = (length + 0.00001) / dist;
count = (length + FLT_EPSILON) / dist;
else
/* if the offset has no translation, just make one copy */
count = 1;