Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def MatchingFor(*versions):
Object(Matching, "SB/Game/zParEmitter.cpp"),
Object(Matching, "SB/Game/zPendulum.cpp"),
Object(Matching, "SB/Game/zPickupTable.cpp"),
Object(NonMatching, "SB/Game/zPlatform.cpp"),
Object(NonMatching, "SB/Game/zPlatform.cpp", extra_cflags=["-sym on"]),
Object(Matching, "SB/Game/zPortal.cpp"),
Object(Matching, "SB/Game/zRenderState.cpp"),
Object(Equivalent, "SB/Game/zRumble.cpp"),
Expand Down
3 changes: 3 additions & 0 deletions src/SB/Core/x/xAnim.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,7 @@ inline F32 xAnimFileRawTime(xAnimFile* data, float time)
return data->TimeOffset + time;
}

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

#endif
28 changes: 0 additions & 28 deletions src/SB/Core/x/xCollide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,6 @@ extern U8 xClumpColl_FilterFlags;
#define RpGeometryGetMorphTargetMacro(_geometry, _index) \
(&((_geometry)->morphTarget[(_index)])) // bageomet.h

#define xVec3NormalizeMacro(o, v, len) \
MACRO_START \
{ \
F32 len2 = SQR((v)->x) + SQR((v)->y) + SQR((v)->z); \
if (xeq(len2, 1.0f, 1e-5f)) \
{ \
(o)->x = (v)->x; \
(o)->y = (v)->y; \
(o)->z = (v)->z; \
*(len) = 1.0f; \
} \
else if (xeq(len2, 0.0f, 1e-5f)) \
{ \
(o)->x = 0.0f; \
(o)->y = 1.0f; \
(o)->z = 0.0f; \
*(len) = 0.0f; \
} \
else \
{ \
*(len) = xsqrt(len2); \
F32 len_inv = 1.0f / *(len); \
(o)->x = (v)->x * len_inv; \
(o)->y = (v)->y * len_inv; \
(o)->z = (v)->z * len_inv; \
} \
} \
MACRO_STOP

_xCollsIdx xCollideGetCollsIdx(const xCollis* coll, const xVec3* tohit, const xMat3x3* mat)
{
Expand Down
34 changes: 27 additions & 7 deletions src/SB/Core/x/xEnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,33 @@ struct xEnt : xBase
void* user_data; // 0xCC
};

// collision types
#define XENT_COLLTYPE_NONE 0x0
#define XENT_COLLTYPE_TRIG 0x1 // trigger (TRIG)
#define XENT_COLLTYPE_STAT 0x2 // static (SIMP)
#define XENT_COLLTYPE_DYN 0x4 // dynamic (PLAT)
#define XENT_COLLTYPE_NPC 0x8 // npc/enemy (VIL)
#define XENT_COLLTYPE_PLYR 0x10 // player (PLYR)
// Ent flags (xEnt::flags)
#define XENT_IS_VISIBLE ((U8)(1 << 0))
#define XENT_IS_STACKED ((U8)(1 << 1))
#define XENT_0x10 ((U8)(1 << 4))
#define XENT_0x40 ((U8)(1 << 6))
#define XENT_0x80 ((U8)(1 << 7))

// Physics flags (xEnt::pflags)
#define XENT_PFLAGS_IS_MOVING ((U8)(1 << 0))
#define XENT_PFLAGS_HAS_VELOCITY ((U8)(1 << 1))
#define XENT_PFLAGS_HAS_GRAVITY ((U8)(1 << 2))
#define XENT_PFLAGS_HAS_DRAG ((U8)(1 << 3))
#define XENT_PFLAGS_HAS_FRICTION ((U8)(1 << 4))

// More ent flags (xEnt::moreFlags)
#define XENT_MORE_FLAGS_0x8 ((U8)1<<3)
#define XENT_MORE_FLAGS_HITTABLE ((U8)1<<4)
#define XENT_MORE_FLAGS_ANIM_COLL ((U8)1<<5)

// Collision types (xEnt::collType)
#define XENT_COLLTYPE_NONE (U8)0
#define XENT_COLLTYPE_TRIG ((U8)(1 << (0)))
#define XENT_COLLTYPE_STAT ((U8)(1 << (1)))
#define XENT_COLLTYPE_DYN ((U8)(1 << (2)))
#define XENT_COLLTYPE_NPC ((U8)(1 << (3)))
#define XENT_COLLTYPE_PLYR ((U8)(1 << (4)))
#define XENT_COLLTYPE_ENV ((U8)(1 << (5)))

// Size: 0x40
struct xEntShadow
Expand Down
2 changes: 1 addition & 1 deletion src/SB/Core/x/xEntDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ struct xEntDrive
void xEntDriveInit(xEntDrive* drv, xEnt* driven);
void xEntDriveMount(xEntDrive* drv, xEnt* driver, F32 mt, const xCollis* coll);
void xEntDriveDismount(xEntDrive* drv, F32 dmt);
void xEntDriveUpdate(xEntDrive* drv, xScene* s, F32 dt, xCollis* coll);
void xEntDriveUpdate(xEntDrive* drv, xScene* s, F32 dt, const xCollis* coll);

#endif
40 changes: 0 additions & 40 deletions src/SB/Core/x/xEntMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,46 +1307,6 @@ void xEntMotionDebugDraw(const xEntMotion*);

_tagxPad* gDebugPad;

void xEntMotionRun(xEntMotion* motion)
{
motion->flags &= 0xFFFB;
}

void xEntMotionStop(xEntMotion* motion)
{
motion->flags |= 0x4;
}

U32 xEntMotionIsStopped(const xEntMotion* motion)
{
return motion->flags & 0x4;
}

U32 xEntERIsExtending(const xEntMotion* motion)
{
return motion->t < motion->er.et;
}

U32 xEntERIsExtended(const xEntMotion* motion)
{
return motion->t >= motion->er.et && motion->t < motion->er.brt;
}

U32 xEntERIsRetracted(const xEntMotion* motion)
{
return motion->t >= motion->er.ert;
}

U32 xEntERIsRetracting(const xEntMotion* motion)
{
return motion->t >= motion->er.brt && motion->t < motion->er.ert;
}

void xEntMPSetSpeed(xEntMotion* motion, F32 speed)
{
motion->mp.speed = MAX(0.0f, speed);
}

void xQuatCopy(xQuat* a, const xQuat* b)
{
a->s = b->s;
Expand Down
49 changes: 49 additions & 0 deletions src/SB/Core/x/xEntMotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define XENTMOTION_H

#include "xEnt.h"
#include "xEntMotionAsset.h"
#include "xMovePoint.h"
#include "xColor.h"

Expand Down Expand Up @@ -186,5 +187,53 @@ void xEntMotionDebugExit();
void xEntMotionStop(xEntMotion* motion);
void xEntMotionRun(xEntMotion* motion);
U32 xEntMotionIsStopped(const xEntMotion* motion);
void xEntMechForward(xEntMotion* motion);
void xEntMechReverse(xEntMotion* motion);
void xEntMPSetSpeed(xEntMotion* motion, F32 speed);

inline U32 xEntMotionIsStopped(const xEntMotion* motion)
{
return motion->flags & k_XENTMOTION_STOPPED;
}

inline void xEntMotionStop(xEntMotion* motion)
{
motion->flags |= k_XENTMOTION_STOPPED;
}

inline void xEntMotionRun(xEntMotion* motion)
{
motion->flags &= (U16)~k_XENTMOTION_STOPPED;
}

inline U32 xEntERIsExtending(const xEntMotion* motion)
{
return motion->t < motion->er.et;
}

inline U32 xEntERIsExtended(const xEntMotion* motion)
{
return motion->t >= motion->er.et && motion->t < motion->er.brt;
}

inline U32 xEntERIsRetracting(const xEntMotion* motion)
{
return motion->t >= motion->er.brt && motion->t < motion->er.ert;
}

inline U32 xEntERIsRetracted(const xEntMotion* motion)
{
return motion->t >= motion->er.ert;
}

inline void xEntMPSetSpeed(xEntMotion* motion, F32 speed)
{
motion->mp.speed = MAX(0.0f, speed);
}

inline void xEntMPAccelerate(xEntMotion* motion, F32 new_speed)
{
motion->mp.speed = MAX(0.0f, motion->mp.speed + new_speed);
}

#endif
29 changes: 29 additions & 0 deletions src/SB/Core/x/xVec3Inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,35 @@ F32 xVec3LengthFast(F32 x, F32 y, F32 z);
F32 xVec3LengthFast(const xVec3* vec);
void xVec3AddScaled(xVec3* o, const xVec3* v, F32 s);

#define xVec3NormalizeMacro(o, v, len) \
MACRO_START \
{ \
F32 len2 = SQR((v)->x) + SQR((v)->y) + SQR((v)->z); \
if (xeq(len2, 1.0f, 1e-5f)) \
{ \
(o)->x = (v)->x; \
(o)->y = (v)->y; \
(o)->z = (v)->z; \
*(len) = 1.0f; \
} \
else if (xeq(len2, 0.0f, 1e-5f)) \
{ \
(o)->x = 0.0f; \
(o)->y = 1.0f; \
(o)->z = 0.0f; \
*(len) = 0.0f; \
} \
else \
{ \
*(len) = xsqrt(len2); \
F32 len_inv = 1.0f / *(len); \
(o)->x = (v)->x * len_inv; \
(o)->y = (v)->y * len_inv; \
(o)->z = (v)->z * len_inv; \
} \
} \
MACRO_STOP

#define xVec3NormalizeDistXZMacro(o, a, b, dist) \
MACRO_START \
{ \
Expand Down
Loading