MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / destroy

Method destroy

Engine/source/T3D/physics/physicsShape.cpp:1090–1145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1088}
1089
1090void 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
1147void PhysicsShape::restore()

Callers 1

physicsShape.cppFile · 0.45

Calls 10

getPositionFunction · 0.85
setDataBlockMethod · 0.80
getUpVectorMethod · 0.80
isDynamicMethod · 0.45
getLinVelocityMethod · 0.45
setSimulationEnabledMethod · 0.45
setTransformMethod · 0.45
registerObjectMethod · 0.45
getObjectMethod · 0.45
setInitialStateMethod · 0.45

Tested by

no test coverage detected