Fixed local physics orientation
This commit is contained in:
+1
-1
Submodule assets updated: 75977fd865...588da9ca0d
+6
-5
@@ -91,7 +91,7 @@ void GameWorld::Initialize()
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
//CreateTerrain();
|
||||
CreateTerrain();
|
||||
|
||||
#pragma region Wall_Debris_Template
|
||||
|
||||
@@ -301,8 +301,7 @@ void GameWorld::Initialize()
|
||||
EventBroker->Publish(e);
|
||||
}*/
|
||||
|
||||
CreateGarage(glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(), 1); // glm::vec3(0, glm::pi<float>()/2.f, 0)
|
||||
CreateGarage(glm::vec3(-323.2f, 41.4f, -10.2f), glm::quat(), 2); // glm::vec3(0, -glm::pi<float>()/2.f, 0)
|
||||
|
||||
|
||||
{
|
||||
auto flag = CreateEntity();
|
||||
@@ -866,7 +865,7 @@ EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int
|
||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||
auto rotate = AddComponent<Components::Rotate>(rightHatch);
|
||||
rotate->StartRotation = transform->Orientation;
|
||||
rotate->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1));
|
||||
rotate->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1));
|
||||
rotate->Time = 5.f;
|
||||
{
|
||||
auto shape = CreateEntity(rightHatch);
|
||||
@@ -1048,7 +1047,7 @@ void GameWorld::CreateTerrain()
|
||||
}
|
||||
|
||||
CreateBase(glm::quat());
|
||||
CreateBase(glm::quat(glm::vec3(0, glm::pi<float>()/2.f, 0)));
|
||||
CreateBase(glm::quat(glm::vec3(0, glm::pi<float>(), 0)));
|
||||
|
||||
{
|
||||
auto tree = CreateEntity();
|
||||
@@ -1219,4 +1218,6 @@ void GameWorld::CreateBase(glm::quat orientation)
|
||||
CommitEntity(groundshape);
|
||||
CommitEntity(road_small);
|
||||
}
|
||||
|
||||
CreateGarage(glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi<float>(), 0)), 1); // glm::vec3(0, glm::pi<float>()/2.f, 0)
|
||||
}
|
||||
@@ -180,6 +180,12 @@ void Systems::PhysicsSystem::Update(double dt)
|
||||
rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation);
|
||||
velocity = GLMVEC3_TO_HKVECTOR4(transformComponent->Velocity);
|
||||
}
|
||||
|
||||
/*auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
||||
position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position);
|
||||
rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation);
|
||||
velocity = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Velocity);*/
|
||||
|
||||
m_PhysicsWorld->markForWrite();
|
||||
m_RigidBodies[entity]->setPositionAndRotation(position, rotation);
|
||||
|
||||
@@ -268,17 +274,33 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
else if(m_RigidBodies.find(entity) != m_RigidBodies.end())
|
||||
{
|
||||
auto transformComponentParent = m_World->GetComponent<Components::Transform>(parent);
|
||||
|
||||
/* if(transformComponentParent)
|
||||
{
|
||||
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
|
||||
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||
transformComponent->Orientation = glm::inverse(HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation())) * absoluteTransformParent.Orientation;
|
||||
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto transformComponentParent = m_World->GetComponent<Components::Transform>(parent);
|
||||
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
||||
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||
}*/
|
||||
|
||||
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
||||
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||
// TODO: No support for Scale, MIGHT be possible
|
||||
|
||||
// HACK: WTF IS THIS?
|
||||
if (transformComponentParent)
|
||||
{
|
||||
transformComponent->Position -= transformComponentParent->Position;
|
||||
transformComponent->Position = transformComponent->Position * transformComponentParent->Orientation;
|
||||
transformComponent->Orientation = transformComponent->Orientation * glm::inverse(transformComponentParent->Orientation);
|
||||
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
|
||||
transformComponent->Position -= absoluteTransformParent.Position;
|
||||
transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation;
|
||||
transformComponent->Orientation = absoluteTransformParent.Orientation * glm::inverse(transformComponent->Orientation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
||||
if(m_MoveItems.find(entity) != m_MoveItems.end())
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
|
||||
glm::vec3 direction = glm::normalize(m_MoveItems[entity].GoalPosition - transform->Position);
|
||||
glm::vec3 movement = direction * m_MoveItems[entity].Speed * (float)dt;
|
||||
|
||||
@@ -54,6 +54,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
||||
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
auto absolutetransform = AbsoluteTransform(entity);
|
||||
|
||||
float percentage = dt/m_RotationItems[entity].Time;
|
||||
m_RotationItems[entity].Time -= dt;
|
||||
|
||||
Reference in New Issue
Block a user