Minor fixes
This commit is contained in:
parent
e3f1000f17
commit
488f3ca6ef
|
|
@ -14,6 +14,7 @@
|
|||
namespace Nz
|
||||
{
|
||||
class MaterialInstance;
|
||||
class RenderBuffer;
|
||||
class RenderPipeline;
|
||||
class Skeleton;
|
||||
class VertexDeclaration;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <Nazara/Graphics/RenderQueueRegistry.hpp>
|
||||
#include <Nazara/Graphics/SkeletonInstance.hpp>
|
||||
#include <Nazara/Graphics/WorldInstance.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace Nz
|
|||
Constraint2D& operator=(Constraint2D&& rhs);
|
||||
|
||||
protected:
|
||||
Constraint2D(Nz::PhysWorld2D* world, cpConstraint* constraint);
|
||||
Constraint2D(PhysWorld2D* world, cpConstraint* constraint);
|
||||
|
||||
MovablePtr<cpConstraint> m_constraint;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Physics2D/Config.hpp>
|
||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||
#include <Nazara/Utils/FunctionRef.hpp>
|
||||
#include <Nazara/Utils/Signal.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
|
@ -62,15 +63,15 @@ namespace Nz
|
|||
std::size_t GetMaxStepCount() const;
|
||||
Time GetStepSize() const;
|
||||
|
||||
bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody = nullptr);
|
||||
bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result);
|
||||
bool NearestBodyQuery(const Vector2f& from, float maxDistance, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, RigidBody2D** nearestBody = nullptr);
|
||||
bool NearestBodyQuery(const Vector2f& from, float maxDistance, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, NearestQueryResult* result);
|
||||
|
||||
void RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, const std::function<void(const RaycastHit&)>& callback);
|
||||
bool RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector<RaycastHit>* hitInfos);
|
||||
bool RaycastQueryFirst(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RaycastHit* hitInfo = nullptr);
|
||||
void RaycastQuery(const Vector2f& from, const Vector2f& to, float radius, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, const FunctionRef<void(const RaycastHit&)>& callback);
|
||||
bool RaycastQuery(const Vector2f& from, const Vector2f& to, float radius, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, std::vector<RaycastHit>* hitInfos);
|
||||
bool RaycastQueryFirst(const Vector2f& from, const Vector2f& to, float radius, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, RaycastHit* hitInfo = nullptr);
|
||||
|
||||
void RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, const std::function<void(Nz::RigidBody2D*)>& callback);
|
||||
void RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector<Nz::RigidBody2D*>* bodies);
|
||||
void RegionQuery(const Rectf& boundingBox, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, const FunctionRef<void(RigidBody2D*)>& callback);
|
||||
void RegionQuery(const Rectf& boundingBox, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, std::vector<RigidBody2D*>* bodies);
|
||||
|
||||
void RegisterCallbacks(unsigned int collisionId, Callback callbacks);
|
||||
void RegisterCallbacks(unsigned int collisionIdA, unsigned int collisionIdB, Callback callbacks);
|
||||
|
|
@ -116,17 +117,17 @@ namespace Nz
|
|||
|
||||
struct NearestQueryResult
|
||||
{
|
||||
Nz::RigidBody2D* nearestBody;
|
||||
Nz::Vector2f closestPoint;
|
||||
Nz::Vector2f fraction;
|
||||
RigidBody2D* nearestBody;
|
||||
Vector2f closestPoint;
|
||||
Vector2f fraction;
|
||||
float distance;
|
||||
};
|
||||
|
||||
struct RaycastHit
|
||||
{
|
||||
Nz::RigidBody2D* nearestBody;
|
||||
Nz::Vector2f hitPos;
|
||||
Nz::Vector2f hitNormal;
|
||||
RigidBody2D* nearestBody;
|
||||
Vector2f hitPos;
|
||||
Vector2f hitNormal;
|
||||
float fraction;
|
||||
};
|
||||
|
||||
|
|
@ -136,7 +137,7 @@ namespace Nz
|
|||
private:
|
||||
void InitCallbacks(cpCollisionHandler* handler, Callback callbacks);
|
||||
|
||||
using PostStep = std::function<void(Nz::RigidBody2D* body)>;
|
||||
using PostStep = std::function<void(RigidBody2D* body)>;
|
||||
|
||||
void OnRigidBodyMoved(RigidBody2D* oldPointer, RigidBody2D* newPointer);
|
||||
void OnRigidBodyRelease(RigidBody2D* rigidBody);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Nz
|
|||
class NAZARA_PHYSICS2D_API RigidBody2D
|
||||
{
|
||||
public:
|
||||
using VelocityFunc = std::function<void(RigidBody2D& body2D, const Nz::Vector2f& gravity, float damping, float deltaTime)>;
|
||||
using VelocityFunc = std::function<void(RigidBody2D& body2D, const Vector2f& gravity, float damping, float deltaTime)>;
|
||||
|
||||
RigidBody2D(PhysWorld2D* world, float mass);
|
||||
RigidBody2D(PhysWorld2D* world, float mass, std::shared_ptr<Collider2D> geom);
|
||||
|
|
@ -41,11 +41,11 @@ namespace Nz
|
|||
void AddImpulse(const Vector2f& impulse, const Vector2f& point, CoordSys coordSys = CoordSys::Global);
|
||||
void AddTorque(const RadianAnglef& torque);
|
||||
|
||||
bool ClosestPointQuery(const Nz::Vector2f& position, Nz::Vector2f* closestPoint = nullptr, float* closestDistance = nullptr) const;
|
||||
bool ClosestPointQuery(const Vector2f& position, Vector2f* closestPoint = nullptr, float* closestDistance = nullptr) const;
|
||||
|
||||
void EnableSimulation(bool simulation);
|
||||
|
||||
void ForEachArbiter(std::function<void(Nz::Arbiter2D& /*arbiter*/)> callback);
|
||||
void ForEachArbiter(std::function<void(Arbiter2D& /*arbiter*/)> callback);
|
||||
void ForceSleep();
|
||||
|
||||
Rectf GetAABB() const;
|
||||
|
|
@ -98,7 +98,7 @@ namespace Nz
|
|||
void SetVelocity(const Vector2f& velocity);
|
||||
void SetVelocityFunction(VelocityFunc velocityFunc);
|
||||
|
||||
void UpdateVelocity(const Nz::Vector2f& gravity, float damping, float deltaTime);
|
||||
void UpdateVelocity(const Vector2f& gravity, float damping, float deltaTime);
|
||||
|
||||
void Wakeup();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_RENDERER_RENDERSTATES_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
#include <memory>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// This file is part of the "Nazara Engine - Vulkan renderer"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <utility>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz::Vk
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
Constraint2D::Constraint2D(Nz::PhysWorld2D* world, cpConstraint* constraint) :
|
||||
Constraint2D::Constraint2D(PhysWorld2D* world, cpConstraint* constraint) :
|
||||
m_constraint(constraint)
|
||||
{
|
||||
cpConstraintSetUserData(m_constraint, this);
|
||||
|
|
|
|||
|
|
@ -159,14 +159,14 @@ namespace Nz
|
|||
return m_stepSize;
|
||||
}
|
||||
|
||||
bool PhysWorld2D::NearestBodyQuery(const Vector2f & from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody)
|
||||
bool PhysWorld2D::NearestBodyQuery(const Vector2f & from, float maxDistance, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, RigidBody2D** nearestBody)
|
||||
{
|
||||
cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask);
|
||||
|
||||
if (cpShape* shape = cpSpacePointQueryNearest(m_handle, {from.x, from.y}, maxDistance, filter, nullptr))
|
||||
{
|
||||
if (nearestBody)
|
||||
*nearestBody = static_cast<Nz::RigidBody2D*>(cpShapeGetUserData(shape));
|
||||
*nearestBody = static_cast<RigidBody2D*>(cpShapeGetUserData(shape));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ namespace Nz
|
|||
return false;
|
||||
}
|
||||
|
||||
bool PhysWorld2D::NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result)
|
||||
bool PhysWorld2D::NearestBodyQuery(const Vector2f& from, float maxDistance, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, NearestQueryResult* result)
|
||||
{
|
||||
cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask);
|
||||
|
||||
|
|
@ -184,10 +184,10 @@ namespace Nz
|
|||
|
||||
if (cpSpacePointQueryNearest(m_handle, { from.x, from.y }, maxDistance, filter, &queryInfo))
|
||||
{
|
||||
result->closestPoint.Set(Nz::Vector2<cpFloat>(queryInfo.point.x, queryInfo.point.y));
|
||||
result->closestPoint.Set(Vector2<cpFloat>(queryInfo.point.x, queryInfo.point.y));
|
||||
result->distance = float(queryInfo.distance);
|
||||
result->fraction.Set(Nz::Vector2<cpFloat>(queryInfo.gradient.x, queryInfo.gradient.y));
|
||||
result->nearestBody = static_cast<Nz::RigidBody2D*>(cpShapeGetUserData(queryInfo.shape));
|
||||
result->fraction.Set(Vector2<cpFloat>(queryInfo.gradient.x, queryInfo.gradient.y));
|
||||
result->nearestBody = static_cast<RigidBody2D*>(cpShapeGetUserData(queryInfo.shape));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ namespace Nz
|
|||
}
|
||||
}
|
||||
|
||||
void PhysWorld2D::RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, const std::function<void(const RaycastHit&)>& callback)
|
||||
void PhysWorld2D::RaycastQuery(const Vector2f& from, const Vector2f& to, float radius, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, const FunctionRef<void(const RaycastHit&)>& callback)
|
||||
{
|
||||
using CallbackType = const std::function<void(const RaycastHit&)>;
|
||||
|
||||
|
|
@ -213,9 +213,9 @@ namespace Nz
|
|||
|
||||
RaycastHit hitInfo;
|
||||
hitInfo.fraction = float(alpha);
|
||||
hitInfo.hitNormal.Set(Nz::Vector2<cpFloat>(normal.x, normal.y));
|
||||
hitInfo.hitPos.Set(Nz::Vector2<cpFloat>(point.x, point.y));
|
||||
hitInfo.nearestBody = static_cast<Nz::RigidBody2D*>(cpShapeGetUserData(shape));
|
||||
hitInfo.hitNormal.Set(Vector2<cpFloat>(normal.x, normal.y));
|
||||
hitInfo.hitPos.Set(Vector2<cpFloat>(point.x, point.y));
|
||||
hitInfo.nearestBody = static_cast<RigidBody2D*>(cpShapeGetUserData(shape));
|
||||
|
||||
callback(hitInfo);
|
||||
};
|
||||
|
|
@ -224,7 +224,7 @@ namespace Nz
|
|||
cpSpaceSegmentQuery(m_handle, { from.x, from.y }, { to.x, to.y }, radius, filter, cpCallback, const_cast<void*>(static_cast<const void*>(&callback)));
|
||||
}
|
||||
|
||||
bool PhysWorld2D::RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector<RaycastHit>* hitInfos)
|
||||
bool PhysWorld2D::RaycastQuery(const Vector2f& from, const Vector2f& to, float radius, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, std::vector<RaycastHit>* hitInfos)
|
||||
{
|
||||
using ResultType = decltype(hitInfos);
|
||||
|
||||
|
|
@ -234,9 +234,9 @@ namespace Nz
|
|||
|
||||
RaycastHit hitInfo;
|
||||
hitInfo.fraction = float(alpha);
|
||||
hitInfo.hitNormal.Set(Nz::Vector2<cpFloat>(normal.x, normal.y));
|
||||
hitInfo.hitPos.Set(Nz::Vector2<cpFloat>(point.x, point.y));
|
||||
hitInfo.nearestBody = static_cast<Nz::RigidBody2D*>(cpShapeGetUserData(shape));
|
||||
hitInfo.hitNormal.Set(Vector2<cpFloat>(normal.x, normal.y));
|
||||
hitInfo.hitPos.Set(Vector2<cpFloat>(point.x, point.y));
|
||||
hitInfo.nearestBody = static_cast<RigidBody2D*>(cpShapeGetUserData(shape));
|
||||
|
||||
results->emplace_back(std::move(hitInfo));
|
||||
};
|
||||
|
|
@ -249,7 +249,7 @@ namespace Nz
|
|||
return hitInfos->size() != previousSize;
|
||||
}
|
||||
|
||||
bool PhysWorld2D::RaycastQueryFirst(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RaycastHit* hitInfo)
|
||||
bool PhysWorld2D::RaycastQueryFirst(const Vector2f& from, const Vector2f& to, float radius, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, RaycastHit* hitInfo)
|
||||
{
|
||||
cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask);
|
||||
|
||||
|
|
@ -260,9 +260,9 @@ namespace Nz
|
|||
if (cpSpaceSegmentQueryFirst(m_handle, { from.x, from.y }, { to.x, to.y }, radius, filter, &queryInfo))
|
||||
{
|
||||
hitInfo->fraction = float(queryInfo.alpha);
|
||||
hitInfo->hitNormal.Set(Nz::Vector2<cpFloat>(queryInfo.normal.x, queryInfo.normal.y));
|
||||
hitInfo->hitPos.Set(Nz::Vector2<cpFloat>(queryInfo.point.x, queryInfo.point.y));
|
||||
hitInfo->nearestBody = static_cast<Nz::RigidBody2D*>(cpShapeGetUserData(queryInfo.shape));
|
||||
hitInfo->hitNormal.Set(Vector2<cpFloat>(queryInfo.normal.x, queryInfo.normal.y));
|
||||
hitInfo->hitPos.Set(Vector2<cpFloat>(queryInfo.point.x, queryInfo.point.y));
|
||||
hitInfo->nearestBody = static_cast<RigidBody2D*>(cpShapeGetUserData(queryInfo.shape));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -278,28 +278,28 @@ namespace Nz
|
|||
}
|
||||
}
|
||||
|
||||
void PhysWorld2D::RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, const std::function<void(Nz::RigidBody2D*)>& callback)
|
||||
void PhysWorld2D::RegionQuery(const Rectf& boundingBox, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, const FunctionRef<void(RigidBody2D*)>& callback)
|
||||
{
|
||||
using CallbackType = const std::function<void(Nz::RigidBody2D*)>;
|
||||
using CallbackType = const std::function<void(RigidBody2D*)>;
|
||||
|
||||
auto cpCallback = [](cpShape* shape, void* data)
|
||||
{
|
||||
CallbackType& callback = *static_cast<CallbackType*>(data);
|
||||
callback(static_cast<Nz::RigidBody2D*>(cpShapeGetUserData(shape)));
|
||||
callback(static_cast<RigidBody2D*>(cpShapeGetUserData(shape)));
|
||||
};
|
||||
|
||||
cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask);
|
||||
cpSpaceBBQuery(m_handle, cpBBNew(boundingBox.x, boundingBox.y, boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height), filter, cpCallback, const_cast<void*>(static_cast<const void*>(&callback)));
|
||||
}
|
||||
|
||||
void PhysWorld2D::RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector<Nz::RigidBody2D*>* bodies)
|
||||
void PhysWorld2D::RegionQuery(const Rectf& boundingBox, UInt32 collisionGroup, UInt32 categoryMask, UInt32 collisionMask, std::vector<RigidBody2D*>* bodies)
|
||||
{
|
||||
using ResultType = decltype(bodies);
|
||||
|
||||
auto callback = [] (cpShape* shape, void* data)
|
||||
{
|
||||
ResultType results = static_cast<ResultType>(data);
|
||||
results->push_back(static_cast<Nz::RigidBody2D*>(cpShapeGetUserData(shape)));
|
||||
results->push_back(static_cast<RigidBody2D*>(cpShapeGetUserData(shape)));
|
||||
};
|
||||
|
||||
cpShapeFilter filter = cpShapeFilterNew(collisionGroup, categoryMask, collisionMask);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ namespace Nz
|
|||
}
|
||||
|
||||
case WindowBackend::Cocoa: systemHandle = handle.cocoa.window; break;
|
||||
case WindowBackend::X11: systemHandle = (void*) handle.x11.window; break;
|
||||
case WindowBackend::X11: systemHandle = reinterpret_cast<void*>(std::uintptr_t(handle.x11.window)); break;
|
||||
case WindowBackend::Windows: systemHandle = handle.windows.window; break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ if is_plat("windows") then
|
|||
set_runtimes(is_mode("debug") and "MDd" or "MD")
|
||||
end
|
||||
|
||||
add_defines("_CRT_SECURE_NO_WARNINGS")
|
||||
add_defines("_CRT_SECURE_NO_WARNINGS", "_ENABLE_EXTENDED_ALIGNED_STORAGE")
|
||||
add_cxxflags("/bigobj", "/permissive-", "/Zc:__cplusplus", "/Zc:externConstexpr", "/Zc:inline", "/Zc:lambda", "/Zc:preprocessor", "/Zc:referenceBinding", "/Zc:strictStrings", "/Zc:throwingNew")
|
||||
add_cxflags("/w44062") -- Enable warning: switch case not handled
|
||||
add_cxflags("/wd4251") -- Disable warning: class needs to have dll-interface to be used by clients of class blah blah blah
|
||||
|
|
|
|||
Loading…
Reference in New Issue