mesh_snap_utilities_line: match blender 2.8 updates
This commit is contained in:
parent
7f1ac1abfa
commit
d140d94bad
|
@ -22,11 +22,11 @@
|
|||
bl_info = {
|
||||
"name": "Snap_Utilities_Line",
|
||||
"author": "Germano Cavalcante",
|
||||
"version": (5, 9, 9),
|
||||
"version": (5, 9, 12),
|
||||
"blender": (2, 80, 0),
|
||||
"location": "View3D > TOOLS > Line Tool",
|
||||
"description": "Extends Blender Snap controls",
|
||||
"wiki_url" : "http://blenderartists.org/forum/showthread.php?363859-Addon-CAD-Snap-Utilities",
|
||||
"wiki_url" : "https://blenderartists.org/t/cad-snap-utilities",
|
||||
"category": "Mesh"}
|
||||
|
||||
if "bpy" in locals():
|
||||
|
|
|
@ -37,56 +37,103 @@ class SnapUtilitiesPreferences(bpy.types.AddonPreferences):
|
|||
bl_idname = __package__
|
||||
|
||||
intersect: BoolProperty(
|
||||
name="Intersect",
|
||||
description="intersects created line with the existing edges, even if the lines do not intersect",
|
||||
default=True)
|
||||
name="Intersect",
|
||||
description="intersects created line with the existing edges, even if the lines do not intersect",
|
||||
default=True)
|
||||
|
||||
create_face: BoolProperty(
|
||||
name="Create faces",
|
||||
description="Create faces defined by enclosed edges",
|
||||
default=False)
|
||||
name="Create faces",
|
||||
description="Create faces defined by enclosed edges",
|
||||
default=False)
|
||||
|
||||
outer_verts: BoolProperty(
|
||||
name="Snap to outer vertices",
|
||||
description="The vertices of the objects are not activated also snapped",
|
||||
default=True)
|
||||
name="Snap to outer vertices",
|
||||
description="The vertices of the objects are not activated also snapped",
|
||||
default=True)
|
||||
|
||||
increments_grid: BoolProperty(
|
||||
name="Increments of Grid",
|
||||
description="Snap to increments of grid",
|
||||
default=False)
|
||||
name="Increments of Grid",
|
||||
description="Snap to increments of grid",
|
||||
default=False)
|
||||
|
||||
incremental: FloatProperty(
|
||||
name="Incremental",
|
||||
description="Snap in defined increments",
|
||||
default=0,
|
||||
min=0,
|
||||
step=1,
|
||||
precision=3)
|
||||
name="Incremental",
|
||||
description="Snap in defined increments",
|
||||
default=0,
|
||||
min=0,
|
||||
step=1,
|
||||
precision=3)
|
||||
|
||||
relative_scale: FloatProperty(
|
||||
name="Relative Scale",
|
||||
description="Value that divides the global scale",
|
||||
default=1,
|
||||
min=0,
|
||||
step=1,
|
||||
precision=3)
|
||||
name="Relative Scale",
|
||||
description="Value that divides the global scale",
|
||||
default=1,
|
||||
min=0,
|
||||
step=1,
|
||||
precision=3)
|
||||
|
||||
out_color: FloatVectorProperty(name="Floor", default=(0.0, 0.0, 0.0, 0.5), size=4, subtype="COLOR", min=0, max=1)
|
||||
face_color: FloatVectorProperty(name="Face Highlighted", default=(1.0, 0.8, 0.0, 0.5), size=4, subtype="COLOR", min=0, max=1)
|
||||
edge_color: FloatVectorProperty(name="Edge Highlighted", default=(0.0, 0.8, 1.0, 0.5), size=4, subtype="COLOR", min=0, max=1)
|
||||
vert_color: FloatVectorProperty(name="Vertex Highlighted", default=(1.0, 0.5, 0.0, 0.5), size=4, subtype="COLOR", min=0, max=1)
|
||||
center_color: FloatVectorProperty(name="Middle of the Edge", default=(1.0, 0.0, 1.0, 1.0), size=4, subtype="COLOR", min=0, max=1)
|
||||
perpendicular_color: FloatVectorProperty(name="Perpendicular Point", default=(0.1, 0.5, 0.5, 1.0), size=4, subtype="COLOR", min=0, max=1)
|
||||
constrain_shift_color: FloatVectorProperty(name="Shift Constrain", default=(0.8, 0.5, 0.4, 1.0), size=4, subtype="COLOR", min=0, max=1)
|
||||
out_color: FloatVectorProperty(
|
||||
name="Floor",
|
||||
default=(0.0, 0.0, 0.0, 0.5),
|
||||
size=4,
|
||||
subtype="COLOR",
|
||||
min=0,
|
||||
max=1)
|
||||
|
||||
face_color: FloatVectorProperty(
|
||||
name="Face Highlighted",
|
||||
default=(1.0, 0.8, 0.0, 0.5),
|
||||
size=4,
|
||||
subtype="COLOR",
|
||||
min=0,
|
||||
max=1)
|
||||
|
||||
edge_color: FloatVectorProperty(
|
||||
name="Edge Highlighted",
|
||||
default=(0.0, 0.8, 1.0, 0.5),
|
||||
size=4,
|
||||
subtype="COLOR",
|
||||
min=0,
|
||||
max=1)
|
||||
|
||||
vert_color: FloatVectorProperty(
|
||||
name="Vertex Highlighted",
|
||||
default=(1.0, 0.5, 0.0, 0.5),
|
||||
size=4, subtype="COLOR",
|
||||
min=0,
|
||||
max=1)
|
||||
|
||||
center_color: FloatVectorProperty(
|
||||
name="Middle of the Edge",
|
||||
default=(1.0, 0.0, 1.0, 1.0),
|
||||
size=4,
|
||||
subtype="COLOR",
|
||||
min=0,
|
||||
max=1)
|
||||
|
||||
perpendicular_color: FloatVectorProperty(
|
||||
name="Perpendicular Point",
|
||||
default=(0.1, 0.5, 0.5, 1.0),
|
||||
size=4,
|
||||
subtype="COLOR",
|
||||
min=0,
|
||||
max=1)
|
||||
|
||||
constrain_shift_color: FloatVectorProperty(
|
||||
name="Shift Constrain",
|
||||
default=(0.8, 0.5, 0.4, 1.0),
|
||||
size=4,
|
||||
subtype="COLOR",
|
||||
min=0,
|
||||
max=1)
|
||||
|
||||
# hidden
|
||||
tabs: EnumProperty(
|
||||
name="Tabs",
|
||||
items = [
|
||||
("GENERAL", "General", ""),
|
||||
("KEYMAPS", "Keymaps", ""),
|
||||
("COLORS", "Colors", ""),
|
||||
("HELP", "Links", ""),
|
||||
],
|
||||
default="GENERAL")
|
||||
|
||||
|
@ -102,12 +149,15 @@ class SnapUtilitiesPreferences(bpy.types.AddonPreferences):
|
|||
if self.tabs == "GENERAL":
|
||||
self.draw_general(box)
|
||||
|
||||
if self.tabs == "COLORS":
|
||||
elif self.tabs == "COLORS":
|
||||
self.draw_snap_utilities_colors(box)
|
||||
|
||||
elif self.tabs == "KEYMAPS":
|
||||
self.draw_snap_utilities_keymaps(context, box)
|
||||
|
||||
elif self.tabs == "HELP":
|
||||
self.draw_snap_utilities_help(box)
|
||||
|
||||
def draw_general(self, layout):
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
|
@ -139,6 +189,20 @@ class SnapUtilitiesPreferences(bpy.types.AddonPreferences):
|
|||
flow.prop(self, "center_color")
|
||||
flow.prop(self, "perpendicular_color")
|
||||
|
||||
def draw_snap_utilities_help(self, layout):
|
||||
layout.operator(
|
||||
"wm.url_open", text="Download Page", icon='HELP',
|
||||
).url = "https://blendermarket.com/products/snap-utilities"
|
||||
|
||||
layout.operator(
|
||||
"wm.url_open", text="Wiki", icon='HELP',
|
||||
).url = "https://github.com/Mano-Wii/Addon-Snap-Utilities-Line/wiki"
|
||||
|
||||
layout.operator(
|
||||
"wm.url_open", text="Forum", icon='HELP',
|
||||
).url = "https://blenderartists.org/t/cad-snap-utilities"
|
||||
|
||||
|
||||
def draw_snap_utilities_keymaps(self, context, layout):
|
||||
from .keys import (
|
||||
generate_snap_utilities_global_keymaps,
|
||||
|
|
|
@ -118,7 +118,7 @@ class _SnapOffscreen():
|
|||
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.buf_color[0])
|
||||
bgl.glTexImage2D(
|
||||
bgl.GL_TEXTURE_2D, 0, bgl.GL_R32UI, self.width, self.height,
|
||||
0, bgl.GL_RED_INTEGER, bgl.GL_UNSIGNED_INT, NULL)
|
||||
0, bgl.GL_RED_INTEGER, bgl.GL_UNSIGNED_INT, None)
|
||||
del NULL
|
||||
|
||||
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
|
||||
|
@ -266,6 +266,24 @@ class SnapContext():
|
|||
return snap_obj
|
||||
return None
|
||||
|
||||
def _read_buffer(self, mval):
|
||||
xmin = int(mval[0]) - self._dist_px
|
||||
ymin = int(mval[1]) - self._dist_px
|
||||
size_x = size_y = self.threshold
|
||||
|
||||
if xmin < 0:
|
||||
#size_x += xmin
|
||||
xmin = 0
|
||||
|
||||
if ymin < 0:
|
||||
#size_y += ymin
|
||||
ymin = 0
|
||||
|
||||
bgl.glReadBuffer(bgl.GL_COLOR_ATTACHMENT0)
|
||||
bgl.glReadPixels(
|
||||
xmin, ymin, size_x, size_y,
|
||||
bgl.GL_RED_INTEGER, bgl.GL_UNSIGNED_INT, self._snap_buffer)
|
||||
|
||||
def _get_nearest_index(self):
|
||||
r_snap_obj = None
|
||||
r_value = 0
|
||||
|
@ -507,7 +525,7 @@ class SnapContext():
|
|||
|
||||
if bbmin != bbmax:
|
||||
MVP = proj_mat @ snap_obj.mat
|
||||
mat_inv = snap_obj.mat.inverted()
|
||||
mat_inv = snap_obj.mat.inverted_safe()
|
||||
ray_orig_local = mat_inv @ ray_orig
|
||||
ray_dir_local = mat_inv.to_3x3() @ ray_dir
|
||||
in_threshold = _Internal.intersect_boundbox_threshold(
|
||||
|
@ -542,13 +560,7 @@ class SnapContext():
|
|||
|
||||
self.drawn_count += 1
|
||||
|
||||
bgl.glReadBuffer(bgl.GL_COLOR_ATTACHMENT0)
|
||||
|
||||
bgl.glReadPixels(
|
||||
int(self.mval[0]) - self._dist_px, int(self.mval[1]) - self._dist_px,
|
||||
self.threshold, self.threshold, bgl.GL_RED_INTEGER, bgl.GL_UNSIGNED_INT, self._snap_buffer)
|
||||
|
||||
#bgl.glReadBuffer(bgl.GL_BACK)
|
||||
self._read_buffer(mval)
|
||||
#import numpy as np
|
||||
#a = np.array(self._snap_buffer)
|
||||
#print(a)
|
||||
|
|
|
@ -145,9 +145,9 @@ class SnapPointWidget(SnapWidgetCommon):
|
|||
|
||||
|
||||
def context_mode_check(context, widget_group):
|
||||
workspace = context.workspace
|
||||
mode = workspace.tools_mode
|
||||
for tool in workspace.tools:
|
||||
tools = context.workspace.tools
|
||||
mode = context.mode
|
||||
for tool in tools:
|
||||
if (tool.widget == widget_group) and (tool.mode == mode):
|
||||
break
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue