Cleanup: Access mesh bounds more directly

Simplifies the fix to #111120, because it is clearer that the threadsafe
Mesh access is used rather than the potentially problematic object-level
bounds access.
This commit is contained in:
Hans Goudey 2023-10-09 22:09:18 +02:00
parent 1d141e721c
commit 4eeabd274e
2 changed files with 14 additions and 13 deletions

View File

@ -106,14 +106,12 @@ static bool raycastMesh(SnapObjectContext *sctx,
/* Test BoundBox */
if (ob_eval->data == me_eval) {
const BoundBox *bb = BKE_object_boundbox_get(ob_eval);
if (bb) {
/* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
if (!isect_ray_aabb_v3_simple(
ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], &len_diff, nullptr))
{
return retval;
}
const Bounds<float3> bounds = *me_eval->bounds_min_max();
/* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
if (!isect_ray_aabb_v3_simple(
ray_start_local, ray_normal_local, bounds.min, bounds.max, &len_diff, nullptr))
{
return retval;
}
}
@ -454,8 +452,8 @@ static eSnapMode snapMesh(SnapObjectContext *sctx,
SnapData_Mesh nearest2d(sctx, me_eval, obmat);
if (ob_eval->data == me_eval) {
const BoundBox *bb = BKE_mesh_boundbox_get(ob_eval);
if (!nearest2d.snap_boundbox(bb->vec[0], bb->vec[6])) {
const Bounds<float3> bounds = *me_eval->bounds_min_max();
if (!nearest2d.snap_boundbox(bounds.min, bounds.max)) {
return SCE_SNAP_TO_NONE;
}
}

View File

@ -128,6 +128,9 @@ static Volume *mesh_to_volume(ModifierData *md,
return input_volume;
}
BKE_mesh_wrapper_ensure_mdata(mesh);
if (mesh->totvert == 0) {
return input_volume;
}
const float4x4 mesh_to_own_object_space_transform = float4x4(ctx->object->world_to_object) *
float4x4(object_to_convert->object_to_world);
@ -147,9 +150,9 @@ static Volume *mesh_to_volume(ModifierData *md,
}
auto bounds_fn = [&](float3 &r_min, float3 &r_max) {
const BoundBox *bb = BKE_object_boundbox_get(mvmd->object);
r_min = bb->vec[0];
r_max = bb->vec[6];
const Bounds<float3> bounds = *mesh->bounds_min_max();
r_min = bounds.min;
r_max = bounds.max;
};
const float voxel_size = geometry::volume_compute_voxel_size(