Skip to content

Commit 0e4f35c

Browse files
committed
[Automated] Merged dev into main
2 parents 7feef8e + 7132f36 commit 0e4f35c

File tree

351 files changed

+226332
-1646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+226332
-1646
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [77.0.1]
2+
3+
### What's Fixed
4+
5+
- Fixed animation quaternion blending edge cases.
6+
- Fixed various retargeting editor issues related to posing, playback, and scaling.
7+
18
## [77.0.0]
29

310
### What's New

Editor/Native/Scripts/JointAlignmentUtility.cs

Lines changed: 312 additions & 278 deletions
Large diffs are not rendered by default.

Editor/Native/Scripts/MSDKUtilityEditor.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public static TextAsset CreateRetargetingConfig(
236236
var target = customData;
237237
if (target == null)
238238
{
239-
target = CreateRetargetingData(targetObject);
239+
target = CreateRetargetingData(targetObject.transform);
240240
if (target == null)
241241
{
242242
Debug.LogError("Error in creating retargeting data!");
@@ -246,9 +246,14 @@ public static TextAsset CreateRetargetingConfig(
246246

247247
var skinnedMeshRenderers = GetValidSkinnedMeshRenderers(targetObject);
248248
var blendshapeNames = GetBlendshapeNames(skinnedMeshRenderers);
249-
250249
var output = MSDKUtilityHelper.CreateRetargetingConfig(
251250
blendshapeNames, sourceData, target, targetObject.name);
251+
if (output == string.Empty)
252+
{
253+
Debug.LogError("Error in creating retargeting config!");
254+
return null;
255+
}
256+
252257
var prefabAssetPath = AssetDatabase.GetAssetPath(targetObject);
253258
if (string.IsNullOrEmpty(prefabAssetPath))
254259
{
@@ -299,21 +304,18 @@ public static TextAsset CreateRetargetingConfig(
299304
/// <summary>
300305
/// Creates retargeting data for a target GameObject.
301306
/// </summary>
302-
/// <param name="target">The target GameObject.</param>
303-
/// <param name="utilityConfig">Optional utility configuration.</param>
307+
/// <param name="target">The target transform.</param>
308+
/// <param name="config"></param>
304309
/// <returns>The created skeleton data.</returns>
305-
public static SkeletonData CreateRetargetingData(GameObject target,
306-
MSDKUtilityEditorConfig utilityConfig = null)
310+
public static SkeletonData CreateRetargetingData(Transform target, MSDKUtilityEditorConfig config = null)
307311
{
308312
var isOvrSkeleton = target.name == "OVRSkeleton";
309-
var jointMapping =
310-
MSDKUtilityHelper.GetChildParentJointMapping(target, isOvrSkeleton, out var previousRootName);
313+
var jointMapping = MSDKUtilityHelper.GetChildParentJointMapping(target, isOvrSkeleton);
311314
if (jointMapping == null)
312315
{
313316
return null;
314317
}
315318

316-
Transform rootJoint = null;
317319
var index = 0;
318320
var jointCount = jointMapping.Keys.Count;
319321
var data = ScriptableObject.CreateInstance<SkeletonData>();
@@ -327,7 +329,6 @@ public static SkeletonData CreateRetargetingData(GameObject target,
327329
if (parentJoint == null)
328330
{
329331
data.ParentJoints[index] = string.Empty;
330-
rootJoint = joint;
331332
}
332333
else
333334
{
@@ -338,15 +339,25 @@ public static SkeletonData CreateRetargetingData(GameObject target,
338339
index++;
339340
}
340341

341-
if (utilityConfig != null)
342+
// Filter out any extra joints not found in config.
343+
if (config != null)
342344
{
343345
foreach (var joint in data.Joints)
344346
{
345-
if (!utilityConfig.JointNames.Contains(joint))
347+
if (!config.JointNames.Contains(joint))
346348
{
347349
data.RemoveJoint(joint);
348350
}
349351
}
352+
353+
for (var i = 0; i < data.ParentJoints.Length; i++)
354+
{
355+
var parentJoint = data.ParentJoints[i];
356+
if (!config.JointNames.Contains(parentJoint))
357+
{
358+
data.ParentJoints[i] = string.Empty;
359+
}
360+
}
350361
}
351362

352363
data.TPoseMin = data.TPose;
@@ -357,14 +368,6 @@ public static SkeletonData CreateRetargetingData(GameObject target,
357368
{
358369
data.SortData();
359370
}
360-
else
361-
{
362-
// Restore the name of the root joint to its previous name.
363-
if (rootJoint != null)
364-
{
365-
rootJoint.name = previousRootName;
366-
}
367-
}
368371

369372
return data;
370373
}
@@ -506,7 +509,7 @@ private static SkinnedMeshRenderer[] GetValidSkinnedMeshRenderers(GameObject gam
506509

507510
private static string[] GetBlendshapeNames(SkinnedMeshRenderer[] skinnedMeshes)
508511
{
509-
List<string> blendshapeNames = new List<string>();
512+
HashSet<string> blendshapeNames = new HashSet<string>();
510513
foreach (var skinnedMesh in skinnedMeshes)
511514
{
512515
int numCurrentBlendshapes = skinnedMesh.sharedMesh.blendShapeCount;

Editor/Native/Scripts/MSDKUtilityEditorConfig.cs

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.IO;
6+
using System.Linq;
67
using Meta.XR.Movement.Retargeting;
78
using Unity.Collections;
89
using UnityEditor;
@@ -213,33 +214,6 @@ public void Initialize(string configJson, SkeletonType skeletonType, SkeletonTPo
213214
ParentIndices = parentIndices.ToArray();
214215
}
215216

216-
public void Initialize(ulong handle, SkeletonType skeletonType, SkeletonTPoseType tPoseType)
217-
{
218-
ConfigHandle = handle;
219-
GetConfigName(ConfigHandle, out ConfigName);
220-
GetBlendShapeNames(ConfigHandle, skeletonType, out BlendshapeNames);
221-
GetSkeletonInfo(ConfigHandle, skeletonType, out SkeletonInfo);
222-
GetJointNames(ConfigHandle, skeletonType, out JointNames);
223-
GetParentJointNames(ConfigHandle, skeletonType, out ParentJointNames);
224-
GetKnownJointNames(ConfigHandle, skeletonType, out KnownJointNames);
225-
SkeletonTPoseType = tPoseType;
226-
227-
// Fill out runtime data.
228-
var count = SkeletonInfo.JointCount;
229-
var tPose = new NativeArray<NativeTransform>(count, Allocator.Temp,
230-
NativeArrayOptions.UninitializedMemory);
231-
var parentIndices = new NativeArray<int>(count, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
232-
GetSkeletonTPoseByRef(ConfigHandle, skeletonType, tPoseType,
233-
JointRelativeSpaceType.RootOriginRelativeSpace, ref tPose);
234-
GetParentJointIndexesByRef(ConfigHandle, skeletonType, ref parentIndices);
235-
GetSkeletonMappings(ConfigHandle, tPoseType, out var jointMappings);
236-
GetSkeletonMappingEntries(ConfigHandle, tPoseType, out var jointMappingEntries);
237-
JointMappings = jointMappings.ToArray();
238-
JointMappingEntries = jointMappingEntries.ToArray();
239-
ReferencePose = tPose.ToArray();
240-
ParentIndices = parentIndices.ToArray();
241-
}
242-
243217
/**********************************************************
244218
*
245219
* Configuration File
@@ -417,24 +391,23 @@ public static void UpdateConfig(
417391
{
418392
if (target.KnownSkeletonJoints[i] == null)
419393
{
394+
target.KnownJointNames[i] = string.Empty;
420395
continue;
421396
}
422397

423-
target.KnownJointNames[i] = i == 0 ? "root" : target.KnownSkeletonJoints[i]?.name;
424-
}
425-
426-
for (var i = 0; i < targetMinTPose.Length; i++)
427-
{
428-
var pose = targetMinTPose[i];
429-
pose.Scale = Vector3.one * Mathf.Clamp(pose.Scale.x, 0.001f, float.MaxValue);
430-
targetMinTPose[i] = pose;
431-
}
432-
433-
for (var i = 0; i < targetMaxTPose.Length; i++)
434-
{
435-
var pose = targetMaxTPose[i];
436-
pose.Scale = Vector3.one * Mathf.Clamp(pose.Scale.x, 0.001f, float.MaxValue);
437-
targetMaxTPose[i] = pose;
398+
var oldRootName = "root";
399+
if (i == 0 && target.KnownJointNames[0] == oldRootName)
400+
{
401+
// Upgrade to use non-root name.
402+
var newRootName = target.KnownSkeletonJoints[0].name;
403+
target.JointNames = target.JointNames.Select(s => s == oldRootName ? newRootName : s).ToArray();
404+
target.ParentJointNames = target.ParentJointNames.Select(s => s == oldRootName ? newRootName : s).ToArray();
405+
target.KnownJointNames = target.KnownJointNames.Select(s => s == oldRootName ? newRootName : s).ToArray();
406+
}
407+
else
408+
{
409+
target.KnownJointNames[i] = target.KnownSkeletonJoints[i]?.name;
410+
}
438411
}
439412

440413
var initParams = new ConfigInitParams();
@@ -521,7 +494,8 @@ public static void LoadConfig(MSDKUtilityEditorWindow win, string customConfig =
521494
/// <param name="win">The editor window.</param>
522495
/// <param name="targetTPoseType">The target T-pose type.</param>
523496
/// <param name="customConfig">Optional custom configuration JSON string.</param>
524-
public static void LoadConfig(MSDKUtilityEditorWindow win,
497+
public static void LoadConfig(
498+
MSDKUtilityEditorWindow win,
525499
SkeletonTPoseType targetTPoseType,
526500
string customConfig = null)
527501
{
@@ -570,7 +544,8 @@ public static void LoadConfig(MSDKUtilityEditorWindow win,
570544
/// <param name="win">The editor window.</param>
571545
/// <param name="customConfig">Optional custom configuration JSON string.</param>
572546
/// <param name="displayDialogue">Whether to display a confirmation dialogue.</param>
573-
public static void ResetConfig(MSDKUtilityEditorWindow win,
547+
public static void ResetConfig(
548+
MSDKUtilityEditorWindow win,
574549
bool displayDialogue,
575550
string customConfig = null)
576551
{
@@ -592,7 +567,8 @@ public static void ResetConfig(MSDKUtilityEditorWindow win,
592567
/// <param name="win">The editor window.</param>
593568
/// <param name="displayDialogue">Whether to display a confirmation dialogue.</param>
594569
/// <param name="customData">Optional custom skeleton data.</param>
595-
public static void CreateConfig(MSDKUtilityEditorWindow win,
570+
public static void CreateConfig(
571+
MSDKUtilityEditorWindow win,
596572
bool displayDialogue,
597573
SkeletonData customData = null)
598574
{
@@ -633,7 +609,8 @@ public static void CreateConfig(MSDKUtilityEditorWindow win,
633609
/// <param name="previewer">The editor previewer.</param>
634610
/// <param name="skeletonDrawTPose">The skeleton draw for T-pose.</param>
635611
/// <param name="config">The utility configuration.</param>
636-
public static void ValidateMSDKUtilityEditorInfo(MSDKUtilityEditorPreviewer previewer,
612+
public static void Validate(
613+
MSDKUtilityEditorPreviewer previewer,
637614
SkeletonDraw skeletonDrawTPose,
638615
MSDKUtilityEditorConfig config)
639616
{

Editor/Native/Scripts/MSDKUtilityEditorOverlay.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public override VisualElement CreatePanelContent()
8484
paddingBottom = 2,
8585
paddingLeft = 4,
8686
paddingRight = 4,
87-
minWidth = 230,
88-
maxWidth = 230
87+
minWidth = 240,
88+
maxWidth = 240
8989
}
9090
};
9191

Editor/Native/Scripts/MSDKUtilityEditorPreviewer.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using Meta.XR.Movement.Retargeting.Editor;
66
using Meta.XR.Movement.Retargeting;
7-
using Meta.XR.Movement.Utils;
87
using Unity.Collections;
98
using UnityEditor;
109
using UnityEngine;
@@ -276,6 +275,15 @@ public void AssociateSceneCharacter(MSDKUtilityEditorConfig target)
276275
out var rootJoint);
277276
target.SkeletonJoints[index] = rootJoint;
278277

278+
// In the case we don't have a root, create one for previewing
279+
if (_sceneViewCharacter.transform == rootJoint && _window.PreviewStage.scene.IsValid())
280+
{
281+
var previewCharacterParent = new GameObject("PreviewCharacter");
282+
SceneManager.MoveGameObjectToScene(previewCharacterParent, _window.PreviewStage.scene);
283+
_sceneViewCharacter.transform.parent = previewCharacterParent.transform;
284+
_sceneViewCharacter = previewCharacterParent;
285+
}
286+
279287
// Associate known joints.
280288
target.KnownSkeletonJoints = new Transform[(int)KnownJointType.KnownJointCount];
281289
for (var i = KnownJointType.Root; i < KnownJointType.KnownJointCount; i++)
@@ -325,7 +333,7 @@ public void ReloadCharacter(MSDKUtilityEditorConfig target)
325333
var tPose = target.ReferencePose[i];
326334
if (joint == null)
327335
{
328-
return;
336+
continue;
329337
}
330338

331339
joint.localScale = tPose.Scale;
@@ -341,6 +349,11 @@ public void ReloadCharacter(MSDKUtilityEditorConfig target)
341349

342350
var joint = target.SkeletonJoints[i];
343351
var tPose = target.ReferencePose[i];
352+
if (joint == null)
353+
{
354+
continue;
355+
}
356+
344357
Undo.RecordObject(joint, "Reload Character");
345358
joint.SetPositionAndRotation(tPose.Position, tPose.Orientation);
346359
}

0 commit comments

Comments
 (0)