procfunc 0.30.0__py3-none-any.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.
- procfunc/__init__.py +87 -0
- procfunc/color.py +57 -0
- procfunc/compute_graph/__init__.py +28 -0
- procfunc/compute_graph/compute_graph.py +115 -0
- procfunc/compute_graph/node.py +200 -0
- procfunc/compute_graph/operators_info.py +92 -0
- procfunc/compute_graph/proxy.py +173 -0
- procfunc/compute_graph/util.py +282 -0
- procfunc/context.py +115 -0
- procfunc/control.py +174 -0
- procfunc/nodes/__init__.py +66 -0
- procfunc/nodes/bindings_util.py +196 -0
- procfunc/nodes/bpy_node_info.py +280 -0
- procfunc/nodes/compositor.py +2242 -0
- procfunc/nodes/execute/construct_nodes.py +571 -0
- procfunc/nodes/execute/construct_special_cases.py +246 -0
- procfunc/nodes/execute/execute.py +548 -0
- procfunc/nodes/execute/infer_runtime_data_type.py +195 -0
- procfunc/nodes/execute/util.py +247 -0
- procfunc/nodes/func.py +1417 -0
- procfunc/nodes/geo.py +4240 -0
- procfunc/nodes/manifest.json +8769 -0
- procfunc/nodes/math.py +644 -0
- procfunc/nodes/node_function.py +160 -0
- procfunc/nodes/shader.py +2359 -0
- procfunc/nodes/types.py +347 -0
- procfunc/ops/__init__.py +35 -0
- procfunc/ops/_util.py +275 -0
- procfunc/ops/addons.py +59 -0
- procfunc/ops/attr.py +426 -0
- procfunc/ops/collection.py +90 -0
- procfunc/ops/curve.py +18 -0
- procfunc/ops/file.py +126 -0
- procfunc/ops/manifest.json +39149 -0
- procfunc/ops/mesh.py +1510 -0
- procfunc/ops/modifier.py +603 -0
- procfunc/ops/object.py +258 -0
- procfunc/ops/primitives/__init__.py +31 -0
- procfunc/ops/primitives/camera.py +45 -0
- procfunc/ops/primitives/curve.py +71 -0
- procfunc/ops/primitives/light.py +114 -0
- procfunc/ops/primitives/mesh.py +358 -0
- procfunc/ops/uv.py +271 -0
- procfunc/random.py +247 -0
- procfunc/tracer/__init__.py +43 -0
- procfunc/tracer/decorator.py +121 -0
- procfunc/tracer/patch.py +494 -0
- procfunc/tracer/proxy.py +127 -0
- procfunc/tracer/trace.py +222 -0
- procfunc/transforms/__init__.py +49 -0
- procfunc/transforms/cleanup.py +214 -0
- procfunc/transforms/convert.py +20 -0
- procfunc/transforms/distribution.py +191 -0
- procfunc/transforms/extract_materials.py +116 -0
- procfunc/transforms/infer_distribution.py +326 -0
- procfunc/transforms/parameters.py +15 -0
- procfunc/transforms/util.py +35 -0
- procfunc/transpiler/__init__.py +24 -0
- procfunc/transpiler/bpy_to_computegraph.py +1348 -0
- procfunc/transpiler/codegen.py +919 -0
- procfunc/transpiler/identifiers.py +595 -0
- procfunc/transpiler/main.py +299 -0
- procfunc/types.py +380 -0
- procfunc/util/__init__.py +0 -0
- procfunc/util/bpy_info.py +145 -0
- procfunc/util/camera.py +0 -0
- procfunc/util/keyframe.py +70 -0
- procfunc/util/log.py +96 -0
- procfunc/util/manifest.py +121 -0
- procfunc/util/pytree.py +343 -0
- procfunc/util/teardown.py +37 -0
- procfunc-0.30.0.dist-info/METADATA +120 -0
- procfunc-0.30.0.dist-info/RECORD +76 -0
- procfunc-0.30.0.dist-info/WHEEL +5 -0
- procfunc-0.30.0.dist-info/licenses/LICENSE.md +11 -0
- procfunc-0.30.0.dist-info/top_level.txt +1 -0
procfunc/ops/modifier.py
ADDED
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
from typing import Literal, Tuple
|
|
2
|
+
|
|
3
|
+
from procfunc import types as t
|
|
4
|
+
from procfunc.tracer import primitive
|
|
5
|
+
|
|
6
|
+
from ._util import modify
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@primitive(mutates=["mutates_obj"])
|
|
10
|
+
def subdivide_surface(
|
|
11
|
+
mutates_obj: t.MeshObject,
|
|
12
|
+
levels: int = 2,
|
|
13
|
+
subdivision_type: Literal["CATMULL_CLARK", "SIMPLE"] = "CATMULL_CLARK",
|
|
14
|
+
boundary_smooth: Literal["PRE_CLIP", "PRESERVE_CORNERS", "ALL"] = "ALL",
|
|
15
|
+
uv_smooth: Literal[
|
|
16
|
+
"NONE",
|
|
17
|
+
"PRESERVE_CORNERS",
|
|
18
|
+
"PRESERVE_CORNERS_AND_JUNCTIONS",
|
|
19
|
+
"PRESERVE_CORNERS_AND_JUNCTIONS_3_POINTS",
|
|
20
|
+
"PRESERVE_BOUNDARIES",
|
|
21
|
+
"ALL",
|
|
22
|
+
] = "PRESERVE_BOUNDARIES",
|
|
23
|
+
use_creases: bool = True,
|
|
24
|
+
quality: int = 3,
|
|
25
|
+
_skip_apply: bool = False,
|
|
26
|
+
):
|
|
27
|
+
"""
|
|
28
|
+
Apply subdivision surface modifier.
|
|
29
|
+
|
|
30
|
+
We disallow render_levels since this function is automatically executed & fully "applied"
|
|
31
|
+
"""
|
|
32
|
+
return modify(
|
|
33
|
+
mutates_obj,
|
|
34
|
+
"SUBSURF",
|
|
35
|
+
levels=levels,
|
|
36
|
+
render_levels=levels,
|
|
37
|
+
subdivision_type=subdivision_type,
|
|
38
|
+
boundary_smooth=boundary_smooth,
|
|
39
|
+
uv_smooth=uv_smooth,
|
|
40
|
+
use_creases=use_creases,
|
|
41
|
+
quality=quality,
|
|
42
|
+
_skip_apply=_skip_apply,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@primitive(mutates=["mutates_obj"])
|
|
47
|
+
def solidify(
|
|
48
|
+
mutates_obj: t.MeshObject,
|
|
49
|
+
thickness: float = 0.01,
|
|
50
|
+
offset: float = -1.0,
|
|
51
|
+
solidify_mode: Literal["EXTRUDE", "NON_MANIFOLD"] = "EXTRUDE",
|
|
52
|
+
use_even_offset: bool = False,
|
|
53
|
+
use_quality_normals: bool = False,
|
|
54
|
+
thickness_clamp: float = 0.0,
|
|
55
|
+
use_rim: bool = True,
|
|
56
|
+
use_rim_only: bool = False,
|
|
57
|
+
use_flip_normals: bool = False,
|
|
58
|
+
material_offset: int = 0,
|
|
59
|
+
material_offset_rim: int = 0,
|
|
60
|
+
nonmanifold_thickness_mode: Literal["FIXED", "EVEN", "CONSTRAINTS"] = "CONSTRAINTS",
|
|
61
|
+
nonmanifold_boundary_mode: Literal["NONE", "ROUND", "FLAT"] = "NONE",
|
|
62
|
+
nonmanifold_merge_threshold: float = 0.0001,
|
|
63
|
+
):
|
|
64
|
+
"""Apply solidify modifier."""
|
|
65
|
+
return modify(
|
|
66
|
+
mutates_obj,
|
|
67
|
+
"SOLIDIFY",
|
|
68
|
+
thickness=thickness,
|
|
69
|
+
offset=offset,
|
|
70
|
+
solidify_mode=solidify_mode,
|
|
71
|
+
use_even_offset=use_even_offset,
|
|
72
|
+
use_quality_normals=use_quality_normals,
|
|
73
|
+
thickness_clamp=thickness_clamp,
|
|
74
|
+
use_rim=use_rim,
|
|
75
|
+
use_rim_only=use_rim_only,
|
|
76
|
+
use_flip_normals=use_flip_normals,
|
|
77
|
+
material_offset=material_offset,
|
|
78
|
+
material_offset_rim=material_offset_rim,
|
|
79
|
+
nonmanifold_thickness_mode=nonmanifold_thickness_mode,
|
|
80
|
+
nonmanifold_boundary_mode=nonmanifold_boundary_mode,
|
|
81
|
+
nonmanifold_merge_threshold=nonmanifold_merge_threshold,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@primitive(mutates=["mutates_obj"])
|
|
86
|
+
def bevel(
|
|
87
|
+
mutates_obj: t.MeshObject,
|
|
88
|
+
width: float = 0.01,
|
|
89
|
+
segments: int = 1,
|
|
90
|
+
):
|
|
91
|
+
"""Apply bevel modifier."""
|
|
92
|
+
return modify(mutates_obj, "BEVEL", width=width, segments=segments)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@primitive(mutates=["mutates_obj"])
|
|
96
|
+
def _boolean(
|
|
97
|
+
mutates_obj: t.MeshObject,
|
|
98
|
+
target: t.MeshObject | t.Collection,
|
|
99
|
+
operation: Literal["DIFFERENCE", "INTERSECT", "UNION"],
|
|
100
|
+
threshold: float = 1e-6,
|
|
101
|
+
fast: bool = True,
|
|
102
|
+
hole_tolerant: bool = False,
|
|
103
|
+
self_intersect: bool = False,
|
|
104
|
+
):
|
|
105
|
+
if isinstance(target, t.Collection):
|
|
106
|
+
target_kwargs = {
|
|
107
|
+
"collection": target,
|
|
108
|
+
"operand_type": "COLLECTION",
|
|
109
|
+
}
|
|
110
|
+
elif isinstance(target, t.MeshObject):
|
|
111
|
+
target_kwargs = {
|
|
112
|
+
"object": target,
|
|
113
|
+
"operand_type": "OBJECT",
|
|
114
|
+
}
|
|
115
|
+
else:
|
|
116
|
+
raise ValueError(f"Invalid target type: {type(target)}")
|
|
117
|
+
|
|
118
|
+
return modify(
|
|
119
|
+
mutates_obj,
|
|
120
|
+
"BOOLEAN",
|
|
121
|
+
operation=operation,
|
|
122
|
+
solver="FAST" if fast else "EXACT",
|
|
123
|
+
use_hole_tolerant=hole_tolerant,
|
|
124
|
+
use_self=self_intersect,
|
|
125
|
+
**target_kwargs,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@primitive(mutates=["mutates_obj"])
|
|
130
|
+
def boolean_difference(
|
|
131
|
+
mutates_obj: t.MeshObject,
|
|
132
|
+
target: t.MeshObject | t.Collection,
|
|
133
|
+
threshold: float = 1e-6,
|
|
134
|
+
fast: bool = True,
|
|
135
|
+
hole_tolerant: bool = False,
|
|
136
|
+
self_intersect: bool = False,
|
|
137
|
+
):
|
|
138
|
+
"""Apply boolean difference modifier."""
|
|
139
|
+
return _boolean(
|
|
140
|
+
mutates_obj,
|
|
141
|
+
target,
|
|
142
|
+
operation="DIFFERENCE",
|
|
143
|
+
threshold=threshold,
|
|
144
|
+
fast=fast,
|
|
145
|
+
hole_tolerant=hole_tolerant,
|
|
146
|
+
self_intersect=self_intersect,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
@primitive(mutates=["mutates_obj"])
|
|
151
|
+
def boolean_intersect(
|
|
152
|
+
mutates_obj: t.MeshObject,
|
|
153
|
+
target: t.MeshObject | t.Collection,
|
|
154
|
+
threshold: float = 1e-6,
|
|
155
|
+
fast: bool = True,
|
|
156
|
+
hole_tolerant: bool = False,
|
|
157
|
+
self_intersect: bool = False,
|
|
158
|
+
):
|
|
159
|
+
"""Apply boolean intersect modifier."""
|
|
160
|
+
return _boolean(
|
|
161
|
+
mutates_obj,
|
|
162
|
+
target,
|
|
163
|
+
operation="INTERSECT",
|
|
164
|
+
threshold=threshold,
|
|
165
|
+
fast=fast,
|
|
166
|
+
hole_tolerant=hole_tolerant,
|
|
167
|
+
self_intersect=self_intersect,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@primitive(mutates=["mutates_obj"])
|
|
172
|
+
def boolean_union(
|
|
173
|
+
mutates_obj: t.MeshObject,
|
|
174
|
+
target: t.MeshObject,
|
|
175
|
+
threshold: float = 1e-6,
|
|
176
|
+
fast: bool = True,
|
|
177
|
+
hole_tolerant: bool = False,
|
|
178
|
+
self_intersect: bool = False,
|
|
179
|
+
):
|
|
180
|
+
"""Apply boolean union modifier."""
|
|
181
|
+
return _boolean(
|
|
182
|
+
mutates_obj,
|
|
183
|
+
target,
|
|
184
|
+
operation="UNION",
|
|
185
|
+
threshold=threshold,
|
|
186
|
+
fast=fast,
|
|
187
|
+
hole_tolerant=hole_tolerant,
|
|
188
|
+
self_intersect=self_intersect,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@primitive(mutates=["mutates_obj"])
|
|
193
|
+
def mirror(
|
|
194
|
+
mutates_obj: t.MeshObject,
|
|
195
|
+
use_axis: Tuple[bool, bool, bool] = (True, False, False),
|
|
196
|
+
use_bisect_axis: Tuple[bool, bool, bool] = (False, False, False),
|
|
197
|
+
use_bisect_flip_axis: Tuple[bool, bool, bool] = (False, False, False),
|
|
198
|
+
merge_threshold: float = 0.0,
|
|
199
|
+
):
|
|
200
|
+
"""
|
|
201
|
+
Apply mirror modifier.
|
|
202
|
+
|
|
203
|
+
TODO: May also be applicable to t.CurveObject
|
|
204
|
+
"""
|
|
205
|
+
return modify(
|
|
206
|
+
mutates_obj,
|
|
207
|
+
"MIRROR",
|
|
208
|
+
use_axis=use_axis,
|
|
209
|
+
use_bisect_axis=use_bisect_axis,
|
|
210
|
+
use_bisect_flip_axis=use_bisect_flip_axis,
|
|
211
|
+
use_mirror_merge=merge_threshold > 0,
|
|
212
|
+
merge_threshold=merge_threshold,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@primitive(mutates=["mutates_obj"])
|
|
217
|
+
def array(
|
|
218
|
+
mutates_obj: t.MeshObject,
|
|
219
|
+
count: int = 2,
|
|
220
|
+
relative_offset_displace: Tuple[float, float, float] | None = None,
|
|
221
|
+
constant_offset_displace: Tuple[float, float, float] | None = None,
|
|
222
|
+
merge_threshold: float = 0.0,
|
|
223
|
+
):
|
|
224
|
+
"""Apply array modifier."""
|
|
225
|
+
if relative_offset_displace is not None and constant_offset_displace is not None:
|
|
226
|
+
raise ValueError(
|
|
227
|
+
"Cannot specify both relative_offset_displace and constant_offset_displace"
|
|
228
|
+
)
|
|
229
|
+
kwargs = {}
|
|
230
|
+
if relative_offset_displace is not None:
|
|
231
|
+
kwargs = {
|
|
232
|
+
"relative_offset_displace": relative_offset_displace,
|
|
233
|
+
"use_relative_offset": True,
|
|
234
|
+
"use_constant_offset": False,
|
|
235
|
+
}
|
|
236
|
+
if constant_offset_displace is not None:
|
|
237
|
+
kwargs = {
|
|
238
|
+
"constant_offset_displace": constant_offset_displace,
|
|
239
|
+
"use_constant_offset": True,
|
|
240
|
+
"use_relative_offset": False,
|
|
241
|
+
}
|
|
242
|
+
return modify(
|
|
243
|
+
mutates_obj,
|
|
244
|
+
"ARRAY",
|
|
245
|
+
count=count,
|
|
246
|
+
merge_threshold=merge_threshold,
|
|
247
|
+
use_merge_vertices=merge_threshold > 0,
|
|
248
|
+
**kwargs,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@primitive(mutates=["mutates_obj"])
|
|
253
|
+
def decimate_collapse(
|
|
254
|
+
mutates_obj: t.MeshObject,
|
|
255
|
+
ratio: float = 0.5,
|
|
256
|
+
# decimate_type: Literal["COLLAPSE", "UNSUBDIV", "DISSOLVE"] = "COLLAPSE",
|
|
257
|
+
):
|
|
258
|
+
"""
|
|
259
|
+
Apply decimate modifier.
|
|
260
|
+
|
|
261
|
+
TODO: we will add other modes e.g. DISSOLVE and UNSUBDIV at a later date if proven necessary
|
|
262
|
+
"""
|
|
263
|
+
return modify(
|
|
264
|
+
mutates_obj,
|
|
265
|
+
"DECIMATE",
|
|
266
|
+
ratio=ratio,
|
|
267
|
+
decimate_type="COLLAPSE",
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
@primitive(mutates=["mutates_obj"])
|
|
272
|
+
def smooth(
|
|
273
|
+
mutates_obj: t.MeshObject,
|
|
274
|
+
iterations: int = 1,
|
|
275
|
+
factor: float = 0.5,
|
|
276
|
+
):
|
|
277
|
+
"""Apply smooth modifier."""
|
|
278
|
+
return modify(
|
|
279
|
+
mutates_obj,
|
|
280
|
+
"SMOOTH",
|
|
281
|
+
iterations=iterations,
|
|
282
|
+
factor=factor,
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@primitive(mutates=["mutates_obj"])
|
|
287
|
+
def wireframe(
|
|
288
|
+
mutates_obj: t.MeshObject,
|
|
289
|
+
thickness: float = 0.01,
|
|
290
|
+
use_boundary: bool = True,
|
|
291
|
+
use_replace: bool = False,
|
|
292
|
+
):
|
|
293
|
+
"""Apply wireframe modifier."""
|
|
294
|
+
return modify(
|
|
295
|
+
mutates_obj,
|
|
296
|
+
"WIREFRAME",
|
|
297
|
+
thickness=thickness,
|
|
298
|
+
use_boundary=use_boundary,
|
|
299
|
+
use_replace=use_replace,
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@primitive(mutates=["mutates_obj"])
|
|
304
|
+
def triangulate(
|
|
305
|
+
mutates_obj: t.MeshObject,
|
|
306
|
+
quad_method: Literal[
|
|
307
|
+
"BEAUTY", "FIXED", "FIXED_ALTERNATIVE", "SHORTEST_DIAGONAL", "LONGEST_DIAGONAL"
|
|
308
|
+
] = "BEAUTY",
|
|
309
|
+
ngon_method: Literal["BEAUTY", "CLIP"] = "BEAUTY",
|
|
310
|
+
min_vertices=4,
|
|
311
|
+
):
|
|
312
|
+
"""Apply triangulate modifier."""
|
|
313
|
+
return modify(
|
|
314
|
+
mutates_obj,
|
|
315
|
+
"TRIANGULATE",
|
|
316
|
+
quad_method=quad_method,
|
|
317
|
+
ngon_method=ngon_method,
|
|
318
|
+
min_vertices=min_vertices,
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
@primitive(mutates=["mutates_obj"])
|
|
323
|
+
def remesh_voxel(
|
|
324
|
+
mutates_obj: t.MeshObject,
|
|
325
|
+
voxel_size: float = 0.1,
|
|
326
|
+
adaptivity: float = 0.0,
|
|
327
|
+
use_smooth_shade: bool = False,
|
|
328
|
+
):
|
|
329
|
+
"""
|
|
330
|
+
Apply remesh modifier.
|
|
331
|
+
|
|
332
|
+
TODO: we will add other modes e.g. BLOCKS and SMOOTH at a later date if proven necessary
|
|
333
|
+
"""
|
|
334
|
+
return modify(
|
|
335
|
+
mutates_obj,
|
|
336
|
+
"REMESH",
|
|
337
|
+
mode="VOXEL",
|
|
338
|
+
voxel_size=voxel_size,
|
|
339
|
+
adaptivity=adaptivity,
|
|
340
|
+
use_smooth_shade=use_smooth_shade,
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
@primitive(mutates=["mutates_obj"])
|
|
345
|
+
def remesh_blocks(
|
|
346
|
+
mutates_obj: t.MeshObject,
|
|
347
|
+
octree_depth: int = 4,
|
|
348
|
+
scale: float = 0.9,
|
|
349
|
+
use_remove_disconnected: bool = True,
|
|
350
|
+
threshold: float = 1.0,
|
|
351
|
+
use_smooth_shade: bool = False,
|
|
352
|
+
):
|
|
353
|
+
"""Apply remesh modifier with BLOCKS mode."""
|
|
354
|
+
return modify(
|
|
355
|
+
mutates_obj,
|
|
356
|
+
"REMESH",
|
|
357
|
+
mode="BLOCKS",
|
|
358
|
+
octree_depth=octree_depth,
|
|
359
|
+
scale=scale,
|
|
360
|
+
use_remove_disconnected=use_remove_disconnected,
|
|
361
|
+
threshold=threshold,
|
|
362
|
+
use_smooth_shade=use_smooth_shade,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
@primitive(mutates=["mutates_obj"])
|
|
367
|
+
def remesh_smooth(
|
|
368
|
+
mutates_obj: t.MeshObject,
|
|
369
|
+
octree_depth: int = 4,
|
|
370
|
+
scale: float = 0.9,
|
|
371
|
+
use_remove_disconnected: bool = True,
|
|
372
|
+
threshold: float = 1.0,
|
|
373
|
+
use_smooth_shade: bool = False,
|
|
374
|
+
):
|
|
375
|
+
"""Apply remesh modifier with SMOOTH mode."""
|
|
376
|
+
return modify(
|
|
377
|
+
mutates_obj,
|
|
378
|
+
"REMESH",
|
|
379
|
+
mode="SMOOTH",
|
|
380
|
+
octree_depth=octree_depth,
|
|
381
|
+
scale=scale,
|
|
382
|
+
use_remove_disconnected=use_remove_disconnected,
|
|
383
|
+
threshold=threshold,
|
|
384
|
+
use_smooth_shade=use_smooth_shade,
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
@primitive(mutates=["mutates_obj"])
|
|
389
|
+
def remesh_sharp(
|
|
390
|
+
mutates_obj: t.MeshObject,
|
|
391
|
+
octree_depth: int = 4,
|
|
392
|
+
scale: float = 0.9,
|
|
393
|
+
sharpness: float = 1.0,
|
|
394
|
+
use_remove_disconnected: bool = True,
|
|
395
|
+
threshold: float = 1.0,
|
|
396
|
+
use_smooth_shade: bool = False,
|
|
397
|
+
):
|
|
398
|
+
"""Apply remesh modifier with SHARP mode."""
|
|
399
|
+
return modify(
|
|
400
|
+
mutates_obj,
|
|
401
|
+
"REMESH",
|
|
402
|
+
mode="SHARP",
|
|
403
|
+
octree_depth=octree_depth,
|
|
404
|
+
scale=scale,
|
|
405
|
+
sharpness=sharpness,
|
|
406
|
+
use_remove_disconnected=use_remove_disconnected,
|
|
407
|
+
threshold=threshold,
|
|
408
|
+
use_smooth_shade=use_smooth_shade,
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
@primitive(mutates=["mutates_obj"])
|
|
413
|
+
def skin(
|
|
414
|
+
mutates_obj: t.MeshObject,
|
|
415
|
+
use_smooth_shade: bool = True,
|
|
416
|
+
):
|
|
417
|
+
"""Apply skin modifier."""
|
|
418
|
+
return modify(mutates_obj, "SKIN", use_smooth_shade=use_smooth_shade)
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
@primitive(mutates=["mutates_obj"])
|
|
422
|
+
def screw(
|
|
423
|
+
mutates_obj: t.MeshObject,
|
|
424
|
+
angle: float = 6.28318, # 2*pi radians = 360 degrees
|
|
425
|
+
iterations: int = 1,
|
|
426
|
+
screw_offset: float = 0,
|
|
427
|
+
):
|
|
428
|
+
"""Apply screw modifier."""
|
|
429
|
+
return modify(
|
|
430
|
+
mutates_obj,
|
|
431
|
+
"SCREW",
|
|
432
|
+
angle=angle,
|
|
433
|
+
iterations=iterations,
|
|
434
|
+
screw_offset=screw_offset,
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
@primitive(mutates=["mutates_obj"])
|
|
439
|
+
def weld(
|
|
440
|
+
mutates_obj: t.MeshObject,
|
|
441
|
+
merge_threshold: float = 0.001,
|
|
442
|
+
mode: Literal["ALL", "CONNECTED"] = "ALL",
|
|
443
|
+
):
|
|
444
|
+
"""Apply weld modifier."""
|
|
445
|
+
return modify(
|
|
446
|
+
mutates_obj,
|
|
447
|
+
"WELD",
|
|
448
|
+
merge_threshold=merge_threshold,
|
|
449
|
+
mode=mode,
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
@primitive(mutates=["mutates_obj"])
|
|
454
|
+
def corrective_smooth(
|
|
455
|
+
mutates_obj: t.MeshObject,
|
|
456
|
+
iterations: int = 1,
|
|
457
|
+
smooth_type: Literal["SIMPLE", "LENGTH_WEIGHTED"] = "SIMPLE",
|
|
458
|
+
):
|
|
459
|
+
"""Apply corrective smooth modifier."""
|
|
460
|
+
return modify(
|
|
461
|
+
mutates_obj,
|
|
462
|
+
"CORRECTIVE_SMOOTH",
|
|
463
|
+
iterations=iterations,
|
|
464
|
+
smooth_type=smooth_type,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
@primitive(mutates=["mutates_obj"])
|
|
469
|
+
def edge_split(
|
|
470
|
+
mutates_obj: t.MeshObject,
|
|
471
|
+
use_edge_angle: bool = True,
|
|
472
|
+
split_angle: float = 0.523599,
|
|
473
|
+
):
|
|
474
|
+
"""Apply edge split modifier."""
|
|
475
|
+
return modify(
|
|
476
|
+
mutates_obj,
|
|
477
|
+
"EDGE_SPLIT",
|
|
478
|
+
use_edge_angle=use_edge_angle,
|
|
479
|
+
split_angle=split_angle,
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
@primitive(mutates=["mutates_obj"])
|
|
484
|
+
def curve_deform(
|
|
485
|
+
mutates_obj: t.MeshObject,
|
|
486
|
+
curve_object: t.CurveObject,
|
|
487
|
+
deform_axis: Literal[
|
|
488
|
+
"POS_X", "POS_Y", "POS_Z", "NEG_X", "NEG_Y", "NEG_Z"
|
|
489
|
+
] = "POS_Y",
|
|
490
|
+
):
|
|
491
|
+
"""Apply curve deform modifier to bend mesh along a curve."""
|
|
492
|
+
return modify(
|
|
493
|
+
mutates_obj,
|
|
494
|
+
"CURVE",
|
|
495
|
+
object=curve_object,
|
|
496
|
+
deform_axis=deform_axis,
|
|
497
|
+
)
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
@primitive(mutates=["mutates_obj"])
|
|
501
|
+
def shrinkwrap(
|
|
502
|
+
mutates_obj: t.MeshObject,
|
|
503
|
+
target: t.MeshObject,
|
|
504
|
+
# wrap_method: Literal["NEAREST_SURFACEPOINT", "NEAREST_VERTEX", "PROJECT", "TARGET_PROJECT"] = "NEAREST_SURFACEPOINT",
|
|
505
|
+
):
|
|
506
|
+
"""Apply shrinkwrap modifier."""
|
|
507
|
+
return modify(
|
|
508
|
+
mutates_obj,
|
|
509
|
+
"SHRINKWRAP",
|
|
510
|
+
target=target,
|
|
511
|
+
wrap_method="NEAREST_SURFACEPOINT",
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
@primitive(mutates=["mutates_obj"])
|
|
516
|
+
def displacement(
|
|
517
|
+
mutates_obj: t.MeshObject,
|
|
518
|
+
texture: t.Texture | None = None,
|
|
519
|
+
strength: float = 1.0,
|
|
520
|
+
mid_level: float = 0.5,
|
|
521
|
+
direction: Literal[
|
|
522
|
+
"X", "Y", "Z", "NORMAL", "CUSTOM_NORMAL", "RGB_TO_XYZ"
|
|
523
|
+
] = "NORMAL",
|
|
524
|
+
space: Literal["LOCAL", "GLOBAL"] = "LOCAL",
|
|
525
|
+
texture_coords: Literal["LOCAL", "GLOBAL", "OBJECT", "UV"] = "LOCAL",
|
|
526
|
+
texture_coords_object: t.Object | None = None,
|
|
527
|
+
uv_layer: str = "",
|
|
528
|
+
vertex_group: str = "",
|
|
529
|
+
invert_vertex_group: bool = False,
|
|
530
|
+
texture_coords_bone: str = "",
|
|
531
|
+
):
|
|
532
|
+
"""Apply displacement modifier."""
|
|
533
|
+
kwargs = {}
|
|
534
|
+
if texture_coords == "OBJECT" and texture_coords_object is not None:
|
|
535
|
+
kwargs["texture_coords_object"] = texture_coords_object
|
|
536
|
+
|
|
537
|
+
return modify(
|
|
538
|
+
mutates_obj,
|
|
539
|
+
"DISPLACE",
|
|
540
|
+
texture=texture,
|
|
541
|
+
strength=strength,
|
|
542
|
+
mid_level=mid_level,
|
|
543
|
+
direction=direction,
|
|
544
|
+
space=space,
|
|
545
|
+
texture_coords=texture_coords,
|
|
546
|
+
uv_layer=uv_layer,
|
|
547
|
+
vertex_group=vertex_group,
|
|
548
|
+
invert_vertex_group=invert_vertex_group,
|
|
549
|
+
texture_coords_bone=texture_coords_bone,
|
|
550
|
+
**kwargs,
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
@primitive(mutates=["mutates_obj"])
|
|
555
|
+
def laplacian_smooth(
|
|
556
|
+
mutates_obj: t.MeshObject,
|
|
557
|
+
iterations: int = 1,
|
|
558
|
+
lambda_factor: float = 1.0,
|
|
559
|
+
lambda_border: float = 1.0,
|
|
560
|
+
):
|
|
561
|
+
"""Apply Laplacian smooth modifier."""
|
|
562
|
+
return modify(
|
|
563
|
+
mutates_obj,
|
|
564
|
+
"LAPLACIANSMOOTH",
|
|
565
|
+
iterations=iterations,
|
|
566
|
+
lambda_factor=lambda_factor,
|
|
567
|
+
lambda_border=lambda_border,
|
|
568
|
+
)
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
'''
|
|
572
|
+
@primitive(mutates=["mutates_obj"])
|
|
573
|
+
def collision(
|
|
574
|
+
mutates_obj: t.MeshObject,
|
|
575
|
+
):
|
|
576
|
+
"""Apply collision modifier."""
|
|
577
|
+
return _modify(mutates_obj, "COLLISION")
|
|
578
|
+
'''
|
|
579
|
+
|
|
580
|
+
__all__ = [
|
|
581
|
+
"array",
|
|
582
|
+
"bevel",
|
|
583
|
+
"boolean_difference",
|
|
584
|
+
"curve_deform",
|
|
585
|
+
"boolean_intersect",
|
|
586
|
+
"boolean_union",
|
|
587
|
+
"corrective_smooth",
|
|
588
|
+
"decimate_collapse",
|
|
589
|
+
"displacement",
|
|
590
|
+
"edge_split",
|
|
591
|
+
"laplacian_smooth",
|
|
592
|
+
"mirror",
|
|
593
|
+
"remesh_voxel",
|
|
594
|
+
"screw",
|
|
595
|
+
"shrinkwrap",
|
|
596
|
+
"skin",
|
|
597
|
+
"smooth",
|
|
598
|
+
"solidify",
|
|
599
|
+
"subdivide_surface",
|
|
600
|
+
"triangulate",
|
|
601
|
+
"weld",
|
|
602
|
+
"wireframe",
|
|
603
|
+
]
|