Refactor PhysicalMaterial to use API bindings
This commit is contained in:
@@ -5,20 +5,13 @@
|
||||
#include "Types.h"
|
||||
#include "Engine/Serialization/ISerializable.h"
|
||||
|
||||
// Default values for the physical material
|
||||
|
||||
#define PhysicalMaterial_Friction 0.7f
|
||||
#define PhysicalMaterial_FrictionCombineMode PhysicsCombineMode::Average
|
||||
#define PhysicalMaterial_OverrideFrictionCombineMode false
|
||||
#define PhysicalMaterial_Restitution 0.3f
|
||||
#define PhysicalMaterial_RestitutionCombineMode PhysicsCombineMode::Average
|
||||
#define PhysicalMaterial_OverrideRestitutionCombineMode false
|
||||
|
||||
/// <summary>
|
||||
/// Physical materials are used to define the response of a physical object when interacting dynamically with the world.
|
||||
/// </summary>
|
||||
class FLAXENGINE_API PhysicalMaterial : public ISerializable
|
||||
API_CLASS() class FLAXENGINE_API PhysicalMaterial final : public ISerializable
|
||||
{
|
||||
API_AUTO_SERIALIZATION();
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(PhysicalMaterial);
|
||||
private:
|
||||
|
||||
PxMaterial* _material;
|
||||
@@ -40,32 +33,38 @@ public:
|
||||
/// <summary>
|
||||
/// The friction value of surface, controls how easily things can slide on this surface.
|
||||
/// </summary>
|
||||
float Friction = PhysicalMaterial_Friction;
|
||||
API_FIELD(Attributes="EditorOrder(0), Limit(0), EditorDisplay(\"Physical Material\")")
|
||||
float Friction = 0.7f;
|
||||
|
||||
/// <summary>
|
||||
/// The friction combine mode, controls how friction is computed for multiple materials.
|
||||
/// </summary>
|
||||
PhysicsCombineMode FrictionCombineMode = PhysicalMaterial_FrictionCombineMode;
|
||||
API_FIELD(Attributes="EditorOrder(1), EditorDisplay(\"Physical Material\")")
|
||||
PhysicsCombineMode FrictionCombineMode = PhysicsCombineMode::Average;
|
||||
|
||||
/// <summary>
|
||||
/// If set we will use the FrictionCombineMode of this material, instead of the FrictionCombineMode found in the Physics settings.
|
||||
/// </summary>
|
||||
bool OverrideFrictionCombineMode = PhysicalMaterial_OverrideFrictionCombineMode;
|
||||
API_FIELD(Attributes="HideInEditor")
|
||||
bool OverrideFrictionCombineMode = false;
|
||||
|
||||
/// <summary>
|
||||
/// The restitution or 'bounciness' of this surface, between 0 (no bounce) and 1 (outgoing velocity is same as incoming).
|
||||
/// </summary>
|
||||
float Restitution = PhysicalMaterial_Restitution;
|
||||
API_FIELD(Attributes="EditorOrder(3), Range(0, 1), EditorDisplay(\"Physical Material\")")
|
||||
float Restitution = 0.3f;
|
||||
|
||||
/// <summary>
|
||||
/// The restitution combine mode, controls how restitution is computed for multiple materials.
|
||||
/// </summary>
|
||||
PhysicsCombineMode RestitutionCombineMode = PhysicalMaterial_RestitutionCombineMode;
|
||||
API_FIELD(Attributes="EditorOrder(4), EditorDisplay(\"Physical Material\")")
|
||||
PhysicsCombineMode RestitutionCombineMode = PhysicsCombineMode::Average;
|
||||
|
||||
/// <summary>
|
||||
/// If set we will use the RestitutionCombineMode of this material, instead of the RestitutionCombineMode found in the Physics settings.
|
||||
/// </summary>
|
||||
bool OverrideRestitutionCombineMode = PhysicalMaterial_OverrideRestitutionCombineMode;
|
||||
API_FIELD(Attributes="HideInEditor")
|
||||
bool OverrideRestitutionCombineMode = false;
|
||||
|
||||
public:
|
||||
|
||||
@@ -79,10 +78,4 @@ public:
|
||||
/// Updates the PhysX material (after any property change).
|
||||
/// </summary>
|
||||
void UpdatePhysXMaterial();
|
||||
|
||||
public:
|
||||
|
||||
// [ISerializable]
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user