Browse Source

World:raycast includes triangle index;

bjorn 9 months ago
parent
commit
43b22ccb7b
2 changed files with 28 additions and 2 deletions
  1. 18 0
      api/init.lua
  2. 10 2
      api/lovr/physics/World/raycast.lua

+ 18 - 0
api/init.lua

@@ -41740,6 +41740,10 @@ return {
                           name = "nz",
                           type = "number"
                         },
+                        {
+                          name = "triangle",
+                          type = "number"
+                        },
                         {
                           name = "fraction",
                           type = "number"
@@ -41811,6 +41815,10 @@ return {
                           name = "nz",
                           type = "number"
                         },
+                        {
+                          name = "triangle",
+                          type = "number"
+                        },
                         {
                           name = "fraction",
                           type = "number"
@@ -41906,6 +41914,11 @@ return {
                       name = "nz",
                       type = "number",
                       description = "The z component of the normal vector."
+                    },
+                    {
+                      name = "triangle",
+                      type = "number",
+                      description = "The index of the triangle that was hit, or nil if a MeshShape was not hit."
                     }
                   }
                 },
@@ -41968,6 +41981,11 @@ return {
                       name = "nz",
                       type = "number",
                       description = "The z component of the normal vector."
+                    },
+                    {
+                      name = "triangle",
+                      type = "number",
+                      description = "The index of the triangle that was hit, or nil if a MeshShape was not hit."
                     }
                   }
                 }

+ 10 - 2
api/lovr/physics/World/raycast.lua

@@ -81,6 +81,10 @@ return {
           name = 'nz',
           type = 'number'
         },
+        {
+          name = 'triangle',
+          type = 'number'
+        },
         {
           name = 'fraction',
           type = 'number'
@@ -128,6 +132,10 @@ return {
     nz = {
       type = 'number',
       description = 'The z component of the normal vector.'
+    },
+    triangle = {
+      type = 'number',
+      description = 'The index of the triangle that was hit, or nil if a MeshShape was not hit.'
     }
   },
   variants = {
@@ -141,11 +149,11 @@ return {
     },
     {
       arguments = { 'x1', 'y1', 'z1', 'x2', 'y2', 'z2', 'filter' },
-      returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
+      returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz', 'triangle' }
     },
     {
       arguments = { 'origin', 'endpoint', 'filter' },
-      returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
+      returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz', 'triangle' }
     }
   },
   notes = [[