From def4322fd05e667e96d5118cba6dbfde4c85a8e0 Mon Sep 17 00:00:00 2001 From: Pravus Date: Fri, 8 Dec 2023 13:11:17 +0100 Subject: [PATCH] corrected entity transformations sbc check order --- .../Transform/Handler/ECSTransformHandler.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/Transform/Handler/ECSTransformHandler.cs b/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/Transform/Handler/ECSTransformHandler.cs index 213dff1207..aebf046a9d 100644 --- a/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/Transform/Handler/ECSTransformHandler.cs +++ b/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/Transform/Handler/ECSTransformHandler.cs @@ -67,25 +67,25 @@ public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity) public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, ECSTransform model) { - bool positionChange = false; Transform transform = entity.gameObject.transform; + bool positionChange = transform.localPosition != model.position; + bool scaleChange = transform.localScale != model.scale; + bool rotationChange = transform.localRotation != model.rotation; + transform.localPosition = model.position; transform.localRotation = model.rotation; transform.localScale = model.scale; if (entity.parentId != model.parentId) { - // reparenting may end up changing the entity's position... Vector3 previousGlobalPosition = transform.position; ProcessNewParent(scene, entity, model.parentId); - positionChange = transform.position != previousGlobalPosition; - } - if (!positionChange) - positionChange = transform.localPosition != model.position; - bool scaleChange = transform.localScale != model.scale; - bool rotationChange = transform.localRotation != model.rotation; + // reparenting may end up changing the entity's position... + if (!positionChange) + positionChange = transform.position != previousGlobalPosition; + } if (positionChange) sbcInternalComponent.SetPosition(scene, entity, transform.position);