Merge branch 'development' into walkabout

Conflicts:
	Engine/source/T3D/aiPlayer.cpp
This commit is contained in:
Daniel Buckmaster 2015-01-29 21:38:20 +11:00
commit bd437cda1c
981 changed files with 304060 additions and 7888 deletions

View file

@ -1245,7 +1245,7 @@ bool AIPlayer::checkInFoV(GameBase* target, F32 camFov, bool _checkEnabled)
// projection and box test.
shapeDir.normalize();
F32 dot = mDot(shapeDir, camDir);
return (dot > camFov);
return (dot > mCos(camFov));
}
DefineEngineMethod(AIPlayer, checkInFoV, bool, (ShapeBase* obj, F32 fov, bool checkEnabled), (NULL, 45.0f, false),

View file

@ -193,7 +193,7 @@ void CameraSpline::renderTimeMap()
void *ptr = vb.lock();
if(!ptr) return;
MRandomLCG random(1376312589 * (U32)this);
MRandomLCG random(1376312589 * (uintptr_t)this);
S32 index = 0;
for(Vector<TimeMap>::iterator itr=mTimeMap.begin(); itr != mTimeMap.end(); itr++)
{

View file

@ -573,7 +573,7 @@ void ConvexShape::prepRenderImage( SceneRenderState *state )
// We sort by the material then vertex buffer.
ri->defaultKey = matInst->getStateHint();
ri->defaultKey2 = (U32)ri->vertBuff; // Not 64bit safe!
ri->defaultKey2 = (uintptr_t)ri->vertBuff; // Not 64bit safe!
// Submit our RenderInst to the RenderPassManager
state->getRenderPass()->addInst( ri );

View file

@ -312,7 +312,7 @@ void DebrisData::packData(BitStream* stream)
if( stream->writeFlag( explosion ) )
{
stream->writeRangedU32(packed? SimObjectId(explosion):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)explosion):
explosion->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
}

View file

@ -343,7 +343,7 @@ void RenderMeshExample::prepRenderImage( SceneRenderState *state )
// We sort by the material then vertex buffer
ri->defaultKey = matInst->getStateHint();
ri->defaultKey2 = (U32)ri->vertBuff; // Not 64bit safe!
ri->defaultKey2 = (uintptr_t)ri->vertBuff; // Not 64bit safe!
// Submit our RenderInst to the RenderPassManager
state->getRenderPass()->addInst( ri );

View file

@ -182,9 +182,9 @@ void GuiShapeNameHud::onRender( Point2I, const RectI &updateRect)
cam.getColumn(3, &camPos);
cam.getColumn(1, &camDir);
F32 camFov;
conn->getControlCameraFov(&camFov);
camFov = mDegToRad(camFov) / 2;
F32 camFovCos;
conn->getControlCameraFov(&camFovCos);
camFovCos = mCos(mDegToRad(camFovCos) / 2);
// Visible distance info & name fading
F32 visDistance = gClientSceneGraph->getVisibleDistance();
@ -236,7 +236,7 @@ void GuiShapeNameHud::onRender( Point2I, const RectI &updateRect)
// projection and box test.
shapeDir.normalize();
F32 dot = mDot(shapeDir, camDir);
if (dot < camFov)
if (dot < camFovCos)
continue;
// Test to see if it's behind something, and we want to

View file

@ -615,7 +615,7 @@ void ExplosionData::packData(BitStream* stream)
}
U32 count;
for(count = 0; count < EC_NUM_TIME_KEYS; count++)
if(times[i] >= 1)
if(times[count] >= 1)
break;
count++;
if(count > EC_NUM_TIME_KEYS)

View file

@ -355,7 +355,7 @@ bool ParticleData::protectedSetSizes( void *object, const char *index, const cha
U32 i;
if (!index)
i = 0;
return (val >= 0.f && val <= MaxParticleSize);
else
i = dAtoui(index);
@ -371,7 +371,7 @@ bool ParticleData::protectedSetTimes( void *object, const char *index, const cha
U32 i;
if (!index)
i = 0;
return (val >= 0.f && val <= 1.f);
else
i = dAtoui(index);

View file

@ -926,7 +926,7 @@ void ParticleEmitter::prepRenderImage(SceneRenderState* state)
ri->softnessDistance = mDataBlock->softnessDistance;
// Sort by texture too.
ri->defaultKey = ri->diffuseTex ? (U32)ri->diffuseTex : (U32)ri->vertBuff;
ri->defaultKey = ri->diffuseTex ? (uintptr_t)ri->diffuseTex : (uintptr_t)ri->vertBuff;
renderManager->addInst( ri );
@ -1833,22 +1833,22 @@ void ParticleEmitter::setupOriented( Particle *part,
lVerts->point = start + crossDir;
lVerts->color = partCol;
// Here and below, we copy UVs from particle datablock's texCoords (oriented)
lVerts->texCoord = part->dataBlock->texCoords[0];
lVerts->texCoord = part->dataBlock->texCoords[1];
++lVerts;
lVerts->point = start - crossDir;
lVerts->color = partCol;
lVerts->texCoord = part->dataBlock->texCoords[1];
lVerts->texCoord = part->dataBlock->texCoords[2];
++lVerts;
lVerts->point = end - crossDir;
lVerts->color = partCol;
lVerts->texCoord = part->dataBlock->texCoords[2];
lVerts->texCoord = part->dataBlock->texCoords[3];
++lVerts;
lVerts->point = end + crossDir;
lVerts->color = partCol;
lVerts->texCoord = part->dataBlock->texCoords[3];
lVerts->texCoord = part->dataBlock->texCoords[0];
++lVerts;
}

View file

@ -527,7 +527,7 @@ void Ribbon::prepRenderImage(SceneRenderState *state)
} else {
ri->defaultKey = 1;
}
ri->defaultKey2 = (U32)ri->vertBuff; // Not 64bit safe!
ri->defaultKey2 = (uintptr_t)ri->vertBuff; // Not 64bit safe!
state->getRenderPass()->addInst(ri);
}

View file

@ -208,6 +208,8 @@ GameConnection::GameConnection()
mAIControlled = false;
mLastPacketTime = 0;
mDisconnectReason[0] = 0;
//blackout vars
@ -465,7 +467,7 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
connectArgv[i + 3] = mConnectArgv[i];
}
connectArgv[0] = "onConnectRequest";
connectArgv[1] = NULL;
connectArgv[1] = 0;
char buffer[256];
Net::addressToString(getNetAddress(), buffer);
connectArgv[2] = buffer;

View file

@ -228,7 +228,7 @@ void GameUpdateCameraFov()
F32 delta = time - CameraAndFOV::sLastCameraUpdateTime;
// snap zoom?
if((CameraAndFOV::sZoomSpeed == 0) || (delta <= 0.f))
if((CameraAndFOV::sZoomSpeed == 0) || (delta <= 0.0f))
CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov;
else
{

View file

@ -26,16 +26,18 @@
#include "core/stream/bitStream.h"
#include "console/engineAPI.h"
#include "lighting/lightInfo.h"
#include "lighting/lightQuery.h"
#include "math/mathUtils.h"
#include "math/mathIO.h"
#include "scene/sceneRenderState.h"
#include "gfx/gfxOcclusionQuery.h"
#include "gfx/gfxDrawUtil.h"
#include "gfx/gfxTextureManager.h"
#include "renderInstance/renderPassManager.h"
#include "T3D/gameBase/gameConnection.h"
#include "T3D/gameBase/processList.h"
#include "collision/collision.h"
#include "lighting/lightManager.h"
const U32 LightFlareData::LosMask = STATIC_COLLISION_TYPEMASK |
ShapeBaseObjectType |
@ -45,8 +47,6 @@ const U32 LightFlareData::LosMask = STATIC_COLLISION_TYPEMASK |
LightFlareState::~LightFlareState()
{
delete occlusionQuery;
delete fullPixelQuery;
}
void LightFlareState::clear()
@ -59,8 +59,6 @@ void LightFlareState::clear()
lightInfo = NULL;
worldRadius = -1.0f;
occlusion = -1.0f;
occlusionQuery = NULL;
fullPixelQuery = NULL;
}
Point3F LightFlareData::sBasePoints[] =
@ -296,47 +294,39 @@ bool LightFlareData::_testVisibility(const SceneRenderState *state, LightFlareSt
// for one-shot initialization of LightFlareState
if ( useOcclusionQuery )
{
if ( flareState->occlusionQuery == NULL )
flareState->occlusionQuery = GFX->createOcclusionQuery();
if ( flareState->fullPixelQuery == NULL )
flareState->fullPixelQuery = GFX->createOcclusionQuery();
// Always treat light as onscreen if using HOQ
// it will be faded out if offscreen anyway.
onScreen = true;
// NOTE: These queries frame lock us as we block to get the
// results. This is ok as long as long as we're not too GPU
// bound... else we waste CPU time here waiting for it when
// we could have been doing other CPU work instead.
needsRaycast = false;
// Test the hardware queries for rendered pixels.
U32 pixels = 0, fullPixels = 0;
GFXOcclusionQuery::OcclusionQueryStatus status = flareState->occlusionQuery->getStatus( true, &pixels );
flareState->fullPixelQuery->getStatus( true, &fullPixels );
if ( status != GFXOcclusionQuery::Occluded && fullPixels != 0 )
GFXOcclusionQuery::OcclusionQueryStatus status;
flareState->occlusionQuery.getLastStatus( false, &status, &pixels );
flareState->fullPixelQuery.getLastStatus( false, NULL, &fullPixels );
if ( status == GFXOcclusionQuery::NotOccluded && fullPixels != 0 )
*outOcclusionFade = mClampF( (F32)pixels / (F32)fullPixels, 0.0f, 1.0f );
// If we got a result then we don't need to fallback to the raycast.
if ( status != GFXOcclusionQuery::Unset )
needsRaycast = false;
// Setup the new queries.
RenderPassManager *rpm = state->getRenderPass();
OccluderRenderInst *ri = rpm->allocInst<OccluderRenderInst>();
ri->type = RenderPassManager::RIT_Occluder;
ri->query = flareState->occlusionQuery;
ri->query2 = flareState->fullPixelQuery;
ri->isSphere = true;
ri->position = lightPos;
if ( isVectorLight && flareState->worldRadius > 0.0f )
ri->scale.set( flareState->worldRadius );
else
ri->scale.set( mOcclusionRadius );
ri->orientation = rpm->allocUniqueXform( lightInfo->getTransform() );
if( !flareState->occlusionQuery.isWaiting() )
{
// Setup the new queries.
RenderPassManager *rpm = state->getRenderPass();
OccluderRenderInst *ri = rpm->allocInst<OccluderRenderInst>();
ri->type = RenderPassManager::RIT_Occluder;
ri->query = flareState->occlusionQuery.getQuery();
ri->query2 = flareState->fullPixelQuery.getQuery();
ri->isSphere = true;
ri->position = lightPos;
if ( isVectorLight && flareState->worldRadius > 0.0f )
ri->scale.set( flareState->worldRadius );
else
ri->scale.set( mOcclusionRadius );
ri->orientation = rpm->allocUniqueXform( lightInfo->getTransform() );
// Submit the queries.
state->getRenderPass()->addInst( ri );
// Submit the queries.
state->getRenderPass()->addInst( ri );
}
}
const Point3F &camPos = state->getCameraPosition();
@ -608,7 +598,7 @@ void LightFlareData::prepRender( SceneRenderState *state, LightFlareState *flare
ri->blendStyle = ParticleRenderInst::BlendGreyscale;
ri->diffuseTex = mFlareTexture;
ri->softnessDistance = 1.0f;
ri->defaultKey = ri->diffuseTex ? (U32)ri->diffuseTex : (U32)ri->vertBuff; // Sort by texture too.
ri->defaultKey = ri->diffuseTex ? (uintptr_t)ri->diffuseTex : (uintptr_t)ri->vertBuff; // Sort by texture too.
// NOTE: Offscreen partical code is currently disabled.
ri->systemState = PSS_AwaitingHighResDraw;

View file

@ -41,12 +41,14 @@
#ifndef _GFXSTATEBLOCK_H_
#include "gfx/gfxStateBlock.h"
#endif
#ifndef _GFXOCCLUSIONQUERY_H_
#include "gfx/gfxOcclusionQuery.h"
#endif
class LightInfo;
struct ObjectRenderInst;
class SceneRenderState;
class BaseMatInstance;
class GFXOcclusionQuery;
struct LightFlareState
{
@ -65,8 +67,8 @@ struct LightFlareState
bool visible;
F32 occlusion;
GFXVertexBufferHandle<GFXVertexPCT> vertBuffer;
GFXOcclusionQuery *occlusionQuery;
GFXOcclusionQuery *fullPixelQuery;
GFXOcclusionQueryHandle occlusionQuery;
GFXOcclusionQueryHandle fullPixelQuery;
};
class LightFlareData : public SimDataBlock

View file

@ -6152,13 +6152,16 @@ U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
stream->writeInt((S32)len, 13);
}
stream->writeFloat(mRot.z / M_2PI_F, 7);
stream->writeSignedFloat(mHead.x / mDataBlock->maxLookAngle, 6);
stream->writeSignedFloat(mHead.x / (mDataBlock->maxLookAngle - mDataBlock->minLookAngle), 6);
stream->writeSignedFloat(mHead.z / mDataBlock->maxFreelookAngle, 6);
delta.move.pack(stream);
stream->writeFlag(!(mask & NoWarpMask));
}
// Ghost need energy to predict reliably
stream->writeFloat(getEnergyLevel() / mDataBlock->maxEnergy,EnergyLevelBits);
if (mDataBlock->maxEnergy > 0.f)
stream->writeFloat(getEnergyLevel() / mDataBlock->maxEnergy, EnergyLevelBits);
else
stream->writeFloat(0.f, EnergyLevelBits);
return retMask;
}
@ -6250,7 +6253,7 @@ void Player::unpackUpdate(NetConnection *con, BitStream *stream)
rot.y = rot.x = 0.0f;
rot.z = stream->readFloat(7) * M_2PI_F;
mHead.x = stream->readSignedFloat(6) * mDataBlock->maxLookAngle;
mHead.x = stream->readSignedFloat(6) * (mDataBlock->maxLookAngle - mDataBlock->minLookAngle);
mHead.z = stream->readSignedFloat(6) * mDataBlock->maxFreelookAngle;
delta.move.unpack(stream);

