diff --git a/src/game/editor.c b/src/game/editor.c index 3f4172c..7ff449f 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -110,7 +110,6 @@ void editor_init(struct Editor* editor) editor->camera_turn_speed = 50.f; editor->camera_move_speed = 20.f; editor->camera_sprint_multiplier = 2.f; - editor->current_transform_space = TS_WORLD; editor->current_mode = EDITOR_MODE_NORMAL; editor->current_axis = EDITOR_AXIS_XZ; editor->previous_axis = EDITOR_AXIS_XZ; @@ -183,7 +182,7 @@ void editor_render(struct Editor* editor, struct Camera * active_camera) if(editor->selected_entity) { transform_get_absolute_position(editor->selected_entity, &position); - transform_get_absolute_scale(editor->selected_entity, &scale); + //transform_get_absolute_scale(editor->selected_entity, &scale); transform_get_absolute_rot(editor->selected_entity, &rotation); } @@ -326,7 +325,7 @@ void editor_update(struct Editor* editor, float dt) nk_layout_row_push(context, 0.45f); nk_spacing(context, 1); - nk_layout_row_push(context, 0.1f); + nk_layout_row_push(context, 0.15f); static const char* editor_transformation_modes[] = { "Mode: Normal", "Mode: Translate", "Mode: Rotate", "Mode: Scale" }; if(nk_combo_begin_label(context, editor_transformation_modes[editor->current_mode], nk_vec2(160, 125))) { @@ -341,19 +340,6 @@ void editor_update(struct Editor* editor, float dt) } nk_layout_row_push(context, 0.1f); - static const char* editor_transformation_spaces[] = { "Space: Local", "Space: Parent", "Space: World" }; - if(nk_combo_begin_label(context, editor_transformation_spaces[editor->current_transform_space], nk_vec2(160, 125))) - { - nk_layout_row_dynamic(context, row_height, 1); - int space = editor->current_transform_space; - space = nk_option_label(context, "Local", space == TS_LOCAL) ? TS_LOCAL : space; - space = nk_option_label(context, "Parent", space == TS_PARENT) ? TS_PARENT : space; - space = nk_option_label(context, "World", space == TS_WORLD) ? TS_WORLD : space; - editor->current_transform_space = space; - nk_combo_end(context); - } - - nk_layout_row_push(context, 0.05f); static const char* editor_axes[] = { "Axis: XZ", "Axis: X", "Axis: Y", "Axis: Z" }; if(nk_combo_begin_label(context, editor_axes[editor->current_axis], nk_vec2(160, 125))) { @@ -435,6 +421,7 @@ void editor_update(struct Editor* editor, float dt) im_sphere(0.5f, editor->tool_mesh_position, (quat) { 0.f, 0.f, 0.f, 1.f }, editor->tool_mesh_color, GDM_TRIANGLES, 2); //im_box(editor->grid_scale, editor->grid_scale, editor->grid_scale, editor->tool_mesh_position, (quat) { 0.f, 0.f, 0.f, 1.f }, editor->tool_mesh_color, GDM_TRIANGLES); + //Draw Axes im_begin(editor->tool_mesh_position, (quat) { 0.f, 0.f, 0.f, 1.f }, (vec3) { 1.f, 1.f, 1.f }, (vec4) { 0.f, 1.f, 1.f, 1.f }, GDM_LINES, 3); switch(editor->current_axis) { @@ -497,7 +484,13 @@ void editor_on_mousebutton(const struct Event* event) { if(editor->current_mode == EDITOR_MODE_TRANSLATE) { - transform_set_position(editor->selected_entity, &editor->tool_mesh_position); + //transform_set_position(editor->selected_entity, &editor->tool_mesh_position); + vec3 translation = { 0.f, 0.f, 0.f }; + vec3 current_position = {0.f, 0.f, 0.f}; + transform_get_absolute_position(editor->selected_entity, ¤t_position); + vec3_sub(&translation, &editor->tool_mesh_position, ¤t_position); + //transform_translate(editor->selected_entity, &translation, editor->current_transform_space); + transform_translate(editor->selected_entity, &translation, TS_WORLD); } else { diff --git a/src/game/editor.h b/src/game/editor.h index e4d717b..f4593ca 100755 --- a/src/game/editor.h +++ b/src/game/editor.h @@ -24,7 +24,6 @@ struct Editor vec4 selected_entity_colour; int current_mode; int current_axis; - int current_transform_space; int previous_axis; int grid_enabled; vec4 grid_color; diff --git a/todo.txt b/todo.txt index 7d2aa6b..a682e48 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,6 @@ Todo: + - Draw coloured axes lines at world origin or grid origin + - Toggle between relative and static grid i.e, grid that moves along with the selected object or grid that remains stationary at the origin - Better, more accurate picking - Highlight if we are about to select an entity or perform the tool action like translate when mouse is hovered and an entity can be selected at that location - Display the projected position if we perform the action for example display what the new location would be right next to the tool mesh @@ -10,6 +12,7 @@ Todo: - Use actual selected entity's mesh for tool mesh when the entity already has a mesh and use a placeholder like a sphere when there is not mesh - Add warning to genie build script when running on windows and WindowsSdkVersion cannot be found. This happens when the script is not run from vcvarsall command prompt - Improve README and add a screenshot to make the repository ready for making it public + - Show Transformation deltas for example a line showing where we are to where we are going to be if we click and apply the selected transformation - Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere ? Improve bounding sphere calculation - Change the way lights are set as uniforms to remove snprintf calls per frame for every light attribute @@ -82,6 +85,7 @@ Bugs: - Fix bounding boxes not aligning in editor - Investigate memory usage increase when window is minimized - Fix hang on fullscreen toggle + - Fix axis lines not aligning with grid lines Done: * Input