Skip to content

Commit

Permalink
Fix submodule path and some clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamakaio committed Jun 16, 2024
1 parent 036c9c5 commit a4617ea
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ out/
.vs/
build/
.vscode/
.cache
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 1 addition & 8 deletions src/ospjolt/activescene/joltinteg.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,18 @@ JPH_SUPPRESS_WARNINGS

#include <Jolt/RegisterTypes.h>
#include <Jolt/Core/Factory.h>
#include <Jolt/Core/TempAllocator.h>
#include <Jolt/Core/JobSystemThreadPool.h>
#include <Jolt/Physics/PhysicsSettings.h>
#include <Jolt/Physics/PhysicsSystem.h>
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
#include <Jolt/Physics/Collision/Shape/CylinderShape.h>
#include <Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h>
#include <Jolt/Physics/Body/BodyCreationSettings.h>
#include <Jolt/Physics/Body/BodyActivationListener.h>
#include <Jolt/Core/TempAllocator.h>
#include <Jolt/Physics/Collision/Shape/CompoundShape.h>
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
#include <Jolt/Physics/Collision/Shape/MutableCompoundShape.h>
#include <Jolt/Physics/PhysicsStepListener.h>
#include <Jolt/Core/JobSystemSingleThreaded.h>

JPH_SUPPRESS_WARNING_POP

Expand All @@ -65,10 +61,7 @@ JPH_SUPPRESS_WARNING_POP

#include <iostream>
#include <cstdarg>
#include <thread>
#include <osp/util/logging.h>
#include <concepts>
#include <typeindex>

#include "osp/core/strong_id.h"

Expand Down Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/ospjolt/activescene/joltinteg_fn.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Open Space Program
* Copyright © 2019-2020 Open Space Program Project
* Copyright © 2019-2024 Open Space Program Project
*
* MIT License
*
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -146,7 +146,7 @@ Ref<Shape> SysJolt::create_primitive(ACtxJoltWorld &rCtxWorld, osp::EShape shape
void SysJolt::scale_shape(Ref<Shape> rShape, Vec3Arg scale) {
if (rShape->GetSubType() == EShapeSubType::Scaled) {
ScaledShape* rScaledShape = dynamic_cast<ScaledShape*>(rShape.GetPtr());
if (rScaledShape)
if (rScaledShape != nullptr)
{
rShape = new ScaledShape(rScaledShape->GetInnerShape(), scale * rScaledShape->GetScale());
}
Expand Down Expand Up @@ -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))
Expand All @@ -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);
Expand All @@ -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);
}

}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ospjolt/activescene/joltinteg_fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SysJolt
}
}
//Apply a scale to a shape.
static void scale_shape(Ref<Shape> rJoltShap, Vec3Arg scale);
static void scale_shape(Ref<Shape> rShape, Vec3Arg scale);

//Get the inverse mass of a jolt body
static float get_inverse_mass_no_lock(PhysicsSystem& physicsSystem, BodyId bodyId);
Expand Down
8 changes: 4 additions & 4 deletions src/testapp/sessions/jolt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* SOFTWARE.
*/
#include "jolt.h"
#include "physics.h"
#include "shapes.h"

#include <osp/activescene/basic_fn.h>
Expand Down Expand Up @@ -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<int>(rPhysShapes.m_spawnRequest.size());

std::vector<JPH::BodyID> addedBodies;
addedBodies.reserve(numBodies);
Expand Down Expand Up @@ -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<int>(addedBodies.size());
BodyInterface::AddState addState = bodyInterface.AddBodiesPrepare(addedBodies.data(), numBodies);
bodyInterface.AddBodiesFinalize(addedBodies.data(), numBodies, addState, EActivation::Activate);
});

return out;
Expand Down

0 comments on commit a4617ea

Please sign in to comment.