Merge pull request #942 from Azaezel/alpha403/miscSoundFixes

misc fixes
This commit is contained in:
Brian Roberts 2022-12-30 00:15:16 -06:00 committed by GitHub
commit b256d62b85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 98 additions and 420 deletions

View file

@ -486,15 +486,15 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
const char* enumString = castConsoleTypeToString(static_cast<enumType>(itter));\ const char* enumString = castConsoleTypeToString(static_cast<enumType>(itter));\
if (enumString && enumString[0])\ if (enumString && enumString[0])\
{\ {\
addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[0], consoleClass) + sizeof(m##name##Name[0])*i, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \ addField(assetEnumNameConcat(enumString, File), TypeSoundFilename, Offset(m##name##Name[i], consoleClass), assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[0], consoleClass) + sizeof(m##name##AssetId[0])*i, assetText(name, asset reference.));\ addField(assetEnumNameConcat(enumString, Asset), TypeSoundAssetId, Offset(m##name##AssetId[i], consoleClass), assetText(name, asset reference.));\
}\ }\
} }
#define PACKDATA_SOUNDASSET_ARRAY(name, index)\ #define PACKDATA_SOUNDASSET_ARRAY(name, index)\
if (stream->writeFlag(m##name##Asset[index].notNull()))\ if (stream->writeFlag(AssetDatabase.isDeclaredAsset(m##name##AssetId[index])))\
{\ {\
stream->writeString(m##name##Asset[index].getAssetId());\ stream->writeString(m##name##AssetId[index]);\
}\ }\
else\ else\
{\ {\

View file

@ -242,7 +242,7 @@ LightningData::LightningData()
for (S32 i = 0; i < MaxThunders; i++) for (S32 i = 0; i < MaxThunders; i++)
{ {
INIT_ASSET_ARRAY(ThunderSound, i); INIT_SOUNDASSET_ARRAY(ThunderSound, i);
} }
for (S32 i = 0; i < MaxTextures; i++) for (S32 i = 0; i < MaxTextures; i++)
@ -335,7 +335,7 @@ void LightningData::packData(BitStream* stream)
U32 i; U32 i;
for (i = 0; i < MaxThunders; i++) for (i = 0; i < MaxThunders; i++)
{ {
PACKDATA_ASSET_ARRAY(ThunderSound, i); PACKDATA_SOUNDASSET_ARRAY(ThunderSound, i);
} }
stream->writeInt(mNumStrikeTextures, 4); stream->writeInt(mNumStrikeTextures, 4);
@ -353,7 +353,7 @@ void LightningData::unpackData(BitStream* stream)
U32 i; U32 i;
for (i = 0; i < MaxThunders; i++) for (i = 0; i < MaxThunders; i++)
{ {
UNPACKDATA_ASSET_ARRAY(ThunderSound, i); UNPACKDATA_SOUNDASSET_ARRAY(ThunderSound, i);
} }
mNumStrikeTextures = stream->readInt(4); mNumStrikeTextures = stream->readInt(4);

View file

@ -423,7 +423,7 @@ PlayerData::PlayerData()
boxHeadFrontPercentage = 1; boxHeadFrontPercentage = 1;
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
INIT_ASSET_ARRAY(PlayerSound, i); INIT_SOUNDASSET_ARRAY(PlayerSound, i);
footPuffEmitter = NULL; footPuffEmitter = NULL;
footPuffID = 0; footPuffID = 0;
@ -469,17 +469,17 @@ bool PlayerData::preload(bool server, String &errorStr)
{ {
if(!Parent::preload(server, errorStr)) if(!Parent::preload(server, errorStr))
return false; return false;
if (!server) {
for (U32 i = 0; i < MaxSounds; ++i) for (U32 i = 0; i < MaxSounds; ++i)
{
_setPlayerSound(getPlayerSound(i), i);
if (getPlayerSound(i) != StringTable->EmptyString())
{ {
if (!getPlayerSoundProfile(i)) _setPlayerSound(getPlayerSound(i), i);
Con::errorf("PlayerData::Preload() - unable to find sfxProfile for asset %d %s", i, mPlayerSoundAssetId[i]); if (getPlayerSound(i) != StringTable->EmptyString())
{
if (!getPlayerSoundProfile(i))
Con::errorf("PlayerData::Preload() - unable to find sfxProfile for asset %d %s", i, mPlayerSoundAssetId[i]);
}
} }
} }
// //
runSurfaceCos = mCos(mDegToRad(runSurfaceAngle)); runSurfaceCos = mCos(mDegToRad(runSurfaceAngle));
jumpSurfaceCos = mCos(mDegToRad(jumpSurfaceAngle)); jumpSurfaceCos = mCos(mDegToRad(jumpSurfaceAngle));
@ -1271,7 +1271,7 @@ void PlayerData::packData(BitStream* stream)
stream->write(minLateralImpactSpeed); stream->write(minLateralImpactSpeed);
for (U32 i = 0; i < MaxSounds; i++) for (U32 i = 0; i < MaxSounds; i++)
PACKDATA_ASSET_ARRAY(PlayerSound, i); PACKDATA_SOUNDASSET_ARRAY(PlayerSound, i);
mathWrite(*stream, boxSize); mathWrite(*stream, boxSize);
mathWrite(*stream, crouchBoxSize); mathWrite(*stream, crouchBoxSize);
@ -1452,7 +1452,7 @@ void PlayerData::unpackData(BitStream* stream)
stream->read(&minLateralImpactSpeed); stream->read(&minLateralImpactSpeed);
for (U32 i = 0; i < MaxSounds; i++) for (U32 i = 0; i < MaxSounds; i++)
UNPACKDATA_ASSET_ARRAY(PlayerSound, i); UNPACKDATA_SOUNDASSET_ARRAY(PlayerSound, i);
mathRead(*stream, &boxSize); mathRead(*stream, &boxSize);
mathRead(*stream, &crouchBoxSize); mathRead(*stream, &crouchBoxSize);

View file

@ -207,6 +207,27 @@ TriggerObjectType |
CorpseObjectType; CorpseObjectType;
typedef RigidShapeData::Body::Sounds bodySounds;
DefineEnumType(bodySounds);
ImplementEnumType(bodySounds, "enum types.\n"
"@ingroup VehicleData\n\n")
{ bodySounds::SoftImpactSound, "SoftImpactSound", "..." },
{ bodySounds::HardImpactSound, "HardImpactSound", "..." },
EndImplementEnumType;
typedef RigidShapeData::Sounds waterSounds;
DefineEnumType(waterSounds);
ImplementEnumType(waterSounds, "enum types.\n"
"@ingroup RigidShapeData\n\n")
{ waterSounds::ExitWater, "ExitWater", "..." },
{ waterSounds::ImpactSoft, "ImpactSoft", "..." },
{ waterSounds::ImpactMedium, "ImpactMedium", "..." },
{ waterSounds::ImpactHard, "ImpactHard", "..." },
{ waterSounds::Wake, "Wake", "..." },
EndImplementEnumType;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
RigidShapeData::RigidShapeData() RigidShapeData::RigidShapeData()
@ -238,7 +259,7 @@ RigidShapeData::RigidShapeData()
density = 4; density = 4;
for (S32 i = 0; i < Body::MaxSounds; i++) for (S32 i = 0; i < Body::MaxSounds; i++)
INIT_ASSET_ARRAY(BodySounds, i); INIT_SOUNDASSET_ARRAY(BodySounds, i);
dustEmitter = NULL; dustEmitter = NULL;
dustID = 0; dustID = 0;
@ -257,7 +278,7 @@ RigidShapeData::RigidShapeData()
enablePhysicsRep = true; enablePhysicsRep = true;
for (S32 i = 0; i < Sounds::MaxSounds; i++) for (S32 i = 0; i < Sounds::MaxSounds; i++)
INIT_ASSET_ARRAY(WaterSounds, i); INIT_SOUNDASSET_ARRAY(WaterSounds, i);
dragForce = 0; dragForce = 0;
vertFactor = 0.25; vertFactor = 0.25;
@ -301,7 +322,7 @@ bool RigidShapeData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (S32 i = 0; i < Body::MaxSounds; i++) for (S32 i = 0; i < Body::MaxSounds; i++)
{ {
if (mBodySounds[i]) if (getBodySounds(i) != StringTable->EmptyString())
{ {
_setBodySounds(getBodySounds(i), i); _setBodySounds(getBodySounds(i), i);
} }
@ -309,7 +330,7 @@ bool RigidShapeData::preload(bool server, String &errorStr)
for (S32 j = 0; j < Sounds::MaxSounds; j++) for (S32 j = 0; j < Sounds::MaxSounds; j++)
{ {
if (mWaterSounds[j]) if (getWaterSounds(j) != StringTable->EmptyString())
{ {
_setWaterSounds(getWaterSounds(j), j); _setWaterSounds(getWaterSounds(j), j);
} }
@ -371,7 +392,7 @@ void RigidShapeData::packData(BitStream* stream)
stream->write(body.friction); stream->write(body.friction);
for (U32 i = 0; i < Body::MaxSounds; ++i) for (U32 i = 0; i < Body::MaxSounds; ++i)
{ {
PACKDATA_ASSET_ARRAY(BodySounds, i); PACKDATA_SOUNDASSET_ARRAY(BodySounds, i);
} }
stream->write(minImpactSpeed); stream->write(minImpactSpeed);
@ -392,7 +413,8 @@ void RigidShapeData::packData(BitStream* stream)
stream->write(cameraDecay); stream->write(cameraDecay);
stream->write(cameraOffset); stream->write(cameraOffset);
stream->write( dustHeight ); stream->write(triggerDustHeight);
stream->write(dustHeight);
stream->write(exitSplashSoundVel); stream->write(exitSplashSoundVel);
stream->write(softSplashSoundVel); stream->write(softSplashSoundVel);
@ -403,7 +425,7 @@ void RigidShapeData::packData(BitStream* stream)
// write the water sound profiles // write the water sound profiles
for (U32 i = 0; i < Sounds::MaxSounds; ++i) for (U32 i = 0; i < Sounds::MaxSounds; ++i)
{ {
PACKDATA_ASSET_ARRAY(WaterSounds, i); PACKDATA_SOUNDASSET_ARRAY(WaterSounds, i);
} }
if (stream->writeFlag( dustEmitter )) if (stream->writeFlag( dustEmitter ))
@ -434,7 +456,7 @@ void RigidShapeData::unpackData(BitStream* stream)
for (U32 i = 0; i < Body::Sounds::MaxSounds; i++) for (U32 i = 0; i < Body::Sounds::MaxSounds; i++)
{ {
UNPACKDATA_ASSET_ARRAY(BodySounds, i); UNPACKDATA_SOUNDASSET_ARRAY(BodySounds, i);
} }
stream->read(&minImpactSpeed); stream->read(&minImpactSpeed);
@ -455,6 +477,7 @@ void RigidShapeData::unpackData(BitStream* stream)
stream->read(&cameraDecay); stream->read(&cameraDecay);
stream->read(&cameraOffset); stream->read(&cameraOffset);
stream->read(&triggerDustHeight);
stream->read( &dustHeight ); stream->read( &dustHeight );
stream->read(&exitSplashSoundVel); stream->read(&exitSplashSoundVel);
@ -466,7 +489,7 @@ void RigidShapeData::unpackData(BitStream* stream)
// write the water sound profiles // write the water sound profiles
for (U32 i = 0; i < Sounds::MaxSounds; ++i) for (U32 i = 0; i < Sounds::MaxSounds; ++i)
{ {
UNPACKDATA_ASSET_ARRAY(WaterSounds, i); UNPACKDATA_SOUNDASSET_ARRAY(WaterSounds, i);
} }
if( stream->readFlag() ) if( stream->readFlag() )
@ -539,14 +562,14 @@ void RigidShapeData::initPersistFields()
addGroup( "Sounds" ); addGroup( "Sounds" );
INITPERSISTFIELD_SOUNDASSET_ARRAY(BodySounds, Body::Sounds::MaxSounds, RigidShapeData, "Sounds for body."); INITPERSISTFIELD_SOUNDASSET_ENUMED(BodySounds, bodySounds, Body::Sounds::MaxSounds, RigidShapeData, "Sounds for body.");
addField("exitSplashSoundVelocity", TypeF32, Offset(exitSplashSoundVel, RigidShapeData), "The minimum velocity at which the exit splash sound will be played when emerging from water.\n"); addField("exitSplashSoundVelocity", TypeF32, Offset(exitSplashSoundVel, RigidShapeData), "The minimum velocity at which the exit splash sound will be played when emerging from water.\n");
addField("softSplashSoundVelocity", TypeF32, Offset(softSplashSoundVel, RigidShapeData),"The minimum velocity at which the soft splash sound will be played when impacting water.\n"); addField("softSplashSoundVelocity", TypeF32, Offset(softSplashSoundVel, RigidShapeData),"The minimum velocity at which the soft splash sound will be played when impacting water.\n");
addField("mediumSplashSoundVelocity", TypeF32, Offset(medSplashSoundVel, RigidShapeData), "The minimum velocity at which the medium splash sound will be played when impacting water.\n"); addField("mediumSplashSoundVelocity", TypeF32, Offset(medSplashSoundVel, RigidShapeData), "The minimum velocity at which the medium splash sound will be played when impacting water.\n");
addField("hardSplashSoundVelocity", TypeF32, Offset(hardSplashSoundVel, RigidShapeData), "The minimum velocity at which the hard splash sound will be played when impacting water.\n"); addField("hardSplashSoundVelocity", TypeF32, Offset(hardSplashSoundVel, RigidShapeData), "The minimum velocity at which the hard splash sound will be played when impacting water.\n");
INITPERSISTFIELD_SOUNDASSET_ARRAY(WaterSounds, Sounds::MaxSounds, RigidShapeData, "Sounds for interacting with water."); INITPERSISTFIELD_SOUNDASSET_ENUMED(WaterSounds, waterSounds, Sounds::MaxSounds, RigidShapeData, "Sounds for interacting with water.");
endGroup( "Sounds" ); endGroup( "Sounds" );

View file

@ -64,7 +64,6 @@ class RigidShapeData : public ShapeBaseData
} body; } body;
DECLARE_SOUNDASSET_ARRAY(RigidShapeData, BodySounds, Body::Sounds::MaxSounds) DECLARE_SOUNDASSET_ARRAY(RigidShapeData, BodySounds, Body::Sounds::MaxSounds)
DECLARE_ASSET_ARRAY_SETGET(RigidShapeData, BodySounds);
enum RigidShapeConsts enum RigidShapeConsts
{ {

View file

@ -1572,7 +1572,7 @@ void ShapeBase::setControllingClient( GameConnection* client )
gSFX3DWorld->setListener( NULL ); gSFX3DWorld->setListener( NULL );
} }
else if( client && client->isConnectionToServer() && !getControllingObject() ) else if( client && client->isConnectionToServer() && (getControllingObject() != this) )
{ {
// We're on the local client and not controlled by another object, so make // We're on the local client and not controlled by another object, so make
// us the current SFX listener. // us the current SFX listener.

View file

@ -116,7 +116,7 @@ FlyingVehicleData::FlyingVehicleData()
jetEmitter[j] = 0; jetEmitter[j] = 0;
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
INIT_ASSET_ARRAY(FlyingSounds, i); INIT_SOUNDASSET_ARRAY(FlyingSounds, i);
vertThrustMultiple = 1.0; vertThrustMultiple = 1.0;
} }
@ -241,7 +241,7 @@ void FlyingVehicleData::packData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
PACKDATA_ASSET_ARRAY(FlyingSounds, i); PACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i);
} }
for (S32 j = 0; j < MaxJetEmitters; j++) for (S32 j = 0; j < MaxJetEmitters; j++)
@ -276,7 +276,7 @@ void FlyingVehicleData::unpackData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
UNPACKDATA_ASSET_ARRAY(FlyingSounds, i); UNPACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i);
} }
for (S32 j = 0; j < MaxJetEmitters; j++) { for (S32 j = 0; j < MaxJetEmitters; j++) {

View file

@ -73,9 +73,9 @@ DefineEnumType(hoverSoundsEnum);
ImplementEnumType(hoverSoundsEnum, "enum types.\n" ImplementEnumType(hoverSoundsEnum, "enum types.\n"
"@ingroup HoverVehicleData\n\n") "@ingroup HoverVehicleData\n\n")
{ HoverVehicleData::JetSound, "JetSound", "..." }, { hoverSoundsEnum::JetSound, "JetSound", "..." },
{ HoverVehicleData::EngineSound, "EngineSound", "..." }, { hoverSoundsEnum::EngineSound, "EngineSound", "..." },
{ HoverVehicleData::FloatSound, "FloatSound", "..." }, { hoverSoundsEnum::FloatSound, "FloatSound", "..." },
EndImplementEnumType; EndImplementEnumType;
namespace { namespace {
@ -162,7 +162,7 @@ HoverVehicleData::HoverVehicleData()
jetEmitter[j] = 0; jetEmitter[j] = 0;
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
INIT_ASSET_ARRAY(HoverSounds, i); INIT_SOUNDASSET_ARRAY(HoverSounds, i);
} }
HoverVehicleData::~HoverVehicleData() HoverVehicleData::~HoverVehicleData()
@ -370,7 +370,7 @@ void HoverVehicleData::packData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
PACKDATA_ASSET_ARRAY(HoverSounds, i); PACKDATA_SOUNDASSET_ARRAY(HoverSounds, i);
} }
for (S32 j = 0; j < MaxJetEmitters; j++) for (S32 j = 0; j < MaxJetEmitters; j++)
@ -419,7 +419,7 @@ void HoverVehicleData::unpackData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
UNPACKDATA_ASSET_ARRAY(HoverSounds, i); UNPACKDATA_SOUNDASSET_ARRAY(HoverSounds, i);
} }
for (S32 j = 0; j < MaxJetEmitters; j++) { for (S32 j = 0; j < MaxJetEmitters; j++) {

View file

@ -80,28 +80,6 @@ static U32 sTriggerMask = ItemObjectType |
IMPLEMENT_CONOBJECT(VehicleData); IMPLEMENT_CONOBJECT(VehicleData);
typedef VehicleData::Body::Sounds bodySounds;
DefineEnumType(bodySounds);
ImplementEnumType(bodySounds, "enum types.\n"
"@ingroup VehicleData\n\n")
{ VehicleData::Body::SoftImpactSound, "SoftImpactSound", "..." },
{ VehicleData::Body::HardImpactSound, "HardImpactSound", "..." },
EndImplementEnumType;
typedef VehicleData::Sounds vehSoundsEnum;
DefineEnumType(vehSoundsEnum);
ImplementEnumType(vehSoundsEnum, "enum types.\n"
"@ingroup VehicleData\n\n")
{ VehicleData::ExitWater, "ExitWater", "..." },
{ VehicleData::ImpactSoft, "ImpactSoft", "..." },
{ VehicleData::ImpactMedium, "ImpactMedium", "..." },
{ VehicleData::ImpactHard, "ImpactHard", "..." },
{ VehicleData::Wake, "Wake", "..." },
EndImplementEnumType;
ConsoleDocClass( VehicleData, ConsoleDocClass( VehicleData,
"@brief Base properties shared by all Vehicles (FlyingVehicle, HoverVehicle, " "@brief Base properties shared by all Vehicles (FlyingVehicle, HoverVehicle, "
"WheeledVehicle).\n\n" "WheeledVehicle).\n\n"
@ -152,70 +130,21 @@ VehicleData::VehicleData()
shadowEnable = true; shadowEnable = true;
shadowSize = 256; shadowSize = 256;
shadowProjectionDistance = 14.0f; shadowProjectionDistance = 14.0f;
body.friction = 0;
body.restitution = 1;
minImpactSpeed = 25;
softImpactSpeed = 25;
hardImpactSpeed = 50;
minRollSpeed = 0;
maxSteeringAngle = M_PI_F/4.0f; // 45 deg. maxSteeringAngle = M_PI_F/4.0f; // 45 deg.
cameraRoll = true;
cameraLag = 0;
cameraDecay = 0;
cameraOffset = 0;
minDrag = 0;
maxDrag = 0;
integration = 1;
collisionTol = 0.1f;
contactTol = 0.1f;
massCenter.set(0,0,0);
massBox.set(0,0,0);
drag = 0.7f;
density = 4;
jetForce = 500; jetForce = 500;
jetEnergyDrain = 0.8f; jetEnergyDrain = 0.8f;
minJetEnergy = 1; minJetEnergy = 1;
steeringReturn = 0.0f; steeringReturn = 0.0f;
steeringReturnSpeedScale = 0.01f; steeringReturnSpeedScale = 0.01f;
powerSteering = false; powerSteering = false;
for (S32 i = 0; i < Body::MaxSounds; i++)
{
INIT_ASSET_ARRAY(VehicleBodySounds, i);
}
dustEmitter = NULL;
dustID = 0;
triggerDustHeight = 3.0;
dustHeight = 1.0;
dMemset( damageEmitterList, 0, sizeof( damageEmitterList ) ); dMemset( damageEmitterList, 0, sizeof( damageEmitterList ) );
dMemset( damageEmitterOffset, 0, sizeof( damageEmitterOffset ) ); dMemset( damageEmitterOffset, 0, sizeof( damageEmitterOffset ) );
dMemset( damageEmitterIDList, 0, sizeof( damageEmitterIDList ) ); dMemset( damageEmitterIDList, 0, sizeof( damageEmitterIDList ) );
dMemset( damageLevelTolerance, 0, sizeof( damageLevelTolerance ) ); dMemset( damageLevelTolerance, 0, sizeof( damageLevelTolerance ) );
dMemset( splashEmitterList, 0, sizeof( splashEmitterList ) );
dMemset( splashEmitterIDList, 0, sizeof( splashEmitterIDList ) );
numDmgEmitterAreas = 0; numDmgEmitterAreas = 0;
splashFreqMod = 300.0;
splashVelEpsilon = 0.50;
exitSplashSoundVel = 2.0;
softSplashSoundVel = 1.0;
medSplashSoundVel = 2.0;
hardSplashSoundVel = 3.0;
for (S32 i = 0; i < Sounds::MaxSounds; i++)
INIT_ASSET_ARRAY(VehicleWaterSounds, i);
collDamageThresholdVel = 20; collDamageThresholdVel = 20;
collDamageMultiplier = 0.05f; collDamageMultiplier = 0.05f;
enablePhysicsRep = true; enablePhysicsRep = true;
@ -237,33 +166,6 @@ bool VehicleData::preload(bool server, String &errorStr)
return false; return false;
} }
// Resolve objects transmitted from server
if (!server) {
for (S32 i = 0; i < Body::MaxSounds; i++)
{
if (getVehicleBodySounds(i) != StringTable->EmptyString() )
{
_setVehicleBodySounds(getVehicleBodySounds(i), i);
}
}
for (S32 j = 0; j < Sounds::MaxSounds; j++)
{
if (getVehicleWaterSounds(j) != StringTable->EmptyString())
{
_setVehicleWaterSounds(getVehicleWaterSounds(j), j);
}
}
}
if( !dustEmitter && dustID != 0 )
{
if( !Sim::findObject( dustID, dustEmitter ) )
{
Con::errorf( ConsoleLogEntry::General, "VehicleData::preload Invalid packet, bad datablockId(dustEmitter): 0x%x", dustID );
}
}
U32 i; U32 i;
for( i=0; i<VC_NUM_DAMAGE_EMITTERS; i++ ) for( i=0; i<VC_NUM_DAMAGE_EMITTERS; i++ )
{ {
@ -276,17 +178,6 @@ bool VehicleData::preload(bool server, String &errorStr)
} }
} }
for( i=0; i<VC_NUM_SPLASH_EMITTERS; i++ )
{
if( !splashEmitterList[i] && splashEmitterIDList[i] != 0 )
{
if( !Sim::findObject( splashEmitterIDList[i], splashEmitterList[i] ) )
{
Con::errorf( ConsoleLogEntry::General, "VehicleData::preload Invalid packet, bad datablockId(splashEmitter): 0x%x", splashEmitterIDList[i] );
}
}
}
return true; return true;
} }
@ -298,27 +189,8 @@ void VehicleData::packData(BitStream* stream)
S32 i; S32 i;
Parent::packData(stream); Parent::packData(stream);
stream->write(body.restitution);
stream->write(body.friction);
for (i = 0; i < Body::MaxSounds; i++)
{
PACKDATA_ASSET_ARRAY(VehicleBodySounds, i);
}
stream->write(minImpactSpeed);
stream->write(softImpactSpeed);
stream->write(hardImpactSpeed);
stream->write(minRollSpeed);
stream->write(maxSteeringAngle); stream->write(maxSteeringAngle);
stream->write(maxDrag);
stream->write(minDrag);
stream->write(integration);
stream->write(collisionTol);
stream->write(contactTol);
mathWrite(*stream,massCenter);
mathWrite(*stream,massBox);
stream->write(jetForce); stream->write(jetForce);
stream->write(jetEnergyDrain); stream->write(jetEnergyDrain);
stream->write(minJetEnergy); stream->write(minJetEnergy);
@ -327,33 +199,10 @@ void VehicleData::packData(BitStream* stream)
stream->write(steeringReturnSpeedScale); stream->write(steeringReturnSpeedScale);
stream->writeFlag(powerSteering); stream->writeFlag(powerSteering);
stream->writeFlag(cameraRoll);
stream->write(cameraLag);
stream->write(cameraDecay);
stream->write(cameraOffset);
stream->write( triggerDustHeight );
stream->write( dustHeight );
stream->write( numDmgEmitterAreas ); stream->write( numDmgEmitterAreas );
stream->write(exitSplashSoundVel);
stream->write(softSplashSoundVel);
stream->write(medSplashSoundVel);
stream->write(hardSplashSoundVel);
stream->write(enablePhysicsRep); stream->write(enablePhysicsRep);
// write the water sound profiles
for (i = 0; i < MaxSounds; i++)
{
PACKDATA_ASSET_ARRAY(VehicleWaterSounds, i);
}
if (stream->writeFlag( dustEmitter ))
{
stream->writeRangedU32( dustEmitter->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast );
}
for (i = 0; i < VC_NUM_DAMAGE_EMITTERS; i++) for (i = 0; i < VC_NUM_DAMAGE_EMITTERS; i++)
{ {
if( stream->writeFlag( damageEmitterList[i] != NULL ) ) if( stream->writeFlag( damageEmitterList[i] != NULL ) )
@ -362,14 +211,6 @@ void VehicleData::packData(BitStream* stream)
} }
} }
for (i = 0; i < VC_NUM_SPLASH_EMITTERS; i++)
{
if( stream->writeFlag( splashEmitterList[i] != NULL ) )
{
stream->writeRangedU32( splashEmitterList[i]->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast );
}
}
for (S32 j = 0; j < VC_NUM_DAMAGE_EMITTER_AREAS; j++) for (S32 j = 0; j < VC_NUM_DAMAGE_EMITTER_AREAS; j++)
{ {
stream->write( damageEmitterOffset[j].x ); stream->write( damageEmitterOffset[j].x );
@ -382,9 +223,6 @@ void VehicleData::packData(BitStream* stream)
stream->write( damageLevelTolerance[k] ); stream->write( damageLevelTolerance[k] );
} }
stream->write(splashFreqMod);
stream->write(splashVelEpsilon);
stream->write(collDamageThresholdVel); stream->write(collDamageThresholdVel);
stream->write(collDamageMultiplier); stream->write(collDamageMultiplier);
} }
@ -393,28 +231,9 @@ void VehicleData::unpackData(BitStream* stream)
{ {
Parent::unpackData(stream); Parent::unpackData(stream);
stream->read(&body.restitution);
stream->read(&body.friction);
S32 i; S32 i;
for (i = 0; i < Body::MaxSounds; i++)
{
UNPACKDATA_ASSET_ARRAY(VehicleBodySounds, i);
}
stream->read(&minImpactSpeed);
stream->read(&softImpactSpeed);
stream->read(&hardImpactSpeed);
stream->read(&minRollSpeed);
stream->read(&maxSteeringAngle); stream->read(&maxSteeringAngle);
stream->read(&maxDrag);
stream->read(&minDrag);
stream->read(&integration);
stream->read(&collisionTol);
stream->read(&contactTol);
mathRead(*stream,&massCenter);
mathRead(*stream,&massBox);
stream->read(&jetForce); stream->read(&jetForce);
stream->read(&jetEnergyDrain); stream->read(&jetEnergyDrain);
stream->read(&minJetEnergy); stream->read(&minJetEnergy);
@ -423,33 +242,10 @@ void VehicleData::unpackData(BitStream* stream)
stream->read(&steeringReturnSpeedScale); stream->read(&steeringReturnSpeedScale);
powerSteering = stream->readFlag(); powerSteering = stream->readFlag();
cameraRoll = stream->readFlag();
stream->read(&cameraLag);
stream->read(&cameraDecay);
stream->read(&cameraOffset);
stream->read( &triggerDustHeight );
stream->read( &dustHeight );
stream->read( &numDmgEmitterAreas ); stream->read( &numDmgEmitterAreas );
stream->read(&exitSplashSoundVel);
stream->read(&softSplashSoundVel);
stream->read(&medSplashSoundVel);
stream->read(&hardSplashSoundVel);
stream->read(&enablePhysicsRep); stream->read(&enablePhysicsRep);
// write the water sound profiles
for (i = 0; i < Sounds::MaxSounds; i++)
{
UNPACKDATA_ASSET_ARRAY(VehicleWaterSounds, i);
}
if( stream->readFlag() )
{
dustID = (S32) stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
}
for (i = 0; i < VC_NUM_DAMAGE_EMITTERS; i++) for (i = 0; i < VC_NUM_DAMAGE_EMITTERS; i++)
{ {
if( stream->readFlag() ) if( stream->readFlag() )
@ -458,14 +254,6 @@ void VehicleData::unpackData(BitStream* stream)
} }
} }
for (i = 0; i < VC_NUM_SPLASH_EMITTERS; i++)
{
if( stream->readFlag() )
{
splashEmitterIDList[i] = stream->readRangedU32( DataBlockObjectIdFirst, DataBlockObjectIdLast );
}
}
for( S32 j=0; j<VC_NUM_DAMAGE_EMITTER_AREAS; j++ ) for( S32 j=0; j<VC_NUM_DAMAGE_EMITTER_AREAS; j++ )
{ {
stream->read( &damageEmitterOffset[j].x ); stream->read( &damageEmitterOffset[j].x );
@ -478,9 +266,6 @@ void VehicleData::unpackData(BitStream* stream)
stream->read( &damageLevelTolerance[k] ); stream->read( &damageLevelTolerance[k] );
} }
stream->read(&splashFreqMod);
stream->read(&splashVelEpsilon);
stream->read(&collDamageThresholdVel); stream->read(&collDamageThresholdVel);
stream->read(&collDamageMultiplier); stream->read(&collDamageMultiplier);
} }
@ -511,69 +296,9 @@ void VehicleData::initPersistFields()
"Amount of effect the vehicle's speed has on its rate of steering return." ); "Amount of effect the vehicle's speed has on its rate of steering return." );
addField( "powerSteering", TypeBool, Offset(powerSteering, VehicleData), addField( "powerSteering", TypeBool, Offset(powerSteering, VehicleData),
"If true, steering does not auto-centre while the vehicle is being steered by its driver." ); "If true, steering does not auto-centre while the vehicle is being steered by its driver." );
addField( "massCenter", TypePoint3F, Offset(massCenter, VehicleData),
"Defines the vehicle's center of mass (offset from the origin of the model)." );
addField( "massBox", TypePoint3F, Offset(massBox, VehicleData),
"@brief Define the box used to estimate the vehicle's moment of inertia.\n\n"
"Currently only used by WheeledVehicle; other vehicle types use a "
"unit sphere to compute inertia." );
addField( "bodyRestitution", TypeF32, Offset(body.restitution, VehicleData),
"Collision 'bounciness'.\nNormally in the range 0 (not bouncy at all) to "
"1 (100% bounciness)." );
addField( "bodyFriction", TypeF32, Offset(body.friction, VehicleData),
"Collision friction coefficient.\nHow well this object will slide against "
"objects it collides with." );
INITPERSISTFIELD_SOUNDASSET_ENUMED(VehicleBodySounds, bodySounds, Body::Sounds::MaxSounds, VehicleData, "Sounds for vehicle body impacts.");
addField( "minImpactSpeed", TypeF32, Offset(minImpactSpeed, VehicleData),
"Minimum collision speed for the onImpact callback to be invoked." );
addField( "softImpactSpeed", TypeF32, Offset(softImpactSpeed, VehicleData),
"Minimum collision speed for the softImpactSound to be played." );
addField( "hardImpactSpeed", TypeF32, Offset(hardImpactSpeed, VehicleData),
"Minimum collision speed for the hardImpactSound to be played." );
addField( "minRollSpeed", TypeF32, Offset(minRollSpeed, VehicleData),
"Unused" );
addField( "maxSteeringAngle", TypeF32, Offset(maxSteeringAngle, VehicleData), addField( "maxSteeringAngle", TypeF32, Offset(maxSteeringAngle, VehicleData),
"Maximum yaw (horizontal) and pitch (vertical) steering angle in radians." ); "Maximum yaw (horizontal) and pitch (vertical) steering angle in radians." );
addField( "maxDrag", TypeF32, Offset(maxDrag, VehicleData),
"Maximum drag coefficient.\nCurrently unused." );
addField( "minDrag", TypeF32, Offset(minDrag, VehicleData),
"Minimum drag coefficient.\nCurrently only used by FlyingVehicle." );
addField( "integration", TypeS32, Offset(integration, VehicleData),
"Number of integration steps per tick.\nIncrease this to improve simulation "
"stability (also increases simulation processing time)." );
addField( "collisionTol", TypeF32, Offset(collisionTol, VehicleData),
"Minimum distance between objects for them to be considered as colliding." );
addField( "contactTol", TypeF32, Offset(contactTol, VehicleData),
"Maximum relative velocity between objects for collisions to be resolved "
"as contacts.\nVelocities greater than this are handled as collisions." );
addField( "cameraRoll", TypeBool, Offset(cameraRoll, VehicleData),
"If true, the camera will roll with the vehicle. If false, the camera will "
"always have the positive Z axis as up." );
addField( "cameraLag", TypeF32, Offset(cameraLag, VehicleData),
"@brief How much the camera lags behind the vehicle depending on vehicle speed.\n\n"
"Increasing this value will make the camera fall further behind the vehicle "
"as it accelerates away.\n\n@see cameraDecay." );
addField("cameraDecay", TypeF32, Offset(cameraDecay, VehicleData),
"How quickly the camera moves back towards the vehicle when stopped.\n\n"
"@see cameraLag." );
addField("cameraOffset", TypeF32, Offset(cameraOffset, VehicleData),
"Vertical (Z axis) height of the camera above the vehicle." );
addField( "dustEmitter", TYPEID< ParticleEmitterData >(), Offset(dustEmitter, VehicleData),
"Dust particle emitter.\n\n@see triggerDustHeight\n\n@see dustHeight");
addField( "triggerDustHeight", TypeF32, Offset(triggerDustHeight, VehicleData),
"@brief Maximum height above surface to emit dust particles.\n\n"
"If the vehicle is less than triggerDustHeight above a static surface "
"with a material that has 'showDust' set to true, the vehicle will emit "
"particles from the dustEmitter." );
addField( "dustHeight", TypeF32, Offset(dustHeight, VehicleData),
"Height above ground at which to emit particles from the dustEmitter." );
addField( "damageEmitter", TYPEID< ParticleEmitterData >(), Offset(damageEmitterList, VehicleData), VC_NUM_DAMAGE_EMITTERS, addField( "damageEmitter", TYPEID< ParticleEmitterData >(), Offset(damageEmitterList, VehicleData), VC_NUM_DAMAGE_EMITTERS,
"@brief Array of particle emitters used to generate damage (dust, smoke etc) " "@brief Array of particle emitters used to generate damage (dust, smoke etc) "
"effects.\n\n" "effects.\n\n"
@ -601,30 +326,6 @@ void VehicleData::initPersistFields()
addField( "numDmgEmitterAreas", TypeF32, Offset(numDmgEmitterAreas, VehicleData), addField( "numDmgEmitterAreas", TypeF32, Offset(numDmgEmitterAreas, VehicleData),
"Number of damageEmitterOffset values to use for each damageEmitter.\n\n" "Number of damageEmitterOffset values to use for each damageEmitter.\n\n"
"@see damageEmitterOffset" ); "@see damageEmitterOffset" );
addField( "splashEmitter", TYPEID< ParticleEmitterData >(), Offset(splashEmitterList, VehicleData), VC_NUM_SPLASH_EMITTERS,
"Array of particle emitters used to generate splash effects." );
addField( "splashFreqMod", TypeF32, Offset(splashFreqMod, VehicleData),
"@brief Number of splash particles to generate based on vehicle speed.\n\n"
"This value is multiplied by the current speed to determine how many "
"particles to generate each frame." );
addField( "splashVelEpsilon", TypeF32, Offset(splashVelEpsilon, VehicleData),
"Minimum speed when moving through water to generate splash particles." );
addField( "exitSplashSoundVelocity", TypeF32, Offset(exitSplashSoundVel, VehicleData),
"Minimum velocity when leaving the water for the exitingWater sound to play." );
addField( "softSplashSoundVelocity", TypeF32, Offset(softSplashSoundVel, VehicleData),
"Minimum velocity when entering the water for the imapactWaterEasy sound "
"to play.\n\n@see impactWaterEasy" );
addField( "mediumSplashSoundVelocity", TypeF32, Offset(medSplashSoundVel, VehicleData),
"Minimum velocity when entering the water for the imapactWaterMedium sound "
"to play.\n\n@see impactWaterMedium" );
addField( "hardSplashSoundVelocity", TypeF32, Offset(hardSplashSoundVel, VehicleData),
"Minimum velocity when entering the water for the imapactWaterHard sound "
"to play.\n\n@see impactWaterHard" );
INITPERSISTFIELD_SOUNDASSET_ENUMED(WaterSounds, vehSoundsEnum, VehicleData::Sounds::MaxSounds, VehicleData, "Sounds for interacting with water.");
addField( "collDamageThresholdVel", TypeF32, Offset(collDamageThresholdVel, VehicleData), addField( "collDamageThresholdVel", TypeF32, Offset(collDamageThresholdVel, VehicleData),
"Minimum collision velocity to cause damage to this vehicle.\nCurrently unused." ); "Minimum collision velocity to cause damage to this vehicle.\nCurrently unused." );
addField( "collDamageMultiplier", TypeF32, Offset(collDamageMultiplier, VehicleData), addField( "collDamageMultiplier", TypeF32, Offset(collDamageMultiplier, VehicleData),
@ -891,9 +592,6 @@ bool Vehicle::onNewDataBlock(GameBaseData* dptr,bool reload)
// Create the sound ahead of time. This reduces runtime // Create the sound ahead of time. This reduces runtime
// costs and makes the system easier to understand. // costs and makes the system easier to understand.
SFX_DELETE( mWakeSound ); SFX_DELETE( mWakeSound );
if ( mDataBlock->getVehicleWaterSounds(VehicleData::Wake) != NULL )
mWakeSound = SFX->createSource( mDataBlock->getVehicleWaterSoundsProfile(VehicleData::Wake), &getTransform() );
} }
return true; return true;
@ -1151,32 +849,32 @@ void Vehicle::updatePos(F32 dt)
F32 collSpeed = (mRigid.linVelocity - origVelocity).len(); F32 collSpeed = (mRigid.linVelocity - origVelocity).len();
S32 impactSound = -1; S32 impactSound = -1;
if (collSpeed >= mDataBlock->hardImpactSpeed) if (collSpeed >= mDataBlock->hardImpactSpeed)
impactSound = VehicleData::Body::HardImpactSound; impactSound = RigidShapeData::Body::HardImpactSound;
else else
if (collSpeed >= mDataBlock->softImpactSpeed) if (collSpeed >= mDataBlock->softImpactSpeed)
impactSound = VehicleData::Body::SoftImpactSound; impactSound = RigidShapeData::Body::SoftImpactSound;
if (impactSound != -1 && mDataBlock->getVehicleBodySoundsProfile(impactSound) != NULL) if (impactSound != -1 && mDataBlock->getBodySoundsProfile(impactSound) != NULL)
SFX->playOnce( mDataBlock->getVehicleBodySoundsProfile(impactSound), &getTransform() ); SFX->playOnce( mDataBlock->getBodySoundsProfile(impactSound), &getTransform() );
} }
// Water volume sounds // Water volume sounds
F32 vSpeed = getVelocity().len(); F32 vSpeed = getVelocity().len();
if (!inLiquid && mWaterCoverage >= 0.8f) { if (!inLiquid && mWaterCoverage >= 0.8f) {
if (vSpeed >= mDataBlock->hardSplashSoundVel) if (vSpeed >= mDataBlock->hardSplashSoundVel)
SFX->playOnce( mDataBlock->getVehicleWaterSoundsProfile(VehicleData::ImpactHard), &getTransform() ); SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactHard), &getTransform() );
else else
if (vSpeed >= mDataBlock->medSplashSoundVel) if (vSpeed >= mDataBlock->medSplashSoundVel)
SFX->playOnce( mDataBlock->getVehicleWaterSoundsProfile(VehicleData::ImpactMedium), &getTransform() ); SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactMedium), &getTransform() );
else else
if (vSpeed >= mDataBlock->softSplashSoundVel) if (vSpeed >= mDataBlock->softSplashSoundVel)
SFX->playOnce( mDataBlock->getVehicleWaterSoundsProfile(VehicleData::ImpactSoft), &getTransform() ); SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ImpactSoft), &getTransform() );
inLiquid = true; inLiquid = true;
} }
else else
if(inLiquid && mWaterCoverage < 0.8f) { if(inLiquid && mWaterCoverage < 0.8f) {
if (vSpeed >= mDataBlock->exitSplashSoundVel) if (vSpeed >= mDataBlock->exitSplashSoundVel)
SFX->playOnce( mDataBlock->getVehicleWaterSoundsProfile(VehicleData::ExitWater), &getTransform() ); SFX->playOnce( mDataBlock->getWaterSoundsProfile(RigidShapeData::ExitWater), &getTransform() );
inLiquid = false; inLiquid = false;
} }
} }
@ -1376,6 +1074,10 @@ void Vehicle::unpackUpdate(NetConnection *con, BitStream *stream)
setEnergyLevel(stream->readFloat(8) * mDataBlock->maxEnergy); setEnergyLevel(stream->readFloat(8) * mDataBlock->maxEnergy);
} }
void Vehicle::setControllingClient(GameConnection* client)
{
ShapeBase::setControllingClient(client);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View file

@ -39,18 +39,6 @@ struct VehicleData : public RigidShapeData
{ {
typedef RigidShapeData Parent; typedef RigidShapeData Parent;
struct Body {
enum Sounds {
SoftImpactSound,
HardImpactSound,
MaxSounds,
};
F32 restitution;
F32 friction;
} body;
DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleBodySounds, Body::Sounds::MaxSounds)
enum VehicleConsts enum VehicleConsts
{ {
VC_NUM_DUST_EMITTERS = 1, VC_NUM_DUST_EMITTERS = 1,
@ -62,44 +50,11 @@ struct VehicleData : public RigidShapeData
VC_BUBBLE_EMITTER = VC_NUM_DAMAGE_EMITTERS - VC_NUM_BUBBLE_EMITTERS, VC_BUBBLE_EMITTER = VC_NUM_DAMAGE_EMITTERS - VC_NUM_BUBBLE_EMITTERS,
}; };
enum Sounds {
ExitWater,
ImpactSoft,
ImpactMedium,
ImpactHard,
Wake,
MaxSounds
};
DECLARE_SOUNDASSET_ARRAY(VehicleData, VehicleWaterSounds, Sounds::MaxSounds)
F32 exitSplashSoundVel;
F32 softSplashSoundVel;
F32 medSplashSoundVel;
F32 hardSplashSoundVel;
F32 minImpactSpeed;
F32 softImpactSpeed;
F32 hardImpactSpeed;
F32 minRollSpeed;
F32 maxSteeringAngle; F32 maxSteeringAngle;
F32 collDamageThresholdVel; F32 collDamageThresholdVel;
F32 collDamageMultiplier; F32 collDamageMultiplier;
bool cameraRoll; ///< Roll the 3rd party camera
F32 cameraLag; ///< Amount of camera lag (lag += car velocity * lag)
F32 cameraDecay; ///< Rate at which camera returns to target pos.
F32 cameraOffset; ///< Vertical offset
F32 minDrag;
F32 maxDrag;
S32 integration; ///< # of physics steps per tick
F32 collisionTol; ///< Collision distance tolerance
F32 contactTol; ///< Contact velocity tolerance
Point3F massCenter; ///< Center of mass for rigid body
Point3F massBox; ///< Size of inertial box
F32 jetForce; F32 jetForce;
F32 jetEnergyDrain; ///< Energy drain/tick F32 jetEnergyDrain; ///< Energy drain/tick
F32 minJetEnergy; F32 minJetEnergy;
@ -108,22 +63,12 @@ struct VehicleData : public RigidShapeData
F32 steeringReturnSpeedScale; F32 steeringReturnSpeedScale;
bool powerSteering; bool powerSteering;
ParticleEmitterData * dustEmitter;
S32 dustID;
F32 triggerDustHeight; ///< height vehicle has to be under to kick up dust
F32 dustHeight; ///< dust height above ground
ParticleEmitterData * damageEmitterList[ VC_NUM_DAMAGE_EMITTERS ]; ParticleEmitterData * damageEmitterList[ VC_NUM_DAMAGE_EMITTERS ];
Point3F damageEmitterOffset[ VC_NUM_DAMAGE_EMITTER_AREAS ]; Point3F damageEmitterOffset[ VC_NUM_DAMAGE_EMITTER_AREAS ];
S32 damageEmitterIDList[ VC_NUM_DAMAGE_EMITTERS ]; S32 damageEmitterIDList[ VC_NUM_DAMAGE_EMITTERS ];
F32 damageLevelTolerance[ VC_NUM_DAMAGE_LEVELS ]; F32 damageLevelTolerance[ VC_NUM_DAMAGE_LEVELS ];
F32 numDmgEmitterAreas; F32 numDmgEmitterAreas;
ParticleEmitterData* splashEmitterList[VC_NUM_SPLASH_EMITTERS];
S32 splashEmitterIDList[VC_NUM_SPLASH_EMITTERS];
F32 splashFreqMod;
F32 splashVelEpsilon;
bool enablePhysicsRep; bool enablePhysicsRep;
// //
@ -171,6 +116,7 @@ class Vehicle : public RigidShape
void readPacketData (GameConnection * conn, BitStream *stream); void readPacketData (GameConnection * conn, BitStream *stream);
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream); U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream);
void unpackUpdate(NetConnection *conn, BitStream *stream); void unpackUpdate(NetConnection *conn, BitStream *stream);
void setControllingClient(GameConnection* connection);
void updateLiftoffDust( F32 dt ); void updateLiftoffDust( F32 dt );
void updateDamageSmoke( F32 dt ); void updateDamageSmoke( F32 dt );

