From 8250e4728d7ed371a91aec948d04fecec3ed838a Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 9 Jun 2014 14:58:45 -0400 Subject: [PATCH 01/17] Mount Process Order Fix 1 Added a controlling object check to GameBase::onMount() so mounted objects will process after objects controlling them. --- Engine/source/T3D/gameBase/gameBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()) { From 172e62a8f115b347b861ee27db18290662919c3d Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 9 Jun 2014 14:59:36 -0400 Subject: [PATCH 02/17] Mount Process Order Fix 2 Added a check to SceneObject::setProcessTick() to prevent objects that have mounts from being removed from the process list so the processAfter chain of the mounted objects is not broken. --- Engine/source/scene/sceneObject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From b5a957dfdc433aa795bc3337fd78c64d62d82389 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:46:25 -0400 Subject: [PATCH 03/17] ShapeBase Mounting Added mount transforms to ShapeBase --- Engine/source/T3D/shapeBase.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 ) From c39ca2c25ebf80538d3621f07f224b56e7b8cf35 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:47:42 -0400 Subject: [PATCH 04/17] StaticShape Mounting --- Engine/source/T3D/staticShape.cpp | 16 ---------------- Engine/source/T3D/staticShape.h | 1 - 2 files changed, 17 deletions(-) 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 6dd9d0432c..c6802a36fa 100644 --- a/Engine/source/T3D/staticShape.h +++ b/Engine/source/T3D/staticShape.h @@ -76,7 +76,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); From cd3b080526da6a24718db2f099f76bd6cb9857a4 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:48:47 -0400 Subject: [PATCH 05/17] Item Mounting --- Engine/source/T3D/item.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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 ) { From 3afd5461c6fa9ea8bd0c773a00a8c9260241077b Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:49:56 -0400 Subject: [PATCH 06/17] Camera Mounting --- Engine/source/T3D/camera.cpp | 16 ---------------- 1 file changed, 16 deletions(-) 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; From a285b7b07b3398a69748a5b0e5be17f10d740a2a Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:53:10 -0400 Subject: [PATCH 07/17] SpawnSphere Mounting --- Engine/source/T3D/missionMarker.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) 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() From 037ee82982c1f2c8b2a1d0bd873deb11b54bb4b0 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:55:58 -0400 Subject: [PATCH 08/17] Player Mounting Removes the z axis rotation for consistency with other mounted object types. --- Engine/source/T3D/player.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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); From a27fddc29a623d72ca1aec82065b416ceba8a1e1 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:58:40 -0400 Subject: [PATCH 09/17] Turret Mounting --- Engine/source/T3D/turret/turretShape.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) 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 ) From 937b8830e11594e60a3dd0f3dd65a4e06a0690b3 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 20:59:19 -0400 Subject: [PATCH 10/17] Vehicle Mounting --- Engine/source/T3D/vehicles/vehicle.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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]); From a9f77c4ffda1a3ddd9f8540ab454b4b681e266b6 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 21:11:15 -0400 Subject: [PATCH 11/17] TSStatic Mounting --- Engine/source/T3D/tsStatic.cpp | 113 +++++++++++++++++++++++---------- Engine/source/T3D/tsStatic.h | 2 + 2 files changed, 83 insertions(+), 32 deletions(-) diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 78240ce16a..6c401e9529 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,20 @@ 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 +800,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 +846,19 @@ 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 +1196,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; } From 16c547306fa113725cb247de752ceddbbe29d933 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Mon, 16 Jun 2014 21:13:27 -0400 Subject: [PATCH 12/17] Mounting demo script --- .../Full/game/scripts/server/mountTest.cs | 89 +++++++++++++++++++ .../Full/game/scripts/server/scriptExec.cs | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 Templates/Full/game/scripts/server/mountTest.cs diff --git a/Templates/Full/game/scripts/server/mountTest.cs b/Templates/Full/game/scripts/server/mountTest.cs new file mode 100644 index 0000000000..3ad3687133 --- /dev/null +++ b/Templates/Full/game/scripts/server/mountTest.cs @@ -0,0 +1,89 @@ +datablock StaticShapeData( StaticShapeBoulder ) +{ + shapeFile = "art/shapes/rocks/boulder.dts"; +}; + +datablock ItemData( ItemBoulder ) +{ + shapeFile = "art/shapes/rocks/boulder.dts"; +}; + +datablock WheeledVehicleData(CustomCheetah : CheetahCar) +{ + nameTag = 'Custom Cheetah'; +}; + +function CustomCheetah::onAdd(%this, %obj) +{ + CheetahCar::onAdd(%this, %obj); + %obj.unmountImage(%this.turretSlot); + + // StaticShape + %staticRock = new StaticShape() { + datablock = StaticShapeBoulder; + scale = "0.2 0.2 0.2"; + }; + %staticRock.setShapeName("StaticShape"); + %obj.staticRock = %staticRock; + %staticRock.car = %obj; + %obj.mountObject(%staticRock, %this.turretSlot, "1.4 0 .5 0 0 1 0"); + + // Item + %itemRock = new Item() { + datablock = ItemBoulder; + scale = "0.2 0.2 0.2"; + }; + %itemRock.setShapeName("Item"); + %obj.itemRock = %itemRock; + %itemRock.car = %obj; + %obj.mountObject(%itemRock, %this.turretSlot, "-1.4 0 .5 0 0 1 0"); + + // Vehicle + %vehicleMount = new WheeledVehicle() { + datablock = CheetahCar; + scale = "0.1 0.1 0.1"; + }; + %vehicleMount.setShapeName("MountedCheetah"); + %obj.vehicleMount = %vehicleMount; + %vehicleMount.car = %obj; + %obj.mountObject(%vehicleMount, %this.turretSlot, "0 0 -.17 0 0 1 1.57"); + + // TSStatic + %tsStaticMount = new TSStatic() { + shapeName = "art/shapes/rocks/boulder.dts"; + scale = "0.1 0.1 0.1"; + }; + %obj.tsStaticMount = %tsStaticMount; + %tsStaticMount.car = %obj; + %obj.mountObject(%tsStaticMount, %this.turretSlot, "0 1.4 0 0 0 1 0"); +} + +function CustomCheetah::onRemove(%this, %obj) +{ + if( isObject(%obj.tsStaticMount) ) + { + %obj.unmountObject(%obj.tsStaticMount); + %obj.tsStaticMount.delete(); + } + + if( isObject(%obj.vehicleMount) ) + { + %obj.unmountObject(%obj.vehicleMount); + %obj.vehicleMount.delete(); + } + + if( isObject(%obj.itemRock) ) + { + %obj.unmountObject(%obj.itemRock); + %obj.itemRock.delete(); + } + + if( isObject(%obj.staticRock) ) + { + %obj.unmountObject(%obj.staticRock); + %obj.staticRock.delete(); + } + + CheetahCar::onRemove(%this, %obj); +} + 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 +} From 8c2d5ee82cc05c5251650da9d581a31f3e5595e6 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Wed, 18 Jun 2014 19:32:39 -0400 Subject: [PATCH 13/17] RigidShape Mounting --- Engine/source/T3D/rigidShape.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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 -= From b8565b2b80d66775946e47315142f437ce8b9f1a Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Wed, 18 Jun 2014 19:33:50 -0400 Subject: [PATCH 14/17] Updated demo script --- Templates/Full/game/scripts/server/mountTest.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Templates/Full/game/scripts/server/mountTest.cs b/Templates/Full/game/scripts/server/mountTest.cs index 3ad3687133..4c05726b94 100644 --- a/Templates/Full/game/scripts/server/mountTest.cs +++ b/Templates/Full/game/scripts/server/mountTest.cs @@ -38,6 +38,16 @@ datablock WheeledVehicleData(CustomCheetah : CheetahCar) %itemRock.car = %obj; %obj.mountObject(%itemRock, %this.turretSlot, "-1.4 0 .5 0 0 1 0"); + // RigidShape + %rigidRock = new RigidShape() { + datablock = BouncingBoulder; + scale = "0.2 0.2 0.2"; + }; + %rigidRock.setShapeName("RigidShape"); + %obj.rigidRock = %itemRock; + %rigidRock.car = %obj; + %obj.mountObject(%rigidRock, %this.turretSlot, "0 1.4 .6 0 0 1 0"); + // Vehicle %vehicleMount = new WheeledVehicle() { datablock = CheetahCar; @@ -72,6 +82,12 @@ datablock WheeledVehicleData(CustomCheetah : CheetahCar) %obj.vehicleMount.delete(); } + if( isObject(%obj.rigidRock) ) + { + %obj.unmountObject(%obj.rigidRock); + %obj.rigidRock.delete(); + } + if( isObject(%obj.itemRock) ) { %obj.unmountObject(%obj.itemRock); From 161cdcb02d09f03fc419a7333f6bc1567d30bf1b Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 17 Jun 2016 10:34:53 -0500 Subject: [PATCH 15/17] Revert "Updated demo script" This reverts commit b288411d1f16d499f59ac89a5070dc88889ed043. --- Templates/Full/game/scripts/server/mountTest.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Templates/Full/game/scripts/server/mountTest.cs b/Templates/Full/game/scripts/server/mountTest.cs index 4c05726b94..3ad3687133 100644 --- a/Templates/Full/game/scripts/server/mountTest.cs +++ b/Templates/Full/game/scripts/server/mountTest.cs @@ -38,16 +38,6 @@ datablock WheeledVehicleData(CustomCheetah : CheetahCar) %itemRock.car = %obj; %obj.mountObject(%itemRock, %this.turretSlot, "-1.4 0 .5 0 0 1 0"); - // RigidShape - %rigidRock = new RigidShape() { - datablock = BouncingBoulder; - scale = "0.2 0.2 0.2"; - }; - %rigidRock.setShapeName("RigidShape"); - %obj.rigidRock = %itemRock; - %rigidRock.car = %obj; - %obj.mountObject(%rigidRock, %this.turretSlot, "0 1.4 .6 0 0 1 0"); - // Vehicle %vehicleMount = new WheeledVehicle() { datablock = CheetahCar; @@ -82,12 +72,6 @@ datablock WheeledVehicleData(CustomCheetah : CheetahCar) %obj.vehicleMount.delete(); } - if( isObject(%obj.rigidRock) ) - { - %obj.unmountObject(%obj.rigidRock); - %obj.rigidRock.delete(); - } - if( isObject(%obj.itemRock) ) { %obj.unmountObject(%obj.itemRock); From e9039b22616c2e3d880c52479d7ad8a0dcca8d3d Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 17 Jun 2016 10:35:02 -0500 Subject: [PATCH 16/17] Revert "Mounting demo script" This reverts commit fb1fb5b7f39e4acb5a474789443cbe66b00cc414. --- .../Full/game/scripts/server/mountTest.cs | 89 ------------------- 1 file changed, 89 deletions(-) delete mode 100644 Templates/Full/game/scripts/server/mountTest.cs diff --git a/Templates/Full/game/scripts/server/mountTest.cs b/Templates/Full/game/scripts/server/mountTest.cs deleted file mode 100644 index 3ad3687133..0000000000 --- a/Templates/Full/game/scripts/server/mountTest.cs +++ /dev/null @@ -1,89 +0,0 @@ -datablock StaticShapeData( StaticShapeBoulder ) -{ - shapeFile = "art/shapes/rocks/boulder.dts"; -}; - -datablock ItemData( ItemBoulder ) -{ - shapeFile = "art/shapes/rocks/boulder.dts"; -}; - -datablock WheeledVehicleData(CustomCheetah : CheetahCar) -{ - nameTag = 'Custom Cheetah'; -}; - -function CustomCheetah::onAdd(%this, %obj) -{ - CheetahCar::onAdd(%this, %obj); - %obj.unmountImage(%this.turretSlot); - - // StaticShape - %staticRock = new StaticShape() { - datablock = StaticShapeBoulder; - scale = "0.2 0.2 0.2"; - }; - %staticRock.setShapeName("StaticShape"); - %obj.staticRock = %staticRock; - %staticRock.car = %obj; - %obj.mountObject(%staticRock, %this.turretSlot, "1.4 0 .5 0 0 1 0"); - - // Item - %itemRock = new Item() { - datablock = ItemBoulder; - scale = "0.2 0.2 0.2"; - }; - %itemRock.setShapeName("Item"); - %obj.itemRock = %itemRock; - %itemRock.car = %obj; - %obj.mountObject(%itemRock, %this.turretSlot, "-1.4 0 .5 0 0 1 0"); - - // Vehicle - %vehicleMount = new WheeledVehicle() { - datablock = CheetahCar; - scale = "0.1 0.1 0.1"; - }; - %vehicleMount.setShapeName("MountedCheetah"); - %obj.vehicleMount = %vehicleMount; - %vehicleMount.car = %obj; - %obj.mountObject(%vehicleMount, %this.turretSlot, "0 0 -.17 0 0 1 1.57"); - - // TSStatic - %tsStaticMount = new TSStatic() { - shapeName = "art/shapes/rocks/boulder.dts"; - scale = "0.1 0.1 0.1"; - }; - %obj.tsStaticMount = %tsStaticMount; - %tsStaticMount.car = %obj; - %obj.mountObject(%tsStaticMount, %this.turretSlot, "0 1.4 0 0 0 1 0"); -} - -function CustomCheetah::onRemove(%this, %obj) -{ - if( isObject(%obj.tsStaticMount) ) - { - %obj.unmountObject(%obj.tsStaticMount); - %obj.tsStaticMount.delete(); - } - - if( isObject(%obj.vehicleMount) ) - { - %obj.unmountObject(%obj.vehicleMount); - %obj.vehicleMount.delete(); - } - - if( isObject(%obj.itemRock) ) - { - %obj.unmountObject(%obj.itemRock); - %obj.itemRock.delete(); - } - - if( isObject(%obj.staticRock) ) - { - %obj.unmountObject(%obj.staticRock); - %obj.staticRock.delete(); - } - - CheetahCar::onRemove(%this, %obj); -} - From 69244a8577d92a0662d8ac8a0aead851e8ef3f8c Mon Sep 17 00:00:00 2001 From: Areloch Date: Mon, 20 Jun 2016 13:14:19 -0500 Subject: [PATCH 17/17] Readded some missed brackets --- Engine/source/T3D/tsStatic.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 6c401e9529..6dd1e51e1f 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -764,20 +764,21 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream) if ( stream->writeFlag( mask & SkinMask ) ) con->packNetStringHandleU( stream, mSkinNameHandle ); - if ( stream->writeFlag( mask & AdvancedStaticOptionsMask ) ) + if (stream->writeFlag(mask & AdvancedStaticOptionsMask)) { - stream->writeString( mShapeName ); - stream->write( (U32)mDecalType ); + 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) ) { @@ -846,19 +847,20 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream) } } - if ( stream->readFlag() ) // AdvancedStaticOptionsMask + if (stream->readFlag()) // AdvancedStaticOptionsMask { mShapeName = stream->readSTString(); - stream->read( (U32*)&mDecalType ); + stream->read((U32*)&mDecalType); mAllowPlayerStep = stream->readFlag(); - mMeshCulling = stream->readFlag(); + mMeshCulling = stream->readFlag(); mUseOriginSort = stream->readFlag(); - stream->read( &mRenderNormalScalar ); + stream->read(&mRenderNormalScalar); - stream->read( &mForceDetail ); + stream->read(&mForceDetail); + } mUseAlphaFade = stream->readFlag(); if (mUseAlphaFade)