Browse Source

Shape:get/setPose;

bjorn 1 year ago
parent
commit
e9830f5e5e

+ 161 - 2
api/init.lua

@@ -30186,6 +30186,7 @@ return {
               module = "lovr.physics",
               notes = "Calling functions on the collider after destroying it is a bad idea.",
               related = {
+                "Collider:isDestroyed",
                 "World:destroy",
                 "Shape:destroy",
                 "Joint:destroy"
@@ -31254,6 +31255,32 @@ return {
                 }
               }
             },
+            {
+              name = "isDestroyed",
+              summary = "Check if the Collider has been destroyed.",
+              description = "Returns whether the collider has been destroyed.",
+              key = "Collider:isDestroyed",
+              module = "lovr.physics",
+              notes = "Calling functions on a collider after destroying it is a bad idea.",
+              related = {
+                "Collider:destroy",
+                "World:destroy",
+                "Shape:destroy",
+                "Joint:destroy"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "destroyed",
+                      type = "boolean",
+                      description = "Whether the collider has been destroyed."
+                    }
+                  }
+                }
+              }
+            },
             {
               name = "isGravityIgnored",
               summary = "Check if the Collider ignores gravity.",
@@ -32984,7 +33011,9 @@ return {
               module = "lovr.physics",
               related = {
                 "Shape:getPosition",
-                "Shape:setPosition"
+                "Shape:setPosition",
+                "Shape:getPose",
+                "Shape:setPose"
               },
               variants = {
                 {
@@ -33014,6 +33043,61 @@ return {
                 }
               }
             },
+            {
+              name = "getPose",
+              summary = "Get the pose of the Shape.",
+              description = "Returns the position and orientation of the Shape, relative to its Collider.",
+              key = "Shape:getPose",
+              module = "lovr.physics",
+              related = {
+                "Shape:getPosition",
+                "Shape:setPosition",
+                "Shape:getOrientation",
+                "Shape:setOrientation"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "x",
+                      type = "number",
+                      description = "The x position of the Shape, in meters."
+                    },
+                    {
+                      name = "y",
+                      type = "number",
+                      description = "The y position of the Shape, in meters."
+                    },
+                    {
+                      name = "z",
+                      type = "number",
+                      description = "The z position of the Shape, in meters."
+                    },
+                    {
+                      name = "angle",
+                      type = "number",
+                      description = "The number of radians the Shape is rotated around its axis of rotation."
+                    },
+                    {
+                      name = "ax",
+                      type = "number",
+                      description = "The x component of the axis of rotation."
+                    },
+                    {
+                      name = "ay",
+                      type = "number",
+                      description = "The y component of the axis of rotation."
+                    },
+                    {
+                      name = "az",
+                      type = "number",
+                      description = "The z component of the axis of rotation."
+                    }
+                  }
+                }
+              }
+            },
             {
               name = "getPosition",
               summary = "Get the Shape's position.",
@@ -33022,7 +33106,9 @@ return {
               module = "lovr.physics",
               related = {
                 "Shape:getOrientation",
-                "Shape:setOrientation"
+                "Shape:setOrientation",
+                "Shape:getPose",
+                "Shape:setPose"
               },
               variants = {
                 {
@@ -33199,6 +33285,79 @@ return {
                 }
               }
             },
+            {
+              name = "setPose",
+              summary = "Set the pose of the Shape.",
+              description = "Sets the position and orientation of the Shape, relative to its Collider.",
+              key = "Shape:setPose",
+              module = "lovr.physics",
+              notes = "If the Shape isn't attached to a Collider, this will error.",
+              related = {
+                "Shape:getPosition",
+                "Shape:setPosition",
+                "Shape:getOrientation",
+                "Shape:setOrientation"
+              },
+              variants = {
+                {
+                  description = "Set the pose of the Shape using numbers.",
+                  arguments = {
+                    {
+                      name = "x",
+                      type = "number",
+                      description = "The x position of the Shape, in meters."
+                    },
+                    {
+                      name = "y",
+                      type = "number",
+                      description = "The y position of the Shape, in meters."
+                    },
+                    {
+                      name = "z",
+                      type = "number",
+                      description = "The z position of the Shape, in meters."
+                    },
+                    {
+                      name = "angle",
+                      type = "number",
+                      description = "The number of radians the Shape is rotated around its axis of rotation."
+                    },
+                    {
+                      name = "ax",
+                      type = "number",
+                      description = "The x component of the axis of rotation."
+                    },
+                    {
+                      name = "ay",
+                      type = "number",
+                      description = "The y component of the axis of rotation."
+                    },
+                    {
+                      name = "az",
+                      type = "number",
+                      description = "The z component of the axis of rotation."
+                    }
+                  },
+                  returns = {}
+                },
+                {
+                  description = "Set the pose of the Shape using vector types.",
+                  arguments = {
+                    {
+                      name = "position",
+                      type = "Vec3",
+                      description = "The position of the Shape, in meters."
+                    },
+                    {
+                      name = "orientation",
+                      type = "Quat",
+                      description = "The orientation of the Shape."
+                    }
+                  },
+                  returns = {}
+                }
+              }
+            },
             {
               name = "setPosition",
               summary = "Set the Shape's position.",

+ 3 - 1
api/lovr/physics/Shape/getOrientation.lua

@@ -28,6 +28,8 @@ return {
   },
   related = {
     'Shape:getPosition',
-    'Shape:setPosition'
+    'Shape:setPosition',
+    'Shape:getPose',
+    'Shape:setPose'
   }
 }

+ 49 - 0
api/lovr/physics/Shape/getPose.lua

@@ -0,0 +1,49 @@
+return {
+  summary = 'Get the pose of the Shape.',
+  description = [[
+    Returns the position and orientation of the Shape, relative to its Collider.
+  ]],
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x position of the Shape, in meters.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y position of the Shape, in meters.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z position of the Shape, in meters.'
+    },
+    angle = {
+      type = 'number',
+      description = 'The number of radians the Shape is rotated around its axis of rotation.'
+    },
+    ax = {
+      type = 'number',
+      description = 'The x component of the axis of rotation.'
+    },
+    ay = {
+      type = 'number',
+      description = 'The y component of the axis of rotation.'
+    },
+    az = {
+      type = 'number',
+      description = 'The z component of the axis of rotation.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'x', 'y', 'z', 'angle', 'ax', 'ay', 'az' }
+    }
+  },
+  related = {
+    'Shape:getPosition',
+    'Shape:setPosition',
+    'Shape:getOrientation',
+    'Shape:setOrientation'
+  }
+}

+ 3 - 1
api/lovr/physics/Shape/getPosition.lua

@@ -24,6 +24,8 @@ return {
   },
   related = {
     'Shape:getOrientation',
-    'Shape:setOrientation'
+    'Shape:setOrientation',
+    'Shape:getPose',
+    'Shape:setPose'
   }
 }

+ 62 - 0
api/lovr/physics/Shape/setPose.lua

@@ -0,0 +1,62 @@
+return {
+  summary = 'Set the pose of the Shape.',
+  description = 'Sets the position and orientation of the Shape, relative to its Collider.',
+  arguments = {
+    x = {
+      type = 'number',
+      description = 'The x position of the Shape, in meters.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y position of the Shape, in meters.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z position of the Shape, in meters.'
+    },
+    angle = {
+      type = 'number',
+      description = 'The number of radians the Shape is rotated around its axis of rotation.'
+    },
+    ax = {
+      type = 'number',
+      description = 'The x component of the axis of rotation.'
+    },
+    ay = {
+      type = 'number',
+      description = 'The y component of the axis of rotation.'
+    },
+    az = {
+      type = 'number',
+      description = 'The z component of the axis of rotation.'
+    },
+    position = {
+      type = 'Vec3',
+      description = 'The position of the Shape, in meters.'
+    },
+    orientation = {
+      type = 'Quat',
+      description = 'The orientation of the Shape.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      description = 'Set the pose of the Shape using numbers.',
+      arguments = { 'x', 'y', 'z', 'angle', 'ax', 'ay', 'az' },
+      returns = {}
+    },
+    {
+      description = 'Set the pose of the Shape using vector types.',
+      arguments = { 'position', 'orientation' },
+      returns = {}
+    }
+  },
+  notes = 'If the Shape isn\'t attached to a Collider, this will error.',
+  related = {
+    'Shape:getPosition',
+    'Shape:setPosition',
+    'Shape:getOrientation',
+    'Shape:setOrientation'
+  }
+}

+ 1 - 1
api/lovr/physics/Shape/setPosition.lua

@@ -19,7 +19,6 @@ return {
       description = 'The position.'
     }
   },
-  notes = 'If the Shape isn\'t attached to a Collider, this will error.',
   returns = {},
   variants = {
     {
@@ -33,6 +32,7 @@ return {
       returns = {}
     }
   },
+  notes = 'If the Shape isn\'t attached to a Collider, this will error.',
   related = {
     'Shape:getOrientation',
     'Shape:setOrientation'