mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Oritentation fixed progress
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user