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

Method unpackUpdate

Engine/source/T3D/physics/physicsShape.cpp:516–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516void PhysicsShape::unpackUpdate( NetConnection *con, BitStream *stream )
517{
518 Parent::unpackUpdate( con, stream );
519
520 if ( stream->readFlag() ) // InitialUpdateMask
521 {
522 MatrixF mat;
523 stream->readAffineTransform( &mat );
524 setTransform( mat );
525 mPlayAmbient = stream->readFlag();
526
527 if ( isProperlyAdded() )
528 _initAmbient();
529
530 if ( stream->readFlag() )
531 {
532 if ( isProperlyAdded() )
533 {
534 // Destroy immediately if we've already been added
535 // to the scene.
536 destroy();
537 }
538 else
539 {
540 // Indicate the shape should be destroyed when the
541 // shape is added.
542 mDestroyed = true;
543 }
544 }
545
546 return;
547 }
548
549 if ( stream->readFlag() ) // StateMask
550 {
551 PhysicsState state;
552
553 // Read the encoded and compressed position... commonly only 6.25 bytes.
554 stream->readCompressedPoint( &state.position );
555
556 // Read the compressed quaternion... 3.5 bytes.
557 stream->readQuat( &state.orientation, 9 );
558
559 state.sleeping = stream->readFlag();
560 if ( !state.sleeping )
561 {
562 stream->readVector( &state.linVelocity, 1000.0f, 16, 9 );
563 stream->readVector( &state.angVelocity, 10.0f, 10, 9 );
564 }
565
566 if ( !smNoCorrections && mPhysicsRep && mPhysicsRep->isDynamic() && !mDestroyed )
567 {
568 // Set the new state on the physics object immediately.
569 mPhysicsRep->applyCorrection( state.getTransform() );
570
571 mPhysicsRep->setSleeping( state.sleeping );
572 if ( !state.sleeping )
573 {

Callers

nothing calls this directly

Calls 13

readFlagMethod · 0.80
readAffineTransformMethod · 0.80
readCompressedPointMethod · 0.80
readQuatMethod · 0.80
readVectorMethod · 0.80
destroyFunction · 0.50
isDynamicMethod · 0.45
applyCorrectionMethod · 0.45
getTransformMethod · 0.45
setSleepingMethod · 0.45
setLinVelocityMethod · 0.45
setAngVelocityMethod · 0.45

Tested by

no test coverage detected