Skip to content

Commit 576b0da

Browse files
Andrew Kimfacebook-github-bot
authored andcommitted
feat(Runtime): Update FullBodyDeformation with additional settings for shoulders and arms
Summary: - Add deformation settings for shoulder width and height - Add deformation settings for arms height - Update spine alignment to use limb proportions Reviewed By: sohailshafiiWk Differential Revision: D52717237 fbshipit-source-id: 249858618a527f0b6913ad684f2162198dfa12da
1 parent 79b3acb commit 576b0da

File tree

8 files changed

+277
-55
lines changed

8 files changed

+277
-55
lines changed

Editor/AnimationRigging/FullBodyDeformationConstraintEditor.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ private static class Content
9191
private SerializedProperty _spineLowerAlignmentWeightProperty;
9292
private SerializedProperty _spineUpperAlignmentWeightProperty;
9393
private SerializedProperty _chestAlignmentWeightProperty;
94+
private SerializedProperty _shouldersHeightAdjustmentWeightProperty;
95+
private SerializedProperty _shouldersWidthAdjustmentWeightProperty;
96+
private SerializedProperty _armsHeightAdjustmentWeightProperty;
9497
private SerializedProperty _alignFeetWeightProperty;
9598

9699
private SerializedProperty _leftShoulderWeightProperty;
@@ -130,6 +133,10 @@ private void OnEnable()
130133
_spineLowerAlignmentWeightProperty = data.FindPropertyRelative("_spineLowerAlignmentWeight");
131134
_spineUpperAlignmentWeightProperty = data.FindPropertyRelative("_spineUpperAlignmentWeight");
132135
_chestAlignmentWeightProperty = data.FindPropertyRelative("_chestAlignmentWeight");
136+
_shouldersHeightAdjustmentWeightProperty = data.FindPropertyRelative("_shouldersHeightAdjustmentWeight");
137+
_shouldersWidthAdjustmentWeightProperty = data.FindPropertyRelative("_shouldersWidthAdjustmentWeight");
138+
_armsHeightAdjustmentWeightProperty = data.FindPropertyRelative("_armsHeightAdjustmentWeight");
139+
133140
_leftShoulderWeightProperty = data.FindPropertyRelative("_leftShoulderWeight");
134141
_rightShoulderWeightProperty = data.FindPropertyRelative("_rightShoulderWeight");
135142
_leftArmWeightProperty = data.FindPropertyRelative("_leftArmWeight");
@@ -266,10 +273,19 @@ private void DisplaySettingsFoldoutContent()
266273
EditorGUILayout.Space();
267274
GUILayout.BeginHorizontal();
268275
GUILayout.Space(EditorGUI.indentLevel * _indentSpacing);
269-
GUILayout.Label(new GUIContent("Arms"), EditorStyles.boldLabel);
276+
GUILayout.Label(new GUIContent("Shoulders"), EditorStyles.boldLabel);
270277
GUILayout.EndHorizontal();
278+
EditorGUILayout.PropertyField(_shouldersHeightAdjustmentWeightProperty);
279+
EditorGUILayout.PropertyField(_shouldersWidthAdjustmentWeightProperty);
271280
AverageWeightSlider(Content.ShouldersWeight,
272281
new[] { _leftShoulderWeightProperty, _rightShoulderWeightProperty });
282+
283+
EditorGUILayout.Space();
284+
GUILayout.BeginHorizontal();
285+
GUILayout.Space(EditorGUI.indentLevel * _indentSpacing);
286+
GUILayout.Label(new GUIContent("Arms"), EditorStyles.boldLabel);
287+
GUILayout.EndHorizontal();
288+
EditorGUILayout.PropertyField(_armsHeightAdjustmentWeightProperty);
273289
AverageWeightSlider(Content.ArmsWeight,
274290
new[] { _leftArmWeightProperty, _rightArmWeightProperty });
275291
AverageWeightSlider(Content.HandsWeight,

Runtime/Scripts/AnimationRigging/DeformationConstraint.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ public void SetUpBonePairs()
697697
bonePairs[i] = bonePair;
698698
}
699699

700-
// Calculate proportions for spine.
701-
for (int i = 0; i < _hipsToHeadBones.Length - 1; i++)
700+
// Calculate proportions for the upper body.
701+
for (int i = 0; i < _hipsToHeadBones.Length + 1; i++)
702702
{
703703
var bonePair = bonePairs[i];
704704
bonePair.HeightProportion = bonePair.Distance / _hipsToHeadDistance;

Runtime/Scripts/AnimationRigging/FullBodyDeformationConstraint.cs

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ public interface IFullBodyDeformationData
161161
/// </summary>
162162
public string ChestAlignmentWeightFloatProperty { get; }
163163

164+
/// <summary>
165+
/// The shoulders height adjustment weight float property.
166+
/// </summary>
167+
string ShouldersHeightAdjustmentWeightFloatProperty { get; }
168+
169+
/// <summary>
170+
/// The shoulders width adjustment weight float property.
171+
/// </summary>
172+
string ShouldersWidthAdjustmentWeightFloatProperty { get; }
173+
174+
/// <summary>
175+
/// The arms height adjustment weight float property.
176+
/// </summary>
177+
string ArmsHeightAdjustmentWeightFloatProperty { get; }
178+
164179
/// <summary>
165180
/// The left shoulder weight float property.
166181
/// </summary>
@@ -356,6 +371,18 @@ bool IFullBodyDeformationData.ShouldUpdate
356371
string IFullBodyDeformationData.ChestAlignmentWeightFloatProperty =>
357372
ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(_chestAlignmentWeight));
358373

374+
/// <inheritdoc />
375+
string IFullBodyDeformationData.ShouldersHeightAdjustmentWeightFloatProperty =>
376+
ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(_shouldersHeightAdjustmentWeight));
377+
378+
/// <inheritdoc />
379+
string IFullBodyDeformationData.ShouldersWidthAdjustmentWeightFloatProperty =>
380+
ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(_shouldersWidthAdjustmentWeight));
381+
382+
/// <inheritdoc />
383+
string IFullBodyDeformationData.ArmsHeightAdjustmentWeightFloatProperty =>
384+
ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(_armsHeightAdjustmentWeight));
385+
359386
/// <inheritdoc />
360387
string IFullBodyDeformationData.LeftShoulderWeightFloatProperty =>
361388
ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(_leftShoulderWeight));
@@ -441,6 +468,42 @@ public float ChestAlignmentWeight
441468
set => _chestAlignmentWeight = value;
442469
}
443470

471+
/// <summary>
472+
/// The weight for shoulders height adjustment.
473+
/// </summary>
474+
[SyncSceneToStream, SerializeField, Range(0.0f, 1.0f)]
475+
[Tooltip(DeformationDataTooltips.ShouldersHeightAdjustmentWeight)]
476+
private float _shouldersHeightAdjustmentWeight;
477+
public float ShouldersHeightAdjustmentWeight
478+
{
479+
get => _shouldersHeightAdjustmentWeight;
480+
set => _shouldersHeightAdjustmentWeight = value;
481+
}
482+
483+
/// <summary>
484+
/// The weight for shoulders width adjustment.
485+
/// </summary>
486+
[SyncSceneToStream, SerializeField, Range(0.0f, 1.0f)]
487+
[Tooltip(DeformationDataTooltips.ShouldersHeightAdjustmentWeight)]
488+
private float _shouldersWidthAdjustmentWeight;
489+
public float ShouldersWidthAdjustmentWeight
490+
{
491+
get => _shouldersWidthAdjustmentWeight;
492+
set => _shouldersWidthAdjustmentWeight = value;
493+
}
494+
495+
/// <summary>
496+
/// The weight for arms height adjustment.
497+
/// </summary>
498+
[SyncSceneToStream, SerializeField, Range(0.0f, 1.0f)]
499+
[Tooltip(DeformationDataTooltips.ArmsHeightAdjustmentWeight)]
500+
private float _armsHeightAdjustmentWeight;
501+
public float ArmsHeightAdjustmentWeight
502+
{
503+
get => _armsHeightAdjustmentWeight;
504+
set => _armsHeightAdjustmentWeight = value;
505+
}
506+
444507
/// <summary>
445508
/// The weight for the deformation on the left shoulder.
446509
/// </summary>
@@ -971,16 +1034,16 @@ public void SetUpBonePairs()
9711034
bonePairs[i] = bonePair;
9721035
}
9731036

974-
// Calculate proportions for spine.
975-
for (int i = 0; i < _hipsToHeadBones.Length - 1; i++)
1037+
// Calculate proportions for the upper body.
1038+
for (int i = 0; i < _hipsToHeadBones.Length + 1; i++)
9761039
{
9771040
var bonePair = bonePairs[i];
9781041
bonePair.HeightProportion = bonePair.Distance / (_hipsToHeadDistance + _hipsToFootDistance);
9791042
bonePair.LimbProportion = bonePair.Distance / _hipsToHeadDistance;
9801043
bonePairs[i] = bonePair;
9811044
}
9821045

983-
// Calculate proportions for legs.
1046+
// Calculate proportions for the lower body.
9841047
for (int i = upperLegIndex; i < bonePairs.Count; i++)
9851048
{
9861049
var bonePair = bonePairs[i];

0 commit comments

Comments
 (0)