MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / preload

Method preload

Engine/source/T3D/physics/physicsShape.cpp:271–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271bool PhysicsShapeData::preload( bool server, String &errorBuffer )
272{
273 if ( !Parent::preload( server, errorBuffer ) )
274 return false;
275
276 // If we don't have a physics plugin active then
277 // we have to fail completely.
278 if ( !PHYSICSMGR )
279 {
280 errorBuffer = "PhysicsShapeData::preload - No physics plugin is active!";
281 return false;
282 }
283
284 bool shapeError = false;
285
286 if (shapeName && shapeName[0])
287 {
288 // Resolve shapename
289 shape = ResourceManager::get().load(shapeName);
290 if (bool(shape) == false)
291 {
292 errorBuffer = String::ToString("PhysicsShapeData: Couldn't load shape \"%s\"", shapeName);
293 return false;
294 }
295 if (!server && !shape->preloadMaterialList(shape.getPath()) && NetConnection::filesWereDownloaded())
296 shapeError = true;
297
298 }
299
300 // Prepare the shared physics collision shape.
301 if ( !colShape && shape )
302 {
303 colShape = shape->buildColShape( false, Point3F::One );
304
305 // If we got here and didn't get a collision shape then
306 // we need to fail... can't have a shape without collision.
307 if ( !colShape )
308 {
309 //no collision so we create a simple box collision shape from the shapes bounds and alert the user
310 Con::warnf( "PhysicsShapeData::preload - No collision found for shape '%s', auto-creating one", shapeName );
311 Point3F halfWidth = shape->bounds.getExtents() * 0.5f;
312 colShape = PHYSICSMGR->createCollision();
313 MatrixF centerXfm(true);
314 centerXfm.setPosition(shape->bounds.getCenter());
315 colShape->addBox(halfWidth, centerXfm);
316 return true;
317 }
318 }
319
320 // My convex demcomposion test
321 /*
322 // Get the verts and triangles for the first visible detail.
323 ConcretePolyList polyList;
324 polyList.setTransform( &MatrixF::Identity, Point3F::One );
325 TSShapeInstance shapeInst( shape, false );
326 shapeInst.animate(0);
327 if ( !shapeInst.buildPolyList( &polyList, 0 ) )
328 return false;

Callers

nothing calls this directly

Calls 11

warnfFunction · 0.85
preloadMaterialListMethod · 0.80
buildColShapeMethod · 0.80
getExtentsMethod · 0.80
getFunction · 0.50
loadMethod · 0.45
getPathMethod · 0.45
createCollisionMethod · 0.45
setPositionMethod · 0.45
getCenterMethod · 0.45
addBoxMethod · 0.45

Tested by

no test coverage detected