Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kim <pk15950@gmail.com>2021-09-02 07:36:46 +0300
committerPeter Kim <pk15950@gmail.com>2021-09-02 07:36:46 +0300
commite2c0ecc936945e27b17eaf69096f2fefff4a851a (patch)
tree60ea8842d4a623ba8e8545a99843be8a83cc12f4
parent7a45dbeda20292a168dccdac102e52018c416c5c (diff)
parent59c8409947c4174983a36ec28dfeda2be9e254d2 (diff)
Merge branch 'master' into xr-controller-support
-rw-r--r--mesh_looptools.py4
-rw-r--r--space_view3d_math_vis/draw.py44
-rw-r--r--space_view3d_math_vis/utils.py18
3 files changed, 41 insertions, 25 deletions
diff --git a/mesh_looptools.py b/mesh_looptools.py
index 62f9aa47..5e0988b5 100644
--- a/mesh_looptools.py
+++ b/mesh_looptools.py
@@ -843,8 +843,8 @@ def move_verts(object, bm, mapping, move, lock, influence):
new_loc = loc * (influence / 100) + \
bm.verts[index].co * ((100 - influence) / 100)
- for vert in bm.verts:
- for mirror_Vector in mirror_Vectors:
+ for mirror_Vector in mirror_Vectors:
+ for vert in bm.verts:
if vert.co == mirror_Vector * bm.verts[index].co:
vert.co = mirror_Vector * new_loc
diff --git a/space_view3d_math_vis/draw.py b/space_view3d_math_vis/draw.py
index fa03061d..0420044e 100644
--- a/space_view3d_math_vis/draw.py
+++ b/space_view3d_math_vis/draw.py
@@ -39,7 +39,9 @@ else:
COLOR_POINT = (1.0, 0.0, 1.0, 1)
COLOR_LINE = (0.5, 0.5, 1, 1)
+COLOR_LINE_ACTIVE = (1.0, 1.0, 0.5, 1)
COLOR_BOUNDING_BOX = (1.0, 1.0, 1.0, 1.0)
+COLOR_BOUNDING_BOX_ACTIVE = (1.0, 0.5, 0.0, 1.0)
def tag_redraw_areas():
@@ -136,6 +138,8 @@ def draw_callback_px():
def draw_callback_view():
settings = bpy.context.window_manager.MathVisProp
+ prop_states = bpy.context.window_manager.MathVisStatePropList
+
scale = settings.bbox_scale
with_bounding_box = not settings.bbox_hide
@@ -145,31 +149,36 @@ def draw_callback_view():
bgl.glDepthFunc(bgl.GL_LESS)
data_matrix, data_quat, data_euler, data_vector, data_vector_array = utils.console_math_data()
+ active_index = settings.index
+ active_key = prop_states[active_index].name if active_index >= 0 else None
if data_vector:
coords = [tuple(vec.to_3d()) for vec in data_vector.values()]
draw_points(coords)
if data_vector_array:
- for line in data_vector_array.values():
+ for key, line in data_vector_array.items():
coords = [tuple(vec.to_3d()) for vec in line]
- draw_line(coords)
+ if key == active_key:
+ draw_line(coords, COLOR_LINE_ACTIVE)
+ else:
+ draw_line(coords, COLOR_LINE)
if data_matrix:
- draw_matrices(list(data_matrix.values()), scale, with_bounding_box)
+ draw_matrices(data_matrix, scale, with_bounding_box, active_key)
if data_euler or data_quat:
cursor = bpy.context.scene.cursor.location.copy()
derived_matrices = []
- for quat in data_quat.values():
+ for key, quat in data_quat.values():
matrix = quat.to_matrix().to_4x4()
matrix.translation = cursor
- derived_matrices.append(matrix)
- for eul in data_euler.values():
+ derived_matrices[key] = matrix
+ for key, eul in data_euler.values():
matrix = eul.to_matrix().to_4x4()
matrix.translation = cursor
- derived_matrices.append(matrix)
- draw_matrices(derived_matrices, scale, with_bounding_box)
+ derived_matrices[key] = matrix
+ draw_matrices(derived_matrices, scale, with_bounding_box, active_key)
def draw_points(points):
@@ -179,10 +188,10 @@ def draw_points(points):
batch.draw(single_color_shader)
-def draw_line(points):
+def draw_line(points, color):
batch = batch_from_points(points, "LINE_STRIP")
single_color_shader.bind()
- single_color_shader.uniform_float("color", COLOR_LINE)
+ single_color_shader.uniform_float("color", color)
batch.draw(single_color_shader)
@@ -190,7 +199,7 @@ def batch_from_points(points, type):
return batch_for_shader(single_color_shader, type, {"pos": points})
-def draw_matrices(matrices, scale, with_bounding_box):
+def draw_matrices(matrices, scale, with_bounding_box, active_key):
x_p = Vector((scale, 0.0, 0.0))
x_n = Vector((-scale, 0.0, 0.0))
y_p = Vector((0.0, scale, 0.0))
@@ -207,7 +216,9 @@ def draw_matrices(matrices, scale, with_bounding_box):
coords = []
colors = []
- for matrix in matrices:
+ selected = []
+ active = []
+ for key, matrix in matrices.items():
coords.append(matrix @ x_n)
coords.append(matrix @ x_p)
colors.extend((red_dark, red_light))
@@ -217,6 +228,10 @@ def draw_matrices(matrices, scale, with_bounding_box):
coords.append(matrix @ z_n)
coords.append(matrix @ z_p)
colors.extend((blue_dark, blue_light))
+ if key == active_key:
+ active.append(matrix)
+ else:
+ selected.append(matrix)
batch = batch_for_shader(smooth_color_shader, "LINES", {
"pos": coords,
@@ -225,7 +240,10 @@ def draw_matrices(matrices, scale, with_bounding_box):
batch.draw(smooth_color_shader)
if with_bounding_box:
- draw_bounding_boxes(matrices, scale, COLOR_BOUNDING_BOX)
+ if selected:
+ draw_bounding_boxes(selected, scale, COLOR_BOUNDING_BOX)
+ if active:
+ draw_bounding_boxes(active, scale, COLOR_BOUNDING_BOX_ACTIVE)
def draw_bounding_boxes(matrices, scale, color):
diff --git a/space_view3d_math_vis/utils.py b/space_view3d_math_vis/utils.py
index 50c8aba3..8174ee5d 100644
--- a/space_view3d_math_vis/utils.py
+++ b/space_view3d_math_vis/utils.py
@@ -35,7 +35,7 @@ def is_display_list(listvar):
from mathutils import Vector
for var in listvar:
- if type(var) is not Vector:
+ if not isinstance(var, Vector):
return False
return True
@@ -120,8 +120,8 @@ def get_math_data():
if len_fn(var) == 0:
continue
- if type_var in {Matrix, Vector, Quaternion, Euler} or \
- type_var in {tuple, list} and is_display_list(var):
+ if isinstance(var, (Matrix, Vector, Quaternion, Euler)) or \
+ isinstance(var, (tuple, list)) and is_display_list(var):
variables[key] = type_var
@@ -168,24 +168,22 @@ def console_math_data():
if not disp:
continue
- var_type = type(var)
-
- if var_type is Matrix:
+ if isinstance(var, Matrix):
if len(var.col) != 4 or len(var.row) != 4:
if len(var.col) == len(var.row):
var = var.to_4x4()
else: # todo, support 4x3 matrix
continue
data_matrix[key] = var
- elif var_type is Vector:
+ elif isinstance(var, Vector):
if len(var) < 3:
var = var.to_3d()
data_vector[key] = var
- elif var_type is Quaternion:
+ elif isinstance(var, Quaternion):
data_quat[key] = var
- elif var_type is Euler:
+ elif isinstance(var, Euler):
data_euler[key] = var
- elif var_type in {list, tuple} and is_display_list(var):
+ elif type(var) in {list, tuple} and is_display_list(var):
data_vector_array[key] = var
return data_matrix, data_quat, data_euler, data_vector, data_vector_array