Refactor of sound asset

Refactored to match image asset.
This commit is contained in:
marauder2k7 2026-04-05 14:17:17 +01:00
parent 5796f0ea07
commit 71273e63c9
46 changed files with 639 additions and 775 deletions

View file

@ -59,31 +59,43 @@
IMPLEMENT_CONOBJECT(SoundAsset); IMPLEMENT_CONOBJECT(SoundAsset);
ConsoleType(SoundAssetPtr, TypeSoundAssetPtr, const char*, ASSET_ID_FIELD_PREFIX) 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.");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -134,7 +146,7 @@ SoundAsset::SoundAsset()
for (U32 i = 0; i < SFXPlayList::NUM_SLOTS; i++) for (U32 i = 0; i < SFXPlayList::NUM_SLOTS; i++)
{ {
mSoundFile[i] = StringTable->EmptyString(); mSoundFile[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,25 +185,41 @@ SoundAsset::SoundAsset()
mProfileDesc.mPriority = 1.0f; mProfileDesc.mPriority = 1.0f;
mProfileDesc.mSourceGroup = NULL; mProfileDesc.mSourceGroup = NULL;
mProfileDesc.mFadeInEase = EaseF(); mProfileDesc.mFadeInEase = EaseF();
mProfileDesc.mSourceGroup = dynamic_cast<SFXSource*>(Sim::findObject("AudioChannelMaster"));
mProfileDesc.mReverb = SFXSoundReverbProperties(); mProfileDesc.mReverb = SFXSoundReverbProperties();
dMemset(mProfileDesc.mParameters, 0, sizeof(mProfileDesc.mParameters)); dMemset(mProfileDesc.mParameters, 0, sizeof(mProfileDesc.mParameters));
mIsPlaylist = false; mIsPlaylist = false;
dMemset(mProfileDesc.mParameters, 0, sizeof(mProfileDesc.mParameters));
mIsPlaylist = false;
mPlaylist.mNumSlotsToPlay = SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; mPlaylist.mNumSlotsToPlay = SFXPlayList::SFXPlaylistSettings::NUM_SLOTS;
mPlaylist.mRandomMode = SFXPlayList::RANDOM_NotRandom; mPlaylist.mRandomMode = SFXPlayList::RANDOM_NotRandom;
mPlaylist.mTrace = false; mPlaylist.mTrace = false;
mPlaylist.mLoopMode = SFXPlayList::LOOP_All; mPlaylist.mLoopMode = SFXPlayList::LOOP_All;
mPlaylist.mActiveSlots = 1; mPlaylist.mActiveSlots = 1;
mResolvedTrack = NULL;
mResolvedDescription = NULL;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SoundAsset::~SoundAsset() SoundAsset::~SoundAsset()
{ {
if (mResolvedTrack)
{
if (mResolvedTrack->isProperlyAdded() && !mResolvedTrack->isDeleted())
mResolvedTrack->deleteObject();
}
if (mPlaylist.isProperlyAdded() && !mPlaylist.isDeleted()) if (mResolvedDescription)
mPlaylist.unregisterObject(); {
if (mResolvedDescription->isProperlyAdded() && !mResolvedDescription->isDeleted())
mResolvedDescription->deleteObject();
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -317,15 +345,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())
@ -334,135 +384,60 @@ 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)
{ {
for (U32 i = 0; i < SFXPlayList::NUM_SLOTS; i++) for (U32 i = 0; i < SFXPlayList::NUM_SLOTS; i++)
{ {
if (path != Torque::Path(mSoundPath[i])) if (path != Torque::Path(mSoundFile[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;
return mLoadedState;
}
else
{
mSFXProfile[i] = new SFXProfile;
mSFXProfile[i]->setDescription(&mProfileDesc);
mSFXProfile[i]->setSoundFileName(mSoundPath[i]);
mSFXProfile[i]->setPreload(mPreload);
mSFXProfile[i]->registerObject(String::ToString("%s_profile_track%d", getAssetName()).c_str());
mPlaylist.mSlots.mTrack[i] = mSFXProfile[i];
}
}
} }
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;
return mLoadedState;
}
else
{
mSFXProfile[0] = new SFXProfile;
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();
@ -478,7 +453,7 @@ StringTableEntry SoundAsset::getAssetIdByFileName(StringTableEntry fileName)
SoundAsset* soundAsset = AssetDatabase.acquireAsset<SoundAsset>(query.mAssetList[i]); SoundAsset* soundAsset = AssetDatabase.acquireAsset<SoundAsset>(query.mAssetList[i]);
if (soundAsset) if (soundAsset)
{ {
if (soundAsset->getSoundPath() == fileName) if (soundAsset->getSoundFile() == fileName)
soundAssetId = soundAsset->getAssetId(); soundAssetId = soundAsset->getAssetId();
AssetDatabase.releaseAsset(query.mAssetList[i]); AssetDatabase.releaseAsset(query.mAssetList[i]);
@ -505,7 +480,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");
@ -520,7 +495,7 @@ U32 SoundAsset::getAssetByFileName(StringTableEntry fileName, AssetPtr<SoundAsse
for (U32 i = 0; i < foundAssetcount; i++) for (U32 i = 0; i < foundAssetcount; i++)
{ {
SoundAsset* tSoundAsset = AssetDatabase.acquireAsset<SoundAsset>(query.mAssetList[i]); SoundAsset* tSoundAsset = AssetDatabase.acquireAsset<SoundAsset>(query.mAssetList[i]);
if (tSoundAsset && tSoundAsset->getSoundPath() == fileName) if (tSoundAsset && tSoundAsset->getSoundFile() == fileName)
{ {
soundAsset->setAssetId(query.mAssetList[i]); soundAsset->setAssetId(query.mAssetList[i]);
AssetDatabase.releaseAsset(query.mAssetList[i]); AssetDatabase.releaseAsset(query.mAssetList[i]);
@ -534,9 +509,162 @@ U32 SoundAsset::getAssetByFileName(StringTableEntry fileName, AssetPtr<SoundAsse
return AssetErrCode::Failed; return AssetErrCode::Failed;
} }
void SoundAsset::buildDescription()
{
if (!mResolvedDescription)
{
mResolvedDescription = new SFXDescription;
// calls on add which should validate the description. but do it on mProfileDesc before applying values anyway.
mResolvedDescription->registerObject(String::ToString("%s_profile_description", getAssetName()).c_str());
}
mProfileDesc.validate();
mResolvedDescription->mPitch = mProfileDesc.mPitch;
mResolvedDescription->mVolume = mProfileDesc.mVolume;
mResolvedDescription->mIs3D = mProfileDesc.mIs3D;
mResolvedDescription->mIsLooping = mProfileDesc.mIsLooping;
mResolvedDescription->mIsStreaming = mProfileDesc.mIsStreaming;
mResolvedDescription->mUseHardware = mProfileDesc.mUseHardware;
mResolvedDescription->mMinDistance = mProfileDesc.mMinDistance;
mResolvedDescription->mMaxDistance = mProfileDesc.mMaxDistance;
mResolvedDescription->mConeInsideAngle = mProfileDesc.mConeInsideAngle;
mResolvedDescription->mConeOutsideAngle = mProfileDesc.mConeOutsideAngle;
mResolvedDescription->mConeOutsideVolume = mProfileDesc.mConeOutsideVolume;
mResolvedDescription->mRolloffFactor = mProfileDesc.mRolloffFactor;
mResolvedDescription->mFadeInTime = mProfileDesc.mFadeInTime;
mResolvedDescription->mFadeOutTime = mProfileDesc.mFadeOutTime;
mResolvedDescription->mFadeLoops = mProfileDesc.mFadeLoops;
mResolvedDescription->mScatterDistance = mProfileDesc.mScatterDistance;
mResolvedDescription->mStreamPacketSize = mProfileDesc.mStreamPacketSize;
mResolvedDescription->mStreamReadAhead = mProfileDesc.mStreamReadAhead;
mResolvedDescription->mPriority = mProfileDesc.mPriority;
mResolvedDescription->mSourceGroup = mProfileDesc.mSourceGroup;
mResolvedDescription->mFadeInEase = mProfileDesc.mFadeInEase;
mResolvedDescription->mSourceGroup = mProfileDesc.mSourceGroup;
}
SFXProfile* SoundAsset::buildProfile()
{
SFXProfile* profile = new SFXProfile(mResolvedDescription, 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(mResolvedDescription, 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);
buildDescription();
if (mResolvedTrack && mResolvedDescription)
{
if (SFX)
SFX->notifyDescriptionChanged(mResolvedDescription);
return;
}
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->getSoundFile();
} }
DefineEngineMethod(SoundAsset, playSound, S32, (Point3F position), (Point3F::Zero), DefineEngineMethod(SoundAsset, playSound, S32, (Point3F position), (Point3F::Zero),
@ -567,7 +695,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,21 +87,12 @@ 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];
SimObjectPtr<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!
Resource<SFXResource> mSoundResource; Resource<SFXResource> mSoundResource;
// SFXDesctriptions, some off these will be removed // SFXDesctriptions, some off these will be removed
F32 mPitchAdjust; F32 mPitchAdjust;
@ -121,9 +112,6 @@ protected:
F32 mPriority; F32 mPriority;
*/ */
typedef Signal<void()> SoundAssetChanged;
SoundAssetChanged mChangeSignal;
public: public:
enum SoundAssetErrCode enum SoundAssetErrCode
{ {
@ -142,179 +130,147 @@ 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];
Resource<SFXResource> mSoundResource[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
SFXDescription mProfileDesc;
SFXPlayList mPlaylist;
// subtitles
StringTableEntry mSubtitleString;
bool mPreload;
bool mIsPlaylist;
SFXTrack* mResolvedTrack;
SFXDescription* mResolvedDescription;
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].getPointer()); } inline StringTableEntry getRelativeSoundFile(U32 slot = 0) { return collapseAssetFilePath(mSoundFile[slot]); }
SFXDescription* getSfxDescription() { return &mProfileDesc; }
bool isPlaylist(){ return mIsPlaylist; } SFXTrack* getSFXTrack() { load(); return mResolvedTrack; }
SFXDescription* getSfxDescription() { return mResolvedDescription ? mResolvedDescription : &mProfileDesc; }
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);
void buildDescription();
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) DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
DefineConsoleType(TypeSoundAssetId, String) DefineConsoleType(TypeSoundAssetId, String)
#pragma region Singular Asset Macros #define DECLARE_SOUNDASSET(className, name) \
private: \
//Singular assets AssetPtr<SoundAsset> m##name##Asset; \
/// <Summary> StringTableEntry m##name##File = StringTable->EmptyString(); \
/// Declares a sound asset public: \
/// This establishes the assetId, asset and legacy filepath fields, along with supplemental getter and setter functions void _set##name(StringTableEntry _in){ \
/// </Summary> if(m##name##Asset.getAssetId() == _in) \
#define DECLARE_SOUNDASSET(className, name) public: \ return; \
Resource<SFXResource> m##name;\ if(get##name##File() == _in) \
StringTableEntry m##name##Name; \ return; \
StringTableEntry m##name##AssetId;\ if(_in == NULL || !String::compare(_in,StringTable->EmptyString())) \
AssetPtr<SoundAsset> m##name##Asset = NULL;\ { \
SFXTrack* m##name##Profile = NULL;\ m##name##Asset = NULL; \
SFXDescription* m##name##Desc = NULL;\ m##name##File = ""; \
SimObjectId m##name##SFXId = 0;\ return; \
public: \ } \
const StringTableEntry get##name##File() const { return m##name##Name; }\ if(!AssetDatabase.isDeclaredAsset(_in)) \
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; }\ StringTableEntry soundAssetId = StringTable->EmptyString(); \
void set##name##Asset(const AssetPtr<SoundAsset> &_in) { m##name##Asset = _in;}\ AssetQuery query; \
\ S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
bool _set##name(StringTableEntry _in)\ if (foundAssetcount != 0) \
{\ { \
if(m##name##AssetId != _in || m##name##Name != _in)\ soundAssetId = query.mAssetList[0]; \
{\ } \
if (_in == NULL || !String::compare(_in,StringTable->EmptyString()))\ else if(Torque::FS::IsFile(_in)) \
{\ { \
m##name##Name = StringTable->EmptyString();\ soundAssetId = SoundAsset::getAssetIdByFilename(_in); \
m##name##AssetId = StringTable->EmptyString();\ if (soundAssetId == StringTable->EmptyString()) \
m##name##Asset = NULL;\ { \
m##name = NULL;\ SoundAsset* privateSound = new SoundAsset(); \
return true;\ privateSound->setSoundFile(_in); \
}\ soundAssetId = AssetDatabase.addPrivateAsset(privateSound); \
\ } \
if (AssetDatabase.isDeclaredAsset(_in))\ } \
{\ else \
m##name##AssetId = _in;\ { \
\ Con::warnf("%s::%s: Could not find asset for: %s, there is no fallback for sound assets.", #className, #name, _in); \
U32 assetState = SoundAsset::getAssetById(m##name##AssetId, &m##name##Asset);\ soundAssetId = StringTable->EmptyString(); \
\ } \
if (SoundAsset::Ok == assetState)\ m##name##Asset = soundAssetId; \
{\ m##name##File = _in; \
m##name##Name = StringTable->EmptyString();\ } \
}\ else \
}\ { \
else\ m##name##Asset = _in; \
{\ m##name##File = get##name##File(); \
StringTableEntry assetId = SoundAsset::getAssetIdByFileName(_in);\ } \
if (assetId != StringTable->EmptyString())\ }; \
{\ \
m##name##AssetId = assetId;\ inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
if(SoundAsset::getAssetById(m##name##AssetId, &m##name##Asset) == SoundAsset::Ok)\ 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;} \
m##name##Name = StringTable->EmptyString();\ 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(#name, TypeSoundFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.), AbstractClassRep::FIELD_HideInInspectors); \
#define INITPERSISTFIELD_SOUNDASSET(name, consoleClass, docs) \ addProtectedField(assetText(name, Asset), TypeSoundAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.)); \
addProtectedField(assetText(name, File), TypeSoundFilename, Offset(m##name##Name, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs)); \ addProtectedField(assetText(name, File), TypeSoundFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.), AbstractClassRep::FIELD_HideInInspectors);
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 +330,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 +424,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); \
}\ }\
} }
@ -543,6 +437,5 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
m##name##AssetId[index] = AssetDatabase.unpackDataAsset(stream) m##name##AssetId[index] = AssetDatabase.unpackDataAsset(stream)
#pragma endregion #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"), NULL, 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;
@ -674,9 +671,7 @@ void ExplosionData::packData(BitStream* stream)
Parent::packData(stream); Parent::packData(stream);
PACKDATA_ASSET_REFACTOR(ExplosionShape); PACKDATA_ASSET_REFACTOR(ExplosionShape);
PACKDATA_ASSET_REFACTOR(Sound);
//PACKDATA_SOUNDASSET(Sound);
PACKDATA_ASSET(Sound);
if (stream->writeFlag(particleEmitter)) if (stream->writeFlag(particleEmitter))
stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast); stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
@ -779,8 +774,7 @@ void ExplosionData::unpackData(BitStream* stream)
Parent::unpackData(stream); Parent::unpackData(stream);
UNPACKDATA_ASSET_REFACTOR(ExplosionShape); UNPACKDATA_ASSET_REFACTOR(ExplosionShape);
UNPACKDATA_ASSET_REFACTOR(Sound);
UNPACKDATA_ASSET(Sound);
if (stream->readFlag()) if (stream->readFlag())
particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
@ -886,7 +880,7 @@ 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
} }
@ -1432,7 +1426,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

@ -70,8 +70,7 @@ class ExplosionData : public GameBaseData, protected AssetPtrCallback {
S32 particleDensity; S32 particleDensity;
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

@ -64,11 +64,8 @@ class LightningData : public GameBaseData
//-------------------------------------- Console set variables //-------------------------------------- Console set variables
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,8 +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);
stream->writeString(mDropShaderName); stream->writeString(mDropShaderName);
@ -205,8 +202,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);
mDropShaderName = stream->readSTString(); mDropShaderName = stream->readSTString();
@ -587,9 +583,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

@ -46,9 +46,7 @@ class PrecipitationData : public GameBaseData
typedef GameBaseData Parent; typedef GameBaseData Parent;
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
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops

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

@ -95,8 +95,7 @@ public:
//AudioProfile* soundProfile; //AudioProfile* soundProfile;
//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,8 +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)
{ {
_setPlayerSound(getPlayerSound(i), i); if (!getPlayerSoundSFXTrack(i))
if (!isPlayerSoundValid(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -1267,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);
@ -1448,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);
@ -1896,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;
@ -3224,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() );
} }
} }
@ -7051,26 +7045,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
{ {
@ -7083,7 +7077,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);
} }
} }
@ -7103,8 +7097,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;
@ -7114,7 +7108,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());
} }
} }
} }
@ -7268,11 +7262,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

