Skip to content

Commit 0802484

Browse files
committed
Shifter blueprints: fix build from serialized guide and squash and streach sampling fix #621
1 parent 34a0482 commit 0802484

3 files changed

Lines changed: 39 additions & 15 deletions

File tree

‎release/scripts/mgear/shifter/component/__init__.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ def __init__(self, rig, guide):
6666
self.model = self.rig.model
6767
# Use merged values to apply blueprint settings when enabled
6868
self.settings = self.guide.getMergedValues()
69+
# Propagate merged FCurve values back into paramDefs. getMergedValues()
70+
# may replace profile samples with the blueprint's correctly-sized list
71+
# (blueprint was sampled with its own div0/div1), but paramDef.value
72+
# still holds the local guide's samples at the local division count.
73+
# Syncing here ensures the component's if-branch sees the right length.
74+
for param_def in self.guide.paramDefs.values():
75+
if isinstance(param_def, attribute.FCurveParamDef):
76+
merged_val = self.settings.get(param_def.scriptName)
77+
if merged_val is not None:
78+
param_def.value = merged_val
6979
self.setupWS = self.rig.setupWS
7080

7181
self.WIP = self.options["mode"]

‎release/scripts/mgear/shifter/component/guide.py‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -296,27 +296,33 @@ def getMergedValues(self):
296296
# Start with a copy of local values
297297
merged = dict(self.values)
298298

299-
# Check if we have a model (guide root)
300-
if not hasattr(self, 'model') or not self.model:
301-
return merged
302-
303-
# Check if blueprint is enabled on the main guide
304-
if not self.model.hasAttr("use_blueprint"):
299+
# Resolve blueprint settings from Maya node (live guide) or from the
300+
# model_options dict injected by set_from_dict (serialized build path).
301+
if hasattr(self, "model") and self.model:
302+
# Live guide: read directly from the Maya guide root node.
303+
if not self.model.hasAttr("use_blueprint"):
304+
return merged
305+
use_blueprint = self.model.attr("use_blueprint").get()
306+
blueprint_path = self.model.attr("blueprint_path").get()
307+
# Per-component local override stored as a Maya attribute.
308+
local_override = False
309+
if self.root and self.root.hasAttr("blueprint_local_override"):
310+
local_override = self.root.attr("blueprint_local_override").get()
311+
elif hasattr(self, "model_options"):
312+
# Serialized build: values forwarded by Main.set_from_dict.
313+
use_blueprint = self.model_options.get("use_blueprint", False)
314+
blueprint_path = self.model_options.get("blueprint_path", "")
315+
# Per-component local override is already in self.values.
316+
local_override = self.values.get("blueprint_local_override", False)
317+
else:
305318
return merged
306319

307-
use_blueprint = self.model.attr("use_blueprint").get()
308320
if not use_blueprint:
309321
return merged
310322

311-
# Check if local override is enabled for this component
312-
if self.root.hasAttr("blueprint_local_override"):
313-
local_override = self.root.attr("blueprint_local_override").get()
314-
if local_override:
315-
# Use local settings
316-
return merged
323+
if local_override:
324+
return merged
317325

318-
# Get blueprint path
319-
blueprint_path = self.model.attr("blueprint_path").get()
320326
if not blueprint_path:
321327
return merged
322328

‎release/scripts/mgear/shifter/guide.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,13 @@ def set_from_dict(self, guide_template_dict):
990990
components_dict = guide_template_dict["components_dict"]
991991
self.componentsIndex = guide_template_dict["components_list"]
992992

993+
# Blueprint settings from the guide root, forwarded to component guides
994+
# so getMergedValues() works on the dict-build path (no Maya nodes).
995+
model_blueprint_options = {
996+
"use_blueprint": self.values.get("use_blueprint", False),
997+
"blueprint_path": self.values.get("blueprint_path", ""),
998+
}
999+
9931000
for comp in self.componentsIndex:
9941001

9951002
c_dict = components_dict[comp]
@@ -1000,6 +1007,7 @@ def set_from_dict(self, guide_template_dict):
10001007
if comp_guide:
10011008
self.components[comp] = comp_guide
10021009
comp_guide.set_from_dict(c_dict)
1010+
comp_guide.model_options = model_blueprint_options
10031011

10041012
pName = c_dict["parent_fullName"]
10051013
if pName:

0 commit comments

Comments
 (0)