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(ObjectNoImpl *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
76 static ObjectDirector *CreateInstance();
77 static void DestroyInstance();
78
79 [[nodiscard]] static ObjectDirector *Instance() {
80 return s_instance;
81 }
82
83private:
85 ~ObjectDirector() override;
86
87 void createObjects();
88 [[nodiscard]] ObjectBase *createObject(const System::MapdataGeoObj &params);
89
90 ObjectFlowTable m_flowTable;
91 ObjectHitTable m_hitTableKart;
92 ObjectHitTable m_hitTableKartObject;
93
94 std::vector<ObjectBase *> m_objects;
95 std::vector<ObjectBase *> m_calcObjects;
96 std::vector<ObjectBase *> m_collisionObjects;
97
98 static constexpr size_t MAX_UNIT_COUNT = 0x100;
99
100 std::array<ObjectCollidable *, MAX_UNIT_COUNT>
102 std::array<EGG::Vector3f, MAX_UNIT_COUNT> m_hitDepths;
103 std::array<Kart::Reaction, MAX_UNIT_COUNT> m_reactions;
104 ObjectPsea *m_psea;
105 std::vector<ObjectCollidable *> m_managedObjects;
106
107 static ObjectDirector *s_instance;
108};
109
110} // 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