From f42de5490a1ef6ff371cdb0fe236f381c7b91cec Mon Sep 17 00:00:00 2001 From: Iceyshell <135187509+Iceyshell@users.noreply.github.com> Date: Sat, 9 Nov 2024 19:25:30 +0800 Subject: [PATCH 1/2] Update collision.cpp Fix ceiling slope hang so which was fixed by others too.However,Ensure that the code is consistent in determining the validity of the p1 coordinate relative to the area range --- src/collision/collision.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collision/collision.cpp b/src/collision/collision.cpp index b4faaf3491e..71188727456 100644 --- a/src/collision/collision.cpp +++ b/src/collision/collision.cpp @@ -129,7 +129,7 @@ bool rectangle_aatriangle(Constraints* constraints, const Rectf& rect, Vector outvec = normal * (depth + 0.2f); - const float RDELTA = 3; + const float RDELTA = 1.5f; if (p1.x < area.get_left() - RDELTA || p1.x > area.get_right() + RDELTA || p1.y < area.get_top() - RDELTA || p1.y > area.get_bottom() + RDELTA) { set_rectangle_rectangle_constraints(constraints, rect, area); From 257c8aa604931f88ebb51f935247d56661be6a92 Mon Sep 17 00:00:00 2001 From: Iceyshell <135187509+Iceyshell@users.noreply.github.com> Date: Sun, 10 Nov 2024 10:43:03 +0800 Subject: [PATCH 2/2] Update collision.cpp again This time, the depth detection logic has been modified to reduce the offset value appropriately so that the player can move more smoothly when close to the ceiling Also, adjusted the constraints to add additional handling of top collisions to make sure players don't stay in the ceiling area Hope this time everything will be fine --- src/collision/collision.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/collision/collision.cpp b/src/collision/collision.cpp index 71188727456..d7e1cf5347a 100644 --- a/src/collision/collision.cpp +++ b/src/collision/collision.cpp @@ -127,7 +127,7 @@ bool rectangle_aatriangle(Constraints* constraints, const Rectf& rect, std::cout << "Norm: " << normal << " Depth: " << depth << "\n"; #endif - Vector outvec = normal * (depth + 0.2f); + Vector outvec = normal * (depth + 0.1f); const float RDELTA = 1.5f; if (p1.x < area.get_left() - RDELTA || p1.x > area.get_right() + RDELTA @@ -146,7 +146,7 @@ bool rectangle_aatriangle(Constraints* constraints, const Rectf& rect, constraints->constrain_bottom(rect.get_bottom() + outvec.y); constraints->hit.bottom = true; hits_rectangle_bottom = true; - } else { + } else if(outvec.y > 0 && normal.y > 0){ constraints->constrain_top(rect.get_top() + outvec.y); constraints->hit.top = true; }