Untitled
Loading...
Searching...
No Matches
editor.c
Go to the documentation of this file.
1
2#include "SDL2/SDL_video.h"
3#include "core/camera.h"
4#include "core/engine_types.h"
5#include "ui/fonts.h"
6#include "load/gltf.h"
7#include "load/load.h"
8#include "editor/editor.h"
10#include "ECS/entity.h"
11#include "load/init.h"
12#include "light/lightmap.h"
13#include "utilities/mathf.h"
14#include "render/render.h"
15#include "utilities/types.h"
16#include "ui/ui.h"
17#include "core/acceleration.h"
18#include "core/nk_config.h"
19#include "physics/physics.h"
20#include "nuklear/nuklear.h"
21#include "nuklear/nuklear_sdl_gl3.h"
22#include "Windows.h"
23#include "audio/audio.h"
24#include "ui/ui_callbacks.h"
25#include "utilities/utilities.h"
26#include <rpcndr.h>
27#include <stddef.h>
28#include <stdint.h>
29
43
44
45#define MAX_GLTF_NAMES 256
48#define MAX_RPROBE_NAMES 256
51
63
65{
66
67 SDL_DisplayMode DM;
68 if (SDL_GetDesktopDisplayMode(0, &DM) == 0)
69 {
70 switch(option)
71 {
73 SCREEN_WIDTH = DM.w;
74 SCREEN_HEIGHT = DM.h;
75 SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
76 break;
78 SCREEN_WIDTH = DM.w;
79 SCREEN_HEIGHT = DM.h;
80 SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
81 break;
82 case FSOPT_WINDOWED:
83 SDL_SetWindowFullscreen(window, 0);
84 SDL_GetWindowSize(window, &SCREEN_WIDTH, &SCREEN_HEIGHT);
85 break;
86 default:
87 break;
88 }
89 }
91
92}
93
95{
96
98 {
102 glBindFramebuffer(GL_FRAMEBUFFER, MAIN_FBO.fbo);
103 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GBUFFER_FBO.depth_rbo.i);
104 }
105 else
106 {
107 glBindFramebuffer(GL_FRAMEBUFFER, MAIN_RESOLVE_FBO.fbo);
108 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, GBUFFER_RESOLVE_FBO.depth_texture.i, 0);
109 }
111
112}
113
114
115void change_ssao_res(int w, int h)
116{
117 SSAO_WIDTH = w;
118 SSAO_HEIGHT = h;
119
120 change_fbo_resolution(&SSAO_FBO, w, h, false);
122}
123void change_dof_res(int w, int h)
124{
125 DOF_WIDTH = w;
126 DOF_HEIGHT = h;
127 change_fbo_resolution(&COC_FBO, w, h, false);
128 change_fbo_resolution(&BOKEH_FBO, w, h, false);
129
130}
131
132void change_bloom_res(int w, int h)
133{
134 BLOOM_WIDTH = w;
135 BLOOM_HEIGHT = h;
136
137 int current_width = w;
138 int current_height = h;
139 for (int i = 0; i < 5; i++)
140 {
141 change_fbo_resolution(&BLOOM_PYRAMID[i], current_width, current_height, false);
142
143
144 current_width /= 2;
145 current_height /= 2;
146 }
147}
148
152Undo * top_undo = NULL;
154
156{
157 for (int i = 0; i < MAX_UNDOS; i++)
158 {
159 UNDOS[i].id = i;
160 UNDOS[i].free = true;
161 UNDOS[i].prev = NULL;
162 UNDOS[i].next = NULL;
163
164 }
165 top_undo = &UNDOS[0];
166}
167
169{
170 for (int i = 0; i < undo->special_count; i++)
171 {
172 if (undo->special_bytes[i]) free(undo->special_bytes[i]);
173 }
174 if (undo->special_bytes) free(undo->special_bytes);
175 undo->special_count = 0;
176 undo->special_bytes = NULL;
177 undo->byte_size = 0;
178
179}
180
181void clear_undo(Undo * undo)
182{
183 undo->next = NULL;
184 undo->free = true;
185 if (undo->special_count > 0)
186 {
187 for (int i = 0; i < undo->special_count; i++)
188 {
189 if (undo->special_bytes) free(undo->special_bytes[i]);
190 undo->special_bytes[i] = NULL;
191 }
192 if (undo->special_bytes) free(undo->special_bytes);
193 undo->special_bytes = NULL;
194 }
195 undo->byte_offset = 0;
196 undo->byte_size = 0;
197 undo->special_count = 0;
198
199}
200
201void destroy_undo(Undo * undo)
202{
203 if (undo->next)
204 {
205 undo->next->prev = NULL;
206 }
207
208 Undo * current = undo;
209 while(current->prev)
210 {
211 clear_undo(current->prev);
212 Undo * tmp = current;
213 current = current->prev;
214 tmp->prev = NULL;
215 }
216
217 clear_undo(undo);
218
219}
220
222{
223
224 Undo * current = &UNDOS[undo_stack_idx];
225 while(current->prev)
226 {
227 current = current->prev;
228 }
229 return current;
230
231}
232
234{
235 for (int i = 0; i < MAX_UNDOS; i++)
236 {
237 if (UNDOS[i].free)
238 {
239 destroy_undo(&UNDOS[i]);
240 return &UNDOS[i];
241 }
242 }
243
244 Undo * undo = find_last_undo();
245 destroy_undo(undo);
246 return undo;
247}
248
249
250
251void link_undo(Undo * undo)
252{
253
254 if (undo->prev)
255 {
256 undo->prev->next = NULL;
257 }
258 undo->prev = top_undo;
259 if (top_undo) top_undo->next = undo;
260 if (undo->next)
261 {
262 undo->next->prev = NULL;
263 }
264 undo->next = NULL;
265 undo->free = false;
266 top_undo = undo;
267 next_redo = NULL;
268
269}
270
271
273{
275 {
276 Undo * current = top_undo;
277 if (!current) return;
278 while(current->prev)
279 {
280 current = current->prev;
281 }
282 destroy_undo(current);
283 if (top_undo == current) top_undo = NULL;
284 }
285}
286
288{
289
290 if (!top_undo)
291 {
292 return;
293 }
294 Undo * undo = top_undo;
295 execute_undo(undo);
296
297
300
301}
302
304{
305 if (!next_redo) return;
306
307 Undo * undo = next_redo;
308 execute_undo(undo);
309
310 top_undo = undo;
311 next_redo = undo->next;
312}
313
314
316{
317
318 if (!top_undo) return;
319 Undo * current = top_undo;
320 Undo * next = current->next;
321 while(next)
322 {
323
324 current = next;
325 current->free = true;
326 current->prev = NULL;
327 next = current->next;
328 clear_undo(current);
329
330 }
331
332}
333
334
335void push_nk_slider_undo(NKSlider * s, UndoStructure structure, size_t byte_offset)
336{
337
338 Undo * undo = find_empty_undo();
339 undo->byte_size = s->byte_size;
340 undo->byte_offset = byte_offset;
341 undo->special_count = 0;
342 memcpy(undo->bytes, s->bytes, s->byte_size);
343 memcpy(&undo->structure, &structure, sizeof(UndoStructure));
344 link_undo(undo);
347
348}
349
350void push_raw_bytes_undo(void * bytes, size_t byte_size, UndoStructure structure, size_t byte_offset)
351{
352
353 Undo * undo = find_empty_undo();
354 undo->byte_size = byte_size;
355 undo->byte_offset = byte_offset;
356 undo->special_count = 0;
357 memcpy(undo->bytes, bytes, byte_size);
358 memcpy(&undo->structure, &structure, sizeof(UndoStructure));
359 link_undo(undo);
360 undo_stack_size += byte_size;
362
363}
364
365void push_special_undo(UndoStructure structure, uint8_t ** bytes, size_t total_byte_size, size_t bytes_count, size_t byte_offset)
366{
367
368 Undo * undo = find_empty_undo();
369 undo->special_count = bytes_count;
370 undo->byte_offset = byte_offset;
371 undo->special_bytes = bytes;
372 memcpy(&undo->structure, &structure, sizeof(UndoStructure));
373 link_undo(undo);
374 undo_stack_size += total_byte_size;
376
377}
378
379void push_special_undo_normal_bytes(UndoStructure structure, void * bytes, size_t byte_size, size_t byte_offset)
380{
381
382 Undo * undo = find_empty_undo();
383 undo->byte_offset = byte_offset;
384 undo->special_count = 0;
385 memcpy(undo->bytes, bytes, byte_size);
386 memcpy(&undo->structure, &structure, sizeof(UndoStructure));
387 link_undo(undo);
388 undo_stack_size += byte_size;
390
391}
392
394{
396 {
397 .special = special,
398 .type = type
399 };
400 if (id)
401 {
402 memcpy(a.ids, id, sizeof(int) * 8);
403 }
404 return a;
405}
406
408{
410 {
411 .special = special,
412 .type = type
413 };
414 a.ids[0] = id;
415 return a;
416}
417
419{
421 {
422 .special = special,
423 .type = UNDOSTRUCT_LIGHT
424 };
425 a.ids[0] = id;
426 return a;
427}
428
429
430void copy_special_undo(Undo * undo, uint8_t *** special_bytes, int ids[8])
431{
432 if (undo->special_count > 0)
433 {
434
435 *special_bytes = malloc(sizeof(uint8_t*) * undo->special_count);
436 for (int i = 0; i < undo->special_count; i++)
437 {
438 (*special_bytes)[i] = malloc(undo->byte_size);
439
440 }
441
442 }
443 else
444 {
445 *special_bytes = NULL;
446 }
447
448
449}
450
451
452
453void execute_non_special_undo(Undo * undo, uint8_t * p)
454{
455 uint8_t temp[MAX_UNDO_BYTES];
456 memcpy(temp, p + undo->byte_offset, undo->byte_size);
457 memcpy(p + undo->byte_offset, undo->bytes, undo->byte_size);
458 memcpy(undo->bytes, temp, undo->byte_size);
459}
460
461
462
464{
465 Light * lights = CAST_VEC(GLOBALS.lights, Light);
466 Light * light = &lights[undo->structure.ids[0]];
467 switch(undo->structure.special)
468 {
469 case UNDOSPECIAL_NONE:
470 execute_non_special_undo(undo, (uint8_t*)light);
471 break;
472 case UNDOLIGHT_SPAWN:
473
474 uint8_t ** bytes = malloc(sizeof(uint8_t*));
475 bytes[0] = malloc(sizeof(Light));
476 memcpy(bytes[0], light, sizeof(Light));
477 size_t total_bytes = sizeof(uint8_t*) + sizeof(Light);
478 undo->byte_size = total_bytes;
479 undo->special_bytes = bytes;
480 undo->special_count = 1;
484 undo->structure.ids[1] = temp;
485
487
489
490 break;
491
492 case UNDOLIGHT_DELETE:
493
494 for (int i = GLOBALS.lights.count; i > undo->structure.ids[0]; i--)
495 {
496 lights[i] = lights[i-1];
497 }
499 memcpy(&lights[undo->structure.ids[0]], undo->special_bytes[0], sizeof(Light));
502 free(undo->special_bytes[0]);
503 free(undo->special_bytes);
504 undo->special_bytes = NULL;
505 undo->special_count = 0;
506 undo->byte_size = 0;
508 break;
509 default:
510 break;
511 }
512 light->sm_dirty = true;
513 GLOBALS.lights_dirty = true;
514}
515
517{
518
519 switch(undo->structure.special)
520 {
521 case UNDOSPECIAL_NONE:
522 execute_non_special_undo(undo, (uint8_t*)&GLOBALS);
523 break;
524 // this needs a redo
526
528
534 Mesh * meshes = CAST_VEC(GLOBALS.meshes, Mesh);
536 for (int i = 0; i < GLOBALS.mesh_nodes.count; i++)
537 {
538 if (mns[i].mesh == -1 || mns[i].free) continue;
539 if (!meshes[mns[i].mesh].static_mesh || !mns[i].static_mesh || mns[i].physics_mode) continue;
540
541 build_uv_islands(&mns[i]);
542 }
544 draw_dirty = true;
545
546 break;
547 default:
548 break;
549 }
550
551}
552
553
555{
557 {
558 .special = special,
560 };
561 return a;
562}
564{
565
566 int temp[8];
567 switch(undo->structure.special)
568 {
569 case UNDOSPECIAL_NONE:
571 break;
575 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
577 break;
579 temp[0] = SCREEN_WIDTH;
580 temp[1] = SCREEN_HEIGHT;
581 SCREEN_WIDTH = undo->structure.ids[0];
582 SCREEN_HEIGHT = undo->structure.ids[1];
583 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
584 SDL_SetWindowSize(window, SCREEN_WIDTH, SCREEN_HEIGHT);
585 break;
587 temp[0] = RENDER_WIDTH;
588 temp[1] = RENDER_HEIGHT;
589 RENDER_WIDTH = undo->structure.ids[0];
590 RENDER_HEIGHT = undo->structure.ids[1];
591 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
593 break;
595 temp[0] = SSAO_WIDTH;
596 temp[1] = SSAO_HEIGHT;
597 change_ssao_res(undo->structure.ids[0], undo->structure.ids[1]);
598 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
599 break;
601 temp[0] = DOF_WIDTH;
602 temp[1] = DOF_HEIGHT;
603 change_dof_res(undo->structure.ids[0], undo->structure.ids[1]);
604 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
605 break;
607 temp[0] = BLOOM_WIDTH;
608 temp[1] = BLOOM_HEIGHT;
609 change_bloom_res(undo->structure.ids[0], undo->structure.ids[1]);
610 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
611 break;
613 temp[0] = SSAO_WIDTH;
614 temp[1] = SSAO_HEIGHT;
615 temp[2] = DOF_WIDTH;
616 temp[3] = DOF_HEIGHT;
617 temp[4] = BLOOM_WIDTH;
618 temp[5] = BLOOM_HEIGHT;
619 change_ssao_res(undo->structure.ids[0], undo->structure.ids[1]);
620 change_dof_res(undo->structure.ids[2], undo->structure.ids[3]);
621 change_bloom_res(undo->structure.ids[4], undo->structure.ids[5]);
622 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
623 break;
624 default:
625 break;
626 }
627
628}
629
631{
633 {
634 .special = special,
635 .type = UNDOSTRUCT_RPROBE
636 };
637 a.ids[0] = id;
638 return a;
639}
640
642{
643
645 ReflectionProbe * rp = &rprobes[undo->structure.ids[0]];
646 int temp[8];
647 switch(undo->structure.special)
648 {
649 case UNDOSPECIAL_NONE:
650 execute_non_special_undo(undo, (uint8_t*)rp);
651 break;
652 case UNDORPROBE_SPAWN:
653 {
654
655 uint8_t ** bytes = malloc(sizeof(uint8_t*));
656 bytes[0] = malloc(sizeof(ReflectionProbe));
657 memcpy(bytes[0], rp, sizeof(ReflectionProbe));
658
659 temp[0] = undo->structure.ids[0];
661
664
665 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
666 undo->special_bytes = bytes;
667 undo->byte_size = sizeof(uint8_t*) + sizeof(ReflectionProbe);
668 undo->special_count = 1;
669
671
672 }
673 break;
674
676 {
677
679 memcpy(rp, undo->special_bytes[0], sizeof(ReflectionProbe));
680 temp[0] = undo->structure.ids[0];
683
685 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
686
688 }
689
690 break;
691 default:
692 break;
693 }
694}
695
697{
699 ProbeVolume * pv = &pvs[undo->structure.ids[0]];
700 int temp[8];
701 switch(undo->structure.special)
702 {
703 case UNDOSPECIAL_NONE:
704
705 execute_non_special_undo(undo, (uint8_t*)pv);
706 break;
707
708 case UNDOLPROBE_SPAWN:
709 {
710
711 // set up bytes to receive the current probe volume
712 uint8_t ** bytes = malloc(sizeof(uint8_t*));
713 bytes[0] = malloc(sizeof(ProbeVolume));
714 memcpy(bytes[0], pv, sizeof(ProbeVolume));
715 // delete the probe volume to undo the spawn
717 // flip the ids that will be used for the redo
718 temp[0] = undo->structure.ids[0];
721 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
722 // reset special fields to reflect how we set up the redo
723 undo->special_bytes = bytes;
724 undo->special_count = 1;
725 undo->byte_size = sizeof(uint8_t*) + sizeof(ProbeVolume);
726 // on redo we will "undo the delete"
728
729 }
730 break;
731
733
734 for (int i = 0; i < LPV_SLOTS; i++)
735 {
738 if (undo->special_bytes[i])
739 {
740 GLOBALS.scene_data.LOADED_LIGHTING_PV[i].lprobes = malloc(sizeof(float) * LPV_PADDED_COUNT * 3 * SH_MAX);
741 memcpy(GLOBALS.scene_data.LOADED_LIGHTING_PV[i].lprobes, undo->special_bytes[i], sizeof(float) * LPV_PADDED_COUNT * 3 * SH_MAX);
743 }
744 else
745 {
748 }
749 }
750 for (int i = 0; i < LPV_SLOTS; i++)
751 {
752 if (undo->special_bytes[i])
753 {
754 free(undo->special_bytes[i]);
755 }
756 }
757
758 free(undo->special_bytes);
759 undo->special_bytes = NULL;
760 undo->special_count = 0;
761 undo->byte_size = 0;
762
764
765 break;
767 size_t total_bytes = sizeof(uint8_t*) * LPV_SLOTS;
768 for (int i = 0; i < LPV_SLOTS; i++)
769 {
770 if (undo->special_bytes[i])
771 {
772 free(undo->special_bytes[i]);
773 }
775 {
776
777 size_t size = sizeof(float) * LPV_PADDED_COUNT * 3 * SH_MAX;
778 undo->special_bytes[i] = malloc(size);
780 total_bytes += size;
781
782 }
783 else
784 {
785 undo->special_bytes[i] = NULL;
786 }
787 }
788
795
796 undo->special_count = 6;
797 undo->byte_size = total_bytes;
798
800
801 break;
803
804 uint8_t * temp_b0 = malloc(sizeof(mat3));
805 uint8_t * temp_b1 = malloc(sizeof(vec3));
806
807 memcpy(temp_b0, (uint8_t*)pv + undo->byte_offset, sizeof(mat3));
808
810
811 memcpy(temp_b1, &obbaxis, sizeof(vec3));
812
813 memcpy((uint8_t*)pv + undo->byte_offset, undo->special_bytes[0], sizeof(mat3));
814 vec3 * axis_angle = (vec3*)undo->special_bytes[1];
815 EDITOR_SETTINGS.obb_axis_x_angle = axis_angle->x;
816 EDITOR_SETTINGS.obb_axis_y_angle = axis_angle->y;
817 EDITOR_SETTINGS.obb_axis_z_angle = axis_angle->z;
818
819 free(undo->special_bytes[0]);
820 free(undo->special_bytes[1]);
821
822 undo->special_bytes[0] = temp_b0;
823 undo->special_bytes[1] = temp_b1;
824
825 break;
827
828 {
829
830 temp[0] = undo->structure.ids[0];
833 memcpy(pv, undo->special_bytes[0], sizeof(ProbeVolume));
835
836 free(undo->special_bytes[0]);
837 free(undo->special_bytes);
838 undo->special_bytes = NULL;
839 undo->special_count = 0;
840 undo->byte_size = 0;
841 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
843 }
844
845 break;
847 {
848
849 temp[0] = undo->structure.ids[0];
850 temp[1] = pv->byte_offset;
851 temp[2] = pv->size;
852 pv->byte_offset = undo->structure.ids[1];
853 pv->size = undo->structure.ids[2];
854 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
855
856 }
857 break;
858 default:
859 break;
860 }
861}
862
864{
866 ProbeVolume * pv = &pvs[undo->structure.ids[0]];
867 int temp[8];
868 switch(undo->structure.special)
869 {
870 case UNDOSPECIAL_NONE:
871 execute_non_special_undo(undo, (uint8_t*)pv);
872 break;
873
875 {
876
877 uint8_t ** bytes = malloc(sizeof(uint8_t*));
878 bytes[0] = malloc(sizeof(ProbeVolume));
879 memcpy(bytes[0], pv, sizeof(ProbeVolume));
880
881
883 temp[0] = undo->structure.ids[0];
886 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
887 undo->special_bytes = bytes;
888 undo->special_count = 1;
889 undo->byte_size = sizeof(uint8_t*) + sizeof(ProbeVolume);
891 }
892 break;
893
895
896 {
897
898 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
899 bytes[0] = malloc(sizeof(size_t));
900 bytes[1] = malloc(sizeof(size_t));
901 *((size_t*)bytes[0]) = pv->byte_offset;
902 *((size_t*)bytes[1]) = pv->size;
903
904 pv->byte_offset = *(size_t*)undo->special_bytes[0];
905 pv->size = *(size_t*)undo->special_bytes[1];
907 undo->byte_size = sizeof(uint8_t*) + sizeof(size_t) * 2;
908 undo->special_count = 2;
909 undo->special_bytes = bytes;
910
911 }
912
913 break;
915 {
916
917 temp[0] = undo->structure.ids[0];
920 memcpy(pv, undo->special_bytes[0], sizeof(ProbeVolume));
922
923 free(undo->special_bytes[0]);
924 free(undo->special_bytes);
925 undo->special_bytes = NULL;
926 undo->special_count = 0;
927 undo->byte_size = 0;
928 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
930
931 }
932 break;
934
935 uint8_t * temp_b0 = malloc(sizeof(mat3));
936 uint8_t * temp_b1 = malloc(sizeof(vec3));
937
938 memcpy(temp_b0, (uint8_t*)pv + undo->byte_offset, sizeof(mat3));
939
941
942 memcpy(temp_b1, &obbaxis, sizeof(vec3));
943
944
945 memcpy((uint8_t*)pv + undo->byte_offset, undo->special_bytes[0], sizeof(mat3));
946 vec3 * axis_angle = (vec3*)undo->special_bytes[1];
947 EDITOR_SETTINGS.obb_axis_x_angle = axis_angle->x;
948 EDITOR_SETTINGS.obb_axis_y_angle = axis_angle->y;
949 EDITOR_SETTINGS.obb_axis_z_angle = axis_angle->z;
950
951 free(undo->special_bytes[0]);
952 free(undo->special_bytes[1]);
953
954 undo->special_bytes[0] = temp_b0;
955 undo->special_bytes[1] = temp_b1;
956
957 break;
958 default:
959 break;
960 }
961}
962
963
965{
966
967 AudioEmitter * e = &AUDIO_EMITTERS[undo->structure.ids[0]];
968 int temp[8];
969 switch(undo->structure.special)
970 {
971 case UNDOSPECIAL_NONE:
972 execute_non_special_undo(undo, (uint8_t*)e);
973 break;
975 destroy_emitter(undo->structure.ids[0]);
976
977 temp[0] = undo->structure.ids[0];
980 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
982 break;
984 load_emitter(e, e->path, e->is_loop, e->is_occludable, e->base_volume);
985 e->free = false;
989 break;
991 load_emitter(e, e->path, e->is_loop, e->is_occludable, e->base_volume);
993 break;
995 unload_emitter(undo->structure.ids[0]);
997 break;
999 end_emitter(e);
1001 break;
1003 play_emitter(e, e->pos);
1005 break;
1006 default:
1007 break;
1008 }
1009
1010}
1011
1012
1014{
1016 AudioPortal * apv = &apvs[undo->structure.ids[0]];
1017 switch(undo->structure.special)
1018 {
1019 case UNDOSPECIAL_NONE:
1020 execute_non_special_undo(undo, (uint8_t*)apv);
1021 break;
1022 case UNDOAPORTAL_SPAWN:
1023
1024 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
1025 bytes[0] = malloc(sizeof(AudioPortal));
1026 bytes[1] = malloc(sizeof(int) * apv->adjacent_portals.count);
1027 memcpy(bytes[0], apv, sizeof(AudioPortal));
1028 memcpy(bytes[1], apv->adjacent_portals.buffer, sizeof(int) * apv->adjacent_portals.count);
1029
1032
1033 undo->special_bytes = bytes;
1034 undo->special_count = 2;
1035 undo->byte_size = sizeof(uint8_t*) * 2 + sizeof(AudioPortal) + sizeof(int) * apv->adjacent_portals.count;
1036
1037
1038 break;
1039 case UNDOAPORTAL_DELETE:
1040
1042 memcpy(apv, undo->special_bytes[0], sizeof(AudioPortal));
1043 if (undo->special_bytes[1])
1044 {
1045 memcpy(apv->adjacent_portals.buffer, undo->special_bytes[1], sizeof(int) * apv->adjacent_portals.capacity);
1046 }
1048
1050
1051 break;
1052 default:
1053 break;
1054 }
1055
1056}
1057
1058
1060{
1061
1062 UIMenu * menus = CAST_VEC(MENUS, UIMenu);
1063 UIMenu * menu = &menus[undo->structure.ids[1]];
1064
1065 switch(undo->structure.special)
1066 {
1067 case UNDOSPECIAL_NONE:
1068 execute_non_special_undo(undo, (uint8_t*)menu);
1069 break;
1070 default:
1071 break;
1072 }
1073
1074}
1075
1077{
1078
1079 UIMenu * menus = CAST_VEC(MENUS, UIMenu);
1080 UIMenu * menu = &menus[undo->structure.ids[1]];
1081 UIElement * el = &menu->elements[undo->structure.ids[0]];
1082
1083 UIContainer * cs = menu->containers;
1084 int temp[8];
1085 switch(undo->structure.special)
1086 {
1087 case UNDOSPECIAL_NONE:
1088 execute_non_special_undo(undo, (uint8_t*)el);
1089 break;
1091 delete_ui_element(el->menu, el->uID);
1093 break;
1095 memcpy(el, undo->bytes, sizeof(UIElement));
1097 break;
1099
1100 if (undo->structure.ids[3] != -1)
1101 {
1102 remove_element_from_container(&cs[undo->structure.ids[3]], el);
1103 }
1104 if (undo->structure.ids[2] != -1)
1105 {
1106 assign_element_to_container(el, &cs[undo->structure.ids[2]]);
1107 }
1108 int s0 = undo->structure.ids[2];
1109 int s1 = undo->structure.ids[3];
1110 undo->structure.ids[2] = s1;
1111 undo->structure.ids[3] = s0;
1112
1113 break;
1115 assign_element_to_container(el, &cs[undo->structure.ids[2]]);
1117 break;
1119 remove_element_from_container(&cs[undo->structure.ids[2]], el);
1121 break;
1123
1124
1125 uint8_t ** bytes = malloc(sizeof(uint8_t*));
1126 size_t byte_size = sizeof(uint8_t*) + sizeof(UIContainer);
1127
1128 bytes[0] = malloc(sizeof(UIContainer));
1129 UIContainer * container = &cs[el->container];
1130 memcpy(bytes[0], container, sizeof(UIContainer));
1131
1132 temp[0] = undo->structure.ids[0];
1133 temp[1] = undo->structure.ids[1];
1134 temp[2] = el->container;
1135 temp[3] = undo->structure.ids[2];
1136
1138 if (undo->special_bytes[0])
1139 {
1140 UIContainer * c = &cs[undo->structure.ids[2]];
1141 memcpy(c, undo->special_bytes[0], sizeof(UIContainer));
1142 }
1143
1145 undo->special_bytes = bytes;
1146 undo->byte_size = byte_size;
1147 undo->special_count = 1;
1148 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
1149
1151
1152 break;
1154 {
1155
1156 UIContainer * c = &cs[undo->structure.ids[2]];
1157 memcpy(c, undo->special_bytes[0], sizeof(UIContainer));
1159
1160 temp[0] = undo->structure.ids[0];
1161 temp[1] = undo->structure.ids[1];
1162 temp[2] = el->container;
1163 temp[3] = undo->structure.ids[3];
1164 uint8_t ** bytes = NULL;
1165 size_t byte_size = 0;
1166 int special_count = 0;
1167 if (undo->structure.ids[3] != -1)
1168 {
1169
1170 UIContainer * del_container = &cs[undo->structure.ids[3]];
1171 bytes = malloc(sizeof(uint8_t*));
1172 bytes[0] = malloc(sizeof(UIContainer));
1173 memcpy(bytes[0], del_container, sizeof(UIContainer));
1174
1175 byte_size += sizeof(uint8_t*);
1176 byte_size += sizeof(UIContainer);
1177 special_count = 1;
1178
1179 delete_ui_container(&menu->elements[del_container->element]);
1180 }
1181
1183
1184 undo->special_bytes = bytes;
1185 undo->byte_size = byte_size;
1186 undo->special_count = special_count;
1188 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
1189
1190 }
1191 break;
1193 {
1194 if (undo->structure.ids[2] != -1)
1195 {
1196 TextBox * tb = &menu->text_boxes[undo->structure.ids[2]];
1197 memcpy(tb, undo->special_bytes[0], sizeof(TextBox));
1198 tb->text = malloc(sizeof(char) * tb->text_cap);
1199 memcpy(tb->text, undo->special_bytes[1], sizeof(char) * tb->text_cap);
1200 }
1201
1202 TextBox * tb = &menu->text_boxes[undo->structure.ids[3]];
1203 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
1204 bytes[0] = malloc(sizeof(TextBox));
1205 bytes[1] = malloc(sizeof(char) * tb->text_cap);
1206 memcpy(bytes[0], tb, sizeof(TextBox));
1207 memcpy(bytes[1], tb->text, sizeof(char) * tb->text_cap);
1208 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(TextBox) + sizeof(char) * tb->text_cap;
1209
1210 delete_text_box(menu->uID, undo->structure.ids[3]);
1211 el->as.label.box = undo->structure.ids[2];
1213
1215 temp[0] = undo->structure.ids[0];
1216 temp[1] = undo->structure.ids[1];
1217 temp[2] = undo->structure.ids[3];
1218 temp[3] = undo->structure.ids[2];
1219
1220 undo->special_bytes = bytes;
1221 undo->byte_size = byte_size;
1222 undo->special_count = 2;
1223
1224 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
1225
1226 }
1227
1228
1229 break;
1231 {
1232
1233 int s0 = el->as.label.align;
1234 el->as.label.align = undo->structure.ids[2];
1235
1237 undo->structure.ids[2] = s0;
1238 }
1239 break;
1240 default:
1241 break;
1242 }
1243
1244}
1245
1247{
1248
1249 UIMenu * menus = CAST_VEC(MENUS, UIMenu);
1250 UIMenu * menu = &menus[undo->structure.ids[1]];
1251
1252 UIContainer * cs = menu->containers;
1253 UIContainer * c = &cs[undo->structure.ids[2]];
1254
1255 int temp[8];
1256 switch(undo->structure.special)
1257 {
1258 case UNDOSPECIAL_NONE:
1259 execute_non_special_undo(undo, (uint8_t*)c);
1260 break;
1262 if (undo->structure.ids[3] != -1)
1263 {
1264 UIElement * old_scrollbar = &menu->elements[undo->structure.ids[3]];
1265 old_scrollbar->as.slider.container = undo->structure.ids[2];
1266 }
1267 if (undo->structure.ids[4] != -1)
1268 {
1269
1270 UIElement * new_element = &menu->elements[undo->structure.ids[4]];
1271 new_element->as.slider.container = undo->structure.ids[5];
1272 }
1273 if (undo->structure.ids[2] != -1)
1274 {
1275 c->scrollbar = undo->structure.ids[3];
1276 }
1277 if (undo->structure.ids[5] != -1)
1278 {
1279 cs[undo->structure.ids[5]].scrollbar = undo->structure.ids[4];
1280 }
1281
1282 temp[0] = undo->structure.ids[0];
1283 temp[1] = undo->structure.ids[1];
1284 temp[2] = undo->structure.ids[2];
1285 temp[3] = undo->structure.ids[4];
1286 temp[4] = undo->structure.ids[3];
1287 temp[5] = undo->structure.ids[6];
1288 temp[6] = undo->structure.ids[5];
1289
1290 memcpy(undo->structure.ids, temp, sizeof(int) * 8);
1291
1292 break;
1293 default:
1294 break;
1295 }
1296}
1297
1299{
1300
1301 UIMenu * menus = CAST_VEC(MENUS, UIMenu);
1302 UIMenu * menu = &menus[undo->structure.ids[1]];
1303
1304 TextBox * tbs = menu->text_boxes;
1305 TextBox * tb = &tbs[undo->structure.ids[0]];
1306 UIContainer * cs = menu->containers;
1307 int temp[8];
1308 switch(undo->structure.special)
1309 {
1310 case UNDOSPECIAL_NONE:
1311 execute_non_special_undo(undo, (uint8_t*)tb);
1312 break;
1314
1315 {
1316
1317 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
1318 bytes[0] = malloc(sizeof(TextBox));
1319 bytes[1] = malloc(sizeof(char) * tb->text_cap);
1320
1321 memcpy(bytes[0], tb, sizeof(TextBox));
1322 memcpy(bytes[1], tb->text, sizeof(char) * tb->text_cap);
1323 size_t byte_size = sizeof(TextBox) + sizeof(uint8_t*) * 2 + sizeof(char) * tb->text_cap;
1324
1325
1326 delete_text_box(undo->structure.ids[1], undo->structure.ids[0]);
1327
1330
1331
1333
1334 undo->special_bytes = bytes;
1335 undo->special_count = 2;
1336 undo->byte_size = byte_size;
1337
1338
1339
1340 }
1341
1342 break;
1344
1345 if (tb->text) free(tb->text);
1346 memcpy(tb, undo->special_bytes[0], sizeof(TextBox));
1347 tb->text = malloc(sizeof(char) * tb->text_cap);
1348 memcpy(tb->text, undo->special_bytes[1], sizeof(char) * tb->text_cap);
1351
1353
1354 break;
1356
1357 {
1358
1359 uint8_t ** bytes = NULL;
1360 size_t byte_size = 0;
1361 int byte_count = 0;
1362
1363 int text_cap = tb->text_cap;
1364 if (tb->text)
1365 {
1366 bytes = malloc(sizeof(uint8_t*));
1367 bytes[0] = malloc(sizeof(char) * tb->text_cap);
1368 byte_size += sizeof(uint8_t*) + sizeof(char) * tb->text_cap;
1369 byte_count = 1;
1370 memcpy(bytes[0], tb->text, sizeof(char) * tb->text_cap);
1371
1372 free(tb->text);
1373 tb->text_cap = 0;
1374 tb->text = NULL;
1375 }
1376 if (undo->special_count > 0)
1377 {
1378 tb->text_cap = undo->structure.ids[2];
1379 tb->text = malloc(sizeof(char) * tb->text_cap);
1380 memcpy(tb->text, undo->special_bytes[0], sizeof(char) * tb->text_cap);
1381 }
1382
1384 undo->special_bytes = bytes;
1385 undo->special_count = byte_count;
1386 undo->byte_size = byte_size;
1387 undo->structure.ids[2] = text_cap;
1388
1390 }
1391
1392 break;
1394 if (undo->structure.ids[2] != -1)
1395 {
1396 remove_text_box_from_container(&cs[undo->structure.ids[2]], tb);
1397 }
1398 if (undo->structure.ids[3] != -1)
1399 {
1400 assign_text_box_to_container(tb, &cs[undo->structure.ids[3]]);
1401 }
1402 tb->parent_container = undo->structure.ids[3];
1403 int s0 = undo->structure.ids[2];
1404 int s1 = undo->structure.ids[3];
1405 undo->structure.ids[2] = s1;
1406 undo->structure.ids[3] = s0;
1407
1408 break;
1409
1411 assign_text_box_to_container(tb, &cs[undo->structure.ids[2]]);
1412 break;
1414 remove_text_box_from_container(&cs[undo->structure.ids[2]], tb);
1415 break;
1416
1417 default:
1418 break;
1419
1420
1421 }
1422
1423
1424}
1425
1427{
1428
1429 AssetInstance * AI = &ASSET_INSTANCES[undo->structure.ids[0]];
1430 int temp[8];
1431 switch(undo->structure.special)
1432 {
1433 case UNDOSPECIAL_NONE:
1434 execute_non_special_undo(undo, (uint8_t*)AI);
1435 break;
1437 {
1438
1439 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 3);
1440 bytes[0] = malloc(sizeof(float));
1441 bytes[1] = malloc(sizeof(mat4));
1442 bytes[2] = malloc(sizeof(vec3));
1443 memcpy(bytes[0], &EDITOR_SETTINGS.rotation_angle, sizeof(float));
1444 memcpy(bytes[1], &AI->model, sizeof(mat4));
1445 memcpy(bytes[2], &AI->rot, sizeof(vec3));
1446
1447 memcpy(&EDITOR_SETTINGS.rotation_angle, undo->special_bytes[0], sizeof(float));
1448 memcpy(&AI->model, undo->special_bytes[1], sizeof(mat4));
1449 memcpy(&AI->rot, undo->special_bytes[2], sizeof(vec3));
1450
1451 free(undo->special_bytes[0]);
1452 free(undo->special_bytes[1]);
1453 free(undo->special_bytes[2]);
1454 free(undo->special_bytes);
1455 undo->special_bytes = bytes;
1456 AI->model = compose_trs_from_vectors(AI->tr, AI->rot, AI->scale);
1457
1458 }
1459 break;
1461 execute_non_special_undo(undo, (uint8_t*)AI);
1462 AI->model = compose_trs_from_vectors(AI->tr, AI->rot, AI->scale);
1463 break;
1464 default:
1465 break;
1466 }
1467
1468}
1469
1471{
1472
1474 MeshNode * mn = &mns[undo->structure.ids[0]];
1475 Mesh * meshes = CAST_VEC(GLOBALS.meshes, Mesh);
1476 int temp[8];
1477 switch(undo->structure.special)
1478 {
1479 case UNDOSPECIAL_NONE:
1480 execute_non_special_undo(undo, (uint8_t*)mn);
1481 break;
1483 {
1484
1485 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 3);
1486 bytes[0] = malloc(sizeof(float));
1487 bytes[1] = malloc(sizeof(mat4));
1488 bytes[2] = malloc(sizeof(vec3));
1489 memcpy(bytes[0], &EDITOR_SETTINGS.rotation_angle, sizeof(float));
1490 memcpy(bytes[1], &mn->global_matrix, sizeof(mat4));
1491 memcpy(bytes[2], &mn->rotation, sizeof(vec3));
1492
1493 memcpy(&EDITOR_SETTINGS.rotation_angle, undo->special_bytes[0], sizeof(float));
1494 memcpy(&mn->global_matrix, undo->special_bytes[1], sizeof(mat4));
1495 memcpy(&mn->rotation, undo->special_bytes[2], sizeof(vec3));
1496
1497 free(undo->special_bytes[0]);
1498 free(undo->special_bytes[1]);
1499 free(undo->special_bytes[2]);
1500 free(undo->special_bytes);
1501 undo->special_bytes = bytes;
1502
1503 }
1504 break;
1505 case UNDOMN_MAT:
1506 execute_non_special_undo(undo, (uint8_t*)mn);
1507 mn->global_matrix = compose_trs_from_mesh_node(mn);
1508 break;
1510 {
1511 Mesh * m = &meshes[mn->mesh];
1512
1513 SubMesh * sms = CAST_VEC(m->submeshes, SubMesh);
1514 SubMesh * sm = &sms[undo->structure.ids[1]];
1515 int temp = sm->material;
1516 sm->material = undo->structure.ids[2];
1517 undo->structure.ids[2] = temp;
1518
1519
1520 draw_dirty = true;
1521 }
1522
1523 break;
1524 default:
1525 break;
1526 }
1527
1528}
1529
1530void execute_undo(Undo * undo)
1531{
1532
1533 switch(undo->structure.type)
1534 {
1535 case UNDOSTRUCT_MENU:
1537 break;
1540 break;
1541 case UNDOSTRUCT_TEXTBOX:
1543 break;
1546 break;
1548 break;
1549 case UNDOSTRUCT_ENTITY:
1550 break;
1551 case UNDOSTRUCT_MN:
1553 break;
1556 break;
1557 case UNDOSTRUCT_GLOBAL:
1559 break;
1560 case UNDOSTRUCT_LIGHT:
1561 execute_light_undo(undo);
1562 break;
1563 case UNDOSTRUCT_RPROBE:
1564 execute_rprobe_undo(undo);
1565 break;
1566 case UNDOSTRUCT_LPROBE:
1567 execute_lprobe_undo(undo);
1568 break;
1569 case UNDOSTRUCT_APROBE:
1570 execute_aprobe_undo(undo);
1571 break;
1572 case UNDOSTRUCT_APORTAL:
1574 break;
1577 break;
1580 break;
1581 default:
1582 break;
1583 }
1584
1585
1586}
1587
1588
1589
1590void store_into_nkslider(NKSlider * s, void * bytes, size_t byte_size)
1591{
1592
1593 memcpy(s->bytes, bytes, byte_size);
1594 s->byte_size = byte_size;
1595
1596}
1597
1598
1599
1600static const char QUERY_NAMES[PQUERY_MAX][256]
1601=
1602{
1603 "Cull",
1604 "Point Light Shadows",
1605 "Shadowmap",
1606 "GBuffer",
1607 "Depth of Field",
1608 "SSAO",
1609 "TAA",
1610 "SSR",
1611 "Bloom",
1612 "Render",
1613 "Postprocessing",
1614};
1615
1617{
1618
1619 UIMenu * ms = CAST_VEC(MENUS, UIMenu);
1621 TextBox * boxes = m->text_boxes;
1622 int query = 0;
1623
1624 double full_time = 0.0f;
1626 {
1627 TextBox * box = &boxes[i];
1628
1629
1630 box->visible = !box->visible;
1631 }
1632}
1633
1634
1636{
1637
1638 UIMenu * ms = CAST_VEC(MENUS, UIMenu);
1640 TextBox * boxes = m->text_boxes;
1641 int query = 0;
1643
1644 sprintf(box->text, "Performance Overlay");
1645
1647
1648 double full_time = 0.0f;
1650 {
1651
1652 TextBox * box = &boxes[i];
1653
1654 double time = query_s[query] / 1e6;
1655 full_time += time;
1656 sprintf(box->text, "%s: %.3f", QUERY_NAMES[query], time);
1658
1659
1660 query++;
1661 }
1663
1664 sprintf(end->text, "Frame Time: %.3f (%.3f FPS)", full_time, 1000.0f/full_time);
1666
1667
1668
1670
1671}
1672
1673
1675{
1676
1677 vec2 translation = (vec2){0,0};
1679
1680 UIMenu * menu = create_menu();
1682
1683 TextBox * boxes = menu->text_boxes;
1684
1685 for (int i = 0; i < PERFORMANCE_OVERLAY_TEXT_BOX_COUNT; i++)
1686 {
1687
1688 TextBox * tb_title = &boxes[i];
1689
1690 *tb_title = DEFAULT_TEXT_BOX;
1691 tb_title->uID = i;
1692 tb_title->translation = translation;
1693 tb_title->text = malloc(256 * sizeof(char));
1694 tb_title->text_cap = 256;
1695 tb_title->text[0] = '\0';
1696 tb_title->justify = JUSTIFY_LEFT;
1697 tb_title->menu = menu->uID;
1698 tb_title->visible = true;
1699 tb_title->free = false;
1700
1701 move_text_box_to_origin(tb_title);
1702
1703 translation.y += 40;
1704
1705 }
1706
1707
1708
1709}
1710
1711// a is src, b is the potentially modified value
1712bool nk_check_equivalency(void * a, void * b, size_t byte_size, NKSlider * s, bool * dirty)
1713{
1714 bool push_undo = false;
1715 // if a != b, we are sliding
1716 if (memcmp(a, b, byte_size) != 0)
1717 {
1718 // if we were not yet sliding, store the value
1719 if (!s->is_held)
1720 {
1721 s->byte_size = byte_size;
1722 memcpy(s->bytes, a, byte_size);
1723 }
1724 // now we are sliding
1725 s->is_held = true;
1726 // if we need to store dirty state
1727 if (dirty != NULL)
1728 {
1729 *dirty = true;
1730 }
1731 // change a to b
1732 memcpy(a, b, byte_size);
1733 // if we have a new action, the redo history is reset
1735 }
1736 else
1737 {
1738 // if we were held and now we have stopped, signal to push the undo
1739 if (s->is_held)
1740 {
1741 push_undo = true;
1742 }
1743 s->is_held = false;
1744 }
1745 return push_undo;
1746}
1747
1748bool check_equivalencyv3(vec3 * a, vec3 b, NKSlider * s, bool * dirty)
1749{
1750
1751 bool push_undo = false;
1752 if (!vec3_equal(*a, b, 1e-6))
1753 {
1754 if (!s->is_held)
1755 {
1756 s->byte_size = sizeof(vec3);
1757 memcpy(s->bytes, a, sizeof(vec3));
1758 }
1759 s->is_held = true;
1760 if (dirty != NULL)
1761 {
1762 *dirty = true;
1763 }
1764 *a = b;
1766 }
1767 else
1768 {
1769 if (s->is_held)
1770 {
1771 // push onto undo stack
1772 push_undo = true;
1773 }
1774 s->is_held = false;
1775 }
1776 return push_undo;
1777}
1778bool check_equivalencyv4(vec4 * a, vec4 b, NKSlider * s, bool * dirty)
1779{
1780
1781 bool push_undo = false;
1782 if (!vec4_equal(*a, b, 1e-6))
1783 {
1784 if (!s->is_held)
1785 {
1786 s->byte_size = sizeof(vec4);
1787 memcpy(s->bytes, a, sizeof(vec4));
1788 push_undo = true;
1789 }
1790 s->is_held = true;
1791 if (dirty != NULL)
1792 {
1793 *dirty = true;
1794 }
1795 *a = b;
1797 }
1798 else
1799 {
1800 s->is_held = false;
1801 }
1802 return push_undo;
1803}
1804
1805bool check_equivalencyf(float * a, float b, NKSlider * s, bool * dirty)
1806{
1807 bool push_undo = false;
1808 if (*a != b)
1809 {
1810 if (!s->is_held)
1811 {
1812 s->byte_size = sizeof(float);
1813 memcpy(s->bytes, a, sizeof(float));
1814 push_undo = true;
1815 }
1816 s->is_held = true;
1817 if (dirty != NULL)
1818 {
1819 *dirty = true;
1820 }
1821 *a = b;
1823 }
1824 else
1825 {
1826 s->is_held = false;
1827 }
1828 return push_undo;
1829}
1830bool check_equivalencyi(int * a, int b, NKSlider * s, bool * dirty)
1831{
1832 bool push_undo = false;
1833 if (*a != b)
1834 {
1835 if (!s->is_held)
1836 {
1837 s->byte_size = sizeof(int);
1838 memcpy(s->bytes, a, sizeof(int));
1839 push_undo = true;
1840 }
1841 s->is_held = true;
1842 if (dirty != NULL)
1843 {
1844 *dirty = true;
1845 }
1846 *a = b;
1848 }
1849 else
1850 {
1851 s->is_held = false;
1852 }
1853
1854 return push_undo;
1855}
1856
1857
1859{
1860
1861 init_vector(&scene_registry.names, 0, sizeof(char) * 256);
1863 sprintf(scene_registry.directory, "./scenes/");
1865 scene_registry.open = nk_false;
1866
1867 init_vector(&lightmap_registry.names, 0, sizeof(char) * 256);
1869 sprintf(lightmap_registry.directory, "./lightmaps/");
1871 lightmap_registry.open = nk_false;
1872
1873 init_vector(&light_registry.names, 0, sizeof(char) * 256);
1875 sprintf(light_registry.directory, "./lights/");
1877 light_registry.open = nk_false;
1878
1879 init_vector(&sound_registry.names, 0, sizeof(char) * 256);
1881 sprintf(sound_registry.directory, "./sounds/");
1883 sound_registry.open = nk_false;
1884
1885 init_vector(&aportal_registry.names, 0, sizeof(char) * 256);
1887 sprintf(aportal_registry.directory, "./aportals/");
1889 aportal_registry.open = nk_false;
1890
1891 init_vector(&rprobe_registry.names, 0, sizeof(char) * 256);
1893 sprintf(rprobe_registry.directory, "./rprobes/");
1895 rprobe_registry.open = nk_false;
1896
1897 init_vector(&lprobe_registry.names, 0, sizeof(char) * 256);
1899 sprintf(lprobe_registry.directory, "./lprobes/");
1901 lprobe_registry.open = nk_false;
1902
1903 init_vector(&aprobe_registry.names, 0, sizeof(char) * 256);
1905 sprintf(aprobe_registry.directory, "./aprobes/");
1907 aprobe_registry.open = nk_false;
1908
1909 init_vector(&scene_apv_registry.names, 0, sizeof(char) * 256);
1911 sprintf(scene_apv_registry.directory, "./scene_apvs/");
1913 scene_apv_registry.open = nk_false;
1914
1915 init_vector(&scene_lpv_registry.names, 0, sizeof(char) * 256);
1917 sprintf(scene_lpv_registry.directory, "./scene_lpvs/");
1919 scene_lpv_registry.open = nk_false;
1920
1921 init_vector(&ui_registry.names, 0, sizeof(char) * 256);
1922 ui_registry.search_suffix = false;
1923 sprintf(ui_registry.directory, "./ui/");
1925 ui_registry.open = nk_false;
1926}
1927
1928
1930{
1931 WIN32_FIND_DATAA find_data;
1932 char search_path[MAX_PATH];
1933 snprintf(search_path, sizeof(search_path), "%s\\*", registry->directory);
1934
1935 HANDLE hFind = FindFirstFileA(search_path, &find_data);
1936 if (hFind == INVALID_HANDLE_VALUE) return;
1937
1938 registry->names.count = 0;
1939
1940 do {
1941 if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
1942
1943 if (registry->search_suffix)
1944 {
1945 // may have no null terminator
1946 if (strstr(find_data.cFileName, registry->suffix))
1947 {
1948 char * name = vector_expand(&registry->names, 1);
1949 strncpy(name, find_data.cFileName, 254);
1950 name[255] = '\0';
1951 }
1952 }
1953 else
1954 {
1955 char * name = vector_expand(&registry->names, 1);
1956 strncpy(name, find_data.cFileName, 254);
1957 name[255] = '\0';
1958 }
1959 }
1960 } while (FindNextFileA(hFind, &find_data));
1961
1962 FindClose(hFind);
1963
1964}
1965
1966void load_rprobe_filenames(const char *folder_path) {
1967
1968 WIN32_FIND_DATAA find_data;
1969 char search_path[MAX_PATH];
1970 snprintf(search_path, sizeof(search_path), "%s\\*", folder_path);
1971
1972 HANDLE hFind = FindFirstFileA(search_path, &find_data);
1973 if (hFind == INVALID_HANDLE_VALUE) return;
1974
1976
1977 do {
1978 if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
1979 strncpy(rprobe_names[rprobe_names_count], find_data.cFileName, 255);
1981 }
1982 } while (FindNextFileA(hFind, &find_data));
1983
1984 FindClose(hFind);
1985}
1986
1987void load_gltf_filenames(const char *folder_path) {
1988
1989 WIN32_FIND_DATAA find_data;
1990 char search_path[MAX_PATH];
1991 snprintf(search_path, sizeof(search_path), "%s\\*", folder_path);
1992
1993 HANDLE hFind = FindFirstFileA(search_path, &find_data);
1994 if (hFind == INVALID_HANDLE_VALUE) return;
1995
1996 gltf_names_count = 0;
1997
1998 do {
1999 if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
2000 if (strstr(find_data.cFileName, "gltf"))
2001 {
2002 strncpy(gltf_names[gltf_names_count], find_data.cFileName, 254);
2003 gltf_names[gltf_names_count][255] = '\0';
2005 }
2006 }
2007 } while (FindNextFileA(hFind, &find_data));
2008
2009 FindClose(hFind);
2010}
2011
2012
2013
2014
2015
2016
2017
2018nk_bool gltf_file_names_open = nk_false;
2019nk_bool rprobe_file_names_open = nk_false;
2020
2021const char target_types[4][256] =
2022{
2023 "FLT",
2024 "V3",
2025 "INT",
2026 "BOOL"
2027};
2029{
2030
2031 if
2032 (
2033 nk_begin
2034 (
2035 NK_CTX,
2037 nk_rect(420, SCREEN_HEIGHT - 320, SCREEN_WIDTH - 420 * 2, 300),
2038 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
2039 )
2040 )
2041 {
2042 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
2043 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
2045 nk_layout_row_dynamic(NK_CTX, 20, 1);
2046 PhysicsComponent * pc = NULL;
2047 AnimationComponent * ac = NULL;
2048
2049
2050 nk_layout_row_dynamic(NK_CTX, 20, 1);
2051 char sk[256];
2052 sprintf(sk, "Skin: %d", ent->skin);
2053 nk_label(NK_CTX, sk, NK_TEXT_ALIGN_LEFT);
2054
2055 if (nk_button_label(NK_CTX, "Player Interact"))
2056 {
2057
2058 if (ent->state)
2059 {
2060 ent->state->fn[ESTATE_PLAYER_INTERACT](ent);
2061 }
2062
2063 }
2064
2065
2066 if (ent->pc)
2067 {
2068 pc = ent->pc;
2069
2070 }
2071
2072 // possibly aabb controls
2073
2074 if (ent->ac)
2075 {
2076 ac = ent->ac;
2077 }
2078
2079 if (pc)
2080 {
2081 if (!pc->free)
2082 {
2083
2084 nk_layout_row_dynamic(NK_CTX, 20, 1);
2085 nk_label(NK_CTX, "PC Menu", NK_TEXT_ALIGN_LEFT);
2086
2087 bool pc_dirty = false;
2088
2089 nk_layout_row_dynamic(NK_CTX, 20, 3);
2090 float mass = nk_propertyf(NK_CTX, "Mass", 0.0f, pc->mass, 10000.0f, 0.01f, 0.01f);
2091 if (mass != pc->mass)
2092 {
2093 pc_dirty = true;
2094 pc->mass = mass;
2095 }
2096 float restitution = nk_propertyf(NK_CTX, "Restitution", 0.0f, pc->restitution, 20.0f, 0.005f, 0.005f);
2097 if (restitution != pc->restitution)
2098 {
2099 pc->restitution= restitution;
2100 }
2101 float mu = nk_propertyf(NK_CTX, "Mu", 0, pc->mu, 20.0f, 0.005f, 0.005f);
2102 if (mu != pc->mu)
2103 {
2104 pc->mu= mu;
2105 }
2106 if (pc_dirty)
2107 {
2109 }
2110
2111 if (nk_button_label(NK_CTX, "Delete PC"))
2112 {
2113 pc->free = true;
2114 }
2115
2116 }
2117
2118 }
2119 else
2120 {
2121
2122 if (nk_button_label(NK_CTX, "Create PC"))
2123 {
2124
2126 }
2127 }
2128
2129 if (ac)
2130 {
2131 if (!ac->free)
2132 {
2133
2134 nk_layout_row_dynamic(NK_CTX, 20, 1);
2135 nk_label(NK_CTX, "AC Menu", NK_TEXT_ALIGN_LEFT);
2136 char tracks[256];
2137 sprintf(tracks, "Tracks: %d", ac->track_count);
2138 nk_label(NK_CTX, tracks, NK_TEXT_ALIGN_LEFT);
2139
2140 for (int i = 0; i < ac->track_count; i++)
2141 {
2142 AnimationTrack * t = &ac->tracks[i];
2143 char keyframe[256];
2144 sprintf(keyframe, "Keyframes t%d: %d", i, t->kf_count);
2145 nk_label(NK_CTX, keyframe, NK_TEXT_ALIGN_LEFT);
2146
2147
2148 for (int j = 0; j < t->kf_count; j++)
2149 {
2150 AnimationKeyframe * kf = &t->kf[j];
2151 char time[256];
2152 sprintf(time, "Time k%d", j);
2153 float new_time = nk_propertyf(NK_CTX, time, 0.01f, kf->time, 10000, 0.01f, 0.01f);
2154 if (new_time != kf->time)
2155 {
2156 kf->time = new_time;
2157 }
2158
2159
2160 switch(t->type)
2161 {
2162 case ANIM_TARGET_FLOAT:
2163
2164 char tg[256];
2165 sprintf(tg, "Flt t%d k%d", i, j);
2166 float new_val = nk_propertyf(NK_CTX, tg, -10000.0f, kf->val.v, 10000, 0.01f, 0.01f);
2167 if (new_val != kf->val.v)
2168 {
2169 kf->val.v = new_val;
2170 }
2171
2172 break;
2173 case ANIM_TARGET_VEC3:
2174 char tgx[256];
2175 sprintf(tgx, "x t%d k%d", i, j);
2176 float new_x = nk_propertyf(NK_CTX, tgx, -10000.0f, kf->val.v3.x, 10000, 0.01f, 0.01f);
2177 if (new_x != kf->val.v3.x)
2178 {
2179 kf->val.v3.x = new_x;
2180 }
2181 char tgy[256];
2182 sprintf(tgy, "y t%d k%d", i, j);
2183 float new_y = nk_propertyf(NK_CTX, tgy, -10000.0f, kf->val.v3.y, 10000, 0.01f, 0.01f);
2184 if (new_y != kf->val.v3.y)
2185 {
2186 kf->val.v3.y = new_y;
2187 }
2188 char tgz[256];
2189 sprintf(tgz, "z t%d k%d", i, j);
2190 float new_z = nk_propertyf(NK_CTX, tgz, -10000.0f, kf->val.v3.z, 10000, 0.01f, 0.01f);
2191 if (new_z != kf->val.v3.z)
2192 {
2193 kf->val.v3.z = new_z;
2194 }
2195 break;
2196 case ANIM_TARGET_INT:
2197 char it[256];
2198 sprintf(it, "Int t%d k%d", i, j);
2199 int new_i = nk_propertyi(NK_CTX, it, -10000, kf->val.i, 10000, 1, 1);
2200 if (new_i != kf->val.i)
2201 {
2202 kf->val.i = new_i;
2203 }
2204 break;
2205 case ANIM_TARGET_BOOL:
2206 break;
2207 default:
2208 break;
2209 }
2210
2211 }
2212 char dr[256];
2213 sprintf(dr, "Duration t%d", i);
2214 float new_duration = nk_propertyf(NK_CTX, dr, 0.01f, t->duration, 10000, 0.01f, 0.01f);
2215 if (new_duration != t->duration)
2216 {
2217 t->duration = new_duration;
2218 }
2219
2220 char lp[256];
2221 sprintf(lp, "Loop t%d", i);
2222 nk_bool looper = t->loop == 1;
2223 if (nk_checkbox_label(NK_CTX, lp, &looper))
2224 {
2225 t->loop = looper;
2226 }
2227 char act[256];
2228 sprintf(act, "Active t%d", i);
2229 nk_bool acter = t->active == 1;
2230 if (nk_checkbox_label(NK_CTX, act, &acter))
2231 {
2232 t->active = acter;
2233 }
2234
2235 char target_type[256];
2236 sprintf(target_type, "Type t%d: %s", i, target_types[t->type]);
2237
2238 if (nk_button_label(NK_CTX, target_type))
2239 {
2240 t->type = (t->type + 1) % ANIM_TARGET_MAX;
2241 }
2242
2243
2244
2245 char add[256];
2246 sprintf(add, "Add t%d KF", i);
2247 if (nk_button_label(NK_CTX, add))
2248 {
2249 t->kf_count++;
2250 }
2251 char rm[256];
2252 sprintf(rm, "Remove Track t%d", i);
2253 if (nk_button_label(NK_CTX, rm))
2254 {
2255
2256 for (int j = i; j < ac->track_count-1; j++)
2257 {
2258 ac->tracks[j] = ac->tracks[j+1];
2259 for (int k = 0; k < ac->tracks[j+1].kf_count; k++)
2260 {
2261 ac->tracks[j].kf[k] = ac->tracks[j+1].kf[k];
2262 }
2263 }
2264
2265 ac->track_count--;
2266 }
2267
2268
2269 }
2270
2271 if (nk_button_label(NK_CTX, "Add Track"))
2272 {
2273 ac->track_count++;
2274 }
2275 if (nk_button_label(NK_CTX, "Delete AC"))
2276 {
2277 ac->free = true;
2278 }
2279
2280
2281 }
2282
2283
2284 }
2285 else
2286 {
2287
2288 if (nk_button_label(NK_CTX, "Create AC"))
2289 {
2290
2292 }
2293
2294 }
2295
2296
2297
2298 }
2299 nk_end(NK_CTX);
2300
2301}
2302
2303
2304
2305
2306const char menu_names[][256]
2307=
2308{
2309 "Main",
2310 "Mesh Node",
2311 "Material",
2312 "Light Menu",
2313 "Entity Menu",
2314 "Text Menu",
2315 "UI Menu",
2316 "Audio Menu",
2317 "LProbe Menu",
2318 "AInst Menu"
2319};
2320
2321
2322
2324{
2325
2326 ComboLabel label;
2327 label.item_count = 0;
2328 label.selected = 0;
2329 if (nk_combo_begin_label(NK_CTX, registry->directory, nk_vec2(200, 200))) {
2330
2331 if (!registry->open)
2332 {
2333 load_filenames(registry);
2334 }
2335 char * names = (char *)registry->names.buffer;
2336 for (int i = 0; i < registry->names.count; i++)
2337 {
2338 snprintf(label.buffer[label.item_count], LABEL_LEN, "%s", &names[i * 256]);
2339 label.ptrs[label.item_count] = label.buffer[label.item_count];
2340 if (registry->current_selection == label.item_count) label.selected = label.item_count;
2341 label.item_count++;
2342
2343 }
2344 registry->open = nk_true;
2345 nk_layout_row_dynamic(NK_CTX, 20, 1);
2346 for (int i = 0; i < label.item_count; i++) {
2347 nk_bool sel = (i == label.selected);
2348 if (nk_selectable_label(NK_CTX, label.ptrs[i], NK_TEXT_LEFT, &sel)) {
2349 registry->current_selection = i;
2350 }
2351 }
2352 nk_combo_end(NK_CTX);
2353 }
2354 else
2355 {
2356 registry->open = nk_false;
2357 }
2358}
2359
2360void render_dropdown_labels(int * selected, char ** options, int option_count)
2361{
2362
2363 ComboLabel label;
2364 label.item_count = 0;
2365 label.selected = 0;
2366 for (int i = 0; i < option_count; i++)
2367 {
2368 snprintf(label.buffer[label.item_count], LABEL_LEN, "%s", options[i]);
2369 label.ptrs[label.item_count] = label.buffer[label.item_count];
2370 if (*selected == label.item_count) label.selected = label.item_count;
2371 label.item_count++;
2372
2373 }
2374 nk_layout_row_dynamic(NK_CTX, 20, 1);
2375 for (int i = 0; i < label.item_count; i++) {
2376 nk_bool sel = (i == label.selected);
2377 if (nk_selectable_label(NK_CTX, label.ptrs[i], NK_TEXT_LEFT, &sel)) {
2378 *selected = i;
2379 }
2380 }
2381}
2382
2383
2384void render_dropdown(const char * dropdown_name, int * selected, char ** options, int option_count, int x, int y)
2385{
2386
2387 char name[512];
2388 if (*selected >= 0 && *selected < option_count)
2389 {
2390 strcpy(name, options[*selected]);
2391
2392 }
2393 else
2394 {
2395 strcpy(name, dropdown_name);
2396 }
2397
2398 if (nk_combo_begin_label(NK_CTX, name, nk_vec2(x, y))) {
2399 ComboLabel label;
2400 label.item_count = 0;
2401 label.selected = 0;
2402 for (int i = 0; i < option_count; i++)
2403 {
2404 snprintf(label.buffer[label.item_count], LABEL_LEN, "%s", options[i]);
2405 label.ptrs[label.item_count] = label.buffer[label.item_count];
2406 if (*selected == label.item_count) label.selected = label.item_count;
2407 label.item_count++;
2408
2409 }
2410 nk_layout_row_dynamic(NK_CTX, 20, 1);
2411 for (int i = 0; i < label.item_count; i++) {
2412 nk_bool sel = (i == label.selected);
2413 if (nk_selectable_label(NK_CTX, label.ptrs[i], NK_TEXT_LEFT, &sel)) {
2414 *selected = i;
2415 }
2416 }
2417 nk_combo_end(NK_CTX);
2418 }
2419
2420}
2421
2422mat3 mat3_rotation_x(float angle_radians) {
2423 float c = cosf(angle_radians);
2424 float s = sinf(angle_radians);
2425 return (mat3){
2426 1.0f, 0.0f, 0.0f,
2427 0.0f, c, -s,
2428 0.0f, s, c
2429 };
2430}
2431
2432
2433mat3 mat3_rotation_y(float angle_radians) {
2434 float c = cosf(angle_radians);
2435 float s = sinf(angle_radians);
2436 return (mat3){
2437 c, 0.0f, s,
2438 0.0f, 1.0f, 0.0f,
2439 -s, 0.0f, c
2440 };
2441}
2442
2443mat3 mat3_rotation_z(float angle_radians) {
2444 float c = cosf(angle_radians);
2445 float s = sinf(angle_radians);
2446 return (mat3){
2447 c, -s, 0.0f,
2448 s, c, 0.0f,
2449 0.0f, 0.0f, 1.0f
2450 };
2451}
2452
2454
2455
2456 vec3 fwd = {obb->rot.a0, obb->rot.a1, obb->rot.a2};
2457 vec3 right = {obb->rot.b0, obb->rot.b1, obb->rot.b2};
2458 vec3 up = {obb->rot.c0, obb->rot.c1, obb->rot.c2};
2459
2460 vec3 r = vec3_normalize(right);
2461
2462 vec3 u = up;
2463 u = vec3_sub(u, vec3_scale(r, vec3_dot(u, r)));
2464 u = vec3_normalize(u);
2465
2466 vec3 f = vec3_cross(r, u);
2467
2468 obb->rot.a0 = f.x;
2469 obb->rot.a1 = f.y;
2470 obb->rot.a2 = f.z;
2471 obb->rot.b0 = r.x;
2472 obb->rot.b1 = r.y;
2473 obb->rot.b2 = r.z;
2474 obb->rot.c0 = u.x;
2475 obb->rot.c1 = u.y;
2476 obb->rot.c2 = u.z;
2477
2478}
2479void render_ivec3_widget(const char * name, UndoStructureType undo_type, int id, ivec3 * vec, NKSlider * sliders)
2480{
2481 bool dirty = false;
2482 nk_layout_row_dynamic(NK_CTX, 20, 3);
2483
2484 const char * pos_names[3] =
2485 {
2486 " x",
2487 " y",
2488 " z",
2489 };
2490
2491 char final_names[3][256];
2492
2493 for (int i = 0; i < 3; i++)
2494 {
2495
2496 strcpy(final_names[i], name);
2497 strcat(final_names[i], pos_names[i]);
2498
2499 }
2500
2501 UndoSpecial special;
2502 size_t byte_offset = 0;
2503 switch(undo_type)
2504 {
2505 case UNDOSTRUCT_APROBE:
2506 special = UNDOSPECIAL_NONE;
2507 byte_offset = offsetof(ProbeVolume, resolution);
2508 break;
2509 default:
2510 break;
2511 }
2512
2513
2514 UndoStructure us = create_undo_structure(undo_type, (int[8]){id}, special);
2515
2516
2517 int vecx = nk_propertyi(NK_CTX, final_names[0], -100000, vec->x, 100000, 1, 1);
2518 if (check_equivalencyi(&vec->x, vecx, &sliders[0], NULL))
2519 {
2520 push_nk_slider_undo(&sliders[0], us, byte_offset + offsetof(ivec3, x));
2521 }
2522
2523
2524 float vecy = nk_propertyi(NK_CTX, final_names[1], -100000, vec->y, 100000, 1, 1);
2525 if (check_equivalencyi(&vec->y, vecy, &sliders[1], NULL))
2526 {
2527 push_nk_slider_undo(&sliders[1], us, byte_offset + offsetof(ivec3, y));
2528 }
2529
2530 float vecz = nk_propertyi(NK_CTX, final_names[2], -100000, vec->z, 100000, 1, 1);
2531 if (check_equivalencyi(&vec->z, vecz, &sliders[2], NULL))
2532 {
2533 push_nk_slider_undo(&sliders[2], us, byte_offset + offsetof(ivec3, z));
2534 }
2535
2536
2537
2538}
2539
2540void render_pos_widget(const char * name, UndoStructureType undo_type, int id, vec3 * pos, NKSlider * sliders)
2541{
2542 bool dirty = false;
2543 nk_layout_row_dynamic(NK_CTX, 20, 3);
2544
2545 const char * pos_names[3] =
2546 {
2547 " x",
2548 " y",
2549 " z",
2550 };
2551
2552 char final_names[3][256];
2553
2554 for (int i = 0; i < 3; i++)
2555 {
2556
2557 strcpy(final_names[i], name);
2558 strcat(final_names[i], pos_names[i]);
2559
2560 }
2561
2562 UndoSpecial special;
2563 size_t byte_offset = 0;
2564 switch(undo_type)
2565 {
2567 special = UNDOSPECIAL_NONE;
2568 byte_offset = offsetof(AudioEmitter, pos);
2569 break;
2570 default:
2571 break;
2572 }
2573
2574
2575 UndoStructure us = create_undo_structure(undo_type, (int[8]){id}, special);
2576
2577
2578 float posx = nk_propertyf(NK_CTX, final_names[0], -100000.0f, pos->x, 100000.0f, 0.01f, 0.01f);
2579 if (check_equivalencyf(&pos->x, posx, &sliders[0], NULL))
2580 {
2581 push_nk_slider_undo(&sliders[0], us, byte_offset + offsetof(vec3, x));
2582 }
2583
2584 float posy = nk_propertyf(NK_CTX, final_names[1], -100000.0f, pos->y, 100000.0f, 0.01f, 0.01f);
2585 if (check_equivalencyf(&pos->y, posy, &sliders[1], NULL))
2586 {
2587 push_nk_slider_undo(&sliders[1], us, byte_offset + offsetof(vec3, y));
2588 }
2589
2590 float posz = nk_propertyf(NK_CTX, final_names[2], -100000.0f, pos->z, 100000.0f, 0.01f, 0.01f);
2591 if (check_equivalencyf(&pos->z, posz, &sliders[2], NULL))
2592 {
2593 push_nk_slider_undo(&sliders[2], us, byte_offset + offsetof(vec3, z));
2594 }
2595
2596
2597
2598}
2599
2600void render_aabb_widget(const char * name, AABB * aabb)
2601{
2602
2603 bool dirty = false;
2604
2605 nk_layout_row_dynamic(NK_CTX, 20, 3);
2606
2607 const char * aabb_names[6] =
2608 {
2609 "_aabb_x",
2610 "_aabb_y",
2611 "_aabb_z",
2612 "_aabbe_x",
2613 "_aabbe_y",
2614 "_aabbe_z"
2615 };
2616
2617 char final_names[6][256];
2618
2619 for (int i = 0; i < 6; i++)
2620 {
2621
2622 strcpy(final_names[i], name);
2623 strcat(final_names[i], aabb_names[i]);
2624
2625 }
2626
2627
2628
2629 float aabbx = nk_propertyf(NK_CTX, final_names[0], -1000.0f, aabb->center.x, 1000.0f, 0.01f, 0.01f);
2630 if (aabbx != aabb->center.x)
2631 {
2632 dirty = true;
2633 aabb->center.x = aabbx;
2634 }
2635 float aabby = nk_propertyf(NK_CTX, final_names[1], -1000.0f, aabb->center.y, 1000.0f, 0.01f, 0.01f);
2636 if (aabby != aabb->center.y)
2637 {
2638 dirty = true;
2639 aabb->center.y = aabby;
2640 }
2641 float aabbz = nk_propertyf(NK_CTX, final_names[2], -1000.0f, aabb->center.z, 1000.0f, 0.01f, 0.01f);
2642 if (aabbz != aabb->center.z)
2643 {
2644 dirty = true;
2645 aabb->center.z = aabbz;
2646 }
2647
2648 nk_layout_row_dynamic(NK_CTX, 20, 3);
2649
2650 float aabbex = nk_propertyf(NK_CTX, final_names[3], -1000.0f, aabb->extents.x, 1000.0f, 0.01f, 0.01f);
2651 if (aabbex != aabb->extents.x)
2652 {
2653 dirty = true;
2654 aabb->extents.x = aabbex;
2655 }
2656 float aabbey = nk_propertyf(NK_CTX, final_names[4], -1000.0f, aabb->extents.y, 1000.0f, 0.01f, 0.01f);
2657 if (aabbey != aabb->extents.y)
2658 {
2659 dirty = true;
2660 aabb->extents.y = aabbey;
2661 }
2662 float aabbez = nk_propertyf(NK_CTX, final_names[5], -1000.0f, aabb->extents.z, 1000.0f, 0.01f, 0.01f);
2663 if (aabbez != aabb->extents.z)
2664 {
2665 dirty = true;
2666 aabb->extents.z = aabbez;
2667 }
2668 if (dirty)
2669 {
2671 }
2672
2673
2674}
2675
2676void render_mat4_widget(const char * name, UndoStructureType undo_type, int id, mat4 * mat, vec3 * tr, vec4 * rot, vec3 * sc, NKSlider * sliders)
2677{
2678
2679 UndoSpecial special;
2680 UndoSpecial mat_special;
2681 UndoSpecial rot_special;
2682 size_t pos_offset = 0;
2683 size_t scale_offset = 0;
2684 switch(undo_type)
2685 {
2687 special = UNDOSPECIAL_NONE;
2688 mat_special = UNDOASSETINSTANCE_MAT;
2690 pos_offset = offsetof(AssetInstance, tr);
2691 scale_offset = offsetof(AssetInstance, scale);
2692 break;
2693 case UNDOSTRUCT_MN:
2694 special = UNDOSPECIAL_NONE;
2695 mat_special = UNDOMN_MAT;
2696 rot_special = UNDOMN_ROTATION_ANGLE;
2697 pos_offset = offsetof(MeshNode, translation);
2698 scale_offset = offsetof(MeshNode, scale);
2699 default:
2700 break;
2701 }
2702
2703
2704 const char * obb_names[] =
2705 {
2706 "_mat_x",
2707 "_mat_y",
2708 "_mat_z",
2709 "_matr_x",
2710 "_matr_y",
2711 "_matr_z",
2712 "_maangle_z",
2713 "_matsc_x",
2714 "_matsc_y",
2715 "_matsc_z",
2716 };
2717
2718 char final_names[10][256];
2719
2720 for (int i = 0; i < 10; i++)
2721 {
2722
2723 strcpy(final_names[i], name);
2724 strcat(final_names[i], obb_names[i]);
2725
2726 }
2727 UndoStructure us = create_undo_structure(undo_type, (int[8]){id}, special);
2728 UndoStructure uss = create_undo_structure(undo_type, (int[8]){id}, mat_special);
2729 UndoStructure rot_us = create_undo_structure(undo_type, (int[8]){id}, rot_special);
2731
2732 bool dirty = false;
2733 vec3 pos;
2734 pos.x = nk_propertyf(NK_CTX, final_names[0], -1000.0f, tr->x, 1000.0f, 0.01f, 0.01f);
2735
2736 pos.y = nk_propertyf(NK_CTX, final_names[1], -1000.0f, tr->y, 1000.0f, 0.01f, 0.01f);
2737
2738 pos.z = nk_propertyf(NK_CTX, final_names[2], -1000.0f, tr->z, 1000.0f, 0.01f, 0.01f);
2739
2740 if (nk_check_equivalency(tr, &pos, sizeof(vec3), &sliders[0], &dirty))
2741 {
2742 push_nk_slider_undo(&sliders[0], uss, pos_offset);
2743 }
2744
2745 bool rot_dirty = false;
2746 vec3 r;
2747 r.x = nk_propertyf(NK_CTX, final_names[3], -1000.0f, EDITOR_SETTINGS.rotation_axis.x, 1000.0f, 0.01f, 0.01f);
2748 r.y = nk_propertyf(NK_CTX, final_names[4], -1000.0f, EDITOR_SETTINGS.rotation_axis.y, 1000.0f, 0.01f, 0.01f);
2749 r.z = nk_propertyf(NK_CTX, final_names[5], -1000.0f, EDITOR_SETTINGS.rotation_axis.z, 1000.0f, 0.01f, 0.01f);
2750
2751 if (nk_check_equivalency(&EDITOR_SETTINGS.rotation_axis, &r, sizeof(vec3), &sliders[3], &rot_dirty))
2752 {
2753 push_nk_slider_undo(&sliders[3], es, offsetof(EditorSettings, rotation_axis));
2754 }
2755
2756 if (rot_dirty)
2757 {
2759 }
2760
2761 float angle = nk_propertyf(NK_CTX, final_names[6], 0, EDITOR_SETTINGS.rotation_angle, 2 * M_PI, 0.001f, 0.001f);
2762 bool angle_dirty = false;
2763 float rot_angle_old = EDITOR_SETTINGS.rotation_angle;
2764 if (check_equivalencyf(&EDITOR_SETTINGS.rotation_angle, angle, &sliders[4], &angle_dirty))
2765 {
2766 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 3);
2767 bytes[0] = malloc(sizeof(float));
2768 bytes[1] = malloc(sizeof(mat4));
2769 bytes[2] = malloc(sizeof(vec3));
2770 memcpy(bytes[0], &rot_angle_old, sizeof(float));
2771 memcpy(bytes[1], mat, sizeof(mat4));
2772 memcpy(bytes[2], rot, sizeof(vec3));
2773
2774 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(float) + sizeof(mat4) + sizeof(vec3);
2775
2776 push_special_undo(rot_us, bytes, byte_size, 3, 0);
2777 }
2778 if (angle_dirty)
2779 {
2780
2782 dirty = true;
2784 *rot = quat;
2785 }
2786
2787 vec3 s;
2788 s.x = nk_propertyf(NK_CTX, final_names[7], -1000.0f, sc->x, 1000.0f, 0.01f, 0.01f);
2789
2790 s.y = nk_propertyf(NK_CTX, final_names[8], -1000.0f, sc->y, 1000.0f, 0.01f, 0.01f);
2791
2792 s.z = nk_propertyf(NK_CTX, final_names[9], -1000.0f, sc->z, 1000.0f, 0.01f, 0.01f);
2793 if (nk_check_equivalency(sc, &s, sizeof(vec3), &sliders[5], &dirty))
2794 {
2795 push_nk_slider_undo(&sliders[5], uss, scale_offset);
2796 }
2797
2798
2799
2800 if (dirty)
2801 {
2802 mat4 out_mat = compose_trs_from_vectors(*tr, *rot, *sc);
2803 *mat = out_mat;
2804
2805 }
2806
2807
2808}
2809
2810
2811void render_obb_widget(const char * name, UndoStructureType undo_type, int id, OBB * obb, NKSlider * sliders)
2812{
2813
2814 bool dirty = false;
2815
2816 nk_layout_row_dynamic(NK_CTX, 20, 3);
2817
2818 const char * obb_names[] =
2819 {
2820 "_obb_x",
2821 "_obb_y",
2822 "_obb_z",
2823 "_obbe_x",
2824 "_obbe_y",
2825 "_obbe_z",
2826 "_obbr_x",
2827 "_obbr_y",
2828 "_obbr_z",
2829 };
2830
2831 char final_names[9][256];
2832
2833 for (int i = 0; i < 9; i++)
2834 {
2835
2836 strcpy(final_names[i], name);
2837 strcat(final_names[i], obb_names[i]);
2838
2839 }
2840
2841 UndoSpecial special;
2842 UndoSpecial rot_special;
2843 switch(undo_type)
2844 {
2845 case UNDOSTRUCT_LPROBE:
2846 special = UNDOSPECIAL_NONE;
2847 rot_special = UNDOLPROBE_OBB_ROT;
2848 break;
2849 case UNDOSTRUCT_APROBE:
2850 special = UNDOSPECIAL_NONE;
2851 rot_special = UNDOAPROBE_OBB_ROT;
2852 break;
2853 default:
2854 break;
2855 }
2856
2857
2858 UndoStructure us = create_undo_structure(undo_type, (int[8]){id}, special);
2859 UndoStructure rot_us = create_undo_structure(undo_type, (int[8]){id}, rot_special);
2860
2861
2862 float obbx = nk_propertyf(NK_CTX, final_names[0], -1000.0f, obb->center.x, 1000.0f, 0.01f, 0.01f);
2863 if (check_equivalencyf(&obb->center.x, obbx, &sliders[0], NULL))
2864 {
2865 push_nk_slider_undo(&sliders[0], us, offsetof(ProbeVolume, obb.center.x));
2866 }
2867 float obby = nk_propertyf(NK_CTX, final_names[1], -1000.0f, obb->center.y, 1000.0f, 0.01f, 0.01f);
2868 if (check_equivalencyf(&obb->center.y, obby, &sliders[1], NULL))
2869 {
2870 push_nk_slider_undo(&sliders[1], us, offsetof(ProbeVolume, obb.center.y));
2871 }
2872 float obbz = nk_propertyf(NK_CTX, final_names[2], -1000.0f, obb->center.z, 1000.0f, 0.01f, 0.01f);
2873 if (check_equivalencyf(&obb->center.z, obbz, &sliders[2], NULL))
2874 {
2875 push_nk_slider_undo(&sliders[2], us, offsetof(ProbeVolume, obb.center.z));
2876 }
2877
2878 nk_layout_row_dynamic(NK_CTX, 20, 3);
2879
2880 float obbex = nk_propertyf(NK_CTX, final_names[3], -1000.0f, obb->extents.x, 1000.0f, 0.01f, 0.01f);
2881 if (check_equivalencyf(&obb->extents.x, obbex, &sliders[3], NULL))
2882 {
2883 push_nk_slider_undo(&sliders[3], us, offsetof(ProbeVolume, obb.extents.x));
2884 }
2885 float obbey = nk_propertyf(NK_CTX, final_names[4], -1000.0f, obb->extents.y, 1000.0f, 0.01f, 0.01f);
2886 if (check_equivalencyf(&obb->extents.y, obbey, &sliders[4], NULL))
2887 {
2888 push_nk_slider_undo(&sliders[4], us, offsetof(ProbeVolume, obb.extents.y));
2889 }
2890 float obbez = nk_propertyf(NK_CTX, final_names[5], -1000.0f, obb->extents.z, 1000.0f, 0.01f, 0.01f);
2891 if (check_equivalencyf(&obb->extents.z, obbez, &sliders[5], NULL))
2892 {
2893 push_nk_slider_undo(&sliders[5], us, offsetof(ProbeVolume, obb.extents.z));
2894 }
2895 bool a_dirty = false;
2896 bool b_dirty = false;
2897 bool c_dirty = false;
2898
2899 float obbrx = nk_propertyf(NK_CTX, final_names[6], -M_PI, EDITOR_SETTINGS.obb_axis_x_angle, M_PI, 0.01f, 0.01f);
2900 bool s6_is_held = sliders[6].is_held;
2901 check_equivalencyf(&EDITOR_SETTINGS.obb_axis_x_angle, obbrx, &sliders[6], &a_dirty);
2902 if (!s6_is_held && sliders[6].is_held)
2903 {
2904
2905 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
2906 bytes[0] = malloc(sizeof(mat3));
2907 memcpy(bytes[0], &obb->rot, sizeof(mat3));
2908 bytes[1] = malloc(sizeof(vec3));
2910 memcpy(bytes[1], &axis, sizeof(vec3));
2911 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(mat3) + sizeof(vec3);
2912
2913 push_special_undo(rot_us, bytes, byte_size, 2, offsetof(ProbeVolume, obb.rot));
2914
2915 }
2916
2917 float obbry = nk_propertyf(NK_CTX, final_names[7], -M_PI, EDITOR_SETTINGS.obb_axis_y_angle, M_PI, 0.01f, 0.01f);
2918 bool s7_is_held = sliders[7].is_held;
2919 check_equivalencyf(&EDITOR_SETTINGS.obb_axis_y_angle, obbry, &sliders[7], &b_dirty);
2920 if (!s7_is_held && sliders[7].is_held)
2921 {
2922
2923 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
2924 bytes[0] = malloc(sizeof(mat3));
2925 memcpy(bytes[0], &obb->rot, sizeof(mat3));
2926 bytes[1] = malloc(sizeof(vec3));
2928 memcpy(bytes[1], &axis, sizeof(vec3));
2929 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(mat3) + sizeof(vec3);
2930
2931 push_special_undo(rot_us, bytes, byte_size, 2, offsetof(ProbeVolume, obb.rot));
2932
2933 }
2934 float obbrz = nk_propertyf(NK_CTX, final_names[8], -M_PI, EDITOR_SETTINGS.obb_axis_z_angle, M_PI, 0.01f, 0.01f);
2935
2936 bool s8_is_held = sliders[8].is_held;
2937 check_equivalencyf(&EDITOR_SETTINGS.obb_axis_z_angle, obbrz, &sliders[8], &c_dirty);
2938
2939 if (!s8_is_held && sliders[8].is_held)
2940 {
2941
2942 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
2943 bytes[0] = malloc(sizeof(mat3));
2944 memcpy(bytes[0], &obb->rot, sizeof(mat3));
2945 bytes[1] = malloc(sizeof(vec3));
2947 memcpy(bytes[1], &axis, sizeof(vec3));
2948 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(mat3) + sizeof(vec3);
2949
2950 push_special_undo(rot_us, bytes, byte_size, 2, offsetof(ProbeVolume, obb.rot));
2951
2952 }
2953
2954 if (a_dirty || b_dirty || c_dirty)
2955 {
2956
2957
2958 obb->rot = mat3_identity();
2960 obb->rot = mat3_mul(obb->rot, new_rot_x);
2962 obb->rot = mat3_mul(obb->rot, new_rot_y);
2964 obb->rot = mat3_mul(obb->rot, new_rot_z);
2965
2966 }
2967
2968
2969}
2970
2971
2972int tb_id_flags = NK_EDIT_INACTIVE;
2973int tb_text_flags = NK_EDIT_INACTIVE;
2974int tb_cont_flags = NK_EDIT_INACTIVE;
2975int ui_menu_id_flags = NK_EDIT_INACTIVE;
2976int ui_id_flags = NK_EDIT_INACTIVE;
2977int ui_parent_cont_flags = NK_EDIT_INACTIVE;
2978int ui_cont_flags = NK_EDIT_INACTIVE;
2979int ui_scrollbar_flags = NK_EDIT_INACTIVE;
2980int ui_label_id_flags = NK_EDIT_INACTIVE;
2981int aportal_flags = NK_EDIT_INACTIVE;
2982int apv_flags = NK_EDIT_INACTIVE;
2983int scene_apv_flags = NK_EDIT_INACTIVE;
2984int lpv_flags = NK_EDIT_INACTIVE;
2985int scene_lpv_flags = NK_EDIT_INACTIVE;
2986int scene_name_flags = NK_EDIT_INACTIVE;
2987int scene_file_name_flags = NK_EDIT_INACTIVE;
2988int ui_name_flags = NK_EDIT_INACTIVE;
2989int rprobe_name_flags = NK_EDIT_INACTIVE;
2990int light_name_flags = NK_EDIT_INACTIVE;
2991int lm_name_flags = NK_EDIT_INACTIVE;
2992
2993
2994
2995
3003{
3004
3005 if
3006 (
3007 nk_begin
3008 (
3009 NK_CTX,
3010 "Selection Mode",
3011 nk_rect(20, SCREEN_HEIGHT - 80, 500, 80),
3012 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE
3013 )
3014 )
3015 {
3016 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
3017 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
3018 nk_layout_row_dynamic(NK_CTX, 12, 6);
3019 if (nk_option_label(NK_CTX, "MN", EDITOR_SETTINGS.SELMODE == SELMODE_MN)) EDITOR_SETTINGS.SELMODE = SELMODE_MN;
3021 if (nk_option_label(NK_CTX, "LPV", EDITOR_SETTINGS.SELMODE == SELMODE_LPV)) EDITOR_SETTINGS.SELMODE = SELMODE_LPV;
3026 if (nk_option_label(NK_CTX, "APV", EDITOR_SETTINGS.SELMODE == SELMODE_APV)) EDITOR_SETTINGS.SELMODE = SELMODE_APV;
3028 if (nk_option_label(NK_CTX, "AEM", EDITOR_SETTINGS.SELMODE == SELMODE_AEM)) EDITOR_SETTINGS.SELMODE = SELMODE_AEM;
3030
3031
3032 }
3033 nk_end(NK_CTX);
3034}
3035
3036
3039
3041{
3042
3043 if
3044 (
3045 nk_begin
3046 (
3047 NK_CTX,
3049 nk_rect(420, 20, SCREEN_WIDTH - 420 * 2, 300),
3050 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE | NK_WINDOW_MOVABLE
3051 )
3052 )
3053 {
3054 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
3055 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
3056
3057 UIMenu * ms = CAST_VEC(MENUS, UIMenu);
3059 TextBox * tbs = m->text_boxes;
3061
3063 (
3065 (int[8]){
3068 }, UNDOSPECIAL_NONE);
3069
3070 nk_layout_row_dynamic(NK_CTX, 20, 1);
3071 char menu_id[512];
3072 sprintf(menu_id, "%s (%d)", m->id, m->uID);
3073 nk_label(NK_CTX, menu_id, NK_TEXT_ALIGN_LEFT);
3074
3075 nk_layout_row_dynamic(NK_CTX, 20, 1);
3076
3077
3078 char id[512];
3079 sprintf(id, "%s (%u)", tb->id, tb->uID);
3080
3081 nk_label(NK_CTX, id, NK_TEXT_ALIGN_LEFT);
3082
3083 nk_layout_row_dynamic(NK_CTX, 20, 1);
3084
3085 char ui_menu_names[MAX_UI_MENU_NAMES][256];
3086
3087 char * refs[MAX_UI_MENU_NAMES];
3088 for (int i = 0; i < MENUS.count; i++)
3089 {
3090 sprintf(ui_menu_names[i], "%s (%d)", ms[i].id, ms[i].uID);
3091 refs[i] = ui_menu_names[i];
3092 }
3093
3094 int current_menu = tb->menu;
3095 render_dropdown("TB UI Menu", &current_menu, (char**)refs, MENUS.count, 300, 100);
3096
3097 if (current_menu != tb->menu)
3098 {
3099
3101
3103 EDITOR_SETTINGS.selected_ui_menu_id = current_menu;
3104
3107 }
3108
3109 nk_layout_row_dynamic(NK_CTX, 20, 1);
3110
3111 nk_bool tb_drag = EDITOR_SETTINGS.text_box_drag_mode;
3112 if (nk_checkbox_label(NK_CTX, "TB Drag Mode", &tb_drag))
3113 {
3115 }
3116
3117 nk_layout_row_dynamic(NK_CTX, 20, 2);
3118
3119 tb_id_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, text_id_buffer, sizeof(text_id_buffer), nk_filter_default);
3120
3121
3122 if (nk_button_label(NK_CTX, "Change ID"))
3123 {
3124 push_raw_bytes_undo(tb->id, sizeof(char) * 256, tb_structure, offsetof(TextBox, id));
3125 strcpy(tb->id, text_id_buffer);
3126 }
3127 nk_layout_row_dynamic(NK_CTX, 20, 1);
3128
3129 if (nk_button_label(NK_CTX, "Create Text Box"))
3130 {
3131
3132 int old_sel = EDITOR_SETTINGS.selected_text_id;
3135 (
3138 (int[8])
3139 {
3142 old_sel,
3143 }, UNDOTEXTBOX_CREATE_TEXT_BOX), NULL, 0, 0, 0);
3144 }
3145
3146 if (nk_button_label(NK_CTX, "Delete Text Box"))
3147 {
3148 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
3149 bytes[0] = malloc(sizeof(TextBox));
3150 bytes[1] = malloc(sizeof(char) * tb->text_cap);
3151 memcpy(bytes[0], tb, sizeof(TextBox));
3152 memcpy(bytes[1], tb->text, sizeof(char) * tb->text_cap);
3153
3154 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(TextBox) + sizeof(char) * tb->text_cap;
3156 (
3159 (int[8])
3160 {
3163 }, UNDOTEXTBOX_DELETE_TEXT_BOX), bytes, byte_size, 2, 0);
3164
3165
3166 delete_text_box(tb->menu, tb->uID);
3168 }
3169
3170 bool dirty = false;
3171 vec2 xyval;
3172 xyval.x = nk_propertyf(NK_CTX, "TB_X", -5000.0f, tb->translation.x, 5000.0f, 0.01f, 0.01f);
3173 xyval.y = nk_propertyf(NK_CTX, "TB_Y", -5000.0f, tb->translation.y, 5000.0f, 0.01f, 0.01f);
3174
3175
3176
3177 if (nk_check_equivalency(&tb->translation, &xyval, sizeof(vec2), &TEXTBOX_MENU.translation, NULL))
3178 {
3179 push_nk_slider_undo(&TEXTBOX_MENU.translation, tb_structure, offsetof(TextBox, translation));
3180 }
3181
3182 float angle = nk_propertyf(NK_CTX, "TB_Angle", 0.0f, tb->angle, 3.1415f, 0.01f, 0.01f);
3183 if (nk_check_equivalency(&tb->angle, &angle, sizeof(float), &TEXTBOX_MENU.angle, NULL))
3184 {
3185 push_nk_slider_undo(&TEXTBOX_MENU.angle, tb_structure, offsetof(TextBox, angle));
3186 }
3187 vec2 scale;
3188 scale.x = nk_propertyf(NK_CTX, "TB_Scale_X", 0.0f, tb->scale.x, 5000.0f, 0.01f, 0.01f);
3189 scale.y = nk_propertyf(NK_CTX, "TB_Scale_Y", 0.0f, tb->scale.y, 5000.0f, 0.01f, 0.01f);
3190 if (nk_check_equivalency(&tb->scale, &scale, sizeof(vec2), &TEXTBOX_MENU.scale, NULL))
3191 {
3192 push_nk_slider_undo(&TEXTBOX_MENU.scale, tb_structure, offsetof(TextBox, scale));
3193 }
3194 float ts = nk_propertyf(NK_CTX, "Text Size", 0.0f, tb->text_size, 5000.0f, 0.01f, 0.01f);
3195 if (nk_check_equivalency(&tb->text_size, &ts, sizeof(float), &TEXTBOX_MENU.text_size, NULL))
3196 {
3197 push_nk_slider_undo(&TEXTBOX_MENU.text_size, tb_structure, offsetof(TextBox, text_size));
3198 }
3199 nk_layout_row_dynamic(NK_CTX, 20, 1);
3200 uint32_t layer = nk_propertyi(NK_CTX, "Text Layer", 0, tb->layer, 5000, 1, 1);
3201 if (nk_check_equivalency(&tb->layer, &layer, sizeof(uint32_t), &TEXTBOX_MENU.layer, NULL))
3202 {
3203 push_nk_slider_undo(&TEXTBOX_MENU.layer, tb_structure, offsetof(TextBox, layer));
3204 }
3205
3206 static char text_buffer[1024] = {0};
3207
3208 tb_text_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, text_buffer, sizeof(text_buffer), nk_filter_default);
3209 if (nk_button_label(NK_CTX, "Change Text"))
3210 {
3211
3212 uint8_t ** bytes = NULL;
3213 int bytes_count = 0;
3214 size_t byte_size = 0;
3215 if (tb->text && tb->text_cap > 0)
3216 {
3217
3218 bytes = malloc(sizeof(uint8_t*));
3219 bytes[0] = malloc(sizeof(char) * tb->text_cap);
3220 memcpy(bytes[0], tb->text, sizeof(char) * tb->text_cap);
3221 byte_size = sizeof(uint8_t*) + sizeof(char) * tb->text_cap;
3222 bytes_count = 1;
3223
3224 }
3226 (
3228 (int[8]){
3231 tb->text_cap
3232
3233 }, UNDOTEXTBOX_CHANGE_TEXT), bytes, byte_size, bytes_count, 0);
3234
3235 if (tb->text) free(tb->text);
3236 tb->text = NULL;
3237 tb->text_cap = (strlen(text_buffer) + 1);
3238 tb->text = malloc(sizeof(char) * tb->text_cap);
3239 strcpy(tb->text, text_buffer);
3240 dirty = true;
3241 }
3242
3243 struct nk_colorf color = {
3244 tb->color.x,
3245 tb->color.y,
3246 tb->color.z,
3247 tb->color.w,
3248 };
3249 nk_label(NK_CTX, "TB_Color", NK_TEXT_LEFT);
3250
3251 if (nk_combo_begin_color(NK_CTX, nk_rgba_cf(color), nk_vec2(150, 150))) {
3252 nk_layout_row_dynamic(NK_CTX, 120, 1);
3253 color = nk_color_picker(NK_CTX, color, NK_RGBA);
3254
3255
3256 nk_layout_row_dynamic(NK_CTX, 25, 1);
3257 color.r = nk_propertyf(NK_CTX, "#R:", 0.0f, color.r, 1.0f, 0.01f, 0.005f);
3258 color.g = nk_propertyf(NK_CTX, "#G:", 0.0f, color.g, 1.0f, 0.01f, 0.005f);
3259 color.b = nk_propertyf(NK_CTX, "#B:", 0.0f, color.b, 1.0f, 0.01f, 0.005f);
3260 color.a = nk_propertyf(NK_CTX, "#A:", 0.0f, color.a, 1.0f, 0.01f, 0.005f);
3261
3262 if (nk_check_equivalency(&tb->color, &color, sizeof(vec4), &TEXTBOX_MENU.color, NULL))
3263 {
3264 push_nk_slider_undo(&TEXTBOX_MENU.color, tb_structure, offsetof(TextBox, color));
3265 }
3266 nk_combo_end(NK_CTX);
3267 }
3268
3269 struct nk_colorf fill = {
3270 tb->fill.x,
3271 tb->fill.y,
3272 tb->fill.z,
3273 tb->fill.w,
3274 };
3275 nk_label(NK_CTX, "TB_fill", NK_TEXT_LEFT);
3276
3277 if (nk_combo_begin_color(NK_CTX, nk_rgba_cf(fill), nk_vec2(150, 150))) {
3278 nk_layout_row_dynamic(NK_CTX, 120, 1);
3279 fill = nk_color_picker(NK_CTX, fill, NK_RGBA);
3280
3281
3282 nk_layout_row_dynamic(NK_CTX, 25, 1);
3283 fill.r = nk_propertyf(NK_CTX, "#R:", 0.0f, fill.r, 1.0f, 0.01f, 0.005f);
3284 fill.g = nk_propertyf(NK_CTX, "#G:", 0.0f, fill.g, 1.0f, 0.01f, 0.005f);
3285 fill.b = nk_propertyf(NK_CTX, "#B:", 0.0f, fill.b, 1.0f, 0.01f, 0.005f);
3286 fill.a = nk_propertyf(NK_CTX, "#A:", 0.0f, fill.a, 1.0f, 0.01f, 0.005f);
3287
3288 if (nk_check_equivalency(&tb->fill, &fill, sizeof(vec4), &TEXTBOX_MENU.fill, NULL))
3289 {
3290 push_nk_slider_undo(&TEXTBOX_MENU.fill, tb_structure, offsetof(TextBox, fill));
3291 }
3292 nk_combo_end(NK_CTX);
3293 }
3294
3295 nk_bool sh = tb->shadow == 1;
3296 if (nk_checkbox_label(NK_CTX, "Shadow", &sh))
3297 {
3298 tb->shadow = sh;
3299 }
3300 float sh_d = nk_propertyf(NK_CTX, "Shadow Dist", 0.0f, tb->shadow_dist, 5000.0f, 0.01f, 0.01f);
3301 if (nk_check_equivalency(&tb->shadow_dist, &sh_d, sizeof(float), &TEXTBOX_MENU.shadow_dist, NULL))
3302 {
3303 push_nk_slider_undo(&TEXTBOX_MENU.shadow_dist, tb_structure, offsetof(TextBox, shadow_dist));
3304 }
3305
3306 bool dirx_dirty = false;
3307 vec2 sh_dir;
3308 float shx = nk_propertyf(NK_CTX, "Shadow DirX", -1.0f, tb->shadow_dir.x, 1.0f, 0.01f, 0.01f);
3309 if (check_equivalencyf(&tb->shadow_dir.x, shx, &TEXTBOX_MENU.shadow_dirx, &dirx_dirty))
3310 {
3311 push_raw_bytes_undo(&tb->shadow_dir, sizeof(vec2), tb_structure, offsetof(TextBox, shadow_dir));
3312 }
3313
3314 if (dirx_dirty)
3315 {
3316 tb->shadow_dir = vec2_normalize((vec2){shx, tb->shadow_dir.y});
3317 }
3318 bool diry_dirty = false;
3319 float shy = nk_propertyf(NK_CTX, "Shadow DirY", -1.0f, tb->shadow_dir.y, 1.0f, 0.01f, 0.01f);
3320 if (check_equivalencyf(&tb->shadow_dir.y, shy, &TEXTBOX_MENU.shadow_diry, &diry_dirty))
3321 {
3322 push_raw_bytes_undo(&tb->shadow_dir, sizeof(vec2), tb_structure, offsetof(TextBox, shadow_dir));
3323 }
3324 if (diry_dirty)
3325 {
3326 tb->shadow_dir = vec2_normalize((vec2){tb->shadow_dir.x, shy});
3327 }
3328
3329
3330 nk_layout_row_dynamic(NK_CTX, 20, 1);
3331
3332 char container_names[MAX_UI_CONTAINERS][256];
3333 char * container_refs[MAX_UI_CONTAINERS];
3334 int found_containers = 0;
3335 int pc_indices[MAX_UI_CONTAINERS];
3336 int current_container_found_id = -1;
3337 for (int i = 0; i < MAX_UI_CONTAINERS; i++)
3338 {
3339 UIContainer * current = &m->containers[i];
3340 if (current->free) continue;
3341 sprintf(container_names[found_containers], "%s (%d)", current->id, current->uID);
3342 container_refs[found_containers] = container_names[found_containers];
3343 pc_indices[found_containers] = current->uID;
3344 if (tb->parent_container == current->uID) current_container_found_id = found_containers;
3345 found_containers++;
3346
3347 }
3348
3349 int current_container = current_container_found_id;
3350 render_dropdown("Container", &current_container, (char**)container_refs, found_containers, 300, 100);
3351
3352 UIContainer * cs = m->containers;
3353 if (current_container != current_container_found_id)
3354 {
3355 int cont_id = pc_indices[current_container];
3356 int old_container = tb->parent_container;
3357 if (cont_id != -1)
3358 {
3359 if (tb->parent_container != -1)
3360 {
3362 }
3363 UIContainer * c = &cs[cont_id];
3364
3366
3368 (
3371 (int[8])
3372 {
3375 cont_id,
3376 old_container,
3377 }, UNDOTEXTBOX_CHANGE_CONTAINER), NULL, 0, 0, 0
3378 );
3379 }
3380 }
3382 {
3383
3384 if (nk_button_label(NK_CTX, "Remove From TB Container"))
3385 {
3386
3388 (
3391 (int[8])
3392 {
3395 tb->parent_container,
3396 }, UNDOTEXTBOX_REMOVE_FROM_CONTAINER), NULL, 0, 0, 0
3397 );
3399 tb->parent_container = -1;
3400 }
3401 }
3402
3403 if (dirty)
3404 {
3406 }
3407
3408
3409 }
3410 nk_end(NK_CTX);
3411
3412
3413}
3414
3417
3419
3423
3425{
3426
3427 if
3428 (
3429 nk_begin
3430 (
3431 NK_CTX,
3433 nk_rect(20, 20, 420, SCREEN_HEIGHT - 120),
3434 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE | NK_WINDOW_MOVABLE
3435 )
3436 )
3437 {
3438
3439 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
3440 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
3441
3442
3443 UIMenu * ms = CAST_VEC(MENUS, UIMenu);
3445 UIElement * els = m->elements;
3447
3450
3451
3452 nk_layout_row_dynamic(NK_CTX, 20, 1);
3453 char menu_id[512];
3454 sprintf(menu_id, "%s (%d)", m->id, m->uID);
3455 nk_label(NK_CTX, menu_id, NK_TEXT_ALIGN_LEFT);
3456
3457 nk_layout_row_dynamic(NK_CTX, 20, 2);
3458 ui_menu_id_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, menu_id_buffer, sizeof(menu_id_buffer), nk_filter_default);
3459
3460 if (nk_button_label(NK_CTX, "Menu Change ID"))
3461 {
3462 push_raw_bytes_undo(m->id, sizeof(m->id), menu_structure, offsetof(UIMenu, id));
3463 strcpy(m->id, menu_id_buffer);
3464 }
3465
3466
3467 nk_layout_row_dynamic(NK_CTX, 20, 1);
3468
3469 char id[512];
3470 sprintf(id, "%s (%d)", el->id, el->uID);
3471
3472 nk_label(NK_CTX, id, NK_TEXT_ALIGN_LEFT);
3473
3474 nk_layout_row_dynamic(NK_CTX, 20, 1);
3475
3476 char ui_menu_names[MAX_UI_MENU_NAMES][256];
3477
3478 char * refs[MAX_UI_MENU_NAMES];
3479 for (int i = 0; i < MENUS.count; i++)
3480 {
3481 sprintf(ui_menu_names[i], "%s (%d)", ms[i].id, ms[i].uID);
3482 refs[i] = ui_menu_names[i];
3483 }
3484
3485 int current_menu = el->menu;
3486 render_dropdown("UI Menu", &current_menu, (char**)refs, MENUS.count, 300, 100);
3487
3488 if (current_menu != el->menu)
3489 {
3490
3493 EDITOR_SETTINGS.selected_ui_menu_id = current_menu;
3494
3495 }
3496
3497
3498 nk_layout_row_dynamic(NK_CTX, 20, 1);
3499
3500 nk_bool el_drag = EDITOR_SETTINGS.element_drag_mode;
3501 if (nk_checkbox_label(NK_CTX, "Element Drag", &el_drag))
3502 {
3504 }
3505
3506 nk_layout_row_dynamic(NK_CTX, 20, 2);
3507
3508 ui_id_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, element_id_buffer, sizeof(element_id_buffer), nk_filter_default);
3509
3510
3511 if (nk_button_label(NK_CTX, "Change ID"))
3512 {
3513 push_raw_bytes_undo(el->id, sizeof(el->id), el_structure, offsetof(UIElement, id));
3514 strcpy(el->id, element_id_buffer);
3515 }
3516
3517 nk_layout_row_dynamic(NK_CTX, 20, 1);
3518 if (nk_button_label(NK_CTX, "Create Element"))
3519 {
3520
3523 }
3524 if (nk_button_label(NK_CTX, "Delete Element"))
3525 {
3526
3528 delete_ui_element(el->menu, el->uID);
3529 }
3530
3531 bool dirty = false;
3532 float xval = nk_propertyf(NK_CTX, "UI_X", -5000.0f, el->translation.x, 5000.0f, 0.1f, 0.1f);
3533 if (check_equivalencyf(&el->translation.x, xval, &UIELEMENT_MENU.x, NULL))
3534 {
3535 push_nk_slider_undo(&UIELEMENT_MENU.x, el_structure, offsetof(UIElement, translation.x));
3536 }
3537
3538 float yval = nk_propertyf(NK_CTX, "UI_Y", -5000.0f, el->translation.y, 5000.0f, 0.1f, 0.1f);
3539 if (check_equivalencyf(&el->translation.y, yval, &UIELEMENT_MENU.y, NULL))
3540 {
3541 push_nk_slider_undo(&UIELEMENT_MENU.y, el_structure, offsetof(UIElement, translation.y));
3542 }
3543
3544 nk_layout_row_dynamic(NK_CTX, 20, 1);
3545 if (nk_button_label(NK_CTX, "New Base Pos"))
3546 {
3547 push_raw_bytes_undo(&el->base_pos, sizeof(vec2), el_structure, offsetof(UIElement, base_pos));
3548 el->base_pos = el->translation;
3549 }
3550
3551
3552 nk_layout_row_dynamic(NK_CTX, 20, 2);
3553 float xsc = nk_propertyf(NK_CTX, "UI_Scale_X", 0.0f, el->scale.x, 5000.0f, 0.01f, 0.01f);
3554 if (check_equivalencyf(&el->scale.x, xsc, &UIELEMENT_MENU.sx, NULL))
3555 {
3556 push_nk_slider_undo(&UIELEMENT_MENU.sx, el_structure, offsetof(UIElement, scale.x));
3557 }
3558 float ysc = nk_propertyf(NK_CTX, "UI_Scale_Y", 0.0f, el->scale.y, 5000.0f, 0.01f, 0.01f);
3559 if (check_equivalencyf(&el->scale.y, ysc, &UIELEMENT_MENU.sy, NULL))
3560 {
3561 push_nk_slider_undo(&UIELEMENT_MENU.sy, el_structure, offsetof(UIElement, scale.y));
3562 }
3563
3564 float r = nk_propertyf(NK_CTX, "UI_Radius", 0.0f, el->radius, 5000.0f, 0.001f, 0.001f);
3565 if (check_equivalencyf(&el->radius, r, &UIELEMENT_MENU.radius, NULL))
3566 {
3567 push_nk_slider_undo(&UIELEMENT_MENU.radius, el_structure, offsetof(UIElement, radius));
3568 }
3569
3570 float angle = nk_propertyf(NK_CTX, "UI_Angle", 0.0f, el->angle, 3.1415f, 0.01f, 0.01f);
3571 if (check_equivalencyf(&el->angle, angle, &UIELEMENT_MENU.angle, NULL))
3572 {
3573 push_nk_slider_undo(&UIELEMENT_MENU.angle, el_structure, offsetof(UIElement, angle));
3574 }
3575
3576 float sx = nk_propertyf(NK_CTX, "UI_Size_X", 0.0f, el->size.x, 5000.0f, 0.01f, 0.01f);
3577 if (check_equivalencyf(&el->size.x, sx, &UIELEMENT_MENU.sizex, NULL))
3578 {
3579 push_nk_slider_undo(&UIELEMENT_MENU.sizex, el_structure, offsetof(UIElement, size.x));
3580 }
3581 float sy = nk_propertyf(NK_CTX, "UI_Size_Y", 0.0f, el->size.y, 5000.0f, 0.01f, 0.01f);
3582 if (check_equivalencyf(&el->size.y, sy, &UIELEMENT_MENU.sizey, NULL))
3583 {
3584 push_nk_slider_undo(&UIELEMENT_MENU.sizey, el_structure, offsetof(UIElement, size.y));
3585 }
3586
3587 nk_layout_row_dynamic(NK_CTX, 20, 1);
3588 int el_layer = el->layer;
3589 int layer = nk_propertyi(NK_CTX, "UI_Layer", 0, el->layer, 5000, 1, 1);
3590 if (check_equivalencyi(&el_layer, layer, &UIELEMENT_MENU.layer, NULL))
3591 {
3592 push_nk_slider_undo(&UIELEMENT_MENU.layer, el_structure, offsetof(UIElement, layer));
3593 }
3594 if (layer != el->layer)
3595 {
3596 el->layer = layer;
3597 }
3598
3599 if (nk_combo_begin_label(NK_CTX, "Action", nk_vec2(200, 200))) {
3600
3601 char ** options = malloc(sizeof(char*) * ACTION_CALLBACK_COUNT);
3602 for (int i = 0; i < ACTION_CALLBACK_COUNT; i++)
3603 {
3604 options[i] = malloc(sizeof(char) * 256);
3605 strcpy(options[i], ACTION_CALLBACKS[i].id);
3606 }
3607
3608 int selected_id = EDITOR_SETTINGS.selected_ui_action_id;
3609
3611
3612 if (EDITOR_SETTINGS.selected_ui_action_id != selected_id)
3613 {
3616 }
3617
3618 for (int i = 0; i < ACTION_CALLBACK_COUNT; i++)
3619 {
3620 free(options[i]);
3621 }
3622 free(options);
3623
3624 nk_combo_end(NK_CTX);
3625 }
3626
3627 if (nk_combo_begin_label(NK_CTX, "Hover", nk_vec2(200, 200))) {
3628
3629 char ** options = malloc(sizeof(char*) * HOVER_CALLBACK_COUNT);
3630 for (int i = 0; i < HOVER_CALLBACK_COUNT; i++)
3631 {
3632 options[i] = malloc(sizeof(char) * 256);
3633 strcpy(options[i], HOVER_CALLBACKS[i].id);
3634 }
3635
3636 int selected_id = EDITOR_SETTINGS.selected_ui_hover_id;
3637
3639
3640 if (EDITOR_SETTINGS.selected_ui_hover_id != selected_id)
3641 {
3644 }
3645
3646 for (int i = 0; i < HOVER_CALLBACK_COUNT; i++)
3647 {
3648 free(options[i]);
3649 }
3650 free(options);
3651
3652 nk_combo_end(NK_CTX);
3653 }
3654
3655
3656
3657 struct nk_colorf color = {
3658 el->color.x,
3659 el->color.y,
3660 el->color.z,
3661 el->color.w,
3662 };
3663 nk_label(NK_CTX, "UI_Color", NK_TEXT_LEFT);
3664
3665 if (nk_combo_begin_color(NK_CTX, nk_rgba_cf(color), nk_vec2(150, 150))) {
3666 nk_layout_row_dynamic(NK_CTX, 120, 1);
3667 color = nk_color_picker(NK_CTX, color, NK_RGBA);
3668
3669
3670 nk_layout_row_dynamic(NK_CTX, 25, 1);
3671 color.r = nk_propertyf(NK_CTX, "#R:", 0.0f, color.r, 1.0f, 0.01f, 0.005f);
3672 color.g = nk_propertyf(NK_CTX, "#G:", 0.0f, color.g, 1.0f, 0.01f, 0.005f);
3673 color.b = nk_propertyf(NK_CTX, "#B:", 0.0f, color.b, 1.0f, 0.01f, 0.005f);
3674 color.a = nk_propertyf(NK_CTX, "#A:", 0.0f, color.a, 1.0f, 0.01f, 0.005f);
3675 if (check_equivalencyv4(&el->color, (vec4){color.r, color.g, color.b, color.a}, &UIELEMENT_MENU.color, NULL))
3676 {
3677 push_nk_slider_undo(&UIELEMENT_MENU.color, el_structure, offsetof(UIElement, color));
3678 }
3679 nk_combo_end(NK_CTX);
3680 }
3681
3682 struct nk_colorf fill = {
3683 el->fill.x,
3684 el->fill.y,
3685 el->fill.z,
3686 el->fill.w,
3687 };
3688 nk_label(NK_CTX, "UI_fill", NK_TEXT_LEFT);
3689
3690 if (nk_combo_begin_color(NK_CTX, nk_rgba_cf(fill), nk_vec2(150, 150))) {
3691 nk_layout_row_dynamic(NK_CTX, 120, 1);
3692 fill = nk_color_picker(NK_CTX, fill, NK_RGBA);
3693
3694
3695 nk_layout_row_dynamic(NK_CTX, 25, 1);
3696 fill.r = nk_propertyf(NK_CTX, "#R:", 0.0f, fill.r, 1.0f, 0.01f, 0.005f);
3697 fill.g = nk_propertyf(NK_CTX, "#G:", 0.0f, fill.g, 1.0f, 0.01f, 0.005f);
3698 fill.b = nk_propertyf(NK_CTX, "#B:", 0.0f, fill.b, 1.0f, 0.01f, 0.005f);
3699 fill.a = nk_propertyf(NK_CTX, "#A:", 0.0f, fill.a, 1.0f, 0.01f, 0.005f);
3700
3701 if (check_equivalencyv4(&el->fill, (vec4){fill.r, fill.g, fill.b, fill.a}, &UIELEMENT_MENU.fill, NULL))
3702 {
3703 push_nk_slider_undo(&UIELEMENT_MENU.fill, el_structure, offsetof(UIElement, fill));
3704 }
3705
3706 nk_combo_end(NK_CTX);
3707 }
3708
3709 nk_bool sh = el->shadow == 1;
3710 if (nk_checkbox_label(NK_CTX, "Shadow", &sh))
3711 {
3712 el->shadow = sh;
3713 }
3714 float sh_d = nk_propertyf(NK_CTX, "Shadow Dist", 0.0f, el->shadow_dist, 5000.0f, 0.01f, 0.01f);
3716 {
3717 push_nk_slider_undo(&UIELEMENT_MENU.shadow_dist, el_structure, offsetof(UIElement, shadow_dist));
3718 }
3719
3720 bool dir_dirty = false;
3721 float shx = nk_propertyf(NK_CTX, "Shadow DirX", -1.0f, el->shadow_dir.x, 1.0f, 0.01f, 0.01f);
3722 if (check_equivalencyf(&el->shadow_dir.x, shx, &UIELEMENT_MENU.shadow_dirx, &dir_dirty))
3723 {
3724 push_nk_slider_undo(&UIELEMENT_MENU.shadow_dirx, el_structure, offsetof(UIElement, shadow_dir.x));
3725 }
3726 float shy = nk_propertyf(NK_CTX, "Shadow DirY", -1.0f, el->shadow_dir.y, 1.0f, 0.01f, 0.01f);
3727 if (check_equivalencyf(&el->shadow_dir.y, shy, &UIELEMENT_MENU.shadow_diry, &dir_dirty))
3728 {
3729 push_nk_slider_undo(&UIELEMENT_MENU.shadow_diry, el_structure, offsetof(UIElement, shadow_dir.y));
3730 }
3731
3732 nk_layout_row_dynamic(NK_CTX, 20, 2);
3733
3734
3735 char container_names[MAX_UI_CONTAINERS][256];
3736 char * container_refs[MAX_UI_CONTAINERS];
3737 int found_containers = 0;
3738 int pc_indices[MAX_UI_CONTAINERS];
3739 int current_container_found_id = -1;
3740 for (int i = 0; i < MAX_UI_CONTAINERS; i++)
3741 {
3742 UIContainer * current = &m->containers[i];
3743 if (current->free) continue;
3744 sprintf(container_names[found_containers], "%s (%d)", current->id, current->uID);
3745 container_refs[found_containers] = container_names[found_containers];
3746 pc_indices[found_containers] = current->uID;
3747 if (el->parent_container == current->uID) current_container_found_id = found_containers;
3748 found_containers++;
3749
3750 }
3751
3752 int current_container = current_container_found_id;
3753 render_dropdown("Container", &current_container, (char**)container_refs, found_containers, 300, 100);
3754
3755 if (current_container != current_container_found_id)
3756 {
3757
3758 UIContainer * cs = m->containers;
3759 int cont_id = pc_indices[current_container];
3760
3761 if (el->parent_container != -1)
3762 {
3764 }
3765
3767 (int[8])
3768 {
3771 el->parent_container,
3772 cont_id
3773 }, UNDOUIELEMENT_CHANGE_CONTAINER), NULL, 0, 0, 0);
3774
3775
3776 if (cont_id != -1 && cont_id != el->container)
3777 {
3778 UIContainer * c = &cs[cont_id];
3779
3781 }
3782
3783 }
3784
3785
3786 if (el->parent_container != -1)
3787 {
3788 nk_layout_row_dynamic(NK_CTX, 20, 1);
3789
3790 if (nk_button_label(NK_CTX, "Remove From Container"))
3791 {
3792
3794 (int[8])
3795 {
3798 el->parent_container,
3799 }, UNDOUIELEMENT_REMOVE_FROM_CONTAINER), NULL, 0, 0, 0);
3800 UIContainer * cs = m->containers;
3802
3803 }
3804
3805 }
3806
3807 nk_layout_row_dynamic(NK_CTX, 20, 2);
3808 bool cont_valid = container_is_valid(el->container, el->menu);
3809 if (nk_button_label(NK_CTX, "Create Container"))
3810 {
3811
3812 UIContainer * cs = m->containers;
3813 uint8_t ** bytes = NULL;
3814 size_t byte_size = 0;
3815 int special_count = 0;
3816
3817 int old_container = el->container;
3818
3819 if (cont_valid)
3820 {
3821 bytes = malloc(sizeof(uint8_t*));
3822 bytes[0] = malloc(sizeof(UIContainer));
3823 UIContainer * cont = &cs[el->container];
3824 memcpy(bytes[0], cont, sizeof(UIContainer));
3826 byte_size += sizeof(uint8_t*);
3827 byte_size += sizeof(UIContainer);
3828 special_count = 1;
3829 }
3830 else
3831 {
3832 bytes[0] = NULL;
3833 }
3834
3837 (int[8])
3838 {
3841 old_container,
3842 }, UNDOUIELEMENT_CREATE_CONTAINER), bytes, byte_size, special_count, 0);
3843
3844 }
3845
3846 // we are here
3847 if (cont_valid)
3848 {
3849 UIContainer * cs = m->containers;
3850 UIContainer * c = &cs[el->container];
3851 if (nk_button_label(NK_CTX, "Delete Container"))
3852 {
3853 uint8_t ** bytes = malloc(sizeof(uint8_t*));
3854 size_t byte_size = sizeof(uint8_t*) + sizeof(UIContainer);;
3855
3856 int old_container = el->container;
3857 UIContainer * cont = &cs[el->container];
3858 bytes[0] = malloc(sizeof(UIContainer));
3859 memcpy(bytes[0], cont, sizeof(UIContainer));
3860
3862 (int[8])
3863 {
3866 old_container,
3867 -1,
3868 }, UNDOUIELEMENT_DELETE_CONTAINER), bytes, byte_size, 1, 0);
3870 }
3871
3872
3873
3874 nk_layout_row_dynamic(NK_CTX, 20, 1);
3875 if (nk_tree_push(NK_CTX, NK_TREE_NODE, "UI Containers", NK_MINIMIZED))
3876 {
3877
3879 nk_layout_row_dynamic(NK_CTX, 20, 1);
3880
3881 char id[256];
3882 sprintf(id, "%s (%d)", c->id, c->uID);
3883
3884 nk_label(NK_CTX, id, NK_TEXT_ALIGN_LEFT);
3885
3886 nk_layout_row_dynamic(NK_CTX, 20, 2);
3887
3888 ui_cont_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, element_cid_buffer, sizeof(element_cid_buffer), nk_filter_default);
3889
3890 nk_bool wrap = c->wrap == 1;
3891 if (nk_checkbox_label(NK_CTX, "Wrap", &wrap))
3892 {
3893 c->wrap = wrap;
3894 }
3895
3896 nk_bool mask = c->mask == 1;
3897 if (nk_checkbox_label(NK_CTX, "Mask", &mask))
3898 {
3899 c->mask = mask;
3900 }
3901
3902 nk_layout_row_dynamic(NK_CTX, 20, 1);
3903
3904 float cx = nk_propertyf(NK_CTX, "CPAD_L", 0.0f, c->padding.x, 1.0f, 0.001f, 0.001f);
3905
3906 float cy = nk_propertyf(NK_CTX, "CPAD_R", 0.0f, c->padding.y, 1.0f, 0.001f, 0.001f);
3907 float cz = nk_propertyf(NK_CTX, "CPAD_U", 0.0f, c->padding.z, 1.0f, 0.001f, 0.001f);
3908 float cw = nk_propertyf(NK_CTX, "CPAD_D", 0.0f, c->padding.w, 1.0f, 0.001f, 0.001f);
3909 if (check_equivalencyv4(&c->padding, (vec4){cx, cy, cz, cw}, &UIELEMENT_MENU.cpad, NULL))
3910 {
3911 push_nk_slider_undo(&UIELEMENT_MENU.cpad, container_undo, offsetof(UIContainer, padding));
3912 }
3913
3914 nk_layout_row_dynamic(NK_CTX, 20, 2);
3915 float xsc = nk_propertyf(NK_CTX, "C_Scroll_X", -1.0f, c->scroll_dir.x, 1.0f, 0.01f, 0.01f);
3916 bool xsc_dirty = false;
3917
3918 if (check_equivalencyf(&c->scroll_dir.x, xsc, &UIELEMENT_MENU.cscrollx, &xsc_dirty))
3919 {
3920 push_nk_slider_undo(&UIELEMENT_MENU.cscrollx, container_undo, offsetof(UIContainer, scroll_dir.x));
3921 }
3922 if (xsc_dirty)
3923 {
3924 c->scroll_dir = vec2_normalize((vec2){xsc, c->scroll_dir.y});
3925 }
3926 float ysc = nk_propertyf(NK_CTX, "C_Scroll_Y", -1.0f, c->scroll_dir.y, 1.0f, 0.01f, 0.01f);
3927 bool ysc_dirty = false;
3928 if (check_equivalencyf(&c->scroll_dir.y, ysc, &UIELEMENT_MENU.cscrolly, &ysc_dirty))
3929 {
3930 push_nk_slider_undo(&UIELEMENT_MENU.cscrolly, container_undo, offsetof(UIContainer, scroll_dir.y));
3931 }
3932 if (ysc_dirty)
3933 {
3934 c->scroll_dir = vec2_normalize((vec2){c->scroll_dir.x, ysc});
3935 }
3936
3937
3938 nk_layout_row_dynamic(NK_CTX, 20, 1);
3939 if (c->scrollbar != -1)
3940 {
3941 UIElement * sc = &m->elements[c->scrollbar];
3942 char current_scrollbar_name[256];
3943
3944 sprintf(current_scrollbar_name, "%s (%d)", sc->id, sc->uID);
3945
3946 nk_label(NK_CTX, current_scrollbar_name, NK_TEXT_ALIGN_LEFT);
3947
3948 }
3949
3950
3951
3952
3953 char scrollbar_names[MAX_UI_ELEMENTS][256];
3954 char * scrollbar_refs[MAX_UI_ELEMENTS];
3955 int found_scrollbars = 0;
3956 int sc_indices[MAX_UI_ELEMENTS];
3957 int current_scrollbar_found_id = -1;
3958 for (int i = 0; i < MAX_UI_ELEMENTS; i++)
3959 {
3960 UIElement * current = &m->elements[i];
3961 if (!current->visible || current->free || current->interactable != UI_INTERACTABLE_SLIDER) continue;
3962 sprintf(scrollbar_names[found_scrollbars], "%s (%d)", current->id, current->uID);
3963 scrollbar_refs[found_scrollbars] = scrollbar_names[found_scrollbars];
3964 sc_indices[found_scrollbars] = current->uID;
3965 if (c->scrollbar == current->uID) current_scrollbar_found_id = found_scrollbars;
3966 found_scrollbars++;
3967
3968 }
3969
3970 int current_scrollbar = current_scrollbar_found_id;
3971 render_dropdown("Scrollbar", &current_scrollbar, (char**)scrollbar_refs, found_scrollbars, 300, 100);
3972
3973 if (current_scrollbar != current_scrollbar_found_id)
3974 {
3975
3976 int element_id = sc_indices[current_scrollbar];
3977
3978 if (element_id != -1)
3979 {
3980
3981 int old_scrollbar = c->scrollbar;
3982 int old_scrollbar_container = -1;
3983 if (old_scrollbar != -1)
3984 {
3985 UIElement * old_sc = &els[old_scrollbar];
3986 if (old_sc->interactable == UI_INTERACTABLE_SLIDER)
3987 {
3988 old_scrollbar_container = old_sc->as.slider.container;
3989
3990 old_sc->as.slider.container = -1;
3991 }
3992 }
3993 c->scrollbar = element_id;
3994 UIElement * sc = &els[element_id];
3995 int old_slider_container = sc->as.slider.container;
3996 sc->as.slider.container = c->uID;
3997
3999 (
4001 {
4004 c->uID,
4005 old_scrollbar,
4006 element_id,
4007 old_slider_container,
4008 -1,
4010 , NULL, 0, 0, 0);
4011 }
4012
4013 }
4014
4015
4016
4017
4018 nk_tree_pop(NK_CTX);
4019
4020 }
4021
4022 }
4023
4024
4025 nk_layout_row_dynamic(NK_CTX, 20, 1);
4026 int interactable_type = el->interactable;
4027 render_dropdown("Interactable", &interactable_type, (char**)UI_INTERACTABLE_NAMES, UI_INTERACTABLE_MAX, 300, 100);
4028 if (interactable_type != el->interactable)
4029 {
4030
4031 el->interactable = interactable_type;
4032 switch(interactable_type)
4033 {
4035 UISlider * sl = &el->as.slider;
4036 *sl = DEFAULT_SLIDER;
4038 break;
4040 UILabel * l = &el->as.label;
4041 *l = DEFAULT_LABEL;
4042 break;
4043 default:
4044 break;
4045 }
4046
4047 }
4048
4049 switch(el->interactable)
4050 {
4051
4053 {
4054
4055 UISlider * sl = &el->as.slider;
4056
4057 nk_layout_row_dynamic(NK_CTX, 20, 1);
4058 if (nk_button_label(NK_CTX, "Compute Bounds"))
4059 {
4060 push_raw_bytes_undo(sl, sizeof(UISlider), el_structure, offsetof(UIElement, as));
4062 }
4063
4064 nk_layout_row_dynamic(NK_CTX, 20, 2);
4065 float dirx = nk_propertyf(NK_CTX, "Slider_X", 0.0f, sl->dir.x, 1.0f, 0.001f, 0.001f);
4066 bool dirx_dirty = false;
4067 if (check_equivalencyf(&sl->dir.x, dirx, &UIELEMENT_MENU.sliderx, &dirx_dirty))
4068 {
4069 push_nk_slider_undo(&UIELEMENT_MENU.sliderx, el_structure, offsetof(UIElement, as.slider.dir.x));
4070 }
4071
4072 if (dirx_dirty)
4073 {
4074 sl->dir = vec2_normalize((vec2){dirx, sl->dir.y});
4075 }
4076 float diry = nk_propertyf(NK_CTX, "Slider_Y", 0.0f, sl->dir.y, 1.0f, 0.001f, 0.001f);
4077 bool diry_dirty = false;
4078 if (check_equivalencyf(&sl->dir.y, diry, &UIELEMENT_MENU.slidery, &diry_dirty))
4079 {
4080 push_nk_slider_undo(&UIELEMENT_MENU.slidery, el_structure, offsetof(UIElement, as.slider.dir.y));
4081 }
4082 if (diry_dirty)
4083 {
4084 sl->dir = vec2_normalize((vec2){sl->dir.x, diry});
4085 }
4086
4087 float minval = nk_propertyf(NK_CTX, "Slider_MinVal", -5000.0f, sl->min_val, 5000.0f, 0.01f, 0.01f);
4088 if (check_equivalencyf(&sl->min_val, minval, &UIELEMENT_MENU.slidermin, NULL))
4089 {
4090 push_nk_slider_undo(&UIELEMENT_MENU.slidermin, el_structure, offsetof(UIElement, as.slider.min_val));
4091 }
4092 float maxval = nk_propertyf(NK_CTX, "Slider_MaxVal", -5000.0f, sl->max_val, 5000.0f, 0.01f, 0.01f);
4093 if (check_equivalencyf(&sl->max_val, maxval, &UIELEMENT_MENU.slidermax, NULL))
4094 {
4095 push_nk_slider_undo(&UIELEMENT_MENU.slidermax, el_structure, offsetof(UIElement, as.slider.max_val));
4096 }
4097 float len = nk_propertyf(NK_CTX, "Slider_Len", -5000.0f, sl->len , 5000.0f, 0.01f, 0.01f);
4098 if (check_equivalencyf(&sl->len, len, &UIELEMENT_MENU.sliderlen, NULL))
4099 {
4100 push_nk_slider_undo(&UIELEMENT_MENU.sliderlen, el_structure, offsetof(UIElement, as.slider.len));
4101 }
4102 float scroll_scale = nk_propertyf(NK_CTX, "Slider_ScrollScale", -5000.0f, sl->scroll_scale , 5000.0f, 0.01f, 0.01f);
4103
4104 if (check_equivalencyf(&sl->scroll_scale, scroll_scale, &UIELEMENT_MENU.sliderscrollscale, NULL))
4105 {
4106 push_nk_slider_undo(&UIELEMENT_MENU.sliderscrollscale, el_structure, offsetof(UIElement, as.slider.scroll_scale));
4107 }
4108
4109 }
4110 break;
4112 {
4113
4114 UILabel * l = &el->as.label;
4115
4116 nk_layout_row_dynamic(NK_CTX, 20, 2);
4117
4118 ui_label_id_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, label_id_buffer, sizeof(label_id_buffer), nk_filter_default);
4119
4120 if (nk_button_label(NK_CTX, "Assign Label"))
4121 {
4122 int label = find_text_box_in_menu(m, label_id_buffer);
4124 (int[8]){
4127 }, UNDOSPECIAL_NONE), offsetof(UIElement, as.label.box));
4128 l->box = label;
4129 }
4130
4131 if (nk_button_label(NK_CTX, "Create Label"))
4132 {
4133 // delete old label
4134 uint8_t ** bytes = NULL;
4135 int byte_count = 0;
4136 size_t byte_size = 0;
4137 int old_box = l->box;
4138 if (l->box != -1)
4139 {
4140 TextBox * tb = &m->text_boxes[l->box];
4141 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
4142 bytes[0] = malloc(sizeof(TextBox));
4143 bytes[1] = malloc(sizeof(char) * tb->text_cap);
4144 memcpy(bytes[0], tb, sizeof(TextBox));
4145 memcpy(bytes[1], tb->text, sizeof(char) * tb->text_cap);
4146 delete_text_box(m->uID, l->box);
4147 byte_size = sizeof(uint8_t*) + sizeof(TextBox) + sizeof(char) * tb->text_cap;
4148 byte_count = 2;
4149 }
4150
4151 int tb_id = create_text_box(m->uID);
4152 l->box = tb_id;
4155
4157 (
4159 (int[8])
4160 {
4163 old_box,
4164 tb_id,
4165 }, UNDOUIELEMENT_CREATE_LABEL), bytes, byte_size, byte_count, 0);
4166 }
4167
4168
4169 if (l->box != -1)
4170 {
4171 nk_layout_row_dynamic(NK_CTX, 20, 1);
4172 int selected_justify = l->align;
4173 render_dropdown("Justify", &selected_justify, (char**)JUSTIFY_NAMES, JUSTIFY_MAX, 300, 100);
4174 if (selected_justify != l->align)
4175 {
4177 (
4179 (int[8])
4180 {
4183 l->align,
4184
4185 }, UNDOUIELEMENT_JUSTIFY_LABEL), NULL, 0, 0, 0);
4186 l->align = selected_justify;
4188 }
4189
4190 }
4191 }
4192
4193 break;
4194 default:
4195 break;
4196
4197 }
4198
4199
4200 if (dir_dirty)
4201 {
4203 }
4204
4205
4206
4207
4208 }
4209 nk_end(NK_CTX);
4210
4211
4212
4213}
4214
4215
4217{
4218
4219 if
4220 (
4221 nk_begin
4222 (
4223 NK_CTX,
4225 nk_rect(420, 20, SCREEN_WIDTH - 420 * 2, 300),
4226 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
4227 )
4228 )
4229 {
4230 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
4231 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
4232
4233
4234 if (nk_tree_push(NK_CTX, NK_TREE_NODE, "Audio Probes", NK_MINIMIZED))
4235 {
4236
4237 nk_layout_row_dynamic(NK_CTX, 20, 1);
4238
4239 int iterations = nk_propertyi(NK_CTX, "Probe Iterations", 1, EDITOR_SETTINGS.audio_probe_iterations, 30000, 1, 1);
4240 if (iterations != EDITOR_SETTINGS.audio_probe_iterations)
4241 {
4243 }
4244 int bounces = nk_propertyi(NK_CTX, "Probe Bounces", 1, EDITOR_SETTINGS.audio_probe_bounces, 100, 1, 1);
4245 if (bounces != EDITOR_SETTINGS.audio_probe_bounces)
4246 {
4248 }
4249
4250
4251 float volume = nk_propertyf(NK_CTX, "Volume", 0.0, EDITOR_SETTINGS.volume, 10.0f, 0.01f, 0.01f);
4252 if (volume != EDITOR_SETTINGS.volume)
4253 {
4254 EDITOR_SETTINGS.volume = volume;
4255 }
4256 float wet = nk_propertyf(NK_CTX, "Wet", 0.0, EDITOR_SETTINGS.reverb_wet, 10.0f, 0.01f, 0.01f);
4257 if (wet != EDITOR_SETTINGS.reverb_wet)
4258 {
4260 }
4261
4262
4263 nk_tree_pop(NK_CTX);
4264 }
4265
4266
4267 if (nk_tree_push(NK_CTX, NK_TREE_NODE, "Audio Emitters", NK_MINIMIZED))
4268 {
4269
4270 nk_layout_row_dynamic(NK_CTX, 20, 2);
4272
4273 if (nk_button_label(NK_CTX, "Spawn Emitter"))
4274 {
4275
4276 AudioEmitter * fs_emitter = init_emitter("./sounds/footstep_01.wav", true, true, 1.0);
4279 }
4280
4282 {
4283
4286
4288
4289
4290 float volume = nk_propertyf(NK_CTX, "AEM Volume", 0.0, em->base_volume, 10.0f, 0.01f, 0.01f);
4291 if (check_equivalencyf(&em->base_volume, volume, &APROBE_MENU.volume, NULL))
4292 {
4293 push_nk_slider_undo(&APROBE_MENU.volume, emitter_us, offsetof(AudioEmitter, base_volume));
4294 }
4295
4296 nk_bool loop = em->is_loop == 1;
4297 if (nk_checkbox_label(NK_CTX, "AEM Loop", &loop))
4298 {
4299 em->is_loop = loop;
4300 }
4301 nk_bool occludable = em->is_occludable == 1;
4302 if (nk_checkbox_label(NK_CTX, "AEM Occludable", &occludable))
4303 {
4304 em->is_occludable = occludable;
4305 }
4306
4307 if (nk_button_label(NK_CTX, "Delete Sound Obj"))
4308 {
4309 if (em->is_loaded)
4310 {
4312 ma_sound_uninit(&em->sound_obj);
4313 em->is_loaded = false;
4314 }
4315 }
4316
4317 nk_label(NK_CTX, em->path, NK_TEXT_ALIGN_LEFT);
4318 if (nk_button_label(NK_CTX, "Set Sound"))
4319 {
4320
4322 {
4323
4324 push_raw_bytes_undo(em->path, sizeof(char) * 256, emitter_us, offsetof(AudioEmitter, path));
4325
4326 char complete_name[256];
4327 strcpy(complete_name, sound_registry.directory);
4328 strncat(complete_name, &(((char*)(sound_registry.names.buffer))[sound_registry.current_selection * 256]), 255 - strlen(sound_registry.directory));
4329 complete_name[255] = '\0';
4330 strcpy(em->path, complete_name);
4331 }
4332
4333 }
4334 if (nk_button_label(NK_CTX, "Load Sound Obj"))
4335 {
4336 if (!em->is_loaded)
4337 {
4339 load_emitter(em, em->path, em->is_loop, em->is_occludable, em->base_volume);
4340 }
4341 }
4342 if (nk_button_label(NK_CTX, "Delete Emitter"))
4343 {
4344 if (em->is_loaded)
4345 {
4346
4349
4350 }
4351 }
4352 if (nk_button_label(NK_CTX, "Play Emitter"))
4353 {
4354
4356 play_emitter(em, em->pos);
4357
4358 }
4359 if (nk_button_label(NK_CTX, "Stop Emitter"))
4360 {
4362 end_emitter(em);
4363 }
4364
4365
4366 }
4367 nk_tree_pop(NK_CTX);
4368 }
4369
4370 nk_layout_row_dynamic(NK_CTX, 20, 1);
4371 if (nk_tree_push(NK_CTX, NK_TREE_NODE, "Audio Portals", NK_MINIMIZED))
4372 {
4373
4374 aportal_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, aportal_name_buffer, sizeof(aportal_name_buffer), nk_filter_default);
4375 if (nk_button_text(NK_CTX, "Save Audio Portals", 12))
4376 {
4377
4378 char complete_name[256];
4379 strcpy(complete_name, aportal_registry.directory);
4380 strncat(complete_name, aportal_name_buffer, 255 - strlen(aportal_registry.directory));
4381 complete_name[255] = '\0';
4382 save_aportals(complete_name, &GLOBALS.audio_portals);
4383 }
4384
4385
4387
4388 if (nk_button_label(NK_CTX, "Load Audio Portals"))
4389 {
4390
4392 {
4393 char complete_name[256];
4394 strcpy(complete_name, aportal_registry.directory);
4395 strncat(complete_name, &(((char*)(aportal_registry.names.buffer))[aportal_registry.current_selection * 256]), 255 - strlen(aportal_registry.directory));
4396 complete_name[255] = '\0';
4397 load_aportals(complete_name, &GLOBALS.audio_portals);
4398 }
4399
4400 }
4401
4402 if (nk_button_label(NK_CTX, "Spawn Audio Portal"))
4403 {
4404
4406 init_new_audio_portal((vec3){0, 0, 0});
4408
4409 }
4410
4411 if (nk_button_label(NK_CTX, "Recalculate Audio Portal Paths"))
4412 {
4414 }
4416 {
4417
4420
4422
4423 if (nk_button_label(NK_CTX, "Delete Audio Portal"))
4424 {
4425
4426 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
4427 bytes[0] = malloc(sizeof(AudioPortal));
4428 memcpy(bytes[0], p, sizeof(AudioPortal));
4429 size_t byte_size = sizeof(AudioPortal) + sizeof(uint8_t*) * 2;
4430
4431 if (p->adjacent_portals.buffer)
4432 {
4433
4434 bytes[1] = malloc(sizeof(int) * p->adjacent_portals.capacity);
4435 memcpy(bytes[1], p->adjacent_portals.buffer, sizeof(int) * p->adjacent_portals.capacity);
4436 byte_size += sizeof(int) * p->adjacent_portals.capacity;
4437
4438 }
4439 else
4440 {
4441 bytes[1] = NULL;
4442 }
4443
4445
4448 }
4449
4450
4451 }
4452 nk_tree_pop(NK_CTX);
4453 }
4454 if (nk_tree_push(NK_CTX, NK_TREE_NODE, "APVs", NK_MINIMIZED))
4455 {
4456
4458 if (nk_button_label(NK_CTX, "Reset APVs"))
4459 {
4461 }
4462 nk_layout_row_dynamic(NK_CTX, 20, 1);
4463 apv_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, aprobe_name_buffer, sizeof(aprobe_name_buffer), nk_filter_default);
4464
4465 nk_layout_row_dynamic(NK_CTX, 20, 2);
4466 if (nk_button_label(NK_CTX, "Open APVs"))
4467 {
4468
4469 char complete_name[256];
4470 strcpy(complete_name, aprobe_registry.directory);
4471 strncat(complete_name, aprobe_name_buffer, 255 - strlen(aprobe_registry.directory));
4472 complete_name[255] = '\0';
4473 save_aprobes(complete_name);
4474
4475 }
4476
4477
4479
4480 if (nk_button_label(NK_CTX, "Load APVs"))
4481 {
4482
4484 {
4485 char complete_name[256];
4486 strcpy(complete_name, aprobe_registry.directory);
4487 strncat(complete_name, &(((char*)(aprobe_registry.names.buffer))[aprobe_registry.current_selection * 256]), 255 - strlen(aprobe_registry.directory));
4488 complete_name[255] = '\0';
4489 load_aprobes(complete_name);
4490 }
4491
4492 }
4493
4495 {
4496 nk_label(NK_CTX, GLOBALS.scene_data.APV_PATH, NK_TEXT_ALIGN_LEFT);
4497 }
4498
4499 nk_layout_row_dynamic(NK_CTX, 20, 1);
4500 scene_apv_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, scene_apv_name_buffer, sizeof(scene_apv_name_buffer), nk_filter_default);
4501
4502 nk_layout_row_dynamic(NK_CTX, 20, 2);
4503 if (nk_button_label(NK_CTX, "Open Scene APV"))
4504 {
4505
4506 char complete_name[256];
4507 strcpy(complete_name, scene_apv_registry.directory);
4508 strncat(complete_name, scene_apv_name_buffer, 255 - strlen(scene_apv_registry.directory));
4509 complete_name[255] = '\0';
4510 // save_scene_apvs(complete_name);
4512 {
4513 fclose(GLOBALS.scene_data.APV_FILE);
4515 }
4516 GLOBALS.scene_data.APV_FILE = fopen(complete_name, "rb+");
4518 {
4519 GLOBALS.scene_data.APV_FILE = fopen(complete_name, "wb+");
4520 }
4521 strcpy(GLOBALS.scene_data.APV_PATH, complete_name);
4522
4523 }
4524
4525
4527
4528 if (nk_button_label(NK_CTX, "Load Scene APV"))
4529 {
4530
4532 {
4533 char complete_name[256];
4534 strcpy(complete_name, scene_apv_registry.directory);
4535 strncat(complete_name, &(((char*)(scene_apv_registry.names.buffer))[scene_apv_registry.current_selection * 256]), 255 - strlen(scene_apv_registry.directory));
4536 complete_name[255] = '\0';
4538 {
4539 fclose(GLOBALS.scene_data.APV_FILE);
4541 }
4542 GLOBALS.scene_data.APV_FILE = fopen(complete_name, "rb+");
4544 {
4545 GLOBALS.scene_data.APV_FILE = fopen(complete_name, "wb+");
4546 }
4547 strcpy(GLOBALS.scene_data.APV_PATH, complete_name);
4548 }
4549
4550 }
4551 if (nk_button_label(NK_CTX, "Overwrite Scene APV"))
4552 {
4553
4555 {
4556 char complete_name[256];
4557 strcpy(complete_name, scene_apv_registry.directory);
4558 strncat(complete_name, &(((char*)(scene_apv_registry.names.buffer))[scene_apv_registry.current_selection * 256]), 255 - strlen(scene_apv_registry.directory));
4559 complete_name[255] = '\0';
4561 {
4562 fclose(GLOBALS.scene_data.APV_FILE);
4564 }
4565 GLOBALS.scene_data.APV_FILE = fopen(complete_name, "wb+");
4566 strcpy(GLOBALS.scene_data.APV_PATH, complete_name);
4567 }
4568
4569 }
4570
4571 if (nk_button_label(NK_CTX, "Spawn APV"))
4572 {
4573
4575
4577 memset(pv, 0, sizeof(ProbeVolume));
4578 pv->obb.extents = (vec3){1,1,1};
4579 pv->resolution = DEFAULT_APV_RES;
4580 pv->obb.rot = mat3_identity();
4581 pv->byte_offset = 0;
4582 pv->size = 0;
4583
4585
4586 }
4587
4588
4590 {
4591
4594
4595
4596 nk_layout_row_dynamic(NK_CTX, 20, 1);
4597 char pv_data[256];
4598 sprintf(pv_data, "APV Offset: %zu Size: %zu", pv->byte_offset, pv->size);
4599 nk_label(NK_CTX, pv_data, NK_TEXT_ALIGN_LEFT);
4600
4602
4604
4605 if (nk_button_label(NK_CTX, "Reset APV Rotation"))
4606 {
4607 push_raw_bytes_undo(&pv->obb.rot, sizeof(mat3), apv_structure, offsetof(ProbeVolume, obb.rot));
4608 pv->obb.rot = mat3_identity();
4609 }
4610 if (nk_button_label(NK_CTX, "Reset APV Size"))
4611 {
4612
4613 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
4614 bytes[0] = malloc(sizeof(size_t));
4615 *bytes[0] = pv->byte_offset;
4616 bytes[1] = malloc(sizeof(size_t));
4617 *bytes[1] = pv->size;
4618
4619 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(size_t) * 2;
4621
4622 pv->byte_offset = 0;
4623 pv->size = 0;
4624 }
4625 if (nk_button_label(NK_CTX, "Delete APV"))
4626 {
4627 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 1);
4628 bytes[0] = malloc(sizeof(ProbeVolume));
4629 memcpy(bytes[0], pv, sizeof(ProbeVolume));
4630 size_t byte_size = sizeof(uint8_t*) * 1 + sizeof(ProbeVolume);
4631
4633
4634
4637 }
4638 nk_bool overlay = EDITOR_SETTINGS.audio_probe_volume_overlay == 1;
4639 if (nk_checkbox_label(NK_CTX, "APV Overlay", &overlay))
4640 {
4642 }
4643
4644 // we dont actually undo the bake, just return byte size and offset to what they were before so you can overwrite what was saved to file
4645 if (nk_button_label(NK_CTX, "Bake APV"))
4646 {
4647
4648 uint8_t ** bytes = malloc(sizeof(uint8_t*) * 2);
4649 bytes[0] = malloc(sizeof(size_t));
4650 *bytes[0] = pv->byte_offset;
4651 bytes[1] = malloc(sizeof(size_t));
4652 *bytes[1] = pv->size;
4653
4654 size_t byte_size = sizeof(uint8_t*) * 2 + sizeof(size_t) * 2;
4656
4658
4659 }
4660
4661 }
4662
4663 nk_tree_pop(NK_CTX);
4664 }
4665
4666
4667
4668
4669
4670 }
4671 nk_end(NK_CTX);
4672}
4673
4674const char * MSAA_OPTIONS[] =
4675{
4676 "2", "4", "8", "16"
4677};
4678
4679
4680
4682{
4683
4685 {
4686
4687 if
4688 (
4689 nk_begin
4690 (
4691 NK_CTX,
4693 nk_rect(420, 20, SCREEN_WIDTH - 420 * 2, 300),
4694 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
4695 )
4696 )
4697 {
4698
4699 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
4700 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
4701
4702 nk_layout_row_dynamic(NK_CTX, 20, 1);
4703 if (nk_button_label(NK_CTX, "Spawn LProbe Volume"))
4704 {
4705
4707 memset(pv, 0, sizeof(ProbeVolume));
4708 pv->obb.extents = (vec3){1,1,1};
4710 pv->obb.rot = mat3_identity();
4711 pv->byte_offset = 0;
4712 pv->size = 0;
4713
4715 (
4720 NULL,
4721 0,
4722 0,
4723 0
4724 );
4725
4727
4728 }
4729
4730 lpv_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, lprobe_name_buffer, sizeof(lprobe_name_buffer), nk_filter_default);
4731
4732 nk_layout_row_dynamic(NK_CTX, 20, 2);
4733 if (nk_button_label(NK_CTX, "Open LPVs"))
4734 {
4735
4736 char complete_name[256];
4737 strcpy(complete_name, lprobe_registry.directory);
4738 strncat(complete_name, lprobe_name_buffer, 255 - strlen(lprobe_registry.directory));
4739 complete_name[255] = '\0';
4741
4742 }
4743
4745
4746 if (nk_button_label(NK_CTX, "Load LPVs"))
4747 {
4748
4750 {
4751
4752 char complete_name[256];
4753 strcpy(complete_name, lprobe_registry.directory);
4754 strncat(complete_name, &(((char*)(lprobe_registry.names.buffer))[lprobe_registry.current_selection * 256]), 255 - strlen(lprobe_registry.directory));
4755 complete_name[255] = '\0';
4757
4758 }
4759
4760 }
4762 {
4763 nk_label(NK_CTX, GLOBALS.scene_data.LPV_PATH, NK_TEXT_ALIGN_LEFT);
4764 }
4765 nk_layout_row_dynamic(NK_CTX, 20, 1);
4766
4767 scene_apv_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, scene_lpv_name_buffer, sizeof(scene_lpv_name_buffer), nk_filter_default);
4768
4769 nk_layout_row_dynamic(NK_CTX, 20, 2);
4770 if (nk_button_label(NK_CTX, "Open Scene LPV"))
4771 {
4772
4773 char complete_name[256];
4774 strcpy(complete_name, scene_lpv_registry.directory);
4775 strncat(complete_name, scene_lpv_name_buffer, 255 - strlen(scene_lpv_registry.directory));
4776 complete_name[255] = '\0';
4777 // save_scene_lpvs(complete_name);
4779 {
4780 fclose(GLOBALS.scene_data.LPV_FILE);
4782 }
4783 GLOBALS.scene_data.LPV_FILE = fopen(complete_name, "rb+");
4785 {
4786 GLOBALS.scene_data.LPV_FILE = fopen(complete_name, "wb+");
4787 }
4788 strcpy(GLOBALS.scene_data.LPV_PATH, complete_name);
4789
4790 }
4791
4792
4794
4795 if (nk_button_label(NK_CTX, "Load Scene LPV"))
4796 {
4797
4799 {
4800 char complete_name[256];
4801 strcpy(complete_name, scene_lpv_registry.directory);
4802 strncat(complete_name, &(((char*)(scene_lpv_registry.names.buffer))[scene_lpv_registry.current_selection * 256]), 255 - strlen(scene_lpv_registry.directory));
4803 complete_name[255] = '\0';
4805 {
4806 fclose(GLOBALS.scene_data.LPV_FILE);
4808 }
4809 GLOBALS.scene_data.LPV_FILE = fopen(complete_name, "rb+");
4811 {
4812 GLOBALS.scene_data.LPV_FILE = fopen(complete_name, "wb+");
4813 }
4814 strcpy(GLOBALS.scene_data.LPV_PATH, complete_name);
4815 }
4816
4817 }
4818 if (nk_button_label(NK_CTX, "Overwrite Scene LPV"))
4819 {
4820
4822 {
4823 char complete_name[256];
4824 strcpy(complete_name, scene_lpv_registry.directory);
4825 strncat(complete_name, &(((char*)(scene_lpv_registry.names.buffer))[scene_lpv_registry.current_selection * 256]), 255 - strlen(scene_lpv_registry.directory));
4826 complete_name[255] = '\0';
4828 {
4829 fclose(GLOBALS.scene_data.LPV_FILE);
4831 }
4832 GLOBALS.scene_data.LPV_FILE = fopen(complete_name, "wb+");
4833 strcpy(GLOBALS.scene_data.LPV_PATH, complete_name);
4834 }
4835
4836 }
4837 if (nk_button_label(NK_CTX, "Reset LPVs"))
4838 {
4839
4840 // im assuming that the lighting pv flag is equivalent to if there is a buffer loaded, therefore we don't need to do any more byte buffer shit
4841 uint8_t ** bytes = malloc(sizeof(uint8_t*) * LPV_SLOTS);
4842 size_t total_bytes = sizeof(uint8_t*) * LPV_SLOTS;
4843 for (int i = 0; i < LPV_SLOTS; i++)
4844 {
4846 {
4847
4848 size_t size = sizeof(float) * LPV_PADDED_COUNT * 3 * SH_MAX;
4849 bytes[i] = malloc(size);
4850 memcpy(bytes[i], GLOBALS.scene_data.LOADED_LIGHTING_PV[i].lprobes, size);
4851 total_bytes += size;
4852
4853 }
4854 else
4855 {
4856 bytes[i] = NULL;
4857 }
4858 }
4861 (int[8])
4862 {
4869 }, UNDOLPROBE_RESET_LPVS), bytes, total_bytes, LPV_SLOTS, 0);
4871 }
4872
4873
4875 {
4876
4879
4880 nk_layout_row_dynamic(NK_CTX, 20, 1);
4881 char pv_data[256];
4882 sprintf(pv_data, "LPV Offset: %zu Size: %zu", pv->byte_offset, pv->size);
4883 nk_label(NK_CTX, pv_data, NK_TEXT_ALIGN_LEFT);
4884
4885 // render_obb_widget("LPV", &pv->obb);
4887
4888 if (nk_button_label(NK_CTX, "Reset LPV Rotation"))
4889 {
4891 pv->obb.rot = mat3_identity();
4892 }
4893 if (nk_button_label(NK_CTX, "Reset LPV Size"))
4894 {
4896 pv->byte_offset = 0;
4897 pv->size = 0;
4898 }
4899 if (nk_button_label(NK_CTX, "Delete LProbe Volume"))
4900 {
4901
4902 uint8_t ** bytes = malloc(sizeof(uint8_t*));
4903 bytes[0] = malloc(sizeof(ProbeVolume));
4904 memcpy(bytes[0], pv, sizeof(ProbeVolume));
4905 size_t byte_size = sizeof(uint8_t*) + sizeof(ProbeVolume);
4906 int byte_count = 1;
4907
4909
4912 }
4913 nk_bool overlay = EDITOR_SETTINGS.lighting_probe_volume_overlay == 1;
4914 if (nk_checkbox_label(NK_CTX, "LPV Overlay", &overlay))
4915 {
4917 }
4918 if (nk_button_label(NK_CTX, "Bake LPV"))
4919 {
4921 }
4922
4923 }
4924
4925 }
4926 nk_end(NK_CTX);
4927 }
4928}
4929
4930
4931
4933{
4934
4935 if
4936 (
4937 nk_begin
4938 (
4939 NK_CTX,
4941 nk_rect(420, 20, SCREEN_WIDTH - 420 * 2, 300),
4942 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
4943 )
4944 )
4945 {
4946 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
4947 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
4948
4949 nk_layout_row_dynamic(NK_CTX, 20, 4);
4950
4951
4952 nk_text(NK_CTX, "Scene Name", 10, NK_TEXT_ALIGN_LEFT);
4953
4954 char scene_name_buffer[256];
4955
4956 scene_name_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, scene_name_buffer, sizeof(scene_name_buffer), nk_filter_default);
4957
4958 if (nk_button_text(NK_CTX, "Change Name", 11))
4959 {
4960
4961 push_raw_bytes_undo(GLOBALS.scene_data.name, sizeof(char) * 256, create_undo_structure(UNDOSTRUCT_GLOBAL, NULL, UNDOSPECIAL_NONE), offsetof(Globals, scene_data.name));
4962
4963 strcpy(GLOBALS.scene_data.name, scene_name_buffer);
4964 }
4965
4966
4967 nk_layout_row_dynamic(NK_CTX, 20, 3);
4968 char file_name_buffer[256];
4969 scene_file_name_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, file_name_buffer, sizeof(file_name_buffer), nk_filter_default);
4970 if (nk_button_label(NK_CTX, "Save Scene"))
4971 {
4972 scene_save(file_name_buffer);
4973 }
4974 if (nk_button_label(NK_CTX, "Save Scene Volumes"))
4975 {
4976 scene_save_volumes(file_name_buffer);
4977 }
4978 nk_layout_row_dynamic(NK_CTX, 20, 3);
4980 if (nk_button_label(NK_CTX, "Load Scene"))
4981 {
4983 {
4984 char complete_name[256];
4985 strcpy(complete_name, &(((char*)(scene_registry.names.buffer))[scene_registry.current_selection * 256]));
4986 // remove bin
4987 char * bin = strstr(complete_name, ".bin");
4988 if (bin) *bin = '\0';
4989 scene_load(complete_name);
4990 }
4991 }
4992 if (nk_button_label(NK_CTX, "Load Scene Volumes"))
4993 {
4995 {
4996 char complete_name[256];
4997 strcpy(complete_name, &(((char*)(scene_registry.names.buffer))[scene_registry.current_selection * 256]));
4998 // remove bin
4999 char * bin = strstr(complete_name, ".bin");
5000 if (bin) *bin = '\0';
5001 scene_load_volumes(complete_name);
5002 }
5003 }
5004
5005 nk_layout_row_dynamic(NK_CTX, 20, 3);
5006 char ui_buffer[256];
5007 ui_name_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, ui_buffer, sizeof(ui_buffer), nk_filter_default);
5008 if (nk_button_label(NK_CTX, "Save UI"))
5009 {
5010 save_ui(ui_buffer);
5011 }
5012
5014
5015 if (nk_button_label(NK_CTX, "Load UI"))
5016 {
5018 {
5019 char complete_name[256];
5020 strcpy(complete_name, &(((char*)(ui_registry.names.buffer))[ui_registry.current_selection * 256]));
5021 char * bin = strstr(complete_name, ".bin");
5022 if (bin) *bin = '\0';
5023 load_ui(complete_name);
5024 }
5025 }
5026
5027 nk_layout_row_dynamic(NK_CTX, 20, 4);
5028 ComboLabel gltf_label;
5029 gltf_label.item_count = 0;
5030 gltf_label.selected = 0;
5031 nk_bool gltf_names_expanded = nk_false;
5032 if (nk_combo_begin_label(NK_CTX, "Expand", nk_vec2(200, 200))) {
5033
5035 {
5037 }
5038 for (int i = 0; i < gltf_names_count; i++)
5039 {
5040 snprintf(gltf_label.buffer[gltf_label.item_count], LABEL_LEN, "%s", gltf_names[i]);
5041 gltf_label.ptrs[gltf_label.item_count] = gltf_label.buffer[gltf_label.item_count];
5042 if (EDITOR_SETTINGS.selected_gltf_file_id == gltf_label.item_count) gltf_label.selected = gltf_label.item_count;
5043 gltf_label.item_count++;
5044
5045 }
5046 gltf_file_names_open = nk_true;
5047 nk_layout_row_dynamic(NK_CTX, 20, 1);
5048 for (int i = 0; i < gltf_label.item_count; i++) {
5049 nk_bool sel = (i == gltf_label.selected);
5050 if (nk_selectable_label(NK_CTX, gltf_label.ptrs[i], NK_TEXT_LEFT, &sel)) {
5052 }
5053 }
5054 nk_combo_end(NK_CTX);
5055 }
5056 else
5057 {
5058 gltf_file_names_open = nk_false;
5059 }
5060
5061
5062 if (nk_button_label(NK_CTX, "Load Asset"))
5063 {
5066 {
5067 char complete_name[256];
5068 strcpy(complete_name, asset_dir);
5069 strncat(complete_name, gltf_names[EDITOR_SETTINGS.selected_gltf_file_id], 255 - strlen(asset_dir));
5070 load_gltf(complete_name);
5071
5072 }
5073 }
5074
5075 ComboLabel asset_label;
5076 asset_label.item_count = 0;
5077 asset_label.selected = 0;
5078 Asset * assets = CAST_VEC(GLOBALS.assets, Asset);
5079 for (int i = 0; i < GLOBALS.assets.count; i++)
5080 {
5081 snprintf(asset_label.buffer[asset_label.item_count], LABEL_LEN, "%s", assets[i].path);
5082 asset_label.ptrs[asset_label.item_count] = asset_label.buffer[asset_label.item_count];
5083 if (EDITOR_SETTINGS.selected_asset_id == asset_label.item_count) asset_label.selected = asset_label.item_count;
5084 asset_label.item_count++;
5085
5086 }
5087 if (nk_combo_begin_label(NK_CTX, asset_label.ptrs[asset_label.selected], nk_vec2(200, 200))) {
5088
5089 gltf_file_names_open = nk_true;
5090 nk_layout_row_dynamic(NK_CTX, 20, 1);
5091 for (int i = 0; i < asset_label.item_count; i++) {
5092 nk_bool sel = (i == asset_label.selected);
5093 if (nk_selectable_label(NK_CTX, asset_label.ptrs[i], NK_TEXT_LEFT, &sel)) {
5095 }
5096 }
5097 nk_combo_end(NK_CTX);
5098 }
5099 if (nk_button_label(NK_CTX, "Spawn Instance"))
5100 {
5101
5102 AssetInstance * ai = init_new_asset_instance(asset_label.ptrs[EDITOR_SETTINGS.selected_asset_id], (vec3){0,0,0}, (vec4){0,0,0,1}, (vec3){1,1,1});
5103
5105
5110 upload_lights();
5112 Mesh * meshes = CAST_VEC(GLOBALS.meshes, Mesh);
5114 for (int i = 0; i < GLOBALS.mesh_nodes.count; i++)
5115 {
5116 if (mns[i].mesh == -1 || mns[i].free) continue;
5117 if (!meshes[mns[i].mesh].static_mesh || !mns[i].static_mesh || mns[i].physics_mode) continue;
5118
5119 build_uv_islands(&mns[i]);
5120 }
5122 draw_dirty = true;
5123
5124
5125 }
5126
5127 char rprobe_name_buffer[256];
5128 rprobe_name_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, rprobe_name_buffer, sizeof(rprobe_name_buffer), nk_filter_default);
5129 if (nk_button_text(NK_CTX, "Save RProbes", 12))
5130 {
5131
5132 char complete_name[256];
5133 strcpy(complete_name, rprobe_dir);
5134 strncat(complete_name, rprobe_name_buffer, 255 - strlen(rprobe_dir));
5135 complete_name[255] = '\0';
5137
5138 }
5139 ComboLabel rprobe_label;
5140 rprobe_label.item_count = 0;
5141 rprobe_label.selected = 0;
5142 nk_bool rprobe_names_expanded = nk_false;
5143 if (nk_combo_begin_label(NK_CTX, "Expand", nk_vec2(200, 200))) {
5144
5146 {
5148 }
5149 for (int i = 0; i < rprobe_names_count; i++)
5150 {
5151 snprintf(rprobe_label.buffer[rprobe_label.item_count], LABEL_LEN, "%s", rprobe_names[i]);
5152 rprobe_label.ptrs[rprobe_label.item_count] = rprobe_label.buffer[rprobe_label.item_count];
5153 if (EDITOR_SETTINGS.selected_rprobe_file_id == rprobe_label.item_count) rprobe_label.selected = rprobe_label.item_count;
5154 rprobe_label.item_count++;
5155
5156 }
5157 rprobe_file_names_open = nk_true;
5158 nk_layout_row_dynamic(NK_CTX, 20, 1);
5159 for (int i = 0; i < rprobe_label.item_count; i++) {
5160 nk_bool sel = (i == rprobe_label.selected);
5161 if (nk_selectable_label(NK_CTX, rprobe_label.ptrs[i], NK_TEXT_LEFT, &sel)) {
5163 }
5164 }
5165 nk_combo_end(NK_CTX);
5166 }
5167 else
5168 {
5169 rprobe_file_names_open = nk_false;
5170 }
5171 if (nk_button_text(NK_CTX, "Load RProbes", 12))
5172 {
5175 {
5176 char complete_name[256];
5177 strcpy(complete_name, rprobe_dir);
5178 strncat(complete_name, rprobe_names[EDITOR_SETTINGS.selected_rprobe_file_id], 255 - strlen(rprobe_dir));
5179 complete_name[255] = '\0';
5181
5182 }
5183 }
5184
5185
5187 nk_layout_row_dynamic(NK_CTX, 20, 1);
5188 render_dropdown("Debug Views", &view, (char**)DVIEW_NAMES, DVIEW_MAX, 300, 100);
5190 {
5192 }
5193
5194 int ppview = EDITOR_SETTINGS.pp_dview;
5195 nk_layout_row_dynamic(NK_CTX, 20, 1);
5196 render_dropdown("PP Debug Views", &ppview, (char**)PPDVIEW_NAMES, PPDVIEW_MAX, 300, 100);
5197 if (ppview != EDITOR_SETTINGS.pp_dview)
5198 {
5199 EDITOR_SETTINGS.pp_dview = ppview;
5200 }
5201
5202 nk_layout_row_dynamic(NK_CTX, 20, 4);
5203 nk_bool ssao = EDITOR_SETTINGS.SSAO == 1;
5204 if (nk_checkbox_label(NK_CTX, "SSAO", &ssao))
5205 {
5206 EDITOR_SETTINGS.SSAO = ssao;
5207 }
5208 nk_bool ssr = EDITOR_SETTINGS.SSR == 1;
5209 if (nk_checkbox_label(NK_CTX, "SSR", &ssr))
5210 {
5211 EDITOR_SETTINGS.SSR = ssr;
5212 }
5213 nk_bool dof = EDITOR_SETTINGS.DOF == 1;
5214 if (nk_checkbox_label(NK_CTX, "DOF", &dof))
5215 {
5216 EDITOR_SETTINGS.DOF = dof;
5217 }
5218
5219 nk_bool mblur = EDITOR_SETTINGS.MBLUR == 1;
5220 if (nk_checkbox_label(NK_CTX, "MBLUR", &mblur))
5221 {
5222 EDITOR_SETTINGS.MBLUR = mblur;
5223 }
5224 nk_bool noise = EDITOR_SETTINGS.NOISE == 1;
5225 if (nk_checkbox_label(NK_CTX, "NOISE", &noise))
5226 {
5227 EDITOR_SETTINGS.NOISE = noise;
5228 }
5229 nk_bool aces = EDITOR_SETTINGS.ACES == 1;
5230 if (nk_checkbox_label(NK_CTX, "ACES", &aces))
5231 {
5232 EDITOR_SETTINGS.ACES = aces;
5233 }
5234 nk_bool lut = EDITOR_SETTINGS.LUT == 1;
5235 if (nk_checkbox_label(NK_CTX, "LUT", &lut))
5236 {
5237 EDITOR_SETTINGS.LUT = lut;
5238 }
5239
5240 nk_bool taa = EDITOR_SETTINGS.TAA == 1;
5241 if (nk_checkbox_label(NK_CTX, "TAA", &taa))
5242 {
5243 EDITOR_SETTINGS.TAA = taa;
5244 }
5245 nk_bool msaa = EDITOR_SETTINGS.MSAA == 1;
5246 if (nk_checkbox_label(NK_CTX, "MSAA", &msaa))
5247 {
5248 EDITOR_SETTINGS.MSAA = msaa;
5250 {
5254 glBindFramebuffer(GL_FRAMEBUFFER, MAIN_FBO.fbo);
5255 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GBUFFER_FBO.depth_rbo.i);
5256
5257 }
5258 else
5259 {
5260
5261 glBindFramebuffer(GL_FRAMEBUFFER, MAIN_RESOLVE_FBO.fbo);
5262 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, GBUFFER_RESOLVE_FBO.depth_texture.i, 0);
5263 }
5264 // else
5265 // {
5266 // allocate_gbuffer();
5267 // }
5268 }
5269 nk_bool full_gbuffer = EDITOR_SETTINGS.FULL_GBUFFER == 1;
5270 if (nk_checkbox_label(NK_CTX, "FULL_GBUFFER", &full_gbuffer))
5271 {
5272 EDITOR_SETTINGS.FULL_GBUFFER = full_gbuffer;
5273 if (full_gbuffer)
5274 {
5275 EDITOR_SETTINGS.MSAA = false;
5277 }
5278 else
5279 {
5281 }
5282 }
5283
5284
5285 nk_bool bloom = EDITOR_SETTINGS.BLOOM == 1;
5286 if (nk_checkbox_label(NK_CTX, "BLOOM", &bloom))
5287 {
5288 EDITOR_SETTINGS.BLOOM = bloom;
5289 }
5290 nk_bool vsync = EDITOR_SETTINGS.VSYNC == 1;
5291 if (nk_checkbox_label(NK_CTX, "VSYNC", &vsync))
5292 {
5293 EDITOR_SETTINGS.VSYNC = vsync;
5294 SDL_GL_SetSwapInterval(vsync);
5295 }
5296 nk_bool ui = EDITOR_SETTINGS.UI == 1;
5297 if (nk_checkbox_label(NK_CTX, "UI", &ui))
5298 {
5299 EDITOR_SETTINGS.UI = ui;
5300 }
5301
5302 int sample_sel;
5303 switch(GLOBALS.msaa_samples)
5304 {
5305 case 2:
5306 sample_sel = 0;
5307 break;
5308 case 4:
5309 sample_sel = 1;
5310 break;
5311 case 8:
5312 sample_sel = 2;
5313 break;
5314 case 16:
5315 sample_sel = 3;
5316 break;
5317 default:
5318 sample_sel = 0;
5319 break;
5320 }
5321
5322 render_dropdown("MSAA Samples", &sample_sel, (char**)MSAA_OPTIONS, MSAA_SAMPLE_OPTIONS_MAX, 300, 100);
5323 switch(sample_sel)
5324 {
5325 case 0:
5327 break;
5328 case 1:
5330 break;
5331 case 2:
5333 break;
5334 case 3:
5335 GLOBALS.msaa_samples = 16;
5336 break;
5337 default:
5339 break;
5340 }
5341
5342
5343
5344
5345
5346 nk_layout_row_dynamic(NK_CTX, 20, 1);
5347 float render_frame = nk_propertyf(NK_CTX, "Render framerate", 0.0f, EDITOR_SETTINGS.render_framerate_target, 120.0f, 0.01f, 0.01f);
5348 if (render_frame != EDITOR_SETTINGS.render_framerate_target)
5349 {
5351 }
5352 if (nk_tree_push(NK_CTX, NK_TREE_NODE, "Resolution", NK_MINIMIZED))
5353 {
5354 nk_layout_row_dynamic(NK_CTX, 20, 2);
5355
5356 int res_width = nk_propertyi(NK_CTX, "Res Width", 0, EDITOR_SETTINGS.res_width, 10000, 1, 1);
5357
5359 {
5361 }
5362
5363 int res_height = nk_propertyi(NK_CTX, "Res Height", 0, EDITOR_SETTINGS.res_height, 10000, 1, 1);
5365 {
5367 }
5368
5369
5370 nk_layout_row_dynamic(NK_CTX, 20, 2);
5373
5374 if (nk_button_label(NK_CTX, "Change FS"))
5375 {
5376
5378 (
5381 NULL,
5382 0,
5383 0,
5384 offsetof(EditorSettings, selected_fullscreen_option)
5385 );
5386
5388 }
5389 nk_layout_row_dynamic(NK_CTX, 20, 1);
5390 if (nk_button_label(NK_CTX, "Screen"))
5391 {
5392
5394 (
5397 NULL,
5398 0,
5399 0,
5400 offsetof(EditorSettings, selected_fullscreen_option)
5401 );
5402
5403 SCREEN_WIDTH = res_width;
5404 SCREEN_HEIGHT = res_height;
5405
5406 SDL_SetWindowSize(window, SCREEN_WIDTH, SCREEN_HEIGHT);
5407 }
5408 char render_res[64];
5409 sprintf(render_res, "%dx%d", RENDER_WIDTH, RENDER_HEIGHT);
5410 nk_label(NK_CTX, render_res, NK_TEXT_ALIGN_LEFT);
5411 if (nk_button_label(NK_CTX, "Render"))
5412 {
5414 (
5417 NULL,
5418 0,
5419 0,
5420 offsetof(EditorSettings, selected_fullscreen_option)
5421 );
5422
5423 RENDER_WIDTH = res_width;
5424 RENDER_HEIGHT = res_height;
5426 }
5427 char ssao_res[64];
5428 sprintf(ssao_res, "%dx%d", SSAO_FBO.w, SSAO_FBO.h);
5429 nk_label(NK_CTX, ssao_res, NK_TEXT_ALIGN_LEFT);
5430 if (nk_button_label(NK_CTX, "SSAO"))
5431 {
5432
5434 (
5437 NULL,
5438 0,
5439 0,
5440 offsetof(EditorSettings, selected_fullscreen_option)
5441 );
5443 }
5444 char coc_res[64];
5445 sprintf(coc_res, "%dx%d", COC_FBO.w, COC_FBO.h);
5446 nk_label(NK_CTX, coc_res, NK_TEXT_ALIGN_LEFT);
5447 if (nk_button_label(NK_CTX, "DOF"))
5448 {
5450 (
5453 NULL,
5454 0,
5455 0,
5456 offsetof(EditorSettings, selected_fullscreen_option)
5457 );
5459 }
5460 char bloom_res[64];
5461 sprintf(bloom_res, "%dx%d", BLOOM_PYRAMID[0].w, BLOOM_PYRAMID[0].h);
5462 nk_label(NK_CTX, bloom_res, NK_TEXT_ALIGN_LEFT);
5463 if (nk_button_label(NK_CTX, "BLOOM"))
5464 {
5465
5467 (
5470 NULL,
5471 0,
5472 0,
5473 offsetof(EditorSettings, selected_fullscreen_option)
5474 );
5476 }
5477 if (nk_button_label(NK_CTX, "Make Effects Halfsize"))
5478 {
5480 (
5482 (int[8]){
5486 },
5488 NULL,
5489 0,
5490 0,
5491 offsetof(EditorSettings, selected_fullscreen_option)
5492 );
5493 int half_width = RENDER_WIDTH / 2;
5494 int half_height = RENDER_HEIGHT / 2;
5495 change_ssao_res(half_width, half_height);
5496 change_dof_res(half_width, half_height);
5497 change_bloom_res(half_width, half_height);
5498
5499 }
5500 nk_tree_pop(NK_CTX);
5501 }
5502
5503 if (nk_tree_push(NK_CTX, NK_TREE_NODE, "DOF Settings", NK_MINIMIZED))
5504 {
5505
5506 nk_layout_row_dynamic(NK_CTX, 20, 2);
5507
5508 float flength = nk_propertyf(NK_CTX, "Focal Length", -5.0, EDITOR_SETTINGS.DOF_focal_length, 5.0f, 0.001f, 0.001f);
5510 {
5512 }
5513 float fstop = nk_propertyf(NK_CTX, "FStop", -5.0, EDITOR_SETTINGS.DOF_fstop, 10.0f, 0.001f, 0.001f);
5515 {
5517 }
5518 float sheight = nk_propertyf(NK_CTX, "Sensor Height", -5.0, EDITOR_SETTINGS.DOF_sensor_height, 5.0f, 0.0001f, 0.0001f);
5520 {
5522 }
5523 float mblurradius = nk_propertyf(NK_CTX, "Blur Radius", -5.0, EDITOR_SETTINGS.DOF_max_blur_radius, 5.0f, 0.001f, 0.001f);
5525 {
5527 }
5528
5529 nk_tree_pop(NK_CTX);
5530 }
5531
5532 }
5533 nk_end(NK_CTX);
5534
5535}
5536
5537
5538
5540{
5541
5542 if
5543 (
5544 nk_begin
5545 (
5546 NK_CTX,
5548 nk_rect(20, 20, 400, SCREEN_HEIGHT - 120),
5549 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
5550 )
5551 )
5552 {
5553 bool dirty = false;
5554
5555 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
5556 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
5557
5558
5559
5562 nk_layout_row_dynamic(NK_CTX, 20, 1);
5563
5564
5565 char idx[256];
5566 sprintf(idx, "%zu", mn->id);
5567 nk_label(NK_CTX, idx, NK_TEXT_ALIGN_LEFT);
5568
5570
5571
5572 Mesh * meshes = CAST_VEC(GLOBALS.meshes, Mesh);
5573 Mesh * m = &meshes[mn->mesh];
5574
5575 SubMesh * sms = CAST_VEC(m->submeshes, SubMesh);
5577
5578
5579 ComboLabel sm_label;
5580 sm_label.item_count = 0;
5581 sm_label.selected = 0;
5582 for (int i = 0; i < m->submeshes.count; i++)
5583 {
5584 snprintf(sm_label.buffer[sm_label.item_count], LABEL_LEN, "%d", i);
5585 sm_label.ptrs[sm_label.item_count] = sm_label.buffer[sm_label.item_count];
5586 if (EDITOR_SETTINGS.selected_sm_id == sm_label.item_count) sm_label.selected = sm_label.item_count;
5587 sm_label.item_count++;
5588
5589 }
5590 if (nk_combo_begin_label(NK_CTX, sm_label.ptrs[sm_label.selected], nk_vec2(200, 200))) {
5591 nk_layout_row_dynamic(NK_CTX, 15, 1);
5592 for (int i = 0; i < sm_label.item_count; i++) {
5593 nk_bool sel = (i == sm_label.selected);
5594 if (nk_selectable_label(NK_CTX, sm_label.ptrs[i], NK_TEXT_LEFT, &sel)) {
5597 }
5598 }
5599 nk_combo_end(NK_CTX);
5600 }
5601
5602 ComboLabel mat_label;
5603 mat_label.item_count = 0;
5604 mat_label.selected = 0;
5607 bool found = false;
5608 for (int i = 0; i < GLOBALS.materials.count; i++)
5609 {
5610
5611 Material * mat = &mats[i];
5612 snprintf(mat_label.buffer[mat_label.item_count], LABEL_LEN, "%s", mats[i].name);
5613 mat_label.ptrs[mat_label.item_count] = mat_label.buffer[mat_label.item_count];
5614 if (EDITOR_SETTINGS.selected_material_mn_id == mat_label.item_count) mat_label.selected = mat_label.item_count;
5615 mat_label.item_count++;
5616 }
5617
5618
5619 int selection = -1;
5620
5621 if (nk_combo_begin_label(NK_CTX, mat_label.ptrs[mat_label.selected], nk_vec2(200, 200))) {
5622 nk_layout_row_dynamic(NK_CTX, 15, 1);
5623 for (int i = 0; i < mat_label.item_count; i++) {
5624 nk_bool sel = (i == mat_label.selected);
5625 if (nk_selectable_label(NK_CTX, mat_label.ptrs[i], NK_TEXT_LEFT, &sel)) {
5627 }
5628 }
5629 nk_combo_end(NK_CTX);
5630 }
5631
5632
5633
5634
5635 if (nk_button_text(NK_CTX, "Change Material", 15))
5636 {
5637
5638
5640
5642
5643
5644
5645
5646 draw_dirty = true;
5647 }
5648
5649 nk_layout_row_dynamic(NK_CTX, 20, 1);
5650 if (nk_button_text(NK_CTX, "Open Material", 8))
5651 {
5654 nk_window_show(NK_CTX, "Material", NK_SHOWN);
5655 }
5656
5657 if (nk_option_label(NK_CTX, "Skip Directional Light", mn->skip_directional_uv_lighting == 1))
5658 {
5660 }
5661 else
5662 {
5663
5664 mn->skip_directional_uv_lighting = false;
5665 }
5666
5667 nk_layout_row_dynamic(NK_CTX, 20, 1);
5668 if (mn->ent)
5669 {
5670 Entity * ent = mn->ent;
5671 if (!ent->free)
5672 {
5673
5674
5675 if (nk_button_label(NK_CTX, "Select Entity MN"))
5676 {
5680 }
5681
5682
5683 }
5684 }
5685
5686 if (dirty)
5687 {
5689 }
5690
5691 }
5692 nk_end(NK_CTX);
5693}
5694
5696{
5697 if
5698 (
5699 nk_begin
5700 (
5701 NK_CTX,
5703 nk_rect(SCREEN_WIDTH - 420, 20, 400, SCREEN_HEIGHT),
5704 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
5705 )
5706 )
5707 {
5708
5709 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
5710 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) {
5711 NUKLEAR_HOVERED = true;
5712 }
5713
5716
5717
5718 bool dirty = false;
5719
5720 nk_layout_row_dynamic(NK_CTX, 20, 1);
5721 struct nk_colorf diffuse_color = {
5722 mat->kd.x,
5723 mat->kd.y,
5724 mat->kd.z,
5725 mat->kd.w,
5726 };
5727 nk_label(NK_CTX, "Diffuse", NK_TEXT_LEFT);
5728
5729 if (nk_combo_begin_color(NK_CTX, nk_rgba_cf(diffuse_color), nk_vec2(150, 150))) {
5730 nk_layout_row_dynamic(NK_CTX, 120, 1);
5731 diffuse_color = nk_color_picker(NK_CTX, diffuse_color, NK_RGBA);
5732
5733
5734 nk_layout_row_dynamic(NK_CTX, 25, 1);
5735 diffuse_color.r = nk_propertyf(NK_CTX, "#R:", 0.0f, diffuse_color.r, 1.0f, 0.01f, 0.005f);
5736 diffuse_color.g = nk_propertyf(NK_CTX, "#G:", 0.0f, diffuse_color.g, 1.0f, 0.01f, 0.005f);
5737 diffuse_color.b = nk_propertyf(NK_CTX, "#B:", 0.0f, diffuse_color.b, 1.0f, 0.01f, 0.005f);
5738 diffuse_color.a = nk_propertyf(NK_CTX, "#A:", 0.0f, diffuse_color.a, 1.0f, 0.01f, 0.005f);
5739
5740 if (diffuse_color.r != mat->kd.x)
5741 {
5742 mat->kd.x = diffuse_color.r;
5743 dirty = true;
5744 }
5745 if (diffuse_color.g != mat->kd.y)
5746 {
5747 mat->kd.y = diffuse_color.g;
5748 dirty = true;
5749 }
5750 if (diffuse_color.b != mat->kd.z)
5751 {
5752 mat->kd.z = diffuse_color.b;
5753 dirty = true;
5754 }
5755 if (diffuse_color.a != mat->kd.w)
5756 {
5757 mat->kd.w = diffuse_color.a;
5758 dirty = true;
5759 }
5760 nk_combo_end(NK_CTX);
5761 }
5762 struct nk_colorf ambient_color = {
5763 mat->ka.x,
5764 mat->ka.y,
5765 mat->ka.z,
5766 1.0f
5767 };
5768 nk_label(NK_CTX, "Ambient", NK_TEXT_LEFT);
5769
5770 if (nk_combo_begin_color(NK_CTX, nk_rgb_cf(ambient_color), nk_vec2(150, 150))) {
5771 nk_layout_row_dynamic(NK_CTX, 120, 1);
5772 ambient_color = nk_color_picker(NK_CTX, ambient_color, NK_RGB);
5773
5774
5775 nk_layout_row_dynamic(NK_CTX, 25, 1);
5776 ambient_color.r = nk_propertyf(NK_CTX, "#R:", 0.0f, ambient_color.r, 1.0f, 0.01f, 0.005f);
5777 ambient_color.g = nk_propertyf(NK_CTX, "#G:", 0.0f, ambient_color.g, 1.0f, 0.01f, 0.005f);
5778 ambient_color.b = nk_propertyf(NK_CTX, "#B:", 0.0f, ambient_color.b, 1.0f, 0.01f, 0.005f);
5779
5780 if (ambient_color.r != mat->ka.x)
5781 {
5782 mat->ka.x = ambient_color.r;
5783 dirty = true;
5784 }
5785 if (ambient_color.g != mat->ka.y)
5786 {
5787 mat->ka.y = ambient_color.g;
5788 dirty = true;
5789 }
5790 if (ambient_color.b != mat->ka.z)
5791 {
5792 mat->ka.z = ambient_color.b;
5793 dirty = true;
5794 }
5795 nk_combo_end(NK_CTX);
5796 }
5797 struct nk_colorf specular_color = {
5798 mat->ks.x,
5799 mat->ks.y,
5800 mat->ks.z,
5801 1.0f
5802 };
5803 nk_label(NK_CTX, "Specular", NK_TEXT_LEFT);
5804
5805 if (nk_combo_begin_color(NK_CTX, nk_rgb_cf(specular_color), nk_vec2(150, 150))) {
5806 nk_layout_row_dynamic(NK_CTX, 120, 1);
5807 specular_color = nk_color_picker(NK_CTX, specular_color, NK_RGB);
5808
5809
5810 nk_layout_row_dynamic(NK_CTX, 25, 1);
5811 specular_color.r = nk_propertyf(NK_CTX, "#R:", 0.0f, specular_color.r, 1.0f, 0.01f, 0.005f);
5812 specular_color.g = nk_propertyf(NK_CTX, "#G:", 0.0f, specular_color.g, 1.0f, 0.01f, 0.005f);
5813 specular_color.b = nk_propertyf(NK_CTX, "#B:", 0.0f, specular_color.b, 1.0f, 0.01f, 0.005f);
5814
5815 if (specular_color.r != mat->ks.x)
5816 {
5817 mat->ks.x = specular_color.r;
5818 dirty = true;
5819 }
5820 if (specular_color.g != mat->ks.y)
5821 {
5822 mat->ks.y = specular_color.g;
5823 dirty = true;
5824 }
5825 if (specular_color.b != mat->ks.z)
5826 {
5827 mat->ks.z = specular_color.b;
5828 dirty = true;
5829 }
5830 nk_combo_end(NK_CTX);
5831 }
5832
5833 struct nk_colorf emissive_color = {
5834 mat->ke.x,
5835 mat->ke.y,
5836 mat->ke.z,
5837 1.0f
5838 };
5839 nk_label(NK_CTX, "Emissive", NK_TEXT_LEFT);
5840
5841 if (nk_combo_begin_color(NK_CTX, nk_rgb_cf(emissive_color), nk_vec2(150, 150))) {
5842 nk_layout_row_dynamic(NK_CTX, 120, 1);
5843 emissive_color = nk_color_picker(NK_CTX, emissive_color, NK_RGB);
5844
5845
5846 nk_layout_row_dynamic(NK_CTX, 25, 1);
5847 emissive_color.r = nk_propertyf(NK_CTX, "#R:", 0.0f, emissive_color.r, 1.0f, 0.01f, 0.005f);
5848 emissive_color.g = nk_propertyf(NK_CTX, "#G:", 0.0f, emissive_color.g, 1.0f, 0.01f, 0.005f);
5849 emissive_color.b = nk_propertyf(NK_CTX, "#B:", 0.0f, emissive_color.b, 1.0f, 0.01f, 0.005f);
5850
5851 if (emissive_color.r != mat->ke.x)
5852 {
5853 mat->ke.x = emissive_color.r;
5854 dirty = true;
5855 }
5856 if (emissive_color.g != mat->ke.y)
5857 {
5858 mat->ke.y = emissive_color.g;
5859 dirty = true;
5860 }
5861 if (emissive_color.b != mat->ke.z)
5862 {
5863 mat->ke.z = emissive_color.b;
5864 dirty = true;
5865 }
5866 nk_combo_end(NK_CTX);
5867 }
5868
5869
5870 nk_layout_row_dynamic(NK_CTX, 20, 1);
5871 nk_bool arm_override = mat->override_arm == 1;
5872 if (nk_checkbox_label(NK_CTX, "Arm Override", &arm_override))
5873 {
5874 dirty = true;
5875 mat->override_arm = arm_override;
5876 }
5877
5878 float metallic = nk_propertyf(NK_CTX, "Metallic", -1, mat->metallic, 2, 0.001, 0.001);
5879 if (metallic != mat->metallic)
5880 {
5881 dirty = true;
5882 mat->metallic = metallic;
5883 }
5884 float roughness = nk_propertyf(NK_CTX, "Roughness", -1, mat->roughness, 2, 0.001, 0.001);
5885 if (roughness != mat->roughness)
5886 {
5887 dirty = true;
5888 mat->roughness = roughness;
5889 }
5890 char am[256];
5891 sprintf(am, "Alpha Mode: %d", mat->alpha_mode);
5892 if (nk_button_label(NK_CTX, am))
5893 {
5894 dirty = true;
5895 mat->alpha_mode = !mat->alpha_mode;
5896 }
5897 float em_str = nk_propertyf(NK_CTX, "Emissive Strength", 0, mat->emissive_strength, 100000, 0.01, 0.01);
5898 if (em_str != mat->emissive_strength)
5899 {
5900 dirty = true;
5901 mat->emissive_strength = em_str;
5902 }
5903 float ao_str = nk_propertyf(NK_CTX, "AO Strength", 0, mat->ao_strength, 100000, 0.01, 0.01);
5904 if (ao_str != mat->ao_strength)
5905 {
5906 dirty = true;
5907 mat->ao_strength = ao_str;
5908 }
5909
5910
5911 if (dirty)
5912 {
5914 }
5915
5916
5917
5918
5919 }
5920 nk_end(NK_CTX);
5921
5922}
5923
5924
5926{
5927 if
5928 (
5929 nk_begin
5930 (
5931 NK_CTX,
5932 "Light Menu",
5933 nk_rect(SCREEN_WIDTH - 420, 20, 400, SCREEN_HEIGHT),
5934 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
5935 )
5936 )
5937 {
5938 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
5939 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
5940
5941
5942 Light * lights = CAST_VEC(GLOBALS.lights, Light);
5943 Light * light = &lights[EDITOR_SETTINGS.selected_light_id];
5944
5945 bool dirty = false;
5946
5947 nk_layout_row_dynamic(NK_CTX, 20, 1);
5948
5949 light_name_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, light_name_buffer, sizeof(light_name_buffer), nk_filter_default);
5950
5951 nk_layout_row_dynamic(NK_CTX, 20, 2);
5952 if (nk_button_label(NK_CTX, "Save Lights"))
5953 {
5954
5955 char complete_name[256];
5956 strcpy(complete_name, light_registry.directory);
5957 strncat(complete_name, light_name_buffer, 255 - strlen(light_registry.directory));
5958 complete_name[255] = '\0';
5959 save_vector(complete_name, &GLOBALS.lights);
5960 }
5961
5962
5964
5965 if (nk_button_label(NK_CTX, "Load Lights"))
5966 {
5967
5969 {
5970 char complete_name[256];
5971 strcpy(complete_name, light_registry.directory);
5972 strncat(complete_name, &(((char*)(light_registry.names.buffer))[light_registry.current_selection * 256]), 255 - strlen(light_registry.directory));
5973 complete_name[255] = '\0';
5974 load_vector(complete_name, &GLOBALS.lights);
5975 }
5976
5977 }
5978
5979
5980 nk_layout_row_dynamic(NK_CTX, 20, 1);
5981 char buf[128];
5982 sprintf(buf, "Selected Light %d", EDITOR_SETTINGS.selected_light_id);
5983 nk_text(NK_CTX, buf, strlen(buf), NK_TEXT_ALIGN_LEFT);
5984 if (light->entity_id != -1)
5985 {
5986 Entity * ent = &ENTITIES[light->entity_id];
5987 if (!ent->free)
5988 {
5989 if (nk_button_label(NK_CTX, "Select Entity Light"))
5990 {
5994 }
5995
5996 }
5997 }
5998
5999 if (nk_button_label(NK_CTX, "Build Light BVH"))
6000 {
6002 }
6003
6004 if (nk_button_label(NK_CTX, "Create Light"))
6005 {
6006 Light * new_light = vector_expand(&GLOBALS.lights, 1);
6007 memset(new_light, 0, sizeof(Light));
6008 *new_light = default_light;
6009 Entity * ent = create_entity(NULL, -1, false, false);
6010 new_light->entity_id = ent->id;
6011
6017 NULL, 0, 0, 0);
6018
6020 }
6021
6022 if (nk_button_label(NK_CTX, "Delete Light"))
6023 {
6024
6026
6027 uint8_t ** bytes = malloc(sizeof(uint8_t*));
6028 bytes[0] = malloc(sizeof(Light));
6029 memcpy(bytes[0], light, sizeof(Light));
6030 size_t total_bytes = sizeof(uint8_t*) + sizeof(Light);
6032
6033 for (int i = EDITOR_SETTINGS.selected_light_id; i < GLOBALS.lights.count-1; i++)
6034 {
6035 Light * l = &ls[i];
6036 *l = ls[i+1];
6037 }
6039 }
6040
6041
6042 struct nk_colorf light_color = {
6043 light->rgb.x,
6044 light->rgb.y,
6045 light->rgb.z,
6046 1.0f
6047 };
6048 nk_label(NK_CTX, "Color", NK_TEXT_LEFT);
6049
6050 if (nk_combo_begin_color(NK_CTX, nk_rgb_cf(light_color), nk_vec2(150, 150))) {
6051 nk_layout_row_dynamic(NK_CTX, 120, 1);
6052 light_color = nk_color_picker(NK_CTX, light_color, NK_RGB);
6053
6054
6055 nk_layout_row_dynamic(NK_CTX, 25, 1);
6056 light_color.r = nk_propertyf(NK_CTX, "#R:", 0.0f, light_color.r, 1.0f, 0.01f, 0.005f);
6057 light_color.g = nk_propertyf(NK_CTX, "#G:", 0.0f, light_color.g, 1.0f, 0.01f, 0.005f);
6058 light_color.b = nk_propertyf(NK_CTX, "#B:", 0.0f, light_color.b, 1.0f, 0.01f, 0.005f);
6059
6060 if (check_equivalencyf(&light->rgb.x, light_color.r, &LIGHT_MENU.color_r, &dirty))
6061 {
6063 }
6064 if (check_equivalencyf(&light->rgb.y, light_color.g, &LIGHT_MENU.color_g, &dirty))
6065 {
6066
6068 }
6069 if (check_equivalencyf(&light->rgb.z, light_color.b, &LIGHT_MENU.color_b, &dirty))
6070 {
6072
6073 }
6074 nk_combo_end(NK_CTX);
6075 }
6076
6077 nk_layout_row_dynamic(NK_CTX, 20, 3);
6078 float xval = nk_propertyf(NK_CTX, "X", -1000.0f, light->pos.x, 1000.0f, 0.01f, 0.01f);
6079 float yval = nk_propertyf(NK_CTX, "Y", -1000.0f, light->pos.y, 1000.0f, 0.01f, 0.01f);
6080 float zval = nk_propertyf(NK_CTX, "Z", -1000.0f, light->pos.z, 1000.0f, 0.01f, 0.01f);
6081 if (check_equivalencyf(&light->pos.x, xval, &LIGHT_MENU.x, &dirty))
6082 {
6084 }
6085 if (check_equivalencyf(&light->pos.y, yval, &LIGHT_MENU.y, &dirty))
6086 {
6088 }
6089 if (check_equivalencyf(&light->pos.z, zval, &LIGHT_MENU.z, &dirty))
6090 {
6092 }
6093 bool dir_dirty = false;
6094
6095 xval = nk_propertyf(NK_CTX, "RX", -1000.0f, light->dir.x, 1000.0f, 0.01f, 0.01f);
6096 yval = nk_propertyf(NK_CTX, "RY", -1000.0f, light->dir.y, 1000.0f, 0.01f, 0.01f);
6097 zval = nk_propertyf(NK_CTX, "RZ", -1000.0f, light->dir.z, 1000.0f, 0.01f, 0.01f);
6098 if (check_equivalencyv3(&light->dir, (vec3){xval, yval, zval}, &LIGHT_MENU.rx, &dir_dirty))
6099 {
6100
6102 }
6103 if (dir_dirty)
6104 {
6105 light->dir = vec3_normalize(light->dir);
6106 dirty = true;
6107 }
6108 nk_layout_row_dynamic(NK_CTX, 20, 1);
6109 float intensity = nk_propertyf(NK_CTX, "Intensity", 0, light->intensity, 10000, 0.1, 0.1);
6110 if (check_equivalencyf(&light->intensity, intensity, &LIGHT_MENU.intensity, &dirty))
6111 {
6112
6114 }
6115
6116 nk_layout_row_dynamic(NK_CTX, 20, 2);
6117 float threshold = nk_propertyf(NK_CTX, "Threshold", 0, light->threshold, 100, 0.0001, 0.0001);
6118 if (check_equivalencyf(&light->threshold, threshold, &LIGHT_MENU.threshold, &dirty))
6119 {
6121 }
6122
6123 char radius[256];
6124 sprintf(radius, "Radius: %f", light->radius);
6125 nk_label(NK_CTX, radius, NK_TEXT_ALIGN_LEFT);
6126
6127
6128 if (light->light_type == SPOT_LIGHT)
6129 {
6130
6131 light->cone_angle = clamp(light->cone_angle, 0, 20);
6132 light->penumbra = clamp(light->penumbra, 0, 20);
6133
6134 float cone_angle= nk_propertyf(NK_CTX, "Cone Angle", 0, light->cone_angle, 20, 0.1, 0.1);
6135 if (check_equivalencyf(&light->cone_angle, cone_angle, &LIGHT_MENU.cone_angle, &dirty))
6136 {
6137
6139 }
6140 float penumbra= nk_propertyf(NK_CTX, "Penumbra", 0, light->penumbra, 20, 0.1, 0.1);
6141 if (check_equivalencyf(&light->penumbra, penumbra, &LIGHT_MENU.penumbra, &dirty))
6142 {
6144
6145 }
6146
6147
6148 }
6149 int light_type = nk_propertyi(NK_CTX, "Light Type", 0, (int)light->light_type, 2, 1, 1);
6150
6151 // this one will not work btw the type is not an int so dont cry when it doesnt work
6152 int lt = light->light_type;
6153 if (check_equivalencyi(&lt, light_type, &LIGHT_MENU.light_type, &dirty))
6154 {
6156 }
6157 if (light->light_type != light_type)
6158 {
6159 light->light_type = light_type;
6160 }
6161
6162
6163 nk_layout_row_dynamic(NK_CTX, 20, 2);
6164 float mfactor = nk_propertyf(NK_CTX, "mfactor", 0.0f, EDITOR_SETTINGS.mfactor, 10, 0.001, 0.001);
6165
6167 {
6169
6170 }
6171
6172 nk_bool mf = EDITOR_SETTINGS.mfactor_enabled == 1;
6173 if (nk_checkbox_label(NK_CTX, "M Factor", &mf))
6174 {
6175
6176
6177 LIGHT_MENU.mfactor_enabled.byte_size = sizeof(bool);
6180
6182 }
6183
6184 nk_layout_row_dynamic(NK_CTX, 20, 1);
6185
6186 float texels_per_unit = nk_propertyf(NK_CTX, "Texels Per Unit", 0, EDITOR_SETTINGS.texels_per_uv_unit, 10, 0.1, 0.1);
6187
6189 {
6190
6192
6193 }
6194
6195
6196 nk_layout_row_dynamic(NK_CTX, 20, 2);
6197 if (nk_button_label(NK_CTX, "Regenerate Texels"))
6198 {
6199
6201 }
6202
6203 if (nk_button_label(NK_CTX, "Assign New Texels"))
6204 {
6205
6207 }
6208
6209 nk_layout_row_dynamic(NK_CTX, 20, 1);
6210 int lm_iterations = nk_propertyi(NK_CTX, "Iterations", 0, EDITOR_SETTINGS.lm_iterations, 2048, 1, 1);
6211
6213 {
6215 }
6216
6217 int probe_iterations = nk_propertyi(NK_CTX, "Probe Iterations", 0, EDITOR_SETTINGS.probe_iterations, 2048, 1, 1);
6218
6220 {
6221
6223 }
6224
6225 int ao_iterations = nk_propertyi(NK_CTX, "AO Iterations", 0, EDITOR_SETTINGS.ao_iterations, 2048, 1, 1);
6226
6228 {
6230 }
6231
6232 float ao_threshold = nk_propertyf(NK_CTX, "AO Threshold", 0, EDITOR_SETTINGS.ao_threshold, 20, 0.1, 0.1);
6233
6235 {
6237 }
6238
6239
6240 if (nk_button_text(NK_CTX, "Regenerate", 10))
6241 {
6242
6243 dirty = true;
6246
6248 upload_lights();
6250 for (int i = 0; i < GLOBALS.scene_data.lightmap_data.islands.count; i++)
6251 {
6252 uvis[i].currently_rasterizing = true;
6253 }
6256
6257 };
6258
6259
6260 static char lightmap_buffer[256] = {0};
6261
6262 nk_layout_row_dynamic(NK_CTX, 20, 2);
6263 lm_name_flags = nk_edit_string_zero_terminated(NK_CTX, NK_EDIT_FIELD, lightmap_buffer, sizeof(lightmap_buffer), nk_filter_default);
6264
6265 if (nk_button_label(NK_CTX, "Save LM"))
6266 {
6267
6268 char lm_name[256];
6269 strcpy(lm_name, lightmap_registry.directory);
6270 strcat(lm_name, lightmap_buffer);
6271 strcat(lm_name, "_lm.bin");
6273 }
6274
6275 nk_layout_row_dynamic(NK_CTX, 20, 2);
6277 if (nk_button_label(NK_CTX, "Load LM"))
6278 {
6279
6281 {
6282 char complete_name[256];
6283 strcpy(complete_name, lightmap_registry.directory);
6284 strncat(complete_name, &(((char*)(lightmap_registry.names.buffer))[lightmap_registry.current_selection * 256]), 255 - strlen(lightmap_registry.directory));
6285 complete_name[255] = '\0';
6287 }
6288
6289 }
6290
6291
6292
6293 bool expand_aabb = false;
6294
6295 nk_layout_row_dynamic(NK_CTX, 20, 3);
6296
6297 float aabbx = nk_propertyf(NK_CTX, "lm_aabbX", -1000.0f, EDITOR_SETTINGS.lm_aabb.center.x, 1000.0f, 0.01f, 0.01f);
6299 {
6301 }
6302
6303 float aabby = nk_propertyf(NK_CTX, "lm_aabbY", -1000.0f, EDITOR_SETTINGS.lm_aabb.center.y, 1000.0f, 0.01f, 0.01f);
6304
6306 {
6308 }
6309
6310 float aabbz = nk_propertyf(NK_CTX, "lm_aabbZ", -1000.0f, EDITOR_SETTINGS.lm_aabb.center.z, 1000.0f, 0.01f, 0.01f);
6311
6313 {
6315 }
6316
6317 nk_layout_row_dynamic(NK_CTX, 20, 3);
6318
6319 float aabbex = nk_propertyf(NK_CTX, "AABBE_X", -1000.0f, EDITOR_SETTINGS.lm_aabb.extents.x, 1000.0f, 0.01f, 0.01f);
6320
6322 {
6324
6325 }
6326
6327 float aabbey = nk_propertyf(NK_CTX, "AABBE_Y", -1000.0f, EDITOR_SETTINGS.lm_aabb.extents.y, 1000.0f, 0.01f, 0.01f);
6329 {
6331 }
6332
6333 float aabbez = nk_propertyf(NK_CTX, "AABBE_Z", -1000.0f, EDITOR_SETTINGS.lm_aabb.extents.z, 1000.0f, 0.01f, 0.01f);
6334
6336 {
6338 }
6339
6340 AABB current_aabb;
6342
6343 nk_layout_row_dynamic(NK_CTX, 20, 1);
6344 // if (nk_button_text(NK_CTX, "UV Lightmap Partial Bake", 24))
6345 // {
6346
6347 // dirty = true;
6348 // traverse_scene_bvh_uv_lightmap(&GLOBALS.scene_data, CAST_VEC(GLOBALS.scene_data.bvh_nodes, BVHNode), EDITOR_SETTINGS.lm_aabb);
6349 // upload_material_data();
6350
6351 // GPU_upload_scene_data();
6352 // upload_lights();
6353 // bake_lightmap(&GLOBALS.scene_data.lightmap_data);
6354 // add_all_meshes_to_buffer(GLOBALS.vertex_layouts.buffer);
6355
6356 // }
6357
6358
6359
6360 if (nk_button_text(NK_CTX, "Spawn New R Probe", 17))
6361 {
6362
6364
6365
6366 probe->aabb.center = (vec3){0,0,0};
6367 probe->aabb.extents = (vec3){1,1,1};
6368 probe->capture_pos = (vec3){0,0,0};
6369 calculate_aabb_bounds(&probe->aabb);
6371 probe->fade_margin = (vec3){1,1,1};
6373
6374
6376
6378
6379
6380 }
6381
6383 {
6384
6385 char buf[128];
6386 sprintf(buf, "Selected Probe %d", EDITOR_SETTINGS.selected_r_probe);
6387 nk_text(NK_CTX, buf, strlen(buf), NK_TEXT_ALIGN_LEFT);
6388
6391
6392 if (nk_button_text(NK_CTX, "Delete R Probe", 17))
6393 {
6394
6395 uint8_t ** bytes = malloc(sizeof(uint8_t*));
6396 bytes[0] = malloc(sizeof(ReflectionProbe));
6397 memcpy(bytes[0], p, sizeof(ReflectionProbe));
6398 size_t total_bytes = sizeof(uint8_t*) + sizeof(ReflectionProbe);
6399 int byte_count = 1;
6400
6402
6404
6405
6406 }
6407
6408 nk_layout_row_dynamic(NK_CTX, 20, 3);
6409
6410 bool rp_expand_aabb = false;
6411
6412 float aabbx = nk_propertyf(NK_CTX, "rp_aabbX", -1000.0f, p->aabb.center.x, 1000.0f, 0.01f, 0.01f);
6413 if (check_equivalencyf(&p->aabb.center.x, aabbx, &LIGHT_MENU.rp_aabbx, &rp_expand_aabb))
6414 {
6415
6417
6418 }
6419
6420 float aabby = nk_propertyf(NK_CTX, "rp_aabbY", -1000.0f, p->aabb.center.y, 1000.0f, 0.01f, 0.01f);
6421 if (check_equivalencyf(&p->aabb.center.y, aabby, &LIGHT_MENU.rp_aabby, &rp_expand_aabb))
6422 {
6424
6425 }
6426 float aabbz = nk_propertyf(NK_CTX, "rp_aabbZ", -1000.0f, p->aabb.center.z, 1000.0f, 0.01f, 0.01f);
6427 if (check_equivalencyf(&p->aabb.center.z, aabbz, &LIGHT_MENU.rp_aabbz, &rp_expand_aabb))
6428 {
6430
6431 }
6432
6433 nk_layout_row_dynamic(NK_CTX, 20, 3);
6434
6435 float aabbex = nk_propertyf(NK_CTX, "rp_AABBE_X", -1000.0f, p->aabb.extents.x, 1000.0f, 0.01f, 0.01f);
6436 if (check_equivalencyf(&p->aabb.extents.x, aabbex, &LIGHT_MENU.rp_aabbe_x, &rp_expand_aabb))
6437 {
6438
6440 }
6441
6442 float aabbey = nk_propertyf(NK_CTX, "rp_AABBE_Y", -1000.0f, p->aabb.extents.y, 1000.0f, 0.01f, 0.01f);
6443 if (check_equivalencyf(&p->aabb.extents.y, aabbey, &LIGHT_MENU.rp_aabbe_y, &rp_expand_aabb))
6444 {
6445
6447 }
6448
6449 float aabbez = nk_propertyf(NK_CTX, "rp_AABBE_Z", -1000.0f, p->aabb.extents.z, 1000.0f, 0.01f, 0.01f);
6450 if (check_equivalencyf(&p->aabb.extents.z, aabbez, &LIGHT_MENU.rp_aabbe_z, &rp_expand_aabb))
6451 {
6452
6454 }
6455
6456 if (rp_expand_aabb)
6457 {
6459 }
6460
6461 float rp_fadex = nk_propertyf(NK_CTX, "rp_fade_X", -1000.0f, p->fade_margin.x, 1000.0f, 0.01f, 0.01f);
6462 if (check_equivalencyf(&p->fade_margin.x, rp_fadex, &LIGHT_MENU.rp_fade_x, NULL))
6463 {
6465 }
6466
6467 float rp_fadey = nk_propertyf(NK_CTX, "rp_fade_Y", -1000.0f, p->fade_margin.y, 1000.0f, 0.01f, 0.01f);
6468 if (check_equivalencyf(&p->fade_margin.y, rp_fadey, &LIGHT_MENU.rp_fade_y, NULL))
6469 {
6471 }
6472
6473 float rp_fadez = nk_propertyf(NK_CTX, "rp_fade_Z", -1000.0f, p->fade_margin.z, 1000.0f, 0.01f, 0.01f);
6474 if (check_equivalencyf(&p->fade_margin.z, rp_fadez, &LIGHT_MENU.rp_fade_z, NULL))
6475 {
6477 }
6478
6479 float capture_posx = nk_propertyf(NK_CTX, "rp_capposX", -1000.0f, p->capture_pos.x, 1000.0f, 0.01f, 0.01f);
6480 if (check_equivalencyf(&p->capture_pos.x, capture_posx, &LIGHT_MENU.rp_capposx, NULL))
6481 {
6483 }
6484
6485 float capture_posy = nk_propertyf(NK_CTX, "rp_capposY", -1000.0f, p->capture_pos.y, 1000.0f, 0.01f, 0.01f);
6486 if (check_equivalencyf(&p->capture_pos.y, capture_posy, &LIGHT_MENU.rp_capposy, NULL))
6487 {
6489 }
6490
6491 float capture_posz = nk_propertyf(NK_CTX, "rp_capposZ", -1000.0f, p->capture_pos.z, 1000.0f, 0.01f, 0.01f);
6492 if (check_equivalencyf(&p->capture_pos.z, capture_posz, &LIGHT_MENU.rp_capposz, NULL))
6493 {
6495 }
6496
6497 nk_layout_row_dynamic(NK_CTX, 20, 1);
6498 if (nk_button_text(NK_CTX, "Center Cap Pos", 14))
6499 {
6502
6503 p->capture_pos = p->aabb.center;
6504 }
6505 if (nk_button_text(NK_CTX, "Bake R Probes", 13))
6506 {
6508 }
6509
6510 }
6511
6512
6513 if (dirty == 1)
6514 {
6515 GLOBALS.lights_dirty = dirty;
6516 light->sm_dirty = dirty;
6517 }
6518
6519 }
6520 nk_end(NK_CTX);
6521
6522}
6523
6525{
6526
6527 if
6528 (
6529 nk_begin
6530 (
6531 NK_CTX,
6533 nk_rect(SCREEN_WIDTH - 420, 20, 400, SCREEN_HEIGHT),
6534 NK_WINDOW_TITLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_CLOSABLE
6535 )
6536 )
6537 {
6538
6539 struct nk_rect win_bounds = nk_window_get_bounds(NK_CTX);
6540 if (nk_input_is_mouse_hovering_rect(&NK_CTX->input, win_bounds)) { NUKLEAR_HOVERED = true; }
6541
6542
6543
6545
6547
6548 nk_layout_row_dynamic(NK_CTX, 20, 1);
6549
6550 char (* node_names)[256] = calloc(ai->node_count, sizeof(*node_names));
6551 char ** name_ptrs = malloc(sizeof(char*) * ai->node_count);
6552
6553 for (int i = 0; i < ai->node_count; i++)
6554 {
6555
6556 MeshNode * mn = &mns[ai->node_indices[i]];
6557
6558 strcpy(node_names[i], mn->name);
6559 name_ptrs[i] = node_names[i];
6560
6561 }
6562
6563
6564
6566 render_dropdown("Nodes", &selected, name_ptrs, ai->node_count, 300, 100);
6567
6569 {
6571 }
6572
6573 free(node_names);
6574 free(name_ptrs);
6575
6576
6577 if (nk_button_label(NK_CTX, "Select Node"))
6578 {
6580 {
6581
6584 }
6585 }
6586
6587
6588 if (nk_button_label(NK_CTX, "Delete Asset Instance"))
6589 {
6592 }
6593
6595
6596
6597
6598 }
6599 nk_end(NK_CTX);
6600
6601}
6602
6603
6604
6606{
6607
6608 NUKLEAR_HOVERED = false;
6609 tb_id_flags = NK_EDIT_INACTIVE;
6610 tb_text_flags = NK_EDIT_INACTIVE;
6611 tb_cont_flags = NK_EDIT_INACTIVE;
6612 ui_id_flags = NK_EDIT_INACTIVE;
6613 ui_parent_cont_flags = NK_EDIT_INACTIVE;
6614 ui_cont_flags = NK_EDIT_INACTIVE;
6615 ui_scrollbar_flags = NK_EDIT_INACTIVE;
6616 ui_label_id_flags = NK_EDIT_INACTIVE;
6617 aportal_flags = NK_EDIT_INACTIVE;
6618 apv_flags = NK_EDIT_INACTIVE;
6619 scene_apv_flags = NK_EDIT_INACTIVE;
6620 lpv_flags = NK_EDIT_INACTIVE;
6621 scene_lpv_flags = NK_EDIT_INACTIVE;
6622 scene_name_flags = NK_EDIT_INACTIVE;
6623 scene_file_name_flags = NK_EDIT_INACTIVE;
6624 ui_name_flags = NK_EDIT_INACTIVE;
6625 rprobe_name_flags = NK_EDIT_INACTIVE;
6626 light_name_flags = NK_EDIT_INACTIVE;
6627 lm_name_flags = NK_EDIT_INACTIVE;
6628
6629
6630
6632 {
6634 }
6636 {
6638 if (nk_window_is_closed(NK_CTX, menu_names[MENU_LPROBE]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_LPROBE]))
6639 {
6641 }
6642 }
6643
6645 {
6647 if (nk_window_is_closed(NK_CTX, menu_names[MENU_MAIN]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_MAIN]))
6648 {
6650 }
6651 }
6652
6654 {
6655
6657 if (nk_window_is_closed(NK_CTX, menu_names[MENU_MN]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_MN]))
6658 {
6660 }
6661
6662 }
6663
6664
6666 {
6668 if (nk_window_is_closed(NK_CTX, menu_names[MENU_MATERIAL]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_MATERIAL]))
6669 {
6671 }
6672
6673 }
6674
6675
6677 {
6678
6680 if (nk_window_is_closed(NK_CTX, "Light Menu") || nk_window_is_hidden(NK_CTX, "Light Menu"))
6681 {
6683 }
6684 }
6686 {
6687
6689 if (!ent->free)
6690 {
6692 if (nk_window_is_closed(NK_CTX, menu_names[MENU_ENT]))
6693 {
6695 }
6696 if (nk_window_is_closed(NK_CTX, menu_names[MENU_ENT]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_ENT]))
6697 {
6699 }
6700 }
6701 }
6703 {
6704
6706 if (nk_window_is_closed(NK_CTX, menu_names[MENU_AUDIO]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_AUDIO]))
6707 {
6709 }
6710 }
6712 {
6714 if (nk_window_is_closed(NK_CTX, menu_names[MENU_AINST]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_AINST]))
6715 {
6717 }
6718 }
6719 UIMenu * ms = CAST_VEC(MENUS, UIMenu);
6721 {
6723
6725 {
6727 if (nk_window_is_closed(NK_CTX, menu_names[MENU_TEXT]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_TEXT]))
6728 {
6730 }
6731 }
6733 {
6735 if (nk_window_is_closed(NK_CTX, menu_names[MENU_UI]) || nk_window_is_hidden(NK_CTX, menu_names[MENU_UI]))
6736 {
6738 }
6739 }
6740 }
6741
6742 if
6743 (
6744 tb_id_flags & NK_EDIT_ACTIVE ||
6745 tb_text_flags & NK_EDIT_ACTIVE ||
6746 tb_cont_flags & NK_EDIT_ACTIVE ||
6747 ui_menu_id_flags & NK_EDIT_ACTIVE ||
6748 ui_id_flags & NK_EDIT_ACTIVE ||
6749 ui_parent_cont_flags & NK_EDIT_ACTIVE ||
6750 ui_cont_flags & NK_EDIT_ACTIVE ||
6751 ui_scrollbar_flags & NK_EDIT_ACTIVE ||
6752 ui_label_id_flags & NK_EDIT_ACTIVE ||
6753 aportal_flags & NK_EDIT_ACTIVE ||
6754 apv_flags & NK_EDIT_ACTIVE ||
6755 scene_apv_flags & NK_EDIT_ACTIVE ||
6756 lpv_flags & NK_EDIT_ACTIVE ||
6757 scene_lpv_flags & NK_EDIT_ACTIVE ||
6758 scene_name_flags & NK_EDIT_ACTIVE ||
6759 scene_file_name_flags & NK_EDIT_ACTIVE ||
6760 ui_name_flags & NK_EDIT_ACTIVE ||
6761 rprobe_name_flags & NK_EDIT_ACTIVE ||
6762 light_name_flags & NK_EDIT_ACTIVE ||
6763 lm_name_flags & NK_EDIT_ACTIVE
6764 )
6765 {
6766 GLOBALS.keyboard_locked = true;
6767 }
6768 else if
6769 (
6770 (tb_id_flags & NK_EDIT_INACTIVE || tb_id_flags == 0) &&
6771 (tb_text_flags & NK_EDIT_INACTIVE || tb_text_flags == 0) &&
6772 (tb_cont_flags & NK_EDIT_INACTIVE || tb_cont_flags == 0) &&
6773 (ui_menu_id_flags & NK_EDIT_INACTIVE || ui_menu_id_flags == 0) &&
6774 (ui_id_flags & NK_EDIT_INACTIVE || ui_id_flags == 0) &&
6775 (ui_parent_cont_flags & NK_EDIT_INACTIVE || ui_parent_cont_flags == 0) &&
6776 (ui_cont_flags & NK_EDIT_INACTIVE || ui_cont_flags == 0) &&
6777 (ui_scrollbar_flags & NK_EDIT_INACTIVE || ui_scrollbar_flags == 0) &&
6778 (ui_label_id_flags & NK_EDIT_INACTIVE || ui_label_id_flags == 0) &&
6779 (aportal_flags & NK_EDIT_INACTIVE || aportal_flags == 0) &&
6780 (apv_flags & NK_EDIT_INACTIVE || apv_flags == 0) &&
6781 (scene_apv_flags & NK_EDIT_INACTIVE || scene_apv_flags == 0) &&
6782 (lpv_flags & NK_EDIT_INACTIVE || lpv_flags == 0) &&
6783 (scene_lpv_flags & NK_EDIT_INACTIVE || scene_lpv_flags == 0) &&
6784 (scene_name_flags & NK_EDIT_INACTIVE || scene_name_flags == 0) &&
6785 (scene_file_name_flags & NK_EDIT_INACTIVE || scene_file_name_flags == 0) &&
6786 (ui_name_flags & NK_EDIT_INACTIVE || ui_name_flags == 0) &&
6787 (rprobe_name_flags & NK_EDIT_INACTIVE || rprobe_name_flags == 0) &&
6788 (light_name_flags & NK_EDIT_INACTIVE || light_name_flags == 0) &&
6789 (lm_name_flags & NK_EDIT_INACTIVE || lm_name_flags == 0)
6790 )
6791 {
6792 GLOBALS.keyboard_locked = false;
6793 }
6794
6795
6796
6797
6798}
6799
6800
6802
void init_scene_bvh()
Initializes or updates the pre-existing scene bvh based on all mesh nodes with valid meshes.
void build_light_bvh()
Initializes a bvh for all current lights and emissive triangles in the scene, and sets the flux up fo...
Acceleration structure generation and how we traverse them.
Audio probe baking, portal creation, probe volumes, and emitter functions.
vec3 rot(vec3 M[3], vec3 a)
Refer to Ken Perlin's 2 joint IK implmentation.
Definition camera.c:1004
Functions for camera.
The debug editor UI for the engine.
shared uint temp[1024]
Engine specific types and defines.
@ PQUERY_MAX
AABB aabb
Bounding box of area.
bool lights_dirty
If lights need to be reuploaded.
float * lprobes
The raw SH data.
FILE * LPV_FILE
FILE pointer to the opened binary file.
FILE * APV_FILE
FILE pointer to the opened binary file.
Vector mesh_nodes
MeshNodes.
int skin
The GLTFSkin to be modified by this Entity (skeletal animations).
@ ESTATE_PLAYER_INTERACT
@ SPOT_LIGHT
const ivec3 DEFAULT_LPV_RES
What LPVs should always be at to match texture dimensions.
SceneData scene_data
SceneData that is more-so scene specific.
AnimationKeyframe kf[64]
The AnimationKeyframes for this track.
bool loop
If the animation loops.
GLuint i
The image handle for this texture.
void(* fn[ESTATE_MAX])(void *)
nk_bool open
If the directory is currently open in a dropdown.
char LPV_PATH[256]
Path to binary file with lighting ProbeVolumes.
AnimationComponent * ac
The AnimationComponent inside of ANIMATION_COMPONENTS.
vec3 capture_pos
The position to capture the cubemap from.
vec3 fade_margin
The margin to fade between this probe and another.
Vector vertex_layouts
VertexLayouts.
#define LPV_SLOTS
Vector audio_portals
AudioPortals.
Vector meshes
Meshes.
@ ANIM_TARGET_BOOL
@ ANIM_TARGET_MAX
@ ANIM_TARGET_VEC3
@ ANIM_TARGET_INT
@ ANIM_TARGET_FLOAT
const char * DVIEW_NAMES[]
Debug view names used for choosing a debug view.
int h
Dimensions.
AnimationTrack tracks[64]
The AnimationTracks with individual values that occur simultaneously.
int kf_count
The amount of AnimationKeyframes.
@ SELMODE_TEXTBOX
TextBox.
@ SELMODE_ASSETINSTANCE
AssetInstance.
@ SELMODE_MN
MeshNode.
@ SELMODE_RPROBE
ReflectionProbe.
@ SELMODE_APV
Audio ProbeVolume (APV).
@ SELMODE_LIGHT
Light.
@ SELMODE_ENTITY
Entity.
@ SELMODE_LPV
Lighting ProbeVolume (LPV).
@ SELMODE_UIELEMENT
UIElement.
@ SELMODE_AEM
AudioEmitter.
@ SELMODE_APORTAL
AudioPortal.
int cubemap_idx
Which cubemap this is linked to.
Globals GLOBALS
Engine Globals.
Definition main.c:310
size_t * node_indices
The indices of MeshNodes spawned from this instance inside of Globals.mesh_nodes.
bool free
If the component is empty.
bool keyboard_locked
If the keyboard is unlocked to register text events in the editor UI.
GLTexture depth_texture
The normal depth texture, if there is one.
LPV LOADED_LIGHTING_PV[6]
Load slots for lighting ProbeVolumes.
Vector reflection_probes
ReflectionProbes in the scene.
#define MAX_UI_MENU_NAMES
Used in editor to determine dropdown size.
Vector lights
Lights.
bool search_suffix
If there is a suffix.
#define LABEL_LEN
The maximum label length of labels in a ComboLabel.
Vector names
The name of each file in the directory.
FullscreenOptions
Fullscreen options.
@ FSOPT_MAX
@ FSOPT_WINDOWED
@ FSOPT_BORDERLESS
@ FSOPT_FULLSCREEN
float duration
The duration of all of the AnimationKeyframes.
@ MENU_MN
@ MENU_MAIN
@ MENU_ENT
@ MENU_UI
@ MENU_MATERIAL
@ MENU_LPROBE
@ MENU_AINST
@ MENU_TEXT
@ MENU_AUDIO
Vector lighting_probe_volumes
All of the lighting probe volumes, regardless of if they have been loaded yet.
const char * PPDVIEW_NAMES[]
Postprocess debug view names used for choosing.
bool free
If the Entity is empty.
const ivec3 DEFAULT_APV_RES
When APVs are spawned, they use this.
Vector audio_probe_volumes
All of the AudioProbe% volumes, regardless of if they have been loaded yet.
@ MSAA_SAMPLE_OPTIONS_MAX
size_t node_count
The amount of MeshNodes in this instance.
size_t material
The Material.
@ PPDVIEW_MAX
size_t id
The ID in ASSET_INSTANCES.
const char * FULLSCREEN_OPTION_NAMES[]
Fullscreen option names.
char APV_PATH[256]
Path to binary file with Audio ProbeVolumes.
Vector materials
Materials.
@ DVIEW_MAX
Vector assets
Assets.
int track_count
The amount of AnimationTracks.
State * state
The current State that describes actions for this Entity.
PhysicsComponent * pc
The PhysicsComponent inside of PHYSICS_COMPONENTS.
char suffix[256]
The suffix to append to the end of the file when searching.
size_t id
ID inside of ENTITIES.
int pv_id
The ProbeVolume in SceneData.lighting_probe_volume.
bool LOADED_LIGHTING_PV_FLAG[6]
Flags that indicate if the slot is loaded.
char directory[256]
Path to directory for the file.
char path[256]
The path to the Asset.
GLuint fbo
The handle for this fbo.
union AnimationKeyframe::@243377164052067242366020157201307241363031166101 val
#define LPV_PADDED_COUNT
LightmapData lightmap_data
The loaded lightmap and lightmap configuration for the scene.
char name[256]
Modifiable name of the scene.
AnimationTargetType type
The type of the data stored on AnimationKeyframe.
bool active
If this animation is currently running.
int current_selection
The file that is currently selected (starts at 0).
Vector islands
The UVIslands on the current lightmap.
int msaa_samples
How many samples our multisampled textures are using.
GLRenderbuffer depth_rbo
The renderbuffer depth texture, if there is one.
#define PERFORMANCE_OVERLAY_TEXT_BOX_COUNT
Offset of how many text boxes are used for the debug performance overlay.
bool currently_rasterizing
If we are going to rasterize this island on the next lightmap bake.
The animation component for interpolation between AnimationKeyframes.
Tagged union for the value stored in a keyframe.
Tagged union for the value stored in a keyframe.
An Asset after it is loaded in from file into Globals.assets.
A instance of an Asset that retains its node structure but can be duplicated into multiple instances ...
Entity structure that holds components and references to the data it owns.
Registry for folders that are used for dropdowns in the editor UI.
Global settings and structures for each system in the engine.
ReflectionProbes used for parallax corrected cubemaps.
Sections of Meshes that are divided based on Material for batching and DrawCommand ordering purposes.
The UVIslands that are generated from contiguous MeshFaces with similar planes for UV lightmapping.
An unused abstraction for VertexLayouts.
mat4 compose_trs_from_mesh_node(MeshNode *mn)
void destroy_entity(Entity *ent)
Deletes an entity by simply freeing it and its components.
Definition entity.c:224
AnimationComponent * create_animation_component(Entity *ent)
Creates an animation component for an entity.
Definition entity.c:121
PhysicsComponent * create_physics_component(Entity *ent, CollisionType collision_type, PhysicsType physics_type)
Creates an physics component for an entity.
Definition entity.c:88
Entity * create_entity(AssetInstance *asset_instance, int mn_id, bool physics_component, bool animation_component)
Creates an entity using the free list of ENTITIES.
Definition entity.c:153
ECS creation and maintenance.
int create_text_box(int menu_id)
Creates a DEFAULT_TEXT_BOX.
Definition fonts.c:202
void delete_text_box(int menu, int id)
Deletes a TextBox and its text and frees it from the UIMenu.
Definition fonts.c:184
void move_text_box_to_origin(TextBox *box)
Moves a TextBox to , while accounting for Justify.
Definition fonts.c:150
Functions that modify TextBoxes and load Fonts.
void load_gltf(const char *gltf_path)
Loads a GLTF.
Definition gltf.c:1250
GLTF parsing related utilities and important initialization data for Meshes, MeshNodes,...
ivec3 resolution
The resolution in X, Y, Z.
size_t size
The byte size of this volume.
size_t byte_offset
The byte offset into the binary file storing this volume.
OBB obb
The OBB that defines the size.
#define SH_MAX
void reset_audio_pvs()
Reset audio pvs, frees each slot in the global audio pv slots.
Definition audio.c:964
void bake_audio_probe_volume(ProbeVolume *pv)
Bakes an audio probe volume.
Definition audio.c:1661
The ProbeVolumes for APVs and LPVs, controlled by OBBs.
bool is_occludable
If the AudioEmitter can be occluded and needs to go through the AudioPortal system.
Vector adjacent_portals
int - Vector of AudioPortals that can be seen from this one.
uint32_t id
The static ID of the AudioEmitter inside of AUDIO_EMITTERS.
bool is_loop
If the AudioEmitter loops.
vec3 pos
The position of the AudioEmitter .
char path[256]
The path to the sound.
float base_volume
The starting volume.
vec3 pos
The position of the AudioPortal.
ma_sound sound_obj
The miniaudio sound obj.
bool is_loaded
If the emitter is loaded in miniaudio.
void end_emitter(AudioEmitter *e)
Stops playing an emitter.
Definition audio.c:881
AudioEmitter * init_emitter(const char *filepath, bool is_loop, bool is_occludable, float base_volume)
Initialized an audio emitter and sets up its audio object in miniaudio.
Definition audio.c:814
void play_emitter(AudioEmitter *emitter, vec3 pos)
Starts playing an emitter.
Definition audio.c:853
void unload_emitter(int id)
Unloads an emitter from miniaudio.
Definition audio.c:831
#define MAX_AUDIO_EMITTERS
The maximum amount of AudioEmitters.
void load_emitter(AudioEmitter *emitter, const char *filepath, bool is_loop, bool is_occludable, float base_volume)
Loads an existing emitter into miniaudio.
Definition audio.c:759
void destroy_emitter(int id)
Unloads an emitter from miniaudio and frees the emitter as well.
Definition audio.c:841
void init_new_audio_portal(vec3 pos)
Creates an audio portal by expanding the vector.
Definition audio.c:737
void remove_audio_portal(int id)
Removes an audio portal from the vector.
Definition audio.c:745
void recalculate_audio_portal_paths()
Recalculates the adjacency map of portals between each other.
Definition audio.c:418
An AudioEmitter that plays audio possibily from a certain position or at a certain time.
AudioPortals used for determining paths to transmit sound when emitter and listener are occluded.
bool free
Definition types.h:179
char buffer[600][256]
int selected_lighting_probe_volume_id
Undo * prev
Definition types.h:184
NKSlider aportal_pos[3]
DebugView current_debug_view
uint8_t bytes[50000]
Definition types.h:197
int ao_iterations
Controls how many iterations per lightmap iteration perform the AO check.
NKSlider apv_res[3]
NKSlider sensor_height
float rotation_angle
The current angle for rotation operations in the editor.
int selected_rprobe_file_id
float ao_threshold
Controls the distance threshold for AO detection.
int probe_iterations
The amount of iterations to bake each probe.
size_t special_count
Definition types.h:180
AABB lm_aabb
The AABB that sizes the current lightmap in world space.
NKSlider ao_threshold
NKSlider res_height
uint32_t id
Definition types.h:183
int audio_probe_iterations
The amount of iterations (sample rays) to bake per AudioProbe.
NKSlider texels_per_unit
int lm_iterations
The amount of iterations to bake a lightmap.
int selected_asset_instance_id
float texels_per_uv_unit
Controls the texel density of the uv lightmapper.
float DOF_sensor_height
size_t byte_size
Definition types.h:198
int selected_audio_probe_volume_id
float reverb_wet
Controls the volume of the reverb signal.
UndoSpecial special
Definition types.h:170
int selected_audio_emitter_id
float DOF_max_blur_radius
NKSlider mfactor_enabled
int selected_fullscreen_option
float volume
Controls the engine volume.
NKSlider OBB_sliders[9]
NKSlider focal_length
float render_framerate_target
The target framerate for rendering and processing ui events (a cap).
bool lighting_probe_volume_overlay
int res_width
Tracks rendering dimensions in editor menu.
NKSlider probe_iterations
const char * ptrs[600]
int ids[8]
Definition types.h:171
NKSlider lm_iterations
PostprocessDView pp_dview
vec3 rotation_axis
The rotation axis for rotation operations in the editor.
NKSlider ao_iterations
int selected_asset_instance_mn_id
bool mfactor_enabled
Controls how many iterations per lightmap iteration perform the AO check.
UndoStructureType type
Definition types.h:169
NKSlider emitter_pos[3]
int current_fullscreen_option
NKSlider OBB_sliders[9]
SelectionMode SELMODE
bool asset_instance_menu_open
uint8_t bytes[50000]
Definition types.h:188
int selected_audio_portal_id
UndoStructure structure
Definition types.h:187
NKSlider blur_radius
bool audio_probe_volume_overlay
uint8_t ** special_bytes
Definition types.h:186
bool is_held
Definition types.h:196
size_t undo_stack_max_byte_size
The maximum memory value for the Undo stack.
int audio_probe_bounces
The amount of bounces to accept per AudioProbe iteration.
size_t byte_offset
Definition types.h:182
Undo * next
Definition types.h:185
float mfactor
Controls how many iterations per lightmap iteration perform the AO check.
int selected_material_mn_id
size_t byte_size
Definition types.h:181
void execute_aprobe_undo(Undo *undo)
Definition editor.c:863
size_t undo_stack_size
Definition editor.c:151
MainEditorMenu MAIN_MENU
Definition editor.c:36
int aportal_flags
Definition editor.c:2981
void render_editor_menu()
Renders the editor menus.
Definition editor.c:6605
void execute_aportal_undo(Undo *undo)
Definition editor.c:1013
nk_bool rprobe_file_names_open
Definition editor.c:2019
const char menu_names[][256]
The array for all editor menu names (to avoid Nuklear hashing problems).
Definition editor.c:2307
LProbeEditorMenu LPROBE_MENU
Definition editor.c:37
char scrollbar_buffer[256]
Definition editor.c:3421
FileDirectoryRegistry rprobe_registry
Definition editor.c:57
void push_nk_slider_undo(NKSlider *s, UndoStructure structure, size_t byte_offset)
Definition editor.c:335
int scene_lpv_flags
Definition editor.c:2985
char text_container_buffer[256]
Definition editor.c:3037
void load_filenames(FileDirectoryRegistry *registry)
Definition editor.c:1929
void execute_rprobe_undo(Undo *undo)
Definition editor.c:641
char element_cid_buffer[256]
Definition editor.c:3420
void update_performance_overlay(GLuint64 query_s[PQUERY_MAX])
Fills performance overlay with text based on current GPU profiling information.
Definition editor.c:1635
AProbeEditorMenu APROBE_MENU
Definition editor.c:38
void execute_globals_undo(Undo *undo)
Definition editor.c:516
void render_mn_menu()
Definition editor.c:5539
AssetInstanceEditorMenu AI_MENU
Definition editor.c:41
void execute_ui_container_undo(Undo *undo)
Definition editor.c:1246
char menu_id_buffer[256]
Definition editor.c:3415
#define MAX_UNDOS
Definition types.h:96
char scene_lpv_name_buffer[256]
Definition editor.c:3001
FileDirectoryRegistry ui_registry
Definition editor.c:62
void render_lprobe_menu()
Definition editor.c:4681
void change_dof_res(int w, int h)
Definition editor.c:123
void render_entity_menu()
Definition editor.c:2028
char element_id_buffer[256]
Definition editor.c:3416
FileDirectoryRegistry aportal_registry
Definition editor.c:56
int tb_cont_flags
Definition editor.c:2974
int light_name_flags
Definition editor.c:2990
FileDirectoryRegistry sound_registry
Definition editor.c:55
const char QUERY_NAMES[PQUERY_MAX][256]
Definition editor.c:1601
void clear_special_undo_bytes(Undo *undo)
Definition editor.c:168
void render_obb_widget(const char *name, UndoStructureType undo_type, int id, OBB *obb, NKSlider *sliders)
Definition editor.c:2811
Undo * top_undo
Definition editor.c:152
int gltf_names_count
Definition editor.c:47
#define MAX_GLTF_NAMES
Definition editor.c:45
bool check_equivalencyi(int *a, int b, NKSlider *s, bool *dirty)
Definition editor.c:1830
FileDirectoryRegistry scene_apv_registry
Definition editor.c:60
void UNDO_INIT()
Initializes Undos inside of UNDOS to free state.
Definition editor.c:155
void execute_editor_settings_undo(Undo *undo)
Definition editor.c:563
char light_name_buffer[256]
Definition editor.c:2997
int tb_id_flags
Definition editor.c:2972
void perform_newest_redo()
Performs top-most Redo (Undo->next) and moves pointers upward.
Definition editor.c:303
int ui_scrollbar_flags
Definition editor.c:2979
int ui_label_id_flags
Definition editor.c:2980
void execute_undo(Undo *undo)
Performs an Undo (switch-case into each UndoStructureType).
Definition editor.c:1530
char aportal_name_buffer[256]
Definition editor.c:2996
void render_material_menu()
Definition editor.c:5695
Undo * find_empty_undo()
Definition editor.c:233
nk_bool gltf_file_names_open
Definition editor.c:2018
void execute_lprobe_undo(Undo *undo)
Definition editor.c:696
int apv_flags
Definition editor.c:2982
void render_pos_widget(const char *name, UndoStructureType undo_type, int id, vec3 *pos, NKSlider *sliders)
Definition editor.c:2540
int lpv_flags
Definition editor.c:2984
void execute_ui_menu_undo(Undo *undo)
Definition editor.c:1059
const char * MSAA_OPTIONS[]
Definition editor.c:4674
bool check_equivalencyv3(vec3 *a, vec3 b, NKSlider *s, bool *dirty)
Definition editor.c:1748
mat3 mat3_rotation_z(float angle_radians)
Definition editor.c:2443
char label_id_buffer[256]
Definition editor.c:3422
void load_gltf_filenames(const char *folder_path)
Definition editor.c:1987
void destroy_redo_history()
Definition editor.c:315
UndoStructure create_rprobe_undo_structure(int id, UndoSpecial special)
Definition editor.c:630
void render_ivec3_widget(const char *name, UndoStructureType undo_type, int id, ivec3 *vec, NKSlider *sliders)
Definition editor.c:2479
void render_dropdown_labels(int *selected, char **options, int option_count)
Definition editor.c:2360
void render_audio_menu()
Definition editor.c:4216
void obb_orthonormalize(OBB *obb)
Definition editor.c:2453
int lm_name_flags
Definition editor.c:2991
FileDirectoryRegistry lightmap_registry
Definition editor.c:53
char gltf_names[256][256]
Definition editor.c:46
void execute_mesh_node_undo(Undo *undo)
Definition editor.c:1470
int ui_menu_id_flags
Definition editor.c:2975
bool check_equivalencyv4(vec4 *a, vec4 b, NKSlider *s, bool *dirty)
Definition editor.c:1778
int scene_name_flags
Definition editor.c:2986
FileDirectoryRegistry lprobe_registry
Definition editor.c:58
void change_fullscreen_option(FullscreenOptions option)
Definition editor.c:64
char lprobe_name_buffer[256]
Definition editor.c:2999
void change_ssao_res(int w, int h)
Definition editor.c:115
UIElementEditorMenu UIELEMENT_MENU
Definition editor.c:39
void change_render_resolution()
Definition editor.c:94
void execute_asset_instance_undo(Undo *undo)
Definition editor.c:1426
UndoStructure create_light_undo_structure(int id, UndoSpecial special)
Definition editor.c:418
void render_selection_menu()
Definition editor.c:3002
void push_raw_bytes_undo(void *bytes, size_t byte_size, UndoStructure structure, size_t byte_offset)
Definition editor.c:350
void store_into_nkslider(NKSlider *s, void *bytes, size_t byte_size)
Definition editor.c:1590
void clear_undo(Undo *undo)
Definition editor.c:181
int rprobe_name_flags
Definition editor.c:2989
UndoStructure create_singular_id_undo_structure(UndoStructureType type, int id, UndoSpecial special)
Definition editor.c:407
int undo_stack_idx
Definition editor.c:150
char scene_apv_name_buffer[256]
Definition editor.c:3000
int ui_parent_cont_flags
Definition editor.c:2977
int ui_id_flags
Definition editor.c:2976
void link_undo(Undo *undo)
Definition editor.c:251
Undo UNDOS[MAX_UNDOS]
Definition editor.c:149
FileDirectoryRegistry light_registry
Definition editor.c:54
int tb_text_flags
Definition editor.c:2973
UndoStructureType
Definition types.h:60
bool check_equivalencyf(float *a, float b, NKSlider *s, bool *dirty)
Definition editor.c:1805
void change_bloom_res(int w, int h)
Definition editor.c:132
void create_performance_overlay()
Allocates and initializes position of the TextBoxes for the performance overlay.
Definition editor.c:1674
void push_special_undo(UndoStructure structure, uint8_t **bytes, size_t total_byte_size, size_t bytes_count, size_t byte_offset)
Definition editor.c:365
mat3 mat3_rotation_x(float angle_radians)
Definition editor.c:2422
int scene_apv_flags
Definition editor.c:2983
void copy_special_undo(Undo *undo, uint8_t ***special_bytes, int ids[8])
Definition editor.c:430
void FILE_DIR_REGISTRY_INIT()
Initializes each FileDirectoryRegistry based on initial paths.
Definition editor.c:1858
char rprobe_names[256][256]
Definition editor.c:49
char text_id_buffer[256]
Definition editor.c:3038
int ui_name_flags
Definition editor.c:2988
void render_light_menu()
Definition editor.c:5925
bool nk_check_equivalency(void *a, void *b, size_t byte_size, NKSlider *s, bool *dirty)
Definition editor.c:1712
void render_text_menu()
Definition editor.c:3040
mat3 mat3_rotation_y(float angle_radians)
Definition editor.c:2433
Undo * find_last_undo()
Definition editor.c:221
int scene_file_name_flags
Definition editor.c:2987
MeshNodeEditorMenu MN_MENU
Definition editor.c:42
FileDirectoryRegistry scene_registry
Definition editor.c:52
FileDirectoryRegistry aprobe_registry
Definition editor.c:59
void perform_newest_undo()
Performs top-most Undo and moves the top-most pointer to the previous.
Definition editor.c:287
void render_dropdown(const char *dropdown_name, int *selected, char **options, int option_count, int x, int y)
Definition editor.c:2384
void render_aabb_widget(const char *name, AABB *aabb)
Definition editor.c:2600
void execute_ui_element_undo(Undo *undo)
Definition editor.c:1076
void execute_non_special_undo(Undo *undo, uint8_t *p)
Definition editor.c:453
char element_parent_container_buffer[256]
Definition editor.c:3418
void execute_light_undo(Undo *undo)
Definition editor.c:463
void render_ui_menu()
Definition editor.c:3424
void render_asset_instance_menu()
Definition editor.c:6524
void render_file_directory_dropdown(FileDirectoryRegistry *registry)
Definition editor.c:2323
UndoSpecial
Definition types.h:103
void push_special_undo_normal_bytes(UndoStructure structure, void *bytes, size_t byte_size, size_t byte_offset)
Definition editor.c:379
void toggle_performance_overlay()
Toggles the performance overlay menu: PERFORMANCE_OVERLAY_MENU.
Definition editor.c:1616
#define MAX_RPROBE_NAMES
Definition editor.c:48
#define MAX_UNDO_BYTES
Definition types.h:95
void render_main_menu()
Definition editor.c:4932
FileDirectoryRegistry scene_lpv_registry
Definition editor.c:61
void render_mat4_widget(const char *name, UndoStructureType undo_type, int id, mat4 *mat, vec3 *tr, vec4 *rot, vec3 *sc, NKSlider *sliders)
Definition editor.c:2676
const char target_types[4][256]
Definition editor.c:2021
void execute_aemitter_undo(Undo *undo)
Definition editor.c:964
int rprobe_names_count
Definition editor.c:50
void destroy_undo(Undo *undo)
Definition editor.c:201
void execute_text_box_undo(Undo *undo)
Definition editor.c:1298
UndoStructure create_editor_settings_undo_structure(UndoSpecial special)
Definition editor.c:554
UndoStructure create_undo_structure(UndoStructureType type, int id[8], UndoSpecial special)
Definition editor.c:393
void load_rprobe_filenames(const char *folder_path)
Definition editor.c:1966
int ui_cont_flags
Definition editor.c:2978
void check_stack_size()
Definition editor.c:272
TextBoxEditorMenu TEXTBOX_MENU
Definition editor.c:40
char aprobe_name_buffer[256]
Definition editor.c:2998
Undo * next_redo
Definition editor.c:153
LightEditorMenu LIGHT_MENU
Definition editor.c:35
@ UNDOSTRUCT_GLOBAL
Definition types.h:67
@ UNDOSTRUCT_RPROBE
Definition types.h:71
@ UNDOSTRUCT_TEXTBOX
Definition types.h:65
@ UNDOSTRUCT_UI_CONTAINER
Definition types.h:64
@ UNDOSTRUCT_APROBE
Definition types.h:73
@ UNDOSTRUCT_EDITOR_SETTINGS
Definition types.h:68
@ UNDOSTRUCT_MATERIAL
Definition types.h:70
@ UNDOSTRUCT_ENTITY
Definition types.h:69
@ UNDOSTRUCT_LIGHT
Definition types.h:66
@ UNDOSTRUCT_UI_ELEMENT
Definition types.h:63
@ UNDOSTRUCT_MN
Definition types.h:62
@ UNDOSTRUCT_LPROBE
Definition types.h:72
@ UNDOSTRUCT_APORTAL
Definition types.h:75
@ UNDOSTRUCT_MENU
Definition types.h:76
@ UNDOSTRUCT_AEMITTER
Definition types.h:74
@ UNDOSTRUCT_ASSETINSTANCE
Definition types.h:77
@ UNDOLPROBE_RESET_LPVS
Definition types.h:133
@ UNDOTEXTBOX_ADD_TO_CONTAINER
Definition types.h:159
@ UNDOMN_ROTATION_ANGLE
Definition types.h:114
@ UNDOSPECIAL_NONE
Definition types.h:104
@ UNDOUICONTAINER_CHANGE_SCROLLBAR
Definition types.h:153
@ REDOUIELEMENT_ADD_TO_CONTAINER
Definition types.h:148
@ UNDOTEXTBOX_DELETE_TEXT_BOX
Definition types.h:155
@ UNDOAEMITTER_DELETE_SOUND_OBJ
Definition types.h:120
@ UNDOAEMITTER_LOAD_SOUND_OBJ
Definition types.h:121
@ UNDOLIGHT_DELETE
Definition types.h:142
@ UNDORPROBE_SPAWN
Definition types.h:139
@ UNDOAPORTAL_SPAWN
Definition types.h:117
@ UNDOEDITORSETTINGS_SCREEN_RES
Definition types.h:106
@ UNDOEDITORSETTINGS_BLOOM_RES
Definition types.h:110
@ UNDOAPROBE_RESET_APV_SIZE
Definition types.h:128
@ UNDOEDITORSETTINGS_DOF_RES
Definition types.h:109
@ UNDOEDITORSETTINGS_HALFSIZE_EFFECTS
Definition types.h:111
@ UNDOUIELEMENT_JUSTIFY_LABEL
Definition types.h:152
@ UNDOAPROBE_DELETE_APV
Definition types.h:129
@ UNDOEDITORSETTINGS_RENDER_RES
Definition types.h:107
@ UNDOLPROBE_RESET_LPV_SIZE
Definition types.h:135
@ UNDOMN_CHANGE_MATERIAL
Definition types.h:116
@ UNDOMN_MAT
Definition types.h:115
@ UNDOUIELEMENT_DELETE_ELEMENT
Definition types.h:145
@ UNDOAPORTAL_DELETE
Definition types.h:118
@ UNDOAPROBE_OBB_ROT
Definition types.h:131
@ REDOLPROBE_RESET_LPVS
Definition types.h:134
@ UNDOAEMITTER_SPAWN
Definition types.h:119
@ UNDOUIELEMENT_CREATE_ELEMENT
Definition types.h:144
@ UNDOTEXTBOX_CREATE_TEXT_BOX
Definition types.h:154
@ UNDOUIELEMENT_DELETE_CONTAINER
Definition types.h:150
@ UNDOGLOBAL_SPAWN_ASSET_INSTANCE
Definition types.h:143
@ UNDOAEMITTER_DELETE_EMITTER
Definition types.h:122
@ UNDOAPROBE_SPAWN_APV
Definition types.h:127
@ UNDORPROBE_DELETE
Definition types.h:140
@ UNDOASSETINSTANCE_ROTATION_ANGLE
Definition types.h:112
@ UNDOUIELEMENT_CREATE_CONTAINER
Definition types.h:149
@ UNDOEDITORSETTINGS_SSAO_RES
Definition types.h:108
@ UNDOUIELEMENT_CREATE_LABEL
Definition types.h:151
@ UNDOLIGHT_SPAWN
Definition types.h:141
@ UNDOLPROBE_OBB_ROT
Definition types.h:138
@ UNDOLPROBE_SPAWN
Definition types.h:132
@ UNDOAEMITTER_STOP_EMITTER
Definition types.h:124
@ UNDOEDITORSETTINGS_FULLSCREENOPT
Definition types.h:105
@ UNDOAEMITTER_PLAY_EMITTER
Definition types.h:123
@ UNDOUIELEMENT_CHANGE_CONTAINER
Definition types.h:146
@ UNDOLPROBE_DELETE
Definition types.h:136
@ UNDOTEXTBOX_CHANGE_TEXT
Definition types.h:156
@ UNDOUIELEMENT_REMOVE_FROM_CONTAINER
Definition types.h:147
@ UNDOTEXTBOX_REMOVE_FROM_CONTAINER
Definition types.h:158
@ UNDOTEXTBOX_CHANGE_CONTAINER
Definition types.h:157
@ UNDOASSETINSTANCE_MAT
Definition types.h:113
The structure used for some dropdown abstractions in the Editor UI.
Editor settings and engine global variables that can be changed through the editor.
Definition types.h:177
mat3 inverse_inertia
IIA (currently just a calculated box).
float mass
Mass of the component.
float mu
The friction constant for the component.
bool free
If this is an empty component.
float restitution
The restitution (bounce).
mat3 calc_inverse_inertia(PhysicsComponent *pc)
Calculates the mat3 IIA for a PhysicsComponent, using AABB bounds and mass.
Definition physics.c:2115
@ COL_HULL
Incremental hull generates a ConvexHull which is used for collision tests.
@ PHYSICS_FULL
All impulse resolution options applied.
Entity Component used for physics resolution.
float intensity
The intensity of the Light.
size_t id
The ID inside of Globals.mesh_nodes.
vec3 pos
Position of light.
vec3 translation
vec3 extents
Definition dynamic.frag:23
LightType light_type
The type of Light.
char name[256]
The Material path.
Entity * ent
The Entity this MeshNode refers to (all children point to the same Entity as parent).
vec3 center
Definition dynamic.frag:15
vec3 dir
Direction for lights that are not POINT_LIGHTs.
char name[256]
The name generated on loading from file.
bool sm_dirty
If a point light needs a new shadowmap.
bool skip_directional_uv_lighting
Skips directional Lights and rays go through them.
vec4 ka
Ambient.
float cone_angle
Cone angle for SPOT_LIGHTs.
float penumbra
Penumbra (opening) for SPOT_LIGHTs.
float emissive_strength
vec4 ke
Emissive.
int mesh
The Mesh it references.
float radius
The radius of the Light.
bool override_arm
If we override the ARM texture and bind a dummy instead.
mat3 rot
Definition types.h:49
vec3 rgb
Color of the light.
vec4 ks
Specular (unused).
float threshold
The threshold (how far a light reaches).
uint32_t entity_id
Entity ID into ENTITIES.
vec4 kd
Diffuse.
The CPU side structure for Lights.
The Materials parsed in from scene files that determine rendering pipeline setup, uploads,...
MeshNodes that describe the position of Meshes, GLTF nodes for GLTFAnimations, or hold references to ...
Oriented Bounding Boxes.
Definition dynamic.frag:14
int uID
The ID inside of UIMenu.containers.
Definition ui.h:227
bool free
If this UIContainer is empty or can be replaced.
Definition ui.h:228
int box
The TextBox index inside of the UIMenu.
Definition ui.h:492
char id[256]
The name of this TextBox.
Definition ui.h:291
bool mask
If the UIElements and TextBoxes contained should not be rendered if outside.
Definition ui.h:236
vec2 scroll_dir
The direction this container moves in when scrolled.
Definition ui.h:232
UIInteractableType interactable
The special interactable type this UIElement may be.
Definition ui.h:544
float angle
Angle of rotation.
Definition ui.h:523
uint shadow
Definition text.vert:35
float angle
The angle to transform this box to.
Definition ui.h:279
char id[256]
The name of this UIContainer.
Definition ui.h:245
float min_val
The minimum value of the slider.
Definition ui.h:426
int container
The UIContainer this UIElement may control.
Definition ui.h:539
bool wrap
If UIElements and TextBoxes wrap around the container (unused).
Definition ui.h:234
union UIElement::@017317244344356306005252125357265110320354311371 as
TextBox text_boxes[1024]
The TextBoxes.
Definition ui.h:567
float shadow_dist
Unused.
Definition text.vert:36
vec2 size
Size of the SDF.
Definition text.vert:38
float scroll_scale
How much the scroll is supposed to influence the UIContainer.
Definition ui.h:428
UIElement elements[1024]
The UIElements.
Definition ui.h:566
vec2 translation
X and Y coords where Y+ is down.
Definition text.vert:45
int scrollbar
The scrollbar UISlider UIElement.
Definition ui.h:244
vec2 translation
Where to place the center of the TextBox on the GPU.
Definition ui.h:278
UICallback action_callback
The event to occur on action (press or hold) or unaction.
Definition ui.h:533
vec4 padding
The padding before UIElements and TextBoxes are wrapped or masked.
Definition ui.h:235
vec2 shadow_dir
Which direction to offset the drop shadow in.
Definition text.vert:13
int text_cap
The amount of characters allocated.
Definition ui.h:266
uint32_t uID
The index inside of MENUS.
Definition ui.h:564
int parent_container
The UIContainer that contains this UIElement.
Definition ui.h:540
char id[256]
The name of this UIElement.
Definition ui.h:542
int menu
The UIMenu this UIElement is inside.
Definition ui.h:538
vec4 color
The color of the text.
Definition text.vert:18
Justify justify
How the text is centered in relation to and/or its UILabel.
Definition ui.h:264
Justify align
How the TextBox is justified within this UIElement.
Definition ui.h:493
float len
The length in pixel space.
Definition ui.h:411
vec2 scale
Scale.
Definition text.vert:46
uint32_t layer
The layer of the UIElement.
Definition ui.h:532
UIContainer containers[1024]
The UIContainers.
Definition ui.h:568
uint32_t layer
Rendering sort key (lower drawn first).
Definition ui.h:287
UICallback hover_callback
The event to occur on hover or unhover.
Definition ui.h:534
int parent_container
The UIContainer that contains this TextBox.
Definition ui.h:290
uint32_t uID
The ID inside of UIMenu.text_boxes.
Definition ui.h:263
char * text
The characters to render.
Definition ui.h:265
vec4 fill
The fill of the text.
Definition text.vert:19
vec4 fill
Unused.
Definition text.vert:43
int element
Which UIElement owns this UIContainer.
Definition ui.h:243
vec2 scale
The scale for this box on the GPU.
Definition ui.h:280
bool free
If this TextBox is empty and can be overwritten.
Definition ui.h:261
bool free
If the UIElement can be replaced or is empty.
Definition ui.h:512
uint32_t uID
The ID inside of UIMenu.
Definition ui.h:514
char id[256]
The unique name of this menu.
Definition ui.h:565
uint visible
Definition text.vert:33
vec2 dir
The direction it slides in.
Definition ui.h:408
int menu
The UIMenu that this box is within.
Definition ui.h:289
uint shadow
Definition text.vert:9
char id[256]
The name of this UICallback inside of its registry.
Definition ui.h:392
vec2 base_pos
Where the element was before it was scrolled or manipulated somehow.
Definition ui.h:522
vec2 shadow_dir
Unused.
Definition text.vert:39
float radius
The radius of the circle OR the radius of a rectangle's corners.
Definition text.vert:47
float text_size
The size to render the Font.
Definition ui.h:267
uint visible
Definition text.vert:7
vec4 color
Color of the shape.
Definition text.vert:42
float max_val
The maximum value of the slider.
Definition ui.h:427
float shadow_dist
How far the drop shadow is.
Definition text.vert:10
void assign_element_to_container(UIElement *el, UIContainer *c)
Assigns a UIElement to be parented to a UIContainer.
Definition ui.c:367
const char * JUSTIFY_NAMES[]
The names of Justify for the Editor UI.
Definition ui.h:170
#define MAX_UI_ELEMENTS
Definition ui.h:33
#define MAX_TEXT_BOXES
Definition ui.h:37
int move_text_box_to_menu(int tb_idx, int current_menu, int target_menu)
Moves a TextBox from its current UIMenu to another UIMenu.
Definition ui.c:329
int move_element_to_menu(int element_idx, int current_menu, int target_menu)
Moves a UIElement from its current UIMenu to another UIMenu.
Definition ui.c:299
void delete_ui_element(int menu, int id)
Deletes a UIElement, removing it from its possible parent UIContainer and deleting its own possible U...
Definition ui.c:176
void remove_element_from_container(UIContainer *c, UIElement *el)
Removes a UIElement from a UIContainer.
Definition ui.c:139
int create_ui_element(int menu_id)
Creates a UIElement on a given UIMenu.
Definition ui.c:39
#define MAX_UI_CONTAINERS
Definition ui.h:34
int find_text_box_in_menu(UIMenu *m, const char *id)
Finds a TextBox inside of a UIMenu via name.
Definition ui.c:261
TextBox DEFAULT_TEXT_BOX
Definition ui.h:661
void align_text_box_label(UIElement *el)
Aligns a TextBox inside of a UILabel based on its Justify.
Definition ui.c:410
Vector MENUS
All UIMenus.
Definition ui.c:13
void delete_ui_container(UIElement *el)
Deletes a UIContainer, removing all references to it from existing TextBoxes and UIElements on the sa...
Definition ui.c:68
const char * UI_INTERACTABLE_NAMES[]
UIElement interactable names for the union that describe unique functions.
Definition ui.h:211
UILabel DEFAULT_LABEL
Definition ui.h:632
void remove_text_box_from_container(UIContainer *c, TextBox *tb)
Removes a TextBox from a UIContainer.
Definition ui.c:157
void reassign_elements_to_container(UIElement *el)
Assigns all children based on current UIContainer children.
Definition ui.c:114
UIContainer * create_ui_container(UIElement *el, int menu_id)
Creates a UIContainer from a given UIElement a given UIMenu.
Definition ui.c:197
UIMenu * create_menu()
Creates a new UIMenu, expanding the MENUS Vector and sets all arrays to free.
Definition ui.h:875
void assign_text_box_to_container(TextBox *tb, UIContainer *c)
Assigns a TextBox to be parented to a UIContainer.
Definition ui.c:388
void compute_slider_bounds(UIElement *element)
Computes the minimum and maximum in UI space for a UISlider.
Definition ui.c:663
bool container_is_valid(int container, int menu)
Checks if a UIContainer and UIMenu ID pairing is valid.
Definition ui.h:905
UISlider DEFAULT_SLIDER
Definition ui.h:620
@ UI_INTERACTABLE_MAX
Definition ui.h:204
@ UI_INTERACTABLE_SLIDER
UISlider that can interpolate on a plane.
Definition ui.h:201
@ UI_INTERACTABLE_LABEL
References a TextBox that is Justified.
Definition ui.h:203
@ JUSTIFY_MAX
Definition ui.h:163
@ JUSTIFY_LEFT
Definition ui.h:155
A structure holding a Font ID and text to be rendered and transformed with its properties.
Definition text.vert:5
UIContainer that contains both TextBoxes and UIElements and can mask and scroll them.
Definition ui.h:225
UIElements that are contained within a UIMenu that may receive events, be contained within UIContaine...
Definition text.vert:31
UIElement UILabels that contain a TextBox reference.
Definition ui.h:490
The top-most UI structure that contains UIElements, TextBoxes, and UIContainers.
Definition ui.h:562
UIElement sliders that interpolate between two points on a line.
Definition ui.h:406
void destroy_asset_instance(uint32_t id)
Destroys and frees an AssetInstance.
Definition init.c:418
void GPU_upload_scene_data()
Uploads current Globals and SceneData structures to the GPU for baking SSBOs.
Definition init.c:661
void allocate_gbuffer_msaa()
Allocated a gbuffer with multisampled textures.
Definition init.c:1769
void allocate_gbuffer()
Allocates a gbuffer without multisampled textures.
Definition init.c:1844
AssetInstance * init_new_asset_instance(const char *asset_name, vec3 tr, vec4 rot, vec3 scale)
Initializes and spawns a new AssetInstance based on an Asset name, and places the AssetInstance....
Definition init.c:304
void change_fbo_resolution(Framebuffer *fbo, int w, int h, bool skip_depth)
Changes Framebuffer's resolution, and deletes the old textures.
Definition init.c:1361
void allocate_main_fbo()
Allocates the main FBO, changes if MSAA is enabled.
Definition init.c:1711
Important globals for the entire engine and initialization functions that are mainly called on engine...
Light default_light
Definition init.h:456
#define MAX_ASSET_INSTANCES
Definition init.h:442
void LM_allocate_empty_mns()
Allocates texels for MeshNodes that don't have UVIslands generated yet.
Definition lightmap.c:502
void build_uv_islands(MeshNode *mn)
Builds UVIslands over a MeshNode by stepping through TriangleAdjacency and stopping when normals beco...
Definition lightmap.c:400
void bake_reflection_probes()
Bakes ReflectionProbes for the entire scene onto cubemaps on RPROBE_CUBE_MAP_ARRAY.
Definition lightmap.c:786
void bake_lightmap(LightmapData *ld)
Bakes a UV Lightmap based on which UVIslands have UVIsland.currently_rasterizing set.
Definition lightmap.c:1009
void LM_regenerate_texels()
Regenerates lightmap texels: re-inits LightmapData, then builds UVIslands, then calls add_all_meshes_...
Definition lightmap.c:486
void load_lightmap_from_binary(LightmapData *ld, const char *name)
Loads a UV lightmap and relevant UVIsland and MeshNode data fro, binary.
Definition lightmap.c:610
void init_lightmap_data(LightmapData *ld)
Frees current LightmapAtlas and UVIsland data and re-initializes the LightmapAtlas array and initiali...
Definition lightmap.c:93
void bake_lighting_probe_volume(ProbeVolume *pv)
Loads a UV lightmap and relevant UVIsland and MeshNode data fro, binary.
Definition lightmap.c:1509
void save_lightmap_to_binary(LightmapData *ld, const char *name)
Saves a UV lightmap and relevant UVIsland and MeshNode data to binary.
Definition lightmap.c:525
void reset_lighting_pvs()
Resets current LPVs from their slots in SceneData.LOADED_LIGHTING_PV.
Definition lightmap.c:1330
UV Lightmap setup and baking, ReflectionProbe baking, and lighting ProbeVolume baking.
Vector submeshes
The SubMeshes split via Materials.
A Mesh with geometry data that is either initialized as static or dynamic and split into SubMeshes.
void scene_save_volumes(const char *name)
Saves only AudioProbes, AudioPortals, and ReflectionProbes.
Definition load.c:2399
void save_ui(const char *name)
Definition load.c:315
void save_vector(const char *filename, Vector *vec)
Definition load.c:2517
void load_ui(const char *name)
Definition load.c:348
void load_rprobes(const char *filename, Vector *vec)
Definition load.c:2555
void scene_save(const char *name)
Saves an entire scene into separate files.
Definition load.c:502
void save_lprobes(const char *filename, Vector *vec)
Definition load.c:2568
void scene_load_volumes(const char *name)
Loads only AudioProbes, AudioPortals, and ReflectionProbes.
Definition load.c:2452
void load_lprobes(const char *filename, Vector *vec)
Definition load.c:2582
void load_aportals(const char *filename, Vector *vec)
Definition load.c:2634
void load_aprobes(const char *filename)
Definition load.c:2699
void save_aportals(const char *filename, Vector *vec)
Definition load.c:2607
void load_vector(const char *filename, Vector *vec)
Definition load.c:2529
void save_aprobes(const char *filename)
Definition load.c:2679
void scene_load(const char *name)
Loads an entire scene from separate files in FileDirectoryRegistry directories.
Definition load.c:1262
void reallocate_rprobe_array()
Reallocates RPROBE_CUBE_MAP_ARRAY to new dimensions or when loading.
Definition load.c:392
Saves and loads various files that store engine data.
Framebuffer MAIN_FBO
Definition main.c:90
char asset_dir[256]
Definition main.c:284
Framebuffer GBUFFER_RESOLVE_FBO
Definition main.c:94
int SSAO_HEIGHT
Definition main.c:88
int RENDER_HEIGHT
Definition main.c:80
Entity ENTITIES[MAX_ENTITIES]
Definition main.c:312
AudioEmitter AUDIO_EMITTERS[1024]
Definition main.c:67
Framebuffer GBUFFER_FBO
Definition main.c:93
Framebuffer SSAO_FBO
Definition main.c:97
struct nk_context * NK_CTX
Nuklear context handle used for Editor UI.
Definition main.c:327
int RENDER_WIDTH
Definition main.c:79
int PERFORMANCE_OVERLAY_TEXT_BOX_START
Definition main.c:246
bool NUKLEAR_HOVERED
Definition main.c:328
int SCREEN_WIDTH
Definition main.c:77
int BLOOM_WIDTH
Definition main.c:81
char rprobe_dir[256]
Definition main.c:285
EditorSettings EDITOR_SETTINGS
Definition main.c:330
int SSAO_WIDTH
Definition main.c:87
int PERFORMANCE_OVERLAY_MENU
Definition main.c:247
float time
The frame time but wrapping at 1.0.
Definition main.c:320
int BLOOM_HEIGHT
Definition main.c:82
SDL_Window * window
Definition main.c:519
Framebuffer BLOOM_PYRAMID[6]
Definition main.c:102
bool draw_dirty
If we need to reupload and resort transforms in create_and_sort_draw_commands() and upload_instance_d...
Definition main.c:388
int DOF_WIDTH
Definition main.c:83
Framebuffer COC_FBO
Definition main.c:100
AssetInstance ASSET_INSTANCES[MAX_ASSET_INSTANCES]
Definition main.c:313
Framebuffer SSAO_BLUR_FBO
Definition main.c:98
Framebuffer DEPTH_DOWNSAMPLE_FBO
Definition main.c:275
Framebuffer MAIN_RESOLVE_FBO
Definition main.c:91
Framebuffer BOKEH_FBO
Definition main.c:101
int SCREEN_HEIGHT
Definition main.c:78
int DOF_HEIGHT
Definition main.c:84
vec3 vec3_cross(vec3 a, vec3 b)
Definition mathf.h:80
float vec3_dot(vec3 a, vec3 b)
Definition mathf.h:322
vec2 vec2_normalize(vec2 v)
Definition mathf.h:38
vec3 vec3_normalize(vec3 v)
Definition mathf.h:46
vec3 vec3_scale(vec3 a, float b)
Definition mathf.h:248
vec3 vec3_sub(vec3 a, vec3 b)
Definition mathf.h:266
float clamp(float a, float b, float c)
Definition mathf.h:379
PhysicsComponent impulse resolution and collision detection and acceleration structure traversal.
void upload_lights()
Uploads all current Lights inside of Globals.lights to the GPU in a triple buffered LIGHT_SSBO.
Definition render.c:634
void upload_material_data()
Uploads Material data to the GPU as MaterialGPU.
Definition render.c:854
void add_all_text_boxes_to_draw_buffer()
Adds all TextBoxes to TEXT_VBO and iterates through each character to push indices to TEXT_EBO.
Definition render.c:1220
void add_all_meshes_to_buffer(VertexLayout *layout)
Adds all Meshes that have valid MeshNodes.
Definition render.c:441
The main render pass, data GPU uploads, and SSBO management.
uniform mat4 view
Definition shadow.vert:16
const int size
Definition sky.frag:9
float x
Definition types.h:11
float w
Definition types.h:13
float c2
Definition types.h:20
float a0
Definition types.h:20
float z
Definition types.h:13
float a1
Definition types.h:20
float x
Definition types.h:13
float c0
Definition types.h:20
float x
Definition types.h:12
float b0
Definition types.h:20
float b1
Definition types.h:20
int y
Definition types.h:15
float y
Definition types.h:11
float y
Definition types.h:13
float y
Definition types.h:12
int z
Definition types.h:15
float z
Definition types.h:12
size_t count
Definition types.h:209
int x
Definition types.h:15
float b2
Definition types.h:20
size_t capacity
Definition types.h:209
void * buffer
Definition types.h:210
float a2
Definition types.h:20
float c1
Definition types.h:20
Definition types.h:15
Definition types.h:20
Definition types.h:21
Definition types.h:11
Definition types.h:12
Definition types.h:13
The standalone UI library that controls text rendering, ui rendering, and events.
UICallback HOVER_CALLBACKS[MAX_CALLBACKS]
int HOVER_CALLBACK_COUNT
int ACTION_CALLBACK_COUNT
UICallback ACTION_CALLBACKS[MAX_CALLBACKS]
bool vec4_equal(vec4 a, vec4 b, float eps)
Definition utilities.c:525
void init_vector(Vector *v, size_t i, size_t type_size)
Definition utilities.c:74
bool vec3_equal(vec3 a, vec3 b, float eps)
Definition utilities.c:541
void calculate_aabb_bounds(AABB *aabb)
Definition utilities.c:305
void * vector_expand(Vector *v, size_t i)
Definition utilities.c:49
#define CAST_VEC(vec, type)
Definition utilities.h:134
#define REMOVE_FROM_VEC(vec, index, type)
Definition utilities.h:276
mat4 compose_trs_from_vectors(vec3 pos, vec4 rot, vec3 scale)
Definition utilities.h:481
mat3 mat3_mul(mat3 M, mat3 N)
Definition utilities.h:559
vec4 quat_from_axis_angle(vec3 axis, float angle)
Definition utilities.h:361
mat3 mat3_identity()
Definition utilities.h:438
#define SHIFT_VEC_RIGHT(vec, index, type)
Definition utilities.h:284
#define M_PI
Definition utilities.h:52
uniform vec3 color
Definition wireframe.frag:6