From f8bbcdd909d60398faa98252fb3c0fe7f2fd9169 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sat, 12 Nov 2022 17:28:49 +0800 Subject: [PATCH] Small fixes --- Assets/Scenes/M2Scene.shade | 8 ++++---- .../src/Physics/PhysicsObject/SHPhysicsObject.cpp | 1 + .../src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp | 4 ++-- .../src/Physics/PhysicsObject/SHPhysicsObjectManager.h | 2 +- SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Assets/Scenes/M2Scene.shade b/Assets/Scenes/M2Scene.shade index b5edc743..0ca9eb31 100644 --- a/Assets/Scenes/M2Scene.shade +++ b/Assets/Scenes/M2Scene.shade @@ -4,7 +4,7 @@ NumberOfChildren: 0 Components: Camera Component: - Position: {x: 0, y: 0, z: 0} + Position: {x: 0, y: 0, z: 8} Pitch: 0 Yaw: 0 Roll: 0 @@ -233,9 +233,9 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: -4.49353218, y: 2.57871056, z: -5} - Rotate: {x: 0, y: 0, z: 0} - Scale: {x: 0.99998343, y: 0.999987662, z: 0.999981642} + Translate: {x: -4.40482807, y: 2.57871056, z: -5.21213436} + Rotate: {x: -0.361265004, y: 1.11661232, z: -0.626627684} + Scale: {x: 0.999982238, y: 0.999987125, z: 0.999981165} RigidBody Component: Type: Dynamic Mass: 1 diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp index d4668963..549f84cb 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp @@ -237,6 +237,7 @@ namespace SHADE case 9: // Mass { rp3dBody->setMass(component.mass); + rp3dBody->updateLocalCenterOfMassFromColliders(); rp3dBody->updateLocalInertiaTensorFromColliders(); break; diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp index 38a3c658..8a381fcb 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp @@ -37,9 +37,9 @@ namespace SHADE factory = &physicsFactory; } - void SHPhysicsObjectManager::SetWorld(rp3d::PhysicsWorld& physicsWorld) noexcept + void SHPhysicsObjectManager::SetWorld(rp3d::PhysicsWorld* physicsWorld) noexcept { - world = &physicsWorld; + world = physicsWorld; } /*-----------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.h b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.h index f796b723..91dcce5f 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.h +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.h @@ -84,7 +84,7 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ void SetFactory (rp3d::PhysicsCommon& physicsFactory) noexcept; - void SetWorld (rp3d::PhysicsWorld& physicsWorld) noexcept; + void SetWorld (rp3d::PhysicsWorld* physicsWorld) noexcept; /*---------------------------------------------------------------------------------*/ /* Function Members */ diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp index ad137ed4..93ee0b11 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp @@ -273,7 +273,7 @@ namespace SHADE collisionListener.BindToWorld(worldState.world); // Link with object manager & create all physics objects - objectManager.SetWorld(*worldState.world); + objectManager.SetWorld(worldState.world); const auto& RIGIDBODY_DENSE = SHComponentManager::GetDense(); const auto& COLLIDER_DENSE = SHComponentManager::GetDense(); @@ -291,6 +291,7 @@ namespace SHADE { // Remove all physics objects objectManager.RemoveAllObjects(); + objectManager.SetWorld(nullptr); // Clear all collision info // Collision listener is automatically unbound when world is destroyed