Converts all game, gui editor, and system classes to utilize assets

Processed core, tools and default modules to utilize assets
Converted all console types that were string based, such as TypeImageFilename to utilize const char*/the string table, which avoids a lot of type swapping shenanigans and avoids string corruption
Removed unneeded MainEditor mockup module
Removed some unused/duplicate image assets from the tools
This commit is contained in:
Areloch 2021-07-19 01:07:08 -05:00
parent 83b0432283
commit 5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions

View file

@ -376,11 +376,11 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
// have more than a base texture.
if (mat->getDetailSize() <= 0 ||
mat->getDetailDistance() <= 0 ||
mat->getDetailMap().isEmpty())
mat->getDetailMap() == StringTable->EmptyString())
continue;
// check for macro detail texture
if (!(mat->getMacroSize() <= 0 || mat->getMacroDistance() <= 0 || mat->getMacroMap().isEmpty()))
if (!(mat->getMacroSize() <= 0 || mat->getMacroDistance() <= 0 || mat->getMacroMap() == StringTable->EmptyString()))
{
if (deferredMat)
features.addFeature(MFT_isDeferred, featureIndex);
@ -393,7 +393,7 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
if (deferredMat)
{
if (!(mat->getORMConfigMap().isEmpty()))
if (!(mat->getORMConfigMap() == StringTable->EmptyString()))
{
features.addFeature(MFT_TerrainORMMap, featureIndex);
}
@ -409,12 +409,11 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
normalMaps.increment();
// Skip normal maps if we need to.
if (!disableNormalMaps && mat->getNormalMap().isNotEmpty())
if (!disableNormalMaps && mat->getNormalMap() != StringTable->EmptyString())
{
features.addFeature(MFT_TerrainNormalMap, featureIndex);
normalMaps.last().set(mat->getNormalMap(),
&GFXNormalMapProfile, "TerrainCellMaterial::_initShader() - NormalMap");
normalMaps.last() = mat->getNormalMapResource();
GFXFormat normalFmt = normalMaps.last().getFormat();
if (normalFmt == GFXFormatBC3)
@ -644,7 +643,7 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
// have more than a base texture.
if (mat->getDetailSize() <= 0 ||
mat->getDetailDistance() <= 0 ||
mat->getDetailMap().isEmpty())
mat->getDetailMap() == StringTable->EmptyString())
continue;
mMaterialInfos[i]->mBlendDepthConst = mShader->getShaderConstHandle(avar("$blendDepth%d", i));
@ -691,7 +690,7 @@ void TerrainCellMaterial::_updateMaterialConsts( )
// have more than a base texture.
if (mat->getDetailSize() <= 0 ||
mat->getDetailDistance() <= 0 ||
mat->getDetailMap().isEmpty())
mat->getDetailMap() == StringTable->EmptyString())
continue;
detailMatCount++;
@ -720,7 +719,7 @@ void TerrainCellMaterial::_updateMaterialConsts( )
// have more than a base texture.
if (mat->getDetailSize() <= 0 ||
mat->getDetailDistance() <= 0 ||
mat->getDetailMap().isEmpty())
mat->getDetailMap() == StringTable->EmptyString())
continue;
F32 detailSize = matInfo->mat->getDetailSize();

View file

@ -978,8 +978,17 @@ void TerrainBlock::addMaterial( const String &name, U32 insertAt )
{
TerrainMaterial *mat = TerrainMaterial::findOrCreate( name );
StringTableEntry newMatName = StringTable->insert(name.c_str());
if ( insertAt == -1 )
{
//Check to ensure we're not trying to add one that already exists, as that'd be kinda dumb
for (U32 i = 0; i < mFile->mMaterials.size(); i++)
{
if (mFile->mMaterials[i]->getInternalName() == newMatName)
return;
}
mFile->mMaterials.push_back( mat );
mFile->_initMaterialInstMapping();
@ -1332,13 +1341,6 @@ U32 TerrainBlock::packUpdate(NetConnection* con, U32 mask, BitStream *stream)
if ( stream->writeFlag( mask & TransformMask ) )
mathWrite( *stream, getTransform() );
if ( stream->writeFlag( mask & FileMask ) )
{
S32 idasdasdf = getId();
stream->write(mCRC);
stream->writeString( mTerrainAsset.getAssetId() );
}
if ( stream->writeFlag( mask & SizeMask ) )
stream->write( mSquareSize );
@ -1350,6 +1352,12 @@ U32 TerrainBlock::packUpdate(NetConnection* con, U32 mask, BitStream *stream)
stream->write( mLightMapSize );
}
if ( stream->writeFlag( mask & FileMask ) )
{
stream->write(mCRC);
stream->writeString( mTerrainAsset.getAssetId() );
}
stream->writeFlag( mask & HeightMapChangeMask );
if ( stream->writeFlag( mask & MiscMask ) )
@ -1374,20 +1382,13 @@ void TerrainBlock::unpackUpdate(NetConnection* con, BitStream *stream)
setTransform( mat );
}
if ( stream->readFlag() ) // FileMask
{
stream->read(&mCRC);
char buffer[256];
stream->readString(buffer);
bool validAsset = setTerrainAsset(StringTable->insert(buffer));
}
if ( stream->readFlag() ) // SizeMask
stream->read( &mSquareSize );
mCastShadows = stream->readFlag();
bool baseTexSizeChanged = false;
if ( stream->readFlag() ) // MaterialMask
{
U32 baseTexSize;
@ -1395,8 +1396,7 @@ void TerrainBlock::unpackUpdate(NetConnection* con, BitStream *stream)
if ( mBaseTexSize != baseTexSize )
{
mBaseTexSize = baseTexSize;
if ( isProperlyAdded() )
_updateBaseTexture( NONE );
baseTexSizeChanged = true;
}
U32 lightMapSize;
@ -1412,6 +1412,18 @@ void TerrainBlock::unpackUpdate(NetConnection* con, BitStream *stream)
}
}
if (stream->readFlag()) // FileMask
{
stream->read(&mCRC);
char buffer[256];
stream->readString(buffer);
bool validAsset = setTerrainAsset(StringTable->insert(buffer));
_updateBaseTexture(NONE);
}
if (baseTexSizeChanged && isProperlyAdded())
_updateBaseTexture(NONE);
if ( stream->readFlag() && isProperlyAdded() ) // HeightMapChangeMask
{
_updateBounds();

View file

@ -124,7 +124,7 @@ protected:
U32 mCRC;
///
FileName mTerrFileName;
StringTableEntry mTerrFileName;
AssetPtr<TerrainAsset> mTerrainAsset;
StringTableEntry mTerrainAssetId;
@ -476,7 +476,7 @@ public:
RayInfo *info,
bool collideEmpty );
const FileName& getTerrainFile() const { return mTerrFileName; }
const StringTableEntry getTerrainFile() const { return mTerrFileName; }
void postLight(Vector<TerrainBlock *> &terrBlocks) {};

View file

@ -259,7 +259,7 @@ void TerrainFile::_initMaterialInstMapping()
for( U32 i = 0; i < mMaterials.size(); ++ i )
{
Torque::Path path( mMaterials[ i ]->getDiffuseMap() );
Torque::Path path( mMaterials[ i ]->getDiffuseMap());
mMaterialInstMapping.push_back( path.getFileName() );
}

View file

