Oritentation fixed progress

This commit is contained in:
Antoine Pilote
2023-07-10 00:57:27 -04:00
parent 4141e2690b
commit 56858ab157
3 changed files with 20 additions and 15 deletions

View File

@@ -289,8 +289,16 @@ namespace Nuake
settings->mShape = GetJoltShape(cc->Shape);
settings->mGravityFactor = 0.0f;
auto& joltPos = JPH::Vec3(cc->Position.x, cc->Position.y, cc->Position.z);
JPH::Character* character = new JPH::Character(settings, joltPos, JPH::Quat::sIdentity(), cc->GetEntity().GetID() , _JoltPhysicsSystem.get());
auto& joltPosition = JPH::Vec3(cc->Position.x, cc->Position.y, cc->Position.z);
Quat& bodyRotation = cc->Rotation;
// We need to add 180 degrees because our forward is -Z.
const auto& yOffset = Vector3(0.0f, Rad(180.0), 0.0f);
bodyRotation = glm::normalize(bodyRotation * Quat(yOffset));
const auto& joltRotation = JPH::Quat(bodyRotation.x, bodyRotation.y, bodyRotation.z, bodyRotation.w);
JPH::Character* character = new JPH::Character(settings, joltPosition, joltRotation, cc->GetEntity().GetID() , _JoltPhysicsSystem.get());
character->AddToPhysicsSystem(JPH::EActivation::Activate);

View File

@@ -142,13 +142,6 @@ namespace Nuake {
{
auto [transform, camera, parent] = view.get<TransformComponent, CameraComponent, ParentComponent>(e);
cam = camera.CameraInstance;
cam->Translation = transform.GetGlobalPosition();
const Vector3& forward = QuatToDirection(transform.GetGlobalRotation());
cam->SetDirection(forward);
camTransform = transform.GetGlobalTransform();
break;
}
}

View File

@@ -1,13 +1,14 @@
#include "TransformSystem.h"
#include "src/Core/Maths.h"
#include "src/Scene/Scene.h"
#include <src/Scene/Components/TransformComponent.h>
#include <src/Scene/Components/CameraComponent.h>
#include <src/Scene/Components/ParentComponent.h>
#include "src/Vendors/glm/gtx/matrix_decompose.hpp"
namespace Nuake {
#include "src/Scene/Components/TransformComponent.h"
#include "src/Scene/Components/CameraComponent.h"
#include "src/Scene/Components/ParentComponent.h"
namespace Nuake
{
TransformSystem::TransformSystem(Scene* scene)
{
m_Scene = scene;
@@ -43,6 +44,9 @@ namespace Nuake {
Matrix4 cameraTransform = camera.CameraInstance->GetTransformRotation();
camera.CameraInstance->Translation = transform.GlobalTranslation;
// We need to invert forward direction since its -1.0f in nuake.
camera.CameraInstance->SetDirection(QuatToDirection(transform.GetGlobalRotation()));
}
// Calculate all local transforms