SoundAsset Refactor

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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