@ -73,11 +73,11 @@ TerrainMaterial::TerrainMaterial()
mIsSRGB(false),
mInvertRoughness(false)
{
initMapSlot(DiffuseMap);
initMapSlot(NormalMap);
initMapSlot(DetailMap);
initMapSlot(ORMConfigMap);
initMapSlot(MacroMap);
INIT_IMAGEASSET(DiffuseMap);
INIT_IMAGEASSET(NormalMap);
INIT_IMAGEASSET(DetailMap);
INIT_IMAGEASSET(ORMConfigMap);
INIT_IMAGEASSET(MacroMap);
}
TerrainMaterial::~TerrainMaterial()
@ -86,10 +86,10 @@ TerrainMaterial::~TerrainMaterial()
void TerrainMaterial::initPersistFields()
{
scriptBindMapSlot(DiffuseMap, TerrainMaterial,"Base Albedo stretched over the whole map");
INITPERSISTFIELD_IMAGEASSET(DiffuseMap, TerrainMaterial,"Base Albedo stretched over the whole map");
addField( "diffuseSize", TypeF32, Offset( mDiffuseSize, TerrainMaterial ), "Used to scale the diffuse map to the material square" );
scriptBindMapSlot(NormalMap, TerrainMaterial,"NormalMap");
INITPERSISTFIELD_IMAGEASSET(NormalMap, TerrainMaterial,"NormalMap");
addField( "parallaxScale", TypeF32, Offset( mParallaxScale, TerrainMaterial ), "Used to scale the height from the normal map to give some self "
"occlusion effect (aka parallax) to the terrain material" );
@ -99,7 +99,7 @@ void TerrainMaterial::initPersistFields()
addField("blendHeightContrast", TypeF32, Offset(mBlendContrast, TerrainMaterial), "A fixed value to add while blending using heightmap-based blending."
"Higher numbers = larger blend radius.");
scriptBindMapSlot(DetailMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo up close.");
INITPERSISTFIELD_IMAGEASSET(DetailMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo up close.");
addField( "detailSize", TypeF32, Offset( mDetailSize, TerrainMaterial ), "Used to scale the detail map to the material square" );
addField( "detailStrength", TypeF32, Offset( mDetailStrength, TerrainMaterial ), "Exponentially sharpens or lightens the detail map rendering on the material" );
addField( "detailDistance", TypeF32, Offset( mDetailDistance, TerrainMaterial ), "Changes how far camera can see the detail map rendering on the material" );
@ -107,12 +107,12 @@ void TerrainMaterial::initPersistFields()
addField( "useSideProjection", TypeBool, Offset( mSideProjection, TerrainMaterial ),"Makes that terrain material project along the sides of steep "
"slopes instead of projected downwards");
scriptBindMapSlot(ORMConfigMap, TerrainMaterial, "AO|Roughness|metalness map (uses DetailMap UV Coords)");
INITPERSISTFIELD_IMAGEASSET(ORMConfigMap, TerrainMaterial, "AO|Roughness|metalness map (uses DetailMap UV Coords)");
addField("isSRGB", TypeBool, Offset(mIsSRGB, TerrainMaterial), "Is the PBR Config map's image in sRGB format?");
addField("invertRoughness", TypeBool, Offset(mInvertRoughness, TerrainMaterial), "Should the roughness channel of the PBR Config map be inverted?");
//Macro maps additions
scriptBindMapSlot(MacroMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo at a distance.");
INITPERSISTFIELD_IMAGEASSET(MacroMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo at a distance.");
addField( "macroSize", TypeF32, Offset( mMacroSize, TerrainMaterial ), "Used to scale the Macro map to the material square" );
addField( "macroStrength", TypeF32, Offset( mMacroStrength, TerrainMaterial ), "Exponentially sharpens or lightens the Macro map rendering on the material" );
addField( "macroDistance", TypeF32, Offset( mMacroDistance, TerrainMaterial ), "Changes how far camera can see the Macro map rendering on the material" );
@ -140,13 +140,6 @@ bool TerrainMaterial::onAdd()
Con::warnf( "TerrainMaterial::onAdd() - Internal name collision; '%s' already exists!", mInternalName );
}
//bind any assets we have
bindMapSlot(DiffuseMap);
bindMapSlot(NormalMap);
bindMapSlot(DetailMap);
bindMapSlot(ORMConfigMap);
bindMapSlot(MacroMap);
set->addObject( this );
return true;
@ -175,7 +168,7 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
{
mat = new TerrainMaterial();
mat->setInternalName( nameOrPath );
mat->mDiffuseMapFilename = nameOrPath;
mat->mDiffuseMapName = nameOrPath;
mat->registerObject();
Sim::getRootGroup()->addObject( mat );
return mat;
@ -190,12 +183,12 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
// fallback here just in case it gets "lost".
mat = new TerrainMaterial();
mat->setInternalName( "warning_material" );
mat->mDiffuseMapFilename = GFXTextureManager::getWarningTexturePath();
mat->mDiffuseMapName = GFXTextureManager::getWarningTexturePath();
mat->mDiffuseSize = 500;
mat->mDetailMapFilename = GFXTextureManager::getWarningTexturePath();
mat->mDiffuseMapName = GFXTextureManager::getWarningTexturePath();
mat->mDetailSize = 5;
mat->mMacroMapFilename = GFXTextureManager::getWarningTexturePath();
mat->mMacroSize = 200;
mat->mDiffuseMapName = GFXTextureManager::getWarningTexturePath();
mat->mMacroSize = 200;
mat->registerObject();
Sim::getRootGroup()->addObject( mat );
@ -203,3 +196,15 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
return mat;
}
//declare general get<entry>, get<entry>Asset and set<entry> methods
//signatures are:
//using DiffuseMap as an example
//material.getDiffuseMap(); //returns the raw file referenced
//material.getDiffuseMapAsset(); //returns the asset id
//material.setDiffuseMap(%texture); //tries to set the asset and failing that attempts a flat file reference
DEF_IMAGEASSET_BINDS(TerrainMaterial, DiffuseMap);
DEF_IMAGEASSET_BINDS(TerrainMaterial, NormalMap);
DEF_IMAGEASSET_BINDS(TerrainMaterial, DetailMap);
DEF_IMAGEASSET_BINDS(TerrainMaterial, ORMConfigMap);
DEF_IMAGEASSET_BINDS(TerrainMaterial, MacroMap);

View file

@ -42,17 +42,20 @@ protected:
//AssetPtr<ImageAsset> mDiffuseAsset;
DECLARE_TEXTUREMAP(TerrainMaterial, DiffuseMap);
DECLARE_IMAGEASSET(TerrainMaterial, DiffuseMap, onDiffuseMapChanged, GFXStaticTextureSRGBProfile);
DECLARE_IMAGEASSET_SETGET(TerrainMaterial, DiffuseMap);
/// The size of the diffuse base map in meters
/// used to generate its texture coordinates.
F32 mDiffuseSize;
///
DECLARE_TEXTUREMAP(TerrainMaterial, NormalMap);
DECLARE_IMAGEASSET(TerrainMaterial, NormalMap, onNormalMapChanged, GFXNormalMapProfile);
DECLARE_IMAGEASSET_SETGET(TerrainMaterial, NormalMap);
///
DECLARE_TEXTUREMAP(TerrainMaterial, DetailMap);
DECLARE_IMAGEASSET(TerrainMaterial, DetailMap, onDetailMapChanged, GFXStaticTextureProfile);
DECLARE_IMAGEASSET_SETGET(TerrainMaterial, DetailMap);
/// The size of the detail map in meters used
/// to generate the texture coordinates for the
@ -66,7 +69,8 @@ protected:
F32 mDetailDistance;
///
DECLARE_TEXTUREMAP(TerrainMaterial, ORMConfigMap);
DECLARE_IMAGEASSET(TerrainMaterial, ORMConfigMap, onORMConfigMapChanged, GFXStaticTextureProfile);
DECLARE_IMAGEASSET_SETGET(TerrainMaterial, ORMConfigMap);
bool mIsSRGB;
bool mInvertRoughness;
@ -77,7 +81,8 @@ protected:
/// planes.
bool mSideProjection;
DECLARE_TEXTUREMAP(TerrainMaterial, MacroMap);
DECLARE_IMAGEASSET(TerrainMaterial, MacroMap, onMacroMapChanged, GFXStaticTextureProfile);
DECLARE_IMAGEASSET_SETGET(TerrainMaterial, MacroMap);
F32 mMacroSize;
F32 mMacroStrength;
F32 mMacroDistance;
@ -137,6 +142,12 @@ public:
bool getInvertRoughness() const { return mInvertRoughness; }
void onDiffuseMapChanged() {}
void onNormalMapChanged() {}
void onDetailMapChanged() {}
void onORMConfigMapChanged() {}
void onMacroMapChanged() {}
};
#endif // _TERRMATERIAL_H_

View file

@ -96,20 +96,19 @@ void TerrainBlock::_updateMaterials()
{
TerrainMaterial *mat = mFile->mMaterials[i];
if (mat->getDiffuseMap().isNotEmpty())
if (mat->getDiffuseMap() != StringTable->EmptyString())
{
mBaseTextures[i].set(mat->getDiffuseMap(), &GFXStaticTextureSRGBProfile,
"TerrainBlock::_updateMaterials() - DiffuseMap");
mBaseTextures[i] = mat->getDiffuseMapResource();
}
else
mBaseTextures[ i ] = GFXTexHandle();
// Find the maximum detail distance.
if ( mat->getDetailMap().isNotEmpty() &&
if ( mat->getDetailMap() != StringTable->EmptyString() &&
mat->getDetailDistance() > mMaxDetailDistance )
mMaxDetailDistance = mat->getDetailDistance();
if ( mat->getMacroMap().isNotEmpty() &&
if ( mat->getMacroMap() != StringTable->EmptyString() &&
mat->getMacroDistance() > mMaxDetailDistance )
mMaxDetailDistance = mat->getMacroDistance();
}
@ -126,17 +125,19 @@ void TerrainBlock::_updateMaterials()
for (U32 i = 0; i < mFile->mMaterials.size(); i++)
{
TerrainMaterial* mat = mFile->mMaterials[i];
if (mat->getDetailMap() != StringTable->EmptyString())
detailTexArray[i] = mat->getDetailMapResource();
if (mat->getMacroMap() != StringTable->EmptyString())
macroTexArray[i] = mat->getMacroMapResource();
if (mat->getNormalMap() != StringTable->EmptyString())
normalTexArray[i] = mat->getNormalMapResource();
//depending on creation method this may or may not have been shoved into srgb space eroneously
GFXTextureProfile* profile = &GFXStaticTextureProfile;
if (mat->getIsSRGB())
profile = &GFXStaticTextureSRGBProfile;
if (mat->getDetailMap().isNotEmpty())
detailTexArray[i] = TEXMGR->createTexture(mat->getDetailMap(), profile);
if (mat->getMacroMap().isNotEmpty())
macroTexArray[i] = TEXMGR->createTexture(mat->getMacroMap(), profile);
if (mat->getNormalMap().isNotEmpty())
normalTexArray[i] = TEXMGR->createTexture(mat->getNormalMap(), profile);
if (mat->getORMConfigMap().isNotEmpty())
if (mat->getORMConfigMap() != StringTable->EmptyString())
ormTexArray[i] = TEXMGR->createTexture(mat->getORMConfigMap(), profile);
}