| 1088 | } |
| 1089 | |
| 1090 | void PhysicsShape::destroy() |
| 1091 | { |
| 1092 | if ( mDestroyed ) |
| 1093 | return; |
| 1094 | |
| 1095 | mDestroyed = true; |
| 1096 | setMaskBits( DamageMask ); |
| 1097 | |
| 1098 | const Point3F lastLinVel = mPhysicsRep->isDynamic() ? mPhysicsRep->getLinVelocity() : Point3F::Zero; |
| 1099 | |
| 1100 | // Disable all simulation of the body... no collision or dynamics. |
| 1101 | mPhysicsRep->setSimulationEnabled( false ); |
| 1102 | |
| 1103 | // On the client side we remove it from the scene graph |
| 1104 | // to disable rendering and volume queries. |
| 1105 | if ( isClientObject() ) |
| 1106 | removeFromScene(); |
| 1107 | |
| 1108 | // Stop doing tick processing for this SceneObject. |
| 1109 | setProcessTick( false ); |
| 1110 | |
| 1111 | PhysicsShapeData *db = getDataBlock(); |
| 1112 | if ( !db ) |
| 1113 | return; |
| 1114 | |
| 1115 | const MatrixF &mat = getTransform(); |
| 1116 | if ( isServerObject() ) |
| 1117 | { |
| 1118 | // We only create the destroyed object on the server |
| 1119 | // and let ghosting deal with updating the client. |
| 1120 | |
| 1121 | if ( db->destroyedShape ) |
| 1122 | { |
| 1123 | mDestroyedShape = new PhysicsShape(); |
| 1124 | mDestroyedShape->setDataBlock( db->destroyedShape ); |
| 1125 | mDestroyedShape->setTransform( mat ); |
| 1126 | if ( !mDestroyedShape->registerObject() ) |
| 1127 | delete mDestroyedShape.getObject(); |
| 1128 | } |
| 1129 | |
| 1130 | return; |
| 1131 | } |
| 1132 | |
| 1133 | // Let the physics debris create itself. |
| 1134 | PhysicsDebris::create( db->debris, mat, lastLinVel ); |
| 1135 | |
| 1136 | if ( db->explosion ) |
| 1137 | { |
| 1138 | Explosion *splod = new Explosion(); |
| 1139 | splod->setDataBlock( db->explosion ); |
| 1140 | splod->setTransform( mat ); |
| 1141 | splod->setInitialState( getPosition(), mat.getUpVector(), 1.0f ); |
| 1142 | if ( !splod->registerObject() ) |
| 1143 | delete splod; |
| 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | void PhysicsShape::restore() |
no test coverage detected