A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectKCL.hh
1#pragma once
2
3#include "game/field/ObjColMgr.hh"
4#include "game/field/obj/ObjectDrivable.hh"
5
6namespace Field {
7
8class ObjectKCL : public ObjectDrivable {
9public:
10 ObjectKCL(const System::MapdataGeoObj &params);
11 ~ObjectKCL() override;
12
13 void createCollision() override;
14 void calcCollisionTransform() override;
15
17 [[nodiscard]] const EGG::Vector3f &getPosition() const override {
18 return m_kclMidpoint;
19 }
20
22 f32 getCollisionRadius() const override {
23 return m_bboxHalfSideLength + colRadiusAdditionalLength();
24 }
25
26 void initCollision() override;
27 [[nodiscard]] bool checkPointPartial(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
28 KCLTypeMask mask, CollisionInfoPartial *info, KCLTypeMask *maskOut) override;
29 [[nodiscard]] bool checkPointPartialPush(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
30 KCLTypeMask mask, CollisionInfoPartial *info, KCLTypeMask *maskOut) override;
31 [[nodiscard]] bool checkPointFull(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
32 KCLTypeMask mask, CollisionInfo *info, KCLTypeMask *maskOut) override;
33 [[nodiscard]] bool checkPointFullPush(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
34 KCLTypeMask mask, CollisionInfo *info, KCLTypeMask *maskOut) override;
35 [[nodiscard]] bool checkSpherePartial(f32 radius, const EGG::Vector3f &pos,
36 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
37 KCLTypeMask *maskOut, u32 timeOffset) override;
38 [[nodiscard]] bool checkSpherePartialPush(f32 radius, const EGG::Vector3f &pos,
39 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
40 KCLTypeMask *maskOut, u32 timeOffset) override;
41 [[nodiscard]] bool checkSphereFull(f32 radius, const EGG::Vector3f &pos,
42 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
43 KCLTypeMask *maskOut, u32 timeOffset) override;
44 [[nodiscard]] bool checkSphereFullPush(f32 radius, const EGG::Vector3f &pos,
45 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
46 KCLTypeMask *maskOut, u32 timeOffset) override;
47 void narrScLocal(f32 radius, const EGG::Vector3f &pos, KCLTypeMask mask,
48 u32 timeOffset) override;
49 [[nodiscard]] bool checkPointCachedPartial(const EGG::Vector3f &pos,
50 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
51 KCLTypeMask *maskOut) override;
52 [[nodiscard]] bool checkPointCachedPartialPush(const EGG::Vector3f &pos,
53 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
54 KCLTypeMask *maskOut) override;
55 [[nodiscard]] bool checkPointCachedFull(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
56 KCLTypeMask mask, CollisionInfo *info, KCLTypeMask *maskOut) override;
57 [[nodiscard]] bool checkPointCachedFullPush(const EGG::Vector3f &pos,
58 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
59 KCLTypeMask *maskOut) override;
60 [[nodiscard]] bool checkSphereCachedPartial(f32 radius, const EGG::Vector3f &pos,
61 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
62 KCLTypeMask *maskOut, u32 timeOffset) override;
63 [[nodiscard]] bool checkSphereCachedPartialPush(f32 radius, const EGG::Vector3f &pos,
64 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
65 KCLTypeMask *maskOut, u32 timeOffset) override;
66 [[nodiscard]] bool checkSphereCachedFull(f32 radius, const EGG::Vector3f &pos,
67 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
68 KCLTypeMask *maskOut, u32 timeOffset) override;
69 [[nodiscard]] bool checkSphereCachedFullPush(f32 radius, const EGG::Vector3f &pos,
70 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
71 KCLTypeMask *maskOut, u32 timeOffset) override;
72
73 virtual void update(u32 timeOffset);
74 virtual void calcScale(u32 timeOffset);
75
76 [[nodiscard]] virtual const EGG::Matrix34f &getUpdatedMatrix(u32 timeOffset);
77
79 [[nodiscard]] virtual f32 getScaleY(u32 /* timeOffset */) const {
80 return m_scale.y;
81 }
82
84 [[nodiscard]] virtual f32 colRadiusAdditionalLength() const {
85 return 0.0f;
86 }
87
89 [[nodiscard]] virtual bool shouldCheckColNoPush() const {
90 return true;
91 }
92
94 [[nodiscard]] virtual bool shouldCheckColPush() const {
95 return true;
96 }
97
98 [[nodiscard]] virtual bool checkCollision(f32 radius, const EGG::Vector3f &pos,
99 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
100 KCLTypeMask *maskOut, u32 timeOffset);
101 [[nodiscard]] virtual bool checkCollisionCached(f32 radius, const EGG::Vector3f &pos,
102 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
103 KCLTypeMask *maskOut, u32 timeOffset);
104
105private:
106 ObjColMgr *m_objColMgr;
107 EGG::Vector3f m_kclMidpoint;
108 f32 m_bboxHalfSideLength;
109 s32 m_lastMtxUpdateFrame;
110 s32 m_lastScaleUpdateFrame;
111};
112
113} // namespace Field
A 3 x 4 matrix.
Definition Matrix.hh:8
Manager for an object's KCL interactions.
Definition ObjColMgr.hh:9
Pertains to collision.
A 3D float vector.
Definition Vector.hh:83