Fixed crash where deleting a hovered entity in editor would result in us crashing because the editor didn't know about the updated state of the entity and would still be pointing to it

dev
Shariq Shah 6 years ago
parent 8fa7de827c
commit 4986df6fb6
  1. 2
      src/common/version.h
  2. 11
      src/game/editor.c
  3. 1
      src/game/editor.h
  4. 1
      src/game/game.c
  5. 4
      todo.txt

@ -4,7 +4,7 @@
/* Auto generated version file. DO NOT MODIFY */
#define SYMMETRY_VERSION_MAJOR 0
#define SYMMETRY_VERSION_MINOR 1
#define SYMMETRY_VERSION_REVISION 305
#define SYMMETRY_VERSION_REVISION 306
#define SYMMETRY_VERSION_BRANCH "dev"
#endif

@ -1223,6 +1223,8 @@ void editor_on_key_release(const struct Event* event)
{
editor->selected_entity->flags |= EF_MARKED_FOR_DELETION;
editor_entity_select(editor, NULL);
if(editor->hovered_entity == editor->selected_entity)
editor->hovered_entity = NULL;
}
if(event->key.key == KEY_D && input_is_key_pressed(KEY_LCTRL) && editor->selected_entity && !editor->camera_looking_around)
@ -1664,6 +1666,8 @@ void editor_show_entity_in_list(struct Editor* editor, struct nk_context* contex
{
entity->flags |= EF_MARKED_FOR_DELETION;
editor_entity_select(editor, NULL);
if(editor->hovered_entity == entity)
editor->hovered_entity = NULL;
}
if(nk_contextual_item_label(context, "Save", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE))
@ -2449,3 +2453,10 @@ void editor_entity_dialog(struct Editor* editor, struct nk_context* context)
}
context->style.window.fixed_background.data.color.a = previous_opacity;
}
void editor_post_update(struct Editor* editor)
{
if(editor->hovered_entity && !(editor->hovered_entity->flags & EF_ACTIVE))
editor->hovered_entity = NULL;
}

@ -64,6 +64,7 @@ void editor_camera_init(struct Editor* editor_state, struct Hashmap* cvars);
void editor_init_entities(struct Editor* editor);
void editor_render(struct Editor* editor_state, struct Camera* active_camera);
void editor_update(struct Editor* editor_state, float dt);
void editor_post_update(struct Editor* editor);
void editor_cleanup(struct Editor* editor_state);
#endif

@ -581,6 +581,7 @@ void game_post_update(float dt)
scene_post_update(game_state->scene);
sound_update_3d(game_state->sound);
debug_vars_post_update(game_state->debug_vars);
editor_post_update(game_state->editor);
}
void game_debug_gui(float dt)

@ -1,6 +1,4 @@
Todo:
? Only show bounding box for hovered entity instead of wireframe mesh
- Fix crash where if an entity is hoverd in editor and deleted, the game crashes because the hovered variable in editor doesn't know that the entity was deleted
? Write entity flags to scene file or when saving entity to file?
? Add scene init/de-init function hashmap that maps a function that should be called when scene is loaded and unloaded. Save this to file for every scene or map functions based on the name of the scene?
- Command to create a placeholder entity of a particular type in a file
@ -108,6 +106,7 @@ Improvements:
- Improve grid/immediate mode drawing by switching to glDrawElements instead of glDrawArrays.
- Investigate why transparency is not working for materials
- Picking for other entity types like lights etc by specifically ray casting for them or in editor switching to pick-mode that specifies if we're picking lights or meshes etc
? Only show bounding box for hovered entity instead of wireframe mesh
Bugs:
- Better handling of wav format checking at load time
@ -396,3 +395,4 @@ Done:
* Simplified rendering further and removed unnecessary intermediate fbos
* We no longer keep geoemtry data loaded from files as it is not needed after data is passed on to opengl
* Shift-A to add entity to scene
* Fixed crash where if an entity is hoverd in editor and deleted, the game crashes because the hovered variable in editor doesn't know that the entity was deleted
Loading…
Cancel
Save