Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
365 changes: 240 additions & 125 deletions Engine/source/T3D/assets/SoundAsset.cpp

Large diffs are not rendered by default.

467 changes: 185 additions & 282 deletions Engine/source/T3D/assets/SoundAsset.h

Large diffs are not rendered by default.

33 changes: 5 additions & 28 deletions Engine/source/T3D/assets/assetImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3292,30 +3292,19 @@ Torque::Path AssetImporter::importSoundAsset(AssetImportObject* assetItem)

StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str());

String soundFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension();
String assetPath = targetPath + "/" + soundFileName;
String soundFileName = assetItem->filePath.getFullFileName();
String assetPath = "@" + soundFileName;
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
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->_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
//file path for reimporting support later
if (!isReimport && String::compare(qualifiedFromFile, qualifiedToFile) && Torque::FS::IsFile(qualifiedFromFile))
if (!isReimport)
{
newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile);
newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, originalPath.c_str());
}

Taml tamlWriter;
Expand All @@ -3328,18 +3317,6 @@ Torque::Path AssetImporter::importSoundAsset(AssetImportObject* assetItem)
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;
}

Expand Down
15 changes: 6 additions & 9 deletions Engine/source/T3D/fx/explosion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,6 @@ ExplosionData::ExplosionData()

faceViewer = false;

INIT_ASSET(Sound);

//soundProfile = NULL;
particleEmitter = NULL;
particleEmitterId = 0;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion Engine/source/T3D/fx/explosion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 10 additions & 17 deletions Engine/source/T3D/fx/lightning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -332,15 +325,15 @@ 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);

for (i = 0; i < MaxTextures; i++)
stream->writeString(strikeTextureNames[i]);

PACKDATA_ASSET(StrikeSound);
PACKDATA_ASSET_REFACTOR(StrikeSound);
}

void LightningData::unpackData(BitStream* stream)
Expand All @@ -350,15 +343,15 @@ 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);

for (i = 0; i < MaxTextures; i++)
strikeTextureNames[i] = stream->readSTString();

UNPACKDATA_ASSET(StrikeSound);
UNPACKDATA_ASSET_REFACTOR(StrikeSound);
}


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 );
}

}
Expand Down
3 changes: 0 additions & 3 deletions Engine/source/T3D/fx/lightning.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
12 changes: 5 additions & 7 deletions Engine/source/T3D/fx/precipitation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ ConsoleDocClass( PrecipitationData,
//----------------------------------------------------------
PrecipitationData::PrecipitationData()
{
INIT_ASSET(Sound);

mDropShaderName = StringTable->EmptyString();

mSplashShaderName = StringTable->EmptyString();
Expand Down Expand Up @@ -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
}
Expand All @@ -188,7 +186,7 @@ void PrecipitationData::packData(BitStream* stream)
{
Parent::packData(stream);

PACKDATA_ASSET(Sound);
PACKDATA_ASSET_REFACTOR(Sound);

PACKDATA_ASSET_REFACTOR(Drop);

Expand All @@ -205,7 +203,7 @@ void PrecipitationData::unpackData(BitStream* stream)
{
Parent::unpackData(stream);

UNPACKDATA_ASSET(Sound);
UNPACKDATA_ASSET_REFACTOR(Sound);

UNPACKDATA_ASSET_REFACTOR(Drop);

Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 0 additions & 1 deletion Engine/source/T3D/fx/precipitation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 4 additions & 9 deletions Engine/source/T3D/fx/splash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
1 change: 0 additions & 1 deletion Engine/source/T3D/fx/splash.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class SplashData : public GameBaseData
//S32 soundProfileId;

DECLARE_SOUNDASSET(SplashData, Sound);
DECLARE_ASSET_SETGET(SplashData, Sound);

ParticleEmitterData* emitterList[NUM_EMITTERS];
S32 emitterIDList[NUM_EMITTERS];
Expand Down
4 changes: 2 additions & 2 deletions Engine/source/T3D/levelInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ U32 LevelInfo::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
mathWrite( *stream, mAmbientLightBlendCurve );

sfxWrite( stream, mSoundAmbience );
stream->writeInt( mSoundDistanceModel, 1 );
stream->writeInt( mSoundDistanceModel, 2);

PACK_ASSET_REFACTOR(conn, AccuTexture);

Expand Down Expand Up @@ -251,7 +251,7 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream)
String errorStr;
if( !sfxReadAndResolve( stream, &mSoundAmbience, errorStr ) )
Con::errorf( "%s", errorStr.c_str() );
mSoundDistanceModel = ( SFXDistanceModel ) stream->readInt( 1 );
mSoundDistanceModel = ( SFXDistanceModel ) stream->readInt(2);

if( isProperlyAdded() )
{
Expand Down
Loading
Loading