lovr.physics.newWorld

Edit

Creates a new physics World.

world = lovr.physics.newWorld(settings)

Arguments

NameTypeDefaultDescription
settingstable An optional table with settings for the physics simulation.
.tagstable{} The list of collision tags (strings). Colliders can be assigned a tag, and collision can be enabled and disabled between different tags. There is a maximum of 31 tags.
.staticTagstable{} An optional list of collision tags that are "static". Colliders with a static tag will not move, and the physics engine uses this for optimization.
.maxCollidersnumber16384 The maximum number of Colliders in the World. Increasing this will use more memory. This can't be bigger than 2^23 (around 8 million).
.threadSafebooleantrue Whether the World and the objects it contains can be used from multiple threads. This will use a set of locks to ensure only one thread can access a Collider at a given time. Disable this to potentially get a small performance boost when only using the World from a single Thread.
.allowSleepbooleantrue Whether colliders should be allowed to go to sleep when they come to rest. Sleeping colliders don't need to simulate movement until something hits them. This improves performance a lot for a typical physics scene where many objects are at rest.
.stabilizationnumber0.2 How quickly the physics engine corrects position error from collisions and joints, from 0 to 1. If the value is too low, objects will be spongy, but if it's too high then physics will explode. Values between .2 and .8 are recommended.
.maxPenetrationnumber.01 The maximum amount that colliders are allowed to overlap, in meters.
.restitutionThresholdnumber1.0 A velocity below which restitution (bounciness) will not be applied, in meters per second. If this is too low then objects may have trouble coming to rest.
.velocityStepsnumber10 The number of solver velocity iterations to run per tick. This must be at least 2. Larger values will increase accuracy but use more CPU.
.positionStepsnumber2 The number of solver position iterations to run per tick. Larger values will increase accuracy but use more CPU.

Returns

NameTypeDescription
worldWorld A whole new World.

See also