Browse Source

HingeJoint;

bjorn 1 year ago
parent
commit
2a2b37c9d3

+ 2 - 0
api/lovr/physics/DistanceJoint/setSpring.lua

@@ -7,6 +7,7 @@ return {
   arguments = {
     frequency = {
       type = 'number',
+      default = '0.0',
       description = [[
         The frequency of the spring, in hertz.  Higher frequencies make the spring more stiff.  When
         zero, the spring is disabled.
@@ -14,6 +15,7 @@ return {
     },
     damping = {
       type = 'number',
+      default = '1.0',
       description = 'The damping ratio of the spring.'
     }
   },

+ 0 - 37
api/lovr/physics/HingeJoint/getAnchors.lua

@@ -1,37 +0,0 @@
-return {
-  summary = 'Get the anchor points of the HingeJoint.',
-  description = 'Returns the anchor points of the HingeJoint.',
-  arguments = {},
-  returns = {
-    x1 = {
-      type = 'number',
-      description = 'The x coordinate of the first anchor point, in world coordinates.'
-    },
-    y1 = {
-      type = 'number',
-      description = 'The y coordinate of the first anchor point, in world coordinates.'
-    },
-    z1 = {
-      type = 'number',
-      description = 'The z coordinate of the first anchor point, in world coordinates.'
-    },
-    x2 = {
-      type = 'number',
-      description = 'The x coordinate of the second anchor point, in world coordinates.'
-    },
-    y2 = {
-      type = 'number',
-      description = 'The y coordinate of the second anchor point, in world coordinates.'
-    },
-    z2 = {
-      type = 'number',
-      description = 'The z coordinate of the second anchor point, in world coordinates.'
-    }
-  },
-  variants = {
-    {
-      arguments = {},
-      returns = { 'x1', 'y1', 'z1', 'x2', 'y2', 'z2' }
-    }
-  }
-}

+ 0 - 24
api/lovr/physics/HingeJoint/getLowerLimit.lua

@@ -1,24 +0,0 @@
-return {
-  summary = 'Get the HingeJoint\'s lower angle limit.',
-  description = 'Returns the lower limit of the hinge angle.  This will be greater than -π.',
-  arguments = {},
-  returns = {
-    limit = {
-      type = 'number',
-      description = 'The lower limit, in radians.'
-    }
-  },
-  variants = {
-    {
-      arguments = {},
-      returns = { 'limit' }
-    }
-  },
-  related = {
-    'HingeJoint:getAngle',
-    'HingeJoint:getUpperLimit',
-    'HingeJoint:setUpperLimit',
-    'HingeJoint:getLimits',
-    'HingeJoint:setLimits'
-  }
-}

+ 36 - 0
api/lovr/physics/HingeJoint/getMaxMotorTorque.lua

@@ -0,0 +1,36 @@
+return {
+  summary = 'Get the maximum amount of torque the motor can use.',
+  description = [[
+    Returns the maximum amount of torque the motor can use to reach its target, in newton meters.
+
+    There are separate limits for each direction the hinge can move.  They're usually kept the same,
+    but one of them can be set to zero to make a motor that can only push in one direction.  Note
+    that both limits are positive.
+  ]],
+  arguments = {},
+  returns = {
+    positive = {
+      type = 'number',
+      description = [[
+        The maximum amount of torque the motor can use to push the hinge in the "positive"
+        direction, in newton meters.
+      ]]
+    },
+    negative = {
+      type = 'number',
+      description = [[
+        The maximum amount of torque the motor can use to push the hinge in the "negative"
+        direction, in newton meters.
+      ]]
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'positive', 'negative' }
+    }
+  },
+  related = {
+    'HingeJoint:getMotorTorque'
+  }
+}

+ 25 - 0
api/lovr/physics/HingeJoint/getMotorMode.lua

@@ -0,0 +1,25 @@
+return {
+  summary = 'Get the motor mode of the HingeJoint.',
+  description = [[
+    Returns the motor mode of the HingeJoint.  When enabled, the motor will drive the hinge to a
+    target angle (for the `position` mode) or a target speed (for the `velocity` mode), set by
+    `HingeJoint:setMotorTarget`.
+  ]],
+  arguments = {},
+  returns = {
+    mode = {
+      type = 'MotorMode',
+      description = 'The mode of the motor, or `nil` if the motor is disabled.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'mode' }
+    }
+  },
+  related = {
+    'HingeJoint:getMotorTarget',
+    'HingeJonit:setMotorTarget'
+  }
+}

+ 36 - 0
api/lovr/physics/HingeJoint/getMotorSpring.lua

@@ -0,0 +1,36 @@
+return {
+  summary = 'Get the spring parameters of the motor target.',
+  description = [[
+    Returns the spring parameters of the motor target.  These are similar to the spring parameters
+    set by `HingeJoint:setSpring`, but they apply to the motor when it reaches its target instead of
+    the angle limits of the hinge joint.  Note that these only take effect when the motor mode is
+    `position`.
+  ]],
+  arguments = {},
+  returns = {
+    frequency = {
+      type = 'number',
+      description = [[
+        The frequency of the spring, in hertz.  Higher frequencies make the spring more stiff.  When
+        zero, the spring is disabled.
+      ]]
+    },
+    damping = {
+      type = 'number',
+      description = 'The damping ratio of the spring.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'frequency', 'damping' }
+    }
+  },
+  notes = 'See `HingeJoint:setSpring` for more detailed info on how the spring parameters work.',
+  related = {
+    'HingeJoint:getSpring',
+    'HingeJoint:setSpring',
+    'HingeJoint:getMotorTarget',
+    'HingeJoint:setMotorTarget'
+  }
+}

+ 24 - 0
api/lovr/physics/HingeJoint/getMotorTarget.lua

@@ -0,0 +1,24 @@
+return {
+  summary = 'Get the target of the hinge motor.',
+  description = [[
+    Sets the target value for the HingeJoint's motor.  This is either a target angle or a target
+    velocity, based on the mode set by `HingeJoint:setMotorMode`.
+  ]],
+  arguments = {},
+  returns = {
+    target = {
+      type = 'number',
+      description = 'The target value, in radians or radians per second, depending on the mode.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'mode' }
+    }
+  },
+  related = {
+    'HingeJoint:getMotorMode',
+    'HingeJoint:setMotorMode'
+  }
+}

+ 23 - 0
api/lovr/physics/HingeJoint/getMotorTorque.lua

@@ -0,0 +1,23 @@
+return {
+  summary = 'Get the current motor torque.',
+  description = [[
+    Returns the current torque the motor is using to reach its target, in newton meters.
+  ]],
+  arguments = {},
+  returns = {
+    torque = {
+      type = 'number',
+      description = 'The current torque, in newton meters.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'torque' }
+    }
+  },
+  related = {
+    'HingeJoint:getMaxMotorTorque',
+    'HingeJoint:setMaxMotorTorque'
+  }
+}

+ 1 - 1
api/lovr/physics/HingeJoint/getSpring.lua

@@ -1,5 +1,5 @@
 return {
-  summary = 'Get the spring parameters of the HingeJoint.',
+  summary = 'Get the spring parameters of the HingeJoint limits.',
   description = [[
     Returns the spring parameters of the HingeJoint.  Use this to make the angle limits of the hinge
     "soft".  When the motor is active, a separate set of spring parameters can be set on the motor,

+ 0 - 24
api/lovr/physics/HingeJoint/getUpperLimit.lua

@@ -1,24 +0,0 @@
-return {
-  summary = 'Get the HingeJoint\'s upper angle limit.',
-  description = 'Returns the upper limit of the hinge angle.  This will be less than π.',
-  arguments = {},
-  returns = {
-    limit = {
-      type = 'number',
-      description = 'The upper limit, in radians.'
-    }
-  },
-  variants = {
-    {
-      arguments = {},
-      returns = { 'limit' }
-    }
-  },
-  related = {
-    'HingeJoint:getAngle',
-    'HingeJoint:getLowerLimit',
-    'HingeJoint:setLowerLimit',
-    'HingeJoint:getLimits',
-    'HingeJoint:setLimits'
-  }
-}

+ 0 - 35
api/lovr/physics/HingeJoint/setAnchor.lua

@@ -1,35 +0,0 @@
-return {
-  summary = 'Set the anchor point of the HingeJoint.',
-  description = 'Sets a new anchor point for the HingeJoint.',
-  arguments = {
-    x = {
-      type = 'number',
-      description = 'The x coordinate of the anchor point, in world coordinates.'
-    },
-    y = {
-      type = 'number',
-      description = 'The y coordinate of the anchor point, in world coordinates.'
-    },
-    z = {
-      type = 'number',
-      description = 'The z coordinate of the anchor point, in world coordinates.'
-    },
-    anchor = {
-      type = 'Vec3',
-      description = 'The anchor point, in world coordinates.'
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      description = 'Sets the anchor point using numbers.',
-      arguments = { 'x', 'y', 'z' },
-      returns = {}
-    },
-    {
-      description = 'Sets the anchor point using a vector.',
-      arguments = { 'anchor' },
-      returns = {}
-    }
-  }
-}

+ 0 - 35
api/lovr/physics/HingeJoint/setAxis.lua

@@ -1,35 +0,0 @@
-return {
-  summary = 'Set the HingeJoint\'s axis.',
-  description = 'Sets the axis of the hinge.',
-  arguments = {
-    x = {
-      type = 'number',
-      description = 'The x component of the axis.'
-    },
-    y = {
-      type = 'number',
-      description = 'The y component of the axis.'
-    },
-    z = {
-      type = 'number',
-      description = 'The z component of the axis.'
-    },
-    axis = {
-      type = 'Vec3',
-      description = 'The axis.'
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      description = 'Set the axis using numbers.',
-      arguments = { 'x', 'y', 'z' },
-      returns = {}
-    },
-    {
-      description = 'Set the axis using a vector.',
-      arguments = { 'axis' },
-      returns = {}
-    }
-  }
-}

+ 0 - 24
api/lovr/physics/HingeJoint/setLowerLimit.lua

@@ -1,24 +0,0 @@
-return {
-  summary = 'Set the HingeJoint\'s lower angle limit.',
-  description = 'Sets the lower limit of the hinge angle.  This should be greater than -π.',
-  arguments = {
-    limit = {
-      type = 'number',
-      description = 'The lower limit, in radians.'
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      arguments = { 'limit' },
-      returns = {}
-    }
-  },
-  related = {
-    'HingeJoint:getAngle',
-    'HingeJoint:getUpperLimit',
-    'HingeJoint:setUpperLimit',
-    'HingeJoint:getLimits',
-    'HingeJoint:setLimits'
-  }
-}

+ 38 - 0
api/lovr/physics/HingeJoint/setMaxMotorTorque.lua

@@ -0,0 +1,38 @@
+return {
+  summary = 'Set the maximum amount of torque the motor can use.',
+  description = [[
+    Sets the maximum amount of torque the motor can use to reach its target, in newton meters.
+
+    There are separate limits for each direction the hinge can move.  They're usually kept the same,
+    but one of them can be set to zero to make a motor that can only push in one direction.  Note
+    that both limits are positive.
+  ]],
+  arguments = {
+    positive = {
+      type = 'number',
+      default = 'math.huge',
+      description = [[
+        The maximum amount of torque the motor can use to push the hinge in the "positive"
+        direction, in newton meters.
+      ]]
+    },
+    negative = {
+      type = 'number',
+      default = 'positive',
+      description = [[
+        The maximum amount of torque the motor can use to push the hinge in the "negative"
+        direction, in newton meters.
+      ]]
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = {},
+      returns = { 'positive', 'negative' }
+    }
+  },
+  related = {
+    'HingeJoint:getMotorTorque'
+  }
+}

+ 30 - 0
api/lovr/physics/HingeJoint/setMotorMode.lua

@@ -0,0 +1,30 @@
+return {
+  summary = 'Set the motor mode of the HingeJoint.',
+  description = [[
+    Sets the motor mode of the HingeJoint.  When enabled, the motor will drive the hinge to a target
+    angle (for the `position` mode) or a target speed (for the `velocity` mode), set by
+    `HingeJoint:setMotorTarget`.
+  ]],
+  arguments = {
+    mode = {
+      type = 'MotorMode',
+      description = 'The mode of the motor.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'mode' },
+      returns = {}
+    },
+    {
+      description = 'Disables the motor.',
+      arguments = {},
+      returns = {}
+    }
+  },
+  related = {
+    'HingeJoint:getMotorTarget',
+    'HingeJonit:setMotorTarget'
+  }
+}

+ 37 - 0
api/lovr/physics/HingeJoint/setMotorSpring.lua

@@ -0,0 +1,37 @@
+return {
+  summary = 'Set the spring parameters of the motor target.',
+  description = [[
+    Sets the spring parameters of the motor target.  These are similar to the spring parameters set
+    by `HingeJoint:setSpring`, but they apply to the motor when it reaches its target instead of the
+    angle limits of the hinge joint.  Note that these only take effect when the motor mode is
+    `position`.
+  ]],
+  arguments = {
+    frequency = {
+      type = 'number',
+      default = '0.0',
+      description = [[
+        The frequency of the spring, in hertz.  Higher frequencies make the spring more stiff.  When
+        zero, the spring is disabled.
+      ]]
+    },
+    damping = {
+      type = 'number',
+      default = '1.0',
+      description = 'The damping ratio of the spring.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'frequency', 'damping' },
+      returns = {}
+    }
+  },
+  notes = 'See `HingeJoint:setSpring` for more detailed info on how the spring parameters work.',
+  related = {
+    'HingeJoint:getSpring',
+    'HingeJoint:setSpring',
+    'HingeJoint:getMotorTarget',
+    'HingeJoint:setMotorTarget'
+  }
+}

+ 24 - 0
api/lovr/physics/HingeJoint/setMotorTarget.lua

@@ -0,0 +1,24 @@
+return {
+  summary = 'Set the target of the hinge motor.',
+  description = [[
+    Returns the target value for the HingeJoint's motor.  This is either a target angle or a target
+    velocity, based on the mode set by `HingeJoint:setMotorMode`.
+  ]],
+  arguments = {},
+  returns = {
+    target = {
+      type = 'number',
+      description = 'The target value, in radians or radians per second, depending on the mode.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'mode' }
+    }
+  },
+  related = {
+    'HingeJoint:getMotorMode',
+    'HingeJoint:setMotorMode'
+  }
+}

+ 3 - 1
api/lovr/physics/HingeJoint/setSpring.lua

@@ -1,5 +1,5 @@
 return {
-  summary = 'Set the spring parameters of the HingeJoint.',
+  summary = 'Set the spring parameters of the HingeJoint limits.',
   description = [[
     Sets the spring parameters of the HingeJoint.  Use this to make the angle limits of the hinge
     "soft".  When the motor is active, a separate set of spring parameters can be set on the motor,
@@ -8,6 +8,7 @@ return {
   arguments = {
     frequency = {
       type = 'number',
+      default = '0.0',
       description = [[
         The frequency of the spring, in hertz.  Higher frequencies make the spring more stiff.  When
         zero, the spring is disabled.
@@ -15,6 +16,7 @@ return {
     },
     damping = {
       type = 'number',
+      default = '1.0',
       description = 'The damping ratio of the spring.'
     }
   },

+ 0 - 24
api/lovr/physics/HingeJoint/setUpperLimit.lua

@@ -1,24 +0,0 @@
-return {
-  summary = 'Set the HingeJoint\'s upper angle limit.',
-  description = 'Sets the upper limit of the hinge angle.  This should be less than π.',
-  arguments = {
-    limit = {
-      type = 'number',
-      description = 'The upper limit, in radians.'
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      arguments = { 'limit' },
-      returns = {}
-    }
-  },
-  related = {
-    'HingeJoint:getAngle',
-    'HingeJoint:getLowerLimit',
-    'HingeJoint:setLowerLimit',
-    'HingeJoint:getLimits',
-    'HingeJoint:setLimits'
-  }
-}