Added inspector for light data and fixed bugs with reading vec types from strings

dev
shariq 8 years ago
parent b5c1f8c85f
commit 5d35656b0c
  1. 2
      src/config_vars.c
  2. 134
      src/editor.c
  3. 29
      src/entity.c
  4. 6
      src/entity.h
  5. 32
      src/game.c
  6. 1
      src/renderer.c
  7. 8
      src/variant.c

@ -19,7 +19,7 @@ void config_vars_init(void)
hashmap_int_set(cvars, "render_width", 1024); hashmap_int_set(cvars, "render_width", 1024);
hashmap_int_set(cvars, "render_height", 768); hashmap_int_set(cvars, "render_height", 768);
hashmap_int_set(cvars, "fog_mode", 0); hashmap_int_set(cvars, "fog_mode", 0);
hashmap_vec3_setf(cvars, "fog_color", 0.5f, 0.2f, 0.2f); hashmap_vec3_setf(cvars, "fog_color", 0.9f, 0.2f, 0.2f);
hashmap_float_set(cvars, "fog_density", 0.1); hashmap_float_set(cvars, "fog_density", 0.1);
hashmap_float_set(cvars, "fog_start_dist", 10.f); hashmap_float_set(cvars, "fog_start_dist", 10.f);
hashmap_float_set(cvars, "fog_max_dist", 50.f); hashmap_float_set(cvars, "fog_max_dist", 50.f);

