| 693 | } |
| 694 | |
| 695 | bool PhysicsShape::_createShape() |
| 696 | { |
| 697 | SAFE_DELETE( mPhysicsRep ); |
| 698 | SAFE_DELETE( mShapeInst ); |
| 699 | mAmbientThread = NULL; |
| 700 | mWorld = NULL; |
| 701 | mAmbientSeq = -1; |
| 702 | |
| 703 | PhysicsShapeData *db = getDataBlock(); |
| 704 | if ( !db || !db->mShape) |
| 705 | return false; |
| 706 | |
| 707 | // Set the world box. |
| 708 | mObjBox = db->mShape->mBounds; |
| 709 | resetWorldBox(); |
| 710 | |
| 711 | // If this is the server and its a client only simulation |
| 712 | // object then disable our tick... the server doesn't do |
| 713 | // any work for this shape. |
| 714 | if ( isServerObject() && |
| 715 | db->simType == PhysicsShapeData::SimType_ClientOnly ) |
| 716 | { |
| 717 | setProcessTick( false ); |
| 718 | return true; |
| 719 | } |
| 720 | |
| 721 | // Create the shape instance. |
| 722 | mShapeInst = new TSShapeInstance( db->mShape, isClientObject() ); |
| 723 | |
| 724 | if ( isClientObject() ) |
| 725 | { |
| 726 | mAmbientSeq = db->mShape->findSequence( "ambient" ); |
| 727 | _initAmbient(); |
| 728 | } |
| 729 | |
| 730 | // If the shape has a mass then its dynamic... else |
| 731 | // its a kinematic shape. |
| 732 | // |
| 733 | // While a kinematic is less optimal than a static body |
| 734 | // it allows for us to enable/disable collision and having |
| 735 | // all dynamic actors react correctly... waking up. |
| 736 | // |
| 737 | const bool isDynamic = db->mass > 0.0f; |
| 738 | |
| 739 | // If we aren't dynamic we don't need to tick. |
| 740 | setProcessTick( isDynamic || mPlayAmbient ); |
| 741 | |
| 742 | // If this is the client and we're a server only object then |
| 743 | // we don't need any physics representation... we're done. |
| 744 | if ( isClientObject() && |
| 745 | db->simType == PhysicsShapeData::SimType_ServerOnly ) |
| 746 | return true; |
| 747 | |
| 748 | mWorld = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" ); |
| 749 | |
| 750 | mPhysicsRep = PHYSICSMGR->createBody(); |
| 751 | mPhysicsRep->init( db->colShape, |
| 752 | db->mass, |
nothing calls this directly
no test coverage detected