Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Dick <weasel>2021-04-30 16:38:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-30 16:40:17 +0300
commita58a8296d9da785920575725bbb41fd5481b5d2d (patch)
tree01fb3ce5cbb6263af6c391f1330cc9e17a628697 /source/blender/modifiers
parent0d07cfd9405464e45186c3c075f255ff519f1d24 (diff)
Fix T85470: Simple deform modifier causes artifacts at low angles
The formula used to compute the bend did subtraction of two big numbers to get the position. Changed to find the delta and add that, by rearranging the formula into a more numerically stable form. Reviewed By: mano-wii, campbellbarton Ref D11074
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index ea31bdc6e31..951eacdecda 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -170,10 +170,12 @@ static void simpleDeform_bend(const float factor,
sint = sinf(theta);
cost = cosf(theta);
+ /* NOTE: the operations below a susceptible to float precision errors
+ * regarding the order of operations, take care when changing, see: T85470 */
switch (axis) {
case 0:
r_co[0] = x;
- r_co[1] = (y - 1.0f / factor) * cost + 1.0f / factor;
+ r_co[1] = y * cost + (1.0f - cost) / factor;
r_co[2] = -(y - 1.0f / factor) * sint;
{
r_co[0] += dcut[0];
@@ -182,7 +184,7 @@ static void simpleDeform_bend(const float factor,
}
break;
case 1:
- r_co[0] = (x - 1.0f / factor) * cost + 1.0f / factor;
+ r_co[0] = x * cost + (1.0f - cost) / factor;
r_co[1] = y;
r_co[2] = -(x - 1.0f / factor) * sint;
{
@@ -193,7 +195,7 @@ static void simpleDeform_bend(const float factor,
break;
default:
r_co[0] = -(y - 1.0f / factor) * sint;
- r_co[1] = (y - 1.0f / factor) * cost + 1.0f / factor;
+ r_co[1] = y * cost + (1.0f - cost) / factor;
r_co[2] = z;
{
r_co[0] += cost * dcut[0];