Skip to content

Commit

Permalink
Start mapping out PathFind related classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Antidote committed Nov 3, 2024
1 parent 6a3e0c0 commit 60189e1
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 8 deletions.
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
cflags_dolphin = [
*cflags_base,
"-multibyte",
"-fp_contract off",
]

# Metrowerks library flags
Expand Down
14 changes: 14 additions & 0 deletions include/Kyoto/Animation/TSegIdMapVariableSize.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef _TSEGIDMAPVARIABLESIZE
#define _TSEGIDMAPVARIABLESIZE

#include <rstl/reserved_vector.hpp>
#include <rstl/pair.hpp>

template < typename T >
struct TSegIdMapVariableSize {

private:
rstl::reserved_vector< rstl::pair< signed char, signed char >, 100 > x4_links;
};

#endif // _TSEGIDMAPVARIABLESIZE
15 changes: 15 additions & 0 deletions include/MetroidPrime/PathFinding/CPFBitSet.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef _CPFBITSET
#define _CPFBITSET

class CPFBitSet {
public:
void Clear();
void Add(int bit);
bool Test(int bit);
void Rmv(int bit);

private:
int mBits[16];
};

#endif // _CPFBITSET
8 changes: 8 additions & 0 deletions include/MetroidPrime/PathFinding/CPathFindArea.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _CPATHFINDAREA
#define _CPATHFINDAREA

class CPFArea {

};

#endif // _CPATHFINDAREA
64 changes: 64 additions & 0 deletions include/MetroidPrime/PathFinding/CPathFindRegion.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef _CPATHFINDREGION
#define _CPATHFINDREGION

#include <Kyoto/Math/CVector3f.hpp>
#include <Kyoto/Math/CAABox.hpp>

class CPFRegion;
class CPFRegionData {
CPFRegionData();

void SetOpenLess(CPFRegion* region);
CPFRegion* GetOpenLess();

void SetOpenMore(CPFRegion* region);
CPFRegion* GetOpenMore();

float GetCost();

void* GetParent();
void Setup(CPFRegion* region, float cost);
void Setup(CPFRegion* region, float, float);
void GetG();

void SetBestPoint(const CVector3f& point);
const CVector3f& GetBestPoint() const;

void SetCookie(int cookie);
int GetCookie() const;

private:
float x0_bestPointDistSq;
CVector3f x4_bestPoint;
int x10_cookie;
float x14_cost;
float x18_g;
float x1c_h;
CPFRegion* x20_parent;
CPFRegion* x24_openLess;
CPFRegion* x28_openMore;
int x2c_parentLink;
};

class CPFArea;
class CPFNode;
class CPFLink;
class CPFRegion {
CPFRegion();
void Fixup(CPFArea& area, int& numNodes);

private:
uint x0_numNodes;
CPFNode* x4_startNode;
uint x8_numLinks;
CPFLink* xc_startLink;
uint x10_flags;
float x14_height;
CVector3f x18_normal;
uint x24_regionIdx;
CVector3f x28_centroid;
CAABox x34_bounds;
CPFRegionData* x4c_data;
};

#endif // _CPATHFINDREGION
11 changes: 11 additions & 0 deletions include/MetroidPrime/PathFinding/CPathFindSearch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _CPATHFINDSEARCH
#define _CPATHFINDSEARCH

class CPFOpenList {

};

class CPathFindSearch {

};
#endif // _CPATHFINDSEARCH
4 changes: 2 additions & 2 deletions src/GuiSys/CGuiObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void CGuiObject::Draw(const CGuiWidgetDrawParms& parms) const {

void CGuiObject::MoveInWorld(const CVector3f& offset) {
CVector3f pos;
if (x64_parent != nullptr) {
pos = x64_parent->RotateW2O(offset);
if (GetParent() != nullptr) {
pos = GetParent()->RotateW2O(offset);
}
x4_localXF.AddTranslation(offset);
RecalculateTransforms();
Expand Down
12 changes: 6 additions & 6 deletions src/MetroidPrime/CPhysicsActor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "MetroidPrime/CPhysicsActor.hpp"

#include "Kyoto/Math/CTransform4f.hpp"
#include "Kyoto/Math/CloseEnough.hpp"

#include "rstl/math.hpp"
Expand Down Expand Up @@ -93,8 +94,8 @@ CPhysicsState CPhysicsActor::GetPhysicsState() const {

void CPhysicsActor::SetPhysicsState(const CPhysicsState& state) {
SetTranslation(state.GetTranslation());
const CQuaternion& quat = state.GetOrientationWR();
const CVector3f& translation = GetTranslation();
CQuaternion quat = state.GetOrientation();
CVector3f translation = GetTranslation();
SetTransform(quat.BuildTransform4f(translation));
SetConstantForceWR(state.GetConstantForceWR());
SetAngularMomentumWR(state.GetAngularMomentumWR());
Expand Down Expand Up @@ -137,7 +138,7 @@ CMotionState CPhysicsActor::PredictAngularMotion(float dt) const {

CMotionState CPhysicsActor::PredictLinearMotion(float dt) const {
CVector3f velocity = CalculateNewVelocityWR_UsingImpulses();
CVector3f sum = x15c_force + x150_momentum;
CVector3f sum = GetConstantTotalForceWR();

return CMotionState(dt * velocity, CNUQuaternion(0.0f, CVector3f::Zero()),
dt * sum + x168_impulse, CAxisAngle::Identity());
Expand Down Expand Up @@ -179,18 +180,17 @@ void CPhysicsActor::AddMotionState(const CMotionState& state) {
CNUQuaternion q(CNUQuaternion::BuildFromMatrix3f(GetTransform().BuildMatrix3f()));
q += state.GetOrientation();
const CQuaternion& quat = CQuaternion::FromNUQuaternion(q);

CVector3f transPos = GetTransform().GetTranslation();
SetTransform(quat.BuildTransform4f(transPos));

transPos += state.GetTranslation();
SetTranslation(transPos);

xfc_constantForce += state.GetVelocity();
x108_angularMomentum += state.GetAngularMomentum();

ComputeDerivedQuantities();

}

bool CPhysicsActor::WillMove(const CStateManager& mgr) {
Expand Down

0 comments on commit 60189e1

Please sign in to comment.