Commit Graph

31 Commits

Author SHA1 Message Date
bjorn 24708f7114 Shape fixes;
- Collider always has Shape now.  When left off or set to null, it's a
  tiny sphere (representing a point).
- Preserve shape offset when changing shape.
2024-04-06 12:51:17 -07:00
bjorn f82715d402 lovrColliderCreate takes shape;
Jolt requires a shape, also it saves a bit of work.
2024-04-06 12:50:59 -07:00
bjorn f79dec31ff Collider shape is required I think;
Jolt doesn't really support bodies without shapes.
2024-04-06 12:50:35 -07:00
bjorn 6b5244a8e1 Add Collider:get/setShapeOffset; 2024-04-06 12:50:35 -07:00
bjorn 8f40d98074 World queries return collider/shapeindex instead of Shape; 2024-04-06 12:50:35 -07:00
bjorn e842c2b772 Require frozen CompoundShapes to have at least 2 children;
If you create a StaticCompoundShape with 1 child, Jolt creates a
RotatedTranslatedShape.  It would be a pain to have to branch on that,
so let's just require 2 children.
2024-04-06 12:50:35 -07:00
bjorn 48559ccd0f rm Shape setters;
Jolt doesn't support this and requires you to recreate the shape.  Since
the shape -> collider relationship is 1:N, we can't really create a new
shape because we'd have to figure out which colliders/compoundshapes to
assign it to, which isn't feasible.
2024-04-06 12:50:35 -07:00
bjorn 6cf9f8082e CompoundShape fixes; 2024-04-06 12:50:35 -07:00
bjorn 7640be2281 Shapes set their userdata; 2024-04-06 12:50:35 -07:00
bjorn 7474192e78 CompoundShape API; 2024-04-06 12:50:35 -07:00
bjorn 50fbcf1450 Start CompoundShape; 2024-04-06 12:50:35 -07:00
bjorn 5244420828 Colliders can only have 1 shape; rm shape pose; 2024-04-06 12:50:35 -07:00
bjorn f4d5c0d758 Add assert for body count; 2024-04-06 00:47:31 -07:00
bjorn 38a68dc4e5 TerrainShape image must be square; 2024-04-06 00:12:50 -07:00
bjorn 5e521b7698 Collider:applyLinear/AngularImpulse; 2024-04-05 19:16:39 -07:00
bjorn fb6b402034 Add Collider:is/setContinuous; 2024-04-05 19:05:25 -07:00
bjorn e9fe088521 Add Collider:get/setGravityScale; Deprecate Collider:get/setGravityIgnored; 2024-04-05 14:22:02 -07:00
bjorn 01194a80c7 Deprecate several World methods;
They still work on ODE, and Jolt makes a best-effort attempt to support
them, but they will be removed in a future version.

- Damping should be set explicitly on colliders.
- Tightness and response time will be supported via spring forces, and
  also some global settings in newWorld will affect joints too.
- Step count will be added to :update soon.  Since the correct value is
  dt-dependent in Jolt, a persistent accessor doesn't make sense.
- Sleeping allowed will be an immutable setting in newWorld soon, but
  otherwise should be changed per-collider.
2024-04-05 14:07:56 -07:00
bjorn ffc23497a9 Details; 2024-04-05 13:58:28 -07:00
bjorn d756cc2b1d Add variant of newWorld that takes an options table; 2024-04-05 13:25:32 -07:00
bjorn ecbd331552 Details; 2024-04-01 20:49:50 -07:00
bjorn fdba60214c Fix Collider/Shape/Joint UserData leak;
refs are cumbersome because they require storing an int and they require
manual cleanup when the object is destroyed.

Instead, we'll go with a pure Lua solution using a table in the
registry.  The table has weak keys containing the LÖVR object, and the
values are the userdata.  This doesn't require any manual cleanup,
reduces the size of objects by 8 bytes, and is about 25% faster.
2024-04-01 16:03:42 -07:00
bjorn cdecc1bae7 Add defer system; Rework exceptions; util cleanup;
Defer can be used to clean up resources when an error occurs.
2024-03-29 18:10:22 -07:00
bjorn b7e1b5111e jolt: fix some shape memory leaks; 2024-03-29 15:26:10 -07:00
bjorn c5d6bb6b48 jolt: rm matrix copies;
JoltC now uses floats for its RVec/RMatrix structs in single precision
mode, so we can operate on them as mat4's directly, copy/cast them, etc.
2024-03-29 15:26:03 -07:00
bjorn 87cd13d95c jolt: adjust includes; 2024-03-29 15:25:41 -07:00
bjorn d097d9819d Add wrappers for malloc functions; 2024-03-11 14:38:00 -07:00
bjorn 2d7b636a90 Change more asserts to checks; 2024-03-11 00:58:21 -07:00
Josip Miskovic 47c9b20542 Jolt world-level damping and sleeping allowed
The damping 0.05 value comes from Jolt's BodyCreationSettings.h.
2024-02-13 19:18:57 +01:00
Josip Miskovic 431062c345 Increase Jolt body & constraint limits
The new values come from comments in the official HelloWorld.cpp. After
the changes the any increase of memory consumption is within the
measurement error.
2024-02-13 17:25:43 +01:00
Josip Miskovic 1ad8f23fb8 Jolt physics engine integration 2024-01-30 18:22:27 +01:00