public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
        {
            var old = base.GetObjectBuilder(copy);
            var ob  = old as MyObjectBuilder_FracturedPiece;

            foreach (var def in OriginalBlocks)
            {
                ob.BlockDefinitions.Add(def);
            }
            if (Physics == null)
            {
                Debug.Assert(m_shapes.Count > 0, "Saving invalid piece!");
                foreach (var shape in m_shapes)
                {
                    ob.Shapes.Add(new MyObjectBuilder_FracturedPiece.Shape()
                    {
                        Name = shape.Name, Orientation = shape.Orientation
                    });
                }
                return(ob);
            }
            if (Physics.BreakableBody.BreakableShape.IsCompound() || string.IsNullOrEmpty(Physics.BreakableBody.BreakableShape.Name))
            {
                Physics.BreakableBody.BreakableShape.GetChildren(m_children);
                if (m_children.Count == 0)
                {
                    Debug.Fail("Saiving invalid piece!");
                    return(ob);
                }
                foreach (var child in m_children)
                {
                    var shape = new MyObjectBuilder_FracturedPiece.Shape()
                    {
                        Name        = child.ShapeName,
                        Orientation = Quaternion.CreateFromRotationMatrix(child.GetTransform().GetOrientation()),
                        Fixed       = MyDestructionHelper.IsFixed(child.Shape)
                    };
                    ob.Shapes.Add(shape);
                }

                if (Physics.IsInWorld)
                {
                    var fixedPosition = Physics.ClusterToWorld(Vector3.Transform(m_children[0].GetTransform().Translation, Physics.RigidBody.GetRigidBodyMatrix()));
                    var posOr         = ob.PositionAndOrientation.Value;
                    posOr.Position            = fixedPosition;
                    ob.PositionAndOrientation = posOr;
                }
                m_children.Clear();
            }
            else
            {
                ob.Shapes.Add(new MyObjectBuilder_FracturedPiece.Shape()
                {
                    Name = Physics.BreakableBody.BreakableShape.Name
                });
            }
            Debug.Assert(ob.Shapes.Count > 0, "Saiving invalid piece!");
            return(ob);
        }
        public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
        {
            var old = base.GetObjectBuilder(copy);
            var ob = old as MyObjectBuilder_FracturedPiece;
            foreach (var def in OriginalBlocks)
                ob.BlockDefinitions.Add(def);
            if (Physics == null)
            {
                Debug.Assert(m_shapes.Count > 0, "Saving invalid piece!");
                foreach (var shape in m_shapes)
                    ob.Shapes.Add(new MyObjectBuilder_FracturedPiece.Shape() { Name = shape.Name, Orientation = shape.Orientation });
                return ob;
            }

            if (Physics.BreakableBody.BreakableShape.IsCompound() || string.IsNullOrEmpty(Physics.BreakableBody.BreakableShape.Name))
            {
                Physics.BreakableBody.BreakableShape.GetChildren(m_children);
                if (m_children.Count == 0)
                {
                    Debug.Fail("Saiving invalid piece!");
                    return ob;
                }

                int childrenCount = m_children.Count;
                for (int i=0; i<childrenCount; ++i)
                {
                    var child = m_children[i];
                    if (string.IsNullOrEmpty(child.ShapeName))
                    {
                        child.GetChildren(m_children);
                    }
                }

                foreach (var child in m_children)
                {
                    var shapeName = child.ShapeName;
                    if (string.IsNullOrEmpty(shapeName))
                        continue;

                    var shape = new MyObjectBuilder_FracturedPiece.Shape()
                    {
                        Name = shapeName,
                        Orientation = Quaternion.CreateFromRotationMatrix(child.GetTransform().GetOrientation()),
                        Fixed = MyDestructionHelper.IsFixed(child.Shape)
                    };
                    ob.Shapes.Add(shape);
                }

                if (Physics.IsInWorld)
                {
                    var fixedPosition = Physics.ClusterToWorld(Vector3.Transform(m_children[0].GetTransform().Translation, Physics.RigidBody.GetRigidBodyMatrix()));
                    var posOr = ob.PositionAndOrientation.Value;
                    posOr.Position = fixedPosition;
                    ob.PositionAndOrientation = posOr;
                }
                m_children.Clear();
            }
            else
            {
                ob.Shapes.Add(new MyObjectBuilder_FracturedPiece.Shape() { Name = Physics.BreakableBody.BreakableShape.Name });
            }
            Debug.Assert(ob.Shapes.Count > 0, "Saiving invalid piece!");
            return ob;
        }