Added refactor of Editor Settings window

Various fixes for asset handling.
WIP of crash tracking
This commit is contained in:
Areloch 2019-06-03 02:47:30 -05:00
parent 691d3f501e
commit ff871f37e3
30 changed files with 662 additions and 273 deletions

View file

@ -47,14 +47,14 @@
IMPLEMENT_CONOBJECT(GUIAsset);
ConsoleType(GUIAssetPtr, TypeGUIAssetPtr, GUIAsset, ASSET_ID_FIELD_PREFIX)
ConsoleType(GUIAssetPtr, TypeGUIAssetPtr, String, ASSET_ID_FIELD_PREFIX)
//-----------------------------------------------------------------------------
ConsoleGetType(TypeGUIAssetPtr)
{
// Fetch asset Id.
return (*((AssetPtr<GUIAsset>*)dptr)).getAssetId();
return *((StringTableEntry*)dptr);
}
//-----------------------------------------------------------------------------
@ -67,19 +67,11 @@ ConsoleSetType(TypeGUIAssetPtr)
// Yes, so fetch field value.
const char* pFieldValue = argv[0];
// Fetch asset pointer.
AssetPtr<GUIAsset>* pAssetPtr = dynamic_cast<AssetPtr<GUIAsset>*>((AssetPtrBase*)(dptr));
// Fetch asset Id.
StringTableEntry* assetId = (StringTableEntry*)(dptr);
// Is the asset pointer the correct type?
if (pAssetPtr == NULL)
{
// No, so fail.
//Con::warnf("(TypeGUIAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
return;
}
// Set asset.
pAssetPtr->setAssetId(pFieldValue);
// Update asset value.
*assetId = StringTable->insert(pFieldValue);
return;
}
@ -268,4 +260,4 @@ bool GuiInspectorTypeGUIAssetPtr::updateRects()
}
return resized;
}
}

View file

@ -225,8 +225,6 @@ const char* GameObjectAsset::create()
//Entity* e = dynamic_cast<Entity*>(pSimObject);
//e->_setGameObject(getAssetId());
StringTableEntry assetId = getAssetId();
pSimObject->setDataField(StringTable->insert("GameObject"), nullptr, getAssetId());
return pSimObject->getIdString();

View file

@ -47,14 +47,14 @@
IMPLEMENT_CONOBJECT(ImageAsset);
ConsoleType(ImageAssetPtr, TypeImageAssetPtr, ImageAsset, ASSET_ID_FIELD_PREFIX)
ConsoleType(ImageAssetPtr, TypeImageAssetPtr, String, ASSET_ID_FIELD_PREFIX)
//-----------------------------------------------------------------------------
ConsoleGetType(TypeImageAssetPtr)
{
// Fetch asset Id.
return (*((AssetPtr<ImageAsset>*)dptr)).getAssetId();
return *((StringTableEntry*)dptr);
}
//-----------------------------------------------------------------------------
@ -67,19 +67,11 @@ ConsoleSetType(TypeImageAssetPtr)
// Yes, so fetch field value.
const char* pFieldValue = argv[0];
// Fetch asset pointer.
AssetPtr<ImageAsset>* pAssetPtr = dynamic_cast<AssetPtr<ImageAsset>*>((AssetPtrBase*)(dptr));
// Fetch asset Id.
StringTableEntry* assetId = (StringTableEntry*)(dptr);
// Is the asset pointer the correct type?
if (pAssetPtr == NULL)
{
// No, so fail.
//Con::warnf("(TypeImageAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
return;
}
// Set asset.
pAssetPtr->setAssetId(pFieldValue);
// Update asset value.
*assetId = StringTable->insert(pFieldValue);
return;
}

View file

@ -47,14 +47,14 @@
IMPLEMENT_CONOBJECT(LevelAsset);
ConsoleType(LevelAssetPtr, TypeLevelAssetPtr, LevelAsset, ASSET_ID_FIELD_PREFIX)
ConsoleType(LevelAssetPtr, TypeLevelAssetPtr, String, ASSET_ID_FIELD_PREFIX)
//-----------------------------------------------------------------------------
ConsoleGetType(TypeLevelAssetPtr)
{
// Fetch asset Id.
return (*((AssetPtr<LevelAsset>*)dptr)).getAssetId();
return *((StringTableEntry*)dptr);
}
//-----------------------------------------------------------------------------
@ -67,19 +67,11 @@ ConsoleSetType(TypeLevelAssetPtr)
// Yes, so fetch field value.
const char* pFieldValue = argv[0];
// Fetch asset pointer.
AssetPtr<LevelAsset>* pAssetPtr = dynamic_cast<AssetPtr<LevelAsset>*>((AssetPtrBase*)(dptr));
// Fetch asset Id.
StringTableEntry* assetId = (StringTableEntry*)(dptr);
// Is the asset pointer the correct type?
if (pAssetPtr == NULL)
{
// No, so fail.
//Con::warnf("(TypeLevelAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
return;
}
// Set asset.
pAssetPtr->setAssetId(pFieldValue);
// Update asset value.
*assetId = StringTable->insert(pFieldValue);
return;
}
@ -121,6 +113,9 @@ void LevelAsset::initPersistFields()
addField("LevelName", TypeString, Offset(mLevelName, LevelAsset), "Human-friendly name for the level.");
addProtectedField("PreviewImage", TypeAssetLooseFilePath, Offset(mPreviewImage, LevelAsset),
&setPreviewImageFile, &getPreviewImageFile, "Path to the image used for selection preview.");
addField("isSubScene", TypeString, Offset(mIsSubLevel, LevelAsset), "Is this a sublevel to another Scene");
addField("gameModeName", TypeString, Offset(mGamemodeName, LevelAsset), "Name of the Game Mode to be used with this level");
}
//------------------------------------------------------------------------------

View file

@ -51,6 +51,8 @@ class LevelAsset : public AssetBase
bool mIsSubLevel;
StringTableEntry mMainLevelAsset;
StringTableEntry mGamemodeName;
public:
LevelAsset();
virtual ~LevelAsset();

View file

@ -531,7 +531,7 @@ void ReflectionProbe::updateProbeParams()
mProbeInfoIdx = ProbeRenderInst::all.size() - 1;
mProbeInfo->mIsEnabled = false;
PROBEMGR->registerProbe(mProbeInfoIdx);
//PROBEMGR->registerProbe(mProbeInfoIdx);
}
mProbeInfo->mProbeShapeType = mProbeShapeType;
@ -965,4 +965,4 @@ DefineEngineMethod(ReflectionProbe, Bake, void, (), ,
{
clientProbe->bake();
}
}
}

View file

