mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
match calc_dynamic_lighting_for_object_1 (#594)
* match calc_dynamic_lighting_for_object_1 * format and score * update score * update score again
This commit is contained in:
@@ -7,7 +7,7 @@ All versions are supported, and the US 1.0 version (SHA1 = 0cb115d8716dbbc2922fd
|
||||
<!-- README_SCORE_SUMMARY_BEGIN -->
|
||||
As of May 28, 2025, this is our current score:
|
||||
|
||||
    Decomp progress: 88.69%
|
||||
    Decomp progress: 88.84%
|
||||
|
||||
    Documentation progress: 58.62%
|
||||
<!-- README_SCORE_SUMMARY_END -->
|
||||
@@ -121,9 +121,9 @@ As of May 28, 2025, this is our current score:
|
||||
```
|
||||
===================================================================
|
||||
ADVENTURE ONE (ASM -> C Decompilation)
|
||||
-------------- 88.69% Complete (89.65% NON_MATCHING) --------------
|
||||
# Decompiled functions: 1904
|
||||
# GLOBAL_ASM remaining: 47
|
||||
-------------- 88.84% Complete (89.81% NON_MATCHING) --------------
|
||||
# Decompiled functions: 1905
|
||||
# GLOBAL_ASM remaining: 46
|
||||
# NON_MATCHING functions: 5
|
||||
# NON_EQUIVALENT WIP functions: 16
|
||||
--------------------------- Game Status ---------------------------
|
||||
|
||||
@@ -494,7 +494,7 @@ GLOBAL_ASM("asm/math_util/f32_vec3_apply_object_rotation.s")
|
||||
|
||||
#ifdef NON_EQUIVALENT
|
||||
/* Official Name: mathOneFloatYPR */
|
||||
void f32_vec3_apply_object_rotation2(ObjectTransform *trans, f32 *arg1) {
|
||||
void f32_vec3_apply_object_rotation2(Vec3s *trans, f32 *arg1) {
|
||||
f32 yRotSine;
|
||||
f32 yRotCosine;
|
||||
f32 xRotSine;
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ void object_inverse_transform_to_matrix(Matrix mtx, ObjectTransform *trans);
|
||||
void f32_matrix_from_rotation_and_scale(Matrix mtx, s32 angle, f32 scale, f32 scaleY);
|
||||
void s16_vec3_apply_object_rotation(ObjectTransform *trans, s16 *vec3Arg);
|
||||
void f32_vec3_apply_object_rotation(ObjectTransform *trans, f32 *vec3_f32);
|
||||
void f32_vec3_apply_object_rotation2(ObjectTransform *trans, f32 *arg1);
|
||||
void f32_vec3_apply_object_rotation2(Vec3s *trans, f32 *arg1);
|
||||
void f32_vec3_apply_object_rotation3(Vec3s *trans, f32 *vec3_f32);
|
||||
s32 point_triangle_2d_xz_intersection(s32 x, s32 z, s16 *vec3A, s16 *vec3B, s16 *vec3C);
|
||||
void f32_matrix_from_position(Matrix *mtx, f32 x, f32 y, f32 z);
|
||||
|
||||
+92
-1
@@ -6063,7 +6063,98 @@ void obj_shade_fancy(ObjectModel *model, Object *object, s32 arg2, f32 intensity
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/nonmatchings/objects/calc_dynamic_lighting_for_object_1.s")
|
||||
void calc_dynamic_lighting_for_object_1(Object *object, ObjectModel *model, s16 arg2, Object *anotherObject,
|
||||
f32 intensity, f32 arg5) {
|
||||
s16 sp9E;
|
||||
s16 j;
|
||||
s16 i;
|
||||
Vec3s sp94;
|
||||
s32 s6;
|
||||
s32 x1, y1, z1;
|
||||
s32 x2, y2, z2;
|
||||
s32 ambientTemp;
|
||||
s32 brightnessTemp;
|
||||
s32 t8;
|
||||
s32 v1;
|
||||
Vec3f sp5C;
|
||||
Vertex *vertices;
|
||||
Vec3s *model40Entries;
|
||||
|
||||
if (object->shading == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
vertices = object->curVertData;
|
||||
model40Entries = model->unk40;
|
||||
sp9E = 0;
|
||||
|
||||
sp5C.x = -(object->shading->unk8 << 3);
|
||||
sp5C.y = -(object->shading->unkA << 3);
|
||||
sp5C.z = -(object->shading->unkC << 3);
|
||||
sp94.y_rotation = -object->segment.trans.rotation.y_rotation;
|
||||
sp94.x_rotation = -object->segment.trans.rotation.x_rotation;
|
||||
sp94.z_rotation = -object->segment.trans.rotation.z_rotation;
|
||||
f32_vec3_apply_object_rotation2(&sp94, &sp5C.f);
|
||||
|
||||
if (object->segment.header->unk3D != 0 && arg2) {
|
||||
f32_matrix_dot(get_projection_matrix_f32(), (Matrix *) &sp5C, (Matrix *) &sp5C);
|
||||
}
|
||||
|
||||
x1 = -sp5C.x;
|
||||
y1 = -sp5C.y;
|
||||
z1 = -sp5C.z;
|
||||
s6 = object->shading->unk7;
|
||||
sp5C.x = object->shading->unk1C << 2;
|
||||
sp5C.y = object->shading->unk1E << 2;
|
||||
sp5C.z = object->shading->unk20 << 2;
|
||||
|
||||
if (arg2) {
|
||||
f32_matrix_dot(get_projection_matrix_f32(), (Matrix *) &sp5C, (Matrix *) &sp5C);
|
||||
}
|
||||
f32_vec3_apply_object_rotation2(&sp94, &sp5C.f);
|
||||
|
||||
x2 = sp5C.x;
|
||||
y2 = sp5C.y;
|
||||
z2 = sp5C.z;
|
||||
|
||||
brightnessTemp = object->shading->brightness * object->shading->unk0 * 255.0f * intensity;
|
||||
ambientTemp = object->shading->ambient * object->shading->unk0 * 255.0f * intensity;
|
||||
|
||||
for (i = 0; i < model->numberOfBatches; i++) {
|
||||
if (model->batches[i].unk6 != 0xFF) { // 0xFF means use vertex colors
|
||||
for (j = model->batches[i].verticesOffset; j < model->batches[i + 1].verticesOffset; j++) {
|
||||
t8 = (model40Entries[sp9E].x * x1 + model40Entries[sp9E].y * y1 + model40Entries[sp9E].z * z1) >> 13;
|
||||
if (t8 > 0) {
|
||||
t8 = (t8 * s6) >> 16;
|
||||
if (t8 > 255) {
|
||||
t8 = 255;
|
||||
}
|
||||
} else {
|
||||
t8 = 0;
|
||||
}
|
||||
|
||||
v1 = (model40Entries[sp9E].x * x2 + model40Entries[sp9E].y * y2 + model40Entries[sp9E].z * z2) >> 13;
|
||||
if (v1 > 0) {
|
||||
v1 = (v1 * ambientTemp) >> 16;
|
||||
v1 += brightnessTemp;
|
||||
if (v1 > 255) {
|
||||
v1 = 255;
|
||||
}
|
||||
} else {
|
||||
v1 = brightnessTemp;
|
||||
}
|
||||
|
||||
vertices[j].r = t8;
|
||||
vertices[j].g = t8;
|
||||
vertices[j].b = t8;
|
||||
vertices[j].a = v1;
|
||||
sp9E++;
|
||||
}
|
||||
} else if (model->batches[i].flags & RENDER_ENVMAP) {
|
||||
sp9E += model->batches[i + 1].verticesOffset - model->batches[i].verticesOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void calc_env_mapping_for_object(ObjectModel *model, s16 zRot, s16 xRot, s16 yRot) {
|
||||
MatrixS objRotMtxS32;
|
||||
|
||||
Reference in New Issue
Block a user