|
|
@ -7,6 +7,7 @@ |
|
|
|
#include "texture.h" |
|
|
|
#include "texture.h" |
|
|
|
#include "framebuffer.h" |
|
|
|
#include "framebuffer.h" |
|
|
|
#include "../common/array.h" |
|
|
|
#include "../common/array.h" |
|
|
|
|
|
|
|
#include "../common/hashmap.h" |
|
|
|
#include "shader.h" |
|
|
|
#include "shader.h" |
|
|
|
#include "../common/num_types.h" |
|
|
|
#include "../common/num_types.h" |
|
|
|
#include "light.h" |
|
|
|
#include "light.h" |
|
|
@ -90,7 +91,6 @@ void editor_init_camera(void) |
|
|
|
editor_camera->clear_color.z = 0.9f; |
|
|
|
editor_camera->clear_color.z = 0.9f; |
|
|
|
editor_camera->clear_color.w = 1.f; |
|
|
|
editor_camera->clear_color.w = 1.f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Hashmap* config = platform->config.get(); |
|
|
|
struct Hashmap* config = platform->config.get(); |
|
|
|
int render_width = hashmap_int_get(config, "render_width"); |
|
|
|
int render_width = hashmap_int_get(config, "render_width"); |
|
|
|
int render_height = hashmap_int_get(config, "render_height"); |
|
|
|
int render_height = hashmap_int_get(config, "render_height"); |
|
|
@ -200,7 +200,7 @@ void editor_update(float dt) |
|
|
|
{ |
|
|
|
{ |
|
|
|
context->style.window.fixed_background = default_background; |
|
|
|
context->style.window.fixed_background = default_background; |
|
|
|
/* Top Panel */ |
|
|
|
/* Top Panel */ |
|
|
|
nk_layout_row_dynamic(context, editor_state.top_panel_height + 10, 1); |
|
|
|
nk_layout_row_dynamic(context, editor_state.top_panel_height + 10.f, 1); |
|
|
|
nk_group_begin(context, "Menubar", NK_WINDOW_NO_SCROLLBAR); |
|
|
|
nk_group_begin(context, "Menubar", NK_WINDOW_NO_SCROLLBAR); |
|
|
|
{ |
|
|
|
{ |
|
|
|
static float top_panel_ratios[] = {0.1f, 0.1f, 0.7f, 0.1f}; |
|
|
|
static float top_panel_ratios[] = {0.1f, 0.1f, 0.7f, 0.1f}; |
|
|
@ -472,22 +472,21 @@ void editor_update(float dt) |
|
|
|
const int row_height = 25; |
|
|
|
const int row_height = 25; |
|
|
|
if(nk_begin_titled(context, "Renderer_Settings_Window", "Renderer Settings", nk_rect(half_width, half_height, 300, 350), window_flags)) |
|
|
|
if(nk_begin_titled(context, "Renderer_Settings_Window", "Renderer Settings", nk_rect(half_width, half_height, 300, 350), window_flags)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static struct Render_Settings render_settings; |
|
|
|
struct Render_Settings* render_settings = &game_state->renderer->settings; |
|
|
|
renderer_settings_get(&render_settings); |
|
|
|
|
|
|
|
if(nk_tree_push(context, NK_TREE_TAB, "Debug", NK_MAXIMIZED)) |
|
|
|
if(nk_tree_push(context, NK_TREE_TAB, "Debug", NK_MAXIMIZED)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static const char* draw_modes[] = {"Triangles", "Lines", "Points"}; |
|
|
|
static const char* draw_modes[] = {"Triangles", "Lines", "Points"}; |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_label(context, "Debug Draw", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
nk_label(context, "Debug Draw", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
nk_checkbox_label(context, "", &render_settings.debug_draw_enabled); |
|
|
|
nk_checkbox_label(context, "", &render_settings->debug_draw_enabled); |
|
|
|
|
|
|
|
|
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_label(context, "Debug Draw Mode", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
nk_label(context, "Debug Draw Mode", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
render_settings.debug_draw_mode = nk_combo(context, draw_modes, 3, render_settings.debug_draw_mode, 20, nk_vec2(180, 100)); |
|
|
|
render_settings->debug_draw_mode = nk_combo(context, draw_modes, 3, render_settings->debug_draw_mode, 20, nk_vec2(180, 100)); |
|
|
|
|
|
|
|
|
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_label(context, "Debug Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
nk_label(context, "Debug Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
editor_widget_color_combov4(context, &render_settings.debug_draw_color, 200, 400); |
|
|
|
editor_widget_color_combov4(context, &render_settings->debug_draw_color, 200, 400); |
|
|
|
nk_tree_pop(context); |
|
|
|
nk_tree_pop(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -496,27 +495,27 @@ void editor_update(float dt) |
|
|
|
static const char* fog_modes[] = {"None", "Linear", "Exponential", "Exponential Squared"}; |
|
|
|
static const char* fog_modes[] = {"None", "Linear", "Exponential", "Exponential Squared"}; |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_label(context, "Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
nk_label(context, "Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
editor_widget_color_combov3(context, &render_settings.fog.color, 200, 400); |
|
|
|
editor_widget_color_combov3(context, &render_settings->fog.color, 200, 400); |
|
|
|
|
|
|
|
|
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_label(context, "Fog Mode", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
nk_label(context, "Fog Mode", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
render_settings.fog.mode = nk_combo(context, |
|
|
|
render_settings->fog.mode = nk_combo(context, |
|
|
|
fog_modes, |
|
|
|
fog_modes, |
|
|
|
4, |
|
|
|
4, |
|
|
|
render_settings.fog.mode, |
|
|
|
render_settings->fog.mode, |
|
|
|
20, |
|
|
|
20, |
|
|
|
nk_vec2(180, 100)); |
|
|
|
nk_vec2(180, 100)); |
|
|
|
|
|
|
|
|
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_layout_row_dynamic(context, row_height, 2); |
|
|
|
nk_label(context, "Density", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
nk_label(context, "Density", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); |
|
|
|
struct nk_rect bounds = nk_widget_bounds(context); |
|
|
|
struct nk_rect bounds = nk_widget_bounds(context); |
|
|
|
nk_slider_float(context, 0.f, &render_settings.fog.density, 1.f, 0.005); |
|
|
|
nk_slider_float(context, 0.f, &render_settings->fog.density, 1.f, 0.005); |
|
|
|
if(nk_input_is_mouse_hovering_rect(&context->input, bounds)) |
|
|
|
if(nk_input_is_mouse_hovering_rect(&context->input, bounds)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(nk_tooltip_begin(context, 100)) |
|
|
|
if(nk_tooltip_begin(context, 100)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nk_layout_row_dynamic(context, row_height, 1); |
|
|
|
nk_layout_row_dynamic(context, row_height, 1); |
|
|
|
nk_labelf(context, NK_TEXT_ALIGN_CENTERED, "%.3f", render_settings.fog.density); |
|
|
|
nk_labelf(context, NK_TEXT_ALIGN_CENTERED, "%.3f", render_settings->fog.density); |
|
|
|
nk_tooltip_end(context); |
|
|
|
nk_tooltip_end(context); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -525,21 +524,20 @@ void editor_update(float dt) |
|
|
|
nk_property_float(context, |
|
|
|
nk_property_float(context, |
|
|
|
"Start Distance", |
|
|
|
"Start Distance", |
|
|
|
0.f, |
|
|
|
0.f, |
|
|
|
&render_settings.fog.start_dist, |
|
|
|
&render_settings->fog.start_dist, |
|
|
|
render_settings.fog.max_dist, |
|
|
|
render_settings->fog.max_dist, |
|
|
|
5.f, 10.f); |
|
|
|
5.f, 10.f); |
|
|
|
|
|
|
|
|
|
|
|
nk_layout_row_dynamic(context, row_height, 1); |
|
|
|
nk_layout_row_dynamic(context, row_height, 1); |
|
|
|
nk_property_float(context, |
|
|
|
nk_property_float(context, |
|
|
|
"Max Distance", |
|
|
|
"Max Distance", |
|
|
|
render_settings.fog.start_dist, |
|
|
|
render_settings->fog.start_dist, |
|
|
|
&render_settings.fog.max_dist, |
|
|
|
&render_settings->fog.max_dist, |
|
|
|
10000.f, |
|
|
|
10000.f, |
|
|
|
5.f, 10.f); |
|
|
|
5.f, 10.f); |
|
|
|
|
|
|
|
|
|
|
|
nk_tree_pop(context); |
|
|
|
nk_tree_pop(context); |
|
|
|
} |
|
|
|
} |
|
|
|
renderer_settings_set(&render_settings); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -592,6 +590,7 @@ void editor_camera_update(float dt) |
|
|
|
//If we're not looking around then allow picking
|
|
|
|
//If we're not looking around then allow picking
|
|
|
|
if(input_mousebutton_state_get(MSB_LEFT, KS_RELEASED)) |
|
|
|
if(input_mousebutton_state_get(MSB_LEFT, KS_RELEASED)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
log_message("editor picking"); |
|
|
|
int mouse_x = 0, mouse_y = 0; |
|
|
|
int mouse_x = 0, mouse_y = 0; |
|
|
|
platform->mouse_position_get(&mouse_x, &mouse_y); |
|
|
|
platform->mouse_position_get(&mouse_x, &mouse_y); |
|
|
|
struct Ray ray = camera_screen_coord_to_ray(editor_camera, mouse_x, mouse_y); |
|
|
|
struct Ray ray = camera_screen_coord_to_ray(editor_camera, mouse_x, mouse_y); |
|
|
|