A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectDirector.hh
1#pragma once
2
3#include "game/field/ObjectCollisionConvexHull.hh"
4#include "game/field/ObjectFlowTable.hh"
5#include "game/field/ObjectHitTable.hh"
6#include "game/field/obj/ObjectCollidable.hh"
7#include "game/field/obj/ObjectNoImpl.hh"
8
9#include <vector>
10
11namespace Kinoko {
12
13namespace Host {
14
15class Context;
16
17} // namespace Host
18
19namespace Field {
20
21class ObjectPsea;
22
24 friend class Host::Context;
25
26public:
27 void init();
28 void calc();
29 void addObject(ObjectCollidable *obj);
30 void addObjectNoImpl(ObjectBase *obj);
31 void addManagedObject(ObjectCollidable *obj);
32
33 size_t checkKartObjectCollision(Kart::KartObject *kartObj,
34 ObjectCollisionConvexHull *convexHull);
35
36 [[nodiscard]] const ObjectFlowTable &flowTable() const {
37 return m_flowTable;
38 }
39
40 [[nodiscard]] const ObjectHitTable &hitTableKart() const {
41 return m_hitTableKart;
42 }
43
44 [[nodiscard]] const ObjectCollidable *collidingObject(size_t idx) const {
45 ASSERT(idx < m_collidingObjects.size());
46 return m_collidingObjects[idx];
47 }
48
49 [[nodiscard]] Kart::Reaction reaction(size_t idx) const {
50 ASSERT(idx < m_reactions.size());
51 return m_reactions[idx];
52 }
53
54 [[nodiscard]] const EGG::Vector3f &hitDepth(size_t idx) const {
55 ASSERT(idx < m_hitDepths.size());
56 return m_hitDepths[idx];
57 }
58
59 [[nodiscard]] std::vector<ObjectCollidable *> &managedObjects() {
60 return m_managedObjects;
61 }
62
63 [[nodiscard]] const std::vector<ObjectCollidable *> &managedObjects() const {
64 return m_managedObjects;
65 }
66
67 void setPsea(ObjectPsea *psea) {
68 m_psea = psea;
69 }
70
71 [[nodiscard]] ObjectPsea *psea() const {
72 return m_psea;
73 }
74
75 [[nodiscard]] f32 distAboveRisingWater(f32 offset) const;
76 [[nodiscard]] f32 risingWaterKillPlaneHeight() const;
77
79 [[nodiscard]] static f32 WanwanMaxPitch() {
80 return s_wanwanMaxPitch;
81 }
82
83 static ObjectDirector *CreateInstance();
84 static void DestroyInstance();
85
86 [[nodiscard]] static ObjectDirector *Instance() {
87 return s_instance;
88 }
89
90private:
92 ~ObjectDirector() override;
93
94 void createObjects();
95 [[nodiscard]] ObjectBase *createObject(const System::MapdataGeoObj &params);
96
97 ObjectFlowTable m_flowTable;
98 ObjectHitTable m_hitTableKart;
99 ObjectHitTable m_hitTableKartObject;
100
101 std::vector<ObjectBase *> m_objects;
102 std::vector<ObjectBase *> m_calcObjects;
103 std::vector<ObjectBase *> m_collisionObjects;
104
105 static constexpr size_t MAX_UNIT_COUNT = 0x100;
106
107 std::array<ObjectCollidable *, MAX_UNIT_COUNT>
109 std::array<EGG::Vector3f, MAX_UNIT_COUNT> m_hitDepths;
110 std::array<Kart::Reaction, MAX_UNIT_COUNT> m_reactions;
111 ObjectPsea *m_psea;
112 std::vector<ObjectCollidable *> m_managedObjects;
113
114 static f32 s_wanwanMaxPitch;
115
116 static ObjectDirector *s_instance;
117};
118
119} // namespace Field
120
121} // namespace Kinoko
An interface for ensuring certain structures and classes are destroyed with the heap.
Definition Disposer.hh:11
Smallest convex shape that encloses a given set of points.
std::vector< ObjectBase * > m_collisionObjects
Objects having collision live here too.
std::array< ObjectCollidable *, MAX_UNIT_COUNT > m_collidingObjects
Objects we are currently colliding with.
std::vector< ObjectBase * > m_calcObjects
Objects needing calc() live here too.
std::vector< ObjectBase * > m_objects
All objects live here.
Represents the rising water on GCN Peach Beach and Delfino Pier battle stage.
Definition ObjectPsea.hh:11
Contexts can be used to restore a previous memory state for the current session.
Definition Context.hh:71
The highest level abstraction for a kart.
Definition KartObject.hh:11
A 3D float vector.
Definition Vector.hh:107