Merge branch 'GarageGames/development' into ueberengine-dev-3.10

Conflicts:
	Engine/source/app/version.h
	Engine/source/terrain/terrData.cpp
This commit is contained in:
Duion 2016-12-13 17:28:36 +01:00
commit 186604eb76
974 changed files with 121718 additions and 233088 deletions

View file

@ -47,6 +47,8 @@
Vector< SimObjectPtr<SceneObject> > AccumulationVolume::smAccuObjects;
Vector< SimObjectPtr<AccumulationVolume> > AccumulationVolume::smAccuVolumes;
GFXTexHandle gLevelAccuMap;
//#define DEBUG_DRAW
IMPLEMENT_CO_NETOBJECT_V1( AccumulationVolume );
@ -296,7 +298,7 @@ void AccumulationVolume::refreshVolumes()
{
SimObjectPtr<SceneObject> object = smAccuObjects[n];
if ( object.isValid() )
object->mAccuTex = GFXTexHandle::ZERO;
object->mAccuTex = gLevelAccuMap;
}
//
@ -337,7 +339,7 @@ void AccumulationVolume::updateObject(SceneObject* object)
// We use ZERO instead of NULL so the accumulation
// texture will be updated in renderMeshMgr.
object->mAccuTex = GFXTexHandle::ZERO;
object->mAccuTex = gLevelAccuMap;
for (S32 i = 0; i < smAccuVolumes.size(); ++i)
{
@ -347,4 +349,4 @@ void AccumulationVolume::updateObject(SceneObject* object)
if ( volume->containsPoint(object->getPosition()) )
object->mAccuTex = volume->mAccuTexture;
}
}
}

View file

@ -1440,10 +1440,9 @@ F32 AIPlayer::getTargetDistance(GameBase* target, bool _checkEnabled)
return (getPosition() - target->getPosition()).len();
}
DefineEngineMethod(AIPlayer, getTargetDistance, bool, (ShapeBase* obj, bool checkEnabled), (NULL, false),
"@brief Check whether an object is within a specified veiw cone.\n"
DefineEngineMethod(AIPlayer, getTargetDistance, F32, (ShapeBase* obj, bool checkEnabled), (NULL, false),
"@brief The distance to a given object.\n"
"@obj Object to check. (If blank, it will check the current target).\n"
"@fov view angle in degrees.(Defaults to 45)\n"
"@checkEnabled check whether the object can take damage and if so is still alive.(Defaults to false)\n")
{
return object->getTargetDistance(obj, checkEnabled);

View file

@ -91,9 +91,9 @@ ConsoleSetType(TypeComponentAssetPtr)
//-----------------------------------------------------------------------------
ComponentAsset::ComponentAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
// Generate an asset definition.
mpAssetDefinition = new AssetDefinition();

View file

@ -91,9 +91,9 @@ ConsoleSetType(TypeExampleAssetPtr)
//-----------------------------------------------------------------------------
ExampleAsset::ExampleAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
// Generate an asset definition.
mpAssetDefinition = new AssetDefinition();

View file

@ -91,9 +91,9 @@ ConsoleSetType(TypeGameObjectAssetPtr)
//-----------------------------------------------------------------------------
GameObjectAsset::GameObjectAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
// Generate an asset definition.
mpAssetDefinition = new AssetDefinition();

View file

@ -45,9 +45,6 @@
// Debug Profiling.
#include "platform/profiler.h"
static U32 execDepth = 0;
static U32 journalDepth = 1;
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(ShapeAsset);
@ -96,9 +93,9 @@ ConsoleSetType(TypeShapeAssetPtr)
//-----------------------------------------------------------------------------
ShapeAsset::ShapeAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
}

View file

@ -393,44 +393,6 @@ void Camera::getEyeCameraTransform(IDisplayDevice *displayDevice, U32 eyeId, Mat
}
}
DisplayPose Camera::calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose)
{
// NOTE: this is intended to be similar to updateMove
DisplayPose outPose;
outPose.orientation = EulerF(0,0,0);
outPose.position = inPose.position;
// Pitch
outPose.orientation.x = (inPose.orientation.x - mLastAbsolutePitch);
// Constrain the range of mRot.x
while (outPose.orientation.x < -M_PI_F)
outPose.orientation.x += M_2PI_F;
while (outPose.orientation.x > M_PI_F)
outPose.orientation.x -= M_2PI_F;
// Yaw
outPose.orientation.z = (inPose.orientation.z - mLastAbsoluteYaw);
// Constrain the range of mRot.z
while (outPose.orientation.z < -M_PI_F)
outPose.orientation.z += M_2PI_F;
while (outPose.orientation.z > M_PI_F)
outPose.orientation.z -= M_2PI_F;
// Bank
if (mDataBlock->cameraCanBank)
{
outPose.orientation.y = (inPose.orientation.y - mLastAbsoluteRoll);
}
// Constrain the range of mRot.y
while (outPose.orientation.y > M_PI_F)
outPose.orientation.y -= M_2PI_F;
return outPose;
}
//----------------------------------------------------------------------------
F32 Camera::getCameraFov()

View file

@ -237,7 +237,6 @@ class Camera: public ShapeBase
virtual void interpolateTick( F32 delta);
virtual void getCameraTransform( F32* pos,MatrixF* mat );
virtual void getEyeCameraTransform( IDisplayDevice *display, U32 eyeId, MatrixF *outMat );
virtual DisplayPose calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose);
virtual void writePacketData( GameConnection* conn, BitStream* stream );
virtual void readPacketData( GameConnection* conn, BitStream* stream );

View file