@ -47,6 +47,7 @@ String GFXTextureManager::smUnavailableTexturePath(Con::getVariable("$Core::UnAv
String GFXTextureManager::smWarningTexturePath(Con::getVariable("$Core::WarningTexturePath"));
String GFXTextureManager::smDefaultIrradianceCubemapPath(Con::getVariable("$Core::DefaultIrradianceCubemap"));
String GFXTextureManager::smDefaultPrefilterCubemapPath(Con::getVariable("$Core::DefaultPrefilterCubemap"));
String GFXTextureManager::smBRDFTexturePath(Con::getVariable("$Core::BRDFTexture"));
GFXTextureManager::EventSignal GFXTextureManager::smEventSignal;
@ -80,6 +81,10 @@ void GFXTextureManager::init()
Con::addVariable("$Core::DefaultPrefilterCubemap", TypeRealString, &smDefaultPrefilterCubemapPath,
"The file path of the texture used as the default specular cubemap for PBR.\n"
"@ingroup GFX\n");
Con::addVariable("$Core::BRDFTexture", TypeRealString, &smBRDFTexturePath,
"The file path of the texture used as the default irradiance cubemap for PBR.\n"
"@ingroup GFX\n");
}
GFXTextureManager::GFXTextureManager()

View file

@ -77,6 +77,8 @@ public:
static const String& getDefaultIrradianceCubemapPath() { return smDefaultIrradianceCubemapPath; }
static const String& getDefaultPrefilterCubemapPath() { return smDefaultPrefilterCubemapPath; }
static const String& getBRDFTexturePath() { return smBRDFTexturePath; }
/// Update width and height based on available resources.
///
/// We provide a simple interface for managing texture memory usage. Specifically,
@ -215,6 +217,7 @@ protected:
static String smDefaultIrradianceCubemapPath;
static String smDefaultPrefilterCubemapPath;
static String smBRDFTexturePath;
GFXTextureObject *mListHead;
GFXTextureObject *mListTail;

View file

@ -27,6 +27,7 @@
#include "gui/editor/guiInspector.h"
#include "core/util/safeDelete.h"
#include "gfx/gfxDrawUtil.h"
#include "util/settings.h"
//-----------------------------------------------------------------------------
// GuiInspectorVariableField
@ -104,7 +105,17 @@ void GuiInspectorVariableField::setData( const char* data, bool callbacks )
{
if (mOwnerObject != nullptr)
{
mOwnerObject->setDataField(mVariableName, NULL, data);
//Special case: if our object is a Settings class, we'll assume that we're trying to get/set the fields via the Setting class's normal behavior
//otherwise, use fields as normal
Settings* setting = dynamic_cast<Settings*>(mOwnerObject);
if (setting)
{
setting->setValue(mVariableName, data);
}
else
{
mOwnerObject->setDataField(mVariableName, NULL, data);
}
}
else
{
@ -121,8 +132,16 @@ const char* GuiInspectorVariableField::getData( U32 inspectObjectIndex )
{
if ( !mCaption || mCaption[0] == 0 )
return "";
return Con::getVariable( mCaption );
Settings* setting = dynamic_cast<Settings*>(mOwnerObject);
if (setting)
{
return setting->value(mVariableName);
}
else
{
return Con::getVariable(mCaption);
}
}
void GuiInspectorVariableField::setValue( const char* newValue )
@ -138,4 +157,4 @@ void GuiInspectorVariableField::updateValue()
return;
setValue( getData() );
}
}

View file

@ -60,7 +60,10 @@ void GuiVariableInspector::loadVars( String searchStr )
void GuiVariableInspector::update()
{
clearGroups();
for (U32 g = 0; g < mGroups.size(); g++)
{
mGroups[g]->clearFields();
}
for (U32 i = 0; i < mFields.size(); i++)
{
@ -149,6 +152,8 @@ void GuiVariableInspector::addField(const char* name, const char* label, const c
fieldTypeMask = TypeF32;
else if (newField.mFieldTypeName == StringTable->insert("vector"))
fieldTypeMask = TypePoint3F;
else if (newField.mFieldTypeName == StringTable->insert("vector2"))
fieldTypeMask = TypePoint2F;
//else if (fieldType == StringTable->insert("material"))
// fieldTypeMask = TypeMaterialName;
else if (newField.mFieldTypeName == StringTable->insert("image"))
@ -264,4 +269,4 @@ DefineEngineMethod(GuiVariableInspector, setFieldEnabled, void, (const char* fie
DefineEngineMethod( GuiVariableInspector, loadVars, void, ( const char * searchString ), , "loadVars( searchString )" )
{
object->loadVars( searchString );
}
}

View file

@ -117,6 +117,7 @@ Material::Material()
mDiffuse[i].set( 1.0f, 1.0f, 1.0f, 1.0f );
mDiffuseMapSRGB[i] = true;
mDiffuseMapAsset[i] = StringTable->EmptyString();
mDiffuseMapAssetId[i] = StringTable->EmptyString();
mSmoothness[i] = 0.0f;
mMetalness[i] = 0.0f;
@ -238,7 +239,7 @@ void Material::initPersistFields()
addField("diffuseMap", TypeImageFilename, Offset(mDiffuseMapFilename, Material), MAX_STAGES,
"The diffuse color texture map." );
addField("diffuseMapAsset", TypeImageAssetPtr, Offset(mDiffuseMapAsset, Material), MAX_STAGES,
addField("diffuseMapAsset", TypeImageAssetPtr, Offset(mDiffuseMapAssetId, Material), MAX_STAGES,
"The diffuse color texture map." );
addField("diffuseMapSRGB", TypeBool, Offset(mDiffuseMapSRGB, Material), MAX_STAGES,
@ -585,6 +586,15 @@ bool Material::onAdd()
if ( slash != String::NPos )
mPath = scriptFile.substr( 0, slash + 1 );
//bind any assets we have
for (U32 i = 0; i < MAX_STAGES; i++)
{
if (mDiffuseMapAssetId[i] != StringTable->EmptyString())
{
mDiffuseMapAsset[0] = mDiffuseMapAssetId[0];
}
}
_mapMaterial();
return true;

View file

@ -409,7 +409,7 @@ void ProcessedMaterial::_setStageData()
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
}
}
else if (!mMaterial->mDiffuseMapAsset[i].isNull())
else if (mMaterial->mDiffuseMapAsset[i] && !mMaterial->mDiffuseMapAsset[i].isNull())
{
mStages[i].setTex(MFT_DiffuseMap, mMaterial->mDiffuseMapAsset[i]->getImage());
if (!mStages[i].getTex(MFT_DiffuseMap))

View file

@ -191,8 +191,8 @@ public:
inline void increaseLoadCount( void ) { ++mLoadCount; }
inline void reduceLoadCount( void ) { --mLoadCount; }
inline S32 getLoadCount( void ) const { return mLoadCount; }
inline void setLocked( const bool status ) { mLocked = status; }
inline bool getLocked( void ) const { return mLocked; }
inline void setModuleLocked( const bool status ) { mLocked = status; }
inline bool getModuleLocked( void ) const { return mLocked; }
inline ModuleManager* getModuleManager( void ) const { return mpModuleManager; }
bool save( void );

View file

@ -2121,7 +2121,7 @@ bool ModuleManager::registerModule( const char* pModulePath, const char* pModule
pModuleDefinition->setSignature( formatBuffer );
// Locked the module definition.
pModuleDefinition->setLocked( true );
pModuleDefinition->setModuleLocked( true );
// Fetch modules definitions.
ModuleDefinitionEntry* pDefinitions = findModuleId( moduleId );

View file

@ -1076,11 +1076,6 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
setShaderConsts_callback();
}
if (mShaderName == String("PFX_ReflectionProbeArray") || getName() == StringTable->insert("reflectionProbeArrayPostFX"))
{
bool derp = true;
}
EffectConstTable::Iterator iter = mEffectConsts.begin();
for ( ; iter != mEffectConsts.end(); iter++ )
iter->value->setToBuffer( mShaderConsts );
@ -1607,6 +1602,22 @@ void PostEffect::setTexture( U32 index, const String &texFilePath )
mTextureType[index] = NormalTextureType;
}
void PostEffect::setTexture(U32 index, const GFXTexHandle& texHandle)
{
// Set the new texture name.
mTexFilename[index] = "";
mTextures[index].free();
// Skip empty stages or ones with variable or target names.
if (!texHandle.isValid())
return;
// Try to load the texture.
mTextures[index] = texHandle;
mTextureType[index] = NormalTextureType;
}
void PostEffect::setCubemapTexture(U32 index, const GFXCubemapHandle &cubemapHandle)
{
// Set the new texture name.
@ -2048,4 +2059,4 @@ DefineEngineFunction( dumpRandomNormalMap, void, (),,
String path = Torque::FS::MakeUniquePath( "", "randNormTex", "png" );
tex->dumpToDisk( "png", path );
}
}

View file

@ -416,6 +416,7 @@ public:
F32 getPriority() const { return mRenderPriority; }
void setTexture( U32 index, const String &filePath );
void setTexture(U32 index, const GFXTexHandle& texHandle);
void setCubemapTexture(U32 index, const GFXCubemapHandle &cubemapHandle);
void setCubemapArrayTexture(U32 index, const GFXCubemapArrayHandle &cubemapArrayHandle);
@ -451,4 +452,4 @@ public:
};
};
#endif // _POST_EFFECT_H_
#endif // _POST_EFFECT_H_

View file

@ -267,6 +267,13 @@ bool RenderProbeMgr::onAdd()
return false;
}
/*String brdfTexturePath = GFXTextureManager::getBRDFTexturePath();
if (!mBRDFTexture.set(brdfTexturePath, &GFXTexturePersistentSRGBProfile, "BRDFTexture"))
{
Con::errorf("RenderProbeMgr::onAdd: Failed to load BRDF Texture");
return false;
}*/
return true;
}
@ -554,6 +561,7 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
ProbeShaderConstants *probeShaderConsts,
GFXShaderConstBuffer *shaderConsts)
{
return;
PROFILE_SCOPE(ProbeManager_Update4ProbeConsts);
// Skip over gathering lights if we don't have to!
@ -658,6 +666,9 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
shaderConsts->setSafe(probeShaderConsts->mProbeBoxMaxSC, probeBoxMaxArray);
shaderConsts->setSafe(probeShaderConsts->mProbeConfigDataSC, probeConfigArray);
//if (mBRDFTexture.isValid())
// GFX->setTexture(3, mBRDFTexture);
if(probeShaderConsts->mProbeSpecularCubemapSC->getSamplerRegister() != -1)
GFX->setCubeArrayTexture(probeShaderConsts->mProbeSpecularCubemapSC->getSamplerRegister(), mPrefilterArray);
if(probeShaderConsts->mProbeIrradianceCubemapSC->getSamplerRegister() != -1)
@ -743,6 +754,7 @@ void RenderProbeMgr::setProbeInfo(ProcessedMaterial *pmat,
//-----------------------------------------------------------------------------
void RenderProbeMgr::render( SceneRenderState *state )
{
return;
//PROFILE_SCOPE(RenderProbeMgr_render);
if (getProbeArrayEffect() == nullptr)
return;
@ -793,6 +805,7 @@ void RenderProbeMgr::render( SceneRenderState *state )
mProbeArrayEffect->setShaderConst("$cubeMips", (float)mMipCount);
if (mEffectiveProbeCount != 0)
{
//mProbeArrayEffect->setTexture(3, mBRDFTexture);
mProbeArrayEffect->setCubemapArrayTexture(4, mPrefilterArray);
mProbeArrayEffect->setCubemapArrayTexture(5, mIrradianceArray);