Browse Source

Remove obsolete tracking system and dead code

master
C. J. Howard 2 years ago
parent
commit
ddab8b2021
8 changed files with 44 additions and 349 deletions
  1. +1
    -0
      CMakeLists.txt
  2. +3
    -1
      src/application.cpp
  3. +0
    -161
      src/entity/systems/tracking.cpp
  4. +0
    -70
      src/entity/systems/tracking.hpp
  5. +2
    -103
      src/game/bootloader.cpp
  6. +0
    -3
      src/game/context.hpp
  7. +7
    -11
      src/game/save.cpp
  8. +31
    -0
      src/game/save.hpp

+ 1
- 0
CMakeLists.txt View File

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.7)
option(VERSION_STRING "Project version string" "0.0.0")
project(antkeeper VERSION ${VERSION_STRING} LANGUAGES CXX)

+ 3
- 1
src/application.cpp View File

@ -630,7 +630,9 @@ void application::translate_sdl_events()
{
input::gamepad_axis axis = input::sdl_axis_table[sdl_event.caxis.axis];
float value = sdl_event.caxis.value;
value /= (value < 0.0f) ? 32768.0f : 32767.0f;
static const float min = static_cast<float>(std::numeric_limits<std::int16_t>::min());
static const float max = static_cast<float>(std::numeric_limits<std::int16_t>::max());
value /= (value < 0.0f) ? -min : max;
it->second->move(axis, value);
}
}

+ 0
- 161
src/entity/systems/tracking.cpp View File

@ -1,161 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tracking.hpp"
#include "entity/components/transform.hpp"
#include "entity/components/marker.hpp"
#include "event/event-dispatcher.hpp"
#include "resources/resource-manager.hpp"
#include "scene/collection.hpp"
#include "scene/model-instance.hpp"
#include "math/math.hpp"
#include "renderer/material.hpp"
#include "renderer/model.hpp"
#include "utility/fundamental-types.hpp"
#include "entity/commands.hpp"
namespace entity {
namespace system {
tracking::tracking(entity::registry& registry, ::event_dispatcher* event_dispatcher, ::resource_manager* resource_manager):
updatable(registry),
event_dispatcher(event_dispatcher),
resource_manager(resource_manager),
scene_collection(nullptr)
{
registry.on_construct<component::trackable>().connect<&tracking::on_component_construct>(this);
registry.on_destroy<component::trackable>().connect<&tracking::on_component_destroy>(this);
// Load paint ball model
paint_ball_model = resource_manager->load<model>("paint-ball.mdl");
// Load tracker model
tracker_model = resource_manager->load<model>("tracker.mdl");
// Load paint ball materials
paint_ball_materials = new material*[7];
paint_ball_materials[0] = resource_manager->load<material>("paint-ball-yellow.mtl");
paint_ball_materials[1] = resource_manager->load<material>("paint-ball-green.mtl");
paint_ball_materials[2] = resource_manager->load<material>("paint-ball-blue.mtl");
paint_ball_materials[3] = resource_manager->load<material>("paint-ball-purple.mtl");
paint_ball_materials[4] = resource_manager->load<material>("paint-ball-pink.mtl");
paint_ball_materials[5] = resource_manager->load<material>("paint-ball-red.mtl");
paint_ball_materials[6] = resource_manager->load<material>("paint-ball-orange.mtl");
event_dispatcher->subscribe<tool_pressed_event>(this);
event_dispatcher->subscribe<tool_released_event>(this);
}
tracking::~tracking()
{
event_dispatcher->unsubscribe<tool_pressed_event>(this);
event_dispatcher->unsubscribe<tool_released_event>(this);
for (auto it = trackers.begin(); it != trackers.end(); ++it)
{
delete it->second;
}
delete[] paint_ball_materials;
}
void tracking::update(double t, double dt)
{
for (auto it = trackers.begin(); it != trackers.end(); ++it)
{
const component::transform& transform = registry.get<component::transform>(it->first);
// Project world coordinates to screen coordinates
// Update billboard position
it->second->set_translation(transform.world.translation);
if (transform.warp)
{
it->second->update_tweens();
}
}
}
void tracking::set_scene(scene::collection* collection)
{
this->scene_collection = collection;
}
void tracking::on_component_construct(entity::registry& registry, entity::id entity_id, component::trackable& component)
{
}
void tracking::on_component_destroy(entity::registry& registry, entity::id entity_id)
{
if (auto it = trackers.find(entity_id); it != trackers.end())
{
// Remove model instance from all layers
/*
for (std::size_t i = 0; i < layers.size(); ++i)
{
layers[i]->remove_object(it->second);
}
*/
delete it->second;
trackers.erase(it);
}
}
void tracking::handle_event(const tool_pressed_event& event)
{
if (registry.has<component::marker>(event.entity_id))
{
math::transform<float> transform = command::get_world_transform(registry, event.entity_id);
int marker_index = registry.get<component::marker>(event.entity_id).color;
if (marker_index > 0)
{
const float tracker_scale = 1.0f;
// Create tracker model instance
scene::model_instance* instance = new scene::model_instance();
instance->set_model(tracker_model);
instance->set_translation(transform.translation);
instance->set_scale(float3{tracker_scale, tracker_scale, tracker_scale});
// Set tracker paint ball material
const model_group* paint_ball_model_group = tracker_model->get_group("paint-ball");
if (paint_ball_model_group != nullptr)
{
instance->set_material(paint_ball_model_group->get_index(), paint_ball_materials[marker_index - 1]);
}
instance->update_tweens();
scene_collection->add_object(instance);
}
}
}
void tracking::handle_event(const tool_released_event& event)
{
}
} // namespace system
} // namespace entity

