mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-27 07:07:09 +00:00
Document Camera BgCamData (#1232)
* Document bgCamData * More changes and cleanup * More docs * Clarify comments * PR Feedback, rename bgcheck functions * remove fallthrough cleanup (other pr that deals with that) * PR Suggestions * bug report * bgCamDataIndexBeforeUnderwater * PR/Discord Discussions * Missed some * sync function header args * Another suggestion * cleanup * Comments * Change bgCamData to s16 for now * PR suggestions * the * use "info" * Missed a suggestion * Discord Discussion * Revert bgCamFuncData to Vec3s * format
This commit is contained in:
parent
08c8126ba5
commit
849fdbf9ea
15 changed files with 384 additions and 330 deletions
|
@ -628,12 +628,12 @@ s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionP
|
|||
void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest);
|
||||
void func_800418D0(CollisionContext* colCtx, PlayState* play);
|
||||
void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys);
|
||||
u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u16 func_80041A4C(CollisionContext* colCtx, u32 camId, s32 bgId);
|
||||
u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId);
|
||||
Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u16 BgCheck_GetBgCamSettingImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId);
|
||||
u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u16 BgCheck_GetBgCamCount(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
Vec3s* BgCheck_GetBgCamFuncDataImpl(CollisionContext* colCtx, s32 bgCamIndex, s32 bgId);
|
||||
Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u32 func_80041D4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
u32 func_80041D70(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
|
||||
|
@ -662,8 +662,8 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos,
|
|||
WaterBox** outWaterBox);
|
||||
s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
|
||||
WaterBox** outWaterBox);
|
||||
u32 WaterBox_GetCamDataIndex(CollisionContext* colCtx, WaterBox* waterBox);
|
||||
u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox);
|
||||
u32 WaterBox_GetBgCamIndex(CollisionContext* colCtx, WaterBox* waterBox);
|
||||
u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox);
|
||||
u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox);
|
||||
s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* point, Vec3f* closestPoint);
|
||||
s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint);
|
||||
|
@ -690,7 +690,7 @@ void Camera_Finish(Camera* camera);
|
|||
s32 Camera_ChangeMode(Camera* camera, s16 mode);
|
||||
s32 Camera_CheckValidMode(Camera* camera, s16 mode);
|
||||
s32 Camera_ChangeSetting(Camera* camera, s16 setting);
|
||||
s32 Camera_ChangeDataIdx(Camera* camera, s32 camDataIdx);
|
||||
s32 Camera_ChangeBgCamIndex(Camera* camera, s32 bgCamIndex);
|
||||
s16 Camera_GetInputDirYaw(Camera* camera);
|
||||
Vec3s* Camera_GetCamDir(Vec3s* dst, Camera* camera);
|
||||
s16 Camera_GetCamDirPitch(Camera* camera);
|
||||
|
@ -703,7 +703,7 @@ s16 func_8005AD1C(Camera* camera, s16 arg1);
|
|||
s32 Camera_ResetAnim(Camera* camera);
|
||||
s32 Camera_SetCSParams(Camera* camera, CutsceneCameraPoint* atPoints, CutsceneCameraPoint* eyePoints, Player* player,
|
||||
s16 relativeToPlayer);
|
||||
s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 camDataIdx, f32 arg3, s16 timer1, s16 timer2,
|
||||
s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2,
|
||||
s16 timer3);
|
||||
s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera);
|
||||
Vec3f* Camera_GetSkyboxOffset(Vec3f* dst, Camera* camera);
|
||||
|
|
|
@ -52,10 +52,26 @@ typedef struct {
|
|||
} CollisionPoly; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u16 cameraSType;
|
||||
/* 0x02 */ s16 numCameras;
|
||||
/* 0x04 */ Vec3s* camPosData;
|
||||
} CamData;
|
||||
/* 0x0 */ u16 setting; // camera setting described by CameraSettingType enum
|
||||
/* 0x2 */ s16 count; // only used when `bgCamFuncData` is a list of points used for crawlspaces
|
||||
/* 0x4 */ Vec3s* bgCamFuncData; // s16 data grouped in threes (ex. Vec3s), is usually of type `BgCamFuncData`, but can be a list of points of type `Vec3s` for crawlspaces
|
||||
} BgCamInfo; // size = 0x8
|
||||
|
||||
typedef BgCamInfo CamData; // Todo: Zapd compatibility
|
||||
|
||||
// The structure used for all instances of s16 data from `BgCamInfo` with the exception of crawlspaces.
|
||||
// See `Camera_Subj4` for Vec3s data usage in crawlspaces
|
||||
typedef struct {
|
||||
/* 0x00 */ Vec3s pos;
|
||||
/* 0x06 */ Vec3s rot;
|
||||
/* 0x0C */ s16 fov;
|
||||
/* 0x0E */ union {
|
||||
s16 jfifId;
|
||||
s16 timer;
|
||||
s16 flags;
|
||||
};
|
||||
/* 0x10 */ s16 unk_10; // unused
|
||||
} BgCamFuncData; // size = 0x12
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 xMin;
|
||||
|
@ -68,7 +84,7 @@ typedef struct {
|
|||
// 0x0008_0000 = ?
|
||||
// 0x0007_E000 = Room Index, 0x3F = all rooms
|
||||
// 0x0000_1F00 = Lighting Settings Index
|
||||
// 0x0000_00FF = CamData index
|
||||
// 0x0000_00FF = BgCam Index
|
||||
} WaterBox; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
|
@ -86,7 +102,7 @@ typedef struct {
|
|||
/* 0x14 */ u16 numPolygons;
|
||||
/* 0x18 */ CollisionPoly* polyList;
|
||||
/* 0x1C */ SurfaceType* surfaceTypeList;
|
||||
/* 0x20 */ CamData* cameraDataList;
|
||||
/* 0x20 */ BgCamInfo* bgCamList;
|
||||
/* 0x24 */ u16 numWaterBoxes;
|
||||
/* 0x28 */ WaterBox* waterBoxes;
|
||||
} CollisionHeader; // original name: BGDataInfo
|
||||
|
|
|
@ -906,7 +906,7 @@ typedef struct {
|
|||
/* 0x00 */ PosRot eyePosRot;
|
||||
/* 0x14 */ char unk_14[0x8];
|
||||
/* 0x1C */ s16 fov;
|
||||
/* 0x1E */ s16 jfifId;
|
||||
/* 0x1E */ s16 flags;
|
||||
} Data4ReadWriteData; // size = 0x20
|
||||
|
||||
typedef struct {
|
||||
|
@ -976,7 +976,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
/* 0x0 */ struct Actor* doorActor;
|
||||
/* 0x4 */ s16 camDataIdx;
|
||||
/* 0x4 */ s16 bgCamIndex;
|
||||
/* 0x6 */ s16 timer1;
|
||||
/* 0x8 */ s16 timer2;
|
||||
/* 0xA */ s16 timer3;
|
||||
|
@ -1010,7 +1010,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
/* 0x00 */ Vec3f initalPos;
|
||||
/* 0x0C */ s16 animTimer;
|
||||
/* 0x10 */ InfiniteLine sceneCamPosPlayerLine;
|
||||
/* 0x10 */ InfiniteLine eyeAndDirection;
|
||||
} Unique0ReadWriteData; // size = 0x28
|
||||
|
||||
typedef struct {
|
||||
|
@ -1363,8 +1363,8 @@ typedef struct {
|
|||
/* 0x104 */ f32 playerGroundY;
|
||||
/* 0x108 */ Vec3f floorNorm;
|
||||
/* 0x114 */ f32 waterYPos;
|
||||
/* 0x118 */ s32 waterPrevCamIdx;
|
||||
/* 0x11C */ s32 waterPrevCamSetting;
|
||||
/* 0x118 */ s32 bgCamIndexBeforeUnderwater;
|
||||
/* 0x11C */ s32 waterCamSetting;
|
||||
/* 0x120 */ s32 waterQuakeId;
|
||||
/* 0x124 */ void* data0;
|
||||
/* 0x128 */ void* data1;
|
||||
|
@ -1377,23 +1377,23 @@ typedef struct {
|
|||
/* 0x140 */ s16 status;
|
||||
/* 0x142 */ s16 setting;
|
||||
/* 0x144 */ s16 mode;
|
||||
/* 0x146 */ s16 bgCheckId;
|
||||
/* 0x148 */ s16 camDataIdx;
|
||||
/* 0x146 */ s16 bgId; // bgId the camera is currently interacting with
|
||||
/* 0x148 */ s16 bgCamIndex;
|
||||
/* 0x14A */ s16 unk_14A;
|
||||
/* 0x14C */ s16 unk_14C;
|
||||
/* 0x14E */ s16 childCamId;
|
||||
/* 0x150 */ s16 waterDistortionTimer;
|
||||
/* 0x152 */ s16 distortionFlags;
|
||||
/* 0x154 */ s16 prevSetting;
|
||||
/* 0x156 */ s16 nextCamDataIdx;
|
||||
/* 0x158 */ s16 nextBGCheckId;
|
||||
/* 0x156 */ s16 nextBgCamIndex;
|
||||
/* 0x158 */ s16 nextBgId;
|
||||
/* 0x15A */ s16 roll;
|
||||
/* 0x15C */ s16 paramFlags;
|
||||
/* 0x15E */ s16 animState;
|
||||
/* 0x160 */ s16 timer;
|
||||
/* 0x162 */ s16 parentCamId;
|
||||
/* 0x164 */ s16 camId;
|
||||
/* 0x166 */ s16 prevCamDataIdx;
|
||||
/* 0x166 */ s16 prevBgCamIndex;
|
||||
/* 0x168 */ s16 csId;
|
||||
/* 0x16A */ s16 unk_16A;
|
||||
} Camera; // size = 0x16C
|
||||
|
|
|
@ -521,7 +521,7 @@ typedef struct Player {
|
|||
/* 0x0450 */ Vec3f unk_450;
|
||||
/* 0x045C */ Vec3f unk_45C;
|
||||
/* 0x0468 */ char unk_468[0x002];
|
||||
/* 0x046A */ s16 unk_46A;
|
||||
/* 0x046A */ s16 doorBgCamIndex;
|
||||
/* 0x046C */ s16 subCamId;
|
||||
/* 0x046E */ char unk_46E[0x02A];
|
||||
/* 0x0498 */ ColliderCylinder cylinder;
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
struct {
|
||||
s8 room; // Room to switch to
|
||||
s8 effects; // How the camera reacts during the transition
|
||||
s8 bgCamIndex; // How the camera reacts during the transition. See `Camera_ChangeDoorCam`
|
||||
} /* 0x00 */ sides[2]; // 0 = front, 1 = back
|
||||
/* 0x04 */ s16 id;
|
||||
/* 0x06 */ Vec3s pos;
|
||||
|
|
|
@ -1032,7 +1032,7 @@ s32 func_8002DF38(PlayState* play, Actor* actor, u8 csMode) {
|
|||
|
||||
player->csMode = csMode;
|
||||
player->unk_448 = actor;
|
||||
player->unk_46A = 0;
|
||||
player->doorBgCamIndex = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1041,7 +1041,7 @@ s32 func_8002DF54(PlayState* play, Actor* actor, u8 csMode) {
|
|||
Player* player = GET_PLAYER(play);
|
||||
|
||||
func_8002DF38(play, actor, csMode);
|
||||
player->unk_46A = 1;
|
||||
player->doorBgCamIndex = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3770,7 +3770,7 @@ void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader) {
|
|||
colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList);
|
||||
colHeader->polyList = SEGMENTED_TO_VIRTUAL(colHeader->polyList);
|
||||
colHeader->surfaceTypeList = SEGMENTED_TO_VIRTUAL(colHeader->surfaceTypeList);
|
||||
colHeader->cameraDataList = SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList);
|
||||
colHeader->bgCamList = SEGMENTED_TO_VIRTUAL(colHeader->bgCamList);
|
||||
colHeader->waterBoxes = SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes);
|
||||
}
|
||||
|
||||
|
@ -3821,137 +3821,152 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId,
|
|||
if (colHeader == NULL || poly == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
surfaceTypes = colHeader->surfaceTypeList;
|
||||
if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return surfaceTypes[poly->type].data[dataIdx];
|
||||
}
|
||||
|
||||
/**
|
||||
* SurfaceType return CamData Index
|
||||
* SurfaceType get index of bgCam
|
||||
*/
|
||||
u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
|
||||
u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
return SurfaceType_GetData(colCtx, poly, bgId, 0) & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* CamData return cameraSType
|
||||
* BgCam get setting of bgCam
|
||||
*/
|
||||
u16 func_80041A4C(CollisionContext* colCtx, u32 camId, s32 bgId) {
|
||||
u16 result;
|
||||
u16 BgCheck_GetBgCamSettingImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId) {
|
||||
u16 camSetting;
|
||||
CollisionHeader* colHeader;
|
||||
CamData* camData;
|
||||
BgCamInfo* bgCamList;
|
||||
|
||||
colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
if (colHeader == NULL) {
|
||||
return 0;
|
||||
return CAM_SET_NONE;
|
||||
}
|
||||
camData = colHeader->cameraDataList;
|
||||
result = camData[camId].cameraSType;
|
||||
return result;
|
||||
|
||||
bgCamList = colHeader->bgCamList;
|
||||
camSetting = bgCamList[bgCamIndex].setting;
|
||||
|
||||
return camSetting;
|
||||
}
|
||||
|
||||
/**
|
||||
* SurfaceType return cameraSType
|
||||
* BgCam Get the camera setting of bgCam
|
||||
*/
|
||||
u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
CamData* camData;
|
||||
BgCamInfo* bgCamList;
|
||||
SurfaceType* surfaceTypes;
|
||||
|
||||
if (colHeader == NULL) {
|
||||
return CAM_SET_NONE;
|
||||
}
|
||||
|
||||
bgCamList = colHeader->bgCamList;
|
||||
if (bgCamList == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return CAM_SET_NONE;
|
||||
}
|
||||
|
||||
surfaceTypes = colHeader->surfaceTypeList;
|
||||
if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return CAM_SET_NONE;
|
||||
}
|
||||
|
||||
return BgCheck_GetBgCamSettingImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* BgCam Get the total count of Vec3s data from bgCamFuncData
|
||||
*/
|
||||
u16 BgCheck_GetBgCamCountImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId) {
|
||||
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
BgCamInfo* bgCamList;
|
||||
|
||||
if (colHeader == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgCamList = colHeader->bgCamList;
|
||||
if (bgCamList == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bgCamList[bgCamIndex].count;
|
||||
}
|
||||
|
||||
/**
|
||||
* BgCam Get the total count of Vec3s data from bgCamFuncData
|
||||
*/
|
||||
u16 BgCheck_GetBgCamCount(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
BgCamInfo* bgCamList;
|
||||
SurfaceType* surfaceTypes;
|
||||
|
||||
if (colHeader == NULL) {
|
||||
return 0;
|
||||
}
|
||||
camData = colHeader->cameraDataList;
|
||||
if (camData == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
|
||||
bgCamList = colHeader->bgCamList;
|
||||
if (bgCamList == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
surfaceTypes = colHeader->surfaceTypeList;
|
||||
if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
}
|
||||
return func_80041A4C(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId);
|
||||
|
||||
return BgCheck_GetBgCamCountImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* CamData Get number of cameras
|
||||
* BgCam Get Vec3s data from bgCamFuncData
|
||||
*/
|
||||
u16 func_80041B24(CollisionContext* colCtx, u32 camId, s32 bgId) {
|
||||
Vec3s* BgCheck_GetBgCamFuncDataImpl(CollisionContext* colCtx, s32 bgCamIndex, s32 bgId) {
|
||||
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
CamData* camData;
|
||||
|
||||
if (colHeader == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
camData = colHeader->cameraDataList;
|
||||
if (camData == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
}
|
||||
return camData[camId].numCameras;
|
||||
}
|
||||
|
||||
/**
|
||||
* SurfaceType Get number of cameras
|
||||
*/
|
||||
u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
CamData* camData;
|
||||
SurfaceType* surfaceTypes;
|
||||
|
||||
if (colHeader == NULL) {
|
||||
return 0;
|
||||
}
|
||||
camData = colHeader->cameraDataList;
|
||||
if (camData == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
}
|
||||
surfaceTypes = colHeader->surfaceTypeList;
|
||||
if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
}
|
||||
return func_80041B24(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* CamData Get camPosData
|
||||
*/
|
||||
Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId) {
|
||||
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
CamData* cameraDataList;
|
||||
BgCamInfo* bgCamList;
|
||||
|
||||
if (colHeader == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
cameraDataList = colHeader->cameraDataList;
|
||||
if (cameraDataList == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
|
||||
bgCamList = colHeader->bgCamList;
|
||||
if (bgCamList == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
return (Vec3s*)SEGMENTED_TO_VIRTUAL(cameraDataList[camId].camPosData);
|
||||
|
||||
return (Vec3s*)SEGMENTED_TO_VIRTUAL(bgCamList[bgCamIndex].bgCamFuncData);
|
||||
}
|
||||
|
||||
/**
|
||||
* SurfaceType Get camPosData
|
||||
* BgCam Get Vec3s data from bgCamFuncData
|
||||
*/
|
||||
Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
|
||||
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
|
||||
CamData* camData;
|
||||
BgCamInfo* bgCamList;
|
||||
SurfaceType* surfaceTypes;
|
||||
|
||||
if (colHeader == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
camData = colHeader->cameraDataList;
|
||||
if (camData == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
|
||||
bgCamList = colHeader->bgCamList;
|
||||
if (bgCamList == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surfaceTypes = colHeader->surfaceTypeList;
|
||||
if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
return func_80041C10(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId);
|
||||
|
||||
return BgCheck_GetBgCamFuncDataImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4263,26 +4278,26 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos,
|
|||
}
|
||||
|
||||
/**
|
||||
* WaterBox get CamData index
|
||||
* WaterBox get BgCam index
|
||||
*/
|
||||
u32 WaterBox_GetCamDataIndex(CollisionContext* colCtx, WaterBox* waterBox) {
|
||||
u32 WaterBox_GetBgCamIndex(CollisionContext* colCtx, WaterBox* waterBox) {
|
||||
u32 prop = waterBox->properties >> 0;
|
||||
|
||||
return prop & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* WaterBox get CamData cameraSType
|
||||
* WaterBox get BgCam setting
|
||||
*/
|
||||
u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox) {
|
||||
s32 camId = WaterBox_GetCamDataIndex(colCtx, waterBox);
|
||||
CamData* camData = colCtx->colHeader->cameraDataList;
|
||||
u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox) {
|
||||
s32 bgCamIndex = WaterBox_GetBgCamIndex(colCtx, waterBox);
|
||||
BgCamInfo* bgCamList = colCtx->colHeader->bgCamList;
|
||||
|
||||
if (camData == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return 0;
|
||||
if (bgCamList == SEGMENTED_TO_VIRTUAL(NULL)) {
|
||||
return CAM_SET_NONE;
|
||||
}
|
||||
|
||||
return colCtx->colHeader->cameraDataList[camId].cameraSType;
|
||||
return colCtx->colHeader->bgCamList[bgCamIndex].setting;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,11 +24,6 @@ s32 Camera_UpdateWater(Camera* camera);
|
|||
// Load the next value and scale down from camera read-only data stored in CameraModeValue
|
||||
#define GET_NEXT_SCALED_RO_DATA(values) CAM_DATA_SCALED(GET_NEXT_RO_DATA(values))
|
||||
|
||||
#define BGCAM_POS(v) ((v)[0])
|
||||
#define BGCAM_ROT(v) ((v)[1])
|
||||
#define BGCAM_FOV(v) ((v)[2].x)
|
||||
#define BGCAM_JFIFID(v) ((v)[2].y)
|
||||
|
||||
#define FLG_ADJSLOPE (1 << 0)
|
||||
#define FLG_OFFGROUND (1 << 7)
|
||||
|
||||
|
@ -327,7 +322,7 @@ s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) {
|
|||
// line is from->to is touching the poly the player is on.
|
||||
to->norm = playerFloorNormF;
|
||||
to->poly = playerFloorPoly;
|
||||
to->bgId = camera->bgCheckId;
|
||||
to->bgId = camera->bgId;
|
||||
to->pos.x = to->norm.x + toNewPos.x;
|
||||
to->pos.y = to->norm.y + toNewPos.y;
|
||||
to->pos.z = to->norm.z + toNewPos.z;
|
||||
|
@ -450,45 +445,45 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the CameraSettingType of the camera at index `camDataIdx`
|
||||
* Returns the CameraSettingType of the camera at index `bgCamIndex`
|
||||
*/
|
||||
s16 Camera_GetCamDataSetting(Camera* camera, s32 camDataIdx) {
|
||||
return func_80041A4C(&camera->play->colCtx, camDataIdx, BGCHECK_SCENE);
|
||||
s16 Camera_GetBgCamSetting(Camera* camera, s32 bgCamIndex) {
|
||||
return BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, bgCamIndex, BGCHECK_SCENE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scene camera info for the current camera data index
|
||||
* Returns the bgCamFuncData using the current bgCam index
|
||||
*/
|
||||
Vec3s* Camera_GetCamBGData(Camera* camera) {
|
||||
return func_80041C10(&camera->play->colCtx, camera->camDataIdx, BGCHECK_SCENE);
|
||||
Vec3s* Camera_GetBgCamFuncData(Camera* camera) {
|
||||
return BgCheck_GetBgCamFuncDataImpl(&camera->play->colCtx, camera->bgCamIndex, BGCHECK_SCENE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scene's camera index for the poly `poly`, returns -1 if
|
||||
* Gets the bgCam index for the poly `poly`, returns -1 if
|
||||
* there is no camera data for that poly.
|
||||
*/
|
||||
s32 Camera_GetDataIdxForPoly(Camera* camera, s32* bgId, CollisionPoly* poly) {
|
||||
s32 camDataIdx;
|
||||
s32 Camera_GetBgCamIndex(Camera* camera, s32* bgId, CollisionPoly* poly) {
|
||||
s32 bgCamIndex;
|
||||
PosRot playerPosRot;
|
||||
s32 ret;
|
||||
|
||||
Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); // unused.
|
||||
camDataIdx = SurfaceType_GetCamDataIndex(&camera->play->colCtx, poly, *bgId);
|
||||
bgCamIndex = SurfaceType_GetBgCamIndex(&camera->play->colCtx, poly, *bgId);
|
||||
|
||||
if (func_80041A4C(&camera->play->colCtx, camDataIdx, *bgId) == CAM_SET_NONE) {
|
||||
if (BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, bgCamIndex, *bgId) == CAM_SET_NONE) {
|
||||
ret = -1;
|
||||
} else {
|
||||
ret = camDataIdx;
|
||||
ret = bgCamIndex;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scene camera info for the floor under the player.
|
||||
* If there is no floor then there is no camera data, returns the number of
|
||||
* pieces of data there are in `dataCnt`
|
||||
* Returns the bgCamFuncData for the floor under the player.
|
||||
* Also returns the number of pieces of data there are in `bgCamCount`.
|
||||
* If there is no floor, then return NULL
|
||||
*/
|
||||
Vec3s* Camera_GetCamBgDataUnderPlayer(Camera* camera, u16* dataCnt) {
|
||||
Vec3s* Camera_GetBgCamFuncDataUnderPlayer(Camera* camera, u16* bgCamCount) {
|
||||
CollisionPoly* floorPoly;
|
||||
s32 pad;
|
||||
s32 bgId;
|
||||
|
@ -496,12 +491,14 @@ Vec3s* Camera_GetCamBgDataUnderPlayer(Camera* camera, u16* dataCnt) {
|
|||
|
||||
Actor_GetWorldPosShapeRot(&playerPosShape, &camera->player->actor);
|
||||
playerPosShape.pos.y += Player_GetHeight(camera->player);
|
||||
|
||||
if (BgCheck_EntityRaycastFloor3(&camera->play->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == BGCHECK_Y_MIN) {
|
||||
// no floor
|
||||
return NULL;
|
||||
}
|
||||
*dataCnt = SurfaceType_GetNumCameras(&camera->play->colCtx, floorPoly, bgId);
|
||||
return SurfaceType_GetCamPosData(&camera->play->colCtx, floorPoly, bgId);
|
||||
|
||||
*bgCamCount = BgCheck_GetBgCamCount(&camera->play->colCtx, floorPoly, bgId);
|
||||
return BgCheck_GetBgCamFuncData(&camera->play->colCtx, floorPoly, bgId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -510,10 +507,10 @@ Vec3s* Camera_GetCamBgDataUnderPlayer(Camera* camera, u16* dataCnt) {
|
|||
* Returns -2 if there is no camera index for the water box.
|
||||
* Returns the camera data index otherwise.
|
||||
*/
|
||||
s32 Camera_GetWaterBoxDataIdx(Camera* camera, f32* waterY) {
|
||||
s32 Camera_GetWaterBoxBgCamIndex(Camera* camera, f32* waterY) {
|
||||
PosRot playerPosShape;
|
||||
WaterBox* waterBox;
|
||||
s32 ret;
|
||||
s32 bgCamIndex;
|
||||
|
||||
Actor_GetWorldPosShapeRot(&playerPosShape, &camera->player->actor);
|
||||
*waterY = playerPosShape.pos.y;
|
||||
|
@ -531,13 +528,15 @@ s32 Camera_GetWaterBoxDataIdx(Camera* camera, f32* waterY) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
ret = WaterBox_GetCamDataIndex(&camera->play->colCtx, waterBox);
|
||||
if ((ret <= 0) || (WaterBox_GetCameraSType(&camera->play->colCtx, waterBox) <= 0)) {
|
||||
bgCamIndex = WaterBox_GetBgCamIndex(&camera->play->colCtx, waterBox);
|
||||
|
||||
//! @bug bgCamIndex = 0 is a valid index, should be (bgCamIndex < 0)
|
||||
if ((bgCamIndex <= 0) || (WaterBox_GetBgCamSetting(&camera->play->colCtx, waterBox) <= CAM_SET_NONE)) {
|
||||
// no camera data index, or no CameraSettingType
|
||||
return -2;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return bgCamIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1673,7 +1672,7 @@ s32 Camera_Normal2(Camera* camera) {
|
|||
Normal2ReadOnlyData* roData = &camera->paramData.norm2.roData;
|
||||
Normal2ReadWriteData* rwData = &camera->paramData.norm2.rwData;
|
||||
s32 pad;
|
||||
Vec3s* bgData;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
f32 playerHeight;
|
||||
f32 yNormal;
|
||||
|
||||
|
@ -1710,16 +1709,16 @@ s32 Camera_Normal2(Camera* camera) {
|
|||
case 10:
|
||||
case 20:
|
||||
case 25:
|
||||
bgData = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->unk_00, &BGCAM_POS(bgData));
|
||||
rwData->unk_20 = BGCAM_ROT(bgData).x;
|
||||
rwData->unk_22 = BGCAM_ROT(bgData).y;
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->unk_00, &bgCamFuncData->pos);
|
||||
rwData->unk_20 = bgCamFuncData->rot.x;
|
||||
rwData->unk_22 = bgCamFuncData->rot.y;
|
||||
rwData->unk_24 = playerPosRot->pos.y;
|
||||
rwData->unk_1C = BGCAM_FOV(bgData) == -1 ? roData->unk_14
|
||||
: BGCAM_FOV(bgData) >= 0x169 ? CAM_DATA_SCALED(BGCAM_FOV(bgData))
|
||||
: BGCAM_FOV(bgData);
|
||||
rwData->unk_1C = bgCamFuncData->fov == -1 ? roData->unk_14
|
||||
: bgCamFuncData->fov > 360 ? CAM_DATA_SCALED(bgCamFuncData->fov)
|
||||
: bgCamFuncData->fov;
|
||||
|
||||
rwData->unk_28 = BGCAM_JFIFID(bgData) == -1 ? 0 : BGCAM_JFIFID(bgData);
|
||||
rwData->unk_28 = bgCamFuncData->flags == -1 ? 0 : bgCamFuncData->flags;
|
||||
|
||||
rwData->unk_18 = 0.0f;
|
||||
|
||||
|
@ -3770,11 +3769,11 @@ s32 Camera_KeepOn4(Camera* camera) {
|
|||
sCameraInterfaceFlags = 0;
|
||||
camera->unk_14C |= (0x4 | 0x2);
|
||||
camera->unk_14C &= ~8;
|
||||
if (camera->prevCamDataIdx < 0) {
|
||||
if (camera->prevBgCamIndex < 0) {
|
||||
Camera_ChangeSettingFlags(camera, camera->prevSetting, 2);
|
||||
} else {
|
||||
Camera_ChangeDataIdx(camera, camera->prevCamDataIdx);
|
||||
camera->prevCamDataIdx = -1;
|
||||
Camera_ChangeBgCamIndex(camera, camera->prevBgCamIndex);
|
||||
camera->prevBgCamIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3799,8 +3798,8 @@ s32 Camera_KeepOn0(Camera* camera) {
|
|||
KeepOn0ReadOnlyData* roData = &camera->paramData.keep0.roData;
|
||||
KeepOn0ReadWriteData* rwData = &camera->paramData.keep0.rwData;
|
||||
s32 pad;
|
||||
Vec3s* sceneCamData;
|
||||
UNUSED Vec3s sceneCamRot;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
UNUSED Vec3s bgCamRot;
|
||||
s16 fov;
|
||||
|
||||
camera->unk_14C &= ~0x10;
|
||||
|
@ -3816,13 +3815,14 @@ s32 Camera_KeepOn0(Camera* camera) {
|
|||
if (R_RELOAD_CAM_PARAMS) {
|
||||
Camera_CopyPREGToModeValues(camera);
|
||||
}
|
||||
sceneCamData = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(eyeNext, &BGCAM_POS(sceneCamData));
|
||||
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos);
|
||||
*eye = *eyeNext;
|
||||
|
||||
sceneCamRot = BGCAM_ROT(sceneCamData);
|
||||
bgCamRot = bgCamFuncData->rot;
|
||||
|
||||
fov = BGCAM_FOV(sceneCamData);
|
||||
fov = bgCamFuncData->fov;
|
||||
if (fov == -1) {
|
||||
fov = 6000;
|
||||
}
|
||||
|
@ -3872,7 +3872,7 @@ s32 Camera_Fixed1(Camera* camera) {
|
|||
VecSph eyeAtOffset;
|
||||
s32 pad2;
|
||||
Vec3f adjustedPos;
|
||||
Vec3s* scenePosData;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
Vec3f* eye = &camera->eye;
|
||||
Vec3f* at = &camera->at;
|
||||
PosRot* playerPosRot = &camera->playerPosRot;
|
||||
|
@ -3882,10 +3882,11 @@ s32 Camera_Fixed1(Camera* camera) {
|
|||
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
|
||||
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
|
||||
|
||||
scenePosData = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->eyePosRotTarget.pos, &BGCAM_POS(scenePosData));
|
||||
rwData->eyePosRotTarget.rot = BGCAM_ROT(scenePosData);
|
||||
rwData->fov = BGCAM_FOV(scenePosData);
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->eyePosRotTarget.pos, &bgCamFuncData->pos);
|
||||
rwData->eyePosRotTarget.rot = bgCamFuncData->rot;
|
||||
rwData->fov = bgCamFuncData->fov;
|
||||
|
||||
roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight;
|
||||
roData->lerpStep = GET_NEXT_SCALED_RO_DATA(values);
|
||||
roData->fov = GET_NEXT_RO_DATA(values);
|
||||
|
@ -3944,7 +3945,7 @@ s32 Camera_Fixed2(Camera* camera) {
|
|||
Vec3f atTarget;
|
||||
Vec3f posOffsetTarget;
|
||||
PosRot* playerPosRot = &camera->playerPosRot;
|
||||
Vec3s* scenePosData;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
Fixed2ReadOnlyData* roData = &camera->paramData.fixd2.roData;
|
||||
Fixed2ReadWriteData* rwData = &camera->paramData.fixd2.rwData;
|
||||
s32 pad;
|
||||
|
@ -3963,11 +3964,12 @@ s32 Camera_Fixed2(Camera* camera) {
|
|||
roData->fov = GET_NEXT_RO_DATA(values);
|
||||
roData->interfaceFlags = GET_NEXT_RO_DATA(values);
|
||||
rwData->fov = roData->fov * 100.0f;
|
||||
scenePosData = Camera_GetCamBGData(camera);
|
||||
if (scenePosData != NULL) {
|
||||
Camera_Vec3sToVec3f(&rwData->eye, &BGCAM_POS(scenePosData));
|
||||
if (BGCAM_FOV(scenePosData) != -1) {
|
||||
rwData->fov = BGCAM_FOV(scenePosData);
|
||||
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
if (bgCamFuncData != NULL) {
|
||||
Camera_Vec3sToVec3f(&rwData->eye, &bgCamFuncData->pos);
|
||||
if (bgCamFuncData->fov != -1) {
|
||||
rwData->fov = bgCamFuncData->fov;
|
||||
}
|
||||
} else {
|
||||
rwData->eye = *eye;
|
||||
|
@ -4023,13 +4025,13 @@ s32 Camera_Fixed3(Camera* camera) {
|
|||
Vec3f* at = &camera->at;
|
||||
Vec3f* eyeNext = &camera->eyeNext;
|
||||
VecSph atSph;
|
||||
Vec3s* sceneCamData;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
VecSph eyeAtOffset;
|
||||
Fixed3ReadOnlyData* roData = &camera->paramData.fixd3.roData;
|
||||
Fixed3ReadWriteData* rwData = &camera->paramData.fixd3.rwData;
|
||||
s32 pad;
|
||||
|
||||
sceneCamData = Camera_GetCamBGData(camera);
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
|
||||
OLib_Vec3fDiffToVecSphGeo(&eyeAtOffset, eye, at);
|
||||
|
||||
|
@ -4037,11 +4039,11 @@ s32 Camera_Fixed3(Camera* camera) {
|
|||
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
|
||||
|
||||
roData->interfaceFlags = GET_NEXT_RO_DATA(values);
|
||||
Camera_Vec3sToVec3f(eyeNext, &BGCAM_POS(sceneCamData));
|
||||
Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos);
|
||||
*eye = *eyeNext;
|
||||
rwData->rot = BGCAM_ROT(sceneCamData);
|
||||
rwData->fov = BGCAM_FOV(sceneCamData);
|
||||
rwData->jfifId = BGCAM_JFIFID(sceneCamData);
|
||||
rwData->rot = bgCamFuncData->rot;
|
||||
rwData->fov = bgCamFuncData->fov;
|
||||
rwData->jfifId = bgCamFuncData->jfifId;
|
||||
if (rwData->fov == -1) {
|
||||
rwData->fov = 6000;
|
||||
}
|
||||
|
@ -4060,9 +4062,9 @@ s32 Camera_Fixed3(Camera* camera) {
|
|||
camera->animState++;
|
||||
}
|
||||
|
||||
if (BGCAM_JFIFID(sceneCamData) != rwData->jfifId) {
|
||||
if (bgCamFuncData->jfifId != rwData->jfifId) {
|
||||
osSyncPrintf("camera: position change %d \n", rwData->jfifId);
|
||||
rwData->jfifId = BGCAM_JFIFID(sceneCamData);
|
||||
rwData->jfifId = bgCamFuncData->jfifId;
|
||||
rwData->updDirTimer = 5;
|
||||
}
|
||||
|
||||
|
@ -4100,13 +4102,14 @@ s32 Camera_Fixed4(Camera* camera) {
|
|||
VecSph atEyeNextOffset;
|
||||
VecSph atTargetEyeNextOffset;
|
||||
PosRot* playerPosRot = &camera->playerPosRot;
|
||||
Vec3s* camPosData;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
Vec3f* posOffset = &camera->posOffset;
|
||||
Fixed4ReadOnlyData* roData = &camera->paramData.fixd4.roData;
|
||||
Fixed4ReadWriteData* rwData = &camera->paramData.fixd4.rwData;
|
||||
f32 playerYOffset;
|
||||
|
||||
playerYOffset = Player_GetHeight(camera->player);
|
||||
|
||||
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
|
||||
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
|
||||
f32 yNormal = ((1.0f + CAM_DATA_SCALED(OREG(46))) - (CAM_DATA_SCALED(OREG(46)) * (68.0f / playerYOffset)));
|
||||
|
@ -4116,9 +4119,10 @@ s32 Camera_Fixed4(Camera* camera) {
|
|||
roData->followSpeed = GET_NEXT_SCALED_RO_DATA(values);
|
||||
roData->fov = GET_NEXT_RO_DATA(values);
|
||||
roData->interfaceFlags = GET_NEXT_RO_DATA(values);
|
||||
camPosData = Camera_GetCamBGData(camera);
|
||||
if (camPosData != NULL) {
|
||||
Camera_Vec3sToVec3f(&rwData->eyeTarget, &BGCAM_POS(camPosData));
|
||||
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
if (bgCamFuncData != NULL) {
|
||||
Camera_Vec3sToVec3f(&rwData->eyeTarget, &bgCamFuncData->pos);
|
||||
} else {
|
||||
rwData->eyeTarget = *eye;
|
||||
}
|
||||
|
@ -4301,12 +4305,25 @@ s32 Camera_Subj3(Camera* camera) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crawlspaces
|
||||
* Moves the camera from third person to first person when entering a crawlspace
|
||||
* While in the crawlspace, link remains fixed in a single direction
|
||||
* The camera is what swings up and down while crawling forward or backwards
|
||||
*
|
||||
* Note:
|
||||
* Subject 4 uses bgCamFuncData.data differently than other functions:
|
||||
* All Vec3s data are points along the crawlspace
|
||||
* The second point represents the entrance, and the second to last point represents the exit
|
||||
* All other points are unused
|
||||
* All instances of crawlspaces have 6 points, except for the Testroom scene which has 9 points
|
||||
*/
|
||||
s32 Camera_Subj4(Camera* camera) {
|
||||
Vec3f* eye = &camera->eye;
|
||||
Vec3f* eyeNext = &camera->eyeNext;
|
||||
Vec3f* at = &camera->at;
|
||||
u16 spAA;
|
||||
Vec3s* spA4;
|
||||
u16 crawlspaceNumPoints;
|
||||
Vec3s* crawlspacePoints;
|
||||
Vec3f sp98;
|
||||
Vec3f sp8C;
|
||||
f32 sp88;
|
||||
|
@ -4343,9 +4360,9 @@ s32 Camera_Subj4(Camera* camera) {
|
|||
OLib_Vec3fDiffToVecSphGeo(&sp5C, at, eye);
|
||||
sCameraInterfaceFlags = roData->interfaceFlags;
|
||||
if (camera->animState == 0) {
|
||||
spA4 = Camera_GetCamBgDataUnderPlayer(camera, &spAA);
|
||||
Camera_Vec3sToVec3f(&rwData->unk_00.point, &spA4[1]);
|
||||
Camera_Vec3sToVec3f(&sp98, &spA4[spAA - 2]);
|
||||
crawlspacePoints = (Vec3s*)Camera_GetBgCamFuncDataUnderPlayer(camera, &crawlspaceNumPoints);
|
||||
Camera_Vec3sToVec3f(&rwData->unk_00.point, &crawlspacePoints[1]);
|
||||
Camera_Vec3sToVec3f(&sp98, &crawlspacePoints[crawlspaceNumPoints - 2]);
|
||||
|
||||
sp64.r = 10.0f;
|
||||
// 0x238C ~ 50 degrees
|
||||
|
@ -4458,7 +4475,7 @@ s32 Camera_Data4(Camera* camera) {
|
|||
f32 yNormal;
|
||||
s16 fov;
|
||||
Vec3f* eyeNext = &camera->eyeNext;
|
||||
Vec3s* sceneCamData;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
Vec3f lookAt;
|
||||
CameraModeValue* values;
|
||||
Data4ReadWriteData* rwData = &camera->paramData.data4.rwData;
|
||||
|
@ -4476,16 +4493,17 @@ s32 Camera_Data4(Camera* camera) {
|
|||
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
|
||||
roData->fov = GET_NEXT_RO_DATA(values);
|
||||
roData->interfaceFlags = GET_NEXT_RO_DATA(values);
|
||||
sceneCamData = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->eyePosRot.pos, &BGCAM_POS(sceneCamData));
|
||||
rwData->eyePosRot.rot = BGCAM_ROT(sceneCamData);
|
||||
fov = BGCAM_FOV(sceneCamData);
|
||||
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->eyePosRot.pos, &bgCamFuncData->pos);
|
||||
rwData->eyePosRot.rot = bgCamFuncData->rot;
|
||||
fov = bgCamFuncData->fov;
|
||||
rwData->fov = fov;
|
||||
if (fov != -1) {
|
||||
roData->fov = rwData->fov <= 360 ? rwData->fov : CAM_DATA_SCALED(rwData->fov);
|
||||
}
|
||||
|
||||
rwData->jfifId = BGCAM_JFIFID(sceneCamData);
|
||||
rwData->flags = bgCamFuncData->flags;
|
||||
*eye = rwData->eyePosRot.pos;
|
||||
}
|
||||
|
||||
|
@ -4505,10 +4523,9 @@ s32 Camera_Data4(Camera* camera) {
|
|||
OLib_Vec3fDiffToVecSphGeo(&eyeAtOffset, eye, at);
|
||||
|
||||
atOffset.r = eyeAtOffset.r;
|
||||
atOffset.yaw =
|
||||
(rwData->jfifId & 1) ? (CAM_DEG_TO_BINANG(camera->data2) + rwData->eyePosRot.rot.y) : eyeAtOffset.yaw;
|
||||
atOffset.yaw = (rwData->flags & 1) ? (CAM_DEG_TO_BINANG(camera->data2) + rwData->eyePosRot.rot.y) : eyeAtOffset.yaw;
|
||||
atOffset.pitch =
|
||||
(rwData->jfifId & 2) ? (CAM_DEG_TO_BINANG(camera->data3) + rwData->eyePosRot.rot.x) : eyeAtOffset.pitch;
|
||||
(rwData->flags & 2) ? (CAM_DEG_TO_BINANG(camera->data3) + rwData->eyePosRot.rot.x) : eyeAtOffset.pitch;
|
||||
|
||||
Camera_Vec3fVecSphGeoAdd(at, eye, &atOffset);
|
||||
|
||||
|
@ -4706,8 +4723,8 @@ s32 Camera_Unique3(Camera* camera) {
|
|||
VecSph sp60;
|
||||
f32 playerHeight;
|
||||
DoorParams* doorParams = &camera->paramData.doorParams;
|
||||
Vec3s* temp_v0_2;
|
||||
Vec3s sp4C;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
Vec3s bgCamRot;
|
||||
Unique3ReadWriteData* rwData = &camera->paramData.uniq3.rwData;
|
||||
Unique3ReadOnlyData* roData = &camera->paramData.uniq3.roData;
|
||||
Vec3f* at = &camera->at;
|
||||
|
@ -4740,13 +4757,16 @@ s32 Camera_Unique3(Camera* camera) {
|
|||
if (doorParams->timer1-- > 0) {
|
||||
break;
|
||||
}
|
||||
temp_v0_2 = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(&camera->eyeNext, &BGCAM_POS(temp_v0_2));
|
||||
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(&camera->eyeNext, &bgCamFuncData->pos);
|
||||
camera->eye = camera->eyeNext;
|
||||
sp4C = BGCAM_ROT(temp_v0_2);
|
||||
bgCamRot = bgCamFuncData->rot;
|
||||
|
||||
sp60.r = 100.0f;
|
||||
sp60.yaw = sp4C.y;
|
||||
sp60.pitch = -sp4C.x;
|
||||
sp60.yaw = bgCamRot.y;
|
||||
sp60.pitch = -bgCamRot.x;
|
||||
|
||||
Camera_Vec3fVecSphGeoAdd(at, &camera->eye, &sp60);
|
||||
camera->animState++;
|
||||
FALLTHROUGH;
|
||||
|
@ -4825,8 +4845,8 @@ s32 Camera_Unique0(Camera* camera) {
|
|||
Player* player;
|
||||
Vec3f playerPosWithOffset;
|
||||
VecSph atPlayerOffset;
|
||||
Vec3s* sceneCamData;
|
||||
Vec3s sceneCamRot;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
Vec3s bgCamRot;
|
||||
PosRot* playerPosRot = &camera->playerPosRot;
|
||||
DoorParams* doorParams = &camera->paramData.doorParams;
|
||||
Unique0ReadOnlyData* roData = &camera->paramData.uniq0.roData;
|
||||
|
@ -4854,24 +4874,25 @@ s32 Camera_Unique0(Camera* camera) {
|
|||
if (camera->animState == 0) {
|
||||
func_80043B60(camera);
|
||||
camera->unk_14C &= ~4;
|
||||
sceneCamData = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->sceneCamPosPlayerLine.point, &BGCAM_POS(sceneCamData));
|
||||
|
||||
*eye = camera->eyeNext = rwData->sceneCamPosPlayerLine.point;
|
||||
sceneCamRot = BGCAM_ROT(sceneCamData);
|
||||
fov = BGCAM_FOV(sceneCamData);
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(&rwData->eyeAndDirection.point, &bgCamFuncData->pos);
|
||||
|
||||
*eye = camera->eyeNext = rwData->eyeAndDirection.point;
|
||||
bgCamRot = bgCamFuncData->rot;
|
||||
fov = bgCamFuncData->fov;
|
||||
if (fov != -1) {
|
||||
camera->fov = fov <= 360 ? fov : CAM_DATA_SCALED(fov);
|
||||
}
|
||||
rwData->animTimer = BGCAM_JFIFID(sceneCamData);
|
||||
rwData->animTimer = bgCamFuncData->timer;
|
||||
if (rwData->animTimer == -1) {
|
||||
rwData->animTimer = doorParams->timer1 + doorParams->timer2;
|
||||
}
|
||||
atPlayerOffset.r = OLib_Vec3fDist(&playerPosWithOffset, eye);
|
||||
atPlayerOffset.yaw = sceneCamRot.y;
|
||||
atPlayerOffset.pitch = -sceneCamRot.x;
|
||||
OLib_VecSphGeoToVec3f(&rwData->sceneCamPosPlayerLine.dir, &atPlayerOffset);
|
||||
Math3D_LineClosestToPoint(&rwData->sceneCamPosPlayerLine, &playerPosRot->pos, &camera->at);
|
||||
atPlayerOffset.yaw = bgCamRot.y;
|
||||
atPlayerOffset.pitch = -bgCamRot.x;
|
||||
OLib_VecSphGeoToVec3f(&rwData->eyeAndDirection.dir, &atPlayerOffset);
|
||||
Math3D_LineClosestToPoint(&rwData->eyeAndDirection, &playerPosRot->pos, &camera->at);
|
||||
rwData->initalPos = playerPosRot->pos;
|
||||
camera->animState++;
|
||||
}
|
||||
|
@ -5000,8 +5021,8 @@ s32 Camera_Unique7(Camera* camera) {
|
|||
CameraModeValue* values;
|
||||
VecSph playerPosEyeOffset;
|
||||
s16 fov;
|
||||
Vec3s* sceneCamData;
|
||||
UNUSED Vec3s sceneCamRot;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
UNUSED Vec3s bgCamRot;
|
||||
Vec3f* at = &camera->at;
|
||||
PosRot* playerPosRot = &camera->playerPosRot;
|
||||
Vec3f* eye = &camera->eye;
|
||||
|
@ -5017,16 +5038,16 @@ s32 Camera_Unique7(Camera* camera) {
|
|||
Camera_CopyPREGToModeValues(camera);
|
||||
}
|
||||
|
||||
sceneCamData = Camera_GetCamBGData(camera);
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
|
||||
Camera_Vec3sToVec3f(eyeNext, &BGCAM_POS(sceneCamData));
|
||||
Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos);
|
||||
*eye = *eyeNext;
|
||||
sceneCamRot = BGCAM_ROT(sceneCamData);
|
||||
bgCamRot = bgCamFuncData->rot;
|
||||
|
||||
OLib_Vec3fDiffToVecSphGeo(&playerPosEyeOffset, eye, &playerPosRot->pos);
|
||||
|
||||
// fov actually goes unused since it's hard set later on.
|
||||
fov = BGCAM_FOV(sceneCamData);
|
||||
fov = bgCamFuncData->fov;
|
||||
if (fov == -1) {
|
||||
fov = roData->fov * 100.0f;
|
||||
}
|
||||
|
@ -5049,8 +5070,7 @@ s32 Camera_Unique7(Camera* camera) {
|
|||
|
||||
// 0x7D0 ~ 10.98 degres.
|
||||
rwData->unk_00.x = Camera_LERPFloorS(playerPosEyeOffset.yaw, rwData->unk_00.x, 0.4f, 0x7D0);
|
||||
playerPosEyeOffset.pitch =
|
||||
-BGCAM_ROT(sceneCamData).x * Math_CosS(playerPosEyeOffset.yaw - BGCAM_ROT(sceneCamData).y);
|
||||
playerPosEyeOffset.pitch = -bgCamFuncData->rot.x * Math_CosS(playerPosEyeOffset.yaw - bgCamFuncData->rot.y);
|
||||
Camera_Vec3fVecSphGeoAdd(at, eye, &playerPosEyeOffset);
|
||||
camera->unk_14C |= 0x400;
|
||||
return true;
|
||||
|
@ -5825,11 +5845,11 @@ s32 Camera_Demo3(Camera* camera) {
|
|||
default:
|
||||
camera->unk_14C |= 0x14;
|
||||
camera->unk_14C &= ~8;
|
||||
if (camera->prevCamDataIdx < 0) {
|
||||
if (camera->prevBgCamIndex < 0) {
|
||||
Camera_ChangeSettingFlags(camera, camera->prevSetting, 2);
|
||||
} else {
|
||||
Camera_ChangeDataIdx(camera, camera->prevCamDataIdx);
|
||||
camera->prevCamDataIdx = -1;
|
||||
Camera_ChangeBgCamIndex(camera, camera->prevBgCamIndex);
|
||||
camera->prevBgCamIndex = -1;
|
||||
}
|
||||
sCameraInterfaceFlags = 0;
|
||||
skipeyeUpdate:
|
||||
|
@ -6594,14 +6614,14 @@ s32 Camera_Special6(Camera* camera) {
|
|||
Vec3f* at = &camera->at;
|
||||
Vec3f* eyeNext = &camera->eyeNext;
|
||||
VecSph atOffset;
|
||||
Vec3f sceneCamPos;
|
||||
Vec3f bgCamPos;
|
||||
Vec3f eyePosCalc;
|
||||
Vec3f eyeAnim;
|
||||
Vec3f atAnim;
|
||||
VecSph eyeAtOffset;
|
||||
PosRot* playerPosRot = &camera->playerPosRot;
|
||||
Vec3s* sceneCamData;
|
||||
Vec3s sceneCamRot;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
Vec3s bgCamRot;
|
||||
s16 fov;
|
||||
f32 sp54;
|
||||
f32 timerF;
|
||||
|
@ -6622,10 +6642,10 @@ s32 Camera_Special6(Camera* camera) {
|
|||
|
||||
OLib_Vec3fDiffToVecSphGeo(&eyeAtOffset, eye, at);
|
||||
|
||||
sceneCamData = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(&sceneCamPos, &BGCAM_POS(sceneCamData));
|
||||
sceneCamRot = BGCAM_ROT(sceneCamData);
|
||||
fov = BGCAM_FOV(sceneCamData);
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(&bgCamPos, &bgCamFuncData->pos);
|
||||
bgCamRot = bgCamFuncData->rot;
|
||||
fov = bgCamFuncData->fov;
|
||||
if (fov == -1) {
|
||||
fov = 6000;
|
||||
}
|
||||
|
@ -6636,15 +6656,14 @@ s32 Camera_Special6(Camera* camera) {
|
|||
|
||||
sCameraInterfaceFlags = roData->interfaceFlags;
|
||||
|
||||
if (eyeNext->x != sceneCamPos.x || eyeNext->y != sceneCamPos.y || eyeNext->z != sceneCamPos.z ||
|
||||
camera->animState == 0) {
|
||||
if (eyeNext->x != bgCamPos.x || eyeNext->y != bgCamPos.y || eyeNext->z != bgCamPos.z || camera->animState == 0) {
|
||||
// A change in the current scene's camera positon has been detected,
|
||||
// Change "screens"
|
||||
camera->player->actor.freezeTimer = 12;
|
||||
sCameraInterfaceFlags = (sCameraInterfaceFlags & 0xF0FF) | 0x300;
|
||||
rwData->initalPlayerY = playerPosRot->pos.y;
|
||||
rwData->animTimer = 12;
|
||||
*eyeNext = sceneCamPos;
|
||||
*eyeNext = bgCamPos;
|
||||
if (camera->animState == 0) {
|
||||
camera->animState++;
|
||||
}
|
||||
|
@ -6662,8 +6681,8 @@ s32 Camera_Special6(Camera* camera) {
|
|||
// set the at point to be 100 units from the eye looking at the
|
||||
// direction specified in the scene's camera data.
|
||||
atOffset.r = 100.0f;
|
||||
atOffset.yaw = sceneCamRot.y;
|
||||
atOffset.pitch = -sceneCamRot.x;
|
||||
atOffset.yaw = bgCamRot.y;
|
||||
atOffset.pitch = -bgCamRot.x;
|
||||
Camera_Vec3fVecSphGeoAdd(&atAnim, &eyeAnim, &atOffset);
|
||||
timerDivisor = 1.0f / timerF;
|
||||
eye->x += (eyeAnim.x - eye->x) * timerDivisor;
|
||||
|
@ -6686,8 +6705,8 @@ s32 Camera_Special6(Camera* camera) {
|
|||
// set the at point to be 100 units from the eye looking at the
|
||||
// direction specified in the scene's camera data.
|
||||
atOffset.r = 100.0f;
|
||||
atOffset.yaw = sceneCamRot.y;
|
||||
atOffset.pitch = -sceneCamRot.x;
|
||||
atOffset.yaw = bgCamRot.y;
|
||||
atOffset.pitch = -bgCamRot.x;
|
||||
Camera_Vec3fVecSphGeoAdd(at, eye, &atOffset);
|
||||
}
|
||||
return true;
|
||||
|
@ -6714,7 +6733,7 @@ s32 Camera_Special9(Camera* camera) {
|
|||
Special9ReadOnlyData* roData = &camera->paramData.spec9.roData;
|
||||
Special9ReadWriteData* rwData = &camera->paramData.spec9.rwData;
|
||||
s32 pad4;
|
||||
Vec3s* camPosData;
|
||||
BgCamFuncData* bgCamFuncData;
|
||||
|
||||
playerYOffset = Player_GetHeight(camera->player);
|
||||
camera->unk_14C &= ~0x10;
|
||||
|
@ -6760,8 +6779,8 @@ s32 Camera_Special9(Camera* camera) {
|
|||
if (doorParams->timer1 <= 0) {
|
||||
camera->animState++;
|
||||
if (roData->interfaceFlags & 1) {
|
||||
camPosData = Camera_GetCamBGData(camera);
|
||||
Camera_Vec3sToVec3f(eyeNext, &BGCAM_POS(camPosData));
|
||||
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera);
|
||||
Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos);
|
||||
spAC = *eye = *eyeNext;
|
||||
} else {
|
||||
s16 yaw;
|
||||
|
@ -6927,9 +6946,9 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState
|
|||
sCameraInterfaceAlpha = 0;
|
||||
camera->unk_14C = 0;
|
||||
camera->setting = camera->prevSetting = CAM_SET_FREE0;
|
||||
camera->camDataIdx = camera->prevCamDataIdx = -1;
|
||||
camera->bgCamIndex = camera->prevBgCamIndex = -1;
|
||||
camera->mode = 0;
|
||||
camera->bgCheckId = BGCHECK_SCENE;
|
||||
camera->bgId = BGCHECK_SCENE;
|
||||
camera->csId = 0x7FFF;
|
||||
camera->timer = -1;
|
||||
camera->unk_14C |= 0x4000;
|
||||
|
@ -7016,11 +7035,11 @@ void Camera_InitPlayerSettings(Camera* camera, Player* player) {
|
|||
camera->up.x = upXZ;
|
||||
|
||||
if (Camera_GetFloorYNorm(camera, &floorPos, at, &bgId) != BGCHECK_Y_MIN) {
|
||||
camera->bgCheckId = bgId;
|
||||
camera->bgId = bgId;
|
||||
}
|
||||
|
||||
camera->waterPrevCamIdx = -1;
|
||||
camera->waterPrevCamSetting = -1;
|
||||
camera->bgCamIndexBeforeUnderwater = -1;
|
||||
camera->waterCamSetting = -1;
|
||||
camera->unk_14C |= 4;
|
||||
|
||||
if (camera == &camera->play->mainCamera) {
|
||||
|
@ -7032,7 +7051,7 @@ void Camera_InitPlayerSettings(Camera* camera, Player* player) {
|
|||
func_80057FC4(camera);
|
||||
camera->unk_14A = 0;
|
||||
camera->paramFlags = 0;
|
||||
camera->nextCamDataIdx = -1;
|
||||
camera->nextBgCamIndex = -1;
|
||||
camera->atLERPStepScale = 1.0f;
|
||||
Camera_CopyDataToRegs(camera, camera->mode);
|
||||
Camera_QRegInit();
|
||||
|
@ -7121,17 +7140,17 @@ void Camera_PrintSettings(Camera* camera) {
|
|||
sCameraFunctionNames[sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx]);
|
||||
|
||||
i = 0;
|
||||
if (camera->camDataIdx < 0) {
|
||||
if (camera->bgCamIndex < 0) {
|
||||
sp50[i++] = '-';
|
||||
}
|
||||
|
||||
//! @bug: this code was clearly meaning to print `abs(camera->camDataIdx)` as a
|
||||
//! @bug: this code was clearly meaning to print `abs(camera->bgCamIndex)` as a
|
||||
//! one-or-two-digit number, instead of `i`.
|
||||
// "sp50[i++] = ..." matches here, but is undefined behavior due to conflicting
|
||||
// reads/writes between sequence points, triggering warnings. Work around by
|
||||
// putting i++ afterwards while on the same line.
|
||||
// clang-format off
|
||||
if (camera->camDataIdx / 10 != 0) {
|
||||
if (camera->bgCamIndex / 10 != 0) {
|
||||
sp50[i] = i / 10 + '0'; i++;
|
||||
}
|
||||
sp50[i] = i % 10 + '0'; i++;
|
||||
|
@ -7151,8 +7170,8 @@ s32 Camera_UpdateWater(Camera* camera) {
|
|||
f32 waterY;
|
||||
s16 newQuakeId;
|
||||
s32 waterLightsIndex;
|
||||
s32* waterPrevCamSetting = &camera->waterPrevCamSetting;
|
||||
s16 waterCamIdx;
|
||||
s32* waterCamSetting = &camera->waterCamSetting;
|
||||
s16 waterBgCamIndex;
|
||||
s16* quakeId = (s16*)&camera->waterQuakeId;
|
||||
Player* player = camera->player;
|
||||
s16 prevBgId;
|
||||
|
@ -7166,55 +7185,55 @@ s32 Camera_UpdateWater(Camera* camera) {
|
|||
Camera_ChangeSettingFlags(camera, CAM_SET_PIVOT_WATER_SURFACE, 6);
|
||||
camera->unk_14C |= (s16)0x8000;
|
||||
} else if (camera->unk_14C & (s16)0x8000) {
|
||||
Camera_ChangeSettingFlags(camera, *waterPrevCamSetting, 6);
|
||||
Camera_ChangeSettingFlags(camera, *waterCamSetting, 6);
|
||||
camera->unk_14C &= ~((s16)0x8000);
|
||||
}
|
||||
}
|
||||
if (!(camera->unk_14C & (s16)0x8000)) {
|
||||
if (waterCamIdx = Camera_GetWaterBoxDataIdx(camera, &waterY), waterCamIdx == -2) {
|
||||
if (waterBgCamIndex = Camera_GetWaterBoxBgCamIndex(camera, &waterY), waterBgCamIndex == -2) {
|
||||
// No camera data index
|
||||
if (!(camera->unk_14C & 0x200)) {
|
||||
camera->unk_14C |= 0x200;
|
||||
camera->waterYPos = waterY;
|
||||
camera->waterPrevCamIdx = camera->camDataIdx;
|
||||
camera->bgCamIndexBeforeUnderwater = camera->bgCamIndex;
|
||||
*quakeId = -1;
|
||||
}
|
||||
if (camera->playerGroundY != camera->playerPosRot.pos.y) {
|
||||
prevBgId = camera->bgCheckId;
|
||||
camera->bgCheckId = BGCHECK_SCENE;
|
||||
prevBgId = camera->bgId;
|
||||
camera->bgId = BGCHECK_SCENE;
|
||||
Camera_ChangeSettingFlags(camera, CAM_SET_NORMAL3, 2);
|
||||
*waterPrevCamSetting = camera->setting;
|
||||
camera->bgCheckId = prevBgId;
|
||||
camera->camDataIdx = -2;
|
||||
*waterCamSetting = camera->setting;
|
||||
camera->bgId = prevBgId;
|
||||
camera->bgCamIndex = -2;
|
||||
}
|
||||
} else if (waterCamIdx != -1) {
|
||||
} else if (waterBgCamIndex != -1) {
|
||||
// player is in a water box
|
||||
if (!(camera->unk_14C & 0x200)) {
|
||||
camera->unk_14C |= 0x200;
|
||||
camera->waterYPos = waterY;
|
||||
camera->waterPrevCamIdx = camera->camDataIdx;
|
||||
camera->bgCamIndexBeforeUnderwater = camera->bgCamIndex;
|
||||
*quakeId = -1;
|
||||
}
|
||||
if (camera->playerGroundY != camera->playerPosRot.pos.y) {
|
||||
prevBgId = camera->bgCheckId;
|
||||
camera->bgCheckId = BGCHECK_SCENE;
|
||||
Camera_ChangeDataIdx(camera, waterCamIdx);
|
||||
*waterPrevCamSetting = camera->setting;
|
||||
camera->bgCheckId = prevBgId;
|
||||
prevBgId = camera->bgId;
|
||||
camera->bgId = BGCHECK_SCENE;
|
||||
Camera_ChangeBgCamIndex(camera, waterBgCamIndex);
|
||||
*waterCamSetting = camera->setting;
|
||||
camera->bgId = prevBgId;
|
||||
}
|
||||
} else if (camera->unk_14C & 0x200) {
|
||||
// player is out of a water box.
|
||||
osSyncPrintf("camera: water: off\n");
|
||||
camera->unk_14C &= ~0x200;
|
||||
prevBgId = camera->bgCheckId;
|
||||
camera->bgCheckId = BGCHECK_SCENE;
|
||||
if (camera->waterPrevCamIdx < 0) {
|
||||
prevBgId = camera->bgId;
|
||||
camera->bgId = BGCHECK_SCENE;
|
||||
if (camera->bgCamIndexBeforeUnderwater < 0) {
|
||||
func_80057FC4(camera);
|
||||
camera->camDataIdx = -1;
|
||||
camera->bgCamIndex = -1;
|
||||
} else {
|
||||
Camera_ChangeDataIdx(camera, camera->waterPrevCamIdx);
|
||||
Camera_ChangeBgCamIndex(camera, camera->bgCamIndexBeforeUnderwater);
|
||||
}
|
||||
camera->bgCheckId = prevBgId;
|
||||
camera->bgId = prevBgId;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7401,7 +7420,7 @@ Vec3s Camera_Update(Camera* camera) {
|
|||
f32 playerGroundY;
|
||||
f32 playerXZSpeed;
|
||||
VecSph eyeAtAngle;
|
||||
s16 camDataIdx;
|
||||
s16 bgCamIndex;
|
||||
PosRot curPlayerPosRot;
|
||||
QuakeCamCalc quake;
|
||||
Player* player;
|
||||
|
@ -7441,7 +7460,7 @@ Vec3s Camera_Update(Camera* camera) {
|
|||
camera->floorNorm.x = COLPOLY_GET_NORMAL(playerFloorPoly->normal.x);
|
||||
camera->floorNorm.y = COLPOLY_GET_NORMAL(playerFloorPoly->normal.y);
|
||||
camera->floorNorm.z = COLPOLY_GET_NORMAL(playerFloorPoly->normal.z);
|
||||
camera->bgCheckId = bgId;
|
||||
camera->bgId = bgId;
|
||||
camera->playerGroundY = playerGroundY;
|
||||
} else {
|
||||
// player is not above ground.
|
||||
|
@ -7460,26 +7479,26 @@ Vec3s Camera_Update(Camera* camera) {
|
|||
}
|
||||
|
||||
if (!(camera->unk_14C & 4)) {
|
||||
camera->nextCamDataIdx = -1;
|
||||
camera->nextBgCamIndex = -1;
|
||||
}
|
||||
|
||||
if ((camera->unk_14C & 1) && (camera->unk_14C & 4) && !(camera->unk_14C & 0x400) &&
|
||||
(!(camera->unk_14C & 0x200) || (player->currentBoots == PLAYER_BOOTS_IRON)) &&
|
||||
(!(camera->unk_14C & (s16)0x8000)) && (playerGroundY != BGCHECK_Y_MIN)) {
|
||||
camDataIdx = Camera_GetDataIdxForPoly(camera, &bgId, playerFloorPoly);
|
||||
if (camDataIdx != -1) {
|
||||
camera->nextBGCheckId = bgId;
|
||||
bgCamIndex = Camera_GetBgCamIndex(camera, &bgId, playerFloorPoly);
|
||||
if (bgCamIndex != -1) {
|
||||
camera->nextBgId = bgId;
|
||||
if (bgId == BGCHECK_SCENE) {
|
||||
camera->nextCamDataIdx = camDataIdx;
|
||||
camera->nextBgCamIndex = bgCamIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (camera->nextCamDataIdx != -1 && (fabsf(curPlayerPosRot.pos.y - playerGroundY) < 2.0f) &&
|
||||
if (camera->nextBgCamIndex != -1 && (fabsf(curPlayerPosRot.pos.y - playerGroundY) < 2.0f) &&
|
||||
(!(camera->unk_14C & 0x200) || (player->currentBoots == PLAYER_BOOTS_IRON))) {
|
||||
camera->bgCheckId = camera->nextBGCheckId;
|
||||
Camera_ChangeDataIdx(camera, camera->nextCamDataIdx);
|
||||
camera->nextCamDataIdx = -1;
|
||||
camera->bgId = camera->nextBgId;
|
||||
Camera_ChangeBgCamIndex(camera, camera->nextBgCamIndex);
|
||||
camera->nextBgCamIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7566,7 +7585,7 @@ Vec3s Camera_Update(Camera* camera) {
|
|||
return camera->inputDir;
|
||||
}
|
||||
|
||||
// setting bgCheckId to the ret of Quake_Calc, and checking that
|
||||
// setting bgId to the ret of Quake_Calc, and checking that
|
||||
// is required, it doesn't make too much sense though.
|
||||
if ((bgId = Quake_Calc(camera, &quake), bgId != 0) && (camera->setting != CAM_SET_TURN_AROUND)) {
|
||||
viewAt.x = camera->at.x + quake.atOffset.x;
|
||||
|
@ -7874,13 +7893,13 @@ s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags) {
|
|||
|
||||
if (flags & 8) {
|
||||
if (1) {}
|
||||
camera->camDataIdx = camera->prevCamDataIdx;
|
||||
camera->prevCamDataIdx = -1;
|
||||
camera->bgCamIndex = camera->prevBgCamIndex;
|
||||
camera->prevBgCamIndex = -1;
|
||||
} else if (!(flags & 4)) {
|
||||
if (!(sCameraSettings[camera->setting].unk_00 & 0x40000000)) {
|
||||
camera->prevCamDataIdx = camera->camDataIdx;
|
||||
camera->prevBgCamIndex = camera->bgCamIndex;
|
||||
}
|
||||
camera->camDataIdx = -1;
|
||||
camera->bgCamIndex = -1;
|
||||
}
|
||||
|
||||
camera->setting = setting;
|
||||
|
@ -7899,30 +7918,30 @@ s32 Camera_ChangeSetting(Camera* camera, s16 setting) {
|
|||
return Camera_ChangeSettingFlags(camera, setting, 0);
|
||||
}
|
||||
|
||||
s32 Camera_ChangeDataIdx(Camera* camera, s32 camDataIdx) {
|
||||
s32 Camera_ChangeBgCamIndex(Camera* camera, s32 bgCamIndex) {
|
||||
s16 newCameraSetting;
|
||||
s16 settingChangeSuccessful;
|
||||
|
||||
if (camDataIdx == -1 || camDataIdx == camera->camDataIdx) {
|
||||
if (bgCamIndex == -1 || bgCamIndex == camera->bgCamIndex) {
|
||||
camera->unk_14A |= 0x40;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(camera->unk_14A & 0x40)) {
|
||||
newCameraSetting = Camera_GetCamDataSetting(camera, camDataIdx);
|
||||
newCameraSetting = Camera_GetBgCamSetting(camera, bgCamIndex);
|
||||
camera->unk_14A |= 0x40;
|
||||
settingChangeSuccessful = Camera_ChangeSettingFlags(camera, newCameraSetting, 5) >= 0;
|
||||
if (settingChangeSuccessful || sCameraSettings[camera->setting].unk_00 & 0x80000000) {
|
||||
camera->camDataIdx = camDataIdx;
|
||||
camera->bgCamIndex = bgCamIndex;
|
||||
camera->unk_14A |= 4;
|
||||
Camera_CopyDataToRegs(camera, camera->mode);
|
||||
} else if (settingChangeSuccessful < -1) {
|
||||
//! @bug: This is likely checking the wrong value. The actual return of Camera_ChangeSettingFlags or
|
||||
// camDataIdx would make more sense.
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "camera: error: illegal camera ID (%d) !! (%d|%d|%d)\n" VT_RST, camDataIdx,
|
||||
camera->camId, 0x32, newCameraSetting);
|
||||
// bgCamIndex would make more sense.
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "camera: error: illegal camera ID (%d) !! (%d|%d|%d)\n" VT_RST, bgCamIndex,
|
||||
camera->camId, BGCHECK_SCENE, newCameraSetting);
|
||||
}
|
||||
return 0x80000000 | camDataIdx;
|
||||
return 0x80000000 | bgCamIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8057,7 +8076,7 @@ s32 Camera_SetCSParams(Camera* camera, CutsceneCameraPoint* atPoints, CutsceneCa
|
|||
Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor);
|
||||
camera->playerPosRot = playerPosRot;
|
||||
|
||||
camera->nextCamDataIdx = -1;
|
||||
camera->nextBgCamIndex = -1;
|
||||
camera->xzSpeed = 0.0f;
|
||||
camera->speedRatio = 0.0f;
|
||||
}
|
||||
|
@ -8075,7 +8094,12 @@ s16 func_8005AD1C(Camera* camera, s16 arg1) {
|
|||
return camera->unk_14C;
|
||||
}
|
||||
|
||||
s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 camDataIdx, f32 arg3, s16 timer1, s16 timer2,
|
||||
/**
|
||||
* A bgCamIndex of -99 will save the door params without changing the camera setting
|
||||
* A bgCamIndex of -1 uses the default door camera setting (CAM_SET_DOORC)
|
||||
* Otherwise, change the door camera setting by reading the bgCam indexed at bgCamIndex
|
||||
*/
|
||||
s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2,
|
||||
s16 timer3) {
|
||||
DoorParams* doorParams = &camera->paramData.doorParams;
|
||||
|
||||
|
@ -8087,27 +8111,27 @@ s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 camDataIdx, f32 a
|
|||
doorParams->timer1 = timer1;
|
||||
doorParams->timer2 = timer2;
|
||||
doorParams->timer3 = timer3;
|
||||
doorParams->camDataIdx = camDataIdx;
|
||||
doorParams->bgCamIndex = bgCamIndex;
|
||||
|
||||
if (camDataIdx == -99) {
|
||||
if (bgCamIndex == -99) {
|
||||
Camera_CopyDataToRegs(camera, camera->mode);
|
||||
return -99;
|
||||
}
|
||||
|
||||
if (camDataIdx == -1) {
|
||||
if (bgCamIndex == -1) {
|
||||
Camera_ChangeSetting(camera, CAM_SET_DOORC);
|
||||
osSyncPrintf(".... change default door camera (set %d)\n", CAM_SET_DOORC);
|
||||
} else {
|
||||
s32 setting = Camera_GetCamDataSetting(camera, camDataIdx);
|
||||
s32 setting = Camera_GetBgCamSetting(camera, bgCamIndex);
|
||||
|
||||
camera->unk_14A |= 0x40;
|
||||
|
||||
if (Camera_ChangeSetting(camera, setting) >= 0) {
|
||||
camera->camDataIdx = camDataIdx;
|
||||
camera->bgCamIndex = bgCamIndex;
|
||||
camera->unk_14A |= 4;
|
||||
}
|
||||
|
||||
osSyncPrintf("....change door camera ID %d (set %d)\n", camera->camDataIdx, camera->setting);
|
||||
osSyncPrintf("....change door camera ID %d (set %d)\n", camera->bgCamIndex, camera->setting);
|
||||
}
|
||||
|
||||
Camera_CopyDataToRegs(camera, camera->mode);
|
||||
|
|
|
@ -16,7 +16,7 @@ u64 D_801614D0[0xA00];
|
|||
void Play_SpawnScene(PlayState* this, s32 sceneNum, s32 spawn);
|
||||
|
||||
void func_800BC450(PlayState* this) {
|
||||
Camera_ChangeDataIdx(GET_ACTIVE_CAM(this), this->unk_1242B - 1);
|
||||
Camera_ChangeBgCamIndex(GET_ACTIVE_CAM(this), this->unk_1242B - 1);
|
||||
}
|
||||
|
||||
void func_800BC490(PlayState* this, s16 point) {
|
||||
|
@ -201,7 +201,7 @@ void Play_Init(GameState* thisx) {
|
|||
u32 zAllocAligned;
|
||||
size_t zAllocSize;
|
||||
Player* player;
|
||||
s32 playerStartCamId;
|
||||
s32 playerStartBgCamIndex;
|
||||
s32 i;
|
||||
u8 tempSetupIndex;
|
||||
s32 pad[2];
|
||||
|
@ -388,10 +388,10 @@ void Play_Init(GameState* thisx) {
|
|||
Camera_InitPlayerSettings(&this->mainCamera, player);
|
||||
Camera_ChangeMode(&this->mainCamera, CAM_MODE_NORMAL);
|
||||
|
||||
playerStartCamId = player->actor.params & 0xFF;
|
||||
if (playerStartCamId != 0xFF) {
|
||||
osSyncPrintf("player has start camera ID (" VT_FGCOL(BLUE) "%d" VT_RST ")\n", playerStartCamId);
|
||||
Camera_ChangeDataIdx(&this->mainCamera, playerStartCamId);
|
||||
playerStartBgCamIndex = player->actor.params & 0xFF;
|
||||
if (playerStartBgCamIndex != 0xFF) {
|
||||
osSyncPrintf("player has start camera ID (" VT_FGCOL(BLUE) "%d" VT_RST ")\n", playerStartBgCamIndex);
|
||||
Camera_ChangeBgCamIndex(&this->mainCamera, playerStartBgCamIndex);
|
||||
}
|
||||
|
||||
if (YREG(15) == 32) {
|
||||
|
|
|
@ -362,32 +362,30 @@ void Room_Draw1Single(PlayState* play, Room* room, u32 flags) {
|
|||
|
||||
BgImage* func_80096A74(MeshHeader1Multi* meshHeader1Multi, PlayState* play) {
|
||||
Camera* activeCam = GET_ACTIVE_CAM(play);
|
||||
s32 camDataIdx;
|
||||
s16 camDataIdx2;
|
||||
s32 bgCamIndex = activeCam->bgCamIndex;
|
||||
s16 jfifId;
|
||||
Player* player;
|
||||
BgImage* bgImage;
|
||||
s32 i;
|
||||
|
||||
camDataIdx = activeCam->camDataIdx;
|
||||
// jfifid
|
||||
camDataIdx2 = func_80041C10(&play->colCtx, camDataIdx, BGCHECK_SCENE)[2].y;
|
||||
if (camDataIdx2 >= 0) {
|
||||
camDataIdx = camDataIdx2;
|
||||
jfifId = ((BgCamFuncData*)BgCheck_GetBgCamFuncDataImpl(&play->colCtx, bgCamIndex, BGCHECK_SCENE))->jfifId;
|
||||
if (jfifId >= 0) {
|
||||
bgCamIndex = jfifId;
|
||||
}
|
||||
|
||||
player = GET_PLAYER(play);
|
||||
player->actor.params = (player->actor.params & 0xFF00) | camDataIdx;
|
||||
player->actor.params = (player->actor.params & 0xFF00) | bgCamIndex;
|
||||
|
||||
bgImage = SEGMENTED_TO_VIRTUAL(meshHeader1Multi->list);
|
||||
for (i = 0; i < meshHeader1Multi->count; i++) {
|
||||
if (bgImage->id == camDataIdx) {
|
||||
if (bgImage->id == bgCamIndex) {
|
||||
return bgImage;
|
||||
}
|
||||
bgImage++;
|
||||
}
|
||||
|
||||
// "z_room.c: Data consistent with camera id does not exist camid=%d"
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, camDataIdx);
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, bgCamIndex);
|
||||
LogUtils_HungupThread("../z_room.c", 726);
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -210,7 +210,7 @@ void Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd) {
|
|||
colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList);
|
||||
colHeader->polyList = SEGMENTED_TO_VIRTUAL(colHeader->polyList);
|
||||
colHeader->surfaceTypeList = SEGMENTED_TO_VIRTUAL(colHeader->surfaceTypeList);
|
||||
colHeader->cameraDataList = SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList);
|
||||
colHeader->bgCamList = SEGMENTED_TO_VIRTUAL(colHeader->bgCamList);
|
||||
colHeader->waterBoxes = SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes);
|
||||
|
||||
BgCheck_Allocate(&play->colCtx, play, colHeader);
|
||||
|
|
|
@ -416,7 +416,8 @@ void func_80996C60(DoorShutter* this, PlayState* play) {
|
|||
DoorShutter_SetupAction(this, func_80997004);
|
||||
this->unk_16C = sp38;
|
||||
this->unk_170 = 0.0f;
|
||||
Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->dyna.actor, player->unk_46A, 0.0f, 12, sp34, 10);
|
||||
Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->dyna.actor, player->doorBgCamIndex, 0.0f, 12, sp34,
|
||||
10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ static Vec3f sRupeePositions[] = {
|
|||
{ 0.0f, 0.0f, -30.0f }, { 55.0f, 0.0f, -30.0f }, { 55.0f, 0.0f, 30.0f }, { 55.0f, 0.0f, 90.0f },
|
||||
};
|
||||
|
||||
static s32 sCamDataIdxs[] = {
|
||||
static s32 sBgCamIndices[] = {
|
||||
7, 7, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 4, 4, 5, 6,
|
||||
};
|
||||
|
||||
|
@ -410,7 +410,7 @@ void EnHeishi1_Update(Actor* thisx, PlayState* play) {
|
|||
|
||||
if (this->type != 5) {
|
||||
path = this->path * 2;
|
||||
if ((sCamDataIdxs[path] == activeCam->camDataIdx) || (sCamDataIdxs[path + 1] == activeCam->camDataIdx)) {
|
||||
if ((sBgCamIndices[path] == activeCam->bgCamIndex) || (sBgCamIndices[path + 1] == activeCam->bgCamIndex)) {
|
||||
if (!sPlayerIsCaught) {
|
||||
if ((this->actionFunc == EnHeishi1_Walk) || (this->actionFunc == EnHeishi1_Wait)) {
|
||||
Vec3f searchBallVel;
|
||||
|
|
|
@ -564,7 +564,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) {
|
|||
if ((this->actor.colChkInfo.health == 0) && sDeathFlag) {
|
||||
this->csMode = 0x18;
|
||||
this->unk_448 = &player->actor;
|
||||
this->unk_46A = 1;
|
||||
this->doorBgCamIndex = 1;
|
||||
sDeathFlag = false;
|
||||
}
|
||||
if ((this->invincibilityTimer == 0) && (this->actor.colChkInfo.health != 0) &&
|
||||
|
|
|
@ -4372,9 +4372,9 @@ s32 func_80839800(Player* this, PlayState* play) {
|
|||
}
|
||||
|
||||
if (doorShutter->dyna.actor.category == ACTORCAT_DOOR) {
|
||||
this->unk_46A = play->transiActorCtx.list[(u16)doorShutter->dyna.actor.params >> 10]
|
||||
.sides[(doorDirection > 0) ? 0 : 1]
|
||||
.effects;
|
||||
this->doorBgCamIndex = play->transiActorCtx.list[(u16)doorShutter->dyna.actor.params >> 10]
|
||||
.sides[(doorDirection > 0) ? 0 : 1]
|
||||
.bgCamIndex;
|
||||
|
||||
Actor_DisableLens(play);
|
||||
}
|
||||
|
@ -4446,7 +4446,7 @@ s32 func_80839800(Player* this, PlayState* play) {
|
|||
Camera_ChangeDoorCam(Play_GetCamera(play, CAM_ID_MAIN), doorActor,
|
||||
play->transiActorCtx.list[(u16)doorActor->params >> 10]
|
||||
.sides[(doorDirection > 0) ? 0 : 1]
|
||||
.effects,
|
||||
.bgCamIndex,
|
||||
0, 38.0f * D_808535EC, 26.0f * D_808535EC, 10.0f * D_808535EC);
|
||||
}
|
||||
}
|
||||
|
@ -4837,7 +4837,7 @@ s32 func_8083AD4C(PlayState* play, Player* this) {
|
|||
s32 func_8083ADD4(PlayState* play, Player* this) {
|
||||
if (this->unk_6AD == 3) {
|
||||
func_80835C58(play, this, func_80852E14, 0);
|
||||
if (this->unk_46A != 0) {
|
||||
if (this->doorBgCamIndex != 0) {
|
||||
this->stateFlags1 |= PLAYER_STATE1_29;
|
||||
}
|
||||
func_80832318(this);
|
||||
|
|
Loading…
Reference in a new issue