diff --git a/Engine/source/T3D/camera.cpp b/Engine/source/T3D/camera.cpp index 027bd308fb..59002d9bf9 100644 --- a/Engine/source/T3D/camera.cpp +++ b/Engine/source/T3D/camera.cpp @@ -495,13 +495,6 @@ void Camera::processTick(const Move* move) if ( isMounted() ) { - // Fetch Mount Transform. - MatrixF mat; - mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); - - // Apply. - setTransform( mat ); - // Update SceneContainer. updateContainer(); return; @@ -868,16 +861,7 @@ void Camera::interpolateTick(F32 dt) Parent::interpolateTick(dt); if ( isMounted() ) - { - // Fetch Mount Transform. - MatrixF mat; - mMount.object->getRenderMountTransform( dt, mMount.node, mMount.xfm, &mat ); - - // Apply. - setRenderTransform( mat ); - return; - } Point3F rot = mDelta.rot + mDelta.rotVec * dt; diff --git a/Engine/source/T3D/gameBase/gameBase.cpp b/Engine/source/T3D/gameBase/gameBase.cpp index baede5c499..7cc745c11c 100644 --- a/Engine/source/T3D/gameBase/gameBase.cpp +++ b/Engine/source/T3D/gameBase/gameBase.cpp @@ -590,7 +590,7 @@ void GameBase::onMount( SceneObject *obj, S32 node ) // Are we mounting to a GameBase object? GameBase *gbaseObj = dynamic_cast( obj ); - if ( gbaseObj && gbaseObj->getControlObject() != this ) + if ( gbaseObj && gbaseObj->getControlObject() != this && gbaseObj->getControllingObject() != this) processAfter( gbaseObj ); if (!isGhost()) { diff --git a/Engine/source/T3D/item.cpp b/Engine/source/T3D/item.cpp index c946ffa00b..8970e3e3cc 100644 --- a/Engine/source/T3D/item.cpp +++ b/Engine/source/T3D/item.cpp @@ -556,6 +556,9 @@ void Item::processTick(const Move* move) { Parent::processTick(move); + if ( isMounted() ) + return; + // if (mCollisionObject && !--mCollisionTimeout) mCollisionObject = 0; @@ -606,6 +609,8 @@ void Item::processTick(const Move* move) void Item::interpolateTick(F32 dt) { Parent::interpolateTick(dt); + if ( isMounted() ) + return; // Client side interpolation Point3F pos = delta.pos + delta.posVec * dt; @@ -1365,6 +1370,8 @@ void Item::buildConvex(const Box3F& box, Convex* convex) void Item::advanceTime(F32 dt) { Parent::advanceTime(dt); + if ( isMounted() ) + return; if( mRotate ) { diff --git a/Engine/source/T3D/missionMarker.cpp b/Engine/source/T3D/missionMarker.cpp index 151cd73366..3a043b0951 100644 --- a/Engine/source/T3D/missionMarker.cpp +++ b/Engine/source/T3D/missionMarker.cpp @@ -442,22 +442,12 @@ void SpawnSphere::unpackUpdate(NetConnection * con, BitStream * stream) void SpawnSphere::processTick( const Move *move ) { - if ( isServerObject() && isMounted() ) - { - MatrixF mat( true ); - mMount.object->getRenderMountTransform( 0.f, mMount.node, mMount.xfm, &mat ); - setTransform( mat ); - } + Parent::processTick( move ); } void SpawnSphere::advanceTime( F32 timeDelta ) { - if ( isMounted() ) - { - MatrixF mat( true ); - mMount.object->getRenderMountTransform( 0.f, mMount.node, mMount.xfm, &mat ); - setTransform( mat ); - } + Parent::advanceTime( timeDelta ); } void SpawnSphere::initPersistFields() diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 5f670abedc..2e365960d1 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -5316,10 +5316,10 @@ void Player::setPosition(const Point3F& pos,const Point3F& rot) MatrixF mat; if (isMounted()) { // Use transform from mounted object - MatrixF nmat,zrot; - mMount.object->getMountTransform( mMount.node, mMount.xfm, &nmat ); - zrot.set(EulerF(0.0f, 0.0f, rot.z)); - mat.mul(nmat,zrot); + //MatrixF nmat,zrot; + mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); + //zrot.set(EulerF(0.0f, 0.0f, rot.z)); + //mat.mul(nmat,zrot); } else { mat.set(EulerF(0.0f, 0.0f, rot.z)); @@ -5338,10 +5338,10 @@ void Player::setRenderPosition(const Point3F& pos, const Point3F& rot, F32 dt) MatrixF mat; if (isMounted()) { // Use transform from mounted object - MatrixF nmat,zrot; - mMount.object->getRenderMountTransform( dt, mMount.node, mMount.xfm, &nmat ); - zrot.set(EulerF(0.0f, 0.0f, rot.z)); - mat.mul(nmat,zrot); + //MatrixF nmat,zrot; + mMount.object->getRenderMountTransform( dt, mMount.node, mMount.xfm, &mat ); + //zrot.set(EulerF(0.0f, 0.0f, rot.z)); + //mat.mul(nmat,zrot); } else { EulerF orient(0.0f, 0.0f, rot.z); diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index 6660486481..dab7d3627e 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -732,6 +732,8 @@ void RigidShape::onRemove() void RigidShape::processTick(const Move* move) { Parent::processTick(move); + if ( isMounted() ) + return; // Warp to catch up to server if (mDelta.warpCount < mDelta.warpTicks) @@ -795,6 +797,8 @@ void RigidShape::processTick(const Move* move) void RigidShape::interpolateTick(F32 dt) { Parent::interpolateTick(dt); + if ( isMounted() ) + return; if(dt == 0.0f) setRenderPosition(mDelta.pos, mDelta.rot[1]); @@ -814,6 +818,9 @@ void RigidShape::advanceTime(F32 dt) updateFroth(dt); + if ( isMounted() ) + return; + // Update 3rd person camera offset. Camera update is done // here as it's a client side only animation. mCameraOffset -= diff --git a/Engine/source/T3D/shapeBase.cpp b/Engine/source/T3D/shapeBase.cpp index 6f40cc134d..4bca5f23bf 100644 --- a/Engine/source/T3D/shapeBase.cpp +++ b/Engine/source/T3D/shapeBase.cpp @@ -1324,6 +1324,12 @@ void ShapeBase::processTick(const Move* move) if (mWhiteOut <= 0.0) mWhiteOut = 0.0; } + + if (isMounted()) { + MatrixF mat; + mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); + Parent::setTransform(mat); + } } void ShapeBase::advanceTime(F32 dt) @@ -1382,6 +1388,12 @@ void ShapeBase::advanceTime(F32 dt) mFadeVal = 1 - mFadeVal; } } + + if (isMounted()) { + MatrixF mat; + mMount.object->getRenderMountTransform( 0.0f, mMount.node, mMount.xfm, &mat ); + Parent::setRenderTransform(mat); + } } void ShapeBase::setControllingClient( GameConnection* client ) diff --git a/Engine/source/T3D/staticShape.cpp b/Engine/source/T3D/staticShape.cpp index 0f882824a8..ffad91dd33 100644 --- a/Engine/source/T3D/staticShape.cpp +++ b/Engine/source/T3D/staticShape.cpp @@ -232,22 +232,6 @@ void StaticShape::processTick(const Move* move) setImageTriggerState(0,move->trigger[0]); setImageTriggerState(1,move->trigger[1]); } - - if (isMounted()) { - MatrixF mat; - mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); - Parent::setTransform(mat); - Parent::setRenderTransform(mat); - } -} - -void StaticShape::interpolateTick(F32 delta) -{ - if (isMounted()) { - MatrixF mat; - mMount.object->getRenderMountTransform( delta, mMount.node, mMount.xfm, &mat ); - Parent::setRenderTransform(mat); - } } void StaticShape::setTransform(const MatrixF& mat) diff --git a/Engine/source/T3D/staticShape.h b/Engine/source/T3D/staticShape.h index caf8402d6e..86aebda137 100644 --- a/Engine/source/T3D/staticShape.h +++ b/Engine/source/T3D/staticShape.h @@ -75,7 +75,6 @@ class StaticShape: public ShapeBase bool onNewDataBlock(GameBaseData *dptr, bool reload); void processTick(const Move *move); - void interpolateTick(F32 delta); void setTransform(const MatrixF &mat); U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream); diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 78240ce16a..6dd1e51e1f 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -520,10 +520,15 @@ void TSStatic::reSkin() void TSStatic::processTick( const Move *move ) { - AssertFatal( mPlayAmbient && mAmbientThread, "TSSTatic::adanceTime called with nothing to play." ); - - if ( isServerObject() ) + if ( isServerObject() && mPlayAmbient && mAmbientThread ) mShapeInstance->advanceTime( TickSec, mAmbientThread ); + + if ( isMounted() ) + { + MatrixF mat( true ); + mMount.object->getMountTransform(mMount.node, mMount.xfm, &mat ); + setTransform( mat ); + } } void TSStatic::interpolateTick( F32 delta ) @@ -532,14 +537,20 @@ void TSStatic::interpolateTick( F32 delta ) void TSStatic::advanceTime( F32 dt ) { - AssertFatal( mPlayAmbient && mAmbientThread, "TSSTatic::advanceTime called with nothing to play." ); - - mShapeInstance->advanceTime( dt, mAmbientThread ); + if ( mPlayAmbient && mAmbientThread ) + mShapeInstance->advanceTime( dt, mAmbientThread ); + + if ( isMounted() ) + { + MatrixF mat( true ); + mMount.object->getRenderMountTransform( dt, mMount.node, mMount.xfm, &mat ); + setRenderTransform( mat ); + } } void TSStatic::_updateShouldTick() { - bool shouldTick = mPlayAmbient && mAmbientThread; + bool shouldTick = (mPlayAmbient && mAmbientThread) || isMounted(); if ( isTicking() != shouldTick ) setProcessTick( shouldTick ); @@ -708,12 +719,15 @@ void TSStatic::onScaleChanged() else _updatePhysics(); } + + setMaskBits( ScaleMask ); } void TSStatic::setTransform(const MatrixF & mat) { Parent::setTransform(mat); - setMaskBits( TransformMask ); + if ( !isMounted() ) + setMaskBits( TransformMask ); if ( mPhysicsRep ) mPhysicsRep->setTransform( mat ); @@ -734,9 +748,15 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream) { U32 retMask = Parent::packUpdate(con, mask, stream); - mathWrite( *stream, getTransform() ); - mathWrite( *stream, getScale() ); - stream->writeString( mShapeName ); + if ( stream->writeFlag( mask & TransformMask ) ) + mathWrite( *stream, getTransform() ); + + if ( stream->writeFlag( mask & ScaleMask ) ) + { + // Only write one bit if the scale is one. + if ( stream->writeFlag( mObjScale != Point3F::One ) ) + mathWrite( *stream, mObjScale ); + } if ( stream->writeFlag( mask & UpdateCollisionMask ) ) stream->write( (U32)mCollisionType ); @@ -744,17 +764,21 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream) if ( stream->writeFlag( mask & SkinMask ) ) con->packNetStringHandleU( stream, mSkinNameHandle ); - stream->write( (U32)mDecalType ); + if (stream->writeFlag(mask & AdvancedStaticOptionsMask)) + { + stream->writeString(mShapeName); + stream->write((U32)mDecalType); - stream->writeFlag( mAllowPlayerStep ); - stream->writeFlag( mMeshCulling ); - stream->writeFlag( mUseOriginSort ); + stream->writeFlag(mAllowPlayerStep); + stream->writeFlag(mMeshCulling); + stream->writeFlag(mUseOriginSort); - stream->write( mRenderNormalScalar ); + stream->write(mRenderNormalScalar); - stream->write( mForceDetail ); + stream->write(mForceDetail); - stream->writeFlag( mPlayAmbient ); + stream->writeFlag(mPlayAmbient); + } if ( stream->writeFlag(mUseAlphaFade) ) { @@ -777,14 +801,25 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream) { Parent::unpackUpdate(con, stream); - MatrixF mat; - Point3F scale; - mathRead( *stream, &mat ); - mathRead( *stream, &scale ); - setScale( scale); - setTransform(mat); + if ( stream->readFlag() ) // TransformMask + { + MatrixF mat; + mathRead( *stream, &mat ); + setTransform(mat); + setRenderTransform(mat); + } - mShapeName = stream->readSTString(); + if ( stream->readFlag() ) // ScaleMask + { + if ( stream->readFlag() ) + { + VectorF scale; + mathRead( *stream, &scale ); + setScale( scale ); + } + else + setScale( Point3F::One ); + } if ( stream->readFlag() ) // UpdateCollisionMask { @@ -812,17 +847,20 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream) } } - stream->read( (U32*)&mDecalType ); + if (stream->readFlag()) // AdvancedStaticOptionsMask + { + mShapeName = stream->readSTString(); - mAllowPlayerStep = stream->readFlag(); - mMeshCulling = stream->readFlag(); - mUseOriginSort = stream->readFlag(); + stream->read((U32*)&mDecalType); - stream->read( &mRenderNormalScalar ); + mAllowPlayerStep = stream->readFlag(); + mMeshCulling = stream->readFlag(); + mUseOriginSort = stream->readFlag(); - stream->read( &mForceDetail ); + stream->read(&mRenderNormalScalar); - mPlayAmbient = stream->readFlag(); + stream->read(&mForceDetail); + } mUseAlphaFade = stream->readFlag(); if (mUseAlphaFade) @@ -1160,6 +1198,19 @@ void TSStaticPolysoupConvex::getFeatures(const MatrixF& mat,const VectorF& n, Co // All done! } +void TSStatic::onMount( SceneObject *obj, S32 node ) +{ + Parent::onMount(obj, node); + _updateShouldTick(); +} + +void TSStatic::onUnmount( SceneObject *obj, S32 node ) +{ + Parent::onUnmount( obj, node ); + setMaskBits( TransformMask ); + _updateShouldTick(); +} + //------------------------------------------------------------------------ //These functions are duplicated in tsStatic and shapeBase. //They each function a little differently; but achieve the same purpose of gathering diff --git a/Engine/source/T3D/tsStatic.h b/Engine/source/T3D/tsStatic.h index 5bf4b53534..57a7fc695b 100644 --- a/Engine/source/T3D/tsStatic.h +++ b/Engine/source/T3D/tsStatic.h @@ -218,6 +218,8 @@ class TSStatic : public SceneObject void onScaleChanged(); void prepRenderImage( SceneRenderState *state ); void inspectPostApply(); + virtual void onMount( SceneObject *obj, S32 node ); + virtual void onUnmount( SceneObject *obj, S32 node ); /// The type of mesh data use for collision queries. MeshType getCollisionType() const { return mCollisionType; } diff --git a/Engine/source/T3D/turret/turretShape.cpp b/Engine/source/T3D/turret/turretShape.cpp index 13aa42bf16..dea5536996 100644 --- a/Engine/source/T3D/turret/turretShape.cpp +++ b/Engine/source/T3D/turret/turretShape.cpp @@ -632,13 +632,6 @@ void TurretShape::processTick(const Move* move) if (!isGhost()) updateAnimation(TickSec); - if (isMounted()) { - MatrixF mat; - mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); - ShapeBase::setTransform(mat); - ShapeBase::setRenderTransform(mat); - } - updateMove(move); } @@ -679,19 +672,11 @@ void TurretShape::advanceTime(F32 dt) } } - // If there is a recoil or image-based thread then - // we also need to update the nodes. - if (mRecoilThread || mImageStateThread) - updateNodes = true; - Parent::advanceTime(dt); updateAnimation(dt); - if (updateNodes) - { - _updateNodes(mRot); - } + _setRotation(mRot); } void TurretShape::setTransform( const MatrixF& mat ) diff --git a/Engine/source/T3D/vehicles/vehicle.cpp b/Engine/source/T3D/vehicles/vehicle.cpp index b6516fc3f4..5533099b33 100644 --- a/Engine/source/T3D/vehicles/vehicle.cpp +++ b/Engine/source/T3D/vehicles/vehicle.cpp @@ -859,6 +859,8 @@ void Vehicle::processTick(const Move* move) PROFILE_SCOPE( Vehicle_ProcessTick ); Parent::processTick(move); + if ( isMounted() ) + return; // Warp to catch up to server if (mDelta.warpCount < mDelta.warpTicks) @@ -929,6 +931,8 @@ void Vehicle::interpolateTick(F32 dt) PROFILE_SCOPE( Vehicle_InterpolateTick ); Parent::interpolateTick(dt); + if ( isMounted() ) + return; if(dt == 0.0f) setRenderPosition(mDelta.pos, mDelta.rot[1]); diff --git a/Engine/source/scene/sceneObject.cpp b/Engine/source/scene/sceneObject.cpp index 1d16377af3..6bd7966079 100644 --- a/Engine/source/scene/sceneObject.cpp +++ b/Engine/source/scene/sceneObject.cpp @@ -945,7 +945,8 @@ void SceneObject::setProcessTick( bool t ) if ( mProcessTick ) { - plUnlink(); + if ( !getMountedObjectCount() ) + plUnlink(); // Only unlink if there is nothing mounted to us mProcessTick = false; } else diff --git a/Templates/Full/game/scripts/server/scriptExec.cs b/Templates/Full/game/scripts/server/scriptExec.cs index d48e268e72..f6eb29b7de 100644 --- a/Templates/Full/game/scripts/server/scriptExec.cs +++ b/Templates/Full/game/scripts/server/scriptExec.cs @@ -77,4 +77,4 @@ { exec("./gameObjects/GameObjectManager.cs"); execGameObjects(); -} \ No newline at end of file +}