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);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//CreateTerrain();
|
CreateTerrain();
|
||||||
|
|
||||||
#pragma region Wall_Debris_Template
|
#pragma region Wall_Debris_Template
|
||||||
|
|
||||||
@@ -301,8 +301,7 @@ void GameWorld::Initialize()
|
|||||||
EventBroker->Publish(e);
|
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();
|
auto flag = CreateEntity();
|
||||||
@@ -866,7 +865,7 @@ EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int
|
|||||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||||
auto rotate = AddComponent<Components::Rotate>(rightHatch);
|
auto rotate = AddComponent<Components::Rotate>(rightHatch);
|
||||||
rotate->StartRotation = transform->Orientation;
|
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;
|
rotate->Time = 5.f;
|
||||||
{
|
{
|
||||||
auto shape = CreateEntity(rightHatch);
|
auto shape = CreateEntity(rightHatch);
|
||||||
@@ -1048,7 +1047,7 @@ void GameWorld::CreateTerrain()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CreateBase(glm::quat());
|
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();
|
auto tree = CreateEntity();
|
||||||
@@ -1219,4 +1218,6 @@ void GameWorld::CreateBase(glm::quat orientation)
|
|||||||
CommitEntity(groundshape);
|
CommitEntity(groundshape);
|
||||||
CommitEntity(road_small);
|
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);
|
rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation);
|
||||||
velocity = GLMVEC3_TO_HKVECTOR4(transformComponent->Velocity);
|
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_PhysicsWorld->markForWrite();
|
||||||
m_RigidBodies[entity]->setPositionAndRotation(position, rotation);
|
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())
|
else if(m_RigidBodies.find(entity) != m_RigidBodies.end())
|
||||||
{
|
{
|
||||||
auto transformComponentParent = m_World->GetComponent<Components::Transform>(parent);
|
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->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||||
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
||||||
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||||
// TODO: No support for Scale, MIGHT be possible
|
|
||||||
|
|
||||||
// HACK: WTF IS THIS?
|
// HACK: WTF IS THIS?
|
||||||
if (transformComponentParent)
|
if (transformComponentParent)
|
||||||
{
|
{
|
||||||
transformComponent->Position -= transformComponentParent->Position;
|
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
|
||||||
transformComponent->Position = transformComponent->Position * transformComponentParent->Orientation;
|
transformComponent->Position -= absoluteTransformParent.Position;
|
||||||
transformComponent->Orientation = transformComponent->Orientation * glm::inverse(transformComponentParent->Orientation);
|
transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation;
|
||||||
|
transformComponent->Orientation = absoluteTransformParent.Orientation * glm::inverse(transformComponent->Orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
|||||||
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
||||||
{
|
{
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
auto absolutetransform = AbsoluteTransform(entity);
|
||||||
|
|
||||||
float percentage = dt/m_RotationItems[entity].Time;
|
float percentage = dt/m_RotationItems[entity].Time;
|
||||||
m_RotationItems[entity].Time -= dt;
|
m_RotationItems[entity].Time -= dt;
|
||||||
|
|||||||
Reference in New Issue
Block a user