From 94523980fa09c7df27b463115227064c3bac6db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 27 Aug 2020 19:26:04 +0200 Subject: [PATCH] Fix Audio & Physics compilation --- src/Nazara/Audio/Audio.cpp | 8 ++++---- src/Nazara/Audio/SoundEmitter.cpp | 8 ++++---- src/Nazara/Physics3D/Collider3D.cpp | 4 ++-- src/Nazara/Physics3D/PhysWorld3D.cpp | 4 +++- src/Nazara/Physics3D/RigidBody3D.cpp | 26 +++++++++++++------------- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Nazara/Audio/Audio.cpp b/src/Nazara/Audio/Audio.cpp index fd0602168..5ebccf9d8 100644 --- a/src/Nazara/Audio/Audio.cpp +++ b/src/Nazara/Audio/Audio.cpp @@ -97,7 +97,7 @@ namespace Nz Vector3f Audio::GetListenerPosition() { Vector3f position; - alGetListenerfv(AL_POSITION, position); + alGetListenerfv(AL_POSITION, &position.x); return position; } @@ -127,7 +127,7 @@ namespace Nz Vector3f Audio::GetListenerVelocity() { Vector3f velocity; - alGetListenerfv(AL_VELOCITY, velocity); + alGetListenerfv(AL_VELOCITY, &velocity.x); return velocity; } @@ -294,7 +294,7 @@ namespace Nz void Audio::SetListenerPosition(const Vector3f& position) { - alListenerfv(AL_POSITION, position); + alListenerfv(AL_POSITION, &position.x); } /*! @@ -340,7 +340,7 @@ namespace Nz void Audio::SetListenerVelocity(const Vector3f& velocity) { - alListenerfv(AL_VELOCITY, velocity); + alListenerfv(AL_VELOCITY, &velocity.x); } /*! diff --git a/src/Nazara/Audio/SoundEmitter.cpp b/src/Nazara/Audio/SoundEmitter.cpp index 1489cda62..c81f26846 100644 --- a/src/Nazara/Audio/SoundEmitter.cpp +++ b/src/Nazara/Audio/SoundEmitter.cpp @@ -142,7 +142,7 @@ namespace Nz NazaraAssert(m_source != InvalidSource, "Invalid sound emitter"); Vector3f position; - alGetSourcefv(m_source, AL_POSITION, position); + alGetSourcefv(m_source, AL_POSITION, &position.x); return position; } @@ -157,7 +157,7 @@ namespace Nz NazaraAssert(m_source != InvalidSource, "Invalid sound emitter"); Vector3f velocity; - alGetSourcefv(m_source, AL_VELOCITY, velocity); + alGetSourcefv(m_source, AL_VELOCITY, &velocity.x); return velocity; } @@ -241,7 +241,7 @@ namespace Nz { NazaraAssert(m_source != InvalidSource, "Invalid sound emitter"); - alSourcefv(m_source, AL_POSITION, position); + alSourcefv(m_source, AL_POSITION, &position.x); } /*! @@ -267,7 +267,7 @@ namespace Nz { NazaraAssert(m_source != InvalidSource, "Invalid sound emitter"); - alSourcefv(m_source, AL_VELOCITY, velocity); + alSourcefv(m_source, AL_VELOCITY, &velocity.x); } /*! diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index 1cd0515e5..bcb048e2d 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -57,12 +57,12 @@ namespace Nz NewtonCollision* collision = CreateHandle(&world); { - NewtonCollisionCalculateAABB(collision, offsetMatrix, min, max); + NewtonCollisionCalculateAABB(collision, offsetMatrix, &min.x, &max.x); } NewtonDestroyCollision(collision); } else - NewtonCollisionCalculateAABB(m_handles.begin()->second, offsetMatrix, min, max); + NewtonCollisionCalculateAABB(m_handles.begin()->second, offsetMatrix, &min.x, &max.x); return Boxf(scale * min, scale * max); } diff --git a/src/Nazara/Physics3D/PhysWorld3D.cpp b/src/Nazara/Physics3D/PhysWorld3D.cpp index 9377d1cee..94e0c0ab7 100644 --- a/src/Nazara/Physics3D/PhysWorld3D.cpp +++ b/src/Nazara/Physics3D/PhysWorld3D.cpp @@ -45,7 +45,9 @@ namespace Nz return bodyIterator(*static_cast(NewtonBodyGetUserData(body))); }; - NewtonWorldForEachBodyInAABBDo(m_world, box.GetMinimum(), box.GetMaximum(), NewtonCallback, const_cast(static_cast(&iterator))); + Vector3f min = box.GetMinimum(); + Vector3f max = box.GetMaximum(); + NewtonWorldForEachBodyInAABBDo(m_world, &min.x, &max.x, NewtonCallback, const_cast(static_cast(&iterator))); } Vector3f PhysWorld3D::GetGravity() const diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index 15cfa0e31..67ef690fd 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -144,7 +144,7 @@ namespace Nz Boxf RigidBody3D::GetAABB() const { Vector3f min, max; - NewtonBodyGetAABB(m_body, min, max); + NewtonBodyGetAABB(m_body, &min.x, &max.x); return Boxf(min, max); } @@ -152,7 +152,7 @@ namespace Nz Vector3f RigidBody3D::GetAngularDamping() const { Vector3f angularDamping; - NewtonBodyGetAngularDamping(m_body, angularDamping); + NewtonBodyGetAngularDamping(m_body, &angularDamping.x); return angularDamping; } @@ -160,7 +160,7 @@ namespace Nz Vector3f RigidBody3D::GetAngularVelocity() const { Vector3f angularVelocity; - NewtonBodyGetOmega(m_body, angularVelocity); + NewtonBodyGetOmega(m_body, &angularVelocity.x); return angularVelocity; } @@ -188,7 +188,7 @@ namespace Nz Vector3f RigidBody3D::GetLinearVelocity() const { Vector3f velocity; - NewtonBodyGetVelocity(m_body, velocity); + NewtonBodyGetVelocity(m_body, &velocity.x); return velocity; } @@ -201,7 +201,7 @@ namespace Nz Vector3f RigidBody3D::GetMassCenter(CoordSys coordSys) const { Vector3f center; - NewtonBodyGetCentreOfMass(m_body, center); + NewtonBodyGetCentreOfMass(m_body, ¢er.x); switch (coordSys) { @@ -268,12 +268,12 @@ namespace Nz void RigidBody3D::SetAngularDamping(const Vector3f& angularDamping) { - NewtonBodySetAngularDamping(m_body, angularDamping); + NewtonBodySetAngularDamping(m_body, &angularDamping.x); } void RigidBody3D::SetAngularVelocity(const Vector3f& angularVelocity) { - NewtonBodySetOmega(m_body, angularVelocity); + NewtonBodySetOmega(m_body, &angularVelocity.x); } void RigidBody3D::SetGeom(Collider3DRef geom) @@ -301,7 +301,7 @@ namespace Nz void RigidBody3D::SetLinearVelocity(const Vector3f& velocity) { - NewtonBodySetVelocity(m_body, velocity); + NewtonBodySetVelocity(m_body, &velocity.x); } void RigidBody3D::SetMass(float mass) @@ -342,7 +342,7 @@ namespace Nz void RigidBody3D::SetMassCenter(const Vector3f& center) { if (m_mass > 0.f) - NewtonBodySetCentreOfMass(m_body, center); + NewtonBodySetCentreOfMass(m_body, ¢er.x); } void RigidBody3D::SetMaterial(const String& materialName) @@ -389,9 +389,9 @@ namespace Nz // Moving a static body in Newton does not update bodies at the target location // http://newtondynamics.com/wiki/index.php5?title=Can_i_dynamicly_move_a_TriMesh%3F Vector3f min, max; - NewtonBodyGetAABB(m_body, min, max); + NewtonBodyGetAABB(m_body, &min.x, &max.x); - NewtonWorldForEachBodyInAABBDo(m_world->GetHandle(), min, max, [](const NewtonBody* const body, void* const userData) -> int + NewtonWorldForEachBodyInAABBDo(m_world->GetHandle(), &min.x, &max.x, [](const NewtonBody* const body, void* const userData) -> int { NazaraUnused(userData); NewtonBodySetSleepState(body, 0); @@ -430,8 +430,8 @@ namespace Nz if (!NumberEquals(me->m_gravityFactor, 0.f)) me->m_forceAccumulator += me->m_world->GetGravity() * me->m_gravityFactor * me->m_mass; - NewtonBodySetForce(body, me->m_forceAccumulator); - NewtonBodySetTorque(body, me->m_torqueAccumulator); + NewtonBodySetForce(body, &me->m_forceAccumulator.x); + NewtonBodySetTorque(body, &me->m_torqueAccumulator.x); me->m_torqueAccumulator.Set(0.f); me->m_forceAccumulator.Set(0.f);