Physics3D/PhysWorld3D: Add ForEachBodyInAABB method
This commit is contained in:
parent
c592acfd5f
commit
b47f5210e0
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
|
#include <Nazara/Math/Box.hpp>
|
||||||
#include <Nazara/Math/Vector3.hpp>
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
#include <Nazara/Physics3D/Config.hpp>
|
#include <Nazara/Physics3D/Config.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
@ -25,6 +26,7 @@ namespace Nz
|
||||||
class NAZARA_PHYSICS3D_API PhysWorld3D
|
class NAZARA_PHYSICS3D_API PhysWorld3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using BodyIterator = std::function<bool(const RigidBody3D& body)>;
|
||||||
using AABBOverlapCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
using AABBOverlapCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
||||||
using CollisionCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
using CollisionCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
||||||
|
|
||||||
|
|
@ -35,6 +37,8 @@ namespace Nz
|
||||||
|
|
||||||
int CreateMaterial(Nz::String name = Nz::String());
|
int CreateMaterial(Nz::String name = Nz::String());
|
||||||
|
|
||||||
|
void ForEachBodyInAABB(const Nz::Boxf& box, BodyIterator iterator);
|
||||||
|
|
||||||
Vector3f GetGravity() const;
|
Vector3f GetGravity() const;
|
||||||
NewtonWorld* GetHandle() const;
|
NewtonWorld* GetHandle() const;
|
||||||
int GetMaterial(const Nz::String& name);
|
int GetMaterial(const Nz::String& name);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,18 @@ namespace Nz
|
||||||
return materialId;
|
return materialId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhysWorld3D::ForEachBodyInAABB(const Nz::Boxf& box, BodyIterator iterator)
|
||||||
|
{
|
||||||
|
auto NewtonCallback = [](const NewtonBody* const body, void* const userdata) -> int
|
||||||
|
{
|
||||||
|
BodyIterator& iterator = *static_cast<BodyIterator*>(userdata);
|
||||||
|
RigidBody3D* nzBody = static_cast<RigidBody3D*>(NewtonBodyGetUserData(body));
|
||||||
|
return iterator(*nzBody);
|
||||||
|
};
|
||||||
|
|
||||||
|
NewtonWorldForEachBodyInAABBDo(m_world, box.GetMinimum(), box.GetMaximum(), NewtonCallback, &iterator);
|
||||||
|
}
|
||||||
|
|
||||||
Vector3f PhysWorld3D::GetGravity() const
|
Vector3f PhysWorld3D::GetGravity() const
|
||||||
{
|
{
|
||||||
return m_gravity;
|
return m_gravity;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue