mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-08 05:04:34 +00:00
- Updates the material and terrain material assets to utilize AssetRef and drop the old macros like how Image and ShapeAssets have been updated.
- Updates the various classes using materials to comply to the change. - Also standardizes some getter names to follow the general convention image and shape used to keep things more consistent across the board to minimize usage friction. - Shifts handling of fallback asset lookups for the thus-far converted classes to have them be loaded during core initialization rather than being loaded as part of other asset loading as that sometimes lead to nesting execution/stability errors. Explicit call now ensures the fallbacks are loaded before any other asset tries to load, so there's no room for confounding or having no fallback to work with.
This commit is contained in:
parent
6d8f83bd3a
commit
c96d58ae34
42 changed files with 583 additions and 698 deletions
|
|
@ -45,15 +45,13 @@ ConsoleDocClass( GuiMaterialCtrl,
|
|||
GuiMaterialCtrl::GuiMaterialCtrl()
|
||||
: mMaterialInst( NULL )
|
||||
{
|
||||
INIT_ASSET(Material);
|
||||
}
|
||||
|
||||
void GuiMaterialCtrl::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
addGroup( "Material" );
|
||||
INITPERSISTFIELD_MATERIALASSET(Material, GuiMaterialCtrl, "");
|
||||
addProtectedField( "materialName", TypeStringFilename, Offset( mMaterialName, GuiMaterialCtrl ), &GuiMaterialCtrl::_setMaterialData, &defaultProtectedGetFn, "", AbstractClassRep::FIELD_HideInInspectors );
|
||||
ADD_FIELD( "materialAsset", TypeMaterialAssetRef, Offset( mMaterialAssetRef, GuiMaterialCtrl ) ).doc( "Material asset to display in this control." );
|
||||
endGroup( "Material" );
|
||||
|
||||
Parent::initPersistFields();
|
||||
|
|
@ -65,7 +63,7 @@ bool GuiMaterialCtrl::onWake()
|
|||
return false;
|
||||
|
||||
setActive( true );
|
||||
setMaterial( getMaterial() );
|
||||
setMaterial( mMaterialAssetRef.assetId );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -77,22 +75,26 @@ void GuiMaterialCtrl::onSleep()
|
|||
Parent::onSleep();
|
||||
}
|
||||
|
||||
bool GuiMaterialCtrl::_setMaterial( void *object, const char *index, const char *data )
|
||||
{
|
||||
static_cast<GuiMaterialCtrl *>( object )->setMaterial( data );
|
||||
|
||||
// Return false to keep the caller from setting the field.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GuiMaterialCtrl::setMaterial( const String &materialName )
|
||||
{
|
||||
SAFE_DELETE( mMaterialInst );
|
||||
|
||||
_setMaterial(StringTable->insert(materialName.c_str()));
|
||||
StringTableEntry matId = StringTable->insert( materialName.c_str() );
|
||||
if ( matId == StringTable->EmptyString() || AssetDatabase.isDeclaredAsset( matId ))
|
||||
{
|
||||
mMaterialAssetRef = matId;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringTableEntry assetId = MaterialAsset::getAssetIdByMaterialName( matId );
|
||||
if ( assetId != StringTable->EmptyString() )
|
||||
mMaterialAssetRef = assetId;
|
||||
}
|
||||
|
||||
if ( getMaterial() != StringTable->EmptyString() && isAwake() )
|
||||
mMaterialInst = MATMGR->createMatInstance( getMaterial(), getGFXVertexFormat<GFXVertexPCT>() );
|
||||
if ( mMaterialAssetRef.notNull() && isAwake() )
|
||||
mMaterialInst = MATMGR->createMatInstance(
|
||||
mMaterialAssetRef.assetPtr->getMaterialName(),
|
||||
getGFXVertexFormat<GFXVertexPCT>() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue