Skip to content
Permalink
Browse files

[Assets] Remove asset upgrader code for versions before 3.0

  • Loading branch information
xen2 committed Jan 27, 2019
1 parent aad3c75 commit 0521c0d066d005bde496ffe9ab656374e2a51f33
Showing with 9 additions and 1,435 deletions.
  1. +0 −49 sources/assets/Xenko.Core.Assets/AssetComposite.cs
  2. +0 −26 sources/assets/Xenko.Core.Assets/AssetCompositeHierarchy.Upgraders.cs
  3. +0 −18 sources/engine/Xenko.Assets.Models/AnimationAsset.Upgrader.cs
  4. +0 −5 sources/engine/Xenko.Assets.Models/AnimationAsset.cs
  5. +0 −5 sources/engine/Xenko.Assets.Models/ModelAsset.cs
  6. +0 −5 sources/engine/Xenko.Assets.Models/PrefabModelAsset.cs
  7. +0 −155 sources/engine/Xenko.Assets.Models/ProceduralModelAsset.cs
  8. +0 −5 sources/engine/Xenko.Assets.Models/SkeletonAsset.cs
  9. +0 −46 sources/engine/Xenko.Assets/Entities/EntityHierarchyAssetBase.Upgraders.cs
  10. +1 −9 sources/engine/Xenko.Assets/Entities/PrefabAsset.cs
  11. +0 −20 sources/engine/Xenko.Assets/Entities/SceneAsset.Upgraders.cs
  12. +1 −10 sources/engine/Xenko.Assets/Entities/SceneAsset.cs
  13. +1 −58 sources/engine/Xenko.Assets/GameSettingsAsset.cs
  14. +0 −5 sources/engine/Xenko.Assets/Materials/MaterialAsset.cs
  15. +0 −5 sources/engine/Xenko.Assets/Media/SoundAsset.cs
  16. +0 −5 sources/engine/Xenko.Assets/Navigation/NavigationMeshAsset.cs
  17. +0 −5 sources/engine/Xenko.Assets/Physics/ColliderShapeAsset.cs
  18. +1 −23 sources/engine/Xenko.Assets/Rendering/GraphicsCompositorAsset.cs
  19. +0 −22 sources/engine/Xenko.Assets/Skyboxes/SkyboxAsset.cs
  20. +0 −50 sources/engine/Xenko.Assets/Sprite/SpriteSheetAsset.cs
  21. +1 −27 sources/engine/Xenko.Assets/SpriteFont/PrecompiledSpriteFontAsset.cs
  22. +0 −5 sources/engine/Xenko.Assets/SpriteFont/SpriteFontAsset.cs
  23. +0 −5 sources/engine/Xenko.Assets/Textures/RenderTextureAsset.cs
  24. +0 −72 sources/engine/Xenko.Assets/Textures/TextureAsset.cs
  25. +1 −8 sources/engine/Xenko.Assets/UI/UILibraryAsset.cs
  26. +1 −8 sources/engine/Xenko.Assets/UI/UIPageAsset.cs
  27. +0 −41 sources/engine/Xenko.Assets/XenkoPackageUpgrader.NamespaceRenaming.cs
  28. +1 −732 sources/engine/Xenko.Assets/XenkoPackageUpgrader.cs
  29. +0 −5 sources/engine/Xenko.SpriteStudio.Offline/SpriteStudioAnimationAsset.cs
  30. +0 −5 sources/engine/Xenko.SpriteStudio.Offline/SpriteStudioModelAsset.cs
  31. +1 −1 sources/targets/Xenko.GlobalSettings.targets
@@ -20,54 +20,5 @@ public abstract class AssetComposite : Asset, IAssetComposite
public abstract IIdentifiable FindPart(Guid partId);

public abstract bool ContainsPart(Guid id);

public class FixPartReferenceUpgrader : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
var rootNode = (YamlNode)asset.Node;

var allScalarNodes = rootNode.AllNodes.OfType<YamlScalarNode>().ToList();

var nextIsId = false;
var inPublicUIElements = false;
foreach (var node in allScalarNodes)
{
var indexFirstSlash = node.Value.IndexOf('/');
Guid targetGuid = Guid.Empty;
if (indexFirstSlash == -1)
{
Guid.TryParseExact(node.Value, "D", out targetGuid);
}
else
{
Guid entityGuid;
if (Guid.TryParseExact(node.Value.Substring(0, indexFirstSlash), "D", out entityGuid))
{
Guid.TryParseExact(node.Value.Substring(indexFirstSlash + 1), "D", out targetGuid);
}
}

if (targetGuid != Guid.Empty && !nextIsId && !inPublicUIElements)
{
node.Value = "ref!! " + targetGuid;
}
else
{
if (nextIsId && targetGuid == Guid.Empty)
nextIsId = false;

if (inPublicUIElements && node.Value == "Hierarchy")
inPublicUIElements = false;

if (node.Value.Contains("Id"))
nextIsId = true;

if (node.Value == "PublicUIElements")
inPublicUIElements = true;
}
}
}
}
}
}

This file was deleted.

This file was deleted.

@@ -22,12 +22,7 @@ namespace Xenko.Assets.Models
[AssetDescription(FileExtension)]
[AssetContentType(typeof(AnimationClip))]
[Display((int)AssetDisplayPriority.Models + 20, "Animation")]
#if XENKO_SUPPORT_BETA_UPGRADE
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "1.10.0-alpha01")]
[AssetUpgrader(XenkoConfig.PackageName, "1.10.0-alpha01", "2.0.0.0", typeof(EmptyAssetUpgrader))]
#else
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "2.0.0.0")]
#endif
public class AnimationAsset : Asset, IAssetWithSource
{
private const string CurrentVersion = "2.0.0.0";
@@ -16,12 +16,7 @@ namespace Xenko.Assets.Models
[AssetDescription(FileExtension, AllowArchetype = true)]
[AssetContentType(typeof(Model))]
[Display((int)AssetDisplayPriority.Models + 80, "Model")]
#if XENKO_SUPPORT_BETA_UPGRADE
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "1.5.0-alpha02")]
[AssetUpgrader(XenkoConfig.PackageName, "1.5.0-alpha02", "2.0.0.0", typeof(EmptyAssetUpgrader))]
#else
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "2.0.0.0")]
#endif
public sealed class ModelAsset : Asset, IAssetWithSource, IModelAsset
{
private const string CurrentVersion = "2.0.0.0";
@@ -15,12 +15,7 @@ namespace Xenko.Assets.Models
[AssetDescription(FileExtension)]
[AssetContentType(typeof(Model))]
[Display((int)AssetDisplayPriority.Models + 60, "Prefab model")]
#if XENKO_SUPPORT_BETA_UPGRADE
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "0.0.0")]
[AssetUpgrader(XenkoConfig.PackageName, "0.0.0", "2.0.0.0", typeof(EmptyAssetUpgrader))]
#else
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "2.0.0.0")]
#endif
public sealed class PrefabModelAsset : Asset, IModelAsset
{
private const string CurrentVersion = "2.0.0.0";
@@ -22,12 +22,7 @@ namespace Xenko.Assets.Models
[AssetDescription(FileExtension)]
[AssetContentType(typeof(Model))]
[Display((int)AssetDisplayPriority.Models + 40, "Procedural model")]
#if XENKO_SUPPORT_BETA_UPGRADE
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "1.9.0-beta01")]
[AssetUpgrader(XenkoConfig.PackageName, "1.9.0-beta01", "2.0.0.0", typeof(EmptyAssetUpgrader))]
#else
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "2.0.0.0")]
#endif
public sealed class ProceduralModelAsset : Asset, IModelAsset
{
private const string CurrentVersion = "2.0.0.0";
@@ -50,155 +45,5 @@ public sealed class ProceduralModelAsset : Asset, IModelAsset
/// <inheritdoc/>
[DataMemberIgnore]
public List<ModelMaterial> Materials => Type.MaterialInstances.Select(x => new ModelMaterial { Name = x.Key, MaterialInstance = x.Value }).ToList();

private class Upgrader : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
// Introduction of MaterialInstance
var material = asset.Type.Material;
if (material != null)
{
asset.Type.MaterialInstance = new YamlMappingNode();
asset.Type.MaterialInstance.Material = material;
asset.Type.Material = DynamicYamlEmpty.Default;
}
var type = asset.Type.Node as YamlMappingNode;
if (type != null && type.Tag == "!CubeProceduralModel")
{
// Size changed from scalar to vector3
var size = asset.Type.Size as DynamicYamlScalar;
if (size != null)
{
var vecSize = new YamlMappingNode
{
{ new YamlScalarNode("X"), new YamlScalarNode(size.Node.Value) },
{ new YamlScalarNode("Y"), new YamlScalarNode(size.Node.Value) },
{ new YamlScalarNode("Z"), new YamlScalarNode(size.Node.Value) }
};
vecSize.Style = DataStyle.Compact;
asset.Type.Size = vecSize;
}
}
}
}

class RenameCapsuleHeight : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
var proceduralType = asset.Type;
if (proceduralType.Node.Tag == "!CapsuleProceduralModel" && proceduralType.Height != null)
{
proceduralType.Length = 2f * (float)proceduralType.Height;
proceduralType.Height = DynamicYamlEmpty.Default;
}
}
}

class RenameDiameters : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
var proceduralType = asset.Type;
if (proceduralType.Diameter != null)
{
proceduralType.Radius = 0.5f * (float)proceduralType.Diameter;
proceduralType.Diameter = DynamicYamlEmpty.Default;
}
if (proceduralType.Node.Tag == "!TorusProceduralModel" && proceduralType.Thickness != null)
{
proceduralType.Thickness = 0.5f * (float)proceduralType.Thickness;
}
}
}

class Standardization : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
var proceduralType = asset.Type;

if (proceduralType.ScaleUV != null)
{
var currentScale = (float)proceduralType.ScaleUV;

var vecSize = new YamlMappingNode
{
{ new YamlScalarNode("X"), new YamlScalarNode(currentScale.ToString(CultureInfo.InvariantCulture)) },
{ new YamlScalarNode("Y"), new YamlScalarNode(currentScale.ToString(CultureInfo.InvariantCulture)) }
};
vecSize.Style = DataStyle.Compact;

proceduralType.RemoveChild("ScaleUV");

proceduralType.UvScale = vecSize;
}
else if (proceduralType.UVScales != null)
{
var x = (float)proceduralType.UVScales.X;
var y = (float)proceduralType.UVScales.Y;

var vecSize = new YamlMappingNode
{
{ new YamlScalarNode("X"), new YamlScalarNode(x.ToString(CultureInfo.InvariantCulture)) },
{ new YamlScalarNode("Y"), new YamlScalarNode(y.ToString(CultureInfo.InvariantCulture)) }
};
vecSize.Style = DataStyle.Compact;

proceduralType.RemoveChild("UVScales");

proceduralType.UvScale = vecSize;
}
else
{
var vecSize = new YamlMappingNode
{
{ new YamlScalarNode("X"), new YamlScalarNode("1") },
{ new YamlScalarNode("Y"), new YamlScalarNode("1") }
};
vecSize.Style = DataStyle.Compact;

proceduralType.UvScale = vecSize;
}
}
}

class CapsuleRadiusDefaultChange : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
// SerializedVersion format changed during renaming upgrade. However, before this was merged back in master, some asset upgrader still with older version numbers were developed.
// However since this upgrader can be reapplied, it is not a problem
var proceduralType = asset.Type;
if (proceduralType.Node.Tag == "!CapsuleProceduralModel" && currentVersion != PackageVersion.Parse("0.0.6"))
{
if (proceduralType.Radius == null)
{
proceduralType.Radius = 0.25f;
}
}
}
}

class ConeOffsetChange : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
// SerializedVersion format changed during renaming upgrade. However, before this was merged back in master, some asset upgrader still with older version numbers were developed.
var proceduralType = asset.Type;
if (proceduralType.Node.Tag == "!ConeProceduralModel" && currentVersion != PackageVersion.Parse("0.0.6"))
{
if (proceduralType.LocalOffset == null)
{
dynamic offset = new DynamicYamlMapping(new YamlMappingNode());
offset.AddChild("X", 0.0f);
offset.AddChild("Y", 0.5f);
offset.AddChild("Z", 0.0f);
proceduralType.AddChild("LocalOffset", offset);
}
}
}
}
}
}
@@ -17,12 +17,7 @@ namespace Xenko.Assets.Models
[AssetDescription(FileExtension, AllowArchetype = false)]
[AssetContentType(typeof(Skeleton))]
[Display((int)AssetDisplayPriority.Models, "Skeleton", "A skeleton (node hierarchy)")]
#if XENKO_SUPPORT_BETA_UPGRADE
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "1.7.8-beta")]
[AssetUpgrader(XenkoConfig.PackageName, "1.7.8-beta", "2.0.0.0", typeof(EmptyAssetUpgrader))]
#else
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "2.0.0.0")]
#endif
public class SkeletonAsset : Asset, IAssetWithSource
{
private const string CurrentVersion = "2.0.0.0";
@@ -12,52 +12,6 @@ namespace Xenko.Assets.Entities
{
partial class EntityHierarchyAssetBase
{
/// <summary>
/// Moves Group from Entity to inside components (for those that support it)
/// </summary>
protected class MoveRenderGroupInsideComponentUpgrader : AssetUpgraderBase
{
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
{
var hierarchy = asset.Hierarchy;
var entities = (DynamicYamlArray)hierarchy.Parts;
foreach (dynamic entityDesign in entities)
{
var entity = entityDesign.Entity;

// Check if entity has a group (otherwise nothing to do
var group = entity.Group;
if (group == null)
continue;

// Save override and remove old element
var groupOverride = entity.GetOverride("Group");
entity.RemoveChild("Group");

foreach (var component in entity.Components)
{
try
{
var componentTag = component.Value.Node.Tag;
if (componentTag == "!ModelComponent"
|| componentTag == "!SpriteComponent" || componentTag == "!UIComponent"
|| componentTag == "!BackgroundComponent" || componentTag == "!SkyboxComponent"
|| componentTag == "!ParticleSystemComponent"
|| componentTag == "!SpriteStudioComponent")
{
component.Value.RenderGroup = group;
component.Value.SetOverride("RenderGroup", groupOverride);
}
}
catch (Exception e)
{
e.Ignore();
}
}
}
}
}

/// <summary>
/// Updates the Gravity field on all CharacterComponents in a SceneAsset from float to Vector3 to support three-dimensional gravity.
/// </summary>
@@ -14,15 +14,7 @@ namespace Xenko.Assets.Entities
[DataContract("PrefabAsset")]
[AssetDescription(FileExtension, AllowArchetype = false)]
[AssetContentType(typeof(Prefab))]
#if XENKO_SUPPORT_BETA_UPGRADE
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "1.9.0-beta05")]
[AssetUpgrader(XenkoConfig.PackageName, "1.9.0-beta05", "1.10.0-beta01", typeof(MoveRenderGroupInsideComponentUpgrader))]
[AssetUpgrader(XenkoConfig.PackageName, "1.10.0-beta01", "1.10.0-beta02", typeof(FixPartReferenceUpgrader))]
[AssetUpgrader(XenkoConfig.PackageName, "1.10.0-beta02", "2.0.0.0", typeof(EmptyAssetUpgrader))]
#else
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "2.0.0.0")]
#endif
[AssetUpgrader(XenkoConfig.PackageName, "2.0.0.0", "2.1.0.1", typeof(RootPartIdsToRootPartsUpgrader))]
[AssetFormatVersion(XenkoConfig.PackageName, CurrentVersion, "2.1.0.1")]
[AssetUpgrader(XenkoConfig.PackageName, "2.1.0.1", "3.1.0.1", typeof(CharacterComponentGravityVector3Upgrader))]
public partial class PrefabAsset : EntityHierarchyAssetBase
{

0 comments on commit 0521c0d

Please sign in to comment.
You can’t perform that action at this time.