From fa2ba25c4ded47b7aa34e9225c93188551dee479 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Tue, 29 Apr 2025 22:41:03 +0200 Subject: [PATCH] fix(part): incorrect comparisons for surface validity --- core/src/objects/part.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/objects/part.cpp b/core/src/objects/part.cpp index 8ee1366..61e4e7a 100644 --- a/core/src/objects/part.cpp +++ b/core/src/objects/part.cpp @@ -213,16 +213,17 @@ void Part::MakeJoints() { for (Vector3 myFace : FACES) { Vector3 myWorldNormal = cframe.Rotation() * myFace; Vector3 validUp = cframe.Rotation() * Vector3(1,1,1).Unit(); // If myFace == (0, 1, 0), then (0, 1, 0) would produce NaN as up, so we fudge the up so that it works - CFrame surfaceFrame(cframe.Position(), cframe * (myFace * size), validUp); - Vector3 mySurfaceCenter = cframe * (myFace * size); + CFrame surfaceFrame = CFrame::pointToward(cframe * (myFace * size / 2.f), cframe.Rotation() * myFace); + Vector3 mySurfaceCenter = cframe * (myFace * size / 2.f); for (Vector3 otherFace : FACES) { Vector3 otherWorldNormal = otherPart->cframe.Rotation() * otherFace; - Vector3 otherSurfaceCenter = otherPart->cframe * (otherFace * otherPart->size); + Vector3 otherSurfaceCenter = otherPart->cframe * (otherFace * otherPart->size / 2.f); Vector3 surfacePointLocalToMyFrame = surfaceFrame.Inverse() * otherSurfaceCenter; float dot = myWorldNormal.Dot(otherWorldNormal); if (dot > -0.99) continue; // Surface is pointing opposite to ours + if (abs(surfacePointLocalToMyFrame.Z()) > 0.05) continue; // Surfaces are within 0.05 studs of one another if (!checkJointContinuity(otherPart)) continue; @@ -243,7 +244,6 @@ void Part::MakeJoints() { CFrame contactPoint = CFrame::pointToward(mySurfaceCenter, -myWorldNormal); CFrame contact0 = cframe.Inverse() * contactPoint; CFrame contact1 = otherPart->cframe.Inverse() * contactPoint; - addDebugRenderCFrame(contactPoint); auto joint_ = makeJointFromSurfaces(mySurface, otherSurface); if (!joint_) continue;