1#include "KartObjectProxy.hh"
3#include "game/kart/CollisionGroup.hh"
4#include "game/kart/KartObject.hh"
5#include "game/kart/KartObjectManager.hh"
6#include "game/kart/KartState.hh"
7#include "game/kart/KartSub.hh"
8#include "game/kart/KartSuspension.hh"
9#include "game/kart/KartTire.hh"
11#include "game/system/CourseMap.hh"
12#include "game/system/RaceManager.hh"
13#include "game/system/map/MapdataCannonPoint.hh"
15#include <egg/math/Math.hh>
22KartObjectProxy::KartObjectProxy() : m_accessor(nullptr) {
23 s_proxyList.push_back(
this);
26KartObjectProxy::~KartObjectProxy() =
default;
30 dynamics()->setPos(pos);
34void KartObjectProxy::setRot(
const EGG::Quatf &q) {
35 dynamics()->setFullRot(q);
36 dynamics()->setMainRot(q);
40void KartObjectProxy::setInertiaScale(
const EGG::Vector3f &scale) {
42 dynamics()->setInertia(cuboids[0] * scale, cuboids[1] * scale);
46KartAction *KartObjectProxy::action() {
47 return m_accessor->action;
51const KartAction *KartObjectProxy::action()
const {
52 return m_accessor->action;
56KartBody *KartObjectProxy::body() {
57 return m_accessor->body;
61const KartBody *KartObjectProxy::body()
const {
62 return m_accessor->body;
66KartCollide *KartObjectProxy::collide() {
67 return m_accessor->collide;
71const KartCollide *KartObjectProxy::collide()
const {
72 return m_accessor->collide;
76CollisionGroup *KartObjectProxy::collisionGroup() {
77 return m_accessor->body->physics()->hitboxGroup();
81const CollisionGroup *KartObjectProxy::collisionGroup()
const {
82 return m_accessor->body->physics()->hitboxGroup();
86KartMove *KartObjectProxy::move() {
87 return m_accessor->move;
91const KartMove *KartObjectProxy::move()
const {
92 return m_accessor->move;
95KartHalfPipe *KartObjectProxy::halfPipe() {
96 return m_accessor->move->halfPipe();
99const KartHalfPipe *KartObjectProxy::halfPipe()
const {
100 return m_accessor->move->halfPipe();
104KartJump *KartObjectProxy::jump() {
105 return m_accessor->move->jump();
109const KartJump *KartObjectProxy::jump()
const {
110 return m_accessor->move->jump();
114KartParam *KartObjectProxy::param() {
115 return m_accessor->param;
119const KartParam *KartObjectProxy::param()
const {
120 return m_accessor->param;
124const BSP &KartObjectProxy::bsp()
const {
125 return param()->bsp();
129KartPhysics *KartObjectProxy::physics() {
130 return body()->physics();
134const KartPhysics *KartObjectProxy::physics()
const {
135 return body()->physics();
139KartDynamics *KartObjectProxy::dynamics() {
140 return physics()->dynamics();
144const KartDynamics *KartObjectProxy::dynamics()
const {
145 return physics()->dynamics();
148KartState *KartObjectProxy::state() {
149 return m_accessor->state;
152const KartState *KartObjectProxy::state()
const {
153 return m_accessor->state;
157KartSub *KartObjectProxy::sub() {
158 return m_accessor->sub;
162const KartSub *KartObjectProxy::sub()
const {
163 return m_accessor->sub;
167KartSuspension *KartObjectProxy::suspension(
u16 suspIdx) {
168 return m_accessor->suspensions[suspIdx];
172const KartSuspension *KartObjectProxy::suspension(
u16 suspIdx)
const {
173 return m_accessor->suspensions[suspIdx];
177KartSuspensionPhysics *KartObjectProxy::suspensionPhysics(
u16 suspIdx) {
178 return m_accessor->suspensions[suspIdx]->suspPhysics();
182const KartSuspensionPhysics *KartObjectProxy::suspensionPhysics(
u16 suspIdx)
const {
183 return m_accessor->suspensions[suspIdx]->suspPhysics();
187KartTire *KartObjectProxy::tire(
u16 tireIdx) {
188 return m_accessor->tires[tireIdx];
192const KartTire *KartObjectProxy::tire(
u16 tireIdx)
const {
193 return m_accessor->tires[tireIdx];
197WheelPhysics *KartObjectProxy::tirePhysics(
u16 tireIdx) {
198 return tire(tireIdx)->wheelPhysics();
202const WheelPhysics *KartObjectProxy::tirePhysics(
u16 tireIdx)
const {
203 return m_accessor->tires[tireIdx]->wheelPhysics();
207CollisionData &KartObjectProxy::collisionData() {
208 return physics()->hitboxGroup()->collisionData();
212const CollisionData &KartObjectProxy::collisionData()
const {
213 return m_accessor->body->physics()->hitboxGroup()->collisionData();
218 return System::RaceManager::Instance()->player().inputs();
223 return m_accessor->model;
228 return m_accessor->model;
233 return m_accessor->objectCollisionKart;
238 return m_accessor->objectCollisionKart;
243 return m_accessor->boxColUnit;
248 return m_accessor->boxColUnit;
252CollisionData &KartObjectProxy::collisionData(
u16 tireIdx) {
253 return tirePhysics(tireIdx)->hitboxGroup()->collisionData();
257const CollisionData &KartObjectProxy::collisionData(
u16 tireIdx)
const {
258 return m_accessor->tires[tireIdx]->wheelPhysics()->hitboxGroup()->collisionData();
263 return move()->scale();
268 return physics()->pose();
293const EGG::Vector3f &KartObjectProxy::componentXAxis()
const {
294 return physics()->xAxis();
298const EGG::Vector3f &KartObjectProxy::componentYAxis()
const {
299 return physics()->yAxis();
303const EGG::Vector3f &KartObjectProxy::componentZAxis()
const {
304 return physics()->zAxis();
309 return dynamics()->pos();
314 return physics()->pos();
317const EGG::Quatf &KartObjectProxy::fullRot()
const {
318 return dynamics()->fullRot();
322 return dynamics()->extVel();
326 return dynamics()->intVel();
330 return dynamics()->velocity();
334f32 KartObjectProxy::speed()
const {
335 return move()->speed();
338f32 KartObjectProxy::acceleration()
const {
339 return move()->acceleration();
342f32 KartObjectProxy::softSpeedLimit()
const {
343 return move()->softSpeedLimit();
346const EGG::Quatf &KartObjectProxy::mainRot()
const {
347 return dynamics()->mainRot();
351 return dynamics()->angVel2();
355bool KartObjectProxy::isBike()
const {
356 return param()->isBike();
360u16 KartObjectProxy::suspCount()
const {
361 return param()->suspCount();
365u16 KartObjectProxy::tireCount()
const {
366 return param()->tireCount();
370bool KartObjectProxy::hasFloorCollision(
const WheelPhysics *wheelPhysics)
const {
371 return wheelPhysics->hitboxGroup()->collisionData().bFloor;
375std::pair<EGG::Vector3f, EGG::Vector3f> KartObjectProxy::getCannonPosRot() {
376 auto *cannon = System::CourseMap::Instance()->getCannonPoint(state()->cannonPointId());
381 rotMat.
makeR(radRot);
384 distance_to_cannon.y = 0.0f;
386 f32 temp0 = local60.
dot(distance_to_cannon);
387 return std::pair(cannonPos + local60 * temp0, cannonRot);
391f32 KartObjectProxy::speedRatio()
const {
392 return move()->speedRatio();
396f32 KartObjectProxy::speedRatioCapped()
const {
397 return move()->speedRatioCapped();
401bool KartObjectProxy::isInRespawn()
const {
402 return move()->respawnTimer() > 0 || move()->respawnPostLandTimer() > 0;
406void KartObjectProxy::apply(
size_t idx) {
407 m_accessor = KartObjectManager::Instance()->object(idx)->accessor();
414 for (
auto iter = s_proxyList.begin(); iter != s_proxyList.end(); ++iter) {
415 (*iter)->m_accessor = pointers;
419std::list<KartObjectProxy *> KartObjectProxy::s_proxyList;
Vector3f multVector33(const Vector3f &vec) const
Multiplies a 3x3 matrix by a vector.
void makeR(const Vector3f &r)
Sets 3x3 rotation matrix from a vector of Euler angles.
Relates a KartObject with its convex hull representation.
Included in Kinoko because it mysteriously sets an angle member variable in KartBody.
Pertains to kart-related functionality.
A quaternion, used to represent 3D rotation.
f32 dot(const Vector3f &rhs) const
The dot product between two vectors.
A representation of the boundaries of an entity that has dynamic collision.
Shared between classes who inherit KartObjectProxy so they can access one another.