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

Method preload

Engine/source/T3D/physics/physicsShape.cpp:270–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

notNullMethod · 0.80
preloadMaterialListMethod · 0.80
buildColShapeMethod · 0.80
getExtentsMethod · 0.80
warnfFunction · 0.50
getPathMethod · 0.45
createCollisionMethod · 0.45
setPositionMethod · 0.45
getCenterMethod · 0.45
addBoxMethod · 0.45

Tested by

no test coverage detected