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

@ -76,7 +76,7 @@ ConsoleDocClass( DecalData,
DecalData::DecalData()
{
size = 5;
materialName = "";
INIT_MATERIALASSET(Material);
lifeSpan = 5000;
fadeTime = 1000;
@ -89,7 +89,6 @@ DecalData::DecalData()
fadeStartPixelSize = -1.0f;
fadeEndPixelSize = 200.0f;
material = NULL;
matInst = NULL;
renderPriority = 10;
@ -144,8 +143,7 @@ void DecalData::initPersistFields()
addField( "size", TypeF32, Offset( size, DecalData ),
"Width and height of the decal in meters before scale is applied." );
addField( "material", TypeMaterialName, Offset( materialName, DecalData ),
"Material to use for this decal." );
INITPERSISTFIELD_MATERIALASSET(Material, DecalData, "Material to use for this decal.");
addField( "lifeSpan", TypeS32, Offset( lifeSpan, DecalData ),
"Time (in milliseconds) before this decal will be automatically deleted." );
@ -226,7 +224,7 @@ void DecalData::onStaticModified( const char *slotName, const char *newValue )
// To allow changing materials live.
if ( dStricmp( slotName, "material" ) == 0 )
{
materialName = newValue;
_setMaterial(newValue);
_updateMaterial();
}
// To allow changing name live.
@ -259,7 +257,9 @@ void DecalData::packData( BitStream *stream )
stream->write( lookupName );
stream->write( size );
stream->write( materialName );
PACKDATA_MATERIALASSET(Material);
stream->write( lifeSpan );
stream->write( fadeTime );
stream->write( texCoordCount );
@ -285,8 +285,10 @@ void DecalData::unpackData( BitStream *stream )
stream->read( &lookupName );
assignName(lookupName);
stream->read( &size );
stream->read( &materialName );
stream->read( &size );
UNPACKDATA_MATERIALASSET(Material);
_updateMaterial();
stream->read( &lifeSpan );
stream->read( &fadeTime );
@ -311,8 +313,10 @@ void DecalData::_initMaterial()
{
SAFE_DELETE( matInst );
if ( material )
matInst = material->createMatInstance();
if (mMaterialAsset.notNull())
{
matInst = getMaterialResource()->createMatInstance();
}
else
matInst = MATMGR->createMatInstance( "WarningMaterial" );
@ -324,7 +328,7 @@ void DecalData::_initMaterial()
matInst->init( MATMGR->getDefaultFeatures(), getGFXVertexFormat<DecalVertex>() );
if( !matInst->isValid() )
{
Con::errorf( "DecalData::_initMaterial - failed to create material instance for '%s'", materialName.c_str() );
Con::errorf( "DecalData::_initMaterial - failed to create material instance for '%s'", mMaterialAssetId );
SAFE_DELETE( matInst );
matInst = MATMGR->createMatInstance( "WarningMaterial" );
matInst->init( MATMGR->getDefaultFeatures(), getGFXVertexFormat< DecalVertex >() );
@ -333,38 +337,29 @@ void DecalData::_initMaterial()
void DecalData::_updateMaterial()
{
if ( materialName.isEmpty() )
if(mMaterialAsset.isNull())
return;
Material *pMat = NULL;
if ( !Sim::findObject( materialName, pMat ) )
{
Con::printf( "DecalData::unpackUpdate, failed to find Material of name %s!", materialName.c_str() );
return;
}
material = pMat;
// Only update material instance if we have one allocated.
if ( matInst )
_initMaterial();
}
Material* DecalData::getMaterial()
Material* DecalData::getMaterialDefinition()
{
if ( !material )
if ( !getMaterialResource() )
{
_updateMaterial();
if ( !material )
material = static_cast<Material*>( Sim::findObject("WarningMaterial") );
if ( !mMaterial )
mMaterial = static_cast<Material*>( Sim::findObject("WarningMaterial") );
}
return material;
return mMaterial;
}
BaseMatInstance* DecalData::getMaterialInstance()
{
if ( !material || !matInst || matInst->getMaterial() != material )
if ( !mMaterial || !matInst || matInst->getMaterial() != mMaterial)
_initMaterial();
return matInst;