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

@ -458,9 +458,9 @@ GroundCover::GroundCover()
mRandomSeed = 1;
initMaterialAsset(Material);
INIT_MATERIALASSET(Material);
mMaterialInst = NULL;
mMatInst = NULL;
mMatParams = NULL;
mTypeRectsParam = NULL;
mFadeParams = NULL;
@ -519,7 +519,8 @@ GroundCover::GroundCover()
mBillboardRects[i].point.set( 0.0f, 0.0f );
mBillboardRects[i].extent.set( 1.0f, 1.0f );
mShapeFilenames[i] = NULL;
INIT_SHAPEASSET_ARRAY(Shape, i);
mShapeInstances[i] = NULL;
mBillboardAspectScales[i] = 1.0f;
@ -530,7 +531,7 @@ GroundCover::GroundCover()
GroundCover::~GroundCover()
{
SAFE_DELETE( mMatInst );
SAFE_DELETE( mMaterialInst );
}
IMPLEMENT_CO_NETOBJECT_V1(GroundCover);
@ -539,7 +540,7 @@ void GroundCover::initPersistFields()
{
addGroup( "GroundCover General" );
scriptBindMaterialAsset(Material, GroundCover, "Material used by all GroundCover segments.");
INITPERSISTFIELD_MATERIALASSET(Material, GroundCover, "Material used by all GroundCover segments.");
addField( "radius", TypeF32, Offset( mRadius, GroundCover ), "Outer generation radius from the current camera position." );
addField( "dissolveRadius",TypeF32, Offset( mFadeRadius, GroundCover ), "This is less than or equal to radius and defines when fading of cover elements begins." );
@ -559,7 +560,8 @@ void GroundCover::initPersistFields()
addField( "billboardUVs", TypeRectUV, Offset( mBillboardRects, GroundCover ), MAX_COVERTYPES, "Subset material UV coordinates for this cover billboard." );
addField( "shapeFilename", TypeFilename, Offset( mShapeFilenames, GroundCover ), MAX_COVERTYPES, "The cover shape filename. [Optional]" );
INITPERSISTFIELD_SHAPEASSET_ARRAY(Shape, GroundCover, "The cover shape. [Optional]");
addField( "shapeFilename", TypeFilename, Offset( mShapeName, GroundCover ), MAX_COVERTYPES, "The cover shape filename. [Optional]", AbstractClassRep::FIELD_HideInInspectors );
addField( "layer", TypeTerrainMaterialName, Offset( mLayer, GroundCover ), MAX_COVERTYPES, "Terrain material name to limit coverage to, or blank to not limit." );
@ -710,7 +712,7 @@ U32 GroundCover::packUpdate( NetConnection *connection, U32 mask, BitStream *str
// TODO: We could probably optimize a few of these
// based on reasonable units at some point.
packMaterialAsset(connection, Material);
PACK_MATERIALASSET(connection, Material);
stream->write( mRadius );
stream->write( mZOffset );
@ -741,11 +743,11 @@ U32 GroundCover::packUpdate( NetConnection *connection, U32 mask, BitStream *str
stream->write( mMinSlope[i] );
stream->write( mMaxSlope[i] );
stream->writeFlag(mConformToNormal[i]);
stream->write(mMinRotX[i]);
stream->write(mMaxRotX[i]);
stream->write(mMinRotY[i]);
stream->write(mMaxRotY[i]);
stream->writeFlag(mConformToNormal[i]);
stream->write(mMinRotX[i]);
stream->write(mMaxRotX[i]);
stream->write(mMinRotY[i]);
stream->write(mMaxRotY[i]);
stream->write( mMinElevation[i] );
stream->write( mMaxElevation[i] );
@ -763,7 +765,7 @@ U32 GroundCover::packUpdate( NetConnection *connection, U32 mask, BitStream *str
stream->write( mBillboardRects[i].extent.x );
stream->write( mBillboardRects[i].extent.y );
stream->writeString( mShapeFilenames[i] );
PACK_SHAPEASSET_ARRAY(connection, Shape, i);
}
stream->writeFlag( mDebugRenderCells );
@ -781,7 +783,7 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
if (stream->readFlag())
{
unpackMaterialAsset(connection, Material);
UNPACK_MATERIALASSET(connection, Material);
stream->read( &mRadius );
stream->read( &mZOffset );
@ -812,11 +814,11 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
stream->read( &mMinSlope[i] );
stream->read( &mMaxSlope[i] );
mConformToNormal[i] = stream->readFlag();
stream->read(&mMinRotX[i]);
stream->read(&mMaxRotX[i]);
stream->read(&mMinRotY[i]);
stream->read(&mMaxRotY[i]);
mConformToNormal[i] = stream->readFlag();
stream->read(&mMinRotX[i]);
stream->read(&mMaxRotX[i]);
stream->read(&mMinRotY[i]);
stream->read(&mMaxRotY[i]);
stream->read( &mMinElevation[i] );
stream->read( &mMaxElevation[i] );
@ -834,7 +836,7 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
stream->read( &mBillboardRects[i].extent.x );
stream->read( &mBillboardRects[i].extent.y );
mShapeFilenames[i] = stream->readSTString();
UNPACK_SHAPEASSET_ARRAY(connection, Shape, i);
}
mDebugRenderCells = stream->readFlag();
@ -854,28 +856,8 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
void GroundCover::_initMaterial()
{
if (mMaterialAsset.notNull())
{
if (mMatInst && String(mMaterialAsset->getMaterialDefinitionName()).equal(mMatInst->getMaterial()->getName(), String::NoCase))
return;
SAFE_DELETE(mMatInst);
if (!Sim::findObject(mMaterialAsset->getMaterialDefinitionName(), mMaterial))
Con::errorf("GroundCover::_initMaterial - Material %s was not found.", mMaterialAsset->getMaterialDefinitionName());
if (mMaterial)
mMatInst = mMaterial->createMatInstance();
else
mMatInst = MATMGR->createMatInstance("WarningMaterial");
if (!mMatInst)
Con::errorf("GroundCover::_initMaterial - no Material called '%s'", mMaterialAsset->getMaterialDefinitionName());
}
else
{
if (!mMaterialInst)
return;
}
// Add our special feature that makes it all work...
FeatureSet features = MATMGR->getDefaultFeatures();
@ -883,10 +865,10 @@ void GroundCover::_initMaterial()
// Our feature requires a pointer back to this object
// to properly setup its shader consts.
mMatInst->setUserObject( this );
mMaterialInst->setUserObject( this );
// DO IT!
mMatInst->init( features, getGFXVertexFormat<GCVertex>() );
mMaterialInst->init( features, getGFXVertexFormat<GCVertex>() );
}
void GroundCover::_initShapes()
@ -895,25 +877,17 @@ void GroundCover::_initShapes()
for ( S32 i=0; i < MAX_COVERTYPES; i++ )
{
if ( !mShapeFilenames[i] || !mShapeFilenames[i][0] )
if ( mShapeAsset[i].isNull() || mShape[i] == nullptr)
continue;
// Load the shape.
Resource<TSShape> shape = ResourceManager::get().load(mShapeFilenames[i]);
if ( !(bool)shape )
if ( isClientObject() && !mShape[i]->preloadMaterialList(mShape[i].getPath()) && NetConnection::filesWereDownloaded() )
{
Con::warnf( "GroundCover::_initShapes() unable to load shape: %s", mShapeFilenames[i] );
continue;
}
if ( isClientObject() && !shape->preloadMaterialList(shape.getPath()) && NetConnection::filesWereDownloaded() )
{
Con::warnf( "GroundCover::_initShapes() material preload failed for shape: %s", mShapeFilenames[i] );
Con::warnf( "GroundCover::_initShapes() material preload failed for shape: %s", mShapeAssetId[i] );
continue;
}
// Create the shape instance.
mShapeInstances[i] = new TSShapeInstance( shape, isClientObject() );
mShapeInstances[i] = new TSShapeInstance(mShape[i], isClientObject() );
}
}
@ -982,16 +956,16 @@ void GroundCover::_initialize( U32 cellCount, U32 cellPlacementCount )
// Rebuild the texture aspect scales for each type.
F32 textureAspect = 1.0f;
if( mMatInst && mMatInst->isValid())
if( mMaterialInst && mMaterialInst->isValid())
{
Material* mat = dynamic_cast<Material*>(mMatInst->getMaterial());
Material* mat = dynamic_cast<Material*>(mMaterialInst->getMaterial());
if(mat)
{
GFXTexHandle tex;
if (!mat->mDiffuseMapFilename[0].isEmpty())
tex = GFXTexHandle(mat->mDiffuseMapFilename[0], &GFXStaticTextureSRGBProfile, "GroundCover texture aspect ratio check");
if (mat->mDiffuseMapName[0] != StringTable->EmptyString())
tex = GFXTexHandle(mat->mDiffuseMapName[0], &GFXStaticTextureSRGBProfile, "GroundCover texture aspect ratio check");
else if (!mat->mDiffuseMapAsset[0].isNull())
tex = mat->mDiffuseMapAsset[0]->getImage(GFXStaticTextureSRGBProfile);
tex = mat->mDiffuseMapAsset[0]->getTexture(&GFXStaticTextureSRGBProfile);
if(tex.isValid())
{
@ -1580,7 +1554,7 @@ void GroundCover::_updateCoverGrid( const Frustum &culler )
void GroundCover::prepRenderImage( SceneRenderState *state )
{
// Reset stats each time we hit the diffuse pass.
if (mMatInst == nullptr)
if (mMaterialInst == nullptr)
return;
if( state->isDiffusePass() )
@ -1617,7 +1591,7 @@ void GroundCover::prepRenderImage( SceneRenderState *state )
// Render billboards but not into shadow passes.
if ( !state->isShadowPass() && mMatInst->isValid() && !mDebugNoBillboards )
if ( !state->isShadowPass() && mMaterialInst->isValid() && !mDebugNoBillboards )
{
PROFILE_SCOPE( GroundCover_RenderBillboards );
@ -1692,7 +1666,7 @@ void GroundCover::prepRenderImage( SceneRenderState *state )
if ( mCuller.isCulled( cell->getRenderBounds() ) )
continue;
cell->renderBillboards( state, mMatInst, &mPrimBuffer );
cell->renderBillboards( state, mMaterialInst, &mPrimBuffer );
}
}