diff --git a/src/common/version.h b/src/common/version.h index bcd23c8..50d8e78 100755 --- a/src/common/version.h +++ b/src/common/version.h @@ -4,7 +4,7 @@ /* Auto generated version file. DO NOT MODIFY */ #define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MINOR 2 -#define SYMMETRY_VERSION_REVISION 359 +#define SYMMETRY_VERSION_REVISION 360 #define SYMMETRY_VERSION_BRANCH "dev" #endif \ No newline at end of file diff --git a/src/game/editor.c b/src/game/editor.c index b43b729..b2f359d 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -2509,7 +2509,7 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor* if(nk_button_label(context, "Select Camera")) editor_entity_select(editor, player->camera); if(nk_button_label(context, "Select Weapon Sound")) editor_entity_select(editor, player->weapon_sound); if(nk_button_label(context, "Select Footstep Sound")) editor_entity_select(editor, player->footstep_sound); - if(nk_button_label(context, "Select Mesh")) editor_entity_select(editor, player->mesh); + if(nk_button_label(context, "Select Mesh")) editor_entity_select(editor, player->body_mesh); nk_tree_pop(context); } diff --git a/src/game/entity.h b/src/game/entity.h index 3871605..dfa36db 100755 --- a/src/game/entity.h +++ b/src/game/entity.h @@ -64,7 +64,8 @@ enum Entity_Flags EF_HIDE_IN_EDITOR_SCENE_HIERARCHY = 1 << 4, EF_SKIP_RENDER = 1 << 5, EF_IGNORE_RAYCAST = 1 << 6, - EF_IGNORE_COLLISION = 1 << 7 + EF_IGNORE_COLLISION = 1 << 7, + EF_ALWAYS_RENDER = 1 << 8 }; enum Pickup_Type @@ -205,7 +206,8 @@ struct Static_Mesh struct Player { struct Entity base; - struct Static_Mesh* mesh; + struct Static_Mesh* body_mesh; + struct Static_Mesh* weapon_mesh; struct Camera* camera; struct Sound_Source* weapon_sound; struct Sound_Source* footstep_sound; diff --git a/src/game/player.c b/src/game/player.c index 001cae8..68e1066 100755 --- a/src/game/player.c +++ b/src/game/player.c @@ -48,7 +48,15 @@ void player_init(struct Player* player, struct Scene* scene) player->health = MAX_PLAYER_HEALTH; player->key_mask = 0; - player->mesh = scene_static_mesh_create(scene, "Player_Mesh", player, "sphere.symbres", MAT_BLINN); + player->body_mesh = scene_static_mesh_create(scene, "Player_Body_Mesh", player, "sphere.symbres", MAT_BLINN); + player->weapon_mesh = scene_static_mesh_create(scene, "PLayer_Weapon_Mesh", player, "player_weapon.symbres", MAT_BLINN); + player->body_mesh->base.flags |= EF_IGNORE_COLLISION | EF_ALWAYS_RENDER; + player->weapon_mesh->base.flags |= EF_IGNORE_COLLISION | EF_ALWAYS_RENDER; + + vec3 translation = { 0.f, 1.f, -1.5f }; + transform_translate(player->weapon_mesh, &translation, TS_LOCAL); + transform_rotate(player->weapon_mesh, &UNIT_Y, 90.f, TS_LOCAL); + transform_scale(player->weapon_mesh, &(vec3){0.2f, 0.1f, 0.1f}); struct Camera* player_camera = &scene->cameras[CAM_GAME]; entity_rename(player_camera, "Player_Camera"); @@ -79,7 +87,7 @@ void player_init(struct Player* player, struct Scene* scene) // Mark player camera and mesh as transient for now. We don't need to save them to file since we recreate them here anyway player->camera->base.flags |= EF_TRANSIENT; - player->mesh->base.flags |= EF_TRANSIENT; + player->body_mesh->base.flags |= EF_TRANSIENT; player->weapon_sound->base.flags |= EF_TRANSIENT; player->footstep_sound->base.flags |= EF_TRANSIENT; player->grunt_sound->base.flags |= EF_TRANSIENT; @@ -210,7 +218,7 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix continue; float distance = bv_distance_ray_bounding_box(&forward_ray, &colliding_entity->derived_bounding_box); - if(distance > 0.f && distance <= player->min_forward_distance && colliding_entity != player->mesh) + if(distance > 0.f && distance <= player->min_forward_distance && colliding_entity != player->body_mesh) { vec3 intersection_point = forward_ray.direction; vec3_scale(&intersection_point, &intersection_point, distance); @@ -237,7 +245,7 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix move_speed_vertical += player->gravity; struct Raycast_Result down_ray_result; struct Ray downward_ray; - transform_get_absolute_position(player->mesh, &downward_ray.origin); + transform_get_absolute_position(player->body_mesh, &downward_ray.origin); vec3_fill(&downward_ray.direction, 0.f, -1.f, 0.f); scene_ray_intersect(scene, &downward_ray, &down_ray_result, ERM_STATIC_MESH); if(down_ray_result.num_entities_intersected > 0) @@ -246,7 +254,7 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix { struct Entity* colliding_entity = down_ray_result.entities_intersected[i]; - if(colliding_entity == player->mesh) + if(colliding_entity == player->body_mesh) continue; if(colliding_entity->flags & EF_IGNORE_COLLISION) continue; @@ -348,7 +356,7 @@ void player_on_mousebutton_released(const struct Event* event) struct Entity* colliding_entity = scene_ray_intersect_closest(scene, &bullet_ray, ERM_STATIC_MESH); - if(!colliding_entity || colliding_entity == player->mesh) + if(!colliding_entity || colliding_entity == player->body_mesh) return; float distance = bv_distance_ray_bounding_box(&bullet_ray, &colliding_entity->derived_bounding_box); diff --git a/src/game/renderer.c b/src/game/renderer.c index 5bf37c1..06fdf58 100755 --- a/src/game/renderer.c +++ b/src/game/renderer.c @@ -188,8 +188,7 @@ void renderer_render(struct Renderer* renderer, struct Scene* scene) struct Geometry* geometry = geom_get(mesh->model.geometry_index); /* Check if model is in frustum */ - - int intersection = bv_intersect_frustum_box(&active_camera->frustum, &mesh->base.derived_bounding_box); + int intersection = mesh->base.flags & EF_ALWAYS_RENDER ? IT_INSIDE : bv_intersect_frustum_box(&active_camera->frustum, &mesh->base.derived_bounding_box); if(intersection == IT_INSIDE || intersection == IT_INTERSECT) { num_indices += geometry->indices_length; diff --git a/todo.txt b/todo.txt index 8d5b870..ec6ed43 100644 --- a/todo.txt +++ b/todo.txt @@ -1,11 +1,11 @@ Todo: - Game End - Don't save parent entity's transform when saving entity archetype. Only save the transformation values for children + - Player weapon mesh and lighting + - Enemies getting hit by bullets - Save case sensitive file names when scene entity entries - Disbale all player actions when scene cleared dialog or scene restart dialog are active - - Enemies getting hit by bullets - Memory utils that provide allocation tracking - - Background music track per scene specified in scene properties - Remove excessive repitition in scene and editor code that handles multiple entity types - Allow switching to editor mode when game is in pause mode - Rendering Additions: @@ -429,4 +429,5 @@ Done: * In-Game Gui * Pickups * Pickup sounds - * Implemented flag for ignoring collisions with certain entities \ No newline at end of file + * Implemented flag for ignoring collisions with certain entities + * Background music track per scene specified in scene properties \ No newline at end of file