View file

@ -289,15 +289,15 @@ ConsoleDocClass( WheeledVehicleData,
"@ingroup Vehicles\n" "@ingroup Vehicles\n"
); );
typedef WheeledVehicleData::Sounds wheelSoundsEnum; typedef WheeledVehicleData::Sounds WheeledVehicleSoundsEnum;
DefineEnumType(wheelSoundsEnum); DefineEnumType(WheeledVehicleSoundsEnum);
ImplementEnumType(wheelSoundsEnum, "enum types.\n" ImplementEnumType(WheeledVehicleSoundsEnum, "enum types.\n"
"@ingroup WheeledVehicleData\n\n") "@ingroup WheeledVehicleData\n\n")
{WheeledVehicleData::JetSound, "JetSound", "..." }, { WheeledVehicleSoundsEnum::JetSound, "JetSound", "..." },
{WheeledVehicleData::EngineSound, "EngineSound", "..." }, { WheeledVehicleSoundsEnum::EngineSound, "EngineSound", "..." },
{WheeledVehicleData::SquealSound, "SquealSound", "..." }, { WheeledVehicleSoundsEnum::SquealSound, "SquealSound", "..." },
{WheeledVehicleData::WheelImpactSound, "WheelImpactSound", "..." }, { WheeledVehicleSoundsEnum::WheelImpactSound, "WheelImpactSound", "..." },
EndImplementEnumType; EndImplementEnumType;
WheeledVehicleData::WheeledVehicleData() WheeledVehicleData::WheeledVehicleData()
@ -312,7 +312,7 @@ WheeledVehicleData::WheeledVehicleData()
wheelCount = 0; wheelCount = 0;
dMemset(&wheel, 0, sizeof(wheel)); dMemset(&wheel, 0, sizeof(wheel));
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
INIT_ASSET_ARRAY(WheeledVehicleSounds, i); INIT_SOUNDASSET_ARRAY(WheeledVehicleSounds, i);
} }
@ -448,7 +448,9 @@ bool WheeledVehicleData::mirrorWheel(Wheel* we)
void WheeledVehicleData::initPersistFields() void WheeledVehicleData::initPersistFields()
{ {
INITPERSISTFIELD_SOUNDASSET_ENUMED(WheeledVehicleSounds, wheelSoundsEnum, MaxSounds, WheeledVehicleData, "Sounds related to wheeled vehicle."); addGroup("Sounds");
INITPERSISTFIELD_SOUNDASSET_ENUMED(WheeledVehicleSounds, WheeledVehicleSoundsEnum, MaxSounds, WheeledVehicleData, "Sounds related to wheeled vehicle.");
endGroup("Sounds");
addField("tireEmitter",TYPEID< ParticleEmitterData >(), Offset(tireEmitter, WheeledVehicleData), addField("tireEmitter",TYPEID< ParticleEmitterData >(), Offset(tireEmitter, WheeledVehicleData),
"ParticleEmitterData datablock used to generate particles from each wheel " "ParticleEmitterData datablock used to generate particles from each wheel "
@ -483,7 +485,7 @@ void WheeledVehicleData::packData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
PACKDATA_ASSET_ARRAY(WheeledVehicleSounds, i); PACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i);
} }
stream->write(maxWheelSpeed); stream->write(maxWheelSpeed);
@ -502,7 +504,7 @@ void WheeledVehicleData::unpackData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++) for (S32 i = 0; i < MaxSounds; i++)
{ {
UNPACKDATA_ASSET_ARRAY(WheeledVehicleSounds, i); UNPACKDATA_SOUNDASSET_ARRAY(WheeledVehicleSounds, i);
} }
stream->read(&maxWheelSpeed); stream->read(&maxWheelSpeed);