View file

@ -707,7 +707,7 @@ void ShapeBaseData::packData(BitStream* stream)
if( stream->writeFlag( debris != NULL ) )
{
stream->writeRangedU32(packed? SimObjectId(debris):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)debris):
debris->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
}
@ -940,8 +940,6 @@ ShapeBase::ShapeBase()
for (i = 0; i < MaxTriggerKeys; i++)
mTrigger[i] = false;
mWeaponCamShake = NULL;
}
@ -1063,15 +1061,7 @@ void ShapeBase::onRemove()
if ( isClientObject() )
{
mCubeReflector.unregisterReflector();
if ( mWeaponCamShake )
{
if ( mWeaponCamShake->isAdded )
gCamFXMgr.removeFX( mWeaponCamShake );
SAFE_DELETE( mWeaponCamShake );
}
mCubeReflector.unregisterReflector();
}
}
@ -2090,7 +2080,7 @@ void ShapeBase::updateAudioState(Sound& st)
{
if ( isGhost() )
{
if ( Sim::findObject( SimObjectId( st.profile ), st.profile ) )
if ( Sim::findObject( SimObjectId((uintptr_t)st.profile), st.profile ) )
{
st.sound = SFX->createSource( st.profile, &getTransform() );
if ( st.sound )
@ -3161,40 +3151,9 @@ void ShapeBase::unpackUpdate(NetConnection *con, BitStream *stream)
{
if ( imageData->lightType == ShapeBaseImageData::WeaponFireLight )
image.lightStart = Sim::getCurrentTime();
// HACK: Only works properly if you are in control
// of the one and only shapeBase object in the scene
// which fires an image that uses camera shake.
if ( imageData->shakeCamera )
{
if ( !mWeaponCamShake )
{
mWeaponCamShake = new CameraShake();
mWeaponCamShake->remoteControlled = true;
}
mWeaponCamShake->init();
mWeaponCamShake->setFrequency( imageData->camShakeFreq );
mWeaponCamShake->setAmplitude( imageData->camShakeAmp );
if ( !mWeaponCamShake->isAdded )
{
gCamFXMgr.addFX( mWeaponCamShake );
mWeaponCamShake->isAdded = true;
}
}
}
updateImageState(i,0);
if ( !image.triggerDown && !image.altTriggerDown )
{
if ( mWeaponCamShake && mWeaponCamShake->isAdded )
{
gCamFXMgr.removeFX( mWeaponCamShake );
mWeaponCamShake->isAdded = false;
}
}
}
else
{

View file

@ -324,7 +324,10 @@ struct ShapeBaseImageData: public GameBaseData {
/// @{
bool shakeCamera;
VectorF camShakeFreq;
VectorF camShakeAmp;
VectorF camShakeAmp;
F32 camShakeDuration;
F32 camShakeRadius;
F32 camShakeFalloff;
/// @}
/// Maximum number of sounds this image can play at a time.
@ -903,9 +906,6 @@ protected:
bool mFlipFadeVal;
/// Camera shake caused by weapon fire.
CameraShake *mWeaponCamShake;
public:
/// @name Collision Notification
@ -1101,6 +1101,7 @@ protected:
virtual void onImageAnimThreadChange(U32 imageSlot, S32 imageShapeIndex, ShapeBaseImageData::StateData* lastState, const char* anim, F32 pos, F32 timeScale, bool reset=false);
virtual void onImageAnimThreadUpdate(U32 imageSlot, S32 imageShapeIndex, F32 dt);
virtual void ejectShellCasing( U32 imageSlot );
virtual void shakeCamera( U32 imageSlot );
virtual void updateDamageLevel();
virtual void updateDamageState();
virtual void onImpact(SceneObject* obj, VectorF vec);

View file

@ -44,6 +44,7 @@
#include "sfx/sfxTypes.h"
#include "scene/sceneManager.h"
#include "core/stream/fileStream.h"
#include "T3D/fx/cameraFXMgr.h"
//----------------------------------------------------------------------------
@ -297,6 +298,9 @@ ShapeBaseImageData::ShapeBaseImageData()
shakeCamera = false;
camShakeFreq = Point3F::Zero;
camShakeAmp = Point3F::Zero;
camShakeDuration = 1.5f;
camShakeRadius = 3.0f;
camShakeFalloff = 10.0f;
}
ShapeBaseImageData::~ShapeBaseImageData()
@ -405,12 +409,12 @@ bool ShapeBaseImageData::preload(bool server, String &errorStr)
// Resolve objects transmitted from server
if (!server) {
if (projectile)
if (Sim::findObject(SimObjectId(projectile), projectile) == false)
if (Sim::findObject(SimObjectId((uintptr_t)projectile), projectile) == false)
Con::errorf(ConsoleLogEntry::General, "Error, unable to load projectile for shapebaseimagedata");
for (U32 i = 0; i < MaxStates; i++) {
if (state[i].emitter)
if (!Sim::findObject(SimObjectId(state[i].emitter), state[i].emitter))
if (!Sim::findObject(SimObjectId((uintptr_t)state[i].emitter), state[i].emitter))
Con::errorf(ConsoleLogEntry::General, "Error, unable to load emitter for image datablock");
String str;
@ -739,10 +743,7 @@ void ShapeBaseImageData::initPersistFields()
"@see lightType");
addField( "shakeCamera", TypeBool, Offset(shakeCamera, ShapeBaseImageData),
"@brief Flag indicating whether the camera should shake when this Image fires.\n\n"
"@note Camera shake only works properly if the player is in control of "
"the one and only shapeBase object in the scene which fires an Image that "
"uses camera shake." );
"@brief Flag indicating whether the camera should shake when this Image fires.\n\n" );
addField( "camShakeFreq", TypePoint3F, Offset(camShakeFreq, ShapeBaseImageData),
"@brief Frequency of the camera shaking effect.\n\n"
@ -752,6 +753,16 @@ void ShapeBaseImageData::initPersistFields()
"@brief Amplitude of the camera shaking effect.\n\n"
"@see shakeCamera" );
addField( "camShakeDuration", TypeF32, Offset(camShakeDuration, ShapeBaseImageData),
"Duration (in seconds) to shake the camera." );
addField( "camShakeRadius", TypeF32, Offset(camShakeRadius, ShapeBaseImageData),
"Radial distance that a camera's position must be within relative to the "
"center of the explosion to be shaken." );
addField( "camShakeFalloff", TypeF32, Offset(camShakeFalloff, ShapeBaseImageData),
"Falloff value for the camera shake." );
addField( "casing", TYPEID< DebrisData >(), Offset(casing, ShapeBaseImageData),
"@brief DebrisData datablock to use for ejected casings.\n\n"
"@see stateEjectShell" );
@ -1008,7 +1019,7 @@ void ShapeBaseImageData::packData(BitStream* stream)
// Write the projectile datablock
if (stream->writeFlag(projectile))
stream->writeRangedU32(packed? SimObjectId(projectile):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)projectile):
projectile->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
stream->writeFlag(cloakable);
@ -1028,6 +1039,9 @@ void ShapeBaseImageData::packData(BitStream* stream)
{
mathWrite( *stream, camShakeFreq );
mathWrite( *stream, camShakeAmp );
stream->write( camShakeDuration );
stream->write( camShakeRadius );
stream->write( camShakeFalloff );
}
mathWrite( *stream, shellExitDir );
@ -1036,7 +1050,7 @@ void ShapeBaseImageData::packData(BitStream* stream)
if( stream->writeFlag( casing ) )
{
stream->writeRangedU32(packed? SimObjectId(casing):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)casing):
casing->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
}
@ -1125,7 +1139,7 @@ void ShapeBaseImageData::packData(BitStream* stream)
if (stream->writeFlag(s.emitter))
{
stream->writeRangedU32(packed? SimObjectId(s.emitter):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)s.emitter):
s.emitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
stream->write(s.emitterTime);
@ -1208,7 +1222,10 @@ void ShapeBaseImageData::unpackData(BitStream* stream)
if ( shakeCamera )
{
mathRead( *stream, &camShakeFreq );
mathRead( *stream, &camShakeAmp );
mathRead( *stream, &camShakeAmp );
stream->read( &camShakeDuration );
stream->read( &camShakeRadius );
stream->read( &camShakeFalloff );
}
mathRead( *stream, &shellExitDir );
@ -2596,6 +2613,10 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force)
ejectShellCasing( imageSlot );
}
// Shake camera on client.
if (isGhost() && nextStateData.fire && image.dataBlock->shakeCamera) {
shakeCamera( imageSlot );
}
// Server must animate the shape if it is a firestate...
if (isServerObject() && (image.dataBlock->state[newState].fire || image.dataBlock->state[newState].altFire))
@ -3339,6 +3360,60 @@ void ShapeBase::ejectShellCasing( U32 imageSlot )
if (!casing->registerObject())
delete casing;
casing->init( shellPos, shellVel );
else
casing->init( shellPos, shellVel );
}
void ShapeBase::shakeCamera( U32 imageSlot )
{
MountedImage& image = mMountedImageList[imageSlot];
ShapeBaseImageData* imageData = image.dataBlock;
if (!imageData->shakeCamera)
return;
// Warning: this logic was duplicated from Explosion.
// first check if explosion is near camera
GameConnection* connection = GameConnection::getConnectionToServer();
ShapeBase *obj = dynamic_cast<ShapeBase*>(connection->getControlObject());
bool applyShake = true;
if (obj)
{
ShapeBase* cObj = obj;
while ((cObj = cObj->getControlObject()) != 0)
{
if (cObj->useObjsEyePoint())
{
applyShake = false;
break;
}
}
}
if (applyShake && obj)
{
VectorF diff;
getMuzzlePoint(imageSlot, &diff);
diff = obj->getPosition() - diff;
F32 dist = diff.len();
if (dist < imageData->camShakeRadius)
{
CameraShake *camShake = new CameraShake;
camShake->setDuration(imageData->camShakeDuration);
camShake->setFrequency(imageData->camShakeFreq);
F32 falloff = dist / imageData->camShakeRadius;
falloff = 1.0f + falloff * 10.0f;
falloff = 1.0f / (falloff * falloff);
VectorF shakeAmp = imageData->camShakeAmp * falloff;
camShake->setAmplitude(shakeAmp);
camShake->setFalloff(imageData->camShakeFalloff);
camShake->init();
gCamFXMgr.addFX(camShake);
}
}
}

View file

@ -1019,7 +1019,7 @@ void TSStaticPolysoupConvex::getPolyList(AbstractPolyList *list)
list->addPoint(verts[2]);
list->addPoint(verts[1]);
list->begin(0, (U32)idx ^ (U32)mesh);
list->begin(0, (U32)idx ^ (uintptr_t)mesh);
list->vertex(base + 2);
list->vertex(base + 1);
list->vertex(base + 0);

View file

@ -23,7 +23,7 @@
#ifndef _TURRETSHAPE_H_
#define _TURRETSHAPE_H_
#ifndef _SHAPEBASE_H_
#ifndef _ITEM_H_
#include "T3D/item.h"
#endif

View file

@ -134,11 +134,11 @@ bool FlyingVehicleData::preload(bool server, String &errorStr)
if (!server) {
for (S32 i = 0; i < MaxSounds; i++)
if (sound[i])
Sim::findObject(SimObjectId(sound[i]),sound[i]);
Sim::findObject(SimObjectId((uintptr_t)sound[i]),sound[i]);
for (S32 j = 0; j < MaxJetEmitters; j++)
if (jetEmitter[j])
Sim::findObject(SimObjectId(jetEmitter[j]),jetEmitter[j]);
Sim::findObject(SimObjectId((uintptr_t)jetEmitter[j]),jetEmitter[j]);
}
// Extract collision planes from shape collision detail level
@ -244,7 +244,7 @@ void FlyingVehicleData::packData(BitStream* stream)
{
if (stream->writeFlag(sound[i]))
{
SimObjectId writtenId = packed ? SimObjectId(sound[i]) : sound[i]->getId();
SimObjectId writtenId = packed ? SimObjectId((uintptr_t)sound[i]) : sound[i]->getId();
stream->writeRangedU32(writtenId, DataBlockObjectIdFirst, DataBlockObjectIdLast);
}
}
@ -253,7 +253,7 @@ void FlyingVehicleData::packData(BitStream* stream)
{
if (stream->writeFlag(jetEmitter[j]))
{
SimObjectId writtenId = packed ? SimObjectId(jetEmitter[j]) : jetEmitter[j]->getId();
SimObjectId writtenId = packed ? SimObjectId((uintptr_t)jetEmitter[j]) : jetEmitter[j]->getId();
stream->writeRangedU32(writtenId, DataBlockObjectIdFirst,DataBlockObjectIdLast);
}
}

View file

