Merge branch 'development' of https://github.com/GarageGames/Torque3D into AIExtracts

Conflicts:
	Engine/source/T3D/aiPlayer.cpp
This commit is contained in:
Azaezel 2016-03-02 10:59:10 -06:00
commit 262cc4bac1
293 changed files with 11902 additions and 2097 deletions

View file

@ -564,6 +564,21 @@ bool AIPlayer::getAIMove(Move *movePtr)
}
}
Pose desiredPose = mPose;
if ( mSwimming )
desiredPose = SwimPose;
else if ( mAiPose == 1 && canCrouch() )
desiredPose = CrouchPose;
else if ( mAiPose == 2 && canProne() )
desiredPose = PronePose;
else if ( mAiPose == 3 && canSprint() )
desiredPose = SprintPose;
else if ( canStand() )
desiredPose = StandPose;
setPose( desiredPose );
// Replicate the trigger state into the move so that
// triggers can be controlled from scripts.
for( U32 i = 0; i < MaxTriggerKeys; i++ )
@ -592,12 +607,24 @@ bool AIPlayer::getAIMove(Move *movePtr)
return true;
}
void AIPlayer::updateMove(const Move* move)
void AIPlayer::updateMove(const Move* move)
{
if (!getControllingClient() && isGhost())
return;
Parent::updateMove(move);
}
void AIPlayer::setAiPose( S32 pose )
{
if (!getControllingClient() && isGhost())
return;
mAiPose = pose;
}
Parent::updateMove(move);
S32 AIPlayer::getAiPose()
{
return mAiPose;
}
/**
@ -1397,3 +1424,18 @@ DefineEngineMethod(AIPlayer, getTargetDistance, bool, (ShapeBase* obj, bool chec
{
return object->getTargetDistance(obj, checkEnabled);
}
DefineEngineMethod( AIPlayer, setAiPose, void, ( S32 pose ),,
"@brief Sets the AiPose for an AI object.\n"
"@param pose StandPose=0, CrouchPose=1, PronePose=2, SprintPose=3.\n"
"Uses the new AiPose variable from shapebase (as defined in its PlayerData datablock).\n")
{
object->setAiPose(pose);
}
DefineEngineMethod( AIPlayer, getAiPose, S32, (),,
"@brief Get the object's current AiPose.\n"
"@return StandPose=0, CrouchPose=1, PronePose=2, SprintPose=3.\n")
{
return object->getAiPose();
}

View file

@ -182,7 +182,9 @@ public:
void setMoveDestination( const Point3F &location, bool slowdown );
Point3F getMoveDestination() const { return mMoveDestination; }
void stopMove();
void setAiPose( S32 pose );
S32 getAiPose();
// Trigger sets/gets
void setMoveTrigger( U32 slot, const bool isSet = true );
bool getMoveTrigger( U32 slot ) const;

View file

@ -39,7 +39,7 @@
#endif
#ifndef _TSSHAPE_H_
#include "ts/TSShape.h"
#include "ts/tsShape.h"
#endif
#ifndef __RESOURCE_H__
#include "core/resource.h"

View file

@ -284,6 +284,7 @@ void DecalData::unpackData( BitStream *stream )
Parent::unpackData( stream );
stream->read( &lookupName );
assignName(lookupName);
stream->read( &size );
stream->read( &materialName );
_updateMaterial();

View file

@ -1744,3 +1744,48 @@ DefineEngineFunction( decalManagerRemoveDecal, bool, ( S32 decalID ),,
gDecalManager->removeDecal(inst);
return true;
}
DefineEngineFunction( decalManagerEditDecal, bool, ( S32 decalID, Point3F pos, Point3F normal, F32 rotAroundNormal, F32 decalScale ),,
"Edit specified decal of the decal manager.\n"
"@param decalID ID of the decal to edit.\n"
"@param pos World position for the decal.\n"
"@param normal Decal normal vector (if the decal was a tire lying flat on a "
"surface, this is the vector pointing in the direction of the axle).\n"
"@param rotAroundNormal Angle (in radians) to rotate this decal around its normal vector.\n"
"@param decalScale Scale factor applied to the decal.\n"
"@return Returns true if successful, false if decalID not found.\n"
"" )
{
DecalInstance *decalInstance = gDecalManager->getDecal( decalID );
if( !decalInstance )
return false;
//Internally we need Point3F tangent instead of the user friendly F32 rotAroundNormal
MatrixF mat( true );
MathUtils::getMatrixFromUpVector( normal, &mat );
AngAxisF rot( normal, rotAroundNormal );
MatrixF rotmat;
rot.setMatrix( &rotmat );
mat.mul( rotmat );
Point3F tangent;
mat.getColumn( 1, &tangent );
//if everything is unchanged just do nothing and return "everything is ok"
if ( pos.equal(decalInstance->mPosition) &&
normal.equal(decalInstance->mNormal) &&
tangent.equal(decalInstance->mTangent) &&
mFabs( decalInstance->mSize - (decalInstance->mDataBlock->size * decalScale) ) < POINT_EPSILON )
return true;
decalInstance->mPosition = pos;
decalInstance->mNormal = normal;
decalInstance->mTangent = tangent;
decalInstance->mSize = decalInstance->mDataBlock->size * decalScale;
gDecalManager->clipDecal( decalInstance, NULL, NULL);
gDecalManager->notifyDecalModified( decalInstance );
return true;
}

View file

@ -426,7 +426,7 @@ void fxFoliageReplicator::CreateFoliage(void)
Point3F MaxPoint( 0.5, 0.5, 0.5 );
// Check Host.
AssertFatal(isClientObject(), "Trying to create Foliage on Server, this is bad!")
AssertFatal(isClientObject(), "Trying to create Foliage on Server, this is bad!");
// Cannot continue without Foliage Texture!
if (dStrlen(mFieldData.mFoliageFile) == 0)
@ -1134,7 +1134,7 @@ void fxFoliageReplicator::ProcessQuadrant(fxFoliageQuadrantNode* pParentNode, fx
void fxFoliageReplicator::SyncFoliageReplicators(void)
{
// Check Host.
AssertFatal(isServerObject(), "We *MUST* be on server when Synchronising Foliage!")
AssertFatal(isServerObject(), "We *MUST* be on server when Synchronising Foliage!");
// Find the Replicator Set.
SimSet *fxFoliageSet = dynamic_cast<SimSet*>(Sim::findObject("fxFoliageSet"));
@ -1196,7 +1196,7 @@ void fxFoliageReplicator::DestroyFoliageItems()
void fxFoliageReplicator::DestroyFoliage(void)
{
// Check Host.
AssertFatal(isClientObject(), "Trying to destroy Foliage on Server, this is bad!")
AssertFatal(isClientObject(), "Trying to destroy Foliage on Server, this is bad!");
// Destroy Quad-tree.
mPotentialFoliageNodes = 0;

View file

@ -224,7 +224,7 @@ void fxShapeReplicator::CreateShapes(void)
}
// Check Shapes.
AssertFatal(mCurrentShapeCount==0,"Shapes already present, this should not be possible!")
AssertFatal(mCurrentShapeCount==0,"Shapes already present, this should not be possible!");
// Check that we have a shape...
if (!mFieldData.mShapeFile) return;

View file

@ -3173,18 +3173,21 @@ void Player::updateMove(const Move* move)
// Update the PlayerPose
Pose desiredPose = mPose;
if ( mSwimming )
desiredPose = SwimPose;
else if ( runSurface && move->trigger[sCrouchTrigger] && canCrouch() )
desiredPose = CrouchPose;
else if ( runSurface && move->trigger[sProneTrigger] && canProne() )
desiredPose = PronePose;
else if ( move->trigger[sSprintTrigger] && canSprint() )
desiredPose = SprintPose;
else if ( canStand() )
desiredPose = StandPose;
if ( !mIsAiControlled )
{
if ( mSwimming )
desiredPose = SwimPose;
else if ( runSurface && move->trigger[sCrouchTrigger] && canCrouch() )
desiredPose = CrouchPose;
else if ( runSurface && move->trigger[sProneTrigger] && canProne() )
desiredPose = PronePose;
else if ( move->trigger[sSprintTrigger] && canSprint() )
desiredPose = SprintPose;
else if ( canStand() )
desiredPose = StandPose;
setPose( desiredPose );
setPose( desiredPose );
}
}
@ -4659,9 +4662,9 @@ Point3F Player::_move( const F32 travelTime, Collision *outCol )
}
Point3F distance = end - start;
if (mFabs(distance.x) < mObjBox.len_x() &&
mFabs(distance.y) < mObjBox.len_y() &&
mFabs(distance.z) < mObjBox.len_z())
if (mFabs(distance.x) < mScaledBox.len_x() &&
mFabs(distance.y) < mScaledBox.len_y() &&
mFabs(distance.z) < mScaledBox.len_z())
{
// We can potentially early out of this. If there are no polys in the clipped polylist at our
// end position, then we can bail, and just set start = end;
@ -6186,6 +6189,10 @@ U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
{
stream->writeFlag(mFalling);
stream->writeFlag(mSwimming);
stream->writeFlag(mJetting);
stream->writeInt(mPose, NumPoseBits);
stream->writeInt(mState,NumStateBits);
if (stream->writeFlag(mState == RecoverState))
stream->writeInt(mRecoverTicks,PlayerData::RecoverDelayBits);
@ -6282,7 +6289,11 @@ void Player::unpackUpdate(NetConnection *con, BitStream *stream)
if (stream->readFlag()) {
mPredictionCount = sMaxPredictionTicks;
mFalling = stream->readFlag();
mSwimming = stream->readFlag();
mJetting = stream->readFlag();
mPose = (Pose)(stream->readInt(NumPoseBits));
ActionState actionState = (ActionState)stream->readInt(NumStateBits);
if (stream->readFlag()) {
mRecoverTicks = stream->readInt(PlayerData::RecoverDelayBits);
@ -6873,31 +6884,13 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S
// Play default sound.
S32 sound = -1;
if( contactMaterial && contactMaterial->mFootstepSoundId != -1 )
if (contactMaterial && (contactMaterial->mImpactSoundId>-1 && contactMaterial->mImpactSoundId<PlayerData::MaxSoundOffsets))
sound = contactMaterial->mFootstepSoundId;
else if( contactObject && contactObject->getTypeMask() & VehicleObjectType )
sound = 2;
switch ( sound )
{
case 0: // Soft
SFX->playOnce( mDataBlock->sound[PlayerData::FootSoft], &footMat );
break;
case 1: // Hard
SFX->playOnce( mDataBlock->sound[PlayerData::FootHard], &footMat );
break;
case 2: // Metal
SFX->playOnce( mDataBlock->sound[PlayerData::FootMetal], &footMat );
break;
case 3: // Snow
SFX->playOnce( mDataBlock->sound[PlayerData::FootSnow], &footMat );
break;
/*
default: //Hard
SFX->playOnce( mDataBlock->sound[PlayerData::FootHard], &footMat );
break;
*/
}
if (sound>=0)
SFX->playOnce(mDataBlock->sound[sound], &footMat);
}
}
@ -6922,36 +6915,13 @@ void Player:: playImpactSound()
else
{
S32 sound = -1;
if( material && material->mImpactSoundId )
if (material && (material->mImpactSoundId>-1 && material->mImpactSoundId<PlayerData::MaxSoundOffsets))
sound = material->mImpactSoundId;
else if( rInfo.object->getTypeMask() & VehicleObjectType )
sound = 2; // Play metal;
switch( sound )
{
case 0:
//Soft
SFX->playOnce( mDataBlock->sound[ PlayerData::ImpactSoft ], &getTransform() );
break;
case 1:
//Hard
SFX->playOnce( mDataBlock->sound[ PlayerData::ImpactHard ], &getTransform() );
break;
case 2:
//Metal
SFX->playOnce( mDataBlock->sound[ PlayerData::ImpactMetal ], &getTransform() );
break;
case 3:
//Snow
SFX->playOnce( mDataBlock->sound[ PlayerData::ImpactSnow ], &getTransform() );
break;
/*
default:
//Hard
alxPlay(mDataBlock->sound[PlayerData::ImpactHard], &getTransform());
break;
*/
}
if (sound >= 0)
SFX->playOnce(mDataBlock->sound[PlayerData::ImpactStart + sound], &getTransform());
}
}
}

View file

@ -190,13 +190,15 @@ struct PlayerData: public ShapeBaseData {
FootHard,
FootMetal,
FootSnow,
MaxSoundOffsets,
FootShallowSplash,
FootWading,
FootUnderWater,
FootBubbles,
MoveBubbles,
WaterBreath,
ImpactSoft,
ImpactStart,
ImpactSoft = ImpactStart,
ImpactHard,
ImpactMetal,
ImpactSnow,

View file

@ -156,7 +156,7 @@ bool Rigid::resolveCollision(const Point3F& p, const Point3F &normal, Rigid* rig
return false;
// Compute impulse
F32 d, n = -nv * (1.0f + restitution * rigid->restitution);
F32 d, n = -nv * (2.0f + restitution * rigid->restitution);
Point3F a1,b1,c1;
mCross(r1,normal,&a1);
invWorldInertia.mulV(a1,&b1);
@ -173,7 +173,7 @@ bool Rigid::resolveCollision(const Point3F& p, const Point3F &normal, Rigid* rig
applyImpulse(r1,impulse);
impulse.neg();
applyImpulse(r2,impulse);
rigid->applyImpulse(r2, impulse);
return true;
}

View file

@ -879,6 +879,7 @@ IMPLEMENT_CALLBACK( ShapeBase, validateCameraFov, F32, (F32 fov), (fov),
ShapeBase::ShapeBase()
: mDataBlock( NULL ),
mIsAiControlled( false ),
mAiPose( 0 ),
mControllingObject( NULL ),
mMoveMotion( false ),
mShapeBaseMount( NULL ),

View file

@ -874,6 +874,7 @@ protected:
/// @name Physical Properties
/// @{
S32 mAiPose; ///< Current pose.
F32 mEnergy; ///< Current enery level.
F32 mRechargeRate; ///< Energy recharge rate (in units/tick).

View file

@ -91,6 +91,9 @@ ConsoleDocClass( TSStatic,
);
TSStatic::TSStatic()
:
cubeDescId( 0 ),
reflectorDesc( NULL )
{
mNetFlags.set(Ghostable | ScopeAlways);
@ -186,6 +189,11 @@ void TSStatic::initPersistFields()
endGroup("Rendering");
addGroup( "Reflection" );
addField( "cubeReflectorDesc", TypeRealString, Offset( cubeDescName, TSStatic ),
"References a ReflectorDesc datablock that defines performance and quality properties for dynamic reflections.\n");
endGroup( "Reflection" );
addGroup("Collision");
addField( "collisionType", TypeTSMeshType, Offset( mCollisionType, TSStatic ),
@ -292,6 +300,14 @@ bool TSStatic::onAdd()
addToScene();
if ( isClientObject() )
{
mCubeReflector.unregisterReflector();
if ( reflectorDesc )
mCubeReflector.registerReflector( this, reflectorDesc );
}
_updateShouldTick();
// Accumulation
@ -357,6 +373,16 @@ bool TSStatic::_createShape()
if ( mAmbientThread )
mShapeInstance->setSequence( mAmbientThread, ambientSeq, 0);
// Resolve CubeReflectorDesc.
if ( cubeDescName.isNotEmpty() )
{
Sim::findObject( cubeDescName, reflectorDesc );
}
else if( cubeDescId > 0 )
{
Sim::findObject( cubeDescId, reflectorDesc );
}
return true;
}
@ -429,6 +455,8 @@ void TSStatic::onRemove()
mShapeInstance = NULL;
mAmbientThread = NULL;
if ( isClientObject() )
mCubeReflector.unregisterReflector();
Parent::onRemove();
}
@ -561,6 +589,12 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
// If we're currently rendering our own reflection we
// don't want to render ourselves into it.
if ( mCubeReflector.isRendering() )
return;
if ( mForceDetail == -1 )
mShapeInstance->setDetailFromDistance( state, dist * invScale );
else
@ -577,6 +611,9 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
rdata.setFadeOverride( 1.0f );
rdata.setOriginSort( mUseOriginSort );
if ( mCubeReflector.isEnabled() )
rdata.setCubemap( mCubeReflector.getCubemap() );
// Acculumation
rdata.setAccuTex(mAccuTex);
@ -604,6 +641,20 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
mat.scale( mObjScale );
GFX->setWorldMatrix( mat );
if ( state->isDiffusePass() && mCubeReflector.isEnabled() && mCubeReflector.getOcclusionQuery() )
{
RenderPassManager *pass = state->getRenderPass();
OccluderRenderInst *ri = pass->allocInst<OccluderRenderInst>();
ri->type = RenderPassManager::RIT_Occluder;
ri->query = mCubeReflector.getOcclusionQuery();
mObjToWorld.mulP( mObjBox.getCenter(), &ri->position );
ri->scale.set( mObjBox.getExtents() );
ri->orientation = pass->allocUniqueXform( mObjToWorld );
ri->isSphere = false;
state->getRenderPass()->addInst( ri );
}
mShapeInstance->animate();
if(mShapeInstance)
{
@ -715,6 +766,10 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
if ( mLightPlugin )
retMask |= mLightPlugin->packUpdate(this, AdvancedStaticOptionsMask, con, mask, stream);
if( stream->writeFlag( reflectorDesc != NULL ) )
{
stream->writeRangedU32( reflectorDesc->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast );
}
return retMask;
}
@ -782,6 +837,11 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream)
mLightPlugin->unpackUpdate(this, con, stream);
}
if( stream->readFlag() )
{
cubeDescId = stream->readRangedU32( DataBlockObjectIdFirst, DataBlockObjectIdLast );
}
if ( isProperlyAdded() )
_updateShouldTick();
}

View file

@ -39,6 +39,10 @@
#include "ts/tsShape.h"
#endif
#ifndef _REFLECTOR_H_
#include "scene/reflector.h"
#endif
class TSShapeInstance;
class TSThread;
class TSStatic;
@ -147,6 +151,11 @@ protected:
/// Start or stop processing ticks depending on our state.
void _updateShouldTick();
String cubeDescName;
U32 cubeDescId;
ReflectorDesc *reflectorDesc;
CubeReflector mCubeReflector;
protected:
Convex *mConvexList;