View file

@ -221,7 +221,7 @@ SFXPlayList::SFXPlayList()
mNumSlotsToPlay( NUM_SLOTS ) mNumSlotsToPlay( NUM_SLOTS )
{ {
for (U32 i=0;i<NUM_SLOTS;i++) for (U32 i=0;i<NUM_SLOTS;i++)
INIT_ASSET_ARRAY(Track, i); INIT_SOUNDASSET_ARRAY(Track, i);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -429,7 +429,7 @@ void SFXPlayList::packData( BitStream* stream )
stream->write( mSlots.mRepeatCount[ i ] ); stream->write( mSlots.mRepeatCount[ i ] );
FOR_EACH_SLOT sfxWrite( stream, mSlots.mState[ i ] ); FOR_EACH_SLOT sfxWrite( stream, mSlots.mState[ i ] );
FOR_EACH_SLOT PACKDATA_ASSET_ARRAY(Track, i); FOR_EACH_SLOT PACKDATA_SOUNDASSET_ARRAY(Track, i);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -468,7 +468,7 @@ void SFXPlayList::unpackData( BitStream* stream )
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mRepeatCount[ i ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mRepeatCount[ i ] );}
FOR_EACH_SLOT sfxRead( stream, &mSlots.mState[ i ] ); FOR_EACH_SLOT sfxRead( stream, &mSlots.mState[ i ] );
FOR_EACH_SLOT UNPACKDATA_ASSET_ARRAY(Track, i); FOR_EACH_SLOT UNPACKDATA_SOUNDASSET_ARRAY(Track, i);
#undef FOR_EACH_SLOT #undef FOR_EACH_SLOT
} }

View file

@ -78,6 +78,12 @@ function spawnGameObject(%name, %addToScene)
return 0; return 0;
} }
function GameBaseData::onNewDataBlock(%this, %obj)
{
%this.onRemove(%obj);
%this.onAdd(%obj);
}
function saveGameObject(%name, %tamlPath, %scriptPath) function saveGameObject(%name, %tamlPath, %scriptPath)
{ {
%gameObjectAsset = findGameObject(%name); %gameObjectAsset = findGameObject(%name);