@ -315,10 +315,10 @@ bool HoverVehicleData::preload(bool server, String &errorStr)
if (!server) {
for (S32 i = 0; i < MaxSounds; i++)
if (sound[i])
Sim::findObject(SimObjectId(sound[i]),sound[i]);
Sim::findObject(SimObjectId((uintptr_t)sound[i]),sound[i]);
for (S32 j = 0; j < MaxJetEmitters; j++)
if (jetEmitter[j])
Sim::findObject(SimObjectId(jetEmitter[j]),jetEmitter[j]);
Sim::findObject(SimObjectId((uintptr_t)jetEmitter[j]),jetEmitter[j]);
}
if( !dustTrailEmitter && dustTrailID != 0 )
@ -364,14 +364,14 @@ void HoverVehicleData::packData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++)
if (stream->writeFlag(sound[i]))
stream->writeRangedU32(packed? SimObjectId(sound[i]):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)sound[i]):
sound[i]->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
for (S32 j = 0; j < MaxJetEmitters; j++)
{
if (stream->writeFlag(jetEmitter[j]))
{
SimObjectId writtenId = packed ? SimObjectId(jetEmitter[j]) : jetEmitter[j]->getId();
SimObjectId writtenId = packed ? SimObjectId((uintptr_t)jetEmitter[j]) : jetEmitter[j]->getId();
stream->writeRangedU32(writtenId, DataBlockObjectIdFirst,DataBlockObjectIdLast);
}
}

View file

@ -226,7 +226,7 @@ bool VehicleData::preload(bool server, String &errorStr)
if (!server) {
for (S32 i = 0; i < Body::MaxSounds; i++)
if (body.sound[i])
Sim::findObject(SimObjectId(body.sound[i]),body.sound[i]);
Sim::findObject(SimObjectId((uintptr_t)body.sound[i]),body.sound[i]);
}
if( !dustEmitter && dustID != 0 )
@ -275,7 +275,7 @@ void VehicleData::packData(BitStream* stream)
stream->write(body.friction);
for (i = 0; i < Body::MaxSounds; i++)
if (stream->writeFlag(body.sound[i]))
stream->writeRangedU32(packed? SimObjectId(body.sound[i]):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)body.sound[i]):
body.sound[i]->getId(),DataBlockObjectIdFirst,
DataBlockObjectIdLast);

View file

@ -343,7 +343,7 @@ bool WheeledVehicleData::preload(bool server, String &errorStr)
return false;
if (tireEmitter)
Sim::findObject(SimObjectId(tireEmitter),tireEmitter);
Sim::findObject(SimObjectId((uintptr_t)tireEmitter),tireEmitter);
}
// Extract wheel information from the shape
@ -477,7 +477,7 @@ void WheeledVehicleData::packData(BitStream* stream)
Parent::packData(stream);
if (stream->writeFlag(tireEmitter))
stream->writeRangedU32(packed? SimObjectId(tireEmitter):
stream->writeRangedU32(packed? SimObjectId((uintptr_t)tireEmitter):
tireEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
for (S32 i = 0; i < MaxSounds; i++)

View file

@ -460,7 +460,7 @@ bool StandardMainLoop::handleCommandLine( S32 argc, const char **argv )
#endif
success = str.open(defaultScriptName, Torque::FS::File::Read);
#if defined( TORQUE_DEBUG ) && defined (TORQUE_TOOLS) && !defined( _XBOX )
#if defined( TORQUE_DEBUG ) && defined (TORQUE_TOOLS) && !defined(TORQUE_DEDICATED) && !defined( _XBOX )
if (!success)
{
OpenFileDialog ofd;

View file

@ -41,10 +41,10 @@
/// code version, the game name, and which type of game it is (TGB, TGE, TGEA, etc.).
///
/// Version number is major * 1000 + minor * 100 + revision * 10.
#define TORQUE_GAME_ENGINE 3620
#define TORQUE_GAME_ENGINE 3630
/// Human readable engine version string.
#define TORQUE_GAME_ENGINE_VERSION_STRING "3.6.2"
#define TORQUE_GAME_ENGINE_VERSION_STRING "3.6.3"
/// Gets the engine version number. The version number is specified as a global in version.cc
U32 getVersionNumber();

View file

@ -427,7 +427,7 @@ extern "C" {
PlatformWindowManager::get()->getFirstWindow()->setSize(Point2I(width,height));
}
#ifdef TORQUE_OS_WIN
#if defined(TORQUE_OS_WIN) && !defined(TORQUE_SDL)
// retrieve the hwnd of our render window
void* torque_gethwnd()
{

View file

@ -456,6 +456,21 @@ expr
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, NULL); }
| VAR '[' aidx_expr ']'
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, $3 ); }
| rwDEFINE '(' var_list_decl ')' '{' statement_list '}'
{
const U32 bufLen = 64;
UTF8 buffer[bufLen];
dSprintf(buffer, bufLen, "__anonymous_function%d", gAnonFunctionID++);
StringTableEntry fName = StringTable->insert(buffer);
StmtNode *fndef = FunctionDeclStmtNode::alloc($1.lineNumber, fName, NULL, $3, $6);
if(!gAnonFunctionList)
gAnonFunctionList = fndef;
else
gAnonFunctionList->append(fndef);
$$ = StrConstNode::alloc( $1.lineNumber, (UTF8*)fName, false );
}
;
slot_acc

File diff suppressed because it is too large Load diff

View file

@ -575,6 +575,8 @@ struct FunctionDeclStmtNode : StmtNode
};
extern StmtNode *gStatementList;
extern ExprEvalState gEvalState;;
extern StmtNode *gAnonFunctionList;
extern U32 gAnonFunctionID;
extern ExprEvalState gEvalState;
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,199 +1,4 @@
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
rwDEFINE = 258,
rwENDDEF = 259,
rwDECLARE = 260,
rwDECLARESINGLETON = 261,
rwBREAK = 262,
rwELSE = 263,
rwCONTINUE = 264,
rwGLOBAL = 265,
rwIF = 266,
rwNIL = 267,
rwRETURN = 268,
rwWHILE = 269,
rwDO = 270,
rwENDIF = 271,
rwENDWHILE = 272,
rwENDFOR = 273,
rwDEFAULT = 274,
rwFOR = 275,
rwFOREACH = 276,
rwFOREACHSTR = 277,
rwIN = 278,
rwDATABLOCK = 279,
rwSWITCH = 280,
rwCASE = 281,
rwSWITCHSTR = 282,
rwCASEOR = 283,
rwPACKAGE = 284,
rwNAMESPACE = 285,
rwCLASS = 286,
rwASSERT = 287,
ILLEGAL_TOKEN = 288,
CHRCONST = 289,
INTCONST = 290,
TTAG = 291,
VAR = 292,
IDENT = 293,
TYPEIDENT = 294,
DOCBLOCK = 295,
STRATOM = 296,
TAGATOM = 297,
FLTCONST = 298,
opINTNAME = 299,
opINTNAMER = 300,
opMINUSMINUS = 301,
opPLUSPLUS = 302,
STMT_SEP = 303,
opSHL = 304,
opSHR = 305,
opPLASN = 306,
opMIASN = 307,
opMLASN = 308,
opDVASN = 309,
opMODASN = 310,
opANDASN = 311,
opXORASN = 312,
opORASN = 313,
opSLASN = 314,
opSRASN = 315,
opCAT = 316,
opEQ = 317,
opNE = 318,
opGE = 319,
opLE = 320,
opAND = 321,
opOR = 322,
opSTREQ = 323,
opCOLONCOLON = 324,
opNTASN = 325,
opNDASN = 326,
opMDASN = 327,
opSTRNE = 328,
UNARY = 329
};
#endif
/* Tokens. */
#define rwDEFINE 258
#define rwENDDEF 259
#define rwDECLARE 260
#define rwDECLARESINGLETON 261
#define rwBREAK 262
#define rwELSE 263
#define rwCONTINUE 264
#define rwGLOBAL 265
#define rwIF 266
#define rwNIL 267
#define rwRETURN 268
#define rwWHILE 269
#define rwDO 270
#define rwENDIF 271
#define rwENDWHILE 272
#define rwENDFOR 273
#define rwDEFAULT 274
#define rwFOR 275
#define rwFOREACH 276
#define rwFOREACHSTR 277
#define rwIN 278
#define rwDATABLOCK 279
#define rwSWITCH 280
#define rwCASE 281
#define rwSWITCHSTR 282
#define rwCASEOR 283
#define rwPACKAGE 284
#define rwNAMESPACE 285
#define rwCLASS 286
#define rwASSERT 287
#define ILLEGAL_TOKEN 288
#define CHRCONST 289
#define INTCONST 290
#define TTAG 291
#define VAR 292
#define IDENT 293
#define TYPEIDENT 294
#define DOCBLOCK 295
#define STRATOM 296
#define TAGATOM 297
#define FLTCONST 298
#define opINTNAME 299
#define opINTNAMER 300
#define opMINUSMINUS 301
#define opPLUSPLUS 302
#define STMT_SEP 303
#define opSHL 304
#define opSHR 305
#define opPLASN 306
#define opMIASN 307
#define opMLASN 308
#define opDVASN 309
#define opMODASN 310
#define opANDASN 311
#define opXORASN 312
#define opORASN 313
#define opSLASN 314
#define opSRASN 315
#define opCAT 316
#define opEQ 317
#define opNE 318
#define opGE 319
#define opLE 320
#define opAND 321
#define opOR 322
#define opSTREQ 323
#define opCOLONCOLON 324
#define opNTASN 325
#define opNDASN 326
#define opMDASN 327
#define opSTRNE 328
#define UNARY 329
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 82 "CMDgram.y"
{
typedef union {
Token< char > c;
Token< int > i;
Token< const char* > s;
@ -209,14 +14,79 @@ typedef union YYSTYPE
ObjectDeclNode* od;
AssignDecl asn;
IfStmtNode* ifnode;
}
/* Line 1529 of yacc.c. */
#line 215 "cmdgram.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
} YYSTYPE;
#define rwDEFINE 258
#define rwENDDEF 259
#define rwDECLARE 260
#define rwDECLARESINGLETON 261
#define rwBREAK 262
#define rwELSE 263
#define rwCONTINUE 264
#define rwGLOBAL 265
#define rwIF 266
#define rwNIL 267
#define rwRETURN 268
#define rwWHILE 269
#define rwDO 270
#define rwENDIF 271
#define rwENDWHILE 272
#define rwENDFOR 273
#define rwDEFAULT 274
#define rwFOR 275
#define rwFOREACH 276
#define rwFOREACHSTR 277
#define rwIN 278
#define rwDATABLOCK 279
#define rwSWITCH 280
#define rwCASE 281
#define rwSWITCHSTR 282
#define rwCASEOR 283
#define rwPACKAGE 284
#define rwNAMESPACE 285
#define rwCLASS 286
#define rwASSERT 287
#define ILLEGAL_TOKEN 288
#define CHRCONST 289
#define INTCONST 290
#define TTAG 291
#define VAR 292
#define IDENT 293
#define TYPEIDENT 294
#define DOCBLOCK 295
#define STRATOM 296
#define TAGATOM 297
#define FLTCONST 298
#define opINTNAME 299
#define opINTNAMER 300
#define opMINUSMINUS 301
#define opPLUSPLUS 302
#define STMT_SEP 303
#define opSHL 304
#define opSHR 305
#define opPLASN 306
#define opMIASN 307
#define opMLASN 308
#define opDVASN 309
#define opMODASN 310
#define opANDASN 311
#define opXORASN 312
#define opORASN 313
#define opSLASN 314
#define opSRASN 315
#define opCAT 316
#define opEQ 317
#define opNE 318
#define opGE 319
#define opLE 320
#define opAND 321
#define opOR 322
#define opSTREQ 323
#define opCOLONCOLON 324
#define opMDASN 325
#define opNDASN 326
#define opNTASN 327
#define opSTRNE 328
#define UNARY 329
extern YYSTYPE CMDlval;

View file

