identify shadows and fix mislabelling from past-me (#380)

This commit is contained in:
Fazana
2023-03-20 16:22:17 +00:00
committed by GitHub
parent c3a26c8af1
commit c9fa292c3d
9 changed files with 924 additions and 924 deletions
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -718,12 +718,12 @@ typedef struct ObjectInteraction {
s8 unk17;
} ObjectInteraction;
typedef struct Object_50 {
f32 unk0;
u8 pad4[0x4];
typedef struct ShadowData {
f32 scale;
TextureHeader *texture;
s16 unk8;
s16 unkA;
} Object_50;
} ShadowData;
typedef struct Object_54 {
f32 unk0;
@@ -1727,7 +1727,7 @@ typedef struct Object {
/* 0x004C */ f32 unk4C_f32;
};
union {
/* 0x0050 */ Object_50 *unk50; //player + 0x2F4
/* 0x0050 */ ShadowData *shadow; //player + 0x2F4
/* 0x0050 */ f32 unk50_f32;
};
union {
+20 -20
View File
@@ -139,7 +139,7 @@ void obj_init_scenery(Object *obj, LevelObjectEntry_Scenery *entry) {
}
phi_f0 /= 64;
obj->segment.trans.scale = obj->segment.header->scale * phi_f0;
((Object_50_Scenery *)obj->unk50)->unk0 = obj->segment.header->unk4 * phi_f0;
obj->shadow->scale = obj->segment.header->unk4 * phi_f0;
obj->segment.unk38.byte.unk3A = entry->unk8;
obj->segment.trans.y_rotation = entry->unkA << 6 << 4;
if (entry->unkB) {
@@ -895,7 +895,7 @@ void obj_loop_airzippers_waterzippers(Object *obj, UNUSED s32 updateRate) {
}
}
void obj_init_groundzipper(Object *arg0, LevelObjectEntry_GroundZipper *entry) {
void obj_init_groundzipper(Object *obj, LevelObjectEntry_GroundZipper *entry) {
ObjectHeader *header;
f32 objScale;
@@ -904,28 +904,28 @@ void obj_init_groundzipper(Object *arg0, LevelObjectEntry_GroundZipper *entry) {
objScale = 10.0f;
}
objScale /= 64;
header = arg0->segment.header;
arg0->segment.trans.scale = header->scale * objScale;
arg0->unk50->unk0 = header->unk4 * objScale;
arg0->segment.trans.y_rotation = entry->rotation << 6 << 4;
if (arg0->segment.unk38.byte.unk3A >= arg0->segment.header->numberOfModelIds) {
arg0->segment.unk38.byte.unk3A = 0;
header = obj->segment.header;
obj->segment.trans.scale = header->scale * objScale;
obj->shadow->scale = header->unk4 * objScale;
obj->segment.trans.y_rotation = entry->rotation << 6 << 4;
if (obj->segment.unk38.byte.unk3A >= obj->segment.header->numberOfModelIds) {
obj->segment.unk38.byte.unk3A = 0;
}
arg0->unk78 = (s32)(28.0f * objScale) + 15;
if (arg0->unk78 < 0) {
arg0->unk78 = 0;
obj->unk78 = (s32) (28.0f * objScale) + 15;
if (obj->unk78 < 0) {
obj->unk78 = 0;
}
if (arg0->unk78 > 255) {
arg0->unk78 = 255;
if (obj->unk78 > 255) {
obj->unk78 = 255;
}
arg0->interactObj->unk14 = 2;
arg0->interactObj->unk11 = 0;
arg0->interactObj->unk10 = 0x14;
arg0->interactObj->unk12 = 0;
arg0->interactObj->unk16 = -0x64;
arg0->interactObj->unk17 = 0x64;
obj->interactObj->unk14 = 2;
obj->interactObj->unk11 = 0;
obj->interactObj->unk10 = 0x14;
obj->interactObj->unk12 = 0;
obj->interactObj->unk16 = -0x64;
obj->interactObj->unk17 = 0x64;
if (get_filtered_cheats() & CHEAT_TURN_OFF_ZIPPERS) {
gParticlePtrList_addObject(arg0);
gParticlePtrList_addObject(obj);
}
}
-4
View File
@@ -217,10 +217,6 @@ typedef struct unk80042CD0 {
s16 unk18;
} unk80042CD0;
typedef struct Object_50_Scenery {
f32 unk0;
} Object_50_Scenery;
//void func_80072348(s16 obj, u8 arg1);
typedef struct unk80041A90_MidiFade {
+16 -14
View File
@@ -852,25 +852,27 @@ s32 func_8000FAC4(Object *obj, Object_6C *arg1) {
return ((obj->segment.header->unk57 << 5) + 3) & ~3;
}
s32 func_8000FBCC(Object *arg0, Object_60 *arg1) {
s32 var_v0;
/**
* Assigns shadow data to an object. Loads and assigns the shadow texture, too.
* Returns zero if the texture is missing.
*/
s32 init_object_shadow(Object *obj, ShadowData *shadow) {
ObjectHeader *objHeader;
arg0->unk50 = (Object_50*) arg1;
arg1->unk4 = NULL;
objHeader = ((ObjectSegment*) arg0)->header;
obj->shadow = shadow;
shadow->texture = NULL;
objHeader = ((ObjectSegment *) obj)->header;
if (objHeader->unk32) {
arg1->unk4 = (Object *) load_texture((s32) ((ObjectHeader *) objHeader)->unk34);
objHeader = ((ObjectSegment*)arg0)->header;
shadow->texture = (TextureHeader *) load_texture((s32) ((ObjectHeader *) objHeader)->unk34);
objHeader = ((ObjectSegment *) obj)->header;
}
((Object_50*) arg1)->unk0 = (f32) objHeader->unk4;
((Object_50*) arg1)->unk8 = -1;
D_8011AE50 = (s32) ((Object_60*)arg1)->unk4;
var_v0 = 16;
if ((((ObjectSegment*) arg0)->header->unk32) && (arg1->unk4 == NULL)) {
shadow->scale = (f32) objHeader->unk4;
shadow->unk8 = -1;
D_8011AE50 = (s32) shadow->texture;
if (((ObjectSegment *) obj)->header->unk32 && shadow->texture == NULL) {
return 0;
}
return var_v0;
return 16;
}
s32 func_8000FC6C(struct_8000FC6C_3 *arg0, struct_8000FC6C *arg1) {
@@ -962,7 +964,7 @@ void func_80010994(s32 updateRate) {
Object *obj;
s32 sp54;
Object_68 *obj68;
Object_64 *obj64;
UNUSED Object_64 *obj64;
func_800245B4(-1);
gRaceStartCountdown = D_8011ADB0;
+1
View File
@@ -410,6 +410,7 @@ void func_8001709C(Object *obj);
s32 func_800113CC(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 evenSoundId);
void func_80011AD0(Object *this);
Object *func_8001BDD4(Object *obj, s32 *cameraID);
s32 init_object_shadow(Object *obj, ShadowData *shadow);
//Non Matching
void calc_dynamic_lighting_for_object_1(Object *, ObjectModel *, s16, Object *, f32, f32);
+1 -1
View File
@@ -4585,7 +4585,7 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate)
break;
case WEAPON_OIL_SLICK:
if (racer->vehicleID != VEHICLE_PLANE) {
spawnedObj->unk50->unk0 = 0;
spawnedObj->shadow->scale = 0;
}
soundID = SOUND_SPLOINK2;
break;
+37 -36
View File
@@ -755,8 +755,8 @@ void render_level_geometry_and_objects(void) {
if (obj->segment.trans.unk6 & 0x8000) {
func_80012D5C(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj);
continue;
} else if (obj->unk50 != NULL) {
render_floor_decal(obj, obj->unk50);
} else if (obj->shadow != NULL) {
render_object_shadow(obj, obj->shadow);
}
func_80012D5C(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj);
if (obj->unk58 != NULL && obj->segment.header->unk30 & 0x10) {
@@ -777,8 +777,8 @@ void render_level_geometry_and_objects(void) {
if (obj->segment.trans.unk6 & 0x8000) {
func_80012D5C(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj);
continue;
} else if (obj->unk50 != NULL) {
render_floor_decal(obj, obj->unk50);
} else if (obj->shadow != NULL) {
render_object_shadow(obj, obj->shadow);
}
func_80012D5C(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj);
if ((obj->unk58 != NULL) && (obj->segment.header->unk30 & 0x10)) {
@@ -822,8 +822,8 @@ void render_level_geometry_and_objects(void) {
if (obj->segment.trans.unk6 & 0x8000) {
func_80012D5C(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj);
goto skip;
} else if (obj->unk50 != NULL) {
render_floor_decal(obj, obj->unk50);
} else if (obj->shadow != NULL) {
render_object_shadow(obj, obj->shadow);
}
func_80012D5C(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj);
if ((obj->unk58 != 0) && (obj->segment.header->unk30 & 0x10)) {
@@ -1725,9 +1725,10 @@ void trackMakeAbsolute(unk8002D30C_a0 *arg0, s32 arg1) {
}
/**
* Render a flat model that projects itself on the floor.
* Render the shadow of an object on the ground as a decal.
* Can subdivide itself to wrap around the terrain properly, as the N64 lacks stencil buffering.
*/
void render_floor_decal(Object *obj, Object_50 *arg1) {
void render_object_shadow(Object *obj, ShadowData *shadow) {
s32 i;
s32 temp_a0;
s32 temp_a3;
@@ -1741,25 +1742,25 @@ void render_floor_decal(Object *obj, Object_50 *arg1) {
s32 someAlpha;
if (obj->segment.header->unk32 != 0) {
if (arg1->unk8 != -1 && D_8011B0C4 == 0) {
if (shadow->unk8 != -1 && D_8011B0C4 == 0) {
D_8011B0CC = D_8011B0C8;
if (obj->segment.header->unk32 == 1) {
D_8011B0CC += 2;
}
i = arg1->unk8;
i = shadow->unk8;
D_8011D360 = (unk8011D360 *) D_8011D350[D_8011B0CC];
D_8011D330 = (unk8011D330 *) D_8011D320[D_8011B0CC];
D_8011D348 = (unk8011D348 *) D_8011D338[D_8011B0CC];
someAlpha = D_8011D348[D_8011D360[i].unk6].unk9;
flags = RENDER_FOG_ACTIVE | RENDER_Z_COMPARE;
if (someAlpha == 0 || obj->segment.unk38.byte.unk39 == 0) {
i = arg1->unkA;
i = shadow->unkA;
} else if (someAlpha != 255 || obj->segment.unk38.byte.unk39 != 255) {
flags = RENDER_FOG_ACTIVE | RENDER_SEMI_TRANSPARENT | RENDER_Z_COMPARE;
someAlpha = (obj->segment.unk38.byte.unk39 * someAlpha) >> 8;
gDPSetPrimColor(gSceneCurrDisplayList++, 0, 0, 255, 255, 255, someAlpha);
}
while (i < arg1->unkA) {
while (i < shadow->unkA) {
load_and_set_texture_no_offset(&gSceneCurrDisplayList, (TextureHeader *) D_8011D360[i].unk0, flags);
// I hope we can clean this part up.
temp2 = new_var2 = D_8011D360[i].unk4; // Fakematch
@@ -1780,7 +1781,7 @@ void render_floor_decal(Object *obj, Object_50 *arg1) {
}
}
void func_8002D670(Object *obj, Object_50 *arg1) {
void func_8002D670(Object *obj, ShadowData *shadow) {
s32 i;
s32 temp_a0;
s32 temp_a3;
@@ -1791,21 +1792,21 @@ void func_8002D670(Object *obj, Object_50 *arg1) {
UNUSED s32 temp3;
if (obj->segment.header->unk36 != 0) {
if ((arg1->unk8 != -1) && (D_8011B0C4 == 0)) {
if ((shadow->unk8 != -1) && (D_8011B0C4 == 0)) {
D_8011B0D0 = D_8011B0C8;
i = arg1->unk8;
i = shadow->unk8;
if (obj->segment.header->unk36 == 1) {
D_8011B0D0 = D_8011B0C8;
D_8011B0D0 += 2;
if (get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position) > 768.0f) {
i = arg1->unkA;
i = shadow->unkA;
}
}
flags = RENDER_FOG_ACTIVE | RENDER_Z_COMPARE;
D_8011D360 = (unk8011D360* ) D_8011D350[D_8011B0D0];
D_8011D330 = (unk8011D330* ) D_8011D320[D_8011B0D0];
D_8011D348 = (unk8011D348* ) D_8011D338[D_8011B0D0];
while (i < arg1->unkA) {
while (i < shadow->unkA) {
load_and_set_texture_no_offset(&gSceneCurrDisplayList, (TextureHeader *) D_8011D360[i].unk0, flags);
temp2 = D_8011D360[i].unk4; // Fakematch
temp3 = D_8011D360[i].unk6; // Fakematch
@@ -1826,13 +1827,13 @@ void func_8002D8DC(s32 arg0, s32 arg1, s32 updateRate) {
s32 sp90;
Object *obj;
ObjectHeader *objHeader;
f32 var_f20;
s32 temp_v1_2;
f32 dist;
s32 radius;
s32 numViewports;
Object **objects;
s32 var_a0;
Object_58_4* obj58_4;
Object_50 *obj50;
ShadowData *shadow;
Object_58* obj58;
s32 playerIndex;
@@ -1852,23 +1853,23 @@ void func_8002D8DC(s32 arg0, s32 arg1, s32 updateRate) {
obj = objects[sp94];
objHeader = obj->segment.header;
obj58 = obj->unk58;
obj50 = obj->unk50;
shadow = obj->shadow;
sp94 += 1;
if (!(obj->segment.trans.unk6 & 0x8000)) {
if (obj50 != NULL && obj50->unk0 > 0.0f && arg0 == objHeader->unk32) {
obj50->unk8 = -1;
if (shadow != NULL && shadow->scale > 0.0f && arg0 == objHeader->unk32) {
shadow->unk8 = -1;
}
if (obj->segment.trans.unk6 & 0x4000) {
obj50 = NULL;
shadow = NULL;
}
if ((obj50 != NULL && objHeader->unk32 == 2) || (obj58 != NULL && objHeader->unk36 == 2)) {
var_f20 = get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position);
if ((shadow != NULL && objHeader->unk32 == 2) || (obj58 != NULL && objHeader->unk36 == 2)) {
dist = get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position);
} else {
var_f20 = 0;
dist = 0;
}
if (obj50 != NULL && obj50->unk0 > 0.0f && arg0 == objHeader->unk32) {
if (shadow != NULL && shadow->scale > 0.0f && arg0 == objHeader->unk32) {
D_8011D0D4 = 1.0f;
obj50->unk8 = -1;
shadow->unk8 = -1;
var_a0 = FALSE;
if (objHeader->unk32 == 2 && numViewports > ONE_PLAYER && numViewports <= FOUR_PLAYERS) {
if (obj->behaviorId == BHV_RACER) {
@@ -1882,10 +1883,10 @@ void func_8002D8DC(s32 arg0, s32 arg1, s32 updateRate) {
var_a0 = TRUE;
}
} else {
temp_v1_2 = objHeader->unk4A;
if (var_f20 < temp_v1_2) {
if (objHeader->unk4C < var_f20) {
D_8011D0D4 = (temp_v1_2 - var_f20) / ( temp_v1_2 - objHeader->unk4C);
radius = objHeader->unk4A;
if (dist < radius) {
if (objHeader->unk4C < dist) {
D_8011D0D4 = (radius - dist) / ( radius - objHeader->unk4C);
}
func_8002E234(obj, FALSE);
var_a0 = TRUE;
@@ -1916,9 +1917,9 @@ void func_8002D8DC(s32 arg0, s32 arg1, s32 updateRate) {
func_8002E234(obj, TRUE);
}
} else {
if (var_f20 < objHeader->unk4A) {
if (objHeader->unk4C < var_f20) {
D_8011D0D4 = (objHeader->unk4A - var_f20) / (objHeader->unk4A - objHeader->unk4C);
if (dist < objHeader->unk4A) {
if (objHeader->unk4C < dist) {
D_8011D0D4 = (objHeader->unk4A - dist) / (objHeader->unk4A - objHeader->unk4C);
}
func_8002E234(obj, TRUE);
}
+2 -2
View File
@@ -147,8 +147,8 @@ s32 check_if_inside_segment(Object *obj, s32 segmentIndex);
s32 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos);
void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentIndex2, u8 *segmentsOrder, s32 *segmentsOrderIndex);
void render_level_geometry_and_objects(void);
void func_8002D670(Object *obj, Object_50 *arg1);
void render_floor_decal(Object *obj, Object_50 *arg1);
void func_8002D670(Object *obj, ShadowData *shadow);
void render_object_shadow(Object *obj, ShadowData *shadow);
s32 should_segment_be_visible(LevelModelSegmentBoundingBox *bb);
s32 check_if_in_draw_range(Object *obj);
void func_8002C954(LevelModelSegment *segment, LevelModelSegmentBoundingBox *bbox, s32 arg2);