mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
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:
parent
83b0432283
commit
5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
#include "console/dynamicTypes.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/MaterialAsset.h"
|
||||
|
||||
GFXDeclareVertexFormat( DecalVertex )
|
||||
{
|
||||
// .xyz = coords
|
||||
|
|
@ -75,11 +77,8 @@ class DecalData : public SimDataBlock
|
|||
F32 fadeStartPixelSize;
|
||||
F32 fadeEndPixelSize;
|
||||
|
||||
/// Name of material to use.
|
||||
String materialName;
|
||||
|
||||
/// Render material for decal.
|
||||
SimObjectPtr<Material> material;
|
||||
DECLARE_MATERIALASSET(DecalData, Material);
|
||||
DECLARE_MATERIALASSET_SETGET(DecalData, Material);
|
||||
|
||||
/// Material instance for decal.
|
||||
BaseMatInstance *matInst;
|
||||
|
|
@ -113,7 +112,7 @@ class DecalData : public SimDataBlock
|
|||
virtual void packData( BitStream* );
|
||||
virtual void unpackData( BitStream* );
|
||||
|
||||
Material* getMaterial();
|
||||
Material* getMaterialDefinition();
|
||||
BaseMatInstance* getMaterialInstance();
|
||||
|
||||
static SimSet* getSet();
|
||||
|
|
|
|||
|
|
@ -206,8 +206,8 @@ bool DecalDataFile::read( Stream &stream )
|
|||
data->lookupName = name;
|
||||
data->registerObject(name);
|
||||
Sim::getRootGroup()->addObject( data );
|
||||
data->materialName = "WarningMaterial";
|
||||
data->material = dynamic_cast<Material*>(Sim::findObject("WarningMaterial"));
|
||||
data->mMaterialName = "WarningMaterial";
|
||||
data->mMaterial = dynamic_cast<Material*>(Sim::findObject("WarningMaterial"));
|
||||
|
||||
Con::errorf( "DecalDataFile::read() - DecalData %s does not exist! Temporarily created %s_missing.", lookupName.c_str(), lookupName.c_str());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ S32 QSORT_CALLBACK cmpDecalRenderOrder( const void *p1, const void *p2 )
|
|||
|
||||
if ( (*pd2)->mFlags & SaveDecal )
|
||||
{
|
||||
S32 id = ( (*pd1)->mDataBlock->getMaterial()->getId() - (*pd2)->mDataBlock->getMaterial()->getId() );
|
||||
S32 id = ( (*pd1)->mDataBlock->getMaterialDefinition()->getId() - (*pd2)->mDataBlock->getMaterialDefinition()->getId() );
|
||||
if ( id != 0 )
|
||||
return id;
|
||||
|
||||
|
|
@ -1225,7 +1225,7 @@ void DecalManager::prepRenderImage( SceneRenderState* state )
|
|||
{
|
||||
DecalInstance *decal = mDecalQueue[i];
|
||||
DecalData *data = decal->mDataBlock;
|
||||
Material *mat = data->getMaterial();
|
||||
Material *mat = data->getMaterialDefinition();
|
||||
|
||||
if ( currentBatch == NULL )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue