Antkeeper  0.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
capsule-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_CAPSULE_COLLIDER_HPP
21 #define ANTKEEPER_PHYSICS_CAPSULE_COLLIDER_HPP
22 
25 
26 namespace physics {
27 
32 {
33 public:
36 
37  [[nodiscard]] inline constexpr collider_type type() const noexcept override
38  {
40  }
41 
47  inline constexpr explicit capsule_collider(const capsule_type& capsule) noexcept:
48  m_capsule{capsule}
49  {}
50 
58  inline constexpr capsule_collider(const capsule_type::segment_type& segment, float radius) noexcept:
59  m_capsule{segment, radius}
60  {}
61  constexpr capsule_collider() noexcept = default;
63 
69  inline constexpr void set_capsule(const capsule_type& capsule) noexcept
70  {
71  m_capsule = capsule;
72  }
73 
79  inline constexpr void set_segment(const capsule_type::segment_type& segment) noexcept
80  {
81  m_capsule.segment = segment;
82  }
83 
89  inline constexpr void set_radius(float radius) noexcept
90  {
91  m_capsule.radius = radius;
92  }
93 
95  [[nodiscard]] inline constexpr const capsule_type& get_capsule() const noexcept
96  {
97  return m_capsule;
98  }
99 
101  [[nodiscard]] inline constexpr const capsule_type::segment_type& get_segment() const noexcept
102  {
103  return m_capsule.segment;
104  }
105 
107  [[nodiscard]] inline constexpr float get_radius() const noexcept
108  {
109  return m_capsule.radius;
110  }
111 
112 private:
113  capsule_type m_capsule{};
114 };
115 
116 } // namespace physics
117 
118 #endif // ANTKEEPER_PHYSICS_CAPSULE_COLLIDER_HPP
Capsule collision object.
constexpr capsule_collider() noexcept=default
Constructs a capsule collider.
constexpr float get_radius() const noexcept
Returns the radius of the capsule hemispheres.
constexpr void set_segment(const capsule_type::segment_type &segment) noexcept
Sets the segment of the capsule.
constexpr capsule_collider(const capsule_type &capsule) noexcept
Constructs a capsule collider from a capsule.
constexpr const capsule_type::segment_type & get_segment() const noexcept
Returns the segment of the capsule, in object space.
constexpr void set_capsule(const capsule_type &capsule) noexcept
Sets the collider's capsule.
constexpr collider_type type() const noexcept override
Returns the collider type.
constexpr capsule_collider(const capsule_type::segment_type &segment, float radius) noexcept
Constructs a capsule collider.
geom::capsule< float > capsule_type
Capule type.
constexpr const capsule_type & get_capsule() const noexcept
Returns the capsule shape.
constexpr void set_radius(float radius) noexcept
Sets the radius of the capsule hemispheres.
Abstract base class for collision objects.
Definition: collider.hpp:34
Physics.
Definition: constants.hpp:23
collider_type
Collider types.
@ capsule
Capsule collider.
n-dimensional capsule.
segment_type segment
Medial line segment.
T radius
Radius of the hemi-hyperspheres.
n-dimensional line segment.