@ -39,14 +39,14 @@ class WaterObject;
struct ContainerQueryInfo
{
ContainerQueryInfo()
: waterCoverage(0.0f),
: box(-1,-1,-1,1,1,1),
mass(1.0f),
waterCoverage(0.0f),
waterHeight(0.0f),
waterDensity(0.0f),
waterViscosity(0.0f),
gravityScale(1.0f),
appliedForce(0,0,0),
box(-1,-1,-1,1,1,1),
mass(1.0f),
waterObject(NULL)
{
}

View file

@ -227,12 +227,12 @@ bool ConvexShape::protectedSetSurface( void *object, const char *index, const ch
ConvexShape::ConvexShape()
: mMaterialInst( NULL ),
mNormalLength( 0.3f ),
: mMaterialName( "Grid512_OrangeLines_Mat" ),
mMaterialInst( NULL ),
mVertCount( 0 ),
mPrimCount( 0 ),
mMaterialName( "Grid512_OrangeLines_Mat" ),
mPhysicsRep( NULL )
mPhysicsRep( NULL ),
mNormalLength( 0.3f )
{
mNetFlags.set( Ghostable | ScopeAlways );
@ -1102,8 +1102,6 @@ void ConvexShape::_updateGeometry( bool updateCollision )
const Vector< ConvexShape::Triangle > &triangles = face.triangles;
const ColorI &faceColor = sgConvexFaceColors[ i % sgConvexFaceColorCount ];
const Point3F binormal = mCross( face.normal, face.tangent );
for ( S32 j = 0; j < triangles.size(); j++ )
{
for ( S32 k = 0; k < 3; k++ )

View file

@ -43,9 +43,6 @@
const U32 csmStaticCollisionMask = TerrainObjectType | StaticShapeObjectType | StaticObjectType;
const U32 csmDynamicCollisionMask = StaticShapeObjectType;
IMPLEMENT_CO_DATABLOCK_V1(DebrisData);
ConsoleDocClass( DebrisData,

View file

@ -62,8 +62,8 @@ struct DebrisData : public GameBaseData
F32 elasticity;
F32 lifetime;
F32 lifetimeVariance;
U32 numBounces;
U32 bounceVariance;
S32 numBounces;
S32 bounceVariance;
F32 minSpinSpeed;
F32 maxSpinSpeed;
bool explodeOnMaxBounce; // explodes after it has bounced max times

View file

@ -43,6 +43,7 @@ class GuiHealthBarHud : public GuiControl
bool mShowFrame;
bool mShowFill;
bool mDisplayEnergy;
bool mFlip;
ColorF mFillColor;
ColorF mFrameColor;
@ -105,6 +106,8 @@ GuiHealthBarHud::GuiHealthBarHud()
mPulseRate = 0;
mPulseThreshold = 0.3f;
mValue = 0.2f;
mFlip = false;
}
void GuiHealthBarHud::initPersistFields()
@ -124,6 +127,7 @@ void GuiHealthBarHud::initPersistFields()
addField( "showFill", TypeBool, Offset( mShowFill, GuiHealthBarHud ), "If true, we draw the background color of the control." );
addField( "showFrame", TypeBool, Offset( mShowFrame, GuiHealthBarHud ), "If true, we draw the frame of the control." );
addField( "displayEnergy", TypeBool, Offset( mDisplayEnergy, GuiHealthBarHud ), "If true, display the energy value rather than the damage value." );
addField( "flip", TypeBool, Offset( mFlip, GuiHealthBarHud), "If true, will fill bar in opposite direction.");
endGroup("Misc");
Parent::initPersistFields();
@ -163,6 +167,7 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
// Pulse the damage fill if it's below the threshold
if (mPulseRate != 0)
{
if (mValue < mPulseThreshold)
{
U32 time = Platform::getVirtualMilliseconds();
@ -171,16 +176,25 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
}
else
mDamageFillColor.alpha = 1;
}
// Render damage fill %
RectI rect(updateRect);
if(getWidth() > getHeight())
{
rect.extent.x = (S32)(rect.extent.x * mValue);
if(mFlip)
rect.point.x = (S32)(updateRect.point.x + (updateRect.extent.x - rect.extent.x));
}
else
{
S32 bottomY = rect.point.y + rect.extent.y;
rect.extent.y = (S32)(rect.extent.y * mValue);
rect.point.y = bottomY - rect.extent.y;
if(mFlip)
rect.extent.y = (S32)(updateRect.extent.y - (updateRect.extent.y - rect.extent.y));
else
rect.point.y = bottomY - rect.extent.y;
}
GFX->getDrawUtil()->drawRectFill(rect, mDamageFillColor);

View file

@ -116,9 +116,6 @@ ConsoleDocClass( GuiShapeNameHud,
"@ingroup GuiGame\n"
);
/// Default distance for object's information to be displayed.
static const F32 cDefaultVisibleDistance = 500.0f;
GuiShapeNameHud::GuiShapeNameHud()
{
mFillColor.set( 0.25f, 0.25f, 0.25f, 0.25f );

View file

@ -132,7 +132,6 @@ ConsoleDocClass( fxFoliageReplicator,
// Trig Table Lookups.
//
//------------------------------------------------------------------------------
const F32 PeriodLen = (F32) 2.0f * (F32) M_PI;
const F32 PeriodLenMinus = (F32) (2.0f * M_PI) - 0.01f;
//------------------------------------------------------------------------------

View file

@ -60,14 +60,14 @@ GFXImplementVertexFormat( GCVertex )
};
GroundCoverShaderConstHandles::GroundCoverShaderConstHandles()
: mTypeRectsSC( NULL ),
: mGroundCover( NULL ),
mTypeRectsSC( NULL ),
mFadeSC( NULL ),
mWindDirSC( NULL ),
mGustInfoSC( NULL ),
mTurbInfoSC( NULL ),
mCamRightSC( NULL ),
mCamUpSC( NULL ),
mGroundCover( NULL )
mCamUpSC( NULL )
{
}

View file

@ -87,7 +87,7 @@ class ParticleEmitterData : public GameBaseData
/// of the ambient color on the particle.
F32 ambientFactor;
U32 lifetimeMS; ///< Lifetime of particles
S32 lifetimeMS; ///< Lifetime of particles
U32 lifetimeVarianceMS; ///< Varience in lifetime from 0 to n
bool overrideAdvance; ///<

View file

@ -354,7 +354,7 @@ void Ribbon::addSegmentPoint(Point3F &point, MatrixF &mat) {
U32 segmentsToDelete = checkRibbonDistance(mDataBlock->segmentsPerUpdate);
for (U32 i = 0; i < segmentsToDelete; i++) {
U32 last = mSegmentPoints.size() - 1;
S32 last = mSegmentPoints.size() - 1;
if (last < 0)
break;
mTravelledDistance += last ? (mSegmentPoints[last] - mSegmentPoints[last-1]).len() : 0;

View file

@ -1,6 +1,7 @@
#include "T3D/gameBase/extended/extendedMove.h"
#include "core/stream/bitStream.h"
#include "math/mathIO.h"
#include "math/mAngAxis.h"
#include "core/module.h"
#include "console/consoleTypes.h"
#include "core/strings/stringFunctions.h"
@ -15,15 +16,17 @@ MODULE_BEGIN( ExtendedMoveManager )
MODULE_END;
S32 ExtendedMoveManager::mPosX[ExtendedMove::MaxPositionsRotations] = { 0, };
S32 ExtendedMoveManager::mPosY[ExtendedMove::MaxPositionsRotations] = { 0, };
S32 ExtendedMoveManager::mPosZ[ExtendedMove::MaxPositionsRotations] = { 0, };
F32 ExtendedMoveManager::mPosX[ExtendedMove::MaxPositionsRotations] = { 0, };
F32 ExtendedMoveManager::mPosY[ExtendedMove::MaxPositionsRotations] = { 0, };
F32 ExtendedMoveManager::mPosZ[ExtendedMove::MaxPositionsRotations] = { 0, };
bool ExtendedMoveManager::mRotIsEuler[ExtendedMove::MaxPositionsRotations] = { 0, };
F32 ExtendedMoveManager::mRotAX[ExtendedMove::MaxPositionsRotations] = { 0, };
F32 ExtendedMoveManager::mRotAY[ExtendedMove::MaxPositionsRotations] = { 0, };
F32 ExtendedMoveManager::mRotAZ[ExtendedMove::MaxPositionsRotations] = { 0, };
F32 ExtendedMoveManager::mRotAA[ExtendedMove::MaxPositionsRotations] = { 1, };
F32 ExtendedMoveManager::mPosScale = 2.0f;
void ExtendedMoveManager::init()
{
for(U32 i = 0; i < ExtendedMove::MaxPositionsRotations; ++i)
@ -31,19 +34,19 @@ void ExtendedMoveManager::init()
char varName[256];
dSprintf(varName, sizeof(varName), "mvPosX%d", i);
Con::addVariable(varName, TypeS32, &mPosX[i],
Con::addVariable(varName, TypeF32, &mPosX[i],
"X position of controller in millimeters. Only 13 bits are networked.\n"
"@ingroup Game");
"@ingroup Game");
dSprintf(varName, sizeof(varName), "mvPosY%d", i);
Con::addVariable(varName, TypeS32, &mPosY[i],
Con::addVariable(varName, TypeF32, &mPosY[i],
"Y position of controller in millimeters. Only 13 bits are networked.\n"
"@ingroup Game");
"@ingroup Game");
dSprintf(varName, sizeof(varName), "mvPosZ%d", i);
Con::addVariable(varName, TypeS32, &mPosZ[i],
Con::addVariable(varName, TypeF32, &mPosZ[i],
"Z position of controller in millimeters. Only 13 bits are networked.\n"
"@ingroup Game");
"@ingroup Game");
dSprintf(varName, sizeof(varName), "mvRotIsEuler%d", i);
Con::addVariable(varName, TypeBool, &mRotIsEuler[i],
@ -52,33 +55,39 @@ void ExtendedMoveManager::init()
"(a vector and angle). When true, the given rotation is a three component "
"Euler angle. When using Euler angles, the $mvRotA component of the ExtendedMove "
"is ignored for this set of rotations.\n"
"@ingroup Game");
"@ingroup Game");
dSprintf(varName, sizeof(varName), "mvRotX%d", i);
Con::addVariable(varName, TypeF32, &mRotAX[i],
"X rotation vector component of controller.\n"
"@ingroup Game");
"@ingroup Game");
dSprintf(varName, sizeof(varName), "mvRotY%d", i);
Con::addVariable(varName, TypeF32, &mRotAY[i],
"Y rotation vector component of controller.\n"
"@ingroup Game");
"@ingroup Game");
dSprintf(varName, sizeof(varName), "mvRotZ%d", i);
Con::addVariable(varName, TypeF32, &mRotAZ[i],
"Z rotation vector component of controller.\n"
"@ingroup Game");
"@ingroup Game");
dSprintf(varName, sizeof(varName), "mvRotA%d", i);
Con::addVariable(varName, TypeF32, &mRotAA[i],
"Angle rotation (in degrees) component of controller.\n"
"@ingroup Game");
"@ingroup Game");
}
Con::addVariable("mvPosScale", TypeF32, &mPosScale,
"@brief Indicates the scale to be given to mvPos values.\n\n"
""
"@ingroup Game");
}
const ExtendedMove NullExtendedMove;
#define CLAMPPOS(x) (x<0 ? -((-x) & (1<<(MaxPositionBits-1))-1) : (x & (1<<(MaxPositionBits-1))-1))
#define CLAMPPOS(x) ((S32)(((x + 1) * .5) * ((1 << MaxPositionBits) - 1)) & ((1<<MaxPositionBits)-1))
#define UNCLAMPPOS(x) ((F32)(x * 2 / F32((1 << MaxPositionBits) - 1) - 1.0f))
#define CLAMPROT(f) ((S32)(((f + 1) * .5) * ((1 << MaxRotationBits) - 1)) & ((1<<MaxRotationBits)-1))
#define UNCLAMPROT(x) ((F32)(x * 2 / F32((1 << MaxRotationBits) - 1) - 1.0f))
@ -94,6 +103,10 @@ ExtendedMove::ExtendedMove() : Move()
rotZ[i] = 0;
rotW[i] = 1;
cposX[i] = 0;
cposY[i] = 0;
cposZ[i] = 0;
EulerBasedRotation[i] = false;
}
}
@ -133,20 +146,20 @@ void ExtendedMove::pack(BitStream *stream, const Move * basemove)
{
// Position
if(stream->writeFlag(posX[i] != extBaseMove->posX[i]))
stream->writeSignedInt(posX[i], MaxPositionBits);
stream->writeInt(cposX[i], MaxPositionBits);
if(stream->writeFlag(posY[i] != extBaseMove->posY[i]))
stream->writeSignedInt(posY[i], MaxPositionBits);
stream->writeInt(cposY[i], MaxPositionBits);
if(stream->writeFlag(posZ[i] != extBaseMove->posZ[i]))
stream->writeSignedInt(posZ[i], MaxPositionBits);
stream->writeInt(cposZ[i], MaxPositionBits);
// Rotation
stream->writeFlag(EulerBasedRotation[i]);
if(stream->writeFlag(rotX[i] != extBaseMove->rotX[i]))
stream->writeInt(crotX[i], MaxRotationBits);
stream->writeInt(crotX[i], EulerBasedRotation[i] ? MaxRotationBits : MaxPositionBits);
if(stream->writeFlag(rotY[i] != extBaseMove->rotY[i]))
stream->writeInt(crotY[i], MaxRotationBits);
stream->writeInt(crotY[i], EulerBasedRotation[i] ? MaxRotationBits : MaxPositionBits);
if(stream->writeFlag(rotZ[i] != extBaseMove->rotZ[i]))
stream->writeInt(crotZ[i], MaxRotationBits);
stream->writeInt(crotZ[i], EulerBasedRotation[i] ? MaxRotationBits : MaxPositionBits);
if(!EulerBasedRotation[i])
{
if(stream->writeFlag(rotW[i] != extBaseMove->rotW[i]))
@ -175,18 +188,27 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
for(U32 i=0; i<MaxPositionsRotations; ++i)
{
// Position
if(stream->readFlag())
posX[i] = stream->readSignedInt(MaxPositionBits);
if (stream->readFlag())
{
cposX[i] = stream->readInt(MaxPositionBits);
posX[i] = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
}
else
posX[i] = extBaseMove->posX[i];
if(stream->readFlag())
posY[i] = stream->readSignedInt(MaxPositionBits);
if (stream->readFlag())
{
cposY[i] = stream->readInt(MaxPositionBits);
posY[i] = UNCLAMPPOS(cposY[i]) * ExtendedMoveManager::mPosScale;
}
else
posY[i] = extBaseMove->posY[i];
if(stream->readFlag())
posZ[i] = stream->readSignedInt(MaxPositionBits);
if (stream->readFlag())
{
cposZ[i] = stream->readInt(MaxPositionBits);
posZ[i] = UNCLAMPPOS(cposZ[i]) * ExtendedMoveManager::mPosScale;
}
else
posZ[i] = extBaseMove->posZ[i];
@ -197,8 +219,8 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
scale = M_2PI_F;
if(stream->readFlag())
{
crotX[i] = stream->readInt(MaxRotationBits);
rotX[i] = UNCLAMPROT(crotX[i]) * scale;
crotX[i] = stream->readInt(EulerBasedRotation[i] ? MaxRotationBits : MaxPositionBits);
rotX[i] = EulerBasedRotation[i] ? (UNCLAMPROT(crotX[i]) * scale) : UNCLAMPPOS(crotX[i]);
}
else
{
@ -207,8 +229,8 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
if(stream->readFlag())
{
crotY[i] = stream->readInt(MaxRotationBits);
rotY[i] = UNCLAMPROT(crotY[i]) * scale;
crotY[i] = stream->readInt(EulerBasedRotation[i] ? MaxRotationBits : MaxPositionBits);
rotY[i] = EulerBasedRotation[i] ? (UNCLAMPROT(crotY[i]) * scale) : UNCLAMPPOS(crotY[i]);
}
else
{
@ -217,8 +239,8 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
if(stream->readFlag())
{
crotZ[i] = stream->readInt(MaxRotationBits);
rotZ[i] = UNCLAMPROT(crotZ[i]) * scale;
crotZ[i] = stream->readInt(EulerBasedRotation[i] ? MaxRotationBits : MaxPositionBits);
rotZ[i] = EulerBasedRotation[i] ? (UNCLAMPROT(crotZ[i]) * scale) : UNCLAMPPOS(crotZ[i]);
}
else
{
@ -230,7 +252,7 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
if(stream->readFlag())
{
crotW[i] = stream->readInt(MaxRotationBits);
rotW[i] = UNCLAMPROT(crotW[i]);
rotW[i] = UNCLAMPROT(crotW[i]) * M_2PI_F;
}
else
{
@ -252,9 +274,9 @@ void ExtendedMove::clamp()
for(U32 i=0; i<MaxPositionsRotations; ++i)
{
// Positions
posX[i] = CLAMPPOS(posX[i]);
posY[i] = CLAMPPOS(posY[i]);
posZ[i] = CLAMPPOS(posZ[i]);
cposX[i] = CLAMPPOS(posX[i] / ExtendedMoveManager::mPosScale);
cposY[i] = CLAMPPOS(posY[i] / ExtendedMoveManager::mPosScale);
cposZ[i] = CLAMPPOS(posZ[i] / ExtendedMoveManager::mPosScale);
// Rotations
if(EulerBasedRotation[i])
@ -265,11 +287,29 @@ void ExtendedMove::clamp()
}
else
{
crotX[i] = CLAMPROT(rotX[i]);
crotY[i] = CLAMPROT(rotY[i]);
crotZ[i] = CLAMPROT(rotZ[i]);
crotW[i] = CLAMPROT(rotW[i]);
crotX[i] = CLAMPPOS(rotX[i]);
crotY[i] = CLAMPPOS(rotY[i]);
crotZ[i] = CLAMPPOS(rotZ[i]);
crotW[i] = CLAMPROT(rotW[i] / M_2PI_F);
}
#ifdef DEBUG_CONTROLLER_MOVE
if (i == 1)
{
F32 x, y, z, a;
x = UNCLAMPPOS(crotX[i]);
y = UNCLAMPPOS(crotY[i]);
z = UNCLAMPPOS(crotZ[i]);
a = UNCLAMPROT(crotW[i]) * M_2PI_F;
Con::printf("INPUT POS == %f,%f,%f", ExtendedMoveManager::mPosX[i], ExtendedMoveManager::mPosY[i], ExtendedMoveManager::mPosZ[i]);
Con::printf("rot %f,%f,%f,%f clamped to %f,%f,%f,%f", rotX[i], rotY[i], rotZ[i], rotW[i], x,y,z,a);
x = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
y = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
z = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
Con::printf("pos %f,%f,%f clamped to %f,%f,%f", posX[i], posY[i], posZ[i], x, y, z);
}
#endif
}
// Perform the standard Move clamp
@ -281,6 +321,10 @@ void ExtendedMove::unclamp()
// Unclamp the values the same as for net traffic so the client matches the server
for(U32 i=0; i<MaxPositionsRotations; ++i)
{
posX[i] = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
posY[i] = UNCLAMPPOS(cposY[i]) * ExtendedMoveManager::mPosScale;
posZ[i] = UNCLAMPPOS(cposZ[i]) * ExtendedMoveManager::mPosScale;
// Rotations
if(EulerBasedRotation[i])
{
@ -290,10 +334,10 @@ void ExtendedMove::unclamp()
}
else
{
rotX[i] = UNCLAMPROT(crotX[i]);
rotY[i] = UNCLAMPROT(crotY[i]);
rotZ[i] = UNCLAMPROT(crotZ[i]);
rotW[i] = UNCLAMPROT(crotW[i]);
rotX[i] = UNCLAMPPOS(crotX[i]);
rotY[i] = UNCLAMPPOS(crotY[i]);
rotZ[i] = UNCLAMPPOS(crotZ[i]);
rotW[i] = UNCLAMPROT(crotW[i]) * M_2PI_F;
}
}

View file

@ -11,12 +11,14 @@ struct ExtendedMove : public Move
enum Constants {
MaxPositionsRotations = 3,
MaxPositionBits = 13,
MaxPositionBits = 16,
MaxRotationBits = 16,
};
// Position is in millimeters
S32 posX[MaxPositionsRotations], posY[MaxPositionsRotations], posZ[MaxPositionsRotations];
F32 posX[MaxPositionsRotations], posY[MaxPositionsRotations], posZ[MaxPositionsRotations];
S32 cposX[MaxPositionsRotations], cposY[MaxPositionsRotations], cposZ[MaxPositionsRotations];
bool EulerBasedRotation[MaxPositionsRotations];
@ -39,15 +41,17 @@ extern const ExtendedMove NullExtendedMove;
class ExtendedMoveManager
{
public:
static S32 mPosX[ExtendedMove::MaxPositionsRotations];
static S32 mPosY[ExtendedMove::MaxPositionsRotations];
static S32 mPosZ[ExtendedMove::MaxPositionsRotations];
static F32 mPosX[ExtendedMove::MaxPositionsRotations];
static F32 mPosY[ExtendedMove::MaxPositionsRotations];
static F32 mPosZ[ExtendedMove::MaxPositionsRotations];
static bool mRotIsEuler[ExtendedMove::MaxPositionsRotations];
static F32 mRotAX[ExtendedMove::MaxPositionsRotations];
static F32 mRotAY[ExtendedMove::MaxPositionsRotations];
static F32 mRotAZ[ExtendedMove::MaxPositionsRotations];
static F32 mRotAA[ExtendedMove::MaxPositionsRotations];
static F32 mPosScale;
static void init();
};

View file

@ -75,11 +75,11 @@ bool ExtendedMoveList::getNextExtMove( ExtendedMove &curMove )
else
{
//Rotation is passed in as an Angle Axis in degrees. We need to convert this into a Quat.
QuatF q(Point3F(ExtendedMoveManager::mRotAX[i], ExtendedMoveManager::mRotAY[i], ExtendedMoveManager::mRotAZ[i]), mDegToRad(ExtendedMoveManager::mRotAA[i]));
curMove.rotX[i] = q.x;
curMove.rotY[i] = q.y;
curMove.rotZ[i] = q.z;
curMove.rotW[i] = q.w;
AngAxisF q(Point3F(ExtendedMoveManager::mRotAX[i], ExtendedMoveManager::mRotAY[i], ExtendedMoveManager::mRotAZ[i]), mDegToRad(ExtendedMoveManager::mRotAA[i]));
curMove.rotX[i] = q.axis.x;
curMove.rotY[i] = q.axis.y;
curMove.rotZ[i] = q.axis.z;
curMove.rotW[i] = q.angle;
}
}

View file

@ -97,14 +97,14 @@ IMPLEMENT_CALLBACK( GameBaseData, onRemove, void, ( GameBase* obj ), ( obj ),
"@param obj the GameBase object\n\n"
"@see onAdd for an example\n" );
IMPLEMENT_CALLBACK( GameBaseData, onMount, void, ( GameBase* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
IMPLEMENT_CALLBACK( GameBaseData, onMount, void, ( SceneObject* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
"@brief Called when the object is mounted to another object in the scene.\n\n"
"@param obj the GameBase object being mounted\n"
"@param mountObj the object we are mounted to\n"
"@param node the mountObj node we are mounted to\n\n"
"@see onAdd for an example\n" );
IMPLEMENT_CALLBACK( GameBaseData, onUnmount, void, ( GameBase* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
IMPLEMENT_CALLBACK( GameBaseData, onUnmount, void, ( SceneObject* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
"@brief Called when the object is unmounted from another object in the scene.\n\n"
"@param obj the GameBase object being unmounted\n"
"@param mountObj the object we are unmounted from\n"

View file

@ -110,8 +110,8 @@ public:
DECLARE_CALLBACK( void, onAdd, ( GameBase* obj ) );
DECLARE_CALLBACK( void, onRemove, ( GameBase* obj ) );
DECLARE_CALLBACK( void, onNewDataBlock, ( GameBase* obj ) );
DECLARE_CALLBACK( void, onMount, ( GameBase* obj, SceneObject* mountObj, S32 node ) );
DECLARE_CALLBACK( void, onUnmount, ( GameBase* obj, SceneObject* mountObj, S32 node ) );
DECLARE_CALLBACK( void, onMount, ( SceneObject* obj, SceneObject* mountObj, S32 node ) );
DECLARE_CALLBACK( void, onUnmount, ( SceneObject* obj, SceneObject* mountObj, S32 node ) );
/// @}
};

View file

@ -407,7 +407,7 @@ bool GameConnection::readConnectAccept(BitStream *stream, const char **errorStri
void GameConnection::writeConnectRequest(BitStream *stream)
{
Parent::writeConnectRequest(stream);
stream->writeString(GameString);
stream->writeString(TORQUE_APP_NAME);
stream->write(CurrentProtocolVersion);
stream->write(MinRequiredProtocolVersion);
stream->writeString(mJoinPassword);
@ -424,7 +424,7 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
U32 currentProtocol, minProtocol;
char gameString[256];
stream->readString(gameString);
if(dStrcmp(gameString, GameString))
if(dStrcmp(gameString, TORQUE_APP_NAME))
{
*errorString = "CHR_GAME";
return false;
@ -469,8 +469,8 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
for(U32 i = 0; i < mConnectArgc+3; i++)
{
connectArgv[i].value = &connectArgvValue[i];
connectArgvValue[i].init();
connectArgv[i].value = &connectArgvValue[i];
connectArgvValue[i].init();
}
for(U32 i = 0; i < mConnectArgc; i++)
@ -681,6 +681,24 @@ bool GameConnection::getControlCameraTransform(F32 dt, MatrixF* mat)
return true;
}
bool GameConnection::getControlCameraHeadTransform(IDisplayDevice *display, MatrixF *transform)
{
GameBase* obj = getCameraObject();
if (!obj)
return false;
GameBase* cObj = obj;
while ((cObj = cObj->getControlObject()) != 0)
{
if (cObj->useObjsEyePoint())
obj = cObj;
}
obj->getEyeCameraTransform(display, -1, transform);
return true;
}
bool GameConnection::getControlCameraEyeTransforms(IDisplayDevice *display, MatrixF *transforms)
{
GameBase* obj = getCameraObject();
@ -896,8 +914,8 @@ void GameConnection::onRemove()
// clientgroup and what not (this is so that we can disconnect from a local server
// without needing to destroy and recreate the server before we can connect to it
// again).
// Safe-delete as we don't know whether the server connection is currently being
// worked on.
// Safe-delete as we don't know whether the server connection is currently being
// worked on.
getRemoteConnection()->safeDeleteObject();
setRemoteConnectionObject(NULL);
}

View file

@ -55,8 +55,6 @@ class MoveList;
struct Move;
struct AuthInfo;
#define GameString TORQUE_APP_NAME
const F32 MinCameraFov = 1.f; ///< min camera FOV
const F32 MaxCameraFov = 179.f; ///< max camera FOV
@ -269,6 +267,10 @@ public:
bool getControlCameraTransform(F32 dt,MatrixF* mat);
bool getControlCameraVelocity(Point3F *vel);
/// Returns the head transform for the control object, using supplemental information
/// from the provided IDisplayDevice
bool getControlCameraHeadTransform(IDisplayDevice *display, MatrixF *transform);
/// Returns the eye transforms for the control object, using supplemental information
/// from the provided IDisplayDevice.
bool getControlCameraEyeTransforms(IDisplayDevice *display, MatrixF *transforms);

View file

@ -36,7 +36,12 @@ class BitStream;
struct Move
{
enum { ChecksumBits = 16, ChecksumMask = ((1<<ChecksumBits)-1), ChecksumMismatch = U32(-1) };
enum : U32
{
ChecksumBits = 16,
ChecksumMask = ((1<<ChecksumBits)-1),
ChecksumMismatch = U32(-1)
};
// packed storage rep, set in clamp
S32 px, py, pz;

View file

@ -348,13 +348,13 @@ bool GameProcessCameraQuery(CameraQuery *query)
query->farPlane = gClientSceneGraph->getVisibleDistance() * CameraAndFOV::sVisDistanceScale;
// Provide some default values
query->projectionOffset = Point2F::Zero;
query->stereoTargets[0] = 0;
query->stereoTargets[1] = 0;
query->eyeOffset[0] = Point3F::Zero;
query->eyeOffset[1] = Point3F::Zero;
query->hasFovPort = false;
query->hasStereoTargets = false;
query->displayDevice = NULL;
F32 cameraFov = 0.0f;
bool fovSet = false;
@ -364,6 +364,9 @@ bool GameProcessCameraQuery(CameraQuery *query)
if(!gEditingMission && connection->hasDisplayDevice())
{
IDisplayDevice* display = connection->getDisplayDevice();
query->displayDevice = display;
// Note: all eye values are invalid until this is called
display->setDrawCanvas(query->drawCanvas);
@ -372,12 +375,6 @@ bool GameProcessCameraQuery(CameraQuery *query)
// Display may activate AFTER so we need to call this again just in case
display->onStartFrame();
// The connection's display device may want to set the projection offset
if(display->providesProjectionOffset())
{
query->projectionOffset = display->getProjectionOffset();
}
// The connection's display device may want to set the eye offset
if(display->providesEyeOffsets())
{
@ -394,6 +391,7 @@ bool GameProcessCameraQuery(CameraQuery *query)
// Grab the latest overriding render view transforms
connection->getControlCameraEyeTransforms(display, query->eyeTransforms);
connection->getControlCameraHeadTransform(display, &query->headMatrix);
display->getStereoViewports(query->stereoViewports);
display->getStereoTargets(query->stereoTargets);
@ -403,6 +401,7 @@ bool GameProcessCameraQuery(CameraQuery *query)
{
query->eyeTransforms[0] = query->cameraMatrix;
query->eyeTransforms[1] = query->cameraMatrix;
query->headMatrix = query->cameraMatrix;
}
// Use the connection's FOV settings if requried

View file

@ -70,9 +70,9 @@ GroundPlane::GroundPlane()
mScaleU( 1.0f ),
mScaleV( 1.0f ),
mMaterial( NULL ),
mPhysicsRep( NULL ),
mMin( 0.0f, 0.0f ),
mMax( 0.0f, 0.0f ),
mPhysicsRep( NULL )
mMax( 0.0f, 0.0f )
{
mTypeMask |= StaticObjectType | StaticShapeObjectType;
mNetFlags.set( Ghostable | ScopeAlways );
@ -591,4 +591,4 @@ DefineEngineMethod( GroundPlane, postApply, void, (),,
)
{
object->inspectPostApply();
}
}

View file

@ -36,15 +36,15 @@
// GuiMaterialPreview
GuiMaterialPreview::GuiMaterialPreview()
: mMaxOrbitDist(5.0f),
mMinOrbitDist(0.0f),
mOrbitDist(5.0f),
mMouseState(None),
: mMouseState(None),
mModel(NULL),
mLastMousePoint(0, 0),
lastRenderTime(0),
runThread(0),
mFakeSun(NULL)
lastRenderTime(0),
mLastMousePoint(0, 0),
mFakeSun(NULL),
mMaxOrbitDist(5.0f),
mMinOrbitDist(0.0f),
mOrbitDist(5.0f)
{
mActive = true;
mCameraMatrix.identity();

View file

@ -89,21 +89,21 @@ IMPLEMENT_CALLBACK( GuiObjectView, onMouseLeave, void, (),(),
//------------------------------------------------------------------------------
GuiObjectView::GuiObjectView()
: mMaxOrbitDist( 5.0f ),
mMinOrbitDist( 0.0f ),
mOrbitDist( 5.0f ),
mMouseState( None ),
mModel( NULL ),
mMountedModel( NULL ),
: mMouseState( None ),
mLastMousePoint( 0, 0 ),
mLastRenderTime( 0 ),
mRunThread( NULL ),
mLight( NULL ),
mAnimationSeq( -1 ),
mMountNodeName( "mount0" ),
mMountNode( -1 ),
mModel( NULL ),
mMaxOrbitDist( 5.0f ),
mMinOrbitDist( 0.0f ),
mCameraRotation( 0.0f, 0.0f, 0.0f ),
mOrbitDist( 5.0f ),
mCameraSpeed( 0.01f ),
mCameraRotation( 0.0f, 0.0f, 0.0f ),
mMountNode( -1 ),
mMountNodeName( "mount0" ),
mMountedModel( NULL ),
mAnimationSeq( -1 ),
mRunThread( NULL ),
mLastRenderTime( 0 ),
mLight( NULL ),
mLightColor( 1.0f, 1.0f, 1.0f ),
mLightAmbient( 0.5f, 0.5f, 0.5f ),
mLightDirection( 0.f, 0.707f, -0.707f )

View file

@ -36,7 +36,7 @@
#include "math/mathIO.h"
#include "torqueConfig.h"
#include "T3D/accumulationVolume.h"
IMPLEMENT_CO_NETOBJECT_V1(LevelInfo);
@ -69,6 +69,8 @@ extern ColorI gCanvasClearColor;
/// @see DecalManager
extern F32 gDecalBias;
/// @see AccumulationVolume
extern GFXTexHandle gLevelAccuMap;
/// Default SFXAmbience used to reset the global soundscape.
static SFXAmbience sDefaultAmbience;
@ -77,16 +79,16 @@ static SFXAmbience sDefaultAmbience;
//-----------------------------------------------------------------------------
LevelInfo::LevelInfo()
: mNearClip( 0.1f ),
: mWorldSize( 10000.0f ),
mNearClip( 0.1f ),
mVisibleDistance( 1000.0f ),
mVisibleGhostDistance ( 0 ),
mDecalBias( 0.0015f ),
mCanvasClearColor( 255, 0, 255, 255 ),
mAmbientLightBlendPhase( 1.f ),
mSoundAmbience( NULL ),
mSoundscape( NULL ),
mSoundDistanceModel( SFXDistanceModelLinear ),
mWorldSize( 10000.0f ),
mAmbientLightBlendPhase( 1.f )
mSoundscape( NULL )
{
mFogData.density = 0.0f;
mFogData.densityOffset = 0.0f;
@ -96,6 +98,8 @@ LevelInfo::LevelInfo()
mNetFlags.set( ScopeAlways | Ghostable );
mAdvancedLightmapSupport = false;
mAccuTextureName = "";
mAccuTexture = NULL;
// Register with the light manager activation signal, and we need to do it first
// so the advanced light bin manager can be instructed about MRT lightmaps
@ -107,6 +111,11 @@ LevelInfo::LevelInfo()
LevelInfo::~LevelInfo()
{
LightManager::smActivateSignal.remove(this, &LevelInfo::_onLMActivate);
if (!mAccuTexture.isNull())
{
mAccuTexture.free();
gLevelAccuMap.free();
}
}
//-----------------------------------------------------------------------------
@ -157,6 +166,9 @@ void LevelInfo::initPersistFields()
addField( "advancedLightmapSupport", TypeBool, Offset( mAdvancedLightmapSupport, LevelInfo ),
"Enable expanded support for mixing static and dynamic lighting (more costly)" );
addProtectedField("AccuTexture", TypeStringFilename, Offset(mAccuTextureName, LevelInfo),
&_setLevelAccuTexture, &defaultProtectedGetFn, "Accumulation texture.");
endGroup( "Lighting" );
addGroup( "Sound" );
@ -203,7 +215,8 @@ U32 LevelInfo::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
sfxWrite( stream, mSoundAmbience );
stream->writeInt( mSoundDistanceModel, 1 );
stream->write(mAccuTextureName);
return retMask;
}
@ -248,6 +261,8 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream)
SFX->setDistanceModel( mSoundDistanceModel );
}
stream->read(&mAccuTextureName);
setLevelAccuTexture(mAccuTextureName);
}
//-----------------------------------------------------------------------------
@ -341,4 +356,26 @@ void LevelInfo::_onLMActivate(const char *lm, bool enable)
lightMgr->getLightBinManager()->MRTLightmapsDuringPrePass(mAdvancedLightmapSupport);
}
#endif
}
bool LevelInfo::_setLevelAccuTexture(void *object, const char *index, const char *data)
{
LevelInfo* volume = reinterpret_cast< LevelInfo* >(object);
volume->setLevelAccuTexture(data);
return false;
}
void LevelInfo::setLevelAccuTexture(const String& name)
{
mAccuTextureName = name;
if (isClientObject() && mAccuTextureName.isNotEmpty())
{
mAccuTexture.set(mAccuTextureName, &GFXDefaultStaticDiffuseProfile, "AccumulationVolume::mAccuTexture");
if (mAccuTexture.isNull())
Con::warnf("AccumulationVolume::setTexture - Unable to load texture: %s", mAccuTextureName.c_str());
else
gLevelAccuMap = mAccuTexture;
}
AccumulationVolume::refreshVolumes();
}

View file

@ -36,6 +36,10 @@
#include "sfx/sfxCommon.h"
#endif
#ifndef _GFXTEXTUREHANDLE_H_
#include "gfx/gfxTextureHandle.h"
#endif
class SFXAmbience;
class SFXSoundscape;
@ -96,6 +100,9 @@ class LevelInfo : public NetObject
void _updateSceneGraph();
void _onLMActivate(const char *lm, bool enable);
protected:
// Name (path) of the accumulation texture.
String mAccuTextureName;
public:
@ -130,9 +137,12 @@ class LevelInfo : public NetObject
UpdateMask = BIT(0)
};
GFXTexHandle mAccuTexture;
virtual U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
virtual void unpackUpdate( NetConnection *conn, BitStream *stream );
static bool _setLevelAccuTexture(void *object, const char *index, const char *data);
void setLevelAccuTexture(const String& name);
/// @}
};

View file

@ -93,7 +93,7 @@ void LightBase::initPersistFields()
addField( "brightness", TypeF32, Offset( mBrightness, LightBase ), "Adjusts the lights power, 0 being off completely." );
addField( "castShadows", TypeBool, Offset( mCastShadows, LightBase ), "Enables/disabled shadow casts by this light." );
addField( "staticRefreshFreq", TypeS32, Offset( mStaticRefreshFreq, LightBase ), "static shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightBase ), "dynamic shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightBase ), "dynamic shadow refresh rate (milliseconds)", AbstractClassRep::FieldFlags::FIELD_HideInInspectors);
addField( "priority", TypeF32, Offset( mPriority, LightBase ), "Used for sorting of lights by the light manager. "
"Priority determines if a light has a stronger effect than, those with a lower value" );

View file

@ -97,7 +97,7 @@ void LightDescription::initPersistFields()
addField( "range", TypeF32, Offset( range, LightDescription ), "Controls the size (radius) of the light" );
addField( "castShadows", TypeBool, Offset( castShadows, LightDescription ), "Enables/disabled shadow casts by this light." );
addField( "staticRefreshFreq", TypeS32, Offset( mStaticRefreshFreq, LightDescription ), "static shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightDescription ), "dynamic shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightDescription ), "dynamic shadow refresh rate (milliseconds)", AbstractClassRep::FieldFlags::FIELD_HideInInspectors);
endGroup( "Light" );

View file

@ -33,6 +33,7 @@
#include "gfx/gfxOcclusionQuery.h"
#include "gfx/gfxDrawUtil.h"
#include "gfx/gfxTextureManager.h"
#include "gfx/sim/debugDraw.h"
#include "renderInstance/renderPassManager.h"
#include "T3D/gameBase/gameConnection.h"
#include "T3D/gameBase/processList.h"
@ -117,11 +118,11 @@ ConsoleDocClass( LightFlareData,
);
LightFlareData::LightFlareData()
: mFlareEnabled( true ),
mElementCount( 0 ),
mScale( 1.0f ),
: mScale( 1.0f ),
mFlareEnabled( true ),
mOcclusionRadius( 0.0f ),
mRenderReflectPass( true )
mRenderReflectPass( true ),
mElementCount( 0 )
{
dMemset( mElementRect, 0, sizeof( RectF ) * MAX_ELEMENTS );
dMemset( mElementScale, 0, sizeof( F32 ) * MAX_ELEMENTS );
@ -275,12 +276,10 @@ bool LightFlareData::_testVisibility(const SceneRenderState *state, LightFlareSt
// is on scren at all... if not then return
// the last result.
const Point3F &lightPos = flareState->lightMat.getPosition();
const RectI &viewport = GFX->getViewport();
MatrixF projMatrix;
state->getCameraFrustum().getProjectionMatrix(&projMatrix);
if( state->isReflectPass() )
projMatrix = state->getSceneManager()->getNonClipProjection();
bool onScreen = MathUtils::mProjectWorldToScreen( lightPos, outLightPosSS, viewport, GFX->getWorldMatrix(), projMatrix );
const RectI &viewport = RectI(Point2I(0, 0), GFX->getViewport().extent);
MatrixF camProjMatrix = state->getSceneManager()->getNonClipProjection();
bool onScreen = MathUtils::mProjectWorldToScreen( lightPos, outLightPosSS, viewport, GFX->getWorldMatrix(), camProjMatrix );
// It is onscreen, so raycast as a simple occlusion test.
const LightInfo *lightInfo = flareState->lightInfo;
@ -297,7 +296,7 @@ bool LightFlareData::_testVisibility(const SceneRenderState *state, LightFlareSt
// Always treat light as onscreen if using HOQ
// it will be faded out if offscreen anyway.
onScreen = true;
needsRaycast = false;
needsRaycast = false;
// Test the hardware queries for rendered pixels.
U32 pixels = 0, fullPixels = 0;
@ -400,63 +399,75 @@ bool LightFlareData::_testVisibility(const SceneRenderState *state, LightFlareSt
return lightVisible;
}
void LightFlareData::prepRender( SceneRenderState *state, LightFlareState *flareState )
void LightFlareData::prepRender(SceneRenderState *state, LightFlareState *flareState)
{
PROFILE_SCOPE( LightFlareData_prepRender );
PROFILE_SCOPE(LightFlareData_prepRender);
const LightInfo *lightInfo = flareState->lightInfo;
if ( mIsZero( flareState->fullBrightness ) ||
mIsZero( lightInfo->getBrightness() ) )
return;
if (mIsZero(flareState->fullBrightness) ||
mIsZero(lightInfo->getBrightness()))
return;
// Figure out the element count to render.
U32 elementCount = mElementCount;
const bool isReflectPass = state->isReflectPass();
if ( isReflectPass )
if (isReflectPass)
{
// Then we don't render anything this pass.
if ( !mRenderReflectPass )
if (!mRenderReflectPass)
return;
// Find the zero distance elements which make
// up the corona of the light flare.
elementCount = 0.0f;
for ( U32 i=0; i < mElementCount; i++ )
if ( mIsZero( mElementDist[i] ) )
elementCount++;
for (U32 i = 0; i < mElementCount; i++)
if (mIsZero(mElementDist[i]))
elementCount++;
}
// Better have something to render.
if ( elementCount == 0 )
if (elementCount == 0)
return;
U32 visDelta = U32_MAX;
F32 occlusionFade = 1.0f;
Point3F lightPosSS;
bool lightVisible = _testVisibility( state, flareState, &visDelta, &occlusionFade, &lightPosSS );
bool lightVisible = _testVisibility(state, flareState, &visDelta, &occlusionFade, &lightPosSS);
//DebugDrawer::get()->drawBox(flareState->lightMat.getPosition() + Point3F(-0.5, -0.5, -0.5) * 4, flareState->lightMat.getPosition() + Point3F(0.5, 0.5, 0.5) * 4, ColorI::BLUE);
// We can only skip rendering if the light is not
// visible, and it has elapsed the fade out time.
if ( mIsZero( occlusionFade ) ||
!lightVisible && visDelta > FadeOutTime )
if (mIsZero(occlusionFade) ||
!lightVisible && visDelta > FadeOutTime)
return;
const RectI &viewport = GFX->getViewport();
Point3F oneOverViewportExtent( 1.0f / (F32)viewport.extent.x, 1.0f / (F32)viewport.extent.y, 0.0f );
Point3F oneOverViewportExtent(1.0f / (F32)viewport.extent.x, 1.0f / (F32)viewport.extent.y, 0.0f);
// Really convert it to screen space.
lightPosSS.x -= viewport.point.x;
lightPosSS.y -= viewport.point.y;
lightPosSS *= oneOverViewportExtent;
lightPosSS = ( lightPosSS * 2.0f ) - Point3F::One;
lightPosSS = (lightPosSS * 2.0f) - Point3F::One;
lightPosSS.y = -lightPosSS.y;
lightPosSS.z = 0.0f;
// Determine the center of the current projection so we can converge there
Point3F centerProj(0);
{
MatrixF camProjMatrix = state->getSceneManager()->getNonClipProjection();
Point3F outCenterPos;
RectI centerViewport = RectI(Point2I(0, 0), viewport.extent);
MathUtils::mProjectWorldToScreen(Point3F(0,state->getSceneManager()->getNearClip(),0), &outCenterPos, centerViewport, MatrixF::Identity, camProjMatrix);
centerProj = outCenterPos;
centerProj *= oneOverViewportExtent;
centerProj = (centerProj * 2.0f) - Point3F::One;
centerProj.y = -centerProj.y;
centerProj.z = 0.0f;
}
// Take any projection offset into account so that the point where the flare's
// elements converge is at the 'eye' point rather than the center of the viewport.
const Point2F& projOffset = state->getCameraFrustum().getProjectionOffset();
Point3F flareVec( -lightPosSS + Point3F(projOffset.x, projOffset.y, 0.0f) );
Point3F flareVec( centerProj - lightPosSS );
const F32 flareLength = flareVec.len();
if ( flareLength > 0.0f )
flareVec *= 1.0f / flareLength;

View file

@ -151,7 +151,7 @@ enum SceneObjectTypes
/// @}
};
enum SceneObjectTypeMasks
enum SceneObjectTypeMasks : U32
{
STATIC_COLLISION_TYPEMASK = (StaticShapeObjectType |
EntityObjectType),

View file

@ -46,9 +46,9 @@ struct PhysicsState
momentum( Point3F::Zero ),
orientation( QuatF::Identity ),
angularMomentum( Point3F::Zero ),
sleeping( false ),
linVelocity( Point3F::Zero ),
angVelocity( Point3F::Zero ),
sleeping( false )
angVelocity( Point3F::Zero )
{
}

View file

@ -312,11 +312,11 @@ PhysicsDebris* PhysicsDebris::create( PhysicsDebrisData *datablock,
}
PhysicsDebris::PhysicsDebris()
: mDataBlock( NULL ),
mLifetime( 0.0f ),
: mLifetime( 0.0f ),
mInitialLinVel( Point3F::Zero ),
mDataBlock( NULL ),
mShapeInstance( NULL ),
mWorld( NULL ),
mInitialLinVel( Point3F::Zero )
mWorld( NULL )
{
mTypeMask |= DebrisObjectType | DynamicShapeObjectType;

View file

@ -41,9 +41,10 @@ ConsoleDocClass( PhysicsForce,
PhysicsForce::PhysicsForce()
: mWorld( NULL ),
mBody( NULL ),
mPhysicsTick( false )
:
mWorld( NULL ),
mPhysicsTick( false ),
mBody( NULL )
{
}

View file

@ -31,6 +31,7 @@
#include "T3D/physics/physicsBody.h"
#include "T3D/physics/physicsWorld.h"
#include "T3D/physics/physicsCollision.h"
#include "T3D/gameBase/gameConnection.h"
#include "collision/concretePolyList.h"
#include "ts/tsShapeInstance.h"
#include "scene/sceneRenderState.h"
@ -271,7 +272,7 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
{
if ( !Parent::preload( server, errorBuffer ) )
return false;
// If we don't have a physics plugin active then
// we have to fail completely.
if ( !PHYSICSMGR )
@ -280,22 +281,24 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
return false;
}
if ( !shapeName || !shapeName[0] )
{
errorBuffer = "PhysicsShapeData::preload - No shape name defined.";
return false;
}
bool shapeError = false;
// Load the shape.
shape = ResourceManager::get().load( shapeName );
if ( bool(shape) == false )
if (shapeName && shapeName[0])
{
errorBuffer = String::ToString( "PhysicsShapeData::preload - Unable to load shape '%s'.", shapeName );
return false;
// Resolve shapename
shape = ResourceManager::get().load(shapeName);
if (bool(shape) == false)
{
errorBuffer = String::ToString("PhysicsShapeData: Couldn't load shape \"%s\"", shapeName);
return false;
}
if (!server && !shape->preloadMaterialList(shape.getPath()) && NetConnection::filesWereDownloaded())
shapeError = true;
}
// Prepare the shared physics collision shape.
if ( !colShape )
if ( !colShape && shape )
{
colShape = shape->buildColShape( false, Point3F::One );
@ -303,8 +306,14 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
// we need to fail... can't have a shape without collision.
if ( !colShape )
{
errorBuffer = String::ToString( "PhysicsShapeData::preload - No collision found for shape '%s'.", shapeName );
return false;
//no collision so we create a simple box collision shape from the shapes bounds and alert the user
Con::warnf( "PhysicsShapeData::preload - No collision found for shape '%s', auto-creating one", shapeName );
Point3F halfWidth = shape->bounds.getExtents() * 0.5f;
colShape = PHYSICSMGR->createCollision();
MatrixF centerXfm(true);
centerXfm.setPosition(shape->bounds.getCenter());
colShape->addBox(halfWidth, centerXfm);
return true;
}
}
@ -376,7 +385,7 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
MatrixF::Identity );
*/
return true;
return !shapeError;
}
@ -392,12 +401,12 @@ ConsoleDocClass( PhysicsShape,
PhysicsShape::PhysicsShape()
: mPhysicsRep( NULL ),
mWorld( NULL ),
mShapeInst( NULL ),
mResetPos( MatrixF::Identity ),
mShapeInst( NULL ),
mDestroyed( false ),
mPlayAmbient( false ),
mAmbientThread( NULL ),
mAmbientSeq( -1 )
mAmbientSeq( -1 ),
mAmbientThread( NULL )
{
mNetFlags.set( Ghostable | ScopeAlways );
mTypeMask |= DynamicShapeObjectType;
@ -694,7 +703,7 @@ bool PhysicsShape::_createShape()
mAmbientSeq = -1;
PhysicsShapeData *db = getDataBlock();
if ( !db )
if ( !db || !db->shape)
return false;
// Set the world box.

View file

@ -55,11 +55,12 @@ public:
/// The constructor.
PhysicsUserData()
: mObject( NULL ),
:
#ifdef TORQUE_DEBUG
mTypeId( smTypeName ),
#endif
mObject( NULL ),
mBody( NULL )
#ifdef TORQUE_DEBUG
, mTypeId( smTypeName )
#endif
{}
/// The destructor.
@ -117,4 +118,4 @@ protected:
PhysicsBody *mBody;
};
#endif // _PHYSICS_PHYSICSUSERDATA_H_
#endif // _PHYSICS_PHYSICSUSERDATA_H_

View file

@ -56,11 +56,18 @@
#include "T3D/decal/decalManager.h"
#include "T3D/decal/decalData.h"
#include "materials/baseMatInstance.h"
#include "math/mathUtils.h"
#include "gfx/sim/debugDraw.h"
#ifdef TORQUE_EXTENDED_MOVE
#include "T3D/gameBase/extended/extendedMove.h"
#endif
#ifdef TORQUE_OPENVR
#include "platform/input/openVR/openVRProvider.h"
#include "platform/input/openVR/openVRTrackedObject.h"
#endif
// Amount of time if takes to transition to a new action sequence.
static F32 sAnimationTransitionTime = 0.25f;
static bool sUseAnimationTransitions = true;
@ -102,8 +109,6 @@ static S32 sMaxPredictionTicks = 30; // Number of ticks to predict
S32 Player::smExtendedMoveHeadPosRotIndex = 0; // The ExtendedMove position/rotation index used for head movements
// Anchor point compression
const F32 sAnchorMaxDistance = 32.0f;
//
static U32 sCollisionMoveMask = TerrainObjectType |
@ -1776,7 +1781,7 @@ void Player::onRemove()
mWorkingQueryBox.minExtents.set(-1e9f, -1e9f, -1e9f);
mWorkingQueryBox.maxExtents.set(-1e9f, -1e9f, -1e9f);
SAFE_DELETE( mPhysicsRep );
SAFE_DELETE( mPhysicsRep );
Parent::onRemove();
}
@ -2489,10 +2494,25 @@ void Player::allowAllPoses()
mAllowSwimming = true;
}
AngAxisF gPlayerMoveRot;
void Player::updateMove(const Move* move)
{
delta.move = *move;
#ifdef TORQUE_OPENVR
if (mControllers[0])
{
mControllers[0]->processTick(move);
}
if (mControllers[1])
{
mControllers[1]->processTick(move);
}
#endif
// Is waterCoverage high enough to be 'swimming'?
{
bool swimming = mWaterCoverage > 0.65f && canSwim();
@ -2531,6 +2551,7 @@ void Player::updateMove(const Move* move)
delta.headVec = mHead;
bool doStandardMove = true;
bool absoluteDelta = false;
GameConnection* con = getControllingClient();
#ifdef TORQUE_EXTENDED_MOVE
@ -2618,6 +2639,38 @@ void Player::updateMove(const Move* move)
while (mHead.y > M_PI_F)
mHead.y -= M_2PI_F;
}
else
{
// Orient the player so we are looking towards the required position, ignoring any banking
AngAxisF moveRot(Point3F(emove->rotX[emoveIndex], emove->rotY[emoveIndex], emove->rotZ[emoveIndex]), emove->rotW[emoveIndex]);
MatrixF trans(1);
moveRot.setMatrix(&trans);
trans.inverse();
Point3F vecForward(0, 10, 0);
Point3F viewAngle;
Point3F orient;
EulerF rot;
trans.mulV(vecForward);
viewAngle = vecForward;
vecForward.z = 0; // flatten
vecForward.normalizeSafe();
F32 yawAng;
F32 pitchAng;
MathUtils::getAnglesFromVector(vecForward, yawAng, pitchAng);
mRot = EulerF(0);
mRot.z = yawAng;
mHead = EulerF(0);
while (mRot.z < 0.0f)
mRot.z += M_2PI_F;
while (mRot.z > M_2PI_F)
mRot.z -= M_2PI_F;
absoluteDelta = true;
}
}
#endif
@ -2666,6 +2719,13 @@ void Player::updateMove(const Move* move)
delta.head = mHead;
delta.headVec -= mHead;
if (absoluteDelta)
{
delta.headVec = Point3F(0, 0, 0);
delta.rotVec = Point3F(0, 0, 0);
}
for(U32 i=0; i<3; ++i)
{
if (delta.headVec[i] > M_PI_F)
@ -3275,9 +3335,9 @@ bool Player::canCrouch()
if ( mDataBlock->actionList[PlayerData::CrouchRootAnim].sequence == -1 )
return false;
// We are already in this pose, so don't test it again...
if ( mPose == CrouchPose )
return true;
// We are already in this pose, so don't test it again...
if ( mPose == CrouchPose )
return true;
// Do standard Torque physics test here!
if ( !mPhysicsRep )
@ -3327,8 +3387,8 @@ bool Player::canStand()
return false;
// We are already in this pose, so don't test it again...
if ( mPose == StandPose )
return true;
if ( mPose == StandPose )
return true;
// Do standard Torque physics test here!
if ( !mPhysicsRep )
@ -3391,9 +3451,9 @@ bool Player::canProne()
if ( !mPhysicsRep )
return true;
// We are already in this pose, so don't test it again...
if ( mPose == PronePose )
return true;
// We are already in this pose, so don't test it again...
if ( mPose == PronePose )
return true;
return mPhysicsRep->testSpacials( getPosition(), mDataBlock->proneBoxSize );
}
@ -3590,7 +3650,7 @@ MatrixF * Player::Death::fallToGround(F32 dt, const Point3F& loc, F32 curZ, F32
normal.normalize();
mat.set(EulerF (0.0f, 0.0f, curZ));
mat.mulV(upY, & ahead);
mCross(ahead, normal, &sideVec);
mCross(ahead, normal, &sideVec);
sideVec.normalize();
mCross(normal, sideVec, &ahead);
@ -3773,11 +3833,13 @@ void Player::updateActionThread()
// Select an action animation sequence, this assumes that
// this function is called once per tick.
if(mActionAnimation.action != PlayerData::NullAnimation)
{
if (mActionAnimation.forward)
mActionAnimation.atEnd = mShapeInstance->getPos(mActionAnimation.thread) == 1;
else
mActionAnimation.atEnd = mShapeInstance->getPos(mActionAnimation.thread) == 0;
}
// Only need to deal with triggers on the client
if( isGhost() )
{
@ -4452,7 +4514,7 @@ void Player::onImageAnimThreadUpdate(U32 imageSlot, S32 imageShapeIndex, F32 dt)
}
}
void Player::onUnmount( ShapeBase *obj, S32 node )
void Player::onUnmount( SceneObject *obj, S32 node )
{
// Reset back to root position during dismount.
setActionThread(PlayerData::RootAnim,true,false,false);
@ -4519,6 +4581,7 @@ void Player::updateAnimationTree(bool firstPerson)
{
S32 mode = 0;
if (firstPerson)
{
if (mActionAnimation.firstPerson)
mode = 0;
// TSShapeInstance::MaskNodeRotation;
@ -4526,7 +4589,7 @@ void Player::updateAnimationTree(bool firstPerson)
// TSShapeInstance::MaskNodePosY;
else
mode = TSShapeInstance::MaskNodeAllButBlend;
}
for (U32 i = 0; i < PlayerData::NumSpineNodes; i++)
if (mDataBlock->spineNode[i] != -1)
mShapeInstance->setNodeAnimationState(mDataBlock->spineNode[i],mode);
@ -5589,58 +5652,6 @@ void Player::getMuzzleTransform(U32 imageSlot,MatrixF* mat)
*mat = nmat;
}
DisplayPose Player::calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose)
{
// NOTE: this is intended to be similar to updateMove
DisplayPose outPose;
outPose.orientation = getRenderTransform().toEuler();
outPose.position = inPose.position;
if (con && con->getControlSchemeAbsoluteRotation())
{
// Pitch
outPose.orientation.x = (inPose.orientation.x - mLastAbsolutePitch);
// Constrain the range of mRot.x
while (outPose.orientation.x < -M_PI_F)
outPose.orientation.x += M_2PI_F;
while (outPose.orientation.x > M_PI_F)
outPose.orientation.x -= M_2PI_F;
// Yaw
// Rotate (heading) head or body?
if ((isMounted() && getMountNode() == 0) || (con && !con->isFirstPerson()))
{
// Rotate head
outPose.orientation.z = (inPose.orientation.z - mLastAbsoluteYaw);
}
else
{
// Rotate body
outPose.orientation.z = (inPose.orientation.z - mLastAbsoluteYaw);
}
// Constrain the range of mRot.z
while (outPose.orientation.z < 0.0f)
outPose.orientation.z += M_2PI_F;
while (outPose.orientation.z > M_2PI_F)
outPose.orientation.z -= M_2PI_F;
// Bank
if (mDataBlock->cameraCanBank)
{
outPose.orientation.y = (inPose.orientation.y - mLastAbsoluteRoll);
}
// Constrain the range of mRot.y
while (outPose.orientation.y > M_PI_F)
outPose.orientation.y -= M_2PI_F;
}
return outPose;
}
void Player::getRenderMuzzleTransform(U32 imageSlot,MatrixF* mat)
{
disableHeadZCalc();
@ -5836,7 +5847,7 @@ F32 Player::getSpeed() const
void Player::setVelocity(const VectorF& vel)
{
AssertFatal( !mIsNaN( vel ), "Player::setVelocity() - The velocity is NaN!" );
AssertFatal( !mIsNaN( vel ), "Player::setVelocity() - The velocity is NaN!" );
mVelocity = vel;
setMaskBits(MoveMask);
@ -5844,7 +5855,7 @@ void Player::setVelocity(const VectorF& vel)
void Player::applyImpulse(const Point3F&,const VectorF& vec)
{
AssertFatal( !mIsNaN( vec ), "Player::applyImpulse() - The vector is NaN!" );
AssertFatal( !mIsNaN( vec ), "Player::applyImpulse() - The vector is NaN!" );
// Players ignore angular velocity
VectorF vel;
@ -6192,7 +6203,7 @@ U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
stream->writeFlag(mSwimming);
stream->writeFlag(mJetting);
stream->writeInt(mPose, NumPoseBits);
stream->writeInt(mState,NumStateBits);
if (stream->writeFlag(mState == RecoverState))
stream->writeInt(mRecoverTicks,PlayerData::RecoverDelayBits);
@ -6293,7 +6304,7 @@ void Player::unpackUpdate(NetConnection *con, BitStream *stream)
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);
@ -7160,3 +7171,38 @@ void Player::renderConvex( ObjectRenderInst *ri, SceneRenderState *state, BaseMa
mConvex.renderWorkingList();
GFX->leaveDebugEvent();
}
#ifdef TORQUE_OPENVR
void Player::setControllers(Vector<OpenVRTrackedObject*> controllerList)
{
mControllers[0] = controllerList.size() > 0 ? controllerList[0] : NULL;
mControllers[1] = controllerList.size() > 1 ? controllerList[1] : NULL;
}
ConsoleMethod(Player, setVRControllers, void, 4, 4, "")
{
OpenVRTrackedObject *controllerL, *controllerR;
Vector<OpenVRTrackedObject*> list;
if (Sim::findObject(argv[2], controllerL))
{
list.push_back(controllerL);
}
else
{
list.push_back(NULL);
}
if (Sim::findObject(argv[3], controllerR))
{
list.push_back(controllerR);
}
else
{
list.push_back(NULL);
}
object->setControllers(list);
}
#endif

View file

@ -40,6 +40,10 @@ class SplashData;
class PhysicsPlayer;
class Player;
#ifdef TORQUE_OPENVR
class OpenVRTrackedObject;
#endif
//----------------------------------------------------------------------------
struct PlayerData: public ShapeBaseData {
@ -480,7 +484,7 @@ protected:
/// @{
struct ActionAnimation {
U32 action;
S32 action;
TSThread* thread;
S32 delayTicks; // before picking another.
bool forward;
@ -518,6 +522,10 @@ protected:
Point3F mLastPos; ///< Holds the last position for physics updates
Point3F mLastWaterPos; ///< Same as mLastPos, but for water
#ifdef TORQUE_OPENVR
SimObjectPtr<OpenVRTrackedObject> mControllers[2];
#endif
struct ContactInfo
{
bool contacted, jump, run;
@ -577,12 +585,17 @@ protected:
PhysicsPlayer* getPhysicsRep() const { return mPhysicsRep; }
#ifdef TORQUE_OPENVR
void setControllers(Vector<OpenVRTrackedObject*> controllerList);
#endif
protected:
virtual void reSkin();
void setState(ActionState state, U32 ticks=0);
void updateState();
// Jetting
bool mJetting;
@ -615,7 +628,7 @@ protected:
/// @name Mounted objects
/// @{
virtual void onUnmount( ShapeBase *obj, S32 node );
virtual void onUnmount( SceneObject *obj, S32 node );
virtual void unmount();
/// @}
@ -686,7 +699,6 @@ public:
void getEyeBaseTransform(MatrixF* mat, bool includeBank);
void getRenderEyeTransform(MatrixF* mat);
void getRenderEyeBaseTransform(MatrixF* mat, bool includeBank);
virtual DisplayPose calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose);
void getCameraParameters(F32 *min, F32 *max, Point3F *offset, MatrixF *rot);
void getMuzzleTransform(U32 imageSlot,MatrixF* mat);
void getRenderMuzzleTransform(U32 imageSlot,MatrixF* mat);

View file

@ -525,6 +525,19 @@ bool Prefab::isValidChild( SimObject *simobj, bool logWarnings )
return true;
}
bool Prefab::buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere)
{
Vector<SceneObject*> foundObjects;
mChildGroup->findObjectByType(foundObjects);
for (S32 i = 0; i < foundObjects.size(); i++)
{
foundObjects[i]->buildPolyList(context, polyList, box, sphere);
}
return true;
}
ExplodePrefabUndoAction::ExplodePrefabUndoAction( Prefab *prefab )
: UndoAction( "Explode Prefab" )
{

View file

@ -96,6 +96,8 @@ public:
/// which is added to the MissionGroup and returned to the caller.
SimGroup* explode();
bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere);
protected:
void _closeFile( bool removeFileNotify );

View file

@ -566,14 +566,14 @@ S32 ProjectileData::scaleValue( S32 value, bool down )
Projectile::Projectile()
: mPhysicsWorld( NULL ),
mDataBlock( NULL ),
mParticleEmitter( NULL ),
mParticleWaterEmitter( NULL ),
mSound( NULL ),
mCurrPosition( 0, 0, 0 ),
mCurrVelocity( 0, 0, 1 ),
mSourceObjectId( -1 ),
mSourceObjectSlot( -1 ),
mCurrTick( 0 ),
mParticleEmitter( NULL ),
mParticleWaterEmitter( NULL ),
mSound( NULL ),
mProjectileShape( NULL ),
mActivateThread( NULL ),
mMaintainThread( NULL ),
@ -1471,4 +1471,4 @@ DefineEngineMethod(Projectile, presimulate, void, (F32 seconds), (1.0f),
"@note This function is not called if the SimObject::hidden is true.")
{
object->simulate( seconds );
}
}

View file

@ -187,8 +187,6 @@ IMPLEMENT_CALLBACK( RigidShape, onLeaveLiquid, void, ( const char* objId, const
namespace {
const U32 sMoveRetryCount = 3;
// Client prediction
const S32 sMaxWarpTicks = 3; // Max warp duration in ticks
const S32 sMaxPredictionTicks = 30; // Number of ticks to predict

View file

@ -95,9 +95,9 @@ SFXEmitter::SFXEmitter()
: SceneObject(),
mSource( NULL ),
mTrack( NULL ),
mUseTrackDescriptionOnly( false ),
mLocalProfile( &mDescription ),
mPlayOnAdd( true ),
mUseTrackDescriptionOnly( false )
mPlayOnAdd( true )
{
mTypeMask |= MarkerObjectType;
mNetFlags.set( Ghostable | ScopeAlways );

View file

@ -62,6 +62,7 @@
#include "materials/materialFeatureTypes.h"
#include "renderInstance/renderOcclusionMgr.h"
#include "core/stream/fileStream.h"
#include "T3D/accumulationVolume.h"
IMPLEMENT_CO_DATABLOCK_V1(ShapeBaseData);
@ -167,12 +168,9 @@ ShapeBaseData::ShapeBaseData()
density( 1.0f ),
maxEnergy( 0.0f ),
maxDamage( 1.0f ),
destroyedLevel( 1.0f ),
disabledLevel( 1.0f ),
repairRate( 0.0033f ),
eyeNode( -1 ),
earNode( -1 ),
cameraNode( -1 ),
disabledLevel( 1.0f ),
destroyedLevel( 1.0f ),
cameraMaxDist( 0.0f ),
cameraMinDist( 0.2f ),
cameraDefaultFov( 75.0f ),
@ -180,6 +178,11 @@ ShapeBaseData::ShapeBaseData()
cameraMaxFov( 120.f ),
cameraCanBank( false ),
mountedImagesBank( false ),
mCRC( 0 ),
computeCRC( false ),
eyeNode( -1 ),
earNode( -1 ),
cameraNode( -1 ),
debrisDetail( -1 ),
damageSequence( -1 ),
hulkSequence( -1 ),
@ -188,9 +191,7 @@ ShapeBaseData::ShapeBaseData()
useEyePoint( false ),
isInvincible( false ),
renderWhenDestroyed( true ),
computeCRC( false ),
inheritEnergyFromMount( false ),
mCRC( 0 )
inheritEnergyFromMount( false )
{
dMemset( mountPointNode, -1, sizeof( S32 ) * SceneObject::NumMountPoints );
}
@ -1045,7 +1046,11 @@ bool ShapeBase::onAdd()
if(mDataBlock->cloakTexName != StringTable->insert(""))
mCloakTexture = TextureHandle(mDataBlock->cloakTexName, MeshTexture, false);
*/
// Accumulation and environment mapping
if (isClientObject() && mShapeInstance)
{
AccumulationVolume::addObject(this);
}
return true;
}
@ -1988,67 +1993,21 @@ void ShapeBase::getEyeCameraTransform(IDisplayDevice *displayDevice, U32 eyeId,
Point3F eyePos;
Point3F rotEyePos;
DisplayPose inPose;
displayDevice->getFrameEyePose(&inPose, eyeId);
DisplayPose newPose = calcCameraDeltaPose(displayDevice->getCurrentConnection(), inPose);
DisplayPose newPose;
displayDevice->getFrameEyePose(&newPose, eyeId);
// Ok, basically we just need to add on newPose to the camera transform
// NOTE: currently we dont support third-person camera in this mode
MatrixF cameraTransform(1);
F32 fakePos = 0;
//cameraTransform = getRenderTransform(); // use this for controllers TODO
getCameraTransform(&fakePos, &cameraTransform);
QuatF baserot = cameraTransform;
QuatF qrot = QuatF(newPose.orientation);
QuatF concatRot;
concatRot.mul(baserot, qrot);
concatRot.setMatrix(&temp);
temp.setPosition(cameraTransform.getPosition() + concatRot.mulP(newPose.position, &rotEyePos));
temp = MatrixF(1);
newPose.orientation.setMatrix(&temp);
temp.setPosition(newPose.position);
*outMat = temp;
}
DisplayPose ShapeBase::calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose)
{
// NOTE: this is intended to be similar to updateMove
// WARNING: does not take into account any move values
DisplayPose outPose;
outPose.orientation = getRenderTransform().toEuler();
outPose.position = inPose.position;
if (con && con->getControlSchemeAbsoluteRotation())
{
// Pitch
outPose.orientation.x = inPose.orientation.x;
// Constrain the range of mRot.x
while (outPose.orientation.x < -M_PI_F)
outPose.orientation.x += M_2PI_F;
while (outPose.orientation.x > M_PI_F)
outPose.orientation.x -= M_2PI_F;
// Yaw
outPose.orientation.z = inPose.orientation.z;
// Constrain the range of mRot.z
while (outPose.orientation.z < -M_PI_F)
outPose.orientation.z += M_2PI_F;
while (outPose.orientation.z > M_PI_F)
outPose.orientation.z -= M_2PI_F;
// Bank
if (mDataBlock->cameraCanBank)
{
outPose.orientation.y = inPose.orientation.y;
}
// Constrain the range of mRot.y
while (outPose.orientation.y > M_PI_F)
outPose.orientation.y -= M_2PI_F;
}
return outPose;
*outMat = cameraTransform * temp;
}
void ShapeBase::getCameraParameters(F32 *min,F32* max,Point3F* off,MatrixF* rot)

View file

@ -496,8 +496,8 @@ struct ShapeBaseImageData: public GameBaseData {
/// @name Callbacks
/// @{
DECLARE_CALLBACK( void, onMount, ( ShapeBase* obj, S32 slot, F32 dt ) );
DECLARE_CALLBACK( void, onUnmount, ( ShapeBase* obj, S32 slot, F32 dt ) );
DECLARE_CALLBACK( void, onMount, ( SceneObject* obj, S32 slot, F32 dt ) );
DECLARE_CALLBACK( void, onUnmount, ( SceneObject* obj, S32 slot, F32 dt ) );
/// @}
};
@ -1601,9 +1601,6 @@ public:
/// orient and position values of the display device.
virtual void getEyeCameraTransform( IDisplayDevice *display, U32 eyeId, MatrixF *outMat );
/// Calculates a delta camera angle and view position based on inPose
virtual DisplayPose calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose);
/// Gets the index of a node inside a mounted image given the name
/// @param imageSlot Image slot
/// @param nodeName Node name

View file

@ -97,14 +97,14 @@ ConsoleDocClass( ShapeBaseImageData,
"@ingroup gameObjects\n"
);
IMPLEMENT_CALLBACK( ShapeBaseImageData, onMount, void, ( ShapeBase* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
IMPLEMENT_CALLBACK( ShapeBaseImageData, onMount, void, ( SceneObject* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
"@brief Called when the Image is first mounted to the object.\n\n"
"@param obj object that this Image has been mounted to\n"
"@param slot Image mount slot on the object\n"
"@param dt time remaining in this Image update\n" );
IMPLEMENT_CALLBACK( ShapeBaseImageData, onUnmount, void, ( ShapeBase* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
IMPLEMENT_CALLBACK( ShapeBaseImageData, onUnmount, void, ( SceneObject* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
"@brief Called when the Image is unmounted from the object.\n\n"
"@param obj object that this Image has been unmounted from\n"
@ -3491,4 +3491,4 @@ void ShapeBase::shakeCamera( U32 imageSlot )
if(mBadPacket)
return;
mShapeBase->setImageState(mImageSlot, mState, true);
}
}

View file

@ -240,7 +240,7 @@ void StaticShape::setTransform(const MatrixF& mat)
setMaskBits(PositionMask);
}
void StaticShape::onUnmount(ShapeBase*,S32)
void StaticShape::onUnmount(SceneObject*,S32)
{
// Make sure the client get's the final server pos.
setMaskBits(PositionMask);
@ -251,14 +251,14 @@ void StaticShape::onUnmount(ShapeBase*,S32)
U32 StaticShape::packUpdate(NetConnection *connection, U32 mask, BitStream *bstream)
{
U32 retMask = Parent::packUpdate(connection,mask,bstream);
U32 retMask = Parent::packUpdate(connection, mask, bstream);
if (bstream->writeFlag(mask & PositionMask | ExtendedInfoMask))
{
// Write the transform (do _not_ use writeAffineTransform. Since this is a static
// object, the transform must be RIGHT THE *&)*$&^ ON or it will goof up the
// synchronization between the client and the server.
mathWrite(*bstream,mObjToWorld);
mathWrite(*bstream, mObjToWorld);
mathWrite(*bstream, mObjScale);
}
@ -275,11 +275,11 @@ U32 StaticShape::packUpdate(NetConnection *connection, U32 mask, BitStream *bstr
void StaticShape::unpackUpdate(NetConnection *connection, BitStream *bstream)
{
Parent::unpackUpdate(connection,bstream);
Parent::unpackUpdate(connection, bstream);
if (bstream->readFlag())
{
MatrixF mat;
mathRead(*bstream,&mat);
mathRead(*bstream, &mat);
Parent::setTransform(mat);
Parent::setRenderTransform(mat);
@ -302,7 +302,7 @@ void StaticShape::unpackUpdate(NetConnection *connection, BitStream *bstream)
// This appears to be legacy T2 stuff
// Marked internal, as this is flagged to be deleted
// [8/1/2010 mperry]
DefineConsoleMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(bool isPowered)"
DefineConsoleMethod(StaticShape, setPoweredState, void, (bool isPowered), , "(bool isPowered)"
"@internal")
{
if(!object->isServerObject())
@ -310,7 +310,7 @@ DefineConsoleMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(b
object->setPowered(isPowered);
}
DefineConsoleMethod( StaticShape, getPoweredState, bool, (), , "@internal")
DefineConsoleMethod(StaticShape, getPoweredState, bool, (), , "@internal")
{
if(!object->isServerObject())
return(false);

View file

@ -56,7 +56,7 @@ class StaticShape: public ShapeBase
StaticShapeData* mDataBlock;
bool mPowered;
void onUnmount(ShapeBase* obj,S32 node);
void onUnmount(SceneObject* obj,S32 node);
protected:
enum MaskBits {

View file

@ -310,11 +310,10 @@ bool TSStatic::onAdd()
_updateShouldTick();
// Accumulation
if ( isClientObject() && mShapeInstance )
// Accumulation and environment mapping
if (isClientObject() && mShapeInstance)
{
if ( mShapeInstance->hasAccumulation() )
AccumulationVolume::addObject(this);
AccumulationVolume::addObject(this);
}
return true;

View file

@ -228,6 +228,7 @@ public:
Resource<TSShape> getShape() const { return mShape; }
StringTableEntry getShapeFileName() { return mShapeName; }
void setShapeFileName(StringTableEntry shapeName) { mShapeName = shapeName; }
TSShapeInstance* getShapeInstance() const { return mShapeInstance; }

View file

@ -36,15 +36,6 @@
//----------------------------------------------------------------------------
// Client prediction
static F32 sMinWarpTicks = 0.5 ; // Fraction of tick at which instant warp occures
static S32 sMaxWarpTicks = 3; // Max warp duration in ticks
const U32 sClientCollisionMask = (TerrainObjectType |
StaticShapeObjectType |
VehicleObjectType);
const U32 sServerCollisionMask = (sClientCollisionMask);
// Trigger objects that are not normally collided with.
static U32 sTriggerMask = ItemObjectType |
TriggerObjectType |
@ -69,7 +60,7 @@ ConsoleDocClass( TurretShapeData,
"@ingroup gameObjects\n"
);
IMPLEMENT_CALLBACK( TurretShapeData, onMountObject, void, ( TurretShape* turret, SceneObject* obj, S32 node ),( turret, obj, node ),
IMPLEMENT_CALLBACK( TurretShapeData, onMountObject, void, ( SceneObject* turret, SceneObject* obj, S32 node ),( turret, obj, node ),
"@brief Informs the TurretShapeData object that a player is mounting it.\n\n"
"@param turret The TurretShape object.\n"
"@param obj The player that is mounting.\n"
@ -77,7 +68,7 @@ IMPLEMENT_CALLBACK( TurretShapeData, onMountObject, void, ( TurretShape* turret,
"@note Server side only.\n"
);
IMPLEMENT_CALLBACK( TurretShapeData, onUnmountObject, void, ( TurretShape* turret, SceneObject* obj ),( turret, obj ),
IMPLEMENT_CALLBACK( TurretShapeData, onUnmountObject, void, ( SceneObject* turret, SceneObject* obj ),( turret, obj ),
"@brief Informs the TurretShapeData object that a player is unmounting it.\n\n"
"@param turret The TurretShape object.\n"
"@param obj The player that is unmounting.\n"
@ -933,7 +924,7 @@ void TurretShape::unmountObject( SceneObject *obj )
}
}
void TurretShape::onUnmount(ShapeBase*,S32)
void TurretShape::onUnmount(SceneObject*,S32)
{
// Make sure the client get's the final server pos of this turret.
setMaskBits(PositionMask);

View file

@ -93,8 +93,8 @@ public:
virtual bool preload(bool server, String &errorStr);
DECLARE_CALLBACK( void, onMountObject, ( TurretShape* turret, SceneObject* obj, S32 node ) );
DECLARE_CALLBACK( void, onUnmountObject, ( TurretShape* turret, SceneObject* obj ) );
DECLARE_CALLBACK( void, onMountObject, ( SceneObject* turret, SceneObject* obj, S32 node ) );
DECLARE_CALLBACK( void, onUnmountObject, ( SceneObject* turret, SceneObject* obj ) );
DECLARE_CALLBACK( void, onStickyCollision, ( TurretShape* obj ) );
};
@ -150,7 +150,7 @@ protected:
void _applyLimits(Point3F& rot);
bool _outsideLimits(Point3F& rot); ///< Return true if any angle is outside of the limits
void onUnmount(ShapeBase* obj,S32 node);
void onUnmount(SceneObject* obj,S32 node);
// Script level control
bool allowManualRotation;

View file

@ -69,8 +69,6 @@ ConsoleDocClass( HoverVehicle,
);
namespace {
const U32 sIntergrationsPerTick = 1;
const F32 sHoverVehicleGravity = -20;
const U32 sCollisionMoveMask = (TerrainObjectType | PlayerObjectType |

View file

@ -63,8 +63,6 @@ static F32 sWorkingQueryBoxSizeMultiplier = 2.0f; // How much larger should the
// will be updated due to motion, but any non-static shape
// that moves into the query box will not be noticed.
const U32 sMoveRetryCount = 3;
// Client prediction
const S32 sMaxWarpTicks = 3; // Max warp duration in ticks
const S32 sMaxPredictionTicks = 30; // Number of ticks to predict