Merge branch 'Preview4_0' of https://github.com/TorqueGameEngines/Torque3D into Preview4_0

This commit is contained in:
Areloch 2021-09-19 02:28:19 -05:00
commit 9a809dfb6b
10 changed files with 102 additions and 57 deletions

View file

@ -127,7 +127,7 @@ ConsoleDocClass( PrecipitationData,
//---------------------------------------------------------- //----------------------------------------------------------
PrecipitationData::PrecipitationData() PrecipitationData::PrecipitationData()
{ {
soundProfile = NULL; INIT_SOUNDASSET(Sound);
INIT_IMAGEASSET(Drop); INIT_IMAGEASSET(Drop);
@ -143,8 +143,7 @@ PrecipitationData::PrecipitationData()
void PrecipitationData::initPersistFields() void PrecipitationData::initPersistFields()
{ {
addField( "soundProfile", TYPEID< SFXTrack >(), Offset(soundProfile, PrecipitationData), INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
"Looping SFXProfile effect to play while Precipitation is active." );
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn, addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn,
"@brief Texture filename for drop particles.\n\n" "@brief Texture filename for drop particles.\n\n"
@ -190,7 +189,7 @@ bool PrecipitationData::preload( bool server, String &errorStr )
if( Parent::preload( server, errorStr) == false) if( Parent::preload( server, errorStr) == false)
return false; return false;
if( !server && !sfxResolve( &soundProfile, errorStr ) ) if (!server && !getSFXProfile())
return false; return false;
return true; return true;
@ -200,7 +199,7 @@ void PrecipitationData::packData(BitStream* stream)
{ {
Parent::packData(stream); Parent::packData(stream);
sfxWrite( stream, soundProfile ); PACKDATA_SOUNDASSET(Sound);
PACKDATA_IMAGEASSET(Drop); PACKDATA_IMAGEASSET(Drop);
@ -217,7 +216,7 @@ void PrecipitationData::unpackData(BitStream* stream)
{ {
Parent::unpackData(stream); Parent::unpackData(stream);
sfxRead( stream, &soundProfile ); UNPACKDATA_SOUNDASSET(Sound);
UNPACKDATA_IMAGEASSET(Drop); UNPACKDATA_IMAGEASSET(Drop);
@ -598,9 +597,9 @@ bool Precipitation::onNewDataBlock( GameBaseData *dptr, bool reload )
{ {
SFX_DELETE( mAmbientSound ); SFX_DELETE( mAmbientSound );
if ( mDataBlock->soundProfile ) if ( mDataBlock->getSFXProfile())
{ {
mAmbientSound = SFX->createSource( mDataBlock->soundProfile, &getTransform() ); mAmbientSound = SFX->createSource(mDataBlock->getSFXProfile(), &getTransform() );
if ( mAmbientSound ) if ( mAmbientSound )
mAmbientSound->play(); mAmbientSound->play();
} }

View file

@ -34,8 +34,9 @@
#endif #endif
#include "T3D/assets/ImageAsset.h" #include "T3D/assets/ImageAsset.h"
#include "T3D/assets/SoundAsset.h"
class SFXTrack; //class SFXTrack;
class SFXSource; class SFXSource;
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -45,30 +46,39 @@ class PrecipitationData : public GameBaseData
typedef GameBaseData Parent; typedef GameBaseData Parent;
public: public:
SFXTrack* soundProfile; //SFXTrack* soundProfile;
DECLARE_SOUNDASSET(PrecipitationData, Sound);
DECLARE_SOUNDASSET_SETGET(PrecipitationData, Sound);
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop); DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop);
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash); DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash);
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
S32 mDropsPerSide; ///< How many drops are on a side of the raindrop texture. S32 mDropsPerSide; ///< How many drops are on a side of the raindrop texture.
S32 mSplashesPerSide; ///< How many splash are on a side of the splash texture. S32 mSplashesPerSide; ///< How many splash are on a side of the splash texture.
PrecipitationData(); PrecipitationData();
DECLARE_CONOBJECT(PrecipitationData); DECLARE_CONOBJECT(PrecipitationData);
bool preload( bool server, String& errorStr ); bool preload( bool server, String& errorStr );
static void initPersistFields(); static void initPersistFields();
virtual void packData(BitStream* stream); virtual void packData(BitStream* stream);
virtual void unpackData(BitStream* stream); virtual void unpackData(BitStream* stream);
void onDropChanged() {} void onDropChanged() {}
void onSplashChanged() {} void onSplashChanged() {}
SFXProfile* getSFXProfile() {
if (mSoundAsset.notNull())
return mSoundAsset->getSfxProfile();
else
return NULL;
}
}; };
struct Raindrop struct Raindrop

View file

@ -290,7 +290,7 @@ GFXAdapter *GFXInit::getBestAdapterChoice()
{ {
S32 adapterIdx = dAtoi(adapterDevice.c_str()); S32 adapterIdx = dAtoi(adapterDevice.c_str());
if (adapterIdx == -1) if (adapterIdx == -1)
adapter = chooseAdapter(adapterType, outputDevice.c_str()); adapter = chooseAdapter(NullDevice, outputDevice.c_str());
else else
adapter = chooseAdapter(adapterType, adapterIdx); adapter = chooseAdapter(adapterType, adapterIdx);
} }

View file

@ -933,7 +933,7 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
} }
GFXShader* GFXGLDevice::createShader() GFXShader* GFXGLDevice::createShader()
{ {
GFXGLShader* shader = new GFXGLShader(); GFXGLShader* shader = new GFXGLShader(this);
shader->registerResourceWithDevice( this ); shader->registerResourceWithDevice( this );
return shader; return shader;
} }

View file

@ -382,10 +382,11 @@ void GFXGLShaderConstBuffer::onShaderReload( GFXGLShader *shader )
mWasLost = true; mWasLost = true;
} }
GFXGLShader::GFXGLShader() : GFXGLShader::GFXGLShader(GFXGLDevice* device) :
mVertexShader(0), mVertexShader(0),
mPixelShader(0), mPixelShader(0),
mProgram(0), mProgram(0),
mDevice(device),
mConstBufferSize(0), mConstBufferSize(0),
mConstBuffer(NULL) mConstBuffer(NULL)
{ {
@ -706,7 +707,8 @@ void GFXGLShader::initHandles()
dMemset(mConstBuffer, 0, mConstBufferSize); dMemset(mConstBuffer, 0, mConstBufferSize);
// Set our program so uniforms are assigned properly. // Set our program so uniforms are assigned properly.
glUseProgram(mProgram); mDevice->setShader(this, false);
// Iterate through uniforms to set sampler numbers. // Iterate through uniforms to set sampler numbers.
for (HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter) for (HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter)
{ {
@ -723,7 +725,6 @@ void GFXGLShader::initHandles()
dMemcpy(mConstBuffer + handle->mOffset, &handle->mSamplerNum, handle->getSize()); dMemcpy(mConstBuffer + handle->mOffset, &handle->mSamplerNum, handle->getSize());
} }
} }
glUseProgram(0);
//instancing //instancing
if (!mInstancingFormat) if (!mInstancingFormat)
@ -830,6 +831,7 @@ void GFXGLShader::setConstantsFromBuffer(GFXGLShaderConstBuffer* buffer)
// Copy new value into our const buffer and set in GL. // Copy new value into our const buffer and set in GL.
dMemcpy(mConstBuffer + handle->mOffset, buffer->mBuffer + handle->mOffset, handle->getSize()); dMemcpy(mConstBuffer + handle->mOffset, buffer->mBuffer + handle->mOffset, handle->getSize());
switch(handle->mDesc.constType) switch(handle->mDesc.constType)
{ {
case GFXSCT_Float: case GFXSCT_Float:

View file

@ -32,14 +32,15 @@
class GFXGLShaderConstHandle; class GFXGLShaderConstHandle;
class FileStream; class FileStream;
class GFXGLShaderConstBuffer; class GFXGLShaderConstBuffer;
class GFXGLDevice;
class GFXGLShader : public GFXShader class GFXGLShader : public GFXShader
{ {
typedef Map<String, GFXGLShaderConstHandle*> HandleMap; typedef Map<String, GFXGLShaderConstHandle*> HandleMap;
public: public:
GFXGLShader(); GFXGLShader(GFXGLDevice* device);
virtual ~GFXGLShader(); virtual ~GFXGLShader();
/// @name GFXShader interface /// @name GFXShader interface
/// @{ /// @{
virtual GFXShaderConstHandle* getShaderConstHandle(const String& name); virtual GFXShaderConstHandle* getShaderConstHandle(const String& name);
@ -99,6 +100,7 @@ protected:
U32 mConstBufferSize; U32 mConstBufferSize;
U8* mConstBuffer; U8* mConstBuffer;
HandleMap mHandles; HandleMap mHandles;
GFXGLDevice* mDevice;
Vector<GFXGLShaderConstHandle*> mValidHandles; Vector<GFXGLShaderConstHandle*> mValidHandles;
}; };

View file

@ -258,17 +258,19 @@ bool GuiCanvas::onAdd()
// Make sure we're able to render. // Make sure we're able to render.
newDevice->setAllowRender( true ); newDevice->setAllowRender( true );
if(mDisplayWindow) // NULL device returns a nullptr for getPlatformWindow
PlatformWindow* window = getPlatformWindow();
if (mDisplayWindow && window)
{ {
getPlatformWindow()->show(); window->show();
WindowManager->setDisplayWindow(true); WindowManager->setDisplayWindow(true);
getPlatformWindow()->setDisplayWindow(true); window->setDisplayWindow(true);
} }
else else if (window)
{ {
getPlatformWindow()->hide(); window->hide();
WindowManager->setDisplayWindow(false); WindowManager->setDisplayWindow(false);
getPlatformWindow()->setDisplayWindow(false); window->setDisplayWindow(false);
} }
// Propagate add to parents. // Propagate add to parents.

View file

@ -1,10 +1,6 @@
$Core::windowIcon = "data/icon.png"; $Core::windowIcon = "data/icon.png";
$Core::splashWindowImage = "data/splash.png"; $Core::splashWindowImage = "data/splash.png";
// Display a splash window immediately to improve app responsiveness before
// engine is initialized and main window created.
displaySplashWindow($Core::splashWindowImage);
// Console does something. // Console does something.
setLogMode(6); setLogMode(6);
@ -20,6 +16,13 @@ ModuleDatabase.setModuleExtension("module");
ModuleDatabase.scanModules( "core", false ); ModuleDatabase.scanModules( "core", false );
ModuleDatabase.LoadExplicit( "CoreModule" ); ModuleDatabase.LoadExplicit( "CoreModule" );
// Display a splash window immediately to improve app responsiveness before
// engine is initialized and main window created.
if ($Server::Dedicated == false)
displaySplashWindow($Core::splashWindowImage);
else
$Video::forceDisplayAdapter = -1;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Load any gameplay modules // Load any gameplay modules
ModuleDatabase.scanModules( "data", false ); ModuleDatabase.scanModules( "data", false );
@ -42,6 +45,7 @@ else
} }
} }
closeSplashWindow(); if ($Server::Dedicated == false)
closeSplashWindow();
echo("Engine initialized..."); echo("Engine initialized...");

