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