💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.4 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_PAINTING_SYSTEM_HPP
  20. #define ANTKEEPER_PAINTING_SYSTEM_HPP
  21. #include "entity-system.hpp"
  22. #include "event/event-handler.hpp"
  23. #include "game/events/tool-events.hpp"
  24. #include "utility/fundamental-types.hpp"
  25. #include <vector>
  26. #include <optional>
  27. class material;
  28. class event_dispatcher;
  29. class resource_manager;
  30. class scene;
  31. class model;
  32. class model_instance;
  33. class model_group;
  34. class vertex_buffer;
  35. class painting_system: public entity_system,
  36. public event_handler<tool_pressed_event>,
  37. public event_handler<tool_released_event>
  38. {
  39. public:
  40. painting_system(entt::registry& registry, event_dispatcher* event_dispatcher, resource_manager* resource_manager);
  41. virtual ~painting_system();
  42. virtual void update(double t, double dt);
  43. void set_scene(scene* scene);
  44. private:
  45. virtual void handle_event(const tool_pressed_event& event);
  46. virtual void handle_event(const tool_released_event& event);
  47. std::optional<std::tuple<float3, float3>> cast_ray(const float3& position) const;
  48. event_dispatcher* event_dispatcher;
  49. resource_manager* resource_manager;
  50. scene* scene;
  51. bool painting;
  52. entt::entity brush_entity;
  53. float3 stroke_start;
  54. float3 stroke_end;
  55. float min_stroke_length;
  56. float min_stroke_length_squared;
  57. float stroke_width;
  58. int max_stroke_segments;
  59. int current_stroke_segment;
  60. float max_miter_angle;
  61. float decal_offset;
  62. float3 stroke_bounds_min;
  63. float3 stroke_bounds_max;
  64. float3 p0;
  65. float3 p0a;
  66. float3 p0b;
  67. std::size_t vertex_size;
  68. std::size_t vertex_stride;
  69. std::size_t vertex_count;
  70. model* stroke_model;
  71. model_group* stroke_model_group;
  72. vertex_buffer* stroke_vbo;
  73. bool midstroke;
  74. model_instance* stroke_model_instance;
  75. };
  76. #endif // ANTKEEPER_PAINTING_SYSTEM_HPP