From e3e471e8bf59593ed2497955d8297af9bcdbf531 Mon Sep 17 00:00:00 2001 From: Shariq Shah Date: Thu, 18 Apr 2019 11:29:14 +1000 Subject: [PATCH] Fixed bug with incorrect editor toggling and checking --- src/game/editor.c | 53 +++--- src/game/editor.h | 1 - src/game/game.c | 3 +- todo.txt | 420 +++++++++++++++++++++++----------------------- 4 files changed, 236 insertions(+), 241 deletions(-) diff --git a/src/game/editor.c b/src/game/editor.c index ee4bff5..9e43dd3 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -66,7 +66,6 @@ static bool editor_widget_v3(struct nk_context* context, void editor_init(struct Editor* editor) { - editor->enabled = true; editor->renderer_settings_window = false; editor->camera_looking_around = false; editor->selected_entity = NULL; @@ -198,8 +197,6 @@ void editor_debugvar_slot_set_quat(int index, quat* value) void editor_update(struct Editor* editor, float dt) { - if(!editor->enabled) return; - editor_camera_update(editor, dt); struct Game_State* game_state = game_state_get(); @@ -217,31 +214,27 @@ void editor_update(struct Editor* editor, float dt) /* Top Panel */ if(nk_begin(context, "Top Panel", nk_recti(0, 0, win_width, editor->top_panel_height), NK_WINDOW_NO_SCROLLBAR)) { - nk_layout_row_dynamic(context, editor->top_panel_height, 1); - nk_group_begin(context, "Menubar", NK_WINDOW_NO_SCROLLBAR); + static float top_panel_ratios[] = { 0.1f, 0.1f, 0.7f, 0.1f }; + static int frames = 0; + static int fps = 0; + static float seconds = 0.f; + seconds += dt; + frames++; + if(seconds >= 1.f) { - static float top_panel_ratios[] = { 0.1f, 0.1f, 0.7f, 0.1f }; - static int frames = 0; - static int fps = 0; - static float seconds = 0.f; - seconds += dt; - frames++; - if(seconds >= 1.f) - { - fps = frames; - seconds = 0.f; - frames = 0; - } - - nk_layout_row(context, NK_DYNAMIC, editor->top_panel_height, sizeof(top_panel_ratios) / sizeof(float), top_panel_ratios); - if(nk_button_label(context, "Render Settings")) - editor->renderer_settings_window = !editor->renderer_settings_window; - if(nk_button_label(context, "Save config")) - config_vars_save("config.symtres", DIRT_USER); - nk_spacing(context, 1); - nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps); + fps = frames; + seconds = 0.f; + frames = 0; } - nk_group_end(context); + + nk_layout_row(context, NK_DYNAMIC, editor->top_panel_height - 10, sizeof(top_panel_ratios) / sizeof(float), top_panel_ratios); + if(nk_button_label(context, "Render Settings")) + editor->renderer_settings_window = !editor->renderer_settings_window; + if(nk_button_label(context, "Save config")) + config_vars_save("config.symtres", DIRT_USER); + nk_spacing(context, 1); + nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps); + nk_layout_row_dynamic(context, editor->top_panel_height, 1); } nk_end(context); @@ -574,8 +567,12 @@ void editor_on_mousebutton(const struct Event* event) { assert(event->type == EVT_MOUSEBUTTON_PRESSED || event->type == EVT_MOUSEBUTTON_RELEASED); - struct Editor* editor = game_state_get()->editor; - struct Gui* gui = game_state_get()->gui; + struct Game_State* game_state = game_state_get(); + struct Editor* editor = game_state->editor; + struct Gui* gui = game_state->gui; + if(game_state->game_mode != GAME_MODE_EDITOR) + return; + if(event->mousebutton.button == MSB_LEFT && event->type == EVT_MOUSEBUTTON_RELEASED && !editor->camera_looking_around && diff --git a/src/game/editor.h b/src/game/editor.h index 62b9d42..d06388f 100755 --- a/src/game/editor.h +++ b/src/game/editor.h @@ -9,7 +9,6 @@ struct Entity; struct Editor { - bool enabled; bool renderer_settings_window; bool camera_looking_around; struct Entity* selected_entity; diff --git a/src/game/game.c b/src/game/game.c index 22779b4..454248a 100755 --- a/src/game/game.c +++ b/src/game/game.c @@ -515,7 +515,6 @@ void game_update(float dt, bool* window_should_close) if(input_map_state_get("Console_Toggle", KS_RELEASED)) console_toggle(game_state->console); if(input_map_state_get("Editor_Toggle", KS_RELEASED)) { - //editor_toggle(); if(game_state->game_mode == GAME_MODE_EDITOR) { game_state->game_mode = GAME_MODE_GAME; @@ -551,7 +550,7 @@ void game_post_update(float dt) void game_debug_gui(float dt) { - struct Gui* gui_state = gui_state_get(); + struct Gui* gui_state = game_state->gui; struct nk_context* ctx = &gui_state->context; /* window flags */ diff --git a/todo.txt b/todo.txt index 6329638..ba22b7b 100644 --- a/todo.txt +++ b/todo.txt @@ -1,210 +1,210 @@ -Todo: - - Specific rendering mode for editor related rendering - - Basic Editor gizmo for transformation i.e. translate/rotate/scale in world and local coordinates - - 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 - - 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 - - Screen mouse coordinates to world-coordinates for aiming - - Player projectiles and sounds - - Console commands - - Console command history - - Console command help - - Space partitioning and scene handling - - Move Gui_State and Editor_State into game_state and modify usage as needed - - Get editor camera speed and other settings from config file - - Recompile Soloud on windows to use static sdl2 backend - - Figure out a way to reduce of remove snprintf calls from render code - - Re-Implement saving/loading scene to/from files - - Implement storing console's scroll location and restore it when console is toggled - - Implement collision/physics data serialization, read and write. - - Physics forces/torque etc - - Implement physics debug visualizations for other primitives and tri mesh shapes - - Serializing/Deserializing physics data - - Proper implementation of Scene struct with per-scene settings and configurations that can be loaded/saved to file instead of just dumping entities into a file - - Necessary basic editor additions like placing objects, scaling, rotating etc - - Add fallback shader - - Implement Game States - - Store Materials in new format supported by parser - - Add model description file which has the same syntax supported by parser and modify old blender exporter to conform to new standards - - Fix bugs with sound sources not updating - - Add creating distributable build and uploading to itch.io account support to GENie under windows and linux. - - Remove hardcoded numerical values from sscanf and other format strings. - ? Recalculated bounding boxes for rotated meshes - ? Wrap malloc and free calls in custom functions to track usage - ? File extension checking for asset loading - ? Only allocate hashmap bucket when required - - Mapping actions to keybindings, for example map action "Jump" to Space key etc - ? Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example - ? Interleaved vbos for meshes and changes to blender exporter accordingly - - Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? - ? Better handling incase assets folder is not found - - Write entity to/from file - - Ogg format loading and playback - - Sound streaming - - Implment missing sound source properties (inner/outer cone, getting sound source data) - - Shadow maps - - Print processor stats and machine capabilites RAM etc on every run to log. - - Do input maps really need to be queried by their string names? - - Write default config/keybindings etc to file if none are found in preferences dir - - Multisampled textures and framebuffers - - Validate necessary assets at game launch - - Gamma correctness - - Log and debug/stats output in gui - - Textual/Binary format for data serialization and persistance - - Array based string type comptible with cstring(char*) - - Reduce fps on window focus loss or minimization - - ??? - - Profit! - -Improvements: - - Better naming semantics for examples, init/deinit for initialization and cleanup and create/destroy when memory is allocated or deallocated - - Reset mouse cursor position to the center of the screen in editor mode after the right click is released - - Categorized entity list in editor for example different subtree for lights and static meshes - - Remove fixed editor windows locations and bring back floating windows - -Bugs: - - Better handling of wav format checking at load time - - Fix light rotation/direction bugs - - Fix lights type not being correctly saved/loaded from file - - Fix culling - - Fix bounding boxes not aligning in editor - - Investigate memory usage increase when window is maximized - -Done: - * Input - * Shaders - * Geometry - * change struct usage - * change Array implementation - * resolve vec-types sizes - * Transform - * Deltatime - * Investigate about Exit() and at_exit() functions and whether to use them or not. - * Fix readme markdown - * Framebuffer and resolution independent rendering - * A simpler build system without dependencies - * Remove dependencies - * Remove Kazmath dependency - * Entity - * Find a permanent solution for build system - * Textures - * Camera - * Test render - * Fix input lag and other framerate related issues - * Materials - * Mesh/Model - * Add modifiers to input maps to enable combinations for example, c-x, m-k etc - * Heirarchical Transforms - * Materials with textures - * Lights! - * Fix problems with texture units - * Fix problems with frustrum culling - * Gui - * Fix mouse bugs on windows - * Configuration/Settings load/save handling - * Fix mousewheel bugs and gui not responding to mousewheel input - * Setup cross compilation with mingw or stick to msvc? - * Toggleable debug drawing for meshes - * Font selection - * Font atlas proper cleanup - * In second refactor pass, use entities everywhere, no need to pass in transform and model separately for example since they're both part of the same entity anyway - * Show SDL dialogbox if we cannot launch at all? - * Writing back to config file - * Reading from config file - * Variant -> String conversion procedure. Use in editor for debug var slots - * Add strings and booleans to variant types - * Fix Key release not being reported - * OpenAL not working in releasebuilds - * 3d sound using OpenAL - * Fix frustum culling bugs - * Array-based Hashmaps - * Fix bugs with heirarchical transformations - * Remove reduntant "settings" structures and move all configuration stuff to config variables - * Log output to file on every run - * Add option to specify where to read/write files from instead of being hard-coded assets dir - * Fix input map bugs - * Live data views in editor - * Camera resize on window reisze - * Resizable framebuffers and textures - * Support for multiple color attachments in framebuffers? - * Better way to store and manage textures attached to framebuffers - * Variant type - * Editor - * Fix frustum culling sometimes not working - * Compile and test on windows - * Fix mouse bugs - * Fix issues with opengl context showing 2.1 only - * Improve this readme - * Replace orgfile with simple text readme and reduce duplication - * Fix camera acting all weird when right click is held - * Fix README to conform with markdown syntax - * Added video driver selection to make game launch under wayland or x11 on linux. - * Separate game code into a dynamical library that can be reloaded at runtime. - * Move game, common and game library related code into separate folders. - * Fixed game crashing on exit after game library has been reloaded more than once. - * Made game compile and run under windows with visual studio 2017 using GENie - * Implemented file copy and file delete on windows and linux. - * Implemented a work-around for dll locking on windows by creating a copy of the game lib at launch and when reloading, - unloading the current dll, deleting it and creating new copy of the updated dll and loading that - * Added file copy and delete to platform api - * Made dll reloading workaround compatilble on linux - * Default keybindings as fallback - * Implemented writing scene to file - * Fixed space not being added after light entities are written to file by adding missing new-line - * Fixed error caused by the way eof was checked in scene file - * Camera fbo params are now written to file when entity is saved - * Fixed several bugs with entity loading - * Removed duplicate parsing logic - * Fixed bugs in stripping key name for input map - * Modify entity loading logic to use the new parsing code by parsing all entity properties into a hashmap first then recreating entity from that - * Implmented writing to file through the new Parser and Parser_Objects - * Changed Config to read/write using new Parser and Parser_Objects - * Implemented Reading/Writing keybindings using new parser object - * Replaced OpenAL with Soloud with SDL2 backend - * Implemented sound/listener loading from scene file - * Finished loading scene from file - * Initial implementation of immediate-mode batched sprite render - * Fixed bugs with shader include file pre-processor - * Fixed bugs with editor's camera property viewer - * Fixed bugs related to changing camera projection - * Fixed bugs with sprite batch renderer not working with projection matrix - * Fixed broken orthographic camera - * Implement necessary changes to run Soloud on linux - * Moved third party libs/include directories into root/lib and root/include. Put common includes like header-only libs into root/include/common and others which require platform specific stuff into root/include/linux etc. - * Got rid of pkg-confg and system-installed SDL2 dependancy on linux and instead put custom compiled SDL libs in libs folder similar to how we're handling it in windows - * Proper physics time-step and speed - * Proper handling of rigidbody associated with an entity and notifying it of movement or collision - * Added physics spheres and other primitive shapes - * Separated collision shape and rigidbody - * Implemented Getting/Modifying primitive physics shapes' values like length, radius etc - * Update physics if entity position/rotation/scale etc are changed - * Implemented Physics raycasting - * Implemented immediate mode renderer that can draw arbitrary points, lines and triangles - * Converted IM_Vertex array to only be used as temporary storage for vertices between begin and end calls - * Implemented Debug physics mesh drawing for box and sphere primitives - * Completed Phase 1 of codebase refactoring - * Improved editor camera handling - * Re-implemented showing all the entities in the editor - * Player init, update, visual representation and movement - * Switching between editor and game mode/cameras - * In-game basis for scrollable console/log-viewer - * Console log output - * Console error/warning output - * Implemented Auto scrolling to the bottom in console - * Implemented screen coordinate to ray conversion and ray-sphere collision - * Split todo and readme into two files - * Replace all renderer_check_gl calls with GL_CHECK macro - * Fixed Console bug when enabled in editor mode - * Migrated from bitbucket to github and from mercurial back to git - * Removed the game executable and game library split. - * Event Subsystem - * Fixed mouse button press/release behaviour by using event callbacks for editor mouse picking - * Ray picking for editor - * Highlight entity selected in editor in a specific color - * Deselect selected entity in editor when nothing is hit on click and an entity is already selected - * Implemented showing a placeholder when an entity other than a static mesh is selected - * Prevented ray casting when clicking on editor window and buttons - * Implemented handling drawing other entity types that can be selected in the editor but are not static meshes - +Todo: + - Implement proper topbar + - Specific rendering mode for editor related rendering + - Basic Editor gizmo for transformation i.e. translate/rotate/scale in world and local coordinates + - 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 + - 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 + - Screen mouse coordinates to world-coordinates for aiming + - Player projectiles and sounds + - Console commands + - Console command history + - Console command help + - Space partitioning and scene handling + - Move Gui_State and Editor_State into game_state and modify usage as needed + - Get editor camera speed and other settings from config file + - Recompile Soloud on windows to use static sdl2 backend + - Figure out a way to reduce of remove snprintf calls from render code + - Re-Implement saving/loading scene to/from files + - Implement storing console's scroll location and restore it when console is toggled + - Implement collision/physics data serialization, read and write. + - Physics forces/torque etc + - Implement physics debug visualizations for other primitives and tri mesh shapes + - Serializing/Deserializing physics data + - Proper implementation of Scene struct with per-scene settings and configurations that can be loaded/saved to file instead of just dumping entities into a file + - Necessary basic editor additions like placing objects, scaling, rotating etc + - Add fallback shader + - Implement Game States + - Store Materials in new format supported by parser + - Add model description file which has the same syntax supported by parser and modify old blender exporter to conform to new standards + - Fix bugs with sound sources not updating + - Add creating distributable build and uploading to itch.io account support to GENie under windows and linux. + - Remove hardcoded numerical values from sscanf and other format strings. + ? Recalculated bounding boxes for rotated meshes + ? Wrap malloc and free calls in custom functions to track usage + ? File extension checking for asset loading + ? Only allocate hashmap bucket when required + - Mapping actions to keybindings, for example map action "Jump" to Space key etc + ? Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example + ? Interleaved vbos for meshes and changes to blender exporter accordingly + - Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? + ? Better handling incase assets folder is not found + - Write entity to/from file + - Ogg format loading and playback + - Sound streaming + - Implment missing sound source properties (inner/outer cone, getting sound source data) + - Shadow maps + - Print processor stats and machine capabilites RAM etc on every run to log. + - Do input maps really need to be queried by their string names? + - Write default config/keybindings etc to file if none are found in preferences dir + - Multisampled textures and framebuffers + - Validate necessary assets at game launch + - Gamma correctness + - Log and debug/stats output in gui + - Textual/Binary format for data serialization and persistance + - Array based string type comptible with cstring(char*) + - Reduce fps on window focus loss or minimization + - ??? + - Profit! + +Improvements: + - Better naming semantics for examples, init/deinit for initialization and cleanup and create/destroy when memory is allocated or deallocated + - Reset mouse cursor position to the center of the screen in editor mode after the right click is released + - Categorized entity list in editor for example different subtree for lights and static meshes + - Remove fixed editor windows locations and bring back floating windows + +Bugs: + - Better handling of wav format checking at load time + - Fix light rotation/direction bugs + - Fix lights type not being correctly saved/loaded from file + - Fix culling + - Fix bounding boxes not aligning in editor + - Investigate memory usage increase when window is maximized + +Done: + * Input + * Shaders + * Geometry + * change struct usage + * change Array implementation + * resolve vec-types sizes + * Transform + * Deltatime + * Investigate about Exit() and at_exit() functions and whether to use them or not. + * Fix readme markdown + * Framebuffer and resolution independent rendering + * A simpler build system without dependencies + * Remove dependencies + * Remove Kazmath dependency + * Entity + * Find a permanent solution for build system + * Textures + * Camera + * Test render + * Fix input lag and other framerate related issues + * Materials + * Mesh/Model + * Add modifiers to input maps to enable combinations for example, c-x, m-k etc + * Heirarchical Transforms + * Materials with textures + * Lights! + * Fix problems with texture units + * Fix problems with frustrum culling + * Gui + * Fix mouse bugs on windows + * Configuration/Settings load/save handling + * Fix mousewheel bugs and gui not responding to mousewheel input + * Setup cross compilation with mingw or stick to msvc? + * Toggleable debug drawing for meshes + * Font selection + * Font atlas proper cleanup + * In second refactor pass, use entities everywhere, no need to pass in transform and model separately for example since they're both part of the same entity anyway + * Show SDL dialogbox if we cannot launch at all? + * Writing back to config file + * Reading from config file + * Variant -> String conversion procedure. Use in editor for debug var slots + * Add strings and booleans to variant types + * Fix Key release not being reported + * OpenAL not working in releasebuilds + * 3d sound using OpenAL + * Fix frustum culling bugs + * Array-based Hashmaps + * Fix bugs with heirarchical transformations + * Remove reduntant "settings" structures and move all configuration stuff to config variables + * Log output to file on every run + * Add option to specify where to read/write files from instead of being hard-coded assets dir + * Fix input map bugs + * Live data views in editor + * Camera resize on window reisze + * Resizable framebuffers and textures + * Support for multiple color attachments in framebuffers? + * Better way to store and manage textures attached to framebuffers + * Variant type + * Editor + * Fix frustum culling sometimes not working + * Compile and test on windows + * Fix mouse bugs + * Fix issues with opengl context showing 2.1 only + * Improve this readme + * Replace orgfile with simple text readme and reduce duplication + * Fix camera acting all weird when right click is held + * Fix README to conform with markdown syntax + * Added video driver selection to make game launch under wayland or x11 on linux. + * Separate game code into a dynamical library that can be reloaded at runtime. + * Move game, common and game library related code into separate folders. + * Fixed game crashing on exit after game library has been reloaded more than once. + * Made game compile and run under windows with visual studio 2017 using GENie + * Implemented file copy and file delete on windows and linux. + * Implemented a work-around for dll locking on windows by creating a copy of the game lib at launch and when reloading, + unloading the current dll, deleting it and creating new copy of the updated dll and loading that + * Added file copy and delete to platform api + * Made dll reloading workaround compatilble on linux + * Default keybindings as fallback + * Implemented writing scene to file + * Fixed space not being added after light entities are written to file by adding missing new-line + * Fixed error caused by the way eof was checked in scene file + * Camera fbo params are now written to file when entity is saved + * Fixed several bugs with entity loading + * Removed duplicate parsing logic + * Fixed bugs in stripping key name for input map + * Modify entity loading logic to use the new parsing code by parsing all entity properties into a hashmap first then recreating entity from that + * Implmented writing to file through the new Parser and Parser_Objects + * Changed Config to read/write using new Parser and Parser_Objects + * Implemented Reading/Writing keybindings using new parser object + * Replaced OpenAL with Soloud with SDL2 backend + * Implemented sound/listener loading from scene file + * Finished loading scene from file + * Initial implementation of immediate-mode batched sprite render + * Fixed bugs with shader include file pre-processor + * Fixed bugs with editor's camera property viewer + * Fixed bugs related to changing camera projection + * Fixed bugs with sprite batch renderer not working with projection matrix + * Fixed broken orthographic camera + * Implement necessary changes to run Soloud on linux + * Moved third party libs/include directories into root/lib and root/include. Put common includes like header-only libs into root/include/common and others which require platform specific stuff into root/include/linux etc. + * Got rid of pkg-confg and system-installed SDL2 dependancy on linux and instead put custom compiled SDL libs in libs folder similar to how we're handling it in windows + * Proper physics time-step and speed + * Proper handling of rigidbody associated with an entity and notifying it of movement or collision + * Added physics spheres and other primitive shapes + * Separated collision shape and rigidbody + * Implemented Getting/Modifying primitive physics shapes' values like length, radius etc + * Update physics if entity position/rotation/scale etc are changed + * Implemented Physics raycasting + * Implemented immediate mode renderer that can draw arbitrary points, lines and triangles + * Converted IM_Vertex array to only be used as temporary storage for vertices between begin and end calls + * Implemented Debug physics mesh drawing for box and sphere primitives + * Completed Phase 1 of codebase refactoring + * Improved editor camera handling + * Re-implemented showing all the entities in the editor + * Player init, update, visual representation and movement + * Switching between editor and game mode/cameras + * In-game basis for scrollable console/log-viewer + * Console log output + * Console error/warning output + * Implemented Auto scrolling to the bottom in console + * Implemented screen coordinate to ray conversion and ray-sphere collision + * Split todo and readme into two files + * Replace all renderer_check_gl calls with GL_CHECK macro + * Fixed Console bug when enabled in editor mode + * Migrated from bitbucket to github and from mercurial back to git + * Removed the game executable and game library split. + * Event Subsystem + * Fixed mouse button press/release behaviour by using event callbacks for editor mouse picking + * Ray picking for editor + * Highlight entity selected in editor in a specific color + * Implemented showing a placeholder when an entity other than a static mesh is selected + * Prevented ray casting when clicking on editor window and buttons + * Implemented handling drawing other entity types that can be selected in the editor but are not static meshes +