sound asset conversions - materials

This commit is contained in:
AzaezelX 2021-10-14 19:09:20 -05:00
parent 9af2de3c4b
commit f0d919e859
3 changed files with 15 additions and 9 deletions

View file

@ -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;

View file

@ -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"

View file

@ -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.