Skip to content

Commit

Permalink
the first step on handle meshCombinator
Browse files Browse the repository at this point in the history
  • Loading branch information
UlyssesWu committed Dec 25, 2024
1 parent 6cf5927 commit a794cbd
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions FreeMote.PsBuild/MmoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit a794cbd

Please sign in to comment.