I tried with pole
Build libsm64 / Build libsm64 for linux (push) Successful in 31s
Build libsm64 / Build libsm64 for windows (push) Successful in 23s
Build libsm64 / Snapshot Release (push) Has been cancelled
Build libsm64 / Build libsm64 for windows (pull_request) Has been cancelled
Build libsm64 / Snapshot Release (pull_request) Has been cancelled
Build libsm64 / Build libsm64 for linux (pull_request) Has been cancelled
Build libsm64 / Build libsm64 for linux (push) Successful in 31s
Build libsm64 / Build libsm64 for windows (push) Successful in 23s
Build libsm64 / Snapshot Release (push) Has been cancelled
Build libsm64 / Build libsm64 for windows (pull_request) Has been cancelled
Build libsm64 / Snapshot Release (pull_request) Has been cancelled
Build libsm64 / Build libsm64 for linux (pull_request) Has been cancelled
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "decomp/game/interaction.h"
|
||||
#ifndef SM64_LIB_EXPORT
|
||||
#define SM64_LIB_EXPORT
|
||||
#endif
|
||||
@@ -55,6 +56,49 @@ struct MarioInstance
|
||||
struct ObjPool s_mario_instance_pool = {0, 0};
|
||||
struct ObjPool s_fakeobj_instance_pool = {0, 0};
|
||||
|
||||
f32 dist_between_objects(struct Object *obj1, struct Object *obj2)
|
||||
{
|
||||
if (obj1 == NULL || obj2 == NULL) { return 0; }
|
||||
f32 dx = obj1->oPosX - obj2->oPosX;
|
||||
f32 dy = obj1->oPosY - obj2->oPosY;
|
||||
f32 dz = obj1->oPosZ - obj2->oPosZ;
|
||||
|
||||
return sqrtf(dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
struct Object *get_closest_pole_object()
|
||||
{
|
||||
struct Object *closestObj = NULL;
|
||||
f32 minDist = 0x20000;
|
||||
|
||||
for (int i = 0; i < s_fakeobj_instance_pool.size; i++)
|
||||
{
|
||||
struct Object *obj = &((struct FakeObject *)s_fakeobj_instance_pool.objects[i])->object;
|
||||
if (obj == NULL || obj->activeFlags == ACTIVE_FLAG_DEACTIVATED || !(obj->oInteractType & INTERACT_POLE) || obj == gMarioObject) continue;
|
||||
|
||||
DEBUG_PRINT(
|
||||
"POOL: %d ptr=%p interact=%X active=%X pos=(%f,%f,%f)",
|
||||
i,
|
||||
obj,
|
||||
obj->oInteractType,
|
||||
obj->activeFlags,
|
||||
obj->oPosX,
|
||||
obj->oPosY,
|
||||
obj->oPosZ
|
||||
);
|
||||
|
||||
f32 objDist = dist_between_objects(gMarioObject, obj);
|
||||
if (objDist < minDist)
|
||||
{
|
||||
closestObj = obj;
|
||||
DEBUG_PRINT("Found pole object with ID %d at distance %f", i, objDist);
|
||||
minDist = objDist;
|
||||
}
|
||||
}
|
||||
|
||||
return closestObj;
|
||||
}
|
||||
|
||||
static void update_button(bool on, u16 button)
|
||||
{
|
||||
gController.buttonPressed &= ~button;
|
||||
|
||||
Reference in New Issue
Block a user