Fixed issue with entities not updating their transformation materix and in turn not being able to update their children after they are transformed in editor

dev
Shariq Shah 6 years ago
parent 11b2f2da14
commit c874dcf598
  1. 28
      src/game/game.c
  2. 3
      src/game/renderer.c
  3. 6
      src/game/scene.c
  4. 2
      src/game/transform.c
  5. 17
      todo.txt

@ -345,30 +345,30 @@ void game_scene_setup(void)
void game_debug(float dt) void game_debug(float dt)
{ {
if(input_is_key_pressed(KEY_SPACE)) if(input_is_key_pressed(KEY_PAGEDOWN))
{ {
struct Entity* model = scene_find(game_state->scene, "Light_Ent"); struct Entity* model = scene_find(game_state->scene, "Suzanne_Test_Parent");
vec3 x_axis = {0, 1, 0}; vec3 x_axis = {0, 1, 0};
transform_rotate(model, &x_axis, 25.f * dt, TS_WORLD); transform_rotate(model, &x_axis, 25.f * dt, TS_WORLD);
} }
if(input_is_key_pressed(KEY_M)) if(input_is_key_pressed(KEY_PAGEUP))
{ {
struct Entity* model = scene_find(game_state->scene, "Model_Entity"); struct Entity* model = scene_find(game_state->scene, "Suzanne_Test_Parent");
//vec3 y_axis = {0, 0, 1}; //vec3 y_axis = {0, 0, 1};
//transform_rotate(mod_tran, &y_axis, 25.f * dt, TS_LOCAL); //transform_rotate(mod_tran, &y_axis, 25.f * dt, TS_LOCAL);
vec3 amount = {0, 0, -5 * dt}; vec3 amount = {0, 0, -5 * dt};
transform_translate(model, &amount, TS_LOCAL); transform_translate(model, &amount, TS_LOCAL);
} }
if(input_is_key_pressed(KEY_N)) // if(input_is_key_pressed(KEY_N))
{ // {
struct Entity* model = scene_find(game_state->scene, "Model_Entity"); // struct Entity* model = scene_find(game_state->scene, "Model_Entity");
/* vec3 y_axis = {0, 0, 1}; */ // /* vec3 y_axis = {0, 0, 1}; */
/* transform_rotate(mod_tran, &y_axis, 25.f * dt, TS_WORLD); */ // /* transform_rotate(mod_tran, &y_axis, 25.f * dt, TS_WORLD); */
vec3 amount = {0, 0, 5 * dt}; // vec3 amount = {0, 0, 5 * dt};
transform_translate(model, &amount, TS_LOCAL); // transform_translate(model, &amount, TS_LOCAL);
} // }
/*struct Entity* model = scene_find("Model_Entity"); /*struct Entity* model = scene_find("Model_Entity");
vec3 x_axis = {0, 1, 0}; vec3 x_axis = {0, 1, 0};
@ -549,6 +549,10 @@ void game_update(float dt, bool* window_should_close)
{ {
game_state->game_mode = GAME_MODE_EDITOR; game_state->game_mode = GAME_MODE_EDITOR;
game_state->scene->active_camera_index = CAM_EDITOR; game_state->scene->active_camera_index = CAM_EDITOR;
input_mouse_mode_set(MM_NORMAL);
int width = 0, height = 0;
window_get_drawable_size(game_state_get()->window, &width, &height);
platform_mouse_position_set(game_state_get()->window, width / 2, height / 2);
} }
} }

@ -325,7 +325,8 @@ void renderer_render(struct Renderer* renderer, struct Scene* scene)
struct Camera* active_camera = &scene->cameras[scene->active_camera_index]; struct Camera* active_camera = &scene->cameras[scene->active_camera_index];
int width, height; int width, height;
struct Game_State* game_state = game_state_get(); struct Game_State* game_state = game_state_get();
window_get_size(game_state->window, &width, &height); //window_get_size(game_state->window, &width, &height);
window_get_drawable_size(game_state->window, &width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
shader_bind(renderer->composition_shader); shader_bind(renderer->composition_shader);

@ -428,12 +428,6 @@ void scene_post_update(struct Scene* scene)
if(light->base.transform.is_modified) light->base.transform.is_modified = false; if(light->base.transform.is_modified) light->base.transform.is_modified = false;
} }
for(int i = 0; i < MAX_ENTITIES; i++)
{
struct Entity* entity = &scene->entities[i];
if(!(entity->flags & EF_ACTIVE)) continue;
}
if(scene->player.base.transform.is_modified) if(scene->player.base.transform.is_modified)
{ {
scene->player.base.transform.is_modified = false; scene->player.base.transform.is_modified = false;

@ -91,9 +91,9 @@ void transform_copy(struct Entity* copy_to, struct Entity* copy_from, bool copy_
{ {
copy_to->transform.parent = current_parent; copy_to->transform.parent = current_parent;
} }
copy_to->transform.is_modified = true; copy_to->transform.is_modified = true;
copy_to->transform.children = current_children; copy_to->transform.children = current_children;
transform_update_transmat(copy_to);
} }
void transform_translate(struct Entity* entity, vec3* amount, enum Transform_Space space) void transform_translate(struct Entity* entity, vec3* amount, enum Transform_Space space)

@ -1,6 +1,4 @@
Todo: Todo:
- Fix hierarchical transforms not working in editor mode
- Fix weird rotational bug when rotation resets or inverts after 180 degrees
- Better, more accurate picking - Better, more accurate picking
- Add editor undo for transformation operations - Add editor undo for transformation operations
- Add material export for blender exporter? - Add material export for blender exporter?
@ -14,13 +12,14 @@ Todo:
- Command history in console - Command history in console
- Bring back debug variable display in editor and allow showing colours, textures etc - Bring back debug variable display in editor and allow showing colours, textures etc
- Serialize player, camera properties to file - Serialize player, camera properties to file
- Multisampled buffers to bring back aa
- Implement behaviour that avoids writing normal entities that do not have children or parent to file to avoid inconsistencies when loading them - Implement behaviour that avoids writing normal entities that do not have children or parent to file to avoid inconsistencies when loading them
- Change mouse behaviour to lock cursor when looking around so as not to interfere with gui elements when in editor mode - Change mouse behaviour to lock cursor when looking around so as not to interfere with gui elements when in editor mode
- Editor functionality to read/write scene to/from file - Editor functionality to read/write scene to/from file
- Folder management api to create/delete folders when none exist. Dirent would suffice for our simple needs? - Folder management api to create/delete folders when none exist. Dirent would suffice for our simple needs?
- Display default mesh when selected entity type in editor does not have a mesh - Display default mesh when selected entity type in editor does not have a mesh
- Allow picking and selecting other entity types in editor i.e. the ones that don't have meshes - Allow picking and selecting other entity types in editor i.e. the ones that don't have meshes
- Separate entity types in entity heirarchy view by the entity type or use a tree view to show parent/child relation or use different colours for different entity types - Separate entity types in entity hierarchy view by the entity type or use a tree view to show parent/child relation or use different colours for different entity types
? Entity creator window to create new types of entities and write them ? Entity creator window to create new types of entities and write them
to disk to disk
- Entity browser window which lists all existing entity types from - Entity browser window which lists all existing entity types from
@ -53,14 +52,14 @@ Todo:
- Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere - Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere
? Improve bounding sphere calculation ? Improve bounding sphere calculation
- Change the way lights are set as uniforms to remove snprintf calls per frame for every light attribute - Change the way lights are set as uniforms to remove snprintf calls per frame for every light attribute
- Filter Scene heirarchy by search using entity name - Filter Scene hierarchy by search using entity name
- Command interface that allows applying commands to selected entity like r x 30 would rotate the selected entity or entities on x axis by 30 degrees - Command interface that allows applying commands to selected entity like r x 30 would rotate the selected entity or entities on x axis by 30 degrees
- Quick scene filter and entity selection by popping up a menu which has list of entities and fuzzy matches them based on the typed name - Quick scene filter and entity selection by popping up a menu which has list of entities and fuzzy matches them based on the typed name
- Screen mouse coordinates to world-coordinates for aiming - Screen mouse coordinates to world-coordinates for aiming
- Player projectiles and sounds - Player projectiles and sounds
- Console command history - Console command history
- Console command help - Console command help
- Debug drawing/variable display that also works in game mode. Can be toggled with a console command. Can show variable values or plots their graphs or debug textures etc - Debug drawing/variable display that also works in game mode. Can be toggled with a console command. Can show variable values or plots thier graphs or debug textures etc
- Space partitioning and scene handling - Space partitioning and scene handling
- Move Gui_State and Editor_State into game_state and modify usage as needed - Move Gui_State and Editor_State into game_state and modify usage as needed
- Get editor camera speed and other settings from config file - Get editor camera speed and other settings from config file
@ -99,7 +98,7 @@ Todo:
- Implment missing sound source properties (inner/outer cone, getting sound source data) - Implment missing sound source properties (inner/outer cone, getting sound source data)
- Shadow maps - Shadow maps
- Print processor stats and machine capabilites RAM etc on every run to log. - 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? - Do input maps really need to be queried by thier string names?
- Write default config/keybindings etc to file if none are found in preferences dir - Write default config/keybindings etc to file if none are found in preferences dir
- Multisampled textures and framebuffers - Multisampled textures and framebuffers
- Validate necessary assets at game launch - Validate necessary assets at game launch
@ -133,8 +132,9 @@ Bugs:
- Fix arc angles resetting when rotating - Fix arc angles resetting when rotating
- Fix shader preprocessor failing when the file in //include directive is empty - Fix shader preprocessor failing when the file in //include directive is empty
- Fix bug with blinn shader reaching maximum uniform number on mac - Fix bug with blinn shader reaching maximum uniform number on mac
- Fix delete in editor not working when the cursor is hovering over scene heirarchy window - Fix delete in editor not working when the cursor is hovering over scene hierarchy window
- Investigate memory leaks caused by nuklear or opengl related operations in gui_update - Investigate memory leaks caused by nuklear or opengl related operations in gui_update
- Fix weird rotational bug when rotation resets or inverts after 180 degrees
Done: Done:
* Input * Input
@ -184,7 +184,7 @@ Done:
* 3d sound using OpenAL * 3d sound using OpenAL
* Fix frustum culling bugs * Fix frustum culling bugs
* Array-based Hashmaps * Array-based Hashmaps
* Fix bugs with heirarchical transformations * Fix bugs with hierarchical transformations
* Remove reduntant "settings" structures and move all configuration stuff to config variables * Remove reduntant "settings" structures and move all configuration stuff to config variables
* Log output to file on every run * Log output to file on every run
* Add option to specify where to read/write files from instead of being hard-coded assets dir * Add option to specify where to read/write files from instead of being hard-coded assets dir
@ -357,3 +357,4 @@ Done:
* Implment/Test reading/writing scene that has a mixture of default entites and entity archetypes * Implment/Test reading/writing scene that has a mixture of default entites and entity archetypes
* Add simple player fps controls * Add simple player fps controls
* Fixed gimbal lock in fps camera by fixing the order of quaternion multiplication when getting absolute rotation * Fixed gimbal lock in fps camera by fixing the order of quaternion multiplication when getting absolute rotation
* Fix hierarchical transforms not working in editor mode
Loading…
Cancel
Save