Skip to content

Commit

Permalink
Use simple pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjaltesorgenfrei committed Feb 5, 2024
1 parent 545303f commit 91fff0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/engine/Physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ PhysicsWorld::PhysicsWorld(entt::registry &registry) {
physicsSystem->OptimizeBroadPhase();
bodyInterface = &physicsSystem->GetBodyInterface();

debugRenderer = std::make_unique<PhysicsDebugDrawer>();
debugRenderer = new PhysicsDebugDrawer();
// Setup up destructors for components
registry.on_destroy<PhysicsBody>().connect<&PhysicsWorld::onPhysicsBodyDestroyed>(this);
registry.on_destroy<CarPhysics>().connect<&PhysicsWorld::onCarPhysicsDestroyed>(this);
Expand All @@ -324,6 +324,7 @@ void PhysicsWorld::onCarPhysicsDestroyed(entt::registry &registry, entt::entity
}

PhysicsWorld::~PhysicsWorld() {
delete debugRenderer;
for (auto id : bodies) {
bodyInterface->RemoveBody(id);
bodyInterface->DestroyBody(id);
Expand Down Expand Up @@ -640,12 +641,12 @@ void PhysicsWorld::rayPick(glm::vec3 origin, glm::vec3 direction, float maxDista

std::vector<std::pair<glm::vec3, glm::vec3>> PhysicsWorld::debugDraw() {
#ifdef JPH_DEBUG_RENDERER
((PhysicsDebugDrawer *)debugRenderer.get())->clear();
((PhysicsDebugDrawer *)debugRenderer)->clear();
BodyManager::DrawSettings settings;
settings.mDrawBoundingBox = false;
settings.mDrawVelocity = true;
physicsSystem->DrawBodies(settings, debugRenderer.get());
return ((PhysicsDebugDrawer *)debugRenderer.get())->lines();
physicsSystem->DrawBodies(settings, debugRenderer);
return ((PhysicsDebugDrawer *)debugRenderer)->lines();
#else
return {};
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Physics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PhysicsWorld {
float accumulator = 0.0f;

JPH::BodyInterface* bodyInterface = nullptr;
std::unique_ptr<JPH::DebugRenderer> debugRenderer = nullptr;
JPH::DebugRenderer* debugRenderer = nullptr;

void addBody(entt::registry& registry, entt::entity entity, IDType bodyID);

Expand Down

0 comments on commit 91fff0b

Please sign in to comment.