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

@ -59,11 +59,7 @@ RenderMeshExample::RenderMeshExample()
// Set it as a "static" object that casts shadows
mTypeMask |= StaticObjectType | StaticShapeObjectType;
// Make sure we the Material instance to NULL
// so we don't try to access it incorrectly
mMaterialInst = NULL;
initMaterialAsset(Material);
INIT_MATERIALASSET(Material);
}
RenderMeshExample::~RenderMeshExample()
@ -78,7 +74,7 @@ RenderMeshExample::~RenderMeshExample()
void RenderMeshExample::initPersistFields()
{
addGroup( "Rendering" );
scriptBindMaterialAsset(Material, RenderMeshExample, "The material used to render the mesh.");
INITPERSISTFIELD_MATERIALASSET(Material, RenderMeshExample, "The material used to render the mesh.");
endGroup( "Rendering" );
// SceneObject already handles exposing the transform
@ -147,7 +143,7 @@ U32 RenderMeshExample::packUpdate( NetConnection *conn, U32 mask, BitStream *str
// Write out any of the updated editable properties
if (stream->writeFlag(mask & UpdateMask))
{
packMaterialAsset(conn, Material);
PACK_MATERIALASSET(conn, Material);
}
return retMask;
@ -168,7 +164,7 @@ void RenderMeshExample::unpackUpdate(NetConnection *conn, BitStream *stream)
if ( stream->readFlag() ) // UpdateMask
{
unpackMaterialAsset(conn, Material);
UNPACK_MATERIALASSET(conn, Material);
if ( isProperlyAdded() )
updateMaterial();

View file

@ -64,18 +64,18 @@ class RenderMeshExample : public SceneObject
NextFreeMask = Parent::NextFreeMask << 2
};
//--------------------------------------------------------------------------
// Rendering variables
//--------------------------------------------------------------------------
DECLARE_NET_MATERIALASSET(RenderMeshExample, Material, UpdateMask);
// The actual Material instance
BaseMatInstance* mMaterialInst;
// Define our vertex format here so we don't have to
// change it in multiple spots later
typedef GFXVertexPNT VertexType;
//--------------------------------------------------------------------------
// Rendering variables
//--------------------------------------------------------------------------
BaseMatInstance* mMaterialInst;
DECLARE_MATERIALASSET(RenderMeshExample, Material);
DECLARE_MATERIALASSET_NET_SETGET(RenderMeshExample, Material, UpdateMask);
// The GFX vertex and primitive buffers
GFXVertexBufferHandle< VertexType > mVertexBuffer;
GFXPrimitiveBufferHandle mPrimitiveBuffer;

View file

@ -72,8 +72,7 @@ RenderShapeExample::~RenderShapeExample()
void RenderShapeExample::initPersistFields()
{
addGroup( "Rendering" );
addField( "shapeFile", TypeStringFilename, Offset( mShapeFile, RenderShapeExample ),
"The path to the DTS shape file." );
INITPERSISTFIELD_SHAPEASSET(Shape, RenderShapeExample, "The path to the shape file.")
endGroup( "Rendering" );
// SceneObject already handles exposing the transform
@ -146,7 +145,7 @@ U32 RenderShapeExample::packUpdate( NetConnection *conn, U32 mask, BitStream *st
// Write out any of the updated editable properties
if ( stream->writeFlag( mask & UpdateMask ) )
{
stream->write( mShapeFile );
PACK_SHAPEASSET(conn, Shape);
// Allow the server object a chance to handle a new shape
createShape();
@ -170,7 +169,7 @@ void RenderShapeExample::unpackUpdate(NetConnection *conn, BitStream *stream)
if ( stream->readFlag() ) // UpdateMask
{
stream->read( &mShapeFile );
UNPACK_SHAPEASSET(conn, Shape);
if ( isProperlyAdded() )
createShape();
@ -182,33 +181,22 @@ void RenderShapeExample::unpackUpdate(NetConnection *conn, BitStream *stream)
//-----------------------------------------------------------------------------
void RenderShapeExample::createShape()
{
if ( mShapeFile.isEmpty() )
if ( getShape() == StringTable->EmptyString() )
return;
// If this is the same shape then no reason to update it
if ( mShapeInstance && mShapeFile.equal( mShape.getPath().getFullPath(), String::NoCase ) )
if ( mShapeInstance && getShape() == StringTable->insert(mShape.getPath().getFullPath().c_str()) )
return;
// Clean up our previous shape
if ( mShapeInstance )
SAFE_DELETE( mShapeInstance );
mShape = NULL;
// Attempt to get the resource from the ResourceManager
mShape = ResourceManager::get().load( mShapeFile );
if ( !mShape )
{
Con::errorf( "RenderShapeExample::createShape() - Unable to load shape: %s", mShapeFile.c_str() );
return;
}
// Attempt to preload the Materials for this shape
if ( isClientObject() &&
!mShape->preloadMaterialList( mShape.getPath() ) &&
NetConnection::filesWereDownloaded() )
{
mShape = NULL;
return;
}

View file

@ -30,6 +30,8 @@
#include "ts/tsShapeInstance.h"
#endif
#include "T3D/assets/ShapeAsset.h"
//-----------------------------------------------------------------------------
// This class implements a basic SceneObject that can exist in the world at a
// 3D position and render itself. There are several valid ways to render an
@ -59,12 +61,13 @@ class RenderShapeExample : public SceneObject
//--------------------------------------------------------------------------
// Rendering variables
//--------------------------------------------------------------------------
// The name of the shape file we will use for rendering
String mShapeFile;
DECLARE_SHAPEASSET(RenderShapeExample, Shape, onShapeChanged);
DECLARE_SHAPEASSET_SETGET(RenderShapeExample, Shape);
// The actual shape instance
TSShapeInstance* mShapeInstance;
// Store the resource so we can access the filename later
Resource<TSShape> mShape;
void onShapeChanged() {}
public:
RenderShapeExample();