Fixed bug with incorrect editor toggling and checking

dev
Shariq Shah 6 years ago
parent 330ec6c3fa
commit e3e471e8bf
  1. 53
      src/game/editor.c
  2. 1
      src/game/editor.h
  3. 3
      src/game/game.c
  4. 420
      todo.txt

@ -66,7 +66,6 @@ static bool editor_widget_v3(struct nk_context* context,
void editor_init(struct Editor* editor) void editor_init(struct Editor* editor)
{ {
editor->enabled = true;
editor->renderer_settings_window = false; editor->renderer_settings_window = false;
editor->camera_looking_around = false; editor->camera_looking_around = false;
editor->selected_entity = NULL; 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) void editor_update(struct Editor* editor, float dt)
{ {
if(!editor->enabled) return;
editor_camera_update(editor, dt); editor_camera_update(editor, dt);
struct Game_State* game_state = game_state_get(); struct Game_State* game_state = game_state_get();
@ -217,31 +214,27 @@ void editor_update(struct Editor* editor, float dt)
/* Top Panel */ /* Top Panel */
if(nk_begin(context, "Top Panel", nk_recti(0, 0, win_width, editor->top_panel_height), NK_WINDOW_NO_SCROLLBAR)) 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); static float top_panel_ratios[] = { 0.1f, 0.1f, 0.7f, 0.1f };
nk_group_begin(context, "Menubar", NK_WINDOW_NO_SCROLLBAR); 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 }; fps = frames;
static int frames = 0; seconds = 0.f;
static int fps = 0; frames = 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);
} }
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); 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); assert(event->type == EVT_MOUSEBUTTON_PRESSED || event->type == EVT_MOUSEBUTTON_RELEASED);
struct Editor* editor = game_state_get()->editor; struct Game_State* game_state = game_state_get();
struct Gui* gui = game_state_get()->gui; 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 && if(event->mousebutton.button == MSB_LEFT &&
event->type == EVT_MOUSEBUTTON_RELEASED && event->type == EVT_MOUSEBUTTON_RELEASED &&
!editor->camera_looking_around && !editor->camera_looking_around &&

@ -9,7 +9,6 @@ struct Entity;
struct Editor struct Editor
{ {
bool enabled;
bool renderer_settings_window; bool renderer_settings_window;
bool camera_looking_around; bool camera_looking_around;
struct Entity* selected_entity; struct Entity* selected_entity;

@ -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("Console_Toggle", KS_RELEASED)) console_toggle(game_state->console);
if(input_map_state_get("Editor_Toggle", KS_RELEASED)) if(input_map_state_get("Editor_Toggle", KS_RELEASED))
{ {
//editor_toggle();
if(game_state->game_mode == GAME_MODE_EDITOR) if(game_state->game_mode == GAME_MODE_EDITOR)
{ {
game_state->game_mode = GAME_MODE_GAME; game_state->game_mode = GAME_MODE_GAME;
@ -551,7 +550,7 @@ void game_post_update(float dt)
void game_debug_gui(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; struct nk_context* ctx = &gui_state->context;
/* window flags */ /* window flags */

@ -1,210 +1,210 @@
Todo: Todo:
- Specific rendering mode for editor related rendering - Implement proper topbar
- Basic Editor gizmo for transformation i.e. translate/rotate/scale in world and local coordinates - Specific rendering mode for editor related rendering
- 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 - Basic Editor gizmo for transformation i.e. translate/rotate/scale in world and local coordinates
- Improve README and add a screenshot to make the repository ready for making it public - 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
- Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere - Improve README and add a screenshot to make the repository ready for making it public
? Improve bounding sphere calculation - Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere
- Change the way lights are set as uniforms to remove snprintf calls per frame for every light attribute ? Improve bounding sphere calculation
- Screen mouse coordinates to world-coordinates for aiming - Change the way lights are set as uniforms to remove snprintf calls per frame for every light attribute
- Player projectiles and sounds - Screen mouse coordinates to world-coordinates for aiming
- Console commands - Player projectiles and sounds
- Console command history - Console commands
- Console command help - Console command history
- Space partitioning and scene handling - Console command help
- Move Gui_State and Editor_State into game_state and modify usage as needed - Space partitioning and scene handling
- Get editor camera speed and other settings from config file - Move Gui_State and Editor_State into game_state and modify usage as needed
- Recompile Soloud on windows to use static sdl2 backend - Get editor camera speed and other settings from config file
- Figure out a way to reduce of remove snprintf calls from render code - Recompile Soloud on windows to use static sdl2 backend
- Re-Implement saving/loading scene to/from files - Figure out a way to reduce of remove snprintf calls from render code
- Implement storing console's scroll location and restore it when console is toggled - Re-Implement saving/loading scene to/from files
- Implement collision/physics data serialization, read and write. - Implement storing console's scroll location and restore it when console is toggled
- Physics forces/torque etc - Implement collision/physics data serialization, read and write.
- Implement physics debug visualizations for other primitives and tri mesh shapes - Physics forces/torque etc
- Serializing/Deserializing physics data - Implement physics debug visualizations for other primitives and tri mesh shapes
- 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 - Serializing/Deserializing physics data
- Necessary basic editor additions like placing objects, scaling, rotating etc - 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
- Add fallback shader - Necessary basic editor additions like placing objects, scaling, rotating etc
- Implement Game States - Add fallback shader
- Store Materials in new format supported by parser - Implement Game States
- Add model description file which has the same syntax supported by parser and modify old blender exporter to conform to new standards - Store Materials in new format supported by parser
- Fix bugs with sound sources not updating - Add model description file which has the same syntax supported by parser and modify old blender exporter to conform to new standards
- Add creating distributable build and uploading to itch.io account support to GENie under windows and linux. - Fix bugs with sound sources not updating
- Remove hardcoded numerical values from sscanf and other format strings. - Add creating distributable build and uploading to itch.io account support to GENie under windows and linux.
? Recalculated bounding boxes for rotated meshes - Remove hardcoded numerical values from sscanf and other format strings.
? Wrap malloc and free calls in custom functions to track usage ? Recalculated bounding boxes for rotated meshes
? File extension checking for asset loading ? Wrap malloc and free calls in custom functions to track usage
? Only allocate hashmap bucket when required ? File extension checking for asset loading
- Mapping actions to keybindings, for example map action "Jump" to Space key etc ? Only allocate hashmap bucket when required
? Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example - Mapping actions to keybindings, for example map action "Jump" to Space key etc
? Interleaved vbos for meshes and changes to blender exporter accordingly ? Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example
- Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? ? Interleaved vbos for meshes and changes to blender exporter accordingly
? Better handling incase assets folder is not found - Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object?
- Write entity to/from file ? Better handling incase assets folder is not found
- Ogg format loading and playback - Write entity to/from file
- Sound streaming - Ogg format loading and playback
- Implment missing sound source properties (inner/outer cone, getting sound source data) - Sound streaming
- Shadow maps - Implment missing sound source properties (inner/outer cone, getting sound source data)
- Print processor stats and machine capabilites RAM etc on every run to log. - Shadow maps
- Do input maps really need to be queried by their string names? - Print processor stats and machine capabilites RAM etc on every run to log.
- Write default config/keybindings etc to file if none are found in preferences dir - Do input maps really need to be queried by their string names?
- Multisampled textures and framebuffers - Write default config/keybindings etc to file if none are found in preferences dir
- Validate necessary assets at game launch - Multisampled textures and framebuffers
- Gamma correctness - Validate necessary assets at game launch
- Log and debug/stats output in gui - Gamma correctness
- Textual/Binary format for data serialization and persistance - Log and debug/stats output in gui
- Array based string type comptible with cstring(char*) - Textual/Binary format for data serialization and persistance
- Reduce fps on window focus loss or minimization - Array based string type comptible with cstring(char*)
- ??? - Reduce fps on window focus loss or minimization
- Profit! - ???
- Profit!
Improvements:
- Better naming semantics for examples, init/deinit for initialization and cleanup and create/destroy when memory is allocated or deallocated Improvements:
- Reset mouse cursor position to the center of the screen in editor mode after the right click is released - Better naming semantics for examples, init/deinit for initialization and cleanup and create/destroy when memory is allocated or deallocated
- Categorized entity list in editor for example different subtree for lights and static meshes - Reset mouse cursor position to the center of the screen in editor mode after the right click is released
- Remove fixed editor windows locations and bring back floating windows - 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 Bugs:
- Fix light rotation/direction bugs - Better handling of wav format checking at load time
- Fix lights type not being correctly saved/loaded from file - Fix light rotation/direction bugs
- Fix culling - Fix lights type not being correctly saved/loaded from file
- Fix bounding boxes not aligning in editor - Fix culling
- Investigate memory usage increase when window is maximized - Fix bounding boxes not aligning in editor
- Investigate memory usage increase when window is maximized
Done:
* Input Done:
* Shaders * Input
* Geometry * Shaders
* change struct usage * Geometry
* change Array implementation * change struct usage
* resolve vec-types sizes * change Array implementation
* Transform * resolve vec-types sizes
* Deltatime * Transform
* Investigate about Exit() and at_exit() functions and whether to use them or not. * Deltatime
* Fix readme markdown * Investigate about Exit() and at_exit() functions and whether to use them or not.
* Framebuffer and resolution independent rendering * Fix readme markdown
* A simpler build system without dependencies * Framebuffer and resolution independent rendering
* Remove dependencies * A simpler build system without dependencies
* Remove Kazmath dependency * Remove dependencies
* Entity * Remove Kazmath dependency
* Find a permanent solution for build system * Entity
* Textures * Find a permanent solution for build system
* Camera * Textures
* Test render * Camera
* Fix input lag and other framerate related issues * Test render
* Materials * Fix input lag and other framerate related issues
* Mesh/Model * Materials
* Add modifiers to input maps to enable combinations for example, c-x, m-k etc * Mesh/Model
* Heirarchical Transforms * Add modifiers to input maps to enable combinations for example, c-x, m-k etc
* Materials with textures * Heirarchical Transforms
* Lights! * Materials with textures
* Fix problems with texture units * Lights!
* Fix problems with frustrum culling * Fix problems with texture units
* Gui * Fix problems with frustrum culling
* Fix mouse bugs on windows * Gui
* Configuration/Settings load/save handling * Fix mouse bugs on windows
* Fix mousewheel bugs and gui not responding to mousewheel input * Configuration/Settings load/save handling
* Setup cross compilation with mingw or stick to msvc? * Fix mousewheel bugs and gui not responding to mousewheel input
* Toggleable debug drawing for meshes * Setup cross compilation with mingw or stick to msvc?
* Font selection * Toggleable debug drawing for meshes
* Font atlas proper cleanup * Font selection
* 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 * Font atlas proper cleanup
* Show SDL dialogbox if we cannot launch at all? * 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
* Writing back to config file * Show SDL dialogbox if we cannot launch at all?
* Reading from config file * Writing back to config file
* Variant -> String conversion procedure. Use in editor for debug var slots * Reading from config file
* Add strings and booleans to variant types * Variant -> String conversion procedure. Use in editor for debug var slots
* Fix Key release not being reported * Add strings and booleans to variant types
* OpenAL not working in releasebuilds * Fix Key release not being reported
* 3d sound using OpenAL * OpenAL not working in releasebuilds
* Fix frustum culling bugs * 3d sound using OpenAL
* Array-based Hashmaps * Fix frustum culling bugs
* Fix bugs with heirarchical transformations * Array-based Hashmaps
* Remove reduntant "settings" structures and move all configuration stuff to config variables * Fix bugs with heirarchical transformations
* Log output to file on every run * Remove reduntant "settings" structures and move all configuration stuff to config variables
* Add option to specify where to read/write files from instead of being hard-coded assets dir * Log output to file on every run
* Fix input map bugs * Add option to specify where to read/write files from instead of being hard-coded assets dir
* Live data views in editor * Fix input map bugs
* Camera resize on window reisze * Live data views in editor
* Resizable framebuffers and textures * Camera resize on window reisze
* Support for multiple color attachments in framebuffers? * Resizable framebuffers and textures
* Better way to store and manage textures attached to framebuffers * Support for multiple color attachments in framebuffers?
* Variant type * Better way to store and manage textures attached to framebuffers
* Editor * Variant type
* Fix frustum culling sometimes not working * Editor
* Compile and test on windows * Fix frustum culling sometimes not working
* Fix mouse bugs * Compile and test on windows
* Fix issues with opengl context showing 2.1 only * Fix mouse bugs
* Improve this readme * Fix issues with opengl context showing 2.1 only
* Replace orgfile with simple text readme and reduce duplication * Improve this readme
* Fix camera acting all weird when right click is held * Replace orgfile with simple text readme and reduce duplication
* Fix README to conform with markdown syntax * Fix camera acting all weird when right click is held
* Added video driver selection to make game launch under wayland or x11 on linux. * Fix README to conform with markdown syntax
* Separate game code into a dynamical library that can be reloaded at runtime. * Added video driver selection to make game launch under wayland or x11 on linux.
* Move game, common and game library related code into separate folders. * Separate game code into a dynamical library that can be reloaded at runtime.
* Fixed game crashing on exit after game library has been reloaded more than once. * Move game, common and game library related code into separate folders.
* Made game compile and run under windows with visual studio 2017 using GENie * Fixed game crashing on exit after game library has been reloaded more than once.
* Implemented file copy and file delete on windows and linux. * Made game compile and run under windows with visual studio 2017 using GENie
* Implemented a work-around for dll locking on windows by creating a copy of the game lib at launch and when reloading, * Implemented file copy and file delete on windows and linux.
unloading the current dll, deleting it and creating new copy of the updated dll and loading that * Implemented a work-around for dll locking on windows by creating a copy of the game lib at launch and when reloading,
* Added file copy and delete to platform api unloading the current dll, deleting it and creating new copy of the updated dll and loading that
* Made dll reloading workaround compatilble on linux * Added file copy and delete to platform api
* Default keybindings as fallback * Made dll reloading workaround compatilble on linux
* Implemented writing scene to file * Default keybindings as fallback
* Fixed space not being added after light entities are written to file by adding missing new-line * Implemented writing scene to file
* Fixed error caused by the way eof was checked in scene file * Fixed space not being added after light entities are written to file by adding missing new-line
* Camera fbo params are now written to file when entity is saved * Fixed error caused by the way eof was checked in scene file
* Fixed several bugs with entity loading * Camera fbo params are now written to file when entity is saved
* Removed duplicate parsing logic * Fixed several bugs with entity loading
* Fixed bugs in stripping key name for input map * Removed duplicate parsing logic
* Modify entity loading logic to use the new parsing code by parsing all entity properties into a hashmap first then recreating entity from that * Fixed bugs in stripping key name for input map
* Implmented writing to file through the new Parser and Parser_Objects * Modify entity loading logic to use the new parsing code by parsing all entity properties into a hashmap first then recreating entity from that
* Changed Config to read/write using new Parser and Parser_Objects * Implmented writing to file through the new Parser and Parser_Objects
* Implemented Reading/Writing keybindings using new parser object * Changed Config to read/write using new Parser and Parser_Objects
* Replaced OpenAL with Soloud with SDL2 backend * Implemented Reading/Writing keybindings using new parser object
* Implemented sound/listener loading from scene file * Replaced OpenAL with Soloud with SDL2 backend
* Finished loading scene from file * Implemented sound/listener loading from scene file
* Initial implementation of immediate-mode batched sprite render * Finished loading scene from file
* Fixed bugs with shader include file pre-processor * Initial implementation of immediate-mode batched sprite render
* Fixed bugs with editor's camera property viewer * Fixed bugs with shader include file pre-processor
* Fixed bugs related to changing camera projection * Fixed bugs with editor's camera property viewer
* Fixed bugs with sprite batch renderer not working with projection matrix * Fixed bugs related to changing camera projection
* Fixed broken orthographic camera * Fixed bugs with sprite batch renderer not working with projection matrix
* Implement necessary changes to run Soloud on linux * Fixed broken orthographic camera
* 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. * Implement necessary changes to run Soloud on linux
* 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 * 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.
* Proper physics time-step and speed * 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 handling of rigidbody associated with an entity and notifying it of movement or collision * Proper physics time-step and speed
* Added physics spheres and other primitive shapes * Proper handling of rigidbody associated with an entity and notifying it of movement or collision
* Separated collision shape and rigidbody * Added physics spheres and other primitive shapes
* Implemented Getting/Modifying primitive physics shapes' values like length, radius etc * Separated collision shape and rigidbody
* Update physics if entity position/rotation/scale etc are changed * Implemented Getting/Modifying primitive physics shapes' values like length, radius etc
* Implemented Physics raycasting * Update physics if entity position/rotation/scale etc are changed
* Implemented immediate mode renderer that can draw arbitrary points, lines and triangles * Implemented Physics raycasting
* Converted IM_Vertex array to only be used as temporary storage for vertices between begin and end calls * Implemented immediate mode renderer that can draw arbitrary points, lines and triangles
* Implemented Debug physics mesh drawing for box and sphere primitives * Converted IM_Vertex array to only be used as temporary storage for vertices between begin and end calls
* Completed Phase 1 of codebase refactoring * Implemented Debug physics mesh drawing for box and sphere primitives
* Improved editor camera handling * Completed Phase 1 of codebase refactoring
* Re-implemented showing all the entities in the editor * Improved editor camera handling
* Player init, update, visual representation and movement * Re-implemented showing all the entities in the editor
* Switching between editor and game mode/cameras * Player init, update, visual representation and movement
* In-game basis for scrollable console/log-viewer * Switching between editor and game mode/cameras
* Console log output * In-game basis for scrollable console/log-viewer
* Console error/warning output * Console log output
* Implemented Auto scrolling to the bottom in console * Console error/warning output
* Implemented screen coordinate to ray conversion and ray-sphere collision * Implemented Auto scrolling to the bottom in console
* Split todo and readme into two files * Implemented screen coordinate to ray conversion and ray-sphere collision
* Replace all renderer_check_gl calls with GL_CHECK macro * Split todo and readme into two files
* Fixed Console bug when enabled in editor mode * Replace all renderer_check_gl calls with GL_CHECK macro
* Migrated from bitbucket to github and from mercurial back to git * Fixed Console bug when enabled in editor mode
* Removed the game executable and game library split. * Migrated from bitbucket to github and from mercurial back to git
* Event Subsystem * Removed the game executable and game library split.
* Fixed mouse button press/release behaviour by using event callbacks for editor mouse picking * Event Subsystem
* Ray picking for editor * Fixed mouse button press/release behaviour by using event callbacks for editor mouse picking
* Highlight entity selected in editor in a specific color * Ray picking for editor
* Deselect selected entity in editor when nothing is hit on click and an entity is already selected * Highlight entity selected in editor in a specific color
* Implemented showing a placeholder when an entity other than a static mesh is 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 * 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 * Implemented handling drawing other entity types that can be selected in the editor but are not static meshes

Loading…
Cancel
Save