bjorn 1 tahun lalu
induk
melakukan
4da0e00cf5
42 mengubah file dengan 522 tambahan dan 522 penghapusan
  1. 393 334
      api/init.lua
  2. 4 3
      api/lovr/physics/Collider/getDegreesOfFreedom.lua
  3. 0 30
      api/lovr/physics/Collider/getLocalCenter.lua
  4. 0 42
      api/lovr/physics/Collider/getMassData.lua
  5. 52 0
      api/lovr/physics/Collider/getRawPose.lua
  6. 4 3
      api/lovr/physics/Collider/setDegreesOfFreedom.lua
  7. 0 42
      api/lovr/physics/Collider/setMassData.lua
  8. 2 1
      api/lovr/physics/ConeJoint/init.lua
  9. 2 1
      api/lovr/physics/ConvexShape/init.lua
  10. 2 2
      api/lovr/physics/HingeJoint/setMaxMotorTorque.lua
  11. 1 1
      api/lovr/physics/HingeJoint/setMotorTarget.lua
  12. 18 0
      api/lovr/physics/MotorMode.lua
  13. 2 2
      api/lovr/physics/SliderJoint/setMaxMotorForce.lua
  14. 1 1
      api/lovr/physics/SliderJoint/setMotorTarget.lua
  15. 2 1
      api/lovr/physics/WeldJoint/init.lua
  16. 0 1
      api/lovr/physics/World/destroy.lua
  17. 0 1
      api/lovr/physics/World/disableCollisionBetween.lua
  18. 0 1
      api/lovr/physics/World/enableCollisionBetween.lua
  19. 0 1
      api/lovr/physics/World/getAngularDamping.lua
  20. 0 1
      api/lovr/physics/World/getGravity.lua
  21. 0 1
      api/lovr/physics/World/getLinearDamping.lua
  22. 0 9
      api/lovr/physics/World/getResponseTime.lua
  23. 0 1
      api/lovr/physics/World/getStepCount.lua
  24. 0 1
      api/lovr/physics/World/getTags.lua
  25. 0 5
      api/lovr/physics/World/getTightness.lua
  26. 0 1
      api/lovr/physics/World/isCollisionEnabledBetween.lua
  27. 25 0
      api/lovr/physics/World/isDestroyed.lua
  28. 0 1
      api/lovr/physics/World/isSleepingAllowed.lua
  29. 0 1
      api/lovr/physics/World/overlapShape.lua
  30. 0 1
      api/lovr/physics/World/queryBox.lua
  31. 0 1
      api/lovr/physics/World/querySphere.lua
  32. 0 1
      api/lovr/physics/World/raycast.lua
  33. 0 1
      api/lovr/physics/World/setAngularDamping.lua
  34. 0 1
      api/lovr/physics/World/setGravity.lua
  35. 0 1
      api/lovr/physics/World/setLinearDamping.lua
  36. 0 9
      api/lovr/physics/World/setResponseTime.lua
  37. 0 1
      api/lovr/physics/World/setSleepingAllowed.lua
  38. 0 1
      api/lovr/physics/World/setStepCount.lua
  39. 0 9
      api/lovr/physics/World/setTightness.lua
  40. 1 2
      api/lovr/physics/World/shapecast.lua
  41. 0 1
      api/lovr/physics/World/update.lua
  42. 13 5
      api/main.lua

File diff ditekan karena terlalu besar
+ 393 - 334
api/init.lua


+ 4 - 3
api/lovr/physics/Collider/getEnabledAxes.lua → api/lovr/physics/Collider/getDegreesOfFreedom.lua

@@ -1,6 +1,6 @@
 return {
   summary = 'Get the enabled translation/rotation axes.',
-  description = 'Get the axes that are enabled for translation and rotation.',
+  description = 'Get the degrees of freedom of the Collider.',
   arguments = {},
   returns = {
     translation = {
@@ -29,7 +29,8 @@ return {
   notes = [[
     The default state is `xyz` for both translation and rotation.
 
-    The physics engine does not support disabling all axes.  At least one translation or rotation
-    axis needs to be enabled.  To disable all movement for a collider, make it kinematic.
+    The physics engine does not support disabling all degrees of freedom.  At least one translation
+    or rotation axis needs to be enabled.  To disable all movement for a collider, make it
+    kinematic.
   ]]
 }

+ 0 - 30
api/lovr/physics/Collider/getLocalCenter.lua

@@ -1,30 +0,0 @@
-return {
-  summary = 'Get the Collider\'s center of mass.',
-  description = 'Returns the Collider\'s center of mass.',
-  arguments = {},
-  returns = {
-    cx = {
-      type = 'number',
-      description = 'The x position of the center of mass.'
-    },
-    cy = {
-      type = 'number',
-      description = 'The y position of the center of mass.'
-    },
-    cz = {
-      type = 'number',
-      description = 'The z position of the center of mass.'
-    }
-  },
-  variants = {
-    {
-      arguments = {},
-      returns = { 'cx', 'cy', 'cz' }
-    }
-  },
-  related = {
-    'Collider:getLocalPoint',
-    'Collider:getMassData',
-    'Collider:setMassData'
-  }
-}

+ 0 - 42
api/lovr/physics/Collider/getMassData.lua

@@ -1,42 +0,0 @@
-return {
-  summary = 'Compute mass properties for the Collider.',
-  description = 'Computes mass properties for the Collider.',
-  arguments = {},
-  returns = {
-    cx = {
-      type = 'number',
-      description = 'The x position of the center of mass.'
-    },
-    cy = {
-      type = 'number',
-      description = 'The y position of the center of mass.'
-    },
-    cz = {
-      type = 'number',
-      description = 'The z position of the center of mass.'
-    },
-    mass = {
-      type = 'number',
-      description = 'The computed mass of the Collider.'
-    },
-    inertia = {
-      type = 'table',
-      description = [[
-        A table containing 6 values of the rotational inertia tensor matrix.  The table contains the
-        3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements
-        of the upper right portion of the 3x3 matrix.
-      ]]
-    }
-  },
-  variants = {
-    {
-      arguments = {},
-      returns = { 'cx', 'cy', 'cz', 'mass', 'inertia' }
-    }
-  },
-  related = {
-    'Collider:getMass',
-    'Collider:setMass',
-    'Shape:getMass'
-  }
-}

+ 52 - 0
api/lovr/physics/Collider/getRawPose.lua

@@ -0,0 +1,52 @@
+return {
+  summary = 'Get the raw pose of the Collider, without any interpolation.',
+  description = [[
+    Returns the position and orientation of the Collider, without any interpolation applied.
+  ]],
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x position of the Collider, in meters.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y position of the Collider, in meters.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z position of the Collider, in meters.'
+    },
+    angle = {
+      type = 'number',
+      description = 'The number of radians the Collider 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' }
+    }
+  },
+  notes = [[
+    To disable all interpolation, disable fixed timestep by setting the `tickRate` to 0 when
+    creating the world.
+  ]],
+  related = {
+    'Collider:getRawPosition',
+    'Collider:getRawOrientation',
+    'Collider:getPose'
+  }
+}

+ 4 - 3
api/lovr/physics/Collider/setEnabledAxes.lua → api/lovr/physics/Collider/setDegreesOfFreedom.lua

@@ -1,6 +1,6 @@
 return {
   summary = 'Set the enabled translation/rotation axes.',
-  description = 'Set the axes that are enabled for translation and rotation.',
+  description = 'Set the degrees of freedom of the Collider.',
   arguments = {
     translation = {
       type = 'string',
@@ -29,8 +29,9 @@ return {
   notes = [[
     The default state is `xyz` for both translation and rotation.
 
-    The physics engine does not support disabling all axes.  At least one translation or rotation
-    axis needs to be enabled.  To disable all movement for a collider, make it kinematic.
+    The physics engine does not support disabling all degrees of freedom.  At least one translation
+    or rotation axis needs to be enabled.  To disable all movement for a collider, make it
+    kinematic.
 
     When all translation axes are disabled, `Collider:getMass` will return 0.
 

+ 0 - 42
api/lovr/physics/Collider/setMassData.lua

@@ -1,42 +0,0 @@
-return {
-  summary = 'Set mass properties for the Collider.',
-  description = 'Sets mass properties for the Collider.',
-  arguments = {
-    cx = {
-      type = 'number',
-      description = 'The x position of the center of mass.'
-    },
-    cy = {
-      type = 'number',
-      description = 'The y position of the center of mass.'
-    },
-    cz = {
-      type = 'number',
-      description = 'The z position of the center of mass.'
-    },
-    mass = {
-      type = 'number',
-      description = 'The computed mass of the Collider.'
-    },
-    inertia = {
-      type = 'table',
-      description = [[
-        A table containing 6 values of the rotational inertia tensor matrix.  The table contains the
-        3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements
-        of the upper right portion of the 3x3 matrix.
-      ]]
-    }
-  },
-  returns = {},
-  variants = {
-    {
-      arguments = { 'cx', 'cy', 'cz', 'mass', 'inertia' },
-      returns = {}
-    }
-  },
-  related = {
-    'Collider:getMass',
-    'Collider:setMass',
-    'Shape:getMass'
-  }
-}

+ 2 - 1
api/lovr/physics/ConeJoint/init.lua

@@ -1,4 +1,5 @@
 return {
   summary = 'TODO',
-  description = 'TODO'
+  description = 'TODO',
+  extends = 'Joint'
 }

+ 2 - 1
api/lovr/physics/ConvexShape/init.lua

@@ -1,4 +1,5 @@
 return {
   summary = 'TODO',
-  description = 'TODO'
+  description = 'TODO',
+  extends = 'Shape'
 }

+ 2 - 2
api/lovr/physics/HingeJoint/setMaxMotorTorque.lua

@@ -28,8 +28,8 @@ return {
   returns = {},
   variants = {
     {
-      arguments = {},
-      returns = { 'positive', 'negative' }
+      arguments = { 'positive', 'negative' },
+      returns = {}
     }
   },
   related = {

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

@@ -13,7 +13,7 @@ return {
   returns = {},
   variants = {
     {
-      arguments = { 'mode' },
+      arguments = { 'target' },
       returns = {}
     }
   },

+ 18 - 0
api/lovr/physics/MotorMode.lua

@@ -0,0 +1,18 @@
+return {
+  summary = 'The different states for joint motors.',
+  description = 'The different ways the motor on a joint can be used.',
+  values = {
+    {
+      name = 'position',
+      description = 'The motor drives to a particular value.'
+    },
+    {
+      name = 'velocity',
+      description = 'The motor drives to a particular speed.'
+    }
+  },
+  related = {
+    'HingeJoint:setMotorMode',
+    'SliderJoint:setMotorMode'
+  }
+}

+ 2 - 2
api/lovr/physics/SliderJoint/setMaxMotorForce.lua

@@ -28,8 +28,8 @@ return {
   returns = {},
   variants = {
     {
-      arguments = {},
-      returns = { 'positive', 'negative' }
+      arguments = { 'positive', 'negative' },
+      returns = {}
     }
   },
   related = {

+ 1 - 1
api/lovr/physics/SliderJoint/setMotorTarget.lua

@@ -13,7 +13,7 @@ return {
   returns = {},
   variants = {
     {
-      arguments = { 'mode' },
+      arguments = { 'target' },
       returns = {}
     }
   },

+ 2 - 1
api/lovr/physics/WeldJoint/init.lua

@@ -1,4 +1,5 @@
 return {
   summary = 'TODO',
-  description = 'TODO'
+  description = 'TODO',
+  extends = 'Joint'
 }

+ 0 - 1
api/lovr/physics/World/destroy.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldBasics',
   summary = 'Destroy the World!!  Muahaha!',
   description = [[
     Destroys the World.  This will destroy all colliders, shapes, and joints in the world.  After

+ 0 - 1
api/lovr/physics/World/disableCollisionBetween.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldCollision',
   summary = 'Disable collision between two tags.',
   description = [[
     Disables collision between two tags.  Use `Collider:setTag` to set a Collider's tag.

+ 0 - 1
api/lovr/physics/World/enableCollisionBetween.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldCollision',
   summary = 'Enable collision between two tags.',
   description = [[
     Enables collision between two tags.  Use `Collider:setTag` to set a Collider's tag.

+ 0 - 1
api/lovr/physics/World/getAngularDamping.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Get the angular damping of the World.',
   description = [[
     Returns the angular damping parameters of the World.  Angular damping makes things less

+ 0 - 1
api/lovr/physics/World/getGravity.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldProperties',
   summary = 'Get the gravity of the World.',
   description = [[
     Returns the World's gravity.  Gravity is a constant acceleration applied to all colliders.  The

+ 0 - 1
api/lovr/physics/World/getLinearDamping.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Get the linear damping of the World.',
   description = [[
     Returns the linear damping parameters of the World.  Linear damping is similar to drag or air

+ 0 - 9
api/lovr/physics/World/getResponseTime.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Get the response time of the World.',
   description = [[
     Returns the response time factor of the World.
@@ -24,13 +23,5 @@ return {
       arguments = {},
       returns = { 'responseTime' }
     }
-  },
-  related = {
-    'BallJoint:getResponseTime',
-    'BallJoint:setResponseTime',
-    'DistanceJoint:getResponseTime',
-    'DistanceJoint:setResponseTime',
-    'World:getTightness',
-    'World:setTightness'
   }
 }

+ 0 - 1
api/lovr/physics/World/getStepCount.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Get the step count of the World.',
   description = [[
     Returns the step count of the World.  The step count influences how many steps are taken during

+ 0 - 1
api/lovr/physics/World/getTags.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldCollision',
   summary = 'Get the World\'s list of collision tags.',
   description = [[
     Returns the list of collision tags that were specified when the World was created.  Tags are

+ 0 - 5
api/lovr/physics/World/getTightness.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Get the tightness of joints in the World.',
   description = [[
     Returns the tightness of joints in the World.
@@ -23,9 +22,5 @@ return {
       arguments = {},
       returns = { 'tightness' }
     }
-  },
-  related = {
-    'DistanceJoint:getTightness',
-    'DistanceJoint:setTightness'
   }
 }

+ 0 - 1
api/lovr/physics/World/isCollisionEnabledBetween.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldCollision',
   summary = 'Check if two tags can collide.',
   description = [[
     Returns whether collisions are enabled between a pair of tags.

+ 25 - 0
api/lovr/physics/World/isDestroyed.lua

@@ -0,0 +1,25 @@
+return {
+  summary = 'Check if the World has been destroyed.',
+  description = [[
+    Returns whether the World has been destroyed.  Destroyed worlds can not be used for anything.
+  ]],
+  arguments = {},
+  returns = {
+    destroyed = {
+      type = 'boolean',
+      description = 'Whether the World has been destroyed.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'destroyed' }
+    }
+  },
+  related = {
+    'World:destroy',
+    'Collider:isDestroyed',
+    'Shape:isDestroyed',
+    'Joint:isDestroyed'
+  }
+}

+ 0 - 1
api/lovr/physics/World/isSleepingAllowed.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Check if colliders can go to sleep.',
   description = 'Returns whether colliders can go to sleep in the World.',
   arguments = {},

+ 0 - 1
api/lovr/physics/World/overlapShape.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldQueries',
   summary = 'Find colliders that overlap a shape.',
   description = [[
     - Collides a shape with the world, returning all colliders that the shape touches.

+ 0 - 1
api/lovr/physics/World/queryBox.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldQueries',
   summary = 'Find colliders that intersect an axis-aligned box.',
   description = [[
     Find colliders within an axis-aligned bounding box.  This is a fast but imprecise query that

+ 0 - 1
api/lovr/physics/World/querySphere.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldQueries',
   summary = 'Find colliders that intersect a sphere.',
   description = [[
     Find colliders within a sphere.  This is a fast but imprecise query that only checks a rough box

+ 0 - 1
api/lovr/physics/World/raycast.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldQueries',
   summary = 'Find colliders that intersect a line.',
   description = [[
     Traces a ray through the world and calls a function for each collider that was hit.

+ 0 - 1
api/lovr/physics/World/setAngularDamping.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Set the angular damping of the World.',
   description = [[
     Sets the angular damping of the World.  Angular damping makes things less "spinny", making them

+ 0 - 1
api/lovr/physics/World/setGravity.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldProperties',
   summary = 'Set the gravity of the World.',
   description = [[
     Sets the World's gravity.  Gravity is a constant acceleration applied to all colliders.  The

+ 0 - 1
api/lovr/physics/World/setLinearDamping.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Set the linear damping of the World.',
   description = [[
     Sets the linear damping of the World.  Linear damping is similar to drag or air resistance,

+ 0 - 9
api/lovr/physics/World/setResponseTime.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Set the response time of the World.',
   description = [[
     Sets the response time factor of the World.
@@ -24,13 +23,5 @@ return {
       arguments = { 'responseTime' },
       returns = {}
     }
-  },
-  related = {
-    'BallJoint:getResponseTime',
-    'BallJoint:setResponseTime',
-    'DistanceJoint:getResponseTime',
-    'DistanceJoint:setResponseTime',
-    'World:getTightness',
-    'World:setTightness'
   }
 }

+ 0 - 1
api/lovr/physics/World/setSleepingAllowed.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Set whether colliders can go to sleep.',
   description = 'Sets whether colliders can go to sleep in the World.',
   arguments = {

+ 0 - 1
api/lovr/physics/World/setStepCount.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Set the step count of the World.',
   description = [[
     Sets the step count of the World.  The step count influences how many steps are taken during a

+ 0 - 9
api/lovr/physics/World/setTightness.lua

@@ -1,6 +1,5 @@
 return {
   deprecated = true,
-  tag = 'worldProperties',
   summary = 'Set the tightness of joints in the World.',
   description = [[
     Sets the tightness of joints in the World.
@@ -23,13 +22,5 @@ return {
       arguments = { 'tightness' },
       returns = {}
     }
-  },
-  related = {
-    'BallJoint:getTightness',
-    'BallJoint:setTightness',
-    'DistanceJoint:getTightness',
-    'DistanceJoint:setTightness',
-    'World:getResponseTime',
-    'World:setResponseTime'
   }
 }

+ 1 - 2
api/lovr/physics/World/shapecast.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldQueries',
   summary = 'Move a shape through the world and return any colliders it touches.',
   description = [[
     Moves a shape from a starting point to an endpoint and returns any colliders it touches along
@@ -192,7 +191,7 @@ return {
   ]],
   related = {
     'World:raycast',
-    'World:collideShape',
+    'World:overlapShape',
     'World:queryBox',
     'World:querySphere'
   }

+ 0 - 1
api/lovr/physics/World/update.lua

@@ -1,5 +1,4 @@
 return {
-  tag = 'worldBasics',
   summary = 'Advance the physics simulation.',
   description = [[
     Updates the World, advancing the physics simulation forward in time and moving all the

+ 13 - 5
api/main.lua

@@ -120,12 +120,12 @@ local function processFunction(path, parent)
     assert(variant.returns, string.format('%q variant #%d is missing returns', fn.key, i))
 
     for j, name in ipairs(variant.arguments) do
-      warnIf(not fn.arguments[name], string.format('Function %q variant argument %q does not exist', fn.key, name))
+      warnIf(not fn.arguments[name], string.format('%s uses unknown argument %s', fn.key, name))
       variant.arguments[j] = copy(fn.arguments[name])
     end
 
     for j, name in ipairs(variant.returns) do
-      warnIf(not fn.returns[name], string.format('Function %q variant return %q does not exist', fn.key, name))
+      warnIf(not fn.returns[name], string.format('%s uses unknown return %s', fn.key, name))
       variant.returns[j] = copy(fn.returns[name])
     end
   end
@@ -267,8 +267,8 @@ end
 -- Validation
 local function validateRelated(item)
   for _, key in ipairs(item.related or {}) do
-    warnIf(not lookup[key], 'Related item for %s not found: %s', item.key, key)
-    warnIf(key == item.key, 'Item %s should not be related to itself', key)
+    warnIf(not lookup[key], '%s has unknown related item %s', item.key, key)
+    warnIf(key == item.key, '%s should not be related to itself', key)
   end
 end
 
@@ -329,6 +329,12 @@ local function validateObject(object)
       hasMethod[method.name] = true
     end
 
+    if object.extends then
+      for i, method in ipairs(lookup[object.extends].methods) do
+        hasMethod[method.name] = true
+      end
+    end
+
     local ignore = {
       type = true,
       release = true,
@@ -354,7 +360,9 @@ local function validateModule(module)
 
   for _, fn in ipairs(module.functions) do
     validateFunction(fn)
-    warnIf(dev and t and not t[fn.name], '%s has docs for unknown function %s', module.key, fn.name)
+    if dev and not fn.deprecated then
+      warnIf(t and not t[fn.name], '%s has docs for unknown function %s', module.key, fn.name)
+    end
   end
 
   for _, fn in ipairs(module.enums) do

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini