소스 검색

Shape docs;

bjorn 1 년 전
부모
커밋
e54a6da0b0

+ 37 - 0
api/lovr/physics/Shape/getCenterOfMass.lua

@@ -0,0 +1,37 @@
+return {
+  summary = 'Get the center of mass of the Shape.',
+  description = [[
+    Returns the center of mass of the Shape.  Currently the only shape that can have a non-zero
+    center of mass is `ConvexShape`.
+  ]],
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x position of the center of mass.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y position of the center of mass.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z position of the center of mass.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'x', 'y', 'z' }
+    }
+  },
+  notes = [[
+    `MeshShape` and `TerrainShape` do not have a well-defined mass, this function returns zero for
+    those shapes.
+  ]],
+  related = {
+    'Collider:getCenterOfMass',
+    'Shape:getOffset',
+    'Shape:setOffset'
+  }
+}

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

@@ -0,0 +1,49 @@
+return {
+  summary = 'Get the local offset of the Shape.',
+  description = [[
+    Returns the local offset of the Shape.  When the Shape is attached to a Collider, it will have
+    this offset relative to the Collider.
+  ]],
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The local x offset of the Shape, in meters.'
+    },
+    y = {
+      type = 'number',
+      description = 'The local y offset of the Shape, in meters.'
+    },
+    z = {
+      type = 'number',
+      description = 'The local z offset 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:getOrientation',
+    'Shape:getPose'
+  }
+}

+ 8 - 4
api/lovr/physics/Shape/getOrientation.lua

