Added button in property inspector to reset the local transform for entity

dev
Shariq Shah 6 years ago
parent 197e195703
commit bff55ba6f5
  1. 2
      src/game/debug_vars.c
  2. 18
      src/game/editor.c
  3. 3
      todo.txt

@ -10,7 +10,7 @@ static void debug_vars_clear(struct Debug_Vars* debug_vars);
void debug_vars_init(struct Debug_Vars* debug_vars)
{
debug_vars->visible = true;
debug_vars->visible = false;
debug_vars->location = DVL_TOP_RIGHT;
debug_vars->window_width = 300;
debug_vars->window_height = 500;

@ -86,7 +86,7 @@ static bool editor_widget_v3(struct nk_context* context,
float inc_per_pixel,
int row_height);
static void editor_window_scene_heirarchy(struct nk_context* context, struct Editor* editor, struct Game_State* game_state);
static void editor_window_scene_hierarchy(struct nk_context* context, struct Editor* editor, struct Game_State* game_state);
static void editor_window_property_inspector(struct nk_context* context, struct Editor* editor, struct Game_State* game_state);
static void editor_window_renderer_settings(struct nk_context* context, struct Editor* editor, struct Game_State* game_state);
static void editor_window_settings_editor(struct nk_context* context, struct Editor* editor, struct Game_State* game_state);
@ -566,7 +566,7 @@ void editor_update(struct Editor* editor, float dt)
}
nk_end(context);
if(editor->window_scene_heirarchy) editor_window_scene_heirarchy(context, editor, game_state);
if(editor->window_scene_heirarchy) editor_window_scene_hierarchy(context, editor, game_state);
if(editor->window_property_inspector) editor_window_property_inspector(context, editor, game_state);
if(editor->window_settings_renderer) editor_window_renderer_settings(context, editor, game_state);
if(editor->window_settings_editor) editor_window_settings_editor(context, editor, game_state);
@ -1455,7 +1455,7 @@ void editor_show_entity_in_list(struct Editor* editor, struct nk_context* contex
}
}
void editor_window_scene_heirarchy(struct nk_context* context, struct Editor* editor, struct Game_State* game_state)
void editor_window_scene_hierarchy(struct nk_context* context, struct Editor* editor, struct Game_State* game_state)
{
if(nk_begin(context, "Scene Heirarchy", nk_recti(0, editor->top_panel_height, 300, 400), window_flags))
{
@ -1501,6 +1501,18 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor*
/* Transform */
{
if(nk_widget_is_hovered(context))
nk_tooltip(context, "Resets the local transformations for this entity without changing the entity's parent");
nk_layout_row_dynamic(context, row_height, 1);
if(nk_button_label(context, "Reset Transform"))
{
vec3_fill(&entity->transform.position, 0.f, 0.f, 0.f);
vec3_fill(&entity->transform.scale, 1.f, 1.f, 1.f);
quat_fill(&entity->transform.rotation, 0.f, 0.f, 0.f, 1.f);
transform_update_transmat(entity);
}
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 };
transform_get_absolute_position(entity, &abs_pos);

@ -366,4 +366,5 @@ Done:
* Brought back debug variable display in editor and allow showing colours, textures etc
* Shortcut key to toggle debug variable display and cycle locations
* Move debug vars display settings to debug_vars struct
* Command history in console
* Command history in console
* Added button to reset local transformations for selected entity in property inspector
Loading…
Cancel
Save