Skip to content

Commit

Permalink
[Automated] Merged dev into main
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Apr 19, 2024
2 parents df3a112 + 34d1477 commit d8d649a
Show file tree
Hide file tree
Showing 98 changed files with 53,182 additions and 184 deletions.
12 changes: 12 additions & 0 deletions Editor/AnimationRigging/FullBodyDeformationConstraintEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private static class Content

private SerializedProperty _leftShoulderWeightProperty;
private SerializedProperty _rightShoulderWeightProperty;
private SerializedProperty _shoulderRollWeightProperty;
private SerializedProperty _leftArmWeightProperty;
private SerializedProperty _rightArmWeightProperty;
private SerializedProperty _leftHandWeightProperty;
Expand All @@ -111,6 +112,9 @@ private static class Content
private SerializedProperty _rightToesWeightProperty;
private SerializedProperty _squashProperty;
private SerializedProperty _stretchProperty;
private SerializedProperty _originalSpinePositionsWeight;
private SerializedProperty _originalSpineBoneCount;
private SerializedProperty _originalSpineUseHipsToHeadToScale;

private SerializedProperty _hipsToHeadBonesProperty;
private SerializedProperty _hipsToHeadBoneTargetsProperty;
Expand Down Expand Up @@ -148,6 +152,7 @@ private void OnEnable()

_leftShoulderWeightProperty = data.FindPropertyRelative("_leftShoulderWeight");
_rightShoulderWeightProperty = data.FindPropertyRelative("_rightShoulderWeight");
_shoulderRollWeightProperty = data.FindPropertyRelative("_shoulderRollWeight");
_leftArmWeightProperty = data.FindPropertyRelative("_leftArmWeight");
_rightArmWeightProperty = data.FindPropertyRelative("_rightArmWeight");
_leftHandWeightProperty = data.FindPropertyRelative("_leftHandWeight");
Expand All @@ -159,6 +164,9 @@ private void OnEnable()
_alignFeetWeightProperty = data.FindPropertyRelative("_alignFeetWeight");
_squashProperty = data.FindPropertyRelative("_squashLimit");
_stretchProperty = data.FindPropertyRelative("_stretchLimit");
_originalSpinePositionsWeight = data.FindPropertyRelative("_originalSpinePositionsWeight");
_originalSpineBoneCount = data.FindPropertyRelative("_originalSpineBoneCount");
_originalSpineUseHipsToHeadToScale = data.FindPropertyRelative("_originalSpineUseHipsToHeadToScale");

_hipsToHeadBonesProperty = data.FindPropertyRelative("_hipsToHeadBones");
_hipsToHeadBoneTargetsProperty = data.FindPropertyRelative("_hipsToHeadBoneTargets");
Expand Down Expand Up @@ -292,6 +300,7 @@ private void DisplaySettingsFoldoutContent()
GUILayout.Label(new GUIContent("Body"), EditorStyles.boldLabel);
GUILayout.EndHorizontal();
EditorGUILayout.PropertyField(_spineTranslationCorrectionTypeProperty);
EditorGUILayout.PropertyField(_originalSpinePositionsWeight);
EditorGUILayout.PropertyField(_spineLowerAlignmentWeightProperty);
EditorGUILayout.PropertyField(_spineUpperAlignmentWeightProperty);
EditorGUILayout.PropertyField(_chestAlignmentWeightProperty);
Expand All @@ -303,6 +312,7 @@ private void DisplaySettingsFoldoutContent()
GUILayout.EndHorizontal();
AverageWeightSlider(Content.ShouldersWeight,
new[] { _leftShoulderWeightProperty, _rightShoulderWeightProperty });
EditorGUILayout.PropertyField(_shoulderRollWeightProperty);

EditorGUILayout.Space();
GUILayout.BeginHorizontal();
Expand Down Expand Up @@ -356,6 +366,8 @@ private void DisplayAdvancedSettingsFoldoutContent()
}
EditorGUILayout.PropertyField(_squashProperty);
EditorGUILayout.PropertyField(_stretchProperty);
EditorGUILayout.PropertyField(_originalSpineBoneCount);
EditorGUILayout.PropertyField(_originalSpineUseHipsToHeadToScale);

EditorGUILayout.Space();
GUILayout.BeginHorizontal();
Expand Down
20 changes: 19 additions & 1 deletion Editor/AnimationRigging/RetargetingLayerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ public class RetargetingLayerEditor : Editor
/// <inheritdoc />
public override void OnInspectorGUI()
{
var retargetingLayer = serializedObject.targetObject as RetargetingLayer;
var animatorComponent = retargetingLayer.GetComponent<Animator>();

if (!IsAnimatorProperlyConfigured(animatorComponent))
{
GUILayout.BeginHorizontal();
EditorGUILayout.HelpBox("Requires Animator component with a humanoid " +
"avatar, and Translation DoF enabled in avatar's Muscles & Settings.", MessageType.Error);
GUILayout.EndVertical();
}

base.OnInspectorGUI();

if (GUILayout.Button("Calculate Adjustments"))
{
var retargetingLayer = serializedObject.targetObject as RetargetingLayer;

if (retargetingLayer != null)
{
var animator = retargetingLayer.GetComponent<Animator>();
Expand All @@ -32,5 +43,12 @@ public override void OnInspectorGUI()

serializedObject.ApplyModifiedProperties();
}

internal static bool IsAnimatorProperlyConfigured(Animator animatorComponent)
{
return animatorComponent != null && animatorComponent.avatar != null &&
animatorComponent.avatar.isHuman &&
animatorComponent.avatar.humanDescription.hasTranslationDoF;
}
}
}
8 changes: 8 additions & 0 deletions Editor/BodyTrackingForFitness.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions Editor/BodyTrackingForFitness/BodyBoneVisualsEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

using System;
using Oculus.Movement.Utils;
using UnityEditor;

namespace Oculus.Movement.BodyTrackingForFitness
{
/// <summary>
/// Adds button features in the inspector:
/// * Connect to <see cref="BodyPoseBoneTransforms"/>
/// * Generate a default bone prefab
/// * Generate and/or refresh positions of bone visuals childed to bone transforms
/// * Delete all bone visuals
/// </summary>
[CustomEditor(typeof(BodyPoseBoneVisuals))]
public class BodyBoneVisualsEditor : Editor
{
private InspectorGuiHelper[] helpers;
private InspectorGuiHelper[] Helpers => helpers != null ? helpers : helpers = new InspectorGuiHelper[]
{
new InspectorGuiHelper(IsSkeletonInvalid, PopulateSkeleton, "Missing target skeleton",
"Find Target Skeleton", InspectorGuiHelper.OptionalIcon.Warning),
new InspectorGuiHelper(IsBoneVisualEmpty, GenerateBoneVisualPrefab, "Needs bone prefab",
"Generate Bone Prefab", InspectorGuiHelper.OptionalIcon.Warning),
new InspectorGuiHelper(IsShowingRefreshButton, Refresh, null,
"Refresh Bone Visuals", InspectorGuiHelper.OptionalIcon.None),
new InspectorGuiHelper(IsPopulatedWithBones, Clear, null,
"Clear Bone Visuals", InspectorGuiHelper.OptionalIcon.None),
};

private BodyPoseBoneVisuals Target => (BodyPoseBoneVisuals)target;

/// <inheritdoc/>
public override void OnInspectorGUI()
{
Array.ForEach(Helpers, helper => helper.DrawInInspector());
DrawDefaultInspector();
}

private bool IsShowingRefreshButton() => !IsSkeletonInvalid();

private bool IsBoneVisualEmpty() => Target.BoneVisualPrefab == null;

private bool IsSkeletonInvalid() => Target.Skeleton == null;

private bool IsPopulatedWithBones() => Target.BoneVisuals.Count != 0;

private void Refresh() => Target.RefreshVisualsInEditor();

private void GenerateBoneVisualPrefab() => Target.CreatePrimitiveCubeVisualPrefab();

private void PopulateSkeleton() => Target.Skeleton = FindBestSkeletonOwner();

private void Clear() => Target.ClearBoneVisuals();

private BodyPoseBoneTransforms FindBestSkeletonOwner() =>
FindFirstObjectByType<BodyPoseBoneTransforms>();
}
}
11 changes: 11 additions & 0 deletions Editor/BodyTrackingForFitness/BodyBoneVisualsEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

using UnityEditor;
using UnityEngine;

namespace Oculus.Movement.BodyTrackingForFitness
{
/// <summary>
/// Used to simplify drawing of a
/// <see cref="BodyPoseAlignmentDetector.AlignmentState"/> element.
/// </summary>
[CustomPropertyDrawer(typeof(BodyPoseAlignmentDetector.AlignmentState))]
public class BodyPoseAlignmentDetectorStateEditor : PropertyDrawer
{
/// <inheritdoc />
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
BoneTupleGUI(position, property, label);
}

/// <summary>
/// Call from OnGUI to draw a <see cref="BodyPoseAlignmentDetector.AlignmentState"/>.
/// </summary>
/// <param name="position"></param>
/// <param name="property"></param>
/// <param name="label"></param>
private static void BoneTupleGUI(Rect position, SerializedProperty property,
GUIContent label) {
SerializedProperty angle = property.FindPropertyRelative(
nameof(BodyPoseAlignmentDetector.AlignmentState.AngleDelta));
EditorGUI.BeginProperty(position, label, property);
const string ElementLabel = "Element ";
if (!label.text.StartsWith(ElementLabel))
{
position = EditorGUI.PrefixLabel(position,
GUIUtility.GetControlID(FocusType.Passive), label);
}
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
Rect rect = new Rect(position.x, position.y, position.width, position.height);
EditorGUI.Slider(rect, "", angle.floatValue, 0, 180);
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions Editor/BodyTrackingForFitness/BodyPoseBoneTransformsEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

using System;
using Oculus.Movement.Utils;
using UnityEditor;

namespace Oculus.Movement.BodyTrackingForFitness
{
/// <summary>
/// Adds button features in the inspector:
/// * Generate and/or refresh positions of bone visuals childed to bone transforms
/// </summary>
[CustomEditor(typeof(BodyPoseBoneTransforms))]
public class BodyPoseBoneTransformsEditor : Editor
{
private InspectorGuiHelper[] _helpers;
private InspectorGuiHelper[] Helpers =>
_helpers != null ? _helpers : _helpers = new InspectorGuiHelper[]
{
new InspectorGuiHelper(IsShowingRefreshButton, Refresh, null,
"Refresh Transforms", InspectorGuiHelper.OptionalIcon.None),
new InspectorGuiHelper(IsAbleToTPose, RefreshTPose, null,
"Refresh T-Pose", InspectorGuiHelper.OptionalIcon.None),
new InspectorGuiHelper(IsAbleToSave, SaveAsset, null,
"Export Asset", InspectorGuiHelper.OptionalIcon.None),
};

private BodyPoseBoneTransforms Target => (BodyPoseBoneTransforms)target;

/// <inheritdoc/>
public override void OnInspectorGUI()
{
Array.ForEach(Helpers, helper => helper.DrawInInspector());
DrawDefaultInspector();
}

private bool IsShowingRefreshButton() => Target.BodyPose != null;

private bool IsAbleToTPose() => true;

private bool IsAbleToSave() => Target.BoneContainer != null;

private void Refresh()
{
Target.RefreshHierarchyDuringEditor();
EditorTransformAwareness.RefreshSystem();
EditorBodyPoseLineSkeleton.RefreshSystem();
}

private void RefreshTPose()
{
Target.RefreshTPose();
}

private void SaveAsset()
{
BodyPoseControllerEditor.SaveAsset(Target);
}
}
}
11 changes: 11 additions & 0 deletions Editor/BodyTrackingForFitness/BodyPoseBoneTransformsEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d8d649a

Please sign in to comment.