#pragma once #include "evo/client/camera.hpp" #include "evo/client/environment_view.hpp" #include "evo/client/organism_view.hpp" #include #include // M9.8c click selection (toolkit-independent). Selection names a presentation item by // key (organism id or voxel) and re-resolves it against each new presentation; it // never holds pointers into presentations across frames and selects nothing in the // world itself. namespace evo::client { class Selection { public: enum class Kind : std::uint8_t { none, organism, cell }; enum class Change : std::uint8_t { none, organism_gone, cell_gone }; // Topmost organism whose drawn body contains the point wins; otherwise the habitat // cell whose voxel contains it; otherwise the selection clears. void pick(ScreenPoint point, const EnvironmentPresentation* environment, const OrganismPresentation* organisms, const Camera& camera); // Clears when the selected item is absent from a present presentation. Without a // presentation (no view yet, reconnecting) the selection is kept but not shown. [[nodiscard]] Change refresh(const EnvironmentPresentation* environment, const OrganismPresentation* organisms); void clear() noexcept { kind_ = Kind::none; } [[nodiscard]] Kind kind() const noexcept { return kind_; } [[nodiscard]] const OrganismCell* organism(const OrganismPresentation* organisms) const; [[nodiscard]] const EnvironmentCell* cell(const EnvironmentPresentation* environment) const; private: Kind kind_{Kind::none}; std::uint64_t organism_{}; world::VoxelAddress voxel_{}; }; } // namespace evo::client