Commit Graph

19 Commits

Author SHA1 Message Date
Josip Miskovic 24a0751c16 Add `World:setStepIterations(num)` and its getter
Physics world's "quick step" is executed in multiple iteration steps.
The getter and setter for this value is now made available as two new
methods in the World object.

This is allows user to balance between the less accurate but quick
simulations, and more stable behavior of physics.

Something similar was already possible, by reducing the delta time and
running the sim multiple times per frame. However, any force user applies
to collider is zeroed after each step. User would thus have to keep track
of applied forces, and re-apply them inside the physics iteration loop.

By default ODE uses 20 iterations in quick step.
2022-04-27 11:39:08 -07:00
bjorn 42e618fa00 World:getContacts; 2022-03-30 22:32:20 -07:00
bjorn 8fcdfd2bb4 Minor physics cleanup; 2022-03-30 22:05:10 -07:00
bjorn 6c9531564e Make physics structs private; 2022-03-25 12:40:29 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn 61ef2747ee World:newMeshCollider uses luax_readmesh;
This is a breaking API change -- instead of a table of tables, a flat
table of coordinates must be used.
2021-03-25 12:29:11 -06:00
bjorn e63099ba6a Flatten api.h; 2021-03-15 18:54:27 -06:00
bjorn 57a215a0aa Minor MeshShape cleanup;
- Fix memory leak
- Minor error message improvements
2021-02-19 17:28:04 -07:00
bjorn bc4cde1653 Adjust lovrRelease signature; 2021-02-08 17:52:26 -07:00
bjorn 3ded60948f rm core/ref; rm lovrAlloc; util does refcounting; 2021-02-08 17:26:44 -07:00
bjorn 3bc2c00b79 api doesn't include util; 2020-12-25 12:50:26 -07:00
Josip Miskovic b4d391f45f Change default damping threshold to zero
Zero as default makes more sense. Colliders can come to full stop which
allows them to go to sleep for CPU optimization. Also in zero gravity
colliders crawling through air with 0.01 velocity are infuriating.
2020-11-12 18:28:59 +01:00
Josip Miskovic 75591fde42 Support for trimesh shape colliders 2020-09-24 20:58:28 +02:00
Josip Miskovic 5d18933411 Limit simulation parameters to positive values 2020-06-03 20:13:13 +03:00
Josip Miskovic 139808cab0 Get/set World and Joint simulation parameters
Tightness parameter is amount of force is exerted on collider to resolve
collisions and enforce joint operation. Low values make joints loose,
high values make it tight and can cause collider to overshot the joint
target. With tightness set to 0 the joint loses its function. Going
above 1 puts even more energy into joint oscillations. Tightness
parameter is called ERP in ODE manual.

The responseTime affects the time constant of physics simulation, both
for collisions and for joint inertia. Low responseTime values make
simulation tight and fast, higher values make it sluggish. For
collisions it affects how fast penetration is resolved, with higher
values resulting in spongy objects with more surface penetration and
slower collision resolving. For joints the responseTime is similar to
inertia, with higher responseTime values resulting in slow oscillations.
The oscillation frequency is also affected by collider mass, so
responseTime can be used to tweak the joint to get desired frequency
with specific collider mass. Values higher than 1 are often desirable,
especially for very light objects. Unlike tightness, responseTime is
tweaked in orders of magnitude with useful values (depending on mass)
being between 10^-8 and 10^8.

Both parameters can be applied to World for simulation-wide usage, or
specified per-joint in case of distance and ball joints. Other joints
don't allow customizing these parameters, and will use World settings
instead..
2020-06-03 19:03:38 +03:00
bjorn dab0be7055 World:getColliders; 2020-05-11 12:05:30 -06:00
Josip Miskovic 2463737722 Physics world accepts both vec3 and number coords
When creating colliders, setting gravity or casting rays on world,
arguments accept either coordinate numbers as before, or vec3 objects.
For functions that receive more than one set of coordinates, any
combination of coordinates and vectors is accepted.
2020-05-07 19:01:30 +03:00
Josip Miskovic 097d39628a Initialize inertia information for new colliders
Inertia matrix has to be calculated with algorithm specific for each
shape. Without calculated matrix the physics behaves very floaty and
slowed down.
2020-04-29 23:05:11 +03:00
bjorn c9b1f257bf api: try new file naming convention; Tupfile: cleanup;
I assume full responsibility for any catastrophes this causes.
2019-12-31 19:31:44 -08:00
Renamed from src/api/l_world.c (Browse further)