MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / testObject

Method testObject

Engine/source/T3D/components/game/triggerComponent.cpp:195–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195bool TriggerComponent::testObject(SceneObject* enter)
196{
197 //First, test to early out
198 Box3F enterBox = enter->getWorldBox();
199
200 //if(!mOwner->getWorldBox().intersect(enterBox) || !)
201 // return false;
202
203 //We're still here, so we should do actual work
204 //We're going to be
205 ConcretePolyList mClippedList;
206
207 SphereF sphere;
208 sphere.center = (mOwner->getWorldBox().minExtents + mOwner->getWorldBox().maxExtents) * 0.5;
209 VectorF bv = mOwner->getWorldBox().maxExtents - sphere.center;
210 sphere.radius = bv.len();
211
212 Entity* enterEntity = dynamic_cast<Entity*>(enter);
213 if(enterEntity)
214 {
215 //quick early out. If the bounds don't overlap, it cannot be colliding or inside
216 if (!mOwner->getWorldBox().isOverlapped(enterBox))
217 return false;
218
219 //check if the entity has a collision shape
220 CollisionInterface *cI = enterEntity->getComponent<CollisionInterface>();
221 if (cI)
222 {
223 cI->buildPolyList(PLC_Collision, &mClippedList, mOwner->getWorldBox(), sphere);
224
225 if (!mClippedList.isEmpty())
226 {
227 //well, it's clipped with, or inside, our bounds
228 //now to test the clipped list against our own collision mesh
229 CollisionInterface *myCI = mOwner->getComponent<CollisionInterface>();
230
231 //wait, how would we NOT have this?
232 if (myCI)
233 {
234 //anywho, build our list and then we'll check intersections
235 ClippedPolyList myList;
236
237 MatrixF ownerTransform = mOwner->getTransform();
238 myList.setTransform(&ownerTransform, mOwner->getScale());
239 myList.setObject(mOwner);
240
241 myCI->buildPolyList(PLC_Collision, &myList, enterBox, sphere);
242
243 bool test = true;
244 }
245 }
246 }
247 }
248
249 return mClippedList.isEmpty() == false;
250}
251
252void TriggerComponent::processTick()

Callers

nothing calls this directly

Calls 9

isOverlappedMethod · 0.60
getWorldBoxMethod · 0.45
lenMethod · 0.45
buildPolyListMethod · 0.45
isEmptyMethod · 0.45
getTransformMethod · 0.45
setTransformMethod · 0.45
getScaleMethod · 0.45
setObjectMethod · 0.45

Tested by

no test coverage detected