@ -468,6 +468,7 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
STEtoCode = compileSTEtoCode;
gStatementList = NULL;
gAnonFunctionList = NULL;
// Set up the parser.
smCurrentParser = getParserForFile(fileName);
@ -477,6 +478,17 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
smCurrentParser->setScanBuffer(script, fileName);
smCurrentParser->restart(NULL);
smCurrentParser->parse();
if (gStatementList)
{
if (gAnonFunctionList)
{
// Prepend anonymous functions to statement list, so they're defined already when
// the statements run.
gAnonFunctionList->append(gStatementList);
gStatementList = gAnonFunctionList;
}
}
if(gSyntaxError)
{
@ -599,6 +611,7 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri
addToCodeList();
gStatementList = NULL;
gAnonFunctionList = NULL;
// Set up the parser.
smCurrentParser = getParserForFile(fileName);
@ -608,6 +621,16 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri
smCurrentParser->setScanBuffer(string, fileName);
smCurrentParser->restart(NULL);
smCurrentParser->parse();
if (gStatementList)
{
if (gAnonFunctionList)
{
// Prepend anonymous functions to statement list, so they're defined already when
// the statements run.
gAnonFunctionList->append(gStatementList);
gStatementList = gAnonFunctionList;
}
}
if(!gStatementList)
{

View file

@ -400,7 +400,7 @@ void CodeStream::reset()
{
CodeData *next = itr->next;
dFree(itr->data);
dFree(itr);
delete(itr);
itr = next;
}

View file

@ -47,6 +47,8 @@ extern ConsoleValueStack CSTK;
ConsoleDocFragment* ConsoleDocFragment::smFirst;
ExprEvalState gEvalState;
StmtNode *gStatementList;
StmtNode *gAnonFunctionList;
U32 gAnonFunctionID = 0;
ConsoleConstructor *ConsoleConstructor::first = NULL;
bool gWarnUndefinedScriptVariables;
@ -1645,7 +1647,7 @@ StringStackConsoleWrapper::~StringStackConsoleWrapper()
{
for (int i=0; i<argc; i++)
{
argv[i] = NULL;
argv[i] = 0;
}
delete[] argv;
}

View file

@ -882,7 +882,7 @@ void Namespace::Entry::clear()
// Clean up usage strings generated for script functions.
if( ( mType == Namespace::Entry::ConsoleFunctionType ) && mUsage )
{
delete mUsage;
dFree(mUsage);
mUsage = NULL;
}
}
@ -908,7 +908,7 @@ Namespace::~Namespace()
clearEntries();
if( mUsage && mCleanUpUsage )
{
delete mUsage;
dFree(mUsage);
mUsage = NULL;
mCleanUpUsage = false;
}

View file

@ -579,7 +579,7 @@ AbstractClassRep* ConsoleObject::getClassRep() const
return NULL;
}
String ConsoleObject::_getLogMessage(const char* fmt, void* args) const
String ConsoleObject::_getLogMessage(const char* fmt, va_list args) const
{
String objClass = "UnknownClass";
if(getClassRep())

View file

@ -863,7 +863,7 @@ public:
/// @param fmt A printf style format string.
/// @param args A va_list containing the args passed ot a log function.
/// @note It is suggested that you use String::VToString.
virtual String _getLogMessage(const char* fmt, void* args) const;
virtual String _getLogMessage(const char* fmt, va_list args) const;
/// @}

View file

@ -575,7 +575,7 @@ namespace _Private {
///
#define FIELDOFFSET( fieldName ) \
U32( ( ( const char* ) &( ( ( ThisType* ) 16 )->fieldName ) ) - 16 ) // Artificial offset to avoid compiler warnings.
uintptr_t( ( ( const char* ) &( ( ( ThisType* ) 16 )->fieldName ) ) - 16 ) // Artificial offset to avoid compiler warnings.
///
#define CLASSDOC( className, doc ) \

View file

@ -1599,8 +1599,7 @@ void SimObject::unlinkNamespaces()
// Handle object name.
StringTableEntry objectName = getName();
if( objectName && objectName[ 0 ] )
if (mNameSpace && mNameSpace->mClassRep == NULL)
mNameSpace->decRefCountToParent();
mNameSpace = NULL;
@ -1833,7 +1832,7 @@ void SimObject::inspectPostApply()
//-----------------------------------------------------------------------------
String SimObject::_getLogMessage(const char* fmt, void* args) const
String SimObject::_getLogMessage(const char* fmt, va_list args) const
{
String objClass = "UnknownClass";
if(getClassRep())

View file

@ -411,7 +411,7 @@ class SimObject: public ConsoleObject
virtual void _onUnselected() {}
/// We can provide more detail, like object name and id.
virtual String _getLogMessage(const char* fmt, void* args) const;
virtual String _getLogMessage(const char* fmt, va_list args) const;
DEFINE_CREATE_METHOD
{

View file

@ -66,6 +66,7 @@ ConnectionProtocol::ConnectionProtocol()
mLastSendSeq = 0; // start sending at 1
mAckMask = 0;
mLastRecvAckAck = 0;
mConnectionEstablished = false;
}
void ConnectionProtocol::buildSendPacketHeader(BitStream *stream, S32 packetType)
{

View file

@ -22,6 +22,7 @@
#include "core/strings/stringFunctions.h"
#include "core/stringTable.h"
#include "platform/profiler.h"
_StringTable *_gStringTable = NULL;
const U32 _StringTable::csm_stInitSize = 29;
@ -121,6 +122,8 @@ void _StringTable::destroy()
//--------------------------------------
StringTableEntry _StringTable::insert(const char* _val, const bool caseSens)
{
PROFILE_SCOPE(StringTableInsert);
// Added 3/29/2007 -- If this is undesirable behavior, let me know -patw
const char *val = _val;
if( val == NULL )
@ -165,6 +168,8 @@ StringTableEntry _StringTable::insertn(const char* src, S32 len, const bool cas
//--------------------------------------
StringTableEntry _StringTable::lookup(const char* val, const bool caseSens)
{
PROFILE_SCOPE(StringTableLookup);
Node **walk, *temp;
U32 key = hashString(val);
walk = &buckets[key % numBuckets];
@ -181,6 +186,8 @@ StringTableEntry _StringTable::lookup(const char* val, const bool caseSens)
//--------------------------------------
StringTableEntry _StringTable::lookupn(const char* val, S32 len, const bool caseSens)
{
PROFILE_SCOPE(StringTableLookupN);
Node **walk, *temp;
U32 key = hashStringn(val, len);
walk = &buckets[key % numBuckets];

View file

@ -391,9 +391,9 @@ void dPrintf(const char *format, ...)
vprintf(format, args);
}
S32 dVprintf(const char *format, void *arglist)
S32 dVprintf(const char *format, va_list arglist)
{
return vprintf(format, (char*)arglist);
return (S32)vprintf(format, arglist);
}
S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)
@ -409,9 +409,9 @@ S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)
}
S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist)
S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, va_list arglist)
{
S32 len = vsnprintf(buffer, bufferSize, format, (char*)arglist);
S32 len = vsnprintf(buffer, bufferSize, format, arglist);
AssertWarn( len < bufferSize, "Buffer too small in call to dVsprintf!" );

View file

@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <cstdarg>
#ifndef _TORQUE_TYPES_H_
#include "platform/types.h"
@ -229,9 +230,9 @@ int dItoa(int n, char s[]);
// standard I/O functions [defined in platformString.cpp]
extern void dPrintf(const char *format, ...);
extern S32 dVprintf(const char *format, void *arglist);
extern S32 dVprintf(const char *format, va_list arglist);
extern S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...);
extern S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist);
extern S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, va_list arglist);
extern S32 dSscanf(const char *buffer, const char *format, ...);
#endif

View file

@ -601,10 +601,13 @@ bool chompUTF8BOM( const char *inString, char **outStringPtr )
{
*outStringPtr = const_cast<char *>( inString );
U8 bom[4];
dMemcpy( bom, inString, 4 );
bool valid = isValidUTF8BOM( bom );
bool valid = false;
if (inString[0] && inString[1] && inString[2])
{
U8 bom[4];
dMemcpy(bom, inString, 4);
valid = isValidUTF8BOM(bom);
}
// This is hackey, but I am not sure the best way to do it at the present.
// The only valid BOM is a UTF8 BOM, which is 3 bytes, even though we read

View file

@ -495,7 +495,7 @@ DefineConsoleFunction( dumpStringMemStats, void, (), , "()"
void* String::StringData::operator new( size_t size, U32 len )
{
AssertFatal( len != 0, "String::StringData::operator new() - string must not be empty" );
StringData *str = reinterpret_cast<StringData*>( dMalloc( size + len * sizeof(StringChar) ) );
StringData *str = static_cast<StringData*>( dMalloc( size + len * sizeof(StringChar) ) );
str->mLength = len;
@ -523,7 +523,7 @@ void String::StringData::operator delete(void *ptr)
void* String::StringData::operator new( size_t size, U32 len, DataChunker& chunker )
{
AssertFatal( len != 0, "String::StringData::operator new() - string must not be empty" );
StringData *str = reinterpret_cast<StringData*>( chunker.alloc( size + len * sizeof(StringChar) ) );
StringData *str = static_cast<StringData*>( chunker.alloc( size + len * sizeof(StringChar) ) );
str->mLength = len;
@ -1434,19 +1434,19 @@ String::StrFormat::~StrFormat()
dFree( _dynamicBuffer );
}
S32 String::StrFormat::format( const char *format, void *args )
S32 String::StrFormat::format( const char *format, va_list args )
{
_len=0;
return formatAppend(format,args);
}
S32 String::StrFormat::formatAppend( const char *format, void *args )
S32 String::StrFormat::formatAppend( const char *format, va_list args )
{
// Format into the fixed buffer first.
S32 startLen = _len;
if (_dynamicBuffer == NULL)
{
_len += vsnprintf(_fixedBuffer + _len, sizeof(_fixedBuffer) - _len, format, *(va_list*)args);
_len += vsnprintf(_fixedBuffer + _len, sizeof(_fixedBuffer) - _len, format, args);
if (_len >= 0 && _len < sizeof(_fixedBuffer))
return _len;
@ -1535,9 +1535,9 @@ String String::ToString(const char *str, ...)
return ret;
}
String String::VToString(const char* str, void* args)
String String::VToString(const char* str, va_list args)
{
StrFormat format(str,&args);
StrFormat format(str,args);
// Copy it into a string
U32 len = format.length();

View file

@ -176,7 +176,7 @@ public:
/// @{
static String ToString(const char *format, ...);
static String VToString(const char* format, void* args);
static String VToString(const char* format, va_list args);
static String ToString( bool v );
static inline String ToString( U32 v ) { return ToString( "%u", v ); }
@ -245,7 +245,7 @@ public:
_fixedBuffer[0] = '\0';
}
StrFormat(const char *formatStr, void *args)
StrFormat(const char *formatStr, va_list args)
: _dynamicBuffer( NULL ),
_dynamicSize( 0 ),
_len( 0 )
@ -255,8 +255,8 @@ public:
~StrFormat();
S32 format( const char *format, void *args );
S32 formatAppend( const char *format, void *args );
S32 format( const char *format, va_list args );
S32 formatAppend( const char *format, va_list args );
S32 append(const char * str, S32 len);
S32 append(const char * str);
@ -357,7 +357,7 @@ class StringBuilder
{
va_list args;
va_start(args, fmt);
return mFormat.formatAppend(fmt, &args);
return mFormat.formatAppend(fmt, args);
}
};

View file

@ -95,7 +95,7 @@ namespace DictHash
inline U32 hash(const void *data)
{
return (U32)data;
return (uintptr_t)data;
}
template<class A, class B>

View file

@ -155,8 +155,8 @@ void DecalRoadNodeEvent::padListToSize()
newlist->mPositions.merge(list->mPositions);
newlist->mWidths.merge(list->mWidths);
mNodeList = newlist;
delete list;
mNodeList = list = newlist;
}
// Pad our list end?
@ -1726,4 +1726,4 @@ DefineEngineMethod( DecalRoad, postApply, void, (),,
)
{
object->inspectPostApply();
}
}

View file

@ -203,8 +203,8 @@ void MeshRoadNodeEvent::padListToSize()
newlist->mDepths.merge(list->mDepths);
newlist->mNormals.merge(list->mNormals);
mNodeList = newlist;
delete list;
mNodeList = list = newlist;
}
// Pad our list end?
@ -864,7 +864,7 @@ void MeshRoad::prepRenderImage( SceneRenderState* state )
// We sort by the material then vertex buffer.
ri->defaultKey = matInst->getStateHint();
ri->defaultKey2 = (U32)ri->vertBuff; // Not 64bit safe!
ri->defaultKey2 = (uintptr_t)ri->vertBuff; // Not 64bit safe!
renderPass->addInst( ri );
}

View file

@ -227,8 +227,8 @@ void RiverNodeEvent::padListToSize()
newlist->mDepths.merge(list->mDepths);
newlist->mNormals.merge(list->mNormals);
mNodeList = newlist;
delete list;
mNodeList = list = newlist;
}
// Pad our list end?

View file

@ -136,6 +136,7 @@ ScatterSky::ScatterSky()
mExposure = 1.0f;
mNightInterpolant = 0;
mZOffset = 0.0f;
mShader = NULL;
@ -313,7 +314,7 @@ void ScatterSky::setElevation( F32 elevation )
void ScatterSky::inspectPostApply()
{
mDirty = true;
setMaskBits( 0xFFFFFFFF );
setMaskBits( 0xFFFFFFFF );
}
void ScatterSky::initPersistFields()
@ -324,13 +325,13 @@ void ScatterSky::initPersistFields()
addField( "skyBrightness", TypeF32, Offset( mSkyBrightness, ScatterSky ),
"Global brightness and intensity applied to the sky and objects in the level." );
addField( "sunSize", TypeF32, Offset( mSunSize, ScatterSky ),
addField( "sunSize", TypeF32, Offset( mSunSize, ScatterSky ),
"Affects the size of the sun's disk." );
addField( "colorizeAmount", TypeF32, Offset( mColorizeAmt, ScatterSky ),
addField( "colorizeAmount", TypeF32, Offset( mColorizeAmt, ScatterSky ),
"Controls how much the the alpha component of colorize brigthens the sky. Setting to 0 returns default behavior." );
addField( "colorize", TypeColorF, Offset( mColorize, ScatterSky ),
addField( "colorize", TypeColorF, Offset( mColorize, ScatterSky ),
"Tints the sky the color specified, the alpha controls the brigthness. The brightness is multipled by the value of colorizeAmt." );
addField( "rayleighScattering", TypeF32, Offset( mRayleighScattering, ScatterSky ),
@ -350,6 +351,9 @@ void ScatterSky::initPersistFields()
addField( "exposure", TypeF32, Offset( mExposure, ScatterSky ),
"Controls the contrast of the sky and sun during daytime." );
addField( "zOffset", TypeF32, Offset( mZOffset, ScatterSky ),
"Offsets the scatterSky to avoid canvas rendering. Use 5000 or greater for the initial adjustment" );
endGroup( "ScatterSky" );
addGroup( "Orbit" );
@ -473,11 +477,13 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
stream->write( mAmbientScale );
stream->write( mSunScale );
stream->write( mFogScale );
stream->write( mColorizeAmt );
stream->write( mColorizeAmt );
stream->write( mColorize );
stream->write( mExposure );
stream->write( mZOffset );
stream->write( mBrightness );
stream->writeFlag( mCastShadows );
@ -556,7 +562,7 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
stream->read( &mAmbientScale );
stream->read( &mSunScale );
stream->read( &mFogScale );
F32 colorizeAmt;
F32 colorizeAmt;
stream->read( &colorizeAmt );
if(mColorizeAmt != colorizeAmt) {
@ -577,6 +583,8 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
stream->read( &mExposure );
stream->read( &mZOffset );
stream->read( &mBrightness );
mCastShadows = stream->readFlag();
@ -658,6 +666,11 @@ void ScatterSky::prepRenderImage( SceneRenderState *state )
mFlareState.lightMat.identity();
mFlareState.lightMat.setPosition( lightPos );
F32 dist = ( lightPos - state->getCameraPosition( ) ).len( );
F32 coronaScale = 0.5f;
F32 screenRadius = GFX->getViewport( ).extent.y * coronaScale * 0.5f;
mFlareState.worldRadius = screenRadius * dist / state->getWorldToScreenScale( ).y;
mFlareData->prepRender( state, &mFlareState );
}
@ -706,7 +719,7 @@ bool ScatterSky::_initShader()
Con::warnf( "ScatterSky::_initShader - failed to locate ScatterSkySBData!" );
else
mStateBlock = GFX->createStateBlock( data->getState() );
}
}
if ( !mStateBlock )
return false;
@ -937,7 +950,7 @@ void ScatterSky::_render( ObjectRenderInst *ri, SceneRenderState *state, BaseMat
Point3F camPos2 = state->getCameraPosition();
MatrixF xfm(true);
xfm.setPosition(camPos2);//-Point3F( 0, 0, 200000.0f));
xfm.setPosition(camPos2 - Point3F( 0, 0, mZOffset));
GFX->multWorld(xfm);
MatrixF xform(proj);//GFX->getProjectionMatrix());
xform *= GFX->getViewMatrix();
@ -979,7 +992,7 @@ void ScatterSky::_render( ObjectRenderInst *ri, SceneRenderState *state, BaseMat
mShaderConsts->setSafe( mUseCubemapSC, 0.0f );
}
GFX->setPrimitiveBuffer( mPrimBuffer );
GFX->setPrimitiveBuffer( mPrimBuffer );
GFX->setVertexBuffer( mVB );
GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, mVertCount, 0, mPrimCount );

View file

@ -179,6 +179,7 @@ protected:
F32 mExposure;
F32 mNightInterpolant;
F32 mZOffset;
VectorF mLightDir;
VectorF mSunDir;

View file

@ -68,7 +68,7 @@ void ForestCreateUndoAction::redo()
// We store the datablock ID rather than the actual pointer
// since the pointer could go bad.
ForestItemData *data;
if ( !Sim::findObject( (SimObjectId)(item.getData()), data ) )
if ( !Sim::findObject( (SimObjectId)(uintptr_t)(item.getData()), data ) )
{
Con::errorf( "ForestCreateUndoAction::redo() - ForestItemData for item to restore does not seem to exist. Undo stack may be hosed." );
continue;
@ -140,7 +140,7 @@ void ForestDeleteUndoAction::undo()
// We store the datablock ID rather than the actual pointer
// since the pointer could go bad.
ForestItemData *data;
if ( !Sim::findObject( (SimObjectId)(item.getData()), data ) )
if ( !Sim::findObject( (SimObjectId)(uintptr_t)(item.getData()), data ) )
{
Con::errorf( "ForestDeleteUndoAction::undo() - ForestItemData for item to restore does not seem to exist. Undo stack may be hosed." );
continue;
@ -201,7 +201,7 @@ void ForestUpdateAction::_swapState()
// We store the datablock ID rather than the actual pointer
// since the pointer could go bad.
ForestItemData *data;
if ( !Sim::findObject( (SimObjectId)(item.getData()), data ) )
if ( !Sim::findObject( (SimObjectId)(uintptr_t)(item.getData()), data ) )
{
Con::errorf( "ForestUpdateAction::_swapState() - ForestItemData for item to restore does not seem to exist. Undo stack may be hosed." );
continue;

View file

@ -39,6 +39,8 @@
#include "T3D/gameBase/processList.h"
#include "console/engineAPI.h"
#include "T3D/gameBase/gameConnection.h"
ConsoleDocClass( ForestWindEmitter,
"@brief Object responsible for simulating wind in a level.\n\n"
@ -513,9 +515,21 @@ void ForestWindEmitter::_renderEmitterInfo( ObjectRenderInst *ri, SceneRenderSta
drawer->drawArrow( desc, pos, pos + (windVec * mWindStrength), ColorI( 0, 0, 255, 255 ) );//Point3F( -235.214, 219.589, 34.0991 ), Point3F( -218.814, 244.731, 37.5587 ), ColorI( 255, 255, 0, 255 ) );//
drawer->drawArrow( desc, pos, pos + (mWind->getTarget() * mWindStrength ), ColorI( 255, 0, 0, 85 ) );
S32 useRadius = mWindRadius;
// Draw a 2D circle for the wind radius.
if ( isRadialEmitter() )
drawer->drawSphere( desc, mWindRadius, pos, ColorI( 255, 0, 0, 80 ) );
{
// If the camera is close to the sphere, shrink the sphere so it remains visible.
GameConnection* gc = GameConnection::getConnectionToServer();
GameBase* gb;
if ( gc && (gb = gc->getCameraObject()) )
{
F32 camDist = (gb->getPosition() - getPosition()).len();
if ( camDist < mWindRadius )
useRadius = camDist;
}
drawer->drawSphere( desc, useRadius, pos, ColorI( 255, 0, 0, 80 ) );
}
}
F32 ForestWindEmitter::getStrength() const

View file

@ -23,7 +23,7 @@
#ifndef _TSFORESTCELLBATCH_H_
#define _TSFORESTCELLBATCH_H_
#ifndef _FORESTCELLBATCH_H_
#ifndef _IMPOSTERRENDERMGR_H_
#include "renderInstance/renderImposterMgr.h"
#endif
#ifndef _FORESTCELLBATCH_H_

View file

@ -130,6 +130,7 @@ GFXD3D9OcclusionQuery::OcclusionQueryStatus GFXD3D9OcclusionQuery::getStatus( bo
//If we're stalled out, proceed with worst-case scenario -BJR
if(GFX->mFrameTime->getElapsedMs()>4)
{
this->begin();
this->end();
return NotOccluded;
}

View file

@ -332,10 +332,8 @@ void GFXPCD3D9Device::init( const GFXVideoMode &mode, PlatformWindow *window /*
initD3DXFnTable();
Win32Window *win = dynamic_cast<Win32Window*>( window );
AssertISV( win, "GFXD3D9Device::init - got a non Win32Window window passed in! Did DX go crossplatform?" );
HWND winHwnd = win->getHWND();
HWND winHwnd = (HWND)window->getSystemWindow( PlatformWindow::WindowSystem_Windows );
AssertISV(winHwnd, "GFXPCD3D9WindowTarget::initPresentationParams() - no HWND");
// Create D3D Presentation params
D3DPRESENT_PARAMETERS d3dpp = setupPresentParams( mode, winHwnd );
@ -1021,10 +1019,6 @@ bool GFXPCD3D9Device::beginSceneInternal()
GFXWindowTarget * GFXPCD3D9Device::allocWindowTarget( PlatformWindow *window )
{
AssertFatal(window,"GFXD3D9Device::allocWindowTarget - no window provided!");
#ifndef TORQUE_OS_XENON
AssertFatal(dynamic_cast<Win32Window*>(window),
"GFXD3D9Device::allocWindowTarget - only works with Win32Windows!");
#endif
// Set up a new window target...
GFXPCD3D9WindowTarget *gdwt = new GFXPCD3D9WindowTarget();

View file

@ -372,10 +372,8 @@ void GFXPCD3D9WindowTarget::initPresentationParams()
"GFXPCD3D9WindowTarget::initPresentationParams - Cannot go fullscreen with secondary window!");
}
Win32Window *win = dynamic_cast<Win32Window*>(mWindow);
AssertISV(win, "GFXPCD3D9WindowTarget::initPresentationParams() - got a non Win32Window window passed in! Did DX go crossplatform?");
HWND hwnd = win->getHWND();
HWND hwnd = (HWND)mWindow->getSystemWindow( PlatformWindow::WindowSystem_Windows );
AssertISV(hwnd, "GFXPCD3D9WindowTarget::initPresentationParams() - no HWND");
// At some point, this will become GFXPCD3D9WindowTarget like trunk has,
// so this cast isn't as bad as it looks. ;) BTR

View file

@ -20,6 +20,9 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _GFX_D3D_VIDEOCAPTURED3D9_H_
#define _GFX_D3D_VIDEOCAPTURED3D9_H_
#ifndef _VIDEOCAPTURE_H_
#include "gfx/video/videoCapture.h"
#endif
@ -79,4 +82,6 @@ protected:
public:
VideoFrameGrabberD3D9();
~VideoFrameGrabberD3D9();
};
};
#endif // _GFX_D3D_VIDEOCAPTURED3D9_H_

View file

@ -279,6 +279,7 @@ GFXDevice::~GFXDevice()
#endif
SAFE_DELETE( mTextureManager );
SAFE_DELETE( mFrameTime );
// Clear out our state block references
mCurrentStateBlocks.clear();

View file

@ -82,4 +82,71 @@ public:
virtual const String describeSelf() const = 0;
};
/// Handle for GFXOcclusionQuery than store last valid state
class GFXOcclusionQueryHandle
{
public:
GFXOcclusionQueryHandle()
: mLastStatus(GFXOcclusionQuery::Unset), mLastData(0), mQuery(NULL), mWaiting(false)
{}
~GFXOcclusionQueryHandle()
{
SAFE_DELETE(mQuery);
}
bool getLastStatus( bool block, GFXOcclusionQuery::OcclusionQueryStatus *statusPtr = NULL, U32 *data = NULL );
GFXOcclusionQuery* getQuery() const { return mQuery; }
void clearLastStatus()
{
mLastStatus = GFXOcclusionQuery::Unset;
mLastData = 0;
mWaiting = false;
if( !mQuery )
return;
mQuery->begin();
mQuery->end();
}
bool isWaiting() const { return mWaiting; }
protected:
GFXOcclusionQuery::OcclusionQueryStatus mLastStatus;
U32 mLastData;
bool mWaiting;
GFXOcclusionQuery *mQuery;
};
inline bool GFXOcclusionQueryHandle::getLastStatus( bool block, GFXOcclusionQuery::OcclusionQueryStatus *statusPtr, U32 *data )
{
if( !mQuery )
mQuery = GFX->createOcclusionQuery();
GFXOcclusionQuery::OcclusionQueryStatus status = mQuery->getStatus( block, data );
if( status == GFXOcclusionQuery::Waiting )
{
mWaiting = true;
if( statusPtr )
*statusPtr = mLastStatus;
if( data )
*data = mLastData;
return true;
}
if( statusPtr )
*statusPtr = status;
mWaiting = false;
mLastStatus = status;
mLastData = *data;
return true;
}
#endif // _GFXOCCLUSIONQUERY_H_

View file

@ -87,9 +87,9 @@ _STRING_VALUE_LOOKUP_FXN(GFXStringBlendOp);
#define VALIDATE_LOOKUPTABLE( tablearray, enumprefix ) \
for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \
if( (S32)tablearray[i] == GFX_UNINIT_VAL ) \
if( (intptr_t)tablearray[i] == GFX_UNINIT_VAL ) \
Con::warnf( "GFXStringEnumTranslate: Unassigned value in " #tablearray ": %i", i ); \
else if( (S32)tablearray[i] == GFX_UNSUPPORTED_VAL ) \
else if( (intptr_t)tablearray[i] == GFX_UNSUPPORTED_VAL ) \
Con::warnf( "GFXStringEnumTranslate: Unsupported value in " #tablearray ": %i", i );
//------------------------------------------------------------------------------

View file

@ -217,35 +217,41 @@ GFXGLPreserveTexture TORQUE_CONCAT(preserve_, __LINE__) (binding, _GET_TEXTURE_B
GFXGLPreserveInteger TORQUE_CONCAT(preserve_, __LINE__) (GL_READ_FRAMEBUFFER, GL_READ_FRAMEBUFFER_BINDING, (GFXGLPreserveInteger::BindFn)glBindFramebuffer);\
GFXGLPreserveInteger TORQUE_CONCAT(preserve2_, __LINE__) (GL_DRAW_FRAMEBUFFER, GL_DRAW_FRAMEBUFFER_BINDING, (GFXGLPreserveInteger::BindFn)glBindFramebuffer)
// Handy macro for checking the status of a framebuffer. Framebuffers can fail in
// all sorts of interesting ways, these are just the most common. Further, no existing GL profiling
// tool catches framebuffer errors when the framebuffer is created, so we actually need this.
#define CHECK_FRAMEBUFFER_STATUS()\
{\
GLenum status;\
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);\
switch(status) {\
case GL_FRAMEBUFFER_COMPLETE:\
break;\
case GL_FRAMEBUFFER_UNSUPPORTED:\
AssertFatal(false, "Unsupported FBO");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\
AssertFatal(false, "Incomplete FBO Attachment");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\
AssertFatal(false, "Incomplete FBO Missing Attachment");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:\
AssertFatal(false, "Incomplete FBO Draw buffer");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:\
AssertFatal(false, "Incomplete FBO Read buffer");\
break;\
default:\
/* programming error; will fail on all hardware */\
AssertFatal(false, "Something really bad happened with an FBO");\
}\
}
#if TORQUE_DEBUG
// Handy macro for checking the status of a framebuffer. Framebuffers can fail in
// all sorts of interesting ways, these are just the most common. Further, no existing GL profiling
// tool catches framebuffer errors when the framebuffer is created, so we actually need this.
#define CHECK_FRAMEBUFFER_STATUS()\
{\
GLenum status;\
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);\
switch(status) {\
case GL_FRAMEBUFFER_COMPLETE:\
break;\
case GL_FRAMEBUFFER_UNSUPPORTED:\
AssertFatal(false, "Unsupported FBO");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\
AssertFatal(false, "Incomplete FBO Attachment");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\
AssertFatal(false, "Incomplete FBO Missing Attachment");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:\
AssertFatal(false, "Incomplete FBO Draw buffer");\
break;\
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:\
AssertFatal(false, "Incomplete FBO Read buffer");\
break;\
default:\
/* programming error; will fail on all hardware */\
AssertFatal(false, "Something really bad happened with an FBO");\
}\
}
#else
#define CHECK_FRAMEBUFFER_STATUS()
#endif //TORQUE_DEBUG
#endif

View file

@ -21,7 +21,7 @@ void GFXGLVertexDecl::prepareVertexFormat() const
{
const glVertexAttribData &glElement = glVerticesFormat[i];
glVertexAttribFormat( glElement.attrIndex, glElement.elementCount, glElement.type, glElement.normalized, (U32)glElement.pointerFirst );
glVertexAttribFormat( glElement.attrIndex, glElement.elementCount, glElement.type, glElement.normalized, (uintptr_t)glElement.pointerFirst );
glVertexAttribBinding( glElement.attrIndex, glElement.stream );
}

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#if defined( TORQUE_SDL )
#if defined( TORQUE_SDL ) && !defined( TORQUE_DEDICATED )
#include "gfx/gfxCubemap.h"
#include "gfx/screenshot.h"

View file

@ -56,6 +56,10 @@ IMPLEMENT_CALLBACK( GuiRolloutCtrl, onCollapsed, void, (), (),
//-----------------------------------------------------------------------------
GuiRolloutCtrl::GuiRolloutCtrl()
: mHeader(0,0,0,0),
mExpanded(0,0,0,0),
mChildRect(0,0,0,0),
mMargin(0,0,0,0)
{
mExpanded.set(0,0,200,60);
mCaption = StringTable->EmptyString();
@ -70,6 +74,7 @@ GuiRolloutCtrl::GuiRolloutCtrl()
mIsContainer = true;
mCanCollapse = true;
mAutoCollapseSiblings = false;
mHasTexture = false;
// Make sure we receive our ticks.
setProcessTicks();
}

View file

@ -72,8 +72,9 @@ GuiScrollCtrl::GuiScrollCtrl()
mAnimating( false ),
mScrollAnimSpeed( -1 ),
mScrollTargetPos( -1, -1 ),
mChildExt(0, 0),
mChildPos(0, 0)
mChildExt(0, 0),
mChildPos(0, 0),
mBaseThumbSize(0)
{
mIsContainer = true;
setExtent(200,200);

View file

@ -98,10 +98,10 @@ GuiWindowCtrl::GuiWindowCtrl()
mMouseMovingWin = false;
mMouseResizeWidth = false;
mMouseResizeHeight = false;
setExtent(100, 200);
mMinimizeIndex = -1;
mTabIndex = -1;
mBitmapBounds = NULL;
setExtent(100, 200);
RectI closeRect(80, 2, 16, 16);
mCloseButton = closeRect;

View file

@ -924,7 +924,7 @@ SimObject* GuiListBoxCtrl::getItemObject( S32 index )
}
SimObject *outObj;
Sim::findObject( (SimObjectId)(mItems[ index ]->itemData), outObj );
Sim::findObject( (SimObjectId)(uintptr_t)(mItems[ index ]->itemData), outObj );
return outObj;
}
@ -1481,7 +1481,7 @@ void GuiListBoxCtrl::_mirror()
for ( U32 i = 0; i < mItems.size(); i++ )
{
curId = (SimObjectId)mItems[i]->itemData;
curId = (SimObjectId)(uintptr_t)mItems[i]->itemData;
Sim::findObject( curId, curObj );
@ -1515,7 +1515,7 @@ void GuiListBoxCtrl::_mirror()
for ( U32 j = 0; j < mItems.size(); j++ )
{
if ( (SimObjectId)(mItems[j]->itemData) == curId )
if ( (SimObjectId)(uintptr_t)(mItems[j]->itemData) == curId )
{
found = true;
break;
@ -1524,7 +1524,7 @@ void GuiListBoxCtrl::_mirror()
for ( U32 j = 0; j < mFilteredItems.size(); j++ )
{
if ( (SimObjectId)(mFilteredItems[j]->itemData) == curId )
if ( (SimObjectId)(uintptr_t)(mFilteredItems[j]->itemData) == curId )
{
found = true;
break;

View file

@ -1785,6 +1785,8 @@ bool GuiTreeViewCtrl::onWake()
// make sure it's big enough for both bitmap AND font...
mItemHeight = getMax((S32)mFont->getHeight(), (S32)mProfile->mBitmapArrayRects[0].extent.y);
}
mFlags.set(RebuildVisible);
return true;
}

View file

@ -30,6 +30,7 @@
#include "gfx/gfxDrawUtil.h"
#include "gui/core/guiTypes.h"
#include "gui/core/guiControl.h"
#include "gui/editor/guiMenuBar.h"
#include "console/consoleTypes.h"
#include "gfx/screenshot.h"
#include "gfx/video/videoCapture.h"
@ -94,9 +95,11 @@ extern InputModifiers convertModifierBits(const U32 in);
//-----------------------------------------------------------------------------
GuiCanvas::GuiCanvas(): GuiControl(),
mCurUpdateRect(0, 0, 0, 0),
mCursorEnabled(true),
mForceMouseToGUI(false),
mAlwaysHandleMouseButtons(false),
mCursorChanged(0),
mClampTorqueCursor(true),
mShowCursor(true),
mLastCursorEnabled(false),
@ -120,6 +123,7 @@ GuiCanvas::GuiCanvas(): GuiControl(),
mLeftMouseLast(false),
mMiddleMouseLast(false),
mRightMouseLast(false),
mMouseDownPoint(0.0f,0.0f),
mPlatformWindow(NULL),
mLastRenderMs(0),
mDisplayWindow(true)
@ -283,6 +287,8 @@ bool GuiCanvas::onAdd()
mLastPurchaseHideTime = 0;
#endif
Sim::findObject("PlatformGenericMenubar", mMenuBarCtrl);
return parentRet;
}
@ -302,6 +308,34 @@ void GuiCanvas::onRemove()
Parent::onRemove();
}
void GuiCanvas::setMenuBar(SimObject *obj)
{
GuiControl *oldMenuBar = mMenuBarCtrl;
mMenuBarCtrl = dynamic_cast<GuiControl*>(obj);
//remove old menubar
if( oldMenuBar )
Parent::removeObject( oldMenuBar );
// set new menubar
if( mMenuBarCtrl )
Parent::addObject(mMenuBarCtrl);
// update window accelerator keys
if( oldMenuBar != mMenuBarCtrl )
{
StringTableEntry ste = StringTable->insert("menubar");
GuiMenuBar* menu = NULL;
menu = !oldMenuBar ? NULL : dynamic_cast<GuiMenuBar*>(oldMenuBar->findObjectByInternalName( ste, true));
if( menu )
menu->removeWindowAcceleratorMap( *getPlatformWindow()->getInputGenerator() );
menu = !mMenuBarCtrl ? NULL : dynamic_cast<GuiMenuBar*>(mMenuBarCtrl->findObjectByInternalName( ste, true));
if( menu )
menu->buildWindowAcceleratorMap( *getPlatformWindow()->getInputGenerator() );
}
}
void GuiCanvas::setWindowTitle(const char *newTitle)
{
if (mPlatformWindow)
@ -1023,7 +1057,7 @@ void GuiCanvas::rootMouseDown(const GuiEvent &event)
{
i--;
GuiControl *ctrl = static_cast<GuiControl *>(*i);
GuiControl *controlHit = ctrl->findHitControl(event.mousePoint);
GuiControl *controlHit = ctrl->findHitControl( event.mousePoint - ctrl->getPosition() );
//see if the controlHit is a modeless dialog...
if( !controlHit->getControlProfile()->mModal )
@ -1293,6 +1327,9 @@ void GuiCanvas::setContentControl(GuiControl *gui)
Sim::getGuiGroup()->addObject( ctrl );
}
// set current menu bar
setMenuBar( mMenuBarCtrl );
// lose the first responder from the old GUI
GuiControl* responder = gui->findFirstTabable();
if(responder)
@ -1556,10 +1593,27 @@ void GuiCanvas::maintainSizing()
GuiControl *ctrl = static_cast<GuiControl*>(*i);
Point2I ext = ctrl->getExtent();
Point2I pos = ctrl->getPosition();
Point2I newExt = screenRect.extent;
Point2I newPos = screenRect.point;
if(pos != screenRect.point || ext != screenRect.extent)
// if menubar is active displace content gui control
if( mMenuBarCtrl && (ctrl == getContentControl()) )
{
const SimObject *menu = mMenuBarCtrl->findObjectByInternalName( StringTable->insert("menubar"), true);
if( !menu )
continue;
AssertFatal( dynamic_cast<const GuiControl*>(menu), "");
const U32 yOffset = static_cast<const GuiControl*>(menu)->getExtent().y;
newPos.y += yOffset;
newExt.y -= yOffset;
}
if(pos != newPos || ext != newExt)
{
ctrl->resize(screenRect.point, screenRect.extent);
ctrl->resize(newPos, newExt);
resetUpdateRegions();
}
}
@ -2273,7 +2327,7 @@ DefineEngineFunction(excludeOtherInstance, bool, (const char* appIdentifer),,
"@ingroup GuiCore")
{
// mac/360 can only run one instance in general.
#if !defined(TORQUE_OS_MAC) && !defined(TORQUE_OS_XENON) && !defined(TORQUE_DEBUG)
#if !defined(TORQUE_OS_MAC) && !defined(TORQUE_OS_XENON) && !defined(TORQUE_DEBUG) && !defined(TORQUE_OS_LINUX)
return Platform::excludeOtherInstances(appIdentifer);
#else
// We can just return true if we get here.
@ -2580,6 +2634,14 @@ DefineConsoleMethod( GuiCanvas, setFocus, void, (), , "() - Claim OS input focus
window->setFocus();
}
DefineEngineMethod( GuiCanvas, setMenuBar, void, ( GuiControl* menu ),,
"Translate a coordinate from canvas window-space to screen-space.\n"
"@param coordinate The coordinate in window-space.\n"
"@return The given coordinate translated to screen-space." )
{
return object->setMenuBar( menu );
}
DefineConsoleMethod( GuiCanvas, setVideoMode, void,
(U32 width, U32 height, bool fullscreen, U32 bitDepth, U32 refreshRate, U32 antialiasLevel),
( false, 0, 0, 0),

View file

@ -190,6 +190,8 @@ protected:
void checkLockMouseMove( const GuiEvent& event );
GuiControl *mMenuBarCtrl;
public:
DECLARE_CONOBJECT(GuiCanvas);
DECLARE_CATEGORY( "Gui Core" );
@ -200,6 +202,8 @@ public:
virtual bool onAdd();
virtual void onRemove();
void setMenuBar(SimObject *obj);
static void initPersistFields();
/// @name Rendering methods

View file

@ -2816,11 +2816,11 @@ DefineConsoleMethod( GuiControl, setExtent, void, ( const char* extOrX, const ch
{
Point2I extent;
if(!dStrIsEmpty(extOrX) && dStrIsEmpty(y))
dSscanf(extOrX, "%f %f", &extent.x, &extent.y);
dSscanf(extOrX, "%d %d", &extent.x, &extent.y);
else if(!dStrIsEmpty(extOrX) && !dStrIsEmpty(y))
{
extent.x = dAtof(extOrX);
extent.y = dAtof(y);
extent.x = dAtoi(extOrX);
extent.y = dAtoi(y);
}
object->setExtent( extent );
}

View file

@ -2575,9 +2575,9 @@ DefineConsoleMethod( GuiEditCtrl, deleteSelection, void, (), , "() - Delete the
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, moveSelection, void, (Point2I pos), , "Move all controls in the selection by (dx,dy) pixels.")
DefineConsoleMethod( GuiEditCtrl, moveSelection, void, (S32 dx, S32 dy), , "Move all controls in the selection by (dx,dy) pixels.")
{
object->moveAndSnapSelection(Point2I(pos));
object->moveAndSnapSelection(Point2I(dx, dy));
}
//-----------------------------------------------------------------------------

View file

@ -215,8 +215,8 @@ DefineEngineMethod(GuiMenuBar, addMenu, void, (const char* menuText, S32 menuId)
object->addMenu(menuText, menuId);
}
DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, S32 menuItemId, const char* accelerator, int checkGroup),
("","",0,"",-1),
DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, S32 menuItemId, const char* accelerator, int checkGroup, const char *cmd),
("","",0,NULL,-1,""),
"@brief Adds a menu item to the specified menu. The menu argument can be either the text of a menu or its id.\n\n"
"@param menu Menu name or menu Id to add the new item to.\n"
"@param menuItemText Text for the new menu item.\n"
@ -250,7 +250,7 @@ DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const
Con::errorf("Cannot find menu %s for addMenuItem.", targetMenu);
return;
}
object->addMenuItem(menu, menuItemText, menuItemId, accelerator != NULL ? accelerator : "", checkGroup == -1 ? -1 : checkGroup);
object->addMenuItem(menu, menuItemText, menuItemId, accelerator != NULL ? accelerator : "", checkGroup == -1 ? -1 : checkGroup, cmd);
}
DefineEngineMethod(GuiMenuBar, setMenuItemEnable, void, (const char* menuTarget, const char* menuItemTarget, bool enabled),,
@ -767,7 +767,7 @@ DefineEngineMethod(GuiMenuBar, setSubmenuItemChecked, void, (const char* menuTar
if(checked && submenuItem->checkGroup != -1)
{
// first, uncheck everything in the group:
for(GuiMenuBar::MenuItem *itemWalk = menuItem->firstSubmenuItem; itemWalk; itemWalk = itemWalk->nextMenuItem)
for(GuiMenuBar::MenuItem *itemWalk = menuItem->submenu->firstMenuItem; itemWalk; itemWalk = itemWalk->nextMenuItem)
if(itemWalk->checkGroup == submenuItem->checkGroup && itemWalk->bitmapIndex == object->mCheckmarkBitmapIndex)
itemWalk->bitmapIndex = -1;
}
@ -777,8 +777,7 @@ DefineEngineMethod(GuiMenuBar, setSubmenuItemChecked, void, (const char* menuTar
//------------------------------------------------------------------------------
// menu management methods
//------------------------------------------------------------------------------
void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
GuiMenuBar::Menu* GuiMenuBar::sCreateMenu(const char *menuText, U32 menuId)
{
// allocate the menu
Menu *newMenu = new Menu;
@ -792,7 +791,12 @@ void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
newMenu->bitmapIndex = -1;
newMenu->drawBitmapOnly = false;
newMenu->drawBorder = true;
return newMenu;
}
void GuiMenuBar::addMenu(GuiMenuBar::Menu *newMenu)
{
// add it to the menu list
menuBarDirty = true;
Menu **walk;
@ -801,6 +805,13 @@ void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
*walk = newMenu;
}
void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
{
Menu *newMenu = sCreateMenu(menuText, menuId);
addMenu(newMenu);
}
GuiMenuBar::Menu *GuiMenuBar::findMenu(const char *menu)
{
if(dIsdigit(menu[0]))
@ -877,7 +888,7 @@ void GuiMenuBar::removeMenuItem(Menu *menu, MenuItem *menuItem)
delete menuItem;
}
void GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup)
GuiMenuBar::MenuItem* GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup, const char *cmd )
{
// allocate the new menu item
MenuItem *newMenuItem = new MenuItem;
@ -886,6 +897,7 @@ void GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *a
newMenuItem->accelerator = dStrdup(accelerator);
else
newMenuItem->accelerator = NULL;
newMenuItem->cmd = cmd;
newMenuItem->id = id;
newMenuItem->checkGroup = checkGroup;
newMenuItem->nextMenuItem = NULL;
@ -896,15 +908,33 @@ void GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *a
// Default to not having a submenu
newMenuItem->isSubmenu = false;
newMenuItem->firstSubmenuItem = NULL;
newMenuItem->submenu = NULL;
newMenuItem->submenuParentMenu = NULL;
// link it into the menu's menu item list
MenuItem **walk = &menu->firstMenuItem;
while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
if(menu)
{
MenuItem **walk = &menu->firstMenuItem;
while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
}
return newMenuItem;
}
GuiMenuBar::MenuItem* GuiMenuBar::addMenuItem(Menu *menu, MenuItem* newMenuItem)
{
// link it into the menu's menu item list
if(menu)
{
MenuItem **walk = &menu->firstMenuItem;
while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
}
return newMenuItem;
}
void GuiMenuBar::clearMenuItems(Menu *menu)
@ -935,16 +965,9 @@ GuiMenuBar::MenuItem *GuiMenuBar::findSubmenuItem(Menu *menu, const char *menuIt
for(MenuItem *walk = menu->firstMenuItem; walk; walk = walk->nextMenuItem)
if(id == walk->id)
{
if(walk->isSubmenu)
if(walk->isSubmenu && walk->submenu)
{
U32 subid = dAtoi(submenuItem);
for(MenuItem *subwalk = walk->firstSubmenuItem; subwalk; subwalk = subwalk->nextMenuItem)
{
if(subid == walk->id)
{
return subwalk;
}
}
return GuiMenuBar::findMenuItem(walk->submenu, submenuItem);
}
return NULL;
}
@ -956,13 +979,9 @@ GuiMenuBar::MenuItem *GuiMenuBar::findSubmenuItem(Menu *menu, const char *menuIt
for(MenuItem *walk = menu->firstMenuItem; walk; walk = walk->nextMenuItem)
if(!dStricmp(menuItem, walk->text))
{
if(walk->isSubmenu)
if(walk->isSubmenu && walk->submenu)
{
for(MenuItem *subwalk = walk->firstSubmenuItem; subwalk; subwalk = subwalk->nextMenuItem)
{
if(!dStricmp(submenuItem, subwalk->text))
return subwalk;
}
return GuiMenuBar::findMenuItem(walk->submenu, submenuItem);
}
return NULL;
}
@ -970,6 +989,14 @@ GuiMenuBar::MenuItem *GuiMenuBar::findSubmenuItem(Menu *menu, const char *menuIt
}
}
GuiMenuBar::MenuItem* GuiMenuBar::findSubmenuItem(MenuItem *menuItem, const char *submenuItem)
{
if( !menuItem->isSubmenu )
return NULL;
return GuiMenuBar::findMenuItem( menuItem->submenu, submenuItem );
}
// Add a menuitem to the given submenu
void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup)
{
@ -997,17 +1024,30 @@ void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text,
// Default to not having a submenu
newMenuItem->isSubmenu = false;
newMenuItem->firstSubmenuItem = NULL;
newMenuItem->submenu = NULL;
// Point back to the submenu's menu
newMenuItem->submenuParentMenu = menu;
// link it into the menu's menu item list
MenuItem **walk = &submenu->firstSubmenuItem;
MenuItem **walk = &submenu->submenu->firstMenuItem;
while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
}
void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, MenuItem *newMenuItem )
{
AssertFatal( submenu && newMenuItem, "");
// Point back to the submenu's menu
newMenuItem->submenuParentMenu = menu;
// link it into the menu's menu item list
MenuItem **walk = &submenu->submenu->firstMenuItem;
while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
}
// Remove a submenu item
@ -1020,17 +1060,7 @@ void GuiMenuBar::removeSubmenuItem(MenuItem *menuItem, MenuItem *submenuItem)
return;
}
for(MenuItem **subwalk = &menuItem->firstSubmenuItem; *subwalk; subwalk = &(*subwalk)->nextMenuItem)
{
if(*subwalk == submenuItem)
{
*subwalk = submenuItem->nextMenuItem;
break;
}
}
dFree(submenuItem->text);
dFree(submenuItem->accelerator);
delete submenuItem;
GuiMenuBar::removeMenuItem(menuItem->submenu, submenuItem);
}
// Clear all menuitems from a submenu
@ -1043,8 +1073,8 @@ void GuiMenuBar::clearSubmenuItems(MenuItem *menuitem)
return;
}
while(menuitem->firstSubmenuItem)
removeSubmenuItem(menuitem, menuitem->firstSubmenuItem);
while(menuitem->submenu->firstMenuItem)
removeSubmenuItem(menuitem, menuitem->submenu->firstMenuItem);
}
//------------------------------------------------------------------------------
@ -1317,9 +1347,8 @@ void GuiMenuBar::onRender(Point2I offset, const RectI &updateRect)
renderChildControls( offset, updateRect );
}
void GuiMenuBar::buildAcceleratorMap()
void GuiMenuBar::buildWindowAcceleratorMap( WindowInputGenerator &inputGenerator )
{
Parent::buildAcceleratorMap();
// ok, accelerator map is cleared...
// add all our keys:
mCurAcceleratorIndex = 1;
@ -1334,18 +1363,22 @@ void GuiMenuBar::buildAcceleratorMap()
continue;
}
EventDescriptor accelEvent;
ActionMap::createEventDescriptor(item->accelerator, &accelEvent);
ActionMap::createEventDescriptor(item->accelerator, &accelEvent);
//now we have a modifier, and a key, add them to the canvas
GuiCanvas *root = getRoot();
if (root)
root->addAcceleratorKey(this, mCurAcceleratorIndex, accelEvent.eventCode, accelEvent.flags);
inputGenerator.addAcceleratorKey( this, item->cmd, accelEvent.eventCode, accelEvent.flags);
item->acceleratorIndex = mCurAcceleratorIndex;
mCurAcceleratorIndex++;
}
}
}
void GuiMenuBar::removeWindowAcceleratorMap( WindowInputGenerator &inputGenerator )
{
inputGenerator.removeAcceleratorKeys( this );
}
void GuiMenuBar::acceleratorKeyPress(U32 index)
{
// loop through all the menus
@ -1617,7 +1650,7 @@ void GuiMenuBar::highlightedMenuItem(S32 selectionIndex, RectI bounds, Point2I c
if(list->isSubmenu)
{
// If there are submenu items, then open the submenu
if(list->firstSubmenuItem)
if(list->submenu->firstMenuItem)
{
mouseOverSubmenu = list;
onSubmenuAction(selstore, bounds, cellSize);
@ -1752,7 +1785,7 @@ void GuiMenuBar::onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellS
// first, call the script callback for menu selection:
onSubmenuSelect_callback(Con::getIntArg(mouseOverSubmenu->id), mouseOverSubmenu->text);
MenuItem *visWalk = mouseOverSubmenu->firstSubmenuItem;
MenuItem *visWalk = mouseOverSubmenu->submenu->firstMenuItem;
while(visWalk)
{
if(visWalk->visible)
@ -1780,7 +1813,7 @@ void GuiMenuBar::onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellS
GFont *font = mProfile->mFont;
for(MenuItem *walk = mouseOverSubmenu->firstSubmenuItem; walk; walk = walk->nextMenuItem)
for(MenuItem *walk = mouseOverSubmenu->submenu->firstMenuItem; walk; walk = walk->nextMenuItem)
{
if(!walk->visible)
continue;
@ -1803,7 +1836,7 @@ void GuiMenuBar::onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellS
U32 entryCount = 0;
for(MenuItem *walk = mouseOverSubmenu->firstSubmenuItem; walk; walk = walk->nextMenuItem)
for(MenuItem *walk = mouseOverSubmenu->submenu->firstMenuItem; walk; walk = walk->nextMenuItem)
{
if(!walk->visible)
continue;
@ -1885,7 +1918,7 @@ void GuiMenuBar::closeSubmenu()
MenuItem *list = NULL;
if(mouseOverSubmenu)
{
list = mouseOverSubmenu->firstSubmenuItem;
list = mouseOverSubmenu->submenu->firstMenuItem;
while(selectionIndex && list)
{

View file

@ -32,6 +32,7 @@
class GuiMenuBar;
class GuiMenuTextListCtrl;
class WindowInputGenerator;
class GuiMenuBackgroundCtrl : public GuiControl
{
@ -105,9 +106,10 @@ public:
MenuItem *nextMenuItem; // next menu item in the linked list
bool isSubmenu; // This menu item has a submenu that will be displayed
MenuItem *firstSubmenuItem; // The first menu item in the submenu
Menu* submenuParentMenu; // For a submenu, this is the parent menu
Menu* submenu;
String cmd;
};
struct Menu
@ -161,21 +163,25 @@ public:
// internal menu handling functions
// these are used by the script manipulation functions to add/remove/change menu items
static Menu* sCreateMenu(const char *menuText, U32 menuId);
void addMenu(Menu *menu);
void addMenu(const char *menuText, U32 menuId);
Menu *findMenu(const char *menu); // takes either a menu text or a string id
MenuItem *findMenuItem(Menu *menu, const char *menuItem); // takes either a menu text or a string id
static MenuItem *findMenuItem(Menu *menu, const char *menuItem); // takes either a menu text or a string id
void removeMenu(Menu *menu);
void removeMenuItem(Menu *menu, MenuItem *menuItem);
void addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup);
void clearMenuItems(Menu *menu);
static void removeMenuItem(Menu *menu, MenuItem *menuItem);
static MenuItem* addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup, const char *cmd);
static MenuItem* addMenuItem(Menu *menu, MenuItem *menuItem);
static void clearMenuItems(Menu *menu);
void clearMenus();
// Methods to deal with submenus
MenuItem* findSubmenuItem(Menu *menu, const char *menuItem, const char *submenuItem);
void addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup);
void removeSubmenuItem(MenuItem *menuItem, MenuItem *submenuItem);
void clearSubmenuItems(MenuItem *menuitem);
static MenuItem* findSubmenuItem(Menu *menu, const char *menuItem, const char *submenuItem);
static MenuItem* findSubmenuItem(MenuItem *menuItem, const char *submenuItem);
static void addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup);
static void addSubmenuItem(Menu *menu, MenuItem *submenu, MenuItem *newMenuItem );
static void removeSubmenuItem(MenuItem *menuItem, MenuItem *submenuItem);
static void clearSubmenuItems(MenuItem *menuitem);
void onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellSize);
void closeSubmenu();
void checkSubmenuMouseMove(const GuiEvent &event);
@ -202,10 +208,11 @@ public:
void onAction();
void closeMenu();
void buildAcceleratorMap();
void buildWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
void removeWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
void acceleratorKeyPress(U32 index);
void menuItemSelected(Menu *menu, MenuItem *item);
virtual void menuItemSelected(Menu *menu, MenuItem *item);
// Added to support 'ticks'
void processTick();

View file

@ -230,6 +230,9 @@ bool ProjectedShadow::_updateDecal( const SceneRenderState *state )
lightCount++;
}
if (mShapeBase)
fade *= mShapeBase->getFadeVal();
lightDir.normalize();
// No light... no shadow.

View file

@ -49,7 +49,7 @@ bool getDllName(std::wstring& dllName, const std::wstring suffix)
return true;
}
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow)
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow)
{
// Try to find the game DLL, which may have one of several file names.
HMODULE hGame = NULL;
@ -75,10 +75,11 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL
return -1;
}
enum { errorSize = 4096 };
if (!hGame)
{
wchar_t error[4096];
_swprintf_l(error, sizeof(error), L"Unable to load game library: %s. Please make sure it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str());
wchar_t error[errorSize];
_swprintf_l(error, errorSize, L"Unable to load game library: %s. Please make sure it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str());
MessageBoxW(NULL, error, L"Error", MB_OK|MB_ICONWARNING);
return -1;
}
@ -86,8 +87,8 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL
torque_winmain = (int (*)(HINSTANCE hInstance, HINSTANCE h, LPSTR lpszCmdLine, int nShow))GetProcAddress(hGame, "torque_winmain");
if (!torque_winmain)
{
wchar_t error[4096];
_swprintf_l(error, sizeof(error), L"Missing torque_winmain export in game library: %s. Please make sure that it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str());
wchar_t error[errorSize];
_swprintf_l(error, errorSize, L"Missing torque_winmain export in game library: %s. Please make sure that it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str());
MessageBoxW(NULL, error, L"Error", MB_OK|MB_ICONWARNING);
return -1;
}

View file

@ -290,6 +290,12 @@ bool MatInstance::init( const FeatureSet &features,
//----------------------------------------------------------------------------
bool MatInstance::reInit()
{
if (!mVertexFormat)
{
mIsValid = false;
return mIsValid;
}
SAFE_DELETE(mProcessedMaterial);
deleteAllHooks();
mIsValid = processMaterial();

View file

@ -263,8 +263,6 @@ void MaterialList::clearMatInstList()
if (mMatInstList[i])
{
BaseMatInstance* current = mMatInstList[i];
delete current;
mMatInstList[i] = NULL;
// ok, since ts material lists can remap difference indexes to the same object
// we need to make sure that we don't delete the same memory twice. walk the
@ -272,6 +270,9 @@ void MaterialList::clearMatInstList()
for (U32 j=0; j<mMatInstList.size(); j++)
if (mMatInstList[j] == current)
mMatInstList[j] = NULL;
mMatInstList[i] = NULL;
delete current;
}
}
}

View file

@ -73,7 +73,7 @@ public:
/// The cubemap to use when the texture type is
/// set to Material::Cube.
/// @see mTexType
GFXCubemap *mCubeMap;
GFXCubemapHandle mCubeMap;
U32 mNumTex;

View file

@ -383,9 +383,10 @@ inline PlaneF::Side PlaneF::whichSide( const OrientedBox3F& obb ) const
// Project the box onto the line defined by the plane center and normal.
// See "3D Game Engine Design" chapter 4.3.2.
const F32 r = obb.getHalfExtents().x * mFabs( mDot( obb.getAxis( 0 ), *this ) ) +
obb.getHalfExtents().y * mFabs( mDot( obb.getAxis( 1 ), *this ) ) +
obb.getHalfExtents().z * mFabs( mDot( obb.getAxis( 2 ), *this ) );
Point3F mObbHalf = obb.getHalfExtents();
const F32 r = mObbHalf.x * mFabs( mDot( obb.getAxis( 0 ), *this ) ) +
mObbHalf.y * mFabs( mDot( obb.getAxis( 1 ), *this ) ) +
mObbHalf.z * mFabs( mDot( obb.getAxis( 2 ), *this ) );
const F32 dist = distToPlane( obb.getCenter() );
if( dist > r )

View file

@ -458,7 +458,7 @@ U32 PlaneSet< T >::clipPolygon( const Point3F* inVertices, U32 inNumVertices, Po
// to indicate we haven't clipped anything.
if( !numClippedPolygonVertices )
return false;
return 0;
// On first iteration, replace the inVertices with the
// outVertices buffer.

View file

@ -20,6 +20,9 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _MPOLYHEDRON_IMPL_H_
#define _MPOLYHEDRON_IMPL_H_
#include "math/mPlaneTransformer.h"
@ -503,3 +506,5 @@ void PolyhedronData::buildBoxData( Polyhedron& poly, const MatrixF& mat, const B
edge ++;
}
}
#endif // _MPOLYHEDRON_IMPL_H_

View file

@ -30,7 +30,7 @@ MatrixSet::MatrixSet()
// this class will provide a place where aligned/specalized matrix math can take place.
// We should be able to plug in any kind of platform-specific optimization
// behind the delgates.
AssertFatal( ((int)this & 0xF) == 0, "MatrixSet has been allocated off a 16-byte boundary!" );
AssertFatal( ((intptr_t)this & 0xF) == 0, "MatrixSet has been allocated off a 16-byte boundary!" );
// Must be initialized by name, not a for(), it's macro magic
MATRIX_SET_BIND_VALUE(ObjectToWorld);
@ -47,4 +47,4 @@ MatrixSet::MatrixSet()
mViewSource = NULL;
mProjectionSource = NULL;
}
}

View file

@ -195,9 +195,9 @@ bool PopupMenu::onMessageObjectReceived(StringTableEntry queue, Message *msg )
// Console Methods
//-----------------------------------------------------------------------------
DefineConsoleMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator), ("", ""), "(pos[, title][, accelerator])")
DefineConsoleMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator, const char* cmd), ("", "", ""), "(pos[, title][, accelerator][, cmd])")
{
return object->insertItem(pos, title, accelerator);
return object->insertItem(pos, title, accelerator, cmd);
}
DefineConsoleMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)")
@ -216,9 +216,9 @@ DefineConsoleMethod(PopupMenu, insertSubMenu, S32, (S32 pos, String title, Strin
return object->insertSubMenu(pos, title, mnu);
}
DefineConsoleMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator), (""), "(pos, title[, accelerator])")
DefineConsoleMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator, const char *cmd), (""), "(pos, title[, accelerator][, cmd])")
{
return object->setItem(pos, title, accelerator);
return object->setItem(pos, title, accelerator, cmd);
}
//-----------------------------------------------------------------------------

View file

@ -85,11 +85,11 @@ public:
/// returns the menu item's ID, or -1 on failure.
/// implementd on a per-platform basis.
/// TODO: factor out common code
S32 insertItem(S32 pos, const char *title, const char* accelerator);
S32 insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// Sets the name title and accelerator for
/// an existing item.
bool setItem(S32 pos, const char *title, const char* accelerator);
bool setItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// pass NULL for @p title to insert a separator
/// returns the menu item's ID, or -1 on failure.

View file

@ -32,16 +32,17 @@
enum MBButtons
{
MBOk,
MBOk = 0,
MBOkCancel,
MBRetryCancel,
MBSaveDontSave,
MBSaveDontSaveCancel,
MBAlertAssert
};
enum MBIcons
{
MIWarning,
MIWarning = 0,
MIInformation,
MIQuestion,
MIStop,

View file

@ -174,6 +174,15 @@ namespace Platform
bool isdst; ///< True if daylight savings time is active
};
enum ALERT_ASSERT_RESULT
{
ALERT_ASSERT_DEBUG,
ALERT_ASSERT_IGNORE,
ALERT_ASSERT_IGNORE_ALL,
ALERT_ASSERT_EXIT
};
void getLocalTime(LocalTime &);
/// Converts the local time to a formatted string appropriate
@ -300,6 +309,7 @@ namespace Platform
void AlertOK(const char *windowTitle, const char *message);
bool AlertOKCancel(const char *windowTitle, const char *message);
bool AlertRetry(const char *windowTitle, const char *message);
ALERT_ASSERT_RESULT AlertAssert(const char *windowTitle, const char *message);
// Volumes
struct VolumeInformation

