feat(decomp): add LinkedCollideRadius function (#48)

This commit is contained in:
Abdulrazzaq Alhendi 2023-04-29 07:32:51 +03:00 committed by GitHub
parent 89c8f0edd4
commit 4e8f66f49b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,33 @@
#include <common.h>
struct Instance* LinkedCollide_Radius(struct Instance* objInst,struct Thread* _objTh,struct Thread* thBucket,unsigned int hitRadius)
{
int diff_z, diff_y, diff_x;
unsigned int diff_dist;
struct Instance* thInst;
// if thread valid, loop through every thread in the linked list until there are no more threads
while (thBucket != 0)
{
thInst = thBucket->inst;
// get difference in X, Y, and Z, from both instances
diff_x = thInst->matrix.t[0] - objInst->matrix.t[0];
diff_y = thInst->matrix.t[1] - objInst->matrix.t[1];
diff_z = thInst->matrix.t[2] - objInst->matrix.t[2];
diff_dist = diff_x * diff_x + diff_z*diff_z;
if ((objInst->model->id == 0x21) && ((diff_dist < hitRadius) && (-0x20 < diff_y))) {
// Minecart has cylindrical collision
return thInst;
} else if (diff_dist + diff_y * diff_y < hitRadius) {
// Spherical collision for everything else
return thInst;
}
// next thread in the list (thread bucket)
thBucket = thBucket->siblingThread;
}
// no collision
return 0;
}

View File

@ -230,6 +230,9 @@ common, exe, LIST_RemoveFront, 0x0, General/LIST/LIST_RemoveFront.c
common, exe, LIST_RemoveBack, 0x0, General/LIST/LIST_RemoveBack.c
common, exe, LIST_Init, 0x0, General/LIST/LIST_Init.c
// LinkedCollide
common, exe, LinkedCollide_Radius, 0x0, General/LinkedCollide.c
// LOAD
common, exe, LOAD_AppendQueue, 0x0, General/LOAD/LOAD_AppendQueue.c
common, exe, LOAD_Callback_Overlay_Generic, 0x0, General/LOAD/LOAD_Callback_Overlay_Generic.c