From a794cbdb20b82aa9bcd55177177169287bb8cec3 Mon Sep 17 00:00:00 2001 From: Ulysses Wu Date: Thu, 26 Dec 2024 01:38:29 +0800 Subject: [PATCH] the first step on handle `meshCombinator` --- FreeMote.PsBuild/MmoBuilder.cs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/FreeMote.PsBuild/MmoBuilder.cs b/FreeMote.PsBuild/MmoBuilder.cs index 08d6f76..7efb818 100644 --- a/FreeMote.PsBuild/MmoBuilder.cs +++ b/FreeMote.PsBuild/MmoBuilder.cs @@ -407,7 +407,7 @@ PsbList BuildChildrenFromMotion(PsbDictionary dic, IPsbCollection parent) objectChildrenItem["metadata"] = motionItem["metadata"] is PsbNull ? FillDefaultMetadata() : motionItem["metadata"]; //TODO: should we set all to default? var parameter = (PsbList)motionItem["parameter"]; objectChildrenItem["parameterize"] = motionItem["parameterize"] is PsbNull - ? FillDefaultParameterize() + ? FillDefaultParameterize(dic) : parameter[((PsbNumber)motionItem["parameterize"]).IntValue]; objectChildrenItem["priorityFrameList"] = BuildPriorityFrameList((PsbList)motionItem["priority"]); objectChildrenItem["referenceModelFileList"] = motionItem["referenceModelFileList"]; @@ -452,12 +452,6 @@ void BuildLayerChildren(IPsbCollection child, PsbList parameter) dic["className"] = classType.ToString().ToPsbString(); dic["comment"] = PsbString.Empty; - //remove meshCombinator - if (dic.ContainsKey("meshCombinator")) - { - dic.Remove("meshCombinator"); - } - //Build frameList MmoFrameMask frameMask = 0; MmoFrameMaskEx frameMaskEx = 0; @@ -476,7 +470,13 @@ void BuildLayerChildren(IPsbCollection child, PsbList parameter) } else { - dic["parameterize"] = FillDefaultParameterize(); + dic["parameterize"] = FillDefaultParameterize(dic); + } + + //remove meshCombinator //TODO: recover this + if (dic.ContainsKey("meshCombinator")) + { + dic.Remove("meshCombinator"); } //Disable features @@ -1473,8 +1473,22 @@ private static void FillDefaultsIntoFrameListContent(PsbDictionary content, bool return; } - private static IPsbValue FillDefaultParameterize() + private static IPsbValue FillDefaultParameterize(PsbDictionary parent) { + if (parent["parameterize"] is PsbNull && parent.ContainsKey("meshCombinator") && parent["meshCombinator"] is PsbDictionary meshCombinator + && meshCombinator.TryGetValue("combinatorList", out var combinatorListObj) && combinatorListObj is PsbList + { Count: > 0 } combinatorList && combinatorList[0] is PsbDictionary combinator + && combinator.TryGetValue("variable", out var variableObj) && variableObj is PsbDictionary variable) // pick from meshCombinator + { + return new PsbDictionary(5) + { + {"discretization", PsbNumber.Zero}, + {"enabled", 1.ToPsbNumber()}, + {"id", variable["key"]}, + {"rangeBegin", variable["rangeBegin"]}, + {"rangeEnd", variable["rangeEnd"]}, + }; + } return new PsbDictionary(5) { {"discretization", PsbNumber.Zero },