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

Method packUpdate

Engine/source/environment/meshRoad.cpp:1410–1505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1408}
1409
1410U32 MeshRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
1411{
1412 U32 retMask = Parent::packUpdate(con, mask, stream);
1413
1414 if ( stream->writeFlag( mask & MeshRoadMask ) )
1415 {
1416 // Write Object Transform.
1417 stream->writeAffineTransform( mObjToWorld );
1418
1419 // Write Materials
1420 PACK_ASSET(con, TopMaterial);
1421 PACK_ASSET(con, BottomMaterial);
1422 PACK_ASSET(con, SideMaterial);
1423
1424 stream->write( mTextureLength );
1425 stream->write( mBreakAngle );
1426 stream->write( mWidthSubdivisions );
1427 }
1428
1429 if ( stream->writeFlag( mask & ProfileMask ) )
1430 {
1431 stream->writeInt( mSideProfile.mNodes.size(), 16 );
1432
1433 for( U32 i = 0; i < mSideProfile.mNodes.size(); i++ )
1434 {
1435 mathWrite( *stream, mSideProfile.mNodes[i].getPosition() );
1436 stream->writeFlag( mSideProfile.mNodes[i].isSmooth() );
1437
1438 if(i)
1439 stream->writeInt(mSideProfile.mSegMtrls[i-1], 3);
1440 else
1441 stream->writeInt(0, 3);
1442 }
1443 }
1444
1445 if ( stream->writeFlag( mask & NodeMask ) )
1446 {
1447 const U32 nodeByteSize = 32; // Based on sending all of a node's parameters
1448
1449 // Test if we can fit all of our nodes within the current stream.
1450 // We make sure we leave 100 bytes still free in the stream for whatever
1451 // may follow us.
1452 S32 allowedBytes = stream->getWriteByteSize() - 100;
1453 if ( stream->writeFlag( (nodeByteSize * mNodes.size()) < allowedBytes ) )
1454 {
1455 // All nodes should fit, so send them out now.
1456 stream->writeInt( mNodes.size(), 16 );
1457
1458 for ( U32 i = 0; i < mNodes.size(); i++ )
1459 {
1460 mathWrite( *stream, mNodes[i].point );
1461 stream->write( mNodes[i].width );
1462 stream->write( mNodes[i].depth );
1463 mathWrite( *stream, mNodes[i].normal );
1464 }
1465 }
1466 else
1467 {

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected