diff options
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/sys_math3d.c | 24 | ||||
| -rw-r--r-- | src/code/z_camera.c | 54 | ||||
| -rw-r--r-- | src/code/z_fbdemo_circle.c | 2 | ||||
| -rw-r--r-- | src/code/z_lights.c | 2 | ||||
| -rw-r--r-- | src/code/z_scene.c | 1 |
5 files changed, 45 insertions, 38 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); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 70dc59a70..ac4eac6fc 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -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); diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.c index 54b64d2ed..add4b9dbe 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.c @@ -1,7 +1,7 @@ #include "global.h" // unused -Gfx sCircleNullDList[] = { +Gfx sCircleEmptyDList[] = { gsSPEndDisplayList(), }; diff --git a/src/code/z_lights.c b/src/code/z_lights.c index f6cf5c7a8..584f7b3e1 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -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); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index e7d112806..7204dda46 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -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; |