View file

@ -919,7 +919,7 @@ T3Dpre4ProjectImporter::genProcessor("DebrisData", "shape shapeAsset shapeFile s
T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset"); T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset");
T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset"); T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset");
T3Dpre4ProjectImporter::genProcessor("ParticleData", "texture textureAsset textureName textureAsset textureExt textureExtAsset textureExtName textureExtAsset"); T3Dpre4ProjectImporter::genProcessor("ParticleData", "texture textureAsset textureName textureAsset textureExt textureExtAsset textureExtName textureExtAsset");
T3Dpre4ProjectImporter::genProcessor("PrecipitationData", "drop dropAsset dropTexture dropAsset splash splashAsset splashTexture splashAsset"); T3Dpre4ProjectImporter::genProcessor("PrecipitationData", "drop dropAsset dropTexture dropAsset splash splashAsset splashTexture splashAsset soundProfile soundAsset");
T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset"); T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset");
T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset"); T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset");
T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset"); T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset");

View file

@ -556,23 +556,49 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
%targetFilename = sanitizeFilename(%value); %targetFilename = sanitizeFilename(%value);
if(isObject(%targetFilename)) if(isObject(%targetFilename))
{
if(%originalFieldName $= "soundProfile")
{ {
//likely a material name, so handle it that way $ProjectImporter::assetQuery.clear();
%assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename); %foundAssets = AssetDatabase.findAssetName($ProjectImporter::assetQuery, %targetFilename);
if(%foundAssets != 0)
{
%assetId = $ProjectImporter::assetQuery.getAsset(0);
}
}
else
{
//likely a material name, so handle it that way
%assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename);
}
} }
else else
{ {
if(!isFile(%targetFilename)) if(!isFile(%targetFilename))
{ {
error("Legacy Project Importer - file described in line could not be found/is not valid"); if(%originalFieldName $= "soundProfile")
return %line; {
} $ProjectImporter::assetQuery.clear();
%foundAssets = AssetDatabase.findAssetName($ProjectImporter::assetQuery, %targetFilename);
$ProjectImporter::assetQuery.clear(); if(%foundAssets != 0)
%foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename); {
if(%foundAssets != 0) %assetId = $ProjectImporter::assetQuery.getAsset(0);
{ }
%assetId = $ProjectImporter::assetQuery.getAsset(0); }
else
{
error("Legacy Project Importer - file described in line could not be found/is not valid");
return %line;
}
}
else
{
$ProjectImporter::assetQuery.clear();
%foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename);
if(%foundAssets != 0)
{
%assetId = $ProjectImporter::assetQuery.getAsset(0);
}
} }
} }