Skip to content

Commit

Permalink
chore: make legacy by default (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia authored Nov 19, 2024
1 parent a9d30b1 commit 741e4e3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,16 @@ private void CreateAnimatorController(IGltfImport gltfImport, string directory)
AssetDatabase.Refresh();
}

private AnimationMethod GetAnimationMethod() =>
settings.buildTarget is BuildTarget.StandaloneWindows64 or BuildTarget.StandaloneOSX
? settings.AnimationMethod
: AnimationMethod.Legacy;
private AnimationMethod GetAnimationMethod()
{
if (entityDTO == null) return AnimationMethod.Legacy;
if (entityDTO.type.ToLower().Contains("emote")) return AnimationMethod.Mecanim;
if (settings.buildTarget is BuildTarget.StandaloneWindows64 or BuildTarget.StandaloneOSX)
return settings.AnimationMethod;

//WebGL platform fallback is always Legacy
return AnimationMethod.Legacy;
}

private void ExtractEmbedMaterialsFromGltf(List<Texture2D> textures, GltfImportSettings gltf, IGltfImport gltfImport, string gltfUrl)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using AssetBundleConverter.Persistence;
using System;
using System.Linq;
using System.Threading.Tasks;
using AssetBundleConverter.Persistence;
using DCL.ABConverter;
using GLTFast;
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Random = UnityEngine.Random;

namespace AssetBundleConverter
{
Expand Down Expand Up @@ -89,7 +90,7 @@ private void OnEnable()
xCoord = PersistentSetting.CreateInt(nameof(xCoord), -110);
yCoord = PersistentSetting.CreateInt(nameof(yCoord), -110);
buildPipelineType = PersistentSetting.CreateEnum(nameof(buildPipelineType), BuildPipelineType.Scriptable);
animationMehtod = PersistentSetting.CreateEnum(nameof(animationMehtod), AnimationMethod.Mecanim);
animationMehtod = PersistentSetting.CreateEnum(nameof(animationMehtod), AnimationMethod.Legacy);
buildTarget = PersistentSetting.CreateEnum(nameof(buildTarget), SupportedBuildTarget.WebGL);
failingConversionTolerance = PersistentSetting.CreateFloat(nameof(failingConversionTolerance), 0.05f); // 5%
downloadBatchSize = PersistentSetting.CreateInt(nameof(downloadBatchSize), 20);
Expand Down Expand Up @@ -288,8 +289,8 @@ private async Task RenderRandomPointerAsync()

try
{
int x = UnityEngine.Random.Range(-150, 151);
int y = UnityEngine.Random.Range(-150, 151);
int x = Random.Range(-150, 151);
int y = Random.Range(-150, 151);

Debug.Log($"Converting {x},{y}");
var targetPosition = new Vector2Int(x, y);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;
using DCL.ABConverter;
using GLTFast;
using System.IO;
using UnityEditor;
using UnityEngine;

Expand All @@ -23,7 +23,7 @@ public class ClientSettings
/// <summary>
/// animation method used to force the legacy animation system or not from CLI
/// </summary>
public AnimationMethod AnimationMethod = AnimationMethod.Mecanim;
public AnimationMethod AnimationMethod = AnimationMethod.Legacy;

/// <summary>
/// if set to true, when conversion finishes, the working folder containing all downloaded assets will be deleted
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using AssetBundleConverter;
using AssetBundleConverter.Wearables;
using GLTFast;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AssetBundleConverter;
using AssetBundleConverter.Wearables;
using GLTFast;
using UnityEditor;
using UnityEngine;
using Environment = AssetBundleConverter.Environment;
Expand Down Expand Up @@ -76,7 +75,7 @@ public static void ExportWearablesCollectionToAssetBundles()
/// Start the scene conversion process with the given commandLineArgs.
/// </summary>
/// <param name="commandLineArgs">An array with the command line arguments.</param>
/// <exception cref="ArgumentException">When an invalid argument is passed</exception>
/// <exception cref="System.ArgumentException">When an invalid argument is passed</exception>
public async static void ExportSceneToAssetBundles(string[] commandLineArgs, ClientSettings settings = default)
{
settings ??= new ClientSettings();
Expand Down Expand Up @@ -173,7 +172,7 @@ public async static void ExportSceneToAssetBundles(string[] commandLineArgs, Cli
/// Start the wearables collection conversion process with the given commandLineArgs.
/// </summary>
/// <param name="commandLineArgs">An array with the command line arguments.</param>
/// <exception cref="ArgumentException">When an invalid argument is passed</exception>
/// <exception cref="System.ArgumentException">When an invalid argument is passed</exception>
public static async void ExportWearablesCollectionToAssetBundles(string[] commandLineArgs)
{
ClientSettings settings = new ClientSettings();
Expand Down Expand Up @@ -243,7 +242,8 @@ private static void ParseCommonSettings(string[] commandLineArgs, ClientSettings
{
var animMethod = animationMethod[0];

settings.AnimationMethod = animMethod switch { "legacy" => AnimationMethod.Legacy, _ => AnimationMethod.Mecanim };
settings.AnimationMethod =
animMethod switch { "mecanim" => AnimationMethod.Mecanim, _ => AnimationMethod.Legacy };

}

Expand Down
2 changes: 1 addition & 1 deletion consumer-server/src/logic/conversion-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export async function executeConversion(
logger.info('Starting conversion for ' + $BUILD_TARGET, defaultLoggerMetadata)
let hasContentChanged = true

if ($BUILD_TARGET !== 'webgl') {
if ($BUILD_TARGET !== 'webgl' && !force) {
try {
hasContentChanged = await hasContentChange(
entityId,
Expand Down
2 changes: 1 addition & 1 deletion consumer-server/src/logic/run-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export async function runConversion(
'-buildTarget',
options.unityBuildTarget,
'-animation',
options.animation || 'mecanim'
options.animation || 'legacy'
]

return await executeProgram({
Expand Down
2 changes: 1 addition & 1 deletion consumer-server/src/test-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function main() {
const logs = await createLogComponent({})
const config = createConfigComponent({})
const metrics = await createMetricsComponent(metricDeclarations, { config })
const animation = 'mecanim'
const animation = 'legacy'

let entityId = ''

Expand Down

0 comments on commit 741e4e3

Please sign in to comment.