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

Method packUpdate

Engine/source/T3D/physics/physicsShape.cpp:456–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456U32 PhysicsShape::packUpdate( NetConnection *con, U32 mask, BitStream *stream )
457{
458 U32 retMask = Parent::packUpdate( con, mask, stream );
459
460 if ( stream->writeFlag( mask & InitialUpdateMask ) )
461 {
462 stream->writeAffineTransform( getTransform() );
463 stream->writeFlag( mPlayAmbient );
464
465 stream->writeFlag( mDestroyed );
466
467 return retMask;
468 }
469
470 // If we got here its not an initial update. So only send
471 // the least amount of data possible.
472
473 if ( stream->writeFlag( mask & StateMask ) )
474 {
475 // This will encode the position relative to the control
476 // object position.
477 //
478 // This will compress the position to as little as 6.25
479 // bytes if the position is within about 30 meters of the
480 // control object.
481 //
482 // Worst case its a full 12 bytes + 2 bits if the position
483 // is more than 500 meters from the control object.
484 //
485 stream->writeCompressedPoint( mState.position );
486
487 // Use only 3.5 bytes to send the orientation.
488 stream->writeQuat( mState.orientation, 9 );
489
490 // If the server object has been set to sleep then
491 // we don't need to send any velocity.
492 if ( !stream->writeFlag( mState.sleeping ) )
493 {
494 // This gives me ~0.015f resolution in velocity magnitude
495 // while only costing me 1 bit of the velocity is zero length,
496 // <5 bytes in normal cases, and <8 bytes if the velocity is
497 // greater than 1000.
498 AssertWarn( mState.linVelocity.len() < 1000.0f,
499 "PhysicsShape::packUpdate - The linVelocity is out of range!" );
500 stream->writeVector( mState.linVelocity, 1000.0f, 16, 9 );
501
502 // For angular velocity we get < 0.01f resolution in magnitude
503 // with the most common case being under 4 bytes.
504 AssertWarn( mState.angVelocity.len() < 10.0f,
505 "PhysicsShape::packUpdate - The angVelocity is out of range!" );
506 stream->writeVector( mState.angVelocity, 10.0f, 10, 9 );
507 }
508 }
509
510 if ( stream->writeFlag( mask & DamageMask ) )
511 stream->writeFlag( mDestroyed );
512
513 return retMask;

Callers

nothing calls this directly

Calls 6

writeAffineTransformMethod · 0.80
writeCompressedPointMethod · 0.80
writeQuatMethod · 0.80
writeVectorMethod · 0.80
writeFlagMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected