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

Method packUpdate

Engine/source/environment/meshRoad.cpp:977–1056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

975}
976
977U32 MeshRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
978{
979 U32 retMask = Parent::packUpdate(con, mask, stream);
980
981 if ( stream->writeFlag( mask & MeshRoadMask ) )
982 {
983 // Write Object Transform.
984 stream->writeAffineTransform( mObjToWorld );
985
986 // Write Materials
987 stream->write( mMaterialName[0] );
988 stream->write( mMaterialName[1] );
989 stream->write( mMaterialName[2] );
990
991 stream->write( mTextureLength );
992 stream->write( mBreakAngle );
993 stream->write( mWidthSubdivisions );
994 }
995
996 if ( stream->writeFlag( mask & NodeMask ) )
997 {
998 const U32 nodeByteSize = 32; // Based on sending all of a node's parameters
999
1000 // Test if we can fit all of our nodes within the current stream.
1001 // We make sure we leave 100 bytes still free in the stream for whatever
1002 // may follow us.
1003 S32 allowedBytes = stream->getWriteByteSize() - 100;
1004 if ( stream->writeFlag( (nodeByteSize * mNodes.size()) < allowedBytes ) )
1005 {
1006 // All nodes should fit, so send them out now.
1007 stream->writeInt( mNodes.size(), 16 );
1008
1009 for ( U32 i = 0; i < mNodes.size(); i++ )
1010 {
1011 mathWrite( *stream, mNodes[i].point );
1012 stream->write( mNodes[i].width );
1013 stream->write( mNodes[i].depth );
1014 mathWrite( *stream, mNodes[i].normal );
1015 }
1016 }
1017 else
1018 {
1019 // There isn't enough space left in the stream for all of the
1020 // nodes. Batch them up into NetEvents.
1021 U32 id = gServerNodeListManager->nextListId();
1022 U32 count = 0;
1023 U32 index = 0;
1024 while (count < mNodes.size())
1025 {
1026 count += NodeListManager::smMaximumNodesPerEvent;
1027 if (count > mNodes.size())
1028 {
1029 count = mNodes.size();
1030 }
1031
1032 MeshRoadNodeEvent* event = new MeshRoadNodeEvent();
1033 event->mId = id;
1034 event->mTotalNodes = mNodes.size();

Callers

nothing calls this directly

Calls 10

mathWriteFunction · 0.85
writeAffineTransformMethod · 0.80
getWriteByteSizeMethod · 0.80
writeIntMethod · 0.80
nextListIdMethod · 0.80
postNetEventMethod · 0.80
writeFlagMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected