// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. #pragma once #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 /// /// Physical materials are used to define the response of a physical object when interacting dynamically with the world. /// class FLAXENGINE_API PhysicalMaterial : public ISerializable { 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. /// float Friction = PhysicalMaterial_Friction; /// /// The friction combine mode, controls how friction is computed for multiple materials. /// PhysicsCombineMode FrictionCombineMode = PhysicalMaterial_FrictionCombineMode; /// /// If set we will use the FrictionCombineMode of this material, instead of the FrictionCombineMode found in the Physics settings. /// bool OverrideFrictionCombineMode = PhysicalMaterial_OverrideFrictionCombineMode; /// /// The restitution or 'bounciness' of this surface, between 0 (no bounce) and 1 (outgoing velocity is same as incoming). /// float Restitution = PhysicalMaterial_Restitution; /// /// The restitution combine mode, controls how restitution is computed for multiple materials. /// PhysicsCombineMode RestitutionCombineMode = PhysicalMaterial_RestitutionCombineMode; /// /// If set we will use the RestitutionCombineMode of this material, instead of the RestitutionCombineMode found in the Physics settings. /// bool OverrideRestitutionCombineMode = PhysicalMaterial_OverrideRestitutionCombineMode; public: /// /// Gets the PhysX material. /// /// The native material object. PxMaterial* GetPhysXMaterial(); /// /// Updates the PhysX material (after any property change). /// void UpdatePhysXMaterial(); public: // [ISerializable] void Serialize(SerializeStream& stream, const void* otherObj) override; void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override; };