From 44eb4aa2362a55f0f9a8bd3c3ec0f0e1221377c7 Mon Sep 17 00:00:00 2001 From: n00b Date: Sun, 22 Dec 2024 14:22:00 -0500 Subject: [PATCH] Added error check for canvas type to RayCast2D functions --- rcbasic_runtime/rc_sprite_physics.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rcbasic_runtime/rc_sprite_physics.h b/rcbasic_runtime/rc_sprite_physics.h index 101001a..5320d34 100644 --- a/rcbasic_runtime/rc_sprite_physics.h +++ b/rcbasic_runtime/rc_sprite_physics.h @@ -621,6 +621,9 @@ std::vector rc_rayHit2D; // Function to perform a ray cast and collect all hits int rc_castRay2D_All(double from_x, double from_y, double to_x, double to_y) { + if(rc_canvas[rc_active_canvas].type != RC_CANVAS_TYPE_SPRITE) + return 0; + rc_rayHit2D.clear(); RayCastCallback callback; b2Vec2 point1(from_x, from_y); @@ -646,6 +649,9 @@ int rc_castRay2D_All(double from_x, double from_y, double to_x, double to_y) // Function to perform a ray cast and collect the closest hit int rc_castRay2D(double from_x, double from_y, double to_x, double to_y) { + if(rc_canvas[rc_active_canvas].type != RC_CANVAS_TYPE_SPRITE) + return 0; + rc_rayHit2D.clear(); RayCastCallback callback; const b2Vec2 point1(from_x, from_y);