Skip to content

Commit 0bb9f0c

Browse files
zSurface/zPlatform progress (#690)
* zSurface: progress Ported from Seil's PC port * Move macro to xVec3Inlines * Move inline xEnt functions to header * zPlatform: progress Ported from Seil's PC port
1 parent c22d867 commit 0bb9f0c

File tree

12 files changed

+1848
-410
lines changed

12 files changed

+1848
-410
lines changed

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def MatchingFor(*versions):
508508
Object(Matching, "SB/Game/zParEmitter.cpp"),
509509
Object(Matching, "SB/Game/zPendulum.cpp"),
510510
Object(Matching, "SB/Game/zPickupTable.cpp"),
511-
Object(NonMatching, "SB/Game/zPlatform.cpp"),
511+
Object(NonMatching, "SB/Game/zPlatform.cpp", extra_cflags=["-sym on"]),
512512
Object(Matching, "SB/Game/zPortal.cpp"),
513513
Object(Matching, "SB/Game/zRenderState.cpp"),
514514
Object(Equivalent, "SB/Game/zRumble.cpp"),

src/SB/Core/x/xAnim.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,7 @@ inline F32 xAnimFileRawTime(xAnimFile* data, float time)
231231
return data->TimeOffset + time;
232232
}
233233

234+
#define xAnimTableNewStateDefault(table, name, flags, userFlags) xAnimTableNewState((table), (name), (flags), (userFlags), 1.0f, NULL, NULL, 0.0f, NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL)
235+
#define xAnimTableNewTransitionDefault(table, source, dest, priority, blendRecip) xAnimTableNewTransition((table), (source), (dest), NULL, NULL, 0x10, 0, 0.0f, 0.0f, (priority), 0, (blendRecip), NULL)
236+
234237
#endif

src/SB/Core/x/xCollide.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,6 @@ extern U8 xClumpColl_FilterFlags;
4848
#define RpGeometryGetMorphTargetMacro(_geometry, _index) \
4949
(&((_geometry)->morphTarget[(_index)])) // bageomet.h
5050

51-
#define xVec3NormalizeMacro(o, v, len) \
52-
MACRO_START \
53-
{ \
54-
F32 len2 = SQR((v)->x) + SQR((v)->y) + SQR((v)->z); \
55-
if (xeq(len2, 1.0f, 1e-5f)) \
56-
{ \
57-
(o)->x = (v)->x; \
58-
(o)->y = (v)->y; \
59-
(o)->z = (v)->z; \
60-
*(len) = 1.0f; \
61-
} \
62-
else if (xeq(len2, 0.0f, 1e-5f)) \
63-
{ \
64-
(o)->x = 0.0f; \
65-
(o)->y = 1.0f; \
66-
(o)->z = 0.0f; \
67-
*(len) = 0.0f; \
68-
} \
69-
else \
70-
{ \
71-
*(len) = xsqrt(len2); \
72-
F32 len_inv = 1.0f / *(len); \
73-
(o)->x = (v)->x * len_inv; \
74-
(o)->y = (v)->y * len_inv; \
75-
(o)->z = (v)->z * len_inv; \
76-
} \
77-
} \
78-
MACRO_STOP
7951

8052
_xCollsIdx xCollideGetCollsIdx(const xCollis* coll, const xVec3* tohit, const xMat3x3* mat)
8153
{

src/SB/Core/x/xEnt.h

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,33 @@ struct xEnt : xBase
184184
void* user_data; // 0xCC
185185
};
186186

187-
// collision types
188-
#define XENT_COLLTYPE_NONE 0x0
189-
#define XENT_COLLTYPE_TRIG 0x1 // trigger (TRIG)
190-
#define XENT_COLLTYPE_STAT 0x2 // static (SIMP)
191-
#define XENT_COLLTYPE_DYN 0x4 // dynamic (PLAT)
192-
#define XENT_COLLTYPE_NPC 0x8 // npc/enemy (VIL)
193-
#define XENT_COLLTYPE_PLYR 0x10 // player (PLYR)
187+
// Ent flags (xEnt::flags)
188+
#define XENT_IS_VISIBLE ((U8)(1 << 0))
189+
#define XENT_IS_STACKED ((U8)(1 << 1))
190+
#define XENT_0x10 ((U8)(1 << 4))
191+
#define XENT_0x40 ((U8)(1 << 6))
192+
#define XENT_0x80 ((U8)(1 << 7))
193+
194+
// Physics flags (xEnt::pflags)
195+
#define XENT_PFLAGS_IS_MOVING ((U8)(1 << 0))
196+
#define XENT_PFLAGS_HAS_VELOCITY ((U8)(1 << 1))
197+
#define XENT_PFLAGS_HAS_GRAVITY ((U8)(1 << 2))
198+
#define XENT_PFLAGS_HAS_DRAG ((U8)(1 << 3))
199+
#define XENT_PFLAGS_HAS_FRICTION ((U8)(1 << 4))
200+
201+
// More ent flags (xEnt::moreFlags)
202+
#define XENT_MORE_FLAGS_0x8 ((U8)1<<3)
203+
#define XENT_MORE_FLAGS_HITTABLE ((U8)1<<4)
204+
#define XENT_MORE_FLAGS_ANIM_COLL ((U8)1<<5)
205+
206+
// Collision types (xEnt::collType)
207+
#define XENT_COLLTYPE_NONE (U8)0
208+
#define XENT_COLLTYPE_TRIG ((U8)(1 << (0)))
209+
#define XENT_COLLTYPE_STAT ((U8)(1 << (1)))
210+
#define XENT_COLLTYPE_DYN ((U8)(1 << (2)))
211+
#define XENT_COLLTYPE_NPC ((U8)(1 << (3)))
212+
#define XENT_COLLTYPE_PLYR ((U8)(1 << (4)))
213+
#define XENT_COLLTYPE_ENV ((U8)(1 << (5)))
194214

195215
// Size: 0x40
196216
struct xEntShadow

src/SB/Core/x/xEntDrive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ struct xEntDrive
3636
void xEntDriveInit(xEntDrive* drv, xEnt* driven);
3737
void xEntDriveMount(xEntDrive* drv, xEnt* driver, F32 mt, const xCollis* coll);
3838
void xEntDriveDismount(xEntDrive* drv, F32 dmt);
39-
void xEntDriveUpdate(xEntDrive* drv, xScene* s, F32 dt, xCollis* coll);
39+
void xEntDriveUpdate(xEntDrive* drv, xScene* s, F32 dt, const xCollis* coll);
4040

4141
#endif

src/SB/Core/x/xEntMotion.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,46 +1307,6 @@ void xEntMotionDebugDraw(const xEntMotion*);
13071307

13081308
_tagxPad* gDebugPad;
13091309

