Merge pull request #147 from SHADE-DP/SP3-2-Physics
SP3-2 Relative Collider Size Bugfix BUGFIXES Fixed bug where collider size was wrongly displayed and set
This commit is contained in:
commit
ec9aa4bb6e
|
@ -128,7 +128,6 @@ namespace Sandbox
|
|||
floorRigidBody.SetType(SHRigidBodyComponent::Type::STATIC);
|
||||
|
||||
auto* floorBox = floorCollider.AddBoundingBox();
|
||||
floorBox->SetHalfExtents(floorTransform.GetWorldScale() * 0.5f);
|
||||
|
||||
// Create blank entity with a script
|
||||
//testObj = SHADE::SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
|
||||
|
|
|
@ -251,7 +251,7 @@ namespace SHADE
|
|||
SHEditorWidgets::DragVec3
|
||||
(
|
||||
"Half Extents", { "X", "Y", "Z" },
|
||||
[box, transformComponent] { return (transformComponent->GetWorldScale() * 2.0f) * box->GetHalfExtents(); },
|
||||
[box, transformComponent] { return (box->GetHalfExtents() * 2.0f) / transformComponent->GetWorldScale(); },
|
||||
[collider](SHVec3 const& vec) { collider->SetBoundingBox(vec); });
|
||||
}
|
||||
else if (collider->GetType() == SHCollider::Type::SPHERE)
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "Editor/SHEditor.h"
|
||||
#include "Math/SHMathHelpers.h"
|
||||
#include "Scene/SHSceneManager.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
#include "Scene/SHSceneManager.h"
|
||||
#include "Scripting/SHScriptEngine.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -325,38 +326,35 @@ namespace SHADE
|
|||
|
||||
void SHPhysicsSystem::PhysicsFixedUpdate::Execute(double dt) noexcept
|
||||
{
|
||||
auto* system = reinterpret_cast<SHPhysicsSystem*>(GetSystem());
|
||||
fixedTimeStep = 1.0 / system->fixedDT;
|
||||
auto* physicsSystem = reinterpret_cast<SHPhysicsSystem*>(GetSystem());
|
||||
|
||||
fixedTimeStep = 1.0 / physicsSystem->fixedDT;
|
||||
accumulatedTime += dt;
|
||||
|
||||
int count = 0;
|
||||
while (accumulatedTime > fixedTimeStep)
|
||||
{
|
||||
system->world->update(static_cast<rp3d::decimal>(fixedTimeStep));
|
||||
physicsSystem->world->update(static_cast<rp3d::decimal>(fixedTimeStep));
|
||||
|
||||
accumulatedTime -= fixedTimeStep;
|
||||
++count;
|
||||
}
|
||||
|
||||
stats.numSteps = count;
|
||||
system->worldUpdated = count > 0;
|
||||
physicsSystem->worldUpdated = count > 0;
|
||||
|
||||
system->interpolationFactor = accumulatedTime / fixedTimeStep;
|
||||
physicsSystem->interpolationFactor = accumulatedTime / fixedTimeStep;
|
||||
}
|
||||
|
||||
void SHPhysicsSystem::PhysicsPostUpdate::Execute(double) noexcept
|
||||
{
|
||||
auto* system = reinterpret_cast<SHPhysicsSystem*>(GetSystem());
|
||||
auto* physicsSystem = reinterpret_cast<SHPhysicsSystem*>(GetSystem());
|
||||
|
||||
// Interpolate transforms for rendering
|
||||
if (system->worldUpdated)
|
||||
{
|
||||
system->SyncTransforms();
|
||||
if (physicsSystem->worldUpdated)
|
||||
physicsSystem->SyncTransforms();
|
||||
|
||||
// TODO(Kah Wei): Take Collision & Trigger messages here
|
||||
|
||||
system->ClearInvalidCollisions();
|
||||
}
|
||||
physicsSystem->ClearInvalidCollisions();
|
||||
}
|
||||
|
||||
void SHPhysicsSystem::onContact(const CallbackData& callbackData)
|
||||
|
|
Loading…
Reference in New Issue