Fix : 기존 리타겟팅으로 롤백
This commit is contained in:
parent
7e10a3d83d
commit
5a0cc1a433
@ -33,7 +33,6 @@ namespace KindRetargeting
|
|||||||
private float hipsWeight = 0f; // 힙의 위치를 위아래로 보정하는 가중치
|
private float hipsWeight = 0f; // 힙의 위치를 위아래로 보정하는 가중치
|
||||||
|
|
||||||
[HideInInspector] public float HipsWeightOffset = 1f;
|
[HideInInspector] public float HipsWeightOffset = 1f;
|
||||||
[HideInInspector] public float HipsHeightAdjustment = 0f; // 허리 높이 절대 조정값
|
|
||||||
|
|
||||||
// HumanPoseHandler를 이용하여 원본 및 대상 아바타의 포즈를 관리
|
// HumanPoseHandler를 이용하여 원본 및 대상 아바타의 포즈를 관리
|
||||||
private HumanPoseHandler sourcePoseHandler;
|
private HumanPoseHandler sourcePoseHandler;
|
||||||
@ -134,19 +133,6 @@ namespace KindRetargeting
|
|||||||
public List<RotationOffsetData> rotationOffsetCache;
|
public List<RotationOffsetData> rotationOffsetCache;
|
||||||
public float initialHipsHeight;
|
public float initialHipsHeight;
|
||||||
public float avatarScale;
|
public float avatarScale;
|
||||||
|
|
||||||
// LimbWeightController 설정들
|
|
||||||
public float maxDistance;
|
|
||||||
public float minDistance;
|
|
||||||
public float weightSmoothSpeed;
|
|
||||||
public float hipsMinDistance;
|
|
||||||
public float hipsMaxDistance;
|
|
||||||
public bool useFixedChairGap;
|
|
||||||
public float chairHipsFixedGap;
|
|
||||||
public float groundHipsMinHeight;
|
|
||||||
public float groundHipsMaxHeight;
|
|
||||||
public float footHeightMinThreshold;
|
|
||||||
public float footHeightMaxThreshold;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 각 손가락 관절별로 필터 버퍼를 관리하는 Dictionary 추가
|
// 각 손가락 관절별로 필터 버퍼를 관리하는 Dictionary 추가
|
||||||
@ -353,9 +339,6 @@ namespace KindRetargeting
|
|||||||
offsetCache.Add(new RotationOffsetData((int)kvp.Key, kvp.Value));
|
offsetCache.Add(new RotationOffsetData((int)kvp.Key, kvp.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// LimbWeightController 컴포넌트 가져오기
|
|
||||||
var limbWeightController = GetComponent<LimbWeightController>();
|
|
||||||
|
|
||||||
var settings = new RetargetingSettings
|
var settings = new RetargetingSettings
|
||||||
{
|
{
|
||||||
hipsWeight = hipsWeight,
|
hipsWeight = hipsWeight,
|
||||||
@ -372,19 +355,6 @@ namespace KindRetargeting
|
|||||||
rotationOffsetCache = offsetCache,
|
rotationOffsetCache = offsetCache,
|
||||||
initialHipsHeight = initialHipsHeight,
|
initialHipsHeight = initialHipsHeight,
|
||||||
avatarScale = avatarScale,
|
avatarScale = avatarScale,
|
||||||
|
|
||||||
// LimbWeightController 설정들 저장
|
|
||||||
maxDistance = limbWeightController?.maxDistance ?? 0.5f,
|
|
||||||
minDistance = limbWeightController?.minDistance ?? 0.1f,
|
|
||||||
weightSmoothSpeed = limbWeightController?.weightSmoothSpeed ?? 10f,
|
|
||||||
hipsMinDistance = limbWeightController?.hipsMinDistance ?? 0.2f,
|
|
||||||
hipsMaxDistance = limbWeightController?.hipsMaxDistance ?? 0.6f,
|
|
||||||
useFixedChairGap = limbWeightController?.useFixedChairGap ?? true,
|
|
||||||
chairHipsFixedGap = limbWeightController?.chairHipsFixedGap ?? 0.1f,
|
|
||||||
groundHipsMinHeight = limbWeightController?.groundHipsMinHeight ?? 0f,
|
|
||||||
groundHipsMaxHeight = limbWeightController?.groundHipsMaxHeight ?? 0.5f,
|
|
||||||
footHeightMinThreshold = limbWeightController?.footHeightMinThreshold ?? 0.2f,
|
|
||||||
footHeightMaxThreshold = limbWeightController?.footHeightMaxThreshold ?? 0.5f,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
string json = JsonUtility.ToJson(settings, true);
|
string json = JsonUtility.ToJson(settings, true);
|
||||||
@ -442,23 +412,6 @@ namespace KindRetargeting
|
|||||||
avatarScale = settings.avatarScale;
|
avatarScale = settings.avatarScale;
|
||||||
previousScale = avatarScale;
|
previousScale = avatarScale;
|
||||||
|
|
||||||
// LimbWeightController 설정들 로드
|
|
||||||
var limbWeightController = GetComponent<LimbWeightController>();
|
|
||||||
if (limbWeightController != null)
|
|
||||||
{
|
|
||||||
limbWeightController.maxDistance = settings.maxDistance;
|
|
||||||
limbWeightController.minDistance = settings.minDistance;
|
|
||||||
limbWeightController.weightSmoothSpeed = settings.weightSmoothSpeed;
|
|
||||||
limbWeightController.hipsMinDistance = settings.hipsMinDistance;
|
|
||||||
limbWeightController.hipsMaxDistance = settings.hipsMaxDistance;
|
|
||||||
limbWeightController.useFixedChairGap = settings.useFixedChairGap;
|
|
||||||
limbWeightController.chairHipsFixedGap = settings.chairHipsFixedGap;
|
|
||||||
limbWeightController.groundHipsMinHeight = settings.groundHipsMinHeight;
|
|
||||||
limbWeightController.groundHipsMaxHeight = settings.groundHipsMaxHeight;
|
|
||||||
limbWeightController.footHeightMinThreshold = settings.footHeightMinThreshold;
|
|
||||||
limbWeightController.footHeightMaxThreshold = settings.footHeightMaxThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//너무 자주 출력되어서 주석처리
|
//너무 자주 출력되어서 주석처리
|
||||||
@ -754,11 +707,10 @@ namespace KindRetargeting
|
|||||||
|
|
||||||
if (sourceHips != null && targetHips != null)
|
if (sourceHips != null && targetHips != null)
|
||||||
{
|
{
|
||||||
// 힙 위치 동기화 + 힙 위치 보정 적용 + 바닥 높이 적용 + 의자 높이 조정
|
// 힙 위치 동기화 + 힙 위치 보정 적용 + 바닥 높이 적용용
|
||||||
Vector3 adjustedPosition = sourceHips.position;
|
Vector3 adjustedPosition = sourceHips.position;
|
||||||
adjustedPosition.y += hipsWeight * HipsWeightOffset; // 기존 힙 높이 조정
|
adjustedPosition.y += hipsWeight * HipsWeightOffset; // 기존 힙 높이 조정
|
||||||
adjustedPosition.y += floorHeight; // 바닥 높이 조정
|
adjustedPosition.y += floorHeight; // 바닥 높이 조정 추가
|
||||||
adjustedPosition.y += HipsHeightAdjustment; // 의자 기반 절대 높이 조정 추가
|
|
||||||
targetHips.position = adjustedPosition;
|
targetHips.position = adjustedPosition;
|
||||||
|
|
||||||
// 힙 회전 동기화 (회전 오프셋 적용)
|
// 힙 회전 동기화 (회전 오프셋 적용)
|
||||||
|
|||||||
@ -12,8 +12,6 @@ namespace KindRetargeting
|
|||||||
SerializedProperty middleWeightMultiplier;
|
SerializedProperty middleWeightMultiplier;
|
||||||
SerializedProperty hipsMinDistance;
|
SerializedProperty hipsMinDistance;
|
||||||
SerializedProperty hipsMaxDistance;
|
SerializedProperty hipsMaxDistance;
|
||||||
SerializedProperty useFixedChairGap;
|
|
||||||
SerializedProperty chairHipsFixedGap;
|
|
||||||
SerializedProperty props;
|
SerializedProperty props;
|
||||||
SerializedProperty characterRoot;
|
SerializedProperty characterRoot;
|
||||||
SerializedProperty groundHipsMinHeight;
|
SerializedProperty groundHipsMinHeight;
|
||||||
@ -26,7 +24,6 @@ namespace KindRetargeting
|
|||||||
private bool showDistanceSettings = true;
|
private bool showDistanceSettings = true;
|
||||||
private bool showWeightSettings = true;
|
private bool showWeightSettings = true;
|
||||||
private bool showHipsSettings = true;
|
private bool showHipsSettings = true;
|
||||||
private bool showChairHeightSettings = true;
|
|
||||||
private bool showReferences = true;
|
private bool showReferences = true;
|
||||||
private bool showGroundHipsSettings = true;
|
private bool showGroundHipsSettings = true;
|
||||||
private bool showFootHeightSettings = true;
|
private bool showFootHeightSettings = true;
|
||||||
@ -45,8 +42,6 @@ namespace KindRetargeting
|
|||||||
middleWeightMultiplier = serializedObject.FindProperty("middleWeightMultiplier");
|
middleWeightMultiplier = serializedObject.FindProperty("middleWeightMultiplier");
|
||||||
hipsMinDistance = serializedObject.FindProperty("hipsMinDistance");
|
hipsMinDistance = serializedObject.FindProperty("hipsMinDistance");
|
||||||
hipsMaxDistance = serializedObject.FindProperty("hipsMaxDistance");
|
hipsMaxDistance = serializedObject.FindProperty("hipsMaxDistance");
|
||||||
useFixedChairGap = serializedObject.FindProperty("useFixedChairGap");
|
|
||||||
chairHipsFixedGap = serializedObject.FindProperty("chairHipsFixedGap");
|
|
||||||
props = serializedObject.FindProperty("props");
|
props = serializedObject.FindProperty("props");
|
||||||
characterRoot = serializedObject.FindProperty("characterRoot");
|
characterRoot = serializedObject.FindProperty("characterRoot");
|
||||||
groundHipsMinHeight = serializedObject.FindProperty("groundHipsMinHeight");
|
groundHipsMinHeight = serializedObject.FindProperty("groundHipsMinHeight");
|
||||||
@ -131,25 +126,6 @@ namespace KindRetargeting
|
|||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUILayout.Space(5);
|
|
||||||
showChairHeightSettings = EditorGUILayout.Foldout(showChairHeightSettings, "의자 거리 기반 허리 높이 설정", true);
|
|
||||||
if (showChairHeightSettings)
|
|
||||||
{
|
|
||||||
EditorGUI.indentLevel++;
|
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(useFixedChairGap, new GUIContent("고정 간격 사용"));
|
|
||||||
|
|
||||||
if (useFixedChairGap.boolValue)
|
|
||||||
{
|
|
||||||
EditorGUILayout.PropertyField(chairHipsFixedGap, new GUIContent("의자-허리 고정 간격"));
|
|
||||||
|
|
||||||
EditorGUILayout.Space(5);
|
|
||||||
EditorGUILayout.HelpBox("의자가 가까워지면 허리 높이가 의자 높이 + 고정 간격으로 자동 조절됩니다.", MessageType.Info);
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUI.indentLevel--;
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUILayout.Space(5);
|
EditorGUILayout.Space(5);
|
||||||
showGroundHipsSettings = EditorGUILayout.Foldout(showGroundHipsSettings, "바닥 기준 히프 보정 설정", true);
|
showGroundHipsSettings = EditorGUILayout.Foldout(showGroundHipsSettings, "바닥 기준 히프 보정 설정", true);
|
||||||
if (showGroundHipsSettings)
|
if (showGroundHipsSettings)
|
||||||
|
|||||||
@ -448,7 +448,6 @@ public class RetargetingControlWindow : EditorWindow
|
|||||||
limb.weightSmoothSpeed = 10f;
|
limb.weightSmoothSpeed = 10f;
|
||||||
limb.groundHipsMinHeight = 0.3f;
|
limb.groundHipsMinHeight = 0.3f;
|
||||||
limb.groundHipsMaxHeight = 0.7f;
|
limb.groundHipsMaxHeight = 0.7f;
|
||||||
limb.chairHipsFixedGap = 0.1f;
|
|
||||||
|
|
||||||
EditorUtility.SetDirty(limb);
|
EditorUtility.SetDirty(limb);
|
||||||
}
|
}
|
||||||
@ -492,8 +491,6 @@ public class RetargetingControlWindow : EditorWindow
|
|||||||
preset.limbMinDistance = limb.minDistance;
|
preset.limbMinDistance = limb.minDistance;
|
||||||
preset.footHeightMinThreshold = limb.footHeightMinThreshold;
|
preset.footHeightMinThreshold = limb.footHeightMinThreshold;
|
||||||
preset.footHeightMaxThreshold = limb.footHeightMaxThreshold;
|
preset.footHeightMaxThreshold = limb.footHeightMaxThreshold;
|
||||||
preset.useFixedChairGap = limb.useFixedChairGap;
|
|
||||||
preset.chairHipsFixedGap = limb.chairHipsFixedGap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
presets[currentPresetName] = preset;
|
presets[currentPresetName] = preset;
|
||||||
@ -522,8 +519,6 @@ public class RetargetingControlWindow : EditorWindow
|
|||||||
limb.minDistance = preset.limbMinDistance;
|
limb.minDistance = preset.limbMinDistance;
|
||||||
limb.footHeightMinThreshold = preset.footHeightMinThreshold;
|
limb.footHeightMinThreshold = preset.footHeightMinThreshold;
|
||||||
limb.footHeightMaxThreshold = preset.footHeightMaxThreshold;
|
limb.footHeightMaxThreshold = preset.footHeightMaxThreshold;
|
||||||
limb.useFixedChairGap = preset.useFixedChairGap;
|
|
||||||
limb.chairHipsFixedGap = preset.chairHipsFixedGap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUtility.SetDirty(script);
|
EditorUtility.SetDirty(script);
|
||||||
@ -917,18 +912,6 @@ public class RetargetingControlWindow : EditorWindow
|
|||||||
|
|
||||||
EditorGUILayout.Space(5);
|
EditorGUILayout.Space(5);
|
||||||
|
|
||||||
// 의자 허리 고정 간격 설정 추가
|
|
||||||
var useFixedChairGap = serializedLimb.FindProperty("useFixedChairGap");
|
|
||||||
var chairHipsFixedGap = serializedLimb.FindProperty("chairHipsFixedGap");
|
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(useFixedChairGap, new GUIContent("의자 고정 간격 사용"));
|
|
||||||
if (useFixedChairGap.boolValue)
|
|
||||||
{
|
|
||||||
EditorGUILayout.Slider(chairHipsFixedGap, 0f, 0.3f, new GUIContent("의자-허리 고정 간격"));
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUILayout.Space(5);
|
|
||||||
|
|
||||||
// 바닥 기준 히프 높이 범위
|
// 바닥 기준 히프 높이 범위
|
||||||
EditorGUILayout.LabelField("바닥과 허리 높이에 의한 블렌딩 (가중치 0 -> 1)");
|
EditorGUILayout.LabelField("바닥과 허리 높이에 의한 블렌딩 (가중치 0 -> 1)");
|
||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
@ -1202,7 +1185,5 @@ public class RetargetingPreset
|
|||||||
public float limbMinDistance;
|
public float limbMinDistance;
|
||||||
public float footHeightMinThreshold;
|
public float footHeightMinThreshold;
|
||||||
public float footHeightMaxThreshold;
|
public float footHeightMaxThreshold;
|
||||||
public bool useFixedChairGap;
|
|
||||||
public float chairHipsFixedGap;
|
|
||||||
// ... 기타 필요한 설정들
|
// ... 기타 필요한 설정들
|
||||||
}
|
}
|
||||||
@ -20,10 +20,6 @@ namespace KindRetargeting
|
|||||||
[SerializeField, Range(0.1f, 1f)] public float hipsMinDistance = 0.2f; // 최소 거리 (가중치 1)
|
[SerializeField, Range(0.1f, 1f)] public float hipsMinDistance = 0.2f; // 최소 거리 (가중치 1)
|
||||||
[SerializeField, Range(0.1f, 1f)] public float hipsMaxDistance = 0.6f; // 최대 거리 (가중치 0)
|
[SerializeField, Range(0.1f, 1f)] public float hipsMaxDistance = 0.6f; // 최대 거리 (가중치 0)
|
||||||
|
|
||||||
[Header("의자 거리 기반 허리 높이 설정")]
|
|
||||||
[SerializeField] public bool useFixedChairGap = true; // 고정 간격 사용 여부
|
|
||||||
[SerializeField, Range(0f, 0.3f)] public float chairHipsFixedGap = 0.1f; // 의자와 허리 간 고정 간격
|
|
||||||
|
|
||||||
[Header("바닥 기준 히프 보정")]
|
[Header("바닥 기준 히프 보정")]
|
||||||
[SerializeField, Range(0.3f, 1f)] public float groundHipsMinHeight = 0f; // 최소 높이 (가중치 0)
|
[SerializeField, Range(0.3f, 1f)] public float groundHipsMinHeight = 0f; // 최소 높이 (가중치 0)
|
||||||
[SerializeField, Range(0.5f, 1.5f)] public float groundHipsMaxHeight = 0.5f; // 최대 높이 (가중치 1)
|
[SerializeField, Range(0.5f, 1.5f)] public float groundHipsMaxHeight = 0.5f; // 최대 높이 (가중치 1)
|
||||||
@ -300,67 +296,19 @@ namespace KindRetargeting
|
|||||||
Transform hipsTransform = crs.sourceAnimator.GetBoneTransform(HumanBodyBones.Hips);
|
Transform hipsTransform = crs.sourceAnimator.GetBoneTransform(HumanBodyBones.Hips);
|
||||||
if (hipsTransform != null && props != null)
|
if (hipsTransform != null && props != null)
|
||||||
{
|
{
|
||||||
float minChairHeight = float.MaxValue;
|
|
||||||
float minDistance = float.MaxValue;
|
float minDistance = float.MaxValue;
|
||||||
bool chairFound = false;
|
|
||||||
|
|
||||||
foreach (Transform prop in props)
|
foreach (Transform prop in props)
|
||||||
{
|
{
|
||||||
PropTypeController ptc = prop.GetComponent<PropTypeController>();
|
PropTypeController ptc = prop.GetComponent<PropTypeController>();
|
||||||
if (ptc != null && ptc.propType == EnumsList.PropType.Chair)
|
if (ptc != null && ptc.propType == EnumsList.PropType.Chair)
|
||||||
{
|
{
|
||||||
Vector3 chairPosition = prop.childCount > 0 ? prop.GetChild(0).position : prop.position;
|
float distance = Vector3.Distance(hipsTransform.position, prop.childCount > 0 ? prop.GetChild(0).position : prop.position);
|
||||||
float chairY = chairPosition.y;
|
minDistance = Mathf.Min(minDistance, distance);
|
||||||
float distance = Vector3.Distance(hipsTransform.position, chairPosition);
|
|
||||||
|
|
||||||
// 의자가 가까운 거리에 있을 때만 높이 조절
|
|
||||||
if (distance <= hipsMaxDistance)
|
|
||||||
{
|
|
||||||
minChairHeight = Mathf.Min(minChairHeight, chairY);
|
|
||||||
minDistance = Mathf.Min(minDistance, distance);
|
|
||||||
chairFound = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chairFound && useFixedChairGap)
|
float t = Mathf.Clamp01((minDistance - hipsMinDistance) / (hipsMaxDistance - hipsMinDistance));
|
||||||
{
|
hipsWeights[0] = t; // 직접 HipsWeightOffset 수정 대신 배열에 저장
|
||||||
// 목표 허리 높이 = 의자 높이 + 고정 간격
|
|
||||||
float targetHipsHeight = minChairHeight + chairHipsFixedGap;
|
|
||||||
float currentHipsHeight = hipsTransform.position.y;
|
|
||||||
|
|
||||||
// 허리 높이 조정값 계산 (절대값)
|
|
||||||
float heightAdjustment = targetHipsHeight - currentHipsHeight;
|
|
||||||
|
|
||||||
// CustomRetargetingScript에 높이 조정값 전달 (가중치 대신 절대값)
|
|
||||||
if (crs != null)
|
|
||||||
{
|
|
||||||
crs.HipsHeightAdjustment = heightAdjustment;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 기존 가중치 시스템도 유지 (필요시)
|
|
||||||
float t = Mathf.Clamp01((minDistance - hipsMinDistance) / (hipsMaxDistance - hipsMinDistance));
|
|
||||||
hipsWeights[0] = t;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 의자가 없거나 멀 때는 조정 안 함
|
|
||||||
if (crs != null)
|
|
||||||
{
|
|
||||||
crs.HipsHeightAdjustment = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 기존 가중치는 기본값으로 설정
|
|
||||||
if (chairFound)
|
|
||||||
{
|
|
||||||
float t = Mathf.Clamp01((minDistance - hipsMinDistance) / (hipsMaxDistance - hipsMinDistance));
|
|
||||||
hipsWeights[0] = t;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hipsWeights[0] = 1f; // 의자가 없을 때는 기본 가중치
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user