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

Method packUpdate

Engine/source/afx/afxMagicMissile.cpp:1548–1610  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1546
1547//--------------------------------------------------------------------------
1548U32 afxMagicMissile::packUpdate(NetConnection* con, U32 mask, BitStream* stream)
1549{
1550 U32 retMask = Parent::packUpdate( con, mask, stream );
1551
1552 const bool isInitalUpdate = mask & GameBase::InitialUpdateMask;
1553
1554 // InitialUpdateMask
1555 if ( stream->writeFlag( isInitalUpdate ) )
1556 {
1557 Point3F pos;
1558 getTransform().getColumn( 3, &pos );
1559 stream->writeCompressedPoint( pos );
1560 F32 len = mCurrVelocity.len();
1561
1562 if ( stream->writeFlag( len > 0.02 ) )
1563 {
1564 Point3F outVel = mCurrVelocity;
1565 outVel *= 1 / len;
1566 stream->writeNormalVector( outVel, 10 );
1567 len *= 32.0; // 5 bits for fraction
1568
1569 if ( len > 8191 )
1570 len = 8191;
1571
1572 stream->writeInt( (S32)len, 13 );
1573 }
1574
1575 stream->writeRangedU32( mCurrTick, 0, afxMagicMissileData::MaxLifetimeTicks );
1576
1577 if (choreographer)
1578 {
1579 S32 ghostIndex = con->getGhostIndex( choreographer );
1580 if ( stream->writeFlag( ghostIndex != -1 ) )
1581 {
1582 stream->writeRangedU32( U32(ghostIndex),
1583 0,
1584 NetConnection::MaxGhostCount );
1585 }
1586 else
1587 // have not recieved the ghost for the source object yet, try again later
1588 retMask |= GameBase::InitialUpdateMask;
1589 }
1590 else
1591 stream->writeFlag( false );
1592 }
1593
1594 // impact update
1595 if (stream->writeFlag(mask & ImpactMask))
1596 {
1597 mathWrite(*stream, mCurrPosition);
1598 mathWrite(*stream, mCurrVelocity);
1599 stream->writeFlag(did_impact);
1600 }
1601
1602 // guided update
1603 if (stream->writeFlag(mask & GuideMask))
1604 {
1605 mathWrite(*stream, mCurrPosition);

Callers

nothing calls this directly

Calls 10

mathWriteFunction · 0.85
getColumnMethod · 0.80
writeCompressedPointMethod · 0.80
writeNormalVectorMethod · 0.80
writeIntMethod · 0.80
writeRangedU32Method · 0.80
getGhostIndexMethod · 0.80
U32Enum · 0.50
writeFlagMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected