merged numerous changes from upstream

This commit is contained in:
Thomas "elfprince13" Dickerson 2017-03-03 21:17:07 -05:00
commit d3956cb532
50 changed files with 914 additions and 363 deletions

View file

@ -200,7 +200,7 @@ void LightningStrikeEvent::unpack(NetConnection* con, BitStream* stream)
{
if(!stream->readFlag())
return;
S32 mClientId = stream->readRangedU32(0, NetConnection::MaxGhostCount);
mClientId = stream->readRangedU32(0, NetConnection::MaxGhostCount);
mLightning = NULL;
NetObject* pObject = con->resolveGhost(mClientId);
if (pObject)
@ -214,10 +214,10 @@ void LightningStrikeEvent::unpack(NetConnection* con, BitStream* stream)
// target id
S32 mTargetID = stream->readRangedU32(0, NetConnection::MaxGhostCount);
NetObject* pObject = con->resolveGhost(mTargetID);
if( pObject != NULL )
NetObject* tObject = con->resolveGhost(mTargetID);
if(tObject != NULL )
{
mTarget = dynamic_cast<SceneObject*>(pObject);
mTarget = dynamic_cast<SceneObject*>(tObject);
}
if( bool(mTarget) == false )
{
@ -243,6 +243,7 @@ LightningData::LightningData()
dMemset( strikeTextureNames, 0, sizeof( strikeTextureNames ) );
dMemset( strikeTextures, 0, sizeof( strikeTextures ) );
dMemset( thunderSounds, 0, sizeof( thunderSounds ) );
mNumStrikeTextures = 0;
}
LightningData::~LightningData()
@ -297,10 +298,14 @@ bool LightningData::preload(bool server, String &errorStr)
if( !sfxResolve( &strikeSound, sfxErrorStr ) )
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str());
mNumStrikeTextures = 0;
for (U32 i = 0; i < MaxTextures; i++)
{
if (strikeTextureNames[i][0])
{
strikeTextures[i] = GFXTexHandle(strikeTextureNames[i], &GFXDefaultStaticDiffuseProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, i, __LINE__));
mNumStrikeTextures++;
}
}
}
@ -317,7 +322,11 @@ void LightningData::packData(BitStream* stream)
U32 i;
for (i = 0; i < MaxThunders; i++)
sfxWrite( stream, thunderSounds[ i ] );
for (i = 0; i < MaxTextures; i++) {
stream->writeInt(mNumStrikeTextures, 4);
for (i = 0; i < MaxTextures; i++)
{
stream->writeString(strikeTextureNames[i]);
}
@ -331,7 +340,11 @@ void LightningData::unpackData(BitStream* stream)
U32 i;
for (i = 0; i < MaxThunders; i++)
sfxRead( stream, &thunderSounds[ i ] );
for (i = 0; i < MaxTextures; i++) {
mNumStrikeTextures = stream->readInt(4);
for (i = 0; i < MaxTextures; i++)
{
strikeTextureNames[i] = stream->readSTString();
}
@ -368,16 +381,16 @@ Lightning::~Lightning()
{
while( mThunderListHead )
{
Thunder* next = mThunderListHead->next;
Thunder* nextThunder = mThunderListHead->next;
delete mThunderListHead;
mThunderListHead = next;
mThunderListHead = nextThunder;
}
while( mStrikeListHead )
{
Strike* next = mStrikeListHead->next;
Strike* nextStrike = mStrikeListHead->next;
delete mStrikeListHead;
mStrikeListHead = next;
mStrikeListHead = nextStrike;
}
}
@ -478,11 +491,16 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base
desc.setBlend( true, GFXBlendSrcAlpha, GFXBlendOne);
desc.setCullMode(GFXCullNone);
desc.zWriteEnable = false;
desc.samplersDefined = true;
desc.samplers[0].magFilter = GFXTextureFilterLinear;
desc.samplers[0].minFilter = GFXTextureFilterLinear;
desc.samplers[0].addressModeU = GFXAddressWrap;
desc.samplers[0].addressModeV = GFXAddressWrap;
desc.vertexColorEnable = true;
if (mDataBlock->mNumStrikeTextures != 0)
{
desc.samplersDefined = true;
desc.samplers[0].magFilter = GFXTextureFilterLinear;
desc.samplers[0].minFilter = GFXTextureFilterLinear;
desc.samplers[0].addressModeU = GFXAddressWrap;
desc.samplers[0].addressModeV = GFXAddressWrap;
}
mLightningSB = GFX->createStateBlock(desc);
@ -494,9 +512,16 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base
Strike* walk = mStrikeListHead;
while (walk != NULL)
{
GFX->setTexture(0, mDataBlock->strikeTextures[0]);
if (mDataBlock->mNumStrikeTextures > 1)
{
GFX->setTexture(0, mDataBlock->strikeTextures[sgLightningRand.randI(0, mDataBlock->mNumStrikeTextures - 1)]);
}
else if (mDataBlock->mNumStrikeTextures > 0)
{
GFX->setTexture(0, mDataBlock->strikeTextures[0]);
}
for( U32 i=0; i<3; i++ )
for( U32 i=0; i<MAX_LIGHTNING; i++ )
{
if( walk->bolt[i].isFading )
{
@ -515,8 +540,8 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base
}
//GFX->setZWriteEnable(true);
//GFX->setAlphaTestEnable(false);
//GFX->setAlphaBlendEnable(false);
//GFX->setAlphaTestEnable(false);
//GFX->setAlphaBlendEnable(false);
}
void Lightning::scheduleThunder(Strike* newStrike)
@ -589,7 +614,7 @@ void Lightning::advanceTime(F32 dt)
while (*pWalker != NULL) {
Strike* pStrike = *pWalker;
for( U32 i=0; i<3; i++ )
for( U32 i=0; i<MAX_LIGHTNING; i++ )
{
pStrike->bolt[i].update( dt );
}
@ -673,7 +698,7 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent)
pStrike->currentAge = 0.0f;
pStrike->next = mStrikeListHead;
for( U32 i=0; i<3; i++ )
for( U32 i=0; i<MAX_LIGHTNING; i++ )
{
F32 randStart = boltStartRadius;
F32 height = mObjScale.z * 0.5f + getPosition().z;
@ -709,6 +734,7 @@ void Lightning::warningFlashes()
{
AssertFatal(isServerObject(), "Error, client objects may not initiate lightning!");
Point3F strikePoint( gRandGen.randF( 0.0f, 1.0f ), gRandGen.randF( 0.0f, 1.0f ), 0.0f );
SimGroup* pClientGroup = Sim::getClientGroup();
for (SimGroup::iterator itr = pClientGroup->begin(); itr != pClientGroup->end(); itr++) {
@ -717,6 +743,9 @@ void Lightning::warningFlashes()
{
LightningStrikeEvent* pEvent = new LightningStrikeEvent;
pEvent->mLightning = this;
pEvent->mStart.x = strikePoint.x;
pEvent->mStart.y = strikePoint.y;
nc->postNetEvent(pEvent);
}
@ -731,18 +760,19 @@ void Lightning::strikeRandomPoint()
Point3F strikePoint( gRandGen.randF( 0.0f, 1.0f ), gRandGen.randF( 0.0f, 1.0f ), 0.0f );
// check if an object is within target range
Point3F worldPosStrikePoint = strikePoint;
strikePoint *= mObjScale;
strikePoint += getPosition();
strikePoint += Point3F( -mObjScale.x * 0.5f, -mObjScale.y * 0.5f, 0.0f );
worldPosStrikePoint *= mObjScale;
worldPosStrikePoint += getPosition();
worldPosStrikePoint += Point3F( -mObjScale.x * 0.5f, -mObjScale.y * 0.5f, 0.0f );
Box3F queryBox;
F32 boxWidth = strikeRadius * 2.0f;
queryBox.minExtents.set( -boxWidth * 0.5f, -boxWidth * 0.5f, -mObjScale.z * 0.5f );
queryBox.maxExtents.set( boxWidth * 0.5f, boxWidth * 0.5f, mObjScale.z * 0.5f );
queryBox.minExtents += strikePoint;
queryBox.maxExtents += strikePoint;
queryBox.minExtents += worldPosStrikePoint;
queryBox.maxExtents += worldPosStrikePoint;
SimpleQueryList sql;
getContainer()->findObjects(queryBox, DAMAGEABLE_TYPEMASK,
@ -837,13 +867,53 @@ void Lightning::strikeRandomPoint()
}
//--------------------------------------------------------------------------
void Lightning::strikeObject(ShapeBase*)
void Lightning::strikeObject(ShapeBase* targetObj)
{
AssertFatal(isServerObject(), "Error, client objects may not initiate lightning!");
AssertFatal(false, "Lightning::strikeObject is not implemented.");
}
Point3F strikePoint = targetObj->getPosition();
Point3F objectCenter;
Box3F wb = getWorldBox();
if (!wb.isContained(strikePoint))
return;
Point3F targetRel = strikePoint - getPosition();
Point3F length(wb.len_x() / 2.0f, wb.len_y() / 2.0f, wb.len_z() / 2.0f);
Point3F strikePos = targetRel / length;
bool playerInWarmup = false;
Player *playerObj = dynamic_cast< Player * >(targetObj);
if (playerObj)
{
if (!playerObj->getControllingClient())
{
playerInWarmup = true;
}
}
if (!playerInWarmup)
{
applyDamage_callback(targetObj->getWorldSphere().center, VectorF(0.0, 0.0, 1.0), targetObj);
}
SimGroup* pClientGroup = Sim::getClientGroup();
for (SimGroup::iterator itr = pClientGroup->begin(); itr != pClientGroup->end(); itr++) {
NetConnection* nc = static_cast<NetConnection*>(*itr);
if (nc != NULL)
{
LightningStrikeEvent* pEvent = new LightningStrikeEvent;
pEvent->mLightning = this;
pEvent->mStart.x = strikePoint.x;
pEvent->mStart.y = strikePoint.y;
pEvent->mTarget = targetObj;
nc->postNetEvent(pEvent);
}
}
}
//--------------------------------------------------------------------------
U32 Lightning::packUpdate(NetConnection* con, U32 mask, BitStream* stream)
@ -864,6 +934,7 @@ U32 Lightning::packUpdate(NetConnection* con, U32 mask, BitStream* stream)
stream->write(color.red);
stream->write(color.green);
stream->write(color.blue);
stream->write(color.alpha);
stream->write(fadeColor.red);
stream->write(fadeColor.green);
stream->write(fadeColor.blue);
@ -895,6 +966,7 @@ void Lightning::unpackUpdate(NetConnection* con, BitStream* stream)
stream->read(&color.red);
stream->read(&color.green);
stream->read(&color.blue);
stream->read(&color.alpha);
stream->read(&fadeColor.red);
stream->read(&fadeColor.green);
stream->read(&fadeColor.blue);
@ -930,7 +1002,7 @@ DefineEngineMethod(Lightning, strikeRandomPoint, void, (),,
object->strikeRandomPoint();
}
DefineEngineMethod(Lightning, strikeObject, void, (ShapeBase* pSB),,
DefineEngineMethod(Lightning, strikeObject, void, (ShapeBase* pSB), (nullAsType<ShapeBase*>()),
"Creates a LightningStrikeEvent which strikes a specific object.\n"
"@note This method is currently unimplemented.\n" )
{
@ -1028,7 +1100,7 @@ void LightningBolt::render( const Point3F &camPos )
renderSegment(mMinorNodes[i], camPos, false);
}
PrimBuild::end();
PrimBuild::end();
for(LightingBoltList::Iterator i = splitList.begin(); i != splitList.end(); ++i)
{
@ -1154,26 +1226,26 @@ void LightningBolt::generateMinorNodes()
//----------------------------------------------------------------------------
// Recursive algo to create bolts that split off from main bolt
//----------------------------------------------------------------------------
void LightningBolt::createSplit( const Point3F &startPoint, const Point3F &endPoint, U32 depth, F32 width )
void LightningBolt::createSplit( const Point3F &startingPoint, const Point3F &endingPoint, U32 depth, F32 splitWidth )
{
if( depth == 0 )
return;
F32 chanceToEnd = gRandGen.randF();
if( chanceToEnd > 0.70f )
return;
if( width < 0.75f )
width = 0.75f;
if(splitWidth < 0.75f )
splitWidth = 0.75f;
VectorF diff = endPoint - startPoint;
VectorF diff = endingPoint - startingPoint;
F32 length = diff.len();
diff.normalizeSafe();
LightningBolt newBolt;
newBolt.startPoint = startPoint;
newBolt.endPoint = endPoint;
newBolt.width = width;
newBolt.startPoint = startingPoint;
newBolt.endPoint = endingPoint;
newBolt.width = splitWidth;
newBolt.numMajorNodes = 3;
newBolt.maxMajorAngle = 30.0f;
newBolt.numMinorNodes = 3;
@ -1184,13 +1256,13 @@ void LightningBolt::createSplit( const Point3F &startPoint, const Point3F &endPo
splitList.pushBack( newBolt );
VectorF newDir1 = MathUtils::randomDir( diff, 10.0f, 45.0f );
Point3F newEndPoint1 = endPoint + newDir1 * gRandGen.randF( 0.5f, 1.5f ) * length;
Point3F newEndPoint1 = endingPoint + newDir1 * gRandGen.randF( 0.5f, 1.5f ) * length;
VectorF newDir2 = MathUtils::randomDir( diff, 10.0f, 45.0f );
Point3F newEndPoint2 = endPoint + newDir2 * gRandGen.randF( 0.5f, 1.5f ) * length;
Point3F newEndPoint2 = endingPoint + newDir2 * gRandGen.randF( 0.5f, 1.5f ) * length;
createSplit( endPoint, newEndPoint1, depth - 1, width * 0.30f );
createSplit( endPoint, newEndPoint2, depth - 1, width * 0.30f );
createSplit(endingPoint, newEndPoint1, depth - 1, splitWidth * 0.30f );
createSplit(endingPoint, newEndPoint2, depth - 1, splitWidth * 0.30f );
}
@ -1203,7 +1275,7 @@ void LightningBolt::startSplits()
for( U32 i=0; i<mMajorNodes.numNodes-1; i++ )
{
if( gRandGen.randF() > 0.3f )
continue;
continue;
Node node = mMajorNodes.nodeList[i];
Node node2 = mMajorNodes.nodeList[i+1];

View file

@ -47,6 +47,7 @@ class ShapeBase;
class LightningStrikeEvent;
class SFXTrack;
#define MAX_LIGHTNING 3
// -------------------------------------------------------------------------
class LightningData : public GameBaseData
@ -70,6 +71,7 @@ class LightningData : public GameBaseData
GFXTexHandle strikeTextures[MaxTextures];
U32 numThunders;
U32 mNumStrikeTextures;
protected:
bool onAdd();
@ -227,7 +229,7 @@ class Lightning : public GameBase
void warningFlashes();
void strikeRandomPoint();
void strikeObject(ShapeBase*);
void strikeObject(ShapeBase* targetObj);
void processEvent(LightningStrikeEvent*);
DECLARE_CONOBJECT(Lightning);

View file

@ -2141,13 +2141,18 @@ DefineEngineFunction( gotoWebPage, void, ( const char* address ),,
//-----------------------------------------------------------------------------
DefineEngineFunction( displaySplashWindow, bool, (const char* path), ("art/gui/splash.bmp"),
DefineEngineFunction( displaySplashWindow, bool, (const char* path), (""),
"Display a startup splash window suitable for showing while the engine still starts up.\n\n"
"@note This is currently only implemented on Windows.\n\n"
"@param path relative path to splash screen image to display.\n"
"@return True if the splash window could be successfully initialized.\n\n"
"@ingroup Platform" )
{
if (path == "")
{
path = Con::getVariable("$Core::splashWindowImage");
}
return Platform::displaySplashWindow(path);
}

View file

@ -197,6 +197,9 @@ void ForestSelectionTool::_selectItem( const ForestItem &item )
void ForestSelectionTool::deleteSelection()
{
if (!mEditor)
return;
ForestDeleteUndoAction *action = new ForestDeleteUndoAction( mForest->getData(), mEditor );
for ( U32 i=0; i < mSelection.size(); i++ )

View file

@ -327,7 +327,10 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool
mNumMipLevels++;
allocPixels += currWidth * currHeight * mBytesPerPixel;
} while (currWidth != 1 && currHeight != 1);
} while (currWidth != 1 || currHeight != 1);
U32 expectedMips = mFloor(mLog2(mMax(in_width, in_height))) + 1;
AssertFatal(mNumMipLevels == expectedMips, "GBitmap::allocateBitmap: mipmap count wrong");
}
AssertFatal(mNumMipLevels <= c_maxMipLevels, "GBitmap::allocateBitmap: too many miplevels");
@ -608,31 +611,31 @@ bool GBitmap::checkForTransparency()
//------------------------------------------------------------------------------
ColorF GBitmap::sampleTexel(F32 u, F32 v) const
{
ColorF col(0.5f, 0.5f, 0.5f);
// normally sampling wraps all the way around at 1.0,
// but locking doesn't support this, and we seem to calc
// the uv based on a clamped 0 - 1...
Point2F max((F32)(getWidth()-1), (F32)(getHeight()-1));
Point2F posf;
posf.x = mClampF(((u) * max.x), 0.0f, max.x);
posf.y = mClampF(((v) * max.y), 0.0f, max.y);
Point2I posi((S32)posf.x, (S32)posf.y);
ColorF col(0.5f, 0.5f, 0.5f);
// normally sampling wraps all the way around at 1.0,
// but locking doesn't support this, and we seem to calc
// the uv based on a clamped 0 - 1...
Point2F max((F32)(getWidth()-1), (F32)(getHeight()-1));
Point2F posf;
posf.x = mClampF(((u) * max.x), 0.0f, max.x);
posf.y = mClampF(((v) * max.y), 0.0f, max.y);
Point2I posi((S32)posf.x, (S32)posf.y);
const U8 *buffer = getBits();
U32 lexelindex = ((posi.y * getWidth()) + posi.x) * mBytesPerPixel;
const U8 *buffer = getBits();
U32 lexelindex = ((posi.y * getWidth()) + posi.x) * mBytesPerPixel;
if(mBytesPerPixel == 2)
{
//U16 *buffer = (U16 *)lockrect->pBits;
}
else if(mBytesPerPixel > 2)
{
col.red = F32(buffer[lexelindex + 0]) / 255.0f;
if(mBytesPerPixel == 2)
{
//U16 *buffer = (U16 *)lockrect->pBits;
}
else if(mBytesPerPixel > 2)
{
col.red = F32(buffer[lexelindex + 0]) / 255.0f;
col.green = F32(buffer[lexelindex + 1]) / 255.0f;
col.blue = F32(buffer[lexelindex + 2]) / 255.0f;
}
col.blue = F32(buffer[lexelindex + 2]) / 255.0f;
}
return col;
return col;
}
//--------------------------------------------------------------------------

View file

@ -1085,21 +1085,7 @@ void GFXTextureManager::_validateTexParams( const U32 width, const U32 height,
// NOTE: Does this belong here?
if( inOutNumMips == 0 && !autoGenSupp )
{
U32 currWidth = width;
U32 currHeight = height;
inOutNumMips = 1;
do
{
currWidth >>= 1;
currHeight >>= 1;
if( currWidth == 0 )
currWidth = 1;
if( currHeight == 0 )
currHeight = 1;
inOutNumMips++;
} while ( currWidth != 1 && currHeight != 1 );
inOutNumMips = mFloor(mLog2(mMax(width, height))) + 1;
}
}
}

View file

@ -314,6 +314,9 @@ DefineEngineFunction( startVideoCapture, void,
"@see stopVideoCapture\n"
"@ingroup Rendering\n" )
{
#ifdef TORQUE_DEBUG
Con::errorf("Recording video is disabled in debug!");
#else
if ( !canvas )
{
Con::errorf("startVideoCapture -Please specify a GuiCanvas object to record from!");
@ -328,6 +331,7 @@ DefineEngineFunction( startVideoCapture, void,
VIDCAP->setResolution(resolution);
VIDCAP->begin(canvas);
#endif
}
DefineEngineFunction( stopVideoCapture, void, (),,

View file

@ -320,6 +320,11 @@ inline F32 mLog(const F32 val)
return (F32) log(val);
}
inline F32 mLog2(const F32 val)
{
return (F32) log2(val);
}
inline F32 mExp(const F32 val)
{
return (F32) exp(val);
@ -380,6 +385,10 @@ inline F64 mLog(const F64 val)
return (F64) log(val);
}
inline F64 mLog2(const F64 val)
{
return (F64) log2(val);
}
inline F32 mCatmullrom(F32 t, F32 p0, F32 p1, F32 p2, F32 p3)
{

View file

@ -429,7 +429,7 @@ struct InputEventInfo
U16 ascii;
/// Modifiers to action: SI_LSHIFT, SI_LCTRL, etc.
InputModifiers modifier;
U32 modifier;
inline void postToSignal(InputEvent &ie)
{

View file

@ -245,7 +245,7 @@ void RenderMeshMgr::render(SceneRenderState * state)
if ( passRI->accuTex != lastAccuTex )
{
sgData.accuTex = passRI->accuTex;
lastAccuTex = lastAccuTex;
lastAccuTex = passRI->accuTex;
dirty = true;
}

View file

@ -589,43 +589,51 @@ bool RenderParticleMgr::_initShader()
void RenderParticleMgr::_onLMActivate( const char*, bool activate )
{
RenderPassManager *rpm = getRenderPass();
if ( !rpm )
return;
// Hunt for the pre-pass manager/target
RenderPrePassMgr *prePassBin = NULL;
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
if ( activate )
{
RenderBinManager *bin = rpm->getManager(i);
if( bin->getRenderInstType() == RenderPrePassMgr::RIT_PrePass )
RenderPassManager *rpm = getRenderPass();
if ( !rpm )
return;
// Hunt for the pre-pass manager/target
RenderPrePassMgr *prePassBin = NULL;
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
{
prePassBin = (RenderPrePassMgr*)bin;
break;
RenderBinManager *bin = rpm->getManager(i);
if( bin->getRenderInstType() == RenderPrePassMgr::RIT_PrePass )
{
prePassBin = (RenderPrePassMgr*)bin;
break;
}
}
}
// If we found the prepass bin, set this bin to render very shortly afterwards
// and re-add this render-manager. If there is no pre-pass bin, or it doesn't
// have a depth-texture, we can't render offscreen.
mOffscreenRenderEnabled = prePassBin && (prePassBin->getTargetChainLength() > 0);
if(mOffscreenRenderEnabled)
{
rpm->removeManager(this);
setRenderOrder( prePassBin->getRenderOrder() + 0.011f );
rpm->addManager(this);
}
// If we found the prepass bin, set this bin to render very shortly afterwards
// and re-add this render-manager. If there is no pre-pass bin, or it doesn't
// have a depth-texture, we can't render offscreen.
mOffscreenRenderEnabled = prePassBin && (prePassBin->getTargetChainLength() > 0);
if(mOffscreenRenderEnabled)
{
rpm->removeManager(this);
setRenderOrder( prePassBin->getRenderOrder() + 0.011f );
rpm->addManager(this);
}
// Find the targets we use
mPrepassTarget = NamedTexTarget::find( "prepass" );
mEdgeTarget = NamedTexTarget::find( "edge" );
// Find the targets we use
mPrepassTarget = NamedTexTarget::find( "prepass" );
mEdgeTarget = NamedTexTarget::find( "edge" );
// Setup the shader
if ( activate )
// Setup the shader
_initShader();
if ( mScreenQuadVertBuff.isNull() )
_initGFXResources();
if ( mScreenQuadVertBuff.isNull() )
_initGFXResources();
}
else
{
mStencilClearSB = NULL;
mScreenQuadPrimBuff = NULL;
mScreenQuadVertBuff = NULL;
}
}
GFXStateBlockRef RenderParticleMgr::_getOffscreenStateBlock(ParticleRenderInst *ri)

View file

@ -124,6 +124,7 @@ RenderPassManager::RenderBinEventSignal& RenderPassManager::getRenderBinSignal()
void RenderPassManager::initPersistFields()
{
Parent::initPersistFields();
}
RenderPassManager::RenderPassManager()

View file

@ -480,7 +480,7 @@ void RenderPrePassMgr::render( SceneRenderState *state )
if (passRI->accuTex != lastAccuTex)
{
sgData.accuTex = passRI->accuTex;
lastAccuTex = lastAccuTex;
lastAccuTex = passRI->accuTex;
dirty = true;
}

View file

@ -22,7 +22,7 @@
#include "platform/platform.h"
#include "console/console.h"
#include "gfx/bitmap/gBitmap.h"
#include "SDL.h"
#include "windowManager/sdl/sdlWindow.h"
@ -36,7 +36,52 @@ bool Platform::displaySplashWindow( String path )
if(path.isEmpty())
return false;
gSplashImage = SDL_LoadBMP(path);
Torque::Path iconPath = Torque::Path(path);
if (iconPath.getExtension() == String("bmp"))
{
Con::errorf("Unable to use bmp format images for the splash screen. Please use a different format.");
return false;
}
Resource<GBitmap> img = GBitmap::load(iconPath);
if (img != NULL)
{
U32 pitch;
U32 width = img->getWidth();
bool hasAlpha = img->getHasTransparency();
U32 depth;
if (hasAlpha)
{
pitch = 4 * width;
depth = 32;
}
else
{
pitch = 3 * width;
depth = 24;
}
Uint32 rmask, gmask, bmask, amask;
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
{
S32 shift = hasAlpha ? 8 : 0;
rmask = 0xff000000 >> shift;
gmask = 0x00ff0000 >> shift;
bmask = 0x0000ff00 >> shift;
amask = 0x000000ff >> shift;
}
else
{
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = hasAlpha ? 0xff000000 : 0;
}
gSplashImage = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask);
}
//now the pop-up window
if (gSplashImage)
@ -53,7 +98,7 @@ bool Platform::displaySplashWindow( String path )
SDL_RenderPresent(gSplashRenderer);
}
return true;
return true;
}
bool Platform::closeSplashWindow()

View file

@ -51,23 +51,41 @@ namespace
{
U32 ret = 0;
if(mod & KMOD_LSHIFT)
ret |= IM_LSHIFT;
if (mod & KMOD_LSHIFT)
{
ret |= SI_LSHIFT;
ret |= SI_SHIFT;
}
if(mod & KMOD_RSHIFT)
ret |= IM_RSHIFT;
if (mod & KMOD_RSHIFT)
{
ret |= SI_RSHIFT;
ret |= SI_SHIFT;
}
if(mod & KMOD_LCTRL)
ret |= IM_LCTRL;
if (mod & KMOD_LCTRL)
{
ret |= SI_LCTRL;
ret |= SI_CTRL;
}
if(mod & KMOD_RCTRL)
ret |= IM_RCTRL;
if (mod & KMOD_RCTRL)
{
ret |= SI_RCTRL;
ret |= SI_CTRL;
}
if(mod & KMOD_LALT)
ret |= IM_LALT;
if (mod & KMOD_LALT)
{
ret |= SI_LALT;
ret |= SI_ALT;
}
if(mod & KMOD_RALT)
ret |= IM_RALT;
if (mod & KMOD_RALT)
{
ret |= SI_RALT;
ret |= SI_ALT;
}
return ret;
}
@ -86,37 +104,37 @@ mShouldLockMouse(false),
mSuppressReset(false),
mMenuHandle(NULL)
{
mCursorController = new PlatformCursorControllerSDL( this );
mCursorController = new PlatformCursorControllerSDL( this );
mVideoMode.bitDepth = 32;
mVideoMode.fullScreen = false;
mVideoMode.refreshRate = 60;
mVideoMode.resolution.set(800,600);
mVideoMode.bitDepth = 32;
mVideoMode.fullScreen = false;
mVideoMode.refreshRate = 60;
mVideoMode.resolution.set(800,600);
}
PlatformWindowSDL::~PlatformWindowSDL()
{
// delete our sdl handle..
SDL_DestroyWindow(mWindowHandle);
// delete our sdl handle..
SDL_DestroyWindow(mWindowHandle);
// unlink ourselves from the window list...
AssertFatal(mOwningManager, "PlatformWindowSDL::~PlatformWindowSDL - orphan window, cannot unlink!");
mOwningManager->unlinkWindow(this);
// unlink ourselves from the window list...
AssertFatal(mOwningManager, "PlatformWindowSDL::~PlatformWindowSDL - orphan window, cannot unlink!");
mOwningManager->unlinkWindow(this);
}
GFXDevice * PlatformWindowSDL::getGFXDevice()
{
return mDevice;
return mDevice;
}
GFXWindowTarget * PlatformWindowSDL::getGFXTarget()
{
return mTarget;
return mTarget;
}
const GFXVideoMode & PlatformWindowSDL::getVideoMode()
{
return mVideoMode;
return mVideoMode;
}
void* PlatformWindowSDL::getSystemWindow(const WindowSystem system)
@ -144,41 +162,41 @@ void PlatformWindowSDL::setVideoMode( const GFXVideoMode &mode )
mVideoMode = mode;
mSuppressReset = true;
// Set our window to have the right style based on the mode
// Set our window to have the right style based on the mode
if(mode.fullScreen && !Platform::getWebDeployment() && !mOffscreenRender)
{
{
setSize(mode.resolution);
SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN);
// When switching to Fullscreen, reset device after setting style
if(mTarget.isValid())
mTarget->resetMode();
}
else
{
if(mTarget.isValid())
mTarget->resetMode();
}
else
{
// Reset device *first*, so that when we call setSize() and let it
// access the monitor settings, it won't end up with our fullscreen
// geometry that is just about to change.
// access the monitor settings, it won't end up with our fullscreen
// geometry that is just about to change.
if(mTarget.isValid())
mTarget->resetMode();
if(mTarget.isValid())
mTarget->resetMode();
if (!mOffscreenRender)
{
SDL_SetWindowFullscreen( mWindowHandle, 0);
SDL_SetWindowFullscreen( mWindowHandle, 0);
}
setSize(mode.resolution);
centerWindow();
}
}
mSuppressReset = false;
mSuppressReset = false;
}
bool PlatformWindowSDL::clearFullscreen()
{
return true;
return true;
}
bool PlatformWindowSDL::isFullscreen()
@ -192,32 +210,32 @@ bool PlatformWindowSDL::isFullscreen()
void PlatformWindowSDL::_setFullscreen(const bool fullscreen)
{
if( isFullscreen() )
return;
if( isFullscreen() )
return;
if(fullscreen && !mOffscreenRender)
{
Con::printf("PlatformWindowSDL::setFullscreen (full) enter");
SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN);
}
else
{
Con::printf("PlatformWindowSDL::setFullscreen (windowed) enter");
if(fullscreen && !mOffscreenRender)
{
Con::printf("PlatformWindowSDL::setFullscreen (full) enter");
SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN);
}
else
{
Con::printf("PlatformWindowSDL::setFullscreen (windowed) enter");
if (!mOffscreenRender)
{
SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN_DESKTOP);
}
setSize(mVideoMode.resolution);
}
Con::printf("PlatformWindowSDL::setFullscreen exit");
}
Con::printf("PlatformWindowSDL::setFullscreen exit");
}
bool PlatformWindowSDL::setCaption( const char *cap )
{
SDL_SetWindowTitle(mWindowHandle, cap);
return true;
return true;
}
const char * PlatformWindowSDL::getCaption()
@ -232,45 +250,45 @@ void PlatformWindowSDL::setFocus()
void PlatformWindowSDL::setClientExtent( const Point2I newExtent )
{
Point2I oldExtent = getClientExtent();
if (oldExtent == newExtent)
return;
Point2I oldExtent = getClientExtent();
if (oldExtent == newExtent)
return;
SDL_SetWindowSize(mWindowHandle, newExtent.x, newExtent.y);
}
const Point2I PlatformWindowSDL::getClientExtent()
{
// Fetch Client Rect from Windows
// Fetch Client Rect from Windows
Point2I size;
SDL_GetWindowSize(mWindowHandle, &size.x, &size.y);
SDL_GetWindowSize(mWindowHandle, &size.x, &size.y);
return size;
return size;
}
void PlatformWindowSDL::setBounds( const RectI &newBounds )
{
// TODO SDL
// TODO SDL
}
const RectI PlatformWindowSDL::getBounds() const
{
// TODO SDL
return RectI(0, 0, 0, 0);
// TODO SDL
return RectI(0, 0, 0, 0);
}
void PlatformWindowSDL::setPosition( const Point2I newPosition )
{
SDL_SetWindowPosition( mWindowHandle, newPosition.x, newPosition.y );
SDL_SetWindowPosition( mWindowHandle, newPosition.x, newPosition.y );
}
const Point2I PlatformWindowSDL::getPosition()
{
Point2I position;
SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
Point2I position;
SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
// Return position
return position;
// Return position
return position;
}
Point2I PlatformWindowSDL::clientToScreen( const Point2I& pos )
@ -293,7 +311,7 @@ void PlatformWindowSDL::centerWindow()
SDL_GetWindowSize(mWindowHandle, &sizeX, &sizeY);
SDL_DisplayMode mode;
SDL_GetDesktopDisplayMode(0, &mode);
SDL_GetDesktopDisplayMode(0, &mode);
U32 posX = (mode.w/2) - (sizeX/2);
U32 posY = (mode.h/2) - (sizeY/2);
@ -307,21 +325,21 @@ bool PlatformWindowSDL::setSize( const Point2I &newSize )
// Let GFX get an update about the new resolution
if (mTarget.isValid())
mTarget->resetMode();
mTarget->resetMode();
return true;
return true;
}
bool PlatformWindowSDL::isOpen()
{
return mWindowHandle;
return mWindowHandle;
}
bool PlatformWindowSDL::isVisible()
{
// Is the window open and visible, ie. not minimized?
if(!mWindowHandle)
return false;
// Is the window open and visible, ie. not minimized?
if(!mWindowHandle)
return false;
if (mOffscreenRender)
return true;
@ -330,7 +348,7 @@ bool PlatformWindowSDL::isVisible()
if( flags & SDL_WINDOW_SHOWN)
return true;
return false;
return false;
}
bool PlatformWindowSDL::isFocused()
@ -371,7 +389,7 @@ bool PlatformWindowSDL::isMaximized()
WindowId PlatformWindowSDL::getWindowId()
{
return mWindowId;
return mWindowId;
}
void PlatformWindowSDL::minimize()
@ -379,7 +397,7 @@ void PlatformWindowSDL::minimize()
if (mOffscreenRender)
return;
SDL_MinimizeWindow( mWindowHandle );
SDL_MinimizeWindow( mWindowHandle );
}
void PlatformWindowSDL::maximize()
@ -387,7 +405,7 @@ void PlatformWindowSDL::maximize()
if (mOffscreenRender)
return;
SDL_MaximizeWindow( mWindowHandle );
SDL_MaximizeWindow( mWindowHandle );
}
void PlatformWindowSDL::restore()
@ -395,7 +413,7 @@ void PlatformWindowSDL::restore()
if (mOffscreenRender)
return;
SDL_RestoreWindow( mWindowHandle );
SDL_RestoreWindow( mWindowHandle );
}
void PlatformWindowSDL::hide()
@ -403,7 +421,7 @@ void PlatformWindowSDL::hide()
if (mOffscreenRender)
return;
SDL_HideWindow( mWindowHandle );
SDL_HideWindow( mWindowHandle );
}
void PlatformWindowSDL::show()
@ -411,17 +429,17 @@ void PlatformWindowSDL::show()
if (mOffscreenRender)
return;
SDL_ShowWindow( mWindowHandle );
SDL_ShowWindow( mWindowHandle );
}
void PlatformWindowSDL::close()
{
delete this;
delete this;
}
void PlatformWindowSDL::defaultRender()
{
// TODO SDL
// TODO SDL
}
void PlatformWindowSDL::_triggerMouseLocationNotify(const SDL_Event& evt)
@ -597,7 +615,7 @@ void PlatformWindowSDL::setMouseLocked( bool enable )
if (mOffscreenRender)
return;
mMouseLocked = enable;
mMouseLocked = enable;
SDL_SetWindowGrab( mWindowHandle, SDL_bool(enable) );
SDL_SetRelativeMouseMode( SDL_bool(enable) );

View file

@ -24,6 +24,7 @@
#include "gfx/gfxDevice.h"
#include "core/util/journal/process.h"
#include "core/strings/unicode.h"
#include "gfx/bitmap/gBitmap.h"
#include "SDL.h"
@ -165,6 +166,59 @@ PlatformWindow *PlatformWindowManagerSDL::createWindow(GFXDevice *device, const
window->mOwningManager = this;
mWindowMap[ window->mWindowId ] = window;
//Now, fetch our window icon, if any
Torque::Path iconPath = Torque::Path(Con::getVariable( "$Core::windowIcon" ));
if (iconPath.getExtension() == String("bmp"))
{
Con::errorf("Unable to use bmp format images for the window icon. Please use a different format.");
}
else
{
Resource<GBitmap> img = GBitmap::load(iconPath);
if (img != NULL)
{
U32 pitch;
U32 width = img->getWidth();
bool hasAlpha = img->getHasTransparency();
U32 depth;
if (hasAlpha)
{
pitch = 4 * width;
depth = 32;
}
else
{
pitch = 3 * width;
depth = 24;
}
Uint32 rmask, gmask, bmask, amask;
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
{
S32 shift = hasAlpha ? 8 : 0;
rmask = 0xff000000 >> shift;
gmask = 0x00ff0000 >> shift;
bmask = 0x0000ff00 >> shift;
amask = 0x000000ff >> shift;
}
else
{
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = hasAlpha ? 0xff000000 : 0;
}
SDL_Surface* iconSurface = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask);
SDL_SetWindowIcon(window->mWindowHandle, iconSurface);
SDL_FreeSurface(iconSurface);
}
}
if(device)
{
window->mDevice = device;

View file

@ -95,7 +95,7 @@ void WindowInputGenerator::generateInputEvent( InputEventInfo &inputEvent )
{
const AccKeyMap &acc = mAcceleratorMap[i];
if (!mWindow->getKeyboardTranslation() &&
(acc.modifier & inputEvent.modifier || (acc.modifier == 0 && inputEvent.modifier == 0))
((acc.modifier == inputEvent.modifier && acc.modifier != 0) || (acc.modifier == 0 && inputEvent.modifier == 0))
&& acc.keyCode == inputEvent.objInst)
{
Con::evaluatef(acc.cmd);
@ -145,7 +145,11 @@ void WindowInputGenerator::handleMouseMove( WindowId did, U32 modifier, S32 x, S
event.deviceType = MouseDeviceType;
event.deviceInst = 0;
event.objType = SI_AXIS;
event.modifier = convertModifierBits(modifier);
#ifdef TORQUE_SDL
event.modifier = modifier;
#else
event.modifier = convertModifierBits(modifier);
#endif
event.ascii = 0;
// Generate delta movement along each axis
@ -231,7 +235,11 @@ void WindowInputGenerator::handleMouseButton( WindowId did, U32 modifiers, U32 a
event.deviceInst = 0;
event.objType = SI_BUTTON;
event.objInst = (InputObjectInstances)(KEY_BUTTON0 + button);
event.modifier = convertModifierBits(modifiers);
#ifdef TORQUE_SDL
event.modifier = modifiers;
#else
event.modifier = convertModifierBits(modifiers);
#endif
event.ascii = 0;
event.action = (action==IA_MAKE) ? SI_MAKE : SI_BREAK;
event.fValue = (action==IA_MAKE) ? 1.0 : 0.0;
@ -248,7 +256,11 @@ void WindowInputGenerator::handleMouseWheel( WindowId did, U32 modifiers, S32 wh
event.deviceType = MouseDeviceType;
event.deviceInst = 0;
event.objType = SI_AXIS;
event.modifier = convertModifierBits(modifiers);
#ifdef TORQUE_SDL
event.modifier = modifiers;
#else
event.modifier = convertModifierBits(modifiers);
#endif
event.ascii = 0;
event.action = SI_MOVE;
@ -281,7 +293,11 @@ void WindowInputGenerator::handleCharInput( WindowId did, U32 modifier, U16 key
event.deviceInst = 0;
event.objType = SI_KEY;
event.objInst = KEY_NULL;
event.modifier = convertModifierBits(modifier);
#ifdef TORQUE_SDL
event.modifier = modifier;
#else
event.modifier = convertModifierBits(modifier);
#endif
event.ascii = key;
event.action = SI_MAKE;
event.fValue = 1.0;
@ -303,7 +319,11 @@ void WindowInputGenerator::handleKeyboard( WindowId did, U32 modifier, U32 actio
event.deviceInst = 0;
event.objType = SI_KEY;
event.objInst = (InputObjectInstances)key;
event.modifier = convertModifierBits(modifier);
#ifdef TORQUE_SDL
event.modifier = modifier;
#else
event.modifier = convertModifierBits(modifier);
#endif
event.ascii = 0;
switch(action)