summaryrefslogtreecommitdiffhomepage
path: root/examples/models
diff options
context:
space:
mode:
authorRay <[email protected]>2022-03-30 20:11:22 +0200
committerRay <[email protected]>2022-03-30 20:11:22 +0200
commit90fc7c0376f39d7b19d632e1d69dec715ec3f2a8 (patch)
treee79f82b60d57b3a4a948be5dfa340b03de567060 /examples/models
parent5abb87a0d27f3a81252c262dc217b0f8b85de753 (diff)
downloadraylib-90fc7c0376f39d7b19d632e1d69dec715ec3f2a8.tar.gz
raylib-90fc7c0376f39d7b19d632e1d69dec715ec3f2a8.zip
WARNING: BREAKING: REMOVED: `GetRayCollisionModel()` #2405
Diffstat (limited to 'examples/models')
-rw-r--r--examples/models/models_mesh_picking.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c
index f48683e4..38378bc4 100644
--- a/examples/models/models_mesh_picking.c
+++ b/examples/models/models_mesh_picking.c
@@ -121,9 +121,22 @@ int main(void)
cursorColor = ORANGE;
hitObjectName = "Box";
- // Check ray collision against model
- // NOTE: It considers model.transform matrix!
- RayCollision meshHitInfo = GetRayCollisionModel(ray, tower);
+ // Check ray collision against model meshes
+ RayCollision meshHitInfo = { 0 };
+ for (int m = 0; m < tower.meshCount; m++)
+ {
+ // NOTE: We consider the model.transform for the collision check but
+ // it can be checked against any transform Matrix, used when checking against same
+ // model drawn multiple times with multiple transforms
+ meshHitInfo = GetRayCollisionMesh(ray, tower.meshes[m], tower.transform);
+ if (meshHitInfo.hit)
+ {
+ // Save the closest hit mesh
+ if ((!collision.hit) || (collision.distance > meshHitInfo.distance)) collision = meshHitInfo;
+
+ break; // Stop once one mesh collision is detected, the colliding mesh is m
+ }
+ }
if (meshHitInfo.hit)
{