Antkeeper  0.0.1
collider.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 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 
20 #ifndef ANTKEEPER_PHYSICS_COLLIDER_HPP
21 #define ANTKEEPER_PHYSICS_COLLIDER_HPP
22 
25 #include <cstdint>
26 #include <memory>
27 
28 namespace physics {
29 
33 class collider
34 {
35 public:
39  [[nodiscard]] virtual constexpr collider_type type() const noexcept = 0;
40 
46  inline constexpr void set_layer_mask(std::uint32_t mask) noexcept
47  {
48  m_layer_mask = mask;
49  }
50 
54  inline void set_material(std::shared_ptr<collider_material> material) noexcept
55  {
56  m_material = material;
57  }
58 
60  [[nodiscard]] inline constexpr std::uint32_t get_layer_mask() const noexcept
61  {
62  return m_layer_mask;
63  }
64 
66  [[nodiscard]] inline constexpr const std::shared_ptr<collider_material>& get_material() const noexcept
67  {
68  return m_material;
69  }
70 
71 private:
73  std::uint32_t m_layer_mask{1};
74 
76  std::shared_ptr<collider_material> m_material;
77 };
78 
79 } // namespace physics
80 
81 #endif // ANTKEEPER_PHYSICS_COLLIDER_HPP
Abstract base class for collision objects.
Definition: collider.hpp:34
virtual constexpr collider_type type() const noexcept=0
Returns the collider type.
constexpr void set_layer_mask(std::uint32_t mask) noexcept
Sets the layer mask of the collider.
Definition: collider.hpp:46
void set_material(std::shared_ptr< collider_material > material) noexcept
Sets the collider material.
Definition: collider.hpp:54
constexpr std::uint32_t get_layer_mask() const noexcept
Returns the layer mask of the collider.
Definition: collider.hpp:60
constexpr const std::shared_ptr< collider_material > & get_material() const noexcept
Returns the collider material.
Definition: collider.hpp:66
Physics.
Definition: constants.hpp:23
collider_type
Collider types.