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

Method packUpdate

Engine/source/environment/decalRoad.cpp:487–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485// NetObject
486
487U32 DecalRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
488{
489 // Pack Parent.
490 U32 retMask = Parent::packUpdate(con, mask, stream);
491
492 if ( stream->writeFlag( mask & DecalRoadMask ) )
493 {
494 // Write Texture Name.
495 PACK_ASSET(con, Material);
496
497 stream->write( mBreakAngle );
498
499 stream->write( mSegmentsPerBatch );
500
501 stream->write( mTextureLength );
502
503 stream->write( mRenderPriority );
504 }
505
506 if ( stream->writeFlag( mask & NodeMask ) )
507 {
508 //stream->writeInt( mNodes.size(), 16 );
509
510 //for ( U32 i = 0; i < mNodes.size(); i++ )
511 //{
512 // mathWrite( *stream, mNodes[i].point );
513 // stream->write( mNodes[i].width );
514 //}
515
516 const U32 nodeByteSize = 16; // Based on sending all of a node's parameters
517
518 // Test if we can fit all of our nodes within the current stream.
519 // We make sure we leave 100 bytes still free in the stream for whatever
520 // may follow us.
521 S32 allowedBytes = stream->getWriteByteSize() - 100;
522 if ( stream->writeFlag( (nodeByteSize * mNodes.size()) < allowedBytes ) )
523 {
524 // All nodes should fit, so send them out now.
525 stream->writeInt( mNodes.size(), 16 );
526
527 for ( U32 i = 0; i < mNodes.size(); i++ )
528 {
529 mathWrite( *stream, mNodes[i].point );
530 stream->write( mNodes[i].width );
531 }
532 }
533 else
534 {
535 // There isn't enough space left in the stream for all of the
536 // nodes. Batch them up into NetEvents.
537 U32 id = gServerNodeListManager->nextListId();
538 U32 count = 0;
539 U32 index = 0;
540 while (count < mNodes.size())
541 {
542 count += NodeListManager::smMaximumNodesPerEvent;
543 if (count > mNodes.size())
544 {

Callers

nothing calls this directly

Calls 9

mathWriteFunction · 0.85
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