mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
SoundAssetImplements
-Explosion -Lightning -Splash -Other sound asset implementations will require soundasset array if possible.
This commit is contained in:
parent
bda5266c88
commit
c92cfe3e81
6 changed files with 87 additions and 35 deletions
|
|
@ -230,7 +230,9 @@ ExplosionData::ExplosionData()
|
|||
|
||||
faceViewer = false;
|
||||
|
||||
soundProfile = NULL;
|
||||
INIT_SOUNDASSET(Sound);
|
||||
|
||||
//soundProfile = NULL;
|
||||
particleEmitter = NULL;
|
||||
particleEmitterId = 0;
|
||||
|
||||
|
|
@ -308,7 +310,7 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game
|
|||
faceViewer = other.faceViewer;
|
||||
particleDensity = other.particleDensity;
|
||||
particleRadius = other.particleRadius;
|
||||
soundProfile = other.soundProfile;
|
||||
CLONE_SOUNDASSET(Sound);
|
||||
particleEmitter = other.particleEmitter;
|
||||
particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr
|
||||
explosionScale = other.explosionScale;
|
||||
|
|
@ -358,12 +360,6 @@ ExplosionData::~ExplosionData()
|
|||
if (!isTempClone())
|
||||
return;
|
||||
|
||||
if (soundProfile && soundProfile->isTempClone())
|
||||
{
|
||||
delete soundProfile;
|
||||
soundProfile = 0;
|
||||
}
|
||||
|
||||
// particleEmitter, emitterList[*], debrisList[*], explosionList[*] will delete themselves
|
||||
|
||||
#ifdef TRACK_EXPLOSION_DATA_CLONES
|
||||
|
|
@ -399,8 +395,9 @@ void ExplosionData::initPersistFields()
|
|||
"of the explosion." );
|
||||
addField( "playSpeed", TypeF32, Offset(playSpeed, ExplosionData),
|
||||
"Time scale at which to play the explosionShape <i>ambient</i> sequence." );
|
||||
addField( "soundProfile", TYPEID< SFXTrack >(), Offset(soundProfile, ExplosionData),
|
||||
"Non-looping sound effect that will be played at the start of the explosion." );
|
||||
|
||||
INITPERSISTFIELD_SOUNDASSET(Sound, ExplosionData, "Sound to play when this explosion explodes.");
|
||||
|
||||
addField( "faceViewer", TypeBool, Offset(faceViewer, ExplosionData),
|
||||
"Controls whether the visual effects of the explosion always face the camera." );
|
||||
|
||||
|
|
@ -523,7 +520,6 @@ void ExplosionData::initPersistFields()
|
|||
onlyKeepClearSubstitutions("debris"); // subs resolving to "~~", or "~0" are OK
|
||||
onlyKeepClearSubstitutions("emitter");
|
||||
onlyKeepClearSubstitutions("particleEmitter");
|
||||
onlyKeepClearSubstitutions("soundProfile");
|
||||
onlyKeepClearSubstitutions("subExplosion");
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
@ -656,7 +652,8 @@ void ExplosionData::packData(BitStream* stream)
|
|||
|
||||
PACKDATA_SHAPEASSET(ExplosionShape);
|
||||
|
||||
sfxWrite( stream, soundProfile );
|
||||
PACKDATA_SOUNDASSET(Sound);
|
||||
|
||||
if (stream->writeFlag(particleEmitter))
|
||||
stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
|
||||
|
||||
|
|
@ -759,7 +756,7 @@ void ExplosionData::unpackData(BitStream* stream)
|
|||
|
||||
UNPACKDATA_SHAPEASSET(ExplosionShape);
|
||||
|
||||
sfxRead( stream, &soundProfile );
|
||||
UNPACKDATA_SOUNDASSET(Sound);
|
||||
|
||||
if (stream->readFlag())
|
||||
particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||
|
|
@ -861,12 +858,13 @@ bool ExplosionData::preload(bool server, String &errorStr)
|
|||
{
|
||||
if (Parent::preload(server, errorStr) == false)
|
||||
return false;
|
||||
|
||||
|
||||
if (!server && !getSFXProfile())
|
||||
return false;
|
||||
|
||||
if( !server )
|
||||
{
|
||||
String sfxErrorStr;
|
||||
if( !sfxResolve( &soundProfile, sfxErrorStr ) )
|
||||
Con::errorf(ConsoleLogEntry::General, "Error, unable to load sound profile for explosion datablock: %s", sfxErrorStr.c_str());
|
||||
if (!particleEmitter && particleEmitterId != 0)
|
||||
if (Sim::findObject(particleEmitterId, particleEmitter) == false)
|
||||
Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock");
|
||||
|
|
@ -1384,7 +1382,7 @@ bool Explosion::explode()
|
|||
resetWorldBox();
|
||||
}
|
||||
|
||||
SFXProfile* sound_prof = dynamic_cast<SFXProfile*>(mDataBlock->soundProfile);
|
||||
SFXProfile* sound_prof = dynamic_cast<SFXProfile*>(mDataBlock->getSFXProfile());
|
||||
if (sound_prof)
|
||||
{
|
||||
soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue