mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 14:47:51 +02:00
add rules for unity version and bone count limit
This commit is contained in:
parent
08344d5510
commit
a9895a90e5
2 changed files with 54 additions and 8 deletions
|
@ -18,7 +18,36 @@ class AvatarExporter : MonoBehaviour {
|
||||||
|
|
||||||
static readonly float HIPS_GROUND_MIN_Y = 0.01f;
|
static readonly float HIPS_GROUND_MIN_Y = 0.01f;
|
||||||
static readonly float HIPS_SPINE_CHEST_MIN_SEPARATION = 0.001f;
|
static readonly float HIPS_SPINE_CHEST_MIN_SEPARATION = 0.001f;
|
||||||
|
static readonly int MAXIMUM_USER_BONE_COUNT = 256;
|
||||||
static readonly string EMPTY_WARNING_TEXT = "None";
|
static readonly string EMPTY_WARNING_TEXT = "None";
|
||||||
|
|
||||||
|
static readonly string[] RECOMMENDED_UNITY_VERSIONS = new string[] {
|
||||||
|
"2018.2.12f1",
|
||||||
|
"2018.2.11f1",
|
||||||
|
"2018.2.10f1",
|
||||||
|
"2018.2.9f1",
|
||||||
|
"2018.2.8f1",
|
||||||
|
"2018.2.7f1",
|
||||||
|
"2018.2.6f1",
|
||||||
|
"2018.2.5f1",
|
||||||
|
"2018.2.4f1",
|
||||||
|
"2018.2.3f1",
|
||||||
|
"2018.2.2f1",
|
||||||
|
"2018.2.1f1",
|
||||||
|
"2018.2.0f2",
|
||||||
|
"2018.1.9f2",
|
||||||
|
"2018.1.8f1",
|
||||||
|
"2018.1.7f1",
|
||||||
|
"2018.1.6f1",
|
||||||
|
"2018.1.5f1",
|
||||||
|
"2018.1.4f1",
|
||||||
|
"2018.1.3f1",
|
||||||
|
"2018.1.2f1",
|
||||||
|
"2018.1.1f1",
|
||||||
|
"2018.1.0f2",
|
||||||
|
"2017.4.18f1",
|
||||||
|
"2017.4.17f1",
|
||||||
|
};
|
||||||
|
|
||||||
static readonly Dictionary<string, string> HUMANOID_TO_HIFI_JOINT_NAME = new Dictionary<string, string> {
|
static readonly Dictionary<string, string> HUMANOID_TO_HIFI_JOINT_NAME = new Dictionary<string, string> {
|
||||||
{"Chest", "Spine1"},
|
{"Chest", "Spine1"},
|
||||||
|
@ -136,19 +165,19 @@ class AvatarExporter : MonoBehaviour {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Humanoid mapping name suffixes for each set of appendages
|
// Humanoid mapping name suffixes for each set of appendages
|
||||||
static readonly string[] legMappingSuffixes = new string[] {
|
static readonly string[] LEG_MAPPING_SUFFIXES = new string[] {
|
||||||
"UpperLeg",
|
"UpperLeg",
|
||||||
"LowerLeg",
|
"LowerLeg",
|
||||||
"Foot",
|
"Foot",
|
||||||
"Toes",
|
"Toes",
|
||||||
};
|
};
|
||||||
static readonly string[] armMappingsSuffixes = new string[] {
|
static readonly string[] ARM_MAPPING_SUFFIXES = new string[] {
|
||||||
"Shoulder",
|
"Shoulder",
|
||||||
"UpperArm",
|
"UpperArm",
|
||||||
"LowerArm",
|
"LowerArm",
|
||||||
"Hand",
|
"Hand",
|
||||||
};
|
};
|
||||||
static readonly string[] handMappingsSuffixes = new string[] {
|
static readonly string[] HAND_MAPPING_SUFFIXES = new string[] {
|
||||||
" Index Distal",
|
" Index Distal",
|
||||||
" Index Intermediate",
|
" Index Intermediate",
|
||||||
" Index Proximal",
|
" Index Proximal",
|
||||||
|
@ -167,6 +196,7 @@ class AvatarExporter : MonoBehaviour {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BoneRule {
|
enum BoneRule {
|
||||||
|
RecommendedUnityVersion,
|
||||||
SingleRoot,
|
SingleRoot,
|
||||||
NoDuplicateMapping,
|
NoDuplicateMapping,
|
||||||
NoAsymmetricalLegMapping,
|
NoAsymmetricalLegMapping,
|
||||||
|
@ -183,10 +213,11 @@ class AvatarExporter : MonoBehaviour {
|
||||||
EyesMapped,
|
EyesMapped,
|
||||||
HipsNotOnGround,
|
HipsNotOnGround,
|
||||||
HipsSpineChestNotCoincident,
|
HipsSpineChestNotCoincident,
|
||||||
|
TotalBoneCountUnderLimit,
|
||||||
BoneRuleEnd,
|
BoneRuleEnd,
|
||||||
};
|
};
|
||||||
// rules that are treated as errors and prevent exporting, otherwise rules will show as warnings
|
// rules that are treated as errors and prevent exporting, otherwise rules will show as warnings
|
||||||
static readonly BoneRule[] exportBlockingBoneRules = new BoneRule[] {
|
static readonly BoneRule[] EXPORT_BLOCKING_BONE_RULES = new BoneRule[] {
|
||||||
BoneRule.HipsMapped,
|
BoneRule.HipsMapped,
|
||||||
BoneRule.SpineMapped,
|
BoneRule.SpineMapped,
|
||||||
BoneRule.ChestMapped,
|
BoneRule.ChestMapped,
|
||||||
|
@ -280,7 +311,7 @@ class AvatarExporter : MonoBehaviour {
|
||||||
string boneErrors = "";
|
string boneErrors = "";
|
||||||
string boneWarnings = "";
|
string boneWarnings = "";
|
||||||
foreach (var failedBoneRule in failedBoneRules) {
|
foreach (var failedBoneRule in failedBoneRules) {
|
||||||
if (Array.IndexOf(exportBlockingBoneRules, failedBoneRule.Key) >= 0) {
|
if (Array.IndexOf(EXPORT_BLOCKING_BONE_RULES, failedBoneRule.Key) >= 0) {
|
||||||
boneErrors += failedBoneRule.Value + "\n\n";
|
boneErrors += failedBoneRule.Value + "\n\n";
|
||||||
} else {
|
} else {
|
||||||
boneWarnings += failedBoneRule.Value + "\n\n";
|
boneWarnings += failedBoneRule.Value + "\n\n";
|
||||||
|
@ -635,6 +666,14 @@ class AvatarExporter : MonoBehaviour {
|
||||||
// to the failed bone rules map with appropriate error or warning text
|
// to the failed bone rules map with appropriate error or warning text
|
||||||
for (BoneRule boneRule = 0; boneRule < BoneRule.BoneRuleEnd; ++boneRule) {
|
for (BoneRule boneRule = 0; boneRule < BoneRule.BoneRuleEnd; ++boneRule) {
|
||||||
switch (boneRule) {
|
switch (boneRule) {
|
||||||
|
case BoneRule.RecommendedUnityVersion:
|
||||||
|
if (Array.IndexOf(RECOMMENDED_UNITY_VERSIONS, Application.unityVersion) == -1) {
|
||||||
|
failedBoneRules.Add(boneRule, "The current version of Unity is not one of the recommended Unity " +
|
||||||
|
"versions. If you are using a version of Unity later than 2018.2.12f1, " +
|
||||||
|
"it is recommended to apply Enforce T-Pose under the Pose dropdown " +
|
||||||
|
"in Humanoid configuration.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case BoneRule.SingleRoot:
|
case BoneRule.SingleRoot:
|
||||||
// bone rule fails if the root bone node has more than one child bone
|
// bone rule fails if the root bone node has more than one child bone
|
||||||
if (userBoneTree.children.Count > 1) {
|
if (userBoneTree.children.Count > 1) {
|
||||||
|
@ -659,13 +698,13 @@ class AvatarExporter : MonoBehaviour {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BoneRule.NoAsymmetricalLegMapping:
|
case BoneRule.NoAsymmetricalLegMapping:
|
||||||
CheckAsymmetricalMappingRule(boneRule, legMappingSuffixes, "leg");
|
CheckAsymmetricalMappingRule(boneRule, LEG_MAPPING_SUFFIXES, "leg");
|
||||||
break;
|
break;
|
||||||
case BoneRule.NoAsymmetricalArmMapping:
|
case BoneRule.NoAsymmetricalArmMapping:
|
||||||
CheckAsymmetricalMappingRule(boneRule, armMappingsSuffixes, "arm");
|
CheckAsymmetricalMappingRule(boneRule, ARM_MAPPING_SUFFIXES, "arm");
|
||||||
break;
|
break;
|
||||||
case BoneRule.NoAsymmetricalHandMapping:
|
case BoneRule.NoAsymmetricalHandMapping:
|
||||||
CheckAsymmetricalMappingRule(boneRule, handMappingsSuffixes, "hand");
|
CheckAsymmetricalMappingRule(boneRule, HAND_MAPPING_SUFFIXES, "hand");
|
||||||
break;
|
break;
|
||||||
case BoneRule.HipsMapped:
|
case BoneRule.HipsMapped:
|
||||||
hipsUserBone = CheckHumanBoneMappingRule(boneRule, "Hips");
|
hipsUserBone = CheckHumanBoneMappingRule(boneRule, "Hips");
|
||||||
|
@ -751,6 +790,13 @@ class AvatarExporter : MonoBehaviour {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case BoneRule.TotalBoneCountUnderLimit:
|
||||||
|
int userBoneCount = userBoneInfos.Count;
|
||||||
|
if (userBoneCount > MAXIMUM_USER_BONE_COUNT) {
|
||||||
|
failedBoneRules.Add(boneRule, "The total number of bones in the avatar (" + userBoneCount +
|
||||||
|
") exceeds the maximum bone limit (" + MAXIMUM_USER_BONE_COUNT + ").");
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue