simplex-solver 3.2.2__cp39-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.
- simplex_solver-3.2.2.dist-info/DELVEWHEEL +2 -0
- simplex_solver-3.2.2.dist-info/METADATA +94 -0
- simplex_solver-3.2.2.dist-info/RECORD +84 -0
- simplex_solver-3.2.2.dist-info/WHEEL +5 -0
- simplex_solver.libs/.load-order-simplex_solver-3.2.2 +1 -0
- simplex_solver.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
- simplexui/__init__.py +86 -0
- simplexui/_version.py +1 -0
- simplexui/channelBox.py +867 -0
- simplexui/comboCheckDialog.py +396 -0
- simplexui/commands/__init__.py +16 -0
- simplexui/commands/alembicCommon.py +1148 -0
- simplexui/commands/alembic_walker.py +299 -0
- simplexui/commands/applyCorrectives.py +452 -0
- simplexui/commands/correctiveInterface.py +259 -0
- simplexui/commands/expandedExport.py +434 -0
- simplexui/commands/hdf5Convert.py +62 -0
- simplexui/commands/mayaCorrectiveInterface.py +159 -0
- simplexui/commands/mayatonumpy.py +416 -0
- simplexui/commands/mesh.py +1085 -0
- simplexui/commands/poseblendlib.py +168 -0
- simplexui/commands/reorderSimplexPoints.py +102 -0
- simplexui/commands/replaceDefinitionJson.py +74 -0
- simplexui/commands/rigidAlign.py +97 -0
- simplexui/commands/unsubdivide.py +1222 -0
- simplexui/commands/uvTransfer.py +976 -0
- simplexui/dragFilter.py +334 -0
- simplexui/falloffDialog.py +504 -0
- simplexui/img/ChefHead.png +0 -0
- simplexui/img/frozen.png +0 -0
- simplexui/interface/__init__.py +30 -0
- simplexui/interface/dummyInterface.py +1313 -0
- simplexui/interface/mayaInterface.py +2294 -0
- simplexui/interfaceModel.py +655 -0
- simplexui/interfaceModelTrees.py +456 -0
- simplexui/items/__init__.py +50 -0
- simplexui/items/accessor.py +145 -0
- simplexui/items/combo.py +645 -0
- simplexui/items/dragItem.py +44 -0
- simplexui/items/falloff.py +748 -0
- simplexui/items/group.py +267 -0
- simplexui/items/progression.py +613 -0
- simplexui/items/shape.py +384 -0
- simplexui/items/simplex.py +1734 -0
- simplexui/items/slider.py +632 -0
- simplexui/items/stack.py +147 -0
- simplexui/items/traversal.py +780 -0
- simplexui/items/treeItem.py +441 -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 +270 -0
- simplexui/menu/genericPlugins/checkPossibleCombos.py +48 -0
- simplexui/menu/genericPlugins/exportSplit.py +67 -0
- simplexui/menu/genericPlugins/showFalloffs.py +26 -0
- simplexui/menu/genericPlugins/showTraversals.py +26 -0
- simplexui/menu/genericPlugins/simplexUvTransfer.py +106 -0
- simplexui/menu/genericPlugins/unsubdivide.py +72 -0
- simplexui/menu/mayaPlugins/__init__.py +16 -0
- simplexui/menu/mayaPlugins/exportOther.py +53 -0
- simplexui/menu/mayaPlugins/extractProgressives.py +68 -0
- simplexui/menu/mayaPlugins/freezeCombo.py +247 -0
- simplexui/menu/mayaPlugins/generateShapeIncrementals.py +99 -0
- simplexui/menu/mayaPlugins/importObjs.py +199 -0
- simplexui/menu/mayaPlugins/linearizeTraversal.py +60 -0
- simplexui/menu/mayaPlugins/makeShelfBtn.py +67 -0
- simplexui/menu/mayaPlugins/relaxToSelection.py +76 -0
- simplexui/menu/mayaPlugins/reloadDefinition.py +44 -0
- simplexui/menu/mayaPlugins/snapToNeutral.py +71 -0
- simplexui/menu/mayaPlugins/softSelectToCluster.py +201 -0
- simplexui/menu/mayaPlugins/tweakMix.py +136 -0
- simplexui/menu/mayaPlugins/updateRestShape.py +113 -0
- simplexui/pysimplex.lib +0 -0
- simplexui/pysimplex.pyd +0 -0
- simplexui/simplexDialog.py +1547 -0
- simplexui/travCheckDialog.py +419 -0
- simplexui/traversalDialog.py +299 -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 +307 -0
simplexui/items/shape.py
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
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
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import TYPE_CHECKING, Any
|
|
20
|
+
|
|
21
|
+
from numpy import typing as npt
|
|
22
|
+
|
|
23
|
+
from ..interface import DCC, undoContext
|
|
24
|
+
from .accessor import SimplexAccessor
|
|
25
|
+
from .stack import stackable
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
from .progression import ProgPair
|
|
29
|
+
from .simplex import DCCObject, Simplex
|
|
30
|
+
from .slider import Slider
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Shape(SimplexAccessor):
|
|
34
|
+
"""A representation of a single blendshape
|
|
35
|
+
|
|
36
|
+
For every Shape object in a system, there will be one blendshape.
|
|
37
|
+
The Simplex solver takes an ordered list of Slider values, and outputs
|
|
38
|
+
an ordered list of shape values.
|
|
39
|
+
|
|
40
|
+
Shapes hold references to their DCC objects, and can also hold
|
|
41
|
+
the vertex positions in certain cases
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
name : str
|
|
46
|
+
The name for the new Shape
|
|
47
|
+
simplex : Simplex
|
|
48
|
+
The Simplex system
|
|
49
|
+
create : bool
|
|
50
|
+
Whether to create the DCC Shape, or look for it already in-scene
|
|
51
|
+
color : QColor
|
|
52
|
+
The color of this item in the Ui
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
classDepth: int = 10
|
|
56
|
+
|
|
57
|
+
def __init__(self, name: str, simplex: Simplex, create: bool = True) -> None:
|
|
58
|
+
super().__init__(simplex)
|
|
59
|
+
with self.stack.store(self):
|
|
60
|
+
self._thing: DCCObject | None = None
|
|
61
|
+
self._verts: npt.NDArray | None = None
|
|
62
|
+
self._thingRepr: str | None = None
|
|
63
|
+
self._name: str = name
|
|
64
|
+
self._buildIdx: int | None = None
|
|
65
|
+
simplex.shapes.append(self)
|
|
66
|
+
self.isRest: bool = False
|
|
67
|
+
self.progPairs: list[ProgPair] = []
|
|
68
|
+
|
|
69
|
+
newThing = self.DCC.getShapeThing(self._name)
|
|
70
|
+
if newThing is None:
|
|
71
|
+
if create:
|
|
72
|
+
self.thing = self.DCC.createShape(self)
|
|
73
|
+
else:
|
|
74
|
+
raise RuntimeError(f"Unable to find existing shape: {self.name}")
|
|
75
|
+
else:
|
|
76
|
+
self.thing = newThing
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def createShape(
|
|
80
|
+
cls, name: str, simplex: Simplex, slider: Slider | None = None
|
|
81
|
+
) -> Shape:
|
|
82
|
+
"""Convenience method for creating a new shape
|
|
83
|
+
This will create all required parent objects to have a new shape
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
name : str
|
|
88
|
+
The name for the new Shape
|
|
89
|
+
simplex : Simplex
|
|
90
|
+
The Simplex system
|
|
91
|
+
slider : Slider or None
|
|
92
|
+
The slider to add this shape to.
|
|
93
|
+
If None, A new Slider will be created (Default value = None)
|
|
94
|
+
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
97
|
+
: Shape
|
|
98
|
+
The new Shape
|
|
99
|
+
"""
|
|
100
|
+
if simplex.restShape is None:
|
|
101
|
+
raise RuntimeError("Simplex system is missing rest shape")
|
|
102
|
+
|
|
103
|
+
if slider is None:
|
|
104
|
+
# Implicitly creates a shape
|
|
105
|
+
from .slider import Slider
|
|
106
|
+
|
|
107
|
+
slider = Slider.createSlider(name, simplex)
|
|
108
|
+
for p in slider.prog.pairs:
|
|
109
|
+
if p.shape.name == name:
|
|
110
|
+
return p.shape
|
|
111
|
+
raise RuntimeError("Problem creating shape with proper name")
|
|
112
|
+
else:
|
|
113
|
+
if slider.simplex != simplex:
|
|
114
|
+
raise RuntimeError("Slider does not belong to the provided Simplex")
|
|
115
|
+
tVal = slider.prog.guessNextTVal()
|
|
116
|
+
pp = slider.prog.createShape(name, tVal)
|
|
117
|
+
return pp.shape
|
|
118
|
+
|
|
119
|
+
@classmethod
|
|
120
|
+
def buildRest(cls, simplex: Simplex) -> Shape:
|
|
121
|
+
"""Create/find the system's rest shape
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
simplex : Simplex
|
|
126
|
+
The Simplex system
|
|
127
|
+
|
|
128
|
+
Returns
|
|
129
|
+
-------
|
|
130
|
+
: Shape
|
|
131
|
+
The system's rest Shape
|
|
132
|
+
"""
|
|
133
|
+
rest = cls(simplex.getRestName(), simplex, create=True)
|
|
134
|
+
rest.isRest = True
|
|
135
|
+
return rest
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def name(self) -> str:
|
|
139
|
+
"""Get the Shape's name"""
|
|
140
|
+
return self._name
|
|
141
|
+
|
|
142
|
+
@name.setter
|
|
143
|
+
@stackable
|
|
144
|
+
def name(self, value: str) -> None:
|
|
145
|
+
"""Set the Shape's name"""
|
|
146
|
+
if value == self._name:
|
|
147
|
+
return
|
|
148
|
+
self.DCC.renameShape(self, value)
|
|
149
|
+
self._name = value
|
|
150
|
+
|
|
151
|
+
def strippedName(self) -> str:
|
|
152
|
+
"""Get the name of this shape with any progressive numbers stripped from the end"""
|
|
153
|
+
sp = self.name.split("_")
|
|
154
|
+
if self.isNumberField(sp[-1]):
|
|
155
|
+
sp = sp[:-1]
|
|
156
|
+
return "_".join(sp)
|
|
157
|
+
|
|
158
|
+
def _buildLinkedRename(
|
|
159
|
+
self,
|
|
160
|
+
newName: str,
|
|
161
|
+
maxDepth: int,
|
|
162
|
+
currentLinks: dict[type, dict[str, tuple[SimplexAccessor, int]]],
|
|
163
|
+
):
|
|
164
|
+
# Now that all the bookkeeping has been handled by the main method
|
|
165
|
+
# I can handle recursing for the object specific stuff here
|
|
166
|
+
|
|
167
|
+
shape = self # TEMP for typechecking. This is very wrong
|
|
168
|
+
|
|
169
|
+
from .combo import Combo
|
|
170
|
+
from .slider import Slider
|
|
171
|
+
from .traversal import Traversal
|
|
172
|
+
|
|
173
|
+
for pp in self.progPairs:
|
|
174
|
+
if pp.prog is None:
|
|
175
|
+
continue
|
|
176
|
+
|
|
177
|
+
currentLinks = pp.prog.siblingRename(shape, newName, currentLinks)
|
|
178
|
+
|
|
179
|
+
ctrl = pp.prog.controller
|
|
180
|
+
if isinstance(ctrl, Slider):
|
|
181
|
+
nn = ""
|
|
182
|
+
currentLinks = ctrl.buildLinkedRename(
|
|
183
|
+
nn, maxDepth=maxDepth - 1, currentLinks=currentLinks
|
|
184
|
+
)
|
|
185
|
+
elif isinstance(ctrl, Combo):
|
|
186
|
+
nn = ""
|
|
187
|
+
currentLinks = ctrl.buildLinkedRename(
|
|
188
|
+
nn, maxDepth=maxDepth - 1, currentLinks=currentLinks
|
|
189
|
+
)
|
|
190
|
+
elif isinstance(ctrl, Traversal):
|
|
191
|
+
nn = ""
|
|
192
|
+
currentLinks = ctrl.buildLinkedRename(
|
|
193
|
+
nn, maxDepth=maxDepth - 1, currentLinks=currentLinks
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
return currentLinks
|
|
197
|
+
"""
|
|
198
|
+
# First, check for a slider rename,
|
|
199
|
+
# if so, recurse into that slider
|
|
200
|
+
# Check for combo renames (because combos use the shape names)
|
|
201
|
+
|
|
202
|
+
# if isinstance(item, Shape):
|
|
203
|
+
# Check if the parent is a slider
|
|
204
|
+
# Check if the slider needs renamed
|
|
205
|
+
# Check if the item's siblings need renamed
|
|
206
|
+
# Check if there are any combos that depend on this shape name
|
|
207
|
+
# If so, rename *both* the combo and its linked children
|
|
208
|
+
# Check if the parent is a combo
|
|
209
|
+
# Check if the combo needs renamed
|
|
210
|
+
# If so, check if the item's siblings need renamed too
|
|
211
|
+
# Check if the parent is a traversal
|
|
212
|
+
# Check if the traversal needs renamed
|
|
213
|
+
# If so, check if the item's siblings need renamed too
|
|
214
|
+
# elif isinstance(item, Slider):
|
|
215
|
+
# Check if the name change is linked to any of my shapes
|
|
216
|
+
# Go through the shape linked rename for one of those instead, maybe?
|
|
217
|
+
# There are possible ambiguities if you do a *full* slider rename
|
|
218
|
+
# with both positive and negatively named shapes.
|
|
219
|
+
# Otherwise
|
|
220
|
+
# Check for linked combos, and rename down that branch
|
|
221
|
+
# Check for linked traversals, and rename down that branch
|
|
222
|
+
# elif isinstance(item, Combo):
|
|
223
|
+
# pass
|
|
224
|
+
# elif isinstance(item, Traversal):
|
|
225
|
+
# pass
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
@property
|
|
229
|
+
def thing(self) -> DCCObject:
|
|
230
|
+
"""Get the stored reference to the DCC object"""
|
|
231
|
+
# if this is a deepcopied object, then self._thing will
|
|
232
|
+
# be None. Rebuild the thing connection by its representation
|
|
233
|
+
if self._thing is None and self._thingRepr:
|
|
234
|
+
self._thing = DCC.loadPersistentShape(self._thingRepr)
|
|
235
|
+
return self._thing
|
|
236
|
+
|
|
237
|
+
@thing.setter
|
|
238
|
+
def thing(self, value: DCCObject) -> None:
|
|
239
|
+
"""Set the stored reference to the DCC object"""
|
|
240
|
+
self._thing = value
|
|
241
|
+
self._thingRepr = self.DCC.getPersistentShape(value)
|
|
242
|
+
|
|
243
|
+
@classmethod
|
|
244
|
+
def loadV2(cls, simplex: Simplex, data: dict[str, Any], create: bool) -> Shape:
|
|
245
|
+
"""Load the data from a version2 formatted json dictionary
|
|
246
|
+
|
|
247
|
+
Parameters
|
|
248
|
+
----------
|
|
249
|
+
simplex : Simplex
|
|
250
|
+
The Simplex system that's being built
|
|
251
|
+
data : dict
|
|
252
|
+
The chunk of the json dict used to build this object
|
|
253
|
+
create : bool
|
|
254
|
+
Whether to create the DCC Shape, or look for it already in-scene
|
|
255
|
+
|
|
256
|
+
Returns
|
|
257
|
+
-------
|
|
258
|
+
: Shape
|
|
259
|
+
The specified Shape
|
|
260
|
+
"""
|
|
261
|
+
return cls(data["name"], simplex, create)
|
|
262
|
+
|
|
263
|
+
def buildDefinition(self, simpDict: dict[str, Any], legacy: bool) -> int:
|
|
264
|
+
"""Output a dictionary definition of this object
|
|
265
|
+
|
|
266
|
+
Parameters
|
|
267
|
+
----------
|
|
268
|
+
simpDict : dict
|
|
269
|
+
The dictionary that is being built
|
|
270
|
+
legacy : bool
|
|
271
|
+
Whether to write out the legacy definition, or the newer one
|
|
272
|
+
"""
|
|
273
|
+
if self._buildIdx is None:
|
|
274
|
+
self._buildIdx = len(simpDict["shapes"])
|
|
275
|
+
if legacy:
|
|
276
|
+
simpDict.setdefault("shapes", []).append(self.name)
|
|
277
|
+
else:
|
|
278
|
+
x = {
|
|
279
|
+
"name": self.name,
|
|
280
|
+
}
|
|
281
|
+
simpDict.setdefault("shapes", []).append(x)
|
|
282
|
+
return self._buildIdx
|
|
283
|
+
|
|
284
|
+
def clearBuildIndex(self) -> None:
|
|
285
|
+
"""Clear the build index of this object
|
|
286
|
+
|
|
287
|
+
The buildIndex is stored when building a definition dictionary
|
|
288
|
+
that keeps track of its index for later referencing
|
|
289
|
+
"""
|
|
290
|
+
self._buildIdx = None
|
|
291
|
+
|
|
292
|
+
def zeroShape(self) -> None:
|
|
293
|
+
"""Set the shape to be equal to the rest shape"""
|
|
294
|
+
self.DCC.zeroShape(self)
|
|
295
|
+
|
|
296
|
+
@staticmethod
|
|
297
|
+
def zeroShapes(shapes) -> None:
|
|
298
|
+
"""Set the shapes to be equal to the rest shape
|
|
299
|
+
|
|
300
|
+
Parameters
|
|
301
|
+
----------
|
|
302
|
+
shapes : [Shape
|
|
303
|
+
Shapes to be zeroed
|
|
304
|
+
"""
|
|
305
|
+
for shape in shapes:
|
|
306
|
+
if not shape.isRest:
|
|
307
|
+
shape.zeroShape()
|
|
308
|
+
|
|
309
|
+
def connectShape(
|
|
310
|
+
self, mesh: DCCObject | None = None, live: bool = False, delete: bool = False
|
|
311
|
+
) -> None:
|
|
312
|
+
"""Force a shape to match a mesh
|
|
313
|
+
The "connect shape" button is: mesh=None, delete=True
|
|
314
|
+
The "match shape" button is: mesh=someMesh, delete=False
|
|
315
|
+
There is a possibility of a "make live" button: live=True, delete=False
|
|
316
|
+
|
|
317
|
+
Parameters
|
|
318
|
+
----------
|
|
319
|
+
mesh : object or None
|
|
320
|
+
The DCC Mesh object. If None, it's searched for by name in scene (Default value = None)
|
|
321
|
+
live : bool
|
|
322
|
+
Whether or not to create a live connection in the DCC. Defaults False
|
|
323
|
+
delete : bool
|
|
324
|
+
Whether to delete the DCC Mesh after its connection. Defaults False
|
|
325
|
+
"""
|
|
326
|
+
self.DCC.connectShape(self, mesh, live, delete)
|
|
327
|
+
|
|
328
|
+
@staticmethod
|
|
329
|
+
def connectShapes(
|
|
330
|
+
shapes: list[Shape],
|
|
331
|
+
meshes: list[DCCObject],
|
|
332
|
+
live: bool = False,
|
|
333
|
+
delete: bool = False,
|
|
334
|
+
) -> None:
|
|
335
|
+
"""Connect multiple meshes to multiple Shapes
|
|
336
|
+
|
|
337
|
+
Parameters
|
|
338
|
+
----------
|
|
339
|
+
shapes : [Shape
|
|
340
|
+
The shapes to connect to
|
|
341
|
+
meshes : [object
|
|
342
|
+
The DCC Meshes
|
|
343
|
+
live : bool
|
|
344
|
+
Whether or not to create a live connection in the DCC. Defaults False
|
|
345
|
+
delete : bool
|
|
346
|
+
Whether to delete the DCC Mesh after its connection. Defaults False
|
|
347
|
+
"""
|
|
348
|
+
with undoContext():
|
|
349
|
+
for shape, mesh in zip(shapes, meshes):
|
|
350
|
+
shape.connectShape(mesh, live, delete)
|
|
351
|
+
|
|
352
|
+
@staticmethod
|
|
353
|
+
def isNumberField(val: str) -> bool:
|
|
354
|
+
"""A utility function to check if a field is numeric
|
|
355
|
+
Also, this allows for the "n" prefix for negative numbers because
|
|
356
|
+
many DCC's don't allow "-" in an object name
|
|
357
|
+
|
|
358
|
+
Parameters
|
|
359
|
+
----------
|
|
360
|
+
val : str
|
|
361
|
+
The string to check
|
|
362
|
+
|
|
363
|
+
Returns
|
|
364
|
+
-------
|
|
365
|
+
: bool
|
|
366
|
+
Whether the field is numeric
|
|
367
|
+
"""
|
|
368
|
+
if not val:
|
|
369
|
+
return False
|
|
370
|
+
if val[0].lower() == "n":
|
|
371
|
+
val = val[1:]
|
|
372
|
+
return val.isdigit()
|
|
373
|
+
|
|
374
|
+
@property
|
|
375
|
+
def verts(self) -> npt.NDArray | None:
|
|
376
|
+
"""Get the stored vertices"""
|
|
377
|
+
if self._verts is None:
|
|
378
|
+
self._verts = self.DCC.getShapeVertices(self)
|
|
379
|
+
return self._verts
|
|
380
|
+
|
|
381
|
+
@verts.setter
|
|
382
|
+
def verts(self, value: npt.NDArray) -> None:
|
|
383
|
+
"""Set the stored vertices"""
|
|
384
|
+
self._verts = value
|