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

z_bgcheck.c, 800430A0.c, 80043480.c (#256)

* beginning of migrating changes

* got matching

* changed order a bit

* clean up bgcheck

* fix conflict

* fix conflict again

* first stab at identifying types, some oks

* Clean up most bad structs/pointer math, move relevant structs to z64bgcheck.h, get some OKs

* more OKs, z_bgcheck.bss migration, update some sys_math3d.c args

* couple more OKs

* pushing some OKs

* fix compilation issues

* code_800430A0.c OK, more files decomp'd

* 8003A3E0 big OK :)

* Decomp most of func_8003C614, decomp helper funcs

* Decomp SurfaceType, CamData, and WaterBox property related functions

* more OKs, big OK in 8003C078

* more OKs, more progress, move a function definition in z_collision_check to functions.h

* more clean-ups, more OKs, dyn_vtx is now defined as u8*

* 8003A5B8, 8003A7D8, 8003C614, 8003DD6C OK, document function args better

* data migrated, more OKs

* 80041240 OK, func_8003B3C8 and func_8003BB18 disassembled

* func_80040284, 800409A8 non_matching, add IS_ZERO macro

* All asm files have C representations, some big OKs, lots of minor tweaks

* More OKs, non-matching code cleanup

* 8003FBF4 and 80040BE4 OK, improve codegen for most functions

* format z_bgcheck.c

* fix warnings, compile errors on NON_MATCHING

* func_8003EE80 is now NON_MATCHING

* begin documenting some functions

* formatting

* more documentation, func_8003A95C OK

* fix PHYSICAL_TO_VIRTUAL changes

* fix var rename

* More documentation, functions 80040E40, 80041648 OK, change types to not be compatible with ZAP

* func_8004239C ok, more NON_MATCHING improvements, more documentation

* Implement most suggested changes

* Convert comments to slower comments

* /**

* Implement ZAP2 changes

* my anti-virus ate my format.sh results

* Rename a couple hundred functions, fix minor stuff

* rename var so that clang formats correctly

* run format.sh

* implement Petrie's matches/suggestions

* format

* matches

* and the asm

* slight error

* Add SSList

* two more matches

* stuff

* implement code changes

* clean up Petrie's matchings

Co-authored-by: Arthur <arthurtilly413@gmail.com>
Co-authored-by: fig02 <fig02srl@gmail.com>
Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
This commit is contained in:
mzxrules 2021-01-08 06:12:58 -05:00 committed by GitHub
parent 209f0d21b8
commit 3cef03f5ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
416 changed files with 6610 additions and 13487 deletions

View file

@ -1,23 +1,64 @@
#include "global.h"
#include "vt.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800430A0/func_800430A0.s")
void func_800430A0(CollisionContext* colCtx, s32 bgId, Actor* actor) {
MtxF prevTransform;
MtxF prevTransformInv;
MtxF curTransform;
Vec3f pos;
Vec3f tempPos;
void func_800432A0(CollisionContext* colCtx, u32 floorPolySource, Actor* actor) {
if (func_8003E934(floorPolySource) != 0) {
s16 v1 = colCtx->dyna.actorMeshArr[floorPolySource].rot2.y - colCtx->dyna.actorMeshArr[floorPolySource].rot1.y;
if (DynaPoly_IsBgIdBgActor(bgId)) {
SkinMatrix_SetScaleRotateYRPTranslate(
&prevTransform, colCtx->dyna.bgActors[bgId].prevTransform.scale.x,
colCtx->dyna.bgActors[bgId].prevTransform.scale.y, colCtx->dyna.bgActors[bgId].prevTransform.scale.z,
colCtx->dyna.bgActors[bgId].prevTransform.rot.x, colCtx->dyna.bgActors[bgId].prevTransform.rot.y,
colCtx->dyna.bgActors[bgId].prevTransform.rot.z, colCtx->dyna.bgActors[bgId].prevTransform.pos.x,
colCtx->dyna.bgActors[bgId].prevTransform.pos.y, colCtx->dyna.bgActors[bgId].prevTransform.pos.z);
if (SkinMatrix_Invert(&prevTransform, &prevTransformInv) != 2) {
SkinMatrix_SetScaleRotateYRPTranslate(
&curTransform, colCtx->dyna.bgActors[bgId].curTransform.scale.x,
colCtx->dyna.bgActors[bgId].curTransform.scale.y, colCtx->dyna.bgActors[bgId].curTransform.scale.z,
colCtx->dyna.bgActors[bgId].curTransform.rot.x, colCtx->dyna.bgActors[bgId].curTransform.rot.y,
colCtx->dyna.bgActors[bgId].curTransform.rot.z, colCtx->dyna.bgActors[bgId].curTransform.pos.x,
colCtx->dyna.bgActors[bgId].curTransform.pos.y, colCtx->dyna.bgActors[bgId].curTransform.pos.z);
SkinMatrix_Vec3fMtxFMultXYZ(&prevTransformInv, &actor->posRot.pos, &tempPos);
SkinMatrix_Vec3fMtxFMultXYZ(&curTransform, &tempPos, &pos);
actor->posRot.pos = pos;
if (BGCHECK_XYZ_ABSMAX <= pos.x || pos.x <= -BGCHECK_XYZ_ABSMAX || BGCHECK_XYZ_ABSMAX <= pos.y ||
pos.y <= -BGCHECK_XYZ_ABSMAX || BGCHECK_XYZ_ABSMAX <= pos.z || pos.z <= -BGCHECK_XYZ_ABSMAX) {
if (actor->id == 0) {
((Player*)actor)->currentYaw += v1;
osSyncPrintf(VT_FGCOL(RED));
// @bug file and line are not passed to osSyncPrintf
// Position is not valid
osSyncPrintf(
"BGCheckCollection_typicalActorPos():位置が妥当ではありません。\npos (%f,%f,%f) file:%s line:%d\n",
pos.x, pos.y, pos.z);
osSyncPrintf(VT_RST);
}
}
actor->shape.rot.y += v1;
actor->posRot.rot.y += v1;
}
}
void func_80043334(CollisionContext* colCtx, Actor* actor, u32 floorPolySource) {
if (func_8003E934(floorPolySource) != 0) {
DynaPolyActor* dynaActor = DynaPolyInfo_GetActor(colCtx, floorPolySource);
/**
* Rotate actor
*/
void func_800432A0(CollisionContext* colCtx, s32 bgId, Actor* actor) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
s16 rot = colCtx->dyna.bgActors[bgId].curTransform.rot.y - colCtx->dyna.bgActors[bgId].prevTransform.rot.y;
if (actor->id == ACTOR_PLAYER) {
((Player*)actor)->currentYaw += rot;
}
actor->shape.rot.y += rot;
actor->posRot.rot.y += rot;
}
}
void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
DynaPolyActor* dynaActor = DynaPoly_GetActor(colCtx, bgId);
if (dynaActor != NULL) {
func_800434A8(dynaActor);
@ -28,33 +69,37 @@ void func_80043334(CollisionContext* colCtx, Actor* actor, u32 floorPolySource)
}
}
s32 func_800433A4(CollisionContext* colCtx, u32 floorPolySource, Actor* actor) {
s32 sp24 = 0;
/**
* Transform actor's position
* `actor` is the actor to update
*/
s32 func_800433A4(CollisionContext* colCtx, s32 bgId, Actor* actor) {
s32 result = false;
DynaPolyActor* dynaActor;
if (func_8003E934(floorPolySource) == 0) {
return 0;
if (DynaPoly_IsBgIdBgActor(bgId) == false) {
return false;
}
if ((colCtx->dyna.flags[floorPolySource] & 2) || !(colCtx->dyna.flags[floorPolySource] & 1)) {
return 0;
if ((colCtx->dyna.bgActorFlags[bgId] & 2) || !(colCtx->dyna.bgActorFlags[bgId] & 1)) {
return false;
}
dynaActor = DynaPolyInfo_GetActor(colCtx, floorPolySource);
dynaActor = (DynaPolyActor*)DynaPoly_GetActor(colCtx, bgId);
if (dynaActor == NULL) {
return 0;
return false;
}
if (dynaActor->unk_15C & 1) {
func_800430A0(colCtx, floorPolySource, actor);
sp24 = 1;
func_800430A0(colCtx, bgId, actor);
result = true;
}
if (dynaActor->unk_15C & 2) {
func_800432A0(colCtx, floorPolySource, actor);
sp24 = 1;
func_800432A0(colCtx, bgId, actor);
result = true;
}
return sp24;
return result;
}

View file

@ -1,7 +1,7 @@
#include "global.h"
void DynaPolyInfo_SetActorMove(DynaPolyActor* dynaActor, DynaPolyMoveFlag flags) {
dynaActor->dynaPolyId = -1;
void DynaPolyActor_Init(DynaPolyActor* dynaActor, DynaPolyMoveFlag flags) {
dynaActor->bgId = -1;
dynaActor->unk_15C = flags;
dynaActor->unk_160 = 0;
dynaActor->unk_150 = 0.0f;
@ -20,8 +20,8 @@ void func_800434B8(DynaPolyActor* dynaActor) {
dynaActor->unk_160 |= 2;
}
void func_800434C8(CollisionContext* colCtx, u32 floorPolySource) {
DynaPolyActor* dynaActor = DynaPolyInfo_GetActor(colCtx, floorPolySource);
void func_800434C8(CollisionContext* colCtx, s32 floorPolySource) {
DynaPolyActor* dynaActor = (DynaPolyActor*)DynaPoly_GetActor(colCtx, floorPolySource);
if (dynaActor != NULL) {
func_800434B8(dynaActor);
@ -32,8 +32,8 @@ void func_800434F8(DynaPolyActor* dynaActor) {
dynaActor->unk_160 |= 4;
}
void func_80043508(CollisionContext* colCtx, u32 floorPolySource) {
DynaPolyActor* dynaActor = DynaPolyInfo_GetActor(colCtx, floorPolySource);
void func_80043508(CollisionContext* colCtx, s32 floorPolySource) {
DynaPolyActor* dynaActor = (DynaPolyActor*)DynaPoly_GetActor(colCtx, floorPolySource);
if (dynaActor != NULL) {
func_800434F8(dynaActor);
@ -46,34 +46,72 @@ void func_80043538(DynaPolyActor* dynaActor) {
s32 func_80043548(DynaPolyActor* dynaActor) {
if (dynaActor->unk_160 & 1) {
return 1;
return true;
} else {
return 0;
return false;
}
}
s32 func_8004356C(DynaPolyActor* dynaActor) {
if (dynaActor->unk_160 & 2) {
return 1;
return true;
} else {
return 0;
return false;
}
}
s32 func_80043590(DynaPolyActor* dynaActor) {
if (dynaActor->unk_160 & 4) {
return 1;
return true;
} else {
return 0;
return false;
}
}
s32 func_800435B4(DynaPolyActor* dynaActor) {
if (dynaActor->unk_160 & 8) {
return 1;
return true;
} else {
return 0;
return false;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80043480/func_800435D8.s")
s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* actor, s16 arg2, s16 arg3, s16 arg4) {
Vec3f posA;
Vec3f posB;
Vec3f posResult;
f32 sin;
f32 cos;
s32 bgId;
CollisionPoly* poly;
f32 a2;
f32 a3;
f32 sign;
sin = Math_SinS(actor->unk_158);
cos = Math_CosS(actor->unk_158);
sign = (0.0f <= actor->unk_150) ? 1.0f : -1.0f;
a2 = (f32)arg2 - 0.1f;
posA.x = actor->actor.posRot.pos.x + (a2 * cos);
posA.y = actor->actor.posRot.pos.y + arg4;
posA.z = actor->actor.posRot.pos.z - (a2 * sin);
a3 = (f32)arg3 - 0.1f;
posB.x = sign * a3 * sin + posA.x;
posB.y = posA.y;
posB.z = sign * a3 * cos + posA.z;
if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId,
actor, 0.0f)) {
return false;
}
posA.x = (actor->actor.posRot.pos.x * 2) - posA.x;
posA.z = (actor->actor.posRot.pos.z * 2) - posA.z;
posB.x = sign * a3 * sin + posA.x;
posB.z = sign * a3 * cos + posA.z;
if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId,
actor, 0.0f)) {
return false;
}
return true;
}

View file

@ -821,7 +821,7 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) {
actor->uncullZoneScale = 350.0f;
actor->uncullZoneDownward = 700.0f;
func_80061E48(&actor->colChkInfo);
actor->floorPolySource = 0x32;
actor->floorPolySource = BGCHECK_SCENE;
ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f);
if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) {
Actor_SetObjectDependency(globalCtx, actor);
@ -1142,30 +1142,30 @@ s32 func_8002E234(Actor* actor, f32 arg1, s32 arg2) {
return 1;
}
UNK_TYPE D_8015BBA0;
u32 D_8015BBA4;
CollisionPoly* D_8015BBA0;
s32 D_8015BBA4;
s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3) {
f32 sp34;
s32 sp30;
s32 bgId;
arg2->y += 50.0f;
actor->groundY = func_8003CA0C(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &sp30, actor, arg2);
actor->groundY = BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &bgId, actor, arg2);
actor->bgCheckFlags &= ~0x0086;
if (actor->groundY <= -32000.0f) {
return func_8002E234(actor, -32000.0f, arg3);
if (actor->groundY <= BGCHECK_Y_MIN) {
return func_8002E234(actor, BGCHECK_Y_MIN, arg3);
}
sp34 = actor->groundY - actor->posRot.pos.y;
actor->floorPolySource = sp30;
actor->floorPolySource = bgId;
if (sp34 >= 0.0f) {
actor->bgCheckFlags |= 0x80;
if (actor->bgCheckFlags & 0x10) {
if (sp30 != D_8015BBA4) {
if (bgId != D_8015BBA4) {
if (sp34 > 15.0f) {
actor->bgCheckFlags |= 0x100;
}
@ -1204,29 +1204,29 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f
f32 sp74;
s32 pad;
Vec3f sp64;
u32 sp60;
s32 bgId;
CollisionPoly* sp5C;
f32 sp58;
WaterBox* sp54;
WaterBox* waterBox;
f32 sp50;
Vec3f ripplePos;
sp74 = actor->posRot.pos.y - actor->pos4.y;
if ((actor->floorPolySource != 0x32) && (actor->bgCheckFlags & 1)) {
if ((actor->floorPolySource != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) {
func_800433A4(&globalCtx->colCtx, actor->floorPolySource, actor);
}
if (arg5 & 1) {
if ((!(arg5 & 0x80) && func_8003D52C(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4, arg3,
&actor->wallPoly, &sp60, actor, arg2)) ||
((arg5 & 0x80) && func_8003D594(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4, arg3,
&actor->wallPoly, &sp60, actor, arg2))) {
if ((!(arg5 & 0x80) && BgCheck_EntitySphVsWall3(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4,
arg3, &actor->wallPoly, &bgId, actor, arg2)) ||
((arg5 & 0x80) && BgCheck_EntitySphVsWall4(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4,
arg3, &actor->wallPoly, &bgId, actor, arg2))) {
sp5C = actor->wallPoly;
Math_Vec3f_Copy(&actor->posRot.pos, &sp64);
actor->wallPolyRot = Math_Atan2S(sp5C->norm.z, sp5C->norm.x);
actor->wallPolyRot = Math_Atan2S(sp5C->normal.z, sp5C->normal.x);
actor->bgCheckFlags |= 8;
actor->wallPolySource = sp60;
actor->wallPolySource = bgId;
} else {
actor->bgCheckFlags &= ~8;
}
@ -1237,7 +1237,8 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f
if (arg5 & 2) {
sp64.y = actor->pos4.y + 10.0f;
if (func_8003D7A0(&globalCtx->colCtx, &sp58, &sp64, (arg4 + sp74) - 10.0f, &D_8015BBA0, &D_8015BBA4, actor)) {
if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &sp58, &sp64, (arg4 + sp74) - 10.0f, &D_8015BBA0,
&D_8015BBA4, actor)) {
actor->bgCheckFlags |= 0x10;
actor->posRot.pos.y = (sp58 + sp74) - 10.0f;
} else {
@ -1249,7 +1250,8 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f
sp64.y = actor->pos4.y;
func_8002E2AC(globalCtx, actor, &sp64, arg5);
sp50 = actor->posRot.pos.y;
if (func_8004213C(globalCtx, &globalCtx->colCtx, actor->posRot.pos.x, actor->posRot.pos.z, &sp50, &sp54)) {
if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->posRot.pos.x, actor->posRot.pos.z, &sp50,
&waterBox)) {
actor->yDistToWater = sp50 - actor->posRot.pos.y;
if (actor->yDistToWater < 0.0f) {
actor->bgCheckFlags &= ~0x60;
@ -1269,7 +1271,7 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f
}
} else {
actor->bgCheckFlags &= ~0x60;
actor->yDistToWater = -32000.0f;
actor->yDistToWater = BGCHECK_Y_MIN;
}
}
}
@ -1674,7 +1676,7 @@ void func_8002F850(GlobalContext* globalCtx, Actor* actor) {
sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG;
}
} else {
sfxId = func_80041F34(&globalCtx->colCtx, actor->floorPoly, actor->floorPolySource);
sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, actor->floorPoly, actor->floorPolySource);
}
func_80078914(&actor->projectedPos, NA_SE_EV_BOMB_BOUND);
@ -1716,15 +1718,16 @@ void func_8002F994(Actor* actor, s32 arg1) {
}
}
s32 func_8002F9EC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* arg2, u32 arg3, Vec3f* arg4) {
if (func_80041D4C(&globalCtx->colCtx, arg2, arg3) == 8) {
// Tests if something hit Jabu Jabu surface, displaying hit splash and playing sfx if true
s32 func_8002F9EC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos) {
if (func_80041D4C(&globalCtx->colCtx, poly, bgId) == 8) {
globalCtx->unk_11D30[0] = 1;
func_8005DFAC(globalCtx, 0, arg4);
func_8005DFAC(globalCtx, NULL, pos);
Audio_PlayActorSound2(actor, NA_SE_IT_WALL_HIT_BUYO);
return 1;
return true;
}
return 0;
return false;
}
// Local data used for Farore's Wind light (stored in BSS, possibly a struct?)
@ -2104,7 +2107,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
if (i == ACTORTYPE_BG) {
func_8003F984(globalCtx, &globalCtx->colCtx.dyna);
DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna);
}
}
@ -2125,7 +2128,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
func_8002C7BC(&actorCtx->targetCtx, player, actor, globalCtx);
TitleCard_Update(globalCtx, &actorCtx->titleCtx);
func_8003FB64(globalCtx, &globalCtx->colCtx.dyna);
DynaPoly_UpdateBgActorTransforms(globalCtx, &globalCtx->colCtx.dyna);
}
void Actor_FaultPrint(Actor* actor, char* command) {
@ -2927,9 +2930,9 @@ void func_800328D4(GlobalContext* globalCtx, ActorContext* actorCtx, Player* pla
if (actor != sp84) {
var = func_8002EFC0(actor, player, D_8015BBFC);
if ((var < D_8015BBF0) && func_8002F090(actor, var) && func_80032880(globalCtx, actor) &&
(!func_8003DD6C(&globalCtx->colCtx, &player->actor.posRot2.pos, &actor->posRot2.pos, &sp70, &sp80,
1, 1, 1, 1, &sp7C) ||
func_80042048(&globalCtx->colCtx, sp80, sp7C))) {
(!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.posRot2.pos, &actor->posRot2.pos,
&sp70, &sp80, 1, 1, 1, 1, &sp7C) ||
SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C))) {
if (actor->unk_10D != 0) {
if (actor->unk_10D < D_8015BBF8) {
D_8015BBEC = actor;
@ -3433,7 +3436,7 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx)
sp50.y = arg0->y + 1.0f;
sp50.z = arg0->z;
var = func_8003C8EC(globalCtx, &globalCtx->colCtx, &sp4C, &sp50);
var = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp4C, &sp50);
if (sp4C != NULL) {
func_80038A28(sp4C, arg0->x, var, arg0->z, &sp60);
@ -4113,9 +4116,9 @@ void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2) {
if (actor->floorPoly != NULL) {
floorPoly = actor->floorPoly;
sp44 = floorPoly->norm.x * (1.0f / 32767);
sp40 = floorPoly->norm.y * (1.0f / 32767);
sp3C = floorPoly->norm.z * (1.0f / 32767);
sp44 = COLPOLY_GET_NORMAL(floorPoly->normal.x);
sp40 = COLPOLY_GET_NORMAL(floorPoly->normal.y);
sp3C = COLPOLY_GET_NORMAL(floorPoly->normal.z);
sp38 = Math_SinS(arg1);
sp34 = Math_CosS(arg1);

File diff suppressed because it is too large Load diff

View file

@ -215,7 +215,7 @@ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) {
fromToOffset.r += 8.0f;
Camera_Vec3fVecSphGeoAdd(&toPoint, from, &fromToOffset);
if (!func_8003DD6C(colCtx, from, &toPoint, &toNewPos, &to->poly, 1, 1, 1, -1, &to->bgId)) {
if (!BgCheck_CameraLineTest1(colCtx, from, &toPoint, &toNewPos, &to->poly, 1, 1, 1, -1, &to->bgId)) {
// no poly in path.
OLib_Vec3fDistNormalize(&fromToNorm, from, &to->pos);
@ -225,7 +225,7 @@ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) {
toNewPos = to->pos;
toNewPos.y += 5.0f;
floorPolyY = func_8003CCA4(colCtx, &floorPoly, &floorBgId, &toNewPos);
floorPolyY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, &floorBgId, &toNewPos);
if ((to->pos.y - floorPolyY) > 5.0f) {
// if the y distance from the check point to the floor is more than 5 units
@ -241,9 +241,9 @@ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) {
to->bgId = floorBgId;
}
to->norm.x = to->poly->norm.x * COLPOLY_NORM_FRAC;
to->norm.y = to->poly->norm.y * COLPOLY_NORM_FRAC;
to->norm.z = to->poly->norm.z * COLPOLY_NORM_FRAC;
to->norm.x = COLPOLY_GET_NORMAL(to->poly->normal.x);
to->norm.y = COLPOLY_GET_NORMAL(to->poly->normal.y);
to->norm.z = COLPOLY_GET_NORMAL(to->poly->normal.z);
to->pos.x = to->norm.x + toNewPos.x;
to->pos.y = to->norm.y + toNewPos.y;
to->pos.z = to->norm.z + toNewPos.z;
@ -278,14 +278,14 @@ s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) {
OLib_Vec3fDiffToVecSphGeo(&fromToGeo, from, &to->pos);
fromToGeo.r += 8.0f;
Camera_Vec3fVecSphGeoAdd(&toPos, from, &fromToGeo);
if (!func_8003DD6C(colCtx, from, &toPos, &toNewPos, &to->poly, 1, 1, 1, -1, &to->bgId)) {
if (!BgCheck_CameraLineTest1(colCtx, from, &toPos, &toNewPos, &to->poly, 1, 1, 1, -1, &to->bgId)) {
OLib_Vec3fDistNormalize(&fromToNorm, from, &to->pos);
to->norm.x = -fromToNorm.x;
to->norm.y = -fromToNorm.y;
to->norm.z = -fromToNorm.z;
toNewPos = to->pos;
toNewPos.y += 5.0f;
floorY = func_8003CCA4(colCtx, &floorPoly, &bgId, &toNewPos);
floorY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, &bgId, &toNewPos);
if ((to->pos.y - floorY) > 5.0f) {
// to is not on the ground or below it.
to->pos.x += to->norm.x;
@ -298,17 +298,17 @@ s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) {
toNewPos.y = floorY + 1.0f;
to->bgId = bgId;
}
to->norm.x = to->poly->norm.x * COLPOLY_NORM_FRAC;
to->norm.y = to->poly->norm.y * COLPOLY_NORM_FRAC;
to->norm.z = to->poly->norm.z * COLPOLY_NORM_FRAC;
to->norm.x = COLPOLY_GET_NORMAL(to->poly->normal.x);
to->norm.y = COLPOLY_GET_NORMAL(to->poly->normal.y);
to->norm.z = COLPOLY_GET_NORMAL(to->poly->normal.z);
if ((to->norm.y > 0.5f) || (to->norm.y < -0.8f)) {
to->pos.x = to->norm.x + toNewPos.x;
to->pos.y = to->norm.y + toNewPos.y;
to->pos.z = to->norm.z + toNewPos.z;
} else if (playerFloorPoly != NULL) {
playerFloorNormF.x = playerFloorPoly->norm.x * COLPOLY_NORM_FRAC;
playerFloorNormF.y = playerFloorPoly->norm.y * COLPOLY_NORM_FRAC;
playerFloorNormF.z = playerFloorPoly->norm.z * COLPOLY_NORM_FRAC;
playerFloorNormF.x = COLPOLY_GET_NORMAL(playerFloorPoly->normal.x);
playerFloorNormF.y = COLPOLY_GET_NORMAL(playerFloorPoly->normal.y);
playerFloorNormF.z = COLPOLY_GET_NORMAL(playerFloorPoly->normal.z);
if (Math3D_LineSegVsPlane(playerFloorNormF.x, playerFloorNormF.y, playerFloorNormF.z, playerFloorPoly->dist,
from, &toPos, &toNewPos, 1)) {
// line is from->to is touching the poly the player is on.
@ -353,7 +353,8 @@ s32 Camera_CheckOOB(Camera* camera, Vec3f* from, Vec3f* to) {
CollisionContext* colCtx = &camera->globalCtx->colCtx;
poly = NULL;
if (func_8003DD6C(colCtx, from, to, &intersect, &poly, 1, 1, 1, 0, &bgId) && (func_80038B7C(poly, from) < 0.0f)) {
if (BgCheck_CameraLineTest1(colCtx, from, to, &intersect, &poly, 1, 1, 1, 0, &bgId) &&
(CollisionPoly_GetPointDistanceFromPlane(poly, from) < 0.0f)) {
// if there is a poly between `from` and `to` and the `from` is behind the poly.
return true;
}
@ -368,7 +369,7 @@ s32 Camera_CheckOOB(Camera* camera, Vec3f* from, Vec3f* to) {
f32 Camera_GetFloorYNorm(Camera* camera, Vec3f* floorNorm, Vec3f* chkPos, s32* bgId) {
s32 pad;
CollisionPoly* floorPoly;
f32 floorY = func_8003C940(&camera->globalCtx->colCtx, &floorPoly, bgId, chkPos);
f32 floorY = BgCheck_EntityRaycastFloor3(&camera->globalCtx->colCtx, &floorPoly, bgId, chkPos);
if (floorY == BGCHECK_Y_MIN) {
// no floor
@ -376,9 +377,9 @@ f32 Camera_GetFloorYNorm(Camera* camera, Vec3f* floorNorm, Vec3f* chkPos, s32* b
floorNorm->y = 1.0f;
floorNorm->z = 0.0f;
} else {
floorNorm->x = floorPoly->norm.x * COLPOLY_NORM_FRAC;
floorNorm->y = floorPoly->norm.y * COLPOLY_NORM_FRAC;
floorNorm->z = floorPoly->norm.z * COLPOLY_NORM_FRAC;
floorNorm->x = COLPOLY_GET_NORMAL(floorPoly->normal.x);
floorNorm->y = COLPOLY_GET_NORMAL(floorPoly->normal.y);
floorNorm->z = COLPOLY_GET_NORMAL(floorPoly->normal.z);
}
return floorY;
@ -409,9 +410,9 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, u32* bgId) {
s32 i;
for (i = 3; i > 0; i--) {
floorY = func_8003CCA4(colCtx, &floorPoly, bgId, pos);
floorY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, bgId, pos);
if (floorY == BGCHECK_Y_MIN ||
(camera->playerGroundY < floorY && !((floorPoly->norm.y * COLPOLY_NORM_FRAC) > 0.5f))) {
(camera->playerGroundY < floorY && !(COLPOLY_GET_NORMAL(floorPoly->normal.y) > 0.5f))) {
// no floor, or player is below the floor and floor is not considered steep
norm->x = 0.0f;
norm->y = 1.0f;
@ -423,9 +424,9 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, u32* bgId) {
pos->y = floorY - 10.0f;
continue;
} else {
norm->x = floorPoly->norm.x * COLPOLY_NORM_FRAC;
norm->y = floorPoly->norm.y * COLPOLY_NORM_FRAC;
norm->z = floorPoly->norm.z * COLPOLY_NORM_FRAC;
norm->x = COLPOLY_GET_NORMAL(floorPoly->normal.x);
norm->y = COLPOLY_GET_NORMAL(floorPoly->normal.y);
norm->z = COLPOLY_GET_NORMAL(floorPoly->normal.z);
break;
}
}
@ -439,14 +440,14 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, u32* bgId) {
* Returns the CameraSettingType of the camera at index `camDataIdx`
*/
s16 Camera_GetCamDataSetting(Camera* camera, s32 camDataIdx) {
return func_80041A4C(&camera->globalCtx->colCtx, camDataIdx, 50);
return func_80041A4C(&camera->globalCtx->colCtx, camDataIdx, BGCHECK_SCENE);
}
/**
* Returns the scene camera info for the current camera data index
*/
Vec3s* Camera_GetCamBGData(Camera* camera) {
return func_80041C10(&camera->globalCtx->colCtx, camera->camDataIdx, 50);
return func_80041C10(&camera->globalCtx->colCtx, camera->camDataIdx, BGCHECK_SCENE);
}
/**
@ -459,7 +460,7 @@ s32 Camera_GetDataIdxForPoly(Camera* camera, u32* bgId, CollisionPoly* poly) {
s32 ret;
func_8002EF44(&playerPosRot, &camera->player->actor); // unused.
camDataIdx = func_80041A28(&camera->globalCtx->colCtx, poly, *bgId);
camDataIdx = SurfaceType_GetCamDataIndex(&camera->globalCtx->colCtx, poly, *bgId);
if (func_80041A4C(&camera->globalCtx->colCtx, camDataIdx, *bgId) == CAM_SET_NONE) {
ret = -1;
@ -482,12 +483,13 @@ Vec3s* Camera_GetCamBgDataUnderPlayer(Camera* camera, u16* dataCnt) {
func_8002EF44(&playerPosShape, &camera->player->actor);
playerPosShape.pos.y += Player_GetHeight(camera->player);
if (func_8003C940(&camera->globalCtx->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == BGCHECK_Y_MIN) {
if (BgCheck_EntityRaycastFloor3(&camera->globalCtx->colCtx, &floorPoly, &bgId, &playerPosShape.pos) ==
BGCHECK_Y_MIN) {
// no floor
return NULL;
}
*dataCnt = func_80041B80(&camera->globalCtx->colCtx, floorPoly, bgId);
return func_80041C98(&camera->globalCtx->colCtx, floorPoly, bgId);
*dataCnt = SurfaceType_GetNumCameras(&camera->globalCtx->colCtx, floorPoly, bgId);
return SurfaceType_GetCamPosData(&camera->globalCtx->colCtx, floorPoly, bgId);
}
/**
@ -504,8 +506,8 @@ s32 Camera_GetWaterBoxDataIdx(Camera* camera, f32* waterY) {
func_8002EF44(&playerPosShape, &camera->player->actor);
*waterY = playerPosShape.pos.y;
if (!func_8004213C(camera->globalCtx, &camera->globalCtx->colCtx, playerPosShape.pos.x, playerPosShape.pos.z,
waterY, &waterBox)) {
if (!WaterBox_GetSurface1(camera->globalCtx, &camera->globalCtx->colCtx, playerPosShape.pos.x, playerPosShape.pos.z,
waterY, &waterBox)) {
// player's position is not in a water box.
*waterY = BGCHECK_Y_MIN;
return -1;
@ -517,8 +519,8 @@ s32 Camera_GetWaterBoxDataIdx(Camera* camera, f32* waterY) {
return -1;
}
ret = func_80042538(&camera->globalCtx->colCtx, waterBox);
if ((ret <= 0) || (func_80042548(&camera->globalCtx->colCtx, waterBox) <= 0)) {
ret = WaterBox_GetCamDataIndex(&camera->globalCtx->colCtx, waterBox);
if ((ret <= 0) || (WaterBox_GetCameraSType(&camera->globalCtx->colCtx, waterBox) <= 0)) {
// no camera data idx, or no CameraSettingType
return -2;
}
@ -539,7 +541,8 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* envProp) {
func_8002EF44(&playerPosRot, &camera->player->actor);
waterY = playerPosRot.pos.y;
if (!func_8004213C(camera->globalCtx, &camera->globalCtx->colCtx, chkPos->x, chkPos->z, &waterY, &waterBox)) {
if (!WaterBox_GetSurface1(camera->globalCtx, &camera->globalCtx->colCtx, chkPos->x, chkPos->z, &waterY,
&waterBox)) {
// chkPos is not within the x/z boundaries of a water box.
return BGCHECK_Y_MIN;
}
@ -550,7 +553,7 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* envProp) {
return BGCHECK_Y_MIN;
}
*envProp = func_8004259C(&camera->globalCtx->colCtx, waterBox);
*envProp = WaterBox_GetLightSettingIndex(&camera->globalCtx->colCtx, waterBox);
return waterY;
}
@ -1284,7 +1287,7 @@ s16 Camera_CalcDefaultYaw(Camera* camera, s16 cur, s16 target, f32 arg3, f32 acc
if (camera->xzSpeed > 0.001f) {
angDelta = target - BINANG_ROT180(cur);
speedT = BINANG_ROT180(angDelta) * COLPOLY_NORM_FRAC;
speedT = COLPOLY_GET_NORMAL(BINANG_ROT180(angDelta));
} else {
angDelta = target - BINANG_ROT180(cur);
speedT = PCT(OREG(48));
@ -3603,7 +3606,7 @@ s32 Camera_KeepOn4(Camera* camera) {
OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext);
D_8015BD50 = playerPosRot->pos;
D_8015BD50.y += playerHeight;
temp_f0_2 = func_8003CCA4(&camera->globalCtx->colCtx, &spC0, &i, &D_8015BD50);
temp_f0_2 = BgCheck_CameraRaycastFloor2(&camera->globalCtx->colCtx, &spC0, &i, &D_8015BD50);
if (temp_f0_2 > (keep4->unk_00 + D_8015BD50.y)) {
D_8015BD50.y = temp_f0_2 + 10.0f;
} else {
@ -6833,7 +6836,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, GlobalCon
camera->setting = camera->prevSetting = 0x21;
camera->camDataIdx = camera->prevCamDataIdx = -1;
camera->mode = 0;
camera->bgCheckId = 0x32;
camera->bgCheckId = BGCHECK_SCENE;
camera->unk_168 = 0x7FFF;
camera->timer = -1;
camera->unk_14C |= 0x4000;
@ -7092,7 +7095,7 @@ s32 Camera_CheckWater(Camera* camera) {
}
if (camera->playerGroundY != camera->playerPosRot.pos.y) {
prevBgId = camera->bgCheckId;
camera->bgCheckId = 50;
camera->bgCheckId = BGCHECK_SCENE;
Camera_ChangeSettingFlags(camera, CAM_SET_NORMAL3, 2);
*waterPrevCamSetting = camera->setting;
camera->bgCheckId = prevBgId;
@ -7108,7 +7111,7 @@ s32 Camera_CheckWater(Camera* camera) {
}
if (camera->playerGroundY != camera->playerPosRot.pos.y) {
prevBgId = camera->bgCheckId;
camera->bgCheckId = 50;
camera->bgCheckId = BGCHECK_SCENE;
Camera_ChangeDataIdx(camera, waterCamIdx);
*waterPrevCamSetting = camera->setting;
camera->bgCheckId = prevBgId;
@ -7118,7 +7121,7 @@ s32 Camera_CheckWater(Camera* camera) {
osSyncPrintf("camera: water: off\n");
camera->unk_14C &= ~0x200;
prevBgId = camera->bgCheckId;
camera->bgCheckId = 50;
camera->bgCheckId = BGCHECK_SCENE;
if (camera->waterPrevCamIdx < 0) {
func_80057FC4(camera);
camera->camDataIdx = -1;
@ -7342,14 +7345,14 @@ Vec3s* Camera_Update(Vec3s* outVec, Camera* camera) {
spAC = curPlayerPosRot.pos;
spAC.y += Player_GetHeight(camera->player);
playerGroundY = func_8003CA0C(camera->globalCtx, &camera->globalCtx->colCtx, &playerFloorPoly, &bgCheckId,
&camera->player->actor, &spAC);
playerGroundY = BgCheck_EntityRaycastFloor5(camera->globalCtx, &camera->globalCtx->colCtx, &playerFloorPoly,
&bgCheckId, &camera->player->actor, &spAC);
if (playerGroundY != BGCHECK_Y_MIN) {
// player is above ground.
sOOBTimer = 0;
camera->floorNorm.x = playerFloorPoly->norm.x * COLPOLY_NORM_FRAC;
camera->floorNorm.y = playerFloorPoly->norm.y * COLPOLY_NORM_FRAC;
camera->floorNorm.z = playerFloorPoly->norm.z * COLPOLY_NORM_FRAC;
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 = bgCheckId;
camera->playerGroundY = playerGroundY;
} else {
@ -7378,7 +7381,7 @@ Vec3s* Camera_Update(Vec3s* outVec, Camera* camera) {
camDataIdx = Camera_GetDataIdxForPoly(camera, &bgCheckId, playerFloorPoly);
if (camDataIdx != -1) {
camera->nextBGCheckId = bgCheckId;
if (bgCheckId == 50) {
if (bgCheckId == BGCHECK_SCENE) {
camera->nextCamDataIdx = camDataIdx;
}
}

View file

@ -1025,10 +1025,10 @@ void CollisionCheck_Draw(GlobalContext* globalCtx, CollisionCheckContext* colChk
}
}
if (AREG(24)) {
func_80042C3C(globalCtx, &globalCtx->colCtx);
BgCheck_DrawDynaCollision(globalCtx, &globalCtx->colCtx);
}
if (AREG(25)) {
func_80042FC4(globalCtx, &globalCtx->colCtx);
BgCheck_DrawStaticCollision(globalCtx, &globalCtx->colCtx);
}
}
}
@ -1281,13 +1281,14 @@ s32 func_8005DF74(ColliderBody* left, ColliderBody* right) {
void func_8005DF9C(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
}
void func_8005DFAC(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
// Blue EffectSpark
void func_8005DFAC(GlobalContext* globalCtx, Collider* collider, Vec3f* pos) {
static EffectSparkInit D_8015D8A0;
s32 sp24;
D_8015D8A0.position.x = (s32)v->x;
D_8015D8A0.position.y = (s32)v->y;
D_8015D8A0.position.z = (s32)v->z;
D_8015D8A0.position.x = (s32)pos->x;
D_8015D8A0.position.y = (s32)pos->y;
D_8015D8A0.position.z = (s32)pos->z;
D_8015D8A0.uDiv = 5;
D_8015D8A0.vDiv = 5;
D_8015D8A0.colorStart[0].r = 10;
@ -1330,13 +1331,14 @@ void func_8005DFAC(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
Effect_Add(globalCtx, &sp24, EFFECT_SPARK, 0, 1, &D_8015D8A0);
}
void func_8005E10C(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
// Green EffectSpark
void func_8005E10C(GlobalContext* globalCtx, Collider* collider, Vec3f* pos) {
static EffectSparkInit D_8015DD68;
s32 sp24;
D_8015DD68.position.x = (s32)v->x;
D_8015DD68.position.y = (s32)v->y;
D_8015DD68.position.z = (s32)v->z;
D_8015DD68.position.x = (s32)pos->x;
D_8015DD68.position.y = (s32)pos->y;
D_8015DD68.position.z = (s32)pos->z;
D_8015DD68.uDiv = 5;
D_8015DD68.vDiv = 5;
D_8015DD68.colorStart[0].r = 10;
@ -1590,7 +1592,7 @@ void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo
sp60.x = rItem->dim.worldSphere.center.x;
sp60.y = rItem->dim.worldSphere.center.y;
sp60.z = rItem->dim.worldSphere.center.z;
if (!(fabsf(sp88) < 0.008f)) {
if (!IS_ZERO(sp88)) {
temp_f0 = rItem->dim.worldSphere.radius / sp88;
sp78.x = (((sp6C.x - sp60.x) * temp_f0) + sp60.x);
sp78.y = (((sp6C.y - sp60.y) * temp_f0) + sp60.y);
@ -1639,7 +1641,7 @@ void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte
sp58.x = right->dim.pos.x;
sp58.y = right->dim.pos.y;
sp58.z = right->dim.pos.z;
if (!(fabsf(sp7C) < 0.008f)) {
if (!IS_ZERO(sp7C)) {
temp_f0 = right->dim.radius / sp7C;
if (temp_f0 <= 1.0f) {
sp70.x = ((sp64.x - sp58.x) * temp_f0) + sp58.x;
@ -1689,7 +1691,7 @@ void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckConte
sp70.x = rItem->dim.worldSphere.center.x;
sp70.y = rItem->dim.worldSphere.center.y;
sp70.z = rItem->dim.worldSphere.center.z;
if (!(fabsf(sp98) < 0.008f)) {
if (!IS_ZERO(sp98)) {
temp_f0 = (f32)rItem->dim.worldSphere.radius / sp98;
if (temp_f0 <= 1.0f) {
sp88.x = ((sp7C.x - sp70.x) * temp_f0) + sp70.x;
@ -1908,7 +1910,7 @@ void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext*
if (Math3D_CylOutsideCylDist(&left->dim, &right->dim, &sp6C, &sp68) == 1) {
Math_Vec3s_ToVec3f(&sp50, &left->dim.pos);
Math_Vec3s_ToVec3f(&sp44, &right->dim.pos);
if (!(fabsf(sp68) < 0.008f)) {
if (!IS_ZERO(sp68)) {
temp_f0 = (f32)right->dim.radius / sp68;
sp5C.y = (f32)right->dim.pos.y + (f32)right->dim.yShift + (f32)right->dim.height * 0.5f;
sp5C.x = ((f32)left->dim.pos.x - right->dim.pos.x) * temp_f0 + right->dim.pos.x;
@ -2489,7 +2491,7 @@ void func_800614A4(Collider* left, ColliderBody* leftBody, Vec3f* leftv, Collide
leftMass = leftActor->colChkInfo.mass;
rightMass = rightActor->colChkInfo.mass;
totalMass = leftMass + rightMass;
if (fabsf(totalMass) < 0.008f) {
if (IS_ZERO(totalMass)) {
totalMass = (leftMass = rightMass = 1.0f) * 2;
}
xDelta = rightv->x - leftv->x;
@ -2525,7 +2527,7 @@ void func_800614A4(Collider* left, ColliderBody* leftBody, Vec3f* leftv, Collide
}
}
if (!(fabsf(xzDist) < 0.008f)) {
if (!IS_ZERO(xzDist)) {
temp_f0 = arg6 / xzDist;
xDelta *= temp_f0;
zDelta *= temp_f0;

View file

@ -39,8 +39,14 @@ static ColliderCylinderInit sCylinderInit = {
{ 25, 60, 0, { 0, 0, 0 } },
};
static UNK_PTR D_8011546C[] = {
0x040394B0, 0x040394B0, 0x0403A120, 0x0403A480, 0x0403A7F0, 0x06000730,
extern CollisionHeader D_040394B0;
extern CollisionHeader D_0403A120;
extern CollisionHeader D_0403A480;
extern CollisionHeader D_0403A7F0;
extern CollisionHeader D_06000730;
static CollisionHeader* D_8011546C[] = {
&D_040394B0, &D_040394B0, &D_0403A120, &D_0403A480, &D_0403A7F0, &D_06000730,
};
static Gfx* D_80115484[] = {
@ -53,7 +59,7 @@ void EnAObj_SetupAction(EnAObj* this, EnAObjActionFunc actionFunc) {
}
void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) {
u32 sp34 = 0;
CollisionHeader* colHeader = NULL;
s32 pad;
EnAObj* this = THIS;
f32 sp28;
@ -91,35 +97,35 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) {
ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawFunc_Circle, sp28);
thisx->posRot2.pos = thisx->posRot.pos;
this->dyna.dynaPolyId = -1;
this->dyna.bgId = BGACTOR_NEG_ONE;
this->dyna.unk_160 = 0;
this->dyna.unk_15C = 0;
this->dyna.unk_15C = DPM_UNK;
thisx->uncullZoneDownward = 1200.0f;
thisx->uncullZoneScale = 200.0f;
switch (thisx->params) {
case A_OBJ_BLOCK_LARGE:
case A_OBJ_BLOCK_HUGE:
this->dyna.dynaPolyId = 1;
this->dyna.bgId = 1;
Actor_ChangeType(globalCtx, &globalCtx->actorCtx, thisx, ACTORTYPE_BG);
func_8001D5C8(this, thisx->params);
break;
case A_OBJ_BLOCK_SMALL_ROT:
case A_OBJ_BLOCK_LARGE_ROT:
this->dyna.dynaPolyId = 3;
this->dyna.bgId = 3;
Actor_ChangeType(globalCtx, &globalCtx->actorCtx, thisx, ACTORTYPE_BG);
func_8001D310(this, thisx->params);
break;
case A_OBJ_UNKNOWN_6:
// clang-format off
thisx->flags |= 0x1; this->dyna.dynaPolyId = 5; this->unk_178 = 10.0f;
thisx->flags |= 0x1; this->dyna.bgId = 5; this->unk_178 = 10.0f;
// clang-format on
thisx->gravity = -2.0f;
func_8001D234(this, thisx->params);
break;
case A_OBJ_GRASS_CLUMP:
case A_OBJ_TREE_STUMP:
this->dyna.dynaPolyId = 0;
this->dyna.bgId = 0;
func_8001D234(this, thisx->params);
break;
case A_OBJ_SIGNPOST_OBLONG:
@ -149,16 +155,16 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) {
thisx->colChkInfo.mass = 0xFF;
}
if (this->dyna.dynaPolyId != -1) {
DynaPolyInfo_Alloc(D_8011546C[this->dyna.dynaPolyId], &sp34);
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, sp34);
if (this->dyna.bgId != BGACTOR_NEG_ONE) {
CollisionHeader_GetVirtual(D_8011546C[this->dyna.bgId], &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader);
}
}
void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnAObj* this = THIS;
DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
switch (this->dyna.actor.params) {
case A_OBJ_SIGNPOST_OBLONG:
@ -277,10 +283,7 @@ void func_8001D5C8(EnAObj* this, s16 params) {
void func_8001D608(EnAObj* this, GlobalContext* globalCtx) {
this->dyna.actor.speedXZ += this->dyna.unk_150;
this->dyna.actor.posRot.rot.y = this->dyna.unk_158;
this->dyna.actor.speedXZ = (this->dyna.actor.speedXZ < -2.5f)
? -2.5f
: ((this->dyna.actor.speedXZ > 2.5f) ? 2.5f : this->dyna.actor.speedXZ);
this->dyna.actor.speedXZ = CLAMP(this->dyna.actor.speedXZ, -2.5f, 2.5f);
Math_SmoothStepToF(&this->dyna.actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f);

View file

@ -471,9 +471,9 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if (D_80157D90 != globalCtx->gameplayFrames) {
D_80157D90_ = globalCtx->gameplayFrames;
D_80157D94 = 0;
for (i = 0; i < 50; i++) {
if (globalCtx->colCtx.dyna.flags[i] & 1) {
dynaActor = globalCtx->colCtx.dyna.actorMeshArr[i].actor;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if (globalCtx->colCtx.dyna.bgActorFlags[i] & 1) {
dynaActor = globalCtx->colCtx.dyna.bgActors[i].actor;
if ((dynaActor != NULL) && (dynaActor->update != NULL) &&
((dynaActor->posRot.pos.x != dynaActor->pos4.x) ||
(dynaActor->posRot.pos.y != dynaActor->pos4.y) ||

View file

@ -12,11 +12,11 @@ void func_8007C76C(Vec3f* src, Vec3s* dst) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_onepointdemo/func_8007C7A8.s")
void func_8007C7F8(CollisionContext* colCtx, Vec3f* arg1) {
void func_8007C7F8(CollisionContext* colCtx, Vec3f* pos) {
CollisionPoly* poly;
s32 bgId;
func_8003C940(colCtx, &poly, &bgId, arg1);
BgCheck_EntityRaycastFloor3(colCtx, &poly, &bgId, pos);
}
void func_8007C820(OnePointDemoCamera* onePointCamera, s16 actionParameters, s16 initTimer,

View file

@ -1379,39 +1379,39 @@ s32 Gameplay_InCsMode(GlobalContext* globalCtx) {
}
f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec) {
CollisionPoly sp50;
CollisionPoly poly;
f32 temp1;
f32 temp2;
f32 temp3;
f32 sp40;
f32 sp3C;
f32 sp38;
f32 sp34;
f32 floorY;
f32 nx;
f32 ny;
f32 nz;
s32 pad[5];
sp40 = func_8003CB30(&globalCtx->colCtx, &sp50, vec, mf);
floorY = BgCheck_AnyRaycastFloor1(&globalCtx->colCtx, &poly, vec);
if (sp40 > -32000.0f) {
sp3C = sp50.norm.x * (1.0f / 32767.0f);
sp38 = sp50.norm.y * (1.0f / 32767.0f);
sp34 = sp50.norm.z * (1.0f / 32767.0f);
if (floorY > BGCHECK_Y_MIN) {
nx = COLPOLY_GET_NORMAL(poly.normal.x);
ny = COLPOLY_GET_NORMAL(poly.normal.y);
nz = COLPOLY_GET_NORMAL(poly.normal.z);
temp1 = sqrtf(1.0f - SQ(sp3C));
temp1 = sqrtf(1.0f - SQ(nx));
if (temp1 != 0.0f) {
temp2 = sp38 * temp1;
temp3 = -sp34 * temp1;
temp2 = ny * temp1;
temp3 = -nz * temp1;
} else {
temp3 = 0.0f;
temp2 = 0.0f;
}
mf->xx = temp1;
mf->xy = -sp3C * temp2;
mf->xz = sp3C * temp3;
mf->yx = sp3C;
mf->yy = sp38;
mf->yz = sp34;
mf->xy = -nx * temp2;
mf->xz = nx * temp3;
mf->yx = nx;
mf->yy = ny;
mf->yz = nz;
mf->zy = temp3;
mf->zz = temp2;
mf->xw = 0.0f;
@ -1419,7 +1419,7 @@ f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec) {
mf->zx = 0.0f;
mf->zw = 0.0f;
mf->wx = vec->x;
mf->wy = sp40;
mf->wy = floorY;
mf->wz = vec->z;
mf->ww = 1.0f;
} else {
@ -1441,7 +1441,7 @@ f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec) {
mf->ww = 1.0f;
}
return sp40;
return floorY;
}
void* Gameplay_LoadFile(GlobalContext* globalCtx, RomFile* file) {
@ -1826,18 +1826,20 @@ s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw) {
return 1;
}
s32 func_800C0DB4(GlobalContext* globalCtx, Vec3f* arg1) {
WaterBox* sp3C;
CollisionPoly* sp38;
Vec3f sp2C;
s32 sp28;
s32 func_800C0DB4(GlobalContext* globalCtx, Vec3f* pos) {
WaterBox* waterBox;
CollisionPoly* poly;
Vec3f waterSurfacePos;
s32 bgId;
sp2C = *arg1;
waterSurfacePos = *pos;
if ((func_8004213C(globalCtx, &globalCtx->colCtx, sp2C.x, sp2C.z, &sp2C.y, &sp3C) == 1) && (arg1->y < sp2C.y) &&
(func_8003C940(&globalCtx->colCtx, &sp38, &sp28, &sp2C) != -32000.0f)) {
return 1;
if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
&waterBox) == true &&
pos->y < waterSurfacePos.y &&
BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN) {
return true;
} else {
return 0;
return false;
}
}

View file

@ -741,7 +741,7 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime,
footprintPos.y += 15.0f;
sp80 = func_8003C9A4(&globalCtx->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74;
sp80 = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74;
if (sp98.y < sp80) {
sp70 = sp98.x - spA4.x;
@ -783,7 +783,7 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime,
temp3 = func_80041D4C(&globalCtx->colCtx, sp88, sp84);
if ((temp3 >= 2) && (temp3 < 4) && !func_80042108(&globalCtx->colCtx, sp88, sp84)) {
if ((temp3 >= 2) && (temp3 < 4) && !SurfaceType_IsWallDamage(&globalCtx->colCtx, sp88, sp84)) {
footprintPos.y = sp80;
EffectSsGFire_Spawn(globalCtx, &footprintPos);
}
@ -1084,7 +1084,7 @@ void func_80090AFC(GlobalContext* globalCtx, Player* this, f32 arg2) {
if (1) {}
if (func_8003E188(&globalCtx->colCtx, &sp8C, &sp80, &sp74, &sp9C, 1, 1, 1, 1, &sp98)) {
if (BgCheck_AnyLineTest3(&globalCtx->colCtx, &sp8C, &sp80, &sp74, &sp9C, 1, 1, 1, 1, &sp98)) {
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2572);
OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x07);

View file

@ -389,7 +389,7 @@ BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) {
camera = ACTIVE_CAM;
camId = camera->camDataIdx;
// jfifid
camId2 = func_80041C10(&globalCtx->colCtx, camId, 50)[2].y;
camId2 = func_80041C10(&globalCtx->colCtx, camId, BGCHECK_SCENE)[2].y;
if (camId2 >= 0) {
camId = camId2;
}

View file

@ -220,13 +220,13 @@ void func_80098674(GlobalContext* globalCtx, SceneCmd* cmd) {
colHeader = SEGMENTED_TO_VIRTUAL(cmd->colHeader.segment);
colHeader->vertexArray = SEGMENTED_TO_VIRTUAL(colHeader->vertexArray);
colHeader->polygonArray = SEGMENTED_TO_VIRTUAL(colHeader->polygonArray);
colHeader->polygonTypes = SEGMENTED_TO_VIRTUAL(colHeader->polygonTypes);
colHeader->cameraData = SEGMENTED_TO_VIRTUAL(colHeader->cameraData);
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->waterBoxes = SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes);
func_8003C078(&globalCtx->colCtx, globalCtx, colHeader);
BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader);
}
// Scene Command 0x04: Room List