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,778 @@
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
+ # pylint:disable=missing-docstring,unused-argument,no-self-use
19
+ import copy
20
+ import math
21
+
22
+ try:
23
+ import numpy as np
24
+ except ImportError:
25
+ np = None
26
+ from Qt.QtGui import QColor
27
+ from ..utils import nested
28
+ from .accessor import SimplexAccessor
29
+ from .stack import stackable
30
+
31
+
32
+ class Falloff(SimplexAccessor):
33
+ """Falloffs define how shapes are split left/right, front/back, top/bottom, or however else
34
+
35
+ Falloffs are the core of the splitting algorithm built into Simplex.
36
+ When splitting, they define how shapes are duplicated and renamed, as well as
37
+ how the deltas are multiplied.
38
+
39
+ Currently only axis-aligned planar falloffs are fully defined and supported, but there are plans
40
+ for per-point falloffs (weightmap), oriented planes, and other implicit geometric shapes.
41
+
42
+ A planar falloff is a worldspace value field where any point past falloff min has the min value,
43
+ any point past the max has the max value, and any point in between is defined by user-controlled curve
44
+ Maya users might think of this as a planar projection of a ramp.
45
+
46
+ A group of static variables controls how splits are detected and renamed. Names are split by
47
+ Falloff.SEP and the split chunks are matched to the items below. In some cases, rather than
48
+ lists of characters, I just use a string.
49
+
50
+ These define the strings identifying their eponymous sides:
51
+ LEFTSIDE, RIGHTSIDE, TOPSIDE, BOTTOMSIDE, FRONTSIDE, BACKSIDE
52
+
53
+ This is a character list definint the single-character values that define centered shapes:
54
+ CENTERS
55
+
56
+ These define the strings that are detected to find splits.
57
+ For instance, if HORIZONTAL_SPLIT="X", then cornerPuller_X would split across the X axis,
58
+ and the new items would be given names
59
+
60
+ ::
61
+ "cornerPuller_{}".format(LEFTSIDE)
62
+ "cornerPuller_{}".format(RIGHTSIDE)
63
+
64
+ VERTICAL_SPLIT, VERTICAL_AXIS, VERTICAL_AXISINDEX
65
+ HORIZONTAL_SPLIT, HORIZONTAL_AXIS, HORIZONTAL_AXISINDEX
66
+ DEPTH_SPLIT, DEPTH_AXIS, DEPTH_AXISINDEX,
67
+
68
+ When UNsplitting a simplex system, this value controls the tolerance
69
+ UNSPLIT_GUESS_TOLERANCE
70
+
71
+ Parameters
72
+ ----------
73
+ name : str
74
+ The name of the falloff
75
+ simplex : Simplex
76
+ The Simplex system
77
+ *data : list
78
+ The data used to build this falloff.
79
+ You should use one of the classmethod like Falloff.createPlanar or Falloff.createMap instead
80
+
81
+ Returns
82
+ -------
83
+
84
+ """
85
+
86
+ LEFTSIDE = "L"
87
+ RIGHTSIDE = "R"
88
+ TOPSIDE = "U"
89
+ BOTTOMSIDE = "D"
90
+ FRONTSIDE = "F"
91
+ BACKSIDE = "B"
92
+ ALLSIDES = LEFTSIDE + RIGHTSIDE + TOPSIDE + BOTTOMSIDE + FRONTSIDE + BACKSIDE
93
+
94
+ CENTERS = "MC"
95
+
96
+ VERTICAL_SPLIT = "V"
97
+ VERTICAL_RESULTS = TOPSIDE + BOTTOMSIDE
98
+ VERTICAL_AXIS = "Y"
99
+ VERTICAL_AXISINDEX = 1
100
+
101
+ HORIZONTAL_SPLIT = "X"
102
+ HORIZONTAL_RESULTS = LEFTSIDE + RIGHTSIDE
103
+ HORIZONTAL_AXIS = "X"
104
+ HORIZONTAL_AXISINDEX = 0
105
+
106
+ DEPTH_SPLIT = "Z"
107
+ DEPTH_RESULTS = FRONTSIDE + BACKSIDE
108
+ DEPTH_AXIS = "Z"
109
+ DEPTH_AXISINDEX = 2
110
+
111
+ RESTNAME = "Rest"
112
+ SEP = "_"
113
+
114
+ UNSPLIT_GUESS_TOLERANCE = 0.33
115
+
116
+ def __init__(self, name, simplex, *data):
117
+ super(Falloff, self).__init__(simplex)
118
+ with self.stack.store(self):
119
+ self._splitType = str(data[0]).lower()
120
+ self._axis = None
121
+ self._maxVal = None
122
+ self._maxHandle = None
123
+ self._minHandle = None
124
+ self._minVal = None
125
+ self._mapName = None
126
+
127
+ self._bezier = None
128
+ self._search = None
129
+ self._rep = None
130
+ self._weights = None
131
+ self._verts = None
132
+ self._thing = None
133
+ self._thingRepr = None
134
+
135
+ if self._splitType == "planar":
136
+ self._axis = data[1]
137
+ self._maxVal = data[2]
138
+ self._maxHandle = data[3]
139
+ self._minHandle = data[4]
140
+ self._minVal = data[5]
141
+ elif self._splitType == "map":
142
+ self._mapName = data[1]
143
+ self._axis = data[2]
144
+
145
+ self._name = name
146
+ self.children = []
147
+ self._buildIdx = None
148
+ self.expanded = {}
149
+ self.color = QColor(128, 128, 128)
150
+
151
+ mgrs = [model.insertItemManager(None) for model in self.falloffModels]
152
+ with nested(*mgrs):
153
+ self.simplex.falloffs.append(self)
154
+
155
+ # newThing = self.DCC.getFalloffThing(self)
156
+ # if newThing is None:
157
+ # self.thing = self.DCC.createFalloff(self)
158
+ # else:
159
+ # self.thing = newThing
160
+
161
+ # @property
162
+ # def thing(self):
163
+ ## if this is a deepcopied object, then self._thing will
164
+ ## be None. Rebuild the thing connection by its representation
165
+ # if self._thing is None and self._thingRepr:
166
+ # self._thing = self.DCC.loadPersistentFalloff(self._thingRepr)
167
+ # return self._thing
168
+
169
+ # @thing.setter
170
+ # def thing(self, value):
171
+ # self._thing = value
172
+ # self._thingRepr = self.DCC.getPersistentFalloff(value)
173
+
174
+ @property
175
+ def name(self):
176
+ """Get the name of a Falloff"""
177
+ return self._name
178
+
179
+ @name.setter
180
+ @stackable
181
+ def name(self, value):
182
+ """Set the name of a Falloff
183
+
184
+ Parameters
185
+ ----------
186
+ value :
187
+
188
+
189
+ Returns
190
+ -------
191
+
192
+ """
193
+ self._name = value
194
+ for model in self.falloffModels:
195
+ model.itemDataChanged(self)
196
+
197
+ @classmethod
198
+ def createPlanar(cls, name, simplex, axis, maxVal, maxHandle, minHandle, minVal):
199
+ """Create a planar falloff
200
+
201
+ Parameters
202
+ ----------
203
+ name : str
204
+ The name to give the falloff
205
+ simplex : Simplex
206
+ The Simplex system
207
+ axis : str
208
+ The axis to align the falloff to. X, Y, or Z
209
+ maxVal : float
210
+ The value past which the falloff is 1.0
211
+ maxHandle : float
212
+ The (0, 1) range of the max cubic falloff handle
213
+ minHandle : float
214
+ The (0, 1) range of the min cubic falloff handle
215
+ minVal : float
216
+ The value past which the falloff is 0.0
217
+
218
+ Returns
219
+ -------
220
+
221
+ """
222
+ return cls(name, simplex, "planar", axis, maxVal, maxHandle, minHandle, minVal)
223
+
224
+ @classmethod
225
+ def createMap(cls, name, simplex, mapName, axis):
226
+ """Create a weightmap falloff
227
+
228
+ Parameters
229
+ ----------
230
+ name : str
231
+ The name to give the falloff
232
+ simplex : Simplex
233
+ The Simplex system
234
+ mapName : str
235
+ The name of the weightmap
236
+ axis : str
237
+ The axis to align the falloff to. X, Y, or Z
238
+
239
+ Returns
240
+ -------
241
+
242
+ """
243
+ return cls(name, simplex, "map", mapName, axis)
244
+
245
+ @classmethod
246
+ def loadV2(cls, simplex, data):
247
+ """Load the falloff from the version 2 json specification
248
+
249
+ Parameters
250
+ ----------
251
+ simplex : Simplex
252
+ The Simplex system
253
+ data : dict
254
+ The data to load
255
+
256
+ Returns
257
+ -------
258
+ : Falloff
259
+ The specified Falloff
260
+
261
+ """
262
+ tpe = data["type"]
263
+ name = data["name"]
264
+ axis = data["axis"]
265
+ if tpe == "map":
266
+ return cls.createMap(name, simplex, data["mapName"], axis)
267
+ elif tpe == "planar":
268
+ maxVal = data["maxVal"]
269
+ maxHandle = data["maxHandle"]
270
+ minHandle = data["minHandle"]
271
+ minVal = data["minVal"]
272
+ return cls.createPlanar(
273
+ name, simplex, axis, maxVal, maxHandle, minHandle, minVal
274
+ )
275
+
276
+ raise ValueError("Bad data passed to Falloff creation")
277
+
278
+ def buildDefinition(self, simpDict, legacy):
279
+ """Output a dictionary definition of this object
280
+
281
+ Parameters
282
+ ----------
283
+ simpDict : dict
284
+ The dictionary that is being built
285
+ legacy : bool
286
+ Whether to write out the legacy definition, or the newer one
287
+
288
+ Returns
289
+ -------
290
+
291
+ """
292
+ if self._buildIdx is None:
293
+ self._buildIdx = len(simpDict["falloffs"])
294
+ if legacy:
295
+ if self.splitType == "planar":
296
+ line = [
297
+ "planar",
298
+ self.axis,
299
+ self.maxVal,
300
+ self.maxHandle,
301
+ self.minHandle,
302
+ self.minVal,
303
+ ]
304
+ else:
305
+ line = ["map", self.mapName]
306
+ simpDict.setdefault("falloffs", []).append([self.name] + line)
307
+ else:
308
+ x = {
309
+ "name": self.name,
310
+ "type": self.splitType,
311
+ "axis": self.axis,
312
+ "maxVal": self.maxVal,
313
+ "maxHandle": self.maxHandle,
314
+ "minHandle": self.minHandle,
315
+ "minVal": self.minVal,
316
+ "mapName": self.mapName,
317
+ "color": self.color.getRgb()[:3],
318
+ }
319
+ simpDict.setdefault("falloffs", []).append(x)
320
+ return self._buildIdx
321
+
322
+ def clearBuildIndex(self):
323
+ """Clear the build index of this object
324
+
325
+ The buildIndex is stored when building a definition dictionary
326
+ that keeps track of its index for later referencing
327
+
328
+ Parameters
329
+ ----------
330
+
331
+ Returns
332
+ -------
333
+
334
+ """
335
+ self._buildIdx = None
336
+
337
+ @stackable
338
+ def duplicate(self, newName):
339
+ """Duplicate a Falloff with a new name
340
+
341
+ Parameters
342
+ ----------
343
+ newName : str
344
+ The name to give the new Falloff
345
+
346
+ Returns
347
+ -------
348
+ : Falloff
349
+ The newly duplicated Falloff
350
+
351
+ """
352
+ nf = copy.copy(self)
353
+ nf.name = newName
354
+ nf.children = []
355
+ nf.clearBuildIndex()
356
+ mgrs = [model.insertItemManager(self) for model in self.falloffModels]
357
+ with nested(*mgrs):
358
+ self.simplex.falloffs.append(nf)
359
+ self.DCC.duplicateFalloff(self, nf)
360
+ return nf
361
+
362
+ @stackable
363
+ def delete(self):
364
+ """Delete the Falloff"""
365
+ fIdx = self.simplex.falloffs.index(self)
366
+ for child in self.children:
367
+ child.falloff = None
368
+
369
+ mgrs = [model.removeItemManager(self) for model in self.falloffModels]
370
+ with nested(*mgrs):
371
+ self.simplex.falloffs.pop(fIdx)
372
+ self.DCC.deleteFalloff(self)
373
+
374
+ @stackable
375
+ def setPlanarData(self, axis, minVal, minHandle, maxHandle, maxVal):
376
+ """Set the type/data for a planar Falloff
377
+
378
+ Parameters
379
+ ----------
380
+ axis : str
381
+ The axis to align the falloff to. X, Y, or Z
382
+ maxVal : float
383
+ The value past which the falloff is 1.0
384
+ maxHandle : float
385
+ The (0, 1) range of the max cubic falloff handle
386
+ minHandle : float
387
+ The (0, 1) range of the min cubic falloff handle
388
+ minVal : float
389
+ The value past which the falloff is 0.0
390
+
391
+ Returns
392
+ -------
393
+
394
+ """
395
+ self.splitType = "planar"
396
+ self.axis = axis
397
+ self.minVal = minVal
398
+ self.minHandle = minHandle
399
+ self.maxHandle = maxHandle
400
+ self.maxVal = maxVal
401
+ self.mapName = None
402
+ self._updateDCC()
403
+
404
+ @stackable
405
+ def setMapData(self, mapName):
406
+ """Set the type/data for a map Falloff
407
+
408
+ Parameters
409
+ ----------
410
+ mapName : str
411
+ The name of the weightmap
412
+
413
+ Returns
414
+ -------
415
+
416
+ """
417
+ self.splitType = "map"
418
+ self.axis = None
419
+ self.minVal = None
420
+ self.minHandle = None
421
+ self.maxHandle = None
422
+ self.maxVal = None
423
+ self.mapName = mapName
424
+ self._updateDCC()
425
+
426
+ @property
427
+ def splitType(self):
428
+ return self._splitType
429
+
430
+ @splitType.setter
431
+ @stackable
432
+ def splitType(self, value):
433
+ self._splitType = str(value).lower()
434
+ for model in self.falloffModels:
435
+ model.itemDataChanged(self)
436
+ self._updateDCC()
437
+
438
+ @property
439
+ def axis(self):
440
+ return self._axis
441
+
442
+ @axis.setter
443
+ @stackable
444
+ def axis(self, value):
445
+ self._axis = value
446
+ for model in self.falloffModels:
447
+ model.itemDataChanged(self)
448
+ self._updateDCC()
449
+
450
+ @property
451
+ def maxVal(self):
452
+ return self._maxVal
453
+
454
+ @maxVal.setter
455
+ @stackable
456
+ def maxVal(self, value):
457
+ self._maxVal = value
458
+ for model in self.falloffModels:
459
+ model.itemDataChanged(self)
460
+ self._updateDCC()
461
+
462
+ @property
463
+ def maxHandle(self):
464
+ return self._maxHandle
465
+
466
+ @maxHandle.setter
467
+ @stackable
468
+ def maxHandle(self, value):
469
+ self._maxHandle = value
470
+ for model in self.falloffModels:
471
+ model.itemDataChanged(self)
472
+ self._updateDCC()
473
+
474
+ @property
475
+ def minHandle(self):
476
+ return self._minHandle
477
+
478
+ @minHandle.setter
479
+ @stackable
480
+ def minHandle(self, value):
481
+ self._minHandle = value
482
+ for model in self.falloffModels:
483
+ model.itemDataChanged(self)
484
+ self._updateDCC()
485
+
486
+ @property
487
+ def minVal(self):
488
+ return self._minVal
489
+
490
+ @minVal.setter
491
+ @stackable
492
+ def minVal(self, value):
493
+ self._minVal = value
494
+ for model in self.falloffModels:
495
+ model.itemDataChanged(self)
496
+ self._updateDCC()
497
+
498
+ @property
499
+ def mapName(self):
500
+ return self._mapName
501
+
502
+ @mapName.setter
503
+ @stackable
504
+ def mapName(self, value):
505
+ self._mapName = value
506
+ for model in self.falloffModels:
507
+ model.itemDataChanged(self)
508
+ self._updateDCC()
509
+
510
+ def _updateDCC(self):
511
+ """ """
512
+ self.DCC.setFalloffData(
513
+ self,
514
+ self.splitType,
515
+ self.axis,
516
+ self.minVal,
517
+ self.minHandle,
518
+ self.maxHandle,
519
+ self.maxVal,
520
+ self.mapName,
521
+ )
522
+
523
+ # Split code
524
+ @property
525
+ def bezier(self):
526
+ """Pre-build a factorization of the cubic bezier curve that is being used for a falloff
527
+ Based on method described at https://pomax.github.io/bezierinfo/#yforx
528
+
529
+ Parameters
530
+ ----------
531
+
532
+ Returns
533
+ -------
534
+
535
+ """
536
+ if self._bezier is None:
537
+ p0x = 0.0
538
+ p1x = self.minHandle
539
+ p2x = self.maxHandle
540
+ p3x = 1.0
541
+
542
+ f = p1x - p0x
543
+ g = p3x - p2x
544
+ d = 3 * f + 3 * g - 2
545
+ n = 2 * f + g - 1
546
+ r = (n * n - f * d) / (d * d)
547
+ qq = (3 * f * d * n - 2 * n * n * n) / (d * d * d)
548
+ self._bezier = (qq, r, d, n)
549
+ return self._bezier
550
+
551
+ def getMultiplier(self, xVal):
552
+ """Get the weight value for the given X
553
+
554
+ Parameters
555
+ ----------
556
+ xVal : float
557
+ The value to get the weight for
558
+
559
+ Returns
560
+ -------
561
+ : float
562
+ The weight
563
+
564
+ """
565
+ # Vertices are assumed to be at (0,0) and (1,1)
566
+ if xVal <= self.minVal:
567
+ return 0.0
568
+ if xVal >= self.maxVal:
569
+ return 1.0
570
+
571
+ tVal = float(xVal - self.minVal) / float(self.maxVal - self.minVal)
572
+ qq, r, d, n = self.bezier
573
+ q = qq - tVal / d
574
+ discriminant = q * q - 4 * r * r * r
575
+ if discriminant >= 0:
576
+ pm = (discriminant**0.5) / 2
577
+ w = (-q / 2 + pm) ** (1 / 3.0)
578
+ u = w + r / w
579
+ else:
580
+ theta = math.acos(-q / (2 * r ** (3 / 2.0)))
581
+ phi = theta / 3 + 4 * math.pi / 3
582
+ u = 2 * r ** (0.5) * math.cos(phi)
583
+ t = u + n / d
584
+ t1 = 1 - t
585
+ return 3 * t1 * t**2 * 1 + t**3 * 1
586
+
587
+ def _setSearchRep(self):
588
+ """ """
589
+ if self.axis.lower() == self.HORIZONTAL_AXIS.lower():
590
+ self._search = self.HORIZONTAL_SPLIT
591
+ self._rep = self.HORIZONTAL_RESULTS
592
+ elif self.axis.lower() == self.VERTICAL_AXIS.lower():
593
+ self._search = self.VERTICAL_SPLIT
594
+ self._rep = self.VERTICAL_RESULTS
595
+ elif self.axis.lower() == self.DEPTH_AXIS.lower():
596
+ self._search = self.DEPTH_SPLIT
597
+ self._rep = self.DEPTH_RESULTS
598
+
599
+ @property
600
+ def search(self):
601
+ """The values this fallof searches for"""
602
+ if self._search is None:
603
+ self._setSearchRep()
604
+ return self._search
605
+
606
+ @property
607
+ def rep(self):
608
+ """The values this falloff replaces with"""
609
+ if self._rep is None:
610
+ self._setSearchRep()
611
+ return self._rep
612
+
613
+ @property
614
+ def verts(self):
615
+ """Get the stored vertex values"""
616
+ return self._verts
617
+
618
+ @verts.setter
619
+ def verts(self, vals):
620
+ """Input the vertices into this falloff and compute the weights
621
+
622
+ Parameters
623
+ ----------
624
+ vals : np.array
625
+ A (Nx3) numpy array of vertices
626
+
627
+ Returns
628
+ -------
629
+
630
+ """
631
+ if self.splitType != "map":
632
+ # Clear out any auto-computed weights
633
+ # when setting verts on a non-map falloff
634
+ self._weights = None
635
+ self._verts = vals
636
+
637
+ @property
638
+ def weights(self):
639
+ """Get the per-vertex weight values"""
640
+
641
+ if self._weights is None:
642
+ if self.splitType == "map":
643
+ raise ValueError(
644
+ "Attempted to auto-compute weights of a map falloff: {}".format(
645
+ self.name
646
+ )
647
+ )
648
+
649
+ if self._verts is None:
650
+ raise ValueError(
651
+ "Attempted to auto-compute weights of a procedural falloff without setting verts: {0}".format(
652
+ self.name
653
+ )
654
+ )
655
+
656
+ if self.axis.lower() == self.HORIZONTAL_AXIS.lower():
657
+ component = self.HORIZONTAL_AXISINDEX
658
+ elif self.axis.lower() == self.VERTICAL_AXIS.lower():
659
+ component = self.VERTICAL_AXISINDEX
660
+ elif self.axis.lower() == self.DEPTH_AXIS.lower():
661
+ component = self.DEPTH_AXISINDEX
662
+ else:
663
+ raise ValueError("Falloff found with no axis set")
664
+
665
+ self._weights = np.array(
666
+ [self.getMultiplier(v[component]) for v in self._verts]
667
+ )
668
+
669
+ return self._weights
670
+
671
+ @weights.setter
672
+ def weights(self, val):
673
+ """Set the per-vertex weight values
674
+
675
+ Parameters
676
+ ----------
677
+ val : A list or numpy array of values between 0 and 1
678
+ """
679
+ self._weights = np.asarray(val)
680
+
681
+ def getSidedName(self, name, sIdx):
682
+ """Take name to split along some axis, and replace the fields based on the index
683
+ For instance, this could take cp_X and return cp_L for sIdx=1 and cp_R for sIdx=2
684
+
685
+ Parameters
686
+ ----------
687
+ name : str
688
+ The name to "split" with this falloff
689
+ sIdx : int
690
+ The index of the replacement value
691
+
692
+ Returns
693
+ -------
694
+ : str
695
+ The newly sided name
696
+
697
+ """
698
+ search = self.search
699
+ replace = self.rep[sIdx]
700
+
701
+ nn = name
702
+ s = "{0}{1}{0}".format(self.SEP, search)
703
+ r = "{0}{1}{0}".format(self.SEP, replace)
704
+ nn = nn.replace(s, r)
705
+
706
+ s = "{0}{1}".format(self.SEP, search) # handle Postfix
707
+ r = "{0}{1}".format(self.SEP, replace)
708
+ if nn.endswith(s):
709
+ nn = r.join(nn.rsplit(s, 1))
710
+
711
+ s = "{1}{0}".format(self.SEP, search) # handle Prefix
712
+ r = "{1}{0}".format(self.SEP, replace)
713
+ if nn.startswith(s):
714
+ nn = nn.replace(s, r, 1)
715
+ return nn
716
+
717
+ def canRename(self, item):
718
+ """Check if the item can be renamed by this Falloff
719
+
720
+ Parameters
721
+ ----------
722
+ item : object
723
+ The named simplex object to check
724
+
725
+ Returns
726
+ -------
727
+ : bool
728
+ Whether this object can be renamed
729
+
730
+ """
731
+ nn = self.getSidedName(item.name, 0)
732
+ return nn != item.name
733
+
734
+ def splitRename(self, item, sIdx):
735
+ """Actually run the rename for a particular item
736
+
737
+ Parameters
738
+ ----------
739
+ item : object
740
+ The named Simplex Item
741
+ sIdx : int
742
+ The replacement index
743
+
744
+ Returns
745
+ -------
746
+
747
+ """
748
+ from .combo import Combo
749
+ from .shape import Shape
750
+ from .slider import Slider
751
+ from .traversal import Traversal
752
+
753
+ if isinstance(item, (Shape, Slider, Combo, Traversal)):
754
+ item.name = self.getSidedName(item.name, sIdx)
755
+
756
+ def applyFalloff(self, shape, sIdx):
757
+ """Apply the falloff to the vertices of a shape
758
+
759
+ Parameters
760
+ ----------
761
+ shape : Shape
762
+ The shape to apply to
763
+ sIdx : int
764
+ The replacement index
765
+
766
+ Returns
767
+ -------
768
+
769
+ """
770
+ rest = self.simplex.restShape
771
+ restVerts = rest.verts
772
+
773
+ weights = self.weights
774
+ if sIdx == 1:
775
+ weights = 1 - weights
776
+
777
+ weightedDeltas = (shape.verts - restVerts) * weights[:, None]
778
+ shape.verts = weightedDeltas + restVerts