mirror of
https://github.com/zeldaret/mm.git
synced 2026-09-10 03:52:00 -04:00
Decompile and Document Camera z_play functions (#933)
* Document z_play camera functions * cleanup function names * PR Suggestion * Fix master merge, add comments * fix merge * small fix Co-authored-by: angie <angheloalf95@gmail.com>
This commit is contained in:
+17
-19
@@ -393,11 +393,7 @@ void func_800B4B50(Actor* actor, Lights* mapper, PlayState* play) {
|
||||
|
||||
void Actor_GetProjectedPos(PlayState* play, Vec3f* worldPos, Vec3f* projectedPos, f32* invW) {
|
||||
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, worldPos, projectedPos, invW);
|
||||
if (*invW < 1.0f) {
|
||||
*invW = 1.0f;
|
||||
} else {
|
||||
*invW = 1.0f / *invW;
|
||||
}
|
||||
*invW = (*invW < 1.0f) ? 1.0f : (1.0f / *invW);
|
||||
}
|
||||
|
||||
void Target_SetPos(TargetContext* targetCtx, s32 index, f32 x, f32 y, f32 z) {
|
||||
@@ -507,11 +503,11 @@ void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play) {
|
||||
|
||||
Actor_GetProjectedPos(play, &targetCtx->targetCenterPos, &projectedPos, &invW);
|
||||
|
||||
projectedPos.x = (160 * (projectedPos.x * invW)) * var1;
|
||||
projectedPos.x = CLAMP(projectedPos.x, -320.0f, 320.0f);
|
||||
projectedPos.x = ((SCREEN_WIDTH / 2) * (projectedPos.x * invW)) * var1;
|
||||
projectedPos.x = CLAMP(projectedPos.x, -SCREEN_WIDTH, SCREEN_WIDTH);
|
||||
|
||||
projectedPos.y = (120 * (projectedPos.y * invW)) * var1;
|
||||
projectedPos.y = CLAMP(projectedPos.y, -240.0f, 240.0f);
|
||||
projectedPos.y = ((SCREEN_HEIGHT / 2) * (projectedPos.y * invW)) * var1;
|
||||
projectedPos.y = CLAMP(projectedPos.y, -SCREEN_HEIGHT, SCREEN_HEIGHT);
|
||||
|
||||
projectedPos.z = projectedPos.z * var1;
|
||||
|
||||
@@ -588,8 +584,8 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS
|
||||
PlayState* play = (PlayState*)gameState;
|
||||
Actor* sp68 = NULL;
|
||||
s32 category;
|
||||
Vec3f sp58;
|
||||
f32 sp54;
|
||||
Vec3f projectedPos;
|
||||
f32 invW;
|
||||
|
||||
if ((player->unk_730 != 0) && (player->unk_AE3[player->unk_ADE] == 2)) {
|
||||
targetCtx->unk_94 = NULL;
|
||||
@@ -641,8 +637,9 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS
|
||||
}
|
||||
|
||||
if (actor != NULL && targetCtx->unk4B == 0) {
|
||||
Actor_GetProjectedPos(play, &actor->focus.pos, &sp58, &sp54);
|
||||
if ((sp58.z <= 0.0f) || (fabsf(sp58.x * sp54) >= 1.0f) || (fabsf(sp58.y * sp54) >= 1.0f)) {
|
||||
Actor_GetProjectedPos(play, &actor->focus.pos, &projectedPos, &invW);
|
||||
if ((projectedPos.z <= 0.0f) || (fabsf(projectedPos.x * invW) >= 1.0f) ||
|
||||
(fabsf(projectedPos.y * invW) >= 1.0f)) {
|
||||
actor = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1963,14 +1960,15 @@ s32 func_800B886C(Actor* actor, PlayState* play) {
|
||||
|
||||
void Actor_GetScreenPos(PlayState* play, Actor* actor, s16* x, s16* y) {
|
||||
Vec3f projectedPos;
|
||||
f32 w;
|
||||
f32 invW;
|
||||
|
||||
Actor_GetProjectedPos(play, &actor->focus.pos, &projectedPos, &w);
|
||||
*x = PROJECTED_TO_SCREEN_X(projectedPos, w);
|
||||
*y = PROJECTED_TO_SCREEN_Y(projectedPos, w);
|
||||
Actor_GetProjectedPos(play, &actor->focus.pos, &projectedPos, &invW);
|
||||
|
||||
*x = PROJECTED_TO_SCREEN_X(projectedPos, invW);
|
||||
*y = PROJECTED_TO_SCREEN_Y(projectedPos, invW);
|
||||
}
|
||||
|
||||
s32 func_800B8934(PlayState* play, Actor* actor) {
|
||||
s32 Actor_OnScreen(PlayState* play, Actor* actor) {
|
||||
Vec3f projectedPos;
|
||||
f32 invW;
|
||||
s32 pad[2];
|
||||
@@ -4058,7 +4056,7 @@ s32 func_800BD2B4(PlayState* play, Actor* actor, s16* arg2, f32 arg3, u16 (*text
|
||||
} else if (*arg2) {
|
||||
*arg2 = arg5(play, actor);
|
||||
return false;
|
||||
} else if (!func_800B8934(play, actor)) {
|
||||
} else if (!Actor_OnScreen(play, actor)) {
|
||||
return false;
|
||||
} else if (!func_800B8614(actor, play, arg3)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user