[go: up one dir, main page]

Skip to content

Commit

Permalink
fixed bug in blender extension plugin (smoothing groups)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicSavichev committed Feb 22, 2024
1 parent e09ca10 commit 8ca24ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion prog/tools/dag4blend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
bl_info = {"name": "dag4blend",
"description": "Tools for editing dag files",
"author": "Gaijin Entertainment",
"version": (2, 1, 7),#2024.02.20
"version": (2, 1, 8),#2024.02.22
"blender": (4, 0, 2),
"location": "File > Export",
"wiki_url": "",
Expand Down
4 changes: 2 additions & 2 deletions prog/tools/dag4blend/exporter/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ..tools.tools_functions import *

from ..smooth_groups.smooth_groups import int_to_uint
from ..smooth_groups.mesh_calc_smooth_groups import mesh_calc_smooth_groups
from ..smooth_groups.mesh_calc_smooth_groups import objects_calc_smooth_groups


SUPPORTED_TYPES = ('MESH', 'CURVE') # ,'CURVE','EMPTY','TEXT','CAMERA','LAMP')
Expand Down Expand Up @@ -365,7 +365,7 @@ def dumpMesh(self, obj, node, scene):
fix_mat_slots(exp_obj)
reorder_uv_layers(me)
if exp_obj.data.attributes.get('SG') is None:
mesh_calc_smooth_groups(exp_obj.data)
objects_calc_smooth_groups([exp_obj])
#collecting from pre-triangulated mesh to make it reversable on import
edge_keys = self.getEdgeKeys(exp_obj, scene)
#dag contains only triangles
Expand Down
6 changes: 3 additions & 3 deletions prog/tools/dag4blend/smooth_groups/mesh_calc_smooth_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def uint_to_int(int):
return int-SG_MAX_UINT

def int_to_uint(int):
if int>0:
if int>=0:
return int
else:
return SG_MAX_UINT+int#2**32-something
Expand Down Expand Up @@ -157,6 +157,7 @@ def mesh_calc_smooth_groups(mesh):
Attr = bm.faces.layers.int.new("SG")
for face in bm.faces:
face[Attr] = SmoothGroups[face.index] if face.smooth else 0
bmesh_to_mesh(bm, mesh)
return

def init_sg_attribute(object):
Expand All @@ -172,8 +173,6 @@ def init_sg_attribute(object):
#Calculates SG attribute for input 'MESH' objects
def objects_calc_smooth_groups(objects):
current_mode = bpy.context.mode
for obj in objects:
init_sg_attribute(obj)
#applying edit_mesh changes to meshes if necessary
if current_mode == 'EDIT_MESH':
needs_update = False
Expand All @@ -185,5 +184,6 @@ def objects_calc_smooth_groups(objects):
bpy.ops.object.editmode_toggle()# "edit_mesh" might not match "mesh", it updates only on switching
bpy.ops.object.editmode_toggle()# keepeng user in the same mode by switching back to edit
for obj in objects:
init_sg_attribute(obj)
mesh_calc_smooth_groups(obj.data)
return

0 comments on commit 8ca24ea

Please sign in to comment.