Reimplement 'FIX_WATER_RINGS' (#325)

* Reimplement 'FIX_WATER_RINGS'
This commit is contained in:
Arceveti
2022-03-18 11:02:38 -07:00
committed by GitHub
parent eaf9d3e4f9
commit 65eb5a755f
2 changed files with 25 additions and 15 deletions

View File

@@ -40,9 +40,8 @@
// -- WATER RING --
// Fix DDD water rings by checking for interaction rather than normals.
//! NOT IMPLEMENTED
// #define FIX_WATER_RINGS
// Fix the water rings in DDD by checking for interaction rather than normals.
#define FIX_WATER_RINGS
// -- POWER STAR --

View File

@@ -1,14 +1,13 @@
// water_ring.inc.c
#ifndef FIX_WATER_RINGS
f32 water_ring_calc_mario_dist(void) {
f32 marioDistX = o->oPosX - gMarioObject->header.gfx.pos[0];
f32 marioDistY = o->oPosY - (gMarioObject->header.gfx.pos[1] + 80.0f);
f32 marioDistZ = o->oPosZ - gMarioObject->header.gfx.pos[2];
f32 marioDistInFront = marioDistX * o->oWaterRingNormalX + marioDistY * o->oWaterRingNormalY
+ marioDistZ * o->oWaterRingNormalZ;
return marioDistInFront;
Vec3f marioDist;
vec3_diff(marioDist, &o->oPosVec, gMarioObject->header.gfx.pos);
marioDist[1] += 80.0f;
return vec3_dot(marioDist, &o->oWaterRingNormalVec);
}
#endif
void water_ring_init(void) {
cur_obj_init_animation(WATER_RING_ANIM_WOBBLE);
@@ -16,6 +15,7 @@ void water_ring_init(void) {
o->oWaterRingScalePhaseY = (s32)(random_float() * 4096.0f) + 0x1000;
o->oWaterRingScalePhaseZ = (s32)(random_float() * 4096.0f) + 0x1000;
#ifndef FIX_WATER_RINGS
//! This normal calculation assumes a facing yaw of 0, which is not the case
// for the manta ray rings. It also errs by multiplying the normal X by -1.
// This cause the ring's orientation for the purposes of collision to be
@@ -32,6 +32,7 @@ void water_ring_init(void) {
//
// o->oFaceAngleYaw = 0;
// o->oFaceAngleRoll *= -1;
#endif
}
void bhv_jet_stream_water_ring_init(void) {
@@ -42,16 +43,21 @@ void bhv_jet_stream_water_ring_init(void) {
}
void water_ring_check_collection(UNUSED f32 avgScale, struct Object *ringManager) {
#ifdef FIX_WATER_RINGS
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
#else
f32 marioDistInFront = water_ring_calc_mario_dist();
if (!is_point_close_to_object(o, gMarioObject->header.gfx.pos[0],
gMarioObject->header.gfx.pos[1] + 80.0f,
gMarioObject->header.gfx.pos[2], (avgScale + 0.2f) * 120.0f)) {
gMarioObject->header.gfx.pos[1] + 80.0f,
gMarioObject->header.gfx.pos[2],
(avgScale + 0.2f) * 120.0f)) {
o->oWaterRingMarioDistInFront = marioDistInFront;
return;
}
if (o->oWaterRingMarioDistInFront * marioDistInFront < 0.0f) {
#endif
struct Object *ringSpawner = o->parentObj;
if (ringSpawner) {
@@ -73,7 +79,9 @@ void water_ring_check_collection(UNUSED f32 avgScale, struct Object *ringManager
o->oAction = WATER_RING_ACT_COLLECTED;
}
#ifndef FIX_WATER_RINGS
o->oWaterRingMarioDistInFront = marioDistInFront;
#endif
}
void water_ring_set_scale(f32 avgScale) {
@@ -154,8 +162,11 @@ void water_ring_spawner_act_inactive(void) {
o->oTimer = 0;
}
if ((o->oTimer == 0) || (o->oTimer == 50) || (o->oTimer == 150) || (o->oTimer == 200)
|| (o->oTimer == 250)) {
if ((o->oTimer == 0)
|| (o->oTimer == 50)
|| (o->oTimer == 150)
|| (o->oTimer == 200)
|| (o->oTimer == 250)) {
struct Object *waterRing = spawn_object(o, MODEL_WATER_RING, bhvJetStreamWaterRing);
waterRing->oWaterRingIndex = o->oWaterRingMgrNextRingIndex;
o->oWaterRingMgrNextRingIndex++;
@@ -199,7 +210,7 @@ void manta_water_ring_act_not_collected(void) {
if (o->oTimer > 150) {
o->oOpacity -= 2;
if (o->oOpacity < 3) {
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
obj_mark_for_deletion(o);
}
}