From 96a561798c1e168b120d3e412f7737a6435be8bf Mon Sep 17 00:00:00 2001 From: dexy Date: Thu, 31 Oct 2019 19:01:06 +1100 Subject: [PATCH] Fix for MLO Instance rotations --- CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs | 15 +++++++++++---- Project/Panels/EditYmapEntityPanel.cs | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs index 55aa92e..119d886 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs @@ -1489,15 +1489,22 @@ namespace CodeWalker.GameFiles } else { - Quaternion inv = inverse ? ori : Quaternion.Normalize(Quaternion.Invert(ori)); - ori = inverse ? Quaternion.Normalize(Quaternion.Invert(ori)) : ori; - Orientation = ori; - _CEntityDef.rotation = inv.ToVector4(); + Orientation = inverse ? Quaternion.Normalize(Quaternion.Invert(ori)) : ori; + if (MloInstance != null) + { + _CEntityDef.rotation = Orientation.ToVector4(); + } + else + { + Quaternion inv = inverse ? ori : Quaternion.Normalize(Quaternion.Invert(ori)); + _CEntityDef.rotation = inv.ToVector4(); + } } if (MloInstance != null) { MloInstance.SetOrientation(ori); + MloInstance.UpdateEntities(); } if (Archetype != null) diff --git a/Project/Panels/EditYmapEntityPanel.cs b/Project/Panels/EditYmapEntityPanel.cs index ecb394f..bd1f447 100644 --- a/Project/Panels/EditYmapEntityPanel.cs +++ b/Project/Panels/EditYmapEntityPanel.cs @@ -408,7 +408,8 @@ namespace CodeWalker.Project.Panels } else { - CurrentEntity.SetOrientation(q, true); + bool useInverse = (CurrentEntity.MloInstance == null); + CurrentEntity.SetOrientation(q, useInverse); } ProjectItemChanged();