@ -225,7 +225,7 @@ struct PlayerData: public ShapeBaseData /*protected AssetPtrCallback < already i
MaxSounds MaxSounds
}; };
DECLARE_SOUNDASSET_ARRAY(PlayerData, PlayerSound, Sounds::MaxSounds); DECLARE_SOUNDASSET_ARRAY(PlayerData, PlayerSound, Sounds::MaxSounds)
Point3F boxSize; ///< Width, depth, height Point3F boxSize; ///< Width, depth, height
Point3F crouchBoxSize; Point3F crouchBoxSize;

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

@ -115,8 +115,7 @@ public:
DecalData *decal; // (impact) Decal Datablock DecalData *decal; // (impact) Decal Datablock
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

@ -45,8 +45,7 @@ struct ProximityMineData: public ItemData
public: 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;
@ -54,8 +53,7 @@ public:
F32 triggerSpeed; F32 triggerSpeed;
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,8 +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++)
{ {
_setBodySounds(getBodySounds(i), i); if (!getBodySoundsSFXTrack(i))
if (!isBodySoundsValid(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -357,8 +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++)
{ {
_setWaterSounds(getWaterSounds(j), j); if (!getWaterSoundsSFXTrack(j))
if (!isWaterSoundsValid(j))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -421,11 +413,7 @@ 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);
stream->write(hardImpactSpeed); stream->write(hardImpactSpeed);
@ -452,13 +440,7 @@ void RigidShapeData::packData(BitStream* stream)
stream->write(medSplashSoundVel); stream->write(medSplashSoundVel);
stream->write(hardSplashSoundVel); stream->write(hardSplashSoundVel);
stream->write(enablePhysicsRep); stream->write(enablePhysicsRep);
PACKDATA_ASSET_ARRAY_REFACTOR(WaterSounds, Sounds::MaxSounds);
// write the water sound profiles
for (U32 i = 0; i < Sounds::MaxSounds; ++i)
{
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 );
@ -485,10 +467,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);
@ -518,10 +497,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);
@ -1212,27 +1188,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 );
} }
@ -409,7 +407,7 @@ U32 SFXEmitter::packUpdate(NetConnection* con, U32 mask, BitStream* stream)
// track // track
if (stream->writeFlag(mask & DirtyUpdateMask)){ if (stream->writeFlag(mask & DirtyUpdateMask)){
PACK_ASSET(con, Sound); PACK_ASSET_REFACTOR(con, Sound);
} }
//if (stream->writeFlag(mDirty.test(Track))) //if (stream->writeFlag(mDirty.test(Track)))
// sfxWrite( stream, mTrack ); // sfxWrite( stream, mTrack );
@ -524,7 +522,7 @@ void SFXEmitter::unpackUpdate( NetConnection *conn, BitStream *stream )
if (stream->readFlag()) // DirtyUpdateMask if (stream->readFlag()) // DirtyUpdateMask
{ {
initialUpdate = false; initialUpdate = false;
UNPACK_ASSET(conn, Sound); UNPACK_ASSET_REFACTOR(conn, Sound);
} }
/*if (_readDirtyFlag(stream, Track)) /*if (_readDirtyFlag(stream, Track))
{ {
@ -775,7 +773,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 +782,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 +796,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 +818,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 +1220,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

@ -121,10 +121,9 @@ class SFXEmitter : public SceneObject
/// The current dirty flags. /// The current dirty flags.
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
@ -327,8 +326,7 @@ 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
} }
@ -578,36 +575,7 @@ void ShapeBaseImageData::handleStateSoundTrack(const U32& stateId)
StateData& s = state[stateId]; StateData& s = state[stateId];
s.sound = getstateSoundAsset(stateId); s.soundTrack = getstateSoundSFXTrack(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 +1130,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 +1332,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 +2744,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 +2755,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,8 +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++)
{ {
_setFlyingSounds(getFlyingSounds(i), i); if (!getFlyingSoundsSFXTrack(i))
if (!isFlyingSoundsValid(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -259,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++)
{ {
@ -294,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;
@ -386,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

@ -45,8 +45,7 @@ struct FlyingVehicleData: public VehicleData {
EngineSound, EngineSound,
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,8 +310,7 @@ bool HoverVehicleData::preload(bool server, String &errorStr)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
_setHoverSounds(getHoverSounds(i), i); if (!getHoverSoundsSFXTrack(i))
if (!isHoverSoundsValid(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -366,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++)
{ {
@ -415,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;
@ -540,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->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

@ -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,8 +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++)
{ {
_setWheeledVehicleSounds(getWheeledVehicleSounds(i), i); if (!getWheeledVehicleSoundsSFXTrack(i))
if (!isWheeledVehicleSoundsValid(i))
{ {
//return false; -TODO: trigger asset download //return false; -TODO: trigger asset download
} }
@ -494,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);
@ -514,10 +508,7 @@ 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);
@ -701,14 +692,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;
@ -249,7 +247,7 @@ afxMagicMissileData::afxMagicMissileData(const afxMagicMissileData& other, bool
{ {
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

@ -123,8 +123,7 @@ public:
SplashData* splash; // Water Splash Datablock SplashData* splash; // Water Splash Datablock
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

@ -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;
@ -393,9 +391,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;
} }
//otherwise, pass the event to it's parent //otherwise, pass the event to it's parent

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

@ -264,8 +264,7 @@ class GuiMLTextCtrl : public GuiControl
bool mUseURLMouseCursor; bool mUseURLMouseCursor;
// 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;
@ -322,19 +320,8 @@ GuiControlProfile::GuiControlProfile(void) :
mTextOffset = def->mTextOffset; mTextOffset = def->mTextOffset;
// default sound // default sound
_setSoundButtonDown(def->getSoundButtonDown()); _setSoundButtonDown(def->getSoundButtonDownFile());
if (getSoundButtonDown() != StringTable->EmptyString()) _setSoundButtonOver(def->getSoundButtonOverFile());
{
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;

View file

@ -466,11 +466,8 @@ public:
bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering
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

@ -83,8 +83,7 @@ protected:
void _update(); void _update();
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,10 +356,8 @@ public:
/// Sound effect to play when walking on surface with this material. /// Sound effect to play when walking on surface with this material.
/// 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

@ -66,8 +66,7 @@ class SFXAmbience : public SimDataBlock
F32 mRolloffFactor; F32 mRolloffFactor;
/// 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

@ -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

@ -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;