star-3d

Surface structuring for efficient 3D geometric queries
git clone git://git.meso-star.fr/star-3d.git
Log | Files | Refs | README | LICENSE

commit 4d4e14ccf033b4120494dcb2fc031cfeac4d05d9
parent 94bb0d5e6e2c4cb61eba8d16d971d9fdd1708c59
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 22 Oct 2020 12:03:21 +0200

Fix the closest point query for the instantiated meshes

The transformation of the query position from world space to instance
space was wrongly computed.

Diffstat:
Msrc/s3d_scene_view_closest_point.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/s3d_scene_view_closest_point.c b/src/s3d_scene_view_closest_point.c @@ -202,15 +202,19 @@ closest_point_mesh query_pos_ls[2] = query_pos_ws[2]; } else { const float* world2inst; + float a[3], b[3], c[3]; ASSERT(args->context->instStackSize == 1); ASSERT(inst && inst->type == GEOM_INSTANCE); world2inst = args->context->world2inst[0]; /* Transform the query position in instance space */ - query_pos_ls[0] = f3_dot(query_pos_ws, world2inst+0) + world2inst[12]; - query_pos_ls[1] = f3_dot(query_pos_ws, world2inst+4) + world2inst[13]; - query_pos_ls[2] = f3_dot(query_pos_ws, world2inst+8) + world2inst[14]; + f3_mulf(a, world2inst+0, query_pos_ws[0]); + f3_mulf(b, world2inst+4, query_pos_ws[1]); + f3_mulf(c, world2inst+8, query_pos_ws[2]); + query_pos_ls[0] = a[0] + b[0] + c[0] + world2inst[12]; + query_pos_ls[1] = a[1] + b[1] + c[1] + world2inst[13]; + query_pos_ls[2] = a[2] + b[2] + c[2] + world2inst[14]; flip_surface = inst->flip_surface; }