Skip to content

Commit 62172ee

Browse files
committed
some RailGraphUtil
1 parent df992c3 commit 62172ee

3 files changed

Lines changed: 78 additions & 1 deletion

File tree

include/Game/Map/RailGraphIter.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class RailGraphIter {
88
public:
99
RailGraphIter(const RailGraph*);
1010

11+
RailGraphIter(const RailGraphIter& rIter) NO_INLINE {
12+
*this = rIter;
13+
}
14+
1115
void moveNodeNext();
1216
void setNode(s32);
1317
void watchStartEdge();
@@ -28,4 +32,4 @@ class RailGraphIter {
2832
s32 mSelectedEdge; // 0x8
2933
s32 mNextEdge; // 0xC
3034
s32 _10;
31-
};
35+
};

include/Game/Util/RailGraphUtil.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ namespace MR {
2121
bool isWatchedPrevEdge(const RailGraphIter* pRailGraphIter);
2222
s32 getWatchEdgeArg7(const RailGraphIter* pRailGraphIter);
2323
void calcWatchEdgeDirection(const RailGraphIter* pRailGraphIter, TVec3f* pVec);
24+
25+
s32 getNearNodeIndex(const RailGraph*, const TVec3f&, f32, RailGraphNodeSelecter*);
2426
} // namespace MR

src/Game/Util/RailGraphUtil.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include "Game/Util/RailGraphUtil.hpp"
2+
#include "Game/Map/RailGraph.hpp"
3+
#include "Game/Util/MathUtil.hpp"
4+
5+
namespace MR {
6+
RailGraphIter* createRailGraphIter(const RailGraph* pGraph) {
7+
return new RailGraphIter(pGraph->getIterator());
8+
}
9+
10+
void moveNextNode(RailGraphIter* pIter) {
11+
pIter->moveNodeNext();
12+
}
13+
14+
void moveNodeNearPosition(RailGraphIter* pRailGraphIter, const TVec3f& rVec, f32 f, RailGraphNodeSelecter* pSelector) {
15+
pRailGraphIter->setNode(getNearNodeIndex(pRailGraphIter->mGraph, rVec, f, pSelector));
16+
}
17+
18+
void selectReverseEdge(RailGraphIter* pRailGraphIter) {
19+
s32 next = pRailGraphIter->mSelectedEdge;
20+
pRailGraphIter->moveNodeNext();
21+
pRailGraphIter->selectEdge(next);
22+
}
23+
24+
bool isSelectedEdge(const RailGraphIter* pRailGraphIter) {
25+
return pRailGraphIter->isSelectedEdge();
26+
}
27+
28+
bool isWatchedPrevEdge(const RailGraphIter* pRailGraphIter) {
29+
return pRailGraphIter->isWatchedPrevEdge();
30+
}
31+
32+
TVec3f* getCurrentNodePosition(const RailGraphIter* pGraph) {
33+
return &pGraph->getCurrentNode()->_0;
34+
}
35+
36+
TVec3f* getNextNodePosition(const RailGraphIter* pIter) {
37+
return &pIter->getNextNode()->_0;
38+
}
39+
40+
void calcWatchEdgeVector(const RailGraphIter* pIter, TVec3f* pEdge) {
41+
pEdge->set< f32 >(pIter->getWatchNode()->_0 - pIter->getCurrentNode()->_0);
42+
}
43+
44+
void calcWatchEdgeDirection(const RailGraphIter* pRailGraphIter, TVec3f* pVec) {
45+
calcWatchEdgeVector(pRailGraphIter, pVec);
46+
MR::normalize(pVec);
47+
}
48+
49+
// MR::getNearNodeIndex
50+
51+
s32 getSelectEdgeArg0(const RailGraphIter* pIter) {
52+
return pIter->getCurrentEdge()->mPointArg0;
53+
}
54+
55+
s32 getSelectEdgeArg1(const RailGraphIter* pIter) {
56+
return pIter->getCurrentEdge()->mPointArg1;
57+
}
58+
59+
s32 getSelectEdgeArg2(const RailGraphIter* pIter) {
60+
return pIter->getCurrentEdge()->mPointArg2;
61+
}
62+
63+
s32 getSelectEdgeArg3(const RailGraphIter* pIter) {
64+
return pIter->getCurrentEdge()->mPointArg3;
65+
}
66+
67+
s32 getWatchEdgeArg7(const RailGraphIter* pIter) {
68+
return pIter->getWatchEdge()->mPointArg7;
69+
}
70+
71+
}; // namespace MR

0 commit comments

Comments
 (0)