1310-
void xEntMotionRun(xEntMotion* motion)
1311-
{
1312-
motion->flags &= 0xFFFB;
1313-
}
1314-
1315-
void xEntMotionStop(xEntMotion* motion)
1316-
{
1317-
motion->flags |= 0x4;
1318-
}
1319-
1320-
U32 xEntMotionIsStopped(const xEntMotion* motion)
1321-
{
1322-
return motion->flags & 0x4;
1323-
}
1324-
1325-
U32 xEntERIsExtending(const xEntMotion* motion)
1326-
{
1327-
return motion->t < motion->er.et;
1328-
}
1329-
1330-
U32 xEntERIsExtended(const xEntMotion* motion)
1331-
{
1332-
return motion->t >= motion->er.et && motion->t < motion->er.brt;
1333-
}
1334-
1335-
U32 xEntERIsRetracted(const xEntMotion* motion)
1336-
{
1337-
return motion->t >= motion->er.ert;
1338-
}
1339-
1340-
U32 xEntERIsRetracting(const xEntMotion* motion)
1341-
{
1342-
return motion->t >= motion->er.brt && motion->t < motion->er.ert;
1343-
}
1344-
1345-
void xEntMPSetSpeed(xEntMotion* motion, F32 speed)
1346-
{
1347-
motion->mp.speed = MAX(0.0f, speed);
1348-
}
1349-
13501310
void xQuatCopy(xQuat* a, const xQuat* b)
13511311
{
13521312
a->s = b->s;

src/SB/Core/x/xEntMotion.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define XENTMOTION_H
33

44
#include "xEnt.h"
5+
#include "xEntMotionAsset.h"
56
#include "xMovePoint.h"
67
#include "xColor.h"
78

@@ -186,5 +187,53 @@ void xEntMotionDebugExit();
186187
void xEntMotionStop(xEntMotion* motion);
187188
void xEntMotionRun(xEntMotion* motion);
188189
U32 xEntMotionIsStopped(const xEntMotion* motion);
190+
void xEntMechForward(xEntMotion* motion);
191+
void xEntMechReverse(xEntMotion* motion);
192+
void xEntMPSetSpeed(xEntMotion* motion, F32 speed);
193+
194+
inline U32 xEntMotionIsStopped(const xEntMotion* motion)
195+
{
196+
return motion->flags & k_XENTMOTION_STOPPED;
197+
}
198+
199+
inline void xEntMotionStop(xEntMotion* motion)
200+
{
201+
motion->flags |= k_XENTMOTION_STOPPED;
202+
}
203+
204+
inline void xEntMotionRun(xEntMotion* motion)
205+
{
206+
motion->flags &= (U16)~k_XENTMOTION_STOPPED;
207+
}
208+
209+
inline U32 xEntERIsExtending(const xEntMotion* motion)
210+
{
211+
return motion->t < motion->er.et;
212+
}
213+
214+
inline U32 xEntERIsExtended(const xEntMotion* motion)
215+
{
216+
return motion->t >= motion->er.et && motion->t < motion->er.brt;
217+
}
218+
219+
inline U32 xEntERIsRetracting(const xEntMotion* motion)
220+
{
221+
return motion->t >= motion->er.brt && motion->t < motion->er.ert;
222+
}
223+
224+
inline U32 xEntERIsRetracted(const xEntMotion* motion)
225+
{
226+
return motion->t >= motion->er.ert;
227+
}
228+
229+
inline void xEntMPSetSpeed(xEntMotion* motion, F32 speed)
230+
{
231+
motion->mp.speed = MAX(0.0f, speed);
232+
}
233+
234+
inline void xEntMPAccelerate(xEntMotion* motion, F32 new_speed)
235+
{
236+
motion->mp.speed = MAX(0.0f, motion->mp.speed + new_speed);
237+
}
189238

190239
#endif

src/SB/Core/x/xVec3Inlines.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,35 @@ F32 xVec3LengthFast(F32 x, F32 y, F32 z);
2121
F32 xVec3LengthFast(const xVec3* vec);
2222
void xVec3AddScaled(xVec3* o, const xVec3* v, F32 s);
2323

24+
#define xVec3NormalizeMacro(o, v, len) \
25+
MACRO_START \
26+
{ \
27+
F32 len2 = SQR((v)->x) + SQR((v)->y) + SQR((v)->z); \
28+
if (xeq(len2, 1.0f, 1e-5f)) \
29+
{ \
30+
(o)->x = (v)->x; \
31+
(o)->y = (v)->y; \
32+
(o)->z = (v)->z; \
33+
*(len) = 1.0f; \
34+
} \
35+
else if (xeq(len2, 0.0f, 1e-5f)) \
36+
{ \
37+
(o)->x = 0.0f; \
38+
(o)->y = 1.0f; \
39+
(o)->z = 0.0f; \
40+
*(len) = 0.0f; \
41+
} \
42+
else \
43+
{ \
44+
*(len) = xsqrt(len2); \
45+
F32 len_inv = 1.0f / *(len); \
46+
(o)->x = (v)->x * len_inv; \
47+
(o)->y = (v)->y * len_inv; \
48+
(o)->z = (v)->z * len_inv; \
49+
} \
50+
} \
51+
MACRO_STOP
52+
2453
#define xVec3NormalizeDistXZMacro(o, a, b, dist) \
2554
MACRO_START \
2655
{ \

0 commit comments

Comments
 (0)