test synced pole
This commit is contained in:
@@ -14,6 +14,53 @@
|
||||
#include "libsm64.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "decomp/shim.h"
|
||||
|
||||
#define o gCurrentObject
|
||||
|
||||
struct Object *cur_obj_find_nearest_pole(void)
|
||||
{
|
||||
struct Object *closestObj = NULL;
|
||||
struct Object *obj;
|
||||
f32 minDist = 0x20000;
|
||||
|
||||
for (s32 i = 0; i < s_fakeobj_instance_pool.size; i++)
|
||||
{
|
||||
obj = s_fakeobj_instance_pool.objects[i];
|
||||
|
||||
if (obj == NULL)
|
||||
continue;
|
||||
|
||||
if (obj->activeFlags == ACTIVE_FLAG_DEACTIVATED)
|
||||
continue;
|
||||
|
||||
if (!(obj->oInteractType & INTERACT_POLE))
|
||||
continue;
|
||||
|
||||
if (obj == o)
|
||||
continue;
|
||||
|
||||
f32 objDist = dist_between_objects(o, obj);
|
||||
|
||||
if (objDist < minDist)
|
||||
{
|
||||
closestObj = obj;
|
||||
minDist = objDist;
|
||||
}
|
||||
}
|
||||
|
||||
return closestObj;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void fake_object_init(struct FakeObject *fake, float x, float y, float z)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user