Merge branch 'physics3d-material'
This commit is contained in:
commit
af75e2cc68
|
|
@ -35,13 +35,13 @@ namespace Nz
|
|||
PhysWorld3D(PhysWorld3D&&) = delete; ///TODO
|
||||
~PhysWorld3D();
|
||||
|
||||
int CreateMaterial(Nz::String name = Nz::String());
|
||||
int CreateMaterial(String name = String());
|
||||
|
||||
void ForEachBodyInAABB(const Nz::Boxf& box, const BodyIterator& iterator);
|
||||
void ForEachBodyInAABB(const Boxf& box, const BodyIterator& iterator);
|
||||
|
||||
Vector3f GetGravity() const;
|
||||
NewtonWorld* GetHandle() const;
|
||||
int GetMaterial(const Nz::String& name);
|
||||
int GetMaterial(const String& name);
|
||||
std::size_t GetMaxStepCount() const;
|
||||
float GetStepSize() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace Nz
|
|||
bool IsSimulationEnabled() const;
|
||||
bool IsSleeping() const;
|
||||
|
||||
void SetAngularDamping(const Nz::Vector3f& angularDamping);
|
||||
void SetAngularDamping(const Vector3f& angularDamping);
|
||||
void SetAngularVelocity(const Vector3f& angularVelocity);
|
||||
void SetGeom(Collider3DRef geom);
|
||||
void SetGravityFactor(float gravityFactor);
|
||||
|
|
@ -67,7 +67,7 @@ namespace Nz
|
|||
void SetLinearVelocity(const Vector3f& velocity);
|
||||
void SetMass(float mass);
|
||||
void SetMassCenter(const Vector3f& center);
|
||||
void SetMaterial(const Nz::String& materialName);
|
||||
void SetMaterial(const String& materialName);
|
||||
void SetMaterial(int materialIndex);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetRotation(const Quaternionf& rotation);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Nz
|
|||
NewtonDestroy(m_world);
|
||||
}
|
||||
|
||||
int PhysWorld3D::CreateMaterial(Nz::String name)
|
||||
int PhysWorld3D::CreateMaterial(String name)
|
||||
{
|
||||
NazaraAssert(m_materialIds.find(name) == m_materialIds.end(), "Material \"" + name + "\" already exists");
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ namespace Nz
|
|||
return materialId;
|
||||
}
|
||||
|
||||
void PhysWorld3D::ForEachBodyInAABB(const Nz::Boxf& box, const BodyIterator& iterator)
|
||||
void PhysWorld3D::ForEachBodyInAABB(const Boxf& box, const BodyIterator& iterator)
|
||||
{
|
||||
auto NewtonCallback = [](const NewtonBody* const body, void* const userdata) -> int
|
||||
{
|
||||
|
|
@ -59,7 +59,7 @@ namespace Nz
|
|||
return m_world;
|
||||
}
|
||||
|
||||
int PhysWorld3D::GetMaterial(const Nz::String& name)
|
||||
int PhysWorld3D::GetMaterial(const String& name)
|
||||
{
|
||||
auto it = m_materialIds.find(name);
|
||||
NazaraAssert(it != m_materialIds.end(), "Material \"" + name + "\" does not exists");
|
||||
|
|
@ -99,7 +99,7 @@ namespace Nz
|
|||
|
||||
void PhysWorld3D::SetMaterialCollisionCallback(int firstMaterial, int secondMaterial, AABBOverlapCallback aabbOverlapCallback, CollisionCallback collisionCallback)
|
||||
{
|
||||
static_assert(sizeof(Nz::UInt64) >= 2 * sizeof(int), "Oops");
|
||||
static_assert(sizeof(UInt64) >= 2 * sizeof(int), "Oops");
|
||||
|
||||
auto callbackPtr = std::make_unique<Callback>();
|
||||
callbackPtr->aabbOverlapCallback = std::move(aabbOverlapCallback);
|
||||
|
|
@ -107,10 +107,10 @@ namespace Nz
|
|||
|
||||
NewtonMaterialSetCollisionCallback(m_world, firstMaterial, secondMaterial, callbackPtr.get(), (callbackPtr->aabbOverlapCallback) ? OnAABBOverlap : nullptr, (callbackPtr->collisionCallback) ? ProcessContact : nullptr);
|
||||
|
||||
Nz::UInt64 firstMaterialId(firstMaterial);
|
||||
Nz::UInt64 secondMaterialId(secondMaterial);
|
||||
UInt64 firstMaterialId(firstMaterial);
|
||||
UInt64 secondMaterialId(secondMaterial);
|
||||
|
||||
Nz::UInt64 callbackIndex = firstMaterialId << 32 | secondMaterialId;
|
||||
UInt64 callbackIndex = firstMaterialId << 32 | secondMaterialId;
|
||||
m_callbacks[callbackIndex] = std::move(callbackPtr);
|
||||
}
|
||||
|
||||
|
|
@ -154,8 +154,8 @@ namespace Nz
|
|||
|
||||
int PhysWorld3D::OnAABBOverlap(const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonBody* const body1, int threadIndex)
|
||||
{
|
||||
Nz::RigidBody3D* bodyA = static_cast<Nz::RigidBody3D*>(NewtonBodyGetUserData(body0));
|
||||
Nz::RigidBody3D* bodyB = static_cast<Nz::RigidBody3D*>(NewtonBodyGetUserData(body1));
|
||||
RigidBody3D* bodyA = static_cast<RigidBody3D*>(NewtonBodyGetUserData(body0));
|
||||
RigidBody3D* bodyB = static_cast<RigidBody3D*>(NewtonBodyGetUserData(body1));
|
||||
assert(bodyA && bodyB);
|
||||
|
||||
Callback* callbackData = static_cast<Callback*>(NewtonMaterialGetMaterialPairUserData(material));
|
||||
|
|
@ -167,14 +167,14 @@ namespace Nz
|
|||
|
||||
void PhysWorld3D::ProcessContact(const NewtonJoint* const contactJoint, float timestep, int threadIndex)
|
||||
{
|
||||
Nz::RigidBody3D* bodyA = static_cast<Nz::RigidBody3D*>(NewtonBodyGetUserData(NewtonJointGetBody0(contactJoint)));
|
||||
Nz::RigidBody3D* bodyB = static_cast<Nz::RigidBody3D*>(NewtonBodyGetUserData(NewtonJointGetBody1(contactJoint)));
|
||||
RigidBody3D* bodyA = static_cast<RigidBody3D*>(NewtonBodyGetUserData(NewtonJointGetBody0(contactJoint)));
|
||||
RigidBody3D* bodyB = static_cast<RigidBody3D*>(NewtonBodyGetUserData(NewtonJointGetBody1(contactJoint)));
|
||||
assert(bodyA && bodyB);
|
||||
|
||||
using ContactJoint = void*;
|
||||
|
||||
// Query all joints first, to prevent removing a joint from the list while iterating on it
|
||||
Nz::StackArray<ContactJoint> contacts = NazaraStackAllocationNoInit(ContactJoint, NewtonContactJointGetContactCount(contactJoint));
|
||||
StackArray<ContactJoint> contacts = NazaraStackAllocationNoInit(ContactJoint, NewtonContactJointGetContactCount(contactJoint));
|
||||
std::size_t contactIndex = 0;
|
||||
for (ContactJoint contact = NewtonContactJointGetFirstContact(contactJoint); contact; contact = NewtonContactJointGetNextContact(contactJoint, contact))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ namespace Nz
|
|||
return NewtonBodyGetSleepState(m_body) != 0;
|
||||
}
|
||||
|
||||
void RigidBody3D::SetAngularDamping(const Nz::Vector3f& angularDamping)
|
||||
void RigidBody3D::SetAngularDamping(const Vector3f& angularDamping)
|
||||
{
|
||||
NewtonBodySetAngularDamping(m_body, angularDamping);
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ namespace Nz
|
|||
NewtonBodySetCentreOfMass(m_body, center);
|
||||
}
|
||||
|
||||
void RigidBody3D::SetMaterial(const Nz::String& materialName)
|
||||
void RigidBody3D::SetMaterial(const String& materialName)
|
||||
{
|
||||
SetMaterial(m_world->GetMaterial(materialName));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue