mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-05 21:40:31 +00:00
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:
commit
186604eb76
974 changed files with 121718 additions and 233088 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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++ )
|
||||
|
|
|
|||
|
|
@ -43,9 +43,6 @@
|
|||
|
||||
const U32 csmStaticCollisionMask = TerrainObjectType | StaticShapeObjectType | StaticObjectType;
|
||||
|
||||
const U32 csmDynamicCollisionMask = StaticShapeObjectType;
|
||||
|
||||
|
||||
IMPLEMENT_CO_DATABLOCK_V1(DebrisData);
|
||||
|
||||
ConsoleDocClass( DebrisData,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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; ///<
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 ) );
|
||||
/// @}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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);
|
||||
/// @}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ enum SceneObjectTypes
|
|||
/// @}
|
||||
};
|
||||
|
||||
enum SceneObjectTypeMasks
|
||||
enum SceneObjectTypeMasks : U32
|
||||
{
|
||||
STATIC_COLLISION_TYPEMASK = (StaticShapeObjectType |
|
||||
EntityObjectType),
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,9 +41,10 @@ ConsoleDocClass( PhysicsForce,
|
|||
|
||||
|
||||
PhysicsForce::PhysicsForce()
|
||||
: mWorld( NULL ),
|
||||
mBody( NULL ),
|
||||
mPhysicsTick( false )
|
||||
:
|
||||
mWorld( NULL ),
|
||||
mPhysicsTick( false ),
|
||||
mBody( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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_
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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" )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -69,8 +69,6 @@ ConsoleDocClass( HoverVehicle,
|
|||
);
|
||||
|
||||
namespace {
|
||||
|
||||
const U32 sIntergrationsPerTick = 1;
|
||||
const F32 sHoverVehicleGravity = -20;
|
||||
|
||||
const U32 sCollisionMoveMask = (TerrainObjectType | PlayerObjectType |
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -162,6 +162,13 @@ DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int po
|
|||
return Net::openPort((S32)port, bind);
|
||||
}
|
||||
|
||||
DefineConsoleFunction(isAddressTypeAvailable, bool, (int addressType), , "(protocol id)"
|
||||
"@brief Determines if a specified address type can be reached.\n\n"
|
||||
"@ingroup Networking")
|
||||
{
|
||||
return Net::isAddressTypeAvailable((NetAddress::Type)addressType);
|
||||
}
|
||||
|
||||
DefineConsoleFunction( closeNetPort, void, (), , "()"
|
||||
"@brief Closes the current network port\n\n"
|
||||
"@ingroup Networking")
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ void StandardMainLoop::init()
|
|||
Sampler::init();
|
||||
|
||||
// Hook in for UDP notification
|
||||
Net::smPacketReceive.notify(GNet, &NetInterface::processPacketReceiveEvent);
|
||||
Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent);
|
||||
|
||||
#ifdef TORQUE_DEBUG_GUARD
|
||||
Memory::flagCurrentAllocs( Memory::FLAG_Static );
|
||||
|
|
@ -604,15 +604,11 @@ bool StandardMainLoop::doMainLoop()
|
|||
lastFocus = newFocus;
|
||||
}
|
||||
|
||||
#ifndef TORQUE_OS_MAC
|
||||
// under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance
|
||||
if (!Platform::getWebDeployment())
|
||||
tm->setBackground(!newFocus);
|
||||
else
|
||||
tm->setBackground(false);
|
||||
#else
|
||||
tm->setBackground(false);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ static Vector<Ping> gQueryList(__FILE__, __LINE__);
|
|||
|
||||
struct PacketStatus
|
||||
{
|
||||
U8 index;
|
||||
U16 index;
|
||||
S32 key;
|
||||
U32 time;
|
||||
U32 tryCount;
|
||||
|
|
@ -191,6 +191,9 @@ struct PacketStatus
|
|||
time = _time;
|
||||
tryCount = gPacketRetryCount;
|
||||
}
|
||||
|
||||
inline U8 getOldIndex() { return (U8)index; }
|
||||
inline U16 getIndex() { return index; }
|
||||
};
|
||||
|
||||
static Vector<PacketStatus> gPacketStatusList(__FILE__, __LINE__);
|
||||
|
|
@ -212,6 +215,7 @@ struct ServerFilter
|
|||
OnlineQuery = 0, // Authenticated with master
|
||||
OfflineQuery = BIT(0), // On our own
|
||||
NoStringCompress = BIT(1),
|
||||
NewStyleResponse = BIT(2), // Include IPV6 servers
|
||||
};
|
||||
|
||||
enum // Filter flags:
|
||||
|
|
@ -222,6 +226,14 @@ struct ServerFilter
|
|||
CurrentVersion = BIT(7),
|
||||
NotXenon = BIT(6)
|
||||
};
|
||||
|
||||
enum // Region mask flags
|
||||
{
|
||||
RegionIsIPV4Address = BIT(30),
|
||||
RegionIsIPV6Address = BIT(31),
|
||||
|
||||
RegionAddressMask = RegionIsIPV4Address | RegionIsIPV6Address
|
||||
};
|
||||
|
||||
//Rearranging the fields according to their sizes
|
||||
char* gameType;
|
||||
|
|
@ -241,7 +253,7 @@ struct ServerFilter
|
|||
ServerFilter()
|
||||
{
|
||||
type = Normal;
|
||||
queryFlags = 0;
|
||||
queryFlags = NewStyleResponse;
|
||||
gameType = NULL;
|
||||
missionType = NULL;
|
||||
minPlayers = 0;
|
||||
|
|
@ -401,10 +413,17 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
|
|||
|
||||
NetAddress addr;
|
||||
char addrText[256];
|
||||
|
||||
// IPV4
|
||||
dSprintf( addrText, sizeof( addrText ), "IP:BROADCAST:%d", port );
|
||||
Net::stringToAddress( addrText, &addr );
|
||||
pushPingBroadcast( &addr );
|
||||
|
||||
// IPV6
|
||||
dSprintf(addrText, sizeof(addrText), "IP6:MULTICAST:%d", port);
|
||||
Net::stringToAddress(addrText, &addr);
|
||||
pushPingBroadcast(&addr);
|
||||
|
||||
Con::executef("onServerQueryStatus", "start", "Querying LAN servers", "0");
|
||||
processPingsAndQueries( gPingSession );
|
||||
}
|
||||
|
|
@ -502,7 +521,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
|
|||
dStrcpy( sActiveFilter.missionType, missionType );
|
||||
}
|
||||
|
||||
sActiveFilter.queryFlags = flags;
|
||||
sActiveFilter.queryFlags = flags | ServerFilter::NewStyleResponse;
|
||||
sActiveFilter.minPlayers = minPlayers;
|
||||
sActiveFilter.maxPlayers = maxPlayers;
|
||||
sActiveFilter.maxBots = maxBots;
|
||||
|
|
@ -519,6 +538,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
|
|||
sActiveFilter.type = ServerFilter::Buddy;
|
||||
sActiveFilter.buddyCount = buddyCount;
|
||||
sActiveFilter.buddyList = (U32*) dRealloc( sActiveFilter.buddyList, buddyCount * 4 );
|
||||
sActiveFilter.queryFlags = ServerFilter::NewStyleResponse;
|
||||
dMemcpy( sActiveFilter.buddyList, buddyList, buddyCount * 4 );
|
||||
clearServerList();
|
||||
}
|
||||
|
|
@ -775,7 +795,7 @@ Vector<MasterInfo>* getMasterServerList()
|
|||
U32 region = 1; // needs to default to something > 0
|
||||
dSscanf(master,"%d:",®ion);
|
||||
const char* madd = dStrchr(master,':') + 1;
|
||||
if (region && Net::stringToAddress(madd,&address)) {
|
||||
if (region && Net::stringToAddress(madd,&address) == Net::NoError) {
|
||||
masterList.increment();
|
||||
MasterInfo& info = masterList.last();
|
||||
info.address = address;
|
||||
|
|
@ -1171,10 +1191,13 @@ static void processMasterServerQuery( U32 session )
|
|||
// Send a request to the master server for the server list:
|
||||
BitStream *out = BitStream::getPacketStream();
|
||||
out->clearStringBuffer();
|
||||
|
||||
out->write( U8( NetInterface::MasterServerListRequest ) );
|
||||
|
||||
out->write( U8( sActiveFilter.queryFlags) );
|
||||
out->write( ( gMasterServerPing.session << 16 ) | ( gMasterServerPing.key & 0xFFFF ) );
|
||||
out->write( U8( 255 ) );
|
||||
|
||||
writeCString( out, sActiveFilter.gameType );
|
||||
writeCString( out, sActiveFilter.missionType );
|
||||
out->write( sActiveFilter.minPlayers );
|
||||
|
|
@ -1359,23 +1382,35 @@ static void processServerListPackets( U32 session )
|
|||
if ( !p.tryCount )
|
||||
{
|
||||
// Packet timed out :(
|
||||
Con::printf( "Server list packet #%d timed out.", p.index + 1 );
|
||||
Con::printf( "Server list packet #%d timed out.", p.getIndex() + 1 );
|
||||
gPacketStatusList.erase( i );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try again...
|
||||
Con::printf( "Rerequesting server list packet #%d...", p.index + 1 );
|
||||
Con::printf( "Rerequesting server list packet #%d...", p.getIndex() + 1 );
|
||||
p.tryCount--;
|
||||
p.time = currentTime;
|
||||
p.key = gKey++;
|
||||
|
||||
BitStream *out = BitStream::getPacketStream();
|
||||
bool extendedPacket = (sActiveFilter.queryFlags & ServerFilter::NewStyleResponse) != 0;
|
||||
|
||||
out->clearStringBuffer();
|
||||
out->write( U8( NetInterface::MasterServerListRequest ) );
|
||||
|
||||
if ( extendedPacket )
|
||||
out->write( U8( NetInterface::MasterServerExtendedListRequest ) );
|
||||
else
|
||||
out->write( U8( NetInterface::MasterServerListRequest ) );
|
||||
|
||||
out->write( U8( sActiveFilter.queryFlags ) ); // flags
|
||||
out->write( ( session << 16) | ( p.key & 0xFFFF ) );
|
||||
out->write( p.index ); // packet index
|
||||
|
||||
if ( extendedPacket )
|
||||
out->write( p.getOldIndex() ); // packet index
|
||||
else
|
||||
out->write( p.getIndex() ); // packet index
|
||||
|
||||
out->write( U8( 0 ) ); // game type
|
||||
out->write( U8( 0 ) ); // mission type
|
||||
out->write( U8( 0 ) ); // minPlayers
|
||||
|
|
@ -1569,6 +1604,98 @@ static void handleMasterServerListResponse( BitStream* stream, U32 key, U8 /*fla
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void handleExtendedMasterServerListResponse(BitStream* stream, U32 key, U8 /*flags*/)
|
||||
{
|
||||
U16 packetIndex, packetTotal;
|
||||
U32 i;
|
||||
U16 serverCount, port;
|
||||
U8 netNum[16];
|
||||
char addressBuffer[256];
|
||||
NetAddress addr;
|
||||
|
||||
stream->read(&packetIndex);
|
||||
// Validate the packet key:
|
||||
U32 packetKey = gMasterServerPing.key;
|
||||
if (gGotFirstListPacket)
|
||||
{
|
||||
for (i = 0; i < gPacketStatusList.size(); i++)
|
||||
{
|
||||
if (gPacketStatusList[i].index == packetIndex)
|
||||
{
|
||||
packetKey = gPacketStatusList[i].key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U32 testKey = (gPingSession << 16) | (packetKey & 0xFFFF);
|
||||
if (testKey != key)
|
||||
return;
|
||||
|
||||
stream->read(&packetTotal);
|
||||
stream->read(&serverCount);
|
||||
|
||||
Con::printf("Received server list packet %d of %d from the master server (%d servers).", (packetIndex + 1), packetTotal, serverCount);
|
||||
|
||||
// Enter all of the servers in this packet into the ping list:
|
||||
for (i = 0; i < serverCount; i++)
|
||||
{
|
||||
U8 type;
|
||||
stream->read(&type);
|
||||
dMemset(&addr, '\0', sizeof(NetAddress));
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
// IPV4
|
||||
addr.type = NetAddress::IPAddress;
|
||||
stream->read(4, &addr.address.ipv4.netNum[0]);
|
||||
stream->read(&addr.port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// IPV6
|
||||
addr.type = NetAddress::IPV6Address;
|
||||
stream->read(16, &addr.address.ipv6.netNum[0]);
|
||||
stream->read(&addr.port);
|
||||
}
|
||||
|
||||
pushPingRequest(&addr);
|
||||
}
|
||||
|
||||
// If this is the first list packet we have received, fill the packet status list
|
||||
// and start processing:
|
||||
if (!gGotFirstListPacket)
|
||||
{
|
||||
gGotFirstListPacket = true;
|
||||
gMasterServerQueryAddress = gMasterServerPing.address;
|
||||
U32 currentTime = Platform::getVirtualMilliseconds();
|
||||
for (i = 0; i < packetTotal; i++)
|
||||
{
|
||||
if (i != packetIndex)
|
||||
{
|
||||
PacketStatus* p = new PacketStatus(i, gMasterServerPing.key, currentTime);
|
||||
gPacketStatusList.push_back(*p);
|
||||
}
|
||||
}
|
||||
|
||||
processServerListPackets(gPingSession);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove the packet we just received from the status list:
|
||||
for (i = 0; i < gPacketStatusList.size(); i++)
|
||||
{
|
||||
if (gPacketStatusList[i].index == packetIndex)
|
||||
{
|
||||
gPacketStatusList.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8 flags )
|
||||
{
|
||||
if ( GNet->doesAllowConnections() )
|
||||
|
|
@ -1585,7 +1712,7 @@ static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8
|
|||
for(U32 i = 0; i < masterList->size(); i++)
|
||||
{
|
||||
masterAddr = &(*masterList)[i].address;
|
||||
if (*(U32*)(masterAddr->netNum) == *(U32*)(address->netNum))
|
||||
if (masterAddr->isSameAddress(*address))
|
||||
{
|
||||
fromMaster = true;
|
||||
break;
|
||||
|
|
@ -2098,6 +2225,10 @@ void DemoNetInterface::handleInfoPacket( const NetAddress* address, U8 packetTyp
|
|||
case GameMasterInfoRequest:
|
||||
handleGameMasterInfoRequest( address, key, flags );
|
||||
break;
|
||||
|
||||
case MasterServerExtendedListResponse:
|
||||
handleExtendedMasterServerListResponse(stream, key, flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ IMPLEMENT_CALLBACK(TCPObject, onDisconnect, void, (),(),
|
|||
|
||||
TCPObject *TCPObject::find(NetSocket tag)
|
||||
{
|
||||
for(TCPObject *walk = table[U32(tag) & TableMask]; walk; walk = walk->mNext)
|
||||
if(walk->mTag == tag)
|
||||
for(TCPObject *walk = table[tag.getHash() & TableMask]; walk; walk = walk->mNext)
|
||||
if(walk->mTag.getHash() == tag.getHash())
|
||||
return walk;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -180,13 +180,13 @@ void TCPObject::addToTable(NetSocket newTag)
|
|||
{
|
||||
removeFromTable();
|
||||
mTag = newTag;
|
||||
mNext = table[U32(mTag) & TableMask];
|
||||
table[U32(mTag) & TableMask] = this;
|
||||
mNext = table[mTag.getHash() & TableMask];
|
||||
table[mTag.getHash() & TableMask] = this;
|
||||
}
|
||||
|
||||
void TCPObject::removeFromTable()
|
||||
{
|
||||
for(TCPObject **walk = &table[U32(mTag) & TableMask]; *walk; walk = &((*walk)->mNext))
|
||||
for(TCPObject **walk = &table[mTag.getHash() & TableMask]; *walk; walk = &((*walk)->mNext))
|
||||
{
|
||||
if(*walk == this)
|
||||
{
|
||||
|
|
@ -207,7 +207,7 @@ TCPObject::TCPObject()
|
|||
mBuffer = NULL;
|
||||
mBufferSize = 0;
|
||||
mPort = 0;
|
||||
mTag = InvalidSocket;
|
||||
mTag = NetSocket::INVALID;
|
||||
mNext = NULL;
|
||||
mState = Disconnected;
|
||||
|
||||
|
|
@ -215,9 +215,9 @@ TCPObject::TCPObject()
|
|||
|
||||
if(gTCPCount == 1)
|
||||
{
|
||||
Net::smConnectionAccept.notify(processConnectedAcceptEvent);
|
||||
Net::smConnectionReceive.notify(processConnectedReceiveEvent);
|
||||
Net::smConnectionNotify.notify(processConnectedNotifyEvent);
|
||||
Net::getConnectionAcceptedEvent().notify(processConnectedAcceptEvent);
|
||||
Net::getConnectionReceiveEvent().notify(processConnectedReceiveEvent);
|
||||
Net::getConnectionNotifyEvent().notify(processConnectedNotifyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,9 +230,9 @@ TCPObject::~TCPObject()
|
|||
|
||||
if(gTCPCount == 0)
|
||||
{
|
||||
Net::smConnectionAccept.remove(processConnectedAcceptEvent);
|
||||
Net::smConnectionReceive.remove(processConnectedReceiveEvent);
|
||||
Net::smConnectionNotify.remove(processConnectedNotifyEvent);
|
||||
Net::getConnectionAcceptedEvent().remove(processConnectedAcceptEvent);
|
||||
Net::getConnectionReceiveEvent().remove(processConnectedReceiveEvent);
|
||||
Net::getConnectionNotifyEvent().remove(processConnectedNotifyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ bool TCPObject::processArguments(S32 argc, ConsoleValueRef *argv)
|
|||
return true;
|
||||
else if(argc == 1)
|
||||
{
|
||||
addToTable(U32(dAtoi(argv[0])));
|
||||
addToTable(NetSocket::fromHandle(dAtoi(argv[0])));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -406,7 +406,7 @@ void TCPObject::onDisconnect()
|
|||
void TCPObject::listen(U16 port)
|
||||
{
|
||||
mState = Listening;
|
||||
U32 newTag = Net::openListenPort(port);
|
||||
NetSocket newTag = Net::openListenPort(port);
|
||||
addToTable(newTag);
|
||||
}
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ void TCPObject::connect(const char *address)
|
|||
|
||||
void TCPObject::disconnect()
|
||||
{
|
||||
if( mTag != InvalidSocket ) {
|
||||
if( mTag != NetSocket::INVALID ) {
|
||||
Net::closeConnectTo(mTag);
|
||||
}
|
||||
removeFromTable();
|
||||
|
|
@ -592,7 +592,7 @@ void processConnectedAcceptEvent(NetSocket listeningPort, NetSocket newConnectio
|
|||
if(!tcpo)
|
||||
return;
|
||||
|
||||
tcpo->onConnectionRequest(&originatingAddress, newConnection);
|
||||
tcpo->onConnectionRequest(&originatingAddress, (U32)newConnection.getHandle());
|
||||
}
|
||||
|
||||
void processConnectedNotifyEvent( NetSocket sock, U32 state )
|
||||
|
|
|
|||
|
|
@ -43,17 +43,6 @@ extern void createFontShutdown(void);
|
|||
|
||||
static HashTable<StringTableEntry,StringTableEntry> gSecureScript;
|
||||
|
||||
#ifdef TORQUE_OS_MAC
|
||||
|
||||
// ObjC hooks for shared library support
|
||||
// See: macMain.mm
|
||||
|
||||
void torque_mac_engineinit(S32 argc, const char **argv);
|
||||
void torque_mac_enginetick();
|
||||
void torque_mac_engineshutdown();
|
||||
|
||||
#endif
|
||||
|
||||
extern bool LinkConsoleFunctions;
|
||||
|
||||
extern "C" {
|
||||
|
|
@ -78,10 +67,6 @@ extern "C" {
|
|||
createFontInit();
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TORQUE_OS_MAC
|
||||
torque_mac_engineinit(argc, argv);
|
||||
#endif
|
||||
// Initialize the subsystems.
|
||||
StandardMainLoop::init();
|
||||
|
||||
|
|
@ -113,11 +98,6 @@ extern "C" {
|
|||
__try {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TORQUE_OS_MAC
|
||||
torque_mac_enginetick();
|
||||
#endif
|
||||
|
||||
bool ret = StandardMainLoop::doMainLoop();
|
||||
return ret;
|
||||
|
||||
|
|
@ -159,10 +139,6 @@ extern "C" {
|
|||
createFontShutdown();
|
||||
#endif
|
||||
|
||||
#ifdef TORQUE_OS_MAC
|
||||
torque_mac_engineshutdown();
|
||||
#endif
|
||||
|
||||
#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,17 +56,24 @@ void AbstractPolyList::addBox(const Box3F &box, BaseMatInstance* material)
|
|||
pos.x += dx; addPoint(pos);
|
||||
|
||||
for (S32 i = 0; i < 6; i++) {
|
||||
begin(material, i);
|
||||
S32 v1 = base + PolyFace[i][0];
|
||||
S32 v2 = base + PolyFace[i][1];
|
||||
S32 v3 = base + PolyFace[i][2];
|
||||
S32 v4 = base + PolyFace[i][3];
|
||||
// First triangle
|
||||
begin(material, i);
|
||||
vertex(v1);
|
||||
vertex(v2);
|
||||
vertex(v3);
|
||||
vertex(v4);
|
||||
plane(v1, v2, v3);
|
||||
end();
|
||||
// Second triangle
|
||||
begin(material, i);
|
||||
vertex(v3);
|
||||
vertex(v4);
|
||||
vertex(v1);
|
||||
plane(v3, v4, v1);
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,9 +96,9 @@ U32 ClippedPolyList::addPointAndNormal(const Point3F& p, const Point3F& normal)
|
|||
AssertFatal(mNormalList.size() == mVertexList.size(), "Normals count does not match vertex count!");
|
||||
|
||||
// Build the plane mask
|
||||
register U32 mask = 1;
|
||||
register S32 count = mPlaneList.size();
|
||||
register PlaneF * plane = mPlaneList.address();
|
||||
U32 mask = 1;
|
||||
S32 count = mPlaneList.size();
|
||||
PlaneF * plane = mPlaneList.address();
|
||||
|
||||
v.mask = 0;
|
||||
while(--count >= 0) {
|
||||
|
|
|
|||
|
|
@ -531,7 +531,7 @@ void Convex::updateStateList(const MatrixF& mat, const Point3F& scale, const Poi
|
|||
|
||||
// Add collision states for new overlapping objects
|
||||
for (CollisionWorkingList* itr0 = mWorking.wLink.mNext; itr0 != &mWorking; itr0 = itr0->wLink.mNext) {
|
||||
register Convex* cv = itr0->mConvex;
|
||||
Convex* cv = itr0->mConvex;
|
||||
if (cv->mTag != sTag && box1.isOverlapped(cv->getBoundingBox())) {
|
||||
CollisionState* state = new GjkCollisionState;
|
||||
state->set(this,cv,mat,cv->getTransform());
|
||||
|
|
|
|||
|
|
@ -87,9 +87,9 @@ class OptimizedPolyList : public AbstractPolyList
|
|||
|
||||
Poly()
|
||||
: plane( -1 ),
|
||||
object( NULL ),
|
||||
vertexCount( 0 ),
|
||||
material( NULL ),
|
||||
vertexCount( 0 ),
|
||||
object( NULL ),
|
||||
type( TriangleFan )
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "console/engineAPI.h"
|
||||
#include <stdarg.h>
|
||||
#include "platform/threads/mutex.h"
|
||||
|
||||
#include "core/util/journal/journal.h"
|
||||
|
||||
extern StringStack STR;
|
||||
extern ConsoleValueStack CSTK;
|
||||
|
|
@ -1138,6 +1138,321 @@ void addCommand( const char *name,BoolCallback cb,const char *usage, S32 minArgs
|
|||
Namespace::global()->addCommand( StringTable->insert(name), cb, usage, minArgs, maxArgs, isToolOnly, header );
|
||||
}
|
||||
|
||||
bool executeFile(const char* fileName, bool noCalls, bool journalScript)
|
||||
{
|
||||
bool journal = false;
|
||||
|
||||
char scriptFilenameBuffer[1024];
|
||||
U32 execDepth = 0;
|
||||
U32 journalDepth = 1;
|
||||
|
||||
execDepth++;
|
||||
if (journalDepth >= execDepth)
|
||||
journalDepth = execDepth + 1;
|
||||
else
|
||||
journal = true;
|
||||
|
||||
bool ret = false;
|
||||
|
||||
if (journalScript && !journal)
|
||||
{
|
||||
journal = true;
|
||||
journalDepth = execDepth;
|
||||
}
|
||||
|
||||
// Determine the filename we actually want...
|
||||
Con::expandScriptFilename(scriptFilenameBuffer, sizeof(scriptFilenameBuffer), fileName);
|
||||
|
||||
// since this function expects a script file reference, if it's a .dso
|
||||
// lets terminate the string before the dso so it will act like a .cs
|
||||
if (dStrEndsWith(scriptFilenameBuffer, ".dso"))
|
||||
{
|
||||
scriptFilenameBuffer[dStrlen(scriptFilenameBuffer) - dStrlen(".dso")] = '\0';
|
||||
}
|
||||
|
||||
// Figure out where to put DSOs
|
||||
StringTableEntry dsoPath = Con::getDSOPath(scriptFilenameBuffer);
|
||||
|
||||
const char *ext = dStrrchr(scriptFilenameBuffer, '.');
|
||||
|
||||
if (!ext)
|
||||
{
|
||||
// We need an extension!
|
||||
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file name %s.", scriptFilenameBuffer);
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check Editor Extensions
|
||||
bool isEditorScript = false;
|
||||
|
||||
// If the script file extension is '.ed.cs' then compile it to a different compiled extension
|
||||
if (dStricmp(ext, ".cs") == 0)
|
||||
{
|
||||
const char* ext2 = ext - 3;
|
||||
if (dStricmp(ext2, ".ed.cs") == 0)
|
||||
isEditorScript = true;
|
||||
}
|
||||
else if (dStricmp(ext, ".gui") == 0)
|
||||
{
|
||||
const char* ext2 = ext - 3;
|
||||
if (dStricmp(ext2, ".ed.gui") == 0)
|
||||
isEditorScript = true;
|
||||
}
|
||||
|
||||
|
||||
StringTableEntry scriptFileName = StringTable->insert(scriptFilenameBuffer);
|
||||
|
||||
#ifndef TORQUE_OS_XENON
|
||||
// Is this a file we should compile? (anything in the prefs path should not be compiled)
|
||||
StringTableEntry prefsPath = Platform::getPrefsPath();
|
||||
bool compiled = dStricmp(ext, ".mis") && !journal && !Con::getBoolVariable("Scripts::ignoreDSOs");
|
||||
|
||||
// [tom, 12/5/2006] stripBasePath() fucks up if the filename is not in the exe
|
||||
// path, current directory or prefs path. Thus, getDSOFilename() will also screw
|
||||
// up and so this allows the scripts to still load but without a DSO.
|
||||
if (Platform::isFullPath(Platform::stripBasePath(scriptFilenameBuffer)))
|
||||
compiled = false;
|
||||
|
||||
// [tom, 11/17/2006] It seems to make sense to not compile scripts that are in the
|
||||
// prefs directory. However, getDSOPath() can handle this situation and will put
|
||||
// the dso along with the script to avoid name clashes with tools/game dsos.
|
||||
if ((dsoPath && *dsoPath == 0) || (prefsPath && prefsPath[0] && dStrnicmp(scriptFileName, prefsPath, dStrlen(prefsPath)) == 0))
|
||||
compiled = false;
|
||||
#else
|
||||
bool compiled = false; // Don't try to compile things on the 360, ignore DSO's when debugging
|
||||
// because PC prefs will screw up stuff like SFX.
|
||||
#endif
|
||||
|
||||
// If we're in a journaling mode, then we will read the script
|
||||
// from the journal file.
|
||||
if (journal && Journal::IsPlaying())
|
||||
{
|
||||
char fileNameBuf[256];
|
||||
bool fileRead = false;
|
||||
U32 fileSize;
|
||||
|
||||
Journal::ReadString(fileNameBuf);
|
||||
Journal::Read(&fileRead);
|
||||
|
||||
if (!fileRead)
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::Script, "Journal script read (failed) for %s", fileNameBuf);
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
Journal::Read(&fileSize);
|
||||
char *script = new char[fileSize + 1];
|
||||
Journal::Read(fileSize, script);
|
||||
script[fileSize] = 0;
|
||||
Con::printf("Executing (journal-read) %s.", scriptFileName);
|
||||
CodeBlock *newCodeBlock = new CodeBlock();
|
||||
newCodeBlock->compileExec(scriptFileName, script, noCalls, 0);
|
||||
delete[] script;
|
||||
|
||||
execDepth--;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ok, we let's try to load and compile the script.
|
||||
Torque::FS::FileNodeRef scriptFile = Torque::FS::GetFileNode(scriptFileName);
|
||||
Torque::FS::FileNodeRef dsoFile;
|
||||
|
||||
// ResourceObject *rScr = gResourceManager->find(scriptFileName);
|
||||
// ResourceObject *rCom = NULL;
|
||||
|
||||
char nameBuffer[512];
|
||||
char* script = NULL;
|
||||
U32 version;
|
||||
|
||||
Stream *compiledStream = NULL;
|
||||
Torque::Time scriptModifiedTime, dsoModifiedTime;
|
||||
|
||||
// Check here for .edso
|
||||
bool edso = false;
|
||||
if (dStricmp(ext, ".edso") == 0 && scriptFile != NULL)
|
||||
{
|
||||
edso = true;
|
||||
dsoFile = scriptFile;
|
||||
scriptFile = NULL;
|
||||
|
||||
dsoModifiedTime = dsoFile->getModifiedTime();
|
||||
dStrcpy(nameBuffer, scriptFileName);
|
||||
}
|
||||
|
||||
// If we're supposed to be compiling this file, check to see if there's a DSO
|
||||
if (compiled && !edso)
|
||||
{
|
||||
const char *filenameOnly = dStrrchr(scriptFileName, '/');
|
||||
if (filenameOnly)
|
||||
++filenameOnly;
|
||||
else
|
||||
filenameOnly = scriptFileName;
|
||||
|
||||
char pathAndFilename[1024];
|
||||
Platform::makeFullPathName(filenameOnly, pathAndFilename, sizeof(pathAndFilename), dsoPath);
|
||||
|
||||
if (isEditorScript)
|
||||
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".edso", NULL);
|
||||
else
|
||||
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".dso", NULL);
|
||||
|
||||
dsoFile = Torque::FS::GetFileNode(nameBuffer);
|
||||
|
||||
if (scriptFile != NULL)
|
||||
scriptModifiedTime = scriptFile->getModifiedTime();
|
||||
|
||||
if (dsoFile != NULL)
|
||||
dsoModifiedTime = dsoFile->getModifiedTime();
|
||||
}
|
||||
|
||||
// Let's do a sanity check to complain about DSOs in the future.
|
||||
//
|
||||
// MM: This doesn't seem to be working correctly for now so let's just not issue
|
||||
// the warning until someone knows how to resolve it.
|
||||
//
|
||||
//if(compiled && rCom && rScr && Platform::compareFileTimes(comModifyTime, scrModifyTime) < 0)
|
||||
//{
|
||||
//Con::warnf("exec: Warning! Found a DSO from the future! (%s)", nameBuffer);
|
||||
//}
|
||||
|
||||
// If we had a DSO, let's check to see if we should be reading from it.
|
||||
//MGT: fixed bug with dsos not getting recompiled correctly
|
||||
//Note: Using Nathan Martin's version from the forums since its easier to read and understand
|
||||
if (compiled && dsoFile != NULL && (scriptFile == NULL || (dsoModifiedTime >= scriptModifiedTime)))
|
||||
{ //MGT: end
|
||||
compiledStream = FileStream::createAndOpen(nameBuffer, Torque::FS::File::Read);
|
||||
if (compiledStream)
|
||||
{
|
||||
// Check the version!
|
||||
compiledStream->read(&version);
|
||||
if (version != Con::DSOVersion)
|
||||
{
|
||||
Con::warnf("exec: Found an old DSO (%s, ver %d < %d), ignoring.", nameBuffer, version, Con::DSOVersion);
|
||||
delete compiledStream;
|
||||
compiledStream = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we're journalling, let's write some info out.
|
||||
if (journal && Journal::IsRecording())
|
||||
Journal::WriteString(scriptFileName);
|
||||
|
||||
if (scriptFile != NULL && !compiledStream)
|
||||
{
|
||||
// If we have source but no compiled version, then we need to compile
|
||||
// (and journal as we do so, if that's required).
|
||||
|
||||
void *data;
|
||||
U32 dataSize = 0;
|
||||
Torque::FS::ReadFile(scriptFileName, data, dataSize, true);
|
||||
|
||||
if (journal && Journal::IsRecording())
|
||||
Journal::Write(bool(data != NULL));
|
||||
|
||||
if (data == NULL)
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file %s.", scriptFileName);
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!dataSize)
|
||||
{
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
|
||||
script = (char *)data;
|
||||
|
||||
if (journal && Journal::IsRecording())
|
||||
{
|
||||
Journal::Write(dataSize);
|
||||
Journal::Write(dataSize, data);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TORQUE_NO_DSO_GENERATION
|
||||
if (compiled)
|
||||
{
|
||||
// compile this baddie.
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::printf("Compiling %s...", scriptFileName);
|
||||
#endif
|
||||
|
||||
CodeBlock *code = new CodeBlock();
|
||||
code->compile(nameBuffer, scriptFileName, script);
|
||||
delete code;
|
||||
code = NULL;
|
||||
|
||||
compiledStream = FileStream::createAndOpen(nameBuffer, Torque::FS::File::Read);
|
||||
if (compiledStream)
|
||||
{
|
||||
compiledStream->read(&version);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have to exit out here, as otherwise we get double error reports.
|
||||
delete[] script;
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (journal && Journal::IsRecording())
|
||||
Journal::Write(bool(false));
|
||||
}
|
||||
|
||||
if (compiledStream)
|
||||
{
|
||||
// Delete the script object first to limit memory used
|
||||
// during recursive execs.
|
||||
delete[] script;
|
||||
script = 0;
|
||||
|
||||
// We're all compiled, so let's run it.
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::printf("Loading compiled script %s.", scriptFileName);
|
||||
#endif
|
||||
CodeBlock *code = new CodeBlock;
|
||||
code->read(scriptFileName, *compiledStream);
|
||||
delete compiledStream;
|
||||
code->exec(0, scriptFileName, NULL, 0, NULL, noCalls, NULL, 0);
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
if (scriptFile)
|
||||
{
|
||||
// No compiled script, let's just try executing it
|
||||
// directly... this is either a mission file, or maybe
|
||||
// we're on a readonly volume.
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::printf("Executing %s.", scriptFileName);
|
||||
#endif
|
||||
|
||||
CodeBlock *newCodeBlock = new CodeBlock();
|
||||
StringTableEntry name = StringTable->insert(scriptFileName);
|
||||
|
||||
newCodeBlock->compileExec(name, script, noCalls, 0);
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't have anything.
|
||||
Con::warnf(ConsoleLogEntry::Script, "Missing file: %s!", scriptFileName);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
delete[] script;
|
||||
execDepth--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ConsoleValueRef evaluate(const char* string, bool echo, const char *fileName)
|
||||
{
|
||||
ConsoleStackFrameSaver stackSaver;
|
||||
|
|
@ -2014,6 +2329,64 @@ void ensureTrailingSlash(char* pDstPath, const char* pSrcPath)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StringTableEntry getDSOPath(const char *scriptPath)
|
||||
{
|
||||
#ifndef TORQUE2D_TOOLS_FIXME
|
||||
|
||||
// [tom, 11/17/2006] Force old behavior for the player. May not want to do this.
|
||||
const char *slash = dStrrchr(scriptPath, '/');
|
||||
if (slash != NULL)
|
||||
return StringTable->insertn(scriptPath, slash - scriptPath, true);
|
||||
|
||||
slash = dStrrchr(scriptPath, ':');
|
||||
if (slash != NULL)
|
||||
return StringTable->insertn(scriptPath, (slash - scriptPath) + 1, true);
|
||||
|
||||
return "";
|
||||
|
||||
#else
|
||||
|
||||
char relPath[1024], dsoPath[1024];
|
||||
bool isPrefs = false;
|
||||
|
||||
// [tom, 11/17/2006] Prefs are handled slightly differently to avoid dso name clashes
|
||||
StringTableEntry prefsPath = Platform::getPrefsPath();
|
||||
if (dStrnicmp(scriptPath, prefsPath, dStrlen(prefsPath)) == 0)
|
||||
{
|
||||
relPath[0] = 0;
|
||||
isPrefs = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringTableEntry strippedPath = Platform::stripBasePath(scriptPath);
|
||||
dStrcpy(relPath, strippedPath);
|
||||
|
||||
char *slash = dStrrchr(relPath, '/');
|
||||
if (slash)
|
||||
*slash = 0;
|
||||
}
|
||||
|
||||
const char *overridePath;
|
||||
if (!isPrefs)
|
||||
overridePath = Con::getVariable("$Scripts::OverrideDSOPath");
|
||||
else
|
||||
overridePath = prefsPath;
|
||||
|
||||
if (overridePath && *overridePath)
|
||||
Platform::makeFullPathName(relPath, dsoPath, sizeof(dsoPath), overridePath);
|
||||
else
|
||||
{
|
||||
char t[1024];
|
||||
dSprintf(t, sizeof(t), "compiledScripts/%s", relPath);
|
||||
Platform::makeFullPathName(t, dsoPath, sizeof(dsoPath), Platform::getPrefsPath());
|
||||
}
|
||||
|
||||
return StringTable->insert(dsoPath);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize)
|
||||
{
|
||||
// Note original destination.
|
||||
|
|
|
|||
|
|
@ -491,6 +491,7 @@ namespace Con
|
|||
bool isBasePath(const char* SrcPath, const char* pBasePath);
|
||||
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath);
|
||||
bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize);
|
||||
StringTableEntry getDSOPath(const char *scriptPath);
|
||||
|
||||
void addPathExpando(const char* pExpandoName, const char* pPath);
|
||||
void removePathExpando(const char* pExpandoName);
|
||||
|
|
@ -802,6 +803,16 @@ namespace Con
|
|||
ConsoleValueRef execute(SimObject *object, S32 argc, const char* argv[], bool thisCallOnly = false);
|
||||
ConsoleValueRef execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly = false);
|
||||
|
||||
/// Executes a script file and compiles it for use in script.
|
||||
///
|
||||
/// @param string File name that is the script to be executed and compiled.
|
||||
/// @param fileName Path to the file to execute
|
||||
/// @param noCalls Deprecated
|
||||
/// @param journalScript Deprecated
|
||||
///
|
||||
/// @return True if the script was successfully executed, false if not.
|
||||
bool executeFile(const char* fileName, bool noCalls, bool journalScript);
|
||||
|
||||
/// Evaluate an arbitrary chunk of code.
|
||||
///
|
||||
/// @param string Buffer containing code to execute.
|
||||
|
|
|
|||
|
|
@ -2251,63 +2251,6 @@ ConsoleFunction( call, const char *, 2, 0, "( string functionName, string args..
|
|||
static U32 execDepth = 0;
|
||||
static U32 journalDepth = 1;
|
||||
|
||||
static StringTableEntry getDSOPath(const char *scriptPath)
|
||||
{
|
||||
#ifndef TORQUE2D_TOOLS_FIXME
|
||||
|
||||
// [tom, 11/17/2006] Force old behavior for the player. May not want to do this.
|
||||
const char *slash = dStrrchr(scriptPath, '/');
|
||||
if(slash != NULL)
|
||||
return StringTable->insertn(scriptPath, slash - scriptPath, true);
|
||||
|
||||
slash = dStrrchr(scriptPath, ':');
|
||||
if(slash != NULL)
|
||||
return StringTable->insertn(scriptPath, (slash - scriptPath) + 1, true);
|
||||
|
||||
return "";
|
||||
|
||||
#else
|
||||
|
||||
char relPath[1024], dsoPath[1024];
|
||||
bool isPrefs = false;
|
||||
|
||||
// [tom, 11/17/2006] Prefs are handled slightly differently to avoid dso name clashes
|
||||
StringTableEntry prefsPath = Platform::getPrefsPath();
|
||||
if(dStrnicmp(scriptPath, prefsPath, dStrlen(prefsPath)) == 0)
|
||||
{
|
||||
relPath[0] = 0;
|
||||
isPrefs = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringTableEntry strippedPath = Platform::stripBasePath(scriptPath);
|
||||
dStrcpy(relPath, strippedPath);
|
||||
|
||||
char *slash = dStrrchr(relPath, '/');
|
||||
if(slash)
|
||||
*slash = 0;
|
||||
}
|
||||
|
||||
const char *overridePath;
|
||||
if(! isPrefs)
|
||||
overridePath = Con::getVariable("$Scripts::OverrideDSOPath");
|
||||
else
|
||||
overridePath = prefsPath;
|
||||
|
||||
if(overridePath && *overridePath)
|
||||
Platform::makeFullPathName(relPath, dsoPath, sizeof(dsoPath), overridePath);
|
||||
else
|
||||
{
|
||||
char t[1024];
|
||||
dSprintf(t, sizeof(t), "compiledScripts/%s", relPath);
|
||||
Platform::makeFullPathName(t, dsoPath, sizeof(dsoPath), Platform::getPrefsPath());
|
||||
}
|
||||
|
||||
return StringTable->insert(dsoPath);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
DefineConsoleFunction( getDSOPath, const char*, ( const char* scriptFileName ),,
|
||||
"Get the absolute path to the file in which the compiled code for the given script file will be stored.\n"
|
||||
"@param scriptFileName %Path to the .cs script file.\n"
|
||||
|
|
@ -2320,7 +2263,7 @@ DefineConsoleFunction( getDSOPath, const char*, ( const char* scriptFileName ),,
|
|||
{
|
||||
Con::expandScriptFilename( scriptFilenameBuffer, sizeof(scriptFilenameBuffer), scriptFileName );
|
||||
|
||||
const char* filename = getDSOPath(scriptFilenameBuffer);
|
||||
const char* filename = Con::getDSOPath(scriptFilenameBuffer);
|
||||
if(filename == NULL || *filename == 0)
|
||||
return "";
|
||||
|
||||
|
|
@ -2347,7 +2290,7 @@ DefineEngineFunction( compile, bool, ( const char* fileName, bool overrideNoDSO
|
|||
Con::expandScriptFilename( scriptFilenameBuffer, sizeof( scriptFilenameBuffer ), fileName );
|
||||
|
||||
// Figure out where to put DSOs
|
||||
StringTableEntry dsoPath = getDSOPath(scriptFilenameBuffer);
|
||||
StringTableEntry dsoPath = Con::getDSOPath(scriptFilenameBuffer);
|
||||
if(dsoPath && *dsoPath == 0)
|
||||
return false;
|
||||
|
||||
|
|
@ -2419,313 +2362,7 @@ DefineEngineFunction( exec, bool, ( const char* fileName, bool noCalls, bool jou
|
|||
"@see eval\n"
|
||||
"@ingroup Scripting" )
|
||||
{
|
||||
bool journal = false;
|
||||
|
||||
execDepth++;
|
||||
if(journalDepth >= execDepth)
|
||||
journalDepth = execDepth + 1;
|
||||
else
|
||||
journal = true;
|
||||
|
||||
bool ret = false;
|
||||
|
||||
if( journalScript && !journal )
|
||||
{
|
||||
journal = true;
|
||||
journalDepth = execDepth;
|
||||
}
|
||||
|
||||
// Determine the filename we actually want...
|
||||
Con::expandScriptFilename( scriptFilenameBuffer, sizeof( scriptFilenameBuffer ), fileName );
|
||||
|
||||
// since this function expects a script file reference, if it's a .dso
|
||||
// lets terminate the string before the dso so it will act like a .cs
|
||||
if(dStrEndsWith(scriptFilenameBuffer, ".dso"))
|
||||
{
|
||||
scriptFilenameBuffer[dStrlen(scriptFilenameBuffer) - dStrlen(".dso")] = '\0';
|
||||
}
|
||||
|
||||
// Figure out where to put DSOs
|
||||
StringTableEntry dsoPath = getDSOPath(scriptFilenameBuffer);
|
||||
|
||||
const char *ext = dStrrchr(scriptFilenameBuffer, '.');
|
||||
|
||||
if(!ext)
|
||||
{
|
||||
// We need an extension!
|
||||
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file name %s.", scriptFilenameBuffer);
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check Editor Extensions
|
||||
bool isEditorScript = false;
|
||||
|
||||
// If the script file extension is '.ed.cs' then compile it to a different compiled extension
|
||||
if( dStricmp( ext, ".cs" ) == 0 )
|
||||
{
|
||||
const char* ext2 = ext - 3;
|
||||
if( dStricmp( ext2, ".ed.cs" ) == 0 )
|
||||
isEditorScript = true;
|
||||
}
|
||||
else if( dStricmp( ext, ".gui" ) == 0 )
|
||||
{
|
||||
const char* ext2 = ext - 3;
|
||||
if( dStricmp( ext2, ".ed.gui" ) == 0 )
|
||||
isEditorScript = true;
|
||||
}
|
||||
|
||||
|
||||
StringTableEntry scriptFileName = StringTable->insert(scriptFilenameBuffer);
|
||||
|
||||
#ifndef TORQUE_OS_XENON
|
||||
// Is this a file we should compile? (anything in the prefs path should not be compiled)
|
||||
StringTableEntry prefsPath = Platform::getPrefsPath();
|
||||
bool compiled = dStricmp(ext, ".mis") && !journal && !Con::getBoolVariable("Scripts::ignoreDSOs");
|
||||
|
||||
// [tom, 12/5/2006] stripBasePath() fucks up if the filename is not in the exe
|
||||
// path, current directory or prefs path. Thus, getDSOFilename() will also screw
|
||||
// up and so this allows the scripts to still load but without a DSO.
|
||||
if(Platform::isFullPath(Platform::stripBasePath(scriptFilenameBuffer)))
|
||||
compiled = false;
|
||||
|
||||
// [tom, 11/17/2006] It seems to make sense to not compile scripts that are in the
|
||||
// prefs directory. However, getDSOPath() can handle this situation and will put
|
||||
// the dso along with the script to avoid name clashes with tools/game dsos.
|
||||
if( (dsoPath && *dsoPath == 0) || (prefsPath && prefsPath[ 0 ] && dStrnicmp(scriptFileName, prefsPath, dStrlen(prefsPath)) == 0) )
|
||||
compiled = false;
|
||||
#else
|
||||
bool compiled = false; // Don't try to compile things on the 360, ignore DSO's when debugging
|
||||
// because PC prefs will screw up stuff like SFX.
|
||||
#endif
|
||||
|
||||
// If we're in a journaling mode, then we will read the script
|
||||
// from the journal file.
|
||||
if(journal && Journal::IsPlaying())
|
||||
{
|
||||
char fileNameBuf[256];
|
||||
bool fileRead = false;
|
||||
U32 fileSize;
|
||||
|
||||
Journal::ReadString(fileNameBuf);
|
||||
Journal::Read(&fileRead);
|
||||
|
||||
if(!fileRead)
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::Script, "Journal script read (failed) for %s", fileNameBuf);
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
Journal::Read(&fileSize);
|
||||
char *script = new char[fileSize + 1];
|
||||
Journal::Read(fileSize, script);
|
||||
script[fileSize] = 0;
|
||||
Con::printf("Executing (journal-read) %s.", scriptFileName);
|
||||
CodeBlock *newCodeBlock = new CodeBlock();
|
||||
newCodeBlock->compileExec(scriptFileName, script, noCalls, 0);
|
||||
delete [] script;
|
||||
|
||||
execDepth--;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ok, we let's try to load and compile the script.
|
||||
Torque::FS::FileNodeRef scriptFile = Torque::FS::GetFileNode(scriptFileName);
|
||||
Torque::FS::FileNodeRef dsoFile;
|
||||
|
||||
// ResourceObject *rScr = gResourceManager->find(scriptFileName);
|
||||
// ResourceObject *rCom = NULL;
|
||||
|
||||
char nameBuffer[512];
|
||||
char* script = NULL;
|
||||
U32 version;
|
||||
|
||||
Stream *compiledStream = NULL;
|
||||
Torque::Time scriptModifiedTime, dsoModifiedTime;
|
||||
|
||||
// Check here for .edso
|
||||
bool edso = false;
|
||||
if( dStricmp( ext, ".edso" ) == 0 && scriptFile != NULL )
|
||||
{
|
||||
edso = true;
|
||||
dsoFile = scriptFile;
|
||||
scriptFile = NULL;
|
||||
|
||||
dsoModifiedTime = dsoFile->getModifiedTime();
|
||||
dStrcpy( nameBuffer, scriptFileName );
|
||||
}
|
||||
|
||||
// If we're supposed to be compiling this file, check to see if there's a DSO
|
||||
if(compiled && !edso)
|
||||
{
|
||||
const char *filenameOnly = dStrrchr(scriptFileName, '/');
|
||||
if(filenameOnly)
|
||||
++filenameOnly;
|
||||
else
|
||||
filenameOnly = scriptFileName;
|
||||
|
||||
char pathAndFilename[1024];
|
||||
Platform::makeFullPathName(filenameOnly, pathAndFilename, sizeof(pathAndFilename), dsoPath);
|
||||
|
||||
if( isEditorScript )
|
||||
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".edso", NULL);
|
||||
else
|
||||
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".dso", NULL);
|
||||
|
||||
dsoFile = Torque::FS::GetFileNode(nameBuffer);
|
||||
|
||||
if(scriptFile != NULL)
|
||||
scriptModifiedTime = scriptFile->getModifiedTime();
|
||||
|
||||
if(dsoFile != NULL)
|
||||
dsoModifiedTime = dsoFile->getModifiedTime();
|
||||
}
|
||||
|
||||
// Let's do a sanity check to complain about DSOs in the future.
|
||||
//
|
||||
// MM: This doesn't seem to be working correctly for now so let's just not issue
|
||||
// the warning until someone knows how to resolve it.
|
||||
//
|
||||
//if(compiled && rCom && rScr && Platform::compareFileTimes(comModifyTime, scrModifyTime) < 0)
|
||||
//{
|
||||
//Con::warnf("exec: Warning! Found a DSO from the future! (%s)", nameBuffer);
|
||||
//}
|
||||
|
||||
// If we had a DSO, let's check to see if we should be reading from it.
|
||||
//MGT: fixed bug with dsos not getting recompiled correctly
|
||||
//Note: Using Nathan Martin's version from the forums since its easier to read and understand
|
||||
if(compiled && dsoFile != NULL && (scriptFile == NULL|| (dsoModifiedTime >= scriptModifiedTime)))
|
||||
{ //MGT: end
|
||||
compiledStream = FileStream::createAndOpen( nameBuffer, Torque::FS::File::Read );
|
||||
if (compiledStream)
|
||||
{
|
||||
// Check the version!
|
||||
compiledStream->read(&version);
|
||||
if(version != Con::DSOVersion)
|
||||
{
|
||||
Con::warnf("exec: Found an old DSO (%s, ver %d < %d), ignoring.", nameBuffer, version, Con::DSOVersion);
|
||||
delete compiledStream;
|
||||
compiledStream = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we're journalling, let's write some info out.
|
||||
if(journal && Journal::IsRecording())
|
||||
Journal::WriteString(scriptFileName);
|
||||
|
||||
if(scriptFile != NULL && !compiledStream)
|
||||
{
|
||||
// If we have source but no compiled version, then we need to compile
|
||||
// (and journal as we do so, if that's required).
|
||||
|
||||
void *data;
|
||||
U32 dataSize = 0;
|
||||
Torque::FS::ReadFile(scriptFileName, data, dataSize, true);
|
||||
|
||||
if(journal && Journal::IsRecording())
|
||||
Journal::Write(bool(data != NULL));
|
||||
|
||||
if( data == NULL )
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file %s.", scriptFileName);
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !dataSize )
|
||||
{
|
||||
execDepth --;
|
||||
return false;
|
||||
}
|
||||
|
||||
script = (char *)data;
|
||||
|
||||
if(journal && Journal::IsRecording())
|
||||
{
|
||||
Journal::Write(dataSize);
|
||||
Journal::Write(dataSize, data);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TORQUE_NO_DSO_GENERATION
|
||||
if(compiled)
|
||||
{
|
||||
// compile this baddie.
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::printf("Compiling %s...", scriptFileName);
|
||||
#endif
|
||||
|
||||
CodeBlock *code = new CodeBlock();
|
||||
code->compile(nameBuffer, scriptFileName, script);
|
||||
delete code;
|
||||
code = NULL;
|
||||
|
||||
compiledStream = FileStream::createAndOpen( nameBuffer, Torque::FS::File::Read );
|
||||
if(compiledStream)
|
||||
{
|
||||
compiledStream->read(&version);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have to exit out here, as otherwise we get double error reports.
|
||||
delete [] script;
|
||||
execDepth--;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if(journal && Journal::IsRecording())
|
||||
Journal::Write(bool(false));
|
||||
}
|
||||
|
||||
if(compiledStream)
|
||||
{
|
||||
// Delete the script object first to limit memory used
|
||||
// during recursive execs.
|
||||
delete [] script;
|
||||
script = 0;
|
||||
|
||||
// We're all compiled, so let's run it.
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::printf("Loading compiled script %s.", scriptFileName);
|
||||
#endif
|
||||
CodeBlock *code = new CodeBlock;
|
||||
code->read(scriptFileName, *compiledStream);
|
||||
delete compiledStream;
|
||||
code->exec(0, scriptFileName, NULL, 0, NULL, noCalls, NULL, 0);
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
if(scriptFile)
|
||||
{
|
||||
// No compiled script, let's just try executing it
|
||||
// directly... this is either a mission file, or maybe
|
||||
// we're on a readonly volume.
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::printf("Executing %s.", scriptFileName);
|
||||
#endif
|
||||
|
||||
CodeBlock *newCodeBlock = new CodeBlock();
|
||||
StringTableEntry name = StringTable->insert(scriptFileName);
|
||||
|
||||
newCodeBlock->compileExec(name, script, noCalls, 0);
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't have anything.
|
||||
Con::warnf(ConsoleLogEntry::Script, "Missing file: %s!", scriptFileName);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
delete [] script;
|
||||
execDepth--;
|
||||
return ret;
|
||||
return Con::executeFile(fileName, noCalls, journalScript);
|
||||
}
|
||||
|
||||
DefineConsoleFunction( eval, const char*, ( const char* consoleString ), , "eval(consoleString)" )
|
||||
|
|
|
|||
|
|
@ -1413,7 +1413,6 @@ ConsoleValueRef Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprE
|
|||
return ConsoleValueRef();
|
||||
}
|
||||
|
||||
static char returnBuffer[32];
|
||||
switch(mType)
|
||||
{
|
||||
case StringCallbackType:
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ public:
|
|||
/// @see addGroup, endGroup
|
||||
/// @see addGroup, endGroup
|
||||
/// @see addDeprecatedField
|
||||
enum ACRFieldTypes
|
||||
enum ACRFieldTypes : U32
|
||||
{
|
||||
/// The first custom field type... all fields
|
||||
/// types greater or equal to this one are not
|
||||
|
|
|
|||
|
|
@ -62,4 +62,4 @@ namespace Con {
|
|||
|
||||
/// @}
|
||||
|
||||
#endif _CONSOLEXMLEXPORT_H_
|
||||
#endif //_CONSOLEXMLEXPORT_H_
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ static VectorPtr< ConsoleBaseType* > gConsoleTypeTable( __FILE__, __LINE__ );
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleBaseType::ConsoleBaseType( const S32 size, S32 *idPtr, const char *aTypeName )
|
||||
: mInspectorFieldType( NULL ),
|
||||
mTypeSize( size ),
|
||||
: mTypeSize( size ),
|
||||
mInspectorFieldType( NULL ),
|
||||
mTypeInfo( NULL )
|
||||
{
|
||||
mTypeName = StringTable->insert( aTypeName );
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ EngineFunctionInfo::EngineFunctionInfo( const char* name,
|
|||
void* address,
|
||||
U32 flags )
|
||||
: SuperType( name, EngineExportKindFunction, scope, docString ),
|
||||
mBindingName( bindingName ),
|
||||
mFunctionFlags( flags ),
|
||||
mFunctionType( functionType ),
|
||||
mDefaultArgumentValues( defaultArgs ),
|
||||
mFunctionFlags( flags ),
|
||||
mBindingName( bindingName ),
|
||||
mPrototypeString( prototypeString ),
|
||||
mNextFunction( smFirstFunction ),
|
||||
mAddress( address )
|
||||
mAddress( address ),
|
||||
mNextFunction( smFirstFunction )
|
||||
{
|
||||
AssertFatal( functionType, "EngineFunctionInfo - Function cannot have void type!" );
|
||||
smFirstFunction = this;
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ EngineTypeInfo::EngineTypeInfo( const char* typeName, EngineExportScope* scope,
|
|||
: SuperType( typeName, scope, docString ),
|
||||
mTypeKind( kind ),
|
||||
mInstanceSize( instanceSize ),
|
||||
mNext( smFirst ),
|
||||
mEnumTable( NULL ),
|
||||
mFieldTable( NULL ),
|
||||
mPropertyTable( NULL ),
|
||||
mSuperType( NULL )
|
||||
mSuperType( NULL ),
|
||||
mNext( smFirst )
|
||||
{
|
||||
mExportKind = EngineExportKindType;
|
||||
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ namespace _Private {
|
|||
|
||||
///
|
||||
#define FIELD( fieldName, exportName, numElements, doc ) \
|
||||
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings.
|
||||
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), (U32)FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings.
|
||||
|
||||
///
|
||||
#define FIELD_AS( type, fieldName, exportName, numElements, doc ) \
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ typedef U32 SimObjectId;
|
|||
/// The RootGroupId is assigned to gRootGroup, in which most SimObjects
|
||||
/// are addded as child members. See simManager.cc for details, particularly
|
||||
/// Sim::initRoot() and following.
|
||||
enum SimObjectsConstants
|
||||
enum SimObjectsConstants : U32
|
||||
{
|
||||
DataBlockObjectIdFirst = 3,
|
||||
DataBlockObjectIdBitSize = 14,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ TelnetConsole::TelnetConsole()
|
|||
{
|
||||
Con::addConsumer(telnetCallback);
|
||||
|
||||
mAcceptSocket = InvalidSocket;
|
||||
mAcceptSocket = NetSocket::INVALID;
|
||||
mAcceptPort = -1;
|
||||
mClientList = NULL;
|
||||
mRemoteEchoEnabled = false;
|
||||
|
|
@ -93,13 +93,13 @@ TelnetConsole::TelnetConsole()
|
|||
TelnetConsole::~TelnetConsole()
|
||||
{
|
||||
Con::removeConsumer(telnetCallback);
|
||||
if(mAcceptSocket != InvalidSocket)
|
||||
if(mAcceptSocket != NetSocket::INVALID)
|
||||
Net::closeSocket(mAcceptSocket);
|
||||
TelnetClient *walk = mClientList, *temp;
|
||||
while(walk)
|
||||
{
|
||||
temp = walk->nextClient;
|
||||
if(walk->socket != InvalidSocket)
|
||||
if(walk->socket != NetSocket::INVALID)
|
||||
Net::closeSocket(walk->socket);
|
||||
delete walk;
|
||||
walk = temp;
|
||||
|
|
@ -113,16 +113,20 @@ void TelnetConsole::setTelnetParameters(S32 port, const char *telnetPassword, co
|
|||
|
||||
mRemoteEchoEnabled = remoteEcho;
|
||||
|
||||
if(mAcceptSocket != InvalidSocket)
|
||||
if(mAcceptSocket != NetSocket::INVALID)
|
||||
{
|
||||
Net::closeSocket(mAcceptSocket);
|
||||
mAcceptSocket = InvalidSocket;
|
||||
mAcceptSocket = NetSocket::INVALID;
|
||||
}
|
||||
mAcceptPort = port;
|
||||
if(mAcceptPort != -1 && mAcceptPort != 0)
|
||||
{
|
||||
NetAddress address;
|
||||
Net::getIdealListenAddress(&address);
|
||||
address.port = mAcceptPort;
|
||||
|
||||
mAcceptSocket = Net::openSocket();
|
||||
Net::bind(mAcceptSocket, mAcceptPort);
|
||||
Net::bindAddress(address, mAcceptSocket);
|
||||
Net::listen(mAcceptSocket, 4);
|
||||
|
||||
Net::setBlocking(mAcceptSocket, false);
|
||||
|
|
@ -151,16 +155,17 @@ void TelnetConsole::process()
|
|||
{
|
||||
NetAddress address;
|
||||
|
||||
if(mAcceptSocket != InvalidSocket)
|
||||
if(mAcceptSocket != NetSocket::INVALID)
|
||||
{
|
||||
// ok, see if we have any new connections:
|
||||
NetSocket newConnection;
|
||||
newConnection = Net::accept(mAcceptSocket, &address);
|
||||
|
||||
if(newConnection != InvalidSocket)
|
||||
if(newConnection != NetSocket::INVALID)
|
||||
{
|
||||
Con::printf ("Telnet connection from %i.%i.%i.%i",
|
||||
address.netNum[0], address.netNum[1], address.netNum[2], address.netNum[3]);
|
||||
char buffer[256];
|
||||
Net::addressToString(&address, buffer);
|
||||
Con::printf("Telnet connection from %s", buffer);
|
||||
|
||||
TelnetClient *cl = new TelnetClient;
|
||||
cl->socket = newConnection;
|
||||
|
|
@ -201,7 +206,7 @@ void TelnetConsole::process()
|
|||
if((err != Net::NoError && err != Net::WouldBlock) || numBytes == 0)
|
||||
{
|
||||
Net::closeSocket(client->socket);
|
||||
client->socket = InvalidSocket;
|
||||
client->socket = NetSocket::INVALID;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -274,7 +279,7 @@ void TelnetConsole::process()
|
|||
if(client->state == DisconnectThisDude)
|
||||
{
|
||||
Net::closeSocket(client->socket);
|
||||
client->socket = InvalidSocket;
|
||||
client->socket = NetSocket::INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -312,7 +317,7 @@ void TelnetConsole::process()
|
|||
TelnetClient *cl;
|
||||
while((cl = *walk) != NULL)
|
||||
{
|
||||
if(cl->socket == InvalidSocket)
|
||||
if(cl->socket == NetSocket::INVALID)
|
||||
{
|
||||
*walk = cl->nextClient;
|
||||
delete cl;
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ TelnetDebugger::TelnetDebugger()
|
|||
Con::addConsumer(debuggerConsumer);
|
||||
|
||||
mAcceptPort = -1;
|
||||
mAcceptSocket = InvalidSocket;
|
||||
mDebugSocket = InvalidSocket;
|
||||
mAcceptSocket = NetSocket::INVALID;
|
||||
mDebugSocket = NetSocket::INVALID;
|
||||
|
||||
mState = NotConnected;
|
||||
mCurPos = 0;
|
||||
|
|
@ -189,9 +189,9 @@ TelnetDebugger::~TelnetDebugger()
|
|||
{
|
||||
Con::removeConsumer(debuggerConsumer);
|
||||
|
||||
if(mAcceptSocket != InvalidSocket)
|
||||
if(mAcceptSocket != NetSocket::INVALID)
|
||||
Net::closeSocket(mAcceptSocket);
|
||||
if(mDebugSocket != InvalidSocket)
|
||||
if(mDebugSocket != NetSocket::INVALID)
|
||||
Net::closeSocket(mDebugSocket);
|
||||
}
|
||||
|
||||
|
|
@ -217,10 +217,10 @@ void TelnetDebugger::send(const char *str)
|
|||
|
||||
void TelnetDebugger::disconnect()
|
||||
{
|
||||
if ( mDebugSocket != InvalidSocket )
|
||||
if ( mDebugSocket != NetSocket::INVALID )
|
||||
{
|
||||
Net::closeSocket(mDebugSocket);
|
||||
mDebugSocket = InvalidSocket;
|
||||
mDebugSocket = NetSocket::INVALID;
|
||||
}
|
||||
|
||||
removeAllBreakpoints();
|
||||
|
|
@ -236,16 +236,20 @@ void TelnetDebugger::setDebugParameters(S32 port, const char *password, bool wai
|
|||
// if(port == mAcceptPort)
|
||||
// return;
|
||||
|
||||
if(mAcceptSocket != InvalidSocket)
|
||||
if(mAcceptSocket != NetSocket::INVALID)
|
||||
{
|
||||
Net::closeSocket(mAcceptSocket);
|
||||
mAcceptSocket = InvalidSocket;
|
||||
mAcceptSocket = NetSocket::INVALID;
|
||||
}
|
||||
mAcceptPort = port;
|
||||
if(mAcceptPort != -1 && mAcceptPort != 0)
|
||||
{
|
||||
NetAddress address;
|
||||
Net::getIdealListenAddress(&address);
|
||||
address.port = mAcceptPort;
|
||||
|
||||
mAcceptSocket = Net::openSocket();
|
||||
Net::bind(mAcceptSocket, mAcceptPort);
|
||||
Net::bindAddress(address, mAcceptSocket);
|
||||
Net::listen(mAcceptSocket, 4);
|
||||
|
||||
Net::setBlocking(mAcceptSocket, false);
|
||||
|
|
@ -279,32 +283,33 @@ void TelnetDebugger::process()
|
|||
{
|
||||
NetAddress address;
|
||||
|
||||
if(mAcceptSocket != InvalidSocket)
|
||||
if(mAcceptSocket != NetSocket::INVALID)
|
||||
{
|
||||
// ok, see if we have any new connections:
|
||||
NetSocket newConnection;
|
||||
newConnection = Net::accept(mAcceptSocket, &address);
|
||||
|
||||
if(newConnection != InvalidSocket && mDebugSocket == InvalidSocket)
|
||||
if(newConnection != NetSocket::INVALID && mDebugSocket == NetSocket::INVALID)
|
||||
{
|
||||
Con::printf ("Debugger connection from %i.%i.%i.%i",
|
||||
address.netNum[0], address.netNum[1], address.netNum[2], address.netNum[3]);
|
||||
char buffer[256];
|
||||
Net::addressToString(&address, buffer);
|
||||
Con::printf("Debugger connection from %s", buffer);
|
||||
|
||||
mState = PasswordTry;
|
||||
mDebugSocket = newConnection;
|
||||
|
||||
Net::setBlocking(newConnection, false);
|
||||
}
|
||||
else if(newConnection != InvalidSocket)
|
||||
else if(newConnection != NetSocket::INVALID)
|
||||
Net::closeSocket(newConnection);
|
||||
}
|
||||
// see if we have any input to process...
|
||||
|
||||
if(mDebugSocket == InvalidSocket)
|
||||
if(mDebugSocket == NetSocket::INVALID)
|
||||
return;
|
||||
|
||||
checkDebugRecv();
|
||||
if(mDebugSocket == InvalidSocket)
|
||||
if(mDebugSocket == NetSocket::INVALID)
|
||||
removeAllBreakpoints();
|
||||
}
|
||||
|
||||
|
|
@ -434,7 +439,7 @@ void TelnetDebugger::breakProcess()
|
|||
{
|
||||
Platform::sleep(10);
|
||||
checkDebugRecv();
|
||||
if(mDebugSocket == InvalidSocket)
|
||||
if(mDebugSocket == NetSocket::INVALID)
|
||||
{
|
||||
mProgramPaused = false;
|
||||
removeAllBreakpoints();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ void *DataChunker::alloc(S32 size)
|
|||
{
|
||||
if (size > mChunkSize)
|
||||
{
|
||||
DataBlock * temp = new DataBlock(size);
|
||||
DataBlock * temp = (DataBlock*)dMalloc(DataChunker::PaddDBSize + size);
|
||||
AssertFatal(temp, "Malloc failed");
|
||||
constructInPlace(temp);
|
||||
if (mCurBlock)
|
||||
{
|
||||
temp->next = mCurBlock->next;
|
||||
|
|
@ -52,30 +54,32 @@ void *DataChunker::alloc(S32 size)
|
|||
mCurBlock = temp;
|
||||
temp->curIndex = mChunkSize;
|
||||
}
|
||||
return temp->data;
|
||||
return temp->getData();
|
||||
}
|
||||
|
||||
if(!mCurBlock || size + mCurBlock->curIndex > mChunkSize)
|
||||
{
|
||||
DataBlock *temp = new DataBlock(mChunkSize);
|
||||
const U32 paddDBSize = (sizeof(DataBlock) + 3) & ~3;
|
||||
DataBlock *temp = (DataBlock*)dMalloc(paddDBSize+ mChunkSize);
|
||||
AssertFatal(temp, "Malloc failed");
|
||||
constructInPlace(temp);
|
||||
temp->next = mCurBlock;
|
||||
temp->curIndex = 0;
|
||||
mCurBlock = temp;
|
||||
}
|
||||
|
||||
void *ret = mCurBlock->data + mCurBlock->curIndex;
|
||||
|
||||
void *ret = mCurBlock->getData() + mCurBlock->curIndex;
|
||||
mCurBlock->curIndex += (size + 3) & ~3; // dword align
|
||||
return ret;
|
||||
}
|
||||
|
||||
DataChunker::DataBlock::DataBlock(S32 size)
|
||||
DataChunker::DataBlock::DataBlock()
|
||||
{
|
||||
data = new U8[size];
|
||||
curIndex = 0;
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
DataChunker::DataBlock::~DataBlock()
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void DataChunker::freeBlocks(bool keepOne)
|
||||
|
|
@ -83,15 +87,17 @@ void DataChunker::freeBlocks(bool keepOne)
|
|||
while(mCurBlock && mCurBlock->next)
|
||||
{
|
||||
DataBlock *temp = mCurBlock->next;
|
||||
delete mCurBlock;
|
||||
dFree(mCurBlock);
|
||||
mCurBlock = temp;
|
||||
}
|
||||
if (!keepOne)
|
||||
{
|
||||
delete mCurBlock;
|
||||
if (mCurBlock) dFree(mCurBlock);
|
||||
mCurBlock = NULL;
|
||||
}
|
||||
else if (mCurBlock)
|
||||
{
|
||||
mCurBlock->curIndex = 0;
|
||||
mCurBlock->next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,21 @@
|
|||
class DataChunker
|
||||
{
|
||||
public:
|
||||
/// Block of allocated memory.
|
||||
///
|
||||
/// <b>This has nothing to do with datablocks as used in the rest of Torque.</b>
|
||||
struct DataBlock
|
||||
{
|
||||
DataBlock* next; ///< linked list pointer to the next DataBlock for this chunker
|
||||
S32 curIndex; ///< current allocation point within this DataBlock
|
||||
DataBlock();
|
||||
~DataBlock();
|
||||
inline U8 *getData();
|
||||
};
|
||||
|
||||
enum {
|
||||
ChunkSize = 16376 ///< Default size of each DataBlock page in the DataChunker
|
||||
PaddDBSize = (sizeof(DataBlock) + 3) & ~3, ///< Padded size of DataBlock
|
||||
ChunkSize = 16384 - PaddDBSize ///< Default size of each DataBlock page in the DataChunker
|
||||
};
|
||||
|
||||
/// Return a pointer to a chunk of memory from a pre-allocated block.
|
||||
|
|
@ -81,27 +94,40 @@ public:
|
|||
mCurBlock = temp;
|
||||
}
|
||||
|
||||
private:
|
||||
/// Block of allocated memory.
|
||||
///
|
||||
/// <b>This has nothing to do with datablocks as used in the rest of Torque.</b>
|
||||
struct DataBlock
|
||||
public:
|
||||
U32 countUsedBlocks()
|
||||
{
|
||||
DataBlock* prev;
|
||||
DataBlock* next; ///< linked list pointer to the next DataBlock for this chunker
|
||||
U8 *data; ///< allocated pointer for the base of this page
|
||||
S32 curIndex; ///< current allocation point within this DataBlock
|
||||
DataBlock(S32 size);
|
||||
~DataBlock();
|
||||
};
|
||||
U32 count = 0;
|
||||
if (!mCurBlock)
|
||||
return 0;
|
||||
for (DataBlock *ptr = mCurBlock; ptr != NULL; ptr = ptr->next)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void setChunkSize(U32 size)
|
||||
{
|
||||
AssertFatal(mCurBlock == NULL, "Cant resize now");
|
||||
mChunkSize = size;
|
||||
}
|
||||
|
||||
DataBlock* mFirstBlock;
|
||||
DataBlock *mCurBlock; ///< current page we're allocating data from. If the
|
||||
|
||||
public:
|
||||
|
||||
DataBlock* mCurBlock; ///< current page we're allocating data from. If the
|
||||
///< data size request is greater than the memory space currently
|
||||
///< available in the current page, a new page will be allocated.
|
||||
S32 mChunkSize; ///< The size allocated for each page in the DataChunker
|
||||
};
|
||||
|
||||
|
||||
inline U8 *DataChunker::DataBlock::getData()
|
||||
{
|
||||
return (U8*)this + DataChunker::PaddDBSize;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template<class T>
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ bool OggDecoder::_nextPacket()
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
OggInputStream::OggInputStream( Stream* stream )
|
||||
: mStream( stream ),
|
||||
mIsAtEnd( false )
|
||||
: mIsAtEnd( false ),
|
||||
mStream( stream )
|
||||
{
|
||||
ogg_sync_init( &mOggSyncState );
|
||||
|
||||
|
|
|
|||
|
|
@ -95,12 +95,12 @@ static inline S32 sampleG( U8* pCb, U8* pCr )
|
|||
|
||||
OggTheoraDecoder::OggTheoraDecoder( const ThreadSafeRef< OggInputStream >& stream )
|
||||
: Parent( stream ),
|
||||
#ifdef TORQUE_DEBUG
|
||||
mLock( 0 ),
|
||||
#endif
|
||||
mTheoraSetup( NULL ),
|
||||
mTheoraDecoder( NULL ),
|
||||
mTranscoder( TRANSCODER_Auto )
|
||||
#ifdef TORQUE_DEBUG
|
||||
,mLock( 0 )
|
||||
#endif
|
||||
{
|
||||
// Initialize.
|
||||
|
||||
|
|
@ -285,8 +285,7 @@ U32 OggTheoraDecoder::read( OggTheoraFrame** buffer, U32 num )
|
|||
|
||||
// Transcode the packet.
|
||||
|
||||
#if ( defined( TORQUE_COMPILER_GCC ) || defined( TORQUE_COMPILER_VISUALC ) ) && defined( TORQUE_CPU_X86 )
|
||||
|
||||
#if ( defined( TORQUE_COMPILER_GCC ) || defined( TORQUE_COMPILER_VISUALC ) ) && (defined( TORQUE_CPU_X86 ) )
|
||||
if( ( mTranscoder == TRANSCODER_Auto || mTranscoder == TRANSCODER_SSE2420RGBA ) &&
|
||||
getDecoderPixelFormat() == PIXEL_FORMAT_420 &&
|
||||
Platform::SystemInfo.processor.properties & CPU_PROP_SSE2 &&
|
||||
|
|
@ -420,7 +419,7 @@ void OggTheoraDecoder::_transcode( th_ycbcr_buffer ycbcr, U8* buffer, const U32
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if defined( TORQUE_CPU_X86 )
|
||||
void OggTheoraDecoder::_transcode420toRGBA_SSE2( th_ycbcr_buffer ycbcr, U8* buffer, U32 width, U32 height, U32 pitch )
|
||||
{
|
||||
AssertFatal( width % 2 == 0, "OggTheoraDecoder::_transcode420toRGBA_SSE2() - width must be multiple of 2" );
|
||||
|
|
@ -560,7 +559,7 @@ void OggTheoraDecoder::_transcode420toRGBA_SSE2( th_ycbcr_buffer ycbcr, U8* buff
|
|||
jnz hloop
|
||||
};
|
||||
|
||||
#elif defined( TORQUE_COMPILER_GCC ) && defined( TORQUE_CPU_X86 )
|
||||
#elif defined( TORQUE_COMPILER_GCC ) && defined( TORQUE_CPU_X86 )
|
||||
|
||||
asm( "pushal\n" // Save all general-purpose registers.
|
||||
|
||||
|
|
@ -692,3 +691,4 @@ void OggTheoraDecoder::_transcode420toRGBA_SSE2( th_ycbcr_buffer ycbcr, U8* buff
|
|||
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -172,10 +172,10 @@ class OggTheoraDecoder : public OggDecoder,
|
|||
/// Generic transcoder going from any of the Y'CbCr pixel formats to
|
||||
/// any RGB format (that is supported by GFXFormatUtils).
|
||||
void _transcode( th_ycbcr_buffer ycbcr, U8* buffer, U32 width, U32 height );
|
||||
|
||||
/// Transcoder with fixed 4:2:0 to RGBA conversion using SSE2 assembly.
|
||||
#if defined( TORQUE_CPU_X86 )
|
||||
/// Transcoder with fixed 4:2:0 to RGBA conversion using SSE2 assembly. Unused on 64 bit archetecture.
|
||||
void _transcode420toRGBA_SSE2( th_ycbcr_buffer ycbcr, U8* buffer, U32 width, U32 height, U32 pitch );
|
||||
|
||||
#endif
|
||||
// OggDecoder.
|
||||
virtual bool _detect( ogg_page* startPage );
|
||||
virtual bool _init();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
class FileStream : public Stream
|
||||
{
|
||||
public:
|
||||
enum
|
||||
enum : U32
|
||||
{
|
||||
BUFFER_SIZE = 8 * 1024, // this can be changed to anything appropriate [in k]
|
||||
BUFFER_INVALID = 0xffffffff // file offsets must all be less than this
|
||||
|
|
|
|||
|
|
@ -300,16 +300,7 @@ bool Stream::write(const NetAddress &na)
|
|||
{
|
||||
bool success = write(na.type);
|
||||
success &= write(na.port);
|
||||
success &= write(na.netNum[0]);
|
||||
success &= write(na.netNum[1]);
|
||||
success &= write(na.netNum[2]);
|
||||
success &= write(na.netNum[3]);
|
||||
success &= write(na.nodeNum[0]);
|
||||
success &= write(na.nodeNum[1]);
|
||||
success &= write(na.nodeNum[2]);
|
||||
success &= write(na.nodeNum[3]);
|
||||
success &= write(na.nodeNum[4]);
|
||||
success &= write(na.nodeNum[5]);
|
||||
success &= write(sizeof(na.address), &na.address);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
@ -317,16 +308,20 @@ bool Stream::read(NetAddress *na)
|
|||
{
|
||||
bool success = read(&na->type);
|
||||
success &= read(&na->port);
|
||||
success &= read(&na->netNum[0]);
|
||||
success &= read(&na->netNum[1]);
|
||||
success &= read(&na->netNum[2]);
|
||||
success &= read(&na->netNum[3]);
|
||||
success &= read(&na->nodeNum[0]);
|
||||
success &= read(&na->nodeNum[1]);
|
||||
success &= read(&na->nodeNum[2]);
|
||||
success &= read(&na->nodeNum[3]);
|
||||
success &= read(&na->nodeNum[4]);
|
||||
success &= read(&na->nodeNum[5]);
|
||||
success &= read(sizeof(na->address), &na->address);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Stream::write(const NetSocket &so)
|
||||
{
|
||||
return write(so.getHandle());
|
||||
}
|
||||
|
||||
bool Stream::read(NetSocket* so)
|
||||
{
|
||||
S32 handle = -1;
|
||||
bool success = read(&handle);
|
||||
*so = NetSocket::fromHandle(handle);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class ColorF;
|
|||
struct NetAddress;
|
||||
class RawData;
|
||||
class String;
|
||||
class NetSocket;
|
||||
|
||||
namespace Torque {
|
||||
class ByteBuffer;
|
||||
|
|
@ -165,6 +166,11 @@ public:
|
|||
/// Read a network address from the stream.
|
||||
bool read(NetAddress*);
|
||||
|
||||
/// Write a network socket to the stream.
|
||||
bool write(const NetSocket &);
|
||||
/// Read a network socket from the stream.
|
||||
bool read(NetSocket*);
|
||||
|
||||
/// Write some raw data onto the stream.
|
||||
bool write(const RawData &);
|
||||
/// Read some raw data from the stream.
|
||||
|
|
|
|||
|
|
@ -25,13 +25,7 @@
|
|||
#include "core/stream/stream.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const char TAG_ASCII_ID[] = "[TAG]";
|
||||
const char TAG_ASCII_END[] = "[END]";
|
||||
const char TAG_ASCII_HEADER[] = "// Auto-Generated by TagDictionary class";
|
||||
|
||||
const S32 sg_tagDictAsciiUser = 1;
|
||||
|
||||
} // namespace
|
||||
|
||||
TagDictionary tagDictionary;
|
||||
|
|
|
|||
|
|
@ -104,9 +104,9 @@ acceptable. Do NOT use for cryptographic purposes.
|
|||
--------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
U32 hash(register const U8 *k, register U32 length, register U32 initval)
|
||||
U32 hash(const U8 *k, U32 length, U32 initval)
|
||||
{
|
||||
register U32 a,b,c,len;
|
||||
U32 a,b,c,len;
|
||||
|
||||
/* Set up the internal state */
|
||||
len = length;
|
||||
|
|
@ -211,9 +211,9 @@ is acceptable. Do NOT use for cryptographic purposes.
|
|||
--------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
U64 hash64( register const U8 *k, register U32 length, register U64 initval )
|
||||
U64 hash64( const U8 *k, U32 length, U64 initval )
|
||||
{
|
||||
register U64 a,b,c,len;
|
||||
U64 a,b,c,len;
|
||||
|
||||
/* Set up the internal state */
|
||||
len = length;
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ void MD5Final( unsigned char digest[16], MD5Context* ctx)
|
|||
*/
|
||||
void MD5Transform( int buf[4], int in[16])
|
||||
{
|
||||
register int a, b, c, d;
|
||||
int a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
|
|
|
|||
|
|
@ -127,8 +127,6 @@ inline void Swizzle<T, mapLength>::ToBuffer( void *destination, const void *sour
|
|||
|
||||
for( S32 i = 0; i < size / ( mapLength * sizeof( T ) ); i++ )
|
||||
{
|
||||
dMemcpy( dest, src, mapLength * sizeof( T ) );
|
||||
|
||||
for( S32 j = 0; j < mapLength; j++ )
|
||||
*dest++ = src[mMap[j]];
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ protected:
|
|||
|
||||
StrTest() : mData( 0 ), mUTF16( 0 ), mLength( 0 ) {}
|
||||
StrTest( const char* str )
|
||||
: mData( str ), mLength( str ? dStrlen( str ) : 0 ), mUTF16( NULL )
|
||||
: mData( str ), mUTF16( NULL ), mLength( str ? dStrlen( str ) : 0 )
|
||||
{
|
||||
if( str )
|
||||
mUTF16 = createUTF16string( mData );
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
** this software for any purpose.
|
||||
*/
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -68,7 +69,11 @@
|
|||
|
||||
#include "core/util/md5.h"
|
||||
|
||||
#if defined (TORQUE_OS_MAC) && defined(TORQUE_CPU_X64)
|
||||
typedef unsigned int unsigned32;
|
||||
#else
|
||||
typedef unsigned long unsigned32;
|
||||
#endif
|
||||
typedef unsigned short unsigned16;
|
||||
typedef unsigned char unsigned8;
|
||||
|
||||
|
|
@ -162,7 +167,7 @@ static void create_uuid_state(uuid_state *st)
|
|||
*/
|
||||
static void format_token(char *target, const xuuid_t *u)
|
||||
{
|
||||
sprintf(target, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
sprintf(target, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
u->time_low, u->time_mid, u->time_hi_and_version,
|
||||
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
||||
u->node[0], u->node[1], u->node[2],
|
||||
|
|
|
|||
|
|
@ -406,9 +406,10 @@ bool VolumetricFog::LoadShape()
|
|||
mIsVBDirty = true;
|
||||
for (U32 k = 0; k < numNrms; k++)
|
||||
{
|
||||
Point3F norm = mesh->mVertexData[k].normal();
|
||||
Point3F vert = mesh->mVertexData[k].vert();
|
||||
Point2F uv = mesh->mVertexData[k].tvert();
|
||||
const TSMesh::__TSMeshVertexBase &vd = mesh->mVertexData.getBase(k);
|
||||
Point3F norm = vd.normal();
|
||||
Point3F vert = vd.vert();
|
||||
Point2F uv = vd.tvert();
|
||||
tmpVerts[k].point = vert;
|
||||
tmpVerts[k].texCoord = uv;
|
||||
tmpVerts[k].normal = norm;
|
||||
|
|
|
|||
|
|
@ -272,11 +272,11 @@ SimObjectPtr<SimSet> DecalRoad::smServerDecalRoadSet = NULL;
|
|||
// Constructors
|
||||
|
||||
DecalRoad::DecalRoad()
|
||||
: mLoadRenderData( true ),
|
||||
mBreakAngle( 3.0f ),
|
||||
: mBreakAngle( 3.0f ),
|
||||
mSegmentsPerBatch( 10 ),
|
||||
mTextureLength( 5.0f ),
|
||||
mRenderPriority( 10 ),
|
||||
mLoadRenderData( true ),
|
||||
mMaterial( NULL ),
|
||||
mMatInst( NULL ),
|
||||
mUpdateEventId( -1 ),
|
||||
|
|
@ -1580,8 +1580,6 @@ void DecalRoad::_captureVerts()
|
|||
box.intersect( batch.bounds );
|
||||
}
|
||||
|
||||
Point3F pos = getPosition();
|
||||
|
||||
mWorldBox = box;
|
||||
resetObjectBox();
|
||||
|
||||
|
|
|
|||
|
|
@ -59,29 +59,28 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl()
|
|||
// tool palette
|
||||
mSelectMeshRoadMode("MeshRoadEditorSelectMode"),
|
||||
mAddMeshRoadMode("MeshRoadEditorAddRoadMode"),
|
||||
mMovePointMode("MeshRoadEditorMoveMode"),
|
||||
mRotatePointMode("MeshRoadEditorRotateMode"),
|
||||
mScalePointMode("MeshRoadEditorScaleMode"),
|
||||
mAddNodeMode("MeshRoadEditorAddNodeMode"),
|
||||
mInsertPointMode("MeshRoadEditorInsertPointMode"),
|
||||
mRemovePointMode("MeshRoadEditorRemovePointMode"),
|
||||
mMode(mSelectMeshRoadMode),
|
||||
|
||||
mHasCopied( false ),
|
||||
mIsDirty( false ),
|
||||
mRoadSet( NULL ),
|
||||
mSelNode( -1 ),
|
||||
mSelRoad( NULL ),
|
||||
mHoverRoad( NULL ),
|
||||
mHoverNode( -1 ),
|
||||
mDefaultWidth( 10.0f ),
|
||||
mDefaultDepth( 5.0f ),
|
||||
mDefaultNormal( 0,0,1 ),
|
||||
mAddNodeIdx( 0 ),
|
||||
mNodeHalfSize( 4,4 ),
|
||||
mHoverSplineColor( 255,0,0,255 ),
|
||||
mSelectedSplineColor( 0,255,0,255 ),
|
||||
mHoverNodeColor( 255,255,255,255 )
|
||||
mMovePointMode("MeshRoadEditorMoveMode"),
|
||||
mScalePointMode("MeshRoadEditorScaleMode"),
|
||||
mRotatePointMode("MeshRoadEditorRotateMode"),
|
||||
mIsDirty( false ),
|
||||
mRoadSet( NULL ),
|
||||
mSelNode( -1 ),
|
||||
mHoverNode( -1 ),
|
||||
mAddNodeIdx( 0 ),
|
||||
mSelRoad( NULL ),
|
||||
mHoverRoad( NULL ),
|
||||
mMode(mSelectMeshRoadMode),
|
||||
mDefaultWidth( 10.0f ),
|
||||
mDefaultDepth( 5.0f ),
|
||||
mDefaultNormal( 0,0,1 ),
|
||||
mNodeHalfSize( 4,4 ),
|
||||
mHoverSplineColor( 255,0,0,255 ),
|
||||
mSelectedSplineColor( 0,255,0,255 ),
|
||||
mHoverNodeColor( 255,255,255,255 ),
|
||||
mHasCopied( false )
|
||||
{
|
||||
mMaterialName[Top] = StringTable->insert("DefaultRoadMaterialTop");
|
||||
mMaterialName[Bottom] = StringTable->insert("DefaultRoadMaterialOther");
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ ConsoleDocClass( GuiRiverEditorCtrl,
|
|||
);
|
||||
|
||||
GuiRiverEditorCtrl::GuiRiverEditorCtrl()
|
||||
: mDefaultNormal( 0, 0, 1 ),
|
||||
mDefaultWidth( 10.0f ),
|
||||
mDefaultDepth( 5.0f )
|
||||
: mDefaultWidth( 10.0f ),
|
||||
mDefaultDepth( 5.0f ),
|
||||
mDefaultNormal( 0, 0, 1 )
|
||||
{
|
||||
// Each of the mode names directly correlates with the River Editor's
|
||||
// tool palette
|
||||
|
|
@ -1478,4 +1478,4 @@ DefineConsoleMethod( GuiRiverEditorCtrl, regenerate, void, (), , "" )
|
|||
River *river = object->getSelectedRiver();
|
||||
if ( river )
|
||||
river->regenerate();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1713,8 +1713,6 @@ void MeshRoad::_generateSlices()
|
|||
}
|
||||
}
|
||||
|
||||
Point3F pos = getPosition();
|
||||
|
||||
mWorldBox = box;
|
||||
resetObjectBox();
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue