summaryrefslogtreecommitdiff
path: root/src/code/sys_math3d.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/code/sys_math3d.c')
-rw-r--r--src/code/sys_math3d.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c
index 867c86443..5c7975754 100644
--- a/src/code/sys_math3d.c
+++ b/src/code/sys_math3d.c
@@ -1925,14 +1925,14 @@ s32 Math3D_SphVsSph(Sphere16* sphereA, Sphere16* sphereB) {
s32 Math3D_SphVsSphOverlap(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize) {
f32 centerDist;
- return Math3D_SphVsSphOverlapCenter(sphereA, sphereB, overlapSize, &centerDist);
+ return Math3D_SphVsSphOverlapCenterDist(sphereA, sphereB, overlapSize, &centerDist);
}
/*
* Determines if two spheres are touching The distance from the centers is placed in `centerDist`,
* and the amount that they're overlapping is placed in `overlapSize`
*/
-s32 Math3D_SphVsSphOverlapCenter(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize, f32* centerDist) {
+s32 Math3D_SphVsSphOverlapCenterDist(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize, f32* centerDist) {
Vec3f diff;
diff.x = (f32)sphereA->center.x - (f32)sphereB->center.x;
@@ -1951,9 +1951,9 @@ s32 Math3D_SphVsSphOverlapCenter(Sphere16* sphereA, Sphere16* sphereB, f32* over
}
/**
- * Checks if `sph` and `cyl` are touching, output the amount of overlap to `overlapSize`
+ * Checks if `sph` and `cyl` are touching, output the amount of xz overlap to `overlapSize`
*/
-s32 Math3D_SphVsCylOverlapDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize) {
+s32 Math3D_SphVsCylOverlap(Sphere16* sph, Cylinder16* cyl, f32* overlapSize) {
f32 centerDist;
return Math3D_SphVsCylOverlapCenterDist(sph, cyl, overlapSize, &centerDist);
@@ -1961,7 +1961,7 @@ s32 Math3D_SphVsCylOverlapDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize)
/**
* Checks if `sph` and `cyl` are touching, output the xz distance of the centers to `centerDist`, and the amount of
- * overlap to `overlapSize`
+ * xz overlap to `overlapSize`
*/
s32 Math3D_SphVsCylOverlapCenterDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize, f32* centerDist) {
static Cylinderf cylf;
@@ -2007,22 +2007,20 @@ s32 Math3D_SphVsCylOverlapCenterDist(Sphere16* sph, Cylinder16* cyl, f32* overla
return false;
}
-/*
- * returns 1 if cylinder `ca` is outside cylinder `cb`.
- * Sets `deadSpace` to the mininum space between the cylinders not occupied by the other.
+/**
+ * Checks if `ca` and `cb` are touching, output the amount of xz overlap to `overlapSize`
*/
-s32 Math3D_CylOutsideCyl(Cylinder16* ca, Cylinder16* cb, f32* deadSpace) {
+s32 Math3D_CylVsCylOverlap(Cylinder16* ca, Cylinder16* cb, f32* overlapSize) {
f32 xzDist;
- return Math3D_CylOutsideCylDist(ca, cb, deadSpace, &xzDist);
+ return Math3D_CylVsCylOverlapCenterDist(ca, cb, overlapSize, &xzDist);
}
-/*
- * returns 1 if cylinder `ca` is outside cylinder `cb`.
- * Sets `xzDist` to the xz distance between the centers of the cylinders.
- * Sets `deadSpace` to the minimum space between the cylinders not occupied by the other.
+/**
+ * Checks if `ca` and `cb` are touching, output the xz distance of the centers to `centerDist`, and the amount of
+ * xz overlap to `overlapSize`
*/
-s32 Math3D_CylOutsideCylDist(Cylinder16* ca, Cylinder16* cb, f32* deadSpace, f32* xzDist) {
+s32 Math3D_CylVsCylOverlapCenterDist(Cylinder16* ca, Cylinder16* cb, f32* overlapSize, f32* centerDist) {
static Cylinderf caf;
static Cylinderf cbf;
@@ -2036,10 +2034,10 @@ s32 Math3D_CylOutsideCylDist(Cylinder16* ca, Cylinder16* cb, f32* deadSpace, f32
cbf.yShift = cb->yShift;
cbf.height = cb->height;
- *xzDist = sqrtf(SQ(caf.pos.x - cbf.pos.x) + SQ(caf.pos.z - cbf.pos.z));
+ *centerDist = sqrtf(SQ(caf.pos.x - cbf.pos.x) + SQ(caf.pos.z - cbf.pos.z));
- // The combined radix are within the xz distance
- if ((caf.radius + cbf.radius) < *xzDist) {
+ // The combined radii are within the xz distance
+ if ((caf.radius + cbf.radius) < *centerDist) {
return false;
}
@@ -2049,7 +2047,7 @@ s32 Math3D_CylOutsideCylDist(Cylinder16* ca, Cylinder16* cb, f32* deadSpace, f32
return false;
}
- *deadSpace = caf.radius + cbf.radius - *xzDist;
+ *overlapSize = caf.radius + cbf.radius - *centerDist;
return true;
}