+ 0
- 70
src/entity/systems/tracking.hpp View File

@ -1,70 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_ENTITY_SYSTEM_TRACKING_HPP
#define ANTKEEPER_ENTITY_SYSTEM_TRACKING_HPP
#include "entity/systems/updatable.hpp"
#include "entity/components/trackable.hpp"
#include "entity/id.hpp"
#include "event/event-handler.hpp"
#include "game/events/tool-events.hpp"
#include <unordered_map>
#include "scene/collection.hpp"
#include "scene/model-instance.hpp"
class material;
class event_dispatcher;
class resource_manager;
class model;
namespace entity {
namespace system {
class tracking: public updatable,
public event_handler<tool_pressed_event>,
public event_handler<tool_released_event>
{
public:
tracking(entity::registry& registry, event_dispatcher* event_dispatcher, resource_manager* resource_manager);
virtual ~tracking();
virtual void update(double t, double dt);
void set_scene(scene::collection* collection);
void set_viewport(const float4& viewport);
private:
void on_component_construct(entity::registry& registry, entity::id entity_id, entity::component::trackable& component);
void on_component_destroy(entity::registry& registry, entity::id entity_id);
virtual void handle_event(const tool_pressed_event& event);
virtual void handle_event(const tool_released_event& event);
event_dispatcher* event_dispatcher;
resource_manager* resource_manager;
scene::collection* scene_collection;
model* tracker_model;
model* paint_ball_model;
material** paint_ball_materials;
std::unordered_map<entity::id, scene::model_instance*> trackers;
};
} // namespace system
} // namespace entity
#endif // ANTKEEPER_ENTITY_SYSTEM_TRACKING_HPP

+ 2
- 103
src/game/bootloader.cpp View File

