Skip to content

Commit 68113e6

Browse files
authored
xCollide (#680)
* Completed and Linked xUpdateCull, and xPtankPool * Review Fixes * Ported all xCollide code from seils pc port repo Thanks seil.
1 parent ed0ea04 commit 68113e6

File tree

9 files changed

+2445
-187
lines changed

9 files changed

+2445
-187
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
"oscontext.h": "c",
6767
"radcb.h": "c",
6868
"popmal.h": "c",
69-
"osalloc.h": "c"
69+
"osalloc.h": "c",
70+
"cmath": "cpp"
7071
},
7172
// Disable C/C++ IntelliSense, use clangd instead
7273
"C_Cpp.intelliSenseEngine": "default",

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def MatchingFor(*versions):
413413
Object(NonMatching, "SB/Core/x/xBound.cpp"),
414414
Object(NonMatching, "SB/Core/x/xCamera.cpp"),
415415
Object(NonMatching, "SB/Core/x/xClimate.cpp"),
416-
Object(NonMatching, "SB/Core/x/xCollide.cpp"),
416+
Object(NonMatching, "SB/Core/x/xCollide.cpp", extra_cflags=["-sym on"]),
417417
Object(Matching, "SB/Core/x/xCollideFast.cpp"),
418418
Object(Matching, "SB/Core/x/xColor.cpp"),
419419
Object(Matching, "SB/Core/x/xCounter.cpp"),

include/rwsdk/rpcollbsptree.h

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// RpCollBSPTree is part of the RpCollis plugin in RW 3.4 and 3.5, but it's not exposed in the public API.
2+
// BFBB had full source code access to the RenderWare SDK and used RpCollBSPTree for some collision checks.
3+
// These definitions are based on the ones found in the BFBB PS2 DWARF data.
4+
//
5+
// Note: RpCollBSPTree was refactored as RpCollTree and added to the public API in RW 3.6.
6+
// TSSM (SpongeBob Movie) and later games used RpCollTree instead of RpCollBSPTree.
7+
8+
#pragma once
9+
10+
#include <rpcollis.h>
11+
12+
typedef struct RpV3dGradient RpV3dGradient;
13+
struct RpV3dGradient
14+
{
15+
RwReal dydx;
16+
RwReal dzdx;
17+
RwReal dxdy;
18+
RwReal dzdy;
19+
RwReal dxdz;
20+
RwReal dydz;
21+
};
22+
23+
typedef struct RpCollBSPBranchNode RpCollBSPBranchNode;
24+
struct RpCollBSPBranchNode
25+
{
26+
RwUInt16 type;
27+
RwUInt8 leftType;
28+
RwUInt8 rightType;
29+
RwUInt16 leftNode;
30+
RwUInt16 rightNode;
31+
RwReal leftValue;
32+
RwReal rightValue;
33+
};
34+
35+
typedef struct RpCollBSPLeafNode RpCollBSPLeafNode;
36+
struct RpCollBSPLeafNode
37+
{
38+
RwUInt16 numPolygons;
39+
RwUInt16 firstPolygon;
40+
};
41+
42+
typedef struct RpCollBSPTriangle RpCollBSPTriangle;
43+
struct RpCollBSPTriangle
44+
{
45+
RwUInt16 vertIndex[3];
46+
RwInt16 index;
47+
};
48+
49+
typedef struct RpCollBSPTree RpCollBSPTree;
50+
struct RpCollBSPTree
51+
{
52+
RwUInt32 numLeafNodes;
53+
RpCollBSPBranchNode* branchNodes;
54+
RpCollBSPLeafNode* leafNodes;
55+
RwUInt8 pad[4];
56+
};
57+
58+
typedef struct RpCollisionData RpCollisionData;
59+
struct RpCollisionData
60+
{
61+
RwInt32 flags;
62+
RpCollBSPTree* tree;
63+
RwInt32 numTriangles;
64+
RwUInt16* triangleMap;
65+
};
66+
67+
#define RpCollisionGeometryGetData(_geometry) \
68+
(RWPLUGINOFFSET(RpCollisionData*, _geometry, _rpCollisionGeometryDataOffset) ? \
69+
*RWPLUGINOFFSET(RpCollisionData*, _geometry, _rpCollisionGeometryDataOffset) : \
70+
NULL)
71+
72+
#ifdef __cplusplus
73+
extern "C"
74+
{
75+
#endif
76+
77+
extern RwInt32 _rpCollisionGeometryDataOffset;
78+
extern RwInt32 _rpCollisionWorldSectorDataOffset;
79+
80+
#ifdef __cplusplus
81+
}
82+
#endif

src/SB/Core/gc/iCollide.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
void iBoxForModelLocal(xBox* o, const xModelInstance* m);
1010
void iBoxForModel(xBox* o, const xModelInstance* m);
11+
RpCollisionTriangle* sphereHitsEnvCB(RpIntersection* isx, RpWorldSector* sector,
12+
RpCollisionTriangle* tri, F32 dist, void* data);
1113
S32 iSphereHitsEnv3(const xSphere* b, const xEnv* env, xCollis* colls, U8 ncolls, F32 sth);
1214
S32 iSphereHitsModel3(const xSphere* b, const xModelInstance* m, xCollis* colls, U8 ncolls,
1315
F32 sth);

0 commit comments

Comments
 (0)