2021-11-08 01:28:30 +00:00
|
|
|
#ifndef _COLLINFO_H
|
|
|
|
#define _COLLINFO_H
|
|
|
|
|
|
|
|
#include "CNode.h"
|
|
|
|
#include "Graphics.h"
|
|
|
|
#include "IDelegate.h"
|
2023-10-09 01:33:37 +00:00
|
|
|
#include "Sys/Sphere.h"
|
2021-11-08 01:28:30 +00:00
|
|
|
#include "id32.h"
|
2023-01-26 01:54:54 +00:00
|
|
|
#include "JSystem/JKernel/JKRFileLoader.h"
|
2021-11-08 01:28:30 +00:00
|
|
|
#include "MonoObjectMgr.h"
|
|
|
|
#include "Sys/Tube.h"
|
|
|
|
#include "SysShape/Model.h"
|
|
|
|
#include "SysShape/MtxObject.h"
|
|
|
|
#include "Vector3.h"
|
2022-10-15 05:42:41 +00:00
|
|
|
#include "Condition.h"
|
2021-11-08 01:28:30 +00:00
|
|
|
|
|
|
|
struct CollPartMgr;
|
2022-10-15 05:42:41 +00:00
|
|
|
|
|
|
|
#define COLLTYPE_SPHERE (0)
|
|
|
|
#define COLLTYPE_TUBE (1)
|
|
|
|
#define COLLTYPE_TUBETREE (2)
|
2021-11-08 01:28:30 +00:00
|
|
|
|
2022-11-23 23:32:17 +00:00
|
|
|
namespace Game {
|
|
|
|
struct Creature;
|
|
|
|
}
|
|
|
|
|
2021-11-08 01:28:30 +00:00
|
|
|
struct CollPart : public CNode {
|
|
|
|
CollPart();
|
|
|
|
CollPart(SysShape::MtxObject*);
|
|
|
|
|
2022-07-26 13:29:09 +00:00
|
|
|
////////////// VTABLE
|
2022-10-15 05:42:41 +00:00
|
|
|
virtual ~CollPart() { } // _08 (weak)
|
|
|
|
virtual int getChildCount() // _0C (weak)
|
|
|
|
{
|
|
|
|
return CNode::getChildCount();
|
|
|
|
}
|
|
|
|
virtual bool isMouth() // _10 (weak)
|
2022-07-26 14:59:19 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2022-10-26 00:12:41 +00:00
|
|
|
virtual void draw(Graphics&); // _14
|
|
|
|
virtual void constructor() { } // _18 (weak)
|
|
|
|
virtual void doAnimation() { } // _1C (weak)
|
|
|
|
virtual void doEntry() { } // _20 (weak)
|
|
|
|
virtual void doSetView(u32) { } // _24 (weak)
|
|
|
|
virtual void doViewCalc() { } // _28 (weak)
|
2023-01-16 20:23:01 +00:00
|
|
|
virtual void doSimulation(f32 rate) { } // _2C (weak)
|
2022-10-26 00:12:41 +00:00
|
|
|
virtual void doDirectDraw(Graphics& gfx) { } // _30 (weak)
|
2022-07-26 13:29:09 +00:00
|
|
|
////////////// END VTABLE
|
2022-01-03 22:01:13 +00:00
|
|
|
|
|
|
|
void init(SysShape::MtxObject*);
|
2022-10-15 05:42:41 +00:00
|
|
|
|
2022-01-30 22:21:06 +00:00
|
|
|
void addChild(CollPart* child) { add(child); }
|
2021-11-08 01:28:30 +00:00
|
|
|
void attachModel(SysShape::MtxObject*);
|
2022-10-15 05:42:41 +00:00
|
|
|
|
2023-12-16 19:52:17 +00:00
|
|
|
void calcStickGlobal(Vector3f& input, Vector3f& globalPosition);
|
|
|
|
void calcStickLocal(Vector3f& input, Vector3f& localPosition);
|
|
|
|
void calcPoseMatrix(Vector3f& input, Matrixf& poseMatrix);
|
2022-10-15 05:42:41 +00:00
|
|
|
|
2023-12-16 19:52:17 +00:00
|
|
|
void checkCollision(Sys::Sphere& input, IDelegate1<CollPart*>* onCollisionCallback);
|
|
|
|
void checkCollisionMulti(CollPart* other, IDelegate3<CollPart*, CollPart*, Vector3f&>* onCollidedCallback);
|
2022-10-15 05:42:41 +00:00
|
|
|
|
2023-12-16 19:52:17 +00:00
|
|
|
CollPart* clone(SysShape::MtxObject* newMtx, CollPartMgr* mgr);
|
|
|
|
bool collide(CollPart* other, Vector3f& hitPosition);
|
2022-10-15 05:42:41 +00:00
|
|
|
|
2023-12-16 19:52:17 +00:00
|
|
|
int getAllCollPartToArray(CollPart** outputArray, int limit, int& count);
|
2022-10-15 05:42:41 +00:00
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
CollPart* getChild() { return (CollPart*)mChild; }
|
2022-01-04 13:18:25 +00:00
|
|
|
CollPart* getCollPart(u32);
|
2023-01-25 21:50:15 +00:00
|
|
|
CollPart* getNext() { return (CollPart*)mNext; }
|
2023-10-15 14:51:05 +00:00
|
|
|
CollPart* getParent() { return (CollPart*)mParent; }
|
2022-10-15 05:42:41 +00:00
|
|
|
|
2023-12-16 19:52:17 +00:00
|
|
|
void getSphere(Sys::Sphere& output);
|
|
|
|
void getTube(Sys::Tube& output);
|
2022-10-15 05:42:41 +00:00
|
|
|
|
|
|
|
bool isLeaf() { return (getChild() == nullptr); }
|
2023-01-25 21:50:15 +00:00
|
|
|
bool isSphere() { return (mPartType == COLLTYPE_SPHERE); }
|
2021-11-08 01:28:30 +00:00
|
|
|
bool isStickable();
|
2023-01-25 21:50:15 +00:00
|
|
|
bool isTube() { return (mPartType == COLLTYPE_TUBE); }
|
|
|
|
bool isTubeTree() { return (mPartType == COLLTYPE_TUBETREE); }
|
2022-10-15 05:42:41 +00:00
|
|
|
bool isTubeLike() { return isTube() || isTubeTree(); }
|
|
|
|
bool isPrim() { return (getChild() == nullptr || isTube() || isTubeTree()); }
|
|
|
|
|
2023-12-16 19:52:17 +00:00
|
|
|
void makeMatrixTo(Matrixf& target);
|
2021-11-08 01:28:30 +00:00
|
|
|
void makeTubeTree();
|
2023-12-16 19:52:17 +00:00
|
|
|
void read(Stream& stream, bool isAgeCollPart);
|
2023-01-16 20:23:01 +00:00
|
|
|
void setScale(f32);
|
2021-11-08 01:28:30 +00:00
|
|
|
void update();
|
|
|
|
|
2024-05-12 14:10:44 +00:00
|
|
|
inline f32 getSqrRadius() { return mRadius * mRadius; }
|
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
f32 mBaseRadius; // _18, base radius used to calculate real radius (in setScale, it's scaled)
|
|
|
|
f32 mRadius; // _1C
|
|
|
|
Vector3f mOffset; // _20
|
|
|
|
u32 mJointIndex; // _2C
|
|
|
|
ID32 mCurrentID; // _30, identifier of current part, initialised to root
|
|
|
|
ID32 mSpecialID; // _3C, used to detect whether the collpart is stickable, denoted by prefixed -s: e.g. 'sp01'
|
|
|
|
u16 mAttribute; // _48
|
|
|
|
Vector3f mPosition; // _4C
|
|
|
|
u8 mPartType; // _58, using define list - 0=Sphere, 1=Tube, 2=TubeTree
|
|
|
|
SysShape::MtxObject* mModel; // _5C
|
2024-04-29 06:10:37 +00:00
|
|
|
u32 mUnusedVal; // _60
|
2021-11-08 01:28:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CollPartMgr : public MonoObjectMgr<CollPart> {
|
2022-07-26 13:29:09 +00:00
|
|
|
|
2022-09-13 13:09:40 +00:00
|
|
|
virtual ~CollPartMgr() { } // _08 (weak)
|
2022-07-26 13:29:09 +00:00
|
|
|
|
2022-01-30 22:21:06 +00:00
|
|
|
CollPart* createOne(SysShape::MtxObject*);
|
2021-11-08 01:28:30 +00:00
|
|
|
};
|
|
|
|
|
2022-10-15 05:42:41 +00:00
|
|
|
struct FindCollPartArg {
|
2023-01-25 21:50:15 +00:00
|
|
|
Condition<CollPart>* mCondition; // _00
|
2024-05-12 14:10:44 +00:00
|
|
|
Sys::Sphere mHitSphere; // _04
|
|
|
|
|
|
|
|
inline Vector3f& getHitPosition() { return mHitSphere.mPosition; }
|
2022-10-15 05:42:41 +00:00
|
|
|
};
|
|
|
|
|
2021-11-08 01:28:30 +00:00
|
|
|
struct MouthCollPart : public CollPart {
|
|
|
|
MouthCollPart();
|
2022-01-03 22:01:13 +00:00
|
|
|
|
2022-07-26 14:59:19 +00:00
|
|
|
virtual ~MouthCollPart() { } // _08 (weak)
|
|
|
|
virtual bool isMouth() // _10 (weak)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2022-01-03 22:01:13 +00:00
|
|
|
|
2021-11-08 01:28:30 +00:00
|
|
|
void copyMatrixTo(Matrixf&);
|
|
|
|
void getPosition(Vector3f&);
|
|
|
|
|
2022-10-15 05:42:41 +00:00
|
|
|
// inlined
|
|
|
|
void setup(SysShape::Model* model, char* jointName, Vector3f& vector);
|
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
Game::Creature* mStuckCreature; // _64
|
|
|
|
SysShape::Joint* mMouthJoint; // _68
|
2024-04-29 06:10:37 +00:00
|
|
|
u8 mIsOniKurage; // _6C, greater jellyfloat uses special calcs for stuff inside it
|
2021-11-08 01:28:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MouthSlots {
|
|
|
|
MouthSlots();
|
|
|
|
void alloc(int);
|
|
|
|
MouthCollPart* getSlot(int);
|
|
|
|
void update();
|
|
|
|
void setup(int, SysShape::Model*, char*);
|
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
int getMax() { return mMax; }
|
2023-01-06 09:33:43 +00:00
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
inline Game::Creature* getStuckCreature(int i) { return getSlot(i)->mStuckCreature; }
|
2023-01-19 13:03:38 +00:00
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
int mMax; // _00
|
|
|
|
MouthCollPart* mSlots; // _04
|
2021-11-08 01:28:30 +00:00
|
|
|
};
|
|
|
|
|
2022-10-17 01:46:10 +00:00
|
|
|
#define ACP_DRAWFLAG_DISABLED (0x0)
|
|
|
|
#define ACP_DRAWFLAG_ENABLED (0x1)
|
|
|
|
|
2021-11-08 01:28:30 +00:00
|
|
|
struct AgeCollPart : public CollPart {
|
|
|
|
AgeCollPart(SysShape::Model*);
|
2022-01-03 22:01:13 +00:00
|
|
|
|
2022-10-15 05:42:41 +00:00
|
|
|
virtual ~AgeCollPart() { } // _08 (weak)
|
2022-07-26 13:29:09 +00:00
|
|
|
virtual void draw(Graphics&); // _14
|
2021-11-08 01:28:30 +00:00
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
u8 mDrawFlags; // _64
|
2021-11-08 01:28:30 +00:00
|
|
|
};
|
|
|
|
|
2022-09-15 03:00:12 +00:00
|
|
|
struct CollPartFactory : public CollPart {
|
2022-01-03 22:01:13 +00:00
|
|
|
inline CollPartFactory(Stream& input)
|
|
|
|
: CollPart()
|
|
|
|
{
|
|
|
|
read(input, false);
|
|
|
|
}
|
|
|
|
|
2022-07-26 14:59:19 +00:00
|
|
|
virtual ~CollPartFactory() { } // _08 (weak)
|
2022-01-03 22:01:13 +00:00
|
|
|
|
|
|
|
static CollPartFactory* load(char*);
|
|
|
|
static CollPartFactory* load(JKRFileLoader*, char*);
|
2022-10-15 05:42:41 +00:00
|
|
|
CollPart* createInstance(SysShape::MtxObject*, CollPartMgr*);
|
2021-11-08 01:28:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CollTree {
|
|
|
|
CollTree();
|
|
|
|
void attachModel(SysShape::MtxObject*);
|
2022-01-12 03:31:11 +00:00
|
|
|
void createFromFactory(SysShape::MtxObject*, CollPartFactory*, CollPartMgr*);
|
|
|
|
void createSingleSphere(SysShape::MtxObject*, int, Sys::Sphere&, CollPartMgr*);
|
2022-01-30 22:21:06 +00:00
|
|
|
bool checkCollision(CollTree*, CollPart**, CollPart**, Vector3f&);
|
2021-11-08 01:28:30 +00:00
|
|
|
void checkCollision(Sys::Sphere&, IDelegate1<CollPart*>*);
|
2022-01-30 22:21:06 +00:00
|
|
|
bool checkCollisionRec(CollPart*, CollPart*, CollPart**, CollPart**, Vector3f&);
|
2022-01-12 03:31:11 +00:00
|
|
|
void checkCollisionMulti(CollTree*, IDelegate3<CollPart*, CollPart*, Vector3f&>*);
|
2022-10-15 05:42:41 +00:00
|
|
|
CollPart* findCollPart(FindCollPartArg&);
|
2021-11-08 01:28:30 +00:00
|
|
|
void getBoundingSphere(Sys::Sphere&);
|
2022-01-04 13:18:25 +00:00
|
|
|
CollPart* getCollPart(u32);
|
2021-11-08 01:28:30 +00:00
|
|
|
CollPart* getRandomCollPart();
|
|
|
|
void release();
|
|
|
|
void releaseRec(CollPart*);
|
|
|
|
void update();
|
|
|
|
|
2022-01-30 22:21:06 +00:00
|
|
|
// Unused/inlined:
|
|
|
|
void checkCollisionMultiRec(CollPart*, CollPart*, IDelegate3<CollPart*, CollPart*, Vector3f&>*);
|
|
|
|
|
2022-11-25 08:43:01 +00:00
|
|
|
static bool mDebug;
|
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
CollPart* mPart; // _00
|
|
|
|
CollPartMgr* mMgr; // _04
|
2021-11-08 01:28:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|