Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compound triggers to KHR_physics_rigid_bodies #26

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions extensions/2.0/Khronos/KHR_physics_rigid_bodies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,17 @@ Note, that this can generate asymmetric states - `A` might determine that it _do

### Triggers

A useful construct in a physics engine is a collision volume which does not generate impulses when overlapping with other volumes - implementations may use this behavior to generate events, which can implement application-specific logic; such objects are typically called "triggers", "phantoms", "sensors", or "overlap volumes" in physics simulation engines.
A useful construct in a physics engine is a collision volume which does not generate impulses when overlapping with other volumes. Triggers allow specifying such volumes either as a single shape or combination of shapes.

A node may have a `trigger` property set; this is similar to the `collider` in that it references a collision volume defined by the `KHR_collision_shapes` extension but lacks a physics material. It does, however, provide a collision filter with the same semantics as the `collider`.
Implementations may use these objects as sensors which generate events and can be used to trigger application-specific logic. These objects are typically called "triggers", "sensors", "phantoms", or "overlap volumes" in physics simulation engines.

A node may have a `trigger` property set, which is similar to the `collider` property. Both have a `shape` property that references a geometric shape defined by the `KHR_collision_shapes` extension, and both provide a collision filter with the same semantics. However, the `trigger` property lacks a physics material. Alternatively, a `trigger` may have a `nodes` property, which is an array of descendant glTF nodes with a trigger property, which make up a compound trigger on this glTF node.

| |Type|Description|
| - | - | -|
|**shape**|`integer`| The index of a top level `Shape`, which provides the geometry of the trigger.|
|**nodes**|`[integer]`|For compound triggers, the set of descendant glTF nodes with a trigger property that make up this compound trigger.|
|**collisionFilter**|`integer`|Indexes into the top level `collisionFilters` and describes a filter which determines if this collider should perform collision detection against another collider.|

Describing the precise mechanism by which overlap events are generated and what occurs as a result is beyond the scope of this specification; simulation software will typically output overlap begin/end events as an output from the simulation step, which is hooked into application-specific business logic.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,41 @@
"title": "KHR_physics_rigid_bodies Node Trigger Property",
"type": "object",
"description": "Parameters describing a volume used for collison detection, but does not cause a collision response.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"allOf": [{ "$ref": "glTFProperty.schema.json" }],
"properties": {
"shape": {
"allOf": [ { "$ref": "glTFid.schema.json" } ],
"allOf": [{ "$ref": "glTFid.schema.json" }],
"description": "The index of the shape in the top level shapes array."
},
"nodes": {
"type": "array",
"description": "For compound triggers, the set of descendant glTF nodes with a trigger property that make up this compound trigger.",
"items": {
"$ref": "glTFid.schema.json"
},
"uniqueItems": true,
"minItems": 1
},
"collisionFilter": {
"allOf": [ { "$ref": "glTFid.schema.json" } ],
"allOf": [{ "$ref": "glTFid.schema.json" }],
"description": "The index of the filter information in the top level collisionFilters array."
},
"extensions": { },
"extras": { }
},
"required": [
"shape"
"anyOf": [
{
"allOf": [
{ "required": ["shape"] },
{ "not": { "required": ["nodes"] } }
]
},
{
"allOf": [
{ "required": ["nodes"] },
{ "not": { "required": ["shape"] } },
{ "not": { "required": ["collisionFilter"] } }
]
}
]
}
Binary file added samples/Triggers/SlopedFloor_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/Triggers/Triggers.bin
Binary file not shown.
Binary file added samples/Triggers/Triggers.glb
Binary file not shown.
Loading