diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/camera.c | 9 | ||||
-rw-r--r-- | src/core/camera.h | 4 | ||||
-rw-r--r-- | src/core/core.c | 4 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/core/camera.c b/src/core/camera.c index cde457b..7bddb7e 100644 --- a/src/core/camera.c +++ b/src/core/camera.c @@ -4,6 +4,9 @@ #include "keys.h" #include "maths.h" +#define CAMERA_SPEED 0.2 +#define CAMERA_SENSITIVITY 0.5 + Camera Camera_Create(Vec3 pos, Vec3 front, Vec3 up, f32 fov) { Camera c = { .position = pos, .front = front, .up = up, .fov = fov }; return c; @@ -22,12 +25,12 @@ Mat4 Camera_ViewProj(Camera *c, f32 lens_height, f32 lens_width, Mat4 *out_view, return mat4_mult(view, proj); } -void Camera_Update(Camera *camera) { +void FlyCamera_Update(Camera *camera) { static f32 yaw = 0.0; static f32 pitch = 0.0; // Keyboard - f32 speed = 0.25; + f32 speed = CAMERA_SPEED; Vec3 horizontal = vec3_cross(camera->front, camera->up); if (key_is_pressed(KEYCODE_A) || key_is_pressed(KEYCODE_KEY_LEFT)) { Vec3 displacement = vec3_mult(horizontal, -speed); @@ -62,7 +65,7 @@ void Camera_Update(Camera *camera) { f32 x_offset = mouse.x_delta; f32 y_offset = -mouse.y_delta; - f32 sensitivity = 0.7f; // change this value to your liking + f32 sensitivity = CAMERA_SENSITIVITY; // change this value to your liking x_offset *= sensitivity; y_offset *= sensitivity; diff --git a/src/core/camera.h b/src/core/camera.h index 450f81e..536feca 100644 --- a/src/core/camera.h +++ b/src/core/camera.h @@ -15,7 +15,7 @@ typedef struct Camera { } Camera; /** @brief create a camera */ -Camera Camera_Create(Vec3 pos, Vec3 front, Vec3 up, f32 fov); +PUB Camera Camera_Create(Vec3 pos, Vec3 front, Vec3 up, f32 fov); /** * @brief Get 3D camera transform matrix @@ -31,7 +31,7 @@ PUB Mat4 Camera_View2D(Camera* c); // TODO: 2D cameras struct Input_State; -void Camera_Update(Camera* camera); +PUB void FlyCamera_Update(Camera* camera); // TODO: (HIGH) Basic reusable camera controls /* diff --git a/src/core/core.c b/src/core/core.c index 20bc813..fffb43d 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -78,6 +78,4 @@ Core* get_global_core() { return &g_core; } GLFWwindow* Core_GetGlfwWindowPtr(Core* core) { return g_core.window; } -struct Renderer* Core_GetRenderer(Core* core) { - return core->renderer; -}
\ No newline at end of file +struct Renderer* Core_GetRenderer(Core* core) { return core->renderer; }
\ No newline at end of file |