From f0d919e85900b1b14b247833770f482dd11f9aab Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 14 Oct 2021 19:09:20 -0500 Subject: [PATCH] sound asset conversions - materials --- Engine/source/T3D/player.cpp | 8 ++++---- Engine/source/materials/materialDefinition.cpp | 7 ++++--- Engine/source/materials/materialDefinition.h | 9 +++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index b1df95f36..6ff20e298 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -7042,11 +7042,11 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S } } } - else if( contactMaterial && contactMaterial->mFootstepSoundCustom ) + else if( contactMaterial && contactMaterial->getCustomFootstepSoundProfile()) { // Footstep sound defined on material. - SFX->playOnce( contactMaterial->mFootstepSoundCustom, &footMat ); + SFX->playOnce( contactMaterial->getCustomFootstepSoundProfile(), &footMat ); } else { @@ -7079,8 +7079,8 @@ void Player:: playImpactSound() { Material* material = ( rInfo.material ? dynamic_cast< Material* >( rInfo.material->getMaterial() ) : 0 ); - if( material && material->mImpactSoundCustom ) - SFX->playOnce( material->mImpactSoundCustom, &getTransform() ); + if( material && material->getCustomImpactSoundProfile() ) + SFX->playOnce( material->getCustomImpactSoundProfile(), &getTransform() ); else { S32 sound = -1; diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index 07a769ee7..1ed904bee 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -231,7 +231,8 @@ Material::Material() mFootstepSoundId = -1; mImpactSoundId = -1; mImpactFXIndex = -1; - mFootstepSoundCustom = 0; mImpactSoundCustom = 0; + INIT_ASSET(CustomFootstepSound); + INIT_ASSET(CustomImpactSound); mFriction = 0.0; mDirectSoundOcclusion = 1.f; @@ -476,7 +477,7 @@ void Material::initPersistFields() "- 16: PlayerData::impactWaterHard\n" "- 17: PlayerData::exitingWater\n"); - addField("customFootstepSound", TypeSFXTrackName, Offset(mFootstepSoundCustom, Material), + INITPERSISTFIELD_SOUNDASSET(CustomFootstepSound, Material, "The sound to play when the player walks over the material. If this is set, it overrides #footstepSoundId. This field is " "useful for directly assigning custom footstep sounds to materials without having to rely on the PlayerData sound assignment.\n\n" "@warn Be aware that materials are client-side objects. This means that the SFXTracks assigned to materials must be client-side, too."); @@ -488,7 +489,7 @@ void Material::initPersistFields() "What FX to play from the PlayerData sound list when the player impacts on the surface with a velocity equal or greater " "than PlayerData::groundImpactMinSpeed.\n\n" "For a list of IDs, see #impactFXId"); - addField("customImpactSound", TypeSFXTrackName, Offset(mImpactSoundCustom, Material), + INITPERSISTFIELD_SOUNDASSET(CustomImpactSound, Material, "The sound to play when the player impacts on the surface with a velocity equal or greater than PlayerData::groundImpactMinSpeed. " "If this is set, it overrides #impactSoundId. This field is useful for directly assigning custom impact sounds to materials " "without having to rely on the PlayerData sound assignment.\n\n" diff --git a/Engine/source/materials/materialDefinition.h b/Engine/source/materials/materialDefinition.h index 0e258e2c5..e29f53695 100644 --- a/Engine/source/materials/materialDefinition.h +++ b/Engine/source/materials/materialDefinition.h @@ -47,6 +47,9 @@ #ifndef _ASSET_PTR_H_ #include "assets/assetPtr.h" #endif +#ifndef SOUND_ASSET_H +#include "T3D/assets/SoundAsset.h" +#endif class CubemapData; class SFXTrack; @@ -367,8 +370,10 @@ public: /// Sound effect to play when walking on surface with this material. /// If defined, overrides mFootstepSoundId. /// @see mFootstepSoundId - SFXTrack* mFootstepSoundCustom; - SFXTrack* mImpactSoundCustom; + DECLARE_SOUNDASSET(Material, CustomFootstepSound); + DECLARE_ASSET_SETGET(Material, CustomFootstepSound); + DECLARE_SOUNDASSET(Material, CustomImpactSound); + DECLARE_ASSET_SETGET(Material, CustomImpactSound); F32 mFriction; ///< Friction coefficient when moving along surface.