| 1166 | } |
| 1167 | |
| 1168 | void 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 | |
| 1208 | void TerrainBlock::onRemove() |
| 1209 | { |
nothing calls this directly
no test coverage detected