Fix Snap to Face Nearest not working properly if transformed

Local `init_co` and `curr_co` were being calculated incorrectly.
This commit is contained in:
Germano Cavalcante
2023-06-30 12:44:35 -03:00
parent 568fe85b94
commit 8cc418b6fc
2 changed files with 6 additions and 4 deletions

View File

@@ -416,8 +416,9 @@ static bool nearest_world_editmesh(SnapCache_EditMesh *em_cache,
return false;
}
float3 init_co = math::transform_point(obmat, float3(sctx->runtime.init_co));
float3 curr_co = math::transform_point(obmat, float3(sctx->runtime.curr_co));
float4x4 imat = math::invert(obmat);
float3 init_co = math::transform_point(imat, float3(sctx->runtime.init_co));
float3 curr_co = math::transform_point(imat, float3(sctx->runtime.curr_co));
BVHTreeNearest nearest{};
nearest.dist_sq = sctx->ret.dist_px_sq;

View File

@@ -231,8 +231,9 @@ static bool nearest_world_mesh(SnapObjectContext *sctx,
return false;
}
float3 init_co = math::transform_point(obmat, float3(sctx->runtime.init_co));
float3 curr_co = math::transform_point(obmat, float3(sctx->runtime.curr_co));
float4x4 imat = math::invert(obmat);
float3 init_co = math::transform_point(imat, float3(sctx->runtime.init_co));
float3 curr_co = math::transform_point(imat, float3(sctx->runtime.curr_co));
BVHTreeNearest nearest{};
nearest.dist_sq = sctx->ret.dist_px_sq;