A serious refactor. Moved the entire window management process to another thread. Made a plotting interface with DLL exports. Refactored camera and changed transformation approach based on Jordan's suggestions

This commit is contained in:
2025-08-25 03:09:32 -05:00
parent b775d5a90f
commit 59162408f1
15 changed files with 566 additions and 293 deletions

24
inc/camera.hpp Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
#include <glm/matrix.hpp>
struct Viewport {
float fov_degrees;
float width;
float height;
};
Viewport make_viewport(float win_w, float win_h, float fov_degrees);
glm::mat4 camera_to_projection(Viewport& v);
struct Camera {
glm::vec3 focus;
float theta, phi, distance;
};
Camera make_camera(glm::vec3 focus, float distance);
void pan_camera(Camera &c, glm::vec2 dxdy);
void rotate_camera(Camera &c, glm::vec2 dxdy);
void zoom_camera(Camera &c, float dz);
glm::mat4 world_to_camera(Camera& c);
glm::mat4 camera_to_world(Camera& c);

View File

@@ -1,6 +1,5 @@
#pragma once
#include "util.hpp"
#include "body.hpp"
bool parse_poses(Array<Body> *bodies_out, const char* filepath);
bool parse_poses(Array<glm::mat2x3>* locs_out, const char* filepath);

12
inc/live_plotter.hpp Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
typedef unsigned long long pointid;
DllExport bool __cdecl start(int win_w, int win_h);
DllExport bool __cdecl stop();
DllExport pointid __cdecl create_point(float x, float y, float z);
DllExport void __cdecl set_color(pointid id, float r, float g, float b);
DllExport void __cdecl set_scale(pointid id, float scale);
DllExport void __cdecl update_point(pointid id, float x, float y, float z);
DllExport void __cdecl set_lifetime(pointid id, float new_lifetime_s);
DllExport void __cdecl clear_point(pointid id);

View File

@@ -1,10 +1,12 @@
#pragma once
#include <stdio.h>
#include <cstdlib>
#include <glm/ext/matrix_float4x4.hpp>
#include <glm/ext/quaternion_float.hpp>
#include <glm/ext/vector_float4.hpp>
#include <stdio.h>
#define DllExport __declspec( dllexport )
typedef unsigned int uint;
@@ -23,4 +25,9 @@ bool read_file(Array<char>* out, const char* filepath);
Array<char*> split_str(const char* s, char delimiter);
Array<char*> split_str(const char* s);
glm::mat4 quat_to_mat4(glm::quat q);
glm::mat4 quat_to_mat4(glm::quat q);
template<class T> T lerp(T start, T end, float t) { return t * end + (1 - t) * start; }
template<class T> float ilerp(T start, T end, T pos) { return (pos - start) / (end - start); }
float randf(); // returns a float between 0 and 1