From c92cfe3e81898f66fe2dfb35118605e97b10a577 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 Sep 2021 09:37:31 +0100 Subject: [PATCH 01/37] SoundAssetImplements -Explosion -Lightning -Splash -Other sound asset implementations will require soundasset array if possible. --- Engine/source/T3D/fx/explosion.cpp | 32 ++++++++++++++---------------- Engine/source/T3D/fx/explosion.h | 13 +++++++++++- Engine/source/T3D/fx/lightning.cpp | 21 ++++++++++---------- Engine/source/T3D/fx/lightning.h | 16 +++++++++++++-- Engine/source/T3D/fx/splash.cpp | 24 +++++++++++++++++++--- Engine/source/T3D/fx/splash.h | 16 +++++++++++++-- 6 files changed, 87 insertions(+), 35 deletions(-) diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index aa86e27a9..e842f73e4 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -230,7 +230,9 @@ ExplosionData::ExplosionData() faceViewer = false; - soundProfile = NULL; + INIT_SOUNDASSET(Sound); + + //soundProfile = NULL; particleEmitter = NULL; particleEmitterId = 0; @@ -308,7 +310,7 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game faceViewer = other.faceViewer; particleDensity = other.particleDensity; particleRadius = other.particleRadius; - soundProfile = other.soundProfile; + CLONE_SOUNDASSET(Sound); particleEmitter = other.particleEmitter; particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr explosionScale = other.explosionScale; @@ -358,12 +360,6 @@ ExplosionData::~ExplosionData() if (!isTempClone()) return; - if (soundProfile && soundProfile->isTempClone()) - { - delete soundProfile; - soundProfile = 0; - } - // particleEmitter, emitterList[*], debrisList[*], explosionList[*] will delete themselves #ifdef TRACK_EXPLOSION_DATA_CLONES @@ -399,8 +395,9 @@ void ExplosionData::initPersistFields() "of the explosion." ); addField( "playSpeed", TypeF32, Offset(playSpeed, ExplosionData), "Time scale at which to play the explosionShape ambient sequence." ); - addField( "soundProfile", TYPEID< SFXTrack >(), Offset(soundProfile, ExplosionData), - "Non-looping sound effect that will be played at the start of the explosion." ); + + INITPERSISTFIELD_SOUNDASSET(Sound, ExplosionData, "Sound to play when this explosion explodes."); + addField( "faceViewer", TypeBool, Offset(faceViewer, ExplosionData), "Controls whether the visual effects of the explosion always face the camera." ); @@ -523,7 +520,6 @@ void ExplosionData::initPersistFields() onlyKeepClearSubstitutions("debris"); // subs resolving to "~~", or "~0" are OK onlyKeepClearSubstitutions("emitter"); onlyKeepClearSubstitutions("particleEmitter"); - onlyKeepClearSubstitutions("soundProfile"); onlyKeepClearSubstitutions("subExplosion"); Parent::initPersistFields(); } @@ -656,7 +652,8 @@ void ExplosionData::packData(BitStream* stream) PACKDATA_SHAPEASSET(ExplosionShape); - sfxWrite( stream, soundProfile ); + PACKDATA_SOUNDASSET(Sound); + if (stream->writeFlag(particleEmitter)) stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast); @@ -759,7 +756,7 @@ void ExplosionData::unpackData(BitStream* stream) UNPACKDATA_SHAPEASSET(ExplosionShape); - sfxRead( stream, &soundProfile ); + UNPACKDATA_SOUNDASSET(Sound); if (stream->readFlag()) particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); @@ -861,12 +858,13 @@ bool ExplosionData::preload(bool server, String &errorStr) { if (Parent::preload(server, errorStr) == false) return false; - + + if (!server && !getSFXProfile()) + return false; + if( !server ) { String sfxErrorStr; - if( !sfxResolve( &soundProfile, sfxErrorStr ) ) - Con::errorf(ConsoleLogEntry::General, "Error, unable to load sound profile for explosion datablock: %s", sfxErrorStr.c_str()); if (!particleEmitter && particleEmitterId != 0) if (Sim::findObject(particleEmitterId, particleEmitter) == false) Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock"); @@ -1384,7 +1382,7 @@ bool Explosion::explode() resetWorldBox(); } - SFXProfile* sound_prof = dynamic_cast(mDataBlock->soundProfile); + SFXProfile* sound_prof = dynamic_cast(mDataBlock->getSFXProfile()); if (sound_prof) { soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index); diff --git a/Engine/source/T3D/fx/explosion.h b/Engine/source/T3D/fx/explosion.h index a82d28644..ae01c4bee 100644 --- a/Engine/source/T3D/fx/explosion.h +++ b/Engine/source/T3D/fx/explosion.h @@ -42,6 +42,7 @@ #endif #include "T3D/assets/ShapeAsset.h" +#include "T3D/assets/SoundAsset.h" class ParticleEmitter; class ParticleEmitterData; @@ -69,7 +70,17 @@ class ExplosionData : public GameBaseData { S32 particleDensity; F32 particleRadius; - SFXTrack* soundProfile; + //SFXTrack* soundProfile; + DECLARE_SOUNDASSET(ExplosionData, Sound); + DECLARE_SOUNDASSET_SETGET(ExplosionData, Sound); + + SFXProfile* getSFXProfile() { + if (mSoundAsset.notNull()) + return mSoundAsset->getSfxProfile(); + else + return NULL; + } + ParticleEmitterData* particleEmitter; S32 particleEmitterId; diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index e808fb406..20925ec58 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -238,7 +238,7 @@ void LightningStrikeEvent::process(NetConnection*) // LightningData::LightningData() { - strikeSound = NULL; + INIT_SOUNDASSET(StrikeSound); for (S32 i = 0; i < MaxThunders; i++) thunderSounds[i] = NULL; @@ -260,8 +260,9 @@ LightningData::~LightningData() //-------------------------------------------------------------------------- void LightningData::initPersistFields() { - addField( "strikeSound", TYPEID< SFXTrack >(), Offset(strikeSound, LightningData), - "Sound profile to play when a lightning strike occurs." ); + + INITPERSISTFIELD_SOUNDASSET(StrikeSound, LightningData, "Sound to play when lightning STRIKES!"); + addField( "thunderSounds", TYPEID< SFXTrack >(), Offset(thunderSounds, LightningData), MaxThunders, "@brief List of thunder sound effects to play.\n\n" "A random one of these sounds will be played shortly after each strike " @@ -302,8 +303,8 @@ bool LightningData::preload(bool server, String &errorStr) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str()); } - if( !sfxResolve( &strikeSound, sfxErrorStr ) ) - Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str()); + if(!getSFXProfile()) + Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset"); mNumStrikeTextures = 0; for (U32 i = 0; i < MaxTextures; i++) @@ -338,7 +339,7 @@ void LightningData::packData(BitStream* stream) for (i = 0; i < MaxTextures; i++) stream->writeString(strikeTextureNames[i]); - sfxWrite( stream, strikeSound ); + PACKDATA_SOUNDASSET(StrikeSound); } void LightningData::unpackData(BitStream* stream) @@ -359,7 +360,7 @@ void LightningData::unpackData(BitStream* stream) for (i = 0; i < MaxTextures; i++) strikeTextureNames[i] = stream->readSTString(); - sfxRead( stream, &strikeSound ); + UNPACKDATA_SOUNDASSET(StrikeSound); } @@ -735,9 +736,9 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent) MatrixF trans(true); trans.setPosition( strikePoint ); - if (mDataBlock->strikeSound) + if (mDataBlock->getSFXProfile()) { - SFX->playOnce(mDataBlock->strikeSound, &trans ); + SFX->playOnce(mDataBlock->getSFXProfile(), &trans ); } } @@ -1337,4 +1338,4 @@ void LightningBolt::update( F32 dt ) isFading = false; elapsedTime = 0.0f; } -} \ No newline at end of file +} diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h index 93a54ffc7..78ef4a20b 100644 --- a/Engine/source/T3D/fx/lightning.h +++ b/Engine/source/T3D/fx/lightning.h @@ -41,7 +41,8 @@ #include "gfx/gfxTextureHandle.h" - +#include "T3D/assets/ImageAsset.h" +#include "T3D/assets/SoundAsset.h" class ShapeBase; class LightningStrikeEvent; @@ -63,7 +64,10 @@ class LightningData : public GameBaseData //-------------------------------------- Console set variables public: SFXTrack* thunderSounds[MaxThunders]; - SFXTrack* strikeSound; + + DECLARE_SOUNDASSET(LightningData, StrikeSound); + DECLARE_SOUNDASSET_SETGET(LightningData, StrikeSound); + StringTableEntry strikeTextureNames[MaxTextures]; //-------------------------------------- load set variables @@ -86,6 +90,14 @@ class LightningData : public GameBaseData DECLARE_CONOBJECT(LightningData); static void initPersistFields(); + + SFXProfile* getSFXProfile() { + if (mStrikeSoundAsset.notNull()) + return mStrikeSoundAsset->getSfxProfile(); + else + return NULL; + } + }; diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index c6ac5582b..6af8a0c1a 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -67,8 +67,10 @@ ConsoleDocClass( Splash, //-------------------------------------------------------------------------- SplashData::SplashData() { - soundProfile = NULL; - soundProfileId = 0; + //soundProfile = NULL; + //soundProfileId = 0; + + INIT_SOUNDASSET(Sound); scale.set(1, 1, 1); @@ -112,7 +114,8 @@ SplashData::SplashData() //-------------------------------------------------------------------------- void SplashData::initPersistFields() { - addField("soundProfile", TYPEID< SFXProfile >(), Offset(soundProfile, SplashData), "SFXProfile effect to play.\n"); + INITPERSISTFIELD_SOUNDASSET(Sound, SplashData, "Sound to play when splash, splashes."); + addField("scale", TypePoint3F, Offset(scale, SplashData), "The scale of this splashing effect, defined as the F32 points X, Y, Z.\n"); addField("emitter", TYPEID< ParticleEmitterData >(), Offset(emitterList, SplashData), NUM_EMITTERS, "List of particle emitters to create at the point of this Splash effect.\n"); addField("delayMS", TypeS32, Offset(delayMS, SplashData), "Time to delay, in milliseconds, before actually starting this effect.\n"); @@ -158,6 +161,8 @@ void SplashData::packData(BitStream* stream) { Parent::packData(stream); + PACKDATA_SOUNDASSET(Sound); + mathWrite(*stream, scale); stream->write(delayMS); stream->write(delayVariance); @@ -212,6 +217,8 @@ void SplashData::unpackData(BitStream* stream) { Parent::unpackData(stream); + UNPACKDATA_SOUNDASSET(Sound); + mathRead(*stream, &scale); stream->read(&delayMS); stream->read(&delayVariance); @@ -267,6 +274,9 @@ bool SplashData::preload(bool server, String &errorStr) if (Parent::preload(server, errorStr) == false) return false; + if (!server && !getSFXProfile()) + return false; + if (!server) { S32 i; @@ -667,6 +677,14 @@ void Splash::spawnExplosion() { if( !mDataBlock->explosion ) return; + /// could just play the explosion one, but explosion could be weapon specific, + /// splash sound could be liquid specific. food for thought. + SFXProfile* sound_prof = dynamic_cast(mDataBlock->getSFXProfile()); + if (sound_prof) + { + SFX->playOnce(sound_prof, &getTransform()); + } + Explosion* pExplosion = new Explosion; pExplosion->onNewDataBlock(mDataBlock->explosion, false); diff --git a/Engine/source/T3D/fx/splash.h b/Engine/source/T3D/fx/splash.h index f90a72d3c..40c6838fc 100644 --- a/Engine/source/T3D/fx/splash.h +++ b/Engine/source/T3D/fx/splash.h @@ -34,6 +34,7 @@ #include "gfx/gfxTextureHandle.h" #include "T3D/assets/ImageAsset.h" +#include "T3D/assets/SoundAsset.h" class ParticleEmitter; class ParticleEmitterData; @@ -91,8 +92,19 @@ class SplashData : public GameBaseData }; public: - AudioProfile* soundProfile; - S32 soundProfileId; + //AudioProfile* soundProfile; + //S32 soundProfileId; + + DECLARE_SOUNDASSET(SplashData, Sound); + DECLARE_SOUNDASSET_SETGET(SplashData, Sound); + + /// this should probably be added as a function higher up to stop repeats. + SFXProfile* getSFXProfile() { + if (mSoundAsset.notNull()) + return mSoundAsset->getSfxProfile(); + else + return NULL; + } ParticleEmitterData* emitterList[NUM_EMITTERS]; S32 emitterIDList[NUM_EMITTERS]; From 3ad6d47ca9eaf57e64afc872cbde5c76cf47557d Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 Sep 2021 09:55:36 +0100 Subject: [PATCH 02/37] Update SoundAsset.h -SoundAsset array setters getters and binds in place --- Engine/source/T3D/assets/SoundAsset.h | 218 ++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 710652830..757d85ab6 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -360,5 +360,223 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText #pragma endregion +#pragma region Arrayed Asset Macros + +#define DECLARE_SOUNDASSET_ARRAY(className, name, max) public: \ + static const U32 sm##name##count = max;\ + Resource m##name[max];\ + StringTableEntry m##name##Name[max]; \ + StringTableEntry m##name##AssetId[max];\ + AssetPtr m##name##Asset[max] = NULL;\ + SFXProfile* m##name##Profile[max] = NULL;\ +public: \ + const StringTableEntry get##name##File(const U32& id) const { return m##name##Name[id]; }\ + void set##name##File(const FileName &_in, const U32& id) { m##name##Name[id] = StringTable->insert(_in.c_str());}\ + const AssetPtr & get##name##Asset(const U32& id) const { return m##name##Asset[id]; }\ + void set##name##Asset(const AssetPtr &_in, const U32& id) { m##name##Asset[id] = _in;}\ + \ + bool _set##name(StringTableEntry _in, const U32& id)\ + {\ + if(m##name##AssetId[id] != _in || m##name##Name[id] != _in)\ + {\ + if (_in == NULL || _in == StringTable->EmptyString())\ + {\ + if(id >= sm##name##Count || id < 0) \ + return false;\ + m##name##Name[id] = StringTable->EmptyString();\ + m##name##AssetId[id] = StringTable->EmptyString();\ + m##name##Asset[id] = NULL;\ + m##name[id] = NULL;\ + return true;\ + }\ + \ + if (AssetDatabase.isDeclaredAsset(_in))\ + {\ + m##name##AssetId[id] = _in;\ + \ + U32 assetState = SoundAsset::getAssetById(m##name##AssetId[id], &m##name##Asset[id]);\ + \ + if (SoundAsset::Ok == assetState)\ + {\ + m##name##Name[id] = StringTable->EmptyString();\ + }\ + }\ + else\ + {\ + StringTableEntry assetId = SoundAsset::getAssetIdByFileName(_in);\ + if (assetId != StringTable->EmptyString())\ + {\ + m##name##AssetId[id] = assetId;\ + if(SoundAsset::getAssetById(m##name##AssetId, &m##name##Asset) == SoundAsset::Ok)\ + {\ + m##name##Name[id] = StringTable->EmptyString();\ + }\ + }\ + else\ + {\ + m##name##Name[id] = _in;\ + m##name##AssetId[id] = StringTable->EmptyString();\ + m##name##Asset[id] = NULL;\ + }\ + }\ + }\ + if (get##name(id) != StringTable->EmptyString() && m##name##Asset[id].notNull())\ + {\ + m##name[id] = m##name##Asset[id]->getSoundResource();\ + }\ + else\ + {\ + m##name[id] = NULL;\ + }\ + \ + if (m##name##Asset[id].notNull() && m##name##Asset[id]->getStatus() != SoundAsset::Ok)\ + {\ + Con::errorf("%s(%s)::_set%s(%i) - sound asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name),id, _in, SoundAsset::getAssetErrstrn(m##name##Asset->getStatus()).c_str());\ + return false; \ + }\ + else if (!m##name)\ + {\ + Con::errorf("%s(%s)::_set%s(%i) - Couldn't load sound \"%s\"", macroText(className), getName(), macroText(name),id, _in);\ + return false;\ + }\ + return true;\ + }\ + \ + const StringTableEntry get##name(const U32& id) const\ + {\ + if (m##name##Asset[id] && (m##name##Asset[id]->getSoundPath() != StringTable->EmptyString()))\ + return m##name##Asset[id]->getSoundPath();\ + else if (m##name##AssetId[id] != StringTable->EmptyString())\ + return m##name##AssetId[id];\ + else if (m##name##Name[id] != StringTable->EmptyString())\ + return StringTable->insert(m##name##Name[id]);\ + else\ + return StringTable->EmptyString();\ + }\ + Resource get##name##Resource() \ + {\ + return m##name;\ + } + +#define DECLARE_SOUNDASSET_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(obj);\ + ret = object->_set##name(StringTable->insert(data), idx);\ + return ret;\ + } + +#define DECLARE_SOUNDASSET_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(obj);\ + ret = object->_set##name(StringTable->insert(data, idx));\ + if(ret)\ + object->setMaskBits(bitmask);\ + return ret;\ + } + +#define DEF_SOUNDASSET_ARRAY_BINDS(className,name)\ +DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\ +{\ + return object->get##name(index); \ +}\ +DefineEngineMethod(className, get##name##Asset, const char*, (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* map, S32 index), , assetText(name,assignment. first tries asset then flat file.))\ +{\ + return object->_set##name(StringTable->insert(map), index);\ +} + +#define INIT_SOUNDASSET_ARRAY(name, index) \ +{\ + m##name##Name[index] = StringTable->EmptyString(); \ + m##name##AssetId[index] = StringTable->EmptyString(); \ + m##name##Asset[index] = NULL;\ +} + +#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS + +#define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, docs) \ + addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs)); \ + addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.)); + +#else + +#define INITPERSISTFIELD_SOUNDASSET_ARRAY(name, arraySize, consoleClass, docs) \ + addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.)); + +#endif + +#define CLONE_SOUNDASSET_ARRAY(name, index) \ +{\ + 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];\ +} + +#define LOAD_SOUNDASSET_ARRAY(name, index)\ +if (m##name##AssetId[index] != StringTable->EmptyString())\ +{\ + S32 assetState = SoundAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]);\ + if (assetState == SoundAsset::Ok )\ + {\ + m##name##Name[index] = StringTable->EmptyString();\ + }\ + else Con::warnf("Warning: %s::LOAD_IMAGEASSET(%s)-%s", mClassName, m##name##AssetId[index], ImageAsset::getAssetErrstrn(assetState).c_str());\ +} + +#define PACKDATA_SOUNDASSET_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_SOUNDASSET_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_SOUNDASSET_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_SOUNDASSET_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 // _ASSET_BASE_H_ From 1ea693fea637a065f17446aefc8f3408b7f684d6 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 Sep 2021 10:49:34 +0100 Subject: [PATCH 03/37] SoundAsset Array Few fixes to soundasset array to stop it complaining --- Engine/source/T3D/assets/SoundAsset.cpp | 1 + Engine/source/T3D/assets/SoundAsset.h | 98 ++++++++++++++----------- Engine/source/T3D/fx/lightning.cpp | 29 ++++---- Engine/source/T3D/fx/lightning.h | 13 +++- 4 files changed, 80 insertions(+), 61 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.cpp b/Engine/source/T3D/assets/SoundAsset.cpp index d00c0dbe2..72a3a2526 100644 --- a/Engine/source/T3D/assets/SoundAsset.cpp +++ b/Engine/source/T3D/assets/SoundAsset.cpp @@ -107,6 +107,7 @@ ConsoleSetType(TypeSoundAssetId) //----------------------------------------------------------------------------- SoundAsset::SoundAsset() + : AssetBase() { mSoundFile = StringTable->EmptyString(); mSoundPath = StringTable->EmptyString(); diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 757d85ab6..adacf2d9b 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -362,43 +362,51 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText #pragma region Arrayed Asset Macros -#define DECLARE_SOUNDASSET_ARRAY(className, name, max) public: \ - static const U32 sm##name##count = max;\ +#define DECLARE_SOUNDASSET_ARRAY(className,name,max) public: \ + static const U32 sm##name##Count = max;\ Resource m##name[max];\ StringTableEntry m##name##Name[max]; \ StringTableEntry m##name##AssetId[max];\ - AssetPtr m##name##Asset[max] = NULL;\ - SFXProfile* m##name##Profile[max] = NULL;\ + AssetPtr m##name##Asset[max];\ + SFXProfile* m##name##Profile[max];\ public: \ - const StringTableEntry get##name##File(const U32& id) const { return m##name##Name[id]; }\ - void set##name##File(const FileName &_in, const U32& id) { m##name##Name[id] = StringTable->insert(_in.c_str());}\ - const AssetPtr & get##name##Asset(const U32& id) const { return m##name##Asset[id]; }\ - void set##name##Asset(const AssetPtr &_in, const U32& id) { m##name##Asset[id] = _in;}\ + const StringTableEntry get##name##File(const U32& index) const { return m##name##Name[index]; }\ + void set##name##File(const FileName &_in, const U32& index) { m##name##Name[index] = StringTable->insert(_in.c_str());}\ + const AssetPtr & get##name##Asset(const U32& index) const { return m##name##Asset[index]; }\ + void set##name##Asset(const AssetPtr &_in, const U32& index) { m##name##Asset[index] = _in;}\ \ - bool _set##name(StringTableEntry _in, const U32& id)\ + bool _set##name(StringTableEntry _in, const U32& index)\ {\ - if(m##name##AssetId[id] != _in || m##name##Name[id] != _in)\ + if(m##name##AssetId[index] != _in || m##name##Name[index] != _in)\ {\ + if(index >= sm##name##Count || index < 0) \ + return false;\ if (_in == NULL || _in == StringTable->EmptyString())\ {\ - if(id >= sm##name##Count || id < 0) \ - return false;\ - m##name##Name[id] = StringTable->EmptyString();\ - m##name##AssetId[id] = StringTable->EmptyString();\ - m##name##Asset[id] = NULL;\ - m##name[id] = NULL;\ + m##name##Name[index] = StringTable->EmptyString();\ + m##name##AssetId[index] = StringTable->EmptyString();\ + m##name##Asset[index] = NULL;\ + m##name[index] = NULL;\ + return true;\ + }\ + else if(_in[0] == '$' || _in[0] == '#')\ + {\ + m##name##Name[index] = _in;\ + m##name##AssetId[index] = StringTable->EmptyString();\ + m##name##Asset[index] = NULL;\ + m##name[index] = NULL;\ return true;\ }\ \ if (AssetDatabase.isDeclaredAsset(_in))\ {\ - m##name##AssetId[id] = _in;\ + m##name##AssetId[index] = _in;\ \ - U32 assetState = SoundAsset::getAssetById(m##name##AssetId[id], &m##name##Asset[id]);\ + U32 assetState = SoundAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]);\ \ if (SoundAsset::Ok == assetState)\ {\ - m##name##Name[id] = StringTable->EmptyString();\ + m##name##Name[index] = StringTable->EmptyString();\ }\ }\ else\ @@ -406,56 +414,58 @@ public: \ StringTableEntry assetId = SoundAsset::getAssetIdByFileName(_in);\ if (assetId != StringTable->EmptyString())\ {\ - m##name##AssetId[id] = assetId;\ - if(SoundAsset::getAssetById(m##name##AssetId, &m##name##Asset) == SoundAsset::Ok)\ + m##name##AssetId[index] = assetId;\ + if(SoundAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]) == SoundAsset::Ok)\ {\ - m##name##Name[id] = StringTable->EmptyString();\ + m##name##Name[index] = StringTable->EmptyString();\ }\ }\ else\ {\ - m##name##Name[id] = _in;\ - m##name##AssetId[id] = StringTable->EmptyString();\ - m##name##Asset[id] = NULL;\ + m##name##Name[index] = _in;\ + m##name##AssetId[index] = StringTable->EmptyString();\ + m##name##Asset[index] = NULL;\ }\ }\ }\ - if (get##name(id) != StringTable->EmptyString() && m##name##Asset[id].notNull())\ + if (get##name(index) != StringTable->EmptyString() && m##name##Asset[index].notNull())\ {\ - m##name[id] = m##name##Asset[id]->getSoundResource();\ + m##name[index] = m##name##Asset[index]->getSoundResource();\ }\ else\ {\ - m##name[id] = NULL;\ + m##name[index] = NULL;\ }\ \ - if (m##name##Asset[id].notNull() && m##name##Asset[id]->getStatus() != SoundAsset::Ok)\ + if (m##name##Asset[index].notNull() && m##name##Asset[index]->getStatus() != SoundAsset::Ok)\ {\ - Con::errorf("%s(%s)::_set%s(%i) - sound asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name),id, _in, SoundAsset::getAssetErrstrn(m##name##Asset->getStatus()).c_str());\ + Con::errorf("%s(%s)::_set%s(%i) - sound asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name),index, _in, SoundAsset::getAssetErrstrn(m##name##Asset[index]->getStatus()).c_str());\ return false; \ }\ - else if (!m##name)\ + else if (!m##name[index])\ {\ - Con::errorf("%s(%s)::_set%s(%i) - Couldn't load sound \"%s\"", macroText(className), getName(), macroText(name),id, _in);\ + Con::errorf("%s(%s)::_set%s(%i) - Couldn't load sound \"%s\"", macroText(className), getName(), macroText(name),index, _in);\ return false;\ }\ return true;\ }\ \ - const StringTableEntry get##name(const U32& id) const\ + const StringTableEntry get##name(const U32& index) const\ {\ - if (m##name##Asset[id] && (m##name##Asset[id]->getSoundPath() != StringTable->EmptyString()))\ - return m##name##Asset[id]->getSoundPath();\ - else if (m##name##AssetId[id] != StringTable->EmptyString())\ - return m##name##AssetId[id];\ - else if (m##name##Name[id] != StringTable->EmptyString())\ - return StringTable->insert(m##name##Name[id]);\ + if (m##name##Asset[index] && (m##name##Asset[index]->getSoundPath() != StringTable->EmptyString()))\ + return m##name##Asset[index]->getSoundPath();\ + 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 get##name##Resource() \ + Resource get##name##Resource(const U32& id) \ {\ - return m##name;\ + if(id >= sm##name##Count || id < 0)\ + return ResourceManager::get().load( "" );\ + return m##name[id];\ } #define DECLARE_SOUNDASSET_ARRAY_SETGET(className, name)\ @@ -512,14 +522,14 @@ DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , a #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, docs) \ - addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs)); \ + addProtectedField(#name, TypeSoundFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs)); \ addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.)); #else #define INITPERSISTFIELD_SOUNDASSET_ARRAY(name, arraySize, consoleClass, docs) \ - addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ - addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.)); + addProtectedField(#name, TypeSoundFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addProtectedField(assetText(name, Asset), TypeSoundAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.)); #endif diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 20925ec58..efc521319 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -241,7 +241,7 @@ LightningData::LightningData() INIT_SOUNDASSET(StrikeSound); for (S32 i = 0; i < MaxThunders; i++) - thunderSounds[i] = NULL; + INIT_SOUNDASSET_ARRAY(ThunderSound, MaxThunders); for (S32 i = 0; i < MaxTextures; i++) { @@ -263,10 +263,8 @@ void LightningData::initPersistFields() INITPERSISTFIELD_SOUNDASSET(StrikeSound, LightningData, "Sound to play when lightning STRIKES!"); - addField( "thunderSounds", TYPEID< SFXTrack >(), Offset(thunderSounds, LightningData), MaxThunders, - "@brief List of thunder sound effects to play.\n\n" - "A random one of these sounds will be played shortly after each strike " - "occurs." ); + INITPERSISTFIELD_SOUNDASSET_ARRAY(ThunderSound, MaxThunders, LightningData, "Sounds for thunder."); + addField( "strikeTextures", TypeString, Offset(strikeTextureNames, LightningData), MaxTextures, "List of textures to use to render lightning strikes." ); @@ -292,15 +290,18 @@ bool LightningData::preload(bool server, String &errorStr) //dQsort(thunderSounds, MaxThunders, sizeof(SFXTrack*), cmpSounds); for (S32 i = 0; i < MaxThunders; i++) { - if (thunderSounds[i]!= NULL) numThunders++; + if (mThunderSound[i] == NULL) + { + _setThunderSound(getThunderSound(i), i); + } } if (server == false) { String sfxErrorStr; for (U32 i = 0; i < MaxThunders; i++) { - if( !sfxResolve( &thunderSounds[ i ], sfxErrorStr ) ) - Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str()); + if (!getThunderProfile(i)) + Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder."); } if(!getSFXProfile()) @@ -330,8 +331,7 @@ void LightningData::packData(BitStream* stream) U32 i; for (i = 0; i < MaxThunders; i++) { - if (stream->writeFlag(thunderSounds[i])) - sfxWrite(stream, thunderSounds[i]); + PACKDATA_SOUNDASSET_ARRAY(ThunderSound, i); } stream->writeInt(mNumStrikeTextures, 4); @@ -349,10 +349,7 @@ void LightningData::unpackData(BitStream* stream) U32 i; for (i = 0; i < MaxThunders; i++) { - if (stream->readFlag()) - sfxRead(stream, &thunderSounds[i]); - else - thunderSounds[i] = NULL; + UNPACKDATA_SOUNDASSET_ARRAY(ThunderSound, i); } mNumStrikeTextures = stream->readInt(4); @@ -585,7 +582,7 @@ void Lightning::scheduleThunder(Strike* newStrike) if (t <= 0.03f) { // If it's really close, just play it... U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1); - SFX->playOnce(mDataBlock->thunderSounds[thunder]); + SFX->playOnce(mDataBlock->getThunderProfile(thunder)); } else { Thunder* pThunder = new Thunder; pThunder->tRemaining = t; @@ -652,7 +649,7 @@ void Lightning::advanceTime(F32 dt) // Play the sound... U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1); - SFX->playOnce(mDataBlock->thunderSounds[thunder]); + SFX->playOnce(mDataBlock->getThunderProfile(thunder)); } else { pThunderWalker = &((*pThunderWalker)->next); } diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h index 78ef4a20b..1e04bd61d 100644 --- a/Engine/source/T3D/fx/lightning.h +++ b/Engine/source/T3D/fx/lightning.h @@ -63,7 +63,10 @@ class LightningData : public GameBaseData //-------------------------------------- Console set variables public: - SFXTrack* thunderSounds[MaxThunders]; + //SFXTrack* thunderSounds[MaxThunders]; + + DECLARE_SOUNDASSET_ARRAY(LightningData, ThunderSound, MaxThunders); + DECLARE_SOUNDASSET_ARRAY_SETGET(LightningData, ThunderSound); DECLARE_SOUNDASSET(LightningData, StrikeSound); DECLARE_SOUNDASSET_SETGET(LightningData, StrikeSound); @@ -91,6 +94,14 @@ class LightningData : public GameBaseData DECLARE_CONOBJECT(LightningData); static void initPersistFields(); + SFXProfile* getThunderProfile(U32 id) + { + if (mThunderSoundAsset[id] != NULL) + return mThunderSoundAsset[id]->getSfxProfile(); + else + return NULL; + } + SFXProfile* getSFXProfile() { if (mStrikeSoundAsset.notNull()) return mStrikeSoundAsset->getSfxProfile(); From 704eb27600bccb34e4713b787c1470f4a093db08 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 Sep 2021 13:07:50 +0100 Subject: [PATCH 04/37] More Implements -Most Vehicles and FX classes -Vehicle classes may need more preloads for assets. --- Engine/source/T3D/fx/explosion.h | 1 - Engine/source/T3D/fx/lightning.cpp | 2 +- Engine/source/T3D/fx/lightning.h | 1 - Engine/source/T3D/fx/precipitation.h | 1 - Engine/source/T3D/projectile.cpp | 25 +++--- Engine/source/T3D/projectile.h | 10 ++- Engine/source/T3D/rigidShape.cpp | 58 +++++++------ Engine/source/T3D/rigidShape.h | 25 +++++- Engine/source/T3D/vehicles/hoverVehicle.cpp | 43 +++++----- Engine/source/T3D/vehicles/hoverVehicle.h | 10 ++- Engine/source/T3D/vehicles/vehicle.cpp | 86 ++++++++----------- Engine/source/T3D/vehicles/vehicle.h | 26 +++++- Engine/source/T3D/vehicles/wheeledVehicle.cpp | 38 ++++---- Engine/source/T3D/vehicles/wheeledVehicle.h | 12 ++- 14 files changed, 191 insertions(+), 147 deletions(-) diff --git a/Engine/source/T3D/fx/explosion.h b/Engine/source/T3D/fx/explosion.h index ae01c4bee..20eadcd88 100644 --- a/Engine/source/T3D/fx/explosion.h +++ b/Engine/source/T3D/fx/explosion.h @@ -70,7 +70,6 @@ class ExplosionData : public GameBaseData { S32 particleDensity; F32 particleRadius; - //SFXTrack* soundProfile; DECLARE_SOUNDASSET(ExplosionData, Sound); DECLARE_SOUNDASSET_SETGET(ExplosionData, Sound); diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index efc521319..73a63550e 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -290,7 +290,7 @@ bool LightningData::preload(bool server, String &errorStr) //dQsort(thunderSounds, MaxThunders, sizeof(SFXTrack*), cmpSounds); for (S32 i = 0; i < MaxThunders; i++) { - if (mThunderSound[i] == NULL) + if (mThunderSound[i]) { _setThunderSound(getThunderSound(i), i); } diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h index 1e04bd61d..7f706d9f8 100644 --- a/Engine/source/T3D/fx/lightning.h +++ b/Engine/source/T3D/fx/lightning.h @@ -63,7 +63,6 @@ class LightningData : public GameBaseData //-------------------------------------- Console set variables public: - //SFXTrack* thunderSounds[MaxThunders]; DECLARE_SOUNDASSET_ARRAY(LightningData, ThunderSound, MaxThunders); DECLARE_SOUNDASSET_ARRAY_SETGET(LightningData, ThunderSound); diff --git a/Engine/source/T3D/fx/precipitation.h b/Engine/source/T3D/fx/precipitation.h index cdef0c2a8..e8114b040 100644 --- a/Engine/source/T3D/fx/precipitation.h +++ b/Engine/source/T3D/fx/precipitation.h @@ -46,7 +46,6 @@ class PrecipitationData : public GameBaseData typedef GameBaseData Parent; public: - //SFXTrack* soundProfile; DECLARE_SOUNDASSET(PrecipitationData, Sound); DECLARE_SOUNDASSET_SETGET(PrecipitationData, Sound); diff --git a/Engine/source/T3D/projectile.cpp b/Engine/source/T3D/projectile.cpp index 739daf4a5..678fde550 100644 --- a/Engine/source/T3D/projectile.cpp +++ b/Engine/source/T3D/projectile.cpp @@ -146,7 +146,7 @@ ProjectileData::ProjectileData() { INIT_SHAPEASSET(ProjectileShape); - sound = NULL; + INIT_SOUNDASSET(ProjectileSound); explosion = NULL; explosionId = 0; @@ -217,7 +217,7 @@ ProjectileData::ProjectileData(const ProjectileData& other, bool temp_clone) : G splashId = other.splashId; // -- for pack/unpack of splash ptr decal = other.decal; decalId = other.decalId; // -- for pack/unpack of decal ptr - sound = other.sound; + CLONE_SOUNDASSET(ProjectileSound); lightDesc = other.lightDesc; lightDescId = other.lightDescId; // -- for pack/unpack of lightDesc ptr CLONE_SHAPEASSET(ProjectileShape);// -- TSShape loads using mProjectileShapeName @@ -252,8 +252,7 @@ void ProjectileData::initPersistFields() "@brief Scale to apply to the projectile's size.\n\n" "@note This is applied after SceneObject::scale\n"); - addField("sound", TypeSFXTrackName, Offset(sound, ProjectileData), - "@brief SFXTrack datablock used to play sounds while in flight.\n\n"); + INITPERSISTFIELD_SOUNDASSET(ProjectileSound, ProjectileData, "The sound for the projectile."); addField("explosion", TYPEID< ExplosionData >(), Offset(explosion, ProjectileData), "@brief Explosion datablock used when the projectile explodes outside of water.\n\n"); @@ -368,9 +367,8 @@ bool ProjectileData::preload(bool server, String &errorStr) if (Sim::findObject(decalId, decal) == false) Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId); - String sfxErrorStr; - if( !sfxResolve( &sound, sfxErrorStr ) ) - Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet: %s", sfxErrorStr.c_str()); + if( !getProjectileSound() ) + Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid asset"); if (!lightDesc && lightDescId != 0) if (Sim::findObject(lightDescId, lightDesc) == false) @@ -436,8 +434,7 @@ void ProjectileData::packData(BitStream* stream) if (stream->writeFlag(decal != NULL)) stream->writeRangedU32(decal->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast); - - sfxWrite( stream, sound ); + PACKDATA_SOUNDASSET(ProjectileSound); if ( stream->writeFlag(lightDesc != NULL)) stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst, @@ -497,8 +494,8 @@ void ProjectileData::unpackData(BitStream* stream) if (stream->readFlag()) decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); - - sfxRead( stream, &sound ); + + UNPACKDATA_SOUNDASSET(ProjectileSound); if (stream->readFlag()) lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); @@ -882,8 +879,8 @@ bool Projectile::onNewDataBlock( GameBaseData *dptr, bool reload ) SFX_DELETE( mSound ); - if ( mDataBlock->sound ) - mSound = SFX->createSource( mDataBlock->sound ); + if ( mDataBlock->getProjectileSound() ) + mSound = SFX->createSource( mDataBlock->getSFXProfile() ); } return true; @@ -1097,7 +1094,7 @@ void Projectile::explode( const Point3F &p, const Point3F &n, const U32 collideT void Projectile::updateSound() { - if (!mDataBlock->sound) + if (!mDataBlock->getProjectileSound()) return; if ( mSound ) diff --git a/Engine/source/T3D/projectile.h b/Engine/source/T3D/projectile.h index 6209ba531..f340d54a7 100644 --- a/Engine/source/T3D/projectile.h +++ b/Engine/source/T3D/projectile.h @@ -44,6 +44,7 @@ #include "lighting/lightInfo.h" #endif +#include "T3D/assets/SoundAsset.h" #include "T3D/assets/ShapeAsset.h" class ExplosionData; @@ -115,7 +116,14 @@ public: DecalData *decal; // (impact) Decal Datablock S32 decalId; // (impact) Decal ID - SFXTrack* sound; // Projectile Sound + DECLARE_SOUNDASSET(ProjectileData, ProjectileSound); + DECLARE_SOUNDASSET_SETGET(ProjectileData, ProjectileSound); + SFXProfile* getSFXProfile() { + if (mProjectileSoundAsset.notNull()) + return mProjectileSoundAsset->getSfxProfile(); + else + return NULL; + } LightDescription *lightDesc; S32 lightDescId; diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index cf26f8ea9..73c8925cf 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -238,7 +238,7 @@ RigidShapeData::RigidShapeData() density = 4; for (S32 i = 0; i < Body::MaxSounds; i++) - body.sound[i] = 0; + INIT_SOUNDASSET_ARRAY(BodySounds, i); dustEmitter = NULL; dustID = 0; @@ -256,7 +256,8 @@ RigidShapeData::RigidShapeData() hardSplashSoundVel = 3.0; enablePhysicsRep = true; - dMemset(waterSound, 0, sizeof(waterSound)); + for (S32 i = 0; i < Sounds::MaxSounds; i++) + INIT_SOUNDASSET_ARRAY(WaterSounds, i); dragForce = 0; vertFactor = 0.25; @@ -299,7 +300,10 @@ bool RigidShapeData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { for (S32 i = 0; i < Body::MaxSounds; i++) - sfxResolve( &body.sound[ i ], errorStr ); + if (mBodySounds[i]) + { + _setBodySounds(getBodySounds(i), i); + } } if( !dustEmitter && dustID != 0 ) @@ -354,8 +358,10 @@ void RigidShapeData::packData(BitStream* stream) stream->write(body.restitution); stream->write(body.friction); - for( U32 i = 0; i < Body::MaxSounds; ++ i ) - sfxWrite( stream, body.sound[ i ] ); + for (U32 i = 0; i < Body::MaxSounds; ++i) + { + PACKDATA_SOUNDASSET_ARRAY(BodySounds, i); + } stream->write(minImpactSpeed); stream->write(softImpactSpeed); @@ -384,8 +390,10 @@ void RigidShapeData::packData(BitStream* stream) stream->write(enablePhysicsRep); // write the water sound profiles - for( U32 i = 0; i < MaxSounds; ++ i ) - sfxWrite( stream, waterSound[ i ] ); + for (U32 i = 0; i < Sounds::MaxSounds; ++i) + { + PACKDATA_SOUNDASSET_ARRAY(WaterSounds, i); + } if (stream->writeFlag( dustEmitter )) stream->writeRangedU32( dustEmitter->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast ); @@ -413,8 +421,10 @@ void RigidShapeData::unpackData(BitStream* stream) stream->read(&body.restitution); stream->read(&body.friction); - for( U32 i = 0; i < Body::MaxSounds; i++) - sfxRead( stream, &body.sound[ i ] ); + for (U32 i = 0; i < Body::Sounds::MaxSounds; i++) + { + UNPACKDATA_SOUNDASSET_ARRAY(BodySounds, i); + } stream->read(&minImpactSpeed); stream->read(&softImpactSpeed); @@ -443,8 +453,10 @@ void RigidShapeData::unpackData(BitStream* stream) stream->read(&enablePhysicsRep); // write the water sound profiles - for( U32 i = 0; i < MaxSounds; ++ i ) - sfxRead( stream, &waterSound[ i ] ); + for (U32 i = 0; i < Sounds::MaxSounds; ++i) + { + UNPACKDATA_SOUNDASSET_ARRAY(WaterSounds, i); + } if( stream->readFlag() ) dustID = (S32) stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); @@ -516,21 +528,15 @@ void RigidShapeData::initPersistFields() addGroup( "Sounds" ); - addField("softImpactSound", TypeSFXTrackName, Offset(body.sound[Body::SoftImpactSound], RigidShapeData), - "Sound to play when body impacts with at least softImageSpeed but less than hardImpactSpeed." ); - addField("hardImpactSound", TypeSFXTrackName, Offset(body.sound[Body::HardImpactSound], RigidShapeData), - "Sound to play when body impacts with at least hardImpactSpeed." ); + INITPERSISTFIELD_SOUNDASSET_ARRAY(BodySounds, Body::Sounds::MaxSounds, RigidShapeData, "Sounds for body."); addField("exitSplashSoundVelocity", TypeF32, Offset(exitSplashSoundVel, RigidShapeData), "The minimum velocity at which the exit splash sound will be played when emerging from water.\n"); addField("softSplashSoundVelocity", TypeF32, Offset(softSplashSoundVel, RigidShapeData),"The minimum velocity at which the soft splash sound will be played when impacting water.\n"); addField("mediumSplashSoundVelocity", TypeF32, Offset(medSplashSoundVel, RigidShapeData), "The minimum velocity at which the medium splash sound will be played when impacting water.\n"); addField("hardSplashSoundVelocity", TypeF32, Offset(hardSplashSoundVel, RigidShapeData), "The minimum velocity at which the hard splash sound will be played when impacting water.\n"); - addField("exitingWater", TypeSFXTrackName, Offset(waterSound[ExitWater], RigidShapeData), "The AudioProfile will be used to produce sounds when emerging from water.\n"); - addField("impactWaterEasy", TypeSFXTrackName, Offset(waterSound[ImpactSoft], RigidShapeData), "The AudioProfile will be used to produce sounds when a soft impact with water occurs.\n"); - addField("impactWaterMedium", TypeSFXTrackName, Offset(waterSound[ImpactMedium], RigidShapeData), "The AudioProfile will be used to produce sounds when a medium impact with water occurs.\n"); - addField("impactWaterHard", TypeSFXTrackName, Offset(waterSound[ImpactHard], RigidShapeData), "The AudioProfile will be used to produce sounds when a hard impact with water occurs.\n"); - addField("waterWakeSound", TypeSFXTrackName, Offset(waterSound[Wake], RigidShapeData), "The AudioProfile will be used to produce sounds when a water wake is displayed.\n"); + INITPERSISTFIELD_SOUNDASSET_ARRAY(WaterSounds, Sounds::MaxSounds, RigidShapeData, "Sounds for interacting with water."); + endGroup( "Sounds" ); addGroup( "Camera" ); @@ -1155,27 +1161,27 @@ void RigidShape::updatePos(F32 dt) if (collSpeed >= mDataBlock->softImpactSpeed) impactSound = RigidShapeData::Body::SoftImpactSound; - if (impactSound != -1 && mDataBlock->body.sound[impactSound] != NULL) - SFX->playOnce(mDataBlock->body.sound[impactSound], &getTransform()); + if (impactSound != -1 && mDataBlock->getBodySounds(impactSound) != NULL) + SFX->playOnce(mDataBlock->getBodySoundProfile(impactSound), &getTransform()); } // Water volume sounds F32 vSpeed = getVelocity().len(); if (!inLiquid && mWaterCoverage >= 0.8f) { if (vSpeed >= mDataBlock->hardSplashSoundVel) - SFX->playOnce(mDataBlock->waterSound[RigidShapeData::ImpactHard], &getTransform()); + SFX->playOnce(mDataBlock->getWaterSoundProfile(RigidShapeData::ImpactHard), &getTransform()); else if (vSpeed >= mDataBlock->medSplashSoundVel) - SFX->playOnce(mDataBlock->waterSound[RigidShapeData::ImpactMedium], &getTransform()); + SFX->playOnce(mDataBlock->getWaterSoundProfile(RigidShapeData::ImpactMedium), &getTransform()); else if (vSpeed >= mDataBlock->softSplashSoundVel) - SFX->playOnce(mDataBlock->waterSound[RigidShapeData::ImpactSoft], &getTransform()); + SFX->playOnce(mDataBlock->getWaterSoundProfile(RigidShapeData::ImpactSoft), &getTransform()); inLiquid = true; } else if (inLiquid && mWaterCoverage < 0.8f) { if (vSpeed >= mDataBlock->exitSplashSoundVel) - SFX->playOnce(mDataBlock->waterSound[RigidShapeData::ExitWater], &getTransform()); + SFX->playOnce(mDataBlock->getWaterSoundProfile(RigidShapeData::ExitWater), &getTransform()); inLiquid = false; } } diff --git a/Engine/source/T3D/rigidShape.h b/Engine/source/T3D/rigidShape.h index 0389f2a72..5fc6ee786 100644 --- a/Engine/source/T3D/rigidShape.h +++ b/Engine/source/T3D/rigidShape.h @@ -35,6 +35,8 @@ #include "T3D/physics/physicsBody.h" #endif +#include "T3D/assets/SoundAsset.h" + class ParticleEmitter; class ParticleEmitterData; class ClippedPolyList; @@ -57,11 +59,21 @@ class RigidShapeData : public ShapeBaseData HardImpactSound, MaxSounds, }; - SFXTrack* sound[MaxSounds]; F32 restitution; F32 friction; } body; + DECLARE_SOUNDASSET_ARRAY(RigidShapeData, BodySounds, Body::Sounds::MaxSounds) + DECLARE_SOUNDASSET_ARRAY_SETGET(RigidShapeData, BodySounds); + + SFXProfile* getBodySoundProfile(U32 id) + { + if (mBodySoundsAsset[id] != NULL) + return mBodySoundsAsset[id]->getSfxProfile(); + else + return NULL; + } + enum RigidShapeConsts { VC_NUM_DUST_EMITTERS = 1, @@ -79,7 +91,16 @@ class RigidShapeData : public ShapeBaseData Wake, MaxSounds }; - SFXTrack* waterSound[MaxSounds]; + DECLARE_SOUNDASSET_ARRAY(RigidShapeData, WaterSounds, Sounds::MaxSounds) + DECLARE_SOUNDASSET_ARRAY_SETGET(RigidShapeData, WaterSounds); + + SFXProfile* getWaterSoundProfile(U32 id) + { + if (mWaterSoundsAsset[id] != NULL) + return mWaterSoundsAsset[id]->getSfxProfile(); + else + return NULL; + } F32 exitSplashSoundVel; F32 softSplashSoundVel; diff --git a/Engine/source/T3D/vehicles/hoverVehicle.cpp b/Engine/source/T3D/vehicles/hoverVehicle.cpp index ee49b917f..404f54506 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.cpp +++ b/Engine/source/T3D/vehicles/hoverVehicle.cpp @@ -152,7 +152,7 @@ HoverVehicleData::HoverVehicleData() jetEmitter[j] = 0; for (S32 i = 0; i < MaxSounds; i++) - sound[i] = 0; + INIT_SOUNDASSET_ARRAY(HoverSounds, i); } HoverVehicleData::~HoverVehicleData() @@ -232,14 +232,8 @@ void HoverVehicleData::initPersistFields() addField( "pitchForce", TypeF32, Offset(pitchForce, HoverVehicleData), "Pitch (rotation about the X-axis) force applied when steering in the y-axis direction." ); - addField( "jetSound", TYPEID< SFXProfile >(), Offset(sound[JetSound], HoverVehicleData), - "Looping sound played when the vehicle is jetting." ); - addField( "engineSound", TYPEID< SFXProfile >(), Offset(sound[EngineSound], HoverVehicleData), - "Looping engine sound.\nThe volume is dynamically adjusted based on the " - "current thrust level." ); - addField( "floatSound", TYPEID< SFXProfile >(), Offset(sound[FloatSound], HoverVehicleData), - "Looping sound played while the vehicle is floating.\n\n@see stabMinLen" ); - + INITPERSISTFIELD_SOUNDASSET_ARRAY(HoverSounds, Sounds::MaxSounds, HoverVehicleData, "Sounds for hover vehicle."); + addField( "dustTrailEmitter", TYPEID< ParticleEmitterData >(), Offset(dustTrailEmitter, HoverVehicleData), "Emitter to generate particles for the vehicle's dust trail.\nThe trail " "of dust particles is generated only while the vehicle is moving." ); @@ -312,8 +306,11 @@ bool HoverVehicleData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { for (S32 i = 0; i < MaxSounds; i++) - if (sound[i]) - Sim::findObject(SimObjectId((uintptr_t)sound[i]),sound[i]); + if (mHoverSounds[i]) + { + _setHoverSounds(getHoverSounds(i), i); + } + for (S32 j = 0; j < MaxJetEmitters; j++) if (jetEmitter[j]) Sim::findObject(SimObjectId((uintptr_t)jetEmitter[j]),jetEmitter[j]); @@ -361,9 +358,9 @@ void HoverVehicleData::packData(BitStream* stream) stream->write(dustTrailFreqMod); for (S32 i = 0; i < MaxSounds; i++) - if (stream->writeFlag(sound[i])) - stream->writeRangedU32(mPacked ? SimObjectId((uintptr_t)sound[i]): - sound[i]->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast); + { + PACKDATA_SOUNDASSET_ARRAY(HoverSounds, i); + } for (S32 j = 0; j < MaxJetEmitters; j++) { @@ -410,9 +407,9 @@ void HoverVehicleData::unpackData(BitStream* stream) stream->read(&dustTrailFreqMod); for (S32 i = 0; i < MaxSounds; i++) - sound[i] = stream->readFlag()? - (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, - DataBlockObjectIdLast): 0; + { + UNPACKDATA_SOUNDASSET_ARRAY(HoverSounds, i); + } for (S32 j = 0; j < MaxJetEmitters; j++) { jetEmitter[j] = NULL; @@ -539,14 +536,14 @@ bool HoverVehicle::onNewDataBlock(GameBaseData* dptr, bool reload) SFX_DELETE( mFloatSound ); SFX_DELETE( mJetSound ); - if ( mDataBlock->sound[HoverVehicleData::EngineSound] ) - mEngineSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::EngineSound], &getTransform() ); + if ( mDataBlock->getHoverSounds(HoverVehicleData::EngineSound) ) + mEngineSound = SFX->createSource( mDataBlock->getHoverSoundProfile(HoverVehicleData::EngineSound), &getTransform() ); - if ( !mDataBlock->sound[HoverVehicleData::FloatSound] ) - mFloatSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::FloatSound], &getTransform() ); + if ( !mDataBlock->getHoverSounds(HoverVehicleData::FloatSound) ) + mFloatSound = SFX->createSource( mDataBlock->getHoverSoundProfile(HoverVehicleData::FloatSound), &getTransform() ); - if ( mDataBlock->sound[HoverVehicleData::JetSound] ) - mJetSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::JetSound], &getTransform() ); + if ( mDataBlock->getHoverSounds(HoverVehicleData::JetSound) ) + mJetSound = SFX->createSource( mDataBlock->getHoverSoundProfile(HoverVehicleData::JetSound), &getTransform() ); } // Todo: Uncomment if this is a "leaf" class diff --git a/Engine/source/T3D/vehicles/hoverVehicle.h b/Engine/source/T3D/vehicles/hoverVehicle.h index 7b44e5987..63ff65977 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.h +++ b/Engine/source/T3D/vehicles/hoverVehicle.h @@ -46,7 +46,15 @@ class HoverVehicleData : public VehicleData FloatSound, MaxSounds }; - SFXProfile* sound[MaxSounds]; + DECLARE_SOUNDASSET_ARRAY(HoverVehicleData, HoverSounds, Sounds::MaxSounds); + DECLARE_SOUNDASSET_ARRAY_SETGET(HoverVehicleData, HoverSounds); + SFXProfile* getHoverSoundProfile(U32 id) + { + if (mHoverSoundsAsset[id] != NULL) + return mHoverSoundsAsset[id]->getSfxProfile(); + else + return NULL; + } enum Jets { // These enums index into a static name list. diff --git a/Engine/source/T3D/vehicles/vehicle.cpp b/Engine/source/T3D/vehicles/vehicle.cpp index c673cd3b7..3aaac0646 100644 --- a/Engine/source/T3D/vehicles/vehicle.cpp +++ b/Engine/source/T3D/vehicles/vehicle.cpp @@ -166,7 +166,9 @@ VehicleData::VehicleData() powerSteering = false; for (S32 i = 0; i < Body::MaxSounds; i++) - body.sound[i] = 0; + { + INIT_SOUNDASSET_ARRAY(VehicleBodySounds, i); + } dustEmitter = NULL; dustID = 0; @@ -189,7 +191,8 @@ VehicleData::VehicleData() medSplashSoundVel = 2.0; hardSplashSoundVel = 3.0; - dMemset(waterSound, 0, sizeof(waterSound)); + for (S32 i = 0; i < Sounds::MaxSounds; i++) + INIT_SOUNDASSET_ARRAY(VehicleWaterSounds, i); collDamageThresholdVel = 20; collDamageMultiplier = 0.05f; @@ -215,8 +218,10 @@ bool VehicleData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { for (S32 i = 0; i < Body::MaxSounds; i++) - if (body.sound[i]) - Sim::findObject(SimObjectId((uintptr_t)body.sound[i]),body.sound[i]); + if (mVehicleBodySounds[i]) + { + _setVehicleBodySounds(getVehicleBodySounds(i), i); + } } if( !dustEmitter && dustID != 0 ) @@ -264,10 +269,9 @@ void VehicleData::packData(BitStream* stream) stream->write(body.restitution); stream->write(body.friction); for (i = 0; i < Body::MaxSounds; i++) - if (stream->writeFlag(body.sound[i])) - stream->writeRangedU32(mPacked ? SimObjectId((uintptr_t)body.sound[i]): - body.sound[i]->getId(),DataBlockObjectIdFirst, - DataBlockObjectIdLast); + { + PACKDATA_SOUNDASSET_ARRAY(VehicleBodySounds, i); + } stream->write(minImpactSpeed); stream->write(softImpactSpeed); @@ -308,9 +312,10 @@ void VehicleData::packData(BitStream* stream) stream->write(enablePhysicsRep); // write the water sound profiles - for(i = 0; i < MaxSounds; i++) - if(stream->writeFlag(waterSound[i])) - stream->writeRangedU32(waterSound[i]->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast); + for (i = 0; i < MaxSounds; i++) + { + PACKDATA_SOUNDASSET_ARRAY(VehicleWaterSounds, i); + } if (stream->writeFlag( dustEmitter )) { @@ -359,11 +364,9 @@ void VehicleData::unpackData(BitStream* stream) stream->read(&body.restitution); stream->read(&body.friction); S32 i; - for (i = 0; i < Body::MaxSounds; i++) { - body.sound[i] = NULL; - if (stream->readFlag()) - body.sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, - DataBlockObjectIdLast); + for (i = 0; i < Body::MaxSounds; i++) + { + UNPACKDATA_SOUNDASSET_ARRAY(VehicleBodySounds, i); } stream->read(&minImpactSpeed); @@ -405,12 +408,10 @@ void VehicleData::unpackData(BitStream* stream) stream->read(&enablePhysicsRep); // write the water sound profiles - for(i = 0; i < MaxSounds; i++) - if(stream->readFlag()) - { - U32 id = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); - waterSound[i] = dynamic_cast( Sim::findObject(id) ); - } + for (i = 0; i < Sounds::MaxSounds; i++) + { + UNPACKDATA_SOUNDASSET_ARRAY(VehicleWaterSounds, i); + } if( stream->readFlag() ) { @@ -491,15 +492,8 @@ void VehicleData::initPersistFields() addField( "bodyFriction", TypeF32, Offset(body.friction, VehicleData), "Collision friction coefficient.\nHow well this object will slide against " "objects it collides with." ); - addField( "softImpactSound", TYPEID< SFXProfile >(), Offset(body.sound[Body::SoftImpactSound], VehicleData), - "@brief Sound to play on a 'soft' impact.\n\n" - "This sound is played if the impact speed is < hardImpactSpeed and >= " - "softImpactSpeed.\n\n" - "@see softImpactSpeed" ); - addField( "hardImpactSound", TYPEID< SFXProfile >(), Offset(body.sound[Body::HardImpactSound], VehicleData), - "@brief Sound to play on a 'hard' impact.\n\n" - "This sound is played if the impact speed >= hardImpactSpeed.\n\n" - "@see hardImpactSpeed" ); + + INITPERSISTFIELD_SOUNDASSET_ARRAY(VehicleBodySounds, Body::Sounds::MaxSounds, VehicleData, "Sounds for vehicle body impacts."); addField( "minImpactSpeed", TypeF32, Offset(minImpactSpeed, VehicleData), "Minimum collision speed for the onImpact callback to be invoked." ); @@ -596,18 +590,8 @@ void VehicleData::initPersistFields() addField( "hardSplashSoundVelocity", TypeF32, Offset(hardSplashSoundVel, VehicleData), "Minimum velocity when entering the water for the imapactWaterHard sound " "to play.\n\n@see impactWaterHard" ); - addField( "exitingWater", TYPEID< SFXProfile >(), Offset(waterSound[ExitWater], VehicleData), - "Sound to play when exiting the water." ); - addField( "impactWaterEasy", TYPEID< SFXProfile >(), Offset(waterSound[ImpactSoft], VehicleData), - "Sound to play when entering the water with speed >= softSplashSoundVelocity " - "and < mediumSplashSoundVelocity." ); - addField( "impactWaterMedium", TYPEID< SFXProfile >(), Offset(waterSound[ImpactMedium], VehicleData), - "Sound to play when entering the water with speed >= mediumSplashSoundVelocity " - "and < hardSplashSoundVelocity." ); - addField( "impactWaterHard", TYPEID< SFXProfile >(), Offset(waterSound[ImpactHard], VehicleData), - "Sound to play when entering the water with speed >= hardSplashSoundVelocity." ); - addField( "waterWakeSound", TYPEID< SFXProfile >(), Offset(waterSound[Wake], VehicleData), - "Looping sound to play while moving through the water." ); + + INITPERSISTFIELD_SOUNDASSET_ARRAY(WaterSounds, Sounds::MaxSounds, VehicleData, "Sounds for interacting with water."); addField( "collDamageThresholdVel", TypeF32, Offset(collDamageThresholdVel, VehicleData), "Minimum collision velocity to cause damage to this vehicle.\nCurrently unused." ); @@ -876,8 +860,8 @@ bool Vehicle::onNewDataBlock(GameBaseData* dptr,bool reload) // costs and makes the system easier to understand. SFX_DELETE( mWakeSound ); - if ( mDataBlock->waterSound[VehicleData::Wake] ) - mWakeSound = SFX->createSource( mDataBlock->waterSound[VehicleData::Wake], &getTransform() ); + if ( mDataBlock->getVehicleWaterSounds(VehicleData::Wake) != NULL ) + mWakeSound = SFX->createSource( mDataBlock->getVehicleWaterSoundProfile(VehicleData::Wake), &getTransform() ); } return true; @@ -1140,27 +1124,27 @@ void Vehicle::updatePos(F32 dt) if (collSpeed >= mDataBlock->softImpactSpeed) impactSound = VehicleData::Body::SoftImpactSound; - if (impactSound != -1 && mDataBlock->body.sound[impactSound] != NULL) - SFX->playOnce( mDataBlock->body.sound[impactSound], &getTransform() ); + if (impactSound != -1 && mDataBlock->getVehicleBodySounds(impactSound) != NULL) + SFX->playOnce( mDataBlock->getVehicleBodySoundProfile(impactSound), &getTransform() ); } // Water volume sounds F32 vSpeed = getVelocity().len(); if (!inLiquid && mWaterCoverage >= 0.8f) { if (vSpeed >= mDataBlock->hardSplashSoundVel) - SFX->playOnce( mDataBlock->waterSound[VehicleData::ImpactHard], &getTransform() ); + SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ImpactHard), &getTransform() ); else if (vSpeed >= mDataBlock->medSplashSoundVel) - SFX->playOnce( mDataBlock->waterSound[VehicleData::ImpactMedium], &getTransform() ); + SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ImpactMedium), &getTransform() ); else if (vSpeed >= mDataBlock->softSplashSoundVel) - SFX->playOnce( mDataBlock->waterSound[VehicleData::ImpactSoft], &getTransform() ); + SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ImpactSoft), &getTransform() ); inLiquid = true; } else if(inLiquid && mWaterCoverage < 0.8f) { if (vSpeed >= mDataBlock->exitSplashSoundVel) - SFX->playOnce( mDataBlock->waterSound[VehicleData::ExitWater], &getTransform() ); + SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ExitWater), &getTransform() ); inLiquid = false; } } diff --git a/Engine/source/T3D/vehicles/vehicle.h b/Engine/source/T3D/vehicles/vehicle.h index 585f81b90..1c26f6cba 100644 --- a/Engine/source/T3D/vehicles/vehicle.h +++ b/Engine/source/T3D/vehicles/vehicle.h @@ -45,11 +45,22 @@ struct VehicleData : public RigidShapeData HardImpactSound, MaxSounds, }; - SFXProfile* sound[MaxSounds]; F32 restitution; F32 friction; } body; + DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleBodySounds, Body::Sounds::MaxSounds) + DECLARE_SOUNDASSET_ARRAY_SETGET(VehicleData, VehicleBodySounds); + + SFXProfile* getVehicleBodySoundProfile(U32 id) + { + if (mVehicleBodySoundsAsset[id] != NULL) + return mVehicleBodySoundsAsset[id]->getSfxProfile(); + else + return NULL; + } + + enum VehicleConsts { VC_NUM_DUST_EMITTERS = 1, @@ -69,7 +80,18 @@ struct VehicleData : public RigidShapeData Wake, MaxSounds }; - SFXProfile* waterSound[MaxSounds]; + + DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleWaterSounds, Sounds::MaxSounds) + DECLARE_SOUNDASSET_ARRAY_SETGET(VehicleData, VehicleWaterSounds); + + SFXProfile* getVehicleWaterSoundProfile(U32 id) + { + if (mVehicleWaterSoundsAsset[id] != NULL) + return mVehicleWaterSoundsAsset[id]->getSfxProfile(); + else + return NULL; + } + F32 exitSplashSoundVel; F32 softSplashSoundVel; F32 medSplashSoundVel; diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.cpp b/Engine/source/T3D/vehicles/wheeledVehicle.cpp index 36a355cdb..3fbde4af7 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.cpp +++ b/Engine/source/T3D/vehicles/wheeledVehicle.cpp @@ -301,7 +301,7 @@ WheeledVehicleData::WheeledVehicleData() wheelCount = 0; dMemset(&wheel, 0, sizeof(wheel)); for (S32 i = 0; i < MaxSounds; i++) - sound[i] = 0; + INIT_SOUNDASSET_ARRAY(WheeledVehicleSounds, i); } @@ -335,10 +335,9 @@ bool WheeledVehicleData::preload(bool server, String &errorStr) if (!server) { for (S32 i = 0; i < MaxSounds; i++) { - if (!sfxResolve(&sound[i], errorStr)) + if (mWheeledVehicleSounds[i]) { - delete si; - return false; + _setWheeledVehicleSounds(getWheeledVehicleSounds(i), i); } } @@ -438,16 +437,7 @@ bool WheeledVehicleData::mirrorWheel(Wheel* we) void WheeledVehicleData::initPersistFields() { - addField( "jetSound", TYPEID< SFXTrack >(), Offset(sound[JetSound], WheeledVehicleData), - "Looping sound played when the vehicle is jetting." ); - addField( "engineSound", TYPEID< SFXTrack >(), Offset(sound[EngineSound], WheeledVehicleData), - "@brief Looping engine sound.\n\n" - "The pitch is dynamically adjusted based on the current engine RPM" ); - addField("squealSound", TYPEID< SFXTrack >(), Offset(sound[SquealSound], WheeledVehicleData), - "@brief Looping sound played while any of the wheels is slipping.\n\n" - "The volume is dynamically adjusted based on how much the wheels are slipping." ); - addField("WheelImpactSound", TYPEID< SFXTrack >(), Offset(sound[WheelImpactSound], WheeledVehicleData), - "Sound played when the wheels impact the ground.\nCurrently unused." ); + INITPERSISTFIELD_SOUNDASSET_ARRAY(WheeledVehicleSounds, Sounds::MaxSounds, WheeledVehicleData, "Sounds related to wheeled vehicle."); addField("tireEmitter",TYPEID< ParticleEmitterData >(), Offset(tireEmitter, WheeledVehicleData), "ParticleEmitterData datablock used to generate particles from each wheel " @@ -481,7 +471,9 @@ void WheeledVehicleData::packData(BitStream* stream) tireEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast); for (S32 i = 0; i < MaxSounds; i++) - sfxWrite( stream, sound[ i ] ); + { + PACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i); + } stream->write(maxWheelSpeed); stream->write(engineTorque); @@ -498,7 +490,9 @@ void WheeledVehicleData::unpackData(BitStream* stream) DataBlockObjectIdLast): 0; for (S32 i = 0; i < MaxSounds; i++) - sfxRead( stream, &sound[ i ] ); + { + UNPACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i); + } stream->read(&maxWheelSpeed); stream->read(&engineTorque); @@ -683,14 +677,14 @@ bool WheeledVehicle::onNewDataBlock(GameBaseData* dptr, bool reload) SFX_DELETE( mSquealSound ); SFX_DELETE( mJetSound ); - if ( mDataBlock->sound[WheeledVehicleData::EngineSound] ) - mEngineSound = SFX->createSource( mDataBlock->sound[WheeledVehicleData::EngineSound], &getTransform() ); + if ( mDataBlock->getWheeledVehicleSounds(WheeledVehicleData::EngineSound) ) + mEngineSound = SFX->createSource( mDataBlock->getWheeledVehicleSound(WheeledVehicleData::EngineSound), &getTransform() ); - if ( mDataBlock->sound[WheeledVehicleData::SquealSound] ) - mSquealSound = SFX->createSource( mDataBlock->sound[WheeledVehicleData::SquealSound], &getTransform() ); + if ( mDataBlock->getWheeledVehicleSounds(WheeledVehicleData::SquealSound) ) + mSquealSound = SFX->createSource( mDataBlock->getWheeledVehicleSound(WheeledVehicleData::SquealSound), &getTransform() ); - if ( mDataBlock->sound[WheeledVehicleData::JetSound] ) - mJetSound = SFX->createSource( mDataBlock->sound[WheeledVehicleData::JetSound], &getTransform() ); + if ( mDataBlock->getWheeledVehicleSounds(WheeledVehicleData::JetSound) ) + mJetSound = SFX->createSource( mDataBlock->getWheeledVehicleSound(WheeledVehicleData::JetSound), &getTransform() ); } scriptOnNewDataBlock(); diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.h b/Engine/source/T3D/vehicles/wheeledVehicle.h index b096670ca..f5fe52fef 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.h +++ b/Engine/source/T3D/vehicles/wheeledVehicle.h @@ -118,7 +118,17 @@ struct WheeledVehicleData: public VehicleData WheelImpactSound, MaxSounds, }; - SFXTrack* sound[MaxSounds]; + DECLARE_SOUNDASSET_ARRAY(WheeledVehicleData, WheeledVehicleSounds, Sounds::MaxSounds); + DECLARE_SOUNDASSET_ARRAY_SETGET(WheeledVehicleData, WheeledVehicleSounds); + + SFXProfile* getWheeledVehicleSound(U32 id) + { + if (mWheeledVehicleSoundsAsset[id] != NULL) + return mWheeledVehicleSoundsAsset[id]->getSfxProfile(); + else + return NULL; + } + ParticleEmitterData* tireEmitter; From 30b57c0f95c91f2f576b8dcf3933c1c0d3b28329 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 Sep 2021 14:17:10 +0100 Subject: [PATCH 05/37] More turns -Flying Vehicle -Proximinity Mine --- Engine/source/T3D/proximityMine.cpp | 42 ++++++++++---------- Engine/source/T3D/proximityMine.h | 8 +++- Engine/source/T3D/vehicles/flyingVehicle.cpp | 36 +++++++---------- Engine/source/T3D/vehicles/flyingVehicle.h | 10 ++++- 4 files changed, 50 insertions(+), 46 deletions(-) diff --git a/Engine/source/T3D/proximityMine.cpp b/Engine/source/T3D/proximityMine.cpp index 2102ef7e1..12eb60a1a 100644 --- a/Engine/source/T3D/proximityMine.cpp +++ b/Engine/source/T3D/proximityMine.cpp @@ -74,16 +74,16 @@ IMPLEMENT_CALLBACK( ProximityMineData, onExplode, void, ( ProximityMine* obj, Po ProximityMineData::ProximityMineData() : armingDelay( 0 ), armingSequence( -1 ), - armingSound( NULL ), triggerRadius( 5.0f ), triggerSpeed( 1.0f ), autoTriggerDelay( 0 ), triggerOnOwner( false ), triggerDelay( 0 ), triggerSequence( -1 ), - triggerSound( NULL ), explosionOffset( 0.05f ) { + INIT_SOUNDASSET(ArmSound); + INIT_SOUNDASSET(TriggerSound); } void ProximityMineData::initPersistFields() @@ -91,9 +91,9 @@ void ProximityMineData::initPersistFields() addGroup( "Arming" ); addField( "armingDelay", TypeF32, Offset(armingDelay, ProximityMineData), "Delay (in seconds) from when the mine is placed to when it becomes active." ); - addField( "armingSound", TypeSFXTrackName, Offset(armingSound, ProximityMineData), - "Sound to play when the mine is armed (starts at the same time as " - "the armed sequence if defined)." ); + + INITPERSISTFIELD_SOUNDASSET(ArmSound, ProximityMineData, "Arming sound for this proximity mine."); + endGroup( "Arming" ); addGroup( "Triggering" ); @@ -111,9 +111,9 @@ void ProximityMineData::initPersistFields() "Speed above which moving objects within the trigger radius will trigger the mine" ); addField( "triggerDelay", TypeF32, Offset(triggerDelay, ProximityMineData), "Delay (in seconds) from when the mine is triggered until it explodes." ); - addField( "triggerSound", TypeSFXTrackName, Offset(triggerSound, ProximityMineData), - "Sound to play when the mine is triggered (starts at the same time as " - "the triggered sequence if defined)." ); + + INITPERSISTFIELD_SOUNDASSET(TriggerSound, ProximityMineData, "Arming sound for this proximity mine."); + endGroup( "Triggering" ); addGroup( "Explosion" ); @@ -135,12 +135,10 @@ bool ProximityMineData::preload( bool server, String& errorStr ) if ( !server ) { - // Resolve sounds - String sfxErrorStr; - if( !sfxResolve( &armingSound, sfxErrorStr ) ) - Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid packet: %s", sfxErrorStr.c_str() ); - if( !sfxResolve( &triggerSound, sfxErrorStr ) ) - Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid packet: %s", sfxErrorStr.c_str() ); + if( !getArmSound() ) + Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid arming sound." ); + if( !getTriggerSound() ) + Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid trigger sound." ); } if ( mShape ) @@ -158,14 +156,14 @@ void ProximityMineData::packData( BitStream* stream ) Parent::packData( stream ); stream->write( armingDelay ); - sfxWrite( stream, armingSound ); + PACKDATA_SOUNDASSET(ArmSound); stream->write( autoTriggerDelay ); stream->writeFlag( triggerOnOwner ); stream->write( triggerRadius ); stream->write( triggerSpeed ); stream->write( triggerDelay ); - sfxWrite( stream, triggerSound ); + PACKDATA_SOUNDASSET(TriggerSound); } void ProximityMineData::unpackData( BitStream* stream ) @@ -173,14 +171,14 @@ void ProximityMineData::unpackData( BitStream* stream ) Parent::unpackData(stream); stream->read( &armingDelay ); - sfxRead( stream, &armingSound ); + UNPACKDATA_SOUNDASSET(ArmSound); stream->read( &autoTriggerDelay ); triggerOnOwner = stream->readFlag(); stream->read( &triggerRadius ); stream->read( &triggerSpeed ); stream->read( &triggerDelay ); - sfxRead( stream, &triggerSound ); + UNPACKDATA_SOUNDASSET(TriggerSound); } //---------------------------------------------------------------------------- @@ -428,8 +426,8 @@ void ProximityMine::processTick( const Move* move ) mAnimThread = mShapeInstance->addThread(); mShapeInstance->setSequence( mAnimThread, mDataBlock->armingSequence, 0.0f ); } - if ( mDataBlock->armingSound ) - SFX->playOnce( mDataBlock->armingSound, &getRenderTransform() ); + if ( mDataBlock->getArmSound() ) + SFX->playOnce( mDataBlock->getArmSoundAsset()->getSfxProfile(), &getRenderTransform() ); } break; @@ -469,8 +467,8 @@ void ProximityMine::processTick( const Move* move ) mAnimThread = mShapeInstance->addThread(); mShapeInstance->setSequence( mAnimThread, mDataBlock->triggerSequence, 0.0f ); } - if ( mDataBlock->triggerSound ) - SFX->playOnce( mDataBlock->triggerSound, &getRenderTransform() ); + if ( mDataBlock->getTriggerSound() ) + SFX->playOnce( mDataBlock->getTriggerSoundAsset()->getSfxProfile(), &getRenderTransform() ); if ( isServerObject() ) mDataBlock->onTriggered_callback( this, sql.mList[0] ); diff --git a/Engine/source/T3D/proximityMine.h b/Engine/source/T3D/proximityMine.h index 7b448e628..4736c0e16 100644 --- a/Engine/source/T3D/proximityMine.h +++ b/Engine/source/T3D/proximityMine.h @@ -27,6 +27,8 @@ #include "T3D/item.h" #endif +#include "T3D/assets/SoundAsset.h" + class ExplosionData; class SFXTrack; class ProximityMine; @@ -43,7 +45,8 @@ struct ProximityMineData: public ItemData public: F32 armingDelay; S32 armingSequence; - SFXTrack* armingSound; + DECLARE_SOUNDASSET(ProximityMineData, ArmSound); + DECLARE_SOUNDASSET_SETGET(ProximityMineData, ArmSound); F32 autoTriggerDelay; bool triggerOnOwner; @@ -51,7 +54,8 @@ public: F32 triggerSpeed; F32 triggerDelay; S32 triggerSequence; - SFXTrack* triggerSound; + DECLARE_SOUNDASSET(ProximityMineData, TriggerSound); + DECLARE_SOUNDASSET_SETGET(ProximityMineData, TriggerSound); F32 explosionOffset; diff --git a/Engine/source/T3D/vehicles/flyingVehicle.cpp b/Engine/source/T3D/vehicles/flyingVehicle.cpp index e092668d8..64ec41fd6 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.cpp +++ b/Engine/source/T3D/vehicles/flyingVehicle.cpp @@ -116,7 +116,7 @@ FlyingVehicleData::FlyingVehicleData() jetEmitter[j] = 0; for (S32 i = 0; i < MaxSounds; i++) - sound[i] = 0; + INIT_SOUNDASSET_ARRAY(FlyingSounds, i); vertThrustMultiple = 1.0; } @@ -131,8 +131,10 @@ bool FlyingVehicleData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { for (S32 i = 0; i < MaxSounds; i++) - if (sound[i]) - Sim::findObject(SimObjectId((uintptr_t)sound[i]),sound[i]); + if (mFlyingSounds[i]) + { + _setFlyingSounds(getFlyingSounds(i), i); + } for (S32 j = 0; j < MaxJetEmitters; j++) if (jetEmitter[j]) @@ -163,10 +165,8 @@ bool FlyingVehicleData::preload(bool server, String &errorStr) void FlyingVehicleData::initPersistFields() { - addField( "jetSound", TYPEID< SFXProfile >(), Offset(sound[JetSound], FlyingVehicleData), - "Looping sound to play while the vehicle is jetting." ); - addField( "engineSound", TYPEID< SFXProfile >(), Offset(sound[EngineSound], FlyingVehicleData), - "Looping engine sound." ); + + INITPERSISTFIELD_SOUNDASSET_ARRAY(FlyingSounds, Sounds::MaxSounds, FlyingVehicleData, "Sounds for flying vehicle"); addField( "maneuveringForce", TypeF32, Offset(maneuveringForce, FlyingVehicleData), "@brief Maximum X and Y (horizontal plane) maneuvering force.\n\n" @@ -240,11 +240,7 @@ void FlyingVehicleData::packData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { - if (stream->writeFlag(sound[i])) - { - SimObjectId writtenId = mPacked ? SimObjectId((uintptr_t)sound[i]) : sound[i]->getId(); - stream->writeRangedU32(writtenId, DataBlockObjectIdFirst, DataBlockObjectIdLast); - } + PACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i); } for (S32 j = 0; j < MaxJetEmitters; j++) @@ -277,11 +273,9 @@ void FlyingVehicleData::unpackData(BitStream* stream) { Parent::unpackData(stream); - for (S32 i = 0; i < MaxSounds; i++) { - sound[i] = NULL; - if (stream->readFlag()) - sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, - DataBlockObjectIdLast); + for (S32 i = 0; i < MaxSounds; i++) + { + UNPACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i); } for (S32 j = 0; j < MaxJetEmitters; j++) { @@ -374,11 +368,11 @@ bool FlyingVehicle::onNewDataBlock(GameBaseData* dptr, bool reload) SFX_DELETE( mJetSound ); SFX_DELETE( mEngineSound ); - if ( mDataBlock->sound[FlyingVehicleData::EngineSound] ) - mEngineSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::EngineSound], &getTransform() ); + if ( mDataBlock->getFlyingSounds(FlyingVehicleData::EngineSound) ) + mEngineSound = SFX->createSource( mDataBlock->getFlyingSoundProfile(FlyingVehicleData::EngineSound), &getTransform() ); - if ( mDataBlock->sound[FlyingVehicleData::JetSound] ) - mJetSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::JetSound], &getTransform() ); + if ( mDataBlock->getFlyingSounds(FlyingVehicleData::JetSound)) + mJetSound = SFX->createSource( mDataBlock->getFlyingSoundProfile(FlyingVehicleData::JetSound), &getTransform() ); } // Jet Sequences diff --git a/Engine/source/T3D/vehicles/flyingVehicle.h b/Engine/source/T3D/vehicles/flyingVehicle.h index 814b66250..18c3379e1 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.h +++ b/Engine/source/T3D/vehicles/flyingVehicle.h @@ -45,7 +45,15 @@ struct FlyingVehicleData: public VehicleData { EngineSound, MaxSounds, }; - SFXProfile* sound[MaxSounds]; + DECLARE_SOUNDASSET_ARRAY(FlyingVehicleData, FlyingSounds, Sounds::MaxSounds); + DECLARE_SOUNDASSET_ARRAY_SETGET(FlyingVehicleData, FlyingSounds); + SFXProfile* getFlyingSoundProfile(U32 id) + { + if (mFlyingSoundsAsset[id] != NULL) + return mFlyingSoundsAsset[id]->getSfxProfile(); + else + return NULL; + } enum Jets { // These enums index into a static name list. From e9d0f68b55a08e8036c1f858265ed3eb88891714 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 Sep 2021 17:05:11 +0100 Subject: [PATCH 06/37] Preload all soundAsset -Fixed: Preloads need to preload all soundAssets not just the ones it was preloading before. --- Engine/source/T3D/fx/lightning.cpp | 26 ++++++++++---------- Engine/source/T3D/rigidShape.cpp | 11 +++++++++ Engine/source/T3D/vehicles/flyingVehicle.cpp | 3 ++- Engine/source/T3D/vehicles/hoverVehicle.cpp | 1 + Engine/source/T3D/vehicles/vehicle.cpp | 10 ++++++++ 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 73a63550e..7586602d4 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -289,18 +289,18 @@ bool LightningData::preload(bool server, String &errorStr) //dQsort(thunderSounds, MaxThunders, sizeof(SFXTrack*), cmpSounds); - for (S32 i = 0; i < MaxThunders; i++) { - if (mThunderSound[i]) - { - _setThunderSound(getThunderSound(i), i); - } - } - + if (server == false) { - String sfxErrorStr; - for (U32 i = 0; i < MaxThunders; i++) { - if (!getThunderProfile(i)) + for (S32 i = 0; i < MaxThunders; i++) { + if (mThunderSound[i]) + { + _setThunderSound(getThunderSound(i), i); + } + } + + for (U32 j = 0; j < MaxThunders; j++) { + if (!getThunderProfile(j)) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder."); } @@ -308,11 +308,11 @@ bool LightningData::preload(bool server, String &errorStr) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset"); mNumStrikeTextures = 0; - for (U32 i = 0; i < MaxTextures; i++) + for (U32 k = 0; k < MaxTextures; k++) { - if (strikeTextureNames[i][0]) + if (strikeTextureNames[k][0]) { - strikeTextures[i] = GFXTexHandle(strikeTextureNames[i], &GFXStaticTextureProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, i, __LINE__)); + strikeTextures[k] = GFXTexHandle(strikeTextureNames[i], &GFXStaticTextureProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, k, __LINE__)); mNumStrikeTextures++; } } diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index 73c8925cf..475854bbb 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -300,10 +300,21 @@ bool RigidShapeData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { for (S32 i = 0; i < Body::MaxSounds; i++) + { if (mBodySounds[i]) { _setBodySounds(getBodySounds(i), i); } + } + + for (S32 j = 0; j < Sounds::MaxSounds; j++) + { + if (mWaterSounds[j]) + { + _setWaterSounds(getWaterSounds(j), j); + } + } + } if( !dustEmitter && dustID != 0 ) diff --git a/Engine/source/T3D/vehicles/flyingVehicle.cpp b/Engine/source/T3D/vehicles/flyingVehicle.cpp index 64ec41fd6..dcc1f8dd2 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.cpp +++ b/Engine/source/T3D/vehicles/flyingVehicle.cpp @@ -131,11 +131,12 @@ bool FlyingVehicleData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { for (S32 i = 0; i < MaxSounds; i++) + { if (mFlyingSounds[i]) { _setFlyingSounds(getFlyingSounds(i), i); } - + } for (S32 j = 0; j < MaxJetEmitters; j++) if (jetEmitter[j]) Sim::findObject(SimObjectId((uintptr_t)jetEmitter[j]),jetEmitter[j]); diff --git a/Engine/source/T3D/vehicles/hoverVehicle.cpp b/Engine/source/T3D/vehicles/hoverVehicle.cpp index 404f54506..0cddc2c72 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.cpp +++ b/Engine/source/T3D/vehicles/hoverVehicle.cpp @@ -305,6 +305,7 @@ bool HoverVehicleData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { + for (S32 i = 0; i < MaxSounds; i++) if (mHoverSounds[i]) { diff --git a/Engine/source/T3D/vehicles/vehicle.cpp b/Engine/source/T3D/vehicles/vehicle.cpp index 3aaac0646..b773dd58f 100644 --- a/Engine/source/T3D/vehicles/vehicle.cpp +++ b/Engine/source/T3D/vehicles/vehicle.cpp @@ -218,10 +218,20 @@ bool VehicleData::preload(bool server, String &errorStr) // Resolve objects transmitted from server if (!server) { for (S32 i = 0; i < Body::MaxSounds; i++) + { if (mVehicleBodySounds[i]) { _setVehicleBodySounds(getVehicleBodySounds(i), i); } + } + + for (S32 j = 0; j < Sounds::MaxSounds; j++) + { + if (mVehicleWaterSounds[j]) + { + _setVehicleWaterSounds(getVehicleWaterSounds(j), j); + } + } } if( !dustEmitter && dustID != 0 ) From 57aceb60fb0b83bc531b328e70a5ec9c730d9d1f Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 Sep 2021 17:57:16 +0100 Subject: [PATCH 07/37] QOC Code cleaning of unnecessary else' Remove unnecessary dynamic_casts --- Engine/source/T3D/fx/explosion.cpp | 2 +- Engine/source/T3D/fx/explosion.h | 4 ++-- Engine/source/T3D/fx/lightning.cpp | 2 ++ Engine/source/T3D/fx/lightning.h | 8 ++++---- Engine/source/T3D/fx/precipitation.h | 4 ++-- Engine/source/T3D/fx/splash.cpp | 4 +++- Engine/source/T3D/fx/splash.h | 4 ++-- Engine/source/T3D/projectile.h | 5 +++-- Engine/source/T3D/rigidShape.h | 8 ++++---- Engine/source/T3D/vehicles/flyingVehicle.h | 4 ++-- Engine/source/T3D/vehicles/hoverVehicle.h | 4 ++-- Engine/source/T3D/vehicles/vehicle.h | 8 ++++---- Engine/source/T3D/vehicles/wheeledVehicle.h | 4 ++-- 13 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index e842f73e4..6fc59b825 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -1382,7 +1382,7 @@ bool Explosion::explode() resetWorldBox(); } - SFXProfile* sound_prof = dynamic_cast(mDataBlock->getSFXProfile()); + SFXProfile* sound_prof = mDataBlock->getSFXProfile(); if (sound_prof) { soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index); diff --git a/Engine/source/T3D/fx/explosion.h b/Engine/source/T3D/fx/explosion.h index 20eadcd88..37694dd1e 100644 --- a/Engine/source/T3D/fx/explosion.h +++ b/Engine/source/T3D/fx/explosion.h @@ -76,8 +76,8 @@ class ExplosionData : public GameBaseData { SFXProfile* getSFXProfile() { if (mSoundAsset.notNull()) return mSoundAsset->getSfxProfile(); - else - return NULL; + + return NULL; } ParticleEmitterData* particleEmitter; diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 7586602d4..16e234818 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -241,7 +241,9 @@ LightningData::LightningData() INIT_SOUNDASSET(StrikeSound); for (S32 i = 0; i < MaxThunders; i++) + { INIT_SOUNDASSET_ARRAY(ThunderSound, MaxThunders); + } for (S32 i = 0; i < MaxTextures; i++) { diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h index 7f706d9f8..f639db3b2 100644 --- a/Engine/source/T3D/fx/lightning.h +++ b/Engine/source/T3D/fx/lightning.h @@ -97,15 +97,15 @@ class LightningData : public GameBaseData { if (mThunderSoundAsset[id] != NULL) return mThunderSoundAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } SFXProfile* getSFXProfile() { if (mStrikeSoundAsset.notNull()) return mStrikeSoundAsset->getSfxProfile(); - else - return NULL; + + return NULL; } }; diff --git a/Engine/source/T3D/fx/precipitation.h b/Engine/source/T3D/fx/precipitation.h index e8114b040..f9eb4bf02 100644 --- a/Engine/source/T3D/fx/precipitation.h +++ b/Engine/source/T3D/fx/precipitation.h @@ -75,8 +75,8 @@ class PrecipitationData : public GameBaseData SFXProfile* getSFXProfile() { if (mSoundAsset.notNull()) return mSoundAsset->getSfxProfile(); - else - return NULL; + + return NULL; } }; diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index 6af8a0c1a..c046ef1a0 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -97,7 +97,9 @@ SplashData::SplashData() U32 i; for (i = 0; i < NUM_TEX; i++) + { INIT_IMAGEASSET_ARRAY(Texture, i); + } for( i=0; i(mDataBlock->getSFXProfile()); + SFXProfile* sound_prof = mDataBlock->getSFXProfile(); if (sound_prof) { SFX->playOnce(sound_prof, &getTransform()); diff --git a/Engine/source/T3D/fx/splash.h b/Engine/source/T3D/fx/splash.h index 40c6838fc..fec9f601e 100644 --- a/Engine/source/T3D/fx/splash.h +++ b/Engine/source/T3D/fx/splash.h @@ -102,8 +102,8 @@ public: SFXProfile* getSFXProfile() { if (mSoundAsset.notNull()) return mSoundAsset->getSfxProfile(); - else - return NULL; + + return NULL; } ParticleEmitterData* emitterList[NUM_EMITTERS]; diff --git a/Engine/source/T3D/projectile.h b/Engine/source/T3D/projectile.h index f340d54a7..69bb84001 100644 --- a/Engine/source/T3D/projectile.h +++ b/Engine/source/T3D/projectile.h @@ -118,11 +118,12 @@ public: DECLARE_SOUNDASSET(ProjectileData, ProjectileSound); DECLARE_SOUNDASSET_SETGET(ProjectileData, ProjectileSound); + SFXProfile* getSFXProfile() { if (mProjectileSoundAsset.notNull()) return mProjectileSoundAsset->getSfxProfile(); - else - return NULL; + + return NULL; } LightDescription *lightDesc; diff --git a/Engine/source/T3D/rigidShape.h b/Engine/source/T3D/rigidShape.h index 5fc6ee786..49e8c1fd6 100644 --- a/Engine/source/T3D/rigidShape.h +++ b/Engine/source/T3D/rigidShape.h @@ -70,8 +70,8 @@ class RigidShapeData : public ShapeBaseData { if (mBodySoundsAsset[id] != NULL) return mBodySoundsAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } enum RigidShapeConsts @@ -98,8 +98,8 @@ class RigidShapeData : public ShapeBaseData { if (mWaterSoundsAsset[id] != NULL) return mWaterSoundsAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } F32 exitSplashSoundVel; diff --git a/Engine/source/T3D/vehicles/flyingVehicle.h b/Engine/source/T3D/vehicles/flyingVehicle.h index 18c3379e1..573d10ccc 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.h +++ b/Engine/source/T3D/vehicles/flyingVehicle.h @@ -51,8 +51,8 @@ struct FlyingVehicleData: public VehicleData { { if (mFlyingSoundsAsset[id] != NULL) return mFlyingSoundsAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } enum Jets { diff --git a/Engine/source/T3D/vehicles/hoverVehicle.h b/Engine/source/T3D/vehicles/hoverVehicle.h index 63ff65977..da22da280 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.h +++ b/Engine/source/T3D/vehicles/hoverVehicle.h @@ -52,8 +52,8 @@ class HoverVehicleData : public VehicleData { if (mHoverSoundsAsset[id] != NULL) return mHoverSoundsAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } enum Jets { diff --git a/Engine/source/T3D/vehicles/vehicle.h b/Engine/source/T3D/vehicles/vehicle.h index 1c26f6cba..3e9636027 100644 --- a/Engine/source/T3D/vehicles/vehicle.h +++ b/Engine/source/T3D/vehicles/vehicle.h @@ -56,8 +56,8 @@ struct VehicleData : public RigidShapeData { if (mVehicleBodySoundsAsset[id] != NULL) return mVehicleBodySoundsAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } @@ -88,8 +88,8 @@ struct VehicleData : public RigidShapeData { if (mVehicleWaterSoundsAsset[id] != NULL) return mVehicleWaterSoundsAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } F32 exitSplashSoundVel; diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.h b/Engine/source/T3D/vehicles/wheeledVehicle.h index f5fe52fef..2f37b6c13 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.h +++ b/Engine/source/T3D/vehicles/wheeledVehicle.h @@ -125,8 +125,8 @@ struct WheeledVehicleData: public VehicleData { if (mWheeledVehicleSoundsAsset[id] != NULL) return mWheeledVehicleSoundsAsset[id]->getSfxProfile(); - else - return NULL; + + return NULL; } From 2181ce08c3264a2809c4a3e7c51a282f1e89a20e Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 26 Sep 2021 03:12:14 -0500 Subject: [PATCH 08/37] lightning ref fixes --- Engine/source/T3D/fx/lightning.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 16e234818..13051d7f4 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -242,7 +242,7 @@ LightningData::LightningData() for (S32 i = 0; i < MaxThunders; i++) { - INIT_SOUNDASSET_ARRAY(ThunderSound, MaxThunders); + INIT_SOUNDASSET_ARRAY(ThunderSound, i); } for (S32 i = 0; i < MaxTextures; i++) @@ -295,7 +295,7 @@ bool LightningData::preload(bool server, String &errorStr) if (server == false) { for (S32 i = 0; i < MaxThunders; i++) { - if (mThunderSound[i]) + if (getThunderSound(i)) { _setThunderSound(getThunderSound(i), i); } @@ -314,7 +314,7 @@ bool LightningData::preload(bool server, String &errorStr) { if (strikeTextureNames[k][0]) { - strikeTextures[k] = GFXTexHandle(strikeTextureNames[i], &GFXStaticTextureProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, k, __LINE__)); + strikeTextures[k] = GFXTexHandle(strikeTextureNames[k], &GFXStaticTextureProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, k, __LINE__)); mNumStrikeTextures++; } } From dba08998874f1b843535a9cbde36862cebfc4506 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 26 Sep 2021 17:30:13 -0500 Subject: [PATCH 09/37] soundasset augments: getProfile methods, test for emptystring, initialize asset arrays lightning provides a conversion sample (attempt. it's still yelling) --- Engine/source/T3D/assets/SoundAsset.h | 15 +++++++++++++++ Engine/source/T3D/fx/lightning.cpp | 12 ++++++------ Engine/source/T3D/fx/lightning.h | 16 ---------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index adacf2d9b..df0ac0d6b 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -262,6 +262,12 @@ public: \ Resource get##name##Resource() \ {\ return m##name;\ + }\ + SFXProfile* get##name##Profile()\ + {\ + if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull())\ + return m##name##Asset->getSfxProfile();\ + return NULL;\ } #define DECLARE_SOUNDASSET_SETGET(className, name)\ @@ -436,6 +442,8 @@ public: \ {\ m##name[index] = NULL;\ }\ + if(get##name(index) == StringTable->EmptyString())\ + return true;\ \ if (m##name##Asset[index].notNull() && m##name##Asset[index]->getStatus() != SoundAsset::Ok)\ {\ @@ -466,6 +474,12 @@ public: \ if(id >= sm##name##Count || id < 0)\ return ResourceManager::get().load( "" );\ return m##name[id];\ + }\ + SFXProfile* get##name##Profile(const U32& id)\ + {\ + if (get##name(id) != StringTable->EmptyString() && m##name##Asset[id].notNull())\ + return m##name##Asset[id]->getSfxProfile();\ + return NULL;\ } #define DECLARE_SOUNDASSET_ARRAY_SETGET(className, name)\ @@ -517,6 +531,7 @@ DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , a m##name##Name[index] = StringTable->EmptyString(); \ m##name##AssetId[index] = StringTable->EmptyString(); \ m##name##Asset[index] = NULL;\ + m##name[index] = NULL;\ } #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 13051d7f4..2f16f4cc0 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -302,11 +302,11 @@ bool LightningData::preload(bool server, String &errorStr) } for (U32 j = 0; j < MaxThunders; j++) { - if (!getThunderProfile(j)) + if (!getThunderSoundProfile(j)) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder."); } - if(!getSFXProfile()) + if(!getStrikeSoundProfile()) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset"); mNumStrikeTextures = 0; @@ -584,7 +584,7 @@ void Lightning::scheduleThunder(Strike* newStrike) if (t <= 0.03f) { // If it's really close, just play it... U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1); - SFX->playOnce(mDataBlock->getThunderProfile(thunder)); + SFX->playOnce(mDataBlock->getThunderSoundProfile(thunder)); } else { Thunder* pThunder = new Thunder; pThunder->tRemaining = t; @@ -651,7 +651,7 @@ void Lightning::advanceTime(F32 dt) // Play the sound... U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1); - SFX->playOnce(mDataBlock->getThunderProfile(thunder)); + SFX->playOnce(mDataBlock->getThunderSoundProfile(thunder)); } else { pThunderWalker = &((*pThunderWalker)->next); } @@ -735,9 +735,9 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent) MatrixF trans(true); trans.setPosition( strikePoint ); - if (mDataBlock->getSFXProfile()) + if (mDataBlock->getStrikeSoundProfile()) { - SFX->playOnce(mDataBlock->getSFXProfile(), &trans ); + SFX->playOnce(mDataBlock->getStrikeSoundProfile(), &trans ); } } diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h index f639db3b2..d241257b0 100644 --- a/Engine/source/T3D/fx/lightning.h +++ b/Engine/source/T3D/fx/lightning.h @@ -92,22 +92,6 @@ class LightningData : public GameBaseData DECLARE_CONOBJECT(LightningData); static void initPersistFields(); - - SFXProfile* getThunderProfile(U32 id) - { - if (mThunderSoundAsset[id] != NULL) - return mThunderSoundAsset[id]->getSfxProfile(); - - return NULL; - } - - SFXProfile* getSFXProfile() { - if (mStrikeSoundAsset.notNull()) - return mStrikeSoundAsset->getSfxProfile(); - - return NULL; - } - }; From 7b137c2ee8127511c98abedfa35a139338b12a6b Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 26 Sep 2021 17:30:57 -0500 Subject: [PATCH 10/37] genProcessor("LightningData"... attempt. will need to re-review. --- .../projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript | 1 + 1 file changed, 1 insertion(+) diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript index 645bd38ca..d9eec5f2e 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript @@ -845,6 +845,7 @@ T3Dpre4ProjectImporter::genProcessor("afxModelData", "shapeName shapeAsset shape T3Dpre4ProjectImporter::genProcessor("afxZodiacData", "texture textureAsset"); T3Dpre4ProjectImporter::genProcessor("afxZodiacPlaneData", "texture textureAsset"); T3Dpre4ProjectImporter::genProcessor("sfxEmitter", "track soundAsset filename soundAsset"); +T3Dpre4ProjectImporter::genProcessor("LightningData", "thunderSounds ThunderSoundAsset strikeSound StrikeSoundAsset"); //============================================================================== // Levels //============================================================================== From ef652ad8b9ee12d9ab11e000aa85335bc97a28e2 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 26 Sep 2021 20:07:49 -0500 Subject: [PATCH 11/37] clean out of the manual getSFXProfile() methods --- Engine/source/T3D/fx/explosion.cpp | 4 ++-- Engine/source/T3D/fx/explosion.h | 7 ------- Engine/source/T3D/fx/precipitation.cpp | 6 +++--- Engine/source/T3D/fx/precipitation.h | 7 ------- Engine/source/T3D/fx/splash.cpp | 4 ++-- Engine/source/T3D/fx/splash.h | 8 -------- Engine/source/T3D/projectile.cpp | 2 +- Engine/source/T3D/projectile.h | 7 ------- 8 files changed, 8 insertions(+), 37 deletions(-) diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index 6fc59b825..d770e2f36 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -859,7 +859,7 @@ bool ExplosionData::preload(bool server, String &errorStr) if (Parent::preload(server, errorStr) == false) return false; - if (!server && !getSFXProfile()) + if (!server && !getSoundProfile()) return false; if( !server ) @@ -1382,7 +1382,7 @@ bool Explosion::explode() resetWorldBox(); } - SFXProfile* sound_prof = mDataBlock->getSFXProfile(); + SFXProfile* sound_prof = mDataBlock->getSoundProfile(); if (sound_prof) { soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index); diff --git a/Engine/source/T3D/fx/explosion.h b/Engine/source/T3D/fx/explosion.h index 37694dd1e..41116cd32 100644 --- a/Engine/source/T3D/fx/explosion.h +++ b/Engine/source/T3D/fx/explosion.h @@ -73,13 +73,6 @@ class ExplosionData : public GameBaseData { DECLARE_SOUNDASSET(ExplosionData, Sound); DECLARE_SOUNDASSET_SETGET(ExplosionData, Sound); - SFXProfile* getSFXProfile() { - if (mSoundAsset.notNull()) - return mSoundAsset->getSfxProfile(); - - return NULL; - } - ParticleEmitterData* particleEmitter; S32 particleEmitterId; diff --git a/Engine/source/T3D/fx/precipitation.cpp b/Engine/source/T3D/fx/precipitation.cpp index 4356cd45f..bf3246dc9 100644 --- a/Engine/source/T3D/fx/precipitation.cpp +++ b/Engine/source/T3D/fx/precipitation.cpp @@ -189,7 +189,7 @@ bool PrecipitationData::preload( bool server, String &errorStr ) if( Parent::preload( server, errorStr) == false) return false; - if (!server && !getSFXProfile()) + if (!server && !getSoundProfile()) return false; return true; @@ -597,9 +597,9 @@ bool Precipitation::onNewDataBlock( GameBaseData *dptr, bool reload ) { SFX_DELETE( mAmbientSound ); - if ( mDataBlock->getSFXProfile()) + if ( mDataBlock->getSoundProfile()) { - mAmbientSound = SFX->createSource(mDataBlock->getSFXProfile(), &getTransform() ); + mAmbientSound = SFX->createSource(mDataBlock->getSoundProfile(), &getTransform() ); if ( mAmbientSound ) mAmbientSound->play(); } diff --git a/Engine/source/T3D/fx/precipitation.h b/Engine/source/T3D/fx/precipitation.h index f9eb4bf02..719613384 100644 --- a/Engine/source/T3D/fx/precipitation.h +++ b/Engine/source/T3D/fx/precipitation.h @@ -71,13 +71,6 @@ class PrecipitationData : public GameBaseData void onDropChanged() {} void onSplashChanged() {} - - SFXProfile* getSFXProfile() { - if (mSoundAsset.notNull()) - return mSoundAsset->getSfxProfile(); - - return NULL; - } }; struct Raindrop diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index c046ef1a0..d1230e5c5 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -276,7 +276,7 @@ bool SplashData::preload(bool server, String &errorStr) if (Parent::preload(server, errorStr) == false) return false; - if (!server && !getSFXProfile()) + if (!server && !getSoundProfile()) return false; if (!server) @@ -681,7 +681,7 @@ void Splash::spawnExplosion() /// could just play the explosion one, but explosion could be weapon specific, /// splash sound could be liquid specific. food for thought. - SFXProfile* sound_prof = mDataBlock->getSFXProfile(); + SFXProfile* sound_prof = mDataBlock->getSoundProfile(); if (sound_prof) { SFX->playOnce(sound_prof, &getTransform()); diff --git a/Engine/source/T3D/fx/splash.h b/Engine/source/T3D/fx/splash.h index fec9f601e..4cde2db00 100644 --- a/Engine/source/T3D/fx/splash.h +++ b/Engine/source/T3D/fx/splash.h @@ -98,14 +98,6 @@ public: DECLARE_SOUNDASSET(SplashData, Sound); DECLARE_SOUNDASSET_SETGET(SplashData, Sound); - /// this should probably be added as a function higher up to stop repeats. - SFXProfile* getSFXProfile() { - if (mSoundAsset.notNull()) - return mSoundAsset->getSfxProfile(); - - return NULL; - } - ParticleEmitterData* emitterList[NUM_EMITTERS]; S32 emitterIDList[NUM_EMITTERS]; diff --git a/Engine/source/T3D/projectile.cpp b/Engine/source/T3D/projectile.cpp index d7532e368..a88276f73 100644 --- a/Engine/source/T3D/projectile.cpp +++ b/Engine/source/T3D/projectile.cpp @@ -882,7 +882,7 @@ bool Projectile::onNewDataBlock( GameBaseData *dptr, bool reload ) SFX_DELETE( mSound ); if ( mDataBlock->getProjectileSound() ) - mSound = SFX->createSource( mDataBlock->getSFXProfile() ); + mSound = SFX->createSource( mDataBlock->getProjectileSoundProfile() ); } return true; diff --git a/Engine/source/T3D/projectile.h b/Engine/source/T3D/projectile.h index 69bb84001..e633e3fd4 100644 --- a/Engine/source/T3D/projectile.h +++ b/Engine/source/T3D/projectile.h @@ -118,13 +118,6 @@ public: DECLARE_SOUNDASSET(ProjectileData, ProjectileSound); DECLARE_SOUNDASSET_SETGET(ProjectileData, ProjectileSound); - - SFXProfile* getSFXProfile() { - if (mProjectileSoundAsset.notNull()) - return mProjectileSoundAsset->getSfxProfile(); - - return NULL; - } LightDescription *lightDesc; S32 lightDescId; From 44b81ace69b3141d1c4a5f8c261d55a7cf2307b9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 27 Sep 2021 20:04:58 -0500 Subject: [PATCH 12/37] don't check a profile if we don't have a sound asset --- Engine/source/T3D/fx/lightning.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 2f16f4cc0..8f1ba8bf6 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -294,19 +294,17 @@ bool LightningData::preload(bool server, String &errorStr) if (server == false) { - for (S32 i = 0; i < MaxThunders; i++) { + for (S32 i = 0; i < MaxThunders; i++) + { if (getThunderSound(i)) { _setThunderSound(getThunderSound(i), i); + if (!getThunderSoundProfile(i)) + Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder."); } } - for (U32 j = 0; j < MaxThunders; j++) { - if (!getThunderSoundProfile(j)) - Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder."); - } - - if(!getStrikeSoundProfile()) + if(getStrikeSound() && !getStrikeSoundProfile()) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset"); mNumStrikeTextures = 0; From ad0c141189a8ecfe74331115eadee0dc0f75b736 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 27 Sep 2021 21:12:27 -0500 Subject: [PATCH 13/37] use _set for all network recipts of shapes, sounds, images and materials to ensure we at least try and fill that out whichever way is ghosted to us --- Engine/source/T3D/assets/ImageAsset.h | 12 +++++++++--- Engine/source/T3D/assets/MaterialAsset.h | 5 ++++- Engine/source/T3D/assets/ShapeAsset.h | 10 ++++++++-- Engine/source/T3D/assets/SoundAsset.h | 5 ++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index ff50ef655..b79dc5f5d 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -345,7 +345,6 @@ if (m##name##AssetId != StringTable->EmptyString())\ if (stream->writeFlag(m##name##Asset.notNull()))\ {\ stream->writeString(m##name##Asset.getAssetId());\ - _set##name(m##name##AssetId);\ }\ else\ stream->writeString(m##name##Name); @@ -354,9 +353,13 @@ if (m##name##AssetId != StringTable->EmptyString())\ if (stream->readFlag())\ {\ m##name##AssetId = stream->readSTString();\ + _set##name(m##name##AssetId);\ }\ else\ - m##name##Name = stream->readSTString(); + {\ + m##name##Name = stream->readSTString();\ + _set##name(m##name##Name);\ + }\ #define PACK_IMAGEASSET(netconn, name)\ if (stream->writeFlag(m##name##Asset.notNull()))\ @@ -591,7 +594,10 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ _set##name(m##name##AssetId[index], index);\ }\ else\ - m##name##Name[index] = stream->readSTString(); + {\ + m##name##Name[index] = stream->readSTString();\ + _set##name(m##name##Name[index], index);\ + }\ #define PACK_IMAGEASSET_ARRAY(netconn, name, index)\ if (stream->writeFlag(m##name##Asset[index].notNull()))\ diff --git a/Engine/source/T3D/assets/MaterialAsset.h b/Engine/source/T3D/assets/MaterialAsset.h index 07ec0227a..c747be793 100644 --- a/Engine/source/T3D/assets/MaterialAsset.h +++ b/Engine/source/T3D/assets/MaterialAsset.h @@ -346,7 +346,10 @@ if (m##name##AssetId != StringTable->EmptyString())\ _set##name(m##name##AssetId);\ }\ else\ - m##name##Name = stream->readSTString(); + {\ + m##name##Name = stream->readSTString();\ + _set##name(m##name##Name);\ + }\ #define PACK_MATERIALASSET(netconn, name)\ if (stream->writeFlag(m##name##Asset.notNull()))\ diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index d5c899564..d3af516c5 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -397,7 +397,10 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText _set##name(m##name##AssetId);\ }\ else\ - m##name##Name = stream->readSTString(); + {\ + m##name##Name = stream->readSTString();\ + _set##name(m##name##Name);\ + } #define PACK_SHAPEASSET(netconn, name)\ if (stream->writeFlag(m##name##Asset.notNull()))\ @@ -609,7 +612,10 @@ DefineEngineMethod(className, set##name, bool, (const char* shape, S32 index), _set##name(m##name##AssetId[index], index);\ }\ else\ - m##name##Name[index] = stream->readSTString(); + {\ + m##name##Name[index] = stream->readSTString();\ + _set##name(m##name##Name[index], index);\ + } #define PACK_SHAPEASSET_ARRAY(netconn, name, index)\ if (stream->writeFlag(m##name##Asset[index].notNull()))\ diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index df0ac0d6b..ca83e477b 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -344,7 +344,10 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText _set##name(m##name##AssetId);\ }\ else\ - m##name##Name = stream->readSTString(); + {\ + m##name##Name = stream->readSTString();\ + _set##name(m##name##Name);\ + } #define PACK_SOUNDASSET(netconn, name)\ if (stream->writeFlag(m##name##Asset.notNull()))\ From 8a1d3f2021cab0a8e3db7f68a7e534a981ae8c1b Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 28 Sep 2021 13:56:35 +0100 Subject: [PATCH 14/37] Working thunder. These changes may need to be applied to other sound arrays or image arrays. --- Engine/source/T3D/assets/SoundAsset.cpp | 10 +++++----- Engine/source/T3D/fx/lightning.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.cpp b/Engine/source/T3D/assets/SoundAsset.cpp index 72a3a2526..45f78bc48 100644 --- a/Engine/source/T3D/assets/SoundAsset.cpp +++ b/Engine/source/T3D/assets/SoundAsset.cpp @@ -279,18 +279,18 @@ StringTableEntry SoundAsset::getAssetIdByFileName(StringTableEntry fileName) return materialAssetId; } -U32 SoundAsset::getAssetById(StringTableEntry assetId, AssetPtr* materialAsset) +U32 SoundAsset::getAssetById(StringTableEntry assetId, AssetPtr* soundAsset) { - (*materialAsset) = assetId; + (*soundAsset) = assetId; - if (materialAsset->notNull()) + if (soundAsset->notNull()) { - return (*materialAsset)->mLoadedState; + return (*soundAsset)->mLoadedState; } else { //Well that's bad, loading the fallback failed. - Con::warnf("MaterialAsset::getAssetById - Finding of asset with id %s failed with no fallback asset", assetId); + Con::warnf("SoundAsset::getAssetById - Finding of asset with id %s failed with no fallback asset", assetId); return AssetErrCode::Failed; } } diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 8f1ba8bf6..e032284e7 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -265,7 +265,9 @@ void LightningData::initPersistFields() INITPERSISTFIELD_SOUNDASSET(StrikeSound, LightningData, "Sound to play when lightning STRIKES!"); + addArray("Thunders", MaxThunders); INITPERSISTFIELD_SOUNDASSET_ARRAY(ThunderSound, MaxThunders, LightningData, "Sounds for thunder."); + endArray("Thunders"); addField( "strikeTextures", TypeString, Offset(strikeTextureNames, LightningData), MaxTextures, "List of textures to use to render lightning strikes." ); @@ -299,9 +301,13 @@ bool LightningData::preload(bool server, String &errorStr) if (getThunderSound(i)) { _setThunderSound(getThunderSound(i), i); + Con::printf("Thunder sound: %d %s", i, getThunderSound(i)); + if (!getThunderSoundProfile(i)) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder."); + } + } if(getStrikeSound() && !getStrikeSoundProfile()) From 4429de59b04a0631721a64a3485103983dca314a Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 28 Sep 2021 14:08:27 +0100 Subject: [PATCH 15/37] okay so addArray isn't even required. --- Engine/source/T3D/fx/lightning.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index e032284e7..6726c5183 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -265,9 +265,7 @@ void LightningData::initPersistFields() INITPERSISTFIELD_SOUNDASSET(StrikeSound, LightningData, "Sound to play when lightning STRIKES!"); - addArray("Thunders", MaxThunders); INITPERSISTFIELD_SOUNDASSET_ARRAY(ThunderSound, MaxThunders, LightningData, "Sounds for thunder."); - endArray("Thunders"); addField( "strikeTextures", TypeString, Offset(strikeTextureNames, LightningData), MaxTextures, "List of textures to use to render lightning strikes." ); From 76addc52eb73fdb631380c27beb3e7a6f61f8e89 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 28 Sep 2021 21:10:48 +0100 Subject: [PATCH 16/37] Checks for emptyString in preload Sound asset out for emptyString --- Engine/source/T3D/assets/SoundAsset.h | 2 ++ Engine/source/T3D/fx/explosion.cpp | 10 +++++++++- Engine/source/T3D/fx/lightning.cpp | 11 ++++++++--- Engine/source/T3D/fx/precipitation.cpp | 11 +++++++++-- Engine/source/T3D/fx/splash.cpp | 12 +++++++++--- Engine/source/T3D/projectile.cpp | 9 +++++++-- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index ca83e477b..502732fee 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -235,6 +235,8 @@ public: \ m##name = NULL;\ }\ \ + if(get##name() == StringTable->EmptyString())\ + return true;\ if (m##name##Asset.notNull() && m##name##Asset->getStatus() != SoundAsset::Ok)\ {\ Con::errorf("%s(%s)::_set%s() - sound asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name), _in, SoundAsset::getAssetErrstrn(m##name##Asset->getStatus()).c_str());\ diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index d770e2f36..17aa6017c 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -864,7 +864,15 @@ bool ExplosionData::preload(bool server, String &errorStr) if( !server ) { - String sfxErrorStr; + + if (getSound() != StringTable->EmptyString()) + { + _setSound(getSound()); + + if (!getSoundProfile()) + Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash."); + } + if (!particleEmitter && particleEmitterId != 0) if (Sim::findObject(particleEmitterId, particleEmitter) == false) Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock"); diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 6726c5183..a53a1f540 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -296,7 +296,7 @@ bool LightningData::preload(bool server, String &errorStr) { for (S32 i = 0; i < MaxThunders; i++) { - if (getThunderSound(i)) + if (getThunderSound(i) != StringTable->EmptyString()) { _setThunderSound(getThunderSound(i), i); Con::printf("Thunder sound: %d %s", i, getThunderSound(i)); @@ -308,8 +308,13 @@ bool LightningData::preload(bool server, String &errorStr) } - if(getStrikeSound() && !getStrikeSoundProfile()) - Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset"); + if (getStrikeSound() != StringTable->EmptyString()) + { + _setStrikeSound(getStrikeSound()); + + if(!getStrikeSoundProfile()) + Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from strike sound."); + } mNumStrikeTextures = 0; for (U32 k = 0; k < MaxTextures; k++) diff --git a/Engine/source/T3D/fx/precipitation.cpp b/Engine/source/T3D/fx/precipitation.cpp index bf3246dc9..68880edf4 100644 --- a/Engine/source/T3D/fx/precipitation.cpp +++ b/Engine/source/T3D/fx/precipitation.cpp @@ -188,9 +188,16 @@ bool PrecipitationData::preload( bool server, String &errorStr ) { if( Parent::preload( server, errorStr) == false) return false; + if (!server) + { + if (getSound() != StringTable->EmptyString()) + { + _setSound(getSound()); - if (!server && !getSoundProfile()) - return false; + if (!getSoundProfile()) + Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash."); + } + } return true; } diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index d1230e5c5..38a4f4e89 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -276,11 +276,17 @@ bool SplashData::preload(bool server, String &errorStr) if (Parent::preload(server, errorStr) == false) return false; - if (!server && !getSoundProfile()) - return false; - if (!server) { + + if (getSound() != StringTable->EmptyString()) + { + _setSound(getSound()); + + if(!getSoundProfile()) + Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash."); + } + S32 i; for( i=0; iEmptyString()) + { + _setProjectileSound(getProjectileSound()); + + if (!getProjectileSoundProfile()) + Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash."); + } if (!lightDesc && lightDescId != 0) if (Sim::findObject(lightDescId, lightDesc) == false) From 96891e5673ca114f3d5c5490cdc180cb0cf2b57e Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 28 Sep 2021 17:33:36 -0500 Subject: [PATCH 17/37] early out if any asset feed route results in explicitly being told to use an emptystring --- Engine/source/T3D/assets/SoundAsset.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index ca83e477b..d6baadbbf 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -234,6 +234,8 @@ public: \ {\ m##name = NULL;\ }\ + if(get##name() == StringTable->EmptyString())\ + return true;\ \ if (m##name##Asset.notNull() && m##name##Asset->getStatus() != SoundAsset::Ok)\ {\ From 6bec47d3fa9855030f5f6506c257fc0dc8a49f42 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 28 Sep 2021 23:36:04 +0100 Subject: [PATCH 18/37] -SoundAsset added init for enum types. -Vehicles updated to use enum initpersistfield. --- Engine/source/T3D/assets/SoundAsset.h | 10 +++++++ Engine/source/T3D/vehicles/hoverVehicle.cpp | 14 +++++++-- Engine/source/T3D/vehicles/vehicle.cpp | 30 ++++++++++++++++--- Engine/source/T3D/vehicles/wheeledVehicle.cpp | 15 ++++++++-- Engine/source/T3D/vehicles/wheeledVehicle.h | 1 + 5 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 502732fee..486aca6c0 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -371,6 +371,16 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText #pragma endregion +#define assetEnumNameConcat(x,suff,ForT)(new std::string(std::string(#x) + suff + std::string(#ForT)))->c_str() + +#define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \ + for (U32 i = 0; i <= maxValue; i++)\ + {\ + const char* enumString = castConsoleTypeToString(static_cast(i));\ + addProtectedField(assetEnumNameConcat(name,enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addProtectedField(assetEnumNameConcat(name,enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));\ + }\ + #pragma region Arrayed Asset Macros #define DECLARE_SOUNDASSET_ARRAY(className,name,max) public: \ diff --git a/Engine/source/T3D/vehicles/hoverVehicle.cpp b/Engine/source/T3D/vehicles/hoverVehicle.cpp index 0cddc2c72..7deb81fe0 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.cpp +++ b/Engine/source/T3D/vehicles/hoverVehicle.cpp @@ -68,6 +68,16 @@ ConsoleDocClass( HoverVehicle, "@ingroup Vehicles\n" ); +typedef HoverVehicleData::Sounds hoverSoundsEnum; +DefineEnumType(hoverSoundsEnum); + +ImplementEnumType(hoverSoundsEnum, "enum types.\n" + "@ingroup HoverVehicleData\n\n") + { HoverVehicleData::JetSound, "JetSound", "..." }, + { HoverVehicleData::EngineSound, "EngineSound", "..." }, + { HoverVehicleData::FloatSound, "FloatSound", "..." }, +EndImplementEnumType; + namespace { const U32 sCollisionMoveMask = (TerrainObjectType | PlayerObjectType | @@ -232,7 +242,7 @@ void HoverVehicleData::initPersistFields() addField( "pitchForce", TypeF32, Offset(pitchForce, HoverVehicleData), "Pitch (rotation about the X-axis) force applied when steering in the y-axis direction." ); - INITPERSISTFIELD_SOUNDASSET_ARRAY(HoverSounds, Sounds::MaxSounds, HoverVehicleData, "Sounds for hover vehicle."); + INITPERSISTFIELD_SOUNDASSET_ENUMED(HoverSounds, hoverSoundsEnum, Sounds::MaxSounds, HoverVehicleData, "Sounds for hover vehicle."); addField( "dustTrailEmitter", TYPEID< ParticleEmitterData >(), Offset(dustTrailEmitter, HoverVehicleData), "Emitter to generate particles for the vehicle's dust trail.\nThe trail " @@ -307,7 +317,7 @@ bool HoverVehicleData::preload(bool server, String &errorStr) if (!server) { for (S32 i = 0; i < MaxSounds; i++) - if (mHoverSounds[i]) + if (getHoverSounds(i) != StringTable->EmptyString()) { _setHoverSounds(getHoverSounds(i), i); } diff --git a/Engine/source/T3D/vehicles/vehicle.cpp b/Engine/source/T3D/vehicles/vehicle.cpp index b773dd58f..8079fc163 100644 --- a/Engine/source/T3D/vehicles/vehicle.cpp +++ b/Engine/source/T3D/vehicles/vehicle.cpp @@ -80,6 +80,28 @@ static U32 sTriggerMask = ItemObjectType | IMPLEMENT_CONOBJECT(VehicleData); +typedef VehicleData::Body::Sounds bodySounds; +DefineEnumType(bodySounds); + +ImplementEnumType(bodySounds, "enum types.\n" + "@ingroup VehicleData\n\n") + { VehicleData::Body::SoftImpactSound, "SoftImpactSound", "..." }, + { VehicleData::Body::HardImpactSound, "HardImpactSound", "..." }, +EndImplementEnumType; + + +typedef VehicleData::Sounds vehSoundsEnum; +DefineEnumType(vehSoundsEnum); + +ImplementEnumType(vehSoundsEnum, "enum types.\n" + "@ingroup VehicleData\n\n") + { VehicleData::ExitWater, "ExitWater", "..." }, + { VehicleData::ImpactSoft, "ImpactSoft", "..." }, + { VehicleData::ImpactMedium, "ImpactMedium", "..." }, + { VehicleData::ImpactHard, "ImpactHard", "..." }, + { VehicleData::Wake, "Wake", "..." }, +EndImplementEnumType; + ConsoleDocClass( VehicleData, "@brief Base properties shared by all Vehicles (FlyingVehicle, HoverVehicle, " "WheeledVehicle).\n\n" @@ -219,7 +241,7 @@ bool VehicleData::preload(bool server, String &errorStr) if (!server) { for (S32 i = 0; i < Body::MaxSounds; i++) { - if (mVehicleBodySounds[i]) + if (getVehicleBodySounds(i) != StringTable->EmptyString() ) { _setVehicleBodySounds(getVehicleBodySounds(i), i); } @@ -227,7 +249,7 @@ bool VehicleData::preload(bool server, String &errorStr) for (S32 j = 0; j < Sounds::MaxSounds; j++) { - if (mVehicleWaterSounds[j]) + if (getVehicleWaterSounds(j) != StringTable->EmptyString()) { _setVehicleWaterSounds(getVehicleWaterSounds(j), j); } @@ -503,7 +525,7 @@ void VehicleData::initPersistFields() "Collision friction coefficient.\nHow well this object will slide against " "objects it collides with." ); - INITPERSISTFIELD_SOUNDASSET_ARRAY(VehicleBodySounds, Body::Sounds::MaxSounds, VehicleData, "Sounds for vehicle body impacts."); + INITPERSISTFIELD_SOUNDASSET_ENUMED(VehicleBodySounds, bodySounds, Body::Sounds::MaxSounds, VehicleData, "Sounds for vehicle body impacts."); addField( "minImpactSpeed", TypeF32, Offset(minImpactSpeed, VehicleData), "Minimum collision speed for the onImpact callback to be invoked." ); @@ -601,7 +623,7 @@ void VehicleData::initPersistFields() "Minimum velocity when entering the water for the imapactWaterHard sound " "to play.\n\n@see impactWaterHard" ); - INITPERSISTFIELD_SOUNDASSET_ARRAY(WaterSounds, Sounds::MaxSounds, VehicleData, "Sounds for interacting with water."); + INITPERSISTFIELD_SOUNDASSET_ENUMED(WaterSounds, vehSoundsEnum, VehicleData::Sounds::MaxSounds, VehicleData, "Sounds for interacting with water."); addField( "collDamageThresholdVel", TypeF32, Offset(collDamageThresholdVel, VehicleData), "Minimum collision velocity to cause damage to this vehicle.\nCurrently unused." ); diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.cpp b/Engine/source/T3D/vehicles/wheeledVehicle.cpp index 3fbde4af7..4e9e7201e 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.cpp +++ b/Engine/source/T3D/vehicles/wheeledVehicle.cpp @@ -289,6 +289,17 @@ ConsoleDocClass( WheeledVehicleData, "@ingroup Vehicles\n" ); +typedef WheeledVehicleData::Sounds wheelSoundsEnum; +DefineEnumType(wheelSoundsEnum); + +ImplementEnumType(wheelSoundsEnum, "enum types.\n" + "@ingroup WheeledVehicleData\n\n") + {WheeledVehicleData::JetSound, "JetSound", "..." }, + {WheeledVehicleData::EngineSound, "EngineSound", "..." }, + {WheeledVehicleData::SquealSound, "SquealSound", "..." }, + {WheeledVehicleData::WheelImpactSound, "WheelImpactSound", "..." }, +EndImplementEnumType; + WheeledVehicleData::WheeledVehicleData() { tireEmitter = 0; @@ -335,7 +346,7 @@ bool WheeledVehicleData::preload(bool server, String &errorStr) if (!server) { for (S32 i = 0; i < MaxSounds; i++) { - if (mWheeledVehicleSounds[i]) + if (getWheeledVehicleSounds(i) != StringTable->EmptyString()) { _setWheeledVehicleSounds(getWheeledVehicleSounds(i), i); } @@ -437,7 +448,7 @@ bool WheeledVehicleData::mirrorWheel(Wheel* we) void WheeledVehicleData::initPersistFields() { - INITPERSISTFIELD_SOUNDASSET_ARRAY(WheeledVehicleSounds, Sounds::MaxSounds, WheeledVehicleData, "Sounds related to wheeled vehicle."); + INITPERSISTFIELD_SOUNDASSET_ENUMED(WheeledVehicleSounds, wheelSoundsEnum, MaxSounds, WheeledVehicleData, "Sounds related to wheeled vehicle."); addField("tireEmitter",TYPEID< ParticleEmitterData >(), Offset(tireEmitter, WheeledVehicleData), "ParticleEmitterData datablock used to generate particles from each wheel " diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.h b/Engine/source/T3D/vehicles/wheeledVehicle.h index 2f37b6c13..a2ab03b11 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.h +++ b/Engine/source/T3D/vehicles/wheeledVehicle.h @@ -118,6 +118,7 @@ struct WheeledVehicleData: public VehicleData WheelImpactSound, MaxSounds, }; + DECLARE_SOUNDASSET_ARRAY(WheeledVehicleData, WheeledVehicleSounds, Sounds::MaxSounds); DECLARE_SOUNDASSET_ARRAY_SETGET(WheeledVehicleData, WheeledVehicleSounds); From 776741770db23fb0684d81b65eddd0d1aed295c5 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 28 Sep 2021 18:16:14 -0500 Subject: [PATCH 19/37] boolean isvalid chjecks for assets. tests wether it's non-empty and reporting zero flaws --- Engine/source/T3D/assets/ImageAsset.h | 6 ++++-- Engine/source/T3D/assets/MaterialAsset.h | 3 ++- Engine/source/T3D/assets/ShapeAsset.h | 6 ++++-- Engine/source/T3D/assets/SoundAsset.h | 6 ++++-- Engine/source/T3D/fx/lightning.cpp | 4 ++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index b79dc5f5d..57155ff2f 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -270,7 +270,8 @@ public: \ GFXTexHandle get##name##Resource() \ {\ return m##name;\ - } + }\ + bool name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } #define DECLARE_IMAGEASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ @@ -494,7 +495,8 @@ public: \ if(index >= sm##name##Count || index < 0)\ return nullptr;\ return m##name[index];\ - } + }\ + bool name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; } #define DECLARE_IMAGEASSET_ARRAY_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ diff --git a/Engine/source/T3D/assets/MaterialAsset.h b/Engine/source/T3D/assets/MaterialAsset.h index c747be793..e9a74174a 100644 --- a/Engine/source/T3D/assets/MaterialAsset.h +++ b/Engine/source/T3D/assets/MaterialAsset.h @@ -259,7 +259,8 @@ public: \ SimObjectPtr get##name##Resource() \ {\ return m##name;\ - } + }\ + bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } #define DECLARE_MATERIALASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index d3af516c5..055ecdb42 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -321,7 +321,8 @@ public: \ Resource get##name##Resource() \ {\ return m##name;\ - } + }\ + bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } #define DECLARE_SHAPEASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ @@ -522,7 +523,8 @@ public: \ if(index >= sm##name##Count || index < 0)\ return ResourceManager::get().load( "" );\ return m##name[index];\ - } + }\ + bool is##name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; } #define DECLARE_SHAPEASSET_ARRAY_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index d6baadbbf..2f70b83c7 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -270,7 +270,8 @@ public: \ if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull())\ return m##name##Asset->getSfxProfile();\ return NULL;\ - } + }\ + bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } #define DECLARE_SOUNDASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ @@ -485,7 +486,8 @@ public: \ if (get##name(id) != StringTable->EmptyString() && m##name##Asset[id].notNull())\ return m##name##Asset[id]->getSfxProfile();\ return NULL;\ - } + }\ + bool is##name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; } #define DECLARE_SOUNDASSET_ARRAY_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 8f1ba8bf6..905615a3d 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -296,7 +296,7 @@ bool LightningData::preload(bool server, String &errorStr) { for (S32 i = 0; i < MaxThunders; i++) { - if (getThunderSound(i)) + if (isThunderSoundValid(i)) { _setThunderSound(getThunderSound(i), i); if (!getThunderSoundProfile(i)) @@ -304,7 +304,7 @@ bool LightningData::preload(bool server, String &errorStr) } } - if(getStrikeSound() && !getStrikeSoundProfile()) + if(isStrikeSoundValid() && !getStrikeSoundProfile()) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset"); mNumStrikeTextures = 0; From 2630b4ada6a97222ad1e200fa962cf426b7d4161 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 28 Sep 2021 18:50:35 -0500 Subject: [PATCH 20/37] corrected and simplified the isValid method macro injections --- Engine/source/T3D/assets/ImageAsset.h | 4 ++-- Engine/source/T3D/assets/MaterialAsset.h | 2 +- Engine/source/T3D/assets/ShapeAsset.h | 4 ++-- Engine/source/T3D/assets/SoundAsset.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index 57155ff2f..7afcd6da2 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -271,7 +271,7 @@ public: \ {\ return m##name;\ }\ - bool name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } + bool name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } #define DECLARE_IMAGEASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ @@ -496,7 +496,7 @@ public: \ return nullptr;\ return m##name[index];\ }\ - bool name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; } + bool name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); } #define DECLARE_IMAGEASSET_ARRAY_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ diff --git a/Engine/source/T3D/assets/MaterialAsset.h b/Engine/source/T3D/assets/MaterialAsset.h index e9a74174a..fc383810f 100644 --- a/Engine/source/T3D/assets/MaterialAsset.h +++ b/Engine/source/T3D/assets/MaterialAsset.h @@ -260,7 +260,7 @@ public: \ {\ return m##name;\ }\ - bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } + bool is##name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } #define DECLARE_MATERIALASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index 055ecdb42..2d641a840 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -322,7 +322,7 @@ public: \ {\ return m##name;\ }\ - bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } + bool is##name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } #define DECLARE_SHAPEASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ @@ -524,7 +524,7 @@ public: \ return ResourceManager::get().load( "" );\ return m##name[index];\ }\ - bool is##name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; } + bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); } #define DECLARE_SHAPEASSET_ARRAY_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 2f70b83c7..2f3cc4615 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -271,7 +271,7 @@ public: \ return m##name##Asset->getSfxProfile();\ return NULL;\ }\ - bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; } + bool is##name##Valid() { return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } #define DECLARE_SOUNDASSET_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ @@ -487,7 +487,7 @@ public: \ return m##name##Asset[id]->getSfxProfile();\ return NULL;\ }\ - bool is##name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; } + bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); } #define DECLARE_SOUNDASSET_ARRAY_SETGET(className, name)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\ From d700ea487842ed6fb614c981837c2029ea8d1324 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Wed, 29 Sep 2021 11:41:57 +0100 Subject: [PATCH 21/37] Committing player separately. shapeBase is its own beast and will require a very critical look over once its up. --- Engine/source/T3D/player.cpp | 131 ++++++++++++++--------------------- Engine/source/T3D/player.h | 5 +- 2 files changed, 56 insertions(+), 80 deletions(-) diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 5bfc44746..3144bfcd9 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -189,6 +189,31 @@ PlayerData::ActionAnimationDef PlayerData::ActionAnimationList[NumTableActionAni //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- +typedef PlayerData::Sounds playerSoundsEnum; +DefineEnumType(playerSoundsEnum); + +ImplementEnumType(playerSoundsEnum, "enum types.\n" + "@ingroup PlayerData\n\n") + {PlayerData::Sounds::FootSoft, "FootSoft","..." }, + {PlayerData::Sounds::FootHard, "FootHard","..." }, + {PlayerData::Sounds::FootMetal, "FootMetal","..." }, + {PlayerData::Sounds::FootSnow, "FootSnow","..." }, + {PlayerData::Sounds::FootShallowSplash, "FootShallowSplash","..." }, + {PlayerData::Sounds::FootWading, "FootWading","..." }, + {PlayerData::Sounds::FootUnderWater, "FootUnderWater","..." }, + {PlayerData::Sounds::FootBubbles, "FootBubbles","..." }, + {PlayerData::Sounds::MoveBubbles, "MoveBubbles","..." }, + {PlayerData::Sounds::WaterBreath, "WaterBreath","..." }, + {PlayerData::Sounds::ImpactStart, "ImpactStart","..." }, + {PlayerData::Sounds::ImpactHard, "ImpactHard","..." }, + {PlayerData::Sounds::ImpactMetal, "ImpactMetal","..." }, + {PlayerData::Sounds::ImpactSnow, "ImpactSnow","..." }, + {PlayerData::Sounds::ImpactWaterEasy, "ImpactWaterEasy","..." }, + {PlayerData::Sounds::ImpactWaterMedium, "ImpactWaterMedium","..." }, + {PlayerData::Sounds::ImpactWaterHard, "ImpactWaterHard","..." }, + {PlayerData::Sounds::ExitWater, "ExitWater","..." }, +EndImplementEnumType; + //---------------------------------------------------------------------------- IMPLEMENT_CO_DATABLOCK_V1(PlayerData); @@ -397,7 +422,7 @@ PlayerData::PlayerData() boxHeadFrontPercentage = 1; for (S32 i = 0; i < MaxSounds; i++) - sound[i] = NULL; + INIT_SOUNDASSET_ARRAY(PlayerSound, i); footPuffEmitter = NULL; footPuffID = 0; @@ -449,9 +474,13 @@ bool PlayerData::preload(bool server, String &errorStr) { for( U32 i = 0; i < MaxSounds; ++ i ) { - String sfxErrorStr; - if( !sfxResolve( &sound[ i ], sfxErrorStr ) ) - Con::errorf( "PlayerData::preload: %s", sfxErrorStr.c_str() ); + if (getPlayerSound(i) != StringTable->EmptyString()) + { + _setPlayerSound(getPlayerSound(i), i); + } + + if (!getPlayerSoundProfile(i)) + Con::errorf("PlayerData::Preload() - unable to find sfxProfile for asset %d %s", i, getPlayerSound(i)); } } @@ -1022,63 +1051,7 @@ void PlayerData::initPersistFields() addGroup( "Interaction: Sounds" ); - addField( "FootSoftSound", TypeSFXTrackName, Offset(sound[FootSoft], PlayerData), - "@brief Sound to play when walking on a surface with Material footstepSoundId 0.\n\n" ); - addField( "FootHardSound", TypeSFXTrackName, Offset(sound[FootHard], PlayerData), - "@brief Sound to play when walking on a surface with Material footstepSoundId 1.\n\n" ); - addField( "FootMetalSound", TypeSFXTrackName, Offset(sound[FootMetal], PlayerData), - "@brief Sound to play when walking on a surface with Material footstepSoundId 2.\n\n" ); - addField( "FootSnowSound", TypeSFXTrackName, Offset(sound[FootSnow], PlayerData), - "@brief Sound to play when walking on a surface with Material footstepSoundId 3.\n\n" ); - - addField( "FootShallowSound", TypeSFXTrackName, Offset(sound[FootShallowSplash], PlayerData), - "@brief Sound to play when walking in water and coverage is less than " - "footSplashHeight.\n\n" - "@see footSplashHeight\n" ); - addField( "FootWadingSound", TypeSFXTrackName, Offset(sound[FootWading], PlayerData), - "@brief Sound to play when walking in water and coverage is less than 1, " - "but > footSplashHeight.\n\n" - "@see footSplashHeight\n" ); - addField( "FootUnderwaterSound", TypeSFXTrackName, Offset(sound[FootUnderWater], PlayerData), - "@brief Sound to play when walking in water and coverage equals 1.0 " - "(fully underwater).\n\n" ); - addField( "FootBubblesSound", TypeSFXTrackName, Offset(sound[FootBubbles], PlayerData), - "@brief Sound to play when walking in water and coverage equals 1.0 " - "(fully underwater).\n\n" ); - addField( "movingBubblesSound", TypeSFXTrackName, Offset(sound[MoveBubbles], PlayerData), - "@brief Sound to play when in water and coverage equals 1.0 (fully underwater).\n\n" - "Note that unlike FootUnderwaterSound, this sound plays even if the " - "player is not moving around in the water.\n" ); - addField( "waterBreathSound", TypeSFXTrackName, Offset(sound[WaterBreath], PlayerData), - "@brief Sound to play when in water and coverage equals 1.0 (fully underwater).\n\n" - "Note that unlike FootUnderwaterSound, this sound plays even if the " - "player is not moving around in the water.\n" ); - - addField( "impactSoftSound", TypeSFXTrackName, Offset(sound[ImpactSoft], PlayerData), - "@brief Sound to play after falling on a surface with Material footstepSoundId 0.\n\n" ); - addField( "impactHardSound", TypeSFXTrackName, Offset(sound[ImpactHard], PlayerData), - "@brief Sound to play after falling on a surface with Material footstepSoundId 1.\n\n" ); - addField( "impactMetalSound", TypeSFXTrackName, Offset(sound[ImpactMetal], PlayerData), - "@brief Sound to play after falling on a surface with Material footstepSoundId 2.\n\n" ); - addField( "impactSnowSound", TypeSFXTrackName, Offset(sound[ImpactSnow], PlayerData), - "@brief Sound to play after falling on a surface with Material footstepSoundId 3.\n\n" ); - - addField( "impactWaterEasy", TypeSFXTrackName, Offset(sound[ImpactWaterEasy], PlayerData), - "@brief Sound to play when entering the water with velocity < " - "mediumSplashSoundVelocity.\n\n" - "@see mediumSplashSoundVelocity\n"); - addField( "impactWaterMedium", TypeSFXTrackName, Offset(sound[ImpactWaterMedium], PlayerData), - "@brief Sound to play when entering the water with velocity >= " - "mediumSplashSoundVelocity and < hardSplashSoundVelocity.\n\n" - "@see mediumSplashSoundVelocity\n" - "@see hardSplashSoundVelocity\n"); - addField( "impactWaterHard", TypeSFXTrackName, Offset(sound[ImpactWaterHard], PlayerData), - "@brief Sound to play when entering the water with velocity >= " - "hardSplashSoundVelocity.\n\n" - "@see hardSplashSoundVelocity\n"); - addField( "exitingWater", TypeSFXTrackName, Offset(sound[ExitWater], PlayerData), - "@brief Sound to play when exiting the water with velocity >= exitSplashSoundVelocity.\n\n" - "@see exitSplashSoundVelocity\n"); + INITPERSISTFIELD_SOUNDASSET_ENUMED(PlayerSound, playerSoundsEnum, PlayerData::Sounds::MaxSounds, PlayerData, "Sounds related to player interaction."); endGroup( "Interaction: Sounds" ); @@ -1303,8 +1276,8 @@ void PlayerData::packData(BitStream* stream) stream->write(minImpactSpeed); stream->write(minLateralImpactSpeed); - for( U32 i = 0; i < MaxSounds; i++) - sfxWrite( stream, sound[ i ] ); + for (U32 i = 0; i < MaxSounds; i++) + PACKDATA_SOUNDASSET_ARRAY(PlayerSound, i); mathWrite(*stream, boxSize); mathWrite(*stream, crouchBoxSize); @@ -1484,8 +1457,8 @@ void PlayerData::unpackData(BitStream* stream) stream->read(&minImpactSpeed); stream->read(&minLateralImpactSpeed); - for( U32 i = 0; i < MaxSounds; i++) - sfxRead( stream, &sound[ i ] ); + for (U32 i = 0; i < MaxSounds; i++) + UNPACKDATA_SOUNDASSET_ARRAY(PlayerSound, i); mathRead(*stream, &boxSize); mathRead(*stream, &crouchBoxSize); @@ -1932,11 +1905,11 @@ bool Player::onNewDataBlock( GameBaseData *dptr, bool reload ) SFX_DELETE( mMoveBubbleSound ); SFX_DELETE( mWaterBreathSound ); - if ( mDataBlock->sound[PlayerData::MoveBubbles] ) - mMoveBubbleSound = SFX->createSource( mDataBlock->sound[PlayerData::MoveBubbles] ); + if ( mDataBlock->getPlayerSound(PlayerData::MoveBubbles) ) + mMoveBubbleSound = SFX->createSource( mDataBlock->getPlayerSoundProfile(PlayerData::MoveBubbles) ); - if ( mDataBlock->sound[PlayerData::WaterBreath] ) - mWaterBreathSound = SFX->createSource( mDataBlock->sound[PlayerData::WaterBreath] ); + if ( mDataBlock->getPlayerSound(PlayerData::WaterBreath) ) + mWaterBreathSound = SFX->createSource( mDataBlock->getPlayerSoundProfile(PlayerData::WaterBreath) ); } mObjBox.maxExtents.x = mDataBlock->boxSize.x * 0.5f; @@ -3300,7 +3273,7 @@ void Player::updateMove(const Move* move) { // exit-water splash sound happens for client only if ( getSpeed() >= mDataBlock->exitSplashSoundVel && !isMounted() ) - SFX->playOnce( mDataBlock->sound[PlayerData::ExitWater], &getTransform() ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ExitWater), &getTransform() ); } } @@ -7060,17 +7033,17 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S // Treading water. if ( mWaterCoverage < mDataBlock->footSplashHeight ) - SFX->playOnce( mDataBlock->sound[ PlayerData::FootShallowSplash ], &footMat ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootShallowSplash ), &footMat ); else { if ( mWaterCoverage < 1.0 ) - SFX->playOnce( mDataBlock->sound[ PlayerData::FootWading ], &footMat ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootWading ), &footMat ); else { if ( triggeredLeft ) { - SFX->playOnce( mDataBlock->sound[ PlayerData::FootUnderWater ], &footMat ); - SFX->playOnce( mDataBlock->sound[ PlayerData::FootBubbles ], &footMat ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootUnderWater ), &footMat ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootBubbles ), &footMat ); } } } @@ -7092,7 +7065,7 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S sound = 2; if (sound>=0) - SFX->playOnce(mDataBlock->sound[sound], &footMat); + SFX->playOnce(mDataBlock->getPlayerSoundProfile(sound), &footMat); } } @@ -7123,7 +7096,7 @@ void Player:: playImpactSound() sound = 2; // Play metal; if (sound >= 0) - SFX->playOnce(mDataBlock->sound[PlayerData::ImpactStart + sound], &getTransform()); + SFX->playOnce(mDataBlock->getPlayerSoundProfile(PlayerData::ImpactStart + sound), &getTransform()); } } } @@ -7277,11 +7250,11 @@ bool Player::collidingWithWater( Point3F &waterHeight ) void Player::createSplash( Point3F &pos, F32 speed ) { if ( speed >= mDataBlock->hardSplashSoundVel ) - SFX->playOnce( mDataBlock->sound[PlayerData::ImpactWaterHard], &getTransform() ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterHard), &getTransform() ); else if ( speed >= mDataBlock->medSplashSoundVel ) - SFX->playOnce( mDataBlock->sound[PlayerData::ImpactWaterMedium], &getTransform() ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterMedium), &getTransform() ); else - SFX->playOnce( mDataBlock->sound[PlayerData::ImpactWaterEasy], &getTransform() ); + SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterEasy), &getTransform() ); if( mDataBlock->splash ) { diff --git a/Engine/source/T3D/player.h b/Engine/source/T3D/player.h index 042f45b37..5b775a79f 100644 --- a/Engine/source/T3D/player.h +++ b/Engine/source/T3D/player.h @@ -35,6 +35,7 @@ #include "collision/boxConvex.h" #endif +#include "T3D/assets/SoundAsset.h" #include "T3D/gameBase/gameProcess.h" class Material; @@ -218,7 +219,9 @@ struct PlayerData: public ShapeBaseData { ExitWater, MaxSounds }; - SFXTrack* sound[MaxSounds]; + + DECLARE_SOUNDASSET_ARRAY(PlayerData, PlayerSound, Sounds::MaxSounds); + DECLARE_SOUNDASSET_ARRAY_SETGET(PlayerData, PlayerSound); Point3F boxSize; ///< Width, depth, height Point3F crouchBoxSize; From 1c14dc5ec451543a95fdff7323abc1d96e0d227c Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Wed, 29 Sep 2021 12:36:02 +0100 Subject: [PATCH 22/37] The beast is ready for a look over. Can't have a soundAsset inside a struct. If we could this might work better. PrevState needs to be kept track of for clearing looping sounds before the next state is loaded in. This might cause issues when switching weapons. --- Engine/source/T3D/shapeBase.h | 15 ++++++++---- Engine/source/T3D/shapeImage.cpp | 39 ++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Engine/source/T3D/shapeBase.h b/Engine/source/T3D/shapeBase.h index 4d3286b5c..bdfb68e4f 100644 --- a/Engine/source/T3D/shapeBase.h +++ b/Engine/source/T3D/shapeBase.h @@ -73,6 +73,7 @@ // Need full definition visible for SimObjectPtr #include "T3D/fx/particleEmitter.h" +#include "T3D/assets/SoundAsset.h" class GFXCubemap; class TSShapeInstance; @@ -259,11 +260,12 @@ struct ShapeBaseImageData: public GameBaseData { /// the imageSlot. ParticleEmitterData* emitter; ///< A particle emitter; this emitter will emit as long as the gun is in this /// this state. - SFXTrack* sound; + + //SFXTrack* sound; F32 emitterTime; ///< S32 emitterNode[MaxShapes]; ///< Node ID on the shape to emit from + //DECLARE_SOUNDASSET(StateData, Sound); }; - /// @name State Data /// Individual state data used to initialize struct array /// @{ @@ -321,7 +323,10 @@ struct ShapeBaseImageData: public GameBaseData { bool stateIgnoreLoadedForReady [MaxStates]; - SFXTrack* stateSound [MaxStates]; + DECLARE_SOUNDASSET_ARRAY(ShapeBaseImageData, stateSound, MaxStates); + DECLARE_SOUNDASSET_ARRAY_SETGET(ShapeBaseImageData, stateSound); + + //SFXTrack* stateSound [MaxStates]; const char* stateScript [MaxStates]; ParticleEmitterData* stateEmitter [MaxStates]; @@ -662,7 +667,7 @@ public: DECLARE_CALLBACK( void, onCollision, ( ShapeBase* obj, SceneObject* collObj, VectorF vec, F32 len ) ); DECLARE_CALLBACK( void, onDamage, ( ShapeBase* obj, F32 delta ) ); DECLARE_CALLBACK( void, onTrigger, ( ShapeBase* obj, S32 index, bool state ) ); - DECLARE_CALLBACK(void, onEndSequence, (ShapeBase* obj, S32 slot, const char* name)); + DECLARE_CALLBACK( void, onEndSequence, (ShapeBase* obj, S32 slot, const char* name)); DECLARE_CALLBACK( void, onForceUncloak, ( ShapeBase* obj, const char* reason ) ); /// @} struct TextureTagRemapping @@ -1070,6 +1075,8 @@ protected: /// @param imageSlot Image slot id /// @param state State id /// @param force Force image to state or let it finish then change + + U32 prevState = 0; void setImageState(U32 imageSlot, U32 state, bool force = false); void updateAnimThread(U32 imageSlot, S32 imageShapeIndex, ShapeBaseImageData::StateData* lastState=NULL); diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index 7bd42bea5..b60105329 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -132,7 +132,7 @@ ShapeBaseImageData::StateData::StateData() loaded = IgnoreLoaded; spin = IgnoreSpin; recoil = NoRecoil; - sound = 0; + //sound = 0; emitter = NULL; shapeSequence = NULL; shapeSequenceScale = true; @@ -256,7 +256,7 @@ ShapeBaseImageData::ShapeBaseImageData() stateShapeSequence[i] = 0; stateScaleShapeSequence[i] = false; - stateSound[i] = 0; + INIT_SOUNDASSET_ARRAY(stateSound, i); stateScript[i] = 0; stateEmitter[i] = 0; stateEmitterTime[i] = 0; @@ -303,6 +303,7 @@ ShapeBaseImageData::ShapeBaseImageData() camShakeDuration = 1.5f; camShakeRadius = 3.0f; camShakeFalloff = 10.0f; + } ShapeBaseImageData::~ShapeBaseImageData() @@ -368,7 +369,7 @@ bool ShapeBaseImageData::onAdd() s.shapeSequence = stateShapeSequence[i]; s.shapeSequenceScale = stateScaleShapeSequence[i]; - s.sound = stateSound[i]; + _setstateSound(getstateSound(i),i); s.script = stateScript[i]; s.emitter = stateEmitter[i]; s.emitterTime = stateEmitterTime[i]; @@ -419,10 +420,14 @@ bool ShapeBaseImageData::preload(bool server, String &errorStr) if (state[i].emitter) if (!Sim::findObject(SimObjectId((uintptr_t)state[i].emitter), state[i].emitter)) Con::errorf(ConsoleLogEntry::General, "Error, unable to load emitter for image datablock"); - - String str; - if( !sfxResolve( &state[ i ].sound, str ) ) - Con::errorf( ConsoleLogEntry::General, str.c_str() ); + + if (getstateSound(i) != StringTable->EmptyString()) + { + _setstateSound(getstateSound(i), i); + if (!getstateSoundProfile(i)) + Con::errorf("ShapeBaseImageData::preload() - Could not find profile for asset %s on state %d", getstateSound(i), i); + } + } } @@ -922,8 +927,8 @@ void ShapeBaseImageData::initPersistFields() addField( "stateScaleShapeSequence", TypeBool, Offset(stateScaleShapeSequence, ShapeBaseImageData), MaxStates, "Indicates if the sequence to be played on the mounting shape should be scaled to the length of the state." ); - addField( "stateSound", TypeSFXTrackName, Offset(stateSound, ShapeBaseImageData), MaxStates, - "Sound to play on entry to this state." ); + INITPERSISTFIELD_SOUNDASSET_ARRAY(stateSound, MaxStates, ShapeBaseImageData, "State sound."); + addField( "stateScript", TypeCaseString, Offset(stateScript, ShapeBaseImageData), MaxStates, "@brief Method to execute on entering this state.\n\n" "Scoped to this image class name, then ShapeBaseImageData. The script " @@ -1140,7 +1145,7 @@ void ShapeBaseImageData::packData(BitStream* stream) } } - sfxWrite( stream, s.sound ); + PACKDATA_SOUNDASSET_ARRAY(stateSound, i); } stream->write(maxConcurrentSounds); stream->writeFlag(useRemainderDT); @@ -1345,7 +1350,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream) else s.emitter = 0; - sfxRead( stream, &s.sound ); + UNPACKDATA_SOUNDASSET_ARRAY(stateSound, i); } } @@ -2753,9 +2758,10 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force) { onImageStateAnimation(imageSlot, stateData.shapeSequence, stateData.direction, stateData.shapeSequenceScale, stateData.timeoutValue); } - // Delete any loooping sounds that were in the previous state. - if (lastState->sound && lastState->sound->getDescription()->mIsLooping) + // this is the crazy bit =/ needs to know prev state in order to stop sounds. + // lastState does not return an id for the prev state so we keep track of it. + if (image.dataBlock->getstateSound(prevState) && image.dataBlock->getstateSoundProfile(prevState)->getDescription()->mIsLooping) { for(Vector::iterator i = image.mSoundSources.begin(); i != image.mSoundSources.end(); i++) SFX_DELETE((*i)); @@ -2764,12 +2770,15 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force) } // Play sound - if( stateData.sound && isGhost() ) + if( image.dataBlock->getstateSound(newState) && isGhost() ) { const Point3F& velocity = getVelocity(); - image.addSoundSource(SFX->createSource( stateData.sound, &getRenderTransform(), &velocity )); + image.addSoundSource(SFX->createSource(image.dataBlock->getstateSoundProfile(newState), &getRenderTransform(), &velocity )); } + /// update our prevState. + prevState = newState; + // Play animation updateAnimThread(imageSlot, imageShapeIndex, lastState); for (U32 i=0; i Date: Wed, 29 Sep 2021 12:48:37 +0100 Subject: [PATCH 23/37] Another way of doing shapeBase, this requires fewer changes but will have an empty asset in each stateData until it is filled with an asset. Both these will need to be tested to see which one is better. --- Engine/source/T3D/shapeBase.h | 4 +--- Engine/source/T3D/shapeImage.cpp | 15 +++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Engine/source/T3D/shapeBase.h b/Engine/source/T3D/shapeBase.h index bdfb68e4f..a2696819e 100644 --- a/Engine/source/T3D/shapeBase.h +++ b/Engine/source/T3D/shapeBase.h @@ -264,7 +264,7 @@ struct ShapeBaseImageData: public GameBaseData { //SFXTrack* sound; F32 emitterTime; ///< S32 emitterNode[MaxShapes]; ///< Node ID on the shape to emit from - //DECLARE_SOUNDASSET(StateData, Sound); + SoundAsset* sound; }; /// @name State Data /// Individual state data used to initialize struct array @@ -1075,8 +1075,6 @@ protected: /// @param imageSlot Image slot id /// @param state State id /// @param force Force image to state or let it finish then change - - U32 prevState = 0; void setImageState(U32 imageSlot, U32 state, bool force = false); void updateAnimThread(U32 imageSlot, S32 imageShapeIndex, ShapeBaseImageData::StateData* lastState=NULL); diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index b60105329..ab43a0ba3 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -132,7 +132,7 @@ ShapeBaseImageData::StateData::StateData() loaded = IgnoreLoaded; spin = IgnoreSpin; recoil = NoRecoil; - //sound = 0; + sound = NULL; emitter = NULL; shapeSequence = NULL; shapeSequenceScale = true; @@ -156,6 +156,7 @@ ShapeBaseImageData::StateData::StateData() flashSequence[i] = false; emitterNode[i] = -1; } + } static ShapeBaseImageData::StateData gDefaultStateData; @@ -369,7 +370,8 @@ bool ShapeBaseImageData::onAdd() s.shapeSequence = stateShapeSequence[i]; s.shapeSequenceScale = stateScaleShapeSequence[i]; - _setstateSound(getstateSound(i),i); + //_setstateSound(getstateSound(i),i); + s.sound = getstateSoundAsset(i); s.script = stateScript[i]; s.emitter = stateEmitter[i]; s.emitterTime = stateEmitterTime[i]; @@ -2761,7 +2763,7 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force) // Delete any loooping sounds that were in the previous state. // this is the crazy bit =/ needs to know prev state in order to stop sounds. // lastState does not return an id for the prev state so we keep track of it. - if (image.dataBlock->getstateSound(prevState) && image.dataBlock->getstateSoundProfile(prevState)->getDescription()->mIsLooping) + if (lastState->sound && lastState->sound->getSfxProfile()->getDescription()->mIsLooping) { for(Vector::iterator i = image.mSoundSources.begin(); i != image.mSoundSources.end(); i++) SFX_DELETE((*i)); @@ -2770,15 +2772,12 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force) } // Play sound - if( image.dataBlock->getstateSound(newState) && isGhost() ) + if( stateData.sound && isGhost() ) { const Point3F& velocity = getVelocity(); - image.addSoundSource(SFX->createSource(image.dataBlock->getstateSoundProfile(newState), &getRenderTransform(), &velocity )); + image.addSoundSource(SFX->createSource(stateData.sound->getSfxProfile(), &getRenderTransform(), &velocity )); } - /// update our prevState. - prevState = newState; - // Play animation updateAnimThread(imageSlot, imageShapeIndex, lastState); for (U32 i=0; i Date: Wed, 29 Sep 2021 12:38:47 -0500 Subject: [PATCH 24/37] conflict resolution --- Engine/source/T3D/fx/lightning.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index dc92c1647..0e28b1a42 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -296,34 +296,20 @@ bool LightningData::preload(bool server, String &errorStr) { for (S32 i = 0; i < MaxThunders; i++) { -<<<<<<< HEAD - if (getThunderSound(i) != StringTable->EmptyString()) -======= - if (isThunderSoundValid(i)) ->>>>>>> 2630b4ada6a97222ad1e200fa962cf426b7d4161 + _setThunderSound(getThunderSound(i), i); + if (isThunderSoundValid(i) && !getThunderSoundProfile(i)) { - _setThunderSound(getThunderSound(i), i); - Con::printf("Thunder sound: %d %s", i, getThunderSound(i)); - - if (!getThunderSoundProfile(i)) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder."); } } -<<<<<<< HEAD - if (getStrikeSound() != StringTable->EmptyString()) + _setStrikeSound(getStrikeSound()); + if (isStrikeSoundValid() && !getStrikeSoundProfile()) { - _setStrikeSound(getStrikeSound()); - - if(!getStrikeSoundProfile()) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from strike sound."); } -======= - if(isStrikeSoundValid() && !getStrikeSoundProfile()) - Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset"); ->>>>>>> 2630b4ada6a97222ad1e200fa962cf426b7d4161 mNumStrikeTextures = 0; for (U32 k = 0; k < MaxTextures; k++) From 64a87ceba8a0d76b20c2efc60039d887f0131b12 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 30 Sep 2021 13:46:03 -0500 Subject: [PATCH 25/37] trim assetEnumNameConcat to 2 values, set INITPERSISTFIELD_SOUNDASSET_ENUMED to exclude maxValue --- Engine/source/T3D/assets/SoundAsset.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 7bbbcdc15..44817eb72 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -374,14 +374,14 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText #pragma endregion -#define assetEnumNameConcat(x,suff,ForT)(new std::string(std::string(#x) + suff + std::string(#ForT)))->c_str() +#define assetEnumNameConcat(x,suff)(new std::string( x + std::string(#suff)))->c_str() #define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \ - for (U32 i = 0; i <= maxValue; i++)\ + for (U32 i = 0; i < maxValue; i++)\ {\ const char* enumString = castConsoleTypeToString(static_cast(i));\ - addProtectedField(assetEnumNameConcat(name,enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ - addProtectedField(assetEnumNameConcat(name,enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));\ + addProtectedField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addProtectedField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));\ }\ #pragma region Arrayed Asset Macros From 65774ff123985804c1b1b6aa7e43c6a7aacfa357 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 30 Sep 2021 14:15:42 -0500 Subject: [PATCH 26/37] converter work pt1 --- .../pre40/T3Dpre4ProjectImporter.tscript | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript index d9eec5f2e..4d368ea12 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript @@ -839,7 +839,7 @@ T3Dpre4ProjectImporter::genProcessor("LevelInfo", "accuTexture accuTextureAsset" T3Dpre4ProjectImporter::genProcessor("TSStatic", "shape shapeAsset shapeName shapeAsset"); T3Dpre4ProjectImporter::genProcessor("TSForestItemData", "shape shapeAsset shapeName shapeAsset shapeFile shapeAsset"); T3Dpre4ProjectImporter::genProcessor("TerrainBlock", "terrainFile terrainAsset"); -T3Dpre4ProjectImporter::genProcessor("afxMagicMissileData", "projectileShapeName projectileShapeAsset"); +T3Dpre4ProjectImporter::genProcessor("afxMagicMissileData", "projectileShapeName projectileShapeAsset sound soundAsset"); T3Dpre4ProjectImporter::genProcessor("afxBillboardData", "texture textureAsset"); T3Dpre4ProjectImporter::genProcessor("afxModelData", "shapeName shapeAsset shapeFile shapeAsset"); T3Dpre4ProjectImporter::genProcessor("afxZodiacData", "texture textureAsset"); @@ -921,15 +921,30 @@ T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset"); T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset"); T3Dpre4ProjectImporter::genProcessor("ParticleData", "texture textureAsset textureName textureAsset textureExt textureExtAsset textureExtName textureExtAsset"); T3Dpre4ProjectImporter::genProcessor("PrecipitationData", "drop dropAsset dropTexture dropAsset splash splashAsset splashTexture splashAsset soundProfile soundAsset"); -T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset"); +T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset soundProfile SoundAsset"); T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset"); T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset"); T3Dpre4ProjectImporter::genProcessor("PhysicsShapeData", "shape shapeAsset shapeName shapeAsset"); T3Dpre4ProjectImporter::genProcessor("PlayerData", "shapeFP shapeFPAsset shapeNameFP shapeFPAsset"); -T3Dpre4ProjectImporter::genProcessor("ProjectileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset"); +T3Dpre4ProjectImporter::genProcessor("ProjectileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset sound soundAsset"); T3Dpre4ProjectImporter::genProcessor("ShapeBaseData", "shapeFile shapeAsset shape shapeAsset debrisShape debrisShapeAsset debrisShapeName debrisShapeAsset"); T3Dpre4ProjectImporter::genProcessor("ShapeBaseImageData", "shape shapeAsset[0] shapeFP shapeAsset[1] shapeFile shapeAsset[0] shapeFileFP shapeAsset[1]"); T3Dpre4ProjectImporter::genProcessor("WheeledVehicleTire", "shape shapeAsset shapeFile shapeAsset"); +T3Dpre4ProjectImporter::genProcessor("WheeledVehicleData", "engineSound engineSoundAsset squealSound squealSoundAsset"); +T3Dpre4ProjectImporter::genProcessor("FlyingVehicleData", "engineSound engineSoundAsset jetSound jetSoundAsset"); +T3Dpre4ProjectImporter::genProcessor("HoverVehicleData", "engineSound engineSoundAsset jetSound jetSoundAsset floatSound floatSoundAsset"); + +//============================================================================== +// Datablocks - Long Lists +//============================================================================== + +$rigidSoundList = "softImpactSound softImpactSoundAsset hardImpactSound hardImpactSoundAsset"; +$rigidSoundList = $rigidSoundList SPC "exitingWater exitingWaterAsset impactWaterEasy impactWaterEasyAsset"; +$rigidSoundList = $rigidSoundList SPC "impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset"; +$rigidSoundList = $rigidSoundList SPC "waterWakeSound waterWakeSoundAsset"; +T3Dpre4ProjectImporter::genProcessor("RigidShapeData",$rigidSoundList); + + //============================================================================== // Materials //============================================================================== From d3693bef8dca3d2c5948f80ee28cccb38b851e23 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 30 Sep 2021 14:40:03 -0500 Subject: [PATCH 27/37] shifted playerdata down to the Long Lists block. fix player enum ref source side --- Engine/source/T3D/player.cpp | 2 +- .../pre40/T3Dpre4ProjectImporter.tscript | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 3144bfcd9..37655598f 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -204,7 +204,7 @@ ImplementEnumType(playerSoundsEnum, "enum types.\n" {PlayerData::Sounds::FootBubbles, "FootBubbles","..." }, {PlayerData::Sounds::MoveBubbles, "MoveBubbles","..." }, {PlayerData::Sounds::WaterBreath, "WaterBreath","..." }, - {PlayerData::Sounds::ImpactStart, "ImpactStart","..." }, + {PlayerData::Sounds::ImpactSoft, "ImpactSoft","..." }, {PlayerData::Sounds::ImpactHard, "ImpactHard","..." }, {PlayerData::Sounds::ImpactMetal, "ImpactMetal","..." }, {PlayerData::Sounds::ImpactSnow, "ImpactSnow","..." }, diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript index 4d368ea12..8382fa7ca 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript @@ -925,10 +925,10 @@ T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset soundPr T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset"); T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset"); T3Dpre4ProjectImporter::genProcessor("PhysicsShapeData", "shape shapeAsset shapeName shapeAsset"); -T3Dpre4ProjectImporter::genProcessor("PlayerData", "shapeFP shapeFPAsset shapeNameFP shapeFPAsset"); T3Dpre4ProjectImporter::genProcessor("ProjectileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset sound soundAsset"); T3Dpre4ProjectImporter::genProcessor("ShapeBaseData", "shapeFile shapeAsset shape shapeAsset debrisShape debrisShapeAsset debrisShapeName debrisShapeAsset"); -T3Dpre4ProjectImporter::genProcessor("ShapeBaseImageData", "shape shapeAsset[0] shapeFP shapeAsset[1] shapeFile shapeAsset[0] shapeFileFP shapeAsset[1]"); +T3Dpre4ProjectImporter::genProcessor("ShapeBaseImageData", "shape shapeAsset[0] shapeFP shapeAsset[1] shapeFile shapeAsset[0] shapeFileFP shapeAsset[1] stateSound stateSoundAsset"); +T3Dpre4ProjectImporter::genProcessor("ProximityMineData","armingSound ArmSoundAsset TriggerSound TriggerSoundAsset"); T3Dpre4ProjectImporter::genProcessor("WheeledVehicleTire", "shape shapeAsset shapeFile shapeAsset"); T3Dpre4ProjectImporter::genProcessor("WheeledVehicleData", "engineSound engineSoundAsset squealSound squealSoundAsset"); T3Dpre4ProjectImporter::genProcessor("FlyingVehicleData", "engineSound engineSoundAsset jetSound jetSoundAsset"); @@ -938,13 +938,25 @@ T3Dpre4ProjectImporter::genProcessor("HoverVehicleData", "engineSound engineSoun // Datablocks - Long Lists //============================================================================== -$rigidSoundList = "softImpactSound softImpactSoundAsset hardImpactSound hardImpactSoundAsset"; -$rigidSoundList = $rigidSoundList SPC "exitingWater exitingWaterAsset impactWaterEasy impactWaterEasyAsset"; -$rigidSoundList = $rigidSoundList SPC "impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset"; -$rigidSoundList = $rigidSoundList SPC "waterWakeSound waterWakeSoundAsset"; -T3Dpre4ProjectImporter::genProcessor("RigidShapeData",$rigidSoundList); +$rigidEntriesList = "softImpactSound softImpactSoundAsset hardImpactSound hardImpactSoundAsset"; +$rigidEntriesList = $rigidEntriesList SPC "exitingWater exitingWaterAsset impactWaterEasy impactWaterEasyAsset"; +$rigidEntriesList = $rigidEntriesList SPC "impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset"; +$rigidEntriesList = $rigidEntriesList SPC "waterWakeSound waterWakeSoundAsset"; +T3Dpre4ProjectImporter::genProcessor("RigidShapeData",$rigidEntriesList); + +$PlayerEntriesList = "shapeFP shapeFPAsset shapeNameFP shapeFPAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "FootSoftSound FootSoftAsset FootHardSound FootHardAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "FootSnowSound FootSnowAsset FootShallowSound FootShallowSplashAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "FootWadingSound FootWadingAsset FootUnderwaterSound FootUnderWaterAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "FootBubblesSound FootBubblesAsset movingBubblesSound MoveBubblesAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "waterBreathSound WaterBreathAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "impactSoftSound ImpactSoftAsset impactHardSound impactHardAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "impactMetalSound ImpactMetalAsset impactSnowSound impactSnowAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "impactWaterEasy impactWaterEasyAsset impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "exitingWater ExitWaterAsset"; +T3Dpre4ProjectImporter::genProcessor("PlayerData", $PlayerEntriesList); //============================================================================== // Materials //============================================================================== From 5c7069555a98cbfb7833b624fbbd44e20239f80c Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 30 Sep 2021 16:00:37 -0500 Subject: [PATCH 28/37] filter out array entries without enum strings --- Engine/source/T3D/assets/SoundAsset.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 44817eb72..97b68f745 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -380,10 +380,12 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText for (U32 i = 0; i < maxValue; i++)\ {\ const char* enumString = castConsoleTypeToString(static_cast(i));\ - addProtectedField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ - addProtectedField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));\ - }\ - + if (enumString && enumString[0])\ + {\ + addProtectedField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addProtectedField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));\ + }\ + } #pragma region Arrayed Asset Macros #define DECLARE_SOUNDASSET_ARRAY(className,name,max) public: \ From c99c9cc3652fb6c0b86c9857587d7bbfd12bec64 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 2 Oct 2021 20:58:44 -0500 Subject: [PATCH 29/37] include metal FootMetalSound oversight, include correction for mangled entries where a given varname and a given assetname match --- .../scripts/pre40/T3Dpre4ProjectImporter.tscript | 2 +- .../projectImporter/scripts/projectImporter.tscript | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript index 8382fa7ca..119ba6066 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript @@ -945,7 +945,7 @@ $rigidEntriesList = $rigidEntriesList SPC "waterWakeSound waterWakeSoundAsset"; T3Dpre4ProjectImporter::genProcessor("RigidShapeData",$rigidEntriesList); $PlayerEntriesList = "shapeFP shapeFPAsset shapeNameFP shapeFPAsset"; -$PlayerEntriesList = $PlayerEntriesList SPC "FootSoftSound FootSoftAsset FootHardSound FootHardAsset"; +$PlayerEntriesList = $PlayerEntriesList SPC "FootSoftSound FootSoftAsset FootHardSound FootHardAsset FootMetalSound FootMetal"; $PlayerEntriesList = $PlayerEntriesList SPC "FootSnowSound FootSnowAsset FootShallowSound FootShallowSplashAsset"; $PlayerEntriesList = $PlayerEntriesList SPC "FootWadingSound FootWadingAsset FootUnderwaterSound FootUnderWaterAsset"; $PlayerEntriesList = $PlayerEntriesList SPC "FootBubblesSound FootBubblesAsset movingBubblesSound MoveBubblesAsset"; diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript index eca0e0b07..cfdd7c8bf 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript @@ -515,7 +515,7 @@ function testFilenameExtensions(%filename) } function processLegacyField(%line, %originalFieldName, %newFieldName) -{ +{ if(!strIsMatchExpr("*"@%originalFieldName@"=*;*", %line) && !strIsMatchExpr("*"@%originalFieldName@"[*=*;*", %line) && !strIsMatchExpr("*"@%originalFieldName@" *=*;*", %line)) @@ -603,10 +603,10 @@ function processLegacyField(%line, %originalFieldName, %newFieldName) if(!strIsMatchExpr("*\"*\"*", %originalValue)) %assetId = "\"" @ %assetId @ "\""; - //if (%assetId.getStatusString() $= "Ok") - %outLine = strReplace(%outLine, %value, %assetId); - //else - // error("Asset assignment failure:", %assetId, getStatusString()); + %firstPart = getToken(%outLine, "=", 0); + %secondPart = getToken(%outLine, "=", 1); + %secondPart = strReplace(%secondPart, %value, %assetId); + %outLine = %firstPart @ "=" @ %secondPart; } } From 0760621212117b9e6eeeafcf133019aa4b08cb8d Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 2 Oct 2021 21:01:14 -0500 Subject: [PATCH 30/37] fix item->importStatus tagging in importer --- Engine/source/T3D/assets/assetImporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index 5df1ca8ab..254df381d 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -1409,7 +1409,7 @@ void AssetImporter::processImportAssets(AssetImportObject* assetItem) Con::executef(this, processCommand.c_str(), item); } - item->importStatus == AssetImportObject::Processed; + item->importStatus = AssetImportObject::Processed; //try recusing on the children(if any) processImportAssets(item); @@ -2018,7 +2018,7 @@ void AssetImporter::validateAsset(AssetImportObject* assetItem) AssetQuery aQuery; U32 numAssetsFound = AssetDatabase.findAllAssets(&aQuery); - bool hasCollision = false; + hasCollision = false; for (U32 i = 0; i < numAssetsFound; i++) { StringTableEntry assetId = aQuery.mAssetList[i]; From 19eb3c42f015a80b09bfeb7f66181ce3af8ad8fa Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 2 Oct 2021 21:05:04 -0500 Subject: [PATCH 31/37] more enum work, now with somewhat clearer boundary names, and some debug spam for initpersistfields, and pack and unpack macros to help us try and trace why those are scrambling --- Engine/source/T3D/assets/SoundAsset.h | 47 ++++++++++++++++++-- Engine/source/T3D/player.cpp | 64 +++++++++++++-------------- Engine/source/T3D/player.h | 4 +- 3 files changed, 77 insertions(+), 38 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 97b68f745..5a9af9eb3 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -381,11 +381,18 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText {\ const char* enumString = castConsoleTypeToString(static_cast(i));\ if (enumString && enumString[0])\ - {\ + { Con::printf("%s", enumString);\ addProtectedField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ addProtectedField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));\ }\ } + +#define INITPERSISTFIELD_SOUNDASSET_ENUM(enumString, name, enumVal, consoleClass, docs) \ + {\ + addProtectedField(assetText(enumString, File), TypeSoundFilename, Offset(m##name##Name[enumVal], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name[enumVal], docs), AbstractClassRep::FIELD_HideInInspectors); \ + addProtectedField(assetText(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[enumVal], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name[enumVal], asset reference.));\ + }\ + #pragma region Arrayed Asset Macros #define DECLARE_SOUNDASSET_ARRAY(className,name,max) public: \ @@ -574,6 +581,7 @@ DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , a 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];\ + m##name[index] = = other.m##name[index];\ } #define LOAD_SOUNDASSET_ARRAY(name, index)\ @@ -602,7 +610,10 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ _set##name(m##name##AssetId[index], index);\ }\ else\ - m##name##Name[index] = stream->readSTString(); + {\ + m##name##Name[index] = stream->readSTString();\ + _set##name(m##name##AssetId[index], index);\ + } #define PACK_SOUNDASSET_ARRAY(netconn, name, index)\ if (stream->writeFlag(m##name##Asset[index].notNull()))\ @@ -620,8 +631,38 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ _set##name(m##name##AssetId[index], index);\ }\ else\ - m##name##Name[index] = stream->readSTString(); + {\ + m##name##Name[index] = stream->readSTString();\ + _set##name(m##name##AssetId[index], index);\ + } +#define PACKDATA_SOUNDASSET_ARRAY_ENUMED(name, enumType, index )\ +{\ + if (stream->writeFlag(m##name##Asset[index].notNull()))\ + {\ + stream->writeString(m##name##Asset[index].getAssetId());\ + const char* enumString = castConsoleTypeToString(static_cast(index));\ + Con::printf("pack: %s = %s",enumString, m##name##AssetId[index]);\ + }\ + else\ + stream->writeString(m##name##Name[index]);\ +} + +#define UNPACKDATA_SOUNDASSET_ARRAY_ENUMED(name, enumType, index )\ +{\ + if (stream->readFlag())\ + {\ + m##name##AssetId[index] = stream->readSTString();\ + _set##name(m##name##AssetId[index], index);\ + const char* enumString = castConsoleTypeToString(static_cast(index));\ + Con::printf("unpack: %s = %s",enumString, m##name##AssetId[index]);\ + }\ + else\ + {\ + m##name##Name[index] = stream->readSTString();\ + _set##name(m##name##AssetId[index], index);\ + }\ +} #pragma endregion #endif // _ASSET_BASE_H_ diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 37655598f..3e994995a 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -194,24 +194,24 @@ DefineEnumType(playerSoundsEnum); ImplementEnumType(playerSoundsEnum, "enum types.\n" "@ingroup PlayerData\n\n") - {PlayerData::Sounds::FootSoft, "FootSoft","..." }, - {PlayerData::Sounds::FootHard, "FootHard","..." }, - {PlayerData::Sounds::FootMetal, "FootMetal","..." }, - {PlayerData::Sounds::FootSnow, "FootSnow","..." }, - {PlayerData::Sounds::FootShallowSplash, "FootShallowSplash","..." }, - {PlayerData::Sounds::FootWading, "FootWading","..." }, - {PlayerData::Sounds::FootUnderWater, "FootUnderWater","..." }, - {PlayerData::Sounds::FootBubbles, "FootBubbles","..." }, - {PlayerData::Sounds::MoveBubbles, "MoveBubbles","..." }, - {PlayerData::Sounds::WaterBreath, "WaterBreath","..." }, - {PlayerData::Sounds::ImpactSoft, "ImpactSoft","..." }, - {PlayerData::Sounds::ImpactHard, "ImpactHard","..." }, - {PlayerData::Sounds::ImpactMetal, "ImpactMetal","..." }, - {PlayerData::Sounds::ImpactSnow, "ImpactSnow","..." }, - {PlayerData::Sounds::ImpactWaterEasy, "ImpactWaterEasy","..." }, - {PlayerData::Sounds::ImpactWaterMedium, "ImpactWaterMedium","..." }, - {PlayerData::Sounds::ImpactWaterHard, "ImpactWaterHard","..." }, - {PlayerData::Sounds::ExitWater, "ExitWater","..." }, + { playerSoundsEnum::FootSoft, "FootSoft", "..." }, + { playerSoundsEnum::FootHard, "FootHard","..." }, + { playerSoundsEnum::FootMetal, "FootMetal","..." }, + { playerSoundsEnum::FootSnow, "FootSnow","..." }, + { playerSoundsEnum::FootShallowSplash, "FootShallowSplash","..." }, + { playerSoundsEnum::FootWading, "FootWading","..." }, + { playerSoundsEnum::FootUnderWater, "FootUnderWater","..." }, + { playerSoundsEnum::FootBubbles, "FootBubbles","..." }, + { playerSoundsEnum::MoveBubbles, "MoveBubbles","..." }, + { playerSoundsEnum::WaterBreath, "WaterBreath","..." }, + { playerSoundsEnum::ImpactSoft, "ImpactSoft","..." }, + { playerSoundsEnum::ImpactHard, "ImpactHard","..." }, + { playerSoundsEnum::ImpactMetal, "ImpactMetal","..." }, + { playerSoundsEnum::ImpactSnow, "ImpactSnow","..." }, + { playerSoundsEnum::ImpactWaterEasy, "ImpactWaterEasy","..." }, + { playerSoundsEnum::ImpactWaterMedium, "ImpactWaterMedium","..." }, + { playerSoundsEnum::ImpactWaterHard, "ImpactWaterHard","..." }, + { playerSoundsEnum::ExitWater, "ExitWater","..." }, EndImplementEnumType; //---------------------------------------------------------------------------- @@ -469,18 +469,16 @@ bool PlayerData::preload(bool server, String &errorStr) if(!Parent::preload(server, errorStr)) return false; - // Resolve objects transmitted from server - if( !server ) + for (U32 i = 0; i < MaxSounds; ++i) { - for( U32 i = 0; i < MaxSounds; ++ i ) + _setPlayerSound(getPlayerSound(i), i); + if (getPlayerSound(i) != StringTable->EmptyString()) { - if (getPlayerSound(i) != StringTable->EmptyString()) - { - _setPlayerSound(getPlayerSound(i), i); - } - if (!getPlayerSoundProfile(i)) - Con::errorf("PlayerData::Preload() - unable to find sfxProfile for asset %d %s", i, getPlayerSound(i)); + Con::errorf("PlayerData::Preload() - unable to find sfxProfile for asset %d %s", i, mPlayerSoundAssetId[i]); + + const char* enumString = castConsoleTypeToString(static_cast(i)); + Con::printf("preload: %s = %s", enumString, mPlayerSoundAssetId[i]); } } @@ -1051,7 +1049,7 @@ void PlayerData::initPersistFields() addGroup( "Interaction: Sounds" ); - INITPERSISTFIELD_SOUNDASSET_ENUMED(PlayerSound, playerSoundsEnum, PlayerData::Sounds::MaxSounds, PlayerData, "Sounds related to player interaction."); + INITPERSISTFIELD_SOUNDASSET_ENUMED(PlayerSound, playerSoundsEnum, PlayerData::Sounds::MaxSounds, PlayerData, "Sounds related to player interaction."); endGroup( "Interaction: Sounds" ); @@ -1277,7 +1275,7 @@ void PlayerData::packData(BitStream* stream) stream->write(minLateralImpactSpeed); for (U32 i = 0; i < MaxSounds; i++) - PACKDATA_SOUNDASSET_ARRAY(PlayerSound, i); + PACKDATA_SOUNDASSET_ARRAY_ENUMED(PlayerSound, PlayerData::Sounds, i); mathWrite(*stream, boxSize); mathWrite(*stream, crouchBoxSize); @@ -1458,7 +1456,7 @@ void PlayerData::unpackData(BitStream* stream) stream->read(&minLateralImpactSpeed); for (U32 i = 0; i < MaxSounds; i++) - UNPACKDATA_SOUNDASSET_ARRAY(PlayerSound, i); + UNPACKDATA_SOUNDASSET_ARRAY_ENUMED(PlayerSound, PlayerData::Sounds, i); mathRead(*stream, &boxSize); mathRead(*stream, &crouchBoxSize); @@ -7059,7 +7057,7 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S // Play default sound. S32 sound = -1; - if (contactMaterial && (contactMaterial->mFootstepSoundId>-1 && contactMaterial->mFootstepSoundIdmFootstepSoundId > -1 && contactMaterial->mFootstepSoundId < PlayerData::WaterStart)) sound = contactMaterial->mFootstepSoundId; else if( contactObject && contactObject->getTypeMask() & VehicleObjectType ) sound = 2; @@ -7090,13 +7088,13 @@ void Player:: playImpactSound() else { S32 sound = -1; - if (material && (material->mImpactSoundId>-1 && material->mImpactSoundIdmImpactSoundId > -1 && material->mImpactSoundId < PlayerData::WaterStart)) sound = material->mImpactSoundId; else if( rInfo.object->getTypeMask() & VehicleObjectType ) sound = 2; // Play metal; if (sound >= 0) - SFX->playOnce(mDataBlock->getPlayerSoundProfile(PlayerData::ImpactStart + sound), &getTransform()); + SFX->playOnce(mDataBlock->getPlayerSoundProfile(PlayerData::ImpactSoft + sound), &getTransform()); } } } diff --git a/Engine/source/T3D/player.h b/Engine/source/T3D/player.h index 5b775a79f..55430749c 100644 --- a/Engine/source/T3D/player.h +++ b/Engine/source/T3D/player.h @@ -201,8 +201,8 @@ struct PlayerData: public ShapeBaseData { FootHard, FootMetal, FootSnow, - MaxSoundOffsets, - FootShallowSplash, + WaterStart, + FootShallowSplash = WaterStart, FootWading, FootUnderWater, FootBubbles, From 10f2453ceede5fd9f8a9ef6648c77fef9e22d2a9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 2 Oct 2021 23:24:46 -0500 Subject: [PATCH 32/37] setget was causing active interference with INITPERSISTFIELD_SOUNDASSET_ENUMED --- Engine/source/T3D/assets/SoundAsset.h | 32 +++++++++++---------------- Engine/source/T3D/player.h | 1 - 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 5a9af9eb3..1d98b61b1 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -374,25 +374,6 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText #pragma endregion -#define assetEnumNameConcat(x,suff)(new std::string( x + std::string(#suff)))->c_str() - -#define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \ - for (U32 i = 0; i < maxValue; i++)\ - {\ - const char* enumString = castConsoleTypeToString(static_cast(i));\ - if (enumString && enumString[0])\ - { Con::printf("%s", enumString);\ - addProtectedField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ - addProtectedField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));\ - }\ - } - -#define INITPERSISTFIELD_SOUNDASSET_ENUM(enumString, name, enumVal, consoleClass, docs) \ - {\ - addProtectedField(assetText(enumString, File), TypeSoundFilename, Offset(m##name##Name[enumVal], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name[enumVal], docs), AbstractClassRep::FIELD_HideInInspectors); \ - addProtectedField(assetText(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[enumVal], consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name[enumVal], asset reference.));\ - }\ - #pragma region Arrayed Asset Macros #define DECLARE_SOUNDASSET_ARRAY(className,name,max) public: \ @@ -663,6 +644,19 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ _set##name(m##name##AssetId[index], index);\ }\ } + +#define assetEnumNameConcat(x,suff)(new std::string( x + std::string(#suff)))->c_str() + +#define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \ + for (U32 i = 0; i < maxValue; i++)\ + {\ + const char* enumString = castConsoleTypeToString(static_cast(i));\ + if (enumString && enumString[0])\ + { Con::printf("%s", enumString);\ + addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), assetText(name, asset reference.));\ + }\ + } #pragma endregion #endif // _ASSET_BASE_H_ diff --git a/Engine/source/T3D/player.h b/Engine/source/T3D/player.h index 55430749c..ed0cfea63 100644 --- a/Engine/source/T3D/player.h +++ b/Engine/source/T3D/player.h @@ -221,7 +221,6 @@ struct PlayerData: public ShapeBaseData { }; DECLARE_SOUNDASSET_ARRAY(PlayerData, PlayerSound, Sounds::MaxSounds); - DECLARE_SOUNDASSET_ARRAY_SETGET(PlayerData, PlayerSound); Point3F boxSize; ///< Width, depth, height Point3F crouchBoxSize; From 98a079a797c6e85bece7d9ea6ea541618a1cdf90 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 3 Oct 2021 02:56:26 -0500 Subject: [PATCH 33/37] code duplication prune. should aid in stability --- Engine/source/T3D/accumulationVolume.cpp | 6 +- Engine/source/T3D/accumulationVolume.h | 2 +- Engine/source/T3D/assets/ImageAsset.h | 135 +-------- Engine/source/T3D/assets/MaterialAsset.h | 85 +----- Engine/source/T3D/assets/ShapeAsset.h | 181 +----------- Engine/source/T3D/assets/SoundAsset.h | 214 +------------- Engine/source/T3D/assets/assetMacroHelpers.h | 274 ++++++++++++++++++ Engine/source/T3D/convexShape.cpp | 8 +- Engine/source/T3D/convexShape.h | 6 +- Engine/source/T3D/debris.cpp | 8 +- Engine/source/T3D/debris.h | 2 +- Engine/source/T3D/decal/decalData.cpp | 6 +- Engine/source/T3D/decal/decalData.h | 4 +- .../source/T3D/examples/renderMeshExample.cpp | 6 +- .../source/T3D/examples/renderMeshExample.h | 2 +- .../T3D/examples/renderShapeExample.cpp | 6 +- .../source/T3D/examples/renderShapeExample.h | 2 +- Engine/source/T3D/fx/explosion.cpp | 16 +- Engine/source/T3D/fx/explosion.h | 4 +- Engine/source/T3D/fx/groundCover.cpp | 12 +- Engine/source/T3D/fx/groundCover.h | 4 +- Engine/source/T3D/fx/lightning.cpp | 12 +- Engine/source/T3D/fx/lightning.h | 4 +- Engine/source/T3D/fx/particle.cpp | 18 +- Engine/source/T3D/fx/particle.h | 4 +- Engine/source/T3D/fx/precipitation.cpp | 18 +- Engine/source/T3D/fx/precipitation.h | 6 +- Engine/source/T3D/fx/splash.cpp | 12 +- Engine/source/T3D/fx/splash.h | 2 +- Engine/source/T3D/groundPlane.cpp | 6 +- Engine/source/T3D/groundPlane.h | 2 +- Engine/source/T3D/levelInfo.cpp | 6 +- Engine/source/T3D/levelInfo.h | 2 +- Engine/source/T3D/lightFlareData.cpp | 6 +- Engine/source/T3D/lightFlareData.h | 2 +- Engine/source/T3D/physics/physicsDebris.cpp | 6 +- Engine/source/T3D/physics/physicsDebris.h | 2 +- Engine/source/T3D/physics/physicsShape.cpp | 6 +- Engine/source/T3D/physics/physicsShape.h | 2 +- Engine/source/T3D/player.cpp | 17 +- Engine/source/T3D/player.h | 7 +- Engine/source/T3D/projectile.cpp | 16 +- Engine/source/T3D/projectile.h | 4 +- Engine/source/T3D/proximityMine.cpp | 12 +- Engine/source/T3D/proximityMine.h | 4 +- Engine/source/T3D/rigidShape.cpp | 12 +- Engine/source/T3D/rigidShape.h | 4 +- Engine/source/T3D/sfx/sfxEmitter.cpp | 6 +- Engine/source/T3D/sfx/sfxEmitter.h | 2 +- Engine/source/T3D/shapeBase.cpp | 16 +- Engine/source/T3D/shapeBase.h | 10 +- Engine/source/T3D/shapeImage.cpp | 12 +- Engine/source/T3D/tsStatic.cpp | 6 +- Engine/source/T3D/tsStatic.h | 2 +- Engine/source/T3D/vehicles/flyingVehicle.cpp | 6 +- Engine/source/T3D/vehicles/flyingVehicle.h | 2 +- Engine/source/T3D/vehicles/hoverVehicle.cpp | 6 +- Engine/source/T3D/vehicles/hoverVehicle.h | 2 +- Engine/source/T3D/vehicles/vehicle.cpp | 12 +- Engine/source/T3D/vehicles/vehicle.h | 4 +- Engine/source/T3D/vehicles/wheeledVehicle.cpp | 12 +- Engine/source/T3D/vehicles/wheeledVehicle.h | 4 +- Engine/source/afx/afxMagicMissile.cpp | 8 +- Engine/source/afx/afxMagicMissile.h | 2 +- Engine/source/afx/ce/afxBillboard.cpp | 8 +- Engine/source/afx/ce/afxBillboard.h | 2 +- Engine/source/afx/ce/afxModel.cpp | 8 +- Engine/source/afx/ce/afxModel.h | 2 +- Engine/source/afx/ce/afxZodiac.cpp | 8 +- Engine/source/afx/ce/afxZodiac.h | 2 +- Engine/source/afx/ce/afxZodiacPlane.cpp | 8 +- Engine/source/afx/ce/afxZodiacPlane.h | 2 +- Engine/source/assets/assetBase.h | 1 - Engine/source/environment/VolumetricFog.cpp | 12 +- Engine/source/environment/VolumetricFog.h | 6 +- Engine/source/environment/basicClouds.cpp | 4 +- Engine/source/environment/cloudLayer.cpp | 6 +- Engine/source/environment/cloudLayer.h | 4 +- Engine/source/environment/decalRoad.cpp | 6 +- Engine/source/environment/decalRoad.h | 2 +- .../editors/guiMeshRoadEditorCtrl.cpp | 6 +- .../editors/guiMeshRoadEditorCtrl.h | 6 +- .../environment/editors/guiRoadEditorCtrl.h | 2 +- Engine/source/environment/meshRoad.cpp | 18 +- Engine/source/environment/meshRoad.h | 6 +- Engine/source/environment/scatterSky.cpp | 6 +- Engine/source/environment/scatterSky.h | 2 +- Engine/source/environment/skyBox.cpp | 6 +- Engine/source/environment/skyBox.h | 2 +- Engine/source/environment/sun.cpp | 6 +- Engine/source/environment/sun.h | 2 +- Engine/source/environment/waterObject.cpp | 18 +- Engine/source/environment/waterObject.h | 6 +- Engine/source/forest/forestItem.cpp | 6 +- Engine/source/forest/forestItem.h | 2 +- Engine/source/gfx/sim/cubemapData.cpp | 4 +- Engine/source/gfx/sim/cubemapData.h | 2 +- .../gui/buttons/guiBitmapButtonCtrl.cpp | 4 +- .../source/gui/buttons/guiBitmapButtonCtrl.h | 2 +- .../source/gui/buttons/guiIconButtonCtrl.cpp | 4 +- Engine/source/gui/buttons/guiIconButtonCtrl.h | 2 +- .../gui/buttons/guiToolboxButtonCtrl.cpp | 12 +- .../source/gui/buttons/guiToolboxButtonCtrl.h | 6 +- Engine/source/gui/controls/guiBitmapCtrl.cpp | 2 +- Engine/source/gui/controls/guiBitmapCtrl.h | 2 +- .../source/gui/controls/guiMaterialCtrl.cpp | 2 +- Engine/source/gui/controls/guiMaterialCtrl.h | 2 +- Engine/source/gui/controls/guiPopUpCtrl.cpp | 4 +- Engine/source/gui/controls/guiPopUpCtrlEx.cpp | 4 +- Engine/source/gui/core/guiControl.cpp | 2 +- Engine/source/gui/core/guiTypes.cpp | 4 +- Engine/source/gui/core/guiTypes.h | 4 +- .../source/gui/game/guiChunkedBitmapCtrl.cpp | 2 +- Engine/source/gui/game/guiChunkedBitmapCtrl.h | 2 +- .../source/gui/game/guiProgressBitmapCtrl.cpp | 2 +- .../source/gui/game/guiProgressBitmapCtrl.h | 2 +- .../source/gui/worldEditor/guiMissionArea.cpp | 2 +- .../source/gui/worldEditor/guiMissionArea.h | 2 +- Engine/source/gui/worldEditor/worldEditor.h | 6 +- .../source/materials/materialDefinition.cpp | 24 +- Engine/source/postFx/postEffect.cpp | 2 +- Engine/source/terrain/terrMaterial.cpp | 20 +- Engine/source/terrain/terrMaterial.h | 10 +- 123 files changed, 632 insertions(+), 966 deletions(-) create mode 100644 Engine/source/T3D/assets/assetMacroHelpers.h diff --git a/Engine/source/T3D/accumulationVolume.cpp b/Engine/source/T3D/accumulationVolume.cpp index 37e9f4ae9..139a843b9 100644 --- a/Engine/source/T3D/accumulationVolume.cpp +++ b/Engine/source/T3D/accumulationVolume.cpp @@ -85,7 +85,7 @@ AccumulationVolume::AccumulationVolume() mWorldToObj.identity(); // Accumulation Texture. - INIT_IMAGEASSET(Texture); + INIT_ASSET(Texture); resetWorldBox(); } @@ -236,7 +236,7 @@ U32 AccumulationVolume::packUpdate( NetConnection *connection, U32 mask, BitStre if (stream->writeFlag(mask & InitialUpdateMask)) { - PACK_IMAGEASSET(connection, Texture); + PACK_ASSET(connection, Texture); } return retMask; @@ -248,7 +248,7 @@ void AccumulationVolume::unpackUpdate( NetConnection *connection, BitStream *str if (stream->readFlag()) { - UNPACK_IMAGEASSET(connection, Texture); + UNPACK_ASSET(connection, Texture); //setTexture(mTextureName); } } diff --git a/Engine/source/T3D/accumulationVolume.h b/Engine/source/T3D/accumulationVolume.h index 2b05fa81b..4c4049b6c 100644 --- a/Engine/source/T3D/accumulationVolume.h +++ b/Engine/source/T3D/accumulationVolume.h @@ -62,7 +62,7 @@ class AccumulationVolume : public ScenePolyhedralSpace virtual void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ); DECLARE_IMAGEASSET(AccumulationVolume, Texture, onTextureChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_NET_SETGET(AccumulationVolume, Texture, -1); + DECLARE_ASSET_NET_SETGET(AccumulationVolume, Texture, -1); void onTextureChanged() {} diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index 7afcd6da2..d4de538f7 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -47,7 +47,7 @@ #include "sim/netConnection.h" #include - +#include "assetMacroHelpers.h" //----------------------------------------------------------------------------- class ImageAsset : public AssetBase { @@ -273,45 +273,6 @@ public: \ }\ bool name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } -#define DECLARE_IMAGEASSET_SETGET(className, name)\ - static bool _set##name##Data(void* obj, const char* index, const char* data)\ - {\ - bool ret = false;\ - className* object = static_cast(obj);\ - ret = object->_set##name(StringTable->insert(data));\ - return ret;\ - } - -#define DECLARE_IMAGEASSET_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(obj);\ - ret = object->_set##name(StringTable->insert(data));\ - if(ret)\ - object->setMaskBits(bitmask);\ - return ret;\ - } - -#define DEF_IMAGEASSET_BINDS(className,name)\ -DefineEngineMethod(className, get##name, const char*, (), , "get name")\ -{\ - return object->get##name(); \ -}\ -DefineEngineMethod(className, get##name##Asset, const char*, (), , assetText(name, asset reference))\ -{\ - return object->m##name##AssetId; \ -}\ -DefineEngineMethod(className, set##name, bool, (const char* map), , assetText(name,assignment. first tries asset then flat file.))\ -{\ - return object->_set##name(StringTable->insert(map));\ -} - -#define INIT_IMAGEASSET(name) \ - m##name##Name = StringTable->EmptyString(); \ - m##name##AssetId = StringTable->EmptyString(); \ - m##name##Asset = NULL; - #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_IMAGEASSET(name, consoleClass, docs) \ @@ -326,11 +287,6 @@ DefineEngineMethod(className, set##name, bool, (const char* map), , assetText(na #endif // SHOW_LEGACY_FILE_FIELDS -#define CLONE_IMAGEASSET(name) \ - m##name##Name = other.m##name##Name;\ - m##name##AssetId = other.m##name##AssetId;\ - m##name##Asset = other.m##name##Asset; - #define LOAD_IMAGEASSET(name)\ if (m##name##AssetId != StringTable->EmptyString())\ {\ @@ -342,43 +298,6 @@ if (m##name##AssetId != StringTable->EmptyString())\ else Con::warnf("Warning: %s::LOAD_IMAGEASSET(%s)-%s", mClassName, m##name##AssetId, ImageAsset::getAssetErrstrn(assetState).c_str());\ } -#define PACKDATA_IMAGEASSET(name)\ - if (stream->writeFlag(m##name##Asset.notNull()))\ - {\ - stream->writeString(m##name##Asset.getAssetId());\ - }\ - else\ - stream->writeString(m##name##Name); - -#define UNPACKDATA_IMAGEASSET(name)\ - if (stream->readFlag())\ - {\ - m##name##AssetId = stream->readSTString();\ - _set##name(m##name##AssetId);\ - }\ - else\ - {\ - m##name##Name = stream->readSTString();\ - _set##name(m##name##Name);\ - }\ - -#define PACK_IMAGEASSET(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_IMAGEASSET(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 @@ -542,13 +461,6 @@ DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , a return object->_set##name(StringTable->insert(map), index);\ } -#define INIT_IMAGEASSET_ARRAY(name, index) \ -{\ - m##name##Name[index] = StringTable->EmptyString(); \ - m##name##AssetId[index] = StringTable->EmptyString(); \ - m##name##Asset[index] = NULL;\ -} - #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, docs) \ @@ -563,13 +475,6 @@ DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , a #endif -#define CLONE_IMAGEASSET_ARRAY(name, index) \ -{\ - 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];\ -} - #define LOAD_IMAGEASSET_ARRAY(name, index)\ if (m##name##AssetId[index] != StringTable->EmptyString())\ {\ @@ -581,44 +486,6 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ else Con::warnf("Warning: %s::LOAD_IMAGEASSET(%s)-%s", mClassName, m##name##AssetId[index], ImageAsset::getAssetErrstrn(assetState).c_str());\ } -#define PACKDATA_IMAGEASSET_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_IMAGEASSET_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();\ - _set##name(m##name##Name[index], index);\ - }\ - -#define PACK_IMAGEASSET_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_IMAGEASSET_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 diff --git a/Engine/source/T3D/assets/MaterialAsset.h b/Engine/source/T3D/assets/MaterialAsset.h index fc383810f..9fab8a1da 100644 --- a/Engine/source/T3D/assets/MaterialAsset.h +++ b/Engine/source/T3D/assets/MaterialAsset.h @@ -54,6 +54,7 @@ #include "materials/materialDefinition.h" #include "materials/customMaterialDefinition.h" #include "materials/materialManager.h" +#include "assetMacroHelpers.h" //----------------------------------------------------------------------------- class MaterialAsset : public AssetBase @@ -262,46 +263,6 @@ public: \ }\ bool is##name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } -#define DECLARE_MATERIALASSET_SETGET(className, name)\ - static bool _set##name##Data(void* obj, const char* index, const char* data)\ - {\ - bool ret = false;\ - className* object = static_cast(obj);\ - ret = object->_set##name(StringTable->insert(data));\ - return ret;\ - } - -#define DECLARE_MATERIALASSET_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(obj);\ - ret = object->_set##name(StringTable->insert(data));\ - if(ret)\ - object->setMaskBits(bitmask);\ - return ret;\ - } - -#define DEF_MATERIALASSET_BINDS(className,name)\ -DefineEngineMethod(className, get##name, const char*, (), , "get name")\ -{\ - return object->get##name(); \ -}\ -DefineEngineMethod(className, get##name##Asset, const char*, (), , assetText(name, asset reference))\ -{\ - return object->m##name##AssetId; \ -}\ -DefineEngineMethod(className, set##name, bool, (const char* mat), , assetText(name,assignment. first tries asset then material name.))\ -{\ - return object->_set##name(StringTable->insert(mat));\ -} - -#define INIT_MATERIALASSET(name) \ - m##name##Name = StringTable->EmptyString(); \ - m##name##AssetId = StringTable->EmptyString(); \ - m##name##Asset = NULL;\ - m##name = NULL; - #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_MATERIALASSET(name, consoleClass, docs) \ @@ -316,11 +277,6 @@ DefineEngineMethod(className, set##name, bool, (const char* mat), , assetText(na #endif // SHOW_LEGACY_FILE_FIELDS -#define CLONE_MATERIALASSET(name) \ - m##name##Name = other.m##name##Name;\ - m##name##AssetId = other.m##name##AssetId;\ - m##name##Asset = other.m##name##Asset; - #define LOAD_MATERIALASSET(name)\ if (m##name##AssetId != StringTable->EmptyString())\ {\ @@ -331,45 +287,6 @@ if (m##name##AssetId != StringTable->EmptyString())\ }\ else Con::warnf("Warning: %s::LOAD_MATERIALASSET(%s)-%s", mClassName, m##name##AssetId, MaterialAsset::getAssetErrstrn(assetState).c_str());\ } - -#define PACKDATA_MATERIALASSET(name)\ - if (stream->writeFlag(m##name##Asset.notNull()))\ - {\ - stream->writeString(m##name##Asset.getAssetId());\ - }\ - else\ - stream->writeString(m##name##Name); - -#define UNPACKDATA_MATERIALASSET(name)\ - if (stream->readFlag())\ - {\ - m##name##AssetId = stream->readSTString();\ - _set##name(m##name##AssetId);\ - }\ - else\ - {\ - m##name##Name = stream->readSTString();\ - _set##name(m##name##Name);\ - }\ - -#define PACK_MATERIALASSET(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_MATERIALASSET(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 #endif // _ASSET_BASE_H_ diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index 2d641a840..36a0a68c1 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -60,6 +60,7 @@ #ifndef _BITSTREAM_H_ #include "core/stream/bitStream.h" #endif +#include "assetMacroHelpers.h" //----------------------------------------------------------------------------- class ShapeAsset : public AssetBase { @@ -324,46 +325,6 @@ public: \ }\ bool is##name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } -#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(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(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(); \ -}\ -DefineEngineMethod(className, get##name##Asset, String, (), , assetText(name, asset reference))\ -{\ - return object->m##name##AssetId; \ -}\ -DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText(name,assignment. first tries asset then flat file.))\ -{\ - 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; \ - m##name = NULL; - #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_SHAPEASSET(name, consoleClass, docs) \ @@ -378,49 +339,6 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText #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)\ - if (stream->writeFlag(m##name##Asset.notNull()))\ - {\ - stream->writeString(m##name##Asset.getAssetId());\ - }\ - else\ - stream->writeString(m##name##Name); - -#define UNPACKDATA_SHAPEASSET(name)\ - if (stream->readFlag())\ - {\ - m##name##AssetId = stream->readSTString();\ - _set##name(m##name##AssetId);\ - }\ - else\ - {\ - m##name##Name = stream->readSTString();\ - _set##name(m##name##Name);\ - } - -#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 @@ -526,58 +444,6 @@ public: \ }\ bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); } -#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(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(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);\ -} - -#define INIT_SHAPEASSET_ARRAY(name, index) \ -{\ - m##name##Name[index] = StringTable->EmptyString(); \ - m##name##AssetId[index] = StringTable->EmptyString(); \ - m##name##Asset[index] = NULL; \ - m##name[index] = NULL;\ -} - #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_SHAPEASSET_ARRAY(name, arraySize, consoleClass, docs) \ @@ -592,51 +458,6 @@ DefineEngineMethod(className, set##name, bool, (const char* shape, S32 index), #endif // SHOW_LEGACY_FILE_FIELDS -#define CLONE_SHAPEASSET_ARRAY(name, index) \ -{\ - 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];\ -} - -#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();\ - _set##name(m##name##Name[index], index);\ - } - -#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 diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 1d98b61b1..77c1e7180 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -57,6 +57,7 @@ #include "sfx/sfxProfile.h" #endif // !_SFXPROFILE_H_ +#include "assetMacroHelpers.h" class SFXResource; //----------------------------------------------------------------------------- @@ -275,46 +276,6 @@ public: \ }\ bool is##name##Valid() { return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } -#define DECLARE_SOUNDASSET_SETGET(className, name)\ - static bool _set##name##Data(void* obj, const char* index, const char* data)\ - {\ - bool ret = false;\ - className* object = static_cast(obj);\ - ret = object->_set##name(StringTable->insert(data));\ - return ret;\ - } - -#define DECLARE_SOUNDASSET_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(obj);\ - ret = object->_set##name(StringTable->insert(data));\ - if(ret)\ - object->setMaskBits(bitmask);\ - return ret;\ - } - -#define DEF_SOUNDASSET_BINDS(className,name)\ -DefineEngineMethod(className, get##name, String, (), , "get name")\ -{\ - return object->get##name(); \ -}\ -DefineEngineMethod(className, get##name##Asset, String, (), , assetText(name, asset reference))\ -{\ - return object->m##name##AssetId; \ -}\ -DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText(name,assignment. first tries asset then flat file.))\ -{\ - return object->_set##name(StringTable->insert(shape));\ -} - -#define INIT_SOUNDASSET(name) \ - m##name##Name = StringTable->EmptyString(); \ - m##name##AssetId = StringTable->EmptyString(); \ - m##name##Asset = NULL; \ - m##name = NULL;\ - #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_SOUNDASSET(name, consoleClass, docs) \ @@ -329,49 +290,6 @@ DefineEngineMethod(className, set##name, bool, (const char* shape), , assetText #endif // TORQUE_SHOW_LEGACY_FILE_FIELDS -#define CLONE_SOUNDASSET(name) \ - m##name##Name = other.m##name##Name;\ - m##name##AssetId = other.m##name##AssetId;\ - m##name##Asset = other.m##name##Asset;\ - -#define PACKDATA_SOUNDASSET(name)\ - if (stream->writeFlag(m##name##Asset.notNull()))\ - {\ - stream->writeString(m##name##Asset.getAssetId());\ - }\ - else\ - stream->writeString(m##name##Name); - -#define UNPACKDATA_SOUNDASSET(name)\ - if (stream->readFlag())\ - {\ - m##name##AssetId = stream->readSTString();\ - _set##name(m##name##AssetId);\ - }\ - else\ - {\ - m##name##Name = stream->readSTString();\ - _set##name(m##name##Name);\ - } - -#define PACK_SOUNDASSET(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_SOUNDASSET(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 @@ -491,57 +409,6 @@ public: \ }\ bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); } -#define DECLARE_SOUNDASSET_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(obj);\ - ret = object->_set##name(StringTable->insert(data), idx);\ - return ret;\ - } - -#define DECLARE_SOUNDASSET_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(obj);\ - ret = object->_set##name(StringTable->insert(data, idx));\ - if(ret)\ - object->setMaskBits(bitmask);\ - return ret;\ - } - -#define DEF_SOUNDASSET_ARRAY_BINDS(className,name)\ -DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\ -{\ - return object->get##name(index); \ -}\ -DefineEngineMethod(className, get##name##Asset, const char*, (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* map, S32 index), , assetText(name,assignment. first tries asset then flat file.))\ -{\ - return object->_set##name(StringTable->insert(map), index);\ -} - -#define INIT_SOUNDASSET_ARRAY(name, index) \ -{\ - m##name##Name[index] = StringTable->EmptyString(); \ - m##name##AssetId[index] = StringTable->EmptyString(); \ - m##name##Asset[index] = NULL;\ - m##name[index] = NULL;\ -} #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS @@ -557,14 +424,6 @@ DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , a #endif -#define CLONE_SOUNDASSET_ARRAY(name, index) \ -{\ - 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];\ - m##name[index] = = other.m##name[index];\ -} - #define LOAD_SOUNDASSET_ARRAY(name, index)\ if (m##name##AssetId[index] != StringTable->EmptyString())\ {\ @@ -576,75 +435,6 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ else Con::warnf("Warning: %s::LOAD_IMAGEASSET(%s)-%s", mClassName, m##name##AssetId[index], ImageAsset::getAssetErrstrn(assetState).c_str());\ } -#define PACKDATA_SOUNDASSET_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_SOUNDASSET_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();\ - _set##name(m##name##AssetId[index], index);\ - } - -#define PACK_SOUNDASSET_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_SOUNDASSET_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();\ - _set##name(m##name##AssetId[index], index);\ - } - -#define PACKDATA_SOUNDASSET_ARRAY_ENUMED(name, enumType, index )\ -{\ - if (stream->writeFlag(m##name##Asset[index].notNull()))\ - {\ - stream->writeString(m##name##Asset[index].getAssetId());\ - const char* enumString = castConsoleTypeToString(static_cast(index));\ - Con::printf("pack: %s = %s",enumString, m##name##AssetId[index]);\ - }\ - else\ - stream->writeString(m##name##Name[index]);\ -} - -#define UNPACKDATA_SOUNDASSET_ARRAY_ENUMED(name, enumType, index )\ -{\ - if (stream->readFlag())\ - {\ - m##name##AssetId[index] = stream->readSTString();\ - _set##name(m##name##AssetId[index], index);\ - const char* enumString = castConsoleTypeToString(static_cast(index));\ - Con::printf("unpack: %s = %s",enumString, m##name##AssetId[index]);\ - }\ - else\ - {\ - m##name##Name[index] = stream->readSTString();\ - _set##name(m##name##AssetId[index], index);\ - }\ -} - #define assetEnumNameConcat(x,suff)(new std::string( x + std::string(#suff)))->c_str() #define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \ @@ -652,7 +442,7 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ {\ const char* enumString = castConsoleTypeToString(static_cast(i));\ if (enumString && enumString[0])\ - { Con::printf("%s", enumString);\ + {\ addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), assetText(name, asset reference.));\ }\ diff --git a/Engine/source/T3D/assets/assetMacroHelpers.h b/Engine/source/T3D/assets/assetMacroHelpers.h new file mode 100644 index 000000000..42f51e8e8 --- /dev/null +++ b/Engine/source/T3D/assets/assetMacroHelpers.h @@ -0,0 +1,274 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- +#pragma once + +//general class-injection hooks for asset support. not all cases are needed for every class/usage. + +//----------------------------------------------------------------------------- +/// INDIVIDUALIZED CLASS ENTRIES +//----------------------------------------------------------------------------- + +//iniitalization +#define INIT_ASSET(name) \ + m##name##Name = StringTable->EmptyString(); \ + m##name##AssetId = StringTable->EmptyString(); \ + m##name##Asset = NULL;\ + m##name = NULL; + +// copy constructor +#define CLONE_ASSET(name) \ + m##name##Name = other.m##name##Name;\ + m##name##AssetId = other.m##name##AssetId;\ + m##name##Asset = other.m##name##Asset;\ + m##name = other.m##name + +// addProtectedField acessors +#define DECLARE_ASSET_SETGET(className, name)\ + static bool _set##name##Data(void* obj, const char* index, const char* data)\ + {\ + bool ret = false;\ + className* object = static_cast(obj);\ + ret = object->_set##name(StringTable->insert(data));\ + return ret;\ + } + +// addProtectedField acessors for networked objects (sets a flag) +#define DECLARE_ASSET_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(obj);\ + ret = object->_set##name(StringTable->insert(data));\ + if(ret)\ + object->setMaskBits(bitmask);\ + return ret;\ + } + +//network send - datablock +#define PACKDATA_ASSET(name)\ + if (stream->writeFlag(m##name##Asset.notNull()))\ + {\ + stream->writeString(m##name##Asset.getAssetId());\ + }\ + else\ + stream->writeString(m##name##Name); + +//network recieve - datablock +#define UNPACKDATA_ASSET(name)\ + if (stream->readFlag())\ + {\ + m##name##AssetId = stream->readSTString();\ + _set##name(m##name##AssetId);\ + }\ + else\ + {\ + m##name##Name = stream->readSTString();\ + _set##name(m##name##Name);\ + } + +//network send - object-instance +#define PACK_ASSET(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); + +//network recieve - object-instance +#define UNPACK_ASSET(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(); + +//script methods for class.asset acces +//declare general get, getAsset and set methods +#define DEF_ASSET_BINDS(className,name)\ +DefineEngineMethod(className, get##name, String, (), , "get name")\ +{\ + return object->get##name(); \ +}\ +DefineEngineMethod(className, get##name##Asset, String, (), , assetText(name, asset reference))\ +{\ + return object->m##name##AssetId; \ +}\ +DefineEngineMethod(className, set##name, bool, (const char* assetName), , assetText(name,assignment. first tries asset then flat file.))\ +{\ + return object->_set##name(StringTable->insert(assetName));\ +} + +//----------------------------------------------------------------------------- +/// ARRAY CLASS ENTRIES +//----------------------------------------------------------------------------- + +//iniitalization +#define INIT_ASSET_ARRAY(name, index) \ +{\ + m##name##Name[index] = StringTable->EmptyString(); \ + m##name##AssetId[index] = StringTable->EmptyString(); \ + m##name##Asset[index] = NULL;\ + m##name[index] = NULL;\ +} + +// copy constructor +#define CLONE_ASSET_ARRAY(name, index) \ +{\ + 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];\ + m##name[index] = other.m##name[index];\ +} +// addProtectedField acessors +#define DECLARE_ASSET_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(obj);\ + ret = object->_set##name(StringTable->insert(data), idx);\ + return ret;\ + } +// addProtectedField acessors for networked objects (sets a flag) +#define DECLARE_ASSET_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(obj);\ + ret = object->_set##name(StringTable->insert(data), idx);\ + if(ret)\ + object->setMaskBits(bitmask);\ + return ret;\ + } +//network send - datablock +#define PACKDATA_ASSET_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]); + +//network recieve - datablock +#define UNPACKDATA_ASSET_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();\ + _set##name(m##name##Name[index], index);\ + } + +//network send - object-instance +#define PACK_ASSET_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]); + +//network recieve - object-instance +#define UNPACK_ASSET_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();\ + _set##name(m##name##Name[index], index);\ + } + +//script methods for class.asset acces +//declare general get, getAsset and set methods +//signatures are: +//using DiffuseMap as an example +//material.getDiffuseMap(%layer); //returns the raw file referenced +//material.getDiffuseMapAsset(%layer); //returns the asset id +//material.setDiffuseMap(%texture, %layer); //tries to set the asset and failing that attempts a flat file reference +#define DEF_ASSET_ARRAY_BINDS(className,name)\ +DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\ +{\ + return object->get##name(index); \ +}\ +DefineEngineMethod(className, get##name##Asset, const char*, (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* assetName, S32 index), , assetText(name,assignment. first tries asset then flat file.))\ +{\ + return object->_set##name(StringTable->insert(assetName), index);\ +} + +//----------------------------------------------------------------------------- +/// ARRAYS REFERENCED VIA ENUM CLASS ENTRIES +//----------------------------------------------------------------------------- +// +// substite these in to see the enum strings and assigned values +//network send - object-instance +#define PACKDATA_ASSET_ARRAY_ENUMED(name, enumType, index )\ +{\ + if (stream->writeFlag(m##name##Asset[index].notNull()))\ + {\ + stream->writeString(m##name##Asset[index].getAssetId());\ + const char* enumString = castConsoleTypeToString(static_cast(index));\ + Con::printf("pack: %s = %s",enumString, m##name##AssetId[index]);\ + }\ + else\ + stream->writeString(m##name##Name[index]);\ +} +//network recieve - object-instance +#define UNPACKDATA_ASSET_ARRAY_ENUMED(name, enumType, index )\ +{\ + if (stream->readFlag())\ + {\ + m##name##AssetId[index] = stream->readSTString();\ + _set##name(m##name##AssetId[index], index);\ + const char* enumString = castConsoleTypeToString(static_cast(index));\ + Con::printf("unpack: %s = %s",enumString, m##name##AssetId[index]);\ + }\ + else\ + {\ + m##name##Name[index] = stream->readSTString();\ + _set##name(m##name##AssetId[index], index);\ + }\ +} + diff --git a/Engine/source/T3D/convexShape.cpp b/Engine/source/T3D/convexShape.cpp index 99f3f418a..47271fd03 100644 --- a/Engine/source/T3D/convexShape.cpp +++ b/Engine/source/T3D/convexShape.cpp @@ -290,7 +290,7 @@ ConvexShape::ConvexShape() mSurfaceUVs.clear(); mSurfaceTextures.clear(); - INIT_MATERIALASSET(Material); + INIT_ASSET(Material); } ConvexShape::~ConvexShape() @@ -528,7 +528,7 @@ U32 ConvexShape::packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) if ( stream->writeFlag( mask & UpdateMask ) ) { - PACK_MATERIALASSET(conn, Material); + PACK_ASSET(conn, Material); U32 surfCount = mSurfaces.size(); stream->writeInt( surfCount, 32 ); @@ -584,7 +584,7 @@ void ConvexShape::unpackUpdate( NetConnection *conn, BitStream *stream ) if ( stream->readFlag() ) // UpdateMask { - UNPACK_MATERIALASSET(conn, Material); + UNPACK_ASSET(conn, Material); mSurfaces.clear(); mSurfaceUVs.clear(); @@ -2171,4 +2171,4 @@ void ConvexShape::Geometry::generate(const Vector< PlaneF > &planes, const Vecto } } -DEF_MATERIALASSET_BINDS(ConvexShape, Material); +DEF_ASSET_BINDS(ConvexShape, Material); diff --git a/Engine/source/T3D/convexShape.h b/Engine/source/T3D/convexShape.h index 22dc4553b..c6d74fe17 100644 --- a/Engine/source/T3D/convexShape.h +++ b/Engine/source/T3D/convexShape.h @@ -138,14 +138,14 @@ public: // The name of the Material we will use for rendering DECLARE_MATERIALASSET(surfaceMaterial, Material); - DECLARE_MATERIALASSET_SETGET(surfaceMaterial, Material); + DECLARE_ASSET_SETGET(surfaceMaterial, Material); // The actual Material instance BaseMatInstance* materialInst; surfaceMaterial() { - INIT_MATERIALASSET(Material); + INIT_ASSET(Material); materialInst = NULL; } @@ -264,7 +264,7 @@ protected: protected: DECLARE_MATERIALASSET(ConvexShape, Material); - DECLARE_MATERIALASSET_SETGET(ConvexShape, Material); + DECLARE_ASSET_SETGET(ConvexShape, Material); // The actual Material instance BaseMatInstance* mMaterialInst; diff --git a/Engine/source/T3D/debris.cpp b/Engine/source/T3D/debris.cpp index 2362fd089..ba94b0892 100644 --- a/Engine/source/T3D/debris.cpp +++ b/Engine/source/T3D/debris.cpp @@ -116,7 +116,7 @@ DebrisData::DebrisData() terminalVelocity = 0.0f; ignoreWater = true; - INIT_SHAPEASSET(Shape); + INIT_ASSET(Shape); } //#define TRACK_DEBRIS_DATA_CLONES @@ -152,7 +152,7 @@ DebrisData::DebrisData(const DebrisData& other, bool temp_clone) : GameBaseData( terminalVelocity = other.terminalVelocity; ignoreWater = other.ignoreWater; - CLONE_SHAPEASSET(Shape); + CLONE_ASSET(Shape); textureName = other.textureName; explosionId = other.explosionId; // -- for pack/unpack of explosion ptr @@ -382,7 +382,7 @@ void DebrisData::packData(BitStream* stream) stream->writeString( textureName ); - PACKDATA_SHAPEASSET(Shape); + PACKDATA_ASSET(Shape); for( S32 i=0; ireadSTString(); - UNPACKDATA_SHAPEASSET(Shape); + UNPACKDATA_ASSET(Shape); for( S32 i=0; iwrite( lookupName ); stream->write( size ); - PACKDATA_MATERIALASSET(Material); + PACKDATA_ASSET(Material); stream->write( lifeSpan ); stream->write( fadeTime ); @@ -287,7 +287,7 @@ void DecalData::unpackData( BitStream *stream ) assignName(lookupName); stream->read( &size ); - UNPACKDATA_MATERIALASSET(Material); + UNPACKDATA_ASSET(Material); _updateMaterial(); stream->read( &lifeSpan ); diff --git a/Engine/source/T3D/decal/decalData.h b/Engine/source/T3D/decal/decalData.h index 5c32c4427..4a053f303 100644 --- a/Engine/source/T3D/decal/decalData.h +++ b/Engine/source/T3D/decal/decalData.h @@ -78,7 +78,7 @@ class DecalData : public SimDataBlock F32 fadeEndPixelSize; DECLARE_MATERIALASSET(DecalData, Material); - DECLARE_MATERIALASSET_SETGET(DecalData, Material); + DECLARE_ASSET_SETGET(DecalData, Material); /// Material instance for decal. BaseMatInstance *matInst; @@ -139,4 +139,4 @@ inline SimSet* DecalData::getSet() return set; } -#endif // _DECALDATA_H_ \ No newline at end of file +#endif // _DECALDATA_H_ diff --git a/Engine/source/T3D/examples/renderMeshExample.cpp b/Engine/source/T3D/examples/renderMeshExample.cpp index 772c7bae6..fe1d099eb 100644 --- a/Engine/source/T3D/examples/renderMeshExample.cpp +++ b/Engine/source/T3D/examples/renderMeshExample.cpp @@ -59,7 +59,7 @@ RenderMeshExample::RenderMeshExample() // Set it as a "static" object that casts shadows mTypeMask |= StaticObjectType | StaticShapeObjectType; - INIT_MATERIALASSET(Material); + INIT_ASSET(Material); } RenderMeshExample::~RenderMeshExample() @@ -143,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)) { - PACK_MATERIALASSET(conn, Material); + PACK_ASSET(conn, Material); } return retMask; @@ -164,7 +164,7 @@ void RenderMeshExample::unpackUpdate(NetConnection *conn, BitStream *stream) if ( stream->readFlag() ) // UpdateMask { - UNPACK_MATERIALASSET(conn, Material); + UNPACK_ASSET(conn, Material); if ( isProperlyAdded() ) updateMaterial(); diff --git a/Engine/source/T3D/examples/renderMeshExample.h b/Engine/source/T3D/examples/renderMeshExample.h index 1c20e4bfe..45686b4a6 100644 --- a/Engine/source/T3D/examples/renderMeshExample.h +++ b/Engine/source/T3D/examples/renderMeshExample.h @@ -74,7 +74,7 @@ class RenderMeshExample : public SceneObject BaseMatInstance* mMaterialInst; DECLARE_MATERIALASSET(RenderMeshExample, Material); - DECLARE_MATERIALASSET_NET_SETGET(RenderMeshExample, Material, UpdateMask); + DECLARE_ASSET_NET_SETGET(RenderMeshExample, Material, UpdateMask); // The GFX vertex and primitive buffers GFXVertexBufferHandle< VertexType > mVertexBuffer; diff --git a/Engine/source/T3D/examples/renderShapeExample.cpp b/Engine/source/T3D/examples/renderShapeExample.cpp index faf2f9b3f..b8aad1ebf 100644 --- a/Engine/source/T3D/examples/renderShapeExample.cpp +++ b/Engine/source/T3D/examples/renderShapeExample.cpp @@ -145,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 ) ) { - PACK_SHAPEASSET(conn, Shape); + PACK_ASSET(conn, Shape); // Allow the server object a chance to handle a new shape createShape(); @@ -169,7 +169,7 @@ void RenderShapeExample::unpackUpdate(NetConnection *conn, BitStream *stream) if ( stream->readFlag() ) // UpdateMask { - UNPACK_SHAPEASSET(conn, Shape); + UNPACK_ASSET(conn, Shape); if ( isProperlyAdded() ) createShape(); @@ -258,4 +258,4 @@ void RenderShapeExample::prepRenderImage( SceneRenderState *state ) // Allow the shape to submit the RenderInst(s) for itself mShapeInstance->render( rdata ); -} \ No newline at end of file +} diff --git a/Engine/source/T3D/examples/renderShapeExample.h b/Engine/source/T3D/examples/renderShapeExample.h index 9c03cbc72..2b3ccf86e 100644 --- a/Engine/source/T3D/examples/renderShapeExample.h +++ b/Engine/source/T3D/examples/renderShapeExample.h @@ -62,7 +62,7 @@ class RenderShapeExample : public SceneObject // Rendering variables //-------------------------------------------------------------------------- DECLARE_SHAPEASSET(RenderShapeExample, Shape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(RenderShapeExample, Shape); + DECLARE_ASSET_SETGET(RenderShapeExample, Shape); // The actual shape instance TSShapeInstance* mShapeInstance; diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index 17aa6017c..88a5a9432 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -230,7 +230,7 @@ ExplosionData::ExplosionData() faceViewer = false; - INIT_SOUNDASSET(Sound); + INIT_ASSET(Sound); //soundProfile = NULL; particleEmitter = NULL; @@ -239,7 +239,7 @@ ExplosionData::ExplosionData() explosionScale.set(1.0f, 1.0f, 1.0f); playSpeed = 1.0f; - INIT_SHAPEASSET(ExplosionShape); + INIT_ASSET(ExplosionShape); explosionAnimation = -1; @@ -310,12 +310,12 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game faceViewer = other.faceViewer; particleDensity = other.particleDensity; particleRadius = other.particleRadius; - CLONE_SOUNDASSET(Sound); + CLONE_ASSET(Sound); particleEmitter = other.particleEmitter; particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr explosionScale = other.explosionScale; playSpeed = other.playSpeed; - CLONE_SHAPEASSET(ExplosionShape); + CLONE_ASSET(ExplosionShape); explosionAnimation = other.explosionAnimation; // -- from explosionShape sequence "ambient" dMemcpy( emitterList, other.emitterList, sizeof( emitterList ) ); dMemcpy( emitterIDList, other.emitterIDList, sizeof( emitterIDList ) ); // -- for pack/unpack of emitterList ptrs @@ -650,9 +650,9 @@ void ExplosionData::packData(BitStream* stream) { Parent::packData(stream); - PACKDATA_SHAPEASSET(ExplosionShape); + PACKDATA_ASSET(ExplosionShape); - PACKDATA_SOUNDASSET(Sound); + PACKDATA_ASSET(Sound); if (stream->writeFlag(particleEmitter)) stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast); @@ -754,9 +754,9 @@ void ExplosionData::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_SHAPEASSET(ExplosionShape); + UNPACKDATA_ASSET(ExplosionShape); - UNPACKDATA_SOUNDASSET(Sound); + UNPACKDATA_ASSET(Sound); if (stream->readFlag()) particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); diff --git a/Engine/source/T3D/fx/explosion.h b/Engine/source/T3D/fx/explosion.h index 41116cd32..eac392e11 100644 --- a/Engine/source/T3D/fx/explosion.h +++ b/Engine/source/T3D/fx/explosion.h @@ -71,7 +71,7 @@ class ExplosionData : public GameBaseData { F32 particleRadius; DECLARE_SOUNDASSET(ExplosionData, Sound); - DECLARE_SOUNDASSET_SETGET(ExplosionData, Sound); + DECLARE_ASSET_SETGET(ExplosionData, Sound); ParticleEmitterData* particleEmitter; S32 particleEmitterId; @@ -80,7 +80,7 @@ class ExplosionData : public GameBaseData { F32 playSpeed; DECLARE_SHAPEASSET(ExplosionData, ExplosionShape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(ExplosionData, ExplosionShape); + DECLARE_ASSET_SETGET(ExplosionData, ExplosionShape); S32 explosionAnimation; diff --git a/Engine/source/T3D/fx/groundCover.cpp b/Engine/source/T3D/fx/groundCover.cpp index 41f8a8c1a..a9c975eec 100644 --- a/Engine/source/T3D/fx/groundCover.cpp +++ b/Engine/source/T3D/fx/groundCover.cpp @@ -459,7 +459,7 @@ GroundCover::GroundCover() mRandomSeed = 1; - INIT_MATERIALASSET(Material); + INIT_ASSET(Material); mMaterialInst = NULL; mMatParams = NULL; @@ -520,7 +520,7 @@ GroundCover::GroundCover() mBillboardRects[i].point.set( 0.0f, 0.0f ); mBillboardRects[i].extent.set( 1.0f, 1.0f ); - INIT_SHAPEASSET_ARRAY(Shape, i); + INIT_ASSET_ARRAY(Shape, i); mShapeInstances[i] = NULL; @@ -713,7 +713,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. - PACK_MATERIALASSET(connection, Material); + PACK_ASSET(connection, Material); stream->write( mRadius ); stream->write( mZOffset ); @@ -766,7 +766,7 @@ U32 GroundCover::packUpdate( NetConnection *connection, U32 mask, BitStream *str stream->write( mBillboardRects[i].extent.x ); stream->write( mBillboardRects[i].extent.y ); - PACK_SHAPEASSET_ARRAY(connection, Shape, i); + PACK_ASSET_ARRAY(connection, Shape, i); } stream->writeFlag( mDebugRenderCells ); @@ -784,7 +784,7 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream ) if (stream->readFlag()) { - UNPACK_MATERIALASSET(connection, Material); + UNPACK_ASSET(connection, Material); stream->read( &mRadius ); stream->read( &mZOffset ); @@ -837,7 +837,7 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream ) stream->read( &mBillboardRects[i].extent.x ); stream->read( &mBillboardRects[i].extent.y ); - UNPACK_SHAPEASSET_ARRAY(connection, Shape, i); + UNPACK_ASSET_ARRAY(connection, Shape, i); } mDebugRenderCells = stream->readFlag(); diff --git a/Engine/source/T3D/fx/groundCover.h b/Engine/source/T3D/fx/groundCover.h index fbf6bf263..aba467810 100644 --- a/Engine/source/T3D/fx/groundCover.h +++ b/Engine/source/T3D/fx/groundCover.h @@ -269,7 +269,7 @@ protected: BaseMatInstance* mMaterialInst; DECLARE_MATERIALASSET(GroundCover, Material); - DECLARE_MATERIALASSET_NET_SETGET(GroundCover, Material, InitialUpdateMask); + DECLARE_ASSET_NET_SETGET(GroundCover, Material, InitialUpdateMask); GroundCoverShaderConstData mShaderConstData; @@ -341,7 +341,7 @@ protected: /// The cover shape filenames. DECLARE_SHAPEASSET_ARRAY(GroundCover, Shape, MAX_COVERTYPES); - DECLARE_SHAPEASSET_ARRAY_NET_SETGET(GroundCover, Shape, -1); + DECLARE_ASSET_ARRAY_NET_SETGET(GroundCover, Shape, -1); /// The cover shape instances. TSShapeInstance* mShapeInstances[MAX_COVERTYPES]; diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 0e28b1a42..8d9e20183 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -238,11 +238,11 @@ void LightningStrikeEvent::process(NetConnection*) // LightningData::LightningData() { - INIT_SOUNDASSET(StrikeSound); + INIT_ASSET(StrikeSound); for (S32 i = 0; i < MaxThunders; i++) { - INIT_SOUNDASSET_ARRAY(ThunderSound, i); + INIT_ASSET_ARRAY(ThunderSound, i); } for (S32 i = 0; i < MaxTextures; i++) @@ -335,7 +335,7 @@ void LightningData::packData(BitStream* stream) U32 i; for (i = 0; i < MaxThunders; i++) { - PACKDATA_SOUNDASSET_ARRAY(ThunderSound, i); + PACKDATA_ASSET_ARRAY(ThunderSound, i); } stream->writeInt(mNumStrikeTextures, 4); @@ -343,7 +343,7 @@ void LightningData::packData(BitStream* stream) for (i = 0; i < MaxTextures; i++) stream->writeString(strikeTextureNames[i]); - PACKDATA_SOUNDASSET(StrikeSound); + PACKDATA_ASSET(StrikeSound); } void LightningData::unpackData(BitStream* stream) @@ -353,7 +353,7 @@ void LightningData::unpackData(BitStream* stream) U32 i; for (i = 0; i < MaxThunders; i++) { - UNPACKDATA_SOUNDASSET_ARRAY(ThunderSound, i); + UNPACKDATA_ASSET_ARRAY(ThunderSound, i); } mNumStrikeTextures = stream->readInt(4); @@ -361,7 +361,7 @@ void LightningData::unpackData(BitStream* stream) for (i = 0; i < MaxTextures; i++) strikeTextureNames[i] = stream->readSTString(); - UNPACKDATA_SOUNDASSET(StrikeSound); + UNPACKDATA_ASSET(StrikeSound); } diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h index d241257b0..be3b65319 100644 --- a/Engine/source/T3D/fx/lightning.h +++ b/Engine/source/T3D/fx/lightning.h @@ -65,10 +65,10 @@ class LightningData : public GameBaseData public: DECLARE_SOUNDASSET_ARRAY(LightningData, ThunderSound, MaxThunders); - DECLARE_SOUNDASSET_ARRAY_SETGET(LightningData, ThunderSound); + DECLARE_ASSET_ARRAY_SETGET(LightningData, ThunderSound); DECLARE_SOUNDASSET(LightningData, StrikeSound); - DECLARE_SOUNDASSET_SETGET(LightningData, StrikeSound); + DECLARE_ASSET_SETGET(LightningData, StrikeSound); StringTableEntry strikeTextureNames[MaxTextures]; diff --git a/Engine/source/T3D/fx/particle.cpp b/Engine/source/T3D/fx/particle.cpp index 7cfa7e182..090a2f119 100644 --- a/Engine/source/T3D/fx/particle.cpp +++ b/Engine/source/T3D/fx/particle.cpp @@ -122,8 +122,8 @@ ParticleData::ParticleData() animTexFramesString = NULL; // string of animation frame indices animTexUVs = NULL; // array of tile vertex UVs - INIT_IMAGEASSET(Texture); - INIT_IMAGEASSET(TextureExt); + INIT_ASSET(Texture); + INIT_ASSET(TextureExt); constrain_pos = false; start_angle = 0.0f; @@ -293,7 +293,7 @@ void ParticleData::packData(BitStream* stream) stream->writeFloat( times[i], 8); } - //PACKDATA_IMAGEASSET(Texture); + //PACKDATA_ASSET(Texture); for (i = 0; i < 4; i++) mathWrite(*stream, texCoords[i]); @@ -307,7 +307,7 @@ void ParticleData::packData(BitStream* stream) stream->writeInt(framesPerSec, 8); } - //PACKDATA_IMAGEASSET(TextureExt); + //PACKDATA_ASSET(TextureExt); stream->writeFlag(constrain_pos); stream->writeFloat(start_angle/360.0f, 11); @@ -378,7 +378,7 @@ void ParticleData::unpackData(BitStream* stream) times[i] = stream->readFloat(8); } - //UNPACKDATA_IMAGEASSET(Texture); + //UNPACKDATA_ASSET(Texture); for (i = 0; i < 4; i++) mathRead(*stream, &texCoords[i]); @@ -391,7 +391,7 @@ void ParticleData::unpackData(BitStream* stream) framesPerSec = stream->readInt(8); } - //UNPACKDATA_IMAGEASSET(Texture); + //UNPACKDATA_ASSET(Texture); constrain_pos = stream->readFlag(); start_angle = 360.0f*stream->readFloat(11); @@ -763,12 +763,12 @@ ParticleData::ParticleData(const ParticleData& other, bool temp_clone) : SimData animTexFramesString = other.animTexFramesString; animTexFrames = other.animTexFrames; // -- parsed from animTexFramesString - CLONE_IMAGEASSET(Texture); + CLONE_ASSET(Texture); spinBias = other.spinBias; randomizeSpinDir = other.randomizeSpinDir; - CLONE_IMAGEASSET(TextureExt); + CLONE_ASSET(TextureExt); constrain_pos = other.constrain_pos; start_angle = other.start_angle; @@ -804,4 +804,4 @@ void ParticleData::onPerformSubstitutions() reload(errorBuffer); } -DEF_IMAGEASSET_BINDS(ParticleData, Texture); +DEF_ASSET_BINDS(ParticleData, Texture); diff --git a/Engine/source/T3D/fx/particle.h b/Engine/source/T3D/fx/particle.h index 1d6d88c12..e05b67b88 100644 --- a/Engine/source/T3D/fx/particle.h +++ b/Engine/source/T3D/fx/particle.h @@ -87,7 +87,7 @@ class ParticleData : public SimDataBlock Vector animTexFrames; DECLARE_IMAGEASSET(ParticleData, Texture, onImageChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(ParticleData, Texture); + DECLARE_ASSET_SETGET(ParticleData, Texture); static bool protectedSetSizes(void* object, const char* index, const char* data); static bool protectedSetTimes(void* object, const char* index, const char* data); @@ -118,7 +118,7 @@ public: bool randomizeSpinDir; public: DECLARE_IMAGEASSET(ParticleData, TextureExt, onImageChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(ParticleData, TextureExt); + DECLARE_ASSET_SETGET(ParticleData, TextureExt); bool constrain_pos; F32 start_angle; diff --git a/Engine/source/T3D/fx/precipitation.cpp b/Engine/source/T3D/fx/precipitation.cpp index 68880edf4..1de61e8e2 100644 --- a/Engine/source/T3D/fx/precipitation.cpp +++ b/Engine/source/T3D/fx/precipitation.cpp @@ -127,13 +127,13 @@ ConsoleDocClass( PrecipitationData, //---------------------------------------------------------- PrecipitationData::PrecipitationData() { - INIT_SOUNDASSET(Sound); + INIT_ASSET(Sound); - INIT_IMAGEASSET(Drop); + INIT_ASSET(Drop); mDropShaderName = StringTable->EmptyString(); - INIT_IMAGEASSET(Splash); + INIT_ASSET(Splash); mSplashShaderName = StringTable->EmptyString(); @@ -206,13 +206,13 @@ void PrecipitationData::packData(BitStream* stream) { Parent::packData(stream); - PACKDATA_SOUNDASSET(Sound); + PACKDATA_ASSET(Sound); - PACKDATA_IMAGEASSET(Drop); + PACKDATA_ASSET(Drop); stream->writeString(mDropShaderName); - PACKDATA_IMAGEASSET(Splash); + PACKDATA_ASSET(Splash); stream->writeString(mSplashShaderName); stream->write(mDropsPerSide); @@ -223,13 +223,13 @@ void PrecipitationData::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_SOUNDASSET(Sound); + UNPACKDATA_ASSET(Sound); - UNPACKDATA_IMAGEASSET(Drop); + UNPACKDATA_ASSET(Drop); mDropShaderName = stream->readSTString(); - UNPACKDATA_IMAGEASSET(Splash); + UNPACKDATA_ASSET(Splash); mSplashShaderName = stream->readSTString(); stream->read(&mDropsPerSide); diff --git a/Engine/source/T3D/fx/precipitation.h b/Engine/source/T3D/fx/precipitation.h index 719613384..eb3a540e0 100644 --- a/Engine/source/T3D/fx/precipitation.h +++ b/Engine/source/T3D/fx/precipitation.h @@ -47,15 +47,15 @@ class PrecipitationData : public GameBaseData public: DECLARE_SOUNDASSET(PrecipitationData, Sound); - DECLARE_SOUNDASSET_SETGET(PrecipitationData, Sound); + DECLARE_ASSET_SETGET(PrecipitationData, Sound); DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles - DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop); + DECLARE_ASSET_SETGET(PrecipitationData, Drop); StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles - DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash); + DECLARE_ASSET_SETGET(PrecipitationData, Splash); StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index 38a4f4e89..3ae7e54b4 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -70,7 +70,7 @@ SplashData::SplashData() //soundProfile = NULL; //soundProfileId = 0; - INIT_SOUNDASSET(Sound); + INIT_ASSET(Sound); scale.set(1, 1, 1); @@ -98,7 +98,7 @@ SplashData::SplashData() U32 i; for (i = 0; i < NUM_TEX; i++) { - INIT_IMAGEASSET_ARRAY(Texture, i); + INIT_ASSET_ARRAY(Texture, i); } for( i=0; iwrite(delayMS); @@ -208,7 +208,7 @@ void SplashData::packData(BitStream* stream) for( i=0; iread(&delayMS); @@ -264,7 +264,7 @@ void SplashData::unpackData(BitStream* stream) for( i=0; iwrite( mScaleU ); stream->write( mScaleV ); - PACK_MATERIALASSET(connection, Material); + PACK_ASSET(connection, Material); return retMask; } @@ -212,7 +212,7 @@ void GroundPlane::unpackUpdate( NetConnection* connection, BitStream* stream ) stream->read( &mScaleU ); stream->read( &mScaleV ); - UNPACK_MATERIALASSET(connection, Material); + UNPACK_ASSET(connection, Material); // If we're added then something possibly changed in // the editor... do an update of the material and the diff --git a/Engine/source/T3D/groundPlane.h b/Engine/source/T3D/groundPlane.h index 752c78668..9e57c325c 100644 --- a/Engine/source/T3D/groundPlane.h +++ b/Engine/source/T3D/groundPlane.h @@ -108,7 +108,7 @@ private: BaseMatInstance* mMaterialInst; DECLARE_MATERIALASSET(GroundPlane, Material); - DECLARE_MATERIALASSET_NET_SETGET(GroundPlane, Material, -1); + DECLARE_ASSET_NET_SETGET(GroundPlane, Material, -1); PhysicsBody *mPhysicsRep; diff --git a/Engine/source/T3D/levelInfo.cpp b/Engine/source/T3D/levelInfo.cpp index 7d6905841..d10077cea 100644 --- a/Engine/source/T3D/levelInfo.cpp +++ b/Engine/source/T3D/levelInfo.cpp @@ -99,7 +99,7 @@ LevelInfo::LevelInfo() mAdvancedLightmapSupport = true; - INIT_IMAGEASSET(AccuTexture); + INIT_ASSET(AccuTexture); // Register with the light manager activation signal, and we need to do it first // so the advanced light bin manager can be instructed about MRT lightmaps @@ -215,7 +215,7 @@ U32 LevelInfo::packUpdate(NetConnection *conn, U32 mask, BitStream *stream) sfxWrite( stream, mSoundAmbience ); stream->writeInt( mSoundDistanceModel, 1 ); - PACK_IMAGEASSET(conn, AccuTexture); + PACK_ASSET(conn, AccuTexture); return retMask; } @@ -262,7 +262,7 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream) SFX->setDistanceModel( mSoundDistanceModel ); } - UNPACK_IMAGEASSET(conn, AccuTexture); + UNPACK_ASSET(conn, AccuTexture); setLevelAccuTexture(getAccuTexture()); } diff --git a/Engine/source/T3D/levelInfo.h b/Engine/source/T3D/levelInfo.h index 5b998dada..122d7ad8d 100644 --- a/Engine/source/T3D/levelInfo.h +++ b/Engine/source/T3D/levelInfo.h @@ -105,7 +105,7 @@ class LevelInfo : public NetObject protected: DECLARE_IMAGEASSET(LevelInfo, AccuTexture, onAccuTextureChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(LevelInfo, AccuTexture); + DECLARE_ASSET_SETGET(LevelInfo, AccuTexture); void onAccuTextureChanged() {} diff --git a/Engine/source/T3D/lightFlareData.cpp b/Engine/source/T3D/lightFlareData.cpp index 98f406a1b..fb8fbaa55 100644 --- a/Engine/source/T3D/lightFlareData.cpp +++ b/Engine/source/T3D/lightFlareData.cpp @@ -133,7 +133,7 @@ LightFlareData::LightFlareData() for ( U32 i = 0; i < MAX_ELEMENTS; i++ ) mElementDist[i] = -1.0f; - INIT_IMAGEASSET(FlareTexture); + INIT_ASSET(FlareTexture); } LightFlareData::~LightFlareData() @@ -219,7 +219,7 @@ void LightFlareData::packData( BitStream *stream ) stream->writeFlag( mFlareEnabled ); - PACKDATA_IMAGEASSET(FlareTexture); + PACKDATA_ASSET(FlareTexture); stream->write( mScale ); stream->write( mOcclusionRadius ); @@ -244,7 +244,7 @@ void LightFlareData::unpackData( BitStream *stream ) mFlareEnabled = stream->readFlag(); - UNPACKDATA_IMAGEASSET(FlareTexture); + UNPACKDATA_ASSET(FlareTexture); stream->read( &mScale ); stream->read( &mOcclusionRadius ); diff --git a/Engine/source/T3D/lightFlareData.h b/Engine/source/T3D/lightFlareData.h index 6d79aac7b..b2a87520c 100644 --- a/Engine/source/T3D/lightFlareData.h +++ b/Engine/source/T3D/lightFlareData.h @@ -121,7 +121,7 @@ protected: bool mFlareEnabled; DECLARE_IMAGEASSET(LightFlareData, FlareTexture, onImageChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(LightFlareData, FlareTexture); + DECLARE_ASSET_SETGET(LightFlareData, FlareTexture); F32 mOcclusionRadius; bool mRenderReflectPass; diff --git a/Engine/source/T3D/physics/physicsDebris.cpp b/Engine/source/T3D/physics/physicsDebris.cpp index 835871bb5..077fcf7d8 100644 --- a/Engine/source/T3D/physics/physicsDebris.cpp +++ b/Engine/source/T3D/physics/physicsDebris.cpp @@ -74,7 +74,7 @@ PhysicsDebrisData::PhysicsDebrisData() lifetime = 5.0f; lifetimeVariance = 0.0f; - INIT_SHAPEASSET(Shape); + INIT_ASSET(Shape); } bool PhysicsDebrisData::onAdd() @@ -215,7 +215,7 @@ void PhysicsDebrisData::packData(BitStream* stream) stream->write( waterDampingScale ); stream->write( buoyancyDensity ); - PACKDATA_SHAPEASSET(Shape); + PACKDATA_ASSET(Shape); } void PhysicsDebrisData::unpackData(BitStream* stream) @@ -236,7 +236,7 @@ void PhysicsDebrisData::unpackData(BitStream* stream) stream->read( &waterDampingScale ); stream->read( &buoyancyDensity ); - UNPACKDATA_SHAPEASSET(Shape); + UNPACKDATA_ASSET(Shape); } DefineEngineMethod( PhysicsDebrisData, preload, void, (), , diff --git a/Engine/source/T3D/physics/physicsDebris.h b/Engine/source/T3D/physics/physicsDebris.h index c58d66626..2a4a3d0fc 100644 --- a/Engine/source/T3D/physics/physicsDebris.h +++ b/Engine/source/T3D/physics/physicsDebris.h @@ -87,7 +87,7 @@ public: bool castShadows; DECLARE_SHAPEASSET(PhysicsDebrisData, Shape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(PhysicsDebrisData, Shape); + DECLARE_ASSET_SETGET(PhysicsDebrisData, Shape); PhysicsDebrisData(); diff --git a/Engine/source/T3D/physics/physicsShape.cpp b/Engine/source/T3D/physics/physicsShape.cpp index 6808866ca..6e6b4e937 100644 --- a/Engine/source/T3D/physics/physicsShape.cpp +++ b/Engine/source/T3D/physics/physicsShape.cpp @@ -78,7 +78,7 @@ PhysicsShapeData::PhysicsShapeData() buoyancyDensity( 0.0f ), simType( SimType_ClientServer ) { - INIT_SHAPEASSET(Shape); + INIT_ASSET(Shape); } PhysicsShapeData::~PhysicsShapeData() @@ -180,7 +180,7 @@ void PhysicsShapeData::packData( BitStream *stream ) { Parent::packData( stream ); - PACKDATA_SHAPEASSET(Shape); + PACKDATA_ASSET(Shape); stream->write( mass ); stream->write( dynamicFriction ); @@ -204,7 +204,7 @@ void PhysicsShapeData::unpackData( BitStream *stream ) { Parent::unpackData(stream); - UNPACKDATA_SHAPEASSET(Shape); + UNPACKDATA_ASSET(Shape); stream->read( &mass ); stream->read( &dynamicFriction ); diff --git a/Engine/source/T3D/physics/physicsShape.h b/Engine/source/T3D/physics/physicsShape.h index a80d85afc..ebbad92d2 100644 --- a/Engine/source/T3D/physics/physicsShape.h +++ b/Engine/source/T3D/physics/physicsShape.h @@ -75,7 +75,7 @@ public: public: DECLARE_SHAPEASSET(PhysicsShapeData, Shape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(PhysicsShapeData, Shape); + DECLARE_ASSET_SETGET(PhysicsShapeData, Shape); /// The shared unscaled collision shape. PhysicsCollisionRef colShape; diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 3e994995a..7aabe0384 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -186,7 +186,6 @@ PlayerData::ActionAnimationDef PlayerData::ActionAnimationList[NumTableActionAni }; -//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- typedef PlayerData::Sounds playerSoundsEnum; @@ -216,6 +215,8 @@ EndImplementEnumType; //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- + IMPLEMENT_CO_DATABLOCK_V1(PlayerData); ConsoleDocClass( PlayerData, @@ -297,7 +298,7 @@ PlayerData::PlayerData() imageAnimPrefixFP = StringTable->EmptyString(); for (U32 i=0; iwrite(minLateralImpactSpeed); for (U32 i = 0; i < MaxSounds; i++) - PACKDATA_SOUNDASSET_ARRAY_ENUMED(PlayerSound, PlayerData::Sounds, i); + PACKDATA_ASSET_ARRAY(PlayerSound, i); mathWrite(*stream, boxSize); mathWrite(*stream, crouchBoxSize); @@ -1343,7 +1342,7 @@ void PlayerData::packData(BitStream* stream) stream->writeString(imageAnimPrefixFP); for (U32 i=0; iread(&minLateralImpactSpeed); for (U32 i = 0; i < MaxSounds; i++) - UNPACKDATA_SOUNDASSET_ARRAY_ENUMED(PlayerSound, PlayerData::Sounds, i); + UNPACKDATA_ASSET_ARRAY(PlayerSound, i); mathRead(*stream, &boxSize); mathRead(*stream, &crouchBoxSize); @@ -1523,7 +1522,7 @@ void PlayerData::unpackData(BitStream* stream) imageAnimPrefixFP = stream->readSTString(); for (U32 i=0; iwriteFlag(faceViewer); if(stream->writeFlag(scale.x != 1 || scale.y != 1 || scale.z != 1)) @@ -439,7 +439,7 @@ void ProjectileData::packData(BitStream* stream) if (stream->writeFlag(decal != NULL)) stream->writeRangedU32(decal->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast); - PACKDATA_SOUNDASSET(ProjectileSound); + PACKDATA_ASSET(ProjectileSound); if ( stream->writeFlag(lightDesc != NULL)) stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst, @@ -470,7 +470,7 @@ void ProjectileData::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_SHAPEASSET(ProjectileShape); + UNPACKDATA_ASSET(ProjectileShape); faceViewer = stream->readFlag(); if(stream->readFlag()) @@ -500,7 +500,7 @@ void ProjectileData::unpackData(BitStream* stream) if (stream->readFlag()) decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); - UNPACKDATA_SOUNDASSET(ProjectileSound); + UNPACKDATA_ASSET(ProjectileSound); if (stream->readFlag()) lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); diff --git a/Engine/source/T3D/projectile.h b/Engine/source/T3D/projectile.h index e633e3fd4..9aa0690d0 100644 --- a/Engine/source/T3D/projectile.h +++ b/Engine/source/T3D/projectile.h @@ -72,7 +72,7 @@ protected: public: DECLARE_SHAPEASSET(ProjectileData, ProjectileShape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(ProjectileData, ProjectileShape); + DECLARE_ASSET_SETGET(ProjectileData, ProjectileShape); /// Set to true if it is a billboard and want it to always face the viewer, false otherwise bool faceViewer; @@ -117,7 +117,7 @@ public: S32 decalId; // (impact) Decal ID DECLARE_SOUNDASSET(ProjectileData, ProjectileSound); - DECLARE_SOUNDASSET_SETGET(ProjectileData, ProjectileSound); + DECLARE_ASSET_SETGET(ProjectileData, ProjectileSound); LightDescription *lightDesc; S32 lightDescId; diff --git a/Engine/source/T3D/proximityMine.cpp b/Engine/source/T3D/proximityMine.cpp index 12eb60a1a..683021255 100644 --- a/Engine/source/T3D/proximityMine.cpp +++ b/Engine/source/T3D/proximityMine.cpp @@ -82,8 +82,8 @@ ProximityMineData::ProximityMineData() triggerSequence( -1 ), explosionOffset( 0.05f ) { - INIT_SOUNDASSET(ArmSound); - INIT_SOUNDASSET(TriggerSound); + INIT_ASSET(ArmSound); + INIT_ASSET(TriggerSound); } void ProximityMineData::initPersistFields() @@ -156,14 +156,14 @@ void ProximityMineData::packData( BitStream* stream ) Parent::packData( stream ); stream->write( armingDelay ); - PACKDATA_SOUNDASSET(ArmSound); + PACKDATA_ASSET(ArmSound); stream->write( autoTriggerDelay ); stream->writeFlag( triggerOnOwner ); stream->write( triggerRadius ); stream->write( triggerSpeed ); stream->write( triggerDelay ); - PACKDATA_SOUNDASSET(TriggerSound); + PACKDATA_ASSET(TriggerSound); } void ProximityMineData::unpackData( BitStream* stream ) @@ -171,14 +171,14 @@ void ProximityMineData::unpackData( BitStream* stream ) Parent::unpackData(stream); stream->read( &armingDelay ); - UNPACKDATA_SOUNDASSET(ArmSound); + UNPACKDATA_ASSET(ArmSound); stream->read( &autoTriggerDelay ); triggerOnOwner = stream->readFlag(); stream->read( &triggerRadius ); stream->read( &triggerSpeed ); stream->read( &triggerDelay ); - UNPACKDATA_SOUNDASSET(TriggerSound); + UNPACKDATA_ASSET(TriggerSound); } //---------------------------------------------------------------------------- diff --git a/Engine/source/T3D/proximityMine.h b/Engine/source/T3D/proximityMine.h index 4736c0e16..2c748317c 100644 --- a/Engine/source/T3D/proximityMine.h +++ b/Engine/source/T3D/proximityMine.h @@ -46,7 +46,7 @@ public: F32 armingDelay; S32 armingSequence; DECLARE_SOUNDASSET(ProximityMineData, ArmSound); - DECLARE_SOUNDASSET_SETGET(ProximityMineData, ArmSound); + DECLARE_ASSET_SETGET(ProximityMineData, ArmSound); F32 autoTriggerDelay; bool triggerOnOwner; @@ -55,7 +55,7 @@ public: F32 triggerDelay; S32 triggerSequence; DECLARE_SOUNDASSET(ProximityMineData, TriggerSound); - DECLARE_SOUNDASSET_SETGET(ProximityMineData, TriggerSound); + DECLARE_ASSET_SETGET(ProximityMineData, TriggerSound); F32 explosionOffset; diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index 475854bbb..01b830db0 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -238,7 +238,7 @@ RigidShapeData::RigidShapeData() density = 4; for (S32 i = 0; i < Body::MaxSounds; i++) - INIT_SOUNDASSET_ARRAY(BodySounds, i); + INIT_ASSET_ARRAY(BodySounds, i); dustEmitter = NULL; dustID = 0; @@ -257,7 +257,7 @@ RigidShapeData::RigidShapeData() enablePhysicsRep = true; for (S32 i = 0; i < Sounds::MaxSounds; i++) - INIT_SOUNDASSET_ARRAY(WaterSounds, i); + INIT_ASSET_ARRAY(WaterSounds, i); dragForce = 0; vertFactor = 0.25; @@ -371,7 +371,7 @@ void RigidShapeData::packData(BitStream* stream) stream->write(body.friction); for (U32 i = 0; i < Body::MaxSounds; ++i) { - PACKDATA_SOUNDASSET_ARRAY(BodySounds, i); + PACKDATA_ASSET_ARRAY(BodySounds, i); } stream->write(minImpactSpeed); @@ -403,7 +403,7 @@ void RigidShapeData::packData(BitStream* stream) // write the water sound profiles for (U32 i = 0; i < Sounds::MaxSounds; ++i) { - PACKDATA_SOUNDASSET_ARRAY(WaterSounds, i); + PACKDATA_ASSET_ARRAY(WaterSounds, i); } if (stream->writeFlag( dustEmitter )) @@ -434,7 +434,7 @@ void RigidShapeData::unpackData(BitStream* stream) for (U32 i = 0; i < Body::Sounds::MaxSounds; i++) { - UNPACKDATA_SOUNDASSET_ARRAY(BodySounds, i); + UNPACKDATA_ASSET_ARRAY(BodySounds, i); } stream->read(&minImpactSpeed); @@ -466,7 +466,7 @@ void RigidShapeData::unpackData(BitStream* stream) // write the water sound profiles for (U32 i = 0; i < Sounds::MaxSounds; ++i) { - UNPACKDATA_SOUNDASSET_ARRAY(WaterSounds, i); + UNPACKDATA_ASSET_ARRAY(WaterSounds, i); } if( stream->readFlag() ) diff --git a/Engine/source/T3D/rigidShape.h b/Engine/source/T3D/rigidShape.h index 49e8c1fd6..ef3ead6e5 100644 --- a/Engine/source/T3D/rigidShape.h +++ b/Engine/source/T3D/rigidShape.h @@ -64,7 +64,7 @@ class RigidShapeData : public ShapeBaseData } body; DECLARE_SOUNDASSET_ARRAY(RigidShapeData, BodySounds, Body::Sounds::MaxSounds) - DECLARE_SOUNDASSET_ARRAY_SETGET(RigidShapeData, BodySounds); + DECLARE_ASSET_ARRAY_SETGET(RigidShapeData, BodySounds); SFXProfile* getBodySoundProfile(U32 id) { @@ -92,7 +92,7 @@ class RigidShapeData : public ShapeBaseData MaxSounds }; DECLARE_SOUNDASSET_ARRAY(RigidShapeData, WaterSounds, Sounds::MaxSounds) - DECLARE_SOUNDASSET_ARRAY_SETGET(RigidShapeData, WaterSounds); + DECLARE_ASSET_ARRAY_SETGET(RigidShapeData, WaterSounds); SFXProfile* getWaterSoundProfile(U32 id) { diff --git a/Engine/source/T3D/sfx/sfxEmitter.cpp b/Engine/source/T3D/sfx/sfxEmitter.cpp index 655e0071a..8ac0de6ad 100644 --- a/Engine/source/T3D/sfx/sfxEmitter.cpp +++ b/Engine/source/T3D/sfx/sfxEmitter.cpp @@ -109,7 +109,7 @@ SFXEmitter::SFXEmitter() mLocalProfile.mFilename = StringTable->EmptyString(); mLocalProfile._registerSignals(); - INIT_SOUNDASSET(Sound); + INIT_ASSET(Sound); mObjBox.minExtents.set( -1.f, -1.f, -1.f ); mObjBox.maxExtents.set( 1.f, 1.f, 1.f ); @@ -290,7 +290,7 @@ U32 SFXEmitter::packUpdate( NetConnection *con, U32 mask, BitStream *stream ) stream->writeAffineTransform( mObjToWorld ); // track - PACK_SOUNDASSET(con, Sound); + PACK_ASSET(con, Sound); //if (stream->writeFlag(mDirty.test(Track))) // sfxWrite( stream, mTrack ); @@ -401,7 +401,7 @@ void SFXEmitter::unpackUpdate( NetConnection *conn, BitStream *stream ) } // track - UNPACK_SOUNDASSET(conn, Sound); + UNPACK_ASSET(conn, Sound); /*if (_readDirtyFlag(stream, Track)) { String errorStr; diff --git a/Engine/source/T3D/sfx/sfxEmitter.h b/Engine/source/T3D/sfx/sfxEmitter.h index aeecd13bf..cdb93a8bf 100644 --- a/Engine/source/T3D/sfx/sfxEmitter.h +++ b/Engine/source/T3D/sfx/sfxEmitter.h @@ -105,7 +105,7 @@ class SFXEmitter : public SceneObject BitSet32 mDirty; DECLARE_SOUNDASSET(SFXEmitter, Sound); - DECLARE_SOUNDASSET_NET_SETGET(SFXEmitter, Sound, DirtyUpdateMask); + DECLARE_ASSET_NET_SETGET(SFXEmitter, Sound, DirtyUpdateMask); /// The sound source for the emitter. SFXSource *mSource; diff --git a/Engine/source/T3D/shapeBase.cpp b/Engine/source/T3D/shapeBase.cpp index c1a814f07..4730ee6b7 100644 --- a/Engine/source/T3D/shapeBase.cpp +++ b/Engine/source/T3D/shapeBase.cpp @@ -197,8 +197,8 @@ ShapeBaseData::ShapeBaseData() renderWhenDestroyed( true ), inheritEnergyFromMount( false ) { - INIT_SHAPEASSET(Shape); - INIT_SHAPEASSET(DebrisShape); + INIT_ASSET(Shape); + INIT_ASSET(DebrisShape); dMemset( mountPointNode, -1, sizeof( S32 ) * SceneObject::NumMountPoints ); remap_txr_tags = NULL; @@ -214,13 +214,13 @@ ShapeBaseData::ShapeBaseData(const ShapeBaseData& other, bool temp_clone) : Game shadowProjectionDistance = other.shadowProjectionDistance; shadowSphereAdjust = other.shadowSphereAdjust; cloakTexName = other.cloakTexName; - CLONE_SHAPEASSET(Shape); + CLONE_ASSET(Shape); cubeDescName = other.cubeDescName; cubeDescId = other.cubeDescId; reflectorDesc = other.reflectorDesc; debris = other.debris; debrisID = other.debrisID; // -- for pack/unpack of debris ptr - CLONE_SHAPEASSET(DebrisShape); + CLONE_ASSET(DebrisShape); explosion = other.explosion; explosionID = other.explosionID; // -- for pack/unpack of explosion ptr underwaterExplosion = other.underwaterExplosion; @@ -757,8 +757,8 @@ void ShapeBaseData::packData(BitStream* stream) stream->write(shadowProjectionDistance); stream->write(shadowSphereAdjust); - PACKDATA_SHAPEASSET(Shape); - PACKDATA_SHAPEASSET(DebrisShape); + PACKDATA_ASSET(Shape); + PACKDATA_ASSET(DebrisShape); stream->writeString(cloakTexName); if(stream->writeFlag(mass != gShapeBaseDataProto.mass)) @@ -835,8 +835,8 @@ void ShapeBaseData::unpackData(BitStream* stream) stream->read(&shadowProjectionDistance); stream->read(&shadowSphereAdjust); - UNPACKDATA_SHAPEASSET(Shape); - UNPACKDATA_SHAPEASSET(DebrisShape); + UNPACKDATA_ASSET(Shape); + UNPACKDATA_ASSET(DebrisShape); cloakTexName = stream->readSTString(); if(stream->readFlag()) diff --git a/Engine/source/T3D/shapeBase.h b/Engine/source/T3D/shapeBase.h index a2696819e..1670a8230 100644 --- a/Engine/source/T3D/shapeBase.h +++ b/Engine/source/T3D/shapeBase.h @@ -324,7 +324,7 @@ struct ShapeBaseImageData: public GameBaseData { bool stateIgnoreLoadedForReady [MaxStates]; DECLARE_SOUNDASSET_ARRAY(ShapeBaseImageData, stateSound, MaxStates); - DECLARE_SOUNDASSET_ARRAY_SETGET(ShapeBaseImageData, stateSound); + DECLARE_ASSET_ARRAY_SETGET(ShapeBaseImageData, stateSound); //SFXTrack* stateSound [MaxStates]; const char* stateScript [MaxStates]; @@ -379,10 +379,10 @@ struct ShapeBaseImageData: public GameBaseData { ///< when the script prefix has changed. DECLARE_SHAPEASSET_ARRAY(ShapeBaseImageData, Shape, MaxShapes); ///< Name of shape to render. - DECLARE_SHAPEASSET_ARRAY_SETGET(ShapeBaseImageData, Shape); + DECLARE_ASSET_ARRAY_SETGET(ShapeBaseImageData, Shape); //DECLARE_SHAPEASSET(ShapeBaseImageData, ShapeFP); ///< Name of shape to render in first person (optional). - //DECLARE_SHAPEASSET_SETGET(ShapeBaseImageData, ShapeFP); + //DECLARE_ASSET_SETGET(ShapeBaseImageData, ShapeFP); StringTableEntry imageAnimPrefix; ///< Passed along to the mounting shape to modify /// animation sequences played in 3rd person. [optional] @@ -546,7 +546,7 @@ public: F32 shadowSphereAdjust; DECLARE_SHAPEASSET(ShapeBaseData, Shape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(ShapeBaseData, Shape); + DECLARE_ASSET_SETGET(ShapeBaseData, Shape); StringTableEntry cloakTexName; @@ -562,7 +562,7 @@ public: S32 debrisID; DECLARE_SHAPEASSET(ShapeBaseData, DebrisShape, onDebrisChanged); - DECLARE_SHAPEASSET_SETGET(ShapeBaseData, DebrisShape); + DECLARE_ASSET_SETGET(ShapeBaseData, DebrisShape); ExplosionData* explosion; S32 explosionID; diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index ab43a0ba3..1563f3be5 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -257,7 +257,7 @@ ShapeBaseImageData::ShapeBaseImageData() stateShapeSequence[i] = 0; stateScaleShapeSequence[i] = false; - INIT_SOUNDASSET_ARRAY(stateSound, i); + INIT_ASSET_ARRAY(stateSound, i); stateScript[i] = 0; stateEmitter[i] = 0; stateEmitterTime[i] = 0; @@ -295,7 +295,7 @@ ShapeBaseImageData::ShapeBaseImageData() hasFlash[i] = false; shapeIsValid[i] = false; - INIT_SHAPEASSET_ARRAY(Shape, i); + INIT_ASSET_ARRAY(Shape, i); } shakeCamera = false; @@ -983,7 +983,7 @@ void ShapeBaseImageData::packData(BitStream* stream) for (U32 j = 0; j < MaxShapes; ++j) { - PACKDATA_SHAPEASSET_ARRAY(Shape, j); // shape 0 for normal use, shape 1 for first person use (optional) + PACKDATA_ASSET_ARRAY(Shape, j); // shape 0 for normal use, shape 1 for first person use (optional) } stream->writeString(imageAnimPrefix); @@ -1147,7 +1147,7 @@ void ShapeBaseImageData::packData(BitStream* stream) } } - PACKDATA_SOUNDASSET_ARRAY(stateSound, i); + PACKDATA_ASSET_ARRAY(stateSound, i); } stream->write(maxConcurrentSounds); stream->writeFlag(useRemainderDT); @@ -1167,7 +1167,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream) for (U32 j = 0; j < MaxShapes; ++j) { - UNPACKDATA_SHAPEASSET_ARRAY(Shape, j); // shape 0 for normal use, shape 1 for first person use (optional) + UNPACKDATA_ASSET_ARRAY(Shape, j); // shape 0 for normal use, shape 1 for first person use (optional) } imageAnimPrefix = stream->readSTString(); @@ -1352,7 +1352,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream) else s.emitter = 0; - UNPACKDATA_SOUNDASSET_ARRAY(stateSound, i); + UNPACKDATA_ASSET_ARRAY(stateSound, i); } } diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 9028653b8..169e6d806 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -149,7 +149,7 @@ TSStatic::TSStatic() mAnimOffset = 0.0f; mAnimSpeed = 1.0f; - INIT_SHAPEASSET(Shape); + INIT_ASSET(Shape); } TSStatic::~TSStatic() @@ -958,7 +958,7 @@ U32 TSStatic::packUpdate(NetConnection* con, U32 mask, BitStream* stream) if (stream->writeFlag(mask & AdvancedStaticOptionsMask)) { - PACK_SHAPEASSET(con, Shape); + PACK_ASSET(con, Shape); stream->write((U32)mDecalType); @@ -1073,7 +1073,7 @@ void TSStatic::unpackUpdate(NetConnection* con, BitStream* stream) if (stream->readFlag()) // AdvancedStaticOptionsMask { - UNPACK_SHAPEASSET(con, Shape); + UNPACK_ASSET(con, Shape); stream->read((U32*)&mDecalType); diff --git a/Engine/source/T3D/tsStatic.h b/Engine/source/T3D/tsStatic.h index 1c82671cb..03c74c651 100644 --- a/Engine/source/T3D/tsStatic.h +++ b/Engine/source/T3D/tsStatic.h @@ -192,7 +192,7 @@ protected: Convex* mConvexList; DECLARE_SHAPEASSET(TSStatic, Shape, onShapeChanged); - DECLARE_SHAPEASSET_NET_SETGET(TSStatic, Shape, AdvancedStaticOptionsMask); + DECLARE_ASSET_NET_SETGET(TSStatic, Shape, AdvancedStaticOptionsMask); U32 mShapeHash; Vector mCollisionDetails; diff --git a/Engine/source/T3D/vehicles/flyingVehicle.cpp b/Engine/source/T3D/vehicles/flyingVehicle.cpp index dcc1f8dd2..8426da2c3 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.cpp +++ b/Engine/source/T3D/vehicles/flyingVehicle.cpp @@ -116,7 +116,7 @@ FlyingVehicleData::FlyingVehicleData() jetEmitter[j] = 0; for (S32 i = 0; i < MaxSounds; i++) - INIT_SOUNDASSET_ARRAY(FlyingSounds, i); + INIT_ASSET_ARRAY(FlyingSounds, i); vertThrustMultiple = 1.0; } @@ -241,7 +241,7 @@ void FlyingVehicleData::packData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { - PACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i); + PACKDATA_ASSET_ARRAY(FlyingSounds, i); } for (S32 j = 0; j < MaxJetEmitters; j++) @@ -276,7 +276,7 @@ void FlyingVehicleData::unpackData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { - UNPACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i); + UNPACKDATA_ASSET_ARRAY(FlyingSounds, i); } for (S32 j = 0; j < MaxJetEmitters; j++) { diff --git a/Engine/source/T3D/vehicles/flyingVehicle.h b/Engine/source/T3D/vehicles/flyingVehicle.h index 573d10ccc..f0a45edd3 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.h +++ b/Engine/source/T3D/vehicles/flyingVehicle.h @@ -46,7 +46,7 @@ struct FlyingVehicleData: public VehicleData { MaxSounds, }; DECLARE_SOUNDASSET_ARRAY(FlyingVehicleData, FlyingSounds, Sounds::MaxSounds); - DECLARE_SOUNDASSET_ARRAY_SETGET(FlyingVehicleData, FlyingSounds); + DECLARE_ASSET_ARRAY_SETGET(FlyingVehicleData, FlyingSounds); SFXProfile* getFlyingSoundProfile(U32 id) { if (mFlyingSoundsAsset[id] != NULL) diff --git a/Engine/source/T3D/vehicles/hoverVehicle.cpp b/Engine/source/T3D/vehicles/hoverVehicle.cpp index 7deb81fe0..dbaee9993 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.cpp +++ b/Engine/source/T3D/vehicles/hoverVehicle.cpp @@ -162,7 +162,7 @@ HoverVehicleData::HoverVehicleData() jetEmitter[j] = 0; for (S32 i = 0; i < MaxSounds; i++) - INIT_SOUNDASSET_ARRAY(HoverSounds, i); + INIT_ASSET_ARRAY(HoverSounds, i); } HoverVehicleData::~HoverVehicleData() @@ -370,7 +370,7 @@ void HoverVehicleData::packData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { - PACKDATA_SOUNDASSET_ARRAY(HoverSounds, i); + PACKDATA_ASSET_ARRAY(HoverSounds, i); } for (S32 j = 0; j < MaxJetEmitters; j++) @@ -419,7 +419,7 @@ void HoverVehicleData::unpackData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { - UNPACKDATA_SOUNDASSET_ARRAY(HoverSounds, i); + UNPACKDATA_ASSET_ARRAY(HoverSounds, i); } for (S32 j = 0; j < MaxJetEmitters; j++) { diff --git a/Engine/source/T3D/vehicles/hoverVehicle.h b/Engine/source/T3D/vehicles/hoverVehicle.h index da22da280..8e7cce79b 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.h +++ b/Engine/source/T3D/vehicles/hoverVehicle.h @@ -47,7 +47,7 @@ class HoverVehicleData : public VehicleData MaxSounds }; DECLARE_SOUNDASSET_ARRAY(HoverVehicleData, HoverSounds, Sounds::MaxSounds); - DECLARE_SOUNDASSET_ARRAY_SETGET(HoverVehicleData, HoverSounds); + DECLARE_ASSET_ARRAY_SETGET(HoverVehicleData, HoverSounds); SFXProfile* getHoverSoundProfile(U32 id) { if (mHoverSoundsAsset[id] != NULL) diff --git a/Engine/source/T3D/vehicles/vehicle.cpp b/Engine/source/T3D/vehicles/vehicle.cpp index 8079fc163..2fad95b6d 100644 --- a/Engine/source/T3D/vehicles/vehicle.cpp +++ b/Engine/source/T3D/vehicles/vehicle.cpp @@ -189,7 +189,7 @@ VehicleData::VehicleData() for (S32 i = 0; i < Body::MaxSounds; i++) { - INIT_SOUNDASSET_ARRAY(VehicleBodySounds, i); + INIT_ASSET_ARRAY(VehicleBodySounds, i); } dustEmitter = NULL; @@ -214,7 +214,7 @@ VehicleData::VehicleData() hardSplashSoundVel = 3.0; for (S32 i = 0; i < Sounds::MaxSounds; i++) - INIT_SOUNDASSET_ARRAY(VehicleWaterSounds, i); + INIT_ASSET_ARRAY(VehicleWaterSounds, i); collDamageThresholdVel = 20; collDamageMultiplier = 0.05f; @@ -302,7 +302,7 @@ void VehicleData::packData(BitStream* stream) stream->write(body.friction); for (i = 0; i < Body::MaxSounds; i++) { - PACKDATA_SOUNDASSET_ARRAY(VehicleBodySounds, i); + PACKDATA_ASSET_ARRAY(VehicleBodySounds, i); } stream->write(minImpactSpeed); @@ -346,7 +346,7 @@ void VehicleData::packData(BitStream* stream) // write the water sound profiles for (i = 0; i < MaxSounds; i++) { - PACKDATA_SOUNDASSET_ARRAY(VehicleWaterSounds, i); + PACKDATA_ASSET_ARRAY(VehicleWaterSounds, i); } if (stream->writeFlag( dustEmitter )) @@ -398,7 +398,7 @@ void VehicleData::unpackData(BitStream* stream) S32 i; for (i = 0; i < Body::MaxSounds; i++) { - UNPACKDATA_SOUNDASSET_ARRAY(VehicleBodySounds, i); + UNPACKDATA_ASSET_ARRAY(VehicleBodySounds, i); } stream->read(&minImpactSpeed); @@ -442,7 +442,7 @@ void VehicleData::unpackData(BitStream* stream) // write the water sound profiles for (i = 0; i < Sounds::MaxSounds; i++) { - UNPACKDATA_SOUNDASSET_ARRAY(VehicleWaterSounds, i); + UNPACKDATA_ASSET_ARRAY(VehicleWaterSounds, i); } if( stream->readFlag() ) diff --git a/Engine/source/T3D/vehicles/vehicle.h b/Engine/source/T3D/vehicles/vehicle.h index 3e9636027..c9a50b831 100644 --- a/Engine/source/T3D/vehicles/vehicle.h +++ b/Engine/source/T3D/vehicles/vehicle.h @@ -50,7 +50,7 @@ struct VehicleData : public RigidShapeData } body; DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleBodySounds, Body::Sounds::MaxSounds) - DECLARE_SOUNDASSET_ARRAY_SETGET(VehicleData, VehicleBodySounds); + DECLARE_ASSET_ARRAY_SETGET(VehicleData, VehicleBodySounds); SFXProfile* getVehicleBodySoundProfile(U32 id) { @@ -82,7 +82,7 @@ struct VehicleData : public RigidShapeData }; DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleWaterSounds, Sounds::MaxSounds) - DECLARE_SOUNDASSET_ARRAY_SETGET(VehicleData, VehicleWaterSounds); + DECLARE_ASSET_ARRAY_SETGET(VehicleData, VehicleWaterSounds); SFXProfile* getVehicleWaterSoundProfile(U32 id) { diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.cpp b/Engine/source/T3D/vehicles/wheeledVehicle.cpp index 4e9e7201e..258222847 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.cpp +++ b/Engine/source/T3D/vehicles/wheeledVehicle.cpp @@ -75,7 +75,7 @@ ConsoleDocClass( WheeledVehicleTire, WheeledVehicleTire::WheeledVehicleTire() { - INIT_SHAPEASSET(Shape); + INIT_ASSET(Shape); staticFriction = 1; kineticFriction = 0.5f; @@ -177,7 +177,7 @@ void WheeledVehicleTire::packData(BitStream* stream) { Parent::packData(stream); - PACKDATA_SHAPEASSET(Shape); + PACKDATA_ASSET(Shape); stream->write(mass); stream->write(staticFriction); @@ -196,7 +196,7 @@ void WheeledVehicleTire::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_SHAPEASSET(Shape); + UNPACKDATA_ASSET(Shape); stream->read(&mass); stream->read(&staticFriction); @@ -312,7 +312,7 @@ WheeledVehicleData::WheeledVehicleData() wheelCount = 0; dMemset(&wheel, 0, sizeof(wheel)); for (S32 i = 0; i < MaxSounds; i++) - INIT_SOUNDASSET_ARRAY(WheeledVehicleSounds, i); + INIT_ASSET_ARRAY(WheeledVehicleSounds, i); } @@ -483,7 +483,7 @@ void WheeledVehicleData::packData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { - PACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i); + PACKDATA_ASSET_ARRAY(WheeledVehicleSounds, i); } stream->write(maxWheelSpeed); @@ -502,7 +502,7 @@ void WheeledVehicleData::unpackData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { - UNPACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i); + UNPACKDATA_ASSET_ARRAY(WheeledVehicleSounds, i); } stream->read(&maxWheelSpeed); diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.h b/Engine/source/T3D/vehicles/wheeledVehicle.h index a2ab03b11..c8759e52d 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.h +++ b/Engine/source/T3D/vehicles/wheeledVehicle.h @@ -44,7 +44,7 @@ struct WheeledVehicleTire: public SimDataBlock typedef SimDataBlock Parent; DECLARE_SHAPEASSET(WheeledVehicleTire, Shape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(WheeledVehicleTire, Shape); + DECLARE_ASSET_SETGET(WheeledVehicleTire, Shape); // Physical properties F32 mass; // Mass of the whole wheel @@ -120,7 +120,7 @@ struct WheeledVehicleData: public VehicleData }; DECLARE_SOUNDASSET_ARRAY(WheeledVehicleData, WheeledVehicleSounds, Sounds::MaxSounds); - DECLARE_SOUNDASSET_ARRAY_SETGET(WheeledVehicleData, WheeledVehicleSounds); + DECLARE_ASSET_ARRAY_SETGET(WheeledVehicleData, WheeledVehicleSounds); SFXProfile* getWheeledVehicleSound(U32 id) { diff --git a/Engine/source/afx/afxMagicMissile.cpp b/Engine/source/afx/afxMagicMissile.cpp index 93d4ef237..a67447248 100644 --- a/Engine/source/afx/afxMagicMissile.cpp +++ b/Engine/source/afx/afxMagicMissile.cpp @@ -141,7 +141,7 @@ U32 Projectile::smProjectileWarpTicks = 5; // afxMagicMissileData::afxMagicMissileData() { - INIT_SHAPEASSET(ProjectileShape); + INIT_ASSET(ProjectileShape); sound = NULL; @@ -246,7 +246,7 @@ afxMagicMissileData::afxMagicMissileData() afxMagicMissileData::afxMagicMissileData(const afxMagicMissileData& other, bool temp_clone) : GameBaseData(other, temp_clone) { - CLONE_SHAPEASSET(ProjectileShape); + CLONE_ASSET(ProjectileShape); projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName sound = other.sound; splash = other.splash; @@ -599,7 +599,7 @@ void afxMagicMissileData::packData(BitStream* stream) { Parent::packData(stream); - PACKDATA_SHAPEASSET(ProjectileShape); + PACKDATA_ASSET(ProjectileShape); /* From stock Projectile code... stream->writeFlag(faceViewer); @@ -710,7 +710,7 @@ void afxMagicMissileData::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_SHAPEASSET(ProjectileShape); + UNPACKDATA_ASSET(ProjectileShape); /* From stock Projectile code... faceViewer = stream->readFlag(); */ diff --git a/Engine/source/afx/afxMagicMissile.h b/Engine/source/afx/afxMagicMissile.h index 1206354fd..626dfd91d 100644 --- a/Engine/source/afx/afxMagicMissile.h +++ b/Engine/source/afx/afxMagicMissile.h @@ -72,7 +72,7 @@ public: // variables set in datablock definition: // Shape related DECLARE_SHAPEASSET(afxMagicMissileData, ProjectileShape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(afxMagicMissileData, ProjectileShape); + DECLARE_ASSET_SETGET(afxMagicMissileData, ProjectileShape); //StringTableEntry projectileShapeName; //bool hasLight; diff --git a/Engine/source/afx/ce/afxBillboard.cpp b/Engine/source/afx/ce/afxBillboard.cpp index 553c2942f..c0092c389 100644 --- a/Engine/source/afx/ce/afxBillboard.cpp +++ b/Engine/source/afx/ce/afxBillboard.cpp @@ -51,7 +51,7 @@ ConsoleDocClass( afxBillboardData, afxBillboardData::afxBillboardData() { color.set(1.0f, 1.0f, 1.0f, 1.0f); - INIT_IMAGEASSET(Texture); + INIT_ASSET(Texture); dimensions.set(1.0f, 1.0f); texCoords[0].set(0.0f, 0.0f); texCoords[1].set(0.0f, 1.0f); @@ -66,7 +66,7 @@ afxBillboardData::afxBillboardData(const afxBillboardData& other, bool temp_clon : GameBaseData(other, temp_clone) { color = other.color; - CLONE_IMAGEASSET(Texture); + CLONE_ASSET(Texture); dimensions = other.dimensions; texCoords[0] = other.texCoords[0]; texCoords[1] = other.texCoords[1]; @@ -123,7 +123,7 @@ void afxBillboardData::packData(BitStream* stream) Parent::packData(stream); stream->write(color); - PACKDATA_IMAGEASSET(Texture); + PACKDATA_ASSET(Texture); mathWrite(*stream, dimensions); mathWrite(*stream, texCoords[0]); @@ -140,7 +140,7 @@ void afxBillboardData::unpackData(BitStream* stream) Parent::unpackData(stream); stream->read(&color); - UNPACKDATA_IMAGEASSET(Texture); + UNPACKDATA_ASSET(Texture); mathRead(*stream, &dimensions); mathRead(*stream, &texCoords[0]); mathRead(*stream, &texCoords[1]); diff --git a/Engine/source/afx/ce/afxBillboard.h b/Engine/source/afx/ce/afxBillboard.h index 1183500a2..8c6532539 100644 --- a/Engine/source/afx/ce/afxBillboard.h +++ b/Engine/source/afx/ce/afxBillboard.h @@ -48,7 +48,7 @@ public: public: DECLARE_IMAGEASSET(afxBillboardData, Texture, onChangeTexture, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(afxBillboardData, Texture); + DECLARE_ASSET_SETGET(afxBillboardData, Texture); LinearColorF color; diff --git a/Engine/source/afx/ce/afxModel.cpp b/Engine/source/afx/ce/afxModel.cpp index ba452156b..7c6eb019c 100644 --- a/Engine/source/afx/ce/afxModel.cpp +++ b/Engine/source/afx/ce/afxModel.cpp @@ -54,7 +54,7 @@ ConsoleDocClass( afxModelData, afxModelData::afxModelData() { - INIT_SHAPEASSET(Shape); + INIT_ASSET(Shape); sequence = ST_NULLSTRING; seq_rate = 1.0f; seq_offset = 0.0f; @@ -84,7 +84,7 @@ afxModelData::afxModelData() afxModelData::afxModelData(const afxModelData& other, bool temp_clone) : GameBaseData(other, temp_clone) { - CLONE_SHAPEASSET(Shape); + CLONE_ASSET(Shape); sequence = other.sequence; seq_rate = other.seq_rate; seq_offset = other.seq_offset; @@ -253,7 +253,7 @@ void afxModelData::packData(BitStream* stream) { Parent::packData(stream); - PACKDATA_SHAPEASSET(Shape); + PACKDATA_ASSET(Shape); stream->writeString(sequence); stream->write(seq_rate); stream->write(seq_offset); @@ -285,7 +285,7 @@ void afxModelData::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_SHAPEASSET(Shape); + UNPACKDATA_ASSET(Shape); sequence = stream->readSTString(); stream->read(&seq_rate); stream->read(&seq_offset); diff --git a/Engine/source/afx/ce/afxModel.h b/Engine/source/afx/ce/afxModel.h index 0d13692ef..80c6803f7 100644 --- a/Engine/source/afx/ce/afxModel.h +++ b/Engine/source/afx/ce/afxModel.h @@ -44,7 +44,7 @@ struct afxModelData : public GameBaseData typedef GameBaseData Parent; DECLARE_SHAPEASSET(afxModelData, Shape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(afxModelData, Shape); + DECLARE_ASSET_SETGET(afxModelData, Shape); StringTableEntry sequence; diff --git a/Engine/source/afx/ce/afxZodiac.cpp b/Engine/source/afx/ce/afxZodiac.cpp index eca56af5a..dc4cb5b01 100644 --- a/Engine/source/afx/ce/afxZodiac.cpp +++ b/Engine/source/afx/ce/afxZodiac.cpp @@ -78,7 +78,7 @@ bool afxZodiacData::sPreferDestinationGradients = false; afxZodiacData::afxZodiacData() { - INIT_IMAGEASSET(Texture); + INIT_ASSET(Texture); radius_xy = 1; vert_range.set(0.0f, 0.0f); @@ -120,7 +120,7 @@ afxZodiacData::afxZodiacData() afxZodiacData::afxZodiacData(const afxZodiacData& other, bool temp_clone) : GameBaseData(other, temp_clone) { - CLONE_IMAGEASSET(Texture); + CLONE_ASSET(Texture); radius_xy = other.radius_xy; vert_range = other.vert_range; @@ -269,7 +269,7 @@ void afxZodiacData::packData(BitStream* stream) merge_zflags(); - PACKDATA_IMAGEASSET(Texture); + PACKDATA_ASSET(Texture); stream->write(radius_xy); stream->write(vert_range.x); stream->write(vert_range.y); @@ -294,7 +294,7 @@ void afxZodiacData::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_IMAGEASSET(Texture); + UNPACKDATA_ASSET(Texture); stream->read(&radius_xy); stream->read(&vert_range.x); stream->read(&vert_range.y); diff --git a/Engine/source/afx/ce/afxZodiac.h b/Engine/source/afx/ce/afxZodiac.h index d03fcf593..917ee5490 100644 --- a/Engine/source/afx/ce/afxZodiac.h +++ b/Engine/source/afx/ce/afxZodiac.h @@ -60,7 +60,7 @@ public: public: DECLARE_IMAGEASSET(afxZodiacData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile); - DECLARE_IMAGEASSET_SETGET(afxZodiacData, Texture); + DECLARE_ASSET_SETGET(afxZodiacData, Texture); F32 radius_xy; Point2F vert_range; diff --git a/Engine/source/afx/ce/afxZodiacPlane.cpp b/Engine/source/afx/ce/afxZodiacPlane.cpp index aaea763e7..c9045bc95 100644 --- a/Engine/source/afx/ce/afxZodiacPlane.cpp +++ b/Engine/source/afx/ce/afxZodiacPlane.cpp @@ -51,7 +51,7 @@ ConsoleDocClass( afxZodiacPlaneData, afxZodiacPlaneData::afxZodiacPlaneData() { - INIT_IMAGEASSET(Texture); + INIT_ASSET(Texture); radius_xy = 1; start_ang = 0; @@ -71,7 +71,7 @@ afxZodiacPlaneData::afxZodiacPlaneData() afxZodiacPlaneData::afxZodiacPlaneData(const afxZodiacPlaneData& other, bool temp_clone) : GameBaseData(other, temp_clone) { - CLONE_IMAGEASSET(Texture); + CLONE_ASSET(Texture); radius_xy = other.radius_xy; start_ang = other.start_ang; @@ -165,7 +165,7 @@ void afxZodiacPlaneData::packData(BitStream* stream) merge_zflags(); - PACKDATA_IMAGEASSET(Texture); + PACKDATA_ASSET(Texture); stream->write(radius_xy); stream->write(start_ang); @@ -184,7 +184,7 @@ void afxZodiacPlaneData::unpackData(BitStream* stream) { Parent::unpackData(stream); - UNPACKDATA_IMAGEASSET(Texture); + UNPACKDATA_ASSET(Texture); stream->read(&radius_xy); stream->read(&start_ang); diff --git a/Engine/source/afx/ce/afxZodiacPlane.h b/Engine/source/afx/ce/afxZodiacPlane.h index e99702b4c..7b2d7aec2 100644 --- a/Engine/source/afx/ce/afxZodiacPlane.h +++ b/Engine/source/afx/ce/afxZodiacPlane.h @@ -60,7 +60,7 @@ public: public: DECLARE_IMAGEASSET(afxZodiacPlaneData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile); - DECLARE_IMAGEASSET_SETGET(afxZodiacPlaneData, Texture); + DECLARE_ASSET_SETGET(afxZodiacPlaneData, Texture); F32 radius_xy; F32 start_ang; diff --git a/Engine/source/assets/assetBase.h b/Engine/source/assets/assetBase.h index 7d1918857..d4efc6a8a 100644 --- a/Engine/source/assets/assetBase.h +++ b/Engine/source/assets/assetBase.h @@ -173,6 +173,5 @@ private: #define assetText(x,suff) #x#suff #define macroText(x) #x #define assetDoc(x,suff) "@brief "#x" "#suff - #endif // _ASSET_BASE_H_ diff --git a/Engine/source/environment/VolumetricFog.cpp b/Engine/source/environment/VolumetricFog.cpp index b602d87ac..c9eaff9df 100644 --- a/Engine/source/environment/VolumetricFog.cpp +++ b/Engine/source/environment/VolumetricFog.cpp @@ -137,8 +137,8 @@ VolumetricFog::VolumetricFog() mSpeed1.set(0.5f, 0.0f); mSpeed2.set(0.1f, 0.1f); - INIT_SHAPEASSET(Shape); - INIT_IMAGEASSET(Texture); + INIT_ASSET(Shape); + INIT_ASSET(Texture); } VolumetricFog::~VolumetricFog() @@ -543,7 +543,7 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream) stream->write(mFogDensity); if (stream->writeFlag(mask & FogModulationMask)) { - PACK_IMAGEASSET(con, Texture); + PACK_ASSET(con, Texture); mTexTiles = mFabs(mTexTiles); stream->write(mTexTiles); stream->write(mStrength); @@ -567,7 +567,7 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream) } if (stream->writeFlag(mask & FogShapeMask)) { - PACK_SHAPEASSET(con, Shape); + PACK_ASSET(con, Shape); mathWrite(*stream, getTransform()); mathWrite(*stream, getScale()); @@ -613,7 +613,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream) } if (stream->readFlag())// Fog Modulation { - UNPACK_IMAGEASSET(con, Texture); + UNPACK_ASSET(con, Texture); stream->read(&mTexTiles); mTexTiles = mFabs(mTexTiles); stream->read(&mStrength); @@ -667,7 +667,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream) } if (stream->readFlag())//Fog shape { - UNPACK_SHAPEASSET(con, Shape); + UNPACK_ASSET(con, Shape); mathRead(*stream, &mat); mathRead(*stream, &scale); diff --git a/Engine/source/environment/VolumetricFog.h b/Engine/source/environment/VolumetricFog.h index 1a4abaca3..83df0c184 100644 --- a/Engine/source/environment/VolumetricFog.h +++ b/Engine/source/environment/VolumetricFog.h @@ -85,7 +85,7 @@ class VolumetricFog : public SceneObject }; DECLARE_SHAPEASSET(VolumetricFog, Shape, onShapeChanged); - DECLARE_SHAPEASSET_NET_SETGET(VolumetricFog, Shape, FogShapeMask); + DECLARE_ASSET_NET_SETGET(VolumetricFog, Shape, FogShapeMask); protected: // Rendertargets; @@ -163,7 +163,7 @@ class VolumetricFog : public SceneObject // Fog Modulation data DECLARE_IMAGEASSET(VolumetricFog, Texture, onImageChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_NET_SETGET(VolumetricFog, Texture, FogModulationMask); + DECLARE_ASSET_NET_SETGET(VolumetricFog, Texture, FogModulationMask); bool mIsTextured; F32 mTexTiles; @@ -257,4 +257,4 @@ class VolumetricFog : public SceneObject DECLARE_CALLBACK(void, onEnterFog, (SimObjectId obj)); DECLARE_CALLBACK(void, onLeaveFog, (SimObjectId obj)); }; -#endif \ No newline at end of file +#endif diff --git a/Engine/source/environment/basicClouds.cpp b/Engine/source/environment/basicClouds.cpp index defd8fc41..462bf573f 100644 --- a/Engine/source/environment/basicClouds.cpp +++ b/Engine/source/environment/basicClouds.cpp @@ -215,7 +215,7 @@ U32 BasicClouds::packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) { stream->writeFlag( mLayerEnabled[i] ); - PACK_IMAGEASSET_ARRAY(conn, Texture, i); + PACK_ASSET_ARRAY(conn, Texture, i); stream->write( mTexScale[i] ); mathWrite( *stream, mTexDirection[i] ); @@ -236,7 +236,7 @@ void BasicClouds::unpackUpdate( NetConnection *conn, BitStream *stream ) { mLayerEnabled[i] = stream->readFlag(); - UNPACK_IMAGEASSET_ARRAY(conn, Texture, i); + UNPACK_ASSET_ARRAY(conn, Texture, i); stream->read( &mTexScale[i] ); mathRead( *stream, &mTexDirection[i] ); diff --git a/Engine/source/environment/cloudLayer.cpp b/Engine/source/environment/cloudLayer.cpp index 01e55dc6e..dce8f84a2 100644 --- a/Engine/source/environment/cloudLayer.cpp +++ b/Engine/source/environment/cloudLayer.cpp @@ -113,7 +113,7 @@ CloudLayer::CloudLayer() mHeight = 4.0f; - INIT_IMAGEASSET(Texture); + INIT_ASSET(Texture); } IMPLEMENT_CO_NETOBJECT_V1( CloudLayer ); @@ -242,7 +242,7 @@ U32 CloudLayer::packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) { U32 retMask = Parent::packUpdate( conn, mask, stream ); - PACK_IMAGEASSET(conn, Texture); + PACK_ASSET(conn, Texture); for ( U32 i = 0; i < TEX_COUNT; i++ ) { @@ -264,7 +264,7 @@ void CloudLayer::unpackUpdate( NetConnection *conn, BitStream *stream ) { Parent::unpackUpdate( conn, stream ); - UNPACK_IMAGEASSET(conn, Texture); + UNPACK_ASSET(conn, Texture); if(mTextureAssetId != StringTable->EmptyString()) mTextureAsset = mTextureAssetId; diff --git a/Engine/source/environment/cloudLayer.h b/Engine/source/environment/cloudLayer.h index 82e152dfb..8f7ffc667 100644 --- a/Engine/source/environment/cloudLayer.h +++ b/Engine/source/environment/cloudLayer.h @@ -97,7 +97,7 @@ protected: static U32 smTriangleCount; DECLARE_IMAGEASSET(CloudLayer, Texture, onImageChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_NET_SETGET(CloudLayer, Texture, CloudLayerMask); + DECLARE_ASSET_NET_SETGET(CloudLayer, Texture, CloudLayerMask); GFXShaderRef mShader; @@ -136,4 +136,4 @@ protected: }; -#endif // _CLOUDLAYER_H_ \ No newline at end of file +#endif // _CLOUDLAYER_H_ diff --git a/Engine/source/environment/decalRoad.cpp b/Engine/source/environment/decalRoad.cpp index e1d9a27ee..bd5e1e619 100644 --- a/Engine/source/environment/decalRoad.cpp +++ b/Engine/source/environment/decalRoad.cpp @@ -287,7 +287,7 @@ DecalRoad::DecalRoad() mTypeMask |= StaticObjectType | StaticShapeObjectType; mNetFlags.set(Ghostable); - INIT_MATERIALASSET(Material); + INIT_ASSET(Material); mMaterialInst = nullptr; } @@ -491,7 +491,7 @@ U32 DecalRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream) if ( stream->writeFlag( mask & DecalRoadMask ) ) { // Write Texture Name. - PACK_MATERIALASSET(con, Material); + PACK_ASSET(con, Material); stream->write( mBreakAngle ); @@ -580,7 +580,7 @@ void DecalRoad::unpackUpdate( NetConnection *con, BitStream *stream ) // DecalRoadMask if ( stream->readFlag() ) { - UNPACK_MATERIALASSET(con, Material); + UNPACK_ASSET(con, Material); if (isProperlyAdded()) _initMaterial(); diff --git a/Engine/source/environment/decalRoad.h b/Engine/source/environment/decalRoad.h index 7934d7889..180b92d08 100644 --- a/Engine/source/environment/decalRoad.h +++ b/Engine/source/environment/decalRoad.h @@ -243,7 +243,7 @@ protected: BaseMatInstance* mMaterialInst; DECLARE_MATERIALASSET(DecalRoad, Material); - DECLARE_MATERIALASSET_NET_SETGET(DecalRoad, Material, DecalRoadMask); + DECLARE_ASSET_NET_SETGET(DecalRoad, Material, DecalRoadMask); U32 mRenderPriority; diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp index b0812f738..7d139c2ea 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp @@ -97,9 +97,9 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl() mHoverNodeColor( 255,255,255,255 ), mHasCopied( false ) { - INIT_MATERIALASSET(TopMaterial); - INIT_MATERIALASSET(BottomMaterial); - INIT_MATERIALASSET(SideMaterial); + INIT_ASSET(TopMaterial); + INIT_ASSET(BottomMaterial); + INIT_ASSET(SideMaterial); mTopMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultTopMaterialAsset"); mBottomMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultBottomMaterialAsset"); diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h index 95cffeab0..497dd14f8 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h @@ -160,13 +160,13 @@ class GuiMeshRoadEditorCtrl : public EditTSCtrl public: DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, TopMaterial); - DECLARE_MATERIALASSET_SETGET(GuiMeshRoadEditorCtrl, TopMaterial); + DECLARE_ASSET_SETGET(GuiMeshRoadEditorCtrl, TopMaterial); DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, BottomMaterial); - DECLARE_MATERIALASSET_SETGET(GuiMeshRoadEditorCtrl, BottomMaterial); + DECLARE_ASSET_SETGET(GuiMeshRoadEditorCtrl, BottomMaterial); DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, SideMaterial); - DECLARE_MATERIALASSET_SETGET(GuiMeshRoadEditorCtrl, SideMaterial); + DECLARE_ASSET_SETGET(GuiMeshRoadEditorCtrl, SideMaterial); }; class GuiMeshRoadEditorUndoAction : public UndoAction diff --git a/Engine/source/environment/editors/guiRoadEditorCtrl.h b/Engine/source/environment/editors/guiRoadEditorCtrl.h index 5e076aa68..9d2c5d014 100644 --- a/Engine/source/environment/editors/guiRoadEditorCtrl.h +++ b/Engine/source/environment/editors/guiRoadEditorCtrl.h @@ -104,7 +104,7 @@ class GuiRoadEditorCtrl : public EditTSCtrl public: DECLARE_MATERIALASSET(GuiRoadEditorCtrl, Material); - DECLARE_MATERIALASSET_SETGET(GuiRoadEditorCtrl, Material); + DECLARE_ASSET_SETGET(GuiRoadEditorCtrl, Material); protected: diff --git a/Engine/source/environment/meshRoad.cpp b/Engine/source/environment/meshRoad.cpp index f27d2d84a..d3f143d88 100644 --- a/Engine/source/environment/meshRoad.cpp +++ b/Engine/source/environment/meshRoad.cpp @@ -920,9 +920,9 @@ MeshRoad::MeshRoad() mTriangleCount[i] = 0; } - INIT_MATERIALASSET(TopMaterial); - INIT_MATERIALASSET(BottomMaterial); - INIT_MATERIALASSET(SideMaterial); + INIT_ASSET(TopMaterial); + INIT_ASSET(BottomMaterial); + INIT_ASSET(SideMaterial); mSideProfile.mRoad = this; } @@ -1416,9 +1416,9 @@ U32 MeshRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream) stream->writeAffineTransform( mObjToWorld ); // Write Materials - PACK_MATERIALASSET(con, TopMaterial); - PACK_MATERIALASSET(con, BottomMaterial); - PACK_MATERIALASSET(con, SideMaterial); + PACK_ASSET(con, TopMaterial); + PACK_ASSET(con, BottomMaterial); + PACK_ASSET(con, SideMaterial); stream->write( mTextureLength ); stream->write( mBreakAngle ); @@ -1515,9 +1515,9 @@ void MeshRoad::unpackUpdate(NetConnection * con, BitStream * stream) stream->readAffineTransform(&ObjectMatrix); Parent::setTransform(ObjectMatrix); - UNPACK_MATERIALASSET(con, TopMaterial); - UNPACK_MATERIALASSET(con, BottomMaterial); - UNPACK_MATERIALASSET(con, SideMaterial); + UNPACK_ASSET(con, TopMaterial); + UNPACK_ASSET(con, BottomMaterial); + UNPACK_ASSET(con, SideMaterial); if ( isProperlyAdded() ) _initMaterial(); diff --git a/Engine/source/environment/meshRoad.h b/Engine/source/environment/meshRoad.h index 718a015cd..9fe7505b9 100644 --- a/Engine/source/environment/meshRoad.h +++ b/Engine/source/environment/meshRoad.h @@ -622,13 +622,13 @@ protected: GFXPrimitiveBufferHandle mPB[SurfaceCount]; DECLARE_MATERIALASSET(MeshRoad, TopMaterial); - DECLARE_MATERIALASSET_NET_SETGET(MeshRoad, TopMaterial, MeshRoadMask); + DECLARE_ASSET_NET_SETGET(MeshRoad, TopMaterial, MeshRoadMask); DECLARE_MATERIALASSET(MeshRoad, BottomMaterial); - DECLARE_MATERIALASSET_NET_SETGET(MeshRoad, BottomMaterial, MeshRoadMask); + DECLARE_ASSET_NET_SETGET(MeshRoad, BottomMaterial, MeshRoadMask); DECLARE_MATERIALASSET(MeshRoad, SideMaterial); - DECLARE_MATERIALASSET_NET_SETGET(MeshRoad, SideMaterial, MeshRoadMask); + DECLARE_ASSET_NET_SETGET(MeshRoad, SideMaterial, MeshRoadMask); //String mMaterialName[SurfaceCount]; SimObjectPtr mMaterial[SurfaceCount]; diff --git a/Engine/source/environment/scatterSky.cpp b/Engine/source/environment/scatterSky.cpp index cd447e56c..36ab28ecf 100644 --- a/Engine/source/environment/scatterSky.cpp +++ b/Engine/source/environment/scatterSky.cpp @@ -168,7 +168,7 @@ ScatterSky::ScatterSky() mNightCubemapName = StringTable->EmptyString(); mSunSize = 1.0f; - INIT_MATERIALASSET(MoonMat); + INIT_ASSET(MoonMat); mMoonMatInst = NULL; @@ -503,7 +503,7 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream) stream->writeFlag( mMoonEnabled ); - PACK_MATERIALASSET(con, MoonMat); + PACK_ASSET(con, MoonMat); stream->write( mMoonScale ); stream->write( mMoonTint ); @@ -617,7 +617,7 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream) mMoonEnabled = stream->readFlag(); - UNPACK_MATERIALASSET(con, MoonMat); + UNPACK_ASSET(con, MoonMat); stream->read( &mMoonScale ); stream->read( &mMoonTint ); diff --git a/Engine/source/environment/scatterSky.h b/Engine/source/environment/scatterSky.h index 2657aa6b8..0633e9e23 100644 --- a/Engine/source/environment/scatterSky.h +++ b/Engine/source/environment/scatterSky.h @@ -212,7 +212,7 @@ protected: bool mMoonEnabled; DECLARE_MATERIALASSET(ScatterSky, MoonMat); - DECLARE_MATERIALASSET_NET_SETGET(ScatterSky, MoonMat, UpdateMask); + DECLARE_ASSET_NET_SETGET(ScatterSky, MoonMat, UpdateMask); BaseMatInstance *mMoonMatInst; F32 mMoonScale; diff --git a/Engine/source/environment/skyBox.cpp b/Engine/source/environment/skyBox.cpp index 057de94aa..468ecb8dd 100644 --- a/Engine/source/environment/skyBox.cpp +++ b/Engine/source/environment/skyBox.cpp @@ -56,7 +56,7 @@ SkyBox::SkyBox() mTypeMask |= EnvironmentObjectType | StaticObjectType; mNetFlags.set(Ghostable | ScopeAlways); - INIT_MATERIALASSET(Material); + INIT_ASSET(Material); mMatInstance = NULL; mIsVBDirty = false; @@ -139,7 +139,7 @@ U32 SkyBox::packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) { U32 retMask = Parent::packUpdate( conn, mask, stream ); - PACK_MATERIALASSET(conn, Material); + PACK_ASSET(conn, Material); stream->writeFlag( mDrawBottom ); stream->write( mFogBandHeight ); @@ -152,7 +152,7 @@ void SkyBox::unpackUpdate( NetConnection *conn, BitStream *stream ) Parent::unpackUpdate( conn, stream ); StringTableEntry oldMatName = getMaterial(); - UNPACK_MATERIALASSET(conn, Material); + UNPACK_ASSET(conn, Material); if (oldMatName != getMaterial()) { _updateMaterial(); diff --git a/Engine/source/environment/skyBox.h b/Engine/source/environment/skyBox.h index 38c2b0ac7..7f2ebe494 100644 --- a/Engine/source/environment/skyBox.h +++ b/Engine/source/environment/skyBox.h @@ -102,7 +102,7 @@ protected: // Material DECLARE_MATERIALASSET(SkyBox, Material); - DECLARE_MATERIALASSET_NET_SETGET(SkyBox, Material, -1); + DECLARE_ASSET_NET_SETGET(SkyBox, Material, -1); BaseMatInstance *mMatInstance; SkyMatParams mMatParamHandle; diff --git a/Engine/source/environment/sun.cpp b/Engine/source/environment/sun.cpp index 42062a78b..47cc91070 100644 --- a/Engine/source/environment/sun.cpp +++ b/Engine/source/environment/sun.cpp @@ -90,7 +90,7 @@ Sun::Sun() mCoronaUseLightColor = true; mCoronaMatInst = NULL; - INIT_MATERIALASSET(CoronaMaterial); + INIT_ASSET(CoronaMaterial); mMatrixSet = reinterpret_cast(dMalloc_aligned(sizeof(MatrixSet), 16)); constructInPlace(mMatrixSet); @@ -240,7 +240,7 @@ U32 Sun::packUpdate(NetConnection *conn, U32 mask, BitStream *stream ) stream->writeFlag( mCoronaEnabled ); - PACK_MATERIALASSET(conn, CoronaMaterial); + PACK_ASSET(conn, CoronaMaterial); stream->write( mCoronaScale ); stream->write( mCoronaTint ); @@ -286,7 +286,7 @@ void Sun::unpackUpdate( NetConnection *conn, BitStream *stream ) mCoronaEnabled = stream->readFlag(); - UNPACK_MATERIALASSET(conn, CoronaMaterial); + UNPACK_ASSET(conn, CoronaMaterial); stream->read( &mCoronaScale ); stream->read( &mCoronaTint ); diff --git a/Engine/source/environment/sun.h b/Engine/source/environment/sun.h index 9d11c0ed1..f9d1674f8 100644 --- a/Engine/source/environment/sun.h +++ b/Engine/source/environment/sun.h @@ -79,7 +79,7 @@ protected: bool mCoronaEnabled; DECLARE_MATERIALASSET(Sun, CoronaMaterial); - DECLARE_MATERIALASSET_NET_SETGET(Sun, CoronaMaterial, UpdateMask); + DECLARE_ASSET_NET_SETGET(Sun, CoronaMaterial, UpdateMask); BaseMatInstance *mCoronaMatInst; MatrixSet *mMatrixSet; diff --git a/Engine/source/environment/waterObject.cpp b/Engine/source/environment/waterObject.cpp index dd5ea1a6f..7aba59163 100644 --- a/Engine/source/environment/waterObject.cpp +++ b/Engine/source/environment/waterObject.cpp @@ -260,9 +260,9 @@ WaterObject::WaterObject() mMatrixSet = reinterpret_cast(dMalloc_aligned(sizeof(MatrixSet), 16)); constructInPlace(mMatrixSet); - INIT_IMAGEASSET(RippleTex); - INIT_IMAGEASSET(FoamTex); - INIT_IMAGEASSET(DepthGradientTex); + INIT_ASSET(RippleTex); + INIT_ASSET(FoamTex); + INIT_ASSET(DepthGradientTex); mCubemapName = StringTable->EmptyString(); } @@ -546,9 +546,9 @@ U32 WaterObject::packUpdate( NetConnection * conn, U32 mask, BitStream *stream ) if ( stream->writeFlag( mask & TextureMask ) ) { - PACK_IMAGEASSET(conn, RippleTex); - PACK_IMAGEASSET(conn, DepthGradientTex); - PACK_IMAGEASSET(conn, FoamTex); + PACK_ASSET(conn, RippleTex); + PACK_ASSET(conn, DepthGradientTex); + PACK_ASSET(conn, FoamTex); stream->writeString( mCubemapName ); } @@ -668,9 +668,9 @@ void WaterObject::unpackUpdate( NetConnection * conn, BitStream *stream ) // TextureMask if ( stream->readFlag() ) { - UNPACK_IMAGEASSET(conn, RippleTex); - UNPACK_IMAGEASSET(conn, DepthGradientTex); - UNPACK_IMAGEASSET(conn, FoamTex); + UNPACK_ASSET(conn, RippleTex); + UNPACK_ASSET(conn, DepthGradientTex); + UNPACK_ASSET(conn, FoamTex); mCubemapName = stream->readSTString(); diff --git a/Engine/source/environment/waterObject.h b/Engine/source/environment/waterObject.h index 3c72ba21e..17d5d8428 100644 --- a/Engine/source/environment/waterObject.h +++ b/Engine/source/environment/waterObject.h @@ -273,11 +273,11 @@ protected: // Other textures DECLARE_IMAGEASSET(WaterObject, RippleTex, onRippleTexChanged, GFXStaticTextureProfile); - DECLARE_IMAGEASSET_NET_SETGET(WaterObject, RippleTex, TextureMask); + DECLARE_ASSET_NET_SETGET(WaterObject, RippleTex, TextureMask); DECLARE_IMAGEASSET(WaterObject, FoamTex, onFoamTexChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_NET_SETGET(WaterObject, FoamTex, TextureMask); + DECLARE_ASSET_NET_SETGET(WaterObject, FoamTex, TextureMask); DECLARE_IMAGEASSET(WaterObject, DepthGradientTex, onDepthGradientTexChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_NET_SETGET(WaterObject, DepthGradientTex, TextureMask); + DECLARE_ASSET_NET_SETGET(WaterObject, DepthGradientTex, TextureMask); StringTableEntry mCubemapName; diff --git a/Engine/source/forest/forestItem.cpp b/Engine/source/forest/forestItem.cpp index 11d514b34..26624abb9 100644 --- a/Engine/source/forest/forestItem.cpp +++ b/Engine/source/forest/forestItem.cpp @@ -53,7 +53,7 @@ ForestItemData::ForestItemData() mTightnessCoefficient( 0.4f ), mDampingCoefficient( 0.7f ) { - INIT_SHAPEASSET(Shape); + INIT_ASSET(Shape); } void ForestItemData::initPersistFields() @@ -164,7 +164,7 @@ void ForestItemData::packData(BitStream* stream) stream->write( localName ); - PACKDATA_SHAPEASSET(Shape); + PACKDATA_ASSET(Shape); stream->writeFlag( mCollidable ); @@ -192,7 +192,7 @@ void ForestItemData::unpackData(BitStream* stream) char readBuffer[1024]; - UNPACKDATA_SHAPEASSET(Shape); + UNPACKDATA_ASSET(Shape); mCollidable = stream->readFlag(); diff --git a/Engine/source/forest/forestItem.h b/Engine/source/forest/forestItem.h index 0c7eb0697..2ffb9f9ab 100644 --- a/Engine/source/forest/forestItem.h +++ b/Engine/source/forest/forestItem.h @@ -63,7 +63,7 @@ protected: public: DECLARE_SHAPEASSET(ForestItemData, Shape, onShapeChanged); - DECLARE_SHAPEASSET_SETGET(ForestItemData, Shape); + DECLARE_ASSET_SETGET(ForestItemData, Shape); /// This is the radius used during placement to ensure /// the element isn't crowded up against other trees. diff --git a/Engine/source/gfx/sim/cubemapData.cpp b/Engine/source/gfx/sim/cubemapData.cpp index a6833de5c..3be7cfbda 100644 --- a/Engine/source/gfx/sim/cubemapData.cpp +++ b/Engine/source/gfx/sim/cubemapData.cpp @@ -44,10 +44,10 @@ CubemapData::CubemapData() for (U32 i = 0; i < 6; i++) { - INIT_IMAGEASSET_ARRAY(CubeMapFace, i); + INIT_ASSET_ARRAY(CubeMapFace, i); } - INIT_IMAGEASSET(CubeMap); + INIT_ASSET(CubeMap); } CubemapData::~CubemapData() diff --git a/Engine/source/gfx/sim/cubemapData.h b/Engine/source/gfx/sim/cubemapData.h index 7ec2e0fb5..c33cf7021 100644 --- a/Engine/source/gfx/sim/cubemapData.h +++ b/Engine/source/gfx/sim/cubemapData.h @@ -74,7 +74,7 @@ public: protected: DECLARE_IMAGEASSET(CubemapData, CubeMap, onCubemapChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(CubemapData, CubeMap); + DECLARE_ASSET_SETGET(CubemapData, CubeMap); DECLARE_IMAGEASSET_ARRAY(CubemapData, CubeMapFace, GFXStaticTextureSRGBProfile, 6); DECLARE_IMAGEASSET_ARRAY_SETGET(CubemapData, CubeMapFace); diff --git a/Engine/source/gui/buttons/guiBitmapButtonCtrl.cpp b/Engine/source/gui/buttons/guiBitmapButtonCtrl.cpp index 91088b2a4..23c451fab 100644 --- a/Engine/source/gui/buttons/guiBitmapButtonCtrl.cpp +++ b/Engine/source/gui/buttons/guiBitmapButtonCtrl.cpp @@ -129,7 +129,7 @@ GuiBitmapButtonCtrl::GuiBitmapButtonCtrl() setExtent( 140, 30 ); mMasked = false; - INIT_IMAGEASSET(Bitmap); + INIT_ASSET(Bitmap); } //----------------------------------------------------------------------------- @@ -668,4 +668,4 @@ bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint) return Parent::pointInControl(parentCoordPoint); } -DEF_IMAGEASSET_BINDS(GuiBitmapButtonCtrl, Bitmap); +DEF_ASSET_BINDS(GuiBitmapButtonCtrl, Bitmap); diff --git a/Engine/source/gui/buttons/guiBitmapButtonCtrl.h b/Engine/source/gui/buttons/guiBitmapButtonCtrl.h index 59e7825f1..1791c563a 100644 --- a/Engine/source/gui/buttons/guiBitmapButtonCtrl.h +++ b/Engine/source/gui/buttons/guiBitmapButtonCtrl.h @@ -119,7 +119,7 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl BitmapMode mBitmapMode; DECLARE_IMAGEASSET(GuiBitmapButtonCtrl, Bitmap, onBitmapChange, GFXDefaultGUIProfile); - DECLARE_IMAGEASSET_SETGET(GuiBitmapButtonCtrl, Bitmap); + DECLARE_ASSET_SETGET(GuiBitmapButtonCtrl, Bitmap); /// alpha masking bool mMasked; diff --git a/Engine/source/gui/buttons/guiIconButtonCtrl.cpp b/Engine/source/gui/buttons/guiIconButtonCtrl.cpp index c0fb939ff..093c79cb7 100644 --- a/Engine/source/gui/buttons/guiIconButtonCtrl.cpp +++ b/Engine/source/gui/buttons/guiIconButtonCtrl.cpp @@ -85,7 +85,7 @@ ConsoleDocClass( GuiIconButtonCtrl, GuiIconButtonCtrl::GuiIconButtonCtrl() { - INIT_IMAGEASSET(Bitmap); + INIT_ASSET(Bitmap); mTextLocation = TextLocLeft; mIconLocation = IconLocLeft; mTextMargin = 4; @@ -412,4 +412,4 @@ void GuiIconButtonCtrl::renderBitmapArray(RectI &bounds, S32 state) } } -DEF_IMAGEASSET_BINDS(GuiIconButtonCtrl, Bitmap); +DEF_ASSET_BINDS(GuiIconButtonCtrl, Bitmap); diff --git a/Engine/source/gui/buttons/guiIconButtonCtrl.h b/Engine/source/gui/buttons/guiIconButtonCtrl.h index d2cf0b9bd..8196fef49 100644 --- a/Engine/source/gui/buttons/guiIconButtonCtrl.h +++ b/Engine/source/gui/buttons/guiIconButtonCtrl.h @@ -43,7 +43,7 @@ private: protected: DECLARE_IMAGEASSET(GuiIconButtonCtrl, Bitmap, onImageChanged, GFXTexturePersistentSRGBProfile); - DECLARE_IMAGEASSET_SETGET(GuiIconButtonCtrl, Bitmap); + DECLARE_ASSET_SETGET(GuiIconButtonCtrl, Bitmap); S32 mIconLocation; S32 mTextLocation; diff --git a/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp b/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp index 3f1b26f0c..f75a93d83 100644 --- a/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp +++ b/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp @@ -43,9 +43,9 @@ ConsoleDocClass( GuiToolboxButtonCtrl, //------------------------------------- GuiToolboxButtonCtrl::GuiToolboxButtonCtrl() { - INIT_IMAGEASSET(NormalBitmap); - INIT_IMAGEASSET(LoweredBitmap); - INIT_IMAGEASSET(HoverBitmap); + INIT_ASSET(NormalBitmap); + INIT_ASSET(LoweredBitmap); + INIT_ASSET(HoverBitmap); setMinExtent(Point2I(16,16)); setExtent(48, 48); @@ -193,6 +193,6 @@ void GuiToolboxButtonCtrl::renderButton(GFXTexHandle &texture, Point2I &offset, } } -DEF_IMAGEASSET_BINDS(GuiToolboxButtonCtrl, NormalBitmap); -DEF_IMAGEASSET_BINDS(GuiToolboxButtonCtrl, LoweredBitmap); -DEF_IMAGEASSET_BINDS(GuiToolboxButtonCtrl, HoverBitmap); +DEF_ASSET_BINDS(GuiToolboxButtonCtrl, NormalBitmap); +DEF_ASSET_BINDS(GuiToolboxButtonCtrl, LoweredBitmap); +DEF_ASSET_BINDS(GuiToolboxButtonCtrl, HoverBitmap); diff --git a/Engine/source/gui/buttons/guiToolboxButtonCtrl.h b/Engine/source/gui/buttons/guiToolboxButtonCtrl.h index ec2b56711..8741cdee9 100644 --- a/Engine/source/gui/buttons/guiToolboxButtonCtrl.h +++ b/Engine/source/gui/buttons/guiToolboxButtonCtrl.h @@ -40,11 +40,11 @@ private: protected: DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, NormalBitmap, onNormalImageChanged, GFXTexturePersistentSRGBProfile); - DECLARE_IMAGEASSET_SETGET(GuiToolboxButtonCtrl, NormalBitmap); + DECLARE_ASSET_SETGET(GuiToolboxButtonCtrl, NormalBitmap); DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, LoweredBitmap, onLoweredImageChanged, GFXTexturePersistentSRGBProfile); - DECLARE_IMAGEASSET_SETGET(GuiToolboxButtonCtrl, LoweredBitmap); + DECLARE_ASSET_SETGET(GuiToolboxButtonCtrl, LoweredBitmap); DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, HoverBitmap, onHoverImageChanged, GFXTexturePersistentSRGBProfile); - DECLARE_IMAGEASSET_SETGET(GuiToolboxButtonCtrl, HoverBitmap); + DECLARE_ASSET_SETGET(GuiToolboxButtonCtrl, HoverBitmap); void renderButton(GFXTexHandle &texture, Point2I &offset, const RectI& updateRect); void renderStateRect( GFXTexHandle &texture, const RectI& rect ); diff --git a/Engine/source/gui/controls/guiBitmapCtrl.cpp b/Engine/source/gui/controls/guiBitmapCtrl.cpp index 1b158d435..89e8ecbb3 100644 --- a/Engine/source/gui/controls/guiBitmapCtrl.cpp +++ b/Engine/source/gui/controls/guiBitmapCtrl.cpp @@ -60,7 +60,7 @@ GuiBitmapCtrl::GuiBitmapCtrl(void) mColor(ColorI::WHITE), mWrap( false ) { - INIT_IMAGEASSET(Bitmap); + INIT_ASSET(Bitmap); } bool GuiBitmapCtrl::setBitmapName( void *object, const char *index, const char *data ) diff --git a/Engine/source/gui/controls/guiBitmapCtrl.h b/Engine/source/gui/controls/guiBitmapCtrl.h index 05f4ca047..c5e2130dd 100644 --- a/Engine/source/gui/controls/guiBitmapCtrl.h +++ b/Engine/source/gui/controls/guiBitmapCtrl.h @@ -40,7 +40,7 @@ class GuiBitmapCtrl : public GuiControl /// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded /// from a file but rather set explicitly on the control. DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile); - DECLARE_IMAGEASSET_SETGET(GuiBitmapCtrl, Bitmap); + DECLARE_ASSET_SETGET(GuiBitmapCtrl, Bitmap); Point2I mStartPoint; ColorI mColor; diff --git a/Engine/source/gui/controls/guiMaterialCtrl.cpp b/Engine/source/gui/controls/guiMaterialCtrl.cpp index 34c0243a9..6d177767f 100644 --- a/Engine/source/gui/controls/guiMaterialCtrl.cpp +++ b/Engine/source/gui/controls/guiMaterialCtrl.cpp @@ -45,7 +45,7 @@ ConsoleDocClass( GuiMaterialCtrl, GuiMaterialCtrl::GuiMaterialCtrl() : mMaterialInst( NULL ) { - INIT_MATERIALASSET(Material); + INIT_ASSET(Material); } void GuiMaterialCtrl::initPersistFields() diff --git a/Engine/source/gui/controls/guiMaterialCtrl.h b/Engine/source/gui/controls/guiMaterialCtrl.h index bafbdf0eb..ff0b44efa 100644 --- a/Engine/source/gui/controls/guiMaterialCtrl.h +++ b/Engine/source/gui/controls/guiMaterialCtrl.h @@ -41,7 +41,7 @@ private: protected: DECLARE_MATERIALASSET(GuiMaterialCtrl, Material); - DECLARE_MATERIALASSET_SETGET(GuiMaterialCtrl, Material); + DECLARE_ASSET_SETGET(GuiMaterialCtrl, Material); BaseMatInstance *mMaterialInst; diff --git a/Engine/source/gui/controls/guiPopUpCtrl.cpp b/Engine/source/gui/controls/guiPopUpCtrl.cpp index 0cd08dfb8..47abbc17c 100644 --- a/Engine/source/gui/controls/guiPopUpCtrl.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrl.cpp @@ -278,8 +278,8 @@ GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void) mBackgroundCancel = false; // Added mReverseTextList = false; // Added - Don't reverse text list if displaying up - INIT_IMAGEASSET_ARRAY(Bitmap, 0); - INIT_IMAGEASSET_ARRAY(Bitmap, 1); + INIT_ASSET_ARRAY(Bitmap, 0); + INIT_ASSET_ARRAY(Bitmap, 1); mBitmapBounds.set(16, 16); // Added mIdMax = -1; diff --git a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp index 5cbd1e3bc..852424075 100644 --- a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp @@ -329,8 +329,8 @@ GuiPopUpMenuCtrlEx::GuiPopUpMenuCtrlEx(void) mBackgroundCancel = false; // Added mReverseTextList = false; // Added - Don't reverse text list if displaying up - INIT_IMAGEASSET_ARRAY(Bitmap, Normal); - INIT_IMAGEASSET_ARRAY(Bitmap, Depressed); + INIT_ASSET_ARRAY(Bitmap, Normal); + INIT_ASSET_ARRAY(Bitmap, Depressed); mBitmapBounds.set(16, 16); // Added mHotTrackItems = false; diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index 2011aa68b..d312c7610 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -2898,7 +2898,7 @@ static ConsoleDocFragment _sGuiControlSetExtent2( "GuiControl", // The class to place the method in; use NULL for functions. "void setExtent( Point2I p );" ); // The definition string. -DefineEngineMethod( GuiControl, setExtent, void, ( const char* extOrX, const char* y ), (""), +DefineEngineMethod( GuiControl, setExtent, void, ( const char* extOrX, const char* y ), ("", nullAsType()), "( Point2I p | int x, int y ) Set the width and height of the control.\n\n" "@hide" ) { diff --git a/Engine/source/gui/core/guiTypes.cpp b/Engine/source/gui/core/guiTypes.cpp index 59fc8b854..d4575d21a 100644 --- a/Engine/source/gui/core/guiTypes.cpp +++ b/Engine/source/gui/core/guiTypes.cpp @@ -79,7 +79,7 @@ GuiCursor::GuiCursor() mRenderOffset.set(0.0f,0.0f); mExtent.set(1,1); - INIT_IMAGEASSET(Bitmap); + INIT_ASSET(Bitmap); } GuiCursor::~GuiCursor() @@ -324,7 +324,7 @@ GuiControlProfile::GuiControlProfile(void) : mMouseOverSelected = false; // bitmap members - INIT_IMAGEASSET(Bitmap); + INIT_ASSET(Bitmap); mUseBitmapArray = false; mChildrenProfileName = NULL; diff --git a/Engine/source/gui/core/guiTypes.h b/Engine/source/gui/core/guiTypes.h index 23fa13246..c82c2fd50 100644 --- a/Engine/source/gui/core/guiTypes.h +++ b/Engine/source/gui/core/guiTypes.h @@ -345,7 +345,7 @@ private: typedef SimObject Parent; DECLARE_IMAGEASSET(GuiCursor, Bitmap, onImageChanged, GFXGuiCursorProfile); - DECLARE_IMAGEASSET_SETGET(GuiCursor, Bitmap); + DECLARE_ASSET_SETGET(GuiCursor, Bitmap); Point2I mHotSpot; Point2F mRenderOffset; @@ -555,7 +555,7 @@ public: { return mBitmap; } - DECLARE_IMAGEASSET_SETGET(GuiControlProfile, Bitmap); + DECLARE_ASSET_SETGET(GuiControlProfile, Bitmap); void onBitmapChanged() {} diff --git a/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp b/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp index 138488f05..90e940e07 100644 --- a/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp +++ b/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp @@ -87,7 +87,7 @@ DefineEngineMethod( GuiChunkedBitmapCtrl, setBitmap, void, (const char* filename GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl() { - INIT_IMAGEASSET(Bitmap); + INIT_ASSET(Bitmap); mUseVariable = false; mTile = false; diff --git a/Engine/source/gui/game/guiChunkedBitmapCtrl.h b/Engine/source/gui/game/guiChunkedBitmapCtrl.h index 037eb91f6..f5d3405b8 100644 --- a/Engine/source/gui/game/guiChunkedBitmapCtrl.h +++ b/Engine/source/gui/game/guiChunkedBitmapCtrl.h @@ -18,7 +18,7 @@ private: protected: DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile); - DECLARE_IMAGEASSET_SETGET(GuiChunkedBitmapCtrl, Bitmap); + DECLARE_ASSET_SETGET(GuiChunkedBitmapCtrl, Bitmap); bool mUseVariable; bool mTile; diff --git a/Engine/source/gui/game/guiProgressBitmapCtrl.cpp b/Engine/source/gui/game/guiProgressBitmapCtrl.cpp index 0d0baa483..0faf2a8e0 100644 --- a/Engine/source/gui/game/guiProgressBitmapCtrl.cpp +++ b/Engine/source/gui/game/guiProgressBitmapCtrl.cpp @@ -124,7 +124,7 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl() mNumberOfBitmaps(0), mDim(0) { - INIT_IMAGEASSET(Bitmap); + INIT_ASSET(Bitmap); } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/game/guiProgressBitmapCtrl.h b/Engine/source/gui/game/guiProgressBitmapCtrl.h index e391f7b72..fba8aaa3c 100644 --- a/Engine/source/gui/game/guiProgressBitmapCtrl.h +++ b/Engine/source/gui/game/guiProgressBitmapCtrl.h @@ -48,7 +48,7 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl F32 mProgress; DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile); - DECLARE_IMAGEASSET_SETGET(GuiProgressBitmapCtrl, Bitmap); + DECLARE_ASSET_SETGET(GuiProgressBitmapCtrl, Bitmap); bool mUseVariable; bool mTile; diff --git a/Engine/source/gui/worldEditor/guiMissionArea.cpp b/Engine/source/gui/worldEditor/guiMissionArea.cpp index cd9c82ac9..a17b5a4ab 100644 --- a/Engine/source/gui/worldEditor/guiMissionArea.cpp +++ b/Engine/source/gui/worldEditor/guiMissionArea.cpp @@ -59,7 +59,7 @@ ConsoleDocClass( GuiMissionAreaCtrl, GuiMissionAreaCtrl::GuiMissionAreaCtrl() { - INIT_IMAGEASSET(HandleBitmap); + INIT_ASSET(HandleBitmap); mHandleTextureSize = Point2I::Zero; mHandleTextureHalfSize = Point2F::Zero; diff --git a/Engine/source/gui/worldEditor/guiMissionArea.h b/Engine/source/gui/worldEditor/guiMissionArea.h index 885f85107..c14438ac6 100644 --- a/Engine/source/gui/worldEditor/guiMissionArea.h +++ b/Engine/source/gui/worldEditor/guiMissionArea.h @@ -64,7 +64,7 @@ protected: GFXStateBlockRef mSolidStateBlock; DECLARE_IMAGEASSET(GuiMissionAreaCtrl, HandleBitmap, onHandleBitmapChanged, GFXTexturePersistentSRGBProfile); - DECLARE_IMAGEASSET_SETGET(GuiMissionAreaCtrl, HandleBitmap); + DECLARE_ASSET_SETGET(GuiMissionAreaCtrl, HandleBitmap); Point2I mHandleTextureSize; Point2F mHandleTextureHalfSize; diff --git a/Engine/source/gui/worldEditor/worldEditor.h b/Engine/source/gui/worldEditor/worldEditor.h index dd596af74..a94fe068d 100644 --- a/Engine/source/gui/worldEditor/worldEditor.h +++ b/Engine/source/gui/worldEditor/worldEditor.h @@ -329,11 +329,11 @@ class WorldEditor : public EditTSCtrl ColorI mPopupTextColor; DECLARE_IMAGEASSET(WorldEditor, SelectHandle, onSelectHandleChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(WorldEditor, SelectHandle); + DECLARE_ASSET_SETGET(WorldEditor, SelectHandle); DECLARE_IMAGEASSET(WorldEditor, DefaultHandle, onDefaultHandleChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(WorldEditor, DefaultHandle); + DECLARE_ASSET_SETGET(WorldEditor, DefaultHandle); DECLARE_IMAGEASSET(WorldEditor, LockedHandle, onLockedHandleChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(WorldEditor, LockedHandle); + DECLARE_ASSET_SETGET(WorldEditor, LockedHandle); ColorI mObjectTextColor; bool mObjectsUseBoxCenter; diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index 7eb49ffc0..823072c4f 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -142,18 +142,18 @@ Material::Material() mAccuCoverage[i] = 0.9f; mAccuSpecular[i] = 16.0f; - INIT_IMAGEASSET_ARRAY(DiffuseMap, i); - INIT_IMAGEASSET_ARRAY(OverlayMap, i); - INIT_IMAGEASSET_ARRAY(LightMap, i); - INIT_IMAGEASSET_ARRAY(ToneMap, i); - INIT_IMAGEASSET_ARRAY(DetailMap, i); - INIT_IMAGEASSET_ARRAY(NormalMap, i); - INIT_IMAGEASSET_ARRAY(ORMConfigMap, i); - INIT_IMAGEASSET_ARRAY(RoughMap, i); - INIT_IMAGEASSET_ARRAY(AOMap, i); - INIT_IMAGEASSET_ARRAY(MetalMap, i); - INIT_IMAGEASSET_ARRAY(GlowMap, i); - INIT_IMAGEASSET_ARRAY(DetailNormalMap, i); + INIT_ASSET_ARRAY(DiffuseMap, i); + INIT_ASSET_ARRAY(OverlayMap, i); + INIT_ASSET_ARRAY(LightMap, i); + INIT_ASSET_ARRAY(ToneMap, i); + INIT_ASSET_ARRAY(DetailMap, i); + INIT_ASSET_ARRAY(NormalMap, i); + INIT_ASSET_ARRAY(ORMConfigMap, i); + INIT_ASSET_ARRAY(RoughMap, i); + INIT_ASSET_ARRAY(AOMap, i); + INIT_ASSET_ARRAY(MetalMap, i); + INIT_ASSET_ARRAY(GlowMap, i); + INIT_ASSET_ARRAY(DetailNormalMap, i); mParallaxScale[i] = 0.0f; diff --git a/Engine/source/postFx/postEffect.cpp b/Engine/source/postFx/postEffect.cpp index a9587c4aa..2f87ffa67 100644 --- a/Engine/source/postFx/postEffect.cpp +++ b/Engine/source/postFx/postEffect.cpp @@ -508,7 +508,7 @@ PostEffect::PostEffect() for (U32 i = 0; i < NumTextures; i++) { - INIT_IMAGEASSET_ARRAY(Texture, i); + INIT_ASSET_ARRAY(Texture, i); } } diff --git a/Engine/source/terrain/terrMaterial.cpp b/Engine/source/terrain/terrMaterial.cpp index 06b3b27bd..8a7683078 100644 --- a/Engine/source/terrain/terrMaterial.cpp +++ b/Engine/source/terrain/terrMaterial.cpp @@ -73,11 +73,11 @@ TerrainMaterial::TerrainMaterial() mIsSRGB(false), mInvertRoughness(false) { - INIT_IMAGEASSET(DiffuseMap); - INIT_IMAGEASSET(NormalMap); - INIT_IMAGEASSET(DetailMap); - INIT_IMAGEASSET(ORMConfigMap); - INIT_IMAGEASSET(MacroMap); + INIT_ASSET(DiffuseMap); + INIT_ASSET(NormalMap); + INIT_ASSET(DetailMap); + INIT_ASSET(ORMConfigMap); + INIT_ASSET(MacroMap); } TerrainMaterial::~TerrainMaterial() @@ -203,8 +203,8 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath ) //material.getDiffuseMap(); //returns the raw file referenced //material.getDiffuseMapAsset(); //returns the asset id //material.setDiffuseMap(%texture); //tries to set the asset and failing that attempts a flat file reference -DEF_IMAGEASSET_BINDS(TerrainMaterial, DiffuseMap); -DEF_IMAGEASSET_BINDS(TerrainMaterial, NormalMap); -DEF_IMAGEASSET_BINDS(TerrainMaterial, DetailMap); -DEF_IMAGEASSET_BINDS(TerrainMaterial, ORMConfigMap); -DEF_IMAGEASSET_BINDS(TerrainMaterial, MacroMap); +DEF_ASSET_BINDS(TerrainMaterial, DiffuseMap); +DEF_ASSET_BINDS(TerrainMaterial, NormalMap); +DEF_ASSET_BINDS(TerrainMaterial, DetailMap); +DEF_ASSET_BINDS(TerrainMaterial, ORMConfigMap); +DEF_ASSET_BINDS(TerrainMaterial, MacroMap); diff --git a/Engine/source/terrain/terrMaterial.h b/Engine/source/terrain/terrMaterial.h index daf111321..4e129ef73 100644 --- a/Engine/source/terrain/terrMaterial.h +++ b/Engine/source/terrain/terrMaterial.h @@ -43,7 +43,7 @@ protected: //AssetPtr mDiffuseAsset; DECLARE_IMAGEASSET(TerrainMaterial, DiffuseMap, onDiffuseMapChanged, GFXStaticTextureSRGBProfile); - DECLARE_IMAGEASSET_SETGET(TerrainMaterial, DiffuseMap); + DECLARE_ASSET_SETGET(TerrainMaterial, DiffuseMap); /// The size of the diffuse base map in meters /// used to generate its texture coordinates. @@ -51,11 +51,11 @@ protected: /// DECLARE_IMAGEASSET(TerrainMaterial, NormalMap, onNormalMapChanged, GFXNormalMapProfile); - DECLARE_IMAGEASSET_SETGET(TerrainMaterial, NormalMap); + DECLARE_ASSET_SETGET(TerrainMaterial, NormalMap); /// DECLARE_IMAGEASSET(TerrainMaterial, DetailMap, onDetailMapChanged, GFXStaticTextureProfile); - DECLARE_IMAGEASSET_SETGET(TerrainMaterial, DetailMap); + DECLARE_ASSET_SETGET(TerrainMaterial, DetailMap); /// The size of the detail map in meters used /// to generate the texture coordinates for the @@ -70,7 +70,7 @@ protected: /// DECLARE_IMAGEASSET(TerrainMaterial, ORMConfigMap, onORMConfigMapChanged, GFXStaticTextureProfile); - DECLARE_IMAGEASSET_SETGET(TerrainMaterial, ORMConfigMap); + DECLARE_ASSET_SETGET(TerrainMaterial, ORMConfigMap); bool mIsSRGB; bool mInvertRoughness; @@ -82,7 +82,7 @@ protected: bool mSideProjection; DECLARE_IMAGEASSET(TerrainMaterial, MacroMap, onMacroMapChanged, GFXStaticTextureProfile); - DECLARE_IMAGEASSET_SETGET(TerrainMaterial, MacroMap); + DECLARE_ASSET_SETGET(TerrainMaterial, MacroMap); F32 mMacroSize; F32 mMacroStrength; F32 mMacroDistance; From ab1b14587e322230da9261e3a00890be858198a5 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 3 Oct 2021 15:19:04 -0500 Subject: [PATCH 34/37] generic asset loader macros. currently unused --- Engine/source/T3D/assets/assetMacroHelpers.h | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Engine/source/T3D/assets/assetMacroHelpers.h b/Engine/source/T3D/assets/assetMacroHelpers.h index 42f51e8e8..ef37cd7d5 100644 --- a/Engine/source/T3D/assets/assetMacroHelpers.h +++ b/Engine/source/T3D/assets/assetMacroHelpers.h @@ -34,6 +34,18 @@ m##name##Asset = NULL;\ m##name = NULL; +//load asset into memory by looking up the ID, spew a warning if anything goes wrong +#define LOAD_ASSET(name, assetClass)\ +if (m##name##AssetId != StringTable->EmptyString())\ +{\ + S32 assetState = assetClass::getAssetById(m##name##AssetId, &m##name##Asset);\ + if (assetState == assetClass::Ok )\ + {\ + m##name##Name = StringTable->EmptyString();\ + }\ + else Con::warnf("Warning: %s::LOAD_ASSET(%s)-%s", mClassName, m##name##AssetId, assetClass::getAssetErrstrn(assetState).c_str());\ +} + // copy constructor #define CLONE_ASSET(name) \ m##name##Name = other.m##name##Name;\ @@ -134,6 +146,18 @@ DefineEngineMethod(className, set##name, bool, (const char* assetName), , assetT m##name[index] = NULL;\ } +//load asset into memory by looking up the ID, spew a warning if anything goes wrong +#define LOAD_ASSET_ARRAY(name, index, assetClass)\ +if (m##name##AssetId[index] != StringTable->EmptyString())\ +{\ + S32 assetState = assetClass::getAssetById(m##name##AssetId[index], &m##name##Asset[index]);\ + if (assetState == assetClass::Ok )\ + {\ + m##name##Name[index] = StringTable->EmptyString();\ + }\ + else Con::warnf("Warning: %s::LOAD_ASSET(%s[%d])-%s", mClassName, m##name##AssetId[index],index, assetClass::getAssetErrstrn(assetState).c_str());\ +} + // copy constructor #define CLONE_ASSET_ARRAY(name, index) \ {\ From 42d137f4a9513c395f281d849dbbf887ec9443b5 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 3 Oct 2021 15:20:08 -0500 Subject: [PATCH 35/37] DECLARE_ASSET_ARRAY_SETGET is incompatible with INITPERSISTFIELD_SOUNDASSET_ENUMED --- Engine/source/T3D/vehicles/hoverVehicle.h | 1 - Engine/source/T3D/vehicles/vehicle.h | 2 -- Engine/source/T3D/vehicles/wheeledVehicle.h | 1 - 3 files changed, 4 deletions(-) diff --git a/Engine/source/T3D/vehicles/hoverVehicle.h b/Engine/source/T3D/vehicles/hoverVehicle.h index 8e7cce79b..8f666a76a 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.h +++ b/Engine/source/T3D/vehicles/hoverVehicle.h @@ -47,7 +47,6 @@ class HoverVehicleData : public VehicleData MaxSounds }; DECLARE_SOUNDASSET_ARRAY(HoverVehicleData, HoverSounds, Sounds::MaxSounds); - DECLARE_ASSET_ARRAY_SETGET(HoverVehicleData, HoverSounds); SFXProfile* getHoverSoundProfile(U32 id) { if (mHoverSoundsAsset[id] != NULL) diff --git a/Engine/source/T3D/vehicles/vehicle.h b/Engine/source/T3D/vehicles/vehicle.h index c9a50b831..2e6440662 100644 --- a/Engine/source/T3D/vehicles/vehicle.h +++ b/Engine/source/T3D/vehicles/vehicle.h @@ -50,7 +50,6 @@ struct VehicleData : public RigidShapeData } body; DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleBodySounds, Body::Sounds::MaxSounds) - DECLARE_ASSET_ARRAY_SETGET(VehicleData, VehicleBodySounds); SFXProfile* getVehicleBodySoundProfile(U32 id) { @@ -82,7 +81,6 @@ struct VehicleData : public RigidShapeData }; DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleWaterSounds, Sounds::MaxSounds) - DECLARE_ASSET_ARRAY_SETGET(VehicleData, VehicleWaterSounds); SFXProfile* getVehicleWaterSoundProfile(U32 id) { diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.h b/Engine/source/T3D/vehicles/wheeledVehicle.h index c8759e52d..56f5997a9 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.h +++ b/Engine/source/T3D/vehicles/wheeledVehicle.h @@ -120,7 +120,6 @@ struct WheeledVehicleData: public VehicleData }; DECLARE_SOUNDASSET_ARRAY(WheeledVehicleData, WheeledVehicleSounds, Sounds::MaxSounds); - DECLARE_ASSET_ARRAY_SETGET(WheeledVehicleData, WheeledVehicleSounds); SFXProfile* getWheeledVehicleSound(U32 id) { From e468c2bf73c7d9e1aef3ec252141fdd68ff0c77a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 11 Oct 2021 14:38:14 -0500 Subject: [PATCH 36/37] add a bit of further clarity to soundasset code injectors --- Engine/source/T3D/assets/SoundAsset.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 77c1e7180..eebcf6590 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -432,7 +432,7 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ {\ m##name##Name[index] = StringTable->EmptyString();\ }\ - else Con::warnf("Warning: %s::LOAD_IMAGEASSET(%s)-%s", mClassName, m##name##AssetId[index], ImageAsset::getAssetErrstrn(assetState).c_str());\ + else Con::warnf("Warning: %s::LOAD_SOUNDASSET_ARRAY(%s[%i])-%s", mClassName, m##name##AssetId[index], index, ImageAsset::getAssetErrstrn(assetState).c_str());\ } #define assetEnumNameConcat(x,suff)(new std::string( x + std::string(#suff)))->c_str() @@ -440,11 +440,12 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ #define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \ for (U32 i = 0; i < maxValue; i++)\ {\ - const char* enumString = castConsoleTypeToString(static_cast(i));\ + const enumType itter = static_cast(i);\ + const char* enumString = castConsoleTypeToString(static_cast(itter));\ if (enumString && enumString[0])\ {\ - addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ - addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), assetText(name, asset reference.));\ + addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[itter], consoleClass), assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[itter], consoleClass), assetText(name, asset reference.));\ }\ } #pragma endregion From d9eea8e5be4f250abe2a6eb08b1a6cfa58753c76 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 11 Oct 2021 16:25:37 -0500 Subject: [PATCH 37/37] make gcc happy --- Engine/source/T3D/assets/SoundAsset.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index eebcf6590..d320986b9 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -444,8 +444,8 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ const char* enumString = castConsoleTypeToString(static_cast(itter));\ if (enumString && enumString[0])\ {\ - addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[itter], consoleClass), assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ - addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[itter], consoleClass), assetText(name, asset reference.));\ + addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[0], consoleClass) + sizeof(m##name##Name[0])*i, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ + addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[0], consoleClass) + sizeof(m##name##AssetId[0])*i, assetText(name, asset reference.));\ }\ } #pragma endregion