mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
sound asset final cleanup
remove mSoundPath array no longer needed add a SFXDescription pointer to resolve to. cleanup on teardown
This commit is contained in:
parent
da40838560
commit
bcdac43338
2 changed files with 63 additions and 17 deletions
|
|
@ -152,7 +152,6 @@ 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;
|
mSoundResource[i] = NULL;
|
||||||
|
|
||||||
mPlaylist.mSlots.mTransitionOut[i] = SFXPlayList::TRANSITION_Wait;
|
mPlaylist.mSlots.mTransitionOut[i] = SFXPlayList::TRANSITION_Wait;
|
||||||
|
|
@ -204,12 +203,24 @@ SoundAsset::SoundAsset()
|
||||||
mPlaylist.mActiveSlots = 1;
|
mPlaylist.mActiveSlots = 1;
|
||||||
|
|
||||||
mResolvedTrack = NULL;
|
mResolvedTrack = NULL;
|
||||||
|
mResolvedDescription = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
SoundAsset::~SoundAsset()
|
SoundAsset::~SoundAsset()
|
||||||
{
|
{
|
||||||
|
if (mResolvedTrack)
|
||||||
|
{
|
||||||
|
if (mResolvedTrack->isProperlyAdded() && !mResolvedTrack->isDeleted())
|
||||||
|
mResolvedTrack->deleteObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mResolvedDescription)
|
||||||
|
{
|
||||||
|
if (mResolvedDescription->isProperlyAdded() && !mResolvedDescription->isDeleted())
|
||||||
|
mResolvedDescription->deleteObject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -387,7 +398,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -443,7 +454,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]);
|
||||||
|
|
@ -485,7 +496,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]);
|
||||||
|
|
@ -499,9 +510,44 @@ 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* SoundAsset::buildProfile()
|
||||||
{
|
{
|
||||||
SFXProfile* profile = new SFXProfile(&mProfileDesc, mSoundFile[0], mPreload);
|
SFXProfile* profile = new SFXProfile(mResolvedDescription, mSoundFile[0], mPreload);
|
||||||
mSoundResource[0] = profile->getResource();
|
mSoundResource[0] = profile->getResource();
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
@ -527,7 +573,7 @@ SFXPlayList* SoundAsset::buildPlaylist()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Build child SFXProfile
|
// Build child SFXProfile
|
||||||
SFXProfile* child = new SFXProfile(&mProfileDesc, mSoundFile[i], mPreload);
|
SFXProfile* child = new SFXProfile(mResolvedDescription, mSoundFile[i], mPreload);
|
||||||
mSoundResource[i] = child->getResource();
|
mSoundResource[i] = child->getResource();
|
||||||
pl->mSlots.mTrack[i] = child;
|
pl->mSlots.mTrack[i] = child;
|
||||||
}
|
}
|
||||||
|
|
@ -544,13 +590,14 @@ void SoundAsset::populateSFXTrack(void)
|
||||||
|
|
||||||
mIsPlaylist = (count > 1);
|
mIsPlaylist = (count > 1);
|
||||||
|
|
||||||
if (mResolvedTrack)
|
buildDescription();
|
||||||
|
|
||||||
|
if (mResolvedTrack && mResolvedDescription)
|
||||||
{
|
{
|
||||||
if (mResolvedTrack->isProperlyAdded() && !mResolvedTrack->isDeleted())
|
if (SFX)
|
||||||
{
|
SFX->notifyDescriptionChanged(mResolvedDescription);
|
||||||
// Track will be referenced through simobjectptr
|
|
||||||
mResolvedTrack->deleteObject();
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mResolvedTrack = NULL;
|
mResolvedTrack = NULL;
|
||||||
|
|
@ -618,7 +665,7 @@ void SoundAsset::onTamlCustomRead(const TamlCustomNodes& 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),
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StringTableEntry mSoundFile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
StringTableEntry mSoundFile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
StringTableEntry mSoundPath[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
|
||||||
Resource<SFXResource> mSoundResource[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
Resource<SFXResource> mSoundResource[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
|
|
||||||
SFXDescription mProfileDesc;
|
SFXDescription mProfileDesc;
|
||||||
|
|
@ -144,6 +143,7 @@ private:
|
||||||
bool mPreload;
|
bool mPreload;
|
||||||
bool mIsPlaylist;
|
bool mIsPlaylist;
|
||||||
SFXTrack* mResolvedTrack;
|
SFXTrack* mResolvedTrack;
|
||||||
|
SFXDescription* mResolvedDescription;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundAsset();
|
SoundAsset();
|
||||||
|
|
@ -167,10 +167,9 @@ public:
|
||||||
void setSoundFile(StringTableEntry pSoundFile, U32 slot = 0);
|
void setSoundFile(StringTableEntry pSoundFile, U32 slot = 0);
|
||||||
inline StringTableEntry getSoundFile(U32 slot = 0) { return mSoundFile[slot]; }
|
inline StringTableEntry getSoundFile(U32 slot = 0) { return mSoundFile[slot]; }
|
||||||
inline StringTableEntry getRelativeSoundFile(U32 slot = 0) { return collapseAssetFilePath(mSoundFile[slot]); }
|
inline StringTableEntry getRelativeSoundFile(U32 slot = 0) { return collapseAssetFilePath(mSoundFile[slot]); }
|
||||||
inline StringTableEntry getSoundPath(const U32 slot = 0) const { return mSoundPath[slot]; };
|
|
||||||
|
|
||||||
SFXTrack* getSFXTrack() { load(); return mResolvedTrack; }
|
SFXTrack* getSFXTrack() { load(); return mResolvedTrack; }
|
||||||
SFXDescription* getSfxDescription() { return &mProfileDesc; }
|
SFXDescription* getSfxDescription() { return mResolvedDescription ? mResolvedDescription : &mProfileDesc; }
|
||||||
bool isPlaylist(){ return mIsPlaylist; }
|
bool isPlaylist(){ return mIsPlaylist; }
|
||||||
|
|
||||||
bool isLoop() { return mProfileDesc.mIsLooping; }
|
bool isLoop() { return mProfileDesc.mIsLooping; }
|
||||||
|
|
@ -180,8 +179,8 @@ public:
|
||||||
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();
|
SFXProfile* buildProfile();
|
||||||
|
|
||||||
SFXPlayList* buildPlaylist();
|
SFXPlayList* buildPlaylist();
|
||||||
|
|
||||||
void populateSFXTrack(void);
|
void populateSFXTrack(void);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue