21 #ifndef PLAYRHO_DYNAMICS_BODYATTY_HPP
22 #define PLAYRHO_DYNAMICS_BODYATTY_HPP
56 return new Body(world, bd);
60 static void Delete(
Body* b)
68 b.m_fixtures.push_back(fixture);
72 static bool RemoveFixture(
Body& b,
Fixture* fixture)
74 const auto begIter = begin(b.m_fixtures);
75 const auto endIter = end(b.m_fixtures);
76 const auto it = std::find_if(begIter, endIter, [fixture](Body::Fixtures::value_type& f) {
77 return GetPtr(f) == fixture;
81 b.m_fixtures.erase(it);
88 static void ClearFixtures(
Body& b, std::function<
void(
Fixture&)> callback)
90 const auto begIter = begin(b.m_fixtures);
91 const auto endIter = end(b.m_fixtures);
92 std::for_each(begIter, endIter, [&](Body::Fixtures::value_type& f) {
99 static void SetTypeFlags(
Body& b,
BodyType type) noexcept
112 b.m_underActiveTime = 0;
120 static void SetAwakeFlag(
Body& b) noexcept
126 static void SetMassDataDirty(
Body& b) noexcept
128 b.SetMassDataDirty();
134 return b.Erase(value);
138 static bool Erase(
Body& b,
const Joint* value)
140 return b.Erase(value);
144 static void ClearContacts(
Body &b)
150 static void ClearJoints(
Body &b)
156 static bool Insert(
Body& b,
Joint* value)
158 return b.Insert(value);
162 static bool Insert(
Body* b,
Joint* value)
166 return Insert(*b, value);
174 return b.Insert(key, value);
178 static void SetPosition0(
Body& b,
const Position value) noexcept
181 b.m_sweep.
pos0 = value;
187 static void SetPosition1(
Body& b,
const Position value) noexcept
190 b.m_sweep.
pos1 = value;
194 static void ResetAlpha0(
Body& b) noexcept
200 static void SetSweep(
Body& b,
const Sweep value) noexcept
211 b.SetTransformation(value);
217 static void SetVelocity(
Body& b,
Velocity value) noexcept
219 b.m_velocity = value;
224 static void Advance0(
Body& b,
Real value) noexcept
238 static void Advance(
Body& b,
Real toi) noexcept
244 static void Restore(
Body& b,
const Sweep value) noexcept
246 BodyAtty::SetSweep(b, value);
251 static void ClearJoints(
Body& b, std::function<
void(
Joint&)> callback)
253 auto joints = std::move(b.m_joints);
254 assert(
empty(b.m_joints));
256 callback(*(std::get<Joint*>(j)));
261 static void EraseContacts(
Body& b,
const std::function<
bool(
Contact&)>& callback)
263 auto last = end(b.m_contacts);
264 auto iter = begin(b.m_contacts);
265 auto index = Body::Contacts::difference_type{0};
269 if (callback(*contact))
271 b.m_contacts.erase(iter);
272 iter = begin(b.m_contacts) + index;
273 last = end(b.m_contacts);
277 iter = std::next(iter);
284 static bool IsIslanded(
const Body& b) noexcept
286 return b.IsIslanded();
290 static void SetIslanded(
Body& b) noexcept
296 static void UnsetIslanded(
Body& b) noexcept
298 b.UnsetIslandedFlag();
307 #endif // PLAYRHO_DYNAMICS_BODYATTY_HPP