Loading...
Searching...
No Matches
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
20namespace CubbyFlow
21{
23template <size_t N>
24class ColliderSet final : public Collider<N>
25{
26 public:
27 class Builder;
28
29 using Collider<N>::GetSurface;
30 using Collider<N>::SetSurface;
31
34
36 explicit ColliderSet(
37 const ConstArrayView1<std::shared_ptr<Collider<N>>>& others);
38
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
54
55 private:
57};
58
61
64
66using ColliderSet2Ptr = std::shared_ptr<ColliderSet2>;
67
69using ColliderSet3Ptr = std::shared_ptr<ColliderSet3>;
70
74template <size_t N>
75class ColliderSet<N>::Builder final
76{
77 public:
80 const ConstArrayView1<std::shared_ptr<Collider<N>>>& others);
81
84
86 std::shared_ptr<ColliderSet<N>> MakeShared() const;
87
88 private:
90};
91} // namespace CubbyFlow
92
93#endif
Definition Array.hpp:36
Generic N-dimensional array class interface.
Definition ArrayView.hpp:26
Abstract base class for generic collider object.
Definition Collider.hpp:31
const std::shared_ptr< Surface< N > > & GetSurface() const
Returns the surface instance.
void SetSurface(const std::shared_ptr< Surface< N > > &newSurface)
Assigns the surface instance from the subclass.
Front-end to create ColliderSet objects step by step.
Definition ColliderSet.hpp:76
ColliderSet Build() const
Builds ColliderSet.
Builder & WithColliders(const ConstArrayView1< std::shared_ptr< Collider< N > > > &others)
Returns builder with other colliders.
std::shared_ptr< ColliderSet< N > > MakeShared() const
Builds shared pointer of ColliderSet instance.
Collection of N-D colliders.
Definition ColliderSet.hpp:25
size_t NumberOfColliders() const
Returns number of colliders.
Vector< double, N > VelocityAt(const Vector< double, N > &point) const override
Returns the velocity of the collider at given point.
static Builder GetBuilder()
Returns builder for ColliderSet.
ColliderSet(const ConstArrayView1< std::shared_ptr< Collider< N > > > &others)
Constructs with other colliders.
std::shared_ptr< Collider< N > > GetCollider(size_t i) const
Returns collider at index i.
ColliderSet()
Default constructor.
void AddCollider(const std::shared_ptr< Collider< N > > &collider)
Adds a collider to the set.
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
std::shared_ptr< ColliderSet2 > ColliderSet2Ptr
Shared pointer for the ColliderSet2 type.
Definition ColliderSet.hpp:66
std::shared_ptr< ColliderSet3 > ColliderSet3Ptr
Shared pointer for the ColliderSet3 type.
Definition ColliderSet.hpp:69