SoundAsset Refactor

This commit is contained in:
marauder2k7 2025-12-12 12:27:33 +00:00
parent 9f29bee45f
commit da40838560
61 changed files with 1333 additions and 1828 deletions

View file

@ -59,33 +59,52 @@
IMPLEMENT_CONOBJECT(SoundAsset); IMPLEMENT_CONOBJECT(SoundAsset);
ConsoleType(SoundAssetPtr, TypeSoundAssetPtr, const char*, ASSET_ID_FIELD_PREFIX)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// REFACTOR
//-----------------------------------------------------------------------------
IMPLEMENT_STRUCT(AssetPtr<SoundAsset>, AssetPtrSoundAsset, , "")
END_IMPLEMENT_STRUCT
ConsoleType(SoundAssetPtr, TypeSoundAssetPtr, AssetPtr<SoundAsset>, ASSET_ID_FIELD_PREFIX)
ConsoleGetType(TypeSoundAssetPtr) ConsoleGetType(TypeSoundAssetPtr)
{ {
// Fetch asset Id. // Fetch asset Id.
return *((const char**)(dptr)); return (*((AssetPtr<SoundAsset>*)dptr)).getAssetId();
} }
//-----------------------------------------------------------------------------
ConsoleSetType(TypeSoundAssetPtr) ConsoleSetType(TypeSoundAssetPtr)
{ {
// Was a single argument specified? // Was a single argument specified?
if (argc == 1) if (argc == 1)
{ {
// Yes, so fetch field value. // Yes, so fetch field value.
*((const char**)dptr) = StringTable->insert(argv[0]); const char* pFieldValue = argv[0];
// Fetch asset pointer.
AssetPtr<SoundAsset>* pAssetPtr = dynamic_cast<AssetPtr<SoundAsset>*>((AssetPtrBase*)(dptr));
// Is the asset pointer the correct type?
if (pAssetPtr == NULL)
{
Con::warnf("(TypeSoundAssetPtrRefactor) - Failed to set asset Id '%d'.", pFieldValue);
return;
}
// Set asset.
pAssetPtr->setAssetId(pFieldValue);
return; return;
} }
// Warn. // Warn.
Con::warnf("(TypeSoundAssetPtr) - Cannot set multiple args to a single asset."); Con::warnf("(TypeSoundAssetPtrRefactor) - Cannot set multiple args to a single asset.");
} }
//-----------------------------------------------------------------------------
// REFACTOR END
//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ConsoleType(assetIdString, TypeSoundAssetId, const char*, ASSET_ID_FIELD_PREFIX) ConsoleType(assetIdString, TypeSoundAssetId, const char*, ASSET_ID_FIELD_PREFIX)
@ -122,7 +141,6 @@ const String SoundAsset::mErrCodeStrings[] =
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SoundAsset::SoundAsset() SoundAsset::SoundAsset()
: AssetBase()
{ {
dMemset(mPlaylist.mSlots.mReplayMode, 0, sizeof(mPlaylist.mSlots.mReplayMode)); dMemset(mPlaylist.mSlots.mReplayMode, 0, sizeof(mPlaylist.mSlots.mReplayMode));
dMemset(mPlaylist.mSlots.mTransitionIn, 0, sizeof(mPlaylist.mSlots.mTransitionIn)); dMemset(mPlaylist.mSlots.mTransitionIn, 0, sizeof(mPlaylist.mSlots.mTransitionIn));
@ -135,6 +153,7 @@ SoundAsset::SoundAsset()
{ {
mSoundFile[i] = StringTable->EmptyString(); mSoundFile[i] = StringTable->EmptyString();
mSoundPath[i] = StringTable->EmptyString(); mSoundPath[i] = StringTable->EmptyString();
mSoundResource[i] = NULL;
mPlaylist.mSlots.mTransitionOut[i] = SFXPlayList::TRANSITION_Wait; mPlaylist.mSlots.mTransitionOut[i] = SFXPlayList::TRANSITION_Wait;
mPlaylist.mSlots.mVolumeScale.mValue[i] = 1.f; mPlaylist.mSlots.mVolumeScale.mValue[i] = 1.f;
@ -173,7 +192,8 @@ SoundAsset::SoundAsset()
mProfileDesc.mPriority = 1.0f; mProfileDesc.mPriority = 1.0f;
mProfileDesc.mSourceGroup = NULL; mProfileDesc.mSourceGroup = NULL;
mProfileDesc.mFadeInEase = EaseF(); mProfileDesc.mFadeInEase = EaseF();
mProfileDesc.mReverb = SFXSoundReverbProperties(); mProfileDesc.mSourceGroup = dynamic_cast<SFXSource*>(Sim::findObject("AudioChannelMaster"));
dMemset(mProfileDesc.mParameters, 0, sizeof(mProfileDesc.mParameters)); dMemset(mProfileDesc.mParameters, 0, sizeof(mProfileDesc.mParameters));
mIsPlaylist = false; mIsPlaylist = false;
@ -183,21 +203,13 @@ SoundAsset::SoundAsset()
mPlaylist.mLoopMode = SFXPlayList::LOOP_All; mPlaylist.mLoopMode = SFXPlayList::LOOP_All;
mPlaylist.mActiveSlots = 1; mPlaylist.mActiveSlots = 1;
mResolvedTrack = NULL;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SoundAsset::~SoundAsset() SoundAsset::~SoundAsset()
{ {
for (U32 i = 0; i < SFXPlayList::NUM_SLOTS; i++)
{
if(mSFXProfile[i].isProperlyAdded() && !mSFXProfile[i].isDeleted())
mSFXProfile[i].unregisterObject();
}
if (mPlaylist.isProperlyAdded() && !mPlaylist.isDeleted())
mPlaylist.unregisterObject();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -323,15 +335,37 @@ void SoundAsset::initPersistFields()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void SoundAsset::onRemove()
{
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; i++)
{
if (mSoundFile[i] == StringTable->EmptyString())
break;
Torque::FS::RemoveChangeNotification(mSoundFile[i], this, &SoundAsset::_onResourceChanged);
}
Parent::onRemove();
}
void SoundAsset::inspectPostApply()
{
Parent::inspectPostApply();
refreshAsset();
}
void SoundAsset::copyTo(SimObject* object) void SoundAsset::copyTo(SimObject* object)
{ {
// Call to parent. // Call to parent.
Parent::copyTo(object); Parent::copyTo(object);
} }
void SoundAsset::initializeAsset(void) void SoundAsset::initializeAsset(void)
{ {
Parent::initializeAsset(); Parent::initializeAsset();
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; i++) for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; i++)
{ {
if (i == 0 && mSoundFile[i] == StringTable->EmptyString()) if (i == 0 && mSoundFile[i] == StringTable->EmptyString())
@ -340,10 +374,12 @@ void SoundAsset::initializeAsset(void)
if (mSoundFile[i] == StringTable->EmptyString()) if (mSoundFile[i] == StringTable->EmptyString())
break; break;
mSoundPath[i] = getOwned() ? expandAssetFilePath(mSoundFile[i]) : mSoundPath[i]; mSoundFile[i] = expandAssetFilePath(mSoundFile[i]);
if (!Torque::FS::IsFile(mSoundPath[i])) if (getOwned())
Con::errorf("SoundAsset::initializeAsset (%s)[%d] could not find %s!", getAssetName(), i, mSoundPath[i]); Torque::FS::AddChangeNotification(mSoundFile[i], this, &SoundAsset::_onResourceChanged);
} }
populateSFXTrack();
} }
void SoundAsset::_onResourceChanged(const Torque::Path &path) void SoundAsset::_onResourceChanged(const Torque::Path &path)
@ -354,129 +390,44 @@ void SoundAsset::_onResourceChanged(const Torque::Path &path)
if (path != Torque::Path(mSoundPath[i])) if (path != Torque::Path(mSoundPath[i]))
return; return;
} }
refreshAsset(); refreshAsset();
} }
void SoundAsset::onAssetRefresh(void) void SoundAsset::onAssetRefresh(void)
{ {
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; i++) if (!isProperlyAdded())
{ return;
if (i == 0 && mSoundFile[i] == StringTable->EmptyString())
return;
if (mSoundFile[i] == StringTable->EmptyString()) Parent::onAssetRefresh();
break;
mSoundPath[i] = getOwned() ? expandAssetFilePath(mSoundFile[i]) : mSoundPath[i];
}
populateSFXTrack();
} }
U32 SoundAsset::load() U32 SoundAsset::load()
{ {
if (mLoadedState == AssetErrCode::Ok) return mLoadedState; if (mLoadedState == AssetErrCode::Ok)
return mLoadedState;
// find out how many active slots we have. if (!mResolvedTrack)
U32 numSlots = 0;
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; i++)
{ {
if (i == 0 && mSoundPath[i] == StringTable->EmptyString()) if (mIsPlaylist)
return false;
if (mSoundPath[i] == StringTable->EmptyString())
break;
numSlots++;
}
if (mProfileDesc.mSourceGroup == NULL)
mProfileDesc.mSourceGroup = dynamic_cast<SFXSource*>(Sim::findObject("AudioChannelMaster"));
if (numSlots > 1)
{
mIsPlaylist = true;
for (U32 i = 0; i < numSlots; i++)
{ {
if (mSoundPath[i]) mResolvedTrack = buildPlaylist();
{ }
if (!Torque::FS::IsFile(mSoundPath[i])) else
{ {
Con::errorf("SoundAsset::initializeAsset: Attempted to load file %s but it was not valid!", mSoundFile[i]); mResolvedTrack = buildProfile();
mLoadedState = BadFileReference;
mSFXProfile[i].setDescription(NULL);
mSFXProfile[i].setSoundFileName(StringTable->insert(StringTable->EmptyString()));
mSFXProfile[i].setPreload(false);
return mLoadedState;
}
else
{
SFXProfile* trackProfile = new SFXProfile();
trackProfile->setDescription(&mProfileDesc);
trackProfile->setSoundFileName(mSoundPath[i]);
trackProfile->setPreload(mPreload);
mSFXProfile[i] = *trackProfile;
mSFXProfile[i].registerObject(String::ToString("%s_profile_track%d", getAssetName()).c_str());
mPlaylist.mSlots.mTrack[i] = trackProfile;
}
}
} }
mPlaylist.setDescription(&mProfileDesc); mResolvedTrack->registerObject(String::ToString("%s_profile_track", getAssetName()).c_str());
mPlaylist.registerObject(String::ToString("%s_playlist", getAssetName()).c_str());
}
else
{
if (mSoundPath[0])
{
if (!Torque::FS::IsFile(mSoundPath[0]))
{
Con::errorf("SoundAsset::initializeAsset: Attempted to load file %s but it was not valid!", mSoundFile[0]);
mLoadedState = BadFileReference;
mSFXProfile[0].setDescription(NULL);
mSFXProfile[0].setSoundFileName(StringTable->insert(StringTable->EmptyString()));
mSFXProfile[0].setPreload(false);
return mLoadedState;
}
else
{
mSFXProfile[0].setDescription(&mProfileDesc);
mSFXProfile[0].setSoundFileName(mSoundPath[0]);
mSFXProfile[0].setPreload(mPreload);
mSFXProfile[0].registerObject(String::ToString("%s_profile", getAssetName()).c_str());
}
}
} }
mChangeSignal.trigger();
mLoadedState = Ok; mLoadedState = Ok;
return mLoadedState; return mLoadedState;
} }
bool SoundAsset::_setSoundFile(void* object, const char* index, const char* data) StringTableEntry SoundAsset::getAssetIdByFilename(StringTableEntry fileName)
{
SoundAsset* pData = static_cast<SoundAsset*>(object);
U32 id = 0;
if (index)
id = dAtoui(index);
// Update.
pData->mSoundFile[id] = StringTable->insert(data, true);
if (pData->mSoundFile[id] == StringTable->EmptyString())
pData->mSoundPath[id] = StringTable->EmptyString();
// Refresh the asset.
pData->refreshAsset();
return true;
}
StringTableEntry SoundAsset::getAssetIdByFileName(StringTableEntry fileName)
{ {
if (fileName == StringTable->EmptyString()) if (fileName == StringTable->EmptyString())
return StringTable->EmptyString(); return StringTable->EmptyString();
@ -519,7 +470,7 @@ U32 SoundAsset::getAssetById(StringTableEntry assetId, AssetPtr<SoundAsset>* sou
} }
} }
U32 SoundAsset::getAssetByFileName(StringTableEntry fileName, AssetPtr<SoundAsset>* soundAsset) U32 SoundAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<SoundAsset>* soundAsset)
{ {
AssetQuery query; AssetQuery query;
U32 foundAssetcount = AssetDatabase.findAssetType(&query, "SoundAsset"); U32 foundAssetcount = AssetDatabase.findAssetType(&query, "SoundAsset");
@ -548,6 +499,123 @@ U32 SoundAsset::getAssetByFileName(StringTableEntry fileName, AssetPtr<SoundAsse
return AssetErrCode::Failed; return AssetErrCode::Failed;
} }
SFXProfile* SoundAsset::buildProfile()
{
SFXProfile* profile = new SFXProfile(&mProfileDesc, mSoundFile[0], mPreload);
mSoundResource[0] = profile->getResource();
return profile;
}
//-----------------------------------------------------------------------------
// BUILD PLAYLIST
//-----------------------------------------------------------------------------
SFXPlayList* SoundAsset::buildPlaylist()
{
SFXPlayList* pl = new SFXPlayList();
pl->mRandomMode = mPlaylist.mRandomMode;
pl->mLoopMode = mPlaylist.mLoopMode;
pl->mNumSlotsToPlay = mPlaylist.mNumSlotsToPlay;
pl->mTrace = mPlaylist.mTrace;
pl->mSlots = mPlaylist.mSlots;
// Build child tracks for each valid slot
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; ++i)
{
if (mSoundFile[i] == StringTable->EmptyString())
continue;
// Build child SFXProfile
SFXProfile* child = new SFXProfile(&mProfileDesc, mSoundFile[i], mPreload);
mSoundResource[i] = child->getResource();
pl->mSlots.mTrack[i] = child;
}
return pl;
}
void SoundAsset::populateSFXTrack(void)
{
U32 count = 0;
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; ++i)
if (mSoundFile[i] != StringTable->EmptyString() && Torque::FS::IsFile(mSoundFile[i]))
++count;
mIsPlaylist = (count > 1);
if (mResolvedTrack)
{
if (mResolvedTrack->isProperlyAdded() && !mResolvedTrack->isDeleted())
{
// Track will be referenced through simobjectptr
mResolvedTrack->deleteObject();
}
}
mResolvedTrack = NULL;
// reset loaded state.
mLoadedState = AssetErrCode::NotLoaded;
}
void SoundAsset::setSoundFile(StringTableEntry pSoundFile, U32 slot)
{
AssertFatal(pSoundFile != NULL, "Cannot use a NULL sound file.");
pSoundFile = StringTable->insert(pSoundFile);
if (pSoundFile == mSoundFile[slot])
return;
mSoundFile[slot] = getOwned() ? expandAssetFilePath(pSoundFile) : StringTable->insert(pSoundFile);;
refreshAsset();
}
void SoundAsset::onTamlPreWrite(void)
{
// Call parent.
Parent::onTamlPreWrite();
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; i++)
{
if (mSoundFile[i] == StringTable->EmptyString())
break;
mSoundFile[i] = collapseAssetFilePath(mSoundFile[i]);
}
}
void SoundAsset::onTamlPostWrite(void)
{
for (U32 i = 0; i < SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; i++)
{
if (mSoundFile[i] == StringTable->EmptyString())
break;
mSoundFile[i] = expandAssetFilePath(mSoundFile[i]);
}
}
void SoundAsset::onTamlCustomWrite(TamlCustomNodes& customNodes)
{
// Debug Profiling.
PROFILE_SCOPE(SoundAsset_OnTamlCustomWrite);
// Call parent.
Parent::onTamlCustomRead(customNodes);
}
void SoundAsset::onTamlCustomRead(const TamlCustomNodes& customNodes)
{
// Debug Profiling.
PROFILE_SCOPE(SoundAsset_OnTamlCustomRead);
// Call parent.
Parent::onTamlCustomRead(customNodes);
}
DefineEngineMethod(SoundAsset, getSoundPath, const char*, (), , "") DefineEngineMethod(SoundAsset, getSoundPath, const char*, (), , "")
{ {
return object->getSoundPath(); return object->getSoundPath();
@ -581,7 +649,7 @@ DefineEngineStaticMethod(SoundAsset, getAssetIdByFilename, const char*, (const c
"Queries the Asset Database to see if any asset exists that is associated with the provided file path.\n" "Queries the Asset Database to see if any asset exists that is associated with the provided file path.\n"
"@return The AssetId of the associated asset, if any.") "@return The AssetId of the associated asset, if any.")
{ {
return SoundAsset::getAssetIdByFileName(StringTable->insert(filePath)); return SoundAsset::getAssetIdByFilename(StringTable->insert(filePath));
} }
IMPLEMENT_CONOBJECT(GuiInspectorTypeSoundAssetPtr); IMPLEMENT_CONOBJECT(GuiInspectorTypeSoundAssetPtr);

View file

@ -87,16 +87,7 @@ class SoundAsset : public AssetBase
typedef AssetPtr<SoundAsset> ConcreteAssetPtr; typedef AssetPtr<SoundAsset> ConcreteAssetPtr;
protected: protected:
StringTableEntry mSoundFile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
StringTableEntry mSoundPath[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
SFXProfile mSFXProfile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
SFXDescription mProfileDesc;
SFXPlayList mPlaylist;
// subtitles
StringTableEntry mSubtitleString;
bool mPreload;
bool mIsPlaylist;
//SFXPlayList::SlotData mSlots; //SFXPlayList::SlotData mSlots;
/*These will be needed in the refactor! /*These will be needed in the refactor!
@ -121,9 +112,6 @@ protected:
F32 mPriority; F32 mPriority;
*/ */
typedef Signal<void()> SoundAssetChanged;
SoundAssetChanged mChangeSignal;
public: public:
enum SoundAssetErrCode enum SoundAssetErrCode
{ {
@ -142,179 +130,151 @@ public:
if (errCode > SoundAssetErrCode::Extended) return "undefined error"; if (errCode > SoundAssetErrCode::Extended) return "undefined error";
return mErrCodeStrings[errCode - Parent::Extended]; return mErrCodeStrings[errCode - Parent::Extended];
}; };
private:
StringTableEntry mSoundFile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
StringTableEntry mSoundPath[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
Resource<SFXResource> mSoundResource[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
SFXDescription mProfileDesc;
SFXPlayList mPlaylist;
// subtitles
StringTableEntry mSubtitleString;
bool mPreload;
bool mIsPlaylist;
SFXTrack* mResolvedTrack;
public:
SoundAsset(); SoundAsset();
virtual ~SoundAsset(); virtual ~SoundAsset();
/// Engine. /// Engine.
static void initPersistFields(); static void initPersistFields();
void onRemove() override;
void inspectPostApply() override;
void copyTo(SimObject* object) override; void copyTo(SimObject* object) override;
//SFXResource* getSound() { return mSoundResource; } //SFXResource* getSound() { return mSoundResource; }
Resource<SFXResource> getSoundResource(const U32 slotId = 0) { load(); return mSFXProfile[slotId].getResource(); } Resource<SFXResource> getSoundResource(const U32 slotId = 0) { load(); return mSoundResource[slotId]; }
/// Declare Console Object. /// Declare Console Object.
DECLARE_CONOBJECT(SoundAsset); DECLARE_CONOBJECT(SoundAsset);
static bool _setSoundFile(void* object, const char* index, const char* data); // asset Base load
U32 load() override; U32 load() override;
inline StringTableEntry getSoundPath(const U32 slotId = 0) const { return mSoundPath[slotId]; };
SFXProfile* getSfxProfile(const U32 slotId = 0) { return &mSFXProfile[slotId]; } void setSoundFile(StringTableEntry pSoundFile, U32 slot = 0);
SFXPlayList* getSfxPlaylist() { return &mPlaylist; } inline StringTableEntry getSoundFile(U32 slot = 0) { return mSoundFile[slot]; }
SFXTrack* getSFXTrack() { load(); return mIsPlaylist ? dynamic_cast<SFXTrack*>(&mPlaylist) : dynamic_cast<SFXTrack*>(&mSFXProfile[0]); } inline StringTableEntry getRelativeSoundFile(U32 slot = 0) { return collapseAssetFilePath(mSoundFile[slot]); }
inline StringTableEntry getSoundPath(const U32 slot = 0) const { return mSoundPath[slot]; };
SFXTrack* getSFXTrack() { load(); return mResolvedTrack; }
SFXDescription* getSfxDescription() { return &mProfileDesc; } SFXDescription* getSfxDescription() { return &mProfileDesc; }
bool isPlaylist(){ return mIsPlaylist; } bool isPlaylist(){ return mIsPlaylist; }
bool isLoop() { return mProfileDesc.mIsLooping; } bool isLoop() { return mProfileDesc.mIsLooping; }
bool is3D() { return mProfileDesc.mIs3D; } bool is3D() { return mProfileDesc.mIs3D; }
static StringTableEntry getAssetIdByFileName(StringTableEntry fileName); static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
static U32 getAssetById(StringTableEntry assetId, AssetPtr<SoundAsset>* materialAsset); static U32 getAssetById(StringTableEntry assetId, AssetPtr<SoundAsset>* materialAsset);
static U32 getAssetByFileName(StringTableEntry fileName, AssetPtr<SoundAsset>* matAsset); static U32 getAssetByFilename(StringTableEntry fileName, AssetPtr<SoundAsset>* matAsset);
SFXProfile* buildProfile();
SFXPlayList* buildPlaylist();
void populateSFXTrack(void);
protected: protected:
void initializeAsset(void) override; // Asset Base callback
void _onResourceChanged(const Torque::Path & path); void initializeAsset(void) override;
void onAssetRefresh(void) override; void _onResourceChanged(const Torque::Path & path);
void onAssetRefresh(void) override;
/// Taml callbacks.
void onTamlPreWrite(void) override;
void onTamlPostWrite(void) override;
void onTamlCustomWrite(TamlCustomNodes& customNodes) override;
void onTamlCustomRead(const TamlCustomNodes& customNodes) override;
protected:
static bool _setSoundFile(void* obj, const char* index, const char* data) { U32 idx = 0; if (index) idx = dAtoi(index); static_cast<SoundAsset*>(obj)->setSoundFile(data, idx); return false; }
}; };
DefineConsoleType(TypeSoundAssetPtr, SoundAsset) DECLARE_STRUCT(AssetPtr<SoundAsset>)
DefineConsoleType(TypeSoundAssetPtr, AssetPtr<SoundAsset>)
DefineConsoleType(TypeSoundAssetId, String) DefineConsoleType(TypeSoundAssetId, String)
#pragma region Singular Asset Macros #pragma region Singular Asset Macros
//Singular assets #define DECLARE_SOUNDASSET(className, name) \
/// <Summary> private: \
/// Declares a sound asset AssetPtr<SoundAsset> m##name##Asset; \
/// This establishes the assetId, asset and legacy filepath fields, along with supplemental getter and setter functions StringTableEntry m##name##File = StringTable->EmptyString(); \
/// </Summary> public: \
#define DECLARE_SOUNDASSET(className, name) public: \ void _set##name(StringTableEntry _in){ \
Resource<SFXResource> m##name;\ if(m##name##Asset.getAssetId() == _in) \
StringTableEntry m##name##Name; \ return; \
StringTableEntry m##name##AssetId;\ if(get##name##File() == _in) \
AssetPtr<SoundAsset> m##name##Asset = NULL;\ return; \
SFXTrack* m##name##Profile = NULL;\ if(_in == NULL || !String::compare(_in,StringTable->EmptyString())) \
SFXDescription* m##name##Desc = NULL;\ { \
SimObjectId m##name##SFXId = 0;\ m##name##Asset = NULL; \
public: \ m##name##File = ""; \
const StringTableEntry get##name##File() const { return m##name##Name; }\ return; \
void set##name##File(const FileName &_in) { m##name##Name = StringTable->insert(_in.c_str());}\ } \
const AssetPtr<SoundAsset> & get##name##Asset() const { return m##name##Asset; }\ if(!AssetDatabase.isDeclaredAsset(_in)) \
void set##name##Asset(const AssetPtr<SoundAsset> &_in) { m##name##Asset = _in;}\ { \
\ StringTableEntry soundAssetId = StringTable->EmptyString(); \
bool _set##name(StringTableEntry _in)\ AssetQuery query; \
{\ S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
if(m##name##AssetId != _in || m##name##Name != _in)\ if (foundAssetcount != 0) \
{\ { \
if (_in == NULL || !String::compare(_in,StringTable->EmptyString()))\ soundAssetId = query.mAssetList[0]; \
{\ } \
m##name##Name = StringTable->EmptyString();\ else if(Torque::FS::IsFile(_in)) \
m##name##AssetId = StringTable->EmptyString();\ { \
m##name##Asset = NULL;\ soundAssetId = SoundAsset::getAssetIdByFilename(_in); \
m##name = NULL;\ if (soundAssetId == StringTable->EmptyString()) \
return true;\ { \
}\ SoundAsset* privateSound = new SoundAsset(); \
\ privateSound->setSoundFile(_in); \
if (AssetDatabase.isDeclaredAsset(_in))\ soundAssetId = AssetDatabase.addPrivateAsset(privateSound); \
{\ } \
m##name##AssetId = _in;\ } \
\ else \
U32 assetState = SoundAsset::getAssetById(m##name##AssetId, &m##name##Asset);\ { \
\ Con::warnf("%s::%s: Could not find asset for: %s, there is no fallback for sound assets.", #className, #name, _in); \
if (SoundAsset::Ok == assetState)\ soundAssetId = StringTable->EmptyString(); \
{\ } \
m##name##Name = StringTable->EmptyString();\ m##name##Asset = soundAssetId; \
}\ m##name##File = _in; \
}\ } \
else\ else \
{\ { \
StringTableEntry assetId = SoundAsset::getAssetIdByFileName(_in);\ m##name##Asset = _in; \
if (assetId != StringTable->EmptyString())\ m##name##File = get##name##File(); \
{\ } \
m##name##AssetId = assetId;\ }; \
if(SoundAsset::getAssetById(m##name##AssetId, &m##name##Asset) == SoundAsset::Ok)\ \
{\ inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
m##name##Name = StringTable->EmptyString();\ AssetPtr<SoundAsset> get##name##Asset(void) { return m##name##Asset; } \
}\ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false;} \
}\ StringTableEntry get##name##File(){ return m##name##Asset.notNull() ? m##name##Asset->getSoundFile() : ""; } \
else\
{\
m##name##Name = _in;\
m##name##AssetId = StringTable->EmptyString();\
m##name##Asset = NULL;\
}\
}\
}\
if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull())\
{\
m##name = m##name##Asset->getSoundResource();\
}\
else\
{\
m##name = NULL;\
}\
if(get##name() == StringTable->EmptyString())\
return true;\
\
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());\
return false; \
}\
else if (!m##name && (m##name##Name != StringTable->EmptyString() && !Sim::findObject(m##name##Name)))\
{\
Con::errorf("%s(%s)::_set%s() - Couldn't load sound \"%s\"", macroText(className), getName(), macroText(name), _in);\
return false;\
}\
return true;\
}\
\
const StringTableEntry get##name() const\
{\
if (m##name##Asset && (m##name##Asset->getSoundPath() != StringTable->EmptyString()))\
return m##name##Asset->getSoundPath();\
else if (m##name##AssetId != StringTable->EmptyString())\
return m##name##AssetId;\
else if (m##name##Name != StringTable->EmptyString())\
return StringTable->insert(m##name##Name);\
else\
return StringTable->EmptyString();\
}\
Resource<SFXResource> get##name##Resource() \
{\
return m##name;\
}\
SFXTrack* get##name##Profile()\
{\
if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull()){\
m##name##Profile = m##name##Asset->getSFXTrack(); \
return m##name##Profile;\
}\
return NULL;\
}\
SFXDescription* get##name##Description()\ SFXDescription* get##name##Description()\
{\ {\
if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull()){\ if (m##name##Asset.notNull())\
m##name##Desc = m##name##Asset->getSfxDescription();\ return m##name##Asset->getSfxDescription();\
return m##name##Desc;}\
return NULL;\ return NULL;\
}\ }\
bool is##name##Valid() { return (get##name() != StringTable->EmptyString() && m##name##Asset && m##name##Asset->getStatus() == AssetBase::Ok); } SimObjectPtr<SFXTrack> get##name##SFXTrack(){ return m##name##Asset.notNull() ? m##name##Asset->getSFXTrack() : NULL; }
#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS #define INITPERSISTFIELD_SOUNDASSET(name, consoleClass, docs) \
addProtectedField(assetText(name, Asset), TypeSoundAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.)); \
#define INITPERSISTFIELD_SOUNDASSET(name, consoleClass, docs) \ addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.));
addProtectedField(assetText(name, File), TypeSoundFilename, Offset(m##name##Name, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs)); \
addProtectedField(assetText(name, Asset), TypeSoundAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));
#else
#define INITPERSISTFIELD_SOUNDASSET(name, consoleClass, docs) \
addProtectedField(assetText(name, File), TypeSoundFilename, Offset(m##name##Name, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
addProtectedField(assetText(name, Asset), TypeSoundAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));
#endif // TORQUE_SHOW_LEGACY_FILE_FIELDS
//network send - datablock //network send - datablock
#define PACKDATA_SOUNDASSET(name)\ #define PACKDATA_SOUNDASSET(name)\
@ -374,136 +334,74 @@ public: \
m##name##SFXId[index] = 0;\ m##name##SFXId[index] = 0;\
} }
#define DECLARE_SOUNDASSET_ARRAY(className,name,max) public: \ #define DECLARE_SOUNDASSET_ARRAY(className,name,max)\
static const U32 sm##name##Count = max;\ private: \
Resource<SFXResource> m##name[max];\ AssetPtr<SoundAsset> m##name##Asset[max]; \
StringTableEntry m##name##Name[max]; \ StringTableEntry m##name##File[max] = {StringTable->EmptyString() }; \
StringTableEntry m##name##AssetId[max];\ public: \
AssetPtr<SoundAsset> m##name##Asset[max];\ void _set##name(StringTableEntry _in, const U32& index){ \
SFXTrack* m##name##Profile[max];\ if(m##name##Asset[index].getAssetId() == _in) \
SimObjectId m##name##SFXId[max];\ return; \
public: \ if(get##name##File(index) == _in) \
const StringTableEntry get##name##File(const U32& index) const { return m##name##Name[index]; }\ return; \
void set##name##File(const FileName &_in, const U32& index) { m##name##Name[index] = StringTable->insert(_in.c_str());}\ if(_in == NULL || !String::compare(_in,StringTable->EmptyString())) \
const AssetPtr<SoundAsset> & get##name##Asset(const U32& index) const { return m##name##Asset[index]; }\ { \
void set##name##Asset(const AssetPtr<SoundAsset> &_in, const U32& index) { m##name##Asset[index] = _in;}\ m##name##Asset[index] = NULL; \
\ m##name##File[index] = ""; \
bool _set##name(StringTableEntry _in, const U32& index)\ return; \
{\ } \
if(m##name##AssetId[index] != _in || m##name##Name[index] != _in)\ if(!AssetDatabase.isDeclaredAsset(_in)) \
{\ { \
if(index >= sm##name##Count || index < 0) \ StringTableEntry soundAssetId = StringTable->EmptyString(); \
return false;\ AssetQuery query; \
if (_in == NULL || !String::compare(_in,StringTable->EmptyString()))\ S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
{\ if (foundAssetcount != 0) \
m##name##Name[index] = StringTable->EmptyString();\ { \
m##name##AssetId[index] = StringTable->EmptyString();\ soundAssetId = query.mAssetList[0]; \
m##name##Asset[index] = NULL;\ } \
m##name[index] = NULL;\ else if(Torque::FS::IsFile(_in)) \
return true;\ { \
}\ soundAssetId = SoundAsset::getAssetIdByFilename(_in); \
else if(_in[0] == '$' || _in[0] == '#')\ if (soundAssetId == StringTable->EmptyString()) \
{\ { \
m##name##Name[index] = _in;\ SoundAsset* privateSound = new SoundAsset(); \
m##name##AssetId[index] = StringTable->EmptyString();\ privateSound->setSoundFile(_in); \
m##name##Asset[index] = NULL;\ soundAssetId = AssetDatabase.addPrivateAsset(privateSound); \
m##name[index] = NULL;\ } \
return true;\ } \
}\ else \
\ { \
if (AssetDatabase.isDeclaredAsset(_in))\ Con::warnf("%s::%s: Could not find asset for: %s, there is no fallback for sound assets.", #className, #name, _in); \
{\ soundAssetId = StringTable->EmptyString(); \
m##name##AssetId[index] = _in;\ } \
\ m##name##Asset[index] = soundAssetId; \
U32 assetState = SoundAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]);\ m##name##File[index] = _in; \
\ } \
if (SoundAsset::Ok == assetState)\ else \
{\ { \
m##name##Name[index] = StringTable->EmptyString();\ m##name##Asset[index] = _in; \
}\ m##name##File[index] = get##name##File(index); \
}\ } \
else\ }; \
{\ \
StringTableEntry assetId = SoundAsset::getAssetIdByFileName(_in);\ inline StringTableEntry _get##name(const U32& index) const { return m##name##Asset[index].getAssetId(); } \
if (assetId != StringTable->EmptyString())\ AssetPtr<SoundAsset> get##name##Asset(const U32& index) { return m##name##Asset[index]; } \
{\ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false; } \
m##name##AssetId[index] = assetId;\ StringTableEntry get##name##File(const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getSoundFile() : ""; } \
if(SoundAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]) == SoundAsset::Ok)\ SFXDescription* get##name##Description(const U32& index) \
{\ { \
m##name##Name[index] = StringTable->EmptyString();\ if (m##name##Asset[index].notNull()) \
}\ return m##name##Asset[index]->getSfxDescription(); \
}\ return NULL; \
else\ } \
{\ SimObjectPtr<SFXTrack> get##name##SFXTrack(const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getSFXTrack() : NULL; }
m##name##Name[index] = _in;\
m##name##AssetId[index] = StringTable->EmptyString();\
m##name##Asset[index] = NULL;\
}\
}\
}\
if (get##name(index) != StringTable->EmptyString() && m##name##Asset[index].notNull())\
{\
m##name[index] = m##name##Asset[index]->getSoundResource();\
}\
else\
{\
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)\
{\
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[index] && (m##name##Name[index] != StringTable->EmptyString() && !Sim::findObject(m##name##Name[index])))\
{\
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& index) const\
{\
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<SFXResource> get##name##Resource(const U32& id) \
{\
if(id >= sm##name##Count || id < 0)\
return ResourceManager::get().load( "" );\
return m##name[id];\
}\
SFXTrack* get##name##Profile(const U32& id)\
{\
if (m##name##Asset[id].notNull())\
return m##name##Asset[id]->getSFXTrack(); \
return NULL;\
}\
bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id] && m##name##Asset[id]->getStatus() == AssetBase::Ok); }
#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
#define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, 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) \ #define INITPERSISTFIELD_SOUNDASSET_ARRAY(name, arraySize, consoleClass, docs) \
addProtectedField(#name, TypeSoundFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ addProtectedField(#name, TypeSoundFilename, Offset(m##name##File, 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.)); addProtectedField(assetText(name, Asset), TypeSoundAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));\
addProtectedField(assetText(name, File), TypeSoundFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
#endif
#define LOAD_SOUNDASSET_ARRAY(name, index)\ #define LOAD_SOUNDASSET_ARRAY(name, index)\
if (m##name##AssetId[index] != StringTable->EmptyString())\ if (m##name##AssetId[index] != StringTable->EmptyString())\
@ -530,8 +428,8 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
const char* enumString = castConsoleTypeToString(static_cast<enumType>(itter));\ const char* enumString = castConsoleTypeToString(static_cast<enumType>(itter));\
if (enumString && enumString[0])\ if (enumString && enumString[0])\
{\ {\
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), TypeSoundAssetPtr, Offset(m##name##Asset[0], consoleClass) + sizeof(m##name##Asset[0])*i, assetText(name, asset reference.));\
addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[0], consoleClass) + sizeof(m##name##AssetId[0])*i, assetText(name, asset reference.));\ addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##File[0], consoleClass) + sizeof(m##name##File[0])*i, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
}\ }\
} }
@ -544,5 +442,11 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
#pragma endregion #pragma endregion
#pragma region Refactor Macros
#pragma endregion
#endif // _ASSET_BASE_H_ #endif // _ASSET_BASE_H_

View file

@ -3292,30 +3292,19 @@ Torque::Path AssetImporter::importSoundAsset(AssetImportObject* assetItem)
StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str()); StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str());
String soundFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension(); String soundFileName = assetItem->filePath.getFullFileName();
String assetPath = targetPath + "/" + soundFileName; String assetPath = "@" + soundFileName;
String tamlPath = targetPath + "/" + assetName + ".asset.taml"; String tamlPath = targetPath + "/" + assetName + ".asset.taml";
String originalPath = assetItem->filePath.getFullPath().c_str(); String originalPath = assetItem->filePath.getFullPath().c_str();
char qualifiedFromFile[2048];
char qualifiedToFile[2048];
#ifndef TORQUE_SECURE_VFS
Platform::makeFullPathName(originalPath.c_str(), qualifiedFromFile, sizeof(qualifiedFromFile));
Platform::makeFullPathName(assetPath.c_str(), qualifiedToFile, sizeof(qualifiedToFile));
#else
dStrcpy(qualifiedFromFile, originalPath.c_str(), sizeof(qualifiedFromFile));
dStrcpy(qualifiedToFile, assetPath.c_str(), sizeof(qualifiedToFile));
#endif
newAsset->setAssetName(assetName); newAsset->setAssetName(assetName);
newAsset->_setSoundFile(newAsset, "0", soundFileName.c_str()); newAsset->setSoundFile(assetPath.c_str());
//If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original //If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original
//file path for reimporting support later //file path for reimporting support later
if (!isReimport && String::compare(qualifiedFromFile, qualifiedToFile) && Torque::FS::IsFile(qualifiedFromFile)) if (!isReimport)
{ {
newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile); newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, originalPath.c_str());
} }
Taml tamlWriter; Taml tamlWriter;
@ -3328,18 +3317,6 @@ Torque::Path AssetImporter::importSoundAsset(AssetImportObject* assetItem)
return ""; return "";
} }
if (!isReimport)
{
bool isInPlace = !String::compare(qualifiedFromFile, qualifiedToFile);
if (!isInPlace && !Torque::FS::CopyFile(qualifiedFromFile, qualifiedToFile, !isReimport))
{
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", assetItem->filePath.getFullPath().c_str());
activityLog.push_back(importLogBuffer);
return "";
}
}
return tamlPath; return tamlPath;
} }

View file

@ -230,9 +230,6 @@ ExplosionData::ExplosionData()
faceViewer = false; faceViewer = false;
INIT_ASSET(Sound);
//soundProfile = NULL;
particleEmitter = NULL; particleEmitter = NULL;
particleEmitterId = 0; particleEmitterId = 0;
@ -310,7 +307,7 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game
faceViewer = other.faceViewer; faceViewer = other.faceViewer;
particleDensity = other.particleDensity; particleDensity = other.particleDensity;
particleRadius = other.particleRadius; particleRadius = other.particleRadius;
CLONE_ASSET(Sound); mSoundAsset = other.mSoundAsset;
particleEmitter = other.particleEmitter; particleEmitter = other.particleEmitter;
particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr
explosionScale = other.explosionScale; explosionScale = other.explosionScale;
@ -675,8 +672,7 @@ void ExplosionData::packData(BitStream* stream)
PACKDATA_ASSET_REFACTOR(ExplosionShape); PACKDATA_ASSET_REFACTOR(ExplosionShape);
//PACKDATA_SOUNDASSET(Sound); PACKDATA_ASSET_REFACTOR(Sound);
PACKDATA_ASSET(Sound);
if (stream->writeFlag(particleEmitter)) if (stream->writeFlag(particleEmitter))
stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast); stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
@ -780,7 +776,7 @@ void ExplosionData::unpackData(BitStream* stream)
UNPACKDATA_ASSET_REFACTOR(ExplosionShape); UNPACKDATA_ASSET_REFACTOR(ExplosionShape);
UNPACKDATA_ASSET(Sound); UNPACKDATA_ASSET_REFACTOR(Sound);
if (stream->readFlag()) if (stream->readFlag())
particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
@ -886,10 +882,11 @@ bool ExplosionData::preload(bool server, String &errorStr)
if (!server) if (!server)
{ {
if (!isSoundValid()) if (!getSoundSFXTrack())
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
if (!particleEmitter && particleEmitterId != 0) if (!particleEmitter && particleEmitterId != 0)
{ {
if (Sim::findObject(particleEmitterId, particleEmitter) == false) if (Sim::findObject(particleEmitterId, particleEmitter) == false)
@ -1432,7 +1429,7 @@ bool Explosion::explode()
resetWorldBox(); resetWorldBox();
} }
SFXProfile* sound_prof = static_cast<SFXProfile*>(mDataBlock->getSoundProfile()); SFXProfile* sound_prof = static_cast<SFXProfile*>(mDataBlock->getSoundSFXTrack().getPointer());
if (sound_prof) if (sound_prof)
{ {
soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index); soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index);

View file

@ -71,7 +71,6 @@ class ExplosionData : public GameBaseData, protected AssetPtrCallback {
F32 particleRadius; F32 particleRadius;
DECLARE_SOUNDASSET(ExplosionData, Sound); DECLARE_SOUNDASSET(ExplosionData, Sound);
DECLARE_ASSET_SETGET(ExplosionData, Sound);
ParticleEmitterData* particleEmitter; ParticleEmitterData* particleEmitter;
S32 particleEmitterId; S32 particleEmitterId;

View file

@ -238,13 +238,6 @@ void LightningStrikeEvent::process(NetConnection*)
// //
LightningData::LightningData() LightningData::LightningData()
{ {
INIT_ASSET(StrikeSound);
for (S32 i = 0; i < MaxThunders; i++)
{
INIT_SOUNDASSET_ARRAY(ThunderSound, i);
}
for (S32 i = 0; i < MaxTextures; i++) for (S32 i = 0; i < MaxTextures; i++)
{ {
strikeTextureNames[i] = NULL; strikeTextureNames[i] = NULL;
@ -297,13 +290,13 @@ bool LightningData::preload(bool server, String &errorStr)
{ {
for (S32 i = 0; i < MaxThunders; i++) for (S32 i = 0; i < MaxThunders; i++)
{ {
if (!isThunderSoundValid(i)) if (!getThunderSoundSFXTrack(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
} }
if (!isStrikeSoundValid()) if (!getStrikeSoundSFXTrack())
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -332,7 +325,7 @@ void LightningData::packData(BitStream* stream)
U32 i; U32 i;
for (i = 0; i < MaxThunders; i++) for (i = 0; i < MaxThunders; i++)
{ {
PACKDATA_SOUNDASSET_ARRAY(ThunderSound, i); PACKDATA_ASSET_ARRAY(ThunderSound, i);
} }
stream->writeInt(mNumStrikeTextures, 4); stream->writeInt(mNumStrikeTextures, 4);
@ -340,7 +333,7 @@ void LightningData::packData(BitStream* stream)
for (i = 0; i < MaxTextures; i++) for (i = 0; i < MaxTextures; i++)
stream->writeString(strikeTextureNames[i]); stream->writeString(strikeTextureNames[i]);
PACKDATA_ASSET(StrikeSound); PACKDATA_ASSET_REFACTOR(StrikeSound);
} }
void LightningData::unpackData(BitStream* stream) void LightningData::unpackData(BitStream* stream)
@ -350,7 +343,7 @@ void LightningData::unpackData(BitStream* stream)
U32 i; U32 i;
for (i = 0; i < MaxThunders; i++) for (i = 0; i < MaxThunders; i++)
{ {
UNPACKDATA_SOUNDASSET_ARRAY(ThunderSound, i); UNPACKDATA_ASSET_ARRAY(ThunderSound, i);
} }
mNumStrikeTextures = stream->readInt(4); mNumStrikeTextures = stream->readInt(4);
@ -358,7 +351,7 @@ void LightningData::unpackData(BitStream* stream)
for (i = 0; i < MaxTextures; i++) for (i = 0; i < MaxTextures; i++)
strikeTextureNames[i] = stream->readSTString(); strikeTextureNames[i] = stream->readSTString();
UNPACKDATA_ASSET(StrikeSound); UNPACKDATA_ASSET_REFACTOR(StrikeSound);
} }
@ -584,7 +577,7 @@ void Lightning::scheduleThunder(Strike* newStrike)
if (t <= 0.03f) { if (t <= 0.03f) {
// If it's really close, just play it... // If it's really close, just play it...
U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1); U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1);
SFX->playOnce(mDataBlock->getThunderSoundProfile(thunder)); SFX->playOnce(mDataBlock->getThunderSoundSFXTrack(thunder));
} else { } else {
Thunder* pThunder = new Thunder; Thunder* pThunder = new Thunder;
pThunder->tRemaining = t; pThunder->tRemaining = t;
@ -651,7 +644,7 @@ void Lightning::advanceTime(F32 dt)
// Play the sound... // Play the sound...
U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1); U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1);
SFX->playOnce(mDataBlock->getThunderSoundProfile(thunder)); SFX->playOnce(mDataBlock->getThunderSoundSFXTrack(thunder));
} else { } else {
pThunderWalker = &((*pThunderWalker)->next); pThunderWalker = &((*pThunderWalker)->next);
} }
@ -735,9 +728,9 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent)
MatrixF trans(true); MatrixF trans(true);
trans.setPosition( strikePoint ); trans.setPosition( strikePoint );
if (mDataBlock->getStrikeSoundProfile()) if (mDataBlock->getStrikeSoundSFXTrack())
{ {
SFX->playOnce(mDataBlock->getStrikeSoundProfile(), &trans ); SFX->playOnce(mDataBlock->getStrikeSoundSFXTrack(), &trans );
} }
} }

View file

@ -65,10 +65,7 @@ class LightningData : public GameBaseData
public: public:
DECLARE_SOUNDASSET_ARRAY(LightningData, ThunderSound, MaxThunders); DECLARE_SOUNDASSET_ARRAY(LightningData, ThunderSound, MaxThunders);
DECLARE_ASSET_ARRAY_SETGET(LightningData, ThunderSound);
DECLARE_SOUNDASSET(LightningData, StrikeSound); DECLARE_SOUNDASSET(LightningData, StrikeSound);
DECLARE_ASSET_SETGET(LightningData, StrikeSound);
StringTableEntry strikeTextureNames[MaxTextures]; StringTableEntry strikeTextureNames[MaxTextures];

View file

@ -127,8 +127,6 @@ ConsoleDocClass( PrecipitationData,
//---------------------------------------------------------- //----------------------------------------------------------
PrecipitationData::PrecipitationData() PrecipitationData::PrecipitationData()
{ {
INIT_ASSET(Sound);
mDropShaderName = StringTable->EmptyString(); mDropShaderName = StringTable->EmptyString();
mSplashShaderName = StringTable->EmptyString(); mSplashShaderName = StringTable->EmptyString();
@ -175,7 +173,7 @@ bool PrecipitationData::preload( bool server, String &errorStr )
return false; return false;
if (!server) if (!server)
{ {
if (!isSoundValid()) if (!getSoundSFXTrack())
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -188,7 +186,7 @@ void PrecipitationData::packData(BitStream* stream)
{ {
Parent::packData(stream); Parent::packData(stream);
PACKDATA_ASSET(Sound); PACKDATA_ASSET_REFACTOR(Sound);
PACKDATA_ASSET_REFACTOR(Drop); PACKDATA_ASSET_REFACTOR(Drop);
@ -205,7 +203,7 @@ void PrecipitationData::unpackData(BitStream* stream)
{ {
Parent::unpackData(stream); Parent::unpackData(stream);
UNPACKDATA_ASSET(Sound); UNPACKDATA_ASSET_REFACTOR(Sound);
UNPACKDATA_ASSET_REFACTOR(Drop); UNPACKDATA_ASSET_REFACTOR(Drop);
@ -587,9 +585,9 @@ bool Precipitation::onNewDataBlock( GameBaseData *dptr, bool reload )
{ {
SFX_DELETE( mAmbientSound ); SFX_DELETE( mAmbientSound );
if ( mDataBlock->getSoundProfile()) if ( mDataBlock->getSoundSFXTrack())
{ {
mAmbientSound = SFX->createSource(mDataBlock->getSoundProfile(), &getTransform() ); mAmbientSound = SFX->createSource(mDataBlock->getSoundSFXTrack(), &getTransform() );
if ( mAmbientSound ) if ( mAmbientSound )
mAmbientSound->play(); mAmbientSound->play();
} }

View file

@ -47,7 +47,6 @@ class PrecipitationData : public GameBaseData
public: public:
DECLARE_SOUNDASSET(PrecipitationData, Sound); DECLARE_SOUNDASSET(PrecipitationData, Sound);
DECLARE_ASSET_SETGET(PrecipitationData, Sound);
DECLARE_IMAGEASSET(PrecipitationData, Drop, GFXStaticTextureSRGBProfile) ///< Texture for drop particles DECLARE_IMAGEASSET(PrecipitationData, Drop, GFXStaticTextureSRGBProfile) ///< Texture for drop particles

View file

@ -67,11 +67,6 @@ ConsoleDocClass( Splash,
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
SplashData::SplashData() SplashData::SplashData()
{ {
//soundProfile = NULL;
//soundProfileId = 0;
INIT_ASSET(Sound);
scale.set(1, 1, 1); scale.set(1, 1, 1);
dMemset( emitterList, 0, sizeof( emitterList ) ); dMemset( emitterList, 0, sizeof( emitterList ) );
@ -171,7 +166,7 @@ void SplashData::packData(BitStream* stream)
{ {
Parent::packData(stream); Parent::packData(stream);
PACKDATA_ASSET(Sound); PACKDATA_ASSET_REFACTOR(Sound);
mathWrite(*stream, scale); mathWrite(*stream, scale);
stream->write(delayMS); stream->write(delayMS);
@ -224,7 +219,7 @@ void SplashData::unpackData(BitStream* stream)
{ {
Parent::unpackData(stream); Parent::unpackData(stream);
UNPACKDATA_ASSET(Sound); UNPACKDATA_ASSET_REFACTOR(Sound);
mathRead(*stream, &scale); mathRead(*stream, &scale);
stream->read(&delayMS); stream->read(&delayMS);
@ -280,7 +275,7 @@ bool SplashData::preload(bool server, String &errorStr)
if (!server) if (!server)
{ {
if (!isSoundValid()) if (!getSoundSFXTrack())
{ {
Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Invalid Sound asset."); Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Invalid Sound asset.");
//return false; //return false;
@ -689,7 +684,7 @@ void Splash::spawnExplosion()
/// could just play the explosion one, but explosion could be weapon specific, /// could just play the explosion one, but explosion could be weapon specific,
/// splash sound could be liquid specific. food for thought. /// splash sound could be liquid specific. food for thought.
SFXTrack* sound_prof = mDataBlock->getSoundProfile(); SFXTrack* sound_prof = mDataBlock->getSoundSFXTrack();
if (sound_prof) if (sound_prof)
{ {
SFX->playOnce(sound_prof, &getTransform()); SFX->playOnce(sound_prof, &getTransform());

View file

@ -96,7 +96,6 @@ public:
//S32 soundProfileId; //S32 soundProfileId;
DECLARE_SOUNDASSET(SplashData, Sound); DECLARE_SOUNDASSET(SplashData, Sound);
DECLARE_ASSET_SETGET(SplashData, Sound);
ParticleEmitterData* emitterList[NUM_EMITTERS]; ParticleEmitterData* emitterList[NUM_EMITTERS];
S32 emitterIDList[NUM_EMITTERS]; S32 emitterIDList[NUM_EMITTERS];

View file

@ -217,7 +217,7 @@ U32 LevelInfo::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
mathWrite( *stream, mAmbientLightBlendCurve ); mathWrite( *stream, mAmbientLightBlendCurve );
sfxWrite( stream, mSoundAmbience ); sfxWrite( stream, mSoundAmbience );
stream->writeInt( mSoundDistanceModel, 1 ); stream->writeInt( mSoundDistanceModel, 2);
PACK_ASSET_REFACTOR(conn, AccuTexture); PACK_ASSET_REFACTOR(conn, AccuTexture);
@ -251,7 +251,7 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream)
String errorStr; String errorStr;
if( !sfxReadAndResolve( stream, &mSoundAmbience, errorStr ) ) if( !sfxReadAndResolve( stream, &mSoundAmbience, errorStr ) )
Con::errorf( "%s", errorStr.c_str() ); Con::errorf( "%s", errorStr.c_str() );
mSoundDistanceModel = ( SFXDistanceModel ) stream->readInt( 1 ); mSoundDistanceModel = ( SFXDistanceModel ) stream->readInt(2);
if( isProperlyAdded() ) if( isProperlyAdded() )
{ {

View file

@ -421,9 +421,6 @@ PlayerData::PlayerData()
boxHeadBackPercentage = 0; boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1; boxHeadFrontPercentage = 1;
for (S32 i = 0; i < MaxSounds; i++)
INIT_SOUNDASSET_ARRAY(PlayerSound, i);
footPuffEmitter = NULL; footPuffEmitter = NULL;
footPuffID = 0; footPuffID = 0;
footPuffNumParts = 15; footPuffNumParts = 15;
@ -471,7 +468,7 @@ bool PlayerData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (U32 i = 0; i < MaxSounds; ++i) for (U32 i = 0; i < MaxSounds; ++i)
{ {
if (!isPlayerSoundValid(i)) if (!getPlayerSoundSFXTrack(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -1266,8 +1263,7 @@ void PlayerData::packData(BitStream* stream)
stream->write(minImpactSpeed); stream->write(minImpactSpeed);
stream->write(minLateralImpactSpeed); stream->write(minLateralImpactSpeed);
for (U32 i = 0; i < MaxSounds; i++) PACKDATA_ASSET_ARRAY_REFACTOR(PlayerSound, MaxSounds);
PACKDATA_SOUNDASSET_ARRAY(PlayerSound, i);
mathWrite(*stream, boxSize); mathWrite(*stream, boxSize);
mathWrite(*stream, crouchBoxSize); mathWrite(*stream, crouchBoxSize);
@ -1447,8 +1443,7 @@ void PlayerData::unpackData(BitStream* stream)
stream->read(&minImpactSpeed); stream->read(&minImpactSpeed);
stream->read(&minLateralImpactSpeed); stream->read(&minLateralImpactSpeed);
for (U32 i = 0; i < MaxSounds; i++) UNPACKDATA_ASSET_ARRAY_REFACTOR(PlayerSound, MaxSounds);
UNPACKDATA_SOUNDASSET_ARRAY(PlayerSound, i);
mathRead(*stream, &boxSize); mathRead(*stream, &boxSize);
mathRead(*stream, &crouchBoxSize); mathRead(*stream, &crouchBoxSize);
@ -1895,11 +1890,11 @@ bool Player::onNewDataBlock( GameBaseData *dptr, bool reload )
SFX_DELETE( mMoveBubbleSound ); SFX_DELETE( mMoveBubbleSound );
SFX_DELETE( mWaterBreathSound ); SFX_DELETE( mWaterBreathSound );
if ( mDataBlock->getPlayerSound(PlayerData::MoveBubbles) ) if ( mDataBlock->getPlayerSoundSFXTrack(PlayerData::MoveBubbles) )
mMoveBubbleSound = SFX->createSource( mDataBlock->getPlayerSoundProfile(PlayerData::MoveBubbles) ); mMoveBubbleSound = SFX->createSource( mDataBlock->getPlayerSoundSFXTrack(PlayerData::MoveBubbles) );
if ( mDataBlock->getPlayerSound(PlayerData::WaterBreath) ) if ( mDataBlock->getPlayerSoundSFXTrack(PlayerData::WaterBreath) )
mWaterBreathSound = SFX->createSource( mDataBlock->getPlayerSoundProfile(PlayerData::WaterBreath) ); mWaterBreathSound = SFX->createSource( mDataBlock->getPlayerSoundSFXTrack(PlayerData::WaterBreath) );
} }
mObjBox.maxExtents.x = mDataBlock->boxSize.x * 0.5f; mObjBox.maxExtents.x = mDataBlock->boxSize.x * 0.5f;
@ -3223,7 +3218,7 @@ void Player::updateMove(const Move* move)
{ {
// exit-water splash sound happens for client only // exit-water splash sound happens for client only
if ( getSpeed() >= mDataBlock->exitSplashSoundVel && !isMounted() ) if ( getSpeed() >= mDataBlock->exitSplashSoundVel && !isMounted() )
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ExitWater), &getTransform() ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack(PlayerData::ExitWater), &getTransform() );
} }
} }
@ -6998,26 +6993,26 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S
// Treading water. // Treading water.
if ( mWaterCoverage < mDataBlock->footSplashHeight ) if ( mWaterCoverage < mDataBlock->footSplashHeight )
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootShallowSplash ), &footMat ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack( PlayerData::FootShallowSplash ), &footMat );
else else
{ {
if ( mWaterCoverage < 1.0 ) if ( mWaterCoverage < 1.0 )
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootWading ), &footMat ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack( PlayerData::FootWading ), &footMat );
else else
{ {
if ( triggeredLeft ) if ( triggeredLeft )
{ {
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootUnderWater ), &footMat ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack( PlayerData::FootUnderWater ), &footMat );
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootBubbles ), &footMat ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack( PlayerData::FootBubbles ), &footMat );
} }
} }
} }
} }
else if( contactMaterial && contactMaterial->getCustomFootstepSoundProfile()) else if( contactMaterial && contactMaterial->getCustomFootstepSoundSFXTrack())
{ {
// Footstep sound defined on material. // Footstep sound defined on material.
SFX->playOnce( contactMaterial->getCustomFootstepSoundProfile(), &footMat ); SFX->playOnce( contactMaterial->getCustomFootstepSoundSFXTrack(), &footMat );
} }
else else
{ {
@ -7030,7 +7025,7 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S
sound = 2; sound = 2;
if (sound>=0) if (sound>=0)
SFX->playOnce(mDataBlock->getPlayerSoundProfile(sound), &footMat); SFX->playOnce(mDataBlock->getPlayerSoundSFXTrack(sound), &footMat);
} }
} }
@ -7050,8 +7045,8 @@ void Player:: playImpactSound()
{ {
Material* material = ( rInfo.material ? dynamic_cast< Material* >( rInfo.material->getMaterial() ) : 0 ); Material* material = ( rInfo.material ? dynamic_cast< Material* >( rInfo.material->getMaterial() ) : 0 );
if( material && material->getCustomImpactSoundProfile() ) if( material && material->getCustomImpactSoundSFXTrack() )
SFX->playOnce( material->getCustomImpactSoundProfile(), &getTransform() ); SFX->playOnce( material->getCustomImpactSoundSFXTrack(), &getTransform() );
else else
{ {
S32 sound = -1; S32 sound = -1;
@ -7061,7 +7056,7 @@ void Player:: playImpactSound()
sound = 2; // Play metal; sound = 2; // Play metal;
if (sound >= 0) if (sound >= 0)
SFX->playOnce(mDataBlock->getPlayerSoundProfile(PlayerData::ImpactSoft + sound), &getTransform()); SFX->playOnce(mDataBlock->getPlayerSoundSFXTrack(PlayerData::ImpactSoft + sound), &getTransform());
} }
} }
} }
@ -7215,11 +7210,11 @@ bool Player::collidingWithWater( Point3F &waterHeight )
void Player::createSplash( Point3F &pos, F32 speed ) void Player::createSplash( Point3F &pos, F32 speed )
{ {
if ( speed >= mDataBlock->hardSplashSoundVel ) if ( speed >= mDataBlock->hardSplashSoundVel )
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterHard), &getTransform() ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack(PlayerData::ImpactWaterHard), &getTransform() );
else if ( speed >= mDataBlock->medSplashSoundVel ) else if ( speed >= mDataBlock->medSplashSoundVel )
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterMedium), &getTransform() ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack(PlayerData::ImpactWaterMedium), &getTransform() );
else else
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterEasy), &getTransform() ); SFX->playOnce( mDataBlock->getPlayerSoundSFXTrack(PlayerData::ImpactWaterEasy), &getTransform() );
if( mDataBlock->splash ) if( mDataBlock->splash )
{ {

View file

@ -147,8 +147,6 @@ ProjectileData::ProjectileData()
{ {
mProjectileShapeAsset.registerRefreshNotify(this); mProjectileShapeAsset.registerRefreshNotify(this);
INIT_ASSET(ProjectileSound);
explosion = NULL; explosion = NULL;
explosionId = 0; explosionId = 0;
@ -220,7 +218,7 @@ ProjectileData::ProjectileData(const ProjectileData& other, bool temp_clone) : G
splashId = other.splashId; // -- for pack/unpack of splash ptr splashId = other.splashId; // -- for pack/unpack of splash ptr
decal = other.decal; decal = other.decal;
decalId = other.decalId; // -- for pack/unpack of decal ptr decalId = other.decalId; // -- for pack/unpack of decal ptr
CLONE_ASSET(ProjectileSound); mProjectileSoundAsset = other.mProjectileSoundAsset;
lightDesc = other.lightDesc; lightDesc = other.lightDesc;
lightDescId = other.lightDescId; // -- for pack/unpack of lightDesc ptr lightDescId = other.lightDescId; // -- for pack/unpack of lightDesc ptr
mProjectileShapeAsset = other.mProjectileShapeAsset;// -- TSShape loads using mProjectileShapeName mProjectileShapeAsset = other.mProjectileShapeAsset;// -- TSShape loads using mProjectileShapeName
@ -412,7 +410,7 @@ bool ProjectileData::preload(bool server, String &errorStr)
if (Sim::findObject(decalId, decal) == false) if (Sim::findObject(decalId, decal) == false)
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId); Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
if (!isProjectileSoundValid()) if (!getProjectileSoundSFXTrack())
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -477,7 +475,7 @@ void ProjectileData::packData(BitStream* stream)
if (stream->writeFlag(decal != NULL)) if (stream->writeFlag(decal != NULL))
stream->writeRangedU32(decal->getId(), DataBlockObjectIdFirst, stream->writeRangedU32(decal->getId(), DataBlockObjectIdFirst,
DataBlockObjectIdLast); DataBlockObjectIdLast);
PACKDATA_ASSET(ProjectileSound); PACKDATA_ASSET_REFACTOR(ProjectileSound);
if ( stream->writeFlag(lightDesc != NULL)) if ( stream->writeFlag(lightDesc != NULL))
stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst, stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst,
@ -539,7 +537,7 @@ void ProjectileData::unpackData(BitStream* stream)
if (stream->readFlag()) if (stream->readFlag())
decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
UNPACKDATA_ASSET(ProjectileSound); UNPACKDATA_ASSET_REFACTOR(ProjectileSound);
if (stream->readFlag()) if (stream->readFlag())
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
@ -928,8 +926,8 @@ bool Projectile::onNewDataBlock( GameBaseData *dptr, bool reload )
SFX_DELETE( mSound ); SFX_DELETE( mSound );
if ( mDataBlock->getProjectileSound() ) if ( mDataBlock->getProjectileSoundSFXTrack() )
mSound = SFX->createSource( mDataBlock->getProjectileSoundProfile() ); mSound = SFX->createSource( mDataBlock->getProjectileSoundSFXTrack() );
} }
return true; return true;
@ -1143,7 +1141,7 @@ void Projectile::explode( const Point3F &p, const Point3F &n, const U32 collideT
void Projectile::updateSound() void Projectile::updateSound()
{ {
if (!mDataBlock->isProjectileSoundValid()) if (!mDataBlock->getProjectileSoundSFXTrack())
return; return;
if ( mSound ) if ( mSound )

View file

@ -116,7 +116,6 @@ public:
S32 decalId; // (impact) Decal ID S32 decalId; // (impact) Decal ID
DECLARE_SOUNDASSET(ProjectileData, ProjectileSound); DECLARE_SOUNDASSET(ProjectileData, ProjectileSound);
DECLARE_ASSET_SETGET(ProjectileData, ProjectileSound);
LightDescription *lightDesc; LightDescription *lightDesc;
S32 lightDescId; S32 lightDescId;

View file

@ -82,8 +82,6 @@ ProximityMineData::ProximityMineData()
triggerSequence( -1 ), triggerSequence( -1 ),
explosionOffset( 0.05f ) explosionOffset( 0.05f )
{ {
INIT_ASSET(ArmSound);
INIT_ASSET(TriggerSound);
} }
void ProximityMineData::initPersistFields() void ProximityMineData::initPersistFields()
@ -134,11 +132,11 @@ bool ProximityMineData::preload( bool server, String& errorStr )
if ( !server ) if ( !server )
{ {
if(!isArmSoundValid() ) if(!getArmSoundSFXTrack() )
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
if(!isTriggerSoundValid() ) if(!getTriggerSoundSFXTrack() )
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -159,14 +157,14 @@ void ProximityMineData::packData( BitStream* stream )
Parent::packData( stream ); Parent::packData( stream );
stream->write( armingDelay ); stream->write( armingDelay );
PACKDATA_ASSET(ArmSound); PACKDATA_ASSET_REFACTOR(ArmSound);
stream->write( autoTriggerDelay ); stream->write( autoTriggerDelay );
stream->writeFlag( triggerOnOwner ); stream->writeFlag( triggerOnOwner );
stream->write( triggerRadius ); stream->write( triggerRadius );
stream->write( triggerSpeed ); stream->write( triggerSpeed );
stream->write( triggerDelay ); stream->write( triggerDelay );
PACKDATA_ASSET(TriggerSound); PACKDATA_ASSET_REFACTOR(TriggerSound);
} }
void ProximityMineData::unpackData( BitStream* stream ) void ProximityMineData::unpackData( BitStream* stream )
@ -174,14 +172,14 @@ void ProximityMineData::unpackData( BitStream* stream )
Parent::unpackData(stream); Parent::unpackData(stream);
stream->read( &armingDelay ); stream->read( &armingDelay );
UNPACKDATA_ASSET(ArmSound); UNPACKDATA_ASSET_REFACTOR(ArmSound);
stream->read( &autoTriggerDelay ); stream->read( &autoTriggerDelay );
triggerOnOwner = stream->readFlag(); triggerOnOwner = stream->readFlag();
stream->read( &triggerRadius ); stream->read( &triggerRadius );
stream->read( &triggerSpeed ); stream->read( &triggerSpeed );
stream->read( &triggerDelay ); stream->read( &triggerDelay );
UNPACKDATA_ASSET(TriggerSound); UNPACKDATA_ASSET_REFACTOR(TriggerSound);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -429,8 +427,8 @@ void ProximityMine::processTick( const Move* move )
mAnimThread = mShapeInstance->addThread(); mAnimThread = mShapeInstance->addThread();
mShapeInstance->setSequence( mAnimThread, mDataBlock->armingSequence, 0.0f ); mShapeInstance->setSequence( mAnimThread, mDataBlock->armingSequence, 0.0f );
} }
if ( mDataBlock->getArmSoundProfile() ) if ( mDataBlock->getArmSoundSFXTrack() )
SFX->playOnce( mDataBlock->getArmSoundProfile(), &getRenderTransform() ); SFX->playOnce( mDataBlock->getArmSoundSFXTrack(), &getRenderTransform() );
} }
break; break;
@ -470,8 +468,8 @@ void ProximityMine::processTick( const Move* move )
mAnimThread = mShapeInstance->addThread(); mAnimThread = mShapeInstance->addThread();
mShapeInstance->setSequence( mAnimThread, mDataBlock->triggerSequence, 0.0f ); mShapeInstance->setSequence( mAnimThread, mDataBlock->triggerSequence, 0.0f );
} }
if ( mDataBlock->getTriggerSoundProfile() ) if ( mDataBlock->getTriggerSoundSFXTrack() )
SFX->playOnce( mDataBlock->getTriggerSoundProfile(), &getRenderTransform() ); SFX->playOnce( mDataBlock->getTriggerSoundSFXTrack(), &getRenderTransform() );
if ( isServerObject() ) if ( isServerObject() )
mDataBlock->onTriggered_callback( this, sql.mList[0] ); mDataBlock->onTriggered_callback( this, sql.mList[0] );

View file

@ -46,7 +46,6 @@ public:
F32 armingDelay; F32 armingDelay;
S32 armingSequence; S32 armingSequence;
DECLARE_SOUNDASSET(ProximityMineData, ArmSound); DECLARE_SOUNDASSET(ProximityMineData, ArmSound);
DECLARE_ASSET_SETGET(ProximityMineData, ArmSound);
F32 autoTriggerDelay; F32 autoTriggerDelay;
bool triggerOnOwner; bool triggerOnOwner;
@ -55,7 +54,6 @@ public:
F32 triggerDelay; F32 triggerDelay;
S32 triggerSequence; S32 triggerSequence;
DECLARE_SOUNDASSET(ProximityMineData, TriggerSound); DECLARE_SOUNDASSET(ProximityMineData, TriggerSound);
DECLARE_ASSET_SETGET(ProximityMineData, TriggerSound);
F32 explosionOffset; F32 explosionOffset;

View file

@ -254,9 +254,6 @@ RigidShapeData::RigidShapeData()
drag = 0.7f; drag = 0.7f;
density = 4; density = 4;
for (S32 i = 0; i < Body::MaxSounds; i++)
INIT_SOUNDASSET_ARRAY(BodySounds, i);
dustEmitter = NULL; dustEmitter = NULL;
dustID = 0; dustID = 0;
triggerDustHeight = 3.0; triggerDustHeight = 3.0;
@ -273,9 +270,6 @@ RigidShapeData::RigidShapeData()
hardSplashSoundVel = 3.0; hardSplashSoundVel = 3.0;
enablePhysicsRep = true; enablePhysicsRep = true;
for (S32 i = 0; i < Sounds::MaxSounds; i++)
INIT_SOUNDASSET_ARRAY(WaterSounds, i);
dragForce = 0.01f; dragForce = 0.01f;
vertFactor = 0.25; vertFactor = 0.25;
@ -348,7 +342,7 @@ bool RigidShapeData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (S32 i = 0; i < Body::MaxSounds; i++) for (S32 i = 0; i < Body::MaxSounds; i++)
{ {
if (!isBodySoundsValid(i)) if (!getBodySoundsSFXTrack(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -356,7 +350,7 @@ bool RigidShapeData::preload(bool server, String &errorStr)
for (S32 j = 0; j < Sounds::MaxSounds; j++) for (S32 j = 0; j < Sounds::MaxSounds; j++)
{ {
if (!isWaterSoundsValid(j)) if (!getWaterSoundsSFXTrack(j))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -419,10 +413,8 @@ void RigidShapeData::packData(BitStream* stream)
stream->write(body.restitution); stream->write(body.restitution);
stream->write(body.friction); stream->write(body.friction);
for (U32 i = 0; i < Body::MaxSounds; ++i)
{ PACKDATA_ASSET_ARRAY_REFACTOR(BodySounds, Body::MaxSounds);
PACKDATA_SOUNDASSET_ARRAY(BodySounds, i);
}
stream->write(minImpactSpeed); stream->write(minImpactSpeed);
stream->write(softImpactSpeed); stream->write(softImpactSpeed);
@ -452,10 +444,7 @@ void RigidShapeData::packData(BitStream* stream)
stream->write(enablePhysicsRep); stream->write(enablePhysicsRep);
// write the water sound profiles // write the water sound profiles
for (U32 i = 0; i < Sounds::MaxSounds; ++i) PACKDATA_ASSET_ARRAY_REFACTOR(WaterSounds, Sounds::MaxSounds);
{
PACKDATA_SOUNDASSET_ARRAY(WaterSounds, i);
}
if (stream->writeFlag( dustEmitter )) if (stream->writeFlag( dustEmitter ))
stream->writeRangedU32( dustEmitter->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast ); stream->writeRangedU32( dustEmitter->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast );
@ -483,10 +472,7 @@ void RigidShapeData::unpackData(BitStream* stream)
stream->read(&body.restitution); stream->read(&body.restitution);
stream->read(&body.friction); stream->read(&body.friction);
for (U32 i = 0; i < Body::Sounds::MaxSounds; i++) UNPACKDATA_ASSET_ARRAY_REFACTOR(BodySounds, Body::Sounds::MaxSounds);
{
UNPACKDATA_SOUNDASSET_ARRAY(BodySounds, i);
}
stream->read(&minImpactSpeed); stream->read(&minImpactSpeed);
stream->read(&softImpactSpeed); stream->read(&softImpactSpeed);
@ -516,10 +502,7 @@ void RigidShapeData::unpackData(BitStream* stream)
stream->read(&enablePhysicsRep); stream->read(&enablePhysicsRep);
// write the water sound profiles // write the water sound profiles
for (U32 i = 0; i < Sounds::MaxSounds; ++i) UNPACKDATA_ASSET_ARRAY_REFACTOR(WaterSounds, Sounds::MaxSounds);
{
UNPACKDATA_SOUNDASSET_ARRAY(WaterSounds, i);
}
if( stream->readFlag() ) if( stream->readFlag() )
dustID = (S32) stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); dustID = (S32) stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
@ -1210,27 +1193,27 @@ void RigidShape::updatePos(F32 dt)
if (collSpeed >= mDataBlock->softImpactSpeed) if (collSpeed >= mDataBlock->softImpactSpeed)
impactSound = RigidShapeData::Body::SoftImpactSound; impactSound = RigidShapeData::Body::SoftImpactSound;
if (impactSound != -1 && mDataBlock->getBodySoundsProfile(impactSound)) if (impactSound != -1 && mDataBlock->getBodySoundsSFXTrack(impactSound))
SFX->playOnce(mDataBlock->getBodySoundsProfile(impactSound), &getTransform()); SFX->playOnce(mDataBlock->getBodySoundsSFXTrack(impactSound), &getTransform());
} }
// Water volume sounds // Water volume sounds
F32 vSpeed = getVelocity().len(); F32 vSpeed = getVelocity().len();
if (!inLiquid && mWaterCoverage >= 0.8f) { if (!inLiquid && mWaterCoverage >= 0.8f) {
if (vSpeed >= mDataBlock->hardSplashSoundVel) if (vSpeed >= mDataBlock->hardSplashSoundVel)
SFX->playOnce(mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactHard), &getTransform()); SFX->playOnce(mDataBlock->getWaterSoundsSFXTrack(RigidShapeData::ImpactHard), &getTransform());
else else
if (vSpeed >= mDataBlock->medSplashSoundVel) if (vSpeed >= mDataBlock->medSplashSoundVel)
SFX->playOnce(mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactMedium), &getTransform()); SFX->playOnce(mDataBlock->getWaterSoundsSFXTrack(RigidShapeData::ImpactMedium), &getTransform());
else else
if (vSpeed >= mDataBlock->softSplashSoundVel) if (vSpeed >= mDataBlock->softSplashSoundVel)
SFX->playOnce(mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactSoft), &getTransform()); SFX->playOnce(mDataBlock->getWaterSoundsSFXTrack(RigidShapeData::ImpactSoft), &getTransform());
inLiquid = true; inLiquid = true;
} }
else else
if (inLiquid && mWaterCoverage < 0.8f) { if (inLiquid && mWaterCoverage < 0.8f) {
if (vSpeed >= mDataBlock->exitSplashSoundVel) if (vSpeed >= mDataBlock->exitSplashSoundVel)
SFX->playOnce(mDataBlock->getWaterSoundsProfile(RigidShapeData::ExitWater), &getTransform()); SFX->playOnce(mDataBlock->getWaterSoundsSFXTrack(RigidShapeData::ExitWater), &getTransform());
inLiquid = false; inLiquid = false;
} }
} }

View file

@ -83,7 +83,6 @@ class RigidShapeData : public ShapeBaseData
MaxSounds MaxSounds
}; };
DECLARE_SOUNDASSET_ARRAY(RigidShapeData, WaterSounds, Sounds::MaxSounds) DECLARE_SOUNDASSET_ARRAY(RigidShapeData, WaterSounds, Sounds::MaxSounds)
DECLARE_ASSET_ARRAY_SETGET(RigidShapeData, WaterSounds);
F32 exitSplashSoundVel; F32 exitSplashSoundVel;
F32 softSplashSoundVel; F32 softSplashSoundVel;

View file

@ -223,8 +223,6 @@ SFXEmitter::SFXEmitter()
mInstanceDescription = &mDescription; mInstanceDescription = &mDescription;
mLocalProfile = NULL; mLocalProfile = NULL;
INIT_ASSET(Sound);
mObjBox.minExtents.set( -1.f, -1.f, -1.f ); mObjBox.minExtents.set( -1.f, -1.f, -1.f );
mObjBox.maxExtents.set( 1.f, 1.f, 1.f ); mObjBox.maxExtents.set( 1.f, 1.f, 1.f );
} }
@ -408,15 +406,10 @@ U32 SFXEmitter::packUpdate(NetConnection* con, U32 mask, BitStream* stream)
stream->writeAffineTransform(mObjToWorld); stream->writeAffineTransform(mObjToWorld);
// track // track
if (stream->writeFlag(mask & DirtyUpdateMask)){ if (stream->writeFlag(mDirty.test(Track))){
PACK_ASSET(con, Sound); PACK_ASSET_REFACTOR(con, Sound);
} }
//if (stream->writeFlag(mDirty.test(Track)))
// sfxWrite( stream, mTrack );
// filename
//if( stream->writeFlag( mDirty.test( Filename ) ) )
// stream->writeString( mLocalProfile.mFilename );
if (!stream->writeFlag(mUseTrackDescriptionOnly)) if (!stream->writeFlag(mUseTrackDescriptionOnly))
{ {
// volume // volume
@ -521,21 +514,10 @@ void SFXEmitter::unpackUpdate( NetConnection *conn, BitStream *stream )
} }
// track // track
if (stream->readFlag()) // DirtyUpdateMask if (_readDirtyFlag(stream, Track)) // DirtyUpdateMask
{ {
initialUpdate = false; UNPACK_ASSET_REFACTOR(conn, Sound);
UNPACK_ASSET(conn, Sound);
} }
/*if (_readDirtyFlag(stream, Track))
{
String errorStr;
if( !sfxReadAndResolve( stream, &mTrack, errorStr ) )
Con::errorf( "%s", errorStr.c_str() );
}
// filename
if ( _readDirtyFlag( stream, Filename ) )
mLocalProfile.mFilename = stream->readSTString();*/
mUseTrackDescriptionOnly = stream->readFlag(); mUseTrackDescriptionOnly = stream->readFlag();
if (!mUseTrackDescriptionOnly) if (!mUseTrackDescriptionOnly)
@ -775,7 +757,7 @@ void SFXEmitter::_update()
SFXStatus prevState = mSource ? mSource->getStatus() : SFXStatusNull; SFXStatus prevState = mSource ? mSource->getStatus() : SFXStatusNull;
// are we overriding the asset properties? // are we overriding the asset properties?
bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && mSoundAsset.notNull() && getSoundProfile()); bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && mSoundAsset.notNull() && getSoundSFXTrack());
if (mSoundAsset.notNull()) if (mSoundAsset.notNull())
{ {
@ -784,7 +766,7 @@ void SFXEmitter::_update()
else else
mInstanceDescription = &mDescription; mInstanceDescription = &mDescription;
mLocalProfile = getSoundProfile(); mLocalProfile = getSoundSFXTrack();
// Make sure all the settings are valid. // Make sure all the settings are valid.
mInstanceDescription->validate(); mInstanceDescription->validate();
@ -798,12 +780,12 @@ void SFXEmitter::_update()
if( mDirty.test( Track | Is3D | IsLooping | IsStreaming | TrackOnly ) ) if( mDirty.test( Track | Is3D | IsLooping | IsStreaming | TrackOnly ) )
{ {
SFX_DELETE( mSource ); SFX_DELETE( mSource );
if (getSoundProfile()) if (getSoundSFXTrack())
{ {
mSource = SFX->createSource(mLocalProfile, &transform, &velocity); mSource = SFX->createSource(mLocalProfile, &transform, &velocity);
if (!mSource) if (!mSource)
Con::errorf("SFXEmitter::_update() - failed to create sound for track %i (%s)", Con::errorf("SFXEmitter::_update() - failed to create sound for track %i (%s)",
getSoundProfile()->getId(), getSoundProfile()->getName()); getSoundSFXTrack()->getId(), getSoundSFXTrack()->getName());
// If we're supposed to play when the emitter is // If we're supposed to play when the emitter is
// added to the scene then also restart playback // added to the scene then also restart playback
@ -820,7 +802,7 @@ void SFXEmitter::_update()
// is toggled on a local profile sound. It makes the // is toggled on a local profile sound. It makes the
// editor feel responsive and that things are working. // editor feel responsive and that things are working.
if( gEditingMission && if( gEditingMission &&
(SoundAsset::getAssetErrCode(mSoundAsset) || !mSoundAsset->getSfxProfile()) && (SoundAsset::getAssetErrCode(mSoundAsset)) &&
mPlayOnAdd && mPlayOnAdd &&
mDirty.test( IsLooping ) ) mDirty.test( IsLooping ) )
prevState = SFXStatusPlaying; prevState = SFXStatusPlaying;
@ -1222,7 +1204,7 @@ void SFXEmitter::setScale( const VectorF &scale )
{ {
F32 maxDistance; F32 maxDistance;
if( mUseTrackDescriptionOnly && mSoundAsset.notNull() && getSoundProfile()) if( mUseTrackDescriptionOnly && mSoundAsset.notNull())
maxDistance = mSoundAsset->getSfxDescription()->mMaxDistance; maxDistance = mSoundAsset->getSfxDescription()->mMaxDistance;
else else
{ {

View file

@ -122,9 +122,8 @@ class SFXEmitter : public SceneObject
BitSet32 mDirty; BitSet32 mDirty;
DECLARE_SOUNDASSET(SFXEmitter, Sound); DECLARE_SOUNDASSET(SFXEmitter, Sound);
DECLARE_ASSET_NET_SETGET(SFXEmitter, Sound, DirtyUpdateMask);
/// returns the shape asset used for this object /// returns the shape asset used for this object
StringTableEntry getTypeHint() const override { return (getSoundAsset()) ? getSoundAsset()->getAssetName() : StringTable->EmptyString(); } StringTableEntry getTypeHint() const override { return (mSoundAsset.notNull()) ? mSoundAsset->getAssetName() : StringTable->EmptyString(); }
/// The sound source for the emitter. /// The sound source for the emitter.
SFXSource *mSource; SFXSource *mSource;

View file

@ -267,7 +267,6 @@ struct ShapeBaseImageData: public GameBaseData, protected AssetPtrCallback
//SFXTrack* sound; //SFXTrack* sound;
F32 emitterTime; ///< F32 emitterTime; ///<
S32 emitterNode[MaxShapes]; ///< Node ID on the shape to emit from S32 emitterNode[MaxShapes]; ///< Node ID on the shape to emit from
SoundAsset* sound;
SFXTrack* soundTrack; ///<Holdover for special, non-asset cases like SFXPlaylists SFXTrack* soundTrack; ///<Holdover for special, non-asset cases like SFXPlaylists
}; };
/// @name State Data /// @name State Data
@ -328,7 +327,6 @@ struct ShapeBaseImageData: public GameBaseData, protected AssetPtrCallback
bool stateIgnoreLoadedForReady [MaxStates]; bool stateIgnoreLoadedForReady [MaxStates];
DECLARE_SOUNDASSET_ARRAY(ShapeBaseImageData, stateSound, MaxStates); DECLARE_SOUNDASSET_ARRAY(ShapeBaseImageData, stateSound, MaxStates);
DECLARE_ASSET_ARRAY_SETGET(ShapeBaseImageData, stateSound);
//SFXTrack* stateSound [MaxStates]; //SFXTrack* stateSound [MaxStates];
const char* stateScript [MaxStates]; const char* stateScript [MaxStates];

View file

@ -132,7 +132,6 @@ ShapeBaseImageData::StateData::StateData()
loaded = IgnoreLoaded; loaded = IgnoreLoaded;
spin = IgnoreSpin; spin = IgnoreSpin;
recoil = NoRecoil; recoil = NoRecoil;
sound = NULL;
soundTrack = NULL; soundTrack = NULL;
emitter = NULL; emitter = NULL;
shapeSequence = NULL; shapeSequence = NULL;
@ -255,8 +254,6 @@ ShapeBaseImageData::ShapeBaseImageData()
stateShapeSequence[i] = 0; stateShapeSequence[i] = 0;
stateScaleShapeSequence[i] = false; stateScaleShapeSequence[i] = false;
INIT_SOUNDASSET_ARRAY(stateSound, i);
stateScript[i] = 0; stateScript[i] = 0;
stateEmitter[i] = 0; stateEmitter[i] = 0;
stateEmitterTime[i] = 0; stateEmitterTime[i] = 0;
@ -421,7 +418,7 @@ bool ShapeBaseImageData::preload(bool server, String &errorStr)
if (!Sim::findObject(SimObjectId((uintptr_t)state[i].emitter), 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"); Con::errorf(ConsoleLogEntry::General, "Error, unable to load emitter for image datablock");
if (!isstateSoundValid(i)) if (!getstateSoundSFXTrack(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -577,37 +574,7 @@ void ShapeBaseImageData::handleStateSoundTrack(const U32& stateId)
return; return;
StateData& s = state[stateId]; StateData& s = state[stateId];
s.soundTrack = getstateSoundSFXTrack(stateId);
s.sound = getstateSoundAsset(stateId);
if (s.sound == NULL)
{
if (mstateSoundName[stateId] != StringTable->EmptyString())
{
//ok, so we've got some sort of special-case here like a fallback or SFXPlaylist. So do the hook-up now
SFXTrack* sndTrack;
if (!Sim::findObject(mstateSoundName[stateId], sndTrack))
{
Con::errorf("ShapeBaseImageData::onAdd() - attempted to find sound %s but failed!", mstateSoundName[stateId]);
}
else
{
s.soundTrack = sndTrack;
}
}
else if (mstateSoundSFXId[stateId] != 0)
{
SFXTrack* sndTrack;
if (!Sim::findObject(mstateSoundSFXId[stateId], sndTrack))
{
Con::errorf("ShapeBaseImageData::onAdd() - attempted to find sound %i but failed!", mstateSoundSFXId[stateId]);
}
else
{
s.soundTrack = sndTrack;
}
}
}
} }
S32 ShapeBaseImageData::lookupState(const char* name) S32 ShapeBaseImageData::lookupState(const char* name)
@ -1162,7 +1129,7 @@ void ShapeBaseImageData::packData(BitStream* stream)
} }
} }
PACKDATA_SOUNDASSET_ARRAY(stateSound, i); PACKDATA_ASSET_ARRAY(stateSound, i);
} }
stream->write(maxConcurrentSounds); stream->write(maxConcurrentSounds);
stream->writeFlag(useRemainderDT); stream->writeFlag(useRemainderDT);
@ -1364,7 +1331,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream)
else else
s.emitter = 0; s.emitter = 0;
UNPACKDATA_SOUNDASSET_ARRAY(stateSound, i); UNPACKDATA_ASSET_ARRAY(stateSound, i);
handleStateSoundTrack(i); handleStateSoundTrack(i);
} }
} }
@ -2776,7 +2743,7 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState, bool force)
// Delete any loooping sounds that were in the previous state. // 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. // 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. // lastState does not return an id for the prev state so we keep track of it.
if (lastState->sound && lastState->sound->getSFXTrack()->getDescription()->mIsLooping) if (lastState->soundTrack && lastState->soundTrack->getDescription()->mIsLooping)
{ {
for (Vector<SFXSource*>::iterator i = image.mSoundSources.begin(); i != image.mSoundSources.end(); i++) for (Vector<SFXSource*>::iterator i = image.mSoundSources.begin(); i != image.mSoundSources.end(); i++)
SFX_DELETE((*i)); SFX_DELETE((*i));
@ -2787,11 +2754,6 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState, bool force)
// Play sound // Play sound
if (isGhost()) if (isGhost())
{ {
if (stateData.sound)
{
const Point3F& velocity = getVelocity();
image.addSoundSource(SFX->createSource(stateData.sound->getSFXTrack(), &getRenderTransform(), &velocity));
}
if (stateData.soundTrack) if (stateData.soundTrack)
{ {
const Point3F& velocity = getVelocity(); const Point3F& velocity = getVelocity();

View file

@ -124,9 +124,6 @@ FlyingVehicleData::FlyingVehicleData()
for (S32 j = 0; j < MaxJetEmitters; j++) for (S32 j = 0; j < MaxJetEmitters; j++)
jetEmitter[j] = 0; jetEmitter[j] = 0;
for (S32 i = 0; i < MaxSounds; i++)
INIT_SOUNDASSET_ARRAY(FlyingSounds, i);
vertThrustMultiple = 1.0; vertThrustMultiple = 1.0;
} }
@ -141,7 +138,7 @@ bool FlyingVehicleData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
if (!isFlyingSoundsValid(i)) if (!getFlyingSoundsSFXTrack(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -258,10 +255,7 @@ void FlyingVehicleData::packData(BitStream* stream)
{ {
Parent::packData(stream); Parent::packData(stream);
for (S32 i = 0; i < MaxSounds; i++) PACKDATA_ASSET_ARRAY_REFACTOR(FlyingSounds, MaxSounds);
{
PACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i);
}
for (S32 j = 0; j < MaxJetEmitters; j++) for (S32 j = 0; j < MaxJetEmitters; j++)
{ {
@ -293,10 +287,7 @@ void FlyingVehicleData::unpackData(BitStream* stream)
{ {
Parent::unpackData(stream); Parent::unpackData(stream);
for (S32 i = 0; i < MaxSounds; i++) UNPACKDATA_ASSET_ARRAY_REFACTOR(FlyingSounds, MaxSounds);
{
UNPACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i);
}
for (S32 j = 0; j < MaxJetEmitters; j++) { for (S32 j = 0; j < MaxJetEmitters; j++) {
jetEmitter[j] = NULL; jetEmitter[j] = NULL;
@ -385,11 +376,11 @@ bool FlyingVehicle::onNewDataBlock(GameBaseData* dptr, bool reload)
SFX_DELETE( mJetSound ); SFX_DELETE( mJetSound );
SFX_DELETE( mEngineSound ); SFX_DELETE( mEngineSound );
if ( mDataBlock->getFlyingSounds(FlyingVehicleData::EngineSound) ) if ( mDataBlock->getFlyingSoundsSFXTrack(FlyingVehicleData::EngineSound) )
mEngineSound = SFX->createSource( mDataBlock->getFlyingSoundsProfile(FlyingVehicleData::EngineSound), &getTransform() ); mEngineSound = SFX->createSource( mDataBlock->getFlyingSoundsSFXTrack(FlyingVehicleData::EngineSound), &getTransform() );
if ( mDataBlock->getFlyingSounds(FlyingVehicleData::JetSound)) if ( mDataBlock->getFlyingSoundsSFXTrack(FlyingVehicleData::JetSound))
mJetSound = SFX->createSource( mDataBlock->getFlyingSoundsProfile(FlyingVehicleData::JetSound), &getTransform() ); mJetSound = SFX->createSource( mDataBlock->getFlyingSoundsSFXTrack(FlyingVehicleData::JetSound), &getTransform() );
} }
// Jet Sequences // Jet Sequences

View file

@ -46,7 +46,6 @@ struct FlyingVehicleData: public VehicleData {
MaxSounds, MaxSounds,
}; };
DECLARE_SOUNDASSET_ARRAY(FlyingVehicleData, FlyingSounds, Sounds::MaxSounds); DECLARE_SOUNDASSET_ARRAY(FlyingVehicleData, FlyingSounds, Sounds::MaxSounds);
DECLARE_ASSET_ARRAY_SETGET(FlyingVehicleData, FlyingSounds);
enum Jets { enum Jets {
// These enums index into a static name list. // These enums index into a static name list.

View file

@ -158,9 +158,6 @@ HoverVehicleData::HoverVehicleData()
for (S32 j = 0; j < MaxJetEmitters; j++) for (S32 j = 0; j < MaxJetEmitters; j++)
jetEmitter[j] = 0; jetEmitter[j] = 0;
for (S32 i = 0; i < MaxSounds; i++)
INIT_SOUNDASSET_ARRAY(HoverSounds, i);
} }
HoverVehicleData::~HoverVehicleData() HoverVehicleData::~HoverVehicleData()
@ -313,7 +310,7 @@ bool HoverVehicleData::preload(bool server, String &errorStr)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
if (!isHoverSoundsValid(i)) if (!getHoverSoundsSFXTrack(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -365,10 +362,7 @@ void HoverVehicleData::packData(BitStream* stream)
stream->write(triggerTrailHeight); stream->write(triggerTrailHeight);
stream->write(dustTrailFreqMod); stream->write(dustTrailFreqMod);
for (S32 i = 0; i < MaxSounds; i++) PACKDATA_ASSET_ARRAY_REFACTOR(HoverSounds, MaxSounds);
{
PACKDATA_SOUNDASSET_ARRAY(HoverSounds, i);
}
for (S32 j = 0; j < MaxJetEmitters; j++) for (S32 j = 0; j < MaxJetEmitters; j++)
{ {
@ -414,10 +408,7 @@ void HoverVehicleData::unpackData(BitStream* stream)
stream->read(&triggerTrailHeight); stream->read(&triggerTrailHeight);
stream->read(&dustTrailFreqMod); stream->read(&dustTrailFreqMod);
for (S32 i = 0; i < MaxSounds; i++) UNPACKDATA_ASSET_ARRAY_REFACTOR(HoverSounds, MaxSounds);
{
UNPACKDATA_SOUNDASSET_ARRAY(HoverSounds, i);
}
for (S32 j = 0; j < MaxJetEmitters; j++) { for (S32 j = 0; j < MaxJetEmitters; j++) {
jetEmitter[j] = NULL; jetEmitter[j] = NULL;
@ -539,14 +530,14 @@ bool HoverVehicle::onNewDataBlock(GameBaseData* dptr, bool reload)
SFX_DELETE( mFloatSound ); SFX_DELETE( mFloatSound );
SFX_DELETE( mJetSound ); SFX_DELETE( mJetSound );
if ( mDataBlock->getHoverSounds(HoverVehicleData::EngineSound) ) if ( mDataBlock->getHoverSoundsSFXTrack(HoverVehicleData::EngineSound) )
mEngineSound = SFX->createSource( mDataBlock->getHoverSoundsProfile(HoverVehicleData::EngineSound), &getTransform() ); mEngineSound = SFX->createSource( mDataBlock->getHoverSoundsSFXTrack(HoverVehicleData::EngineSound), &getTransform() );
if ( !mDataBlock->getHoverSounds(HoverVehicleData::FloatSound) ) if ( !mDataBlock->getHoverSoundsSFXTrack(HoverVehicleData::FloatSound) )
mFloatSound = SFX->createSource( mDataBlock->getHoverSoundsProfile(HoverVehicleData::FloatSound), &getTransform() ); mFloatSound = SFX->createSource( mDataBlock->getHoverSoundsSFXTrack(HoverVehicleData::FloatSound), &getTransform() );
if ( mDataBlock->getHoverSounds(HoverVehicleData::JetSound) ) if ( mDataBlock->getHoverSoundsSFXTrack(HoverVehicleData::JetSound) )
mJetSound = SFX->createSource( mDataBlock->getHoverSoundsProfile(HoverVehicleData::JetSound), &getTransform() ); mJetSound = SFX->createSource( mDataBlock->getHoverSoundsSFXTrack(HoverVehicleData::JetSound), &getTransform() );
} }
// Todo: Uncomment if this is a "leaf" class // Todo: Uncomment if this is a "leaf" class

View file

@ -882,27 +882,27 @@ void Vehicle::updatePos(F32 dt)
if (collSpeed >= mDataBlock->softImpactSpeed) if (collSpeed >= mDataBlock->softImpactSpeed)
impactSound = RigidShapeData::Body::SoftImpactSound; impactSound = RigidShapeData::Body::SoftImpactSound;
if (impactSound != -1 && mDataBlock->getBodySoundsProfile(impactSound) != NULL) if (impactSound != -1 && mDataBlock->getBodySoundsSFXTrack(impactSound) != NULL)
SFX->playOnce( mDataBlock->getBodySoundsProfile(impactSound), &getTransform() ); SFX->playOnce( mDataBlock->getBodySoundsSFXTrack(impactSound), &getTransform() );
} }
// Water volume sounds // Water volume sounds
F32 vSpeed = getVelocity().len(); F32 vSpeed = getVelocity().len();
if (!inLiquid && mWaterCoverage >= 0.8f) { if (!inLiquid && mWaterCoverage >= 0.8f) {
if (vSpeed >= mDataBlock->hardSplashSoundVel) if (vSpeed >= mDataBlock->hardSplashSoundVel)
SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactHard), &getTransform() ); SFX->playOnce( mDataBlock->getBodySoundsSFXTrack(RigidShapeData::ImpactHard), &getTransform() );
else else
if (vSpeed >= mDataBlock->medSplashSoundVel) if (vSpeed >= mDataBlock->medSplashSoundVel)
SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactMedium), &getTransform() ); SFX->playOnce( mDataBlock->getBodySoundsSFXTrack(RigidShapeData::ImpactMedium), &getTransform() );
else else
if (vSpeed >= mDataBlock->softSplashSoundVel) if (vSpeed >= mDataBlock->softSplashSoundVel)
SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactSoft), &getTransform() ); SFX->playOnce( mDataBlock->getBodySoundsSFXTrack(RigidShapeData::ImpactSoft), &getTransform() );
inLiquid = true; inLiquid = true;
} }
else else
if(inLiquid && mWaterCoverage < 0.8f) { if(inLiquid && mWaterCoverage < 0.8f) {
if (vSpeed >= mDataBlock->exitSplashSoundVel) if (vSpeed >= mDataBlock->exitSplashSoundVel)
SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ExitWater), &getTransform() ); SFX->playOnce( mDataBlock->getBodySoundsSFXTrack(RigidShapeData::ExitWater), &getTransform() );
inLiquid = false; inLiquid = false;
} }
} }

