Пример #1
0
        /// <summary>
        /// When transformation finished, register and do transformation action
        /// </summary>
        public static void EndTransformationData()
        {
            if (m_transformAction != null)
            {
                Vector3? snapMovement = null;
                foreach (MyEntity entity in SelectedEntities)
                {
                    Matrix rotation = entity.GetWorldRotation();

                    if (SnapEnabled)
                    {
                        Vector3 pos = entity.GetPosition();

                        if (snapMovement == null) // We snap only first entities
                        {
                            Vector3 oldPosition = pos;
                            SnapToGrid(ref pos, TranslationSnapValue);
                            snapMovement = pos - oldPosition;
                        }
                        else // We move other entites based only on movement of first entity
                        {
                            pos += snapMovement.Value;
                        }



                        if (!MyEditor.Static.IsLinked(entity))
                        {
                            entity.MoveAndRotate(pos, rotation);
                        }
                        else if (SelectedEntities.Count == 1)
                        {
                            List<MyEntity> temp = new List<MyEntity>();
                            entity.MoveAndRotate(pos, rotation);
                            MyEditor.Static.FixLinkedEntities(entity, temp, null);
                        }
                    }

                    MyEditorTransformData data = new MyEditorTransformData(entity, entity.GetPosition(), entity.GetWorldRotation());
                    m_transformAction.AddEndData(data);
                }

                m_transformAction.RegisterAndDoAction();
                m_transformAction = null;
            }
            m_gizmoStartRotation = null;
        }
Пример #2
0
        /// <summary>
        /// When transformation starts, prepare transformation action data
        /// </summary>
        public static void StartTransformationData()
        {

            m_gizmoStartRotation = m_gizmoWorld;

            m_transformAction = new MyEditorActionEntityTransform();
            foreach (MyEntity entity in SelectedEntities)
            {
                MyEditorTransformData data = new MyEditorTransformData(entity, entity.GetPosition(), entity.GetWorldRotation());
                m_transformAction.AddStartData(data);
            }
        }