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

@ -66,8 +66,7 @@ ConsoleDocClass( PhysicsShapeData,
);
PhysicsShapeData::PhysicsShapeData()
: shapeName( NULL ),
mass( 1.0f ),
: mass( 1.0f ),
dynamicFriction( 0.0f ),
staticFriction( 0.0f ),
restitution( 0.0f ),
@ -79,6 +78,7 @@ PhysicsShapeData::PhysicsShapeData()
buoyancyDensity( 0.0f ),
simType( SimType_ClientServer )
{
INIT_SHAPEASSET(Shape);
}
PhysicsShapeData::~PhysicsShapeData()
@ -91,9 +91,8 @@ void PhysicsShapeData::initPersistFields()
addGroup("Media");
addField( "shapeName", TypeShapeFilename, Offset( shapeName, PhysicsShapeData ),
"@brief Path to the .DAE or .DTS file to use for this shape.\n\n"
"Compatable with Live-Asset Reloading. ");
INITPERSISTFIELD_SHAPEASSET(Shape, PhysicsShapeData, "@brief Shape asset to be used with this physics object.\n\n"
"Compatable with Live-Asset Reloading. ")
addField( "debris", TYPEID< SimObjectRef<PhysicsDebrisData> >(), Offset( debris, PhysicsShapeData ),
"@brief Name of a PhysicsDebrisData to spawn when this shape is destroyed (optional)." );
@ -181,7 +180,7 @@ void PhysicsShapeData::packData( BitStream *stream )
{
Parent::packData( stream );
stream->writeString( shapeName );
PACKDATA_SHAPEASSET(Shape);
stream->write( mass );
stream->write( dynamicFriction );
@ -205,7 +204,7 @@ void PhysicsShapeData::unpackData( BitStream *stream )
{
Parent::unpackData(stream);
shapeName = stream->readSTString();
UNPACKDATA_SHAPEASSET(Shape);
stream->read( &mass );
stream->read( &dynamicFriction );
@ -242,28 +241,28 @@ void PhysicsShapeData::onRemove()
void PhysicsShapeData::_onResourceChanged( const Torque::Path &path )
{
if ( path != Path( shapeName ) )
if (mShapeAsset.isNull())
return;
if ( path != Path(mShapeAsset->getShapeFilePath()) )
return;
_setShape(getShape());
// Reload the changed shape.
Resource<TSShape> reloadShape;
PhysicsCollisionRef reloadcolShape;
reloadShape = ResourceManager::get().load( shapeName );
if ( !bool(reloadShape) )
if ( !mShape )
{
Con::warnf( ConsoleLogEntry::General, "PhysicsShapeData::_onResourceChanged: Could not reload %s.", path.getFileName().c_str() );
return;
}
// Reload the collision shape.
reloadcolShape = reloadShape->buildColShape( false, Point3F::One );
reloadcolShape = mShape->buildColShape( false, Point3F::One );
if ( bool(reloadShape) && bool(reloadcolShape))
{
shape = reloadShape;
if ( bool(reloadcolShape))
colShape = reloadcolShape;
}
mReloadSignal.trigger();
}
@ -283,35 +282,33 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
bool shapeError = false;
if (shapeName && shapeName[0])
if (mShapeAsset.notNull())
{
// Resolve shapename
shape = ResourceManager::get().load(shapeName);
if (bool(shape) == false)
if (bool(mShape) == false)
{
errorBuffer = String::ToString("PhysicsShapeData: Couldn't load shape \"%s\"", shapeName);
errorBuffer = String::ToString("PhysicsShapeData: Couldn't load shape \"%s\"", mShapeAssetId);
return false;
}
if (!server && !shape->preloadMaterialList(shape.getPath()) && NetConnection::filesWereDownloaded())
if (!server && !mShape->preloadMaterialList(mShape.getPath()) && NetConnection::filesWereDownloaded())
shapeError = true;
}
// Prepare the shared physics collision shape.
if ( !colShape && shape )
if ( !colShape && mShape)
{
colShape = shape->buildColShape( false, Point3F::One );
colShape = mShape->buildColShape( false, Point3F::One );
// If we got here and didn't get a collision shape then
// we need to fail... can't have a shape without collision.
if ( !colShape )
{
//no collision so we create a simple box collision shape from the shapes bounds and alert the user
Con::warnf( "PhysicsShapeData::preload - No collision found for shape '%s', auto-creating one", shapeName );
Point3F halfWidth = shape->mBounds.getExtents() * 0.5f;
Con::warnf( "PhysicsShapeData::preload - No collision found for shape '%s', auto-creating one", mShapeAssetId);
Point3F halfWidth = mShape->mBounds.getExtents() * 0.5f;
colShape = PHYSICSMGR->createCollision();
MatrixF centerXfm(true);
centerXfm.setPosition(shape->mBounds.getCenter());
centerXfm.setPosition(mShape->mBounds.getCenter());
colShape->addBox(halfWidth, centerXfm);
return true;
}
@ -703,11 +700,11 @@ bool PhysicsShape::_createShape()
mAmbientSeq = -1;
PhysicsShapeData *db = getDataBlock();
if ( !db || !db->shape)
if ( !db || !db->mShape)
return false;
// Set the world box.
mObjBox = db->shape->mBounds;
mObjBox = db->mShape->mBounds;
resetWorldBox();
// If this is the server and its a client only simulation
@ -721,11 +718,11 @@ bool PhysicsShape::_createShape()
}
// Create the shape instance.
mShapeInst = new TSShapeInstance( db->shape, isClientObject() );
mShapeInst = new TSShapeInstance( db->mShape, isClientObject() );
if ( isClientObject() )
{
mAmbientSeq = db->shape->findSequence( "ambient" );
mAmbientSeq = db->mShape->findSequence( "ambient" );
_initAmbient();
}
@ -1207,4 +1204,4 @@ DefineEngineMethod(PhysicsShape, applyForce, void, (Point3F force), ,
"@note This value is ignored on physics shapes that are not dynamic. Wakes up the dynamic physics shape if it is sleeping.\n")
{
object->applyForce( force );
}
}