View file

@ -33,6 +33,7 @@ PlatformAssert *PlatformAssert::platformAssert = NULL;
PlatformAssert::PlatformAssert()
{
processing = false;
ignoreAll = false;
}
//--------------------------------------
@ -94,47 +95,57 @@ bool PlatformAssert::process(Type assertType,
U32 lineNumber,
const char *message)
{
// If we're somehow recursing, just die.
if(processing)
Platform::debugBreak();
processing = true;
bool ret = true;
// always dump to the Assert to the Console
if (Con::isActive())
{
if (assertType == Warning)
Con::warnf(ConsoleLogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message);
else
Con::errorf(ConsoleLogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message);
}
// if not a WARNING pop-up a dialog box
if (assertType != Warning)
{
// used for processing navGraphs (an assert won't botch the whole build)
if(Con::getBoolVariable("$FP::DisableAsserts", false) == true)
Platform::forceShutdown(1);
char buffer[2048];
dSprintf(buffer, 2048, "%s(%ld) : %s", filename, lineNumber, typeName[assertType] );
#ifdef TORQUE_DEBUG
// In debug versions, allow a retry even for ISVs...
bool retry = displayMessageBox(buffer, message, true);
#else
bool retry = displayMessageBox(buffer, message, ((assertType == Fatal) ? true : false) );
#endif
if(!retry)
Platform::forceShutdown(1);
ret = askToEnterDebugger(message);
}
processing = false;
return ret;
// If we're somehow recursing, just die.
if(processing)
Platform::debugBreak();
processing = true;
bool ret = false;
// always dump to the Assert to the Console
if (Con::isActive())
{
if (assertType == Warning)
Con::warnf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
else
Con::errorf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
}
// if not a WARNING pop-up a dialog box
if (assertType != Warning)
{
// used for processing navGraphs (an assert won't botch the whole build)
if(Con::getBoolVariable("$FP::DisableAsserts", false) == true)
Platform::forceShutdown(1);
char buffer[2048];
dSprintf(buffer, 2048, "%s: (%s @ %ld)", typeName[assertType], filename, lineNumber);
if( !ignoreAll )
{
// Display message box with Debug, Ignore, Ignore All, and Exit options
switch( Platform::AlertAssert(buffer, message) )
{
case Platform::ALERT_ASSERT_DEBUG:
ret = true;
break;
case Platform::ALERT_ASSERT_IGNORE:
ret = false;
break;
case Platform::ALERT_ASSERT_IGNORE_ALL:
ignoreAll = true;
ret = false;
break;
default:
case Platform::ALERT_ASSERT_EXIT:
Platform::forceShutdown(1);
break;
}
}
}
processing = false;
return ret;
}
bool PlatformAssert::processingAssert()
@ -170,3 +181,11 @@ const char* avar(const char *message, ...)
dVsprintf(buffer, sizeof(buffer), message, args);
return( buffer );
}
//-----------------------------------------------------------------------------
ConsoleFunction( Assert, void, 3, 3, "(condition, message) - Fatal Script Assertion" )
{
// Process Assertion.
AssertISV( dAtob(argv[1]), argv[2] );
}

