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 Host {
12
13class Context;
14
15} // namespace Host
16
17namespace Field {
18
19class ObjectPsea;
20
22 friend class Host::Context;
23
24public:
25 void init();
26 void calc();
27 void addObject(ObjectCollidable *obj);
28 void addObjectNoImpl(ObjectBase *obj);
29 void addManagedObject(ObjectCollidable *obj);
30
31 size_t checkKartObjectCollision(Kart::KartObject *kartObj,
32 ObjectCollisionConvexHull *convexHull);
33
34 [[nodiscard]] const ObjectFlowTable &flowTable() const {
35 return m_flowTable;
36 }
37
38 [[nodiscard]] const ObjectHitTable &hitTableKart() const {
39 return m_hitTableKart;
40 }
41
42 [[nodiscard]] const ObjectCollidable *collidingObject(size_t idx) const {
43 ASSERT(idx < m_collidingObjects.size());
44 return m_collidingObjects[idx];
45 }
46
47 [[nodiscard]] Kart::Reaction reaction(size_t idx) const {
48 ASSERT(idx < m_reactions.size());
49 return m_reactions[idx];
50 }
51
52 [[nodiscard]] const EGG::Vector3f &hitDepth(size_t idx) const {
53 ASSERT(idx < m_hitDepths.size());
54 return m_hitDepths[idx];
55 }
56
57 [[nodiscard]] std::vector<ObjectCollidable *> &managedObjects() {
58 return m_managedObjects;
59 }
60
61 [[nodiscard]] const std::vector<ObjectCollidable *> &managedObjects() const {
62 return m_managedObjects;
63 }
64
65 void setPsea(ObjectPsea *psea) {
66 m_psea = psea;
67 }
68
69 [[nodiscard]] ObjectPsea *psea() const {
70 return m_psea;
71 }
72
73 [[nodiscard]] f32 distAboveRisingWater(f32 offset) const;
74 [[nodiscard]] f32 risingWaterKillPlaneHeight() const;
75
77 [[nodiscard]] static f32 WanwanMaxPitch() {
78 return s_wanwanMaxPitch;
79 }
80
81 static ObjectDirector *CreateInstance();
82 static void DestroyInstance();
83
84 [[nodiscard]] static ObjectDirector *Instance() {
85 return s_instance;
86 }
87
88private:
90 ~ObjectDirector() override;
91
92 void createObjects();
93 [[nodiscard]] ObjectBase *createObject(const System::MapdataGeoObj &params);
94
95 ObjectFlowTable m_flowTable;
96 ObjectHitTable m_hitTableKart;
97 ObjectHitTable m_hitTableKartObject;
98
99 std::vector<ObjectBase *> m_objects;
100 std::vector<ObjectBase *> m_calcObjects;
101 std::vector<ObjectBase *> m_collisionObjects;
102
103 static constexpr size_t MAX_UNIT_COUNT = 0x100;
104
105 std::array<ObjectCollidable *, MAX_UNIT_COUNT>
107 std::array<EGG::Vector3f, MAX_UNIT_COUNT> m_hitDepths;
108 std::array<Kart::Reaction, MAX_UNIT_COUNT> m_reactions;
109 ObjectPsea *m_psea;
110 std::vector<ObjectCollidable *> m_managedObjects;
111
112 static f32 s_wanwanMaxPitch;
113
114 static ObjectDirector *s_instance;
115};
116
117} // namespace Field
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_objects
All objects live here.
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.
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:59
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
Represents the host application.
Definition HeapCommon.hh:9
A 3D float vector.
Definition Vector.hh:88