mirror of https://github.com/bjornbytes/lovr.git
Merge branch 'master' into dev
This commit is contained in:
commit
72284c2c5b
|
@ -88,9 +88,10 @@ endif()
|
|||
|
||||
# Lua
|
||||
if(LOVR_USE_LUAJIT AND NOT EMSCRIPTEN)
|
||||
if (APPLE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000")
|
||||
endif()
|
||||
# Required to make luajit compile without breaking linker cache on macOS Big Sur. Also, is a better,
|
||||
# newer GC so enable it on all builds.
|
||||
set(LUAJIT_ENABLE_GC64 ON)
|
||||
|
||||
if(LOVR_SYSTEM_LUA)
|
||||
pkg_search_module(LUAJIT REQUIRED luajit)
|
||||
include_directories(${LUAJIT_INCLUDE_DIRS})
|
||||
|
|
|
@ -75,7 +75,7 @@ function lovr.draw()
|
|||
end
|
||||
```
|
||||
|
||||
You can try more examples in your browser on the [docs page](https://lovr.org/docs/Hello_World).
|
||||
You can try more examples in your browser on the [docs page](https://lovr.org/docs/Intro/Hello_World).
|
||||
|
||||
Building
|
||||
---
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6b01affd89975c7d08c98036ce0882d8ac540f4a
|
||||
Subproject commit 94773111300fee0453844a4c9407af7e880b4df8
|
|
@ -1 +1 @@
|
|||
Subproject commit c37be68cf0876eb60f9f9ffd3920963f6ef01d7e
|
||||
Subproject commit 05db1d35d8a35f74ce40d0ba5e387717ad91b24d
|
|
@ -1656,6 +1656,16 @@ static int l_lovrMat4LookAt(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrMat4Target(lua_State* L) {
|
||||
mat4 m = luax_checkvector(L, 1, V_MAT4, NULL);
|
||||
vec3 from = luax_checkvector(L, 2, V_VEC3, NULL);
|
||||
vec3 to = luax_checkvector(L, 3, V_VEC3, NULL);
|
||||
vec3 up = lua_isnoneornil(L, 4) ? (float[4]) { 0.f, 1.f, 0.f } : luax_checkvector(L, 4, V_VEC3, NULL);
|
||||
mat4_target(m, from, to, up);
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrMat4__mul(lua_State* L) {
|
||||
mat4 m = luax_checkvector(L, 1, V_MAT4, NULL);
|
||||
VectorType type;
|
||||
|
@ -1739,6 +1749,7 @@ const luaL_Reg lovrMat4[] = {
|
|||
{ "perspective", l_lovrMat4Perspective },
|
||||
{ "fov", l_lovrMat4Fov },
|
||||
{ "lookAt", l_lovrMat4LookAt },
|
||||
{ "target", l_lovrMat4Target },
|
||||
{ "__mul", l_lovrMat4__mul },
|
||||
{ "__tostring", l_lovrMat4__tostring },
|
||||
{ "__newindex", l_lovrMat4__newindex },
|
||||
|
|
|
@ -42,18 +42,22 @@ static int threadRunner(void* data) {
|
|||
}
|
||||
}
|
||||
|
||||
mtx_lock(&thread->lock);
|
||||
|
||||
// Error handling
|
||||
size_t length;
|
||||
const char* error = lua_tolstring(L, -1, &length);
|
||||
mtx_lock(&thread->lock);
|
||||
thread->error = malloc(length + 1);
|
||||
if (thread->error) {
|
||||
memcpy(thread->error, error, length + 1);
|
||||
lovrEventPush((Event) {
|
||||
.type = EVENT_THREAD_ERROR,
|
||||
.data.thread = { thread, thread->error }
|
||||
});
|
||||
if (error) {
|
||||
thread->error = malloc(length + 1);
|
||||
if (thread->error) {
|
||||
memcpy(thread->error, error, length + 1);
|
||||
lovrEventPush((Event) {
|
||||
.type = EVENT_THREAD_ERROR,
|
||||
.data.thread = { thread, thread->error }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
thread->running = false;
|
||||
mtx_unlock(&thread->lock);
|
||||
lovrRelease(thread, lovrThreadDestroy);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -537,7 +538,12 @@ MAF void mat4_getAngleAxis(mat4 m, float* angle, float* ax, float* ay, float* az
|
|||
diagonal[1] /= sy;
|
||||
diagonal[2] /= sz;
|
||||
vec3_normalize(axis);
|
||||
*angle = acosf((diagonal[0] + diagonal[1] + diagonal[2] - 1.f) / 2.f);
|
||||
float cosangle = (diagonal[0] + diagonal[1] + diagonal[2] - 1.f) / 2.f;
|
||||
if (fabsf(cosangle) < 1.f - FLT_EPSILON) {
|
||||
*angle = acosf(cosangle);
|
||||
} else {
|
||||
*angle = (float) M_PI;
|
||||
}
|
||||
*ax = axis[0];
|
||||
*ay = axis[1];
|
||||
*az = axis[2];
|
||||
|
@ -622,6 +628,32 @@ MAF void mat4_getFov(mat4 m, float* left, float* right, float* up, float* down)
|
|||
}
|
||||
|
||||
MAF mat4 mat4_lookAt(mat4 m, vec3 from, vec3 to, vec3 up) {
|
||||
float x[4];
|
||||
float y[4];
|
||||
float z[4];
|
||||
vec3_normalize(vec3_sub(vec3_init(z, from), to));
|
||||
vec3_normalize(vec3_cross(vec3_init(x, up), z));
|
||||
vec3_cross(vec3_init(y, z), x);
|
||||
m[0] = x[0];
|
||||
m[1] = y[0];
|
||||
m[2] = z[0];
|
||||
m[3] = 0.f;
|
||||
m[4] = x[1];
|
||||
m[5] = y[1];
|
||||
m[6] = z[1];
|
||||
m[7] = 0.f;
|
||||
m[8] = x[2];
|
||||
m[9] = y[2];
|
||||
m[10] = z[2];
|
||||
m[11] = 0.f;
|
||||
m[12] = -vec3_dot(x, from);
|
||||
m[13] = -vec3_dot(y, from);
|
||||
m[14] = -vec3_dot(z, from);
|
||||
m[15] = 1.f;
|
||||
return m;
|
||||
}
|
||||
|
||||
MAF mat4 mat4_target(mat4 m, vec3 from, vec3 to, vec3 up) {
|
||||
float x[4];
|
||||
float y[4];
|
||||
float z[4];
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef void* arr_allocator(void* data, size_t size);
|
|||
#define arr_push(a, x) arr_reserve(a, (a)->length + 1), (a)->data[(a)->length++] = x
|
||||
#define arr_pop(a) (a)->data[--(a)->length]
|
||||
#define arr_append(a, p, n) arr_reserve(a, (a)->length + n), memcpy((a)->data + (a)->length, p, n * sizeof(*(p))), (a)->length += n
|
||||
#define arr_splice(a, i, n) memmove((a)->data + (i), (a)->data + ((i) + n), ((a)->length - (n)) * sizeof(*(a)->data)), (a)->length -= n
|
||||
#define arr_splice(a, i, n) memmove((a)->data + (i), (a)->data + ((i) + n), ((a)->length - (i) - (n)) * sizeof(*(a)->data)), (a)->length -= n
|
||||
#define arr_clear(a) (a)->length = 0
|
||||
|
||||
static inline void _arr_reserve(void** data, size_t n, size_t* capacity, size_t stride, arr_allocator* allocator) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define STBI_ONLY_PNG
|
||||
#define STBI_ONLY_HDR
|
||||
#define STBI_ASSERT(x)
|
||||
#define STBI_FAILURE_USERMSG
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wsign-compare"
|
||||
#include "stb_image.h"
|
||||
|
|
|
@ -528,7 +528,7 @@ Image* lovrImageCreateFromBlob(Blob* blob, bool flip) {
|
|||
}
|
||||
|
||||
if (!image->blob->data) {
|
||||
lovrThrow("Could not load image from '%s'", blob->name);
|
||||
lovrThrow("Could not load image from '%s': %s", blob->name, stbi_failure_reason());
|
||||
lovrRelease(image->blob, lovrBlobDestroy);
|
||||
free(image);
|
||||
return NULL;
|
||||
|
|
|
@ -542,7 +542,9 @@ static void openxr_destroy(void) {
|
|||
}
|
||||
|
||||
static bool openxr_getName(char* name, size_t length) {
|
||||
XrSystemProperties properties;
|
||||
XrSystemProperties properties = {
|
||||
.type = XR_TYPE_SYSTEM_PROPERTIES
|
||||
};
|
||||
XR(xrGetSystemProperties(state.instance, state.system, &properties));
|
||||
strncpy(name, properties.systemName, length - 1);
|
||||
name[length - 1] = '\0';
|
||||
|
@ -741,6 +743,10 @@ static bool openxr_getSkeleton(Device device, float* poses) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!state.features.handTracking) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XrHandTrackerEXT* handTracker = &state.handTrackers[device - DEVICE_HAND_LEFT];
|
||||
|
||||
// Hand trackers are created lazily because on some implementations xrCreateHandTrackerEXT will
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.lovr.app">
|
||||
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="25"/>
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="26"/>
|
||||
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
|
||||
<uses-feature android:name="android.hardware.vr.headtracking" android:required="false"/>
|
||||
<uses-feature android:name="oculus.software.handtracking" android:required="false"/>
|
||||
|
|
|
@ -16,7 +16,7 @@ before_build:
|
|||
- git submodule update --init
|
||||
- md build
|
||||
- cd build
|
||||
- cmake -DCMAKE_BUILD_TYPE=%configuration% ..
|
||||
- cmake -DCMAKE_BUILD_TYPE=%configuration% -A x64 ..
|
||||
|
||||
configuration: Release
|
||||
|
||||
|
|
|
@ -223,9 +223,9 @@ function lovr.mirror()
|
|||
local texture = lovr.headset.getMirrorTexture()
|
||||
if texture then -- On some drivers, texture is printed directly to the window
|
||||
if lovr.headset.getDriver() == 'oculus' then
|
||||
lovr.graphics.fill(lovr.headset.getMirrorTexture(), 0, 1, 1, -1)
|
||||
lovr.graphics.fill(texture, 0, 1, 1, -1)
|
||||
else
|
||||
lovr.graphics.fill(lovr.headset.getMirrorTexture())
|
||||
lovr.graphics.fill(texture)
|
||||
end
|
||||
end
|
||||
lovr.graphics.setBlendMode(blend, alpha)
|
||||
|
@ -276,12 +276,15 @@ function lovr.errhand(message, traceback)
|
|||
if lovr.graphics.hasWindow() then
|
||||
lovr.graphics.setViewPose(1)
|
||||
local width, height = lovr.graphics.getDimensions()
|
||||
local projection = mat4():perspective(.1, 100, math.rad(67), width / height)
|
||||
local projection = lovr.math.mat4():perspective(.1, 100, math.rad(67), width / height)
|
||||
lovr.graphics.setProjection(1, projection)
|
||||
lovr.graphics.clear()
|
||||
render()
|
||||
end
|
||||
lovr.graphics.present()
|
||||
if lovr.math then
|
||||
lovr.math.drain()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ const char* lovrShaderVertexPrefix = ""
|
|||
"#if defined MULTIVIEW \n"
|
||||
"layout(num_views = 2) in; \n"
|
||||
"#define lovrViewID (int(gl_ViewID_OVR)) \n"
|
||||
"#define lovrInstanceID gl_InstanceID \n"
|
||||
"#elif defined INSTANCED_STEREO \n"
|
||||
"#define lovrViewID gl_ViewportIndex \n"
|
||||
"#define lovrInstanceID (gl_InstanceID / lovrViewportCount) \n"
|
||||
|
|
|
@ -377,7 +377,7 @@ var webxr = {
|
|||
}
|
||||
Module.stackRestore(matrix);
|
||||
Module._lovrGraphicsSetBackbuffer(state.canvas, true, true);
|
||||
Module.dynCall_vi(callback, userdata);
|
||||
{{{ makeDynCall('vi', 'callback') }}} (userdata);
|
||||
Module._lovrGraphicsSetBackbuffer(0, false, false);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue