Commit 42df1aab authored by Jakob Bornecrantz's avatar Jakob Bornecrantz
Browse files

d/ns: Tidy code

parent eee034c1
......@@ -4,6 +4,7 @@
#include "deformation_northstar.h"
OpticalSystem::OpticalSystem(const OpticalSystem &_in)
{
ellipseMinorAxis = _in.ellipseMinorAxis;
......@@ -107,7 +108,6 @@ OpticalSystem::RegenerateMesh()
}
}
Vector2
OpticalSystem::RenderUVToDisplayUV(Vector2 inputUV)
{
......@@ -187,7 +187,6 @@ OpticalSystem::RenderUVToDisplayUV(Vector3 inputUV)
return ScreenUV_Real;
}
Vector2
OpticalSystem::SolveDisplayUVToRenderUV(Vector2 inputUV,
Vector2 initailGuess,
......@@ -294,22 +293,22 @@ OpticalSystem::DisplayUVToRenderUVPreviousSeed(Vector2 inputUV)
}
extern "C" ns_optical_system *
extern "C" struct ns_optical_system *
ns_create_optical_system(struct ns_eye *eye)
{
OpticalSystem *opticalSystem = new OpticalSystem();
opticalSystem->LoadOpticalData(eye);
opticalSystem->setiters(50, 50);
opticalSystem->RegenerateMesh();
return (ns_optical_system *)opticalSystem;
return (struct ns_optical_system *)opticalSystem;
}
extern "C" void
ns_display_uv_to_render_uv(struct ns_uv in,
struct ns_uv *out,
struct ns_eye eye)
struct ns_eye *eye)
{
OpticalSystem *opticalSystem = (OpticalSystem *)eye.optical_system;
OpticalSystem *opticalSystem = (OpticalSystem *)eye->optical_system;
Vector2 inUV = Vector2(in.u, 1.f - in.v);
Vector2 outUV = opticalSystem->DisplayUVToRenderUVPreviousSeed(inUV);
out->u = outUV.x;
......
......@@ -9,7 +9,6 @@
* @ingroup drv_ns
*/
#include <math.h>
#include <stdio.h>
#include <unistd.h>
......@@ -37,22 +36,10 @@
*
*/
struct ns_hmd *
get_ns_hmd(struct xrt_device *xdev)
{
return (struct ns_hmd *)xdev;
}
static inline struct ns_mesh *
ns_mesh(struct u_uv_generator *gen)
{
return (struct ns_mesh *)gen;
}
static void
ns_hmd_destroy(struct xrt_device *xdev)
{
struct ns_hmd *ns = get_ns_hmd(xdev);
struct ns_hmd *ns = ns_hmd(xdev);
// Remove the variable tracking.
u_var_remove_root(ns);
......@@ -63,7 +50,7 @@ ns_hmd_destroy(struct xrt_device *xdev)
static void
ns_hmd_update_inputs(struct xrt_device *xdev, struct time_state *timekeeping)
{
struct ns_hmd *ns = get_ns_hmd(xdev);
struct ns_hmd *ns = ns_hmd(xdev);
if (ns->tracker != NULL) {
ns->tracker->update_inputs(ns->tracker, timekeeping);
......@@ -77,7 +64,7 @@ ns_hmd_get_tracked_pose(struct xrt_device *xdev,
int64_t *out_timestamp,
struct xrt_space_relation *out_relation)
{
struct ns_hmd *ns = get_ns_hmd(xdev);
struct ns_hmd *ns = ns_hmd(xdev);
// If the tracking device is created use it.
......@@ -107,7 +94,7 @@ ns_hmd_get_view_pose(struct xrt_device *xdev,
uint32_t view_index,
struct xrt_pose *out_pose)
{
struct ns_hmd *ns = get_ns_hmd(xdev);
struct ns_hmd *ns = ns_hmd(xdev);
*out_pose = ns->eye_configs[view_index].eye_pose;
}
......@@ -129,7 +116,8 @@ ns_mesh_calc(struct u_uv_generator *gen,
struct ns_uv uv = {u, v};
struct ns_uv warped_uv = {0.0f, 0.0f};
ns_display_uv_to_render_uv(uv, &warped_uv, mesh->ns->eye_configs[view]);
ns_display_uv_to_render_uv(uv, &warped_uv,
&mesh->ns->eye_configs[view]);
result->r.x = warped_uv.u;
result->r.y = warped_uv.v;
......
......@@ -16,16 +16,11 @@
#include "xrt/xrt_defines.h"
#include "xrt/xrt_device.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* @defgroup drv_ns North Star Driver
* @ingroup drv
*
* @brief Driver for the North Star HMD.
*/
/*
*
......@@ -65,14 +60,12 @@ extern "C" {
*
*/
/*!
* Opaque struct for optical system C++ integration
*
* @ingroup drv_ns
*/
typedef struct _ns_optical_system ns_optical_system;
struct ns_optical_system;
/*!
* Simple UV struct.
......@@ -85,7 +78,6 @@ struct ns_uv
float v;
};
/*!
* Configuration information about the LMC or Rigel sensor according to the
* configuration file.
......@@ -99,7 +91,6 @@ struct ns_leap
struct xrt_pose pose;
};
/*!
* Distortion information about an eye parsed from the configuration file.
*
......@@ -120,7 +111,7 @@ struct ns_eye
struct xrt_matrix_4x4 sphere_to_world_space;
struct xrt_matrix_4x4 world_to_screen_space;
ns_optical_system *optical_system;
struct ns_optical_system *optical_system;
};
/*!
......@@ -155,12 +146,6 @@ struct ns_mesh
struct ns_hmd *ns;
};
/*!
* @dir drivers/north_star
*
* @brief @ref drv_ns files.
*/
/*
*
......@@ -169,25 +154,38 @@ struct ns_mesh
*/
/*!
* Convert the display UV to the render UV using the distortion mesh.
* Get the North Star HMD information from a @ref xrt_device.
*
* @ingroup drv_ns
*/
void
ns_display_uv_to_render_uv(struct ns_uv display_uv,
struct ns_uv *render_uv,
struct ns_eye eye);
XRT_MAYBE_UNUSED static inline struct ns_hmd *
ns_hmd(struct xrt_device *xdev)
{
return (struct ns_hmd *)xdev;
}
/*!
* Get the North Star HMD information from the xrt_device.
* Get the North Star mesh generator from a @ref u_uv_generator.
*
* @ingroup drv_ns
*/
struct ns_hmd *
get_ns_hmd(struct xrt_device *xdev);
XRT_MAYBE_UNUSED static inline struct ns_mesh *
ns_mesh(struct u_uv_generator *gen)
{
return (struct ns_mesh *)gen;
}
/*!
* Convert the display UV to the render UV using the distortion mesh.
*
* @ingroup drv_ns
*/
void
ns_display_uv_to_render_uv(struct ns_uv display_uv,
struct ns_uv *render_uv,
struct ns_eye *eye);
ns_optical_system *
struct ns_optical_system *
ns_create_optical_system(struct ns_eye *eye);
......
......@@ -14,6 +14,7 @@
extern "C" {
#endif
/*!
* @defgroup drv_ns North Star Driver
* @ingroup drv
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment