Skip to content

Commit 91fff0b

Browse files
Use simple pointer
1 parent 545303f commit 91fff0b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/engine/Physics.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ PhysicsWorld::PhysicsWorld(entt::registry &registry) {
298298
physicsSystem->OptimizeBroadPhase();
299299
bodyInterface = &physicsSystem->GetBodyInterface();
300300

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

326326
PhysicsWorld::~PhysicsWorld() {
327+
delete debugRenderer;
327328
for (auto id : bodies) {
328329
bodyInterface->RemoveBody(id);
329330
bodyInterface->DestroyBody(id);
@@ -640,12 +641,12 @@ void PhysicsWorld::rayPick(glm::vec3 origin, glm::vec3 direction, float maxDista
640641

641642
std::vector<std::pair<glm::vec3, glm::vec3>> PhysicsWorld::debugDraw() {
642643
#ifdef JPH_DEBUG_RENDERER
643-
((PhysicsDebugDrawer *)debugRenderer.get())->clear();
644+
((PhysicsDebugDrawer *)debugRenderer)->clear();
644645
BodyManager::DrawSettings settings;
645646
settings.mDrawBoundingBox = false;
646647
settings.mDrawVelocity = true;
647-
physicsSystem->DrawBodies(settings, debugRenderer.get());
648-
return ((PhysicsDebugDrawer *)debugRenderer.get())->lines();
648+
physicsSystem->DrawBodies(settings, debugRenderer);
649+
return ((PhysicsDebugDrawer *)debugRenderer)->lines();
649650
#else
650651
return {};
651652
#endif

src/engine/Physics.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class PhysicsWorld {
7878
float accumulator = 0.0f;
7979

8080
JPH::BodyInterface* bodyInterface = nullptr;
81-
std::unique_ptr<JPH::DebugRenderer> debugRenderer = nullptr;
81+
JPH::DebugRenderer* debugRenderer = nullptr;
8282

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

0 commit comments

Comments
 (0)