diff --git a/src/game/editor.c b/src/game/editor.c index 400915a..068315f 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -1012,7 +1012,7 @@ void editor_entity_select(struct Editor* editor, struct Entity* entity) { if(!entity && editor->selected_entity) // Deselect { - editor->selected_entity->editor_selected = false; + editor->selected_entity->selected_in_editor = false; editor->selected_entity = NULL; editor_tool_reset(editor); } @@ -1020,7 +1020,7 @@ void editor_entity_select(struct Editor* editor, struct Entity* entity) { if(editor->selected_entity && editor->selected_entity != entity) { - editor->selected_entity->editor_selected = false; + editor->selected_entity->selected_in_editor = false; editor->selected_entity = NULL; } @@ -1030,7 +1030,7 @@ void editor_entity_select(struct Editor* editor, struct Entity* entity) editor_axis_set(editor, EDITOR_AXIS_XZ); editor->draw_cursor_entity = true; } - entity->editor_selected = true; + entity->selected_in_editor = true; editor->selected_entity = entity; transform_copy(editor->cursor_entity, editor->selected_entity, false); } @@ -1304,19 +1304,14 @@ void editor_show_entity_in_list(struct Editor* editor, struct nk_context* contex if(!entity->active) return; nk_layout_row_dynamic(context, 20, 1); - if(nk_selectable_label(context, entity->name, NK_TEXT_ALIGN_LEFT, &entity->editor_selected)) + if(nk_selectable_label(context, entity->name, NK_TEXT_ALIGN_LEFT, &entity->selected_in_editor)) { if(editor->selected_entity && editor->selected_entity != entity) - { - editor->selected_entity->editor_selected = false; - editor->selected_entity = NULL; - } - else if(editor->selected_entity && editor->selected_entity == entity && !entity->editor_selected) - { - editor->selected_entity = NULL; - } + editor_entity_select(editor, entity); + else if(editor->selected_entity && editor->selected_entity == entity && !entity->selected_in_editor) + editor_entity_select(editor, NULL); - if(entity->editor_selected) + if(entity->selected_in_editor) { editor->selected_entity = entity; if(!editor->window_property_inspector) editor->window_property_inspector = true; @@ -1391,7 +1386,7 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor* struct Entity* parent_ent = entity->transform.parent; 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_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_layout_row_dynamic(context, row_height, 2); nk_label(context, "Selected", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%s", entity->editor_selected ? "True" : "False"); + nk_layout_row_dynamic(context, row_height, 2); nk_label(context, "Selected", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%s", entity->selected_in_editor ? "True" : "False"); 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)); nk_layout_row_dynamic(context, row_height, 2); nk_label(context, "Parent Name", NK_TEXT_ALIGN_LEFT); nk_label(context, parent_ent ? parent_ent->name : "NONE", NK_TEXT_ALIGN_RIGHT); @@ -1467,10 +1462,10 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor* 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)); + light->outer_angle = nk_propertyf(context, "Outer Angle", light->inner_angle, 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)); + light->inner_angle = nk_propertyf(context, "Inner Angle", 1.f, light->inner_angle, 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); diff --git a/src/game/entity.c b/src/game/entity.c index f1c447e..4223241 100755 --- a/src/game/entity.c +++ b/src/game/entity.c @@ -35,7 +35,7 @@ void entity_init(struct Entity* entity, const char* name, struct Entity* parent) entity->type = ET_DEFAULT; entity->active = true; entity->marked_for_deletion = false; - entity->editor_selected = false; + entity->selected_in_editor = false; transform_init(entity, parent); } @@ -45,7 +45,7 @@ void entity_reset(struct Entity * entity, int id) entity->id = id; entity->active = false; entity->marked_for_deletion = false; - entity->editor_selected = false; + entity->selected_in_editor = false; memset(entity->name, '\0', MAX_ENTITY_NAME_LEN); } diff --git a/src/game/entity.h b/src/game/entity.h index ce86796..c1eafbe 100755 --- a/src/game/entity.h +++ b/src/game/entity.h @@ -65,7 +65,7 @@ struct Entity char name[MAX_ENTITY_NAME_LEN]; bool marked_for_deletion; bool active; - bool editor_selected; + bool selected_in_editor; struct Transform transform; }; diff --git a/src/game/light.c b/src/game/light.c index 4a390de..54b4cc2 100755 --- a/src/game/light.c +++ b/src/game/light.c @@ -1,8 +1,6 @@ #include "light.h" -#include "../common/array.h" #include "entity.h" -#include void light_init(struct Light* light, int light_type) { @@ -13,8 +11,8 @@ void light_init(struct Light* light, int light_type) light->pcf_enabled = false; light->intensity = 1.f; light->falloff = 1.5f; - light->outer_angle = TO_RADIANS(30.f); - light->inner_angle = TO_RADIANS(20.f); + light->outer_angle = 30.f; + light->inner_angle = 20.f; light->radius = 20.f; vec3_fill(&light->color, 1.f, 1.f, 1.f); } diff --git a/src/game/renderer.c b/src/game/renderer.c index a3b4b27..1ed1286 100755 --- a/src/game/renderer.c +++ b/src/game/renderer.c @@ -198,11 +198,11 @@ void renderer_render(struct Renderer* renderer, struct Scene* scene) memset(uniform_name, '\0', MAX_UNIFORM_NAME_LEN); snprintf(uniform_name, MAX_UNIFORM_NAME_LEN, "lights[%d].outer_angle", light_count); - shader_set_uniform_float(material->shader, uniform_name, light->outer_angle); + shader_set_uniform_float(material->shader, uniform_name, TO_RADIANS(light->outer_angle)); memset(uniform_name, '\0', MAX_UNIFORM_NAME_LEN); snprintf(uniform_name, MAX_UNIFORM_NAME_LEN, "lights[%d].inner_angle", light_count); - shader_set_uniform_float(material->shader, uniform_name, light->inner_angle); + shader_set_uniform_float(material->shader, uniform_name, TO_RADIANS(light->inner_angle)); memset(uniform_name, '\0', MAX_UNIFORM_NAME_LEN); snprintf(uniform_name, MAX_UNIFORM_NAME_LEN, "lights[%d].falloff", light_count); diff --git a/src/game/scene.c b/src/game/scene.c index 31d5b17..db590e8 100755 --- a/src/game/scene.c +++ b/src/game/scene.c @@ -396,7 +396,7 @@ void scene_entity_remove(struct Scene* scene, struct Entity* entity) transform_destroy(entity); entity->active = false; - entity->editor_selected = false; + entity->selected_in_editor = false; entity->marked_for_deletion = false; memset(entity->name, '\0', MAX_ENTITY_NAME_LEN); }