From a4617eacbaa954240da76a8eee4954a078772500 Mon Sep 17 00:00:00 2001 From: Lamakaio Date: Sun, 16 Jun 2024 13:21:44 +0200 Subject: [PATCH] Fix submodule path and some clang warnings --- .gitignore | 1 + .gitmodules | 2 +- src/ospjolt/activescene/joltinteg.h | 9 +-------- src/ospjolt/activescene/joltinteg_fn.cpp | 16 ++++++++-------- src/ospjolt/activescene/joltinteg_fn.h | 2 +- src/testapp/sessions/jolt.cpp | 8 ++++---- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index e5babb84..d638450a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ out/ .vs/ build/ .vscode/ +.cache \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 8a480c16..1713c4b9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -39,4 +39,4 @@ url = https://github.com/freetype/freetype [submodule "3rdparty/JoltPhysics"] path = 3rdparty/JoltPhysics - url = git@github.com:jrouwe/JoltPhysics.git + url = https://github.com/jrouwe/JoltPhysics.git diff --git a/src/ospjolt/activescene/joltinteg.h b/src/ospjolt/activescene/joltinteg.h index d7a31828..54be7724 100644 --- a/src/ospjolt/activescene/joltinteg.h +++ b/src/ospjolt/activescene/joltinteg.h @@ -37,22 +37,18 @@ JPH_SUPPRESS_WARNINGS #include #include -#include #include -#include #include #include #include #include #include #include -#include #include #include #include #include #include -#include JPH_SUPPRESS_WARNING_POP @@ -65,10 +61,7 @@ JPH_SUPPRESS_WARNING_POP #include #include -#include #include -#include -#include #include "osp/core/strong_id.h" @@ -240,7 +233,7 @@ class PhysicsStepListenerImpl : public PhysicsStepListener { public: PhysicsStepListenerImpl(ACtxJoltWorld* pContext) : m_context(pContext) {}; - void OnStep(float inDeltaTime, PhysicsSystem& inPhysicsSystem) override; + void OnStep(float inDeltaTime, PhysicsSystem& rPhysicsSystem) override; private: ACtxJoltWorld* m_context; diff --git a/src/ospjolt/activescene/joltinteg_fn.cpp b/src/ospjolt/activescene/joltinteg_fn.cpp index 5025da32..81102b1c 100644 --- a/src/ospjolt/activescene/joltinteg_fn.cpp +++ b/src/ospjolt/activescene/joltinteg_fn.cpp @@ -1,6 +1,6 @@ /** * Open Space Program - * Copyright © 2019-2020 Open Space Program Project + * Copyright © 2019-2024 Open Space Program Project * * MIT License * @@ -99,7 +99,7 @@ void SysJolt::update_world( rCtxWorld.m_pTransform = std::addressof(rTf); - uint collisionSteps = 1; + int collisionSteps = 1; pJoltWorld->Update(timestep, collisionSteps, &rCtxWorld.m_temp_allocator, rCtxWorld.m_joltJobSystem.get()); } @@ -146,7 +146,7 @@ Ref SysJolt::create_primitive(ACtxJoltWorld &rCtxWorld, osp::EShape shape void SysJolt::scale_shape(Ref rShape, Vec3Arg scale) { if (rShape->GetSubType() == EShapeSubType::Scaled) { ScaledShape* rScaledShape = dynamic_cast(rShape.GetPtr()); - if (rScaledShape) + if (rScaledShape != nullptr) { rShape = new ScaledShape(rScaledShape->GetInnerShape(), scale * rScaledShape->GetScale()); } @@ -180,7 +180,7 @@ void SysJolt::find_shapes_recurse( ACompTransformStorage_t const& rTf, ActiveEnt ent, Matrix4 const& transform, - CompoundShapeSettings& pCompound) noexcept + CompoundShapeSettings& rCompound) noexcept { // Add jolt shape if exists if (rCtxWorld.m_shapes.contains(ent)) @@ -189,7 +189,7 @@ void SysJolt::find_shapes_recurse( // Set transform relative to root body SysJolt::scale_shape(rShape, Vec3MagnumToJolt(transform.scaling())); - pCompound.AddShape( + rCompound.AddShape( Vec3MagnumToJolt(transform.translation()), QuatMagnumToJolt(osp::Quaternion::fromMatrix(transform.rotation())), rShape); @@ -210,7 +210,7 @@ void SysJolt::find_shapes_recurse( Matrix4 const childMatrix = transform * rChildTransform.m_transform; find_shapes_recurse( - rCtxPhys, rCtxWorld, rScnGraph, rTf, child, childMatrix, pCompound); + rCtxPhys, rCtxWorld, rScnGraph, rTf, child, childMatrix, rCompound); } } @@ -220,10 +220,10 @@ void SysJolt::find_shapes_recurse( //TODO this is locking on all bodies. Is it bad ? //The easy fix is to provide multiple step listeners for disjoint sets of bodies, which can then run in parallel. //It might not be worth it considering this function should be quite fast. -void PhysicsStepListenerImpl::OnStep(float inDeltaTime, PhysicsSystem &rJoltWorld) +void PhysicsStepListenerImpl::OnStep(float inDeltaTime, PhysicsSystem &rPhysicsSystem) { //no lock as all bodies are already locked - BodyInterface &bodyInterface = rJoltWorld.GetBodyInterfaceNoLock(); + BodyInterface &bodyInterface = rPhysicsSystem.GetBodyInterfaceNoLock(); for (BodyId bodyId : m_context->m_bodyIds) { JPH::BodyID joltBodyId = BToJolt(bodyId); diff --git a/src/ospjolt/activescene/joltinteg_fn.h b/src/ospjolt/activescene/joltinteg_fn.h index 80ca224b..a1bcd469 100644 --- a/src/ospjolt/activescene/joltinteg_fn.h +++ b/src/ospjolt/activescene/joltinteg_fn.h @@ -90,7 +90,7 @@ class SysJolt } } //Apply a scale to a shape. - static void scale_shape(Ref rJoltShap, Vec3Arg scale); + static void scale_shape(Ref rShape, Vec3Arg scale); //Get the inverse mass of a jolt body static float get_inverse_mass_no_lock(PhysicsSystem& physicsSystem, BodyId bodyId); diff --git a/src/testapp/sessions/jolt.cpp b/src/testapp/sessions/jolt.cpp index 76d5d306..4e495e24 100644 --- a/src/testapp/sessions/jolt.cpp +++ b/src/testapp/sessions/jolt.cpp @@ -23,7 +23,6 @@ * SOFTWARE. */ #include "jolt.h" -#include "physics.h" #include "shapes.h" #include @@ -207,7 +206,7 @@ Session setup_phys_shapes_jolt( PhysicsSystem *pJoltWorld = rJolt.m_pPhysicsSystem.get(); BodyInterface &bodyInterface = pJoltWorld->GetBodyInterface(); - std::size_t numBodies = rPhysShapes.m_spawnRequest.size(); + int numBodies = static_cast(rPhysShapes.m_spawnRequest.size()); std::vector addedBodies; addedBodies.reserve(numBodies); @@ -517,8 +516,9 @@ Session setup_vehicle_spawn_jolt( itWeldOffsets = itWeldOffsetsNext; } //Bodies are added all at once for performance reasons. - BodyInterface::AddState addState = bodyInterface.AddBodiesPrepare(addedBodies.data(), addedBodies.size()); - bodyInterface.AddBodiesFinalize(addedBodies.data(), addedBodies.size(), addState, EActivation::Activate); + int numBodies = static_cast(addedBodies.size()); + BodyInterface::AddState addState = bodyInterface.AddBodiesPrepare(addedBodies.data(), numBodies); + bodyInterface.AddBodiesFinalize(addedBodies.data(), numBodies, addState, EActivation::Activate); }); return out;