@ -67,14 +67,12 @@
#include "entity/systems/ui.hpp"
#include "entity/systems/vegetation.hpp"
#include "entity/systems/spatial.hpp"
#include "entity/systems/tracking.hpp"
#include "entity/systems/painting.hpp"
#include "entity/systems/astronomy.hpp"
#include "entity/systems/blackbody.hpp"
#include "entity/systems/atmosphere.hpp"
#include "entity/systems/orbit.hpp"
#include "entity/systems/proteome.hpp"
#include "entity/components/marker.hpp"
#include "entity/commands.hpp"
#include "utility/paths.hpp"
#include "event/event-dispatcher.hpp"
@ -249,7 +247,7 @@ void setup_resources(game::context* ctx)
ctx->config_path = get_config_path(application_name);
ctx->mods_path = ctx->config_path + "mods/";
ctx->saves_path = ctx->config_path + "saves/";
ctx->screenshots_path = ctx->config_path + "screenshots/";
ctx->screenshots_path = ctx->config_path + "gallery/";
ctx->controls_path = ctx->config_path + "controls/";
// Log resource paths
@ -337,8 +335,7 @@ void setup_resources(game::context* ctx)
// Mount data package
ctx->resource_manager->mount(ctx->data_package_path);
// Include resource search paths in order of priority
ctx->resource_manager->include("/shaders/");
ctx->resource_manager->include("/models/");
@ -607,17 +604,6 @@ void setup_rendering(game::context* ctx)
ctx->billboard_vao->bind_attribute(VERTEX_BARYCENTRIC_LOCATION, *ctx->billboard_vbo, 3, gl::vertex_attribute_type::float_32, billboard_vertex_stride, sizeof(float) * 5);
}
// Load marker albedo textures
ctx->marker_albedo_textures = new gl::texture_2d*[8];
ctx->marker_albedo_textures[0] = ctx->resource_manager->load<gl::texture_2d>("marker-clear-albedo.tex");
ctx->marker_albedo_textures[1] = ctx->resource_manager->load<gl::texture_2d>("marker-yellow-albedo.tex");
ctx->marker_albedo_textures[2] = ctx->resource_manager->load<gl::texture_2d>("marker-green-albedo.tex");
ctx->marker_albedo_textures[3] = ctx->resource_manager->load<gl::texture_2d>("marker-blue-albedo.tex");
ctx->marker_albedo_textures[4] = ctx->resource_manager->load<gl::texture_2d>("marker-purple-albedo.tex");
ctx->marker_albedo_textures[5] = ctx->resource_manager->load<gl::texture_2d>("marker-pink-albedo.tex");
ctx->marker_albedo_textures[6] = ctx->resource_manager->load<gl::texture_2d>("marker-red-albedo.tex");
ctx->marker_albedo_textures[7] = ctx->resource_manager->load<gl::texture_2d>("marker-orange-albedo.tex");
// Create renderer
ctx->renderer = new renderer();
ctx->renderer->set_billboard_vao(ctx->billboard_vao);
@ -850,10 +836,6 @@ void setup_systems(game::context* ctx)
// Setup constraint system
ctx->constraint_system = new entity::system::constraint(*ctx->entity_registry);
// Setup tracking system
ctx->tracking_system = new entity::system::tracking(*ctx->entity_registry, event_dispatcher, ctx->resource_manager);
ctx->tracking_system->set_scene(ctx->surface_scene);
// Setup painting system
ctx->painting_system = new entity::system::painting(*ctx->entity_registry, event_dispatcher, ctx->resource_manager);
ctx->painting_system->set_scene(ctx->surface_scene);
@ -917,88 +899,6 @@ void setup_controls(game::context* ctx)
// Setup input listener
ctx->input_listener = new input::listener();
ctx->input_listener->set_event_dispatcher(event_dispatcher);
/*
// Add menu control mappings
ctx->input_event_router->add_mapping(input::gamepad_button_mapping(ctx->menu_back_control, nullptr, input::gamepad_button::b));
//ctx->input_event_router->add_mapping(input::key_mapping(ctx->control_system->get_tool_menu_control(), nullptr, input::scancode::left_shift));
ctx->input_event_router->add_mapping(input::gamepad_button_mapping(ctx->control_system->get_tool_menu_control(), nullptr, input::gamepad_button::x));
ctx->input_event_router->add_mapping(input::key_mapping(ctx->menu_select_control, nullptr, input::scancode::enter));
ctx->input_event_router->add_mapping(input::key_mapping(ctx->menu_select_control, nullptr, input::scancode::space));
ctx->input_event_router->add_mapping(input::key_mapping(ctx->control_system->get_toggle_view_control(), nullptr, input::scancode::tab));
ctx->control_system->get_toggle_view_control()->set_activated_callback(
[ctx]()
{
if (ctx->active_scene == ctx->surface_scene)
{
ctx->active_scene = ctx->underground_scene;
ctx->radial_transition_inner->transition(0.5f, false, ease<float, double>::in_quad);
auto switch_cameras = [ctx]()
{
ctx->surface_camera->set_active(false);
ctx->underground_camera->set_active(true);
ctx->fade_transition->transition(0.25f, true, ease<float, double>::out_quad);
};
float t = ctx->timeline->get_position();
ctx->timeline->add_cue({t + 0.5f, switch_cameras});
}
else
{
ctx->active_scene = ctx->surface_scene;
ctx->fade_transition->transition(0.25f, false, ease<float, double>::out_quad);
auto switch_cameras = [ctx]()
{
ctx->surface_camera->set_active(true);
ctx->underground_camera->set_active(false);
ctx->radial_transition_inner->transition(0.5f, true, ease<float, double>::out_quad);
};
float t = ctx->timeline->get_position();
ctx->timeline->add_cue({t + 0.25f, switch_cameras});
}
});
float time_scale = ctx->config->get<float>("time_scale");
ctx->control_system->get_fast_forward_control()->set_activated_callback
(
[ctx, time_scale]()
{
ctx->orbit_system->set_time_scale(time_scale * 100.0f / seconds_per_day);
ctx->astronomy_system->set_time_scale(time_scale * 100.0f / seconds_per_day);
}
);
ctx->control_system->get_fast_forward_control()->set_deactivated_callback
(
[ctx, time_scale]()
{
ctx->orbit_system->set_time_scale(time_scale / seconds_per_day);
ctx->astronomy_system->set_time_scale(time_scale / seconds_per_day);
}
);
ctx->control_system->get_rewind_control()->set_activated_callback
(
[ctx, time_scale]()
{
ctx->orbit_system->set_time_scale(time_scale * -100.0f / seconds_per_day);
ctx->astronomy_system->set_time_scale(time_scale * -100.0f / seconds_per_day);
}
);
ctx->control_system->get_rewind_control()->set_deactivated_callback
(
[ctx, time_scale]()
{
ctx->orbit_system->set_time_scale(time_scale / seconds_per_day);
ctx->astronomy_system->set_time_scale(time_scale / seconds_per_day);
}
);
*/
}
void setup_cli(game::context* ctx)
@ -1068,7 +968,6 @@ void setup_callbacks(game::context* ctx)
ctx->astronomy_system->update(t, dt);
ctx->spatial_system->update(t, dt);
ctx->constraint_system->update(t, dt);
ctx->tracking_system->update(t, dt);
ctx->painting_system->update(t, dt);
ctx->proteome_system->update(t, dt);

+ 0
- 3
src/game/context.hpp View File

@ -81,7 +81,6 @@ namespace entity
class vegetation;
class ui;
class spatial;
class tracking;
class painting;
class astronomy;
class blackbody;
@ -157,7 +156,6 @@ struct context
gl::vertex_array* billboard_vao;
material* fallback_material;
material* splash_billboard_material;
gl::texture_2d** marker_albedo_textures;
// Compositing
clear_pass* ui_clear_pass;
@ -241,7 +239,6 @@ struct context
entity::system::ui* ui_system;
entity::system::vegetation* vegetation_system;
entity::system::spatial* spatial_system;
entity::system::tracking* tracking_system;
entity::system::painting* painting_system;
entity::system::blackbody* blackbody_system;
entity::system::atmosphere* atmosphere_system;

src/entity/components/marker.hpp → src/game/save.cpp View File

@ -17,18 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_ENTITY_COMPONENT_MARKER_HPP
#define ANTKEEPER_ENTITY_COMPONENT_MARKER_HPP
#include "game/save.hpp"
#include "application.hpp"
namespace entity {
namespace component {
namespace game {
struct marker
bool save(game::context* ctx)
{
int color;
};
return false;
}
} // namespace component
} // namespace entity
#endif // ANTKEEPER_ENTITY_COMPONENT_MARKER_HPP
} // namespace game

+ 31
- 0
src/game/save.hpp View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_SAVE_HPP
#define ANTKEEPER_GAME_SAVE_HPP
#include "game/context.hpp"
namespace game {
bool save(game::context* ctx);
} // namespace game
#endif // ANTKEEPER_GAME_SAVE_HPP

Loading…
Cancel
Save