Space Sim
Loading...
Searching...
No Matches
camera.c
Go to the documentation of this file.
1#include <math.h>
2#include <omp.h>
3#include "mesh/mesh.h"
4#include "core/types.h"
5#include "utilities/mathf.h"
6#include "core/camera.h"
7#include "core/init.h"
8#include <stdio.h>
9
10
11void
13 (
14 Camera * cam,
15 vec3 world_up
16 )
17
18{
19
20 cam->forward.x = cosf(cam->yaw) * cosf(cam->pitch);
21 cam->forward.y = sinf(cam->yaw) * cosf(cam->pitch);
22 cam->forward.z = sinf(cam->pitch);
24
25 cam->right = vec3_cross(cam->forward, world_up);
27
30
31}
32
33mat4
35 (
36 float left,
37 float right,
38 float bottom,
39 float top,
40 float near,
41 float far
42 )
43
44{
45
46 float rl = right - left;
47 float tb = top - bottom;
48 float fn = far - near;
49
50 mat4 out;
51
52 out.a0 = 2 / rl;
53 out.a1 = 0;
54 out.a2 = 0;
55 out.a3 = 0;
56
57 out.b0 = 0;
58 out.b1 = 2 / tb;
59 out.b2 = 0;
60 out.b3 = 0;
61
62 out.c0 = 0;
63 out.c1 = 0;
64 out.c2 = -2 / fn;
65 out.c3 = 0;
66
67 out.d0 = -(right + left) / rl;
68 out.d1 = -(top + bottom) / tb;
69 out.d2 = -(far + near) / fn;
70 out.d3 = 1;
71 return out;
72}
73
74
75mat4
77 (
78 float fov_deg,
79 float aspect,
80 float near,
81 float far
82 )
83
84{
85
86 float fov_rad = fov_deg * (M_PI / 180.0f);
87 float f = 1.0f / tanf(fov_rad / 2.0f);
88 mat4 out;
89 out.a0 = f / aspect;
90 out.a1 = 0;
91 out.a2 = 0;
92 out.a3 = 0;
93
94 out.b0 = 0;
95 out.b1 = f;
96 out.b2 = 0;
97 out.b3 = 0;
98
99 out.c0 = 0;
100 out.c1 = 0;
101 out.c2 = (far + near) / (near - far);
102 out.c3 = -1;
103
104 out.d0 = 0;
105 out.d1 = 0;
106 out.d2 = (2 * far * near) / (near - far);
107 out.d3 = 0;
108 return out;
109}
110
111void
113 ( const mat4 *m )
114
115{
116
117 printf("MAT4:\n"
118 " % .6f % .6f % .6f % .6f\n"
119 " % .6f % .6f % .6f % .6f\n"
120 " % .6f % .6f % .6f % .6f\n"
121 " % .6f % .6f % .6f % .6f\n",
122 m->a0,m->a1,m->a2,m->a3,
123 m->b0,m->b1,m->b2,m->b3,
124 m->c0,m->c1,m->c2,m->c3,
125 m->d0,m->d1,m->d2,m->d3);
126
127}
128
129mat4
131 (
132 Camera * cam,
133 vec3 eye
134 )
135
136{
137
138 vec3 f = cam->forward;
139 vec3 s = cam->right;
140 vec3 u = cam->up;
141
142 mat4 out;
143 out.a0 = s.x;
144 out.a1 = u.x;
145 out.a2 = -f.x;
146 out.a3 = 0;
147
148 out.b0 = s.y;
149 out.b1 = u.y;
150 out.b2 = -f.y;
151 out.b3 = 0;
152
153 out.c0 = s.z;
154 out.c1 = u.z;
155 out.c2 = -f.z;
156 out.c3 = 0;
157
158
159 out.d0 = -vec3_dot(s, eye);
160 out.d1 = -vec3_dot(u, eye);
161 out.d2 = vec3_dot(f, eye);
162 out.d3 = 1;
163 return out;
164}
165
166
167void
169 ( Camera * lcam )
170
171{
172
173 lcam->cam_data.proj = make_ortho(-50.0f, 50.0f, -50.0f, 50.0f, 1.0f, 200.0f);
174
175 vec3 cam_pos = (vec3){
179 };
180
181 vec3 offset = (vec3){0, 0, 0};
182
183 vec3 pos = vec3_add(cam_pos, offset);
184
185 vec3 sd = {
189 };
190
191 vec3 negated_sun_dir = {
192 -sd.x,
193 -sd.y,
194 -sd.z
195 };
196
197 vec3 light_dir = vec3_normalize(negated_sun_dir);
198
199 float distance = 100.0f;
200 pos.x += light_dir.x * distance;
201 pos.y += light_dir.y * distance;
202 pos.z += light_dir.z * distance;
203
204 lcam->cam_data.cam_pos = (vec4){
205 pos.x,
206 pos.y,
207 pos.z,
208 0.0
209 };
210
211 lcam->pitch = -M_PI / 2;
212 lcam->yaw = 0;
213
214 compute_camera_basis(lcam, (vec3){0, 0, 1});
215
216 lcam->target = vec3_add(pos, lcam->forward);
217 lcam->cam_data.view = make_look_at(lcam, pos);
218
219}
220
221void
223 ( Camera * cam )
224
225{
226
227 cam->cam_data.cam_pos.z += 0.5f;
228
229 compute_camera_basis(cam, (vec3){0, 0, 1});
230
232 FOV,
233 (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT,
234 VIEW_NEAR,
236 );
237
239 (vec3){
243 },
244 cam->forward
245 );
246
248 cam,
249 (vec3){
253 }
254 );
255
258 cam->cam_data.cam_pos.z -= 0.5f;
259
260}
261
262void
264 (
265 vec2 wish,
266 float wish_speed,
267 float accel,
268 float dt
269 )
270
271{
272
273 vec3 fwd = cam.forward;
274 float wlen = sqrtf(wish.x * wish.x + wish.y * wish.y);
275 float falignment = 0.0f;
276 if (wlen > 1e-5f)
277 {
278 falignment = (fwd.x * wish.x + fwd.y * wish.y) / (wlen);
279 falignment = clamp(falignment, -1.0f, 1.0f);
280 falignment += 1;
281 if (falignment > 1) falignment -= 1;
282 }
283 wish = (vec2){wish.x + fwd.x, wish.y + fwd.y};
284 wlen = sqrtf(wish.x * wish.x + wish.y * wish.y);
285 if (wlen > 1e-5f) {
286 wish.x /= wlen;
287 wish.y /= wlen;
288 }
289
290 float vx = cam.cam_data.cam_vel.x;
291 float vy = cam.cam_data.cam_vel.y;
292 float curr = vx * wish.x + vy * wish.y;
293 float add = wish_speed - curr;
294 if (add <= 0.0f) return;
295
296 float acc = 0.005 * wish_speed * dt;
297 if (acc > add) acc = add;
298 if (acc > 0)
299 {
300 cam.cam_data.cam_vel.x += acc * wish.x * falignment;
301 cam.cam_data.cam_vel.y += acc * wish.y * falignment;
302 }
303
304 float vlen = sqrtf(vx * vx + vy * vy);
305
306 float alignment = 0.0f;
307 if (vlen > 1e-5f && wlen > 1e-5f)
308 {
309 alignment = (vx * wish.x + vy * wish.y) / (vlen * wlen);
310 alignment = clamp(alignment, -1.0f, 1.0f);
311 }
312 float steer = 1.0f - alignment;
313 steer *= steer;
314
315 float steer_nudge = 0.005 * steer * dt;
316
317 cam.cam_data.cam_vel.x += wish.x * steer_nudge;
318 cam.cam_data.cam_vel.y += wish.y * steer_nudge;
319
321 if (nlen > vlen)
322 {
323 float scale = vlen / nlen;
324 scale = fminf(scale * 1.1f, 1.0f);
327 }
328
329
330}
331
332void
334 (
335 Camera * cam,
336 vec3 move_dir,
337 float dt
338 )
339
340{
341
342 static const float MAX_SPEED = 0.5f;
343 static const float ACCEL = 0.001f;
344 static const float GRAVITY = 0.002f;
345 float accel_step = ACCEL * dt;
346 float s_len = sqrtf(move_dir.x * move_dir.x + move_dir.y * move_dir.y);
347 if (s_len < 0.01f)
348 {
349 if (cam->on_ground)
350 {
351
353 }
354 else
355 {
356 cam->cam_data.cam_vel.z -= GRAVITY * dt;
357
358 }
359 return;
360 }
361
362 vec3 fwd = {cosf(cam->yaw), sinf(cam->yaw), sinf(cam->pitch)};
363 vec3 rgt = {-sinf(cam->yaw), cosf(cam->yaw), 0.0f};
364 fwd = vec3_normalize(fwd);
365 rgt = vec3_normalize(rgt);
366 float wish_x = move_dir.x * fwd.x + move_dir.y * rgt.x;
367 float wish_y = move_dir.x * fwd.y + move_dir.y * rgt.y;
368
369 float proj_wish = wish_x * rgt.x + wish_y * rgt.y;
370 float target_roll = proj_wish * -0.05f;
371 if (wish_x == 0.0f && wish_y == 0.0f) target_roll = 0.0f;
372 cam->roll = lerp(cam->roll, target_roll, dt * 10.0f);
373
374 if (s_len > 0.0f)
375 {
376 wish_x /= s_len;
377 wish_y /= s_len;
378 }
379 float cur = cam->cam_data.cam_vel.x * wish_x + cam->cam_data.cam_vel.y * wish_y;
380 if (cam->on_ground)
381 {
382 float add = MAX_SPEED - cur;
383 if (add)
384 {
385 float push = fminf(add, accel_step);
386 cam->cam_data.cam_vel.x += wish_x * push;
387 cam->cam_data.cam_vel.y += wish_y * push;
388 }
389 }
390 else
391 {
392 apply_air_acceleration((vec2){wish_x, wish_y}, s_len, 18, dt);
393 cam->cam_data.cam_vel.z -= GRAVITY * dt;
394 }
395
396
397 float nlen = sqrtf(cam->cam_data.cam_vel.x * cam->cam_data.cam_vel.x + cam->cam_data.cam_vel.y * cam->cam_data.cam_vel.y);
398 if (nlen > MAX_SPEED)
399 {
400 float scale = MAX_SPEED / nlen;
403 }
404
405
406}
407
408vec3
410 (
411 vec3 sample,
412 float d
413 )
414
415{
416
417 vec3 normal;
418 normal.x = calc_density(vec3_add(sample, (vec3){d, 0, 0})) - calc_density(vec3_add(sample, (vec3){-d, 0, 0}));
419 normal.y = calc_density(vec3_add(sample, (vec3){0, d, 0})) - calc_density(vec3_add(sample, (vec3){0, -d, 0}));
420 normal.z = calc_density(vec3_add(sample, (vec3){0, 0, d})) - calc_density(vec3_add(sample, (vec3){0, 0, -d}));
421 normal = vec3_normalize(normal);
422
423 return normal;
424
425}
426
427bool
429 (
430 vec3 start,
431 vec3 p,
432 vec3 * entry,
433 vec3 * normal,
434 float voxel_size,
435 float radius,
436 float planet_radius
437 )
438
439{
440
441 const int STEP_AMT = 100;
442 const float THRESHOLD = 0.2f;
443
444 // adjust for planet radius (we are technically higher than surface level)
445 start.z -= planet_radius;
446 p.z -= planet_radius;
447
448 float d = calc_density(start);
449 vec3 dir = vec3_sub(p, start);
450 float step_len = vec3_length(vec3_scale(dir, (float)1 / STEP_AMT));
451 vec3 dir_step = vec3_scale(vec3_normalize(dir), step_len);
452 float prev_d = d;
453
454 // if we start within a surface, we push out
455 bool started_inside = (prev_d < THRESHOLD);
456 if (started_inside)
457 {
458
459 *entry = start;
460 *normal = find_density_normal(*entry, voxel_size);
461 return true;
462 }
463
464 // iterate to STEP AMT to find a surface in the direction of movement
465 vec3 prev = start;
466 for (int i = 0; i < STEP_AMT; i++)
467 {
468
469 vec3 o = vec3_add(prev, dir_step);
470 d = calc_density(o);
471
472 if ((d - THRESHOLD) * (prev_d - THRESHOLD) < 0.0f)
473 {
474
475 // interpolate the entry density and push out to find the entry point
476 float t = prev_d / (prev_d - d);
477 *entry = vec3_add(prev, vec3_scale(vec3_sub(o, prev), t));
478 *normal = find_density_normal(*entry, voxel_size);
479 return true;
480
481 }
482
483 prev = o;
484 prev_d = d;
485
486 }
487 return false;
488
489}
490
491float
493 ( vec3 p )
494
495{
496
497 float z0 = p.z;
498 float z1 = p.z - 1.0f;
499
500 float d0 = calc_density((vec3){p.x, p.y, z0});
501 float d1 = calc_density((vec3){p.x, p.y, z1});
502
503 if (d0 * d1 > 0.0f) {
504 return p.z;
505 }
506
507 for (int i = 0; i < 100; i++)
508 {
509 float zm = 0.5f * (z0 + z1);
510 float dm = calc_density((vec3){p.x, p.y, zm});
511
512 if (dm > 0.0f)
513 z0 = zm;
514 else
515 z1 = zm;
516 }
517
518 return 0.5f * (z0 + z1);
519}
520
521float
523 (
524 vec3 cam_pos,
525 vec3 p,
526 float planet_radius
527 )
528
529{
530
531 const int FAIL = 5000;
532 const float STEP_SIZE = 0.0065f;
533 const float THRESHOLD = 0.35f;
534
535 vec3 prop = p;
536 prop.z = cam_pos.z + 0.5f - planet_radius;
537 float fail_bottom = calc_density((vec3){p.x, p.y, prop.z - STEP_SIZE * FAIL});
538 if (fail_bottom > THRESHOLD)
539 {
540 return -9999;
541 }
542 float top = p.z;
543 float density = calc_density(prop);
544
545 bool top_outside = false;
546 if (density > THRESHOLD)
547 {
548 int failsafe = 0;
549 bool valid_hit = false;
550 while (density > THRESHOLD && failsafe < FAIL)
551 {
552 density = calc_density(prop);
553 if (density <= THRESHOLD)
554 {
555
556 valid_hit = true;
557 break;
558 }
559 prop.z -= STEP_SIZE;
560 failsafe++;
561 }
562 if (valid_hit && failsafe < FAIL)
563 {
564 top_outside = true;
565 top = prop.z;
566 }
567 }
568
569 if (!top_outside)
570 {
571 top = -9999;
572 }
573 return top;
574}
575
576bool was_on_ground = false;
577bool was_not_on_ground = false;
578bool ground_hit = false;
579
580const float radius = 0.5;
581bool hit_ground(float z, float current_floor)
582{
583 cam.cam_data.cam_pos.z = current_floor;
584 float dist_to_floor = z - (current_floor);
585 if (dist_to_floor <= 0.1f)
586 {
587
588 cam.cam_data.cam_vel.z = 0;
589 cam.on_ground = true;
590
591 ground_hit = true;
592 return true;
593 }
594 else
595 {
596 if (!was_on_ground) was_on_ground = true;
597 cam.on_ground = false;
598 return false;
599 }
600
601}
602
603
604
605
606bool
608 (
609 vec3 start, // starting position
610 vec3 final, // proposed position
611 vec3 * normal, // pointer to hit surface normal
612 vec3 * entrance, // pointer to hit position
613 float d, // voxel size
614 float current_floor, // current ground
615 float planet_radius
616 )
617
618{
619
620 // check sampling for current height of the player to see if we are too high or too low
622 ground_hit = hit_ground(final.z - planet_radius, current_floor);
623
624 if (!was_on_ground && ground_hit) { final.z = current_floor + 0.005f; }
625
626 bool entered = find_surface_entry(start, final, entrance, normal, d, radius, planet_radius);
627 if (entered){
628
629 return true;
630
631 }
632 return false;
633
634}
635
636
637void
639 (
640 Camera * cam,
641 float planet_radius
642 )
643
644{
645
646 ground_hit = false;
647
648
649 float chunk_world_size = CHUNK_WORLD_SIZE;
650
651 float voxel_size = chunk_world_size / 64.0;
652
653
656
657 vec3 proposed = vec3_add(cam_pos, cam_vel);
658
659 vec3 prop2 = proposed;
660
661 prop2.z = 0;
662
663 float d = voxel_size;
664 Timer find_s, cc;
665 start_timer(&find_s);
666 float ground = find_surface(cam_pos, proposed, planet_radius);
667
668 vec3 collision_normal = (vec3){99, 99, 99};
669 vec3 entrance;
670
671 start_timer(&cc);
672 if (!check_collision(
673 (vec3){cam_pos.x, cam_pos.y, cam_pos.z},
674 (vec3){proposed.x, proposed.y, proposed.z},
675 &collision_normal,
676 &entrance,
677 d,
678 ground,
680 ))
681 {
682 cam->cam_data.cam_pos.x = proposed.x;
683 cam->cam_data.cam_pos.y = proposed.y;
684 cam->cam_data.cam_pos.z = proposed.z;
685
686 }
687 else
688 {
689 if (collision_normal.x != 99 && collision_normal.y != 99 && collision_normal.z != 99)
690 {
691 vec3 wish = vec3_sub(proposed, cam_pos);
692
693 float vel_dot_n = vec3_dot(wish, collision_normal);
694
695 if (vel_dot_n < 0.0f)
696 {
697 wish = vec3_sub(wish, vec3_scale(collision_normal, vel_dot_n));
698 proposed.x = cam_pos.x + wish.x;
699 proposed.y = cam_pos.y + wish.y;
700 proposed.z = cam_pos.z + wish.z;
701
702 proposed.x += collision_normal.x * 0.01f;
703 proposed.y += collision_normal.y * 0.01f;
704 proposed.z += collision_normal.z * 0.01f;
705 }
706
707 cam->cam_data.cam_vel.x = wish.x;
708 cam->cam_data.cam_vel.y = wish.y;
709 cam->cam_data.cam_vel.z = wish.z;
710
711 cam->cam_data.cam_pos.x = proposed.x;
712 cam->cam_data.cam_pos.y = proposed.y;
713 cam->cam_data.cam_pos.z = proposed.z;
714
715 }
716 else
717 {
718 cam->cam_data.cam_vel.x = 0;
719 cam->cam_data.cam_vel.y = 0;
720 cam->cam_data.cam_vel.z = 0;
721
722 }
723 return;
724 }
725
726}
727
728
729
730void
732 (
733 Camera * cam,
734 vec3 move_dir,
735 float dt
736 )
737
738{
739
740 static const float MAX_SPEED = 100.0f;
741 static const float ACCEL = 1.0f;
742 float accel_step = ACCEL * dt;
743 float s_len = sqrtf(move_dir.x * move_dir.x + move_dir.y * move_dir.y);
744 if (s_len < 0.01f)
745 {
747 }
748
749 vec3 fwd = {cosf(cam->yaw), sinf(cam->yaw), sinf(cam->pitch)};
750 vec3 rgt = {-sinf(cam->yaw), cosf(cam->yaw), 0.0f};
751 fwd = vec3_normalize(fwd);
752 rgt = vec3_normalize(rgt);
753 float wish_x = move_dir.x * fwd.x + move_dir.y * rgt.x;
754 float wish_y = move_dir.x * fwd.y + move_dir.y * rgt.y;
755 float wish_z = move_dir.x * fwd.z + move_dir.y * rgt.z;
756
757 float proj_wish = wish_x * rgt.x + wish_y * rgt.y + wish_z * rgt.z;
758 float target_roll = proj_wish * -0.05f;
759 if (wish_x == 0.0f && wish_y == 0.0f) target_roll = 0.0f;
760 cam->roll = lerp(cam->roll, target_roll, dt * 10.0f);
761
762 if (s_len > 0.0f)
763 {
764 wish_x /= s_len;
765 wish_y /= s_len;
766 wish_z /= s_len;
767 }
768 float cur = cam->cam_data.cam_vel.x * wish_x + cam->cam_data.cam_vel.y * wish_y + cam->cam_data.cam_vel.z * wish_z;
769 float add = MAX_SPEED - cur;
770 if (add)
771 {
772 float push = fminf(add, accel_step);
773 cam->cam_data.cam_vel.x += wish_x * push;
774 cam->cam_data.cam_vel.y += wish_y * push;
775 cam->cam_data.cam_vel.z += wish_z * push;
776 }
780}
781
782float
784 (
785 vec2 a,
786 vec2 b
787 )
788
789{
790
791 float cross = a.x*b.y - a.y*b.x;
792 float dot = a.x*b.x + a.y*b.y;
793 return atan2f(cross, dot);
794
795}
796
797float
799 (
800 vec3 a,
801 vec3 b,
802 vec3 n
803 )
804
805{
806
807 vec3 cross = vec3_cross(a, b);
808 float dot = vec3_dot(cross, n);
809 float angle = atan2f(dot, vec3_dot(a, b));
810 if (dot < 0) angle = -angle;
811 return angle;
812
813}
814
815float
817 (
818 vec3 a,
819 vec3 b
820 )
821
822{
823
824 float pa = atan2f(a.z, sqrtf(a.x * a.x + a.y * a.y));
825 float pb = atan2f(b.z, sqrtf(b.x * b.x + b.y * b.y));
826 return pb - pa;
827
828}
829
830
831void
833
834{
835
836 vec4 pos;
837
838 glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, 60);
839 glBindBuffer(GL_SHADER_STORAGE_BUFFER, PARTICLE_SSBO);
840 vec4 * ptr = glMapBufferRange(
841 GL_SHADER_STORAGE_BUFFER,
842 offsetof(ParticleData, p) + sizeof(Particle) * GLOBALS.selected_body,
843 sizeof(vec4),
844 GL_MAP_READ_BIT
845 );
846
847 memcpy(&pos, ptr, sizeof(vec4));
848 glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
849
850 vec3 ppos = {pos.x, pos.y, pos.z};
851
853
854 vec2 forward2 = { cam.forward.x, cam.forward.y };
855
856 float s_angle = signed_angle(forward2, (vec2){fdest.x, fdest.y});
857 cam.yaw += s_angle;
858
859
860 cam.forward.x = cosf(cam.yaw) * cosf(cam.pitch);
861 cam.forward.y = sinf(cam.yaw) * cosf(cam.pitch);
862 cam.forward.z = sinf(cam.pitch);
864
865
867
868 vec3 final_pos = vec3_sub(ppos, vec3_scale(fdest, 10.0f));
869 cam.cam_data.cam_pos.x = final_pos.x;
870 cam.cam_data.cam_pos.y = final_pos.y;
871 cam.cam_data.cam_pos.z = final_pos.z;
872
873}
874
float scale(float fCos)
void update_light_camera(Camera *lcam)
Definition camera.c:169
bool ground_hit
Definition camera.c:578
float pitch_difference(vec3 a, vec3 b)
Definition camera.c:817
float signed_angle(vec2 a, vec2 b)
Definition camera.c:784
void resolve_collisions(Camera *cam, float planet_radius)
Definition camera.c:639
mat4 make_ortho(float left, float right, float bottom, float top, float near, float far)
Definition camera.c:35
vec3 find_density_normal(vec3 sample, float d)
Definition camera.c:410
bool was_not_on_ground
Definition camera.c:577
void print_mat4(const mat4 *m)
Definition camera.c:113
float find_surface(vec3 cam_pos, vec3 p, float planet_radius)
Definition camera.c:523
float find_surface_z(vec3 p)
Definition camera.c:493
float signed_angle_3d(vec3 a, vec3 b, vec3 n)
Definition camera.c:799
void apply_velocity(Camera *cam, vec3 move_dir, float dt)
Definition camera.c:732
const float radius
Definition camera.c:580
bool find_surface_entry(vec3 start, vec3 p, vec3 *entry, vec3 *normal, float voxel_size, float radius, float planet_radius)
Definition camera.c:429
void look_at_selected_body()
Definition camera.c:832
void update_camera(Camera *cam)
Definition camera.c:223
mat4 make_look_at(Camera *cam, vec3 eye)
Definition camera.c:131
bool check_collision(vec3 start, vec3 final, vec3 *normal, vec3 *entrance, float d, float current_floor, float planet_radius)
Definition camera.c:608
bool was_on_ground
Definition camera.c:576
void apply_air_acceleration(vec2 wish, float wish_speed, float accel, float dt)
Definition camera.c:264
bool hit_ground(float z, float current_floor)
Definition camera.c:581
mat4 make_projection(float fov_deg, float aspect, float near, float far)
Definition camera.c:77
void compute_camera_basis(Camera *cam, vec3 world_up)
Definition camera.c:13
void apply_planet_velocity(Camera *cam, vec3 move_dir, float dt)
Definition camera.c:334
Camera cam
Definition main.c:222
float calc_density(vec3 p)
Copies the exact density function from the GPU to the CPU.
Definition mesh.c:324
GLuint PARTICLE_SSBO
Definition main.c:202
int SCREEN_WIDTH
Definition main.c:41
PlanetData PLANET_DATA
Definition main.c:194
int SCREEN_HEIGHT
Definition main.c:42
GLsync fence
Definition main.c:247
float planet_radius
Definition main.c:262
float dt
Definition main.c:229
Globals GLOBALS
Definition main.c:39
vec3 vec3_cross(vec3 a, vec3 b)
Definition mathf.h:27
float vec3_dot(vec3 a, vec3 b)
Definition mathf.h:101
vec3 vec3_normalize(vec3 v)
Definition mathf.h:7
vec3 vec3_scale(vec3 a, float b)
Definition mathf.h:39
vec3 vec3_sub(vec3 a, vec3 b)
Definition mathf.h:57
vec3 vec3_add(vec3 a, vec3 b)
Definition mathf.h:73
float lerp(float a, float b, float t)
Definition mathf.h:143
vec4 vec4_scale(vec4 a, float b)
Definition mathf.h:43
float clamp(float a, float b, float c)
Definition mathf.h:147
mat4 mat4_inverse(mat4 in)
Definition mathf.h:111
float vec3_length(vec3 v)
Definition mathf.h:107
bool s
Definition menu.c:6
Definition main.h:8
float x
Definition types.h:45
float a1
Definition types.h:51
float roll
Definition types.h:234
bool on_ground
Definition types.h:240
float z
Definition types.h:47
vec4 sun_dir
Definition types.h:415
float d3
Definition types.h:51
float c2
Definition types.h:51
float b0
Definition types.h:51
float c1
Definition types.h:51
float x
Definition types.h:47
float a2
Definition types.h:51
float x
Definition main.h:5
#define CHUNK_WORLD_SIZE
Definition types.h:318
mat4 inv_proj
Definition types.h:225
#define VIEW_NEAR
Definition types.h:36
float b3
Definition types.h:51
float y
Definition types.h:45
float y
Definition types.h:47
mat4 inv_view
Definition types.h:225
float y
Definition main.h:5
vec3 forward
Definition types.h:233
void start_timer(Timer *t)
Definition types.h:58
float d1
Definition types.h:51
float a3
Definition types.h:51
float c0
Definition types.h:51
float z
Definition main.h:5
vec3 target
Definition types.h:233
mat4 view
Definition types.h:225
float pitch
Definition types.h:234
vec3 right
Definition types.h:233
#define VIEW_FAR
Definition types.h:37
float b2
Definition types.h:51
float d0
Definition types.h:51
vec4 cam_vel
Definition types.h:224
float yaw
Definition types.h:234
mat4 proj
Definition types.h:225
int selected_body
Definition types.h:256
CamData cam_data
Definition types.h:235
float a0
Definition types.h:51
float c3
Definition types.h:51
vec4 cam_pos
Definition types.h:224
float b1
Definition types.h:51
#define FOV
Definition types.h:35
float d2
Definition types.h:51
vec3 up
Definition types.h:233
Definition types.h:53
Definition types.h:51
Definition types.h:45
Definition main.h:5
Definition types.h:47
uniform float t
Definition water.comp:23