Sdk/PhysicsSystem3D: Fix CollisionComponent3D teleportating causing velocity increase in physical objects

This commit is contained in:
Lynix 2018-01-14 18:05:29 +01:00
parent e9cba3ab6c
commit 78c2e06b58
1 changed files with 12 additions and 0 deletions

View File

@ -60,6 +60,18 @@ namespace Ndk
{
m_dynamicObjects.Remove(entity);
m_staticObjects.Insert(entity);
// If entities just got added to the system, teleport them to their NodeComponent position/rotation
// This will prevent the physics engine to mess with the scene while correcting position/rotation
if (justAdded)
{
auto& collision = entity->GetComponent<CollisionComponent3D>();
auto& node = entity->GetComponent<NodeComponent>();
Nz::RigidBody3D* physObj = collision.GetStaticBody();
physObj->SetPosition(node.GetPosition());
physObj->SetRotation(node.GetRotation());
}
}
if (!m_world)