pikmin2/include/CollInfo.h

207 lines
6.0 KiB
C
Raw Normal View History

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"
#include "Condition.h"
2021-11-08 01:28:30 +00:00
struct CollPartMgr;
#define COLLTYPE_SPHERE (0)
#define COLLTYPE_TUBE (1)
#define COLLTYPE_TUBETREE (2)
2021-11-08 01:28:30 +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
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)
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
void init(SysShape::MtxObject*);
Squashed commit of the following: commit 1aebcc3b566ea2937375f32b1a8bcaec483ad086 Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Sun Jan 30 17:18:58 2022 -0500 Fix build commit 557102b1dc6bc352a1c0c473fba1cb9010eeb4ff Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Sun Jan 30 13:04:20 2022 -0500 tab alignment in makefile minor edit commit 6fad05508ed56656dc3305c5f0920df58aede94a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Thu Jan 27 22:30:48 2022 -0500 Create .gitattributes commit 0276b2dd5ff4043a2c70d86be92d5d7e6de7f1a3 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:45:06 2022 -0500 undo naïve change of mine commit 77c4f5183d192bec4ad7f3126fef361a418bc15f Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:25:15 2022 -0500 correct fakepiki and associates repair @intns mistake from d0e0ebe4e4632d74e51663b286bd364bfa5991dc properly toss in motionlistener commit cf1e8fab44e0802db35acf05c92deda48fe916e0 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Mon Jan 24 18:35:11 2022 -0500 formatting commit e2182b5352cf056cca84020f8c820cf69e73f03a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:35:01 2022 -0500 Rename LICENSE to LICENSE.MD commit 99d42518c02a22380ae068690bc063a38501859b Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:34:44 2022 -0500 Create LICENSE commit 8fd5812f2cc1a8340586468737454a2993dfb57e Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Thu Jan 20 20:00:20 2022 -0500 Massive collinfo.cpp progress. Also everything else I had.
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*);
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);
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);
2023-12-16 19:52:17 +00:00
CollPart* clone(SysShape::MtxObject* newMtx, CollPartMgr* mgr);
bool collide(CollPart* other, Vector3f& hitPosition);
2023-12-16 19:52:17 +00:00
int getAllCollPartToArray(CollPart** outputArray, int limit, int& count);
CollPart* getChild() { return (CollPart*)mChild; }
CollPart* getCollPart(u32);
CollPart* getNext() { return (CollPart*)mNext; }
CollPart* getParent() { return (CollPart*)mParent; }
2023-12-16 19:52:17 +00:00
void getSphere(Sys::Sphere& output);
void getTube(Sys::Tube& output);
bool isLeaf() { return (getChild() == nullptr); }
bool isSphere() { return (mPartType == COLLTYPE_SPHERE); }
2021-11-08 01:28:30 +00:00
bool isStickable();
bool isTube() { return (mPartType == COLLTYPE_TUBE); }
bool isTubeTree() { return (mPartType == COLLTYPE_TUBETREE); }
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);
void setScale(f32);
2021-11-08 01:28:30 +00:00
void update();
inline f32 getSqrRadius() { return mRadius * mRadius; }
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
virtual ~CollPartMgr() { } // _08 (weak)
2022-07-26 13:29:09 +00:00
Squashed commit of the following: commit 1aebcc3b566ea2937375f32b1a8bcaec483ad086 Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Sun Jan 30 17:18:58 2022 -0500 Fix build commit 557102b1dc6bc352a1c0c473fba1cb9010eeb4ff Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Sun Jan 30 13:04:20 2022 -0500 tab alignment in makefile minor edit commit 6fad05508ed56656dc3305c5f0920df58aede94a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Thu Jan 27 22:30:48 2022 -0500 Create .gitattributes commit 0276b2dd5ff4043a2c70d86be92d5d7e6de7f1a3 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:45:06 2022 -0500 undo naïve change of mine commit 77c4f5183d192bec4ad7f3126fef361a418bc15f Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:25:15 2022 -0500 correct fakepiki and associates repair @intns mistake from d0e0ebe4e4632d74e51663b286bd364bfa5991dc properly toss in motionlistener commit cf1e8fab44e0802db35acf05c92deda48fe916e0 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Mon Jan 24 18:35:11 2022 -0500 formatting commit e2182b5352cf056cca84020f8c820cf69e73f03a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:35:01 2022 -0500 Rename LICENSE to LICENSE.MD commit 99d42518c02a22380ae068690bc063a38501859b Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:34:44 2022 -0500 Create LICENSE commit 8fd5812f2cc1a8340586468737454a2993dfb57e Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Thu Jan 20 20:00:20 2022 -0500 Massive collinfo.cpp progress. Also everything else I had.
2022-01-30 22:21:06 +00:00
CollPart* createOne(SysShape::MtxObject*);
2021-11-08 01:28:30 +00:00
};
struct FindCollPartArg {
Condition<CollPart>* mCondition; // _00
Sys::Sphere mHitSphere; // _04
inline Vector3f& getHitPosition() { return mHitSphere.mPosition; }
};
2021-11-08 01:28:30 +00:00
struct MouthCollPart : public CollPart {
MouthCollPart();
2022-07-26 14:59:19 +00:00
virtual ~MouthCollPart() { } // _08 (weak)
virtual bool isMouth() // _10 (weak)
{
return true;
}
2021-11-08 01:28:30 +00:00
void copyMatrixTo(Matrixf&);
void getPosition(Vector3f&);
// inlined
void setup(SysShape::Model* model, char* jointName, Vector3f& vector);
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*);
int getMax() { return mMax; }
2023-01-06 09:33:43 +00:00
inline Game::Creature* getStuckCreature(int i) { return getSlot(i)->mStuckCreature; }
int mMax; // _00
MouthCollPart* mSlots; // _04
2021-11-08 01:28:30 +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*);
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
u8 mDrawFlags; // _64
2021-11-08 01:28:30 +00:00
};
struct CollPartFactory : public CollPart {
inline CollPartFactory(Stream& input)
: CollPart()
{
read(input, false);
}
2022-07-26 14:59:19 +00:00
virtual ~CollPartFactory() { } // _08 (weak)
static CollPartFactory* load(char*);
static CollPartFactory* load(JKRFileLoader*, char*);
CollPart* createInstance(SysShape::MtxObject*, CollPartMgr*);
2021-11-08 01:28:30 +00:00
};
struct CollTree {
CollTree();
void attachModel(SysShape::MtxObject*);
void createFromFactory(SysShape::MtxObject*, CollPartFactory*, CollPartMgr*);
void createSingleSphere(SysShape::MtxObject*, int, Sys::Sphere&, CollPartMgr*);
Squashed commit of the following: commit 1aebcc3b566ea2937375f32b1a8bcaec483ad086 Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Sun Jan 30 17:18:58 2022 -0500 Fix build commit 557102b1dc6bc352a1c0c473fba1cb9010eeb4ff Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Sun Jan 30 13:04:20 2022 -0500 tab alignment in makefile minor edit commit 6fad05508ed56656dc3305c5f0920df58aede94a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Thu Jan 27 22:30:48 2022 -0500 Create .gitattributes commit 0276b2dd5ff4043a2c70d86be92d5d7e6de7f1a3 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:45:06 2022 -0500 undo naïve change of mine commit 77c4f5183d192bec4ad7f3126fef361a418bc15f Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:25:15 2022 -0500 correct fakepiki and associates repair @intns mistake from d0e0ebe4e4632d74e51663b286bd364bfa5991dc properly toss in motionlistener commit cf1e8fab44e0802db35acf05c92deda48fe916e0 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Mon Jan 24 18:35:11 2022 -0500 formatting commit e2182b5352cf056cca84020f8c820cf69e73f03a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:35:01 2022 -0500 Rename LICENSE to LICENSE.MD commit 99d42518c02a22380ae068690bc063a38501859b Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:34:44 2022 -0500 Create LICENSE commit 8fd5812f2cc1a8340586468737454a2993dfb57e Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Thu Jan 20 20:00:20 2022 -0500 Massive collinfo.cpp progress. Also everything else I had.
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*>*);
Squashed commit of the following: commit 1aebcc3b566ea2937375f32b1a8bcaec483ad086 Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Sun Jan 30 17:18:58 2022 -0500 Fix build commit 557102b1dc6bc352a1c0c473fba1cb9010eeb4ff Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Sun Jan 30 13:04:20 2022 -0500 tab alignment in makefile minor edit commit 6fad05508ed56656dc3305c5f0920df58aede94a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Thu Jan 27 22:30:48 2022 -0500 Create .gitattributes commit 0276b2dd5ff4043a2c70d86be92d5d7e6de7f1a3 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:45:06 2022 -0500 undo naïve change of mine commit 77c4f5183d192bec4ad7f3126fef361a418bc15f Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:25:15 2022 -0500 correct fakepiki and associates repair @intns mistake from d0e0ebe4e4632d74e51663b286bd364bfa5991dc properly toss in motionlistener commit cf1e8fab44e0802db35acf05c92deda48fe916e0 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Mon Jan 24 18:35:11 2022 -0500 formatting commit e2182b5352cf056cca84020f8c820cf69e73f03a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:35:01 2022 -0500 Rename LICENSE to LICENSE.MD commit 99d42518c02a22380ae068690bc063a38501859b Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:34:44 2022 -0500 Create LICENSE commit 8fd5812f2cc1a8340586468737454a2993dfb57e Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Thu Jan 20 20:00:20 2022 -0500 Massive collinfo.cpp progress. Also everything else I had.
2022-01-30 22:21:06 +00:00
bool checkCollisionRec(CollPart*, CollPart*, CollPart**, CollPart**, Vector3f&);
void checkCollisionMulti(CollTree*, IDelegate3<CollPart*, CollPart*, Vector3f&>*);
CollPart* findCollPart(FindCollPartArg&);
2021-11-08 01:28:30 +00:00
void getBoundingSphere(Sys::Sphere&);
CollPart* getCollPart(u32);
2021-11-08 01:28:30 +00:00
CollPart* getRandomCollPart();
void release();
void releaseRec(CollPart*);
void update();
Squashed commit of the following: commit 1aebcc3b566ea2937375f32b1a8bcaec483ad086 Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Sun Jan 30 17:18:58 2022 -0500 Fix build commit 557102b1dc6bc352a1c0c473fba1cb9010eeb4ff Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Sun Jan 30 13:04:20 2022 -0500 tab alignment in makefile minor edit commit 6fad05508ed56656dc3305c5f0920df58aede94a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Thu Jan 27 22:30:48 2022 -0500 Create .gitattributes commit 0276b2dd5ff4043a2c70d86be92d5d7e6de7f1a3 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:45:06 2022 -0500 undo naïve change of mine commit 77c4f5183d192bec4ad7f3126fef361a418bc15f Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Wed Jan 26 14:25:15 2022 -0500 correct fakepiki and associates repair @intns mistake from d0e0ebe4e4632d74e51663b286bd364bfa5991dc properly toss in motionlistener commit cf1e8fab44e0802db35acf05c92deda48fe916e0 Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Mon Jan 24 18:35:11 2022 -0500 formatting commit e2182b5352cf056cca84020f8c820cf69e73f03a Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:35:01 2022 -0500 Rename LICENSE to LICENSE.MD commit 99d42518c02a22380ae068690bc063a38501859b Author: EpochFlame <82550703+EpochFlame@users.noreply.github.com> Date: Fri Jan 21 21:34:44 2022 -0500 Create LICENSE commit 8fd5812f2cc1a8340586468737454a2993dfb57e Author: SodiumChlorideLogic <19625889+SodiumChlorideLogic@users.noreply.github.com> Date: Thu Jan 20 20:00:20 2022 -0500 Massive collinfo.cpp progress. Also everything else I had.
2022-01-30 22:21:06 +00:00
// Unused/inlined:
void checkCollisionMultiRec(CollPart*, CollPart*, IDelegate3<CollPart*, CollPart*, Vector3f&>*);
static bool mDebug;
CollPart* mPart; // _00
CollPartMgr* mMgr; // _04
2021-11-08 01:28:30 +00:00
};
#endif