// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Config/Settings.h" #include "Engine/Core/Math/Vector3.h" #include "Types.h" /// /// Physics simulation settings container. /// API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings", NoConstructor) class FLAXENGINE_API PhysicsSettings : public SettingsBase { DECLARE_SCRIPTING_TYPE_MINIMAL(PhysicsSettings); public: /// /// The default gravity force value (in cm^2/s). /// API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"Simulation\")") Vector3 DefaultGravity = Vector3(0, -981.0f, 0); /// /// Minimum relative velocity required for an object to bounce. A typical value for simulation stability is about 0.2 * gravity /// API_FIELD(Attributes="EditorOrder(30), EditorDisplay(\"Simulation\")") float BounceThresholdVelocity = 200.0f; /// /// Default friction combine mode, controls how friction is computed for multiple materials. /// API_FIELD(Attributes="EditorOrder(40), EditorDisplay(\"Simulation\")") PhysicsCombineMode FrictionCombineMode = PhysicsCombineMode::Average; /// /// Default restitution combine mode, controls how restitution is computed for multiple materials. /// API_FIELD(Attributes="EditorOrder(40), EditorDisplay(\"Simulation\")") PhysicsCombineMode RestitutionCombineMode = PhysicsCombineMode::Average; /// /// If true CCD will be ignored. This is an optimization when CCD is never used which removes the need for physics to check it internally. /// API_FIELD(Attributes="EditorOrder(70), EditorDisplay(\"Simulation\")") bool DisableCCD = false; /// /// Enables adaptive forces to accelerate convergence of the solver. Can improve physics simulation performance but lead to artifacts. /// API_FIELD(Attributes="EditorOrder(80), EditorDisplay(\"Simulation\")") bool EnableAdaptiveForce = false; /// /// The maximum allowed delta time (in seconds) for the physics simulation step. /// API_FIELD(Attributes="EditorOrder(1000), EditorDisplay(\"Framerate\")") float MaxDeltaTime = 0.1f; /// /// Whether to substep the physics simulation. /// API_FIELD(Attributes="EditorOrder(1005), EditorDisplay(\"Framerate\")") bool EnableSubstepping = false; /// /// Delta time (in seconds) for an individual simulation substep. /// API_FIELD(Attributes="EditorOrder(1010), EditorDisplay(\"Framerate\")") float SubstepDeltaTime = 0.00833333333f; /// /// The maximum number of substeps for physics simulation. /// API_FIELD(Attributes="EditorOrder(1020), EditorDisplay(\"Framerate\")") int32 MaxSubsteps = 5; /// /// Enables support for cooking physical collision shapes geometry at runtime. Use it to enable generating runtime terrain collision or convex mesh colliders. /// API_FIELD(Attributes="EditorOrder(1100), EditorDisplay(\"Other\")") bool SupportCookingAtRuntime = false; /// /// 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. /// API_FIELD(Attributes="EditorOrder(1110), EditorDisplay(\"Other\")") float TriangleMeshTriangleMinAreaThreshold = 5.0f; /// /// 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. /// API_FIELD(Attributes="EditorOrder(1200), EditorDisplay(\"Other\")") bool QueriesHitTriggers = true; /// /// The collision layers masks. Used to define layer-based collision detection. /// uint32 LayerMasks[32]; public: /// /// Initializes a new instance of the class. /// PhysicsSettings(); /// /// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use. /// static PhysicsSettings* Get(); // [SettingsBase] void Apply() override; void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override; };