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
|
|
@ -56,7 +56,6 @@ SkyBox::SkyBox()
|
|||
mTypeMask |= EnvironmentObjectType | StaticObjectType;
|
||||
mNetFlags.set(Ghostable | ScopeAlways);
|
||||
|
||||
INIT_ASSET(Material);
|
||||
mMatInstance = NULL;
|
||||
|
||||
mIsVBDirty = false;
|
||||
|
|
@ -117,7 +116,9 @@ void SkyBox::initPersistFields()
|
|||
docsURL;
|
||||
addGroup( "Sky Box" );
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(Material, SkyBox, "The name of a cubemap material for the sky box.");
|
||||
ADD_FIELD( "materialAsset", TypeMaterialAssetRef, Offset( mMaterialAssetRef, SkyBox ) )
|
||||
.network(-1)
|
||||
.doc( "The material asset for a cubemap material for the sky box." );
|
||||
|
||||
addField( "drawBottom", TypeBool, Offset( mDrawBottom, SkyBox ),
|
||||
"If false the bottom of the skybox is not rendered." );
|
||||
|
|
@ -140,7 +141,7 @@ U32 SkyBox::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
|
|||
{
|
||||
U32 retMask = Parent::packUpdate( conn, mask, stream );
|
||||
|
||||
PACK_ASSET(conn, Material);
|
||||
AssetDatabase.packDataAsset( stream, mMaterialAssetRef.getAssetId() );
|
||||
|
||||
stream->writeFlag( mDrawBottom );
|
||||
stream->write( mFogBandHeight );
|
||||
|
|
@ -152,9 +153,9 @@ void SkyBox::unpackUpdate( NetConnection *conn, BitStream *stream )
|
|||
{
|
||||
Parent::unpackUpdate( conn, stream );
|
||||
|
||||
StringTableEntry oldMatName = getMaterial();
|
||||
UNPACK_ASSET(conn, Material);
|
||||
if (oldMatName != getMaterial())
|
||||
StringTableEntry oldMatId = mMaterialAssetRef.getAssetId();
|
||||
mMaterialAssetRef = AssetDatabase.unpackDataAsset( stream );
|
||||
if ( oldMatId != mMaterialAssetRef.getAssetId() )
|
||||
{
|
||||
_updateMaterial();
|
||||
}
|
||||
|
|
@ -594,8 +595,8 @@ void SkyBox::_initMaterial()
|
|||
if ( mMatInstance )
|
||||
SAFE_DELETE( mMatInstance );
|
||||
|
||||
if ( mMaterial )
|
||||
mMatInstance = mMaterial->createMatInstance();
|
||||
if (mMaterialAssetRef.notNull())
|
||||
mMatInstance = mMaterialAssetRef.assetPtr->getMaterial()->createMatInstance();
|
||||
else
|
||||
mMatInstance = MATMGR->createMatInstance( "WarningMaterial" );
|
||||
|
||||
|
|
@ -621,21 +622,13 @@ void SkyBox::_initMaterial()
|
|||
|
||||
void SkyBox::_updateMaterial()
|
||||
{
|
||||
if (!getMaterialResource().isValid())
|
||||
{
|
||||
//If our materialDef isn't valid, try setting it
|
||||
_setMaterial(getMaterial());
|
||||
}
|
||||
|
||||
if (getMaterialResource().isValid())
|
||||
{
|
||||
if (mMaterialAssetRef.notNull())
|
||||
_initMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
BaseMatInstance* SkyBox::_getMaterialInstance()
|
||||
{
|
||||
if ( !mMaterial || !mMatInstance || mMatInstance->getMaterial() != mMaterial )
|
||||
if (!mMaterialAssetRef.notNull() || !mMatInstance || mMatInstance->getMaterial() != mMaterialAssetRef.assetPtr->getMaterial().getPointer())
|
||||
_initMaterial();
|
||||
|
||||
if ( !mMatInstance )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue