Island.hpp
Go to the documentation of this file.
1 /*
2  * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3  * Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  * 1. The origin of this software must not be misrepresented; you must not
12  * claim that you wrote the original software. If you use this software
13  * in a product, an acknowledgment in the product documentation would be
14  * appreciated but is not required.
15  * 2. Altered source versions must be plainly marked as such, and must not be
16  * misrepresented as being the original software.
17  * 3. This notice may not be removed or altered from any source distribution.
18  */
19 
20 #ifndef PLAYRHO_DYNAMICS_ISLAND_HPP
21 #define PLAYRHO_DYNAMICS_ISLAND_HPP
22 
23 #include <PlayRho/Common/Math.hpp>
24 #include <vector>
25 
26 namespace playrho {
27 namespace d2 {
28 
29 class Body;
30 class Contact;
31 class Joint;
32 
37 struct Island
38 {
40  using Bodies = std::vector<Body*>;
41 
43  using Contacts = std::vector<Contact*>;
44 
46  using Joints = std::vector<Joint*>;
47 
49  Island(Bodies::size_type bodyCapacity, Contacts::size_type contactCapacity,
50  Joints::size_type jointCapacity);
51 
53  Island(const Island& copy) = default;
54 
56  Island(Island&& other) noexcept = default;
57 
59  ~Island() = default;
60 
62  Island& operator= (const Island& other) = default;
63 
65  Island& operator= (Island&& other) noexcept = default;
66 
70 };
71 
74 inline bool IsFullOfBodies(const Island& island)
75 {
76  return IsFull(island.m_bodies);
77 }
78 
81 inline bool IsFullOfContacts(const Island& island)
82 {
83  return IsFull(island.m_contacts);
84 }
85 
88 std::size_t Count(const Island& island, const Body* entry);
89 
92 std::size_t Count(const Island& island, const Contact* entry);
93 
96 std::size_t Count(const Island& island, const Joint* entry);
97 
98 } // namespace d2
99 } // namespace playrho
100 
101 #endif // PLAYRHO_DYNAMICS_ISLAND_HPP