From d2a79f24125a7a8da2e8310bf78787da989d9519 Mon Sep 17 00:00:00 2001 From: Fuzzy2319 Date: Mon, 2 Dec 2024 16:22:24 +0100 Subject: [PATCH 1/5] add:ConveyerStep implementation --- data/odyssey_functions.csv | 22 ++-- lib/al/Library/MapObj/ConveyerStep.cpp | 110 +++++++++++++++++++ lib/al/Library/MapObj/ConveyerStep.h | 69 ++++++++++++ lib/al/Library/Placement/PlacementFunction.h | 1 + 4 files changed, 191 insertions(+), 11 deletions(-) create mode 100644 lib/al/Library/MapObj/ConveyerStep.cpp create mode 100644 lib/al/Library/MapObj/ConveyerStep.h diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index 849f54ce..489c181f 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -58221,17 +58221,17 @@ Address,Quality,Size,Name 0x0000007100912ea8,U,000028,_ZNK2al10FunctorV0MIPNS_16ConveyerMapPartsEMS1_FvvEEclEv 0x0000007100912ec4,U,000076,_ZNK2al10FunctorV0MIPNS_16ConveyerMapPartsEMS1_FvvEE5cloneEv 0x0000007100912f10,U,000004,_ZN2al10FunctorV0MIPNS_16ConveyerMapPartsEMS1_FvvEED0Ev -0x0000007100912f14,U,000140,_ZN2al12ConveyerStepC2EPKc -0x0000007100912fa0,U,000152,_ZN2al12ConveyerStepC1EPKc -0x0000007100913038,U,000076,_ZN2al12ConveyerStep4initERKNS_13ActorInitInfoE -0x0000007100913084,U,000024,_ZN2al12ConveyerStep10receiveMsgEPKNS_9SensorMsgEPNS_9HitSensorES5_ -0x000000710091309c,U,000008,_ZN2al12ConveyerStep7setHostEPNS_9LiveActorE -0x00000071009130a4,U,000012,_ZN2al12ConveyerStep20setConveyerKeyKeeperEPKNS_17ConveyerKeyKeeperEf -0x00000071009130b0,U,000012,_ZN2al12ConveyerStep15setTransByCoordEfb -0x00000071009130bc,U,000480,_ZN2al12ConveyerStep15setTransByCoordEfbb -0x000000710091329c,U,000012,_ZN2al12ConveyerStep23setTransAndResetByCoordEf -0x00000071009132a8,U,000004,_ZN2al12ConveyerStep7exeWaitEv -0x00000071009132ac,U,000004, +0x0000007100912f14,O,000140,_ZN2al12ConveyerStepC2EPKc +0x0000007100912fa0,O,000152,_ZN2al12ConveyerStepC1EPKc +0x0000007100913038,O,000076,_ZN2al12ConveyerStep4initERKNS_13ActorInitInfoE +0x0000007100913084,O,000024,_ZN2al12ConveyerStep10receiveMsgEPKNS_9SensorMsgEPNS_9HitSensorES5_ +0x000000710091309c,O,000008,_ZN2al12ConveyerStep7setHostEPNS_9LiveActorE +0x00000071009130a4,O,000012,_ZN2al12ConveyerStep20setConveyerKeyKeeperEPKNS_17ConveyerKeyKeeperEf +0x00000071009130b0,O,000012,_ZN2al12ConveyerStep15setTransByCoordEfb +0x00000071009130bc,M,000480,_ZN2al12ConveyerStep15setTransByCoordEfbb +0x000000710091329c,O,000012,_ZN2al12ConveyerStep23setTransAndResetByCoordEf +0x00000071009132a8,O,000004,_ZN2al12ConveyerStep7exeWaitEv +0x00000071009132ac,O,000004,_ZNK12_GLOBAL__N_119ConveyerStepNrvWait7executeEPN2al11NerveKeeperE 0x00000071009132b0,O,000156,_ZN2al12FallMapPartsC2EPKc 0x000000710091334c,O,000168,_ZN2al12FallMapPartsC1EPKc 0x00000071009133f4,O,000164,_ZN2al12FallMapParts4initERKNS_13ActorInitInfoE diff --git a/lib/al/Library/MapObj/ConveyerStep.cpp b/lib/al/Library/MapObj/ConveyerStep.cpp new file mode 100644 index 00000000..0fb3cf32 --- /dev/null +++ b/lib/al/Library/MapObj/ConveyerStep.cpp @@ -0,0 +1,110 @@ +#include "Library/MapObj/ConveyerStep.h" + +#include "Library/Base/StringUtil.h" +#include "Library/LiveActor/ActorActionFunction.h" +#include "Library/LiveActor/ActorClippingFunction.h" +#include "Library/LiveActor/ActorInitFunction.h" +#include "Library/LiveActor/ActorMovementFunction.h" +#include "Library/LiveActor/ActorPoseKeeper.h" +#include "Library/Math/MathUtil.h" +#include "Library/Nerve/NerveSetupUtil.h" +#include "Library/Placement/PlacementFunction.h" + +namespace { +using namespace al; + +NERVE_IMPL(ConveyerStep, Wait) + +NERVES_MAKE_STRUCT(ConveyerStep, Wait) +} // namespace + +namespace al { +ConveyerStep::ConveyerStep(const char* name) : LiveActor(name) {} + +void ConveyerStep::init(const ActorInitInfo& info) { + initMapPartsActor(this, info, nullptr); + initNerve(this, &NrvConveyerStep.Wait, 0); + onDrawClipping(this); + + makeActorAlive(); +} + +bool ConveyerStep::receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) { + if (mHost != nullptr) + return mHost->receiveMsg(message, other, self); + + return false; +} + +void ConveyerStep::setHost(LiveActor* host) { + mHost = host; +} + +void ConveyerStep::setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 param_2) { + mConveyerKeyKeeper = conveyerKeyKeeper; + _12c = param_2; +} + +void ConveyerStep::setTransByCoord(f32 param_1, bool param_2) { + setTransByCoord(param_1, param_2, false); +} + +inline void test(ConveyerStep* conveyerStep, f32 mod) __attribute__((always_inline)) { + if (mod <= conveyerStep->getConveyerKeyKeeper()->get_34()) { + if (!conveyerStep->get_130()) { + conveyerStep->set_130(true); + if (conveyerStep->getModelKeeper() != nullptr && isHideModel(conveyerStep)) + showModel(conveyerStep); + if (isExistCollisionParts(conveyerStep)) + validateCollisionParts(conveyerStep); + } + } else if (conveyerStep->get_130()) { + conveyerStep->set_130(false); + if (conveyerStep->getModelKeeper() != nullptr && !isHideModel(conveyerStep)) + hideModel(conveyerStep); + if (isExistCollisionParts(conveyerStep)) + invalidateCollisionParts(conveyerStep); + } + + conveyerStep->set_128(mod); +} + +void ConveyerStep::setTransByCoord(f32 param_1, bool param_2, bool param_3) + __attribute__((noinline)) { + f32 mod = modf(_12c + param_1, _12c) + 0.0f; + s32 index = -1; + + mConveyerKeyKeeper->calcPosAndQuat(getTransPtr(this), getQuatPtr(this), &index, mod); + + const char* keyHitReactionName = nullptr; + const char* actionName = nullptr; + + if (index > -1) { + const ConveyerKey conveyerKey = mConveyerKeyKeeper->getConveyerKey(index); + + if (tryGetStringArg(&keyHitReactionName, *conveyerKey.mPlacementInfo, + "KeyHitReactionName") && + (mKeyHitReactionName == nullptr || + !isEqualString(mKeyHitReactionName, keyHitReactionName))) + startHitReaction(this, keyHitReactionName); + + if (tryGetStringArg(&actionName, *conveyerKey.mPlacementInfo, "ActionName") && + (mActionName == nullptr || !isEqualString(mActionName, actionName))) + startHitReaction(this, actionName); + } + + mKeyHitReactionName = keyHitReactionName; + mActionName = actionName; + + if (param_3 || (!param_2 && _128 >= mod) || (param_2 && _128 <= mod)) + resetPosition(this); + + test(this, mod); +} + +void ConveyerStep::setTransAndResetByCoord(f32 param_1) { + setTransByCoord(param_1, true, true); +} + +void ConveyerStep::exeWait() {} +} // namespace al diff --git a/lib/al/Library/MapObj/ConveyerStep.h b/lib/al/Library/MapObj/ConveyerStep.h new file mode 100644 index 00000000..b72aadb6 --- /dev/null +++ b/lib/al/Library/MapObj/ConveyerStep.h @@ -0,0 +1,69 @@ +#pragma once + +#include "Library/LiveActor/ActorCollisionFunction.h" +#include "Library/LiveActor/ActorModelFunction.h" +#include "Library/LiveActor/LiveActor.h" + +namespace al { +class ConveyerKeyKeeper; +class PlacementInfo; + +struct ConveyerKey { + void* _0[5]; + PlacementInfo* mPlacementInfo; +}; + +class ConveyerKeyKeeper { +public: + ConveyerKeyKeeper(); + + void init(const ActorInitInfo& info); + void calcPosAndQuat(sead::Vector3f*, sead::Quatf*, s32*, f32) const; + void calcPosAndQuatByKeyIndex(sead::Vector3f*, sead::Quatf*, s32 index) const; + void calcClippingSphere(sead::Vector3f*, f32*, f32) const; + const ConveyerKey& getConveyerKey(s32 index) const; // return type depends on the type of _0 + + f32 get_34() const { return _34; } + +private: + ConveyerKey* mConveyerKeys; // array of a struct/class with a size of 0x30? + s32 mConveyerKeyCount; + sead::Quatf mQuat; + sead::Vector3f mTrans; + sead::Vector3f _28; + f32 _34; +}; + +class ConveyerStep : public LiveActor { +public: + ConveyerStep(const char* name); + + void init(const ActorInitInfo& info) override; + bool receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) override; + + void setHost(LiveActor* host); + void setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32); + void setTransByCoord(f32, bool); + void setTransByCoord(f32, bool, bool) __attribute__((noinline)); + void setTransAndResetByCoord(f32); + + void exeWait(); + + const ConveyerKeyKeeper* getConveyerKeyKeeper() const { return mConveyerKeyKeeper; } + + bool get_130() const { return _130; } + + void set_128(float ukn) { _128 = ukn; } + + void set_130(bool ukn) { _130 = ukn; } + +private: + LiveActor* mHost = nullptr; + const ConveyerKeyKeeper* mConveyerKeyKeeper = nullptr; + const char* mKeyHitReactionName = nullptr; + const char* mActionName = nullptr; + f32 _128 = 0.0f; + f32 _12c = 0.0f; + bool _130 = true; +}; +} // namespace al diff --git a/lib/al/Library/Placement/PlacementFunction.h b/lib/al/Library/Placement/PlacementFunction.h index 8657af9c..445f1a64 100644 --- a/lib/al/Library/Placement/PlacementFunction.h +++ b/lib/al/Library/Placement/PlacementFunction.h @@ -118,6 +118,7 @@ void getStringArg(const ActorInitInfo& initInfo, const char* key); void getStringArg(const PlacementInfo& placementInfo, const char* key); void getStringArg(const AreaInitInfo& initInfo, const char* key); bool tryGetStringArg(const char** arg, const ActorInitInfo& initInfo, const char* key); +bool tryGetStringArg(const char** arg, const PlacementInfo& initInfo, const char* key); bool tryGetStringArg(const char** arg, const AreaInitInfo& initInfo, const char* key); bool tryGetArgV2f(sead::Vector2f* arg, const ActorInitInfo& initInfo, const char* key); bool tryGetArgV2f(sead::Vector2f* arg, const PlacementInfo& initInfo, const char* key); From 6301aed100069c5bc555ed0f2af7bb439441a4d0 Mon Sep 17 00:00:00 2001 From: Fuzzy2319 Date: Tue, 3 Dec 2024 09:11:04 +0100 Subject: [PATCH 2/5] fix:ConveyerStep::setTransByCoord mismatch --- data/odyssey_functions.csv | 2 +- lib/al/Library/MapObj/ConveyerStep.cpp | 51 ++++++++++---------- lib/al/Library/MapObj/ConveyerStep.h | 37 -------------- lib/al/Project/LiveActor/ConveyerKeyKeeper.h | 35 ++++++++++++++ 4 files changed, 61 insertions(+), 64 deletions(-) create mode 100644 lib/al/Project/LiveActor/ConveyerKeyKeeper.h diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index 489c181f..22c5e8a4 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -58228,7 +58228,7 @@ Address,Quality,Size,Name 0x000000710091309c,O,000008,_ZN2al12ConveyerStep7setHostEPNS_9LiveActorE 0x00000071009130a4,O,000012,_ZN2al12ConveyerStep20setConveyerKeyKeeperEPKNS_17ConveyerKeyKeeperEf 0x00000071009130b0,O,000012,_ZN2al12ConveyerStep15setTransByCoordEfb -0x00000071009130bc,M,000480,_ZN2al12ConveyerStep15setTransByCoordEfbb +0x00000071009130bc,O,000480,_ZN2al12ConveyerStep15setTransByCoordEfbb 0x000000710091329c,O,000012,_ZN2al12ConveyerStep23setTransAndResetByCoordEf 0x00000071009132a8,O,000004,_ZN2al12ConveyerStep7exeWaitEv 0x00000071009132ac,O,000004,_ZNK12_GLOBAL__N_119ConveyerStepNrvWait7executeEPN2al11NerveKeeperE diff --git a/lib/al/Library/MapObj/ConveyerStep.cpp b/lib/al/Library/MapObj/ConveyerStep.cpp index 0fb3cf32..7480a2b9 100644 --- a/lib/al/Library/MapObj/ConveyerStep.cpp +++ b/lib/al/Library/MapObj/ConveyerStep.cpp @@ -3,12 +3,15 @@ #include "Library/Base/StringUtil.h" #include "Library/LiveActor/ActorActionFunction.h" #include "Library/LiveActor/ActorClippingFunction.h" +#include "Library/LiveActor/ActorCollisionFunction.h" #include "Library/LiveActor/ActorInitFunction.h" +#include "Library/LiveActor/ActorModelFunction.h" #include "Library/LiveActor/ActorMovementFunction.h" #include "Library/LiveActor/ActorPoseKeeper.h" #include "Library/Math/MathUtil.h" #include "Library/Nerve/NerveSetupUtil.h" #include "Library/Placement/PlacementFunction.h" +#include "Project/LiveActor/ConveyerKeyKeeper.h" namespace { using namespace al; @@ -49,26 +52,6 @@ void ConveyerStep::setTransByCoord(f32 param_1, bool param_2) { setTransByCoord(param_1, param_2, false); } -inline void test(ConveyerStep* conveyerStep, f32 mod) __attribute__((always_inline)) { - if (mod <= conveyerStep->getConveyerKeyKeeper()->get_34()) { - if (!conveyerStep->get_130()) { - conveyerStep->set_130(true); - if (conveyerStep->getModelKeeper() != nullptr && isHideModel(conveyerStep)) - showModel(conveyerStep); - if (isExistCollisionParts(conveyerStep)) - validateCollisionParts(conveyerStep); - } - } else if (conveyerStep->get_130()) { - conveyerStep->set_130(false); - if (conveyerStep->getModelKeeper() != nullptr && !isHideModel(conveyerStep)) - hideModel(conveyerStep); - if (isExistCollisionParts(conveyerStep)) - invalidateCollisionParts(conveyerStep); - } - - conveyerStep->set_128(mod); -} - void ConveyerStep::setTransByCoord(f32 param_1, bool param_2, bool param_3) __attribute__((noinline)) { f32 mod = modf(_12c + param_1, _12c) + 0.0f; @@ -80,26 +63,42 @@ void ConveyerStep::setTransByCoord(f32 param_1, bool param_2, bool param_3) const char* actionName = nullptr; if (index > -1) { - const ConveyerKey conveyerKey = mConveyerKeyKeeper->getConveyerKey(index); + const ConveyerKey* conveyerKey = mConveyerKeyKeeper->getConveyerKey(index); - if (tryGetStringArg(&keyHitReactionName, *conveyerKey.mPlacementInfo, + if (tryGetStringArg(&keyHitReactionName, conveyerKey->mPlacementInfo, "KeyHitReactionName") && (mKeyHitReactionName == nullptr || !isEqualString(mKeyHitReactionName, keyHitReactionName))) startHitReaction(this, keyHitReactionName); - if (tryGetStringArg(&actionName, *conveyerKey.mPlacementInfo, "ActionName") && + if (tryGetStringArg(&actionName, conveyerKey->mPlacementInfo, "ActionName") && (mActionName == nullptr || !isEqualString(mActionName, actionName))) - startHitReaction(this, actionName); + startAction(this, actionName); } mKeyHitReactionName = keyHitReactionName; mActionName = actionName; - if (param_3 || (!param_2 && _128 >= mod) || (param_2 && _128 <= mod)) + if ((param_2 && mod < _128) || (!param_2 && mod > _128) || param_3) resetPosition(this); - test(this, mod); + if (mod > mConveyerKeyKeeper->get_34()) { + if (_130) { + _130 = false; + if (getModelKeeper() != nullptr && !isHideModel(this)) + hideModel(this); + if (isExistCollisionParts(this)) + invalidateCollisionParts(this); + } + } else if (!_130) { + _130 = true; + if (getModelKeeper() != nullptr && isHideModel(this)) + showModel(this); + if (isExistCollisionParts(this)) + validateCollisionParts(this); + } + + _128 = mod; } void ConveyerStep::setTransAndResetByCoord(f32 param_1) { diff --git a/lib/al/Library/MapObj/ConveyerStep.h b/lib/al/Library/MapObj/ConveyerStep.h index b72aadb6..08c15fbc 100644 --- a/lib/al/Library/MapObj/ConveyerStep.h +++ b/lib/al/Library/MapObj/ConveyerStep.h @@ -1,38 +1,9 @@ #pragma once -#include "Library/LiveActor/ActorCollisionFunction.h" -#include "Library/LiveActor/ActorModelFunction.h" #include "Library/LiveActor/LiveActor.h" namespace al { class ConveyerKeyKeeper; -class PlacementInfo; - -struct ConveyerKey { - void* _0[5]; - PlacementInfo* mPlacementInfo; -}; - -class ConveyerKeyKeeper { -public: - ConveyerKeyKeeper(); - - void init(const ActorInitInfo& info); - void calcPosAndQuat(sead::Vector3f*, sead::Quatf*, s32*, f32) const; - void calcPosAndQuatByKeyIndex(sead::Vector3f*, sead::Quatf*, s32 index) const; - void calcClippingSphere(sead::Vector3f*, f32*, f32) const; - const ConveyerKey& getConveyerKey(s32 index) const; // return type depends on the type of _0 - - f32 get_34() const { return _34; } - -private: - ConveyerKey* mConveyerKeys; // array of a struct/class with a size of 0x30? - s32 mConveyerKeyCount; - sead::Quatf mQuat; - sead::Vector3f mTrans; - sead::Vector3f _28; - f32 _34; -}; class ConveyerStep : public LiveActor { public: @@ -49,14 +20,6 @@ class ConveyerStep : public LiveActor { void exeWait(); - const ConveyerKeyKeeper* getConveyerKeyKeeper() const { return mConveyerKeyKeeper; } - - bool get_130() const { return _130; } - - void set_128(float ukn) { _128 = ukn; } - - void set_130(bool ukn) { _130 = ukn; } - private: LiveActor* mHost = nullptr; const ConveyerKeyKeeper* mConveyerKeyKeeper = nullptr; diff --git a/lib/al/Project/LiveActor/ConveyerKeyKeeper.h b/lib/al/Project/LiveActor/ConveyerKeyKeeper.h new file mode 100644 index 00000000..ecfbd0b8 --- /dev/null +++ b/lib/al/Project/LiveActor/ConveyerKeyKeeper.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include + +namespace al { +class ActorInitInfo; +class PlacementInfo; + +struct ConveyerKey { + void* _0[5]; + PlacementInfo& mPlacementInfo; +}; + +class ConveyerKeyKeeper { +public: + ConveyerKeyKeeper(); + + void init(const ActorInitInfo& info); + void calcPosAndQuat(sead::Vector3f*, sead::Quatf*, s32*, f32) const; + void calcPosAndQuatByKeyIndex(sead::Vector3f*, sead::Quatf*, s32 index) const; + void calcClippingSphere(sead::Vector3f*, f32*, f32) const; + const ConveyerKey* getConveyerKey(s32 index) const; // return type depends on the type of _0 + + f32 get_34() const { return _34; } + +private: + ConveyerKey** mConveyerKeys; // array of a struct/class with a size of 0x30? + s32 mConveyerKeyCount; + sead::Quatf mQuat; + sead::Vector3f mTrans; + sead::Vector3f _28; + f32 _34; +}; +} // namespace al From ea5b7ac37db26ec57fddc3eca29ad99f527aef49 Mon Sep 17 00:00:00 2001 From: Fuzzy2319 Date: Tue, 3 Dec 2024 12:35:04 +0100 Subject: [PATCH 3/5] add:ConveyerStep missing names --- lib/al/Library/MapObj/ConveyerStep.cpp | 35 +++++++++++++------------- lib/al/Library/MapObj/ConveyerStep.h | 14 +++++------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/al/Library/MapObj/ConveyerStep.cpp b/lib/al/Library/MapObj/ConveyerStep.cpp index 7480a2b9..80198e09 100644 --- a/lib/al/Library/MapObj/ConveyerStep.cpp +++ b/lib/al/Library/MapObj/ConveyerStep.cpp @@ -43,21 +43,21 @@ void ConveyerStep::setHost(LiveActor* host) { mHost = host; } -void ConveyerStep::setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 param_2) { +void ConveyerStep::setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 coord) { mConveyerKeyKeeper = conveyerKeyKeeper; - _12c = param_2; + mCoord = coord; } -void ConveyerStep::setTransByCoord(f32 param_1, bool param_2) { - setTransByCoord(param_1, param_2, false); +void ConveyerStep::setTransByCoord(f32 coord, bool isMoving) { + setTransByCoord(coord, isMoving, false); } -void ConveyerStep::setTransByCoord(f32 param_1, bool param_2, bool param_3) - __attribute__((noinline)) { - f32 mod = modf(_12c + param_1, _12c) + 0.0f; +__attribute__((noinline)) void ConveyerStep::setTransByCoord(f32 coord, bool isMoving, + bool forceReset) { + f32 relativeCoord = modf(mCoord + coord, mCoord) + 0.0f; s32 index = -1; - mConveyerKeyKeeper->calcPosAndQuat(getTransPtr(this), getQuatPtr(this), &index, mod); + mConveyerKeyKeeper->calcPosAndQuat(getTransPtr(this), getQuatPtr(this), &index, relativeCoord); const char* keyHitReactionName = nullptr; const char* actionName = nullptr; @@ -79,30 +79,31 @@ void ConveyerStep::setTransByCoord(f32 param_1, bool param_2, bool param_3) mKeyHitReactionName = keyHitReactionName; mActionName = actionName; - if ((param_2 && mod < _128) || (!param_2 && mod > _128) || param_3) + if ((isMoving && relativeCoord < mRelativeCoord) || + (!isMoving && relativeCoord > mRelativeCoord) || forceReset) resetPosition(this); - if (mod > mConveyerKeyKeeper->get_34()) { - if (_130) { - _130 = false; + if (relativeCoord > mConveyerKeyKeeper->get_34()) { + if (mIsExist) { + mIsExist = false; if (getModelKeeper() != nullptr && !isHideModel(this)) hideModel(this); if (isExistCollisionParts(this)) invalidateCollisionParts(this); } - } else if (!_130) { - _130 = true; + } else if (!mIsExist) { + mIsExist = true; if (getModelKeeper() != nullptr && isHideModel(this)) showModel(this); if (isExistCollisionParts(this)) validateCollisionParts(this); } - _128 = mod; + mRelativeCoord = relativeCoord; } -void ConveyerStep::setTransAndResetByCoord(f32 param_1) { - setTransByCoord(param_1, true, true); +void ConveyerStep::setTransAndResetByCoord(f32 coord) { + setTransByCoord(coord, true, true); } void ConveyerStep::exeWait() {} diff --git a/lib/al/Library/MapObj/ConveyerStep.h b/lib/al/Library/MapObj/ConveyerStep.h index 08c15fbc..0c3f5133 100644 --- a/lib/al/Library/MapObj/ConveyerStep.h +++ b/lib/al/Library/MapObj/ConveyerStep.h @@ -13,10 +13,10 @@ class ConveyerStep : public LiveActor { bool receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) override; void setHost(LiveActor* host); - void setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32); - void setTransByCoord(f32, bool); - void setTransByCoord(f32, bool, bool) __attribute__((noinline)); - void setTransAndResetByCoord(f32); + void setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 coord); + void setTransByCoord(f32 coord, bool isMoving); + __attribute__((noinline)) void setTransByCoord(f32 coord, bool isMoving, bool forceReset); + void setTransAndResetByCoord(f32 coord); void exeWait(); @@ -25,8 +25,8 @@ class ConveyerStep : public LiveActor { const ConveyerKeyKeeper* mConveyerKeyKeeper = nullptr; const char* mKeyHitReactionName = nullptr; const char* mActionName = nullptr; - f32 _128 = 0.0f; - f32 _12c = 0.0f; - bool _130 = true; + f32 mRelativeCoord = 0.0f; + f32 mCoord = 0.0f; + bool mIsExist = true; }; } // namespace al From ede7c5bc452bd6fd75e57fd503b1ebad2834c977 Mon Sep 17 00:00:00 2001 From: Fuzzy2319 Date: Mon, 9 Dec 2024 09:39:09 +0100 Subject: [PATCH 4/5] update:names --- lib/al/Library/MapObj/ConveyerStep.cpp | 22 ++++++++++---------- lib/al/Library/MapObj/ConveyerStep.h | 8 +++---- lib/al/Project/LiveActor/ConveyerKeyKeeper.h | 7 ++++--- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/al/Library/MapObj/ConveyerStep.cpp b/lib/al/Library/MapObj/ConveyerStep.cpp index 80198e09..8350206e 100644 --- a/lib/al/Library/MapObj/ConveyerStep.cpp +++ b/lib/al/Library/MapObj/ConveyerStep.cpp @@ -45,19 +45,19 @@ void ConveyerStep::setHost(LiveActor* host) { void ConveyerStep::setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 coord) { mConveyerKeyKeeper = conveyerKeyKeeper; - mCoord = coord; + mInitialCoord = coord; } -void ConveyerStep::setTransByCoord(f32 coord, bool isMoving) { - setTransByCoord(coord, isMoving, false); +void ConveyerStep::setTransByCoord(f32 coord, bool isBackwards) { + setTransByCoord(coord, isBackwards, false); } -__attribute__((noinline)) void ConveyerStep::setTransByCoord(f32 coord, bool isMoving, - bool forceReset) { - f32 relativeCoord = modf(mCoord + coord, mCoord) + 0.0f; +__attribute__((noinline)) void ConveyerStep::setTransByCoord(f32 coord, bool isBackwards, + bool isForceReset) { + f32 newCoord = modf(mInitialCoord + coord, mInitialCoord) + 0.0f; s32 index = -1; - mConveyerKeyKeeper->calcPosAndQuat(getTransPtr(this), getQuatPtr(this), &index, relativeCoord); + mConveyerKeyKeeper->calcPosAndQuat(getTransPtr(this), getQuatPtr(this), &index, newCoord); const char* keyHitReactionName = nullptr; const char* actionName = nullptr; @@ -79,11 +79,11 @@ __attribute__((noinline)) void ConveyerStep::setTransByCoord(f32 coord, bool isM mKeyHitReactionName = keyHitReactionName; mActionName = actionName; - if ((isMoving && relativeCoord < mRelativeCoord) || - (!isMoving && relativeCoord > mRelativeCoord) || forceReset) + if ((isBackwards && newCoord < mCurrentCoord) || (!isBackwards && newCoord > mCurrentCoord) || + isForceReset) resetPosition(this); - if (relativeCoord > mConveyerKeyKeeper->get_34()) { + if (newCoord > mConveyerKeyKeeper->get_34()) { if (mIsExist) { mIsExist = false; if (getModelKeeper() != nullptr && !isHideModel(this)) @@ -99,7 +99,7 @@ __attribute__((noinline)) void ConveyerStep::setTransByCoord(f32 coord, bool isM validateCollisionParts(this); } - mRelativeCoord = relativeCoord; + mCurrentCoord = newCoord; } void ConveyerStep::setTransAndResetByCoord(f32 coord) { diff --git a/lib/al/Library/MapObj/ConveyerStep.h b/lib/al/Library/MapObj/ConveyerStep.h index 0c3f5133..8d61aab2 100644 --- a/lib/al/Library/MapObj/ConveyerStep.h +++ b/lib/al/Library/MapObj/ConveyerStep.h @@ -14,8 +14,8 @@ class ConveyerStep : public LiveActor { void setHost(LiveActor* host); void setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 coord); - void setTransByCoord(f32 coord, bool isMoving); - __attribute__((noinline)) void setTransByCoord(f32 coord, bool isMoving, bool forceReset); + void setTransByCoord(f32 coord, bool isBackwards); + __attribute__((noinline)) void setTransByCoord(f32 coord, bool isBackwards, bool isForceReset); void setTransAndResetByCoord(f32 coord); void exeWait(); @@ -25,8 +25,8 @@ class ConveyerStep : public LiveActor { const ConveyerKeyKeeper* mConveyerKeyKeeper = nullptr; const char* mKeyHitReactionName = nullptr; const char* mActionName = nullptr; - f32 mRelativeCoord = 0.0f; - f32 mCoord = 0.0f; + f32 mCurrentCoord = 0.0f; + f32 mInitialCoord = 0.0f; bool mIsExist = true; }; } // namespace al diff --git a/lib/al/Project/LiveActor/ConveyerKeyKeeper.h b/lib/al/Project/LiveActor/ConveyerKeyKeeper.h index ecfbd0b8..8a248831 100644 --- a/lib/al/Project/LiveActor/ConveyerKeyKeeper.h +++ b/lib/al/Project/LiveActor/ConveyerKeyKeeper.h @@ -7,6 +7,7 @@ namespace al { class ActorInitInfo; class PlacementInfo; +// TODO: I'm not sure about this struct ConveyerKey { void* _0[5]; PlacementInfo& mPlacementInfo; @@ -17,9 +18,9 @@ class ConveyerKeyKeeper { ConveyerKeyKeeper(); void init(const ActorInitInfo& info); - void calcPosAndQuat(sead::Vector3f*, sead::Quatf*, s32*, f32) const; - void calcPosAndQuatByKeyIndex(sead::Vector3f*, sead::Quatf*, s32 index) const; - void calcClippingSphere(sead::Vector3f*, f32*, f32) const; + void calcPosAndQuat(sead::Vector3f* pos, sead::Quatf* quat, s32* index, f32 coord) const; + void calcPosAndQuatByKeyIndex(sead::Vector3f* pos, sead::Quatf* quat, s32 index) const; + void calcClippingSphere(sead::Vector3f* clippingTrans, f32* clippingRadius, f32 offset) const; const ConveyerKey* getConveyerKey(s32 index) const; // return type depends on the type of _0 f32 get_34() const { return _34; } From 24082065a6eb084841bcc18c249e606c1779c811 Mon Sep 17 00:00:00 2001 From: Fuzzy2319 Date: Mon, 16 Dec 2024 08:47:52 +0100 Subject: [PATCH 5/5] fix:requested changes --- lib/al/Library/MapObj/ConveyerStep.cpp | 13 ++++++------- lib/al/Library/MapObj/ConveyerStep.h | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/al/Library/MapObj/ConveyerStep.cpp b/lib/al/Library/MapObj/ConveyerStep.cpp index 8350206e..3691914e 100644 --- a/lib/al/Library/MapObj/ConveyerStep.cpp +++ b/lib/al/Library/MapObj/ConveyerStep.cpp @@ -45,16 +45,15 @@ void ConveyerStep::setHost(LiveActor* host) { void ConveyerStep::setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 coord) { mConveyerKeyKeeper = conveyerKeyKeeper; - mInitialCoord = coord; + mMaxCoord = coord; } -void ConveyerStep::setTransByCoord(f32 coord, bool isBackwards) { - setTransByCoord(coord, isBackwards, false); +void ConveyerStep::setTransByCoord(f32 coord, bool isForwards) { + setTransByCoord(coord, isForwards, false); } -__attribute__((noinline)) void ConveyerStep::setTransByCoord(f32 coord, bool isBackwards, - bool isForceReset) { - f32 newCoord = modf(mInitialCoord + coord, mInitialCoord) + 0.0f; +void ConveyerStep::setTransByCoord(f32 coord, bool isForwards, bool isForceReset) { + f32 newCoord = modf(mMaxCoord + coord, mMaxCoord) + 0.0f; s32 index = -1; mConveyerKeyKeeper->calcPosAndQuat(getTransPtr(this), getQuatPtr(this), &index, newCoord); @@ -79,7 +78,7 @@ __attribute__((noinline)) void ConveyerStep::setTransByCoord(f32 coord, bool isB mKeyHitReactionName = keyHitReactionName; mActionName = actionName; - if ((isBackwards && newCoord < mCurrentCoord) || (!isBackwards && newCoord > mCurrentCoord) || + if ((isForwards && newCoord < mCurrentCoord) || (!isForwards && newCoord > mCurrentCoord) || isForceReset) resetPosition(this); diff --git a/lib/al/Library/MapObj/ConveyerStep.h b/lib/al/Library/MapObj/ConveyerStep.h index 8d61aab2..81ce6544 100644 --- a/lib/al/Library/MapObj/ConveyerStep.h +++ b/lib/al/Library/MapObj/ConveyerStep.h @@ -14,8 +14,8 @@ class ConveyerStep : public LiveActor { void setHost(LiveActor* host); void setConveyerKeyKeeper(const ConveyerKeyKeeper* conveyerKeyKeeper, f32 coord); - void setTransByCoord(f32 coord, bool isBackwards); - __attribute__((noinline)) void setTransByCoord(f32 coord, bool isBackwards, bool isForceReset); + void setTransByCoord(f32 coord, bool isForwards); + void setTransByCoord(f32 coord, bool isForwards, bool isForceReset); void setTransAndResetByCoord(f32 coord); void exeWait(); @@ -26,7 +26,7 @@ class ConveyerStep : public LiveActor { const char* mKeyHitReactionName = nullptr; const char* mActionName = nullptr; f32 mCurrentCoord = 0.0f; - f32 mInitialCoord = 0.0f; + f32 mMaxCoord = 0.0f; bool mIsExist = true; }; } // namespace al