mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Merge branch 'development' into walkabout
Conflicts: Engine/source/T3D/aiPlayer.cpp
This commit is contained in:
commit
bd437cda1c
981 changed files with 304060 additions and 7888 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef _TURRETSHAPE_H_
|
||||
#define _TURRETSHAPE_H_
|
||||
|
||||
#ifndef _SHAPEBASE_H_
|
||||
#ifndef _ITEM_H_
|
||||
#include "T3D/item.h"
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue