A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjColMgr.cc
1#include "ObjColMgr.hh"
2
3#include "game/field/CourseColMgr.hh"
4
5namespace Field {
6
8ObjColMgr::ObjColMgr(const void *file)
9 : m_mtx(EGG::Matrix34f::ident), m_mtxInv(EGG::Matrix34f::ident), m_kclScale(1.0f),
10 m_movingObjVel(EGG::Vector3f::zero) {
11 m_data = new KColData(file);
12}
13
15ObjColMgr::~ObjColMgr() {
16 ASSERT(m_data);
17 delete m_data;
18}
19
21void ObjColMgr::narrScLocal(f32 radius, const EGG::Vector3f &pos, KCLTypeMask flags) {
22 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
23 CourseColMgr::Instance()->scaledNarrowScopeLocal(m_kclScale, radius, m_data, posWrtModel,
24 flags);
25}
26
28EGG::Vector3f ObjColMgr::kclLowWorld() const {
29 EGG::Vector3f posLocal = m_data->bbox().min * m_kclScale;
30 return m_mtx.ps_multVector(posLocal);
31}
32
34EGG::Vector3f ObjColMgr::kclHighWorld() const {
35 EGG::Vector3f posLocal = m_data->bbox().max * m_kclScale;
36 return m_mtx.ps_multVector(posLocal);
37}
38
40bool ObjColMgr::checkPointPartial(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
41 KCLTypeMask flags, CollisionInfoPartial *info, KCLTypeMask *typeMaskOut) {
42 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
43 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
44 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
45 auto *courseColMgr = CourseColMgr::Instance();
46
47 if (info) {
48 CollisionInfoPartial tempInfo;
49 tempInfo.bbox.setZero();
50
51 if (courseColMgr->noBounceWallInfo()) {
52 courseColMgr->setLocalMtx(&m_mtx);
53 }
54
55 if (courseColMgr->checkPointPartial(m_kclScale, m_data, posWrtModel, prevPosWrtModel, flags,
56 &tempInfo, typeMaskOut)) {
57 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
58 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
59
60 EGG::Vector3f min = tempInfo.bbox.min;
61 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
62 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
63
64 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
65 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
66
67 return true;
68 }
69
70 return false;
71 }
72
73 return courseColMgr->checkPointPartial(m_kclScale, m_data, posWrtModel, prevPosWrtModel, flags,
74 info, typeMaskOut);
75}
76
78bool ObjColMgr::checkPointPartialPush(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
79 KCLTypeMask flags, CollisionInfoPartial *info, KCLTypeMask *typeMaskOut) {
80 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
81 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
82 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
83 auto *courseColMgr = CourseColMgr::Instance();
84
85 if (info) {
86 CollisionInfoPartial tempInfo;
87 tempInfo.bbox.setZero();
88
89 if (courseColMgr->noBounceWallInfo()) {
90 courseColMgr->setLocalMtx(&m_mtx);
91 }
92
93 if (courseColMgr->checkPointPartialPush(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
94 flags, &tempInfo, typeMaskOut)) {
95 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
96 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
97
98 EGG::Vector3f min = tempInfo.bbox.min;
99 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
100 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
101
102 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
103 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
104
105 return true;
106 }
107
108 return false;
109 }
110
111 return courseColMgr->checkPointPartialPush(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
112 flags, info, typeMaskOut);
113}
114
116bool ObjColMgr::checkPointFull(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
117 KCLTypeMask flags, CollisionInfo *info, KCLTypeMask *typeMaskOut) {
118 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
119 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
120 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
121 auto *courseColMgr = CourseColMgr::Instance();
122
123 if (info) {
124 CollisionInfo tempInfo;
125 tempInfo.reset();
126
127 if (courseColMgr->noBounceWallInfo()) {
128 courseColMgr->setLocalMtx(&m_mtx);
129 }
130
131 if (courseColMgr->checkPointFull(m_kclScale, m_data, posWrtModel, prevPosWrtModel, flags,
132 &tempInfo, typeMaskOut)) {
133 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
134
135 return true;
136 }
137
138 return false;
139 }
140
141 return courseColMgr->checkPointFull(m_kclScale, m_data, posWrtModel, prevPosWrtModel, flags,
142 info, typeMaskOut);
143}
144
146bool ObjColMgr::checkPointFullPush(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
147 KCLTypeMask flags, CollisionInfo *info, KCLTypeMask *typeMaskOut) {
148 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
149 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
150 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
151 auto *courseColMgr = CourseColMgr::Instance();
152
153 if (info) {
154 CollisionInfo tempInfo;
155 tempInfo.reset();
156
157 if (courseColMgr->noBounceWallInfo()) {
158 courseColMgr->setLocalMtx(&m_mtx);
159 }
160
161 if (courseColMgr->checkPointFullPush(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
162 flags, &tempInfo, typeMaskOut)) {
163 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
164
165 return true;
166 }
167
168 return false;
169 }
170
171 return courseColMgr->checkPointFullPush(m_kclScale, m_data, posWrtModel, prevPosWrtModel, flags,
172 info, typeMaskOut);
173}
174
176bool ObjColMgr::checkSpherePartial(f32 radius, const EGG::Vector3f &pos,
177 const EGG::Vector3f &prevPos, KCLTypeMask flags, CollisionInfoPartial *info,
178 KCLTypeMask *typeMaskOut) {
179 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
180 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
181 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
182 auto *courseColMgr = CourseColMgr::Instance();
183
184 if (info) {
185 CollisionInfoPartial tempInfo;
186 tempInfo.bbox.setZero();
187
188 if (courseColMgr->noBounceWallInfo()) {
189 courseColMgr->setLocalMtx(&m_mtx);
190 }
191
192 if (courseColMgr->checkSpherePartial(m_kclScale, radius, m_data, posWrtModel,
193 prevPosWrtModel, flags, &tempInfo, typeMaskOut)) {
194 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
195 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
196
197 EGG::Vector3f min = tempInfo.bbox.min;
198 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
199 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
200
201 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
202 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
203
204 return true;
205 }
206
207 return false;
208 }
209
210 return courseColMgr->checkSpherePartial(m_kclScale, radius, m_data, posWrtModel,
211 prevPosWrtModel, flags, info, typeMaskOut);
212}
213
215bool ObjColMgr::checkSpherePartialPush(f32 radius, const EGG::Vector3f &pos,
216 const EGG::Vector3f &prevPos, KCLTypeMask flags, CollisionInfoPartial *info,
217 KCLTypeMask *typeMaskOut) {
218 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
219 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
220 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
221 auto *courseColMgr = CourseColMgr::Instance();
222
223 if (info) {
224 CollisionInfoPartial tempInfo;
225 tempInfo.bbox.setZero();
226
227 if (courseColMgr->noBounceWallInfo()) {
228 courseColMgr->setLocalMtx(&m_mtx);
229 }
230
231 if (courseColMgr->checkSpherePartialPush(m_kclScale, radius, m_data, posWrtModel,
232 prevPosWrtModel, flags, &tempInfo, typeMaskOut)) {
233 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
234 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
235
236 EGG::Vector3f min = tempInfo.bbox.min;
237 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
238 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
239
240 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
241 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
242
243 return true;
244 }
245
246 return false;
247 }
248
249 return courseColMgr->checkSpherePartialPush(m_kclScale, radius, m_data, posWrtModel,
250 prevPosWrtModel, flags, info, typeMaskOut);
251}
252
254bool ObjColMgr::checkSphereFull(f32 radius, const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
255 KCLTypeMask flags, CollisionInfo *info, KCLTypeMask *typeMaskOut) {
256 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
257 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
258 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
259 auto *courseColMgr = CourseColMgr::Instance();
260
261 if (info) {
262 CollisionInfo tempInfo;
263 tempInfo.reset();
264
265 if (courseColMgr->noBounceWallInfo()) {
266 courseColMgr->setLocalMtx(&m_mtx);
267 }
268
269 if (courseColMgr->checkSphereFull(m_kclScale, radius, m_data, posWrtModel, prevPosWrtModel,
270 flags, &tempInfo, typeMaskOut)) {
271 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
272
273 return true;
274 }
275
276 return false;
277 }
278
279 return courseColMgr->checkSphereFull(m_kclScale, radius, m_data, posWrtModel, prevPosWrtModel,
280 flags, info, typeMaskOut);
281}
282
284bool ObjColMgr::checkSphereFullPush(f32 radius, const EGG::Vector3f &pos,
285 const EGG::Vector3f &prevPos, KCLTypeMask flags, CollisionInfo *info,
286 KCLTypeMask *typeMaskOut) {
287 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
288 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
289 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
290 auto *courseColMgr = CourseColMgr::Instance();
291
292 if (info) {
293 CollisionInfo tempInfo;
294 tempInfo.reset();
295
296 if (courseColMgr->noBounceWallInfo()) {
297 courseColMgr->setLocalMtx(&m_mtx);
298 }
299
300 if (courseColMgr->checkSphereFullPush(m_kclScale, radius, m_data, posWrtModel,
301 prevPosWrtModel, flags, &tempInfo, typeMaskOut)) {
302 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
303
304 return true;
305 }
306
307 return false;
308 }
309
310 return courseColMgr->checkSphereFullPush(m_kclScale, radius, m_data, posWrtModel,
311 prevPosWrtModel, flags, info, typeMaskOut);
312}
313
315bool ObjColMgr::checkPointCachedPartial(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
316 KCLTypeMask flags, CollisionInfoPartial *info, KCLTypeMask *typeMaskOut) {
317 if (m_data->prismCache(0) == 0) {
318 return false;
319 }
320
321 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
322 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
323 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
324 auto *courseColMgr = CourseColMgr::Instance();
325
326 if (info) {
327 CollisionInfoPartial tempInfo;
328 tempInfo.bbox.setZero();
329
330 if (courseColMgr->noBounceWallInfo()) {
331 courseColMgr->setLocalMtx(&m_mtx);
332 }
333
334 if (courseColMgr->checkPointCachedPartial(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
335 flags, &tempInfo, typeMaskOut)) {
336 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
337 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
338
339 EGG::Vector3f min = tempInfo.bbox.min;
340 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
341 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
342
343 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
344 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
345
346 return true;
347 }
348
349 return false;
350 }
351
352 return courseColMgr->checkPointCachedPartial(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
353 flags, info, typeMaskOut);
354}
355
357bool ObjColMgr::checkPointCachedPartialPush(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
358 KCLTypeMask flags, CollisionInfoPartial *info, KCLTypeMask *typeMaskOut) {
359 if (m_data->prismCache(0) == 0) {
360 return false;
361 }
362
363 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
364 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
365 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
366 auto *courseColMgr = CourseColMgr::Instance();
367
368 if (info) {
369 CollisionInfoPartial tempInfo;
370 tempInfo.bbox.setZero();
371
372 if (courseColMgr->noBounceWallInfo()) {
373 courseColMgr->setLocalMtx(&m_mtx);
374 }
375
376 if (courseColMgr->checkPointCachedPartialPush(m_kclScale, m_data, posWrtModel,
377 prevPosWrtModel, flags, &tempInfo, typeMaskOut)) {
378 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
379 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
380
381 EGG::Vector3f min = tempInfo.bbox.min;
382 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
383 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
384
385 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
386 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
387
388 return true;
389 }
390
391 return false;
392 }
393
394 return courseColMgr->checkPointCachedPartialPush(m_kclScale, m_data, posWrtModel,
395 prevPosWrtModel, flags, info, typeMaskOut);
396}
397
399bool ObjColMgr::checkPointCachedFull(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
400 KCLTypeMask flags, CollisionInfo *info, KCLTypeMask *typeMaskOut) {
401 if (m_data->prismCache(0) == 0) {
402 return false;
403 }
404
405 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
406 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
407 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
408 auto *courseColMgr = CourseColMgr::Instance();
409
410 if (info) {
411 CollisionInfo tempInfo;
412 tempInfo.reset();
413
414 if (courseColMgr->noBounceWallInfo()) {
415 courseColMgr->setLocalMtx(&m_mtx);
416 }
417
418 if (courseColMgr->checkPointCachedFull(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
419 flags, &tempInfo, typeMaskOut)) {
420 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
421
422 return true;
423 }
424
425 return false;
426 }
427
428 return courseColMgr->checkPointCachedFull(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
429 flags, info, typeMaskOut);
430}
431
433bool ObjColMgr::checkPointCachedFullPush(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos,
434 KCLTypeMask flags, CollisionInfo *info, KCLTypeMask *typeMaskOut) {
435 if (m_data->prismCache(0) == 0) {
436 return false;
437 }
438
439 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
440 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
441 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
442 auto *courseColMgr = CourseColMgr::Instance();
443
444 if (info) {
445 CollisionInfo tempInfo;
446 tempInfo.reset();
447
448 if (courseColMgr->noBounceWallInfo()) {
449 courseColMgr->setLocalMtx(&m_mtx);
450 }
451
452 if (courseColMgr->checkPointCachedFullPush(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
453 flags, &tempInfo, typeMaskOut)) {
454 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
455
456 return true;
457 }
458
459 return false;
460 }
461
462 return courseColMgr->checkPointCachedFullPush(m_kclScale, m_data, posWrtModel, prevPosWrtModel,
463 flags, info, typeMaskOut);
464}
465
467bool ObjColMgr::checkSphereCachedPartial(f32 radius, const EGG::Vector3f &pos,
468 const EGG::Vector3f &prevPos, KCLTypeMask typeflags, CollisionInfoPartial *info,
469 KCLTypeMask *typeMaskOut) {
470 if (m_data->prismCache(0) == 0) {
471 return false;
472 }
473
474 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
475 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
476 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
477 auto *courseColMgr = CourseColMgr::Instance();
478
479 if (info) {
480 CollisionInfoPartial tempInfo;
481 tempInfo.bbox.setZero();
482
483 if (courseColMgr->noBounceWallInfo()) {
484 courseColMgr->setLocalMtx(&m_mtx);
485 }
486
487 if (courseColMgr->checkSphereCachedPartial(m_kclScale, radius, m_data, posWrtModel,
488 prevPosWrtModel, typeflags, &tempInfo, typeMaskOut)) {
489 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
490 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
491
492 EGG::Vector3f min = tempInfo.bbox.min;
493 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
494 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
495
496 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
497 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
498
499 return true;
500 }
501
502 return false;
503 }
504
505 return courseColMgr->checkSphereCachedPartial(m_kclScale, radius, m_data, posWrtModel,
506 prevPosWrtModel, typeflags, info, typeMaskOut);
507}
508
510bool ObjColMgr::checkSphereCachedPartialPush(f32 radius, const EGG::Vector3f &pos,
511 const EGG::Vector3f &prevPos, KCLTypeMask typeflags, CollisionInfoPartial *info,
512 KCLTypeMask *typeMaskOut) {
513 if (m_data->prismCache(0) == 0) {
514 return false;
515 }
516
517 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
518 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
519 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
520 auto *courseColMgr = CourseColMgr::Instance();
521
522 if (info) {
523 CollisionInfoPartial tempInfo;
524 tempInfo.bbox.setZero();
525
526 if (courseColMgr->noBounceWallInfo()) {
527 courseColMgr->setLocalMtx(&m_mtx);
528 }
529
530 if (courseColMgr->checkSphereCachedPartialPush(m_kclScale, radius, m_data, posWrtModel,
531 prevPosWrtModel, typeflags, &tempInfo, typeMaskOut)) {
532 tempInfo.bbox.min = m_mtx.ps_multVector33(tempInfo.bbox.min);
533 tempInfo.bbox.max = m_mtx.ps_multVector33(tempInfo.bbox.max);
534
535 EGG::Vector3f min = tempInfo.bbox.min;
536 tempInfo.bbox.min = min.minimize(tempInfo.bbox.max);
537 tempInfo.bbox.max = min.maximize(tempInfo.bbox.max);
538
539 info->bbox.min = info->bbox.min.minimize(tempInfo.bbox.min);
540 info->bbox.max = info->bbox.max.maximize(tempInfo.bbox.max);
541
542 return true;
543 }
544
545 return false;
546 }
547
548 return courseColMgr->checkSphereCachedPartialPush(m_kclScale, radius, m_data, posWrtModel,
549 prevPosWrtModel, typeflags, info, typeMaskOut);
550}
551
553bool ObjColMgr::checkSphereCachedFull(f32 radius, const EGG::Vector3f &pos,
554 const EGG::Vector3f &prevPos, KCLTypeMask typeflags, CollisionInfo *info,
555 KCLTypeMask *typeMaskOut) {
556 if (m_data->prismCache(0) == 0) {
557 return false;
558 }
559
560 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
561 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
562 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
563 auto *courseColMgr = CourseColMgr::Instance();
564
565 if (info) {
566 CollisionInfo tempInfo;
567 tempInfo.reset();
568
569 if (courseColMgr->noBounceWallInfo()) {
570 courseColMgr->setLocalMtx(&m_mtx);
571 }
572
573 if (courseColMgr->checkSphereCachedFull(m_kclScale, radius, m_data, posWrtModel,
574 prevPosWrtModel, typeflags, &tempInfo, typeMaskOut)) {
575 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
576
577 return true;
578 }
579
580 return false;
581 }
582
583 return courseColMgr->checkSphereCachedFull(m_kclScale, radius, m_data, posWrtModel,
584 prevPosWrtModel, typeflags, info, typeMaskOut);
585}
586
588bool ObjColMgr::checkSphereCachedFullPush(f32 radius, const EGG::Vector3f &pos,
589 const EGG::Vector3f &prevPos, KCLTypeMask typeflags, CollisionInfo *info,
590 KCLTypeMask *typeMaskOut) {
591 if (m_data->prismCache(0) == 0) {
592 return false;
593 }
594
595 EGG::Vector3f posWrtModel = m_mtxInv.ps_multVector(pos);
596 bool hasPrevY = prevPos.y != std::numeric_limits<f32>::infinity();
597 EGG::Vector3f prevPosWrtModel = hasPrevY ? m_mtxInv.ps_multVector(prevPos) : EGG::Vector3f::inf;
598 auto *courseColMgr = CourseColMgr::Instance();
599
600 if (info) {
601 CollisionInfo tempInfo;
602 tempInfo.reset();
603
604 if (courseColMgr->noBounceWallInfo()) {
605 courseColMgr->setLocalMtx(&m_mtx);
606 }
607
608 if (courseColMgr->checkSphereCachedFullPush(m_kclScale, radius, m_data, posWrtModel,
609 prevPosWrtModel, typeflags, &tempInfo, typeMaskOut)) {
610 info->transformInfo(tempInfo, m_mtx, m_movingObjVel);
611
612 return true;
613 }
614
615 return false;
616 }
617
618 return courseColMgr->checkSphereCachedFullPush(m_kclScale, radius, m_data, posWrtModel,
619 prevPosWrtModel, typeflags, info, typeMaskOut);
620}
621
622} // namespace Field
EGG core library.
Definition Archive.cc:6
Pertains to collision.
A 3D float vector.
Definition Vector.hh:83
Vector3f maximize(const Vector3f &rhs) const
Returns a vector whose elements are the max of the elements of both vectors.
Definition Vector.cc:65
Vector3f minimize(const Vector3f &rhs) const
Returns a vector whose elements are the min of the elements of both vectors.
Definition Vector.cc:77