@@ -1,6 +1,10 @@
 return {
-  summary = 'Get the Shape\'s orientation.',
-  description = 'Get the orientation of the Shape relative to its Collider.',
+  summary = 'Get the orientation of the Shape.',
+  description = [[
+    Get the orientation of the Shape in world space, taking into account the position and
+    orientation of the Collider it's attached to, if any.  Shapes that aren't attached to a Collider
+    will return their local offset.
+  ]],
   arguments = {},
   returns = {
     angle = {
@@ -28,8 +32,8 @@ return {
   },
   related = {
     'Shape:getPosition',
-    'Shape:setPosition',
     'Shape:getPose',
-    'Shape:setPose'
+    'Shape:getOffset',
+    'Shape:setOffset'
   }
 }

+ 5 - 3
api/lovr/physics/Shape/getPose.lua

@@ -1,7 +1,9 @@
 return {
   summary = 'Get the pose of the Shape.',
   description = [[
-    Returns the position and orientation of the Shape, relative to its Collider.
+    Returns the position and orientation of the Shape in world space, taking into the account the
+    position and orientation of the Collider it's attached to, if any.  Shapes that aren't attached
+    to a Collider will return their local offset.
   ]],
   arguments = {},
   returns = {
@@ -42,8 +44,8 @@ return {
   },
   related = {
     'Shape:getPosition',
-    'Shape:setPosition',
     'Shape:getOrientation',
-    'Shape:setOrientation'
+    'Shape:getOffset',
+    'Shape:setOffset'
   }
 }

+ 11 - 7
api/lovr/physics/Shape/getPosition.lua

@@ -1,19 +1,23 @@
 return {
-  summary = 'Get the position of the Shape in the world.',
-  description = 'Get the position of the Shape in the world.',
+  summary = 'Get the position of the Shape.',
+  description = [[
+    Returns the position of the Shape in world space, taking into the account the position and
+    orientation of the Collider it's attached to, if any.  Shapes that aren't attached to a Collider
+    will return their local offset.
+  ]],
   arguments = {},
   returns = {
     x = {
       type = 'number',
-      description = 'The x offset.'
+      description = 'The x position, in world space.'
     },
     y = {
       type = 'number',
-      description = 'The y offset.'
+      description = 'The y position, in world space.'
     },
     z = {
       type = 'number',
-      description = 'The z offset.'
+      description = 'The z position, in world space.'
     }
   },
   variants = {
@@ -24,8 +28,8 @@ return {
   },
   related = {
     'Shape:getOrientation',
-    'Shape:setOrientation',
     'Shape:getPose',
-    'Shape:setPose'
+    'Shape:getOffset',
+    'Shape:setOffset'
   }
 }

+ 0 - 18
api/lovr/physics/Shape/isEnabled.lua

@@ -1,18 +0,0 @@
-return {
-  summary = 'Check if the Shape is enabled.',
-  description = 'Returns whether the Shape is enabled.',
-  arguments = {},
-  returns = {
-    enabled = {
-      type = 'boolean',
-      description = 'Whether the Shape is enabled.'
-    }
-  },
-  variants = {
-    {
-      arguments = {},
-      returns = { 'enabled' }
-    }
-  },
-  notes = 'Disabled shapes won\'t collide with anything.'
-}

+ 0 - 18
api/lovr/physics/Shape/setEnabled.lua

@@ -1,18 +0,0 @@
-return {
-  summary = 'Enable or disable the Shape.',
-  description = 'Enable or disable the Shape.',
-  arguments = {
-    enabled = {
-      type = 'boolean',
-      description = 'Whether the Shape should be enabled.'
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      arguments = { 'enabled' },
-      returns = {}
-    }
-  },
-  notes = 'Disabled shapes won\'t collide with anything.'
-}

+ 13 - 14
api/lovr/physics/Shape/setPose.lua → api/lovr/physics/Shape/setOffset.lua

@@ -1,18 +1,21 @@
 return {
-  summary = 'Set the pose of the Shape.',
-  description = 'Sets the position and orientation of the Shape, relative to its Collider.',
+  summary = 'Set the local offset of the Shape.',
+  description = [[
+    Sets the local offset of the Shape.  When the Shape is attached to a Collider, it will have this
+    offset relative to the Collider.
+  ]],
   arguments = {
     x = {
       type = 'number',
-      description = 'The x position of the Shape, in meters.'
+      description = 'The local x offset of the Shape, in meters.'
     },
     y = {
       type = 'number',
-      description = 'The y position of the Shape, in meters.'
+      description = 'The local y offset of the Shape, in meters.'
     },
     z = {
       type = 'number',
-      description = 'The z position of the Shape, in meters.'
+      description = 'The local z offset of the Shape, in meters.'
     },
     angle = {
       type = 'number',
@@ -32,31 +35,27 @@ return {
     },
     position = {
       type = 'Vec3',
-      description = 'The position of the Shape, in meters.'
+      description = 'The local offset of the Shape, in meters.'
     },
-    orientation = {
+    rotation = {
       type = 'Quat',
-      description = 'The orientation of the Shape.'
+      description = 'The local rotation of the Shape, in meters.'
     }
   },
   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' },
+      arguments = { 'position', 'rotation' },
       returns = {}
     }
   },
-  notes = 'If the Shape isn\'t attached to a Collider, this will error.',
   related = {
     'Shape:getPosition',
-    'Shape:setPosition',
     'Shape:getOrientation',
-    'Shape:setOrientation'
+    'Shape:getPose'
   }
 }

+ 0 - 44
api/lovr/physics/Shape/setOrientation.lua

@@ -1,44 +0,0 @@
-return {
-  summary = 'Set the Shape\'s orientation.',
-  description = 'Set the orientation of the Shape relative to its Collider.',
-  arguments = {
-    angle = {
-      type = 'number',
-      description = 'The number of radians the Shape is rotated.'
-    },
-    ax = {
-      type = 'number',
-      description = 'The x component of the rotation axis.'
-    },
-    ay = {
-      type = 'number',
-      description = 'The y component of the rotation axis.'
-    },
-    az = {
-      type = 'number',
-      description = 'The z component of the rotation axis.'
-    },
-    orientation = {
-      type = 'Quat',
-      description = 'The orientation of the Shape.'
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      description = 'Set the orientation of the Shape using numbers.',
-      arguments = { 'angle', 'ax', 'ay', 'az' },
-      returns = {}
-    },
-    {
-      description = 'Set the orientation of the Shape using a quaternion.',
-      arguments = { 'orientation' },
-      returns = {}
-    }
-  },
-  notes = 'If the Shape isn\'t attached to a Collider, this will error.',
-  related = {
-    'Shape:getPosition',
-    'Shape:setPosition'
-  }
-}

+ 0 - 40
api/lovr/physics/Shape/setPosition.lua

@@ -1,40 +0,0 @@
-return {
-  summary = 'Set the Shape\'s position.',
-  description = 'Set the position of the Shape relative to its Collider.',
-  arguments = {
-    x = {
-      type = 'number',
-      description = 'The x offset.'
-    },
-    y = {
-      type = 'number',
-      description = 'The y offset.'
-    },
-    z = {
-      type = 'number',
-      description = 'The z offset.'
-    },
-    position = {
-      type = 'Vec3',
-      description = 'The position.'
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      description = 'Set the position of the Shape using numbers.',
-      arguments = { 'x', 'y', 'z' },
-      returns = {}
-    },
-    {
-      description = 'Set the position of the Shape using a vector.',
-      arguments = { 'position' },
-      returns = {}
-    }
-  },
-  notes = 'If the Shape isn\'t attached to a Collider, this will error.',
-  related = {
-    'Shape:getOrientation',
-    'Shape:setOrientation'
-  }
-}