mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
enhanced-projectile
This commit is contained in:
parent
d78f5bc4e9
commit
c32c9557ab
2 changed files with 15 additions and 3 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
// Copyright (C) 2015 Faust Logic, Inc.
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "T3D/projectile.h"
|
#include "T3D/projectile.h"
|
||||||
|
|
||||||
|
|
@ -621,6 +622,9 @@ Projectile::Projectile()
|
||||||
mLightState.setLightInfo( mLight );
|
mLightState.setLightInfo( mLight );
|
||||||
|
|
||||||
mDataBlock = 0;
|
mDataBlock = 0;
|
||||||
|
ignoreSourceTimeout = false;
|
||||||
|
dynamicCollisionMask = csmDynamicCollisionMask;
|
||||||
|
staticCollisionMask = csmStaticCollisionMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Projectile::~Projectile()
|
Projectile::~Projectile()
|
||||||
|
|
@ -661,6 +665,7 @@ void Projectile::initPersistFields()
|
||||||
addField("sourceSlot", TypeS32, Offset(mSourceObjectSlot, Projectile),
|
addField("sourceSlot", TypeS32, Offset(mSourceObjectSlot, Projectile),
|
||||||
"@brief The sourceObject's weapon slot that the projectile originates from.\n\n");
|
"@brief The sourceObject's weapon slot that the projectile originates from.\n\n");
|
||||||
|
|
||||||
|
addField("ignoreSourceTimeout", TypeBool, Offset(ignoreSourceTimeout, Projectile));
|
||||||
endGroup("Source");
|
endGroup("Source");
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1140,7 +1145,7 @@ void Projectile::simulate( F32 dt )
|
||||||
// disable the source objects collision reponse for a short time while we
|
// disable the source objects collision reponse for a short time while we
|
||||||
// determine if the projectile is capable of moving from the old position
|
// determine if the projectile is capable of moving from the old position
|
||||||
// to the new position, otherwise we'll hit ourself
|
// to the new position, otherwise we'll hit ourself
|
||||||
bool disableSourceObjCollision = (mSourceObject.isValid() && mCurrTick <= SourceIdTimeoutTicks);
|
bool disableSourceObjCollision = (mSourceObject.isValid() && (ignoreSourceTimeout || mCurrTick <= SourceIdTimeoutTicks));
|
||||||
if ( disableSourceObjCollision )
|
if ( disableSourceObjCollision )
|
||||||
mSourceObject->disableCollision();
|
mSourceObject->disableCollision();
|
||||||
disableCollision();
|
disableCollision();
|
||||||
|
|
@ -1157,12 +1162,12 @@ void Projectile::simulate( F32 dt )
|
||||||
if ( mPhysicsWorld )
|
if ( mPhysicsWorld )
|
||||||
hit = mPhysicsWorld->castRay( oldPosition, newPosition, &rInfo, Point3F( newPosition - oldPosition) * mDataBlock->impactForce );
|
hit = mPhysicsWorld->castRay( oldPosition, newPosition, &rInfo, Point3F( newPosition - oldPosition) * mDataBlock->impactForce );
|
||||||
else
|
else
|
||||||
hit = getContainer()->castRay(oldPosition, newPosition, csmDynamicCollisionMask | csmStaticCollisionMask, &rInfo);
|
hit = getContainer()->castRay(oldPosition, newPosition, dynamicCollisionMask | staticCollisionMask, &rInfo);
|
||||||
|
|
||||||
if ( hit )
|
if ( hit )
|
||||||
{
|
{
|
||||||
// make sure the client knows to bounce
|
// make sure the client knows to bounce
|
||||||
if ( isServerObject() && ( rInfo.object->getTypeMask() & csmStaticCollisionMask ) == 0 )
|
if(isServerObject() && (rInfo.object->getTypeMask() & staticCollisionMask) == 0)
|
||||||
setMaskBits( BounceMask );
|
setMaskBits( BounceMask );
|
||||||
|
|
||||||
MatrixF xform( true );
|
MatrixF xform( true );
|
||||||
|
|
@ -1353,6 +1358,7 @@ U32 Projectile::packUpdate( NetConnection *con, U32 mask, BitStream *stream )
|
||||||
stream->writeRangedU32( U32(mSourceObjectSlot),
|
stream->writeRangedU32( U32(mSourceObjectSlot),
|
||||||
0,
|
0,
|
||||||
ShapeBase::MaxMountedImages - 1 );
|
ShapeBase::MaxMountedImages - 1 );
|
||||||
|
stream->writeFlag(ignoreSourceTimeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// have not recieved the ghost for the source object yet, try again later
|
// have not recieved the ghost for the source object yet, try again later
|
||||||
|
|
@ -1396,6 +1402,7 @@ void Projectile::unpackUpdate(NetConnection* con, BitStream* stream)
|
||||||
mSourceObjectId = stream->readRangedU32( 0, NetConnection::MaxGhostCount );
|
mSourceObjectId = stream->readRangedU32( 0, NetConnection::MaxGhostCount );
|
||||||
mSourceObjectSlot = stream->readRangedU32( 0, ShapeBase::MaxMountedImages - 1 );
|
mSourceObjectSlot = stream->readRangedU32( 0, ShapeBase::MaxMountedImages - 1 );
|
||||||
|
|
||||||
|
ignoreSourceTimeout = stream->readFlag();
|
||||||
NetObject* pObject = con->resolveGhost( mSourceObjectId );
|
NetObject* pObject = con->resolveGhost( mSourceObjectId );
|
||||||
if ( pObject != NULL )
|
if ( pObject != NULL )
|
||||||
mSourceObject = dynamic_cast<ShapeBase*>( pObject );
|
mSourceObject = dynamic_cast<ShapeBase*>( pObject );
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
// Copyright (C) 2015 Faust Logic, Inc.
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#ifndef _PROJECTILE_H_
|
#ifndef _PROJECTILE_H_
|
||||||
#define _PROJECTILE_H_
|
#define _PROJECTILE_H_
|
||||||
|
|
||||||
|
|
@ -286,6 +287,10 @@ protected:
|
||||||
Point3F mExplosionPosition;
|
Point3F mExplosionPosition;
|
||||||
Point3F mExplosionNormal;
|
Point3F mExplosionNormal;
|
||||||
U32 mCollideHitType;
|
U32 mCollideHitType;
|
||||||
|
public:
|
||||||
|
bool ignoreSourceTimeout;
|
||||||
|
U32 dynamicCollisionMask;
|
||||||
|
U32 staticCollisionMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PROJECTILE_H_
|
#endif // _PROJECTILE_H_
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue