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