View file

@ -312,8 +312,6 @@ WheeledVehicleData::WheeledVehicleData()
steeringSequence = -1; steeringSequence = -1;
wheelCount = 0; wheelCount = 0;
dMemset(&wheel, 0, sizeof(wheel)); dMemset(&wheel, 0, sizeof(wheel));
for (S32 i = 0; i < MaxSounds; i++)
INIT_SOUNDASSET_ARRAY(WheeledVehicleSounds, i);
mDownForce = 0; mDownForce = 0;
} }
@ -348,7 +346,7 @@ bool WheeledVehicleData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
if (!isWheeledVehicleSoundsValid(i)) if (!getWheeledVehicleSoundsSFXTrack(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -493,10 +491,7 @@ void WheeledVehicleData::packData(BitStream* stream)
stream->writeRangedU32(mPacked ? SimObjectId((uintptr_t)tireEmitter): stream->writeRangedU32(mPacked ? SimObjectId((uintptr_t)tireEmitter):
tireEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast); tireEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
for (S32 i = 0; i < MaxSounds; i++) PACKDATA_ASSET_ARRAY_REFACTOR(WheeledVehicleSounds, MaxSounds);
{
PACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i);
}
stream->write(maxWheelSpeed); stream->write(maxWheelSpeed);
stream->write(engineTorque); stream->write(engineTorque);
@ -513,10 +508,8 @@ void WheeledVehicleData::unpackData(BitStream* stream)
(ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast): 0; DataBlockObjectIdLast): 0;
for (S32 i = 0; i < MaxSounds; i++) UNPACKDATA_ASSET_ARRAY_REFACTOR(WheeledVehicleSounds, MaxSounds);
{
UNPACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i);
}
stream->read(&maxWheelSpeed); stream->read(&maxWheelSpeed);
stream->read(&engineTorque); stream->read(&engineTorque);
@ -700,14 +693,14 @@ bool WheeledVehicle::onNewDataBlock(GameBaseData* dptr, bool reload)
SFX_DELETE( mSquealSound ); SFX_DELETE( mSquealSound );
SFX_DELETE( mJetSound ); SFX_DELETE( mJetSound );
if ( mDataBlock->getWheeledVehicleSounds(WheeledVehicleData::EngineSound) ) if ( mDataBlock->getWheeledVehicleSoundsSFXTrack(WheeledVehicleData::EngineSound) )
mEngineSound = SFX->createSource( mDataBlock->getWheeledVehicleSoundsProfile(WheeledVehicleData::EngineSound), &getTransform() ); mEngineSound = SFX->createSource( mDataBlock->getWheeledVehicleSoundsSFXTrack(WheeledVehicleData::EngineSound), &getTransform() );
if ( mDataBlock->getWheeledVehicleSounds(WheeledVehicleData::SquealSound) ) if ( mDataBlock->getWheeledVehicleSoundsSFXTrack(WheeledVehicleData::SquealSound) )
mSquealSound = SFX->createSource( mDataBlock->getWheeledVehicleSoundsProfile(WheeledVehicleData::SquealSound), &getTransform() ); mSquealSound = SFX->createSource( mDataBlock->getWheeledVehicleSoundsSFXTrack(WheeledVehicleData::SquealSound), &getTransform() );
if ( mDataBlock->getWheeledVehicleSounds(WheeledVehicleData::JetSound) ) if ( mDataBlock->getWheeledVehicleSoundsSFXTrack(WheeledVehicleData::JetSound) )
mJetSound = SFX->createSource( mDataBlock->getWheeledVehicleSoundsProfile(WheeledVehicleData::JetSound), &getTransform() ); mJetSound = SFX->createSource( mDataBlock->getWheeledVehicleSoundsSFXTrack(WheeledVehicleData::JetSound), &getTransform() );
} }
scriptOnNewDataBlock(reload); scriptOnNewDataBlock(reload);

View file

@ -141,8 +141,6 @@ U32 Projectile::smProjectileWarpTicks = 5;
// //
afxMagicMissileData::afxMagicMissileData() afxMagicMissileData::afxMagicMissileData()
{ {
INIT_ASSET(ProjectileSound);
/* From stock Projectile code... /* From stock Projectile code...
explosion = NULL; explosion = NULL;
explosionId = 0; explosionId = 0;
@ -247,9 +245,9 @@ afxMagicMissileData::afxMagicMissileData()
afxMagicMissileData::afxMagicMissileData(const afxMagicMissileData& other, bool temp_clone) : GameBaseData(other, temp_clone) afxMagicMissileData::afxMagicMissileData(const afxMagicMissileData& other, bool temp_clone) : GameBaseData(other, temp_clone)
{ {
mProjectileShapeAsset = other.mProjectileShapeAsset; mProjectileShapeAsset = other.mProjectileShapeAsset;
projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName
CLONE_ASSET(ProjectileSound); mProjectileSoundAsset = other.mProjectileSoundAsset;
splash = other.splash; splash = other.splash;
splashId = other.splashId; // -- for pack/unpack of splash ptr splashId = other.splashId; // -- for pack/unpack of splash ptr
lightDesc = other.lightDesc; lightDesc = other.lightDesc;
@ -522,7 +520,7 @@ bool afxMagicMissileData::preload(bool server, String &errorStr)
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId); Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
*/ */
if (!isProjectileSoundValid()) if (!getProjectileSoundSFXTrack())
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -622,7 +620,7 @@ void afxMagicMissileData::packData(BitStream* stream)
DataBlockObjectIdLast); DataBlockObjectIdLast);
*/ */
PACKDATA_ASSET(ProjectileSound); PACKDATA_ASSET_REFACTOR(ProjectileSound);
if ( stream->writeFlag(lightDesc != NULL)) if ( stream->writeFlag(lightDesc != NULL))
stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst, stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst,
@ -728,7 +726,7 @@ void afxMagicMissileData::unpackData(BitStream* stream)
decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
*/ */
UNPACKDATA_ASSET(ProjectileSound); UNPACKDATA_ASSET_REFACTOR(ProjectileSound);
if (stream->readFlag()) if (stream->readFlag())
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
@ -1152,8 +1150,7 @@ bool afxMagicMissile::onNewDataBlock(GameBaseData* dptr, bool reload)
SFX_DELETE( mSound ); SFX_DELETE( mSound );
if (mDataBlock->getProjectileSound()) mSound = SFX->createSource(mDataBlock->getProjectileSoundSFXTrack());
mSound = SFX->createSource(mDataBlock->getProjectileSoundProfile());
} }
return true; return true;
@ -1988,7 +1985,7 @@ void afxMagicMissile::get_launch_data(Point3F& pos, Point3F& vel)
void afxMagicMissile::updateSound() void afxMagicMissile::updateSound()
{ {
if (!mDataBlock->isProjectileSoundValid()) if (!mDataBlock->getProjectileSoundAsset().isNull())
return; return;
if ( mSound ) if ( mSound )

View file

@ -124,7 +124,6 @@ public:
S32 splashId; // Water splash ID S32 splashId; // Water splash ID
DECLARE_SOUNDASSET(afxMagicMissileData, ProjectileSound); DECLARE_SOUNDASSET(afxMagicMissileData, ProjectileSound);
DECLARE_ASSET_SETGET(afxMagicMissileData, ProjectileSound);
LightDescription *lightDesc; LightDescription *lightDesc;
S32 lightDescId; S32 lightDescId;

View file

@ -120,7 +120,7 @@ void WindDeformationHLSL::processVert( Vector<ShaderComponent*> &componentList,
{ {
accumTime = new Var( "accumTime", "float" ); accumTime = new Var( "accumTime", "float" );
accumTime->uniform = true; accumTime->uniform = true;
accumTime->constSortPos = cspPass; accumTime->constSortPos = cspScene;
} }
// Get the transform to world space. // Get the transform to world space.

View file

@ -258,8 +258,7 @@ void GuiButtonBaseCtrl::onMouseDown(const GuiEvent& event)
if (mProfile->mCanKeyFocus) if (mProfile->mCanKeyFocus)
setFirstResponder(); setFirstResponder();
if (mProfile->isSoundButtonDownValid()) SFX->playOnce(mProfile->getSoundButtonDownSFXTrack());
SFX->playOnce(mProfile->getSoundButtonDownProfile());
mMouseDownPoint = event.mousePoint; mMouseDownPoint = event.mousePoint;
mMouseDragged = false; mMouseDragged = false;
@ -299,8 +298,7 @@ void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent& event)
} }
else else
{ {
if (mProfile->isSoundButtonOverValid()) SFX->playOnce(mProfile->getSoundButtonOverSFXTrack());
SFX->playOnce(mProfile->getSoundButtonOverProfile());
mHighlighted = true; mHighlighted = true;
messageSiblings(mRadioGroup); messageSiblings(mRadioGroup);
@ -388,8 +386,7 @@ bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent& event)
if ((event.keyCode == KEY_RETURN || event.keyCode == KEY_SPACE) if ((event.keyCode == KEY_RETURN || event.keyCode == KEY_SPACE)
&& event.modifier == 0) && event.modifier == 0)
{ {
if (mProfile->isSoundButtonDownValid()) SFX->playOnce(mProfile->getSoundButtonDownSFXTrack());
SFX->playOnce(mProfile->getSoundButtonDownProfile());
return true; return true;
} }

View file

@ -282,7 +282,6 @@ GuiMLTextCtrl::GuiMLTextCtrl()
{ {
mActive = true; mActive = true;
//mInitialText = StringTable->EmptyString(); //mInitialText = StringTable->EmptyString();
INIT_ASSET(DeniedSound);
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -344,8 +343,6 @@ bool GuiMLTextCtrl::onAdd()
if (!mTextBuffer.length() && mInitialText[0] != 0) if (!mTextBuffer.length() && mInitialText[0] != 0)
setText(mInitialText, dStrlen(mInitialText)+1); setText(mInitialText, dStrlen(mInitialText)+1);
_setDeniedSound(getDeniedSound());
return true; return true;
} }
@ -964,8 +961,8 @@ void GuiMLTextCtrl::insertChars(const char* inputChars,
if (numCharsToInsert <= 0) if (numCharsToInsert <= 0)
{ {
// Play the "Denied" sound: // Play the "Denied" sound:
if ( numInputChars > 0 && getDeniedSoundProfile()) if ( numInputChars > 0)
SFX->playOnce(getDeniedSoundProfile()); SFX->playOnce(getDeniedSoundSFXTrack());
return; return;
} }

View file

@ -265,7 +265,6 @@ class GuiMLTextCtrl : public GuiControl
// Too many chars sound: // Too many chars sound:
DECLARE_SOUNDASSET(GuiMLTextCtrl, DeniedSound); DECLARE_SOUNDASSET(GuiMLTextCtrl, DeniedSound);
DECLARE_ASSET_SETGET(GuiMLTextCtrl, DeniedSound);
// Typeout over time // Typeout over time
bool mUseTypeOverTime; bool mUseTypeOverTime;
U32 mTypeOverTimeStartMS; U32 mTypeOverTimeStartMS;

View file

@ -205,8 +205,7 @@ void GuiSliderCtrl::onMouseDown(const GuiEvent &event)
setFirstResponder(); setFirstResponder();
mDepressed = true; mDepressed = true;
if (mProfile->isSoundButtonDownValid()) SFX->playOnce(mProfile->getSoundButtonDownSFXTrack());
SFX->playOnce(mProfile->getSoundButtonDownProfile());
Point2I curMousePos = globalToLocalCoord( event.mousePoint ); Point2I curMousePos = globalToLocalCoord( event.mousePoint );
F32 value; F32 value;
@ -262,11 +261,9 @@ void GuiSliderCtrl::onMouseEnter(const GuiEvent &event)
} }
else else
{ {
if( mActive && mProfile->mSoundButtonOver ) if( mActive )
{ {
//F32 pan = (F32(event.mousePoint.x)/F32(getRoot()->getWidth())*2.0f-1.0f)*0.8f; SFX->playOnce(mProfile->getSoundButtonOverSFXTrack());
if (mProfile->isSoundButtonOverValid())
SFX->playOnce(mProfile->getSoundButtonOverProfile());
} }
mMouseOver = true; mMouseOver = true;

View file

@ -244,8 +244,6 @@ GuiControlProfile::GuiControlProfile(void) :
mTextOffset(0,0), mTextOffset(0,0),
mBitmapArrayRects(0) mBitmapArrayRects(0)
{ {
INIT_ASSET(SoundButtonDown);
INIT_ASSET(SoundButtonOver);
mLoadCount = 0; mLoadCount = 0;
mUseCount = 0; mUseCount = 0;
@ -321,21 +319,6 @@ GuiControlProfile::GuiControlProfile(void) :
mUseBitmapArray = def->mUseBitmapArray; mUseBitmapArray = def->mUseBitmapArray;
mTextOffset = def->mTextOffset; mTextOffset = def->mTextOffset;
// default sound
_setSoundButtonDown(def->getSoundButtonDown());
if (getSoundButtonDown() != StringTable->EmptyString())
{
if (!getSoundButtonDownProfile())
Con::errorf(ConsoleLogEntry::General, "GuiControlProfile: Can't get default button pressed sound asset.");
}
_setSoundButtonOver(def->getSoundButtonOver());
if (getSoundButtonOver() != StringTable->EmptyString())
{
if (!getSoundButtonOverProfile())
Con::errorf(ConsoleLogEntry::General, "GuiControlProfile: Can't get default button hover sound asset.");
}
//used by GuiTextCtrl //used by GuiTextCtrl
mModal = def->mModal; mModal = def->mModal;
mAlignment = def->mAlignment; mAlignment = def->mAlignment;

View file

@ -467,10 +467,8 @@ public:
Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes
DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonDown); ///< Sound played when a button is pressed. DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonDown); ///< Sound played when a button is pressed.
DECLARE_ASSET_SETGET(GuiControlProfile, SoundButtonDown);
DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonOver); ///< Sound played when a button is hovered. DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonOver); ///< Sound played when a button is hovered.
DECLARE_ASSET_SETGET(GuiControlProfile, SoundButtonOver);
StringTableEntry mChildrenProfileName; ///< The name of the profile to use for the children controls StringTableEntry mChildrenProfileName; ///< The name of the profile to use for the children controls

View file

@ -40,7 +40,6 @@ ConsoleDocClass( GuiAudioCtrl,
GuiAudioCtrl::GuiAudioCtrl() GuiAudioCtrl::GuiAudioCtrl()
{ {
INIT_ASSET(Sound);
mTickPeriodMS = 100; mTickPeriodMS = 100;
mLastThink = 0; mLastThink = 0;
mCurrTick = 0; mCurrTick = 0;
@ -85,7 +84,7 @@ void GuiAudioCtrl::processTick()
{ {
mCurrTick = 0; mCurrTick = 0;
mLastThink = 0; mLastThink = 0;
if (isSoundValid()) if (getSoundAsset().notNull())
{ {
_update(); _update();
} }
@ -154,14 +153,11 @@ void GuiAudioCtrl::_update()
if (testCondition() && isAwake()) if (testCondition() && isAwake())
{ {
bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && getSoundProfile()); bool useTrackDescriptionOnly = mUseTrackDescriptionOnly;
if (getSoundProfile()) if (mSoundPlaying == NULL)
{ {
if (mSoundPlaying == NULL) mSoundPlaying = SFX->createSource(getSoundSFXTrack(), &(SFX->getListener().getTransform()));
{
mSoundPlaying = SFX->createSource(getSoundProfile(), &(SFX->getListener().getTransform()));
}
} }
if ( mSoundPlaying && !mSoundPlaying->isPlaying()) if ( mSoundPlaying && !mSoundPlaying->isPlaying())

View file

@ -84,7 +84,6 @@ protected:
public: public:
DECLARE_SOUNDASSET(GuiAudioCtrl, Sound); DECLARE_SOUNDASSET(GuiAudioCtrl, Sound);
DECLARE_ASSET_SETGET(GuiAudioCtrl, Sound);
GuiAudioCtrl(); GuiAudioCtrl();
~GuiAudioCtrl(); ~GuiAudioCtrl();
// GuiControl. // GuiControl.

View file

@ -228,8 +228,6 @@ Material::Material()
mFootstepSoundId = -1; mImpactSoundId = -1; mFootstepSoundId = -1; mImpactSoundId = -1;
mImpactFXIndex = -1; mImpactFXIndex = -1;
INIT_ASSET(CustomFootstepSound);
INIT_ASSET(CustomImpactSound);
mFriction = 0.0; mFriction = 0.0;
mDirectSoundOcclusion = 1.f; mDirectSoundOcclusion = 1.f;

View file

@ -356,9 +356,7 @@ public:
/// If defined, overrides mFootstepSoundId. /// If defined, overrides mFootstepSoundId.
/// @see mFootstepSoundId /// @see mFootstepSoundId
DECLARE_SOUNDASSET(Material, CustomFootstepSound); DECLARE_SOUNDASSET(Material, CustomFootstepSound);
DECLARE_ASSET_SETGET(Material, CustomFootstepSound);
DECLARE_SOUNDASSET(Material, CustomImpactSound); DECLARE_SOUNDASSET(Material, CustomImpactSound);
DECLARE_ASSET_SETGET(Material, CustomImpactSound);
F32 mFriction; ///< Friction coefficient when moving along surface. F32 mFriction; ///< Friction coefficient when moving along surface.

View file

@ -88,7 +88,6 @@ SFXAmbience::SFXAmbience()
mEnvironment( NULL ) mEnvironment( NULL )
{ {
dMemset( mState, 0, sizeof( mState ) ); dMemset( mState, 0, sizeof( mState ) );
INIT_ASSET(SoundTrack);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -133,7 +132,6 @@ bool SFXAmbience::onAdd()
Sim::getSFXAmbienceSet()->addObject( this ); Sim::getSFXAmbienceSet()->addObject( this );
_setSoundTrack(getSoundTrack());
return true; return true;
} }
@ -153,7 +151,7 @@ bool SFXAmbience::preload( bool server, String& errorStr )
if( !sfxResolve( &mEnvironment, errorStr ) ) if( !sfxResolve( &mEnvironment, errorStr ) )
return false; return false;
if (!isSoundTrackValid()) if (!getSoundTrackSFXTrack())
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -173,7 +171,7 @@ void SFXAmbience::packData( BitStream* stream )
Parent::packData( stream ); Parent::packData( stream );
sfxWrite( stream, mEnvironment ); sfxWrite( stream, mEnvironment );
PACKDATA_ASSET(SoundTrack); PACKDATA_ASSET_REFACTOR(SoundTrack);
stream->write( mRolloffFactor ); stream->write( mRolloffFactor );
stream->write( mDopplerFactor ); stream->write( mDopplerFactor );
@ -189,7 +187,7 @@ void SFXAmbience::unpackData( BitStream* stream )
Parent::unpackData( stream ); Parent::unpackData( stream );
sfxRead( stream, &mEnvironment ); sfxRead( stream, &mEnvironment );
UNPACKDATA_ASSET(SoundTrack); UNPACKDATA_ASSET_REFACTOR(SoundTrack);
stream->read( &mRolloffFactor ); stream->read( &mRolloffFactor );
stream->read( &mDopplerFactor ); stream->read( &mDopplerFactor );

View file

@ -67,7 +67,6 @@ class SFXAmbience : public SimDataBlock
/// Sound track to play when inside the ambient space. /// Sound track to play when inside the ambient space.
DECLARE_SOUNDASSET(SFXAmbience, SoundTrack); DECLARE_SOUNDASSET(SFXAmbience, SoundTrack);
DECLARE_ASSET_SETGET(SFXAmbience, SoundTrack);
/// Reverb environment to apply when inside the ambient space. /// Reverb environment to apply when inside the ambient space.
SFXEnvironment* mEnvironment; SFXEnvironment* mEnvironment;

View file

@ -178,7 +178,7 @@ inline F32 SFXDistanceAttenuation( SFXDistanceModel model, F32 minDistance, F32
distance = getMax( distance, minDistance ); distance = getMax( distance, minDistance );
distance = getMin( distance, maxDistance ); distance = getMin( distance, maxDistance );
gain = ( 1 - ( distance - minDistance ) / ( maxDistance - minDistance ) ); gain = ( 1 - rolloffFactor * ( distance - minDistance ) / ( maxDistance - minDistance ) );
break; break;
case SFXDistanceModelLogarithmic: case SFXDistanceModelLogarithmic:
@ -363,8 +363,8 @@ public:
flGain = 0.0f; flGain = 0.0f;
flGainHF = 0.0f; flGainHF = 0.0f;
flGainLF = 0.0000f; flGainLF = 0.0000f;
flDecayTime = 0.0f; flDecayTime = 0.1f;
flDecayHFRatio = 0.0f; flDecayHFRatio = 0.1f;
flDecayLFRatio = 0.0f; flDecayLFRatio = 0.0f;
flReflectionsGain = 0.0f; flReflectionsGain = 0.0f;
flReflectionsDelay = 0.0f; flReflectionsDelay = 0.0f;
@ -372,15 +372,17 @@ public:
flLateReverbGain = 0.0f; flLateReverbGain = 0.0f;
flLateReverbDelay = 0.0f; flLateReverbDelay = 0.0f;
dMemset(flLateReverbPan, 0, sizeof(flLateReverbPan)); dMemset(flLateReverbPan, 0, sizeof(flLateReverbPan));
flEchoTime = 0.0f; flEchoTime = 0.075f;
flEchoDepth = 0.0f; flEchoDepth = 0.0f;
flModulationTime = 0.0f; flModulationTime = 0.04f;
flModulationDepth = 0.0f; flModulationDepth = 0.0f;
flAirAbsorptionGainHF = 0.0f; flAirAbsorptionGainHF = 0.892f;
flHFReference = 0.0f; flHFReference = 0.0f;
flLFReference = 0.0f; flLFReference = 0.0f;
flRoomRolloffFactor = 0.0f; flRoomRolloffFactor = 0.0f;
iDecayHFLimit = 0; iDecayHFLimit = 0;
validate();
} }
void validate() void validate()

View file

@ -173,7 +173,6 @@ SFXDescription::SFXDescription( const SFXDescription& desc )
mStreamPacketSize( desc.mStreamPacketSize ), mStreamPacketSize( desc.mStreamPacketSize ),
mUseReverb( desc.mUseReverb ), mUseReverb( desc.mUseReverb ),
mStreamReadAhead( desc.mStreamReadAhead ), mStreamReadAhead( desc.mStreamReadAhead ),
mReverb( desc.mReverb ),
mScatterDistance( desc.mScatterDistance ), mScatterDistance( desc.mScatterDistance ),
mPriority( desc.mPriority ) mPriority( desc.mPriority )
{ {
@ -206,7 +205,6 @@ SFXDescription::SFXDescription(const SFXDescription& other, bool temp_clone)
mStreamPacketSize( other.mStreamPacketSize ), mStreamPacketSize( other.mStreamPacketSize ),
mStreamReadAhead( other.mStreamReadAhead ), mStreamReadAhead( other.mStreamReadAhead ),
mUseReverb( other.mUseReverb ), mUseReverb( other.mUseReverb ),
mReverb( other.mReverb ),
mPriority( other.mPriority ), mPriority( other.mPriority ),
mScatterDistance( other.mScatterDistance ) mScatterDistance( other.mScatterDistance )
{ {
@ -390,54 +388,12 @@ void SFXDescription::initPersistFields()
addGroup( "Reverb" ); addGroup( "Reverb" );
addField("useCustomReverb", TypeBool, Offset(mUseReverb, SFXDescription), addField("allowReverb", TypeBool, Offset(mUseReverb, SFXDescription),
"If true, use the reverb properties defined here on sounds.\n" "If true, use the reverb properties defined here on sounds.\n"
"By default, sounds will be assigned a generic reverb profile. By setting this flag to true, " "By default, sounds will be assigned a generic reverb profile. By setting this flag to true, "
"a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned " "a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned "
"to sounds playing with the description.\n\n" "to sounds playing with the description.\n\n"
"@ref SFX_reverb"); "@ref SFX_reverb");
addFieldV("reverbDensity", TypeRangedF32, Offset(mReverb.flDensity, SFXDescription), &CommonValidators::PositiveFloat,
"Density of reverb environment.");
addFieldV("reverbDiffusion", TypeRangedF32, Offset(mReverb.flDiffusion, SFXDescription), &CommonValidators::PositiveFloat,
"Environment diffusion.");
addFieldV("reverbGain", TypeRangedF32, Offset(mReverb.flGain, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb Gain Level.");
addFieldV("reverbGainHF", TypeRangedF32, Offset(mReverb.flGainHF, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb Gain to high frequencies");
addFieldV("reverbGainLF", TypeRangedF32, Offset(mReverb.flGainLF, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb Gain to high frequencies");
addFieldV("reverbDecayTime", TypeRangedF32, Offset(mReverb.flDecayTime, SFXDescription), &CommonValidators::PositiveFloat,
"Decay time for the reverb.");
addFieldV("reverbDecayHFRatio", TypeRangedF32, Offset(mReverb.flDecayHFRatio, SFXDescription), &CommonValidators::PositiveFloat,
"High frequency decay time ratio.");
addFieldV("reverbDecayLFRatio", TypeRangedF32, Offset(mReverb.flDecayLFRatio, SFXDescription), &CommonValidators::PositiveFloat,
"High frequency decay time ratio.");
addFieldV("reflectionsGain", TypeRangedF32, Offset(mReverb.flReflectionsGain, SFXDescription), &CommonValidators::PositiveFloat,
"Reflection Gain.");
addFieldV("reflectionDelay", TypeRangedF32, Offset(mReverb.flReflectionsDelay, SFXDescription), &CommonValidators::PositiveFloat,
"How long to delay reflections.");
addFieldV("lateReverbGain", TypeRangedF32, Offset(mReverb.flLateReverbGain, SFXDescription), &CommonValidators::PositiveFloat,
"Late reverb gain amount.");
addFieldV("lateReverbDelay", TypeRangedF32, Offset(mReverb.flLateReverbDelay, SFXDescription), &CommonValidators::PositiveFloat,
"Late reverb delay time.");
addFieldV("reverbEchoTime", TypeRangedF32, Offset(mReverb.flEchoTime, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb echo time.");
addFieldV("reverbEchoDepth", TypeRangedF32, Offset(mReverb.flEchoDepth, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb echo depth.");
addFieldV("reverbModTime", TypeRangedF32, Offset(mReverb.flModulationTime, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb Modulation time.");
addFieldV("reverbModDepth", TypeRangedF32, Offset(mReverb.flModulationDepth, SFXDescription), &CommonValidators::NormalizedFloat,
"Reverb Modulation Depth.");
addFieldV("airAbsorbtionGainHF", TypeRangedF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription), &CommonValidators::PositiveFloat,
"High Frequency air absorbtion");
addFieldV("reverbHFRef", TypeRangedF32, Offset(mReverb.flHFReference, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb High Frequency Reference.");
addFieldV("reverbLFRef", TypeRangedF32, Offset(mReverb.flLFReference, SFXDescription), &CommonValidators::PositiveFloat,
"Reverb Low Frequency Reference.");
addFieldV("roomRolloffFactor", TypeRangedF32, Offset(mReverb.flRoomRolloffFactor, SFXDescription), &CommonValidators::NegDefaultF32,
"Rolloff factor for reverb.");
addFieldV("decayHFLimit", TypeRangedS32, Offset(mReverb.iDecayHFLimit, SFXDescription), &CommonValidators::PositiveInt,
"High Frequency decay limit.");
endGroup("Reverb"); endGroup("Reverb");
Parent::initPersistFields(); Parent::initPersistFields();
@ -495,11 +451,6 @@ void SFXDescription::validate()
mConeInsideAngle = mClamp( mConeInsideAngle, 0, 360 ); mConeInsideAngle = mClamp( mConeInsideAngle, 0, 360 );
mConeOutsideAngle = mClamp( mConeOutsideAngle, mConeInsideAngle, 360 ); mConeOutsideAngle = mClamp( mConeOutsideAngle, mConeInsideAngle, 360 );
mConeOutsideVolume = mClampF( mConeOutsideVolume, 0, 1 ); mConeOutsideVolume = mClampF( mConeOutsideVolume, 0, 1 );
if( !mIs3D )
mUseReverb = false;
mReverb.validate();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -534,30 +485,6 @@ void SFXDescription::packData( BitStream *stream )
stream->writeFloat( mConeOutsideVolume, 6 ); stream->writeFloat( mConeOutsideVolume, 6 );
if( mUseReverb )
{
stream->write(mReverb.flDensity);
stream->write(mReverb.flDiffusion);
stream->write(mReverb.flGain);
stream->write(mReverb.flGainHF);
stream->write(mReverb.flGainLF);
stream->write(mReverb.flDecayTime);
stream->write(mReverb.flDecayHFRatio);
stream->write(mReverb.flDecayLFRatio);
stream->write(mReverb.flReflectionsGain);
stream->write(mReverb.flReflectionsDelay);
stream->write(mReverb.flLateReverbGain);
stream->write(mReverb.flLateReverbDelay);
stream->write(mReverb.flEchoTime);
stream->write(mReverb.flEchoDepth);
stream->write(mReverb.flModulationTime);
stream->write(mReverb.flModulationDepth);
stream->write(mReverb.flAirAbsorptionGainHF);
stream->write(mReverb.flHFReference);
stream->write(mReverb.flLFReference);
stream->write(mReverb.flRoomRolloffFactor);
stream->write(mReverb.iDecayHFLimit);
}
} }
stream->write( mFadeInTime ); stream->write( mFadeInTime );
@ -607,30 +534,6 @@ void SFXDescription::unpackData( BitStream *stream )
mConeOutsideVolume = stream->readFloat( 6 ); mConeOutsideVolume = stream->readFloat( 6 );
if( mUseReverb )
{
stream->read(&mReverb.flDensity);
stream->read(&mReverb.flDiffusion);
stream->read(&mReverb.flGain);
stream->read(&mReverb.flGainHF);
stream->read(&mReverb.flGainLF);
stream->read(&mReverb.flDecayTime);
stream->read(&mReverb.flDecayHFRatio);
stream->read(&mReverb.flDecayLFRatio);
stream->read(&mReverb.flReflectionsGain);
stream->read(&mReverb.flReflectionsDelay);
stream->read(&mReverb.flLateReverbGain);
stream->read(&mReverb.flLateReverbDelay);
stream->read(&mReverb.flEchoTime);
stream->read(&mReverb.flEchoDepth);
stream->read(&mReverb.flModulationTime);
stream->read(&mReverb.flModulationDepth);
stream->read(&mReverb.flAirAbsorptionGainHF);
stream->read(&mReverb.flHFReference);
stream->read(&mReverb.flLFReference);
stream->read(&mReverb.flRoomRolloffFactor);
stream->read(&mReverb.iDecayHFLimit);
}
} }
stream->read( &mFadeInTime ); stream->read( &mFadeInTime );

View file

@ -171,9 +171,6 @@ class SFXDescription : public SimDataBlock
/// Only relevant if "isStreaming" is true. /// Only relevant if "isStreaming" is true.
U32 mStreamReadAhead; U32 mStreamReadAhead;
/// Reverb properties for sound playback.
SFXSoundReverbProperties mReverb;
/// Parameters to which sources playing with this description should automatically /// Parameters to which sources playing with this description should automatically
/// connect when created. /// connect when created.
StringTableEntry mParameters[ MaxNumParameters ]; StringTableEntry mParameters[ MaxNumParameters ];

View file

@ -261,10 +261,8 @@ bool SFXSound::_allocVoice( SFXDevice* device )
_setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume ); _setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume );
} }
// Set reverb, if enabled. // Set reverb, if the source group allows it.
mVoice->setReverb(getSourceGroup()->getDescription()->mUseReverb);
if( mDescription->mUseReverb )
mVoice->setReverb( mDescription->mReverb );
// Update the duration... it shouldn't have changed, but // Update the duration... it shouldn't have changed, but
// its probably better that we're accurate if it did. // its probably better that we're accurate if it did.

View file

@ -157,7 +157,7 @@ void SFXSoundscapeManager::update()
if( !soundscape->_isOverridden() ) if( !soundscape->_isOverridden() )
{ {
SFXTrack* track = ambience->getSoundTrackProfile(); SFXTrack* track = ambience->getSoundTrackSFXTrack();
if( !soundscape->mSource || soundscape->mSource->getTrack() != track ) if( !soundscape->mSource || soundscape->mSource->getTrack() != track )
{ {
if( soundscape->mSource != NULL ) if( soundscape->mSource != NULL )

View file

@ -1621,13 +1621,13 @@ DefineEngineFunction( sfxPlayOnce, S32, (StringTableEntry assetId, const char* a
if (String::isEmpty(arg0) || !tempSoundAsset->is3D()) if (String::isEmpty(arg0) || !tempSoundAsset->is3D())
{ {
source = SFX->playOnce(tempSoundAsset->getSfxProfile()); source = SFX->playOnce(tempSoundAsset->getSFXTrack());
} }
else else
{ {
MatrixF transform; MatrixF transform;
transform.set(EulerF(0, 0, 0), Point3F(dAtof(arg0), dAtof(arg1), dAtof(arg2))); transform.set(EulerF(0, 0, 0), Point3F(dAtof(arg0), dAtof(arg1), dAtof(arg2)));
source = SFX->playOnce(tempSoundAsset->getSfxProfile(), &transform, NULL, dAtof(arg3)); source = SFX->playOnce(tempSoundAsset->getSFXTrack(), &transform, NULL, dAtof(arg3));
} }
} }
else else

View file

@ -212,7 +212,7 @@ class SFXVoice : public StrongRefBase,
/// Set the reverb properties for playback of this sound. /// Set the reverb properties for playback of this sound.
/// @note Has no effect on devices that do not support reverb. /// @note Has no effect on devices that do not support reverb.
virtual void setReverb( const SFXSoundReverbProperties& reverb ) {} virtual void setReverb( bool useReverb ) {}
/// Set the priority of this voice. Default 1.0. /// Set the priority of this voice. Default 1.0.
/// @note Has no effect on devices that do not support voice management. /// @note Has no effect on devices that do not support voice management.

View file

@ -50,7 +50,7 @@ void EyeSpaceDepthOutHLSL::processVert( Vector<ShaderComponent*> &componentLis
eyePos->setType("float3"); eyePos->setType("float3");
eyePos->setName("eyePosWorld"); eyePos->setName("eyePosWorld");
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
meta->addStatement( new GenOp( " @ = float4( @.xyz - @, 1 );\r\n", outWSEyeVec, wsPosition, eyePos ) ); meta->addStatement( new GenOp( " @ = float4( @.xyz - @, 1 );\r\n", outWSEyeVec, wsPosition, eyePos ) );
@ -74,7 +74,7 @@ void EyeSpaceDepthOutHLSL::processPix( Vector<ShaderComponent*> &componentList,
vEye->setType("float3"); vEye->setType("float3");
vEye->setName("vEye"); vEye->setName("vEye");
vEye->uniform = true; vEye->uniform = true;
vEye->constSortPos = cspPass; vEye->constSortPos = cspScene;
// Expose the depth to the depth format feature // Expose the depth to the depth format feature
Var *depthOut = new Var; Var *depthOut = new Var;
@ -99,7 +99,7 @@ void EyeSpaceDepthOutHLSL::processPix( Vector<ShaderComponent*> &componentList,
farDist->setType("float4"); farDist->setType("float4");
farDist->setName("oneOverFarplane"); farDist->setName("oneOverFarplane");
farDist->uniform = true; farDist->uniform = true;
farDist->constSortPos = cspPass; farDist->constSortPos = cspScene;
} }
meta->addStatement( new GenOp( " @ = length( @.xyz / @.w ) * @.x;\r\n", depthOutDecl, wsEyeVec, wsEyeVec, farDist ) ); meta->addStatement( new GenOp( " @ = length( @.xyz / @.w ) * @.x;\r\n", depthOutDecl, wsEyeVec, wsEyeVec, farDist ) );

View file

@ -593,7 +593,7 @@ Var* ShaderFeatureHLSL::getModelView( Vector<ShaderComponent*> &componentList,
viewProj->setType( "float4x4" ); viewProj->setType( "float4x4" );
viewProj->setName( "viewProj" ); viewProj->setName( "viewProj" );
viewProj->uniform = true; viewProj->uniform = true;
viewProj->constSortPos = cspPass; viewProj->constSortPos = cspScene;
} }
modelview = new Var; modelview = new Var;
@ -893,7 +893,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
{ {
wsEyePos = new Var("eyePosWorld", "float3"); wsEyePos = new Var("eyePosWorld", "float3");
wsEyePos->uniform = true; wsEyePos->uniform = true;
wsEyePos->constSortPos = cspPass; wsEyePos->constSortPos = cspScene;
} }
Var *wsPosition = getInWsPosition(componentList); Var *wsPosition = getInWsPosition(componentList);
@ -1867,7 +1867,7 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
{ {
eyePos = new Var( "eyePosWorld", "float3" ); eyePos = new Var( "eyePosWorld", "float3" );
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
// eye to vert // eye to vert
@ -2152,7 +2152,7 @@ void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
{ {
eyePos = new Var( "eyePosWorld", "float3" ); eyePos = new Var( "eyePosWorld", "float3" );
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
//Temporarily disabled while we figure out how to better handle normals without a normal map //Temporarily disabled while we figure out how to better handle normals without a normal map
@ -2237,43 +2237,43 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
Var *inLightPos = new Var( "inLightPos", "float4" ); Var *inLightPos = new Var( "inLightPos", "float4" );
inLightPos->uniform = true; inLightPos->uniform = true;
inLightPos->arraySize = 4; inLightPos->arraySize = 4;
inLightPos->constSortPos = cspPotentialPrimitive; inLightPos->constSortPos = cspLightBuffer;
Var * inLightConfigData = new Var( "inLightConfigData", "float4" ); Var * inLightConfigData = new Var( "inLightConfigData", "float4" );
inLightConfigData->uniform = true; inLightConfigData->uniform = true;
inLightConfigData->arraySize = 4; inLightConfigData->arraySize = 4;
inLightConfigData->constSortPos = cspPotentialPrimitive; inLightConfigData->constSortPos = cspLightBuffer;
Var *inLightColor = new Var( "inLightColor", "float4" ); Var *inLightColor = new Var( "inLightColor", "float4" );
inLightColor->uniform = true; inLightColor->uniform = true;
inLightColor->arraySize = 4; inLightColor->arraySize = 4;
inLightColor->constSortPos = cspPotentialPrimitive; inLightColor->constSortPos = cspLightBuffer;
Var *inLightSpotDir = new Var( "inLightSpotDir", "float4" ); Var *inLightSpotDir = new Var( "inLightSpotDir", "float4" );
inLightSpotDir->uniform = true; inLightSpotDir->uniform = true;
inLightSpotDir->arraySize = 4; inLightSpotDir->arraySize = 4;
inLightSpotDir->constSortPos = cspPotentialPrimitive; inLightSpotDir->constSortPos = cspLightBuffer;
Var * lightSpotParams = new Var( "inlightSpotParams", "float2" ); Var * lightSpotParams = new Var( "inlightSpotParams", "float2" );
lightSpotParams->uniform = true; lightSpotParams->uniform = true;
lightSpotParams->arraySize = 4; lightSpotParams->arraySize = 4;
lightSpotParams->constSortPos = cspPotentialPrimitive; lightSpotParams->constSortPos = cspLightBuffer;
Var* hasVectorLight = new Var("hasVectorLight", "int"); Var* hasVectorLight = new Var("hasVectorLight", "int");
hasVectorLight->uniform = true; hasVectorLight->uniform = true;
hasVectorLight->constSortPos = cspPotentialPrimitive; hasVectorLight->constSortPos = cspLightBuffer;
Var* vectorLightDirection = new Var("vectorLightDirection", "float4"); Var* vectorLightDirection = new Var("vectorLightDirection", "float4");
vectorLightDirection->uniform = true; vectorLightDirection->uniform = true;
vectorLightDirection->constSortPos = cspPotentialPrimitive; vectorLightDirection->constSortPos = cspLightBuffer;
Var* vectorLightColor = new Var("vectorLightColor", "float4"); Var* vectorLightColor = new Var("vectorLightColor", "float4");
vectorLightColor->uniform = true; vectorLightColor->uniform = true;
vectorLightColor->constSortPos = cspPotentialPrimitive; vectorLightColor->constSortPos = cspLightBuffer;
Var* vectorLightBrightness = new Var("vectorLightBrightness", "float"); Var* vectorLightBrightness = new Var("vectorLightBrightness", "float");
vectorLightBrightness->uniform = true; vectorLightBrightness->uniform = true;
vectorLightBrightness->constSortPos = cspPotentialPrimitive; vectorLightBrightness->constSortPos = cspLightBuffer;
Var* surface = getSurface(componentList, meta, fd); Var* surface = getSurface(componentList, meta, fd);
if (!surface) if (!surface)
@ -2289,7 +2289,7 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
{ {
ambient = new Var("ambient", "float4"); ambient = new Var("ambient", "float4");
ambient->uniform = true; ambient->uniform = true;
ambient->constSortPos = cspPass; ambient->constSortPos = cspScene;
} }
Var* lighting = new Var("lighting", "float4"); Var* lighting = new Var("lighting", "float4");
@ -2349,12 +2349,12 @@ void FogFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
{ {
eyePos = new Var( "eyePosWorld", "float3" ); eyePos = new Var( "eyePosWorld", "float3" );
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
Var *fogData = new Var( "fogData", "float3" ); Var *fogData = new Var( "fogData", "float3" );
fogData->uniform = true; fogData->uniform = true;
fogData->constSortPos = cspPass; fogData->constSortPos = cspScene;
Var *wsPosition = new Var( "fogPos", "float3" ); Var *wsPosition = new Var( "fogPos", "float3" );
getWsPosition( componentList, getWsPosition( componentList,
@ -2393,7 +2393,7 @@ void FogFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
fogColor->setType( "float4" ); fogColor->setType( "float4" );
fogColor->setName( "fogColor" ); fogColor->setName( "fogColor" );
fogColor->uniform = true; fogColor->uniform = true;
fogColor->constSortPos = cspPass; fogColor->constSortPos = cspScene;
// Get the out color. // Get the out color.
Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
@ -2429,12 +2429,12 @@ void FogFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
{ {
eyePos = new Var( "eyePosWorld", "float3" ); eyePos = new Var( "eyePosWorld", "float3" );
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
Var *fogData = new Var( "fogData", "float3" ); Var *fogData = new Var( "fogData", "float3" );
fogData->uniform = true; fogData->uniform = true;
fogData->constSortPos = cspPass; fogData->constSortPos = cspScene;
/// Get the fog amount. /// Get the fog amount.
fogAmount = new Var( "fogAmount", "float" ); fogAmount = new Var( "fogAmount", "float" );
@ -2695,7 +2695,7 @@ void FoliageFeatureHLSL::processVert( Vector<ShaderComponent*> &componentList,
{ {
eyePos = new Var( "eyePosWorld", "float3" ); eyePos = new Var( "eyePosWorld", "float3" );
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
// All actual work is offloaded to this method. // All actual work is offloaded to this method.
@ -2832,7 +2832,7 @@ void ImposterVertFeatureHLSL::processVert( Vector<ShaderComponent*> &component
{ {
eyePos = new Var( "eyePosWorld", "float3" ); eyePos = new Var( "eyePosWorld", "float3" );
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
// Declare the outputs from this feature. // Declare the outputs from this feature.
@ -3153,7 +3153,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
eyePos->setType("float3"); eyePos->setType("float3");
eyePos->setName("eyePosWorld"); eyePos->setName("eyePosWorld");
eyePos->uniform = true; eyePos->uniform = true;
eyePos->constSortPos = cspPass; eyePos->constSortPos = cspScene;
} }
Var* accumTime = (Var*)LangElement::find("accumTime"); Var* accumTime = (Var*)LangElement::find("accumTime");
@ -3161,7 +3161,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
{ {
accumTime = new Var("accumTime", "float"); accumTime = new Var("accumTime", "float");
accumTime->uniform = true; accumTime->uniform = true;
accumTime->constSortPos = cspPass; accumTime->constSortPos = cspScene;
} }
Var* dampness = (Var*)LangElement::find("dampness"); Var* dampness = (Var*)LangElement::find("dampness");
@ -3169,7 +3169,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
{ {
dampness = new Var("dampness", "float"); dampness = new Var("dampness", "float");
dampness->uniform = true; dampness->uniform = true;
dampness->constSortPos = cspPass; dampness->constSortPos = cspScene;
} }
String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
@ -3185,7 +3185,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
{ {
ambient = new Var("ambient","float4"); ambient = new Var("ambient","float4");
ambient->uniform = true; ambient->uniform = true;
ambient->constSortPos = cspPass; ambient->constSortPos = cspScene;
} }
meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient));
meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl));

View file

@ -73,10 +73,14 @@ enum ConstantSortPosition
cspUninit = 0, cspUninit = 0,
/// Updated before every draw primitive call. /// Updated before every draw primitive call.
cspPrimitive, cspPrimitive,
/// Potentially updated every draw primitive call, but not necessarily (lights for example) /// Potentially updated every draw primitive call
cspPotentialPrimitive, cspPotentialPrimitive,
/// Updated one per pass /// Unique buffer just for lights.
cspLightBuffer,
/// Updated per pass
cspPass, cspPass,
/// per scene const buffers (should only be set once)
cspScene,
/// Count var, do not use /// Count var, do not use
csp_Count csp_Count
}; };

View file

@ -1,10 +1,9 @@
<SoundAsset <SoundAsset
AssetName="buttonClick" AssetName="buttonClick"
sourceGroup="AudioChannelDefault" sourceGroup="AudioChannelGui"
MaxDistance="100"> originalFilePath="core/gui/sounds/buttonClick.wav">
<SoundAsset.slots> <SoundAsset.slots>
<slots_beginarray <slots_beginarray
SoundFile="@assetFile=buttonClick.wav" SoundFile="@assetFile=@buttonClick.wav"/>
MaxDistance="100"/>
</SoundAsset.slots> </SoundAsset.slots>
</SoundAsset> </SoundAsset>

View file

@ -1,10 +1,9 @@
<SoundAsset <SoundAsset
AssetName="buttonHover" AssetName="buttonHover"
sourceGroup="AudioChannelDefault" sourceGroup="AudioChannelGui"
MaxDistance="100"> originalFilePath="core/gui/sounds/buttonHover.wav">
<SoundAsset.slots> <SoundAsset.slots>
<slots_beginarray <slots_beginarray
SoundFile="@assetFile=buttonHover.wav" SoundFile="@assetFile=@buttonHover.wav"/>
MaxDistance="100"/>
</SoundAsset.slots> </SoundAsset.slots>
</SoundAsset> </SoundAsset>

View file

@ -35,6 +35,13 @@ singleton SFXDescription( AudioChannel )
sourceGroup = AudioChannelMaster; sourceGroup = AudioChannelMaster;
}; };
singleton SFXDescription( AudioEffectChannel )
{
sourceGroup = AudioChannelMaster;
allowReverb = true;
};
singleton SFXSource( AudioChannelDefault ) singleton SFXSource( AudioChannelDefault )
{ {
description = AudioChannel; description = AudioChannel;
@ -45,7 +52,7 @@ singleton SFXSource( AudioChannelGui )
}; };
singleton SFXSource( AudioChannelEffects ) singleton SFXSource( AudioChannelEffects )
{ {
description = AudioChannel; description = AudioEffectChannel;
}; };
singleton SFXSource( AudioChannelMessages ) singleton SFXSource( AudioChannelMessages )
{ {
@ -66,7 +73,7 @@ AudioChannelMusic.play();
AudioChannelMessages.play(); AudioChannelMessages.play();
// Stop in-game effects channels. // Stop in-game effects channels.
AudioChannelEffects.stop(); AudioChannelEffects.play();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Master SFXDescriptions. // Master SFXDescriptions.

View file

@ -170,8 +170,8 @@ singleton GuiControlProfile( GuiMenuButtonProfile )
justify = "center"; justify = "center";
canKeyFocus = false; canKeyFocus = false;
hasBitmapArray = false; hasBitmapArray = false;
soundButtonDown = "UI:buttonClick"; soundButtonDownAsset = "UI:buttonClick";
soundButtonOver = "UI:buttonHover"; soundButtonOverAsset = "UI:buttonHover";
category = "BaseUI"; category = "BaseUI";
fontColors[0] = "200 200 200 255"; fontColors[0] = "200 200 200 255";
fontColors[2] = "108 108 108 255"; fontColors[2] = "108 108 108 255";

View file

@ -1,10 +1,8 @@
<SoundAsset <SoundAsset
AssetName="buttonClick" AssetName="buttonClick"
soundFile="@assetFile=buttonClick.wav" originalFilePath="data/UI/sounds/buttonClick.wav">
PitchAdjust="1" <SoundAsset.slots>
VolumeAdjust="1" <slots_beginarray
is3D="false" SoundFile="@assetFile=@buttonClick.wav"/>
minDistance="1" </SoundAsset.slots>
maxDistance="100" </SoundAsset>
sourceGroup="AudioChannelGui"
/>

View file

@ -1,10 +1,9 @@
<SoundAsset <SoundAsset
AssetName="buttonHover" AssetName="buttonHover"
soundFile="@assetFile=buttonHover.wav" sourceGroup="AudioChannelGui"
PitchAdjust="1" originalFilePath="data/UI/sounds/buttonHover.wav">
VolumeAdjust="1" <SoundAsset.slots>
is3D="false" <slots_beginarray
minDistance="1" SoundFile="@assetFile=@buttonHover.wav"/>
maxDistance="100" </SoundAsset.slots>
sourceGroup="AudioChannelGui" </SoundAsset>
/>

View file

@ -13,6 +13,54 @@ function SoundAsset::onChanged(%this)
sfxStop($PreviewSoundSource); sfxStop($PreviewSoundSource);
} }
function SoundAsset::onShowActionMenu(%this)
{
GenericAsset::onShowActionMenu(%this);
%assetId = %this.getAssetId();
EditAssetPopup.objectData = %assetId;
EditAssetPopup.objectType = AssetDatabase.getAssetType(%assetId);
EditAssetPopup.reloadItems();
EditAssetPopup.showPopup(Canvas);
}
function SoundAsset::onEditProperties(%this)
{
Canvas.pushDialog(AssetBrowser_editAsset);
AssetBrowser_editAssetWindow.text = "Asset Properties - " @ %this.getAssetId();
AssetEditInspector.tempAsset = %this.deepClone();
AssetEditInspector.inspect(%this);
AssetBrowser_editAsset.editedObjectData = %this.getAssetId();
AssetBrowser_editAsset.editedObject = %this;
AssetBrowser_editAsset.editedObjectType = AssetDatabase.getAssetType(%this.getAssetId());
//remove some of the groups we don't need:
for(%i=0; %i < AssetEditInspector.getCount(); %i++)
{
%caption = AssetEditInspector.getObject(%i).caption;
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
{
AssetEditInspector.remove(AssetEditInspector.getObject(%i));
%i--;
}
}
}
//Called when the AssetType has it's properties saved from the onEditProperties process
function SoundAsset::onSaveProperties(%this)
{
%this.refreshAsset();
}
function SoundAsset::buildBrowserElement(%this, %previewData) function SoundAsset::buildBrowserElement(%this, %previewData)
{ {
%previewData.assetName = %this.assetName; %previewData.assetName = %this.assetName;