mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
sceneobject xform transmission review
This commit is contained in:
parent
4579f327b4
commit
3ff3a5eef4
1 changed files with 54 additions and 73 deletions
|
|
@ -905,61 +905,47 @@ U32 SceneObject::packUpdate( NetConnection* conn, U32 mask, BitStream* stream )
|
||||||
if ( stream->writeFlag( mask & FlagMask ) )
|
if ( stream->writeFlag( mask & FlagMask ) )
|
||||||
stream->writeRangedU32( (U32)mObjectFlags, 0, getObjectFlagMax() );
|
stream->writeRangedU32( (U32)mObjectFlags, 0, getObjectFlagMax() );
|
||||||
|
|
||||||
// PATHSHAPE
|
|
||||||
//Begin attachment
|
|
||||||
retMask = 0; //retry mask
|
retMask = 0; //retry mask
|
||||||
|
|
||||||
if (stream->writeFlag(getParent() != NULL)) {
|
|
||||||
stream->writeAffineTransform(mGraph.objToParent);
|
|
||||||
}
|
|
||||||
if (stream->writeFlag(mask & MountedMask))
|
if (stream->writeFlag(mask & MountedMask))
|
||||||
{
|
{
|
||||||
// Check to see if we need to write an object ID
|
// Check to see if we need to write an object ID
|
||||||
if (stream->writeFlag(mGraph.parent)) {
|
if (stream->writeFlag(mGraph.parent))
|
||||||
|
{
|
||||||
S32 t = conn->getGhostIndex(mGraph.parent);
|
S32 t = conn->getGhostIndex(mGraph.parent);
|
||||||
// Check to see if we can actually ghost this...
|
// Check to see if we can actually ghost this...
|
||||||
if (t == -1) {
|
if (stream->writeFlag(t != -1))
|
||||||
// Cant, try again later
|
{
|
||||||
retMask |= MountedMask;
|
|
||||||
stream->writeFlag(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Can, write it.
|
// Can, write it.
|
||||||
stream->writeFlag(true);
|
|
||||||
stream->writeRangedU32(U32(t), 0, NetConnection::MaxGhostCount);
|
stream->writeRangedU32(U32(t), 0, NetConnection::MaxGhostCount);
|
||||||
stream->writeAffineTransform(mGraph.objToParent);
|
stream->writeAffineTransform(mGraph.objToParent);
|
||||||
//Con::errorf("%d: sent mounted on %d", getId(), mGraph.parent->getId());
|
//Con::errorf("%d: sent mounted on %d", getId(), mGraph.parent->getId());
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
|
||||||
// End of Attachment
|
|
||||||
// PATHSHAPE END
|
|
||||||
|
|
||||||
if ( mask & MountedMask )
|
|
||||||
{
|
|
||||||
if ( mMount.object )
|
|
||||||
{
|
|
||||||
S32 gIndex = conn->getGhostIndex( mMount.object );
|
|
||||||
|
|
||||||
if ( stream->writeFlag( gIndex != -1 ) )
|
|
||||||
{
|
{
|
||||||
stream->writeFlag( true );
|
// Cant, try again later
|
||||||
stream->writeInt( gIndex, NetConnection::GhostIdBitSize );
|
retMask |= MountedMask;
|
||||||
if ( stream->writeFlag( mMount.node != -1 ) )
|
}
|
||||||
stream->writeInt( mMount.node, NumMountPointBits );
|
}
|
||||||
mathWrite( *stream, mMount.xfm );
|
else if (stream->writeFlag(mMount.object))
|
||||||
|
{
|
||||||
|
S32 gIndex = conn->getGhostIndex(mMount.object);
|
||||||
|
|
||||||
|
if (stream->writeFlag(gIndex != -1))
|
||||||
|
{
|
||||||
|
stream->writeInt(gIndex, NetConnection::GhostIdBitSize);
|
||||||
|
if (stream->writeFlag(mMount.node != -1))
|
||||||
|
stream->writeInt(mMount.node, NumMountPointBits);
|
||||||
|
mathWrite(*stream, mMount.xfm);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// Will have to try again later
|
// Will have to try again later
|
||||||
retMask |= MountedMask;
|
retMask |= MountedMask;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
// Unmount if this isn't the initial packet
|
|
||||||
if ( stream->writeFlag( !(mask & InitialUpdateMask) ) )
|
|
||||||
stream->writeFlag( false );
|
|
||||||
}
|
}
|
||||||
else
|
else if (stream->writeFlag(getParent() != NULL)) //parent xform sync
|
||||||
stream->writeFlag( false );
|
{
|
||||||
|
stream->writeAffineTransform(mGraph.objToParent);
|
||||||
|
}
|
||||||
|
|
||||||
return retMask;
|
return retMask;
|
||||||
}
|
}
|
||||||
|
|
@ -974,15 +960,7 @@ void SceneObject::unpackUpdate( NetConnection* conn, BitStream* stream )
|
||||||
if ( stream->readFlag() )
|
if ( stream->readFlag() )
|
||||||
mObjectFlags = stream->readRangedU32( 0, getObjectFlagMax() );
|
mObjectFlags = stream->readRangedU32( 0, getObjectFlagMax() );
|
||||||
|
|
||||||
// PATHSHAPE
|
if (stream->readFlag())// MountedMask
|
||||||
// begin of attachment
|
|
||||||
if (stream->readFlag())
|
|
||||||
{
|
|
||||||
MatrixF m;
|
|
||||||
stream->readAffineTransform(&m);
|
|
||||||
mGraph.objToParent = m;
|
|
||||||
}
|
|
||||||
if (stream->readFlag())
|
|
||||||
{
|
{
|
||||||
// Check to see if we need to read an object ID
|
// Check to see if we need to read an object ID
|
||||||
if (stream->readFlag())
|
if (stream->readFlag())
|
||||||
|
|
@ -990,7 +968,7 @@ void SceneObject::unpackUpdate( NetConnection* conn, BitStream* stream )
|
||||||
// Check to see if we can actually ghost this...
|
// Check to see if we can actually ghost this...
|
||||||
if (stream->readFlag())
|
if (stream->readFlag())
|
||||||
{
|
{
|
||||||
GameBase *newParent = static_cast<GameBase*>(conn->resolveGhost(stream->readRangedU32(0, NetConnection::MaxGhostCount)));
|
GameBase* newParent = static_cast<GameBase*>(conn->resolveGhost(stream->readRangedU32(0, NetConnection::MaxGhostCount)));
|
||||||
MatrixF m;
|
MatrixF m;
|
||||||
stream->readAffineTransform(&m);
|
stream->readAffineTransform(&m);
|
||||||
|
|
||||||
|
|
@ -1001,39 +979,42 @@ void SceneObject::unpackUpdate( NetConnection* conn, BitStream* stream )
|
||||||
}
|
}
|
||||||
|
|
||||||
attachToParent(newParent, &m);
|
attachToParent(newParent, &m);
|
||||||
//Con::errorf("%d: got mounted on %d", getId(), mParentObject->getId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
attachToParent(NULL);
|
attachToParent(NULL);
|
||||||
}
|
|
||||||
}
|
|
||||||
// End of attachment
|
|
||||||
// PATHSHAPE END
|
|
||||||
|
|
||||||
// MountedMask
|
if (stream->readFlag()) //mounted to an object
|
||||||
if ( stream->readFlag() )
|
|
||||||
{
|
|
||||||
if ( stream->readFlag() )
|
|
||||||
{
|
|
||||||
S32 gIndex = stream->readInt( NetConnection::GhostIdBitSize );
|
|
||||||
SceneObject* obj = dynamic_cast<SceneObject*>( conn->resolveGhost( gIndex ) );
|
|
||||||
S32 node = -1;
|
|
||||||
if ( stream->readFlag() ) // node != -1
|
|
||||||
node = stream->readInt( NumMountPointBits );
|
|
||||||
MatrixF xfm;
|
|
||||||
mathRead( *stream, &xfm );
|
|
||||||
if ( !obj )
|
|
||||||
{
|
{
|
||||||
conn->setLastError( "Invalid packet from server." );
|
if (stream->readFlag()) //object was ghosted
|
||||||
return;
|
{
|
||||||
|
S32 gIndex = stream->readInt(NetConnection::GhostIdBitSize);
|
||||||
|
SceneObject* obj = dynamic_cast<SceneObject*>(conn->resolveGhost(gIndex));
|
||||||
|
S32 node = -1;
|
||||||
|
if (stream->readFlag()) // node != -1
|
||||||
|
node = stream->readInt(NumMountPointBits);
|
||||||
|
MatrixF xfm;
|
||||||
|
mathRead(*stream, &xfm);
|
||||||
|
if (!obj)
|
||||||
|
{
|
||||||
|
conn->setLastError("Invalid packet from server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj->mountObject(this, node, xfm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
obj->mountObject( this, node, xfm );
|
else
|
||||||
|
unmount();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
unmount();
|
|
||||||
}
|
}
|
||||||
|
else if (stream->readFlag()) //parent xform sync
|
||||||
|
{
|
||||||
|
MatrixF m;
|
||||||
|
stream->readAffineTransform(&m);
|
||||||
|
mGraph.objToParent = m;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue