Library/MapObj: Implement SurfMapParts (#195)
Some checks are pending
Compile and verify functions / compile_verify (push) Waiting to run
Copy headers to separate repo / copy_headers (push) Waiting to run
lint / clang-format (push) Waiting to run
lint / custom-lint (push) Waiting to run
progress / publish_progress (push) Waiting to run
testcompile / test_compile (push) Waiting to run

This commit is contained in:
Fuzzy2319 2024-11-20 21:42:17 +01:00 committed by GitHub
parent 36fb2fa78f
commit 799f31bd28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 133 additions and 7 deletions

View File

@ -30477,7 +30477,7 @@ Address,Quality,Size,Name
0x00000071004bd21c,U,000052,_ZN2al19createActorFunctionINS_14SeesawMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd250,U,000052,_ZN2al19createActorFunctionINS_13SlideMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd284,U,000052,_ZN2al19createActorFunctionINS_19SubActorLodMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd2b8,U,000052,_ZN2al19createActorFunctionINS_12SurfMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd2b8,O,000052,_ZN2al19createActorFunctionINS_12SurfMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd2ec,U,000052,_ZN2al19createActorFunctionINS_13SwingMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd320,U,000052,_ZN2al19createActorFunctionINS_20SwitchDitherMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd354,U,000052,_ZN2al19createActorFunctionINS_19SwitchKeepOnWatcherEEEPNS_9LiveActorEPKc
@ -58487,11 +58487,11 @@ Address,Quality,Size,Name
0x000000710091a05c,U,000004,_ZN2al28SupportFreezeSyncGroupHolderD0Ev
0x000000710091a060,U,000004,_ZThn264_N2al28SupportFreezeSyncGroupHolderD1Ev
0x000000710091a064,U,000008,_ZThn264_N2al28SupportFreezeSyncGroupHolderD0Ev
0x000000710091a06c,U,000224,_ZN2al12SurfMapPartsC2EPKc
0x000000710091a14c,U,000236,_ZN2al12SurfMapPartsC1EPKc
0x000000710091a238,U,000240,_ZN2al12SurfMapParts4initERKNS_13ActorInitInfoE
0x000000710091a328,U,000424,_ZN2al12SurfMapParts7exeWaitEv
0x000000710091a4d0,U,000008,
0x000000710091a06c,O,000224,_ZN2al12SurfMapPartsC2EPKc
0x000000710091a14c,O,000236,_ZN2al12SurfMapPartsC1EPKc
0x000000710091a238,O,000240,_ZN2al12SurfMapParts4initERKNS_13ActorInitInfoE
0x000000710091a328,O,000424,_ZN2al12SurfMapParts7exeWaitEv
0x000000710091a4d0,O,000008,_ZNK12_GLOBAL__N_119SurfMapPartsNrvWait7executeEPN2al11NerveKeeperE
0x000000710091a4d8,U,000168,_ZN2al13SwingMapPartsC2EPKc
0x000000710091a580,U,000180,_ZN2al13SwingMapPartsC1EPKc
0x000000710091a634,U,000380,_ZN2al13SwingMapParts4initERKNS_13ActorInitInfoE

Can't render this file because it is too large.

View File

@ -0,0 +1,16 @@
#pragma once
#include <math/seadVector.h>
namespace al {
class CollisionPartsFilterBase;
class IUseCollision;
class Triangle;
class TriangleFilterBase;
} // namespace al
namespace alCollisionUtil {
bool getFirstPolyOnArrow(const al::IUseCollision*, sead::Vector3f*, al::Triangle*,
const sead::Vector3f&, const sead::Vector3f&,
const al::CollisionPartsFilterBase*, const al::TriangleFilterBase*);
}

View File

@ -8,6 +8,8 @@
namespace al {
class ByamlIter;
class CollisionParts;
class LiveActor;
struct KCPrismHeader {
u32 mPositionsOffset;
@ -189,4 +191,20 @@ private:
f32 mPrevStep;
};
class CollisionPartsFilterBase {
public:
virtual bool isInvalidParts(CollisionParts* collisionParts) = 0;
};
class CollisionPartsFilterActor : public CollisionPartsFilterBase {
public:
CollisionPartsFilterActor(LiveActor* actor) : mActor(actor) {}
bool isInvalidParts(CollisionParts* collisionParts) override;
private:
LiveActor* mActor;
bool mIsCompareEqual = true;
};
} // namespace al

View File

@ -168,6 +168,7 @@ void addRotateAndRepeatZ(LiveActor* actor, f32);
void addRandomRotateY(LiveActor* actor);
void calcQuatSide(sead::Vector3f*, const LiveActor* actor);
void calcQuatUp(sead::Vector3f*, const LiveActor* actor);
void calcQuatUp(sead::Vector3f*, const sead::Quatf& quat);
void calcQuatFront(sead::Vector3f*, const LiveActor* actor);
void calcQuatLocalAxis(sead::Vector3f*, const LiveActor* actor, s32);
void calcTransOffsetFront(sead::Vector3f*, const LiveActor* actor, f32);

View File

@ -0,0 +1,63 @@
#include "Library/MapObj/SurfMapParts.h"
#include "Library/Collision/CollisionPartsKeeperUtil.h"
#include "Library/Collision/CollisionPartsTriangle.h"
#include "Library/Collision/KCollisionServer.h"
#include "Library/LiveActor/ActorAreaFunction.h"
#include "Library/LiveActor/ActorInitFunction.h"
#include "Library/LiveActor/ActorPoseKeeper.h"
#include "Library/Math/VectorUtil.h"
#include "Library/Nerve/NerveSetupUtil.h"
#include "Library/Placement/PlacementFunction.h"
namespace {
using namespace al;
NERVE_IMPL(SurfMapParts, Wait)
NERVES_MAKE_STRUCT(SurfMapParts, Wait)
} // namespace
namespace al {
SurfMapParts::SurfMapParts(const char* name) : LiveActor(name) {}
void SurfMapParts::init(const ActorInitInfo& info) {
initMapPartsActor(this, info, nullptr);
tryGetQuatPtr(this);
initNerve(this, &NrvSurfMapParts.Wait, 0);
registerAreaHostMtx(this, info);
tryGetArg(&mIsEnableSlope, info, "IsEnableSlope");
initMaterialCode(this, info);
mQuat = getQuat(this);
mTrans = getTrans(this);
calcQuatUp(&mUpDir, mQuat);
mCollisionPartsFilterActor = new CollisionPartsFilterActor(this);
trySyncStageSwitchAppear(this);
}
void SurfMapParts::exeWait() {
sead::Vector3f hitPos;
Triangle triangle;
sead::Vector3f trans = getTrans(this);
if (alCollisionUtil::getFirstPolyOnArrow(
this, &hitPos, &triangle, getTrans(this) + mCheckOffset * sead::Vector3f::ey * 0.5f,
-mCheckOffset * sead::Vector3f::ey, mCollisionPartsFilterActor, nullptr)) {
setTrans(this, trans * 0.9f + hitPos * 0.1f);
if (mIsEnableSlope) {
sead::Quatf quat;
sead::Vector3f normal = triangle.getNormal(0);
turnQuatYDirRate(&quat, getQuat(this), normal, 0.1f);
calcQuatUp(&mUpDir, quat);
}
}
if (mIsEnableSlope)
turnQuatYDirRate(getQuatPtr(this), mQuat, mUpDir, 1.0f);
}
} // namespace al

View File

@ -0,0 +1,25 @@
#pragma once
#include "Library/LiveActor/LiveActor.h"
namespace al {
class CollisionPartsFilterActor;
class SurfMapParts : public LiveActor {
public:
SurfMapParts(const char* name);
void init(const ActorInitInfo& info) override;
void exeWait();
private:
CollisionPartsFilterActor* mCollisionPartsFilterActor = nullptr;
f32 mCheckOffset = 1000.0f;
sead::Quatf mQuat = sead::Quatf::unit;
sead::Vector3f mTrans = sead::Vector3f::zero;
sead::Vector3f mUpDir = sead::Vector3f::ey;
bool mIsEnableSlope = true;
};
static_assert(sizeof(SurfMapParts) == 0x140);
} // namespace al

View File

@ -26,4 +26,6 @@ void makeMtxUpFrontPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vect
const sead::Vector3f&);
void makeMtxRotateTrans(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&);
void turnQuatYDirRate(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, f32);
} // namespace al

View File

@ -8,6 +8,7 @@
#include "Library/MapObj/GateMapParts.h"
#include "Library/MapObj/OneMeshFixMapParts.h"
#include "Library/MapObj/RollingCubeMapParts.h"
#include "Library/MapObj/SurfMapParts.h"
#include "Library/Obj/AllDeadWatcher.h"
#include "MapObj/AnagramAlphabet.h"
@ -574,7 +575,7 @@ static al::NameToCreator<al::ActorCreatorFunction> sProjectActorFactoryEntries[]
{"SeesawMapParts", nullptr},
{"SlideMapParts", nullptr},
{"SubActorLodMapParts", nullptr},
{"SurfMapParts", nullptr},
{"SurfMapParts", al::createActorFunction<al::SurfMapParts>},
{"SwingMapParts", nullptr},
{"SwitchDitherMapParts", nullptr},
{"SwitchKeepOnWatcher", nullptr},