View file

@ -40,6 +40,7 @@ public:
private:
static PlatformAssert *platformAssert;
bool processing;
bool ignoreAll;
virtual bool displayMessageBox(const char *title, const char *message, bool retry);
virtual bool process(Type assertType,
@ -77,6 +78,14 @@ public:
{ if ((x)==0) \
::PlatformAssert::processAssert(::PlatformAssert::Warning, __FILE__, __LINE__, y); }
/*!
Helper macro called when AssertFatal failed.
Used for help static code analyzers.
*/
#ifndef ON_FAIL_ASSERTFATAL
#define ON_FAIL_ASSERTFATAL
#endif
/*!
Assert that the statement x is true, otherwise halt.

View file

@ -21,6 +21,12 @@
// must ensure BIOS settings is not configured to restrict CPUID functionalities.
//-------------------------------------------------------------------------------------------------
#if defined(TORQUE_OS_LINUX) || defined(LINUX)
// TODO GCC code don't compile on Release with optimizations, mover code to platform layer
#else
#include "platform/platform.h"
#include "platform/platformCPUCount.h"
@ -666,3 +672,5 @@ next:
#endif
#endif
#endif

View file

@ -68,7 +68,7 @@ inline bool dCompareAndSwap( volatile U32& ref, U32 oldVal, U32 newVal )
#if defined(TORQUE_OS_PS3)
return ( cellAtomicCompareAndSwap32( (std::uint32_t *)&ref, newVal, oldVal ) == oldVal );
#elif !defined(TORQUE_OS_MAC)
return ( __sync_val_compare_and_swap( ( volatile long* ) &ref, oldVal, newVal ) == oldVal );
return ( __sync_val_compare_and_swap( &ref, oldVal, newVal ) == oldVal );
#else
return OSAtomicCompareAndSwap32(oldVal, newVal, (int32_t *) &ref);
#endif
@ -79,7 +79,7 @@ inline bool dCompareAndSwap( volatile U64& ref, U64 oldVal, U64 newVal )
#if defined(TORQUE_OS_PS3)
return ( cellAtomicCompareAndSwap32( (std::uint32_t *)&ref, newVal, oldVal ) == oldVal );
#elif !defined(TORQUE_OS_MAC)
return ( __sync_val_compare_and_swap( ( volatile long long* ) &ref, oldVal, newVal ) == oldVal );
return ( __sync_val_compare_and_swap( &ref, oldVal, newVal ) == oldVal );
#else
return OSAtomicCompareAndSwap64(oldVal, newVal, (int64_t *) &ref);
#endif

View file

@ -30,8 +30,13 @@
//--------------------------------------
// Types
#if TORQUE_X86
typedef signed long long S64;
typedef unsigned long long U64;
#else
typedef signed long S64;
typedef unsigned long U64;
#endif
//--------------------------------------
@ -73,11 +78,11 @@ typedef unsigned long long U64;
# define TORQUE_OS_PS3
# include "platform/types.posix.h"
#elif defined(linux)
#elif defined(linux) || defined(LINUX)
# define TORQUE_OS_STRING "Linux"
# define TORQUE_OS_LINUX
# define TORQUE_SUPPORTS_NASM
# define TORQUE_SUPPORTS_GCC_INLINE_X86_ASM
//# define TORQUE_SUPPORTS_NASM
//# define TORQUE_SUPPORTS_GCC_INLINE_X86_ASM
# include "platform/types.posix.h"
#elif defined(__OpenBSD__)
@ -115,6 +120,11 @@ typedef unsigned long long U64;
# define TORQUE_CPU_X86
# define TORQUE_LITTLE_ENDIAN
#elif defined(__x86_64__)
# define TORQUE_CPU_STRING "Intel x64"
# define TORQUE_CPU_X64
# define TORQUE_LITTLE_ENDIAN
#elif defined(__ppc__)
# define TORQUE_CPU_STRING "PowerPC"
# define TORQUE_CPU_PPC

View file

@ -23,6 +23,8 @@
#ifndef _TORQUE_TYPES_H_
#define _TORQUE_TYPES_H_
#include <stdint.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------Basic Types--------------------------------------------------//
//////////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -29,7 +29,8 @@
// size_t is needed to overload new
// size_t tends to be OS and compiler specific and may need to
// be if/def'ed in the future
typedef unsigned int dsize_t;
#include <stddef.h>
typedef size_t dsize_t;
/** Platform dependent file date-time structure. The defination of this structure

View file

@ -29,7 +29,7 @@
#include "platform/platform.h"
#include "math/mMath.h"
#include "gfx/gl/ggl/ggl.h"
#include "gfx/gl/tGL/tGL.h"
#define __gl_h_
#include <AGL/agl.h>

Some files were not shown because too many files have changed in this diff Show more