~bl4ckb0ne/wxrc

01441282652eaa4a87ad07c40474183886f37994 — Simon Zeni 1 year, 3 months ago 9644d99
example/cube: fix input
1 files changed, 7 insertions(+), 10 deletions(-)

M example/cube.c
M example/cube.c => example/cube.c +7 -10
@@ 189,17 189,19 @@ controller_frame(void *data, struct xr_controller_v1* xr_controller_v1)
	TRACE_BEGIN;

	struct controller *controller = data;
	if (!controller->grabbing) {
		return;
	}

	struct state *state = controller->state;
	vec3 box[2] = {0};
	glm_aabb_transform(state->bounding_box, state->transform, box);

	if (controller->grabbing && glm_aabb_point(box, controller->position)) {
	if (glm_aabb_point(box, controller->position)) {
		mat4 transform;
		glm_translate_make(transform, controller->position);
		glm_quat_rotate(transform, controller->orientation, transform);
		glm_scale_uni(transform, state->scale);

		glm_mat4_copy(transform, state->transform);
	}



@@ 241,7 243,7 @@ hand_gesture(void *data, struct xr_hand_v1 *xr_hand_v1, uint32_t state,
			|| state == XR_HAND_V1_GESTURE_STATE_PINCH) {
		printf("xr_hand_v1 %p grabbing\n", xr_hand_v1);
		hand->grabbing = true;
	} else {
	} else if (hand->grabbing) {
		printf("xr_hand_v1 %p releasing\n", xr_hand_v1);
		hand->grabbing = false;
	}


@@ 253,15 255,11 @@ hand_pose(void *data, struct xr_hand_v1 *xr_hand_v1, struct wl_array *position,
{
	struct hand *hand = data;

	if (!hand->grabbing) {
		return;
	}

	assert(position->size == sizeof(vec3));
	memcpy(hand->position, position->data, sizeof(vec3));

	assert(orientation->size == sizeof(versor));
	memcpy(hand->orientation, orientation->data, sizeof(vec3));
	memcpy(hand->orientation, orientation->data, sizeof(versor));
}

static void


@@ 492,7 490,6 @@ render(struct state *state, uint32_t time)
	eglSwapBuffers(state->allocator.dpy, EGL_NO_SURFACE);

	TRACE_END;

/*
	static uint32_t benchmark_time = 0, frames = 0;
	static const uint32_t interval = 5;


@@ 640,7 637,7 @@ main(int argc, char **argv)
	}

	glm_mat4_identity(state.transform);
	glm_translate(state.transform, (vec3){0.f, 0.f, -0.5f});
	glm_translate(state.transform, (vec3){0.f, 0.5f, -0.25f});

	state.scale = 0.2f;
	glm_scale_uni(state.transform, state.scale);