2015-10-13 20:19:36 +00:00
//-----------------------------------------------------------------------------
// Copyright (c) 2013 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
2016-05-14 19:16:43 +00:00
# ifndef SHAPE_ASSET_H
# define SHAPE_ASSET_H
2015-10-13 20:19:36 +00:00
# ifndef _ASSET_BASE_H_
# include "assets/assetBase.h"
# endif
# ifndef _ASSET_DEFINITION_H_
# include "assets/assetDefinition.h"
# endif
# ifndef _STRINGUNIT_H_
# include "string/stringUnit.h"
# endif
# ifndef _ASSET_FIELD_TYPES_H_
# include "assets/assetFieldTypes.h"
# endif
# ifndef _TSSHAPE_H_
2016-01-09 06:37:41 +00:00
# include "ts/tsShape.h"
2015-10-13 20:19:36 +00:00
# endif
# ifndef __RESOURCE_H__
# include "core/resource.h"
# endif
2018-01-28 20:48:02 +00:00
# ifndef _ASSET_PTR_H_
# include "assets/assetPtr.h"
# endif
# ifndef MATERIALASSET_H
# include "MaterialAsset.h"
# endif
# ifndef SHAPE_ANIMATION_ASSET_H
# include "ShapeAnimationAsset.h"
# endif
2020-12-02 01:16:36 +00:00
# ifdef TORQUE_TOOLS
2018-01-28 20:48:02 +00:00
# include "gui/editor/guiInspectorTypes.h"
2020-12-02 01:16:36 +00:00
# endif
2020-12-21 01:01:43 +00:00
# ifndef _BITSTREAM_H_
# include "core/stream/bitStream.h"
# endif
2015-10-13 20:19:36 +00:00
//-----------------------------------------------------------------------------
class ShapeAsset : public AssetBase
{
typedef AssetBase Parent ;
protected :
StringTableEntry mFileName ;
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path
Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc
Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector
Adjusted expand behavior of guiTree to be more reliable
Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields
Removed redundant PreMult translucency type code
Added setting of feature so probes work when in forward/basic lit mode
Corrected indexing error in SQLiteObject class so it properly parses with the updated console API
Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy
Fixed var when trying to bind the camera to the client
Added project setting field to dictate the default render mode between Forward or Deferred
Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field
Integrated DOF PostFX into updated PostFX Editor paradigm
Updated setting group name for vignette postFX
Shifted shaderCache to be in data/cache along with other cached files
Added helper function to replace strings in a file
Fixed ExampleCppObject asset to have correct loose file references
Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default
Fixed verve reference to root scene group
Adjusted location of a nonmodal gui profile so it loads at the correct time
Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag
Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful
Initial work into zip and folder drag-and-drop asset importing support
Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions
Updated example asset type file
Ensured all asset types have proper handling for move, rename and delete actions
Fixed double-click behavior on folders in the AB
Fixed CPP asset preview
Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser
Added ability to convert a non-module top-level folder in the AB into a module
Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules
Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake
Fixed convex editor's material handling to work with AB and reference back properly
Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow
Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open
Added some additional common text gui profiles
Disabled calls to old editor settings logic in various editors to remove spam
Added callOnModules call so tools can initialize properly when the world editor is opened
Fixed logic test for visualizers
Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
StringTableEntry mConstructorFileName ;
2020-08-07 05:24:26 +00:00
StringTableEntry mFilePath ;
StringTableEntry mConstructorFilePath ;
2015-10-13 20:19:36 +00:00
Resource < TSShape > mShape ;
2018-01-28 20:48:02 +00:00
//Material assets we're dependent on and use
Vector < StringTableEntry > mMaterialAssetIds ;
Vector < AssetPtr < MaterialAsset > > mMaterialAssets ;
//Animation assets we're dependent on and use
Vector < StringTableEntry > mAnimationAssetIds ;
Vector < AssetPtr < ShapeAnimationAsset > > mAnimationAssets ;
2020-09-13 22:57:19 +00:00
typedef Signal < void ( ) > ShapeAssetChanged ;
ShapeAssetChanged mChangeSignal ;
2021-07-19 06:07:08 +00:00
typedef Signal < void ( S32 index ) > ShapeAssetArrayChanged ;
ShapeAssetArrayChanged mChangeArraySignal ;
2015-10-13 20:19:36 +00:00
public :
2020-12-02 01:16:36 +00:00
enum ShapeAssetErrCode
{
TooManyVerts = AssetErrCode : : Extended ,
TooManyBones ,
2020-12-03 21:37:51 +00:00
MissingAnimatons ,
Extended
} ;
2021-07-19 06:07:08 +00:00
static StringTableEntry smNoShapeAssetFallback ;
2020-12-03 21:37:51 +00:00
static const String mErrCodeStrings [ ShapeAssetErrCode : : Extended - Parent : : Extended + 1 ] ;
2021-07-19 06:07:08 +00:00
static U32 getAssetErrCode ( AssetPtr < ShapeAsset > shapeAsset ) { if ( shapeAsset ) return shapeAsset - > mLoadedState ; else return 0 ; }
2020-12-03 21:37:51 +00:00
static String getAssetErrstrn ( U32 errCode )
{
if ( errCode < Parent : : Extended ) return Parent : : getAssetErrstrn ( errCode ) ;
if ( errCode > ShapeAssetErrCode : : Extended ) return " undefined error " ;
return mErrCodeStrings [ errCode ] ;
2020-12-02 01:16:36 +00:00
} ;
2015-10-13 20:19:36 +00:00
ShapeAsset ( ) ;
virtual ~ ShapeAsset ( ) ;
2021-07-19 06:07:08 +00:00
/// Set up some global script interface stuff.
static void consoleInit ( ) ;
2015-10-13 20:19:36 +00:00
/// Engine.
static void initPersistFields ( ) ;
virtual void copyTo ( SimObject * object ) ;
2021-07-19 06:07:08 +00:00
virtual void setDataField ( StringTableEntry slotName , StringTableEntry array , StringTableEntry value ) ;
2018-01-28 20:48:02 +00:00
2015-10-13 20:19:36 +00:00
virtual void initializeAsset ( ) ;
/// Declare Console Object.
DECLARE_CONOBJECT ( ShapeAsset ) ;
bool loadShape ( ) ;
TSShape * getShape ( ) { return mShape ; }
2016-05-14 04:14:55 +00:00
Resource < TSShape > getShapeResource ( ) { return mShape ; }
2018-01-28 20:48:02 +00:00
void SplitSequencePathAndName ( String & srcPath , String & srcName ) ;
2021-07-19 06:07:08 +00:00
StringTableEntry getShapeFileName ( ) { return mFileName ; }
StringTableEntry getShapePath ( ) { return mFilePath ; }
2020-08-07 05:24:26 +00:00
U32 getShapeFilenameHash ( ) { return _StringTable : : hashString ( mFilePath ) ; }
2018-01-28 20:48:02 +00:00
2019-05-04 16:49:42 +00:00
Vector < AssetPtr < MaterialAsset > > getMaterialAssets ( ) { return mMaterialAssets ; }
2021-07-19 06:07:08 +00:00
inline AssetPtr < MaterialAsset > getMaterialAsset ( U32 matId )
{
if ( matId > = mMaterialAssets . size ( ) )
return nullptr ;
else
return mMaterialAssets [ matId ] ;
2019-05-04 16:49:42 +00:00
}
void clearMaterialAssets ( ) { mMaterialAssets . clear ( ) ; }
void addMaterialAssets ( AssetPtr < MaterialAsset > matPtr ) { mMaterialAssets . push_back ( matPtr ) ; }
2018-01-28 20:48:02 +00:00
S32 getMaterialCount ( ) { return mMaterialAssets . size ( ) ; }
S32 getAnimationCount ( ) { return mAnimationAssets . size ( ) ; }
ShapeAnimationAsset * getAnimation ( S32 index ) ;
2021-07-19 06:07:08 +00:00
void _onResourceChanged ( const Torque : : Path & path ) ;
2019-05-04 16:49:42 +00:00
2020-09-13 22:57:19 +00:00
ShapeAssetChanged & getChangedSignal ( ) { return mChangeSignal ; }
2021-07-19 06:07:08 +00:00
ShapeAssetArrayChanged & getChangedArraySignal ( ) { return mChangeArraySignal ; }
2019-05-04 16:49:42 +00:00
void setShapeFile ( const char * pScriptFile ) ;
inline StringTableEntry getShapeFile ( void ) const { return mFileName ; } ;
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path
Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc
Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector
Adjusted expand behavior of guiTree to be more reliable
Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields
Removed redundant PreMult translucency type code
Added setting of feature so probes work when in forward/basic lit mode
Corrected indexing error in SQLiteObject class so it properly parses with the updated console API
Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy
Fixed var when trying to bind the camera to the client
Added project setting field to dictate the default render mode between Forward or Deferred
Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field
Integrated DOF PostFX into updated PostFX Editor paradigm
Updated setting group name for vignette postFX
Shifted shaderCache to be in data/cache along with other cached files
Added helper function to replace strings in a file
Fixed ExampleCppObject asset to have correct loose file references
Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default
Fixed verve reference to root scene group
Adjusted location of a nonmodal gui profile so it loads at the correct time
Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag
Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful
Initial work into zip and folder drag-and-drop asset importing support
Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions
Updated example asset type file
Ensured all asset types have proper handling for move, rename and delete actions
Fixed double-click behavior on folders in the AB
Fixed CPP asset preview
Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser
Added ability to convert a non-module top-level folder in the AB into a module
Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules
Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake
Fixed convex editor's material handling to work with AB and reference back properly
Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow
Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open
Added some additional common text gui profiles
Disabled calls to old editor settings logic in various editors to remove spam
Added callOnModules call so tools can initialize properly when the world editor is opened
Fixed logic test for visualizers
Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
void setShapeConstructorFile ( const char * pScriptFile ) ;
inline StringTableEntry getShapeConstructorFile ( void ) const { return mConstructorFileName ; } ;
2020-08-07 05:24:26 +00:00
inline StringTableEntry getShapeFilePath ( void ) const { return mFilePath ; } ;
inline StringTableEntry getShapeConstructorFilePath ( void ) const { return mConstructorFilePath ; } ;
2021-07-19 06:07:08 +00:00
static U32 getAssetByFilename ( StringTableEntry fileName , AssetPtr < ShapeAsset > * shapeAsset ) ;
2020-12-02 01:16:36 +00:00
2020-04-15 17:15:12 +00:00
static StringTableEntry getAssetIdByFilename ( StringTableEntry fileName ) ;
2020-12-02 01:16:36 +00:00
static U32 getAssetById ( StringTableEntry assetId , AssetPtr < ShapeAsset > * shapeAsset ) ;
2020-03-19 14:47:38 +00:00
2021-01-27 07:54:26 +00:00
# ifdef TORQUE_TOOLS
const char * generateCachedPreviewImage ( S32 resolution ) ;
# endif
2015-10-13 20:19:36 +00:00
protected :
2016-06-07 02:20:00 +00:00
virtual void onAssetRefresh ( void ) ;
2019-05-04 16:49:42 +00:00
2021-07-19 06:07:08 +00:00
static bool setShapeFile ( void * obj , StringTableEntry index , StringTableEntry data ) { static_cast < ShapeAsset * > ( obj ) - > setShapeFile ( data ) ; return false ; }
2019-05-04 16:49:42 +00:00
static const char * getShapeFile ( void * obj , const char * data ) { return static_cast < ShapeAsset * > ( obj ) - > getShapeFile ( ) ; }
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path
Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc
Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector
Adjusted expand behavior of guiTree to be more reliable
Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields
Removed redundant PreMult translucency type code
Added setting of feature so probes work when in forward/basic lit mode
Corrected indexing error in SQLiteObject class so it properly parses with the updated console API
Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy
Fixed var when trying to bind the camera to the client
Added project setting field to dictate the default render mode between Forward or Deferred
Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field
Integrated DOF PostFX into updated PostFX Editor paradigm
Updated setting group name for vignette postFX
Shifted shaderCache to be in data/cache along with other cached files
Added helper function to replace strings in a file
Fixed ExampleCppObject asset to have correct loose file references
Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default
Fixed verve reference to root scene group
Adjusted location of a nonmodal gui profile so it loads at the correct time
Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag
Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful
Initial work into zip and folder drag-and-drop asset importing support
Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions
Updated example asset type file
Ensured all asset types have proper handling for move, rename and delete actions
Fixed double-click behavior on folders in the AB
Fixed CPP asset preview
Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser
Added ability to convert a non-module top-level folder in the AB into a module
Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules
Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake
Fixed convex editor's material handling to work with AB and reference back properly
Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow
Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open
Added some additional common text gui profiles
Disabled calls to old editor settings logic in various editors to remove spam
Added callOnModules call so tools can initialize properly when the world editor is opened
Fixed logic test for visualizers
Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
static bool setShapeConstructorFile ( void * obj , const char * index , const char * data ) { static_cast < ShapeAsset * > ( obj ) - > setShapeConstructorFile ( data ) ; return false ; }
static const char * getShapeConstructorFile ( void * obj , const char * data ) { return static_cast < ShapeAsset * > ( obj ) - > getShapeConstructorFile ( ) ; }
2015-10-13 20:19:36 +00:00
} ;
2020-12-02 01:16:36 +00:00
# ifdef TORQUE_TOOLS
2018-01-28 20:48:02 +00:00
DefineConsoleType ( TypeShapeAssetPtr , S32 )
2020-04-15 17:15:12 +00:00
DefineConsoleType ( TypeShapeAssetId , String )
2018-01-28 20:48:02 +00:00
//-----------------------------------------------------------------------------
// TypeAssetId GuiInspectorField Class
//-----------------------------------------------------------------------------
class GuiInspectorTypeShapeAssetPtr : public GuiInspectorTypeFileName
{
typedef GuiInspectorTypeFileName Parent ;
public :
2021-07-19 06:07:08 +00:00
GuiBitmapButtonCtrl * mShapeEdButton ;
2018-01-28 20:48:02 +00:00
DECLARE_CONOBJECT ( GuiInspectorTypeShapeAssetPtr ) ;
static void consoleInit ( ) ;
virtual GuiControl * constructEditControl ( ) ;
virtual bool updateRects ( ) ;
} ;
2015-10-13 20:19:36 +00:00
2020-04-15 17:15:12 +00:00
class GuiInspectorTypeShapeAssetId : public GuiInspectorTypeShapeAssetPtr
{
typedef GuiInspectorTypeShapeAssetPtr Parent ;
public :
DECLARE_CONOBJECT ( GuiInspectorTypeShapeAssetId ) ;
static void consoleInit ( ) ;
} ;
2020-12-02 01:16:36 +00:00
# endif
2021-07-19 06:07:08 +00:00
# pragma region Singular Asset Macros
# define DECLARE_SHAPEASSET(className,name,changeFunc) public: \
Resource < TSShape > m # # name ; \
StringTableEntry m # # name # # Name ; \
StringTableEntry m # # name # # AssetId ; \
AssetPtr < ShapeAsset > m # # name # # Asset ; \
public : \
const StringTableEntry get # # name # # File ( ) const { return StringTable - > insert ( m # # name # # Name ) ; } \
void set # # name # # Name ( const FileName & _in ) { m # # name # # Name = _in ; } \
const AssetPtr < ShapeAsset > & get # # name # # Asset ( ) const { return m # # name # # Asset ; } \
void set # # name # # Asset ( const AssetPtr < ShapeAsset > & _in ) { m # # name # # Asset = _in ; } \
2020-12-02 01:16:36 +00:00
\
2021-07-19 06:07:08 +00:00
bool _set # # name ( StringTableEntry _in ) \
2020-12-02 01:16:36 +00:00
{ \
2021-07-19 06:07:08 +00:00
if ( m # # name # # AssetId ! = _in | | m # # name # # Name ! = _in ) \
2020-12-02 01:16:36 +00:00
{ \
2021-07-19 06:07:08 +00:00
if ( m # # name # # Asset . notNull ( ) ) \
2020-12-02 01:16:36 +00:00
{ \
2021-07-19 06:07:08 +00:00
m # # name # # Asset - > getChangedSignal ( ) . remove ( this , & className : : changeFunc ) ; \
} \
2021-08-29 22:41:20 +00:00
if ( _in = = NULL | | _in = = StringTable - > EmptyString ( ) ) \
2021-07-19 06:07:08 +00:00
{ \
m # # name # # Name = StringTable - > EmptyString ( ) ; \
m # # name # # AssetId = StringTable - > EmptyString ( ) ; \
m # # name # # Asset = NULL ; \
m # # name = NULL ; \
2020-12-02 01:16:36 +00:00
return true ; \
} \
2021-07-19 06:07:08 +00:00
\
if ( AssetDatabase . isDeclaredAsset ( _in ) ) \
2020-12-02 01:16:36 +00:00
{ \
2021-07-19 06:07:08 +00:00
m # # name # # AssetId = _in ; \
2020-12-02 01:16:36 +00:00
\
2021-07-19 06:07:08 +00:00
U32 assetState = ShapeAsset : : getAssetById ( m # # name # # AssetId , & m # # name # # Asset ) ; \
\
if ( ShapeAsset : : Ok = = assetState ) \
{ \
m # # name # # Name = StringTable - > EmptyString ( ) ; \
} \
} \
else \
{ \
StringTableEntry assetId = ShapeAsset : : getAssetIdByFilename ( _in ) ; \
if ( assetId ! = StringTable - > EmptyString ( ) ) \
{ \
m # # name # # AssetId = assetId ; \
if ( ShapeAsset : : getAssetById ( m # # name # # AssetId , & m # # name # # Asset ) = = ShapeAsset : : Ok ) \
{ \
m # # name # # Name = StringTable - > EmptyString ( ) ; \
} \
} \
else \
{ \
m # # name # # Name = _in ; \
m # # name # # AssetId = StringTable - > EmptyString ( ) ; \
m # # name # # Asset = NULL ; \
} \
2020-12-02 01:16:36 +00:00
} \
} \
2021-07-19 06:07:08 +00:00
if ( get # # name ( ) ! = StringTable - > EmptyString ( ) & & m # # name # # Asset . notNull ( ) ) \
{ \
m # # name = m # # name # # Asset - > getShapeResource ( ) ; \
\
m # # name # # Asset - > getChangedSignal ( ) . notify ( this , & className : : changeFunc ) ; \
} \
else \
{ \
m # # name = NULL ; \
} \
\
if ( get # # name ( ) = = StringTable - > EmptyString ( ) ) \
return true ; \
\
if ( m # # name # # Asset . notNull ( ) & & m # # name # # Asset - > getStatus ( ) ! = ShapeAsset : : Ok ) \
{ \
Con : : errorf ( " %s(%s)::_set%s() - shape asset failure \" %s \" due to [%s] " , macroText ( className ) , getName ( ) , macroText ( name ) , _in , ShapeAsset : : getAssetErrstrn ( m # # name # # Asset - > getStatus ( ) ) . c_str ( ) ) ; \
return false ; \
} \
2021-08-29 23:32:44 +00:00
else if ( m # # name ) \
2021-07-19 06:07:08 +00:00
{ \
Con : : errorf ( " %s(%s)::_set%s() - Couldn't load shape \" %s \" " , macroText ( className ) , getName ( ) , macroText ( name ) , _in ) ; \
return false ; \
} \
return true ; \
2020-12-02 01:16:36 +00:00
} \
2021-07-19 06:07:08 +00:00
\
const StringTableEntry get # # name ( ) const \
2020-12-02 01:16:36 +00:00
{ \
2021-07-19 06:07:08 +00:00
if ( m # # name # # Asset & & ( m # # name # # Asset - > getShapePath ( ) ! = StringTable - > EmptyString ( ) ) ) \
return m # # name # # Asset - > getShapePath ( ) ; \
else if ( m # # name # # AssetId ! = StringTable - > EmptyString ( ) ) \
return m # # name # # AssetId ; \
else if ( m # # name # # Name ! = StringTable - > EmptyString ( ) ) \
return m # # name # # Name ; \
else \
return StringTable - > EmptyString ( ) ; \
2020-12-02 01:16:36 +00:00
} \
2021-07-19 06:07:08 +00:00
Resource < TSShape > get # # name # # Resource ( ) \
{ \
return m # # name ; \
}
# define DECLARE_SHAPEASSET_SETGET(className, name)\
static bool _set # # name # # Data ( void * obj , const char * index , const char * data ) \
{ \
bool ret = false ; \
className * object = static_cast < className * > ( obj ) ; \
ret = object - > _set # # name ( StringTable - > insert ( data ) ) ; \
return ret ; \
}
# define DECLARE_SHAPEASSET_NET_SETGET(className, name, bitmask)\
static bool _set # # name # # Data ( void * obj , const char * index , const char * data ) \
{ \
bool ret = false ; \
className * object = static_cast < className * > ( obj ) ; \
ret = object - > _set # # name ( StringTable - > insert ( data ) ) ; \
if ( ret ) \
object - > setMaskBits ( bitmask ) ; \
return ret ; \
}
# define DEF_SHAPEASSET_BINDS(className,name)\
DefineEngineMethod ( className , get # # name , String , ( ) , , " get name " ) \
{ \
return object - > get # # name ( ) ; \
2020-12-02 01:16:36 +00:00
} \
2021-07-19 06:07:08 +00:00
DefineEngineMethod ( className , get # # name # # Asset , String , ( ) , , assetText ( name , asset reference ) ) \
2020-12-02 01:16:36 +00:00
{ \
2021-07-19 06:07:08 +00:00
return object - > m # # name # # AssetId ; \
2020-12-21 01:01:43 +00:00
} \
2021-07-19 06:07:08 +00:00
DefineEngineMethod ( className , set # # name , bool , ( const char * shape ) , , assetText ( name , assignment . first tries asset then flat file . ) ) \
2020-12-21 01:01:43 +00:00
{ \
2021-07-19 06:07:08 +00:00
return object - > _set # # name ( StringTable - > insert ( shape ) ) ; \
}
# define INIT_SHAPEASSET(name) \
m # # name # # Name = StringTable - > EmptyString ( ) ; \
m # # name # # AssetId = StringTable - > EmptyString ( ) ; \
m # # name # # Asset = NULL ; \
2021-07-22 17:35:25 +00:00
m # # name = NULL ;
2021-07-19 06:07:08 +00:00
# ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
# define INITPERSISTFIELD_SHAPEASSET(name, consoleClass, docs) \
addProtectedField ( assetText ( name , File ) , TypeShapeFilename , Offset ( m # # name # # Name , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , assetText ( name , docs ) ) ; \
addProtectedField ( assetText ( name , Asset ) , TypeShapeAssetId , Offset ( m # # name # # AssetId , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , assetText ( name , asset reference . ) ) ;
# else
# define INITPERSISTFIELD_SHAPEASSET(name, consoleClass, docs) \
addProtectedField ( assetText ( name , File ) , TypeShapeFilename , Offset ( m # # name # # Name , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , assetText ( name , docs ) , AbstractClassRep : : FIELD_HideInInspectors ) ; \
addProtectedField ( assetText ( name , Asset ) , TypeShapeAssetId , Offset ( m # # name # # AssetId , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , assetText ( name , asset reference . ) ) ;
# endif // SHOW_LEGACY_FILE_FIELDS
# define CLONE_SHAPEASSET(name) \
m # # name # # Name = other . m # # name # # Name ; \
m # # name # # AssetId = other . m # # name # # AssetId ; \
m # # name # # Asset = other . m # # name # # Asset ; \
# define PACKDATA_SHAPEASSET(name)\
2020-12-21 01:01:43 +00:00
if ( stream - > writeFlag ( m # # name # # Asset . notNull ( ) ) ) \
2021-07-19 06:07:08 +00:00
{ \
2020-12-21 01:01:43 +00:00
stream - > writeString ( m # # name # # Asset . getAssetId ( ) ) ; \
2021-07-19 06:07:08 +00:00
} \
2020-12-21 01:01:43 +00:00
else \
2021-07-19 06:07:08 +00:00
stream - > writeString ( m # # name # # Name ) ;
# define UNPACKDATA_SHAPEASSET(name)\
2020-12-21 01:01:43 +00:00
if ( stream - > readFlag ( ) ) \
{ \
m # # name # # AssetId = stream - > readSTString ( ) ; \
2021-07-19 06:07:08 +00:00
_set # # name ( m # # name # # AssetId ) ; \
2020-12-21 01:01:43 +00:00
} \
else \
2021-07-19 06:07:08 +00:00
m # # name # # Name = stream - > readSTString ( ) ;
# define PACK_SHAPEASSET(netconn, name)\
if ( stream - > writeFlag ( m # # name # # Asset . notNull ( ) ) ) \
{ \
NetStringHandle assetIdStr = m # # name # # Asset . getAssetId ( ) ; \
netconn - > packNetStringHandleU ( stream , assetIdStr ) ; \
} \
else \
stream - > writeString ( m # # name # # Name ) ;
# define UNPACK_SHAPEASSET(netconn, name)\
if ( stream - > readFlag ( ) ) \
{ \
m # # name # # AssetId = StringTable - > insert ( netconn - > unpackNetStringHandleU ( stream ) . getString ( ) ) ; \
_set # # name ( m # # name # # AssetId ) ; \
} \
else \
m # # name # # Name = stream - > readSTString ( ) ;
# pragma endregion
# pragma region Arrayed Asset Macros
# define DECLARE_SHAPEASSET_ARRAY(className,name,max) public: \
static const U32 sm # # name # # Count = max ; \
Resource < TSShape > m # # name [ max ] ; \
StringTableEntry m # # name # # Name [ max ] ; \
StringTableEntry m # # name # # AssetId [ max ] ; \
AssetPtr < ShapeAsset > m # # name # # Asset [ max ] ; \
public : \
const StringTableEntry get # # name # # File ( const U32 & index ) const { return m # # name # # Name [ index ] ; } \
void set # # name # # Name ( const FileName & _in , const U32 & index ) { m # # name # # Name [ index ] = _in ; } \
const AssetPtr < ShapeAsset > & get # # name # # Asset ( const U32 & index ) const { return m # # name # # Asset [ index ] ; } \
void set # # name # # Asset ( const AssetPtr < ShapeAsset > & _in , const U32 & index ) { m # # name # # Asset [ index ] = _in ; } \
\
bool _set # # name ( StringTableEntry _in , const U32 & index ) \
{ \
if ( m # # name # # AssetId [ index ] ! = _in | | m # # name # # Name [ index ] ! = _in ) \
{ \
if ( index > = sm # # name # # Count | | index < 0 ) \
return false ; \
2021-08-29 22:41:20 +00:00
if ( _in = = NULL | | _in = = StringTable - > EmptyString ( ) ) \
2021-07-19 06:07:08 +00:00
{ \
m # # name # # Name [ index ] = StringTable - > EmptyString ( ) ; \
m # # name # # AssetId [ index ] = StringTable - > EmptyString ( ) ; \
m # # name # # Asset [ index ] = NULL ; \
m # # name [ index ] = NULL ; \
return true ; \
} \
\
if ( AssetDatabase . isDeclaredAsset ( _in ) ) \
{ \
m # # name # # AssetId [ index ] = _in ; \
\
U32 assetState = ShapeAsset : : getAssetById ( m # # name # # AssetId [ index ] , & m # # name # # Asset [ index ] ) ; \
\
if ( ShapeAsset : : Ok = = assetState ) \
{ \
m # # name # # Name [ index ] = StringTable - > EmptyString ( ) ; \
} \
} \
else \
{ \
StringTableEntry assetId = ShapeAsset : : getAssetIdByFilename ( _in ) ; \
if ( assetId ! = StringTable - > EmptyString ( ) ) \
{ \
m # # name # # AssetId [ index ] = assetId ; \
if ( ShapeAsset : : getAssetById ( m # # name # # AssetId [ index ] , & m # # name # # Asset [ index ] ) = = ShapeAsset : : Ok ) \
{ \
m # # name # # Name [ index ] = StringTable - > EmptyString ( ) ; \
} \
} \
else \
{ \
m # # name # # Name [ index ] = _in ; \
m # # name # # AssetId [ index ] = StringTable - > EmptyString ( ) ; \
m # # name # # Asset [ index ] = NULL ; \
} \
} \
} \
if ( get # # name ( index ) ! = StringTable - > EmptyString ( ) & & m # # name # # Asset [ index ] . notNull ( ) ) \
{ \
m # # name [ index ] = m # # name # # Asset [ index ] - > getShapeResource ( ) ; \
} \
else \
{ \
m # # name [ index ] = NULL ; \
} \
\
if ( get # # name ( index ) = = StringTable - > EmptyString ( ) ) \
return true ; \
\
if ( m # # name # # Asset [ index ] . notNull ( ) & & m # # name # # Asset [ index ] - > getStatus ( ) ! = ShapeAsset : : Ok ) \
{ \
Con : : errorf ( " %s(%s)::_set%s(%i) - shape asset failure \" %s \" due to [%s] " , macroText ( className ) , getName ( ) , macroText ( name ) , index , _in , ShapeAsset : : getAssetErrstrn ( m # # name # # Asset [ index ] - > getStatus ( ) ) . c_str ( ) ) ; \
return false ; \
} \
else if ( bool ( m # # name [ index ] ) = = NULL ) \
{ \
Con : : errorf ( " %s(%s)::_set%s(%i) - Couldn't load shape \" %s \" " , macroText ( className ) , getName ( ) , macroText ( name ) , index , _in ) ; \
return false ; \
} \
return true ; \
} \
\
const StringTableEntry get # # name ( const U32 & index ) const \
{ \
if ( m # # name # # Asset [ index ] & & ( m # # name # # Asset [ index ] - > getShapePath ( ) ! = StringTable - > EmptyString ( ) ) ) \
return m # # name # # Asset [ index ] - > getShapePath ( ) ; \
else if ( m # # name # # AssetId [ index ] ! = StringTable - > EmptyString ( ) ) \
return m # # name # # AssetId [ index ] ; \
else if ( m # # name # # Name [ index ] ! = StringTable - > EmptyString ( ) ) \
return StringTable - > insert ( m # # name # # Name [ index ] ) ; \
else \
return StringTable - > EmptyString ( ) ; \
} \
Resource < TSShape > get # # name # # Resource ( const U32 & index ) \
{ \
if ( index > = sm # # name # # Count | | index < 0 ) \
2021-08-10 08:13:46 +00:00
return ResourceManager : : get ( ) . load ( " " ) ; \
2021-07-19 06:07:08 +00:00
return m # # name [ index ] ; \
}
# define DECLARE_SHAPEASSET_ARRAY_SETGET(className, name)\
static bool _set # # name # # Data ( void * obj , const char * index , const char * data ) \
{ \
if ( ! index ) return false ; \
U32 idx = dAtoi ( index ) ; \
if ( idx > = sm # # name # # Count ) \
return false ; \
bool ret = false ; \
className * object = static_cast < className * > ( obj ) ; \
ret = object - > _set # # name ( StringTable - > insert ( data ) , idx ) ; \
return ret ; \
}
# define DECLARE_SHAPEASSET_ARRAY_NET_SETGET(className, name, bitmask)\
static bool _set # # name # # Data ( void * obj , const char * index , const char * data ) \
{ \
if ( ! index ) return false ; \
U32 idx = dAtoi ( index ) ; \
if ( idx > = sm # # name # # Count ) \
return false ; \
bool ret = false ; \
className * object = static_cast < className * > ( obj ) ; \
ret = object - > _set # # name ( StringTable - > insert ( data ) , idx ) ; \
if ( ret ) \
object - > setMaskBits ( bitmask ) ; \
return ret ; \
}
# define DEF_SHAPEASSET_ARRAY_BINDS(className,name)\
DefineEngineMethod ( className , get # # name , String , ( S32 index ) , , " get name " ) \
{ \
return object - > get # # name ( index ) ; \
} \
DefineEngineMethod ( className , get # # name # # Asset , String , ( S32 index ) , , assetText ( name , asset reference ) ) \
{ \
if ( index > = className : : sm # # name # # Count | | index < 0 ) \
return " " ; \
return object - > m # # name # # AssetId [ index ] ; \
} \
DefineEngineMethod ( className , set # # name , bool , ( const char * shape , S32 index ) , , assetText ( name , assignment . first tries asset then flat file . ) ) \
{ \
return object - > _set # # name ( StringTable - > insert ( shape ) , index ) ; \
2020-12-02 01:16:36 +00:00
}
2020-04-15 17:15:12 +00:00
2021-07-19 06:07:08 +00:00
# define INIT_SHAPEASSET_ARRAY(name, index) \
2021-07-21 01:05:49 +00:00
{ \
2021-07-19 06:07:08 +00:00
m # # name # # Name [ index ] = StringTable - > EmptyString ( ) ; \
m # # name # # AssetId [ index ] = StringTable - > EmptyString ( ) ; \
m # # name # # Asset [ index ] = NULL ; \
m # # name [ index ] = NULL ; \
2021-07-21 01:05:49 +00:00
}
2015-10-13 20:19:36 +00:00
2021-07-19 06:07:08 +00:00
# ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
2021-08-09 04:44:17 +00:00
# define INITPERSISTFIELD_SHAPEASSET_ARRAY(name, arraySize, consoleClass, docs) \
addProtectedField ( assetText ( name , File ) , TypeShapeFilename , Offset ( m # # name # # Name , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , arraySize , assetText ( name , docs ) ) ; \
addProtectedField ( assetText ( name , Asset ) , TypeShapeAssetId , Offset ( m # # name # # AssetId , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , arraySize , assetText ( name , asset reference . ) ) ;
2021-07-19 06:07:08 +00:00
# else
2021-08-09 04:44:17 +00:00
# define INITPERSISTFIELD_SHAPEASSET_ARRAY(name, arraySize, consoleClass, docs) \
addProtectedField ( assetText ( name , File ) , TypeShapeFilename , Offset ( m # # name # # Name , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , arraySize , assetText ( name , docs ) , AbstractClassRep : : FIELD_HideInInspectors ) ; \
addProtectedField ( assetText ( name , Asset ) , TypeShapeAssetId , Offset ( m # # name # # AssetId , consoleClass ) , _set # # name # # Data , & defaultProtectedGetFn , arraySize , assetText ( name , asset reference . ) ) ;
2021-07-19 06:07:08 +00:00
# endif // SHOW_LEGACY_FILE_FIELDS
# define CLONE_SHAPEASSET_ARRAY(name, index) \
2021-07-21 01:05:49 +00:00
{ \
2021-07-19 06:07:08 +00:00
m # # name # # Name [ index ] = other . m # # name # # Name [ index ] ; \
m # # name # # AssetId [ index ] = other . m # # name # # AssetId [ index ] ; \
m # # name # # Asset [ index ] = other . m # # name # # Asset [ index ] ; \
2021-07-21 01:05:49 +00:00
}
2021-07-19 06:07:08 +00:00
# define PACKDATA_SHAPEASSET_ARRAY(name, index)\
if ( stream - > writeFlag ( m # # name # # Asset [ index ] . notNull ( ) ) ) \
{ \
stream - > writeString ( m # # name # # Asset [ index ] . getAssetId ( ) ) ; \
} \
else \
stream - > writeString ( m # # name # # Name [ index ] ) ;
# define UNPACKDATA_SHAPEASSET_ARRAY(name, index)\
if ( stream - > readFlag ( ) ) \
{ \
m # # name # # AssetId [ index ] = stream - > readSTString ( ) ; \
_set # # name ( m # # name # # AssetId [ index ] , index ) ; \
} \
else \
m # # name # # Name [ index ] = stream - > readSTString ( ) ;
# define PACK_SHAPEASSET_ARRAY(netconn, name, index)\
if ( stream - > writeFlag ( m # # name # # Asset [ index ] . notNull ( ) ) ) \
{ \
NetStringHandle assetIdStr = m # # name # # Asset [ index ] . getAssetId ( ) ; \
netconn - > packNetStringHandleU ( stream , assetIdStr ) ; \
} \
else \
stream - > writeString ( m # # name # # Name [ index ] ) ;
# define UNPACK_SHAPEASSET_ARRAY(netconn, name, index)\
if ( stream - > readFlag ( ) ) \
{ \
m # # name # # AssetId [ index ] = StringTable - > insert ( netconn - > unpackNetStringHandleU ( stream ) . getString ( ) ) ; \
_set # # name ( m # # name # # AssetId [ index ] , index ) ; \
} \
else \
m # # name # # Name [ index ] = stream - > readSTString ( ) ;
# pragma endregion
# endif