diff options
| author | cadmic <cadmic24@gmail.com> | 2023-10-07 16:42:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-07 19:42:28 -0400 |
| commit | b3486b57ef41a284a366eb40ca07bf82bf4750d6 (patch) | |
| tree | 80dd18b85d967d0ee6b043f4effa9ee1a881bd49 /src/code/sys_math3d.c | |
| parent | 181b4383937a18c95c4772c45a8f33b1b783fa1d (diff) | |
Rename Math3D_CylOutsideCyl and Math3D_CylOutsideCylDist (#1557)
* Rename Math3D_CylOutsideCyl and Math3D_CylOutsideCylDist
* radix -> radii
Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
* Make Math3D sphere/cylinder collision check function names more consistent
---------
Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
Diffstat (limited to 'src/code/sys_math3d.c')
| -rw-r--r-- | src/code/sys_math3d.c | 36 |
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, ¢erDist); + return Math3D_SphVsSphOverlapCenterDist(sphereA, sphereB, overlapSize, ¢erDist); } /* * 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, ¢erDist); @@ -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; } |
