Skip to content

Engine → Physics → physics_settings.h

physics_settings

Syntax

struct CONJURE_API physics_settings

Variables

AccessNameTypeDefaultDescription
publicallowSleepingbooltrue
publiccollisionStepsu321
publicdeterministicbooltrue
publicestimateContactImpulsesbooltrue
publicgravitymath::vec3math::vec3(0.0f, -9.81f, 0.0f)
publiclayersphysics_layer_table{}
publicmaxBarriersu328
publicmaxBodiesu3265536
publicmaxBodyPairsu3265536
publicmaxCharactersu32256
publicmaxContactConstraintsu3216384
publicmaxContactEventsPerStepu3216384
publicmaxJobsu322048
publicmaxQueuedCommandsu328192
publicnumBodyMutexesu320
publicnumPositionStepsu322
publicnumVelocityStepsu3210
publicpenetrationSlopf320.005f
publicpointVelocitySleepThresholdf320.03f
publicspeculativeContactDistancef320.02f
publictempAllocatorBytesusize32 * MIB
publictimeBeforeSleepSecondsf320.5f

Functions

Public

from_json

[[nodiscard]] static core::result<physics_settings> from_json(
    const core::json::value &physicsSection,
    const core::json::value &layersSection);

Reads the project.json "physics" object (snake_case keys matching the fields above; "enabled" is the engine's and is ignored; unknown keys log one WARN each) and the "extensions.physics_layers" object (an invalid or missing value keeps the default table). Fails with INVALID_SETTINGS for a value of the wrong type and with the layer errors of physics_layer_table::from_json. The result is not validated; call validate().

validate

[[nodiscard]] core::result<void> validate() const;

Rejects maxBodies == 0 or above 1 << 23, a maxBodyPairs or maxContactConstraints below 4 or above 1 << 24, collisionSteps == 0, tempAllocatorBytes below 1 MiB, a maxJobs below 64 or not a power of two, maxBarriers == 0, maxContactEventsPerStep == 0, maxQueuedCommands == 0, maxCharacters == 0, numVelocitySteps == 0, numPositionSteps == 0, a negative timeBeforeSleepSeconds, pointVelocitySleepThreshold, speculativeContactDistance or penetrationSlop, a non-finite gravity, and whatever layers.validate() rejects. The INVALID_SETTINGS message names the field.