@ -26,6 +26,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <float.h> #include <float.h>
#include <limits.h>
#include <math.h> #include <math.h>
struct Editor_State struct Editor_State
@ -46,8 +47,9 @@ static struct Editor_State editor_state;
static struct Debug_Variable* debug_vars_list = NULL; static struct Debug_Variable* debug_vars_list = NULL;
static int* empty_indices = NULL; static int* empty_indices = NULL;
static void editor_color_combo(struct nk_context* context, vec4* color, int width, int height); static void editor_widget_color_combov3(struct nk_context* context, vec3* color, int width, int height);
static bool editor_widget_vec3(struct nk_context* context, static void editor_widget_color_combov4(struct nk_context* context, vec4* color, int width, int height);
static bool editor_widget_v3(struct nk_context* context,
vec3* value, vec3* value,
const char* name_x, const char* name_x,
const char* name_y, const char* name_y,
@ -267,20 +269,23 @@ void editor_update(float dt)
/* Entity Inspector */ /* Entity Inspector */
if(nk_tree_push(context, NK_TREE_TAB, "Inspector", NK_MAXIMIZED)) if(nk_tree_push(context, NK_TREE_TAB, "Inspector", NK_MAXIMIZED))
{ {
const int row_height = 18;
if(editor_state.selected_entity_id != -1) if(editor_state.selected_entity_id != -1)
{ {
struct Entity* entity = entity_get(editor_state.selected_entity_id); struct Entity* entity = entity_get(editor_state.selected_entity_id);
static const int row_height = 15;
nk_layout_row_dynamic(context, row_height, 2); nk_layout_row_dynamic(context, row_height, 2);
nk_label(context, "Name", NK_TEXT_ALIGN_LEFT); nk_label(context, entity->name, NK_TEXT_ALIGN_RIGHT); nk_label(context, "Name", NK_TEXT_ALIGN_LEFT); nk_label(context, entity->name, NK_TEXT_ALIGN_RIGHT);
nk_layout_row_dynamic(context, row_height, 2); nk_layout_row_dynamic(context, row_height, 2);
nk_label(context, "ID", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%d", entity->id); nk_label(context, "ID", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%d", entity->id);
nk_layout_row_dynamic(context, row_height, 2);
nk_label(context, "Entity Type", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%s", entity_type_name_get(entity));
/* Transform */ /* Transform */
{
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Position", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Position", NK_TEXT_ALIGN_CENTERED);
vec3 abs_pos = {0.f, 0.f, 0.f}; vec3 abs_pos = {0.f, 0.f, 0.f};
transform_get_absolute_pos(entity, &abs_pos); transform_get_absolute_pos(entity, &abs_pos);
if(editor_widget_vec3(context, &abs_pos, "Px", "Py", "Pz", -FLT_MAX, FLT_MAX, 5.f, 1.f, row_height)) transform_set_position(entity, &abs_pos); if(editor_widget_v3(context, &abs_pos, "Px", "Py", "Pz", -FLT_MAX, FLT_MAX, 5.f, 1.f, row_height)) transform_set_position(entity, &abs_pos);
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Rotation", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Rotation", NK_TEXT_ALIGN_CENTERED);
quat abs_rot = {0.f, 0.f, 0.f, 1.f}; quat abs_rot = {0.f, 0.f, 0.f, 1.f};
@ -310,12 +315,58 @@ void editor_update(float dt)
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Scale", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Scale", NK_TEXT_ALIGN_CENTERED);
vec3 abs_scale = {0.f, 0.f, 0.f}; vec3 abs_scale = {0.f, 0.f, 0.f};
transform_get_absolute_scale(entity, &abs_scale); transform_get_absolute_scale(entity, &abs_scale);
if(editor_widget_vec3(context, &abs_scale, "SX", "SY", "SZ", 0.1f, FLT_MAX, 1.f, 0.1f, row_height)) if(editor_widget_v3(context, &abs_scale, "SX", "SY", "SZ", 0.1f, FLT_MAX, 1.f, 0.1f, row_height))
{ {
entity->transform.scale = abs_scale; entity->transform.scale = abs_scale;
transform_update_transmat(entity); transform_update_transmat(entity);
} }
}
/* Light */
if(entity->type == ET_LIGHT)
{
if(nk_tree_push(context, NK_TREE_TAB, "Light", NK_MAXIMIZED))
{
struct Light* light = &entity->light;
if(light->type > LT_POINT)
{
nk_layout_row_dynamic(context, row_height, 1);
nk_label(context, "Invalid light type!", NK_TEXT_ALIGN_CENTERED);
}
else
{
static const char* light_types[] = {"Spot", "Directional", "Point"};
float combo_width = nk_widget_width(context), combo_height = row_height * (LT_MAX);
nk_layout_row_dynamic(context, row_height, 2);
nk_label(context, "Light Type", NK_TEXT_ALIGN_LEFT);
nk_combobox(context, light_types, LT_MAX - 1, &light->type, row_height, nk_vec2(combo_width, combo_height));
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Light Color", NK_TEXT_ALIGN_CENTERED);
nk_layout_row_dynamic(context, row_height, 1);
editor_widget_color_combov3(context, &light->color, 200, 300);
nk_layout_row_dynamic(context, row_height, 1);
nk_property_float(context, "Intensity", 0.f, &light->intensity, 100.f, 0.1f, 0.05f);
if(light->type != LT_DIR)
{
nk_layout_row_dynamic(context, row_height, 1);
light->outer_angle = TO_RADIANS(nk_propertyf(context, "Outer Angle", TO_DEGREES(light->inner_angle), TO_DEGREES(light->outer_angle), 360, 1.f, 0.5f));
nk_layout_row_dynamic(context, row_height, 1);
light->inner_angle = TO_RADIANS(nk_propertyf(context, "Inner Angle", 1.f, TO_DEGREES(light->inner_angle), TO_DEGREES(light->outer_angle), 1.f, 0.5f));
nk_layout_row_dynamic(context, row_height, 1);
nk_property_int(context, "Radius", 1, &light->radius, INT_MAX, 1, 1);
nk_layout_row_dynamic(context, row_height, 1);
nk_property_float(context, "Falloff", 0.f, &light->falloff, 100.f, 0.1f, 0.05f);
}
}
nk_tree_pop(context);
}
}
} }
else else
{ {
@ -326,7 +377,6 @@ void editor_update(float dt)
nk_group_end(context); nk_group_end(context);
} }
} }
nk_end(context); nk_end(context);
context->style.window.padding = default_padding; context->style.window.padding = default_padding;
@ -334,6 +384,7 @@ void editor_update(float dt)
/* Render Settings Window */ /* Render Settings Window */
if(editor_state.renderer_settings_window) if(editor_state.renderer_settings_window)
{ {
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; static struct Render_Settings render_settings;
@ -341,31 +392,28 @@ void editor_update(float dt)
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, 25, 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, 25, 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, 25, 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_color_combo(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);
} }
if(nk_tree_push(context, NK_TREE_TAB, "Fog", NK_MAXIMIZED)) if(nk_tree_push(context, NK_TREE_TAB, "Fog", NK_MAXIMIZED))
{ {
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, 25, 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);
static vec4 fog_color; editor_widget_color_combov3(context, &render_settings.fog.color, 200, 400);
vec4_fill_vec3(&fog_color, &render_settings.fog.color, 1.f);
editor_color_combo(context, &fog_color, 200, 400);
vec3_fill(&render_settings.fog.color, fog_color.x, fog_color.y, fog_color.z);
nk_layout_row_dynamic(context, 25, 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,
@ -374,19 +422,21 @@ void editor_update(float dt)
20, 20,
nk_vec2(180, 100)); nk_vec2(180, 100));
nk_layout_row_dynamic(context, 25, 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))
{ {
static char float_str[10] = {'\0'}; if(nk_tooltip_begin(context, 100))
snprintf(float_str, 6, "%.4f", render_settings.fog.density); {
float_str[6] = '\0'; nk_layout_row_dynamic(context, row_height, 1);
nk_tooltip(context, float_str); nk_labelf(context, NK_TEXT_ALIGN_CENTERED, "%.3f", render_settings.fog.density);
nk_tooltip_end(context);
}
} }
nk_layout_row_dynamic(context, 25, 1); nk_layout_row_dynamic(context, row_height, 1);
nk_property_float(context, nk_property_float(context,
"Start Distance", "Start Distance",
0.f, 0.f,
@ -394,7 +444,7 @@ void editor_update(float dt)
render_settings.fog.max_dist, render_settings.fog.max_dist,
5.f, 10.f); 5.f, 10.f);
nk_layout_row_dynamic(context, 25, 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,
@ -419,7 +469,41 @@ void editor_toggle(void)
editor_state.enabled = !editor_state.enabled; editor_state.enabled = !editor_state.enabled;
} }
void editor_color_combo(struct nk_context* context, vec4* color, int width, int height) void editor_widget_color_combov3(struct nk_context* context, vec3* color, int width, int height)
{
struct nk_color temp_color = nk_rgba_f(color->x, color->y, color->z, 1.f);
if(nk_combo_begin_color(context, temp_color, nk_vec2(width, height)))
{
enum color_mode {COL_RGB, COL_HSV};
static int col_mode = COL_RGB;
nk_layout_row_dynamic(context, 25, 2);
col_mode = nk_option_label(context, "RGB", col_mode == COL_RGB) ? COL_RGB : col_mode;
col_mode = nk_option_label(context, "HSV", col_mode == COL_HSV) ? COL_HSV : col_mode;
nk_layout_row_dynamic(context, 120, 1);
temp_color = nk_color_picker(context, temp_color, NK_RGB);
nk_layout_row_dynamic(context, 25, 1);
if(col_mode == COL_RGB)
{
temp_color.r = (nk_byte)nk_propertyi(context, "#R:", 0, temp_color.r, 255, 1,1);
temp_color.g = (nk_byte)nk_propertyi(context, "#G:", 0, temp_color.g, 255, 1,1);
temp_color.b = (nk_byte)nk_propertyi(context, "#B:", 0, temp_color.b, 255, 1,1);
}
else
{
nk_byte tmp[4];
nk_color_hsva_bv(tmp, temp_color);
tmp[0] = (nk_byte)nk_propertyi(context, "#H:", 0, tmp[0], 255, 1,1);
tmp[1] = (nk_byte)nk_propertyi(context, "#S:", 0, tmp[1], 255, 1,1);
tmp[2] = (nk_byte)nk_propertyi(context, "#V:", 0, tmp[2], 255, 1,1);
temp_color = nk_hsva_bv(tmp);
}
float empty = 1.f;
nk_color_f(&color->x, &color->y, &color->z, &empty, temp_color);
nk_combo_end(context);
}
}
void editor_widget_color_combov4(struct nk_context* context, vec4* color, int width, int height)
{ {
struct nk_color temp_color = nk_rgba_f(color->x, color->y, color->z, color->w); struct nk_color temp_color = nk_rgba_f(color->x, color->y, color->z, color->w);
if(nk_combo_begin_color(context, temp_color, nk_vec2(width, height))) if(nk_combo_begin_color(context, temp_color, nk_vec2(width, height)))
@ -463,7 +547,7 @@ void editor_cleanup(void)
} }
bool editor_widget_vec3(struct nk_context* context, vec3* value, const char* name_x, const char* name_y, const char* name_z, float min, float max, float step, float inc_per_pixel, int row_height) bool editor_widget_v3(struct nk_context* context, vec3* value, const char* name_x, const char* name_y, const char* name_z, float min, float max, float step, float inc_per_pixel, int row_height)
{ {
bool changed = false; bool changed = false;
vec3 val_copy = {0.f, 0.f, 0.f}; vec3 val_copy = {0.f, 0.f, 0.f};

@ -61,8 +61,7 @@ void entity_remove(int index)
entity->marked_for_deletion = false; entity->marked_for_deletion = false;
entity->editor_selected = 0; entity->editor_selected = 0;
entity->renderable = false; entity->renderable = false;
entity->name = NULL; memset(entity->name, '\0', MAX_ENTITY_NAME_LEN);
free(entity->name);
array_push(empty_indices, index, int); array_push(empty_indices, index, int);
} }
@ -80,12 +79,11 @@ struct Entity* entity_create(const char* name, const int type, int parent_id)
else else
{ {
new_entity = array_grow(entity_list, struct Entity); new_entity = array_grow(entity_list, struct Entity);
new_entity->name = NULL;
index = array_len(entity_list) - 1; index = array_len(entity_list) - 1;
} }
if(new_entity->name) free(new_entity->name); strncpy(new_entity->name, name ? name : "DEFAULT_ENTITY_NAME", MAX_ENTITY_NAME_LEN);
new_entity->name = name ? str_new(name) : str_new("DEFAULT_NAME"); new_entity->name[MAX_ENTITY_NAME_LEN - 1] = '\0';
new_entity->id = index; new_entity->id = index;
new_entity->is_listener = false; new_entity->is_listener = false;
new_entity->type = type; new_entity->type = type;
@ -111,7 +109,7 @@ struct Entity* entity_find(const char* name)
for(int i = 0; i < array_len(entity_list); i++) for(int i = 0; i < array_len(entity_list); i++)
{ {
struct Entity* curr_ent = &entity_list[i]; struct Entity* curr_ent = &entity_list[i];
if(!curr_ent->name) if(curr_ent->id == -1)
continue; continue;
if(strcmp(curr_ent->name, name) == 0) if(strcmp(curr_ent->name, name) == 0)
{ {
@ -270,7 +268,7 @@ struct Entity* entity_load(const char* filename, int directory_type)
.is_listener = false, .is_listener = false,
.renderable = false, .renderable = false,
.marked_for_deletion = false, .marked_for_deletion = false,
.name = NULL, .name = "DEFAULT_ENTITY_NAME",
.editor_selected = 0 .editor_selected = 0
}; };
@ -505,3 +503,20 @@ struct Entity* entity_load(const char* filename, int directory_type)
fclose(entity_file); fclose(entity_file);
return new_entity; return new_entity;
} }
const char* entity_type_name_get(struct Entity* entity)
{
const char* typename = "NONE";
switch(entity->type)
{
case ET_NONE: typename = "None"; break;
case ET_CAMERA: typename = "Camera"; break;
case ET_LIGHT: typename = "Light"; break;
case ET_PLAYER: typename = "Player"; break;
case ET_ROOT: typename = "Root"; break;
case ET_SOUND_SOURCE: typename = "Sound Source"; break;
case ET_STATIC_MESH: typename = "Static Mesh"; break;
default: typename = "Unknown"; break;
};
return typename;
}

@ -4,6 +4,8 @@
#include "linmath.h" #include "linmath.h"
#include "num_types.h" #include "num_types.h"
#define MAX_ENTITY_NAME_LEN 128
struct Material_Param; struct Material_Param;
enum Entity_Type enum Entity_Type
@ -91,7 +93,7 @@ struct Entity
{ {
int id; int id;
int type; int type;
char* name; char name[MAX_ENTITY_NAME_LEN];
bool is_listener; /* TODO: Replace all booleans with flags */ bool is_listener; /* TODO: Replace all booleans with flags */
bool marked_for_deletion; bool marked_for_deletion;
bool renderable; bool renderable;
@ -124,5 +126,7 @@ struct Entity* entity_get_all(void);
struct Entity* entity_get_parent(int node); struct Entity* entity_get_parent(int node);
bool entity_save(struct Entity* entity, const char* filename, int directory_type); bool entity_save(struct Entity* entity, const char* filename, int directory_type);
struct Entity* entity_load(const char* filename, int directory_type); struct Entity* entity_load(const char* filename, int directory_type);
const char* entity_type_name_get(struct Entity* entity);
#endif #endif

@ -98,7 +98,7 @@ void scene_setup(void)
vec4_fill(&player->camera.clear_color, 0.3f, 0.6f, 0.9f, 1.0f); vec4_fill(&player->camera.clear_color, 0.3f, 0.6f, 0.9f, 1.0f);
sound_listener_set(player->id); sound_listener_set(player->id);
vec4 color = {0.f, 1.f, 1.f, 1.f }; vec4 color = {1.f, 1.f, 1.f, 1.f };
struct Entity* new_ent = scene_add_new("Model_Entity", ET_STATIC_MESH); struct Entity* new_ent = scene_add_new("Model_Entity", ET_STATIC_MESH);
vec3 position = {0, 0, -5}; vec3 position = {0, 0, -5};
transform_translate(new_ent, &position, TS_WORLD); transform_translate(new_ent, &position, TS_WORLD);
@ -119,7 +119,7 @@ void scene_setup(void)
sound_source_play(sound_ent); sound_source_play(sound_ent);
int parent_node = new_ent->id; int parent_node = new_ent->id;
int num_suz = 200; int num_suz = 2;
srand(time(NULL)); srand(time(NULL));
for(int i = 0; i < num_suz; i++) for(int i = 0; i < num_suz; i++)
{ {
@ -166,26 +166,26 @@ void scene_setup(void)
/* model_set_material_param(screen_model, "diffuse_color", &color); */ /* model_set_material_param(screen_model, "diffuse_color", &color); */
/* model_set_material_param(screen_model, "diffuse_texture", &cam->render_tex); */ /* model_set_material_param(screen_model, "diffuse_texture", &cam->render_tex); */
/* const int MAX_LIGHTS = 6; */ const int MAX_LIGHTS = 6;
/* for(int i = 0; i < MAX_LIGHTS; i++) */ for(int i = 0; i < MAX_LIGHTS; i++)
/* { */ {
/* int x = rand() % MAX_LIGHTS; */ int x = rand() % MAX_LIGHTS;
/* int z = rand() % MAX_LIGHTS; */ int z = rand() % MAX_LIGHTS;
/* x++; z++; */ x++; z++;
/* struct Entity* light_ent = scene_add_new("Light_Ent", ET_LIGHT); */ struct Entity* light_ent = scene_add_new("Light_Ent", ET_LIGHT);
/* vec3 lt_pos = {x * 20, 0, z * 20}; */ vec3 lt_pos = {x * 20, 0, z * 20};
/* transform_set_position(light_ent, &lt_pos); */ transform_set_position(light_ent, &lt_pos);
/* light_create(light_ent, LT_POINT); */ light_create(light_ent, LT_POINT);
/* vec3_fill(&light_ent->light.color, 1.f / (float)x, 1.f / ((rand() % 10) + 1.f), 1.f / (float)z); */ vec3_fill(&light_ent->light.color, 1.f / (float)x, 1.f / ((rand() % 10) + 1.f), 1.f / (float)z);
/* light_ent->light.intensity = 1.f; */ light_ent->light.intensity = 1.f;
/* } */ }
/* log_message("Sizeof Entity : %d", sizeof(struct Entity)); */ /* log_message("Sizeof Entity : %d", sizeof(struct Entity)); */
/* struct Entity* light_ent = entity_find("Ground"); */ /* struct Entity* light_ent = entity_find("Ground"); */
/* entity_save(light_ent, "ground.ent", DT_INSTALL); */ /* entity_save(light_ent, "ground.ent", DT_INSTALL); */
struct Entity* light = entity_load("light.ent", DT_INSTALL); //struct Entity* light = entity_load("light.ent", DT_INSTALL);
} }
void debug(float dt) void debug(float dt)

@ -474,6 +474,7 @@ void renderer_settings_set(const struct Render_Settings* settings)
hashmap_float_set(cvars, "fog_density", settings->fog.density); hashmap_float_set(cvars, "fog_density", settings->fog.density);
hashmap_float_set(cvars, "fog_start_dist", settings->fog.start_dist); hashmap_float_set(cvars, "fog_start_dist", settings->fog.start_dist);
hashmap_float_set(cvars, "fog_max_dist", settings->fog.max_dist); hashmap_float_set(cvars, "fog_max_dist", settings->fog.max_dist);
hashmap_vec3_set(cvars, "fog_color", &settings->fog.color);
hashmap_bool_set(cvars, "debug_draw_enabled", settings->debug_draw_enabled); hashmap_bool_set(cvars, "debug_draw_enabled", settings->debug_draw_enabled);
hashmap_int_set(cvars, "debug_draw_mode", settings->debug_draw_mode); hashmap_int_set(cvars, "debug_draw_mode", settings->debug_draw_mode);
hashmap_vec4_set(cvars, "debug_draw_color", &settings->debug_draw_color); hashmap_vec4_set(cvars, "debug_draw_color", &settings->debug_draw_color);

@ -181,10 +181,10 @@ void variant_to_str(const struct Variant* variant, char* str, int len)
case VT_INT: snprintf(str, len, "%d", variant->val_int); break; case VT_INT: snprintf(str, len, "%d", variant->val_int); break;
case VT_FLOAT: snprintf(str, len, "%.4f", variant->val_float); break; case VT_FLOAT: snprintf(str, len, "%.4f", variant->val_float); break;
case VT_DOUBLE: snprintf(str, len, "%.4f", variant->val_double); break; case VT_DOUBLE: snprintf(str, len, "%.4f", variant->val_double); break;
case VT_VEC2: snprintf(str, len, "%.3f, %.3f", variant->val_vec2.x, variant->val_vec2.y); break; case VT_VEC2: snprintf(str, len, "%.3f %.3f", variant->val_vec2.x, variant->val_vec2.y); break;
case VT_VEC3: snprintf(str, len, "%.3f, %.3f, %.3f", variant->val_vec3.x, variant->val_vec3.y, variant->val_vec3.z); break; case VT_VEC3: snprintf(str, len, "%.3f %.3f %.3f", variant->val_vec3.x, variant->val_vec3.y, variant->val_vec3.z); break;
case VT_VEC4: snprintf(str, len, "%.3f, %.3f, %.3f, %.3f", variant->val_vec4.x, variant->val_vec4.y, variant->val_vec4.z, variant->val_vec4.w); break; case VT_VEC4: snprintf(str, len, "%.3f %.3f %.3f %.3f", variant->val_vec4.x, variant->val_vec4.y, variant->val_vec4.z, variant->val_vec4.w); break;
case VT_QUAT: snprintf(str, len, "%.3f, %.3f, %.3f, %.3f", variant->val_quat.x, variant->val_quat.y, variant->val_quat.z, variant->val_quat.w); break; case VT_QUAT: snprintf(str, len, "%.3f %.3f %.3f %.3f", variant->val_quat.x, variant->val_quat.y, variant->val_quat.z, variant->val_quat.w); break;
case VT_STR: snprintf(str, len, "%s", variant->val_str); break; case VT_STR: snprintf(str, len, "%s", variant->val_str); break;
case VT_NONE: snprintf(str, len, "%s", "NONE"); break; case VT_NONE: snprintf(str, len, "%s", "NONE"); break;
default: snprintf(str, len, "Unsupported Variant type"); break; default: snprintf(str, len, "Unsupported Variant type"); break;

Loading…
Cancel
Save