ColliderSet.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_COLLIDER_SET_HPP
12 #define CUBBYFLOW_COLLIDER_SET_HPP
13 
14 #include <Core/Array/Array.hpp>
17 
18 #include <memory>
19 
20 namespace CubbyFlow
21 {
23 template <size_t N>
24 class ColliderSet final : public Collider<N>
25 {
26  public:
27  class Builder;
28 
31 
33  ColliderSet();
34 
36  explicit ColliderSet(
37  const ConstArrayView1<std::shared_ptr<Collider<N>>>& others);
38 
40  [[nodiscard]] Vector<double, N> VelocityAt(
41  const Vector<double, N>& point) const override;
42 
44  void AddCollider(const std::shared_ptr<Collider<N>>& collider);
45 
47  [[nodiscard]] size_t NumberOfColliders() const;
48 
50  [[nodiscard]] std::shared_ptr<Collider<N>> GetCollider(size_t i) const;
51 
53  static Builder GetBuilder();
54 
55  private:
57 };
58 
61 
64 
66 using ColliderSet2Ptr = std::shared_ptr<ColliderSet2>;
67 
69 using ColliderSet3Ptr = std::shared_ptr<ColliderSet3>;
70 
74 template <size_t N>
75 class ColliderSet<N>::Builder final
76 {
77  public:
79  Builder& WithColliders(
80  const ConstArrayView1<std::shared_ptr<Collider<N>>>& others);
81 
83  ColliderSet Build() const;
84 
86  std::shared_ptr<ColliderSet<N>> MakeShared() const;
87 
88  private:
90 };
91 } // namespace CubbyFlow
92 
93 #endif
std::shared_ptr< ColliderSet3 > ColliderSet3Ptr
Shared pointer for the ColliderSet3 type.
Definition: ColliderSet.hpp:69
ColliderSet()
Default constructor.
std::shared_ptr< Collider< N > > GetCollider(size_t i) const
Returns collider at index i.
Collection of N-D colliders.
Definition: ColliderSet.hpp:24
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
Definition: Array-Impl.hpp:19
size_t NumberOfColliders() const
Returns number of colliders.
Generic N-dimensional array class interface.
Definition: Array.hpp:32
Front-end to create ColliderSet objects step by step.
Definition: ColliderSet.hpp:75
std::shared_ptr< ColliderSet2 > ColliderSet2Ptr
Shared pointer for the ColliderSet2 type.
Definition: ColliderSet.hpp:66
static Builder GetBuilder()
Returns builder for ColliderSet.
Abstract base class for generic collider object.
Definition: Collider.hpp:30
Vector< double, N > VelocityAt(const Vector< double, N > &point) const override
Returns the velocity of the collider at given point.
void AddCollider(const std::shared_ptr< Collider< N >> &collider)
Adds a collider to the set.