From c895c9e617c219a3826279373bc907bacdc27e85 Mon Sep 17 00:00:00 2001 From: jacob Date: Fri, 16 May 2025 13:24:25 -0500 Subject: [PATCH] change epa validity_epsilon as a temporary fix for unstable rounded edge collisions --- src/collider.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/collider.c b/src/collider.c index 54a2c472..e58e3348 100644 --- a/src/collider.c +++ b/src/collider.c @@ -7,7 +7,7 @@ #define COLLISION_TOLERANCE 0.005f /* NOTE: Should always be less than tolerance, since colliding = true if origin is within this distance. */ -#define MIN_UNIQUE_PT_DIST_SQ (0.0001f * 0.0001f) +#define MIN_UNIQUE_PT_DIST_SQ (0.001f * 0.001f) /* To prevent extremely large prototypes when origin is in exact center of rounded feature */ #define MAX_EPA_ITERATIONS 64 @@ -384,6 +384,7 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0 #if COLLIDER_DEBUG { + /* If debug step count is reached, we still want to inspect the normal at the step */ normal = v2_norm(dir); closest_feature.a = closest_a; closest_feature.b = closest_b; @@ -399,7 +400,8 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0 { /* NOTE: Changing this value affects how stable normals are for circular colliders */ //const f32 validity_epsilon = min_unique_pt_dist_sq; /* Arbitrary */ - const f32 validity_epsilon = 0.00000000001f; /* Arbitrary */ + //const f32 validity_epsilon = 0.00000000001f; /* Arbitrary */ + const f32 validity_epsilon = min_unique_pt_dist_sq; /* Arbitrary */ struct v2 vam = v2_sub(m.p, closest_a.p); struct v2 vbm = v2_sub(closest_b.p, closest_a.p);