| 193 | } |
| 194 | |
| 195 | bool 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 | |
| 252 | void TriggerComponent::processTick() |
nothing calls this directly
no test coverage detected