diff --git a/README.md b/README.md
index 5db08215..735d5a10 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# banjo (96.6439%)
+# banjo (96.6549%)
diff --git a/progress/progress_core1.svg b/progress/progress_core1.svg
index b303b729..b94f9ef6 100644
--- a/progress/progress_core1.svg
+++ b/progress/progress_core1.svg
@@ -9,7 +9,7 @@
-
+
@@ -17,7 +17,7 @@
core1
- 93.8214%
- 93.8214%
+ 93.8967%
+ 93.8967%
\ No newline at end of file
diff --git a/progress/progress_total.svg b/progress/progress_total.svg
index 4712ab98..fd09b0f6 100644
--- a/progress/progress_total.svg
+++ b/progress/progress_total.svg
@@ -17,7 +17,7 @@
Banjo-Kazooie (us.v10)
- 96.6439%
- 96.6439%
+ 96.6549%
+ 96.6549%
\ No newline at end of file
diff --git a/src/core1/code_13990.c b/src/core1/code_13990.c
index 41ba4114..03d510bb 100644
--- a/src/core1/code_13990.c
+++ b/src/core1/code_13990.c
@@ -103,15 +103,12 @@ void mlMtxPop(void){
void func_802516E0(void) {
s32 i, j;
f32 *var_a3;
- f32 (*var_a2)[4];
-
- var_a3 = D_80282FD0;
+ f32 *var_a2;
+
var_a2 = D_80282FD0 + 1;
- if(1);
- for(i = 0; i < 4; i++){
- for(j = 0; j < 4; j++){
- var_a2[i][j] = var_a3[4*i + j];
- }
+ var_a3 = D_80282FD0;
+ for(i = 0; i < 16; i++) {
+ var_a2[i] = var_a3[i];
}
D_80282FD0++;
}
diff --git a/src/core2/code_47BD0.c b/src/core2/code_47BD0.c
index 7cf792fe..6841df70 100644
--- a/src/core2/code_47BD0.c
+++ b/src/core2/code_47BD0.c
@@ -311,8 +311,8 @@ void chBeeSwarm_update(Actor *this) {
f32 spB0;
f32 spAC;
f32 spA0[3];
- f32 sp94[3];
- f32 sp88[3];
+ f32 position[3];
+ f32 next_position[3];
f32 sp7C[3];
s32 sp78;
f32 temp_f0;
@@ -340,18 +340,18 @@ void chBeeSwarm_update(Actor *this) {
this->position[1] = local->unkC[1];
this->position[2] = local->unkC[2];
- sp94[0] = this->position[0];
- sp94[1] = this->position[1];
- sp94[2] = this->position[2];
+ position[0] = this->position[0];
+ position[1] = this->position[1];
+ position[2] = this->position[2];
- sp88[0] = this->position[0];
- sp88[1] = this->position[1];
- sp88[2] = this->position[2];
+ next_position[0] = this->position[0];
+ next_position[1] = this->position[1];
+ next_position[2] = this->position[2];
- sp94[1] += 50.0f;
- sp88[1] -= 500.0f;
- if (func_80309B48(sp94, sp88, sp7C, 0x5E0000)) {
- local->unk18 = sp88[1];
+ position[1] += 50.0f;
+ next_position[1] -= 500.0f;
+ if (func_80309B48(position, next_position, sp7C, 0x5E0000)) {
+ local->unk18 = next_position[1];
}
}
if (!this->unk16C_4) {
@@ -397,14 +397,14 @@ void chBeeSwarm_update(Actor *this) {
}
this->unk58_0 = TRUE;
}
- sp94[0] = this->position[0];
- sp94[1] = this->position[1];
- sp94[2] = this->position[2];
- sp88[0] = this->position[0] + (this->velocity[0] * spAC);
- sp88[1] = this->position[1] + (this->velocity[1] * spAC);
- sp88[2] = this->position[2] + (this->velocity[2] * spAC);
+ position[0] = this->position[0];
+ position[1] = this->position[1];
+ position[2] = this->position[2];
+ next_position[0] = this->position[0] + (this->velocity[0] * spAC);
+ next_position[1] = this->position[1] + (this->velocity[1] * spAC);
+ next_position[2] = this->position[2] + (this->velocity[2] * spAC);
if (this->state != 7) {
- if (func_80309DBC(sp94, sp88, 75.0f, sp7C, 3, 0)) {
+ if (func_80309DBC(position, next_position, 75.0f, sp7C, 3, 0)) {
ml_vec3f_normalize(sp7C);
temp_f0 = (this->velocity[0]*sp7C[0] + this->velocity[1]*sp7C[1] + this->velocity[2]*sp7C[2]) * -1.5;
this->velocity[0] = this->velocity[0] + (sp7C[0] * temp_f0);
@@ -423,13 +423,13 @@ void chBeeSwarm_update(Actor *this) {
if (map_get() == MAP_78_GL_RBB_AND_MMM_PUZZLE) {
if (this->unk38_31++ == 0x1E) {
this->unk38_31 = 0;
- sp88[0] = this->position[0];
- sp88[1] = this->position[1];
- sp88[2] = this->position[2];
- sp94[1] += 1000.0f;
- sp88[1] -= 1000.0f;
- if (func_80309B48(sp94, sp88, sp7C, 0xF800FF0F)) {
- local->unk1C = sp88[1];
+ next_position[0] = this->position[0];
+ next_position[1] = this->position[1];
+ next_position[2] = this->position[2];
+ position[1] += 1000.0f;
+ next_position[1] -= 1000.0f;
+ if (func_80309B48(position, next_position, sp7C, 0xF800FF0F)) {
+ local->unk1C = next_position[1];
} else {
local->unk1C = -16000.0f;
}
diff --git a/src/core2/code_5FD90.c b/src/core2/code_5FD90.c
index cce0db92..f6943d78 100644
--- a/src/core2/code_5FD90.c
+++ b/src/core2/code_5FD90.c
@@ -8,7 +8,7 @@ extern void func_80252C08(f32[3],f32[3], f32, f32[3]);
extern void func_80252CC4(f32[3],s32, f32, s32);
extern f32 func_802560D0(f32[3], f32[3], f32[3]);
extern f32 func_802EC920(BKVertexList *);
-extern void func_8033D5D0(f32 arg0[3], f32 arg1[3], f32 margin, f32 min[3], f32 max[3]);
+extern void points_to_boundingBoxWithMargin(f32 arg0[3], f32 arg1[3], f32 margin, f32 min[3], f32 max[3]);
#define ABS_F(s) (((s) >= 0.0f) ? (s) : -(s))
@@ -442,7 +442,7 @@ int func_802E805C(BKCollisionList *collision_list, BKVertexList *vtxList, f32 ar
return sp34;
}
-s32 func_802E81CC(BKCollisionList *collisionList, BKVertexList *vertexList, f32 p1[3], f32 p2[3], f32 arg4[3], f32 arg5, s32 flagFilter, s32 *arg7, s32 *arg8) {
+s32 func_802E81CC(BKCollisionList *collisionList, BKVertexList *vertexList, f32 p1[3], f32 p2[3], f32 velocity[3], f32 margin, s32 flagFilter, s32 **activeTriStartPtr, s32 *activeTriEndPtr) {
BKCollisionGeo **start_geo;
BKCollisionGeo **i_geo;
BKCollisionGeo **end_geo;
@@ -462,7 +462,7 @@ s32 func_802E81CC(BKCollisionList *collisionList, BKVertexList *vertexList, f32
f32 temp_f0;
- func_8033D5D0(p1, p2, arg5, min, max);
+ points_to_boundingBoxWithMargin(p1, p2, margin, min, max);
temp_f0 = func_802EC920(vertexList);
for(i = 0; i < 3; i++){
if ((max[i] <= -temp_f0) || (temp_f0 <= min[i])) {
@@ -535,10 +535,10 @@ s32 func_802E81CC(BKCollisionList *collisionList, BKVertexList *vertexList, f32
}
}
else{
- if (((var_s2->normal[0]*arg4[0]) + (var_s2->normal[1]*arg4[1]) + (var_s2->normal[2]*arg4[2])) > 0.0f)
- continue; //arg4 is same direction as triangle normal
+ if (((var_s2->normal[0]*velocity[0]) + (var_s2->normal[1]*velocity[1]) + (var_s2->normal[2]*velocity[2])) > 0.0f)
+ continue; //velocity is same direction as triangle normal
}
- //add tri to active collisions
+ //add tri to active tri collisions
var_s2->tri_ptr = i_tri;
var_s2++;
if ((var_s2 - D_8037EAD0) > 100)
@@ -548,14 +548,14 @@ s32 func_802E81CC(BKCollisionList *collisionList, BKVertexList *vertexList, f32
if ((var_s2 - D_8037EAD0) > 100)
break;
}
- *arg7 = (s32) D_8037EAD0; //collisionPool
- *arg8 = (s32) var_s2; //collisionPoolEnd
+ *activeTriStartPtr = (s32) D_8037EAD0; //activeTriPool
+ *activeTriEndPtr = (s32) var_s2; //activeTriPoolEnd
return var_s2 - D_8037EAD0 > 0; //Count
}
-Struct_core2_5FD90_0 *func_802E879C(Struct_core2_5FD90_0 *arg0, Struct_core2_5FD90_0 *arg1, f32 arg2[3], f32 arg3, f32 arg4[3]) {
+Struct_core2_5FD90_0 *func_802E879C(Struct_core2_5FD90_0 *startTri, Struct_core2_5FD90_0 *endTri, f32 position[3], f32 radius, f32 arg4[3]) {
s32 i;
- Struct_core2_5FD90_0 *i_ptr;
+ Struct_core2_5FD90_0 *i_tri;
f32 sp144[3][3];
f32 sp120[3][3];
@@ -584,59 +584,61 @@ Struct_core2_5FD90_0 *func_802E879C(Struct_core2_5FD90_0 *arg0, Struct_core2_5FD
arg4[0] = 0.0f;
arg4[1] = 0.0f;
arg4[2] = 0.0f;
- for(i_ptr = arg0; i_ptr < arg1; i_ptr++){
- sp120[0][0] = arg2[0] - i_ptr->tri_coord[0][0];
- sp120[0][1] = arg2[1] - i_ptr->tri_coord[0][1];
- sp120[0][2] = arg2[2] - i_ptr->tri_coord[0][2];
- temp_f18 = (sp120[0][0] * i_ptr->normal[0]) + (sp120[0][1] * i_ptr->normal[1]) + (sp120[0][2] * i_ptr->normal[2]);
- if ((-(arg3 - 0.5)>= temp_f18) || ((arg3 -0.5) <= temp_f18))
+ for(i_tri = startTri; i_tri < endTri; i_tri++){
+ //project point onto plane of triangle
+ sp120[0][0] = position[0] - i_tri->tri_coord[0][0];
+ sp120[0][1] = position[1] - i_tri->tri_coord[0][1];
+ sp120[0][2] = position[2] - i_tri->tri_coord[0][2];
+ temp_f18 = (sp120[0][0] * i_tri->normal[0]) + (sp120[0][1] * i_tri->normal[1]) + (sp120[0][2] * i_tri->normal[2]);
+ if ((-(radius - 0.5)>= temp_f18) || ((radius -0.5) <= temp_f18))
continue;
- temp_f8 = i_ptr->normal[0];
- normal_length = (temp_f8 * i_ptr->normal[0]) + (i_ptr->normal[1] * i_ptr->normal[1]) + (i_ptr->normal[2] * i_ptr->normal[2]);
+ temp_f8 = i_tri->normal[0];
+ normal_length = (temp_f8 * i_tri->normal[0]) + (i_tri->normal[1] * i_tri->normal[1]) + (i_tri->normal[2] * i_tri->normal[2]);
if(normal_length == 0.0f)
continue;
normal_length = -temp_f18 / normal_length;
- projected_position[0] = arg2[0] + (i_ptr->normal[0] * normal_length); //project point onto triangle
- projected_position[1] = arg2[1] + (i_ptr->normal[1] * normal_length);
- projected_position[2] = arg2[2] + (i_ptr->normal[2] * normal_length);
+ projected_position[0] = position[0] + (i_tri->normal[0] * normal_length);
+ projected_position[1] = position[1] + (i_tri->normal[1] * normal_length);
+ projected_position[2] = position[2] + (i_tri->normal[2] * normal_length);
- var_a2 = (ABS_F(i_ptr->normal[0]) > ABS_F(i_ptr->normal[1])) ? 0 : 1;
- var_a2 = (ABS_F(i_ptr->normal[2]) > ABS_F(i_ptr->normal[var_a2])) ? 2 : var_a2;
+ //check if projected point is inside of triangle
+ var_a2 = (ABS_F(i_tri->normal[0]) > ABS_F(i_tri->normal[1])) ? 0 : 1;
+ var_a2 = (ABS_F(i_tri->normal[2]) > ABS_F(i_tri->normal[var_a2])) ? 2 : var_a2;
-
- spFC[0] = projected_position[(var_a2 + 1)%3] - i_ptr->tri_coord[0][(var_a2 + 1)%3];
- spFC[1] = i_ptr->edgeAB[(var_a2 + 1)%3];
- spFC[2] = i_ptr->edgeAC[(var_a2 + 1)%3];
+ spFC[0] = projected_position[(var_a2 + 1)%3] - i_tri->tri_coord[0][(var_a2 + 1)%3];
+ spFC[1] = i_tri->edgeAB[(var_a2 + 1)%3];
+ spFC[2] = i_tri->edgeAC[(var_a2 + 1)%3];
- spF0[0] = projected_position[(var_a2 + 2)%3] - i_ptr->tri_coord[0][(var_a2 + 2)%3];
- spF0[1] = i_ptr->edgeAB[(var_a2 + 2)%3];
- spF0[2] = i_ptr->edgeAC[(var_a2 + 2)%3];
+ spF0[0] = projected_position[(var_a2 + 2)%3] - i_tri->tri_coord[0][(var_a2 + 2)%3];
+ spF0[1] = i_tri->edgeAB[(var_a2 + 2)%3];
+ spF0[2] = i_tri->edgeAC[(var_a2 + 2)%3];
temp_f2_4 = (spFC[1] * spF0[2]) - (spF0[1] * spFC[2]);
temp_f12_3 = ((spFC[0] * spF0[2]) - (spF0[0] * spFC[2]))/temp_f2_4;
temp_f0_4 = ((spFC[1] * spF0[0]) - (spF0[1] * spFC[0]))/ temp_f2_4;
if ((0.0f <= temp_f12_3) && (temp_f12_3 <= 1.0f)
&& (0.0f <= temp_f0_4) && (temp_f0_4 <= 1.0f))
- if (((temp_f12_3 + temp_f0_4) <= 1.0f)
- ) {
- spD0 = i_ptr;
- arg4[0] = arg4[0] + i_ptr->normal[0];
- arg4[1] = arg4[1] + i_ptr->normal[1];
- arg4[2] = arg4[2] + i_ptr->normal[2];
+ if ((0 <= 1.0f - (temp_f12_3 + temp_f0_4))) {
+ //projected point lies on triangle
+ spD0 = i_tri;
+ arg4[0] = arg4[0] + i_tri->normal[0];
+ arg4[1] = arg4[1] + i_tri->normal[1];
+ arg4[2] = arg4[2] + i_tri->normal[2];
continue;
}
+ //projected point lies outside triangle
for(i = 0; i < 3; i++){
- sp120[i][0] = arg2[0] - i_ptr->tri_coord[i][0];
- sp120[i][1] = arg2[1] - i_ptr->tri_coord[i][1];
- sp120[i][2] = arg2[2] - i_ptr->tri_coord[i][2];
- if (sp120[i][0]*sp120[i][0] + sp120[i][1]*sp120[i][1] + sp120[i][2]*sp120[i][2] < arg3 * arg3) {
- spD0 = i_ptr;
- arg4[0] = arg4[0] + i_ptr->normal[0];
- arg4[1] = arg4[1] + i_ptr->normal[1];
- arg4[2] = arg4[2] + i_ptr->normal[2];
+ sp120[i][0] = position[0] - i_tri->tri_coord[i][0];
+ sp120[i][1] = position[1] - i_tri->tri_coord[i][1];
+ sp120[i][2] = position[2] - i_tri->tri_coord[i][2];
+ if (sp120[i][0]*sp120[i][0] + sp120[i][1]*sp120[i][1] + sp120[i][2]*sp120[i][2] < radius * radius) {
+ spD0 = i_tri;
+ arg4[0] = arg4[0] + i_tri->normal[0];
+ arg4[1] = arg4[1] + i_tri->normal[1];
+ arg4[2] = arg4[2] + i_tri->normal[2];
break;
}
@@ -645,10 +647,9 @@ Struct_core2_5FD90_0 *func_802E879C(Struct_core2_5FD90_0 *arg0, Struct_core2_5FD
continue;
for(i = 0; i < 3; i++){
-
- sp144[i][0] = i_ptr->tri_coord[(i + 1) % 3][0] - i_ptr->tri_coord[i][0];
- sp144[i][1] = i_ptr->tri_coord[(i + 1) % 3][1] - i_ptr->tri_coord[i][1];
- sp144[i][2] = i_ptr->tri_coord[(i + 1) % 3][2] - i_ptr->tri_coord[i][2];
+ sp144[i][0] = i_tri->tri_coord[(i + 1) % 3][0] - i_tri->tri_coord[i][0];
+ sp144[i][1] = i_tri->tri_coord[(i + 1) % 3][1] - i_tri->tri_coord[i][1];
+ sp144[i][2] = i_tri->tri_coord[(i + 1) % 3][2] - i_tri->tri_coord[i][2];
temp_f22 = sp144[i][0]*sp144[i][0] + sp144[i][1]*sp144[i][1] + sp144[i][2]*sp144[i][2];
ml_vec3f_normalize(sp144[i]);
temp_f0_3 = (sp144[i][0]*sp120[i][0]) + (sp144[i][1]*sp120[i][1]) + (sp144[i][2]*sp120[i][2]);
@@ -656,11 +657,11 @@ Struct_core2_5FD90_0 *func_802E879C(Struct_core2_5FD90_0 *arg0, Struct_core2_5FD
projected_position[0] = sp120[i][0] - sp144[i][0]*temp_f0_3;
projected_position[1] = sp120[i][1] - sp144[i][1]*temp_f0_3;
projected_position[2] = sp120[i][2] - sp144[i][2]*temp_f0_3;
- if(projected_position[0]*projected_position[0] + projected_position[1]*projected_position[1] + projected_position[2]*projected_position[2] < arg3 * arg3){
- spD0 = i_ptr;
- arg4[0] = arg4[0] + i_ptr->normal[0];
- arg4[1] = arg4[1] + i_ptr->normal[1];
- arg4[2] = arg4[2] + i_ptr->normal[2];
+ if(projected_position[0]*projected_position[0] + projected_position[1]*projected_position[1] + projected_position[2]*projected_position[2] < radius * radius){
+ spD0 = i_tri;
+ arg4[0] = arg4[0] + i_tri->normal[0];
+ arg4[1] = arg4[1] + i_tri->normal[1];
+ arg4[2] = arg4[2] + i_tri->normal[2];
break;
}
}
@@ -669,9 +670,9 @@ Struct_core2_5FD90_0 *func_802E879C(Struct_core2_5FD90_0 *arg0, Struct_core2_5FD
return spD0;
}
-BKCollisionTri *func_802E8E88(BKCollisionList *collision_list, BKVertexList *vtx_list, f32 arg2[3], f32 arg3[3], f32 arg4, f32 arg5[3], s32 arg6, s32 flagFilter){
- Struct_core2_5FD90_0 * spC4;
- Struct_core2_5FD90_0 * spC0;
+BKCollisionTri *func_802E8E88(BKCollisionList *collision_list, BKVertexList *vtx_list, f32 p1[3], f32 p2[3], f32 radius, f32 arg5[3], s32 arg6, s32 flagFilter){
+ Struct_core2_5FD90_0 * start_active_tri;
+ Struct_core2_5FD90_0 * end_active_tri;
f32 spB4[3];
f32 temp_f20;
@@ -685,33 +686,33 @@ BKCollisionTri *func_802E8E88(BKCollisionList *collision_list, BKVertexList *vtx
Struct_core2_5FD90_0 *phi_v0;
f32 sp78[3];
- sp78[0] = arg3[0] - arg2[0];
- sp78[1] = arg3[1] - arg2[1];
- sp78[2] = arg3[2] - arg2[2];
- if (!func_802E81CC(collision_list, vtx_list, arg2, arg3, sp78, (f32) ((f64) arg4 + 0.5), flagFilter, &spC4, &spC0)) {
+ sp78[0] = p2[0] - p1[0];
+ sp78[1] = p2[1] - p1[1];
+ sp78[2] = p2[2] - p1[2];
+ if (!func_802E81CC(collision_list, vtx_list, p1, p2, sp78, (f32) ((f64) radius + 0.5), flagFilter, &start_active_tri, &end_active_tri)) {
return NULL;
}
- phi_s5 = func_802E879C(spC4, spC0, arg3, arg4, sp8C);
+ phi_s5 = func_802E879C(start_active_tri, end_active_tri, p2, radius, sp8C);
if (phi_s5 == NULL) {
return NULL;
}
arg5[0] = sp8C[0];
arg5[1] = sp8C[1];
arg5[2] = sp8C[2];
- spB4[0] = arg3[0] - arg2[0];
- spB4[1] = arg3[1] - arg2[1];
- spB4[2] = arg3[2] - arg2[2];
- arg3[0] = arg2[0];
- arg3[1] = arg2[1];
- arg3[2] = arg2[2];
+ spB4[0] = p2[0] - p1[0];
+ spB4[1] = p2[1] - p1[1];
+ spB4[2] = p2[2] - p1[2];
+ p2[0] = p1[0];
+ p2[1] = p1[1];
+ p2[2] = p1[2];
phi_f22 = 0.0f;
phi_f24 = 1.0f;
for(phi_s0 = 0; phi_s0 < arg6; phi_s0++){
temp_f20 = (phi_f22 + phi_f24) * 0.5;
- sp98[0] = arg2[0] + (spB4[0] * temp_f20);
- sp98[1] = arg2[1] + (spB4[1] * temp_f20);
- sp98[2] = arg2[2] + (spB4[2] * temp_f20);
- phi_v0 = func_802E879C(spC4, spC0, sp98, arg4, sp8C);
+ sp98[0] = p1[0] + (spB4[0] * temp_f20);
+ sp98[1] = p1[1] + (spB4[1] * temp_f20);
+ sp98[2] = p1[2] + (spB4[2] * temp_f20);
+ phi_v0 = func_802E879C(start_active_tri, end_active_tri, sp98, radius, sp8C);
if (phi_v0 != NULL) {
arg5[0] = sp8C[0];
arg5[1] = sp8C[1];
@@ -719,9 +720,9 @@ BKCollisionTri *func_802E8E88(BKCollisionList *collision_list, BKVertexList *vtx
phi_f24 = temp_f20;
phi_s5 = phi_v0;
} else {
- arg3[0] = sp98[0];
- arg3[1] = sp98[1];
- arg3[2] = sp98[2];
+ p2[0] = sp98[0];
+ p2[1] = sp98[1];
+ p2[2] = sp98[2];
phi_f22 = temp_f20;
}
}
diff --git a/src/core2/code_B6640.c b/src/core2/code_B6640.c
index 5203ab1c..979a927b 100644
--- a/src/core2/code_B6640.c
+++ b/src/core2/code_B6640.c
@@ -3,17 +3,17 @@
#include "variables.h"
-void func_8033D5D0(f32 arg0[3], f32 arg1[3], f32 margin, f32 min[3], f32 max[3]) {
+void points_to_boundingBoxWithMargin(f32 p1[3], f32 p2[3], f32 margin, f32 min[3], f32 max[3]) {
s32 i;
i = 0;
for(i = 0; i < 3; i++){
- if (arg0[i] < arg1[i]) {
- min[i] = arg0[i];
- max[i] = arg1[i];
+ if (p1[i] < p2[i]) {
+ min[i] = p1[i];
+ max[i] = p2[i];
} else {
- min[i] = arg1[i];
- max[i] = arg0[i];
+ min[i] = p2[i];
+ max[i] = p1[i];
}
min[i] -= margin;
max[i] += margin;
diff --git a/src/core2/code_B8080.c b/src/core2/code_B8080.c
index 94cd6abf..87ff129e 100644
--- a/src/core2/code_B8080.c
+++ b/src/core2/code_B8080.c
@@ -104,65 +104,61 @@ s32 func_8033F3C0(BKModel *model, f32 position[3]){
#ifndef NONMATCHING
#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_B8080/func_8033F3E8.s")
#else
-s32 func_8033F3E8(BKModel *arg0, f32 arg1[3], s32 min_id, s32 max_id) {
+s32 func_8033F3E8(BKModel *model, f32 position[3], s32 min_id, s32 max_id) {
int i;
int j;
int k;
- s16 sp64[3];
- s16 sp5C[3];
- s16 sp54[3];
- s16 temp_v1_3;
- Vtx *temp_v0;
- BKMesh *phi_t3;
- Vtx *phi_a1;
+ s16 min[3];
+ s16 max[3];
+ s16 position_s16[3];
+ s32 temp_v1_3;
+ Vtx *vertex_pool;
+ BKMesh *current_mesh;
+ Vtx *current_vertex;
s32 mesh_cnt;
- s32 vtx_cnt;
- s16 *tmp;
- s16 t8;
+ s16 *vertex_index_list;
- temp_v0 = vtxList_getVertices(arg0->vtxList_4);
- sp54[0] = (s16) arg1[0];
- sp54[1] = (s16) arg1[1];
- sp54[2] = (s16) arg1[2];
- phi_t3 = (BKMesh *)(arg0->meshList_0 + 1);
- for(k = 0; k < arg0->meshList_0->meshCount_0; k++){
- if ((min_id > phi_t3->uid_0 || phi_t3->uid_0 >= max_id)){
- vtx_cnt = phi_t3->vtxCount_2;
- }
- else{
- t8 = *(s16*)(phi_t3 + 1);
- phi_a1 = temp_v0 + t8;
- for(i = 0; &sp64[i] < &sp64[3]; i++){
- temp_v1_3 = phi_a1->v.ob[i];
- sp64[i] = temp_v1_3;
- sp5C[i] = temp_v1_3;
+ vertex_pool = vtxList_getVertices(model->vtxList_4);
+ position_s16[0] = (s16) position[0];
+ position_s16[1] = (s16) position[1];
+ position_s16[2] = (s16) position[2];
+ current_mesh = (BKMesh *)(model->meshList_0 + 1);
+ for(k = 0; k < model->meshList_0->meshCount_0; k++, current_mesh = ((s16 *)(current_mesh + 1)) + current_mesh->vtxCount_2){
+ if ((min_id > current_mesh->uid_0 || current_mesh->uid_0 >= max_id))
+ continue;
+
+ j = 0;
+ vertex_index_list = ((s16*)(current_mesh + 1));
+ current_vertex = vertex_pool + vertex_index_list[j];
+ for(i = 0; &min[i] < &min[3]; i++){
+ temp_v1_3 = current_vertex->v.ob[i];
+ min[i] = temp_v1_3;
+ max[i] = temp_v1_3;
+ };
+
+
+ for(j = 1; j < current_mesh->vtxCount_2; j++){
+ current_vertex = vertex_pool + vertex_index_list[j];
+ for(i = 0; i < 3; i++){
+ temp_v1_3 = current_vertex->v.ob[i];
+ min[i] = MIN(temp_v1_3, min[i]);
+ max[i] = MAX(temp_v1_3, max[i]);
};
-
- tmp = (s16*)(phi_t3 + 1);
- for(j = 0; j < phi_t3->vtxCount_2; j++){
- phi_a1 = temp_v0 + tmp[j];
- for(i = 0; i < 3; i++){
- temp_v1_3 = phi_a1->v.ob[i];
- sp64[i] = (temp_v1_3 < sp64[i]) ? temp_v1_3 : sp64[i];
- sp5C[i] = (sp5C[i] < temp_v1_3) ? temp_v1_3 : sp5C[i];
- };
- }
- if( (sp64[0] < sp54[0] && sp54[0] < sp5C[0])
- && (sp64[2] < sp54[2] && sp54[2] < sp5C[2])
- ){
- return phi_t3->uid_0;
- }
- vtx_cnt = phi_t3->vtxCount_2;
}
- phi_t3 = &(((s16 *)(phi_t3 + 1))[vtx_cnt]);
+ if( (min[0] < position_s16[0] && position_s16[0] < max[0])
+ && (min[2] < position_s16[2] && position_s16[2] < max[2])
+ ){
+ return current_mesh->uid_0;
+ }
+
}
return 0;
}
#endif
-void model_free(void *arg0){
- free(arg0);
+void model_free(BKModel *model){
+ free(model);
}
BKModel *func_8033F5F8(BKMeshList *meshList, BKVertexList *vertexList) {
diff --git a/src/core2/mapModel.c b/src/core2/mapModel.c
index 66dacd88..3871c884 100644
--- a/src/core2/mapModel.c
+++ b/src/core2/mapModel.c
@@ -507,19 +507,19 @@ UNK_TYPE(s32) func_80309D58(UNK_TYPE(s32) arg0, UNK_TYPE(s32) arg1) {
return 0;
}
-UNK_TYPE(s32) func_80309DBC(f32 arg0[3], f32 arg1[3], f32 arg2, f32 arg3[3], s32 arg4, s32 arg5) {
+UNK_TYPE(s32) func_80309DBC(f32 currentPosition[3], f32 next_position[3], f32 arg2, f32 arg3[3], s32 arg4, s32 arg5) {
s32 sp34;
s32 temp_v0_2;
mapModel.unk20 = 0;
- sp34 = func_802E8E88(mapModel.collision_opa, func_8033A148(mapModel.model_bin_opa), arg0, arg1, arg2, arg3, arg4, arg5);
+ sp34 = func_802E8E88(mapModel.collision_opa, func_8033A148(mapModel.model_bin_opa), currentPosition, next_position, arg2, arg3, arg4, arg5);
if (sp34 != 0) {
mapModel.unk20 = (s32) mapModel.model_bin_opa;
}
if (mapModel.collision_xlu == 0) {
return sp34;
}
- temp_v0_2 = func_802E8E88(mapModel.collision_xlu, func_8033A148(mapModel.model_bin_xlu), arg0, arg1, arg2, arg3, arg4, arg5);
+ temp_v0_2 = func_802E8E88(mapModel.collision_xlu, func_8033A148(mapModel.model_bin_xlu), currentPosition, next_position, arg2, arg3, arg4, arg5);
if (temp_v0_2 != 0) {
mapModel.unk20 = (s32) mapModel.model_bin_xlu;
return temp_v0_2;
diff --git a/src/core2/modelRender.c b/src/core2/modelRender.c
index d88ce137..3506b40f 100644
--- a/src/core2/modelRender.c
+++ b/src/core2/modelRender.c
@@ -95,7 +95,7 @@ typedef struct {
s16 unk8;
s16 unkA;
f32 unkC[3];
-}GeoCmd9;
+}GeoCmdA;
typedef struct {
s32 cmd_0;
@@ -869,7 +869,7 @@ void func_80338B50(Gfx **gfx, Mtx **mtx, void *arg2){
//CmdA_REFERENCE_POINT
void func_80338BFC(Gfx **gfx, Mtx **mtx, void *arg2){
- GeoCmd9 *cmd = (GeoCmd9 *)arg2;
+ GeoCmdA *cmd = (GeoCmdA *)arg2;
f32 sp20[3];
if(D_80383650){