|
@@ -297,13 +297,16 @@ void SimDataBlockEvent::process(NetConnection *cptr)
|
|
|
static F32 SoundPosAccuracy = 0.5;
|
|
|
static S32 SoundRotBits = 8;
|
|
|
|
|
|
-SimSoundAssetEvent::SimSoundAssetEvent(StringTableEntry assetId, const MatrixF& mat)
|
|
|
+SimSoundAssetEvent::SimSoundAssetEvent(StringTableEntry assetId, const MatrixF* mat)
|
|
|
{
|
|
|
// cant get here unless the asset is declared.
|
|
|
mAsset = assetId;
|
|
|
-
|
|
|
+ sentTransform = false;
|
|
|
if (mat)
|
|
|
- mTransform = mat;
|
|
|
+ {
|
|
|
+ mTransform = *mat;
|
|
|
+ sentTransform = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void SimSoundAssetEvent::pack(NetConnection* con, BitStream* stream)
|
|
@@ -311,10 +314,9 @@ void SimSoundAssetEvent::pack(NetConnection* con, BitStream* stream)
|
|
|
NetStringHandle assetIdStr = mAsset->getAssetId();
|
|
|
con->packNetStringHandleU(stream, assetIdStr);
|
|
|
|
|
|
- // only stream if this is a 3d sound asset.
|
|
|
- if (mAsset->is3D())
|
|
|
+ SFXDescription* ad = mAsset->getSfxDescription();
|
|
|
+ if (stream->writeFlag(sentTransform))
|
|
|
{
|
|
|
- SFXDescription* ad = mAsset->getSfxDescription();
|
|
|
if (stream->writeFlag(ad->mConeInsideAngle || ad->mConeOutsideAngle))
|
|
|
{
|
|
|
QuatF q(mTransform);
|
|
@@ -322,10 +324,10 @@ void SimSoundAssetEvent::pack(NetConnection* con, BitStream* stream)
|
|
|
|
|
|
// LH - we can get a valid quat that's very slightly over 1 in and so
|
|
|
// this fails (barely) check against zero. So use some error-
|
|
|
- AssertFatal((1.0 - ((q.x * q.x) + (q.y * q.y) + (q.z * q.z))) >= (0.0 - 0.001),
|
|
|
- "QuatF::normalize() is broken in Sim3DAudioEvent");
|
|
|
+ AssertFatal((1.0 - ((q.x * q.x) + (q.y * q.y) + (q.z * q.z))) >= (0.0 - 0.001),
|
|
|
+ "QuatF::normalize() is broken in Sim3DAudioEvent");
|
|
|
|
|
|
- stream->writeSignedFloat(q.x, SoundRotBits);
|
|
|
+ stream->writeSignedFloat(q.x, SoundRotBits);
|
|
|
stream->writeSignedFloat(q.y, SoundRotBits);
|
|
|
stream->writeSignedFloat(q.z, SoundRotBits);
|
|
|
stream->writeFlag(q.w < 0.0);
|
|
@@ -335,7 +337,6 @@ void SimSoundAssetEvent::pack(NetConnection* con, BitStream* stream)
|
|
|
mTransform.getColumn(3, &pos);
|
|
|
stream->writeCompressedPoint(pos, SoundPosAccuracy);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
void SimSoundAssetEvent::write(NetConnection* con, BitStream* stream)
|
|
@@ -356,8 +357,8 @@ void SimSoundAssetEvent::unpack(NetConnection* con, BitStream* stream)
|
|
|
mAsset = temp;
|
|
|
}
|
|
|
|
|
|
- if (mAsset->is3D())
|
|
|
- {
|
|
|
+ sentTransform = stream->readFlag();
|
|
|
+ if (sentTransform) {
|
|
|
if (stream->readFlag()) {
|
|
|
QuatF q;
|
|
|
q.x = stream->readSignedFloat(SoundRotBits);
|
|
@@ -381,16 +382,15 @@ void SimSoundAssetEvent::unpack(NetConnection* con, BitStream* stream)
|
|
|
stream->readCompressedPoint(&pos, SoundPosAccuracy);
|
|
|
mTransform.setColumn(3, pos);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mTransform = SFX->getListener(0).getTransform();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void SimSoundAssetEvent::process(NetConnection* con)
|
|
|
{
|
|
|
-
|
|
|
- if (mAsset->is3D())
|
|
|
- SFX->playOnce(mAsset->getSFXTrack(), &mTransform);
|
|
|
- else
|
|
|
- SFX->playOnce(mAsset->getSFXTrack());
|
|
|
-
|
|
|
+ SFX->playOnce(mAsset->getSFXTrack(), &mTransform);
|
|
|
}
|
|
|
|
|
|
Sim2DAudioEvent::Sim2DAudioEvent(SFXProfile *profile)
|