Skip to content

Commit ba6dcf6

Browse files
committed
Fixes for 3.4
1 parent 740544f commit ba6dcf6

File tree

5 files changed

+40
-22
lines changed

5 files changed

+40
-22
lines changed

file/copybuffer_flatten.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import bpy
22
import re
3-
from ..helpers import get_context, select_only, load_selection, save_selection, swap_object_names
3+
from ..helpers import (
4+
get_context,
5+
load_selection,
6+
save_selection,
7+
select_only,
8+
swap_object_names,
9+
try_call,
10+
)
411

512
# TODO
613
# - Make flattening optional and rename to Copy Advanced
@@ -20,14 +27,6 @@ def clear_pointers(obj):
2027
if getattr(obj, prop_id) != my_data:
2128
setattr(obj, prop_id, None)
2229

23-
def try_call(f, *args, **kwargs):
24-
try:
25-
f(*args, **kwargs)
26-
return True
27-
except RuntimeError:
28-
pass
29-
return False
30-
3130
class GRET_OT_copybuffer_flatten(bpy.types.Operator):
3231
#tooltip
3332
"""Selected objects alone are copied to the clipboard, even if they reference other objects.

helpers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,14 @@ def wrapper(*args, **kwargs):
441441
else:
442442
return decorator(_func)
443443

444+
def try_call(f, *args, **kwargs):
445+
try:
446+
f(*args, **kwargs)
447+
return True
448+
except RuntimeError:
449+
pass
450+
return False
451+
444452
def get_export_path(path, fields):
445453
"""Returns an absolute path from an export path."""
446454

jobs/rig_export.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,9 @@ def should_apply_modifier(modifier):
299299
obj.data.name = job.export_collection.name
300300
job.export_collection.objects.link(obj)
301301
context.scene.collection.objects.unlink(obj)
302-
# Disable features on output meshes for performance
302+
# Auto-smooth has a noticeable impact in performance while animating,
303+
# disable unless the user explicitly enabled it back in the previous build result
303304
obj.data.use_auto_smooth = use_auto_smooth
304-
obj.data.use_customdata_vertex_bevel = False
305-
obj.data.use_customdata_edge_bevel = False
306-
obj.data.use_customdata_edge_crease = False
307305
# Don't delete this
308306
self.new_objs.discard(obj)
309307
self.new_meshes.discard(obj.data)

mesh/collision.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
get_point_dist_to_line_sq,
1212
get_range_pct,
1313
)
14-
from ..helpers import get_collection, TempModifier
14+
from ..helpers import try_call, get_context, get_collection, TempModifier
1515

1616
# make_collision TODO:
1717
# - Non-axis aligned boxes
@@ -34,19 +34,33 @@ def find_free_col_name(prefix, name):
3434
break
3535
return col_name
3636

37+
def clear_customdata(obj, sculpt_mask_data=True, skin_data=True, custom_split_normals=True,
38+
edge_bevel_weight=True, vertex_bevel_weight=True, edge_crease=True, vertex_crease=True):
39+
ctx = get_context(obj)
40+
if sculpt_mask_data:
41+
try_call(bpy.ops.mesh.customdata_mask_clear, ctx)
42+
if skin_data:
43+
try_call(bpy.ops.mesh.customdata_skin_clear, ctx)
44+
if custom_split_normals:
45+
try_call(bpy.ops.mesh.customdata_custom_splitnormals_clear, ctx)
46+
if edge_bevel_weight:
47+
try_call(bpy.ops.mesh.customdata_bevel_weight_edge_clear, ctx)
48+
if vertex_bevel_weight:
49+
try_call(bpy.ops.mesh.customdata_bevel_weight_vertex_clear, ctx)
50+
if edge_crease:
51+
try_call(bpy.ops.mesh.customdata_crease_edge_clear, ctx)
52+
if vertex_crease:
53+
try_call(bpy.ops.mesh.customdata_crease_vertex_clear, ctx)
54+
3755
def remove_extra_data(obj):
3856
assert obj.type == 'MESH'
3957

4058
obj.vertex_groups.clear()
4159
obj.shape_key_clear()
60+
clear_customdata(obj)
4261

4362
mesh = obj.data
44-
mesh.use_customdata_vertex_bevel = False
45-
mesh.use_customdata_edge_bevel = False
46-
mesh.use_customdata_edge_crease = False
47-
48-
# mesh.materials.clear() seems to crash
49-
while mesh.materials:
63+
while mesh.materials: # mesh.materials.clear() seems to crash
5064
mesh.materials.pop()
5165
while mesh.uv_layers.active:
5266
mesh.uv_layers.remove(mesh.uv_layers.active)

mesh/extra_objects.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ def execute(self, context):
284284
mesh.from_pydata(vertices, [], faces)
285285
for face in mesh.polygons:
286286
face.use_smooth = self.use_smooth_shade
287-
mesh.use_customdata_edge_crease = True
288287
mesh.use_auto_smooth = True
289288
mesh.auto_smooth_angle = pi
290289
for edge in (mesh.edges[4], mesh.edges[8]):
@@ -318,7 +317,7 @@ def execute(self, context):
318317
mod.deform_axis = 'Z'
319318

320319
mod = obj.modifiers.new(type='ARRAY', name="")
321-
mod.count = self.number_of_rows
320+
mod.count = self.rows
322321
mod.relative_offset_displace = [0.0, 0.0, 1.0]
323322
mod.use_merge_vertices = True
324323
mod.merge_threshold = 1e-5

0 commit comments

Comments
 (0)