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

Method packUpdate

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

Source from the content-addressed store, hash-verified

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