Browse Source

Headset seated mode;

bjorn 1 year ago
parent
commit
6b70f08856
3 changed files with 63 additions and 8 deletions
  1. 28 4
      api/init.lua
  2. 4 4
      api/lovr/callbacks/conf.lua
  3. 31 0
      api/lovr/headset/isSeated.lua

+ 28 - 4
api/init.lua

@@ -10,7 +10,7 @@ return {
       examples = {
         {
           description = "A noop conf.lua that sets all configuration settings to their defaults:",
-          code = "function lovr.conf(t)\n\n  -- Set the project version and identity\n  t.version = '0.16.0'\n  t.identity = 'default'\n\n  -- Set save directory precedence\n  t.saveprecedence = true\n\n  -- Enable or disable different modules\n  t.modules.audio = true\n  t.modules.data = true\n  t.modules.event = true\n  t.modules.graphics = true\n  t.modules.headset = true\n  t.modules.math = true\n  t.modules.physics = true\n  t.modules.system = true\n  t.modules.thread = true\n  t.modules.timer = true\n\n  -- Audio\n  t.audio.spatializer = nil\n  t.audio.samplerate = 48000\n  t.audio.start = true\n\n  -- Graphics\n  t.graphics.debug = false\n  t.graphics.vsync = true\n  t.graphics.stencil = false\n  t.graphics.antialias = true\n  t.graphics.shadercache = true\n\n  -- Headset settings\n  t.headset.drivers = { 'openxr', 'desktop' }\n  t.headset.supersample = false\n  t.headset.offset = 1.7\n  t.headset.antialias = true\n  t.headset.stencil = false\n  t.headset.submitdepth = true\n  t.headset.overlay = false\n\n  -- Math settings\n  t.math.globals = true\n\n  -- Configure the desktop window\n  t.window.width = 1080\n  t.window.height = 600\n  t.window.fullscreen = false\n  t.window.resizable = false\n  t.window.title = 'LÖVR'\n  t.window.icon = nil\nend"
+          code = "function lovr.conf(t)\n\n  -- Set the project version and identity\n  t.version = '0.16.0'\n  t.identity = 'default'\n\n  -- Set save directory precedence\n  t.saveprecedence = true\n\n  -- Enable or disable different modules\n  t.modules.audio = true\n  t.modules.data = true\n  t.modules.event = true\n  t.modules.graphics = true\n  t.modules.headset = true\n  t.modules.math = true\n  t.modules.physics = true\n  t.modules.system = true\n  t.modules.thread = true\n  t.modules.timer = true\n\n  -- Audio\n  t.audio.spatializer = nil\n  t.audio.samplerate = 48000\n  t.audio.start = true\n\n  -- Graphics\n  t.graphics.debug = false\n  t.graphics.vsync = true\n  t.graphics.stencil = false\n  t.graphics.antialias = true\n  t.graphics.shadercache = true\n\n  -- Headset settings\n  t.headset.drivers = { 'openxr', 'desktop' }\n  t.headset.supersample = false\n  t.headset.seated = false\n  t.headset.antialias = true\n  t.headset.stencil = false\n  t.headset.submitdepth = true\n  t.headset.overlay = false\n\n  -- Math settings\n  t.math.globals = true\n\n  -- Configure the desktop window\n  t.window.width = 1080\n  t.window.height = 600\n  t.window.fullscreen = false\n  t.window.resizable = false\n  t.window.title = 'LÖVR'\n  t.window.icon = nil\nend"
         }
       },
       notes = "Disabling unused modules can improve startup time.\n\n`t.window` can be set to nil to avoid creating the window.  The window can later be opened manually using `lovr.system.openWindow`.\n\nEnabling the `t.graphics.debug` flag will add additional error checks and will send messages from the GPU driver to the `lovr.log` callback.  This will decrease performance but can help provide information on performance problems or other bugs.  It will also cause `lovr.graphics.newShader` to embed debugging information in shaders which allows inspecting variables and stepping through shaders line-by-line in tools like RenderDoc.\n\n`t.graphics.debug` can also be enabled using the `--graphics-debug` command line option.\n\nThe `headset.offset` field is a vertical offset applied to the scene for headsets that do not center their tracking origin on the floor.  This can be thought of as a \"default user height\". Setting this offset makes it easier to design experiences that work in both seated and standing VR configurations.",
@@ -167,9 +167,9 @@ return {
                       description = "A scaling factor to apply to the headset texture.  Improves visual quality but reduces performance.  Can also be a boolean."
                     },
                     {
-                      name = "offset",
-                      type = "number",
-                      description = "The vertical offset for seated experiences."
+                      name = "seated",
+                      type = "boolean",
+                      description = "Whether seated mode should be used instead of standing."
                     },
                     {
                       name = "antialias",
@@ -23615,6 +23615,30 @@ return {
             }
           }
         },
+        {
+          name = "isSeated",
+          tag = "headset",
+          summary = "Check if the headset coordinate space is configured for standing or sitting.",
+          description = "Returns whether the headset coordinate space is in seated mode.\n\nSeated mode is enabled by setting `t.headset.seated` to true in `lovr.conf`.  In seated mode, `y=0` will be at eye level, instead of on the floor like in standing-scale experiences.\n\nThe seated coordinate space can be more convenient for applications that are rendering a simple interface in front of the user (like a video player) instead of a roomscale 3D scene.  y=0 will also be at the correct height at startup, whether the user is sitting or standing.",
+          key = "lovr.headset.isSeated",
+          module = "lovr.headset",
+          related = {
+            "lovr.conf",
+            "lovr.recenter"
+          },
+          variants = {
+            {
+              arguments = {},
+              returns = {
+                {
+                  name = "seated",
+                  type = "boolean",
+                  description = "Whether the experience is seated."
+                }
+              }
+            }
+          }
+        },
         {
           name = "isTouched",
           tag = "input",

+ 4 - 4
api/lovr/callbacks/conf.lua

@@ -163,9 +163,9 @@ return {
               ]]
             },
             {
-              name = 'offset',
-              type = 'number',
-              description = 'The vertical offset for seated experiences.'
+              name = 'seated',
+              type = 'boolean',
+              description = 'Whether seated mode should be used instead of standing.'
             },
             {
               name = 'antialias',
@@ -302,7 +302,7 @@ return {
           -- Headset settings
           t.headset.drivers = { 'openxr', 'desktop' }
           t.headset.supersample = false
-          t.headset.offset = 1.7
+          t.headset.seated = false
           t.headset.antialias = true
           t.headset.stencil = false
           t.headset.submitdepth = true

+ 31 - 0
api/lovr/headset/isSeated.lua

@@ -0,0 +1,31 @@
+return {
+  tag = 'headset',
+  summary = 'Check if the headset coordinate space is configured for standing or sitting.',
+  description = [[
+    Returns whether the headset coordinate space is in seated mode.
+
+    Seated mode is enabled by setting `t.headset.seated` to true in `lovr.conf`.  In seated mode,
+    `y=0` will be at eye level, instead of on the floor like in standing-scale experiences.
+
+    The seated coordinate space can be more convenient for applications that are rendering a simple
+    interface in front of the user (like a video player) instead of a roomscale 3D scene.  y=0 will
+    also be at the correct height at startup, whether the user is sitting or standing.
+  ]],
+  arguments = {},
+  returns = {
+    seated = {
+      type = 'boolean',
+      description = 'Whether the experience is seated.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'seated' }
+    }
+  },
+  related = {
+    'lovr.conf',
+    'lovr.recenter'
+  }
+}