mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +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
|
|
@ -288,8 +288,6 @@ DecalRoad::DecalRoad()
|
|||
mTypeMask |= StaticObjectType | StaticShapeObjectType;
|
||||
mNetFlags.set(Ghostable);
|
||||
|
||||
INIT_ASSET(Material);
|
||||
|
||||
mMaterialInst = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +305,9 @@ void DecalRoad::initPersistFields()
|
|||
docsURL;
|
||||
addGroup( "DecalRoad" );
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(Material, DecalRoad, "Material used for rendering.");
|
||||
ADD_FIELD( "materialAsset", TypeMaterialAssetRef, Offset( mMaterialAssetRef, DecalRoad ) )
|
||||
.network( DecalRoadMask )
|
||||
.doc( "Material asset used for rendering." );
|
||||
|
||||
addProtectedFieldV("textureLength", TypeRangedF32, Offset(mTextureLength, DecalRoad), &DecalRoad::ptSetTextureLength, &defaultProtectedGetFn, &drTextureLengthV,
|
||||
"The length in meters of textures mapped to the DecalRoad" );
|
||||
|
|
@ -522,8 +522,7 @@ U32 DecalRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
|
|||
|
||||
if ( stream->writeFlag( mask & DecalRoadMask ) )
|
||||
{
|
||||
// Write Texture Name.
|
||||
PACK_ASSET(con, Material);
|
||||
AssetDatabase.packDataAsset( stream, mMaterialAssetRef.getAssetId() );
|
||||
|
||||
stream->write( mBreakAngle );
|
||||
|
||||
|
|
@ -612,7 +611,7 @@ void DecalRoad::unpackUpdate( NetConnection *con, BitStream *stream )
|
|||
// DecalRoadMask
|
||||
if ( stream->readFlag() )
|
||||
{
|
||||
UNPACK_ASSET(con, Material);
|
||||
mMaterialAssetRef = AssetDatabase.unpackDataAsset( stream );
|
||||
|
||||
if (isProperlyAdded())
|
||||
_initMaterial();
|
||||
|
|
@ -1078,29 +1077,21 @@ bool DecalRoad::addNodeFromField( void *object, const char *index, const char *d
|
|||
|
||||
void DecalRoad::_initMaterial()
|
||||
{
|
||||
_setMaterial(getMaterial());
|
||||
|
||||
if (mMaterialAsset.notNull())
|
||||
if (mMaterialAssetRef.notNull())
|
||||
{
|
||||
if (mMaterialInst && String(mMaterialAsset->getMaterialDefinitionName()).equal(mMaterialInst->getMaterial()->getName(), String::NoCase))
|
||||
if (mMaterialInst && String(mMaterialAssetRef.assetPtr->getMaterialName()).equal(mMaterialInst->getMaterial()->getName(), String::NoCase))
|
||||
return;
|
||||
|
||||
SAFE_DELETE(mMaterialInst);
|
||||
|
||||
Material* tMat = NULL;
|
||||
|
||||
if (!Sim::findObject(mMaterialAsset->getMaterialDefinitionName(), tMat))
|
||||
Con::errorf("DecalRoad::_initMaterial - Material %s was not found.", mMaterialAsset->getMaterialDefinitionName());
|
||||
|
||||
mMaterial = tMat;
|
||||
|
||||
if (mMaterial)
|
||||
mMaterialInst = mMaterial->createMatInstance();
|
||||
Material* tMat = mMaterialAssetRef.assetPtr->getMaterial();
|
||||
if (tMat)
|
||||
mMaterialInst = tMat->createMatInstance();
|
||||
else
|
||||
mMaterialInst = MATMGR->createMatInstance("WarningMaterial");
|
||||
|
||||
if (!mMaterialInst)
|
||||
Con::errorf("DecalRoad::_initMaterial - no Material called '%s'", mMaterialAsset->getMaterialDefinitionName());
|
||||
Con::errorf("DecalRoad::_initMaterial - no Material called '%s'", mMaterialAssetRef.assetPtr->getMaterialName());
|
||||
}
|
||||
|
||||
if (!mMaterialInst)
|
||||
|
|
|
|||
|
|
@ -246,8 +246,8 @@ protected:
|
|||
|
||||
BaseMatInstance* mMaterialInst;
|
||||
|
||||
DECLARE_MATERIALASSET(DecalRoad, Material);
|
||||
DECLARE_ASSET_NET_SETGET(DecalRoad, Material, DecalRoadMask);
|
||||
AssetRef<MaterialAsset> mMaterialAssetRef;
|
||||
StringTableEntry getMaterialAssetId() const { return mMaterialAssetRef.getAssetId(); }
|
||||
|
||||
S16 mRenderPriority;
|
||||
|
||||
|
|
|
|||
|
|
@ -97,13 +97,9 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl()
|
|||
mHoverNodeColor( 255,255,255,255 ),
|
||||
mHasCopied( false )
|
||||
{
|
||||
INIT_ASSET(TopMaterial);
|
||||
INIT_ASSET(BottomMaterial);
|
||||
INIT_ASSET(SideMaterial);
|
||||
|
||||
mTopMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultTopMaterialAsset");
|
||||
mBottomMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultBottomMaterialAsset");
|
||||
mSideMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultSideMaterialAsset");
|
||||
mTopMaterialAssetRef = Con::getVariable( "$MeshRoadEditor::defaultTopMaterialAsset" );
|
||||
mBottomMaterialAssetRef = Con::getVariable( "$MeshRoadEditor::defaultBottomMaterialAsset" );
|
||||
mSideMaterialAssetRef = Con::getVariable( "$MeshRoadEditor::defaultSideMaterialAsset" );
|
||||
}
|
||||
|
||||
GuiMeshRoadEditorCtrl::~GuiMeshRoadEditorCtrl()
|
||||
|
|
@ -222,10 +218,10 @@ void GuiMeshRoadEditorCtrl::initPersistFields()
|
|||
addField( "SelectedSplineColor", TypeColorI, Offset( mSelectedSplineColor, GuiMeshRoadEditorCtrl ) );
|
||||
addField( "HoverNodeColor", TypeColorI, Offset( mHoverNodeColor, GuiMeshRoadEditorCtrl ) );
|
||||
addField( "isDirty", TypeBool, Offset( mIsDirty, GuiMeshRoadEditorCtrl ) );
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(TopMaterial, GuiMeshRoadEditorCtrl, "Default Material used by the Mesh Road Editor on upper surface road creation.");
|
||||
INITPERSISTFIELD_MATERIALASSET(BottomMaterial, GuiMeshRoadEditorCtrl, "Default Material used by the Mesh Road Editor on bottom surface road creation.");
|
||||
INITPERSISTFIELD_MATERIALASSET(SideMaterial, GuiMeshRoadEditorCtrl, "Default Material used by the Mesh Road Editor on side surface road creation.");
|
||||
|
||||
ADD_FIELD( "topMaterialAsset", TypeMaterialAssetRef, Offset( mTopMaterialAssetRef, GuiMeshRoadEditorCtrl ) ).doc( "Default material asset used by the Mesh Road Editor on upper surface road creation." );
|
||||
ADD_FIELD( "bottomMaterialAsset", TypeMaterialAssetRef, Offset( mBottomMaterialAssetRef, GuiMeshRoadEditorCtrl ) ).doc( "Default material asset used by the Mesh Road Editor on bottom surface road creation." );
|
||||
ADD_FIELD( "sideMaterialAsset", TypeMaterialAssetRef, Offset( mSideMaterialAssetRef, GuiMeshRoadEditorCtrl ) ).doc( "Default material asset used by the Mesh Road Editor on side surface road creation." );
|
||||
|
||||
//addField( "MoveNodeCursor", TYPEID< SimObject >(), Offset( mMoveNodeCursor, GuiMeshRoadEditorCtrl) );
|
||||
//addField( "AddNodeCursor", TYPEID< SimObject >(), Offset( mAddNodeCursor, GuiMeshRoadEditorCtrl) );
|
||||
|
|
@ -627,12 +623,12 @@ void GuiMeshRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
|
|||
|
||||
MeshRoad *newRoad = new MeshRoad;
|
||||
|
||||
if(mTopMaterialAsset.notNull())
|
||||
newRoad->_setTopMaterial(mTopMaterialAssetId);
|
||||
if (mBottomMaterialAsset.notNull())
|
||||
newRoad->_setBottomMaterial(mBottomMaterialAssetId);
|
||||
if (mSideMaterialAsset.notNull())
|
||||
newRoad->_setSideMaterial(mSideMaterialAssetId);
|
||||
if ( mTopMaterialAssetRef.notNull() )
|
||||
newRoad->mTopMaterialAssetRef = mTopMaterialAssetRef.getAssetId();
|
||||
if ( mBottomMaterialAssetRef.notNull() )
|
||||
newRoad->mBottomMaterialAssetRef = mBottomMaterialAssetRef.getAssetId();
|
||||
if ( mSideMaterialAssetRef.notNull() )
|
||||
newRoad->mSideMaterialAssetRef = mSideMaterialAssetRef.getAssetId();
|
||||
|
||||
newRoad->registerObject();
|
||||
|
||||
|
|
|
|||
|
|
@ -159,14 +159,9 @@ class GuiMeshRoadEditorCtrl : public EditTSCtrl
|
|||
bool mHasCopied;
|
||||
public:
|
||||
|
||||
DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, TopMaterial);
|
||||
DECLARE_ASSET_SETGET(GuiMeshRoadEditorCtrl, TopMaterial);
|
||||
|
||||
DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, BottomMaterial);
|
||||
DECLARE_ASSET_SETGET(GuiMeshRoadEditorCtrl, BottomMaterial);
|
||||
|
||||
DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, SideMaterial);
|
||||
DECLARE_ASSET_SETGET(GuiMeshRoadEditorCtrl, SideMaterial);
|
||||
AssetRef<MaterialAsset> mTopMaterialAssetRef;
|
||||
AssetRef<MaterialAsset> mBottomMaterialAssetRef;
|
||||
AssetRef<MaterialAsset> mSideMaterialAssetRef;
|
||||
};
|
||||
|
||||
class GuiMeshRoadEditorUndoAction : public UndoAction
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ GuiRoadEditorCtrl::GuiRoadEditorCtrl()
|
|||
mSavedDrag = false;
|
||||
mIsDirty = false;
|
||||
|
||||
mMaterialAssetId = Con::getVariable("$DecalRoadEditor::defaultMaterialAsset");
|
||||
mMaterialAssetRef = Con::getVariable( "$DecalRoadEditor::defaultMaterialAsset" );
|
||||
}
|
||||
|
||||
GuiRoadEditorCtrl::~GuiRoadEditorCtrl()
|
||||
|
|
@ -100,7 +100,7 @@ void GuiRoadEditorUndoAction::undo()
|
|||
return;
|
||||
|
||||
// Temporarily save the roads current data.
|
||||
String materialAssetId = road->mMaterialAssetId;
|
||||
StringTableEntry materialAssetId = road->getMaterialAssetId();
|
||||
F32 textureLength = road->mTextureLength;
|
||||
F32 breakAngle = road->mBreakAngle;
|
||||
F32 segmentsPerBatch = road->mSegmentsPerBatch;
|
||||
|
|
@ -108,7 +108,7 @@ void GuiRoadEditorUndoAction::undo()
|
|||
nodes.merge( road->mNodes );
|
||||
|
||||
// Restore the Road properties saved in the UndoAction
|
||||
road->_setMaterial(materialAssetId);
|
||||
road->mMaterialAssetRef = mMaterialAssetId;
|
||||
road->mBreakAngle = breakAngle;
|
||||
road->mSegmentsPerBatch = segmentsPerBatch;
|
||||
road->mTextureLength = textureLength;
|
||||
|
|
@ -165,7 +165,7 @@ void GuiRoadEditorCtrl::initPersistFields()
|
|||
addField( "HoverNodeColor", TypeColorI, Offset( mHoverNodeColor, GuiRoadEditorCtrl ) );
|
||||
addField( "isDirty", TypeBool, Offset( mIsDirty, GuiRoadEditorCtrl ) );
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(Material, GuiRoadEditorCtrl, "Default Material used by the Road Editor on road creation.");
|
||||
ADD_FIELD( "materialAsset", TypeMaterialAssetRef, Offset( mMaterialAssetRef, GuiRoadEditorCtrl ) ).doc( "Default material asset used by the Road Editor on road creation." );
|
||||
|
||||
//addField( "MoveNodeCursor", TYPEID< SimObject >(), Offset( mMoveNodeCursor, GuiRoadEditorCtrl) );
|
||||
//addField( "AddNodeCursor", TYPEID< SimObject >(), Offset( mAddNodeCursor, GuiRoadEditorCtrl) );
|
||||
|
|
@ -407,8 +407,8 @@ void GuiRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
|
|||
|
||||
DecalRoad *newRoad = new DecalRoad;
|
||||
|
||||
if (mMaterialAsset.notNull())
|
||||
newRoad->_setMaterial(mMaterialAssetId);
|
||||
if ( mMaterialAssetRef.notNull() )
|
||||
newRoad->mMaterialAssetRef = mMaterialAssetRef.getAssetId();
|
||||
|
||||
newRoad->registerObject();
|
||||
|
||||
|
|
@ -1029,7 +1029,7 @@ void GuiRoadEditorCtrl::submitUndo( const UTF8 *name )
|
|||
|
||||
action->mObjId = mSelRoad->getId();
|
||||
action->mBreakAngle = mSelRoad->mBreakAngle;
|
||||
action->mMaterialAssetId = mSelRoad->mMaterialAssetId;
|
||||
action->mMaterialAssetId = mSelRoad->getMaterialAssetId();
|
||||
action->mSegmentsPerBatch = mSelRoad->mSegmentsPerBatch;
|
||||
action->mTextureLength = mSelRoad->mTextureLength;
|
||||
action->mRoadEditor = this;
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ class GuiRoadEditorCtrl : public EditTSCtrl
|
|||
|
||||
public:
|
||||
|
||||
DECLARE_MATERIALASSET(GuiRoadEditorCtrl, Material);
|
||||
DECLARE_ASSET_SETGET(GuiRoadEditorCtrl, Material);
|
||||
AssetRef<MaterialAsset> mMaterialAssetRef;
|
||||
StringTableEntry getMaterialAssetId() const { return mMaterialAssetRef.getAssetId(); }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
|
|
@ -920,10 +920,6 @@ MeshRoad::MeshRoad()
|
|||
mTriangleCount[i] = 0;
|
||||
}
|
||||
|
||||
INIT_ASSET(TopMaterial);
|
||||
INIT_ASSET(BottomMaterial);
|
||||
INIT_ASSET(SideMaterial);
|
||||
|
||||
mSideProfile.mRoad = this;
|
||||
}
|
||||
|
||||
|
|
@ -939,9 +935,15 @@ void MeshRoad::initPersistFields()
|
|||
docsURL;
|
||||
addGroup( "MeshRoad" );
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(TopMaterial, MeshRoad, "Material for the upper surface of the road.");
|
||||
INITPERSISTFIELD_MATERIALASSET(BottomMaterial, MeshRoad, "Material for the bottom surface of the road.");
|
||||
INITPERSISTFIELD_MATERIALASSET(SideMaterial, MeshRoad, "Material for the side surface of the road.");
|
||||
ADD_FIELD( "topMaterialAsset", TypeMaterialAssetRef, Offset( mTopMaterialAssetRef, MeshRoad ) )
|
||||
.network( MeshRoadMask )
|
||||
.doc( "Material asset for the upper surface of the road." );
|
||||
ADD_FIELD( "bottomMaterialAsset", TypeMaterialAssetRef, Offset( mBottomMaterialAssetRef, MeshRoad ) )
|
||||
.network( MeshRoadMask )
|
||||
.doc( "Material asset for the bottom surface of the road." );
|
||||
ADD_FIELD( "sideMaterialAsset", TypeMaterialAssetRef, Offset( mSideMaterialAssetRef, MeshRoad ) )
|
||||
.network( MeshRoadMask )
|
||||
.doc( "Material asset for the side surface of the road." );
|
||||
|
||||
addFieldV( "textureLength", TypeRangedF32, Offset( mTextureLength, MeshRoad ), &mrTextureLengthV,
|
||||
"The length in meters of textures mapped to the MeshRoad." );
|
||||
|
|
@ -1320,18 +1322,12 @@ void MeshRoad::prepRenderImage( SceneRenderState* state )
|
|||
|
||||
void MeshRoad::_initMaterial()
|
||||
{
|
||||
if (mTopMaterialAsset.notNull())
|
||||
if (mTopMaterialAssetRef.notNull())
|
||||
{
|
||||
if (!mMatInst[Top] || !String(mTopMaterialAsset->getMaterialDefinitionName()).equal(mMatInst[Top]->getMaterial()->getName(), String::NoCase))
|
||||
if (!mMatInst[Top] || !String(mTopMaterialAssetRef.assetPtr->getMaterialName()).equal(mMatInst[Top]->getMaterial()->getName(), String::NoCase))
|
||||
{
|
||||
SAFE_DELETE(mMatInst[Top]);
|
||||
|
||||
Material* tMat = NULL;
|
||||
if (!Sim::findObject(mTopMaterialAsset->getMaterialDefinitionName(), tMat))
|
||||
Con::errorf("MeshRoad::_initMaterial - Material %s was not found.", mTopMaterialAsset->getMaterialDefinitionName());
|
||||
|
||||
mMaterial[Top] = tMat;
|
||||
|
||||
mMaterial[Top] = mTopMaterialAssetRef.assetPtr->getMaterial();
|
||||
if (mMaterial[Top])
|
||||
mMatInst[Top] = mMaterial[Top]->createMatInstance();
|
||||
else
|
||||
|
|
@ -1341,19 +1337,12 @@ void MeshRoad::_initMaterial()
|
|||
}
|
||||
}
|
||||
|
||||
if (mBottomMaterialAsset.notNull())
|
||||
if (mBottomMaterialAssetRef.notNull())
|
||||
{
|
||||
if (!mMatInst[Bottom] || !String(mBottomMaterialAsset->getMaterialDefinitionName()).equal(mMatInst[Bottom]->getMaterial()->getName(), String::NoCase))
|
||||
if (!mMatInst[Bottom] || !String(mBottomMaterialAssetRef.assetPtr->getMaterialName()).equal(mMatInst[Bottom]->getMaterial()->getName(), String::NoCase))
|
||||
{
|
||||
|
||||
SAFE_DELETE(mMatInst[Bottom]);
|
||||
|
||||
Material* tMat = NULL;
|
||||
if (!Sim::findObject(mBottomMaterialAsset->getMaterialDefinitionName(), tMat))
|
||||
Con::errorf("MeshRoad::_initMaterial - Material %s was not found.", mBottomMaterialAsset->getMaterialDefinitionName());
|
||||
|
||||
mMaterial[Bottom] = tMat;
|
||||
|
||||
mMaterial[Bottom] = mBottomMaterialAssetRef.assetPtr->getMaterial();
|
||||
if (mMaterial[Bottom])
|
||||
mMatInst[Bottom] = mMaterial[Bottom]->createMatInstance();
|
||||
else
|
||||
|
|
@ -1363,18 +1352,12 @@ void MeshRoad::_initMaterial()
|
|||
}
|
||||
}
|
||||
|
||||
if (mSideMaterialAsset.notNull())
|
||||
if (mSideMaterialAssetRef.notNull())
|
||||
{
|
||||
if (!mMatInst[Side] || !String(mSideMaterialAsset->getMaterialDefinitionName()).equal(mMatInst[Side]->getMaterial()->getName(), String::NoCase))
|
||||
if (!mMatInst[Side] || !String(mSideMaterialAssetRef.assetPtr->getMaterialName()).equal(mMatInst[Side]->getMaterial()->getName(), String::NoCase))
|
||||
{
|
||||
SAFE_DELETE(mMatInst[Side]);
|
||||
|
||||
Material* tMat = NULL;
|
||||
if (!Sim::findObject(mSideMaterialAsset->getMaterialDefinitionName(), tMat))
|
||||
Con::errorf("MeshRoad::_initMaterial - Material %s was not found.", mSideMaterialAsset->getMaterialDefinitionName());
|
||||
|
||||
mMaterial[Side] = tMat;
|
||||
|
||||
mMaterial[Side] = mSideMaterialAssetRef.assetPtr->getMaterial();
|
||||
if (mMaterial[Side])
|
||||
mMatInst[Side] = mMaterial[Side]->createMatInstance();
|
||||
else
|
||||
|
|
@ -1472,9 +1455,9 @@ U32 MeshRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
|
|||
stream->writeAffineTransform( mObjToWorld );
|
||||
|
||||
// Write Materials
|
||||
PACK_ASSET(con, TopMaterial);
|
||||
PACK_ASSET(con, BottomMaterial);
|
||||
PACK_ASSET(con, SideMaterial);
|
||||
AssetDatabase.packDataAsset( stream, mTopMaterialAssetRef.getAssetId() );
|
||||
AssetDatabase.packDataAsset( stream, mBottomMaterialAssetRef.getAssetId() );
|
||||
AssetDatabase.packDataAsset( stream, mSideMaterialAssetRef.getAssetId() );
|
||||
|
||||
stream->write( mTextureLength );
|
||||
stream->write( mBreakAngle );
|
||||
|
|
@ -1571,9 +1554,9 @@ void MeshRoad::unpackUpdate(NetConnection * con, BitStream * stream)
|
|||
stream->readAffineTransform(&ObjectMatrix);
|
||||
Parent::setTransform(ObjectMatrix);
|
||||
|
||||
UNPACK_ASSET(con, TopMaterial);
|
||||
UNPACK_ASSET(con, BottomMaterial);
|
||||
UNPACK_ASSET(con, SideMaterial);
|
||||
mTopMaterialAssetRef = AssetDatabase.unpackDataAsset( stream );
|
||||
mBottomMaterialAssetRef = AssetDatabase.unpackDataAsset( stream );
|
||||
mSideMaterialAssetRef = AssetDatabase.unpackDataAsset( stream );
|
||||
|
||||
if ( isProperlyAdded() )
|
||||
_initMaterial();
|
||||
|
|
|
|||
|
|
@ -625,14 +625,9 @@ protected:
|
|||
GFXVertexBufferHandle<GFXVertexPNTT> mVB[SurfaceCount];
|
||||
GFXPrimitiveBufferHandle mPB[SurfaceCount];
|
||||
|
||||
DECLARE_MATERIALASSET(MeshRoad, TopMaterial);
|
||||
DECLARE_ASSET_NET_SETGET(MeshRoad, TopMaterial, MeshRoadMask);
|
||||
|
||||
DECLARE_MATERIALASSET(MeshRoad, BottomMaterial);
|
||||
DECLARE_ASSET_NET_SETGET(MeshRoad, BottomMaterial, MeshRoadMask);
|
||||
|
||||
DECLARE_MATERIALASSET(MeshRoad, SideMaterial);
|
||||
DECLARE_ASSET_NET_SETGET(MeshRoad, SideMaterial, MeshRoadMask);
|
||||
AssetRef<MaterialAsset> mTopMaterialAssetRef;
|
||||
AssetRef<MaterialAsset> mBottomMaterialAssetRef;
|
||||
AssetRef<MaterialAsset> mSideMaterialAssetRef;
|
||||
|
||||
//String mMaterialName[SurfaceCount];
|
||||
SimObjectPtr<Material> mMaterial[SurfaceCount];
|
||||
|
|
|
|||
|
|
@ -170,7 +170,6 @@ ScatterSky::ScatterSky()
|
|||
mNightCubemapName = StringTable->EmptyString();
|
||||
mSunSize = 1.0f;
|
||||
|
||||
INIT_ASSET(MoonMat);
|
||||
|
||||
mMoonMatInst = NULL;
|
||||
|
||||
|
|
@ -413,7 +412,9 @@ void ScatterSky::initPersistFields()
|
|||
addField( "moonEnabled", TypeBool, Offset( mMoonEnabled, ScatterSky ),
|
||||
"Enable or disable rendering of the moon sprite during night." );
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(MoonMat, ScatterSky, "Material for the moon sprite.");
|
||||
ADD_FIELD( "moonMatAsset", TypeMaterialAssetRef, Offset( mMoonMatAssetRef, ScatterSky ) )
|
||||
.network( UpdateMask )
|
||||
.doc( "Material asset for the moon sprite." );
|
||||
|
||||
addFieldV( "moonScale", TypeRangedF32, Offset( mMoonScale, ScatterSky ), &CommonValidators::PositiveFloat,
|
||||
"Controls size the moon sprite renders, specified as a fractional amount of the screen height." );
|
||||
|
|
@ -506,7 +507,7 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
|||
|
||||
stream->writeFlag( mMoonEnabled );
|
||||
|
||||
PACK_ASSET(con, MoonMat);
|
||||
AssetDatabase.packDataAsset( stream, mMoonMatAssetRef.getAssetId() );
|
||||
|
||||
stream->write( mMoonScale );
|
||||
stream->write( mMoonTint );
|
||||
|
|
@ -620,7 +621,7 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
|
||||
mMoonEnabled = stream->readFlag();
|
||||
|
||||
UNPACK_ASSET(con, MoonMat);
|
||||
mMoonMatAssetRef = AssetDatabase.unpackDataAsset( stream );
|
||||
|
||||
stream->read( &mMoonScale );
|
||||
stream->read( &mMoonTint );
|
||||
|
|
@ -914,14 +915,14 @@ void ScatterSky::_initMoon()
|
|||
if ( mMoonMatInst )
|
||||
SAFE_DELETE( mMoonMatInst );
|
||||
|
||||
if (mMoonMatAsset.notNull())
|
||||
if (mMoonMatAssetRef.notNull())
|
||||
{
|
||||
FeatureSet features = MATMGR->getDefaultFeatures();
|
||||
features.removeFeature(MFT_RTLighting);
|
||||
features.removeFeature(MFT_Visibility);
|
||||
features.removeFeature(MFT_ReflectionProbes);
|
||||
features.addFeature(MFT_isBackground);
|
||||
mMoonMatInst = MATMGR->createMatInstance(mMoonMatAsset->getMaterialDefinitionName(), features, getGFXVertexFormat<GFXVertexPCT>());
|
||||
mMoonMatInst = MATMGR->createMatInstance(mMoonMatAssetRef.assetPtr->getMaterialName(), features, getGFXVertexFormat<GFXVertexPCT>());
|
||||
|
||||
GFXStateBlockDesc desc;
|
||||
desc.setBlend(true);
|
||||
|
|
|
|||
|
|
@ -233,8 +233,7 @@ protected:
|
|||
|
||||
bool mMoonEnabled;
|
||||
|
||||
DECLARE_MATERIALASSET(ScatterSky, MoonMat);
|
||||
DECLARE_ASSET_NET_SETGET(ScatterSky, MoonMat, UpdateMask);
|
||||
AssetRef<MaterialAsset> mMoonMatAssetRef;
|
||||
|
||||
BaseMatInstance *mMoonMatInst;
|
||||
F32 mMoonScale;
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
|
|
@ -102,8 +102,7 @@ public:
|
|||
protected:
|
||||
|
||||
// Material
|
||||
DECLARE_MATERIALASSET(SkyBox, Material);
|
||||
DECLARE_ASSET_NET_SETGET(SkyBox, Material, -1);
|
||||
AssetRef<MaterialAsset> mMaterialAssetRef;
|
||||
|
||||
BaseMatInstance *mMatInstance;
|
||||
SkyMatParams mMatParamHandle;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ SkySphere::SkySphere()
|
|||
mTypeMask |= EnvironmentObjectType | StaticObjectType;
|
||||
mNetFlags.set(Ghostable | ScopeAlways);
|
||||
|
||||
INIT_ASSET(Material);
|
||||
mMatInstance = NULL;
|
||||
|
||||
mIsVBDirty = false;
|
||||
|
|
@ -116,7 +115,9 @@ void SkySphere::initPersistFields()
|
|||
docsURL;
|
||||
addGroup("Sky Sphere");
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(Material, SkySphere, "The name of a cubemap material for the sky box.");
|
||||
ADD_FIELD( "materialAsset", TypeMaterialAssetRef, Offset( mMaterialAssetRef, SkySphere ) )
|
||||
.network(-1)
|
||||
.doc( "The material asset of a cubemap for the sky box." );
|
||||
|
||||
addFieldV("fogBandHeight", TypeRangedF32, Offset(mFogBandHeight, SkySphere), &CommonValidators::NormalizedFloat,
|
||||
"The height (0-1) of the fog band from the horizon to the top of the SkySphere.");
|
||||
|
|
@ -136,7 +137,7 @@ U32 SkySphere::packUpdate(NetConnection* conn, U32 mask, BitStream* stream)
|
|||
{
|
||||
U32 retMask = Parent::packUpdate(conn, mask, stream);
|
||||
|
||||
PACK_ASSET(conn, Material);
|
||||
AssetDatabase.packDataAsset( stream, mMaterialAssetRef.getAssetId() );
|
||||
|
||||
stream->write(mFogBandHeight);
|
||||
|
||||
|
|
@ -147,9 +148,9 @@ void SkySphere::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();
|
||||
}
|
||||
|
|
@ -589,8 +590,8 @@ void SkySphere::_initMaterial()
|
|||
if (mMatInstance)
|
||||
SAFE_DELETE(mMatInstance);
|
||||
|
||||
if (mMaterial)
|
||||
mMatInstance = mMaterial->createMatInstance();
|
||||
if (mMaterialAssetRef.notNull())
|
||||
mMatInstance = mMaterialAssetRef.assetPtr->getMaterial()->createMatInstance();
|
||||
else
|
||||
mMatInstance = MATMGR->createMatInstance("WarningMaterial");
|
||||
|
||||
|
|
@ -615,21 +616,13 @@ void SkySphere::_initMaterial()
|
|||
|
||||
void SkySphere::_updateMaterial()
|
||||
{
|
||||
if (!getMaterialResource().isValid())
|
||||
{
|
||||
//If our materialDef isn't valid, try setting it
|
||||
_setMaterial(getMaterial());
|
||||
}
|
||||
|
||||
if (getMaterialResource().isValid())
|
||||
{
|
||||
if (mMaterialAssetRef.notNull())
|
||||
_initMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
BaseMatInstance* SkySphere::_getMaterialInstance()
|
||||
{
|
||||
if (!mMaterial || !mMatInstance || mMatInstance->getMaterial() != mMaterial)
|
||||
if (!mMaterialAssetRef.notNull() || !mMatInstance || mMatInstance->getMaterial() != mMaterialAssetRef.assetPtr->getMaterial().getPointer())
|
||||
_initMaterial();
|
||||
|
||||
if (!mMatInstance)
|
||||
|
|
|
|||
|
|
@ -142,8 +142,7 @@ public:
|
|||
protected:
|
||||
|
||||
// Material
|
||||
DECLARE_MATERIALASSET(SkySphere, Material);
|
||||
DECLARE_ASSET_NET_SETGET(SkySphere, Material, -1);
|
||||
AssetRef<MaterialAsset> mMaterialAssetRef;
|
||||
|
||||
BaseMatInstance* mMatInstance;
|
||||
SkyMatParams mMatParamHandle;
|
||||
|
|
|
|||
|
|
@ -91,8 +91,6 @@ Sun::Sun()
|
|||
mCoronaUseLightColor = true;
|
||||
mCoronaMatInst = NULL;
|
||||
|
||||
INIT_ASSET(CoronaMaterial);
|
||||
|
||||
mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16));
|
||||
constructInPlace(mMatrixSet);
|
||||
|
||||
|
|
@ -181,7 +179,9 @@ void Sun::initPersistFields()
|
|||
addField( "coronaEnabled", TypeBool, Offset( mCoronaEnabled, Sun ),
|
||||
"Enable or disable rendering of the corona sprite." );
|
||||
|
||||
INITPERSISTFIELD_MATERIALASSET(CoronaMaterial, Sun, "Material for the corona sprite.");
|
||||
ADD_FIELD( "coronaMaterialAsset", TypeMaterialAssetRef, Offset( mCoronaMaterialAssetRef, Sun ) )
|
||||
.network( UpdateMask )
|
||||
.doc( "Material asset for the corona sprite." );
|
||||
|
||||
addFieldV( "coronaScale", TypeRangedF32, Offset( mCoronaScale, Sun ), &CommonValidators::PositiveFloat,
|
||||
"Controls size the corona sprite renders, specified as a fractional amount of the screen height." );
|
||||
|
|
@ -242,7 +242,7 @@ U32 Sun::packUpdate(NetConnection *conn, U32 mask, BitStream *stream )
|
|||
|
||||
stream->writeFlag( mCoronaEnabled );
|
||||
|
||||
PACK_ASSET(conn, CoronaMaterial);
|
||||
AssetDatabase.packDataAsset( stream, mCoronaMaterialAssetRef.getAssetId() );
|
||||
|
||||
stream->write( mCoronaScale );
|
||||
stream->write( mCoronaTint );
|
||||
|
|
@ -288,7 +288,7 @@ void Sun::unpackUpdate( NetConnection *conn, BitStream *stream )
|
|||
|
||||
mCoronaEnabled = stream->readFlag();
|
||||
|
||||
UNPACK_ASSET(conn, CoronaMaterial);
|
||||
mCoronaMaterialAssetRef = AssetDatabase.unpackDataAsset( stream );
|
||||
|
||||
stream->read( &mCoronaScale );
|
||||
stream->read( &mCoronaTint );
|
||||
|
|
@ -453,7 +453,7 @@ void Sun::_initCorona()
|
|||
|
||||
SAFE_DELETE( mCoronaMatInst );
|
||||
|
||||
if (mCoronaMaterialAsset.notNull())
|
||||
if (mCoronaMaterialAssetRef.notNull())
|
||||
{
|
||||
FeatureSet features = MATMGR->getDefaultFeatures();
|
||||
features.removeFeature(MFT_RTLighting);
|
||||
|
|
@ -462,7 +462,7 @@ void Sun::_initCorona()
|
|||
features.addFeature(MFT_isBackground);
|
||||
features.addFeature(MFT_VertLit);
|
||||
|
||||
mCoronaMatInst = MATMGR->createMatInstance(mCoronaMaterialAsset->getMaterialDefinitionName(), features, getGFXVertexFormat<GFXVertexPCT>());
|
||||
mCoronaMatInst = MATMGR->createMatInstance(mCoronaMaterialAssetRef.assetPtr->getMaterialName(), features, getGFXVertexFormat<GFXVertexPCT>());
|
||||
|
||||
GFXStateBlockDesc desc;
|
||||
desc.setBlend(true);
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ protected:
|
|||
|
||||
bool mCoronaEnabled;
|
||||
|
||||
DECLARE_MATERIALASSET(Sun, CoronaMaterial);
|
||||
DECLARE_ASSET_NET_SETGET(Sun, CoronaMaterial, UpdateMask);
|
||||
AssetRef<MaterialAsset> mCoronaMaterialAssetRef;
|
||||
|
||||
BaseMatInstance *mCoronaMatInst;
|
||||
MatrixSet *mMatrixSet;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue