From f974236432d623677acdc82bce14f253fd0edcf7 Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 30 Sep 2013 04:32:08 -0400 Subject: [PATCH] change to/from ellipsoid space methods to regular instance methods so we don't have to pass an ellipsoid radius every time --- src/com/blarg/gdx/math/SweptSphere.java | 32 +++++++++---------- .../gdx/math/SweptSphereCollisionTester.java | 6 ++-- .../blarg/gdx/math/SweptSphereHandler.java | 12 +++---- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/com/blarg/gdx/math/SweptSphere.java b/src/com/blarg/gdx/math/SweptSphere.java index e6c7aae..a64e8aa 100644 --- a/src/com/blarg/gdx/math/SweptSphere.java +++ b/src/com/blarg/gdx/math/SweptSphere.java @@ -67,27 +67,27 @@ public class SweptSphere { esIntersectionPoint.set(Vector3.Zero); } - public static void toEllipsoidSpace(Vector3 in, Vector3 ellipsoidRadius, Vector3 out) { - out.x = in.x / ellipsoidRadius.x; - out.y = in.y / ellipsoidRadius.y; - out.z = in.z / ellipsoidRadius.z; + public void toEllipsoidSpace(Vector3 in, Vector3 out) { + out.x = in.x / radius.x; + out.y = in.y / radius.y; + out.z = in.z / radius.z; } - public static void toEllipsoidSpace(Vector3 v, Vector3 ellipsoidRadius) { - v.x /= ellipsoidRadius.x; - v.y /= ellipsoidRadius.y; - v.z /= ellipsoidRadius.z; + public void toEllipsoidSpace(Vector3 v) { + v.x /= radius.x; + v.y /= radius.y; + v.z /= radius.z; } - public static void fromEllipsoidSpace(Vector3 in, Vector3 ellipsoidRadius, Vector3 out) { - out.x = in.x * ellipsoidRadius.x; - out.y = in.y * ellipsoidRadius.y; - out.z = in.z * ellipsoidRadius.z; + public void fromEllipsoidSpace(Vector3 in, Vector3 out) { + out.x = in.x * radius.x; + out.y = in.y * radius.y; + out.z = in.z * radius.z; } - public static void fromEllipsoidSpace(Vector3 v, Vector3 ellipsoidRadius) { - v.x *= ellipsoidRadius.x; - v.y *= ellipsoidRadius.y; - v.z *= ellipsoidRadius.z; + public void fromEllipsoidSpace(Vector3 v) { + v.x *= radius.x; + v.y *= radius.y; + v.z *= radius.z; } } diff --git a/src/com/blarg/gdx/math/SweptSphereCollisionTester.java b/src/com/blarg/gdx/math/SweptSphereCollisionTester.java index cc8ec6c..f8640f3 100644 --- a/src/com/blarg/gdx/math/SweptSphereCollisionTester.java +++ b/src/com/blarg/gdx/math/SweptSphereCollisionTester.java @@ -20,9 +20,9 @@ public final class SweptSphereCollisionTester { public static boolean test(SweptSphere sphere, Vector3 v1, Vector3 v2, Vector3 v3) { boolean foundCollision = false; - SweptSphere.toEllipsoidSpace(v1, sphere.radius, p1); - SweptSphere.toEllipsoidSpace(v2, sphere.radius, p2); - SweptSphere.toEllipsoidSpace(v3, sphere.radius, p3); + sphere.toEllipsoidSpace(v1, p1); + sphere.toEllipsoidSpace(v2, p2); + sphere.toEllipsoidSpace(v3, p3); trianglePlane.set(p1, p2, p3); diff --git a/src/com/blarg/gdx/math/SweptSphereHandler.java b/src/com/blarg/gdx/math/SweptSphereHandler.java index e9b2d4e..835fa48 100644 --- a/src/com/blarg/gdx/math/SweptSphereHandler.java +++ b/src/com/blarg/gdx/math/SweptSphereHandler.java @@ -67,8 +67,8 @@ public class SweptSphereHandler { //calculatePossibleCollisionArea(sphere, velocity); // convert position and velocity to ellipsoid space - SweptSphere.toEllipsoidSpace(sphere.position, sphere.radius, esPosition); - SweptSphere.toEllipsoidSpace(velocity, sphere.radius, esVelocity); + sphere.toEllipsoidSpace(sphere.position, esPosition); + sphere.toEllipsoidSpace(velocity, esVelocity); // check for and respond to any collisions along this velocity vector sphere.nearestCollisionDistance = 0.0f; @@ -79,16 +79,16 @@ public class SweptSphereHandler { Vector3 newEsPosition = getNewPositionForMovement(0, sphere, esPosition, esVelocity, resultingVelocity, canSlide, onlySlideIfTooSteep, tooSteepAngleY); // resulting velocity will have been calculated in ellipsoid space - SweptSphere.fromEllipsoidSpace(resultingVelocity, sphere.radius); + sphere.fromEllipsoidSpace(resultingVelocity); if (sphere.foundCollision) - SweptSphere.fromEllipsoidSpace(sphere.esIntersectionPoint, sphere.radius, sphere.nearestCollisionPoint); + sphere.fromEllipsoidSpace(sphere.esIntersectionPoint, sphere.nearestCollisionPoint); // sliding plane origin will be in ellipsoid space still... - SweptSphere.fromEllipsoidSpace(sphere.slidingPlaneOrigin, sphere.radius); + sphere.fromEllipsoidSpace(sphere.slidingPlaneOrigin); // convert the new position back to normal space and move the entity there - SweptSphere.fromEllipsoidSpace(newEsPosition, sphere.radius, sphere.position); + sphere.fromEllipsoidSpace(newEsPosition, sphere.position); outVelocity.set(resultingVelocity); }