Skip to content

Commit

Permalink
Merge various clarifications and fixes from development branch
Browse files Browse the repository at this point in the history
  • Loading branch information
eoineoineoin committed Jul 22, 2024
1 parent 16d0368 commit a651dd1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 40 deletions.
30 changes: 15 additions & 15 deletions extensions/2.0/Khronos/KHR_physics_rigid_bodies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ The attachment frames are specified using the transforms of `node` objects; the

A node's `joint` must specify a `joint` property, which indexes into the top-level array of `physicsJoints` inside the `KHR_physics_rigid_bodies` extension object. This object describes the limits and drives utilized by the joint in a shareable manner.

A joint description must contain one of more `joint.limit` objects and zero or more `joint.drive` objects. Each of the limit objects remove some of the relative movement permitted between the two attachment frames, while the drive objects apply forces to achieve a relative transform or velocity between the attachment frames.
A joint description contains zero or more `joint.limit` objects and zero or more `joint.drive` objects. Each of the limit objects remove some of the relative movement permitted between the two attachment frames, while the drive objects apply forces to achieve a relative transform or velocity between the attachment frames.

If a joint were to eliminate all degrees of freedom, the physics simulation should attempt to move the `motion` nodes such that the transforms of the constrained child nodes (i.e. the `joint` node and the node at index `connectedNode`) become aligned with each other in world space. <!--TODO: remove?-->
If a joint were to eliminate all degrees of freedom, the physics simulation should attempt to move the `motion` nodes such that the transforms of the constrained child nodes (i.e. the `joint` node and the node at index `connectedNode`) become aligned with each other in global space.

Each `joint.limit` contains the following properties:

Expand All @@ -295,13 +295,13 @@ Each `joint.limit` contains the following properties:

Each limit must provide either `linearAxes` or `angularAxes`, declaring which are restricted. The indices in these arrays refer to the columns of the basis defined by the attachment frame of the joint and as such, must be in the range 0 to 2. The number of axes determines whether the limit should be a 1, 2, or 3 dimensional constraint as follows:

* A 1D linear limit should keep the world-space translation of the attachment frames within the signed distance from the infinite plane spanned by the other two axes.
* A 1D linear limit should keep the global space translation of the attachment frames within the signed distance from the infinite plane spanned by the other two axes.
* A 2D linear limit should keep the attachment frame translations within a distance from the infinite line along the remaining axis.
* A 3D linear limit should keep the attachment frame translations within a distance from each other.
* A 1D angular limit should restrict the attachment frame rotation about that axis, as in a universal joint.
* A 2D angular limit should restrict the attachment frame rotations to a cone oriented along the remaining axis.

Each limit contains a `min` and `max` parameter, describing the range of allowed difference between the two node transforms - within this range, the limit is considered non-violating and no corrective forces are applied. These values represent a _distance_ in meters for linear limit, or an _angle_ in radians for angular limit.
Each limit contains an optional `min` and `max` parameter, describing the range of allowed difference between the two node transforms - within this range, the limit is considered non-violating and no corrective forces are applied. These values represent a _distance_ in meters for a linear limit, or an _angle_ in radians for an angular limit. If the `min` parameter is not provided, there is no lower bound on the range. Similarly, if the `max` parameter is not provided, there is no upper bound.

Additionally, each `joint.limit` has an optional `stiffness` and `damping` which specify the proportion of the recovery applied to the limit. By default, an infinite spring constant is assumed, implying hard limits. Specifying a finite stiffness will cause the limit to become soft at the limits.

Expand Down Expand Up @@ -375,15 +375,15 @@ When used in conjunction with `KHR_interactivity`, this extension describes addi
|-|-|-|
| Input flow sockets | `in` | The entry point into this node |
| Input value sockets | `int nodeIndex` | The node to which the impulse should be applied |
| | `float3 linearImpulse` | Linear impulse to apply (world space, default 0,0,0) |
| | `float3 angularImpulse` | Angular impulse to apply (world space, default 0,0,0) |
| | `float3 linearImpulse` | Linear impulse to apply (global space, default 0,0,0) |
| | `float3 angularImpulse` | Angular impulse to apply (global space, default 0,0,0) |

|Type|`rigid_body/applyPointImpulse`| Apply a point impulse to a body |
|-|-|-|
| Input flow sockets | `in` | The entry point into this node |
| Input value sockets | `int nodeIndex` | The node to which the impulse should be applied |
| |`float3 impulse` | Impulse to apply (world space) |
| | `float3 position` | Position at which to apply impulse (world space) |
| |`float3 impulse` | Impulse to apply (global space) |
| | `float3 position` | Position at which to apply impulse (global space) |

These nodes are used to apply impulses to a dynamic rigid body, useful when the mass or inertia of a motion is not known in advance. In order to have an effect, the input node index must refer to a node which has `motion` properties or is a descendent of a node with `motion` properties.

Expand All @@ -394,12 +394,12 @@ These nodes are used to apply impulses to a dynamic rigid body, useful when the
| Input flow sockets | `in` | The entry point into this node |
| Output flow sockets | `hit` | The flow triggered when this query detects an intersection |
| | `miss` | The flow triggered when this query does not detect an intersection |
| Input value sockets | `float3 rayStart` | Start position of ray segment (world space) |
| | `float3 rayEnd` | End position of ray segment (world space) |
| Input value sockets | `float3 rayStart` | Start position of ray segment (global space) |
| | `float3 rayEnd` | End position of ray segment (global space) |
| | `int collisionFilterIndex` | Optional collision filter to apply (default -1) |
| Output value sockets | `int hitNodeIndex` | Index of the node which detected an intersection |
| | `float hitFraction` | Fraction along ray segment where intersection occurred |
| |`float3 hitNormal` | The normal of the shape at the point of intersection (world space) |
| |`float3 hitNormal` | The normal of the shape at the point of intersection (global space) |

This node can be activated to determine the intersection of a ray segment with any colliders in the scene. When a ray segment intersects multiple colliders, the output `hitNodeIndex` should be set to the node closest to the start position of the ray, i.e. the collider with the minimal `hitFraction`. The output value sockets are only valid when the `hit` flow is triggered.

Expand Down Expand Up @@ -448,10 +448,10 @@ To determine if a particular joint limit is violated, it is useful to determine

Where:
- $e_i$ is the $i$-th basis vector.
- $t_a$ is the translation of the joint node in world space.
- $t_b$ is the translation of the attached node in world space.
- $q_a$ is the orientation of the joint node in world space.
- $q_b$ is the orientation of the attached node in world space.
- $t_a$ is the translation of the joint node in global space.
- $t_b$ is the translation of the attached node in global space.
- $q_a$ is the orientation of the joint node in global space.
- $q_b$ is the orientation of the attached node in global space.
- $\mathrm{Tw_i}$ is the function which returns the twist component of the twist-swing decomposition of a quaternion.
- $\mathrm{Re}$ is the function which extracts the real component of a quaternion.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"$id": "glTF.KHR_physics_rigid_bodies.joint.drive.schema.json",
"title": "KHR_physics_rigid_bodies Physics Joint Drive",
"type": "object",
"description": "Parameters describing a drive which applies forces within a joint.",
"description": "Parameters describing a drive or motor which applies forces within a joint.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"type": {
Expand Down Expand Up @@ -41,7 +41,7 @@
"axis": {
"type": "integer",
"minimum": 0,
"maximum": 3,
"maximum": 2,
"description": "The index of the axis which this drive applies forces on."
},
"maxForce": {
Expand All @@ -51,11 +51,11 @@
},
"positionTarget": {
"type": "number",
"description": "The target translation/angle along the axis that this drive attempts to achieve."
"description": "The target translation or angle along/about the axis that this drive attempts to achieve."
},
"velocityTarget": {
"type": "number",
"description": "The target velocity along/about the axis that this drive attempts to achieve."
"description": "The target linear velocity or angular velocity along/about the axis that this drive attempts to achieve."
},
"stiffness": {
"type": "number",
Expand All @@ -74,5 +74,11 @@
"type",
"mode",
"axis"
]
],
"dependencies": {
"positionTarget": [ "stiffness" ],
"stiffness": [ "positionTarget" ],
"velocityTarget": [ "damping" ],
"damping": [ "velocityTarget" ]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
"$id": "glTF.KHR_physics_rigid_bodies.joint.limit.schema.json",
"title": "KHR_physics_rigid_bodies Physics Joint Limit",
"type": "object",
"description": "Parameters describing how the relative motion of a pair of nodes is constrained.",
"description": "Parameters describing how a joint constrains the relative motion of a pair of nodes.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"min": {
"type": "number",
"description": "The minimum of the allowed range of relative distance/angle."
"description": "The minimum of the allowed range of relative distance in meters, or angle in radians."
},
"max": {
"type": "number",
"description": "The maximum of the allowed range of relative distance/angle."
"description": "The maximum of the allowed range of relative distance in meters, or angle in radians."
},
"stiffness": {
"type": "number",
"description": "The spring constant used to calculate a restorative force when the joint is extended beyond the limit. If not present, limit should be infinitely stiff.",
"minimum": 0
"description": "The spring constant used to calculate a restorative force when the joint is extended beyond the limit. If not present, the limit should be infinitely stiff.",
"minimum": 0.0
},
"damping": {
"type": "number",
"description": "Damping applied to the velocity when the joint is extended beyond the limit.",
"minimum": 0,
"default": 0
"minimum": 0.0,
"default": 0.0
},
"extensions": { },
"extras": { }
Expand All @@ -33,7 +33,7 @@
"type": "object",
"properties": {
"linearAxes": {
"description": "The indices of the linear axes which are limited, constraining the linear motion in 1, 2 or 3 dimensions. 1D keeps an object some distance from an infinite plane. 2D keeps an object some distance from an infinite line. 3D keeps an object some distance from a point.",
"description": "The indices of the linear axes which are limited, constraining the linear motion in 1, 2 or 3 dimensions. 1D keeps an object some distance from an infinite plane. 2D keeps an object some distance from an infinite line. 3D keeps an object some distance from a point. Can only contain 0 (X), 1 (Y), or 2 (Z), so [0, 1, 2] constrains all three axes.",
"type": "array",
"items": {
"type": "integer",
Expand All @@ -51,7 +51,7 @@
"type": "object",
"properties": {
"angularAxes": {
"description": "The indices of the angular axes which are limited, constraining the angular motion in 1, 2 or 3 dimensions. 1D limits rotation about one axis (e.g. a universal joint). 2D limits rotation about two axes (e.g. a cone). 3D limits rotation about all three axes.",
"description": "The indices of the angular axes which are limited, constraining the angular motion in 1, 2 or 3 dimensions. 1D limits rotation about one axis (e.g. a universal joint). 2D limits rotation about two axes (e.g. a cone). 3D limits rotation about all three axes. Can only contain 0 (X), 1 (Y), or 2 (Z), so [0, 1, 2] constrains all three axes.",
"type": "array",
"items": {
"type": "integer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
"$id": "glTF.KHR_physics_rigid_bodies.joint.schema.json",
"title": "KHR_physics_rigid_bodies Physics Joint",
"type": "object",
"description": "Parameters describing a joint, constraining the motion of a pair of bodies.",
"description": "Parameters describing a joint, which may constrain or drive the relative motion of a pair of nodes.",
"allOf": [ { "$ref": "glTFChildOfRootProperty.schema.json" } ],
"properties": {
"limits": {
"type": "array",
"description": "The set of limits which make up this joint",
"description": "The set of limits which constrain relative motion.",
"items": {
"type": "object",
"$ref": "glTF.KHR_physics_rigid_bodies.joint.limit.schema.json"
}
},
"drives": {
"type": "array",
"description": "The set of drives applying forces to this joint",
"description": "The set of drives applying forces to this joint.",
"items": {
"type": "object",
"$ref": "glTF.KHR_physics_rigid_bodies.joint.drive.schema.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
"$id": "glTF.KHR_physics_rigid_bodies.material.schema.json",
"title": "KHR_physics_rigid_bodies Physics Material",
"type": "object",
"description": "Parameters describing how an object should respond to collisions during physics simulation.",
"description": "Parameters describing the collision response of a surface in a physics simulation.",
"allOf": [ { "$ref": "glTFChildOfRootProperty.schema.json" } ],
"properties": {
"staticFriction": {
"type": "number",
"description": "The friction used when an object is laying still on a surface. Usually a value from 0 to 1. A value of zero feels like ice, a value of 1 will make it very hard to get the object moving. Simulations which do not differentiate between static and dynamic friction should use the dynamic friction value.",
"description": "The friction used when an object is laying still on a surface. Usually a value from 0 to 1. A value of 0 feels like ice, a value of 1 will make it very hard to get the object moving. Simulations which do not differentiate between static and dynamic friction should use the dynamic friction value.",
"minimum": 0.0,
"default": 0.6
},
"dynamicFriction": {
"type": "number",
"description": "The friction used when already moving. Usually a value from 0 to 1. A value of zero feels like ice, a value of 1 will make it come to rest very quickly unless a lot of force or gravity pushes the object.",
"description": "The friction used when already moving. Usually a value from 0 to 1. A value of 0 feels like ice, a value of 1 will make it come to rest very quickly unless a lot of force or gravity pushes the object.",
"minimum": 0.0,
"default": 0.6
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"$id": "glTF.KHR_physics_rigid_bodies.schema.json",
"title": "KHR_physics_rigid_bodies glTF Document Extension",
"type": "object",
"description": "Top level physics properties.",
"description": "Top level physics properties and resources.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"physicsMaterials": {
Expand All @@ -17,7 +17,7 @@
},
"collisionFilters": {
"type": "array",
"description": "An array providing collision filter descriptions.",
"description": "An array of collision filter descriptions.",
"items": {
"type": "object",
"$ref": "glTF.KHR_physics_rigid_bodies.collision_filter.schema.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
},
"joint": {
"allOf": [ { "$ref": "glTFid.schema.json" } ],
"description": "The index of the joint limits in the top level physicsJoints array."
"description": "The index of the joint in the top level physicsJoints array."
},
"enableCollision": {
"type": "boolean",
"description": "Allow the connected objects to collide. Connected objects do not collide by default.",
"description": "If true, allow the connected objects to collide. Connected objects do not collide by default.",
"default": false
},
"extensions": { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"gravityFactor": {
"type": "number",
"description": "A multiplier applied to the global acceleration due to gravity.",
"description": "A multiplier applied to the acceleration due to gravity.",
"default": 1.0
},
"extensions": { },
Expand Down

0 comments on commit a651dd1

Please sign in to comment.