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