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

Method _updatePhysics

Engine/source/T3D/item.cpp:377–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377void Item::_updatePhysics()
378{
379 SAFE_DELETE( mPhysicsRep );
380
381 if ( !PHYSICSMGR )
382 return;
383
384 if (mDataBlock->simpleServerCollision)
385 {
386 // We only need the trigger on the server.
387 if ( isServerObject() )
388 {
389 PhysicsCollision *colShape = PHYSICSMGR->createCollision();
390 colShape->addBox( mObjBox.getExtents() * 0.5f, MatrixF::Identity );
391
392 PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
393 mPhysicsRep = PHYSICSMGR->createBody();
394 mPhysicsRep->init( colShape, 0, PhysicsBody::BF_TRIGGER | PhysicsBody::BF_KINEMATIC, this, world );
395 mPhysicsRep->setTransform( getTransform() );
396 }
397 }
398 else
399 {
400 if ( !mShapeInstance )
401 return;
402
403 PhysicsCollision* colShape = mShapeInstance->getShape()->buildColShape( false, getScale() );
404
405 if ( colShape )
406 {
407 PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
408 mPhysicsRep = PHYSICSMGR->createBody();
409 mPhysicsRep->init( colShape, 0, PhysicsBody::BF_KINEMATIC, this, world );
410 mPhysicsRep->setTransform( getTransform() );
411 }
412 }
413}
414
415bool Item::onNewDataBlock( GameBaseData *dptr, bool reload )
416{

Callers

nothing calls this directly

Calls 9

getExtentsMethod · 0.80
buildColShapeMethod · 0.80
createCollisionMethod · 0.45
addBoxMethod · 0.45
getWorldMethod · 0.45
createBodyMethod · 0.45
initMethod · 0.45
setTransformMethod · 0.45
getShapeMethod · 0.45

Tested by

no test coverage detected