// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Config/Settings.h" #include "Engine/Core/Math/Vector3.h" #include "Types.h" // Default values for the physics settings #define PhysicsSettings_DefaultGravity Vector3(0, -981.0f, 0) #define PhysicsSettings_TriangleMeshTriangleMinAreaThreshold (5.0f) #define PhysicsSettings_BounceThresholdVelocity (200.0f) #define PhysicsSettings_FrictionCombineMode PhysicsCombineMode::Average #define PhysicsSettings_RestitutionCombineMode PhysicsCombineMode::Average #define PhysicsSettings_DisableCCD false #define PhysicsSettings_EnableAdaptiveForce false #define PhysicsSettings_MaxDeltaTime (1.0f / 10.0f) #define PhysicsSettings_EnableSubstepping false #define PhysicsSettings_SubstepDeltaTime (1.0f / 120.0f) #define PhysicsSettings_MaxSubsteps 5 #define PhysicsSettings_QueriesHitTriggers true #define PhysicsSettings_SupportCookingAtRuntime false /// /// Physics simulation settings container. /// /// class PhysicsSettings : public Settings { public: /// /// Initializes a new instance of the class. /// PhysicsSettings() { for (int32 i = 0; i < 32; i++) LayerMasks[i] = MAX_uint32; } public: /// /// The default gravity force value (in cm^2/s). /// Vector3 DefaultGravity = PhysicsSettings_DefaultGravity; /// /// Triangles from triangle meshes (CSG) with an area less than or equal to this value will be removed from physics collision data. Set to less than or equal 0 to disable. /// float TriangleMeshTriangleMinAreaThreshold = PhysicsSettings_TriangleMeshTriangleMinAreaThreshold; /// /// Minimum relative velocity required for an object to bounce. A typical value for simulation stability is about 0.2 * gravity /// float BounceThresholdVelocity = PhysicsSettings_BounceThresholdVelocity; /// /// Default friction combine mode, controls how friction is computed for multiple materials. /// PhysicsCombineMode FrictionCombineMode = PhysicsSettings_FrictionCombineMode; /// /// Default restitution combine mode, controls how restitution is computed for multiple materials. /// PhysicsCombineMode RestitutionCombineMode = PhysicsSettings_RestitutionCombineMode; /// /// If true CCD will be ignored. This is an optimization when CCD is never used which removes the need for physx to check it internally. /// bool DisableCCD = PhysicsSettings_DisableCCD; /// /// Enables adaptive forces to accelerate convergence of the solver. Can improve physics simulation performance but lead to artifacts. /// bool EnableAdaptiveForce = PhysicsSettings_EnableAdaptiveForce; /// /// The maximum allowed delta time (in seconds) for the physics simulation step. /// float MaxDeltaTime = PhysicsSettings_MaxDeltaTime; /// /// Whether to substep the physics simulation. /// bool EnableSubstepping = PhysicsSettings_EnableSubstepping; /// /// Delta time (in seconds) for an individual simulation substep. /// float SubstepDeltaTime = PhysicsSettings_SubstepDeltaTime; /// /// The maximum number of substeps for physics simulation. /// int32 MaxSubsteps = PhysicsSettings_MaxSubsteps; /// /// If enabled, any Raycast or other scene query that intersects with a Collider marked as a Trigger will returns with a hit. Individual raycasts can override this behavior. /// bool QueriesHitTriggers = PhysicsSettings_QueriesHitTriggers; /// /// Enables support for cooking physical collision shapes geometry at runtime. Use it to enable generating runtime terrain collision or convex mesh colliders. /// bool SupportCookingAtRuntime = PhysicsSettings_SupportCookingAtRuntime; public: /// /// The collision layers masks. Used to define layer-based collision detection. /// uint32 LayerMasks[32]; public: // [Settings] void Apply() override; void RestoreDefault() override; void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override; };