diff options
| author | Dragorn421 <Dragorn421@users.noreply.github.com> | 2022-02-20 14:31:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-20 08:31:31 -0500 |
| commit | e51fd737040352ab366a2bc531b60858f3b00aae (patch) | |
| tree | 041379e266d374e502979ce966ea7162af01e810 /src/code/sys_math3d.c | |
| parent | a9526a3354d7da16051e41e0b599927a202331a2 (diff) | |
Fix misc 7 (#1149)
* Fixup `Math3D_LineClosestToPoint`
* `gDodongosCavernBossLavaFloorTex` is 32x64
* Name empty-dlist-making functions `_EmptyDList`
* Fix typos
* transitionRate -> morphFrames
* Compare `xyzDistToPlayerSq` to squared values
* Fix hookshot target/post collision header names being swapped
* Fix description of `z_bg_mizu_movebg.c`
* Add scene command comment to `func_80098508` to match other scene command handlers
* Some fixup in `Camera_Demo5`
* `1` -> `ALLOCTYPE_ABSOLUTE` in comment on `ActorContext.absoluteSpace`
Diffstat (limited to 'src/code/sys_math3d.c')
| -rw-r--r-- | src/code/sys_math3d.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index d442b7c4a..d0b286c19 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -114,25 +114,27 @@ s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Ve * Determines the closest point on the line `line` to `pos`, by forming a line perpendicular from * `point` to `line` closest point is placed in `closestPoint` */ -void Math3D_LineClosestToPoint(Linef* line, Vec3f* pos, Vec3f* closestPoint) { - f32 dirVectorSize; +void Math3D_LineClosestToPoint(InfiniteLine* line, Vec3f* pos, Vec3f* closestPoint) { + f32 dirVectorLengthSq; f32 t; - dirVectorSize = Math3D_Vec3fMagnitudeSq(&line->b); - if (IS_ZERO(dirVectorSize)) { + dirVectorLengthSq = Math3D_Vec3fMagnitudeSq(&line->dir); + if (IS_ZERO(dirVectorLengthSq)) { osSyncPrintf(VT_COL(YELLOW, BLACK)); // "Math3D_lineVsPosSuisenCross(): No straight line length" osSyncPrintf("Math3D_lineVsPosSuisenCross():直線の長さがありません\n"); osSyncPrintf("cross = pos を返します。\n"); // "Returns cross = pos." osSyncPrintf(VT_RST); Math_Vec3f_Copy(closestPoint, pos); + //! @bug Missing early return } - t = (((pos->x - line->a.x) * line->b.x) + ((pos->y - line->a.y) * line->b.y) + ((pos->z - line->a.z) * line->b.z)) / - dirVectorSize; - closestPoint->x = (line->b.x * t) + line->a.x; - closestPoint->y = (line->b.y * t) + line->a.y; - closestPoint->z = (line->b.z * t) + line->a.z; + t = (((pos->x - line->point.x) * line->dir.x) + ((pos->y - line->point.y) * line->dir.y) + + ((pos->z - line->point.z) * line->dir.z)) / + dirVectorLengthSq; + closestPoint->x = (line->dir.x * t) + line->point.x; + closestPoint->y = (line->dir.y * t) + line->point.y; + closestPoint->z = (line->dir.z * t) + line->point.z; } void Math3D_FindPointOnPlaneIntersect(f32 planeAAxis1Norm, f32 planeAAxis2Norm, f32 planeBAxis1Norm, @@ -195,10 +197,10 @@ s32 Math3D_PlaneVsPlaneNewLine(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeA */ s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* point, Vec3f* closestPoint) { - static Linef planeIntersect; + static InfiniteLine planeIntersect; if (!Math3D_PlaneVsPlaneNewLine(planeAA, planeAB, planeAC, planeADist, planeBA, planeBB, planeBC, planeBDist, - (InfiniteLine*)&planeIntersect)) { + &planeIntersect)) { return false; } Math3D_LineClosestToPoint(&planeIntersect, point, closestPoint); |
