Fix T49527: Blender stalls when changing armature ghosting range with stepsize = 0

A big thanks to Steffen Mortensen (stifan) for finding the root cause of this bug!
This commit is contained in:
Joshua Leung 2017-01-22 02:54:35 +13:00
parent 82187a58f5
commit d2382f782e
Notes: blender-bot 2023-02-14 07:32:45 +01:00
Referenced by issue #49527, Blender stales when changing the ghosting range
2 changed files with 10 additions and 1 deletions

View File

@ -87,6 +87,7 @@ bArmature *BKE_armature_add(Main *bmain, const char *name)
arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE;
arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */
arm->layer = 1;
arm->ghostsize = 1;
return arm;
}

View File

@ -2463,6 +2463,10 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base
if (end <= start)
return;
/* prevent infinite loops if this is set to 0 - T49527 */
if (arm->ghostsize < 1)
arm->ghostsize = 1;
stepsize = (float)(arm->ghostsize);
range = (float)(end - start);
@ -2608,7 +2612,11 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
calc_action_range(adt->action, &start, &end, 0);
if (start == end)
return;
/* prevent infinite loops if this is set to 0 - T49527 */
if (arm->ghostsize < 1)
arm->ghostsize = 1;
stepsize = (float)(arm->ghostsize);
range = (float)(arm->ghostep) * stepsize + 0.5f; /* plus half to make the for loop end correct */