1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 06:54:33 +00:00

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`
This commit is contained in:
Dragorn421 2022-02-20 14:31:31 +01:00 committed by GitHub
parent a9526a3354
commit e51fd73704
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 93 additions and 87 deletions

View file

@ -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);

View file

@ -4291,23 +4291,23 @@ s32 Camera_Subj4(Camera* camera) {
sCameraInterfaceFlags = subj4->interfaceFlags;
if (camera->animState == 0) {
spA4 = Camera_GetCamBgDataUnderPlayer(camera, &spAA);
Camera_Vec3sToVec3f(&anim->unk_00.a, &spA4[1]);
Camera_Vec3sToVec3f(&anim->unk_00.point, &spA4[1]);
Camera_Vec3sToVec3f(&sp98, &spA4[spAA - 2]);
sp64.r = 10.0f;
// 0x238C ~ 50 degrees
sp64.pitch = 0x238C;
sp64.yaw = Camera_XZAngle(&sp98, &anim->unk_00.a);
sp88 = OLib_Vec3fDist(&playerPosRot->pos, &anim->unk_00.a);
sp64.yaw = Camera_XZAngle(&sp98, &anim->unk_00.point);
sp88 = OLib_Vec3fDist(&playerPosRot->pos, &anim->unk_00.point);
if (OLib_Vec3fDist(&playerPosRot->pos, &sp98) < sp88) {
anim->unk_00.b.x = anim->unk_00.a.x - sp98.x;
anim->unk_00.b.y = anim->unk_00.a.y - sp98.y;
anim->unk_00.b.z = anim->unk_00.a.z - sp98.z;
anim->unk_00.a = sp98;
anim->unk_00.dir.x = anim->unk_00.point.x - sp98.x;
anim->unk_00.dir.y = anim->unk_00.point.y - sp98.y;
anim->unk_00.dir.z = anim->unk_00.point.z - sp98.z;
anim->unk_00.point = sp98;
} else {
anim->unk_00.b.x = sp98.x - anim->unk_00.a.x;
anim->unk_00.b.y = sp98.y - anim->unk_00.a.y;
anim->unk_00.b.z = sp98.z - anim->unk_00.a.z;
anim->unk_00.dir.x = sp98.x - anim->unk_00.point.x;
anim->unk_00.dir.y = sp98.y - anim->unk_00.point.y;
anim->unk_00.dir.z = sp98.z - anim->unk_00.point.z;
sp64.yaw = BINANG_ROT180(sp64.yaw);
}
anim->unk_30 = sp64.yaw;
@ -4340,9 +4340,9 @@ s32 Camera_Subj4(Camera* camera) {
Actor_GetWorldPosShapeRot(&sp6C, &camera->player->actor);
Math3D_LineClosestToPoint(&anim->unk_00, &sp6C.pos, eyeNext);
at->x = eyeNext->x + anim->unk_00.b.x;
at->y = eyeNext->y + anim->unk_00.b.y;
at->z = eyeNext->z + anim->unk_00.b.z;
at->x = eyeNext->x + anim->unk_00.dir.x;
at->y = eyeNext->y + anim->unk_00.dir.y;
at->z = eyeNext->z + anim->unk_00.dir.z;
*eye = *eyeNext;
sp64.yaw = anim->unk_30;
sp64.r = 5.0f;
@ -4792,9 +4792,9 @@ s32 Camera_Unique0(Camera* camera) {
func_80043B60(camera);
camera->unk_14C &= ~4;
sceneCamData = Camera_GetCamBGData(camera);
Camera_Vec3sToVec3f(&anim->sceneCamPosPlayerLine.a, &BGCAM_POS(sceneCamData));
Camera_Vec3sToVec3f(&anim->sceneCamPosPlayerLine.point, &BGCAM_POS(sceneCamData));
*eye = camera->eyeNext = anim->sceneCamPosPlayerLine.a;
*eye = camera->eyeNext = anim->sceneCamPosPlayerLine.point;
sceneCamRot = BGCAM_ROT(sceneCamData);
fov = BGCAM_FOV(sceneCamData);
if (fov != -1) {
@ -4807,7 +4807,7 @@ s32 Camera_Unique0(Camera* camera) {
atPlayerOffset.r = OLib_Vec3fDist(&playerPosWithOffset, eye);
atPlayerOffset.yaw = sceneCamRot.y;
atPlayerOffset.pitch = -sceneCamRot.x;
OLib_VecSphGeoToVec3f(&anim->sceneCamPosPlayerLine.b, &atPlayerOffset);
OLib_VecSphGeoToVec3f(&anim->sceneCamPosPlayerLine.dir, &atPlayerOffset);
Math3D_LineClosestToPoint(&anim->sceneCamPosPlayerLine, &playerPosRot->pos, &camera->at);
anim->initalPos = playerPosRot->pos;
camera->animState++;
@ -5814,12 +5814,14 @@ s32 Camera_Demo5(Camera* camera) {
f32 sp90;
VecSph playerTargetGeo;
VecSph eyePlayerGeo;
VecSph sp78;
s16 targetScreenPosX;
s16 targetScreenPosY;
s32 pad1;
PosRot playerhead;
PosRot targethead;
Player* player;
s16 sp4A;
s32 pad;
s32 framesDiff;
s32 temp_v0;
s16 t;
s32 pad2;
@ -5837,7 +5839,7 @@ s32 Camera_Demo5(Camera* camera) {
Actor_GetFocus(&camera->targetPosRot, camera->target);
OLib_Vec3fDiffToVecSphGeo(&playerTargetGeo, &camera->targetPosRot.pos, &camera->playerPosRot.pos);
D_8011D3AC = camera->target->category;
Actor_GetScreenPos(camera->globalCtx, camera->target, &sp78.yaw, &sp78.pitch);
Actor_GetScreenPos(camera->globalCtx, camera->target, &targetScreenPosX, &targetScreenPosY);
eyeTargetDist = OLib_Vec3fDist(&camera->targetPosRot.pos, &camera->eye);
OLib_Vec3fDiffToVecSphGeo(&eyePlayerGeo, &playerhead.pos, &camera->eyeNext);
sp4A = eyePlayerGeo.yaw - playerTargetGeo.yaw;
@ -5869,7 +5871,8 @@ s32 Camera_Demo5(Camera* camera) {
// distance between player and target is less than 30 units.
ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D79C;
ONEPOINT_CS_INFO(camera)->keyFrameCnt = ARRAY_COUNT(D_8011D79C);
if ((sp78.yaw < 0x15) || (sp78.yaw >= 0x12C) || (sp78.pitch < 0x29) || (sp78.pitch >= 0xC8)) {
if ((targetScreenPosX < 0x15) || (targetScreenPosX >= 0x12C) || (targetScreenPosY < 0x29) ||
(targetScreenPosY >= 0xC8)) {
D_8011D79C[0].actionFlags = 0x41;
D_8011D79C[0].atTargetInit.y = -30.0f;
D_8011D79C[0].atTargetInit.x = 0.0f;
@ -5901,7 +5904,8 @@ s32 Camera_Demo5(Camera* camera) {
// The distance between the camera's current position and the target is less than 700 units
// and the angle between the camera's position and the player, and the player to the target
// is less than ~76.9 degrees
if (sp78.yaw >= 0x15 && sp78.yaw < 0x12C && sp78.pitch >= 0x29 && sp78.pitch < 0xC8 && eyePlayerGeo.r > 30.0f) {
if (targetScreenPosX >= 0x15 && targetScreenPosX < 0x12C && targetScreenPosY >= 0x29 &&
targetScreenPosY < 0xC8 && eyePlayerGeo.r > 30.0f) {
D_8011D88C[0].timerInit = camera->timer;
ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D88C;
ONEPOINT_CS_INFO(camera)->keyFrameCnt = ARRAY_COUNT(D_8011D88C);
@ -5997,8 +6001,8 @@ s32 Camera_Demo5(Camera* camera) {
}
}
pad = sDemo5PrevSfxFrame - camera->globalCtx->state.frames;
if ((pad >= 0x33) || (pad < -0x32)) {
framesDiff = sDemo5PrevSfxFrame - camera->globalCtx->state.frames;
if ((framesDiff > 50) || (framesDiff < -50)) {
func_80078884(camera->data1);
}
@ -6012,11 +6016,11 @@ s32 Camera_Demo5(Camera* camera) {
} else {
sp4A = playerhead.rot.y - playerTargetGeo.yaw;
if (camera->target->category == ACTORCAT_PLAYER) {
pad = camera->globalCtx->state.frames - sDemo5PrevAction12Frame;
framesDiff = camera->globalCtx->state.frames - sDemo5PrevAction12Frame;
if (player->stateFlags1 & PLAYER_STATE1_11) {
// holding object over head.
func_8002DF54(camera->globalCtx, camera->target, 8);
} else if (ABS(pad) > 3000) {
} else if (ABS(framesDiff) > 3000) {
func_8002DF54(camera->globalCtx, camera->target, 12);
} else {
func_8002DF54(camera->globalCtx, camera->target, 69);

View file

@ -1,7 +1,7 @@
#include "global.h"
// unused
Gfx sCircleNullDList[] = {
Gfx sCircleEmptyDList[] = {
gsSPEndDisplayList(),
};

View file

@ -76,7 +76,7 @@ void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx) {
if (0) {}
i++; // abmient light is total number of lights + 1
i++; // ambient light is total number of lights + 1
gSPLight(POLY_OPA_DISP++, &lights->l.a, i);
gSPLight(POLY_XLU_DISP++, &lights->l.a, i);

View file

@ -182,6 +182,7 @@ s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd) {
return 0;
}
// Scene Command 0x00: Spawn List
void func_80098508(GlobalContext* globalCtx, SceneCmd* cmd) {
ActorEntry* linkEntry = globalCtx->linkActorEntry = (ActorEntry*)SEGMENTED_TO_VIRTUAL(cmd->spawnList.segment) +
globalCtx->setupEntranceList[globalCtx->curSpawn].spawn;