Merge branch 'main' into SP3-6-c-scripting

# Conflicts:
#	SHADE_Engine/src/Physics/SHPhysicsSystem.cpp
This commit is contained in:
Kah Wei 2022-11-01 00:12:51 +08:00
commit 76737a735a
3 changed files with 11 additions and 12 deletions

View File

@ -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>();

View File

@ -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)

View File

@ -19,8 +19,8 @@
#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
@ -326,33 +326,33 @@ 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();
// Collision & Trigger messages
auto scriptSys = SHSystemManager::GetSystem<SHScriptEngine>();