change to/from ellipsoid space methods to regular instance methods so we don't have to pass an ellipsoid radius every time
This commit is contained in:
parent
d1d4350ac1
commit
f974236432
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue