mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-23 08:33:50 +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
|
|
@ -46,6 +46,8 @@
|
|||
/// For frame signal
|
||||
#include "gui/core/guiCanvas.h"
|
||||
|
||||
#include "T3D/assets/LevelAsset.h"
|
||||
|
||||
|
||||
extern bool gEditingMission;
|
||||
|
||||
|
|
@ -333,18 +335,23 @@ void Forest::createNewFile()
|
|||
mData = NULL;
|
||||
|
||||
// We need to construct a default file name
|
||||
String missionName( Con::getVariable( "$Client::MissionFile" ) );
|
||||
String levelDirectory( Con::getVariable( "$pref::Directories::Level" ) );
|
||||
if ( levelDirectory.isEmpty() )
|
||||
{
|
||||
levelDirectory = "levels";
|
||||
}
|
||||
missionName.replace( "tools/levels", levelDirectory );
|
||||
missionName = Platform::makeRelativePathName(missionName, Platform::getMainDotCsDir());
|
||||
String levelAssetId(Con::getVariable("$Client::LevelAsset"));
|
||||
|
||||
LevelAsset* levelAsset;
|
||||
if (!Sim::findObject(levelAssetId.c_str(), levelAsset))
|
||||
{
|
||||
Con::errorf("Forest::createNewFile() - Unable to find current level's LevelAsset. Unable to construct forest filePath");
|
||||
return;
|
||||
}
|
||||
|
||||
Torque::Path basePath(levelAsset->getForestPath() );
|
||||
|
||||
//If we didn't already define a forestfile to work with, just base it off our filename
|
||||
if (basePath.isEmpty())
|
||||
basePath = levelAsset->getLevelPath();
|
||||
|
||||
Torque::Path basePath( missionName );
|
||||
String fileName = Torque::FS::MakeUniquePath( basePath.getPath(), basePath.getFileName(), "forest" );
|
||||
mDataFileName = StringTable->insert( fileName );
|
||||
mDataFileName = StringTable->insert( fileName.c_str() );
|
||||
|
||||
ForestData *file = new ForestData;
|
||||
file->write( mDataFileName );
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ SimSet* ForestItemData::smSet = NULL;
|
|||
|
||||
ForestItemData::ForestItemData()
|
||||
: mNeedPreload( true ),
|
||||
mShapeFile( NULL ),
|
||||
mRadius( 1 ),
|
||||
mCollidable( true ),
|
||||
mWindScale( 0.0f ),
|
||||
|
|
@ -54,6 +53,7 @@ ForestItemData::ForestItemData()
|
|||
mTightnessCoefficient( 0.4f ),
|
||||
mDampingCoefficient( 0.7f )
|
||||
{
|
||||
INIT_SHAPEASSET(Shape);
|
||||
}
|
||||
|
||||
void ForestItemData::initPersistFields()
|
||||
|
|
@ -61,9 +61,11 @@ void ForestItemData::initPersistFields()
|
|||
Parent::initPersistFields();
|
||||
|
||||
addGroup( "Media" );
|
||||
|
||||
INITPERSISTFIELD_SHAPEASSET(Shape, ForestItemData, "Shape asset for this item type");
|
||||
|
||||
addField( "shapeFile", TypeShapeFilename, Offset( mShapeFile, ForestItemData ),
|
||||
"Shape file for this item type" );
|
||||
addProtectedField( "shapeFile", TypeShapeFilename, Offset( mShapeName, ForestItemData ), &_setShapeData, &defaultProtectedGetFn,
|
||||
"Shape file for this item type", AbstractClassRep::FIELD_HideInInspectors );
|
||||
|
||||
addField( "collidable", TypeBool, Offset( mCollidable, ForestItemData ),
|
||||
"Can other objects or spacial queries hit items of this type." );
|
||||
|
|
@ -162,7 +164,7 @@ void ForestItemData::packData(BitStream* stream)
|
|||
|
||||
stream->write( localName );
|
||||
|
||||
stream->writeString(mShapeFile);
|
||||
PACKDATA_SHAPEASSET(Shape);
|
||||
|
||||
stream->writeFlag( mCollidable );
|
||||
|
||||
|
|
@ -190,8 +192,7 @@ void ForestItemData::unpackData(BitStream* stream)
|
|||
|
||||
char readBuffer[1024];
|
||||
|
||||
stream->readString(readBuffer);
|
||||
mShapeFile = StringTable->insert(readBuffer);
|
||||
UNPACKDATA_SHAPEASSET(Shape);
|
||||
|
||||
mCollidable = stream->readFlag();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "console/dynamicTypes.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/ShapeAsset.h"
|
||||
|
||||
class ForestItem;
|
||||
class ForestCellBatch;
|
||||
|
|
@ -61,8 +62,8 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
/// Shape file for this item type.
|
||||
StringTableEntry mShapeFile;
|
||||
DECLARE_SHAPEASSET(ForestItemData, Shape, onShapeChanged);
|
||||
DECLARE_SHAPEASSET_SETGET(ForestItemData, Shape);
|
||||
|
||||
/// This is the radius used during placement to ensure
|
||||
/// the element isn't crowded up against other trees.
|
||||
|
|
@ -141,6 +142,8 @@ public:
|
|||
static ReloadSignal theSignal;
|
||||
return theSignal;
|
||||
}
|
||||
|
||||
void onShapeChanged() {}
|
||||
};
|
||||
|
||||
typedef Vector<ForestItemData*> ForestItemDataVector;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ void TSForestItemData::inspectPostApply()
|
|||
|
||||
void TSForestItemData::_onResourceChanged( const Torque::Path &path )
|
||||
{
|
||||
if ( path != Path( mShapeFile ) )
|
||||
if (mShapeAsset.isNull()) return;
|
||||
if ( path != Path(mShapeAsset->getShapeFilePath()) )
|
||||
return;
|
||||
|
||||
SAFE_DELETE( mShapeInstance );
|
||||
|
|
@ -110,12 +111,15 @@ void TSForestItemData::_onResourceChanged( const Torque::Path &path )
|
|||
|
||||
void TSForestItemData::_loadShape()
|
||||
{
|
||||
mShape = ResourceManager::get().load(mShapeFile);
|
||||
if (mShapeAsset.isNull()) return;
|
||||
|
||||
_setShape(mShapeAssetId);
|
||||
|
||||
if ( !(bool)mShape )
|
||||
return;
|
||||
|
||||
if ( mIsClientObject &&
|
||||
!mShape->preloadMaterialList( mShapeFile ) )
|
||||
!mShape->preloadMaterialList(mShapeAsset->getShapeFilePath()) )
|
||||
return;
|
||||
|
||||
// Lets add an autobillboard detail if don't have one.
|
||||
|
|
@ -153,13 +157,14 @@ TSShapeInstance* TSForestItemData::_getShapeInstance() const
|
|||
|
||||
void TSForestItemData::_checkLastDetail()
|
||||
{
|
||||
if (mShapeAsset.isNull()) return;
|
||||
const S32 dl = mShape->mSmallestVisibleDL;
|
||||
const TSDetail *detail = &mShape->details[dl];
|
||||
|
||||
// TODO: Expose some real parameters to the datablock maybe?
|
||||
if ( detail->subShapeNum != -1 )
|
||||
{
|
||||
mShape->addImposter( mShapeFile, 10, 4, 0, 0, 256, 0, 0 );
|
||||
mShape->addImposter(mShapeAsset->getShapeFilePath(), 10, 4, 0, 0, 256, 0, 0 );
|
||||
|
||||
// HACK: If i don't do this it crashes!
|
||||
while ( mShape->detailCollisionAccelerators.size() < mShape->details.size() )
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ protected:
|
|||
// This is setup during forest creation.
|
||||
mutable TSShapeInstance *mShapeInstance;
|
||||
|
||||
Resource<TSShape> mShape;
|
||||
|
||||
Vector<S32> mCollisionDetails;
|
||||
Vector<S32> mLOSDetails;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue