Browse Source

Model:hasJoints;

bjorn 4 years ago
parent
commit
b1f8d4a875
2 changed files with 48 additions and 0 deletions
  1. 24 0
      api/init.lua
  2. 24 0
      api/lovr/graphics/Model/hasJoints.lua

+ 24 - 0
api/init.lua

@@ -12693,6 +12693,30 @@ return {
               },
               notes = "For skinned nodes to render correctly, use a Shader created with the `animated` flag set to `true`.  See `lovr.graphics.newShader` for more."
             },
+            {
+              name = "hasJoints",
+              summary = "Check if a Model has joints.",
+              description = "Returns whether the Model has any nodes associated with animated joints.  This can be used to approximately determine whether an animated shader needs to be used with an arbitrary Model.",
+              key = "Model:hasJoints",
+              module = "lovr.graphics",
+              related = {
+                "Model:getAnimationCount",
+                "lovr.graphics.newShader"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "skeletal",
+                      type = "boolean",
+                      description = "Whether the Model has any nodes that use skeletal animation."
+                    }
+                  }
+                }
+              },
+              notes = "A model can still be animated even if this function returns false, since node transforms can still be animated with keyframes without skinning.  These types of animations don't need to use a Shader with the `animated = true` flag, though."
+            },
             {
               name = "pose",
               summary = "Set the pose of a single node, or clear the pose.",

+ 24 - 0
api/lovr/graphics/Model/hasJoints.lua

@@ -0,0 +1,24 @@
+return {
+  summary = 'Check if a Model has joints.',
+  description = [[
+    Returns whether the Model has any nodes associated with animated joints.  This can be used to
+    approximately determine whether an animated shader needs to be used with an arbitrary Model.
+  ]],
+  arguments = {},
+  returns = {
+    {
+      name = 'skeletal',
+      type = 'boolean',
+      description = 'Whether the Model has any nodes that use skeletal animation.'
+    }
+  },
+  notes = [[
+    A model can still be animated even if this function returns false, since node transforms can
+    still be animated with keyframes without skinning.  These types of animations don't need to use
+    a Shader with the `animated = true` flag, though.
+  ]],
+  related = {
+    'Model:getAnimationCount',
+    'lovr.graphics.newShader'
+  }
+}