Borrowed shape handles identify a one-based child slot on a Defold-owned collision object. They remain attached to that logical slot when its native shape is replaced and become invalid with their owning collision object. Shape mutation is copy-on-write, so instances sharing a collision resource are not modified together. Lengths use Defold world units.
Version: alpha
| FUNCTIONS | |
|---|---|
| bullet3d.collision_object.get_shape() | Get one attached shape by one-based index. |
| bullet3d.collision_object.get_shape_count() | Get the number of shapes attached to a collision object. |
| bullet3d.collision_object.get_shapes() | Get all attached shapes. |
| bullet3d.shape.get_collision_object() | Get the owning collision object. |
| bullet3d.shape.get_index() | Get the one-based child index. |
| bullet3d.shape.get_local_transform() | Get a compound child's local transform. |
| bullet3d.shape.get_shape() | Get shape geometry data. |
| bullet3d.shape.get_type() | Get the normalized Defold shape type. |
| bullet3d.shape.is_valid() | Test whether a shape handle and its owner still exist. |
| bullet3d.shape.set_local_transform() | Set a compound child's local transform. |
| bullet3d.shape.set_shape() | Set shape geometry data. |
| CONSTANTS | |
|---|---|
| bullet3d.shape.SHAPE_TYPE_BOX | Box shape type |
| bullet3d.shape.SHAPE_TYPE_CAPSULE | Capsule shape type |
| bullet3d.shape.SHAPE_TYPE_HULL | Convex hull shape type |
| bullet3d.shape.SHAPE_TYPE_SPHERE | Sphere shape type |
bullet3d.collision_object.get_shape(object,shape_index)
Get one attached shape by one-based index.
PARAMETERS
object |
btCollisionObject |
collision object |
shape_index |
number |
one-based shape index |
RETURNS
shape |
btCollisionShape |
borrowed logical shape handle |
bullet3d.collision_object.get_shape_count(object)
Get the number of shapes attached to a collision object.
PARAMETERS
object |
btCollisionObject |
collision object |
RETURNS
count |
number |
shape count |
bullet3d.collision_object.get_shapes(object)
Get all attached shapes.
PARAMETERS
object |
btCollisionObject |
collision object |
RETURNS
shapes |
table |
array of borrowed shape handles |
EXAMPLES
Enumerate the logical shapes attached to a collision object:function init(self)
local object = bullet3d.get_collision_object("#collisionobject")
for _, shape in ipairs(bullet3d.collision_object.get_shapes(object)) do
local index = bullet3d.shape.get_index(shape)
local data = bullet3d.shape.get_shape(shape)
print("shape", index, "type", data.type)
end
end
bullet3d.shape.get_collision_object(shape)
Get the owning collision object.
PARAMETERS
shape |
btCollisionShape |
shape handle |
RETURNS
object |
btCollisionObject |
owning collision object |
bullet3d.shape.get_index(shape)
Get the one-based child index.
PARAMETERS
shape |
btCollisionShape |
shape handle |
RETURNS
shape_index |
number |
one-based shape index |
bullet3d.shape.get_local_transform(shape)
Get a compound child's local transform.
PARAMETERS
shape |
btCollisionShape |
shape handle |
RETURNS
position |
vector3 |
local position |
rotation |
quaternion |
local rotation |
bullet3d.shape.get_shape(shape)
The returned table always contains type, one of bullet3d.shape.SHAPE_TYPE_*.
A sphere also contains numeric diameter; a box contains vector3
dimensions; a capsule contains numeric diameter and cylindrical-section
height; and a hull contains a vertices array of vector3 values. The table
uses Defold units and can be passed to a bullet3d.world shape query after
adding the desired position and optional rotation fields.
PARAMETERS
shape |
btCollisionShape |
shape handle |
RETURNS
data |
table |
typed shape geometry in Defold units |
bullet3d.shape.get_type(shape)
Get the normalized Defold shape type.
PARAMETERS
shape |
btCollisionShape |
shape handle |
RETURNS
type |
number |
one of bullet3d.shape.SHAPE_TYPE_* |
bullet3d.shape.is_valid(shape)
Test whether a shape handle and its owner still exist.
PARAMETERS
shape |
btCollisionShape |
shape handle |
RETURNS
valid |
boolean |
validity |
bullet3d.shape.set_local_transform(shape,position,rotation)
Set a compound child's local transform.
PARAMETERS
shape |
btCollisionShape |
shape handle |
position |
vector3 |
finite local position |
rotation |
quaternion |
finite non-zero local rotation |
bullet3d.shape.set_shape(shape,data)
The table uses the same format as get_shape. Its type must match the
existing shape because changing native shape type is not supported. Primitive
dimensions must be finite and greater than zero. Hulls require at least four
finite vertices.
PARAMETERS
shape |
btCollisionShape |
shape handle |
data |
table |
typed shape geometry in Defold units |
EXAMPLES
Increase the dimensions of the first box shape by 50 percent for this instance:function init(self)
local object = bullet3d.get_collision_object("#collisionobject")
local shape = bullet3d.collision_object.get_shape(object, 1)
local data = bullet3d.shape.get_shape(shape)
if data.type == bullet3d.shape.SHAPE_TYPE_BOX then
data.dimensions = data.dimensions * 1.5
bullet3d.shape.set_shape(shape, data)
end
end
Value 1. Shape data contains positive vector3 dimensions in Defold units.
Value 2. Shape data contains a positive numeric diameter and positive
numeric cylindrical-section height in Defold units.
Value 3. Shape data contains a vertices array with at least four finite
vector3 values in Defold units.
Value 0. Shape data contains a positive numeric diameter in Defold units.