1#include "ObjectDrivableDirector.hh"
6void ObjectDrivableDirector::init() {
14void ObjectDrivableDirector::calc() {
25void ObjectDrivableDirector::addObject(ObjectDrivable *obj) {
26 if (obj->loadFlags() & 1) {
34bool ObjectDrivableDirector::checkSpherePartial(f32 radius,
const EGG::Vector3f &pos,
35 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
36 KCLTypeMask *maskOut, u32 timeOffset) {
41 bool hasCollision =
false;
42 auto *boxColMgr = BoxColManager::Instance();
43 boxColMgr->search(radius, pos, eBoxColFlag::Drivable);
45 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
47 obj->checkSpherePartial(radius, pos, prevPos, mask, info, maskOut, timeOffset);
54bool ObjectDrivableDirector::checkSpherePartialPush(f32 radius,
const EGG::Vector3f &pos,
55 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
56 KCLTypeMask *maskOut, u32 timeOffset) {
61 bool hasCollision =
false;
62 auto *boxColMgr = BoxColManager::Instance();
63 boxColMgr->search(radius, pos, eBoxColFlag::Drivable);
65 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
67 obj->checkSpherePartialPush(radius, pos, prevPos, mask, info, maskOut, timeOffset);
74bool ObjectDrivableDirector::checkSphereFull(f32 radius,
const EGG::Vector3f &pos,
75 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info, KCLTypeMask *maskOut,
81 bool hasCollision =
false;
82 auto *boxColMgr = BoxColManager::Instance();
83 boxColMgr->search(radius, pos, eBoxColFlag::Drivable);
85 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
86 hasCollision |= obj->checkSphereFull(radius, pos, prevPos, mask, info, maskOut, timeOffset);
93bool ObjectDrivableDirector::checkSphereFullPush(f32 radius,
const EGG::Vector3f &pos,
94 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info, KCLTypeMask *maskOut,
100 bool hasCollision =
false;
101 auto *boxColMgr = BoxColManager::Instance();
102 boxColMgr->search(radius, pos, eBoxColFlag::Drivable);
104 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
106 obj->checkSphereFullPush(radius, pos, prevPos, mask, info, maskOut, timeOffset);
113bool ObjectDrivableDirector::checkSphereCachedPartial(f32 radius,
const EGG::Vector3f &pos,
114 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
115 KCLTypeMask *maskOut, u32 timeOffset) {
120 auto *boxColMgr = BoxColManager::Instance();
122 if (boxColMgr->isSphereInSpatialCache(radius, pos, eBoxColFlag::Drivable)) {
123 boxColMgr->resetIterators();
125 bool hasCollision =
false;
126 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
127 hasCollision |= obj->checkSphereCachedPartial(radius, pos, prevPos, mask, info, maskOut,
134 return checkSpherePartial(radius, pos, prevPos, mask, info, maskOut, timeOffset);
138bool ObjectDrivableDirector::checkSphereCachedPartialPush(f32 radius,
const EGG::Vector3f &pos,
139 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfoPartial *info,
140 KCLTypeMask *maskOut, u32 timeOffset) {
145 auto *boxColMgr = BoxColManager::Instance();
147 if (boxColMgr->isSphereInSpatialCache(radius, pos, eBoxColFlag::Drivable)) {
148 boxColMgr->resetIterators();
150 bool hasCollision =
false;
151 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
152 hasCollision |= obj->checkSphereCachedPartialPush(radius, pos, prevPos, mask, info,
153 maskOut, timeOffset);
159 return checkSpherePartialPush(radius, pos, prevPos, mask, info, maskOut, timeOffset);
163bool ObjectDrivableDirector::checkSphereCachedFullPush(f32 radius,
const EGG::Vector3f &pos,
164 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info, KCLTypeMask *maskOut,
170 auto *boxColMgr = BoxColManager::Instance();
172 if (boxColMgr->isSphereInSpatialCache(radius, pos, eBoxColFlag::Drivable)) {
173 bool hasCollision =
false;
174 boxColMgr->resetIterators();
176 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
177 hasCollision |= obj->checkSphereCachedFullPush(radius, pos, prevPos, mask, info,
178 maskOut, timeOffset);
184 return checkSphereFullPush(radius, pos, prevPos, mask, info, maskOut, timeOffset);
188void ObjectDrivableDirector::colNarScLocal(f32 radius,
const EGG::Vector3f &pos, KCLTypeMask mask,
194 auto *boxColMgr = BoxColManager::Instance();
195 boxColMgr->search(radius, pos, eBoxColFlag::Drivable);
197 while (ObjectDrivable *obj = boxColMgr->getNextDrivable()) {
198 obj->narrScLocal(radius, pos, mask, timeOffset);
203ObjectDrivableDirector *ObjectDrivableDirector::CreateInstance() {
205 s_instance =
new ObjectDrivableDirector;
210void ObjectDrivableDirector::DestroyInstance() {
212 auto *instance = s_instance;
213 s_instance =
nullptr;
218ObjectDrivableDirector::ObjectDrivableDirector() =
default;
221ObjectDrivableDirector::~ObjectDrivableDirector() {
223 s_instance =
nullptr;
224 WARN(
"ObjectDrivableDirector instance not explicitly handled!");
228ObjectDrivableDirector *ObjectDrivableDirector::s_instance =
nullptr;
std::vector< ObjectDrivable * > m_objects
All objects live here.
std::vector< ObjectDrivable * > m_calcObjects
Objects needing calc() live here too.