| 614 | } |
| 615 | |
| 616 | void Trigger::setTriggerPolyhedron(const Polyhedron& rPolyhedron) |
| 617 | { |
| 618 | mTriggerPolyhedron = rPolyhedron; |
| 619 | |
| 620 | if (mTriggerPolyhedron.mPointList.size() != 0) { |
| 621 | mObjBox.minExtents.set(1e10, 1e10, 1e10); |
| 622 | mObjBox.maxExtents.set(-1e10, -1e10, -1e10); |
| 623 | for (U32 i = 0; i < mTriggerPolyhedron.mPointList.size(); i++) { |
| 624 | mObjBox.minExtents.setMin(mTriggerPolyhedron.mPointList[i]); |
| 625 | mObjBox.maxExtents.setMax(mTriggerPolyhedron.mPointList[i]); |
| 626 | } |
| 627 | } else { |
| 628 | mObjBox.minExtents.set(-0.5, -0.5, -0.5); |
| 629 | mObjBox.maxExtents.set( 0.5, 0.5, 0.5); |
| 630 | } |
| 631 | |
| 632 | MatrixF xform = getTransform(); |
| 633 | setTransform(xform); |
| 634 | |
| 635 | mClippedList.clear(); |
| 636 | mClippedList.mPlaneList = mTriggerPolyhedron.mPlaneList; |
| 637 | // for (U32 i = 0; i < mClippedList.mPlaneList.size(); i++) |
| 638 | // mClippedList.mPlaneList[i].neg(); |
| 639 | |
| 640 | MatrixF base(true); |
| 641 | base.scale(Point3F(1.0/mObjScale.x, |
| 642 | 1.0/mObjScale.y, |
| 643 | 1.0/mObjScale.z)); |
| 644 | base.mul(mWorldToObj); |
| 645 | |
| 646 | mClippedList.setBaseTransform(base); |
| 647 | |
| 648 | SAFE_DELETE( mPhysicsRep ); |
| 649 | |
| 650 | if ( PHYSICSMGR ) |
| 651 | { |
| 652 | PhysicsCollision *colShape = PHYSICSMGR->createCollision(); |
| 653 | |
| 654 | MatrixF colMat( true ); |
| 655 | colMat.displace( Point3F( 0, 0, mObjBox.getExtents().z * 0.5f * mObjScale.z ) ); |
| 656 | |
| 657 | colShape->addBox( mObjBox.getExtents() * 0.5f * mObjScale, colMat ); |
| 658 | //MatrixF colMat( true ); |
| 659 | //colMat.scale( mObjScale ); |
| 660 | //colShape->addConvex( mTriggerPolyhedron.pointList.address(), mTriggerPolyhedron.pointList.size(), colMat ); |
| 661 | |
| 662 | PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" ); |
| 663 | mPhysicsRep = PHYSICSMGR->createBody(); |
| 664 | mPhysicsRep->init( colShape, 0, PhysicsBody::BF_TRIGGER | PhysicsBody::BF_KINEMATIC, this, world ); |
| 665 | mPhysicsRep->setTransform( getTransform() ); |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | |
| 670 | //-------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected