Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/GarageGames/Torque3D
Browse files Browse the repository at this point in the history
…into FrameMallocMallet

Conflicts:
	Engine/source/gfx/gl/gfxGLTextureManager.cpp
  • Loading branch information
Azaezel committed Jun 6, 2016
2 parents 5a27313 + d2161e5 commit 75fa06d
Show file tree
Hide file tree
Showing 91 changed files with 2,124 additions and 475 deletions.
8 changes: 5 additions & 3 deletions Engine/source/T3D/lightAnimData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@ void LightAnimData::AnimValue<COUNT>::updateKey()
}

template<U32 COUNT>
bool LightAnimData::AnimValue<COUNT>::animate( F32 time, F32 *output )
bool LightAnimData::AnimValue<COUNT>::animate(F32 time, F32 *output, bool multiply)
{
F32 scaledTime, lerpFactor, valueRange, keyFrameLerp;
U32 posFrom, posTo;
S32 keyFrameFrom, keyFrameTo;
F32 initialValue = *output;

if (!multiply)
initialValue = 1;

bool wasAnimated = false;

for ( U32 i=0; i < COUNT; i++ )
Expand Down Expand Up @@ -305,6 +307,6 @@ void LightAnimData::animate( LightInfo *lightInfo, LightAnimState *state )
lightInfo->setColor( color );

F32 brightness = state->brightness;
mBrightness.animate( time, &brightness );
mBrightness.animate( time, &brightness, true );
lightInfo->setBrightness( brightness );
}
2 changes: 1 addition & 1 deletion Engine/source/T3D/lightAnimData.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class LightAnimData : public SimDataBlock
/// Performs the animation returning the results in the output if
/// the time scale is greater than zero.
/// @return Returns true if the animation was performed.
bool animate( F32 time, F32 *output );
bool animate(F32 time, F32 *output, bool multiply = false);

/// Called when the key string is changed to update the
/// key length and time scale.
Expand Down
22 changes: 22 additions & 0 deletions Engine/source/T3D/physics/bullet/btBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,25 @@ void BtBody::setSimulationEnabled( bool enabled )

mIsEnabled = enabled;
}

void BtBody::moveKinematicTo(const MatrixF &transform)
{
AssertFatal(mActor, "BtBody::moveKinematicTo - The actor is null!");

U32 bodyflags = mActor->getCollisionFlags();
const bool isKinematic = bodyflags & BF_KINEMATIC;
if (!isKinematic)
{
Con::errorf("BtBody::moveKinematicTo is only for kinematic bodies.");
return;
}

if (mCenterOfMass)
{
MatrixF xfm;
xfm.mul(transform, *mCenterOfMass);
mActor->setCenterOfMassTransform(btCast<btTransform>(xfm));
}
else
mActor->setCenterOfMassTransform(btCast<btTransform>(transform));
}
2 changes: 2 additions & 0 deletions Engine/source/T3D/physics/bullet/btBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class BtBody : public PhysicsBody
F32 staticFriction );
virtual void applyCorrection( const MatrixF &xfm );
virtual void applyImpulse( const Point3F &origin, const Point3F &force );
virtual void moveKinematicTo(const MatrixF &xfm);

};

#endif // _T3D_PHYSICS_BTBODY_H_
25 changes: 15 additions & 10 deletions Engine/source/T3D/physics/bullet/btPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void BtPlayer::init( const char *type,
mObject = obj;
mWorld = (BtWorld*)world;

mSlopeAngle = runSurfaceCos;
mStepHeight = stepHeight;

//if ( dStricmp( type, "Capsule" ) == 0 )
Expand Down Expand Up @@ -102,6 +103,17 @@ Point3F BtPlayer::move( const VectorF &disp, CollisionList &outCol )
{
AssertFatal( mGhostObject, "BtPlayer::move - The controller is null!" );

if (!mWorld->isEnabled())
{
btTransform currentTrans = mGhostObject->getWorldTransform();
btVector3 currentPos = currentTrans.getOrigin();

Point3F returnPos = btCast<Point3F>(currentPos);

returnPos.z -= mOriginOffset;
return returnPos;
}

// First recover from any penetrations from the previous tick.
U32 numPenetrationLoops = 0;
bool touchingContact = false;
Expand Down Expand Up @@ -305,16 +317,9 @@ bool BtPlayer::_sweep( btVector3 *inOutCurrPos, const btVector3 &disp, Collision
col.normal = btCast<Point3F>( callback.m_hitNormalWorld );
col.object = PhysicsUserData::getObject( callback.m_hitCollisionObject->getUserPointer() );

if (disp.z() < 0.0f)
{
// We're sweeping down as part of the stepping routine. In this
// case we want to have the collision normal only point in the opposite direction.
// i.e. up If we include the sideways part of the normal then the Player class
// velocity calculations using this normal will affect the player's forwards
// momentum. This is especially noticable on stairs as the rounded bottom of
// the capsule slides up the corner of a stair.
col.normal.set(0.0f, 0.0f, 1.0f);
}
F32 vd = col.normal.z;
if (vd < mSlopeAngle)
return false;
}

return true;
Expand Down
4 changes: 4 additions & 0 deletions Engine/source/T3D/physics/bullet/btPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class BtPlayer : public PhysicsPlayer
///
F32 mOriginOffset;

///
F32 mSlopeAngle;
///

///
F32 mStepHeight;
///
Expand Down
4 changes: 4 additions & 0 deletions Engine/source/T3D/physics/physicsBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class PhysicsBody : public PhysicsObject

///
virtual void applyImpulse( const Point3F &origin, const Point3F &force ) = 0;

///
virtual void moveKinematicTo(const MatrixF &xfm) = 0;

};


Expand Down
19 changes: 19 additions & 0 deletions Engine/source/T3D/physics/physx3/px3Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,22 @@ void Px3Body::applyImpulse( const Point3F &origin, const Point3F &force )

}

void Px3Body::moveKinematicTo(const MatrixF &transform)
{
AssertFatal(mActor, "Px3Body::moveKinematicTo - The actor is null!");

const bool isKinematic = mBodyFlags & BF_KINEMATIC;
if (!isKinematic)
{
Con::errorf("Px3Body::moveKinematicTo is only for kinematic bodies.");
return;
}

mWorld->lockScene();

physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
actor->setKinematicTarget(px3Cast<physx::PxTransform>(transform));

mWorld->unlockScene();
}

2 changes: 2 additions & 0 deletions Engine/source/T3D/physics/physx3/px3Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class Px3Body : public PhysicsBody
F32 staticFriction );
virtual void applyCorrection( const MatrixF &xfm );
virtual void applyImpulse( const Point3F &origin, const Point3F &force );
virtual void moveKinematicTo(const MatrixF &xfm);

};

#endif // _PX3BODY_H_
30 changes: 30 additions & 0 deletions Engine/source/T3D/physics/physx3/px3Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,33 @@ Box3F Px3Player::getWorldBounds()
return px3Cast<Box3F>( bounds );
}

bool Px3Player::testSpacials(const Point3F &nPos, const Point3F &nSize) const
{
F32 offset = nSize.z * 0.5f;
F32 radius = getMax(nSize.x, nSize.y) * 0.5f - mSkinWidth;
F32 height = (nSize.z - (radius * 2.0f)) * 0.5f;
height -= mSkinWidth * 2.0f;
physx::PxCapsuleGeometry geom(radius, height);

physx::PxVec3 pos(nPos.x, nPos.y, nPos.z + offset);
physx::PxQuat orientation(Float_HalfPi, physx::PxVec3(0.0f, 1.0f, 0.0f));

physx::PxOverlapBuffer hit;
physx::PxQueryFilterData queryFilter(physx::PxQueryFlag::eANY_HIT | physx::PxQueryFlag::eSTATIC | physx::PxQueryFlag::eDYNAMIC);
queryFilter.data.word0 = PX3_DEFAULT;
bool hasHit = mWorld->getScene()->overlap(geom, physx::PxTransform(pos, orientation), hit, queryFilter);

return !hasHit; // Return true if there are no overlapping objects
}

void Px3Player::setSpacials(const Point3F &nPos, const Point3F &nSize)
{
mOriginOffset = nSize.z * 0.5f;
F32 radius = getMax(nSize.x, nSize.y) * 0.5f - mSkinWidth;
F32 height = nSize.z - (radius * 2.0f);
height -= mSkinWidth * 2.0f;

mWorld->releaseWriteLock();
mController->resize(height);
px3GetFirstShape(mController->getActor())->getCapsuleGeometry(mGeometry);
}
4 changes: 2 additions & 2 deletions Engine/source/T3D/physics/physx3/px3Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class Px3Player : public PhysicsPlayer, public physx::PxUserControllerHitReport
PhysicsWorld *world );
virtual Point3F move( const VectorF &displacement, CollisionList &outCol );
virtual void findContact( SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects ) const;
virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const { return true; }
virtual void setSpacials( const Point3F &nPos, const Point3F &nSize ) {}
virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const;
virtual void setSpacials( const Point3F &nPos, const Point3F &nSize );
virtual void enableCollision();
virtual void disableCollision();
};
Expand Down
59 changes: 58 additions & 1 deletion Engine/source/T3D/physics/physx3/px3World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ Px3World::Px3World(): mScene( NULL ),
mIsEnabled( false ),
mEditorTimeScale( 1.0f ),
mAccumulator( 0 ),
mControllerManager( NULL )
mControllerManager(NULL),
mIsSceneLocked(false)
{
}

Expand Down Expand Up @@ -335,6 +336,62 @@ void Px3World::releaseWriteLock()
//AssertFatal( mScene->isWritable(), "PhysX3World::releaseWriteLock() - We should have been writable now!" );
}

void Px3World::lockScenes()
{
Px3World *world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("server"));

if (world)
world->lockScene();

world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("client"));

if (world)
world->lockScene();
}

void Px3World::unlockScenes()
{
Px3World *world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("server"));

if (world)
world->unlockScene();

world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("client"));

if (world)
world->unlockScene();
}

void Px3World::lockScene()
{
if (!mScene)
return;

if (mIsSceneLocked)
{
Con::printf("Px3World: Attempting to lock a scene that is already locked.");
return;
}

mScene->lockWrite();
mIsSceneLocked = true;
}

void Px3World::unlockScene()
{
if (!mScene)
return;

if (!mIsSceneLocked)
{
Con::printf("Px3World: Attempting to unlock a scene that is not locked.");
return;
}

mScene->unlockWrite();
mIsSceneLocked = false;
}

bool Px3World::castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse )
{

Expand Down
5 changes: 5 additions & 0 deletions Engine/source/T3D/physics/physx3/px3World.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Px3World : public PhysicsWorld
bool mIsEnabled;
bool mIsSimulating;
bool mIsServer;
bool mIsSceneLocked;
U32 mTickCount;
ProcessList *mProcessList;
F32 mEditorTimeScale;
Expand Down Expand Up @@ -96,11 +97,15 @@ class Px3World : public PhysicsWorld
void releaseWriteLock();
bool isServer(){return mIsServer;}
physx::PxController* createController( physx::PxControllerDesc &desc );
void lockScene();
void unlockScene();
//static
static bool restartSDK( bool destroyOnly = false, Px3World *clientWorld = NULL, Px3World *serverWorld = NULL );
static void releaseWriteLocks();
static physx::PxCooking *getCooking();
static void setTiming(F32 stepTime,U32 maxIterations);
static void lockScenes();
static void unlockScenes();
};

#endif // _PX3WORLD_H_
19 changes: 10 additions & 9 deletions Engine/source/T3D/shapeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4881,17 +4881,18 @@ DefineEngineMethod( ShapeBase, getTargetCount, S32, (),,

"@see getTargetName()\n")
{
ShapeBase *obj = dynamic_cast< ShapeBase* > ( object );
if(obj)
{
// Try to use the client object (so we get the reskinned targets in the Material Editor)
if ((ShapeBase*)obj->getClientObject())
obj = (ShapeBase*)obj->getClientObject();
ShapeBase *obj = dynamic_cast< ShapeBase* > ( object );
if(obj)
{
// Try to use the client object (so we get the reskinned targets in the Material Editor)
if ((ShapeBase*)obj->getClientObject())
obj = (ShapeBase*)obj->getClientObject();

return obj->getShapeInstance()->getTargetCount();
if (obj->getShapeInstance() != NULL)
return obj->getShapeInstance()->getTargetCount();
}

return -1;
return -1;
}

DefineEngineMethod( ShapeBase, changeMaterial, void, ( const char* mapTo, Material* oldMat, Material* newMat ),,
Expand Down
Loading

0 comments on commit 75fa06d

Please sign in to comment.