Fix collision (#18)

* Fix collision
This commit is contained in:
MegaMech
2024-06-14 03:03:51 -06:00
committed by GitHub
parent 0d629e466a
commit dd5844ab81
4 changed files with 26 additions and 25 deletions
+1
View File
@@ -56,6 +56,7 @@ GameEngine::GameEngine() {
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
wnd->SetRendererUCode(ucode_f3dex);
this->context->InitGfxDebugger();
auto loader = context->GetResourceManager()->GetResourceLoader();
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3fV0>(), RESOURCE_FORMAT_BINARY, "Vec3f", static_cast<uint32_t>(SF64::ResourceType::Vec3f), 0);
+1 -1
View File
@@ -123,7 +123,7 @@ void *segmented_uintptr_t_to_virtual(uintptr_t addr) {
uint32_t numCommands = offset / 8;
offset = numCommands * sizeof(Gfx);
printf("seg_gfx_to_virt: 0x%llX to 0x%llX\n", newAddr, (gSegmentTable[segment] + offset));
printf("seg_uintptr_t_to_virt: 0x%llX to 0x%llX\n", newAddr, (gSegmentTable[segment] + offset));
return (void *) ((gSegmentTable[segment] + offset));
}
+16 -23
View File
@@ -47,16 +47,24 @@ s32 func_80290C20(Camera *camera) {
return 0;
}
void parse_course_displaylists(TrackSections *addr) {
TrackSections *first = &addr[0];
TrackSections *section = &addr[0];
// Stupid hack to allocate memory to convert a u32 ptr DLs to 64 bit. Should probably be done in torch instead.
TrackSections trackSectionsBuffer[100];
void parse_course_displaylists(TrackSectionsI *addr) {
TrackSections *section = &trackSectionsBuffer[0];
while (addr->addr != 0) {
section->addr = segmented_uintptr_t_to_virtual(addr->addr);
section->flags = addr->flags;
section->sectionId = addr->sectionId;
section->surfaceType = addr->surfaceType;
while (section->addr != 0) {
printf("SECTION ADDR: 0x%X\n", section->addr);
section->addr = segmented_uintptr_t_to_virtual(section->addr);
section++;
addr++;
}
section = first;
section = &trackSectionsBuffer[0];
//section->surfaceType = addr->surfaceType;
//section->flags = addr->flags;
//section->sectionId = addr->sectionId;
@@ -92,7 +100,6 @@ void load_surface_map(const char* addr[], struct UnkStruct_800DC5EC *arg1) {
s16 sp1E;
s16 temp_v0_3;
u16 rot;
//printf("--------Loading Collision Mesh--------\n");
if (gIsMirrorMode) {
rot = (u16) camera->rot[1];
if (rot < 0x2000) {
@@ -181,7 +188,6 @@ void load_surface_map(const char* addr[], struct UnkStruct_800DC5EC *arg1) {
}
}
} else {
printf("ELSE\n");
temp_v1 = func_802ABD40(camera->unk_54.unk3A);
if (camera->unk_54.unk3C[2] > 30.0f) {
temp_v1 = arg1->pathCounter;
@@ -192,12 +198,7 @@ void load_surface_map(const char* addr[], struct UnkStruct_800DC5EC *arg1) {
arg1->pathCounter = temp_v1;
temp_v1 = ((temp_v1 - 1) * 4) + var_a3;
printf("----Collision DL Call----\n");
//printf("temp_v1: %d\n", temp_v1);
//printf("Call: %s\n", addr[temp_v1]);
gSPDisplayList(gDisplayListHead++, addr[0]);
printf("--------Collision Mesh Loaded--------\n");
gSPDisplayList(gDisplayListHead++, addr[temp_v1]);
}
void func_80291198(void) {
@@ -1420,14 +1421,6 @@ void func_80295D6C(void) {
D_8015F6F6 = -3000;
}
typedef struct {
uint16_t segment;
uint16_t offset;
uint8_t surfaceType;
uint8_t sectionId;
uint16_t flags;
} TrackSectionsI;
void func_80295D88(void) {
gNumActors = 0;
@@ -1458,7 +1451,7 @@ void func_80295D88(void) {
// d_course_mario_raceway_packed_dl_2D68
set_vertex_data_with_defaults((Gfx *) segmented_gfx_to_virtual(0x07002D68));
}
TrackSections *section = (TrackSections *) LOAD_ASSET(d_course_mario_raceway_addr);
TrackSectionsI *section = (TrackSectionsI *) LOAD_ASSET(d_course_mario_raceway_addr);
parse_course_displaylists(section);
func_80295C6C();
+8 -1
View File
@@ -4,9 +4,16 @@
#include "code_800029B0.h"
#include "../camera.h"
typedef struct {
u32 addr;
u8 surfaceType;
u8 sectionId;
u16 flags;
} TrackSectionsI;
void func_8029122C(struct UnkStruct_800DC5EC*, s32);
s32 func_80290C20(Camera*);
void parse_course_displaylists(uintptr_t);
void parse_course_displaylists(TrackSectionsI*);
void load_surface_map(const char*[], struct UnkStruct_800DC5EC*);
void func_80291198(void);
void func_802911C4(void);