/// <summary> /// Store beziers data /// </summary> /// <param name="data"></param> public void Serialize(VertexWarper.SerializeData data) { if (data == null) { return; } data.modifySilently = ModifySilently; data.y = Y; data.minX = MinX; data.maxX = MaxX; data.minZ = MinZ; data.maxZ = MaxZ; if (controlPoints == null || controlPoints.Length == 0) { data.controlPointsInfo = null; return; } data.controlPointsInfo = new Vector3[CONTROL_POINT_COUNT * Bezier.ControlPoint.PROPERTY_COUNT]; for (int i = 0; i < data.controlPointsInfo.Length; i += Bezier.ControlPoint.PROPERTY_COUNT) { data.controlPointsInfo[i] = controlPoints[i / Bezier.ControlPoint.PROPERTY_COUNT].Position; data.controlPointsInfo[i + 1] = controlPoints[i / Bezier.ControlPoint.PROPERTY_COUNT].Handles[0]; data.controlPointsInfo[i + 2] = controlPoints[i / Bezier.ControlPoint.PROPERTY_COUNT].Handles[1]; } }
/// <summary> /// Load saved beziers data /// </summary> /// <param name="data"></param> public void DeSerialize(VertexWarper.SerializeData data) { if (data == null || data.controlPointsInfo == null || data.controlPointsInfo.Length == 0) { return; } ModifySilently = data.modifySilently; Y = data.y; MinX = data.minX; MaxX = data.maxX; MinZ = data.minZ; MaxZ = data.maxZ; ApplyTemplate(data.controlPointsInfo); }