diff --git a/assets/scenes/Level_1.symtres b/assets/scenes/Level_1.symtres index 04af975..53bc997 100755 --- a/assets/scenes/Level_1.symtres +++ b/assets/scenes/Level_1.symtres @@ -16,9 +16,9 @@ Player { type : 2 scale : 1.000 1.000 1.000 - rotation : 0.000 -0.616 0.000 0.789 + rotation : 0.000 -0.489 0.000 0.873 active : true - position : -33.936 4.392 -38.211 + position : -51.333 6.103 -36.095 name : Player camera_clear_color : 0.298 0.600 0.898 1.000 } diff --git a/src/common/parser.c b/src/common/parser.c index 207e0de..5f42789 100755 --- a/src/common/parser.c +++ b/src/common/parser.c @@ -278,6 +278,8 @@ void parser_free(struct Parser *parser) object->data = NULL; object->type = PO_UNKNOWN; } + array_free(parser->objects); + free(parser); } struct Parser* parser_new(void) diff --git a/src/game/debug_vars.c b/src/game/debug_vars.c index ed92f7b..0452369 100755 --- a/src/game/debug_vars.c +++ b/src/game/debug_vars.c @@ -140,7 +140,8 @@ void debug_vars_post_update(struct Debug_Vars* debug_vars) case VT_INT: // Texture nk_layout_row_dynamic(context, debug_vars->row_height_texture, 2); nk_label(context, &variable->name[0], name_flags); - nk_image_color(context, nk_image_id(texture_get_texture_handle(variable->value.val_int)), nk_rgb_f(1.f, 1.f, 1.f)); + //nk_image_color(context, nk_image_id(texture_get_texture_handle(variable->value.val_int)), nk_rgb_f(1.f, 1.f, 1.f)); + nk_image_color(context, nk_image_id(variable->value.val_int), nk_rgb_f(1.f, 1.f, 1.f)); break; case VT_VEC3: // Color RGB nk_layout_row_dynamic(context, debug_vars->row_height_color, 2); diff --git a/src/game/editor.c b/src/game/editor.c index 2dc1d49..c1e3dfc 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -1499,6 +1499,8 @@ void editor_camera_update(struct Editor* editor, float dt) debug_vars_show_texture("Editor Cam Depth", editor_camera->depth_tex); debug_vars_show_color_rgba("Editor Cam Clear Color", &editor_camera->clear_color); + debug_vars_show_int("Editor Cam Depth Index", editor_camera->depth_tex); + debug_vars_show_int("Editor Cam Render Index", editor_camera->render_tex); } void editor_widget_color_combov3(struct nk_context* context, vec3* color, int width, int height) diff --git a/src/game/entity.c b/src/game/entity.c index 8e43b56..24dd923 100755 --- a/src/game/entity.c +++ b/src/game/entity.c @@ -121,12 +121,9 @@ bool entity_write(struct Entity* entity, struct Parser_Object* object, bool writ //hashmap_str_set(entity_data, "parent", parent ? parent->name : "NONE"); /* Transform */ - if(write_transform) - { - hashmap_vec3_set(entity_data, "position", &entity->transform.position); - hashmap_vec3_set(entity_data, "scale", &entity->transform.scale); - hashmap_quat_set(entity_data, "rotation", &entity->transform.rotation); - } + hashmap_vec3_set(entity_data, "position", &entity->transform.position); + hashmap_vec3_set(entity_data, "scale", &entity->transform.scale); + hashmap_quat_set(entity_data, "rotation", &entity->transform.rotation); switch(entity->type) { @@ -456,22 +453,18 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e } //If there's a parent entity then it means this is a child entity and we shoud load it's relative transform values - if(parent_entity) - { - vec3 position = { 0.f, 0.f, 0.f }; - quat rotation = { 0.f, 0.f, 0.f, 1.f }; - vec3 scale = { 1.f, 1.f, 1.f }; - - if(hashmap_value_exists(object->data, "position")) position = hashmap_vec3_get(object->data, "position"); - if(hashmap_value_exists(object->data, "rotation")) rotation = hashmap_quat_get(object->data, "rotation"); - if(hashmap_value_exists(object->data, "scale")) scale = hashmap_vec3_get(object->data, "scale"); - - transform_set_position(new_entity, &position); - transform_scale(new_entity, &scale); - quat_mul(&new_entity->transform.rotation, &new_entity->transform.rotation, &rotation); - transform_update_transmat(new_entity); - - } + vec3 position = { 0.f, 0.f, 0.f }; + quat rotation = { 0.f, 0.f, 0.f, 1.f }; + vec3 scale = { 1.f, 1.f, 1.f }; + + if(hashmap_value_exists(object->data, "position")) position = hashmap_vec3_get(object->data, "position"); + if(hashmap_value_exists(object->data, "rotation")) rotation = hashmap_quat_get(object->data, "rotation"); + if(hashmap_value_exists(object->data, "scale")) scale = hashmap_vec3_get(object->data, "scale"); + + transform_set_position(new_entity, &position); + transform_scale(new_entity, &scale); + quat_mul(&new_entity->transform.rotation, &new_entity->transform.rotation, &rotation); + transform_update_transmat(new_entity); return new_entity; } diff --git a/src/game/gui.c b/src/game/gui.c index f7105e3..781166d 100755 --- a/src/game/gui.c +++ b/src/game/gui.c @@ -226,13 +226,13 @@ void gui_render(struct Gui* gui, enum nk_anti_aliasing AA) (GLint)(cmd->clip_rect.w * scale.x), (GLint)(cmd->clip_rect.h * scale.y)); glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count, GL_UNSIGNED_SHORT, offset); + texture_unbind(cmd->texture.id); offset += cmd->elem_count; } nk_clear(&gui->context); } shader_unbind(); - texture_unbind(gui->font_tex); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindVertexArray(0); diff --git a/src/game/texture.c b/src/game/texture.c index 2046b7a..ebdc7fa 100755 --- a/src/game/texture.c +++ b/src/game/texture.c @@ -158,15 +158,24 @@ void texture_cleanup(void) void texture_bind(int index) { - assert(index > -1 && index < array_len(texture_list)); - glActiveTexture(GL_TEXTURE0 + texture_list[index].texture_unit); - glBindTexture(GL_TEXTURE_2D, texture_list[index].handle); + if(index < 0 || index >= array_len(texture_list)) + { + log_warning("Cannot bind invalid texture handle"); + return; + } + GL_CHECK(glActiveTexture(GL_TEXTURE0 + texture_list[index].texture_unit)); + GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture_list[index].handle)); } void texture_unbind(int index) { - glActiveTexture(GL_TEXTURE0 + texture_list[index].texture_unit); - glBindTexture(GL_TEXTURE_2D, 0); + if(index < 0 || index >= array_len(texture_list)) + { + log_warning("Cannot unbind invalid texture handle"); + return; + } + GL_CHECK(glActiveTexture(GL_TEXTURE0 + texture_list[index].texture_unit)); + GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0)); } int load_img(FILE* file, GLubyte** image_data, int* width, int* height, int* fmt, int* internal_format) diff --git a/todo.txt b/todo.txt index ce001de..12fc079 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,5 @@ Todo: + - Command to create a placeholder entity of a particular type in a file - Re-write/Overhaul bounding volumes and ray intersection - Reduce the opacity of wireframe around selected entity in editor - Allow picking and selecting other entity types in editor i.e. the ones that don't have meshes @@ -7,10 +8,14 @@ Todo: this will prevent us from having needless amount of entities with only minor changes from one another ? Split up material declarations into their own separate files. Materials have a base material like Blinn or Unshaded and in the file we save an instance with modified properties. when we are assigning materials to entites, we assign the instance of a particular material to them. + ? Change hierarchical transformations from parent/child to an entity having attachments/slots where another entity can be attached or mounted. This way we can have hierarchical transformations and not have to store + a whole enitity hierarchy when saving the entity. When loading the entity, we load the entity and see which entites are attached to it and get references to those entity in the scene, if they are not loaded we could + either load them there and then or complain to the scene that we couldn't find the attachements and just carry on as usual - When loading entities, show an additional optional textfield where user can enter the name they want for the entity after it is loaded - Add editor undo for transformation operations - Decide how to handle scale when checking sphere-ray intersection - Add material export for blender exporter? + - Show current filename of the scene we are working on and whether we have made any changes to it since the last time we saved - Fix crash when exiting from fullscreen mode - Check if we still need to rotate by 90 degrees when exporting from blender - Fire an event when the game mode is changed so that editor camera state and other game related systems know when to update @@ -42,10 +47,7 @@ Todo: - Color palette, picker and dropper - Key binding and function to snap editor camera to selected entity location - - Implement resetting complete transform or just rotation, translation - or scale for selected entity - Key binding and function to orient entity to camera orientation - - Make lights and other entity types pickable - Mouse warp to opposite side of the window when it reaches bounds - Add other axis combinations like YZ and XY to transform tool - Transformation space selection for translation, rotation and scale. @@ -392,4 +394,6 @@ Done: * Separate entity types in entity hierarchy view by the entity type or use a tree view to show parent/child relation or use different colours for different entity types * Show archetype name in property inspector for selected entity * Write player camera clear colour when saving scene - * Add uv tiling parameter to materials that can be serialized along with entities \ No newline at end of file + * Add uv tiling parameter to materials that can be serialized along with entities + * Implement resetting complete transform or just rotation, translation + or scale for selected entity \ No newline at end of file