[fix] fix various bugs
- update README to keep update with plugin design * refactor Select by Virtools Group section * add material preset function description - fix issue about flatten uv may get zero base vector. - update elements adder menu. - bump up version to 3.1
This commit is contained in:
@ -74,13 +74,26 @@ def _real_flatten_uv(mesh, reference_edge, scale_correction):
|
||||
if not face.select:
|
||||
continue
|
||||
|
||||
# check whether ref edge is legal
|
||||
allPoint = len(face.loops)
|
||||
|
||||
if allPoint <= reference_edge:
|
||||
no_processed_count+=1
|
||||
continue
|
||||
|
||||
# get correct new corrdinate system
|
||||
# yyc mark:
|
||||
# we use 3 points located in this face to calc
|
||||
# the base of this local uv corredinate system.
|
||||
# however if this 3 points are set in a line,
|
||||
# this method will cause a error, zero vector error.
|
||||
#
|
||||
# if z axis is zero vector, we will try using face normal instead
|
||||
# to try getting correct data.
|
||||
#
|
||||
# zero base is not important. because it will not raise any math exceptio
|
||||
# just a weird uv. user will notice this problem.
|
||||
|
||||
# get point
|
||||
p1Relative = reference_edge
|
||||
p2Relative = reference_edge + 1
|
||||
p3Relative = reference_edge + 2
|
||||
@ -93,13 +106,19 @@ def _real_flatten_uv(mesh, reference_edge, scale_correction):
|
||||
p2=mathutils.Vector(tuple(face.loops[p2Relative].vert.co[x] for x in range(3)))
|
||||
p3=mathutils.Vector(tuple(face.loops[p3Relative].vert.co[x] for x in range(3)))
|
||||
|
||||
# get y axis
|
||||
new_y_axis = p2 - p1
|
||||
new_y_axis.normalize()
|
||||
vec1 = p3 - p2
|
||||
vec1.normalize()
|
||||
|
||||
# get z axis
|
||||
new_z_axis = new_y_axis.cross(vec1)
|
||||
new_z_axis.normalize()
|
||||
if not any(round(v, 7) for v in new_z_axis):
|
||||
new_z_axis = face.normal.normalized()
|
||||
|
||||
# get x axis
|
||||
new_x_axis = new_y_axis.cross(new_z_axis)
|
||||
new_x_axis.normalize()
|
||||
|
||||
@ -109,14 +128,14 @@ def _real_flatten_uv(mesh, reference_edge, scale_correction):
|
||||
(0, 1.0, 0),
|
||||
(0, 0, 1.0)
|
||||
))
|
||||
origin_base.invert()
|
||||
origin_base.invert_safe()
|
||||
new_base = mathutils.Matrix((
|
||||
(new_x_axis.x, new_y_axis.x, new_z_axis.x),
|
||||
(new_x_axis.y, new_y_axis.y, new_z_axis.y),
|
||||
(new_x_axis.z, new_y_axis.z, new_z_axis.z)
|
||||
))
|
||||
transition_matrix = origin_base @ new_base
|
||||
transition_matrix.invert()
|
||||
transition_matrix.invert_safe()
|
||||
|
||||
# process each face
|
||||
for loop_index in range(allPoint):
|
||||
|
@ -71,6 +71,13 @@ class BALLANCE_OT_add_components(common_add_component_props):
|
||||
layout.prop(self, "elements_type")
|
||||
self.parent_draw(layout, self.elements_type)
|
||||
|
||||
@classmethod
|
||||
def draw_blc_menu(self, layout):
|
||||
for item in UTILS_constants.bmfile_componentList:
|
||||
cop = layout.operator(
|
||||
self.bl_idname, text=item,
|
||||
icon_value = UTILS_icons_manager.get_element_icon(item))
|
||||
cop.elements_type = item
|
||||
|
||||
|
||||
class BALLANCE_OT_add_components_dup(common_add_component_props):
|
||||
@ -79,6 +86,10 @@ class BALLANCE_OT_add_components_dup(common_add_component_props):
|
||||
bl_label = "Add Duplicated Elements"
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
can_duplicated_elements = (
|
||||
'P_Extra_Point', 'P_Modul_18', 'P_Modul_26'
|
||||
)
|
||||
|
||||
elements_type: bpy.props.EnumProperty(
|
||||
name="Type",
|
||||
description="This element type",
|
||||
@ -86,9 +97,7 @@ class BALLANCE_OT_add_components_dup(common_add_component_props):
|
||||
items=tuple(
|
||||
# token, display name, descriptions, icon, index
|
||||
(blk, blk, "", UTILS_icons_manager.get_element_icon(blk), idx)
|
||||
for idx, blk in enumerate(
|
||||
('P_Extra_Point', 'P_Modul_18', 'P_Modul_26')
|
||||
)
|
||||
for idx, blk in enumerate(can_duplicated_elements)
|
||||
),
|
||||
)
|
||||
|
||||
@ -125,6 +134,13 @@ class BALLANCE_OT_add_components_dup(common_add_component_props):
|
||||
self.parent_draw(layout, self.elements_type)
|
||||
layout.prop(self, "elements_dup_times")
|
||||
|
||||
@classmethod
|
||||
def draw_blc_menu(self, layout):
|
||||
for item in self.can_duplicated_elements:
|
||||
cop = layout.operator(
|
||||
self.bl_idname, text=item,
|
||||
icon_value = UTILS_icons_manager.get_element_icon(item))
|
||||
cop.elements_type = item
|
||||
|
||||
|
||||
class BALLANCE_OT_add_components_series(common_add_component_props):
|
||||
@ -208,3 +224,11 @@ class BALLANCE_OT_add_components_series(common_add_component_props):
|
||||
self.parent_draw(layout, self.elements_type)
|
||||
layout.prop(self, "elements_dup_times")
|
||||
layout.prop(self, "elements_span")
|
||||
|
||||
@classmethod
|
||||
def draw_blc_menu(self, layout):
|
||||
for key, item in self.supported_series.items():
|
||||
cop = layout.operator(
|
||||
self.bl_idname, text=item[0],
|
||||
icon_value = UTILS_icons_manager.get_element_icon(item[1]))
|
||||
cop.elements_type = key
|
||||
|
@ -155,6 +155,9 @@ class BALLANCE_OT_add_floors(bpy.types.Operator):
|
||||
# now I migrate default side value setter to updator of enum property.
|
||||
# nothing need to process in here now.
|
||||
|
||||
# trigger default side props updator
|
||||
self.floor_type_updated(context)
|
||||
|
||||
return self.execute(context)
|
||||
|
||||
|
||||
|
@ -119,24 +119,37 @@ class BALLANCE_MT_AddRailMenu(bpy.types.Menu):
|
||||
layout.operator(OBJS_add_rails.BALLANCE_OT_add_rails.bl_idname, text="Rail Section")
|
||||
layout.operator(OBJS_add_rails.BALLANCE_OT_add_tunnels.bl_idname, text="Tunnel Section")
|
||||
|
||||
class BALLANCE_MT_AddNormalElementsMenu(bpy.types.Menu):
|
||||
"""Add Ballance Elements"""
|
||||
bl_idname = "BALLANCE_MT_AddNormalElementsMenu"
|
||||
bl_label = "Elements"
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
OBJS_add_components.BALLANCE_OT_add_components.draw_blc_menu(layout)
|
||||
class BALLANCE_MT_AddDupElementsMenu(bpy.types.Menu):
|
||||
"""Add Ballance Elements"""
|
||||
bl_idname = "BALLANCE_MT_AddDupElementsMenu"
|
||||
bl_label = "Elements"
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
OBJS_add_components.BALLANCE_OT_add_components_dup.draw_blc_menu(layout)
|
||||
class BALLANCE_MT_AddElementsMenu(bpy.types.Menu):
|
||||
"""Add Ballance Elements"""
|
||||
bl_idname = "BALLANCE_MT_AddElementsMenu"
|
||||
bl_label = "Elements"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.label(text="Basic Elements")
|
||||
for item in UTILS_constants.bmfile_componentList:
|
||||
cop = layout.operator(
|
||||
OBJS_add_components.BALLANCE_OT_add_components.bl_idname,
|
||||
text=item, icon_value = UTILS_icons_manager.get_element_icon(item))
|
||||
cop.elements_type = item
|
||||
|
||||
layout.label(text="Special Elements")
|
||||
layout.operator(OBJS_add_components.BALLANCE_OT_add_components_dup.bl_idname, text="Dup Elements")
|
||||
layout.operator(OBJS_add_components.BALLANCE_OT_add_components_series.bl_idname, text="Elements Series")
|
||||
OBJS_add_components.BALLANCE_OT_add_components.draw_blc_menu(layout)
|
||||
|
||||
layout.separator()
|
||||
layout.label(text="Duplicated Elements")
|
||||
OBJS_add_components.BALLANCE_OT_add_components_dup.draw_blc_menu(layout)
|
||||
|
||||
layout.separator()
|
||||
layout.label(text="Elements Series")
|
||||
OBJS_add_components.BALLANCE_OT_add_components_series.draw_blc_menu(layout)
|
||||
|
||||
# =============================================
|
||||
# blender call system
|
||||
|
Reference in New Issue
Block a user