simplex-solver 3.1.0__39-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. simplex_solver-3.1.0.dist-info/METADATA +90 -0
  2. simplex_solver-3.1.0.dist-info/RECORD +79 -0
  3. simplex_solver-3.1.0.dist-info/WHEEL +5 -0
  4. simplexui/__init__.py +53 -0
  5. simplexui/_version.py +1 -0
  6. simplexui/channelBox.py +858 -0
  7. simplexui/comboCheckDialog.py +343 -0
  8. simplexui/commands/__init__.py +16 -0
  9. simplexui/commands/alembicCommon.py +991 -0
  10. simplexui/commands/applyCorrectives.py +451 -0
  11. simplexui/commands/correctiveInterface.py +261 -0
  12. simplexui/commands/expandedExport.py +436 -0
  13. simplexui/commands/hdf5Convert.py +60 -0
  14. simplexui/commands/mayaCorrectiveInterface.py +161 -0
  15. simplexui/commands/mayatonumpy.py +375 -0
  16. simplexui/commands/mesh.py +1081 -0
  17. simplexui/commands/numpytoimath.py +319 -0
  18. simplexui/commands/poseblendlib.py +166 -0
  19. simplexui/commands/reorderSimplexPoints.py +102 -0
  20. simplexui/commands/rigidAlign.py +99 -0
  21. simplexui/commands/smpxBlend.py +629 -0
  22. simplexui/commands/unsubdivide.py +1227 -0
  23. simplexui/commands/uvTransfer.py +977 -0
  24. simplexui/dragFilter.py +299 -0
  25. simplexui/falloffDialog.py +471 -0
  26. simplexui/img/ChefHead.png +0 -0
  27. simplexui/img/frozen.png +0 -0
  28. simplexui/interface/__init__.py +28 -0
  29. simplexui/interface/dummyInterface.py +1585 -0
  30. simplexui/interface/mayaInterface.py +3271 -0
  31. simplexui/interfaceModel.py +1053 -0
  32. simplexui/interfaceModelTrees.py +441 -0
  33. simplexui/items/__init__.py +42 -0
  34. simplexui/items/accessor.py +213 -0
  35. simplexui/items/combo.py +852 -0
  36. simplexui/items/falloff.py +778 -0
  37. simplexui/items/group.py +297 -0
  38. simplexui/items/progression.py +743 -0
  39. simplexui/items/shape.py +443 -0
  40. simplexui/items/simplex.py +1764 -0
  41. simplexui/items/slider.py +738 -0
  42. simplexui/items/stack.py +154 -0
  43. simplexui/items/traversal.py +966 -0
  44. simplexui/main.pyw +22 -0
  45. simplexui/menu/__init__.py +69 -0
  46. simplexui/menu/dummyPlugins/__init__.py +16 -0
  47. simplexui/menu/genericPlugins/__init__.py +16 -0
  48. simplexui/menu/genericPlugins/_builtins.py +268 -0
  49. simplexui/menu/genericPlugins/checkPossibleCombos.py +45 -0
  50. simplexui/menu/genericPlugins/exportSplit.py +59 -0
  51. simplexui/menu/genericPlugins/showFalloffs.py +24 -0
  52. simplexui/menu/genericPlugins/showTraversals.py +24 -0
  53. simplexui/menu/genericPlugins/simplexUvTransfer.py +107 -0
  54. simplexui/menu/genericPlugins/unsubdivide.py +70 -0
  55. simplexui/menu/mayaPlugins/__init__.py +16 -0
  56. simplexui/menu/mayaPlugins/exportOther.py +43 -0
  57. simplexui/menu/mayaPlugins/extractProgressives.py +65 -0
  58. simplexui/menu/mayaPlugins/freezeCombo.py +245 -0
  59. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +97 -0
  60. simplexui/menu/mayaPlugins/importObjs.py +193 -0
  61. simplexui/menu/mayaPlugins/linearizeTraversal.py +48 -0
  62. simplexui/menu/mayaPlugins/makeShelfBtn.py +65 -0
  63. simplexui/menu/mayaPlugins/relaxToSelection.py +75 -0
  64. simplexui/menu/mayaPlugins/reloadDefinition.py +33 -0
  65. simplexui/menu/mayaPlugins/snapToNeutral.py +72 -0
  66. simplexui/menu/mayaPlugins/softSelectToCluster.py +200 -0
  67. simplexui/menu/mayaPlugins/tweakMix.py +134 -0
  68. simplexui/menu/mayaPlugins/updateRestShape.py +105 -0
  69. simplexui/pysimplex.dll.a +0 -0
  70. simplexui/pysimplex.pyd +0 -0
  71. simplexui/simplexDialog.py +1454 -0
  72. simplexui/travCheckDialog.py +397 -0
  73. simplexui/traversalDialog.py +271 -0
  74. simplexui/ui/comboCheckDialog.ui +475 -0
  75. simplexui/ui/falloffDialog.ui +243 -0
  76. simplexui/ui/simplexDialog.ui +1458 -0
  77. simplexui/ui/travCheckDialog.ui +488 -0
  78. simplexui/ui/traversalDialog.ui +532 -0
  79. simplexui/utils.py +320 -0
@@ -0,0 +1,629 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from ..items import (
19
+ Combo,
20
+ ComboPair,
21
+ Falloff,
22
+ Group,
23
+ ProgPair,
24
+ Progression,
25
+ Shape,
26
+ Simplex,
27
+ Slider,
28
+ Traversal,
29
+ TravPair,
30
+ )
31
+
32
+
33
+ class Skip(object):
34
+ """A pseudo-singleton object to signify completely skipping the un-matched shape
35
+ This will be used by running ``smpxMismatchCheck``, taking the dict, and manually
36
+ telling it to ``Skip`` certain shapes
37
+ """
38
+
39
+ pass
40
+
41
+
42
+ def smpxMismatchCheck(simpA, simpB):
43
+ """Search for mismatches between two simplex systems
44
+
45
+ Parameters
46
+ ----------
47
+ simpA : Simplex
48
+ A simplex system
49
+ simpB : Simplex
50
+ A simplex system
51
+
52
+ Returns
53
+ -------
54
+ : {str: {str: (object, object)}}
55
+ A structure of dict[objectType][objectName]
56
+ That returns an ordered pair of objects. The object is None if it doesn't
57
+ exist in (simplexA, simplexB)
58
+ """
59
+ mmDict = {}
60
+
61
+ # saShapeNames = {sa.name: sa for sa in simpA.shapes}
62
+ # sbShapeNames = {sb.name: sb for sb in simpB.shapes}
63
+ # saShapeNameUnique = saShapeNames.viewkeys() - sbShapeNames.viewkeys()
64
+ # sbShapeNameUnique = sbShapeNames.viewkeys() - saShapeNames.viewkeys()
65
+ # slnMatch = [(san, None) for san in saShapeNameUnique] + [(None, sbn) for sbn in sbShapeNameUnique]
66
+ # mmDict['shape'] = slnMatch
67
+
68
+ saSliderNames = {sa.name: sa for sa in simpA.sliders}
69
+ sbSliderNames = {sb.name: sb for sb in simpB.sliders}
70
+ saSliderNameUnique = saSliderNames.keys() - sbSliderNames.keys()
71
+ sbSliderNameUnique = sbSliderNames.keys() - saSliderNames.keys()
72
+ slnMatch = {}
73
+ for san in saSliderNameUnique:
74
+ slnMatch[san] = (san, None)
75
+ for sbn in sbSliderNameUnique:
76
+ slnMatch[sbn] = (None, sbn)
77
+ mmDict["slider"] = slnMatch
78
+
79
+ saComboNames = {sa.name: sa for sa in simpA.combos}
80
+ sbComboNames = {sb.name: sb for sb in simpB.combos}
81
+ saComboNameUnique = saComboNames.keys() - sbComboNames.keys()
82
+ sbComboNameUnique = sbComboNames.keys() - saComboNames.keys()
83
+ # TODO search for combos with mis-ordered inputs
84
+ cnMatch = {}
85
+ for can in saComboNameUnique:
86
+ cnMatch[can] = (can, None)
87
+ for cbn in sbComboNameUnique:
88
+ cnMatch[cbn] = (None, cbn)
89
+ mmDict["combo"] = cnMatch
90
+
91
+ saTravNames = {sa.name: sa for sa in simpA.traversals}
92
+ sbTravNames = {sb.name: sb for sb in simpB.traversals}
93
+ saTravNameUnique = saTravNames.keys() - sbTravNames.keys()
94
+ sbTravNameUnique = sbTravNames.keys() - saTravNames.keys()
95
+ # TODO search for travs with mis-ordered inputs
96
+ tnMatch = {}
97
+ for tan in saTravNameUnique:
98
+ tnMatch[tan] = (tan, None)
99
+ for tbn in sbTravNameUnique:
100
+ tnMatch[tbn] = (None, tbn)
101
+ mmDict["traversal"] = tnMatch
102
+
103
+ return mmDict
104
+
105
+
106
+ def orderedMerge(va, vb):
107
+ """Merge two sets, keeping some semblance of order
108
+
109
+ Parameters
110
+ ----------
111
+ va : set
112
+ A set
113
+ vb : set
114
+ A set
115
+
116
+ Returns
117
+ -------
118
+ : list
119
+ An ordered list
120
+ """
121
+ # come up with a better way that keeps some of the input structure
122
+ return sorted(set(va) | set(vb))
123
+
124
+
125
+ # Falloffs
126
+ def mergeFalloffs(simpA, simpB, outSimp, translation, nameOnly=True):
127
+ """Merge the falloffs between two simplex systems
128
+
129
+ Parameters
130
+ ----------
131
+ simpA : Simplex
132
+ The master Simplex
133
+ simpB : Simplex
134
+ A simplex system to merge
135
+ outSimp : Simplex
136
+ The output simplex that is being built
137
+ translation : {object: object}
138
+ A dictionary of input objects to output objects
139
+ nameOnly : bool
140
+ Whether to match the falloffs by name only.
141
+ Defaults to True. False is not implemented yet
142
+ """
143
+ if not nameOnly:
144
+ raise ValueError("Not implemented yet")
145
+ aNames = [f.name for f in simpA.falloffs]
146
+ aDict = dict(zip(aNames, simpA.falloffs))
147
+ bNames = [f.name for f in simpB.falloffs]
148
+ bDict = dict(zip(bNames, simpB.falloffs))
149
+ oNames = orderedMerge(aNames, bNames)
150
+ for oName in oNames:
151
+ baseFo = aDict.get(oName, bDict[oName])
152
+ if baseFo.splitType == "planar":
153
+ data = (
154
+ baseFo.splitType,
155
+ baseFo.axis,
156
+ baseFo.maxVal,
157
+ baseFo.maxHandle,
158
+ baseFo.minHandle,
159
+ baseFo.minVal,
160
+ )
161
+ else:
162
+ data = (baseFo.splitType, baseFo.mapName)
163
+ fo = Falloff(oName, outSimp, *data)
164
+ translation[aDict.get(oName)] = fo
165
+ translation[bDict.get(oName)] = fo
166
+
167
+
168
+ # Groups
169
+ def _mergeGroupSubset(aTypedGroups, bTypedGroups, outSimp, gType, translation):
170
+ asG = [g.name for g in aTypedGroups]
171
+ bsG = [g.name for g in bTypedGroups]
172
+ asGDict = dict(zip(asG, aTypedGroups))
173
+ bsGDict = dict(zip(bsG, bTypedGroups))
174
+ osG = orderedMerge(asG, bsG)
175
+ for groupName in osG:
176
+ newGroup = Group(groupName, outSimp, gType)
177
+ translation[asGDict.get(groupName)] = newGroup
178
+ translation[bsGDict.get(groupName)] = newGroup
179
+
180
+
181
+ def mergeGroups(simpA, simpB, outSimp, translation):
182
+ """Merge the groups from simpA and simpB
183
+
184
+ Parameters
185
+ ----------
186
+ simpA : Simplex
187
+ The master Simplex
188
+ simpB : Simplex
189
+ A simplex system to merge
190
+ outSimp : Simplex
191
+ The output simplex that is being built
192
+ translation : {object: object}
193
+ A dictionary of input objects to output objects
194
+ """
195
+ _mergeGroupSubset(
196
+ simpA.sliderGroups, simpB.sliderGroups, outSimp, Slider, translation
197
+ )
198
+ _mergeGroupSubset(simpA.comboGroups, simpB.comboGroups, outSimp, Combo, translation)
199
+ _mergeGroupSubset(
200
+ simpA.traversalGroups, simpB.traversalGroups, outSimp, Traversal, translation
201
+ )
202
+
203
+
204
+ # Shapes
205
+ def _blendShape(aShape, bShape, outSimp, blendVal, translation):
206
+ if aShape in translation or bShape in translation:
207
+ return translation.get(aShape, translation[bShape])
208
+
209
+ newShape = Shape(aShape.name, outSimp, create=True)
210
+
211
+ aDeltas = aShape.verts - aShape.simplex.restShape.verts
212
+ bDeltas = bShape.verts - bShape.simplex.restShape.verts
213
+ deltas = aDeltas * (1.0 - blendVal) + bDeltas * blendVal
214
+ newShape.verts = outSimp.restShape.verts + deltas
215
+
216
+ translation[aShape] = newShape
217
+ translation[bShape] = newShape
218
+ return newShape
219
+
220
+
221
+ def _copyShape(shape, outSimp, translation, deltaOverride=None):
222
+ if shape in translation:
223
+ return translation[shape]
224
+ newShape = Shape(shape.name, outSimp, create=True)
225
+
226
+ if deltaOverride is None:
227
+ deltas = shape.verts - shape.simplex.restShape.verts
228
+ newShape.verts = outSimp.restShape.verts + deltas
229
+ else:
230
+ newShape.verts = deltaOverride
231
+
232
+ translation[shape] = newShape
233
+ return newShape
234
+
235
+
236
+ # Progs
237
+ def _deltaProg(shape, srcMin, srcMax, tarMin, tarMax, tVal):
238
+ srcExtDelta = tVal * (srcMax.verts - srcMin.verts)
239
+ srcShpDelta = shape.verts - srcMin.verts
240
+ srcOffset = srcShpDelta - srcExtDelta
241
+ ret = tVal * (tarMax.verts - tarMin.verts) + srcOffset
242
+ return ret
243
+
244
+
245
+ def _blendProg(aProg, bProg, outSimp, blendVal, translation):
246
+ aVals = [float(pp.value) for pp in aProg.pairs]
247
+ bVals = [float(pp.value) for pp in bProg.pairs]
248
+ commonVals = sorted(set(aVals) & set(bVals))
249
+ aUniq = set(aVals) - set(commonVals)
250
+ bUniq = set(bVals) - set(commonVals)
251
+ aValDict = dict(zip(aVals, aProg.pairs))
252
+ bValDict = dict(zip(bVals, bProg.pairs))
253
+
254
+ # First handle all the common values
255
+ outValDict = {}
256
+ for c in commonVals:
257
+ newShape = _blendShape(
258
+ aValDict[c].shape, bValDict[c].shape, outSimp, blendVal, translation
259
+ )
260
+ outValDict[c] = newShape
261
+
262
+ # Then handle any unique extremes
263
+ if 1.0 in aUniq:
264
+ outValDict[1.0] = _copyShape(aValDict[1.0].shape, outSimp, translation)
265
+ if -1.0 in aUniq:
266
+ outValDict[-1.0] = _copyShape(aValDict[-1.0].shape, outSimp, translation)
267
+ if 1.0 in bUniq:
268
+ outValDict[1.0] = _copyShape(bValDict[1.0].shape, outSimp, translation)
269
+ if -1.0 in bUniq:
270
+ outValDict[-1.0] = _copyShape(bValDict[-1.0].shape, outSimp, translation)
271
+
272
+ # Finally handle the unique progressions as deltas off the extremes
273
+ outRest = outValDict[0.0]
274
+ aRest = aValDict[0.0].shape
275
+ for c in aUniq:
276
+ aShp = aValDict[c].shape
277
+ mm = 1.0 if c > 0.0 else -1.0
278
+ dd = _deltaProg(
279
+ aShp, aRest, aValDict[mm].shape, outRest, outValDict[mm], mm * c
280
+ )
281
+ outValDict[c] = _copyShape(aShp, outSimp, translation, deltaOverride=dd)
282
+
283
+ bRest = bValDict[0.0].shape
284
+ for c in bUniq:
285
+ bShp = bValDict[c].shape
286
+ mm = 1.0 if c > 0.0 else -1.0
287
+ dd = _deltaProg(
288
+ bShp, bRest, bValDict[mm].shape, outRest, outValDict[mm], mm * c
289
+ )
290
+ outValDict[c] = _copyShape(bShp, outSimp, translation, deltaOverride=dd)
291
+
292
+ outPairs = [
293
+ ProgPair(outSimp, outValDict[val], val) for val in sorted(outValDict.keys())
294
+ ]
295
+ prog = Progression(aProg.name, outSimp, pairs=outPairs, interp=aProg.interp)
296
+ translation[aProg] = prog
297
+ translation[bProg] = prog
298
+ return prog
299
+
300
+
301
+ def _copyProg(prog, outSimp, translation):
302
+ pairs = []
303
+ for pp in prog.pairs:
304
+ newShape = _copyShape(pp.shape, outSimp, translation)
305
+ pair = ProgPair(outSimp, newShape, pp.value)
306
+ pairs.append(pair)
307
+ outProg = Progression(prog.name, outSimp, pairs=pairs, interp=prog.interp)
308
+ translation[prog] = outProg
309
+ return outProg
310
+
311
+
312
+ # Sliders
313
+ def _blendSliders(aSlider, bSlider, outSimp, blendVal, translation):
314
+ if aSlider in translation or bSlider in translation:
315
+ return translation.get(aSlider, translation[bSlider])
316
+
317
+ group = translation.get(aSlider.group, translation[bSlider.group])
318
+ prog = _blendProg(aSlider.prog, bSlider.prog, outSimp, blendVal, translation)
319
+ outSlider = Slider(aSlider.name, outSimp, prog, group)
320
+ translation[aSlider] = outSlider
321
+ translation[bSlider] = outSlider
322
+ return outSlider
323
+
324
+
325
+ def _copySlider(slider, outSimp, translation):
326
+ if slider in translation:
327
+ return translation[slider]
328
+
329
+ group = translation[slider.group]
330
+ prog = _copyProg(slider.prog, outSimp, translation)
331
+ outSlider = Slider(slider.name, outSimp, prog, group)
332
+ translation[slider] = outSlider
333
+ return outSlider
334
+
335
+
336
+ def sliderBlend(simpA, simpB, outSimp, blendVal, translation, mismatch):
337
+ """Blend between the sliders of simpA and simpB
338
+
339
+ Parameters
340
+ ----------
341
+ simpA : Simplex
342
+ The master Simplex
343
+ simpB : Simplex
344
+ A simplex system to merge
345
+ outSimp : Simplex
346
+ The output simplex that is being built
347
+ blendVal : float
348
+ The 0 to 1 blend value between the simplices
349
+ translation : {object: object}
350
+ A dictionary of input objects to output objects
351
+ mismatch : dict
352
+ The crazy mismatch dict from ``smpxMismatchCheck``
353
+ """
354
+ aNames = [s.name for s in simpA.sliders]
355
+ aDict = dict(zip(aNames, simpA.sliders))
356
+ bNames = [s.name for s in simpB.sliders]
357
+ bDict = dict(zip(bNames, simpB.sliders))
358
+ oNames = orderedMerge(aNames, bNames)
359
+
360
+ for oIdx, oName in enumerate(oNames):
361
+ print("Copying Slider {0} of {1}: {2}".format(oIdx, len(oNames), oName))
362
+ aName, bName = mismatch["slider"].get(oName, (oName, oName))
363
+ if aName is Skip or bName is Skip:
364
+ continue
365
+ elif aName is None:
366
+ _copySlider(bDict[bName], outSimp, translation)
367
+ elif bName is None:
368
+ _copySlider(aDict[aName], outSimp, translation)
369
+ else:
370
+ _blendSliders(aDict[aName], bDict[bName], outSimp, blendVal, translation)
371
+
372
+
373
+ # Combos
374
+ def _blendCombos(aCombo, bCombo, outSimp, blendVal, translation):
375
+ if aCombo in translation or bCombo in translation:
376
+ return translation.get(aCombo, translation[bCombo])
377
+
378
+ group = translation.get(aCombo.group, translation[bCombo.group])
379
+
380
+ cPairs = []
381
+ for aPair, bPair in zip(aCombo.pairs, bCombo.pairs):
382
+ slider = _blendSliders(
383
+ aPair.slider, bPair.slider, outSimp, blendVal, translation
384
+ )
385
+ cPairs.append(ComboPair(slider, aPair.value))
386
+
387
+ prog = _blendProg(aCombo.prog, bCombo.prog, outSimp, blendVal, translation)
388
+ outCombo = Combo(aCombo.name, outSimp, cPairs, prog, group, aCombo.solveType)
389
+ translation[aCombo] = outCombo
390
+ translation[bCombo] = outCombo
391
+ return outCombo
392
+
393
+
394
+ def _copyCombo(combo, outSimp, translation):
395
+ if combo in translation:
396
+ return translation[combo]
397
+ group = translation[combo.group]
398
+
399
+ cPairs = []
400
+ for pair in combo.pairs:
401
+ slider = _copySlider(pair.slider, outSimp, translation)
402
+ cPairs.append(ComboPair(slider, pair.value))
403
+ prog = _copyProg(combo.prog, outSimp, translation)
404
+
405
+ outCombo = Combo(combo.name, outSimp, cPairs, prog, group, combo.solveType)
406
+ translation[combo] = outCombo
407
+ return outCombo
408
+
409
+
410
+ def comboBlend(simpA, simpB, outSimp, blendVal, translation, mismatch):
411
+ """Blend between the combos of simpA and simpB
412
+
413
+ Parameters
414
+ ----------
415
+ simpA : Simplex
416
+ The master Simplex
417
+ simpB : Simplex
418
+ A simplex system to merge
419
+ outSimp : Simplex
420
+ The output simplex that is being built
421
+ blendVal : float
422
+ The 0 to 1 blend value between the simplices
423
+ translation : {object: object}
424
+ A dictionary of input objects to output objects
425
+ mismatch : dict
426
+ The crazy mismatch dict from ``smpxMismatchCheck``
427
+ """
428
+ aNames = [s.name for s in simpA.combos]
429
+ aDict = dict(zip(aNames, simpA.combos))
430
+ bNames = [s.name for s in simpB.combos]
431
+ bDict = dict(zip(bNames, simpB.combos))
432
+ oNames = orderedMerge(aNames, bNames)
433
+
434
+ for oIdx, oName in enumerate(oNames):
435
+ print("Copying Combo {0} of {1}: {2}".format(oIdx, len(oNames), oName))
436
+ aName, bName = mismatch["combo"].get(oName, (oName, oName))
437
+
438
+ if oName in mismatch:
439
+ print("Getting", oName)
440
+ print("Mismatch Get", oName in mismatch, aName, bName)
441
+
442
+ if aName is Skip or bName is Skip:
443
+ continue
444
+ elif aName is None:
445
+ _copyCombo(bDict[bName], outSimp, translation)
446
+ elif bName is None:
447
+ _copyCombo(aDict[aName], outSimp, translation)
448
+ else:
449
+ _blendCombos(aDict[aName], bDict[bName], outSimp, blendVal, translation)
450
+
451
+
452
+ # Traversals
453
+ def _blendController(aItem, bItem, outSimp, blendVal, translation):
454
+ aCtrl = aItem.controller
455
+ bCtrl = bItem.controller
456
+
457
+ if isinstance(aCtrl, Slider):
458
+ ctrl = _blendSliders(aCtrl, bCtrl, outSimp, blendVal, translation)
459
+ elif isinstance(aCtrl, Combo):
460
+ ctrl = _blendCombos(aCtrl, bCtrl, outSimp, blendVal, translation)
461
+ else:
462
+ raise ValueError("Bad object type: {0} {1}".format(aCtrl, type(aCtrl)))
463
+ return TravPair(ctrl, aItem.value, aItem.usage)
464
+
465
+
466
+ def _copyController(item, outSimp, translation):
467
+ iCtrl = item.controller
468
+ if isinstance(iCtrl, Slider):
469
+ ctrl = _copySlider(iCtrl, outSimp, translation)
470
+ elif isinstance(iCtrl, Combo):
471
+ ctrl = _copyCombo(iCtrl, outSimp, translation)
472
+ else:
473
+ raise ValueError("Bad object type: {0} {1}".format(iCtrl, type(iCtrl)))
474
+ return TravPair(ctrl, item.value, item.usage)
475
+
476
+
477
+ def _blendTraversals(aTrav, bTrav, outSimp, blendVal, translation):
478
+ group = translation.get(aTrav.group, translation[bTrav.group])
479
+ multCtrl = _blendController(
480
+ aTrav.multiplierCtrl, bTrav.multiplierCtrl, outSimp, blendVal, translation
481
+ )
482
+ progCtrl = _blendController(
483
+ aTrav.progressCtrl, bTrav.progressCtrl, outSimp, blendVal, translation
484
+ )
485
+ prog = _blendProg(aTrav.prog, bTrav.prog, outSimp, blendVal, translation)
486
+ outTrav = Traversal(aTrav.name, outSimp, multCtrl, progCtrl, prog, group)
487
+ translation[aTrav] = outTrav
488
+ translation[bTrav] = outTrav
489
+ return outTrav
490
+
491
+
492
+ def _copyTraversal(traversal, outSimp, translation):
493
+ group = translation[traversal.group]
494
+ multCtrl = _copyController(traversal.multiplierCtrl, outSimp, translation)
495
+ progCtrl = _copyController(traversal.progressCtrl, outSimp, translation)
496
+ prog = _copyProg(traversal.prog, outSimp, translation)
497
+ outTrav = Traversal(traversal.name, outSimp, multCtrl, progCtrl, prog, group)
498
+ translation[traversal] = outTrav
499
+ return outTrav
500
+
501
+
502
+ def traversalBlend(simpA, simpB, outSimp, blendVal, translation, mismatch):
503
+ """Blend between the traversals of simpA and simpB
504
+
505
+ Parameters
506
+ ----------
507
+ simpA : Simplex
508
+ The master Simplex
509
+ simpB : Simplex
510
+ A simplex system to merge
511
+ outSimp : Simplex
512
+ The output simplex that is being built
513
+ blendVal : float
514
+ The 0 to 1 blend value between the simplices
515
+ translation : {object: object}
516
+ A dictionary of input objects to output objects
517
+ mismatch : dict
518
+ The crazy mismatch dict from ``smpxMismatchCheck``
519
+ """
520
+ aNames = [s.name for s in simpA.traversals]
521
+ aDict = dict(zip(aNames, simpA.traversals))
522
+ bNames = [s.name for s in simpB.traversals]
523
+ bDict = dict(zip(bNames, simpB.traversals))
524
+ oNames = orderedMerge(aNames, bNames)
525
+
526
+ for oIdx, oName in enumerate(oNames):
527
+ print("Copying Traversal {0} of {1}: {2}".format(oIdx, len(oNames), oName))
528
+ aName, bName = mismatch["traversal"].get(oName, (oName, oName))
529
+ if aName is Skip or bName is Skip:
530
+ continue
531
+ elif aName is None:
532
+ _copyTraversal(bDict[bName], outSimp, translation)
533
+ elif bName is None:
534
+ _copyTraversal(aDict[aName], outSimp, translation)
535
+ else:
536
+ _blendTraversals(aDict[aName], bDict[bName], outSimp, blendVal, translation)
537
+
538
+
539
+ # Simplex
540
+ def smpxBlend(simpA, simpB, blendVal=0.50, mismatchDict=None, name="Face"):
541
+ """Blend the deltas from simplexA and simplexB. Apply the output to simplexA
542
+ Equal falloffs will be combined. Others will be given suffixes
543
+
544
+ Parameters
545
+ ----------
546
+ simpA : Simplex
547
+ The master Simplex
548
+ simpB : Simplex
549
+ The Simplex to be merged into simpA
550
+ blendVal : float
551
+ A value between 0 and 1, where 0 is fully simpA, and 1 is fully simpB. Defaults to 0.5
552
+ mismatchDict : dict or None
553
+ A dictionary like the one returned from ``spxMismatchCheck``. Defaults to None
554
+ name : str
555
+ The new name of the output system
556
+
557
+ Returns
558
+ -------
559
+ : Simplex
560
+ A new simplex system blended between the two inputs
561
+
562
+ """
563
+ mismatchDict = mismatchDict or {}
564
+ simpA.stack.enabled = False
565
+ simpB.stack.enabled = False
566
+
567
+ outSimp = Simplex(name=name, forceDummy=True)
568
+ outSimp.stack.enabled = False
569
+
570
+ dcc = outSimp.DCC
571
+ # TODO: Maybe add accessors to the simplex or DCC
572
+ dcc._faces = simpA.DCC._faces
573
+ dcc._counts = simpA.DCC._counts
574
+ dcc._uvs = simpA.DCC._uvs
575
+ dcc._falloffs = simpA.DCC._falloffs
576
+ dcc._numVerts = simpA.DCC._numVerts
577
+
578
+ rest = Shape.buildRest(outSimp)
579
+ rest.verts = (
580
+ simpA.restShape.verts * (1 - blendVal) + simpB.restShape.verts * blendVal
581
+ )
582
+
583
+ outSimp.restShape = rest
584
+
585
+ # When walking through this smpx file, keep a "translation" dictionary
586
+ # where translation[InputObjectID] = OutputObject
587
+ translation = {}
588
+ translation[simpA.restShape] = rest
589
+ translation[simpB.restShape] = rest
590
+
591
+ # Merge the groups. This one is easy. Merge by name
592
+ mergeGroups(simpA, simpB, outSimp, translation)
593
+
594
+ # Merge the falloffs. We can either require them to have equal values to "merge"
595
+ # Or we can just merge by name. The nameOnly kwarg handles this. True for now
596
+ mergeFalloffs(simpA, simpB, outSimp, translation, nameOnly=True)
597
+
598
+ # Copying one of the "big" object types should create and blend its child prog and shapes
599
+ print("Copying Sliders")
600
+ sliderBlend(simpA, simpB, outSimp, blendVal, translation, mismatchDict)
601
+ print("Copying Combos")
602
+ comboBlend(simpA, simpB, outSimp, blendVal, translation, mismatchDict)
603
+ print("Copying Traversals")
604
+ traversalBlend(simpA, simpB, outSimp, blendVal, translation, mismatchDict)
605
+
606
+ # push the verts to the dummy dcc for later export
607
+ dcc.pushAllShapeVertices(outSimp.shapes)
608
+ return outSimp
609
+
610
+
611
+ if __name__ == "__main__":
612
+ pathA = r"D:\Users\tyler\Desktop\TEST\GumboA.smpx"
613
+ pathB = r"D:\Users\tyler\Desktop\TEST\GumboB.smpx"
614
+ outPath = r"D:\Users\tyler\Desktop\TEST\hoping2.smpx"
615
+
616
+ print("Loading SimpA")
617
+ simpA = Simplex.buildSystemFromSmpx(pathA, forceDummy=True)
618
+ print("Loading SimpB")
619
+ simpB = Simplex.buildSystemFromSmpx(pathB, forceDummy=True)
620
+
621
+ print("Matching A:B")
622
+ mismatch = smpxMismatchCheck(simpA, simpB)
623
+ outSmpx = smpxBlend(simpA, simpB, blendVal=0.5, mismatchDict=mismatch)
624
+
625
+ print("Exporting")
626
+ print("OUT SMPX", outSmpx)
627
+ outSmpx.exportAbc(outPath)
628
+
629
+ print("DONE")