// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "Types.h"
#include "Engine/Serialization/ISerializable.h"
///
/// Physical materials are used to define the response of a physical object when interacting dynamically with the world.
///
API_CLASS() class FLAXENGINE_API PhysicalMaterial final : public ISerializable
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE_MINIMAL(PhysicalMaterial);
private:
PxMaterial* _material;
public:
///
/// Initializes a new instance of the class.
///
PhysicalMaterial();
///
/// Finalizes an instance of the class.
///
~PhysicalMaterial();
public:
///
/// The friction value of surface, controls how easily things can slide on this surface.
///
API_FIELD(Attributes="EditorOrder(0), Limit(0), EditorDisplay(\"Physical Material\")")
float Friction = 0.7f;
///
/// The friction combine mode, controls how friction is computed for multiple materials.
///
API_FIELD(Attributes="EditorOrder(1), EditorDisplay(\"Physical Material\")")
PhysicsCombineMode FrictionCombineMode = PhysicsCombineMode::Average;
///
/// If set we will use the FrictionCombineMode of this material, instead of the FrictionCombineMode found in the Physics settings.
///
API_FIELD(Attributes="HideInEditor")
bool OverrideFrictionCombineMode = false;
///
/// The restitution or 'bounciness' of this surface, between 0 (no bounce) and 1 (outgoing velocity is same as incoming).
///
API_FIELD(Attributes="EditorOrder(3), Range(0, 1), EditorDisplay(\"Physical Material\")")
float Restitution = 0.3f;
///
/// The restitution combine mode, controls how restitution is computed for multiple materials.
///
API_FIELD(Attributes="EditorOrder(4), EditorDisplay(\"Physical Material\")")
PhysicsCombineMode RestitutionCombineMode = PhysicsCombineMode::Average;
///
/// If set we will use the RestitutionCombineMode of this material, instead of the RestitutionCombineMode found in the Physics settings.
///
API_FIELD(Attributes="HideInEditor")
bool OverrideRestitutionCombineMode = false;
public:
///
/// Gets the PhysX material.
///
/// The native material object.
PxMaterial* GetPhysXMaterial();
///
/// Updates the PhysX material (after any property change).
///
void UpdatePhysXMaterial();
};