Fix #120245: Grid snap not working when constraining axis before moving
`sctx->grid.size` was only updated while the constraint was not enabled. This was causing division by zero.
This commit is contained in:
@@ -1140,26 +1140,29 @@ static bool snap_object_context_runtime_init(SnapObjectContext *sctx,
|
||||
sctx->runtime.rv3d = rv3d;
|
||||
|
||||
if (sctx->runtime.snap_to_flag & SCE_SNAP_TO_GRID) {
|
||||
if (init_co) {
|
||||
sctx->grid.use_init_co = true;
|
||||
}
|
||||
else if (!compare_m4m4(sctx->grid.persmat.ptr(), rv3d->persmat, FLT_EPSILON)) {
|
||||
if (!compare_m4m4(sctx->grid.persmat.ptr(), rv3d->persmat, FLT_EPSILON)) {
|
||||
sctx->grid.persmat = float4x4(rv3d->persmat);
|
||||
memset(sctx->grid.planes, 0, sizeof(sctx->grid.planes));
|
||||
sctx->grid.planes[0][2] = 1.0f;
|
||||
if (math::abs(sctx->runtime.ray_dir[0]) < math::abs(sctx->runtime.ray_dir[1])) {
|
||||
sctx->grid.planes[1][1] = 1.0f;
|
||||
sctx->grid.planes[2][0] = 1.0f;
|
||||
}
|
||||
else {
|
||||
sctx->grid.planes[1][0] = 1.0f;
|
||||
sctx->grid.planes[2][1] = 1.0f;
|
||||
}
|
||||
|
||||
plane_from_point_normal_v3(sctx->grid.planes[3], sctx->runtime.curr_co, rv3d->viewinv[2]);
|
||||
|
||||
sctx->grid.size = ED_view3d_grid_view_scale(
|
||||
sctx->scene, sctx->runtime.v3d, region, nullptr);
|
||||
|
||||
if (init_co) {
|
||||
sctx->grid.use_init_co = true;
|
||||
}
|
||||
else {
|
||||
memset(sctx->grid.planes, 0, sizeof(sctx->grid.planes));
|
||||
sctx->grid.planes[0][2] = 1.0f;
|
||||
if (math::abs(sctx->runtime.ray_dir[0]) < math::abs(sctx->runtime.ray_dir[1])) {
|
||||
sctx->grid.planes[1][1] = 1.0f;
|
||||
sctx->grid.planes[2][0] = 1.0f;
|
||||
}
|
||||
else {
|
||||
sctx->grid.planes[1][0] = 1.0f;
|
||||
sctx->grid.planes[2][1] = 1.0f;
|
||||
}
|
||||
|
||||
plane_from_point_normal_v3(
|
||||
sctx->grid.planes[3], sctx->runtime.curr_co, rv3d->viewinv[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user