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

Method _updatePhysics

Engine/source/terrain/terrData.cpp:1168–1206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1166}
1167
1168void TerrainBlock::_updatePhysics()
1169{
1170 if ( !PHYSICSMGR )
1171 return;
1172
1173 SAFE_DELETE( mPhysicsRep );
1174
1175 PhysicsCollision *colShape;
1176
1177 // If we can steal the collision shape from the local server
1178 // object then do so as it saves us alot of cpu time and memory.
1179 //
1180 // TODO: We should move this sharing down into TerrFile where
1181 // it probably belongs.
1182 //
1183 if ( getServerObject() )
1184 {
1185 TerrainBlock *serverTerrain = (TerrainBlock*)getServerObject();
1186 colShape = serverTerrain->mPhysicsRep->getColShape();
1187 }
1188 else
1189 {
1190 // Get empty state of each vert
1191 bool *holes = new bool[ getBlockSize() * getBlockSize() ];
1192 for ( U32 row = 0; row < getBlockSize(); row++ )
1193 for ( U32 column = 0; column < getBlockSize(); column++ )
1194 holes[ row + (column * getBlockSize()) ] = mFile->isEmptyAt( row, column );
1195
1196 colShape = PHYSICSMGR->createCollision();
1197 colShape->addHeightfield( mFile->getHeightMap().address(), holes, getBlockSize(), mSquareSize, MatrixF::Identity );
1198
1199 delete [] holes;
1200 }
1201
1202 PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
1203 mPhysicsRep = PHYSICSMGR->createBody();
1204 mPhysicsRep->init( colShape, 0, 0, this, world );
1205 mPhysicsRep->setTransform( getTransform() );
1206}
1207
1208void TerrainBlock::onRemove()
1209{

Callers

nothing calls this directly

Calls 9

isEmptyAtMethod · 0.80
getColShapeMethod · 0.45
createCollisionMethod · 0.45
addHeightfieldMethod · 0.45
addressMethod · 0.45
getWorldMethod · 0.45
createBodyMethod · 0.45
initMethod · 0.45
setTransformMethod · 0.45

Tested by

no test coverage detected