[Bf-extensions-cvs] [d3fd9837] master: remove `mesh_snap_utilities_line` to move to addons repository
Germano Cavalcante
noreply at git.blender.org
Sat Apr 8 15:31:42 CEST 2017
Commit: d3fd983706c5cb0f9056250ce59c3fc71728096a
Author: Germano Cavalcante
Date: Sat Apr 8 10:31:07 2017 -0300
Branches: master
https://developer.blender.org/rBACd3fd983706c5cb0f9056250ce59c3fc71728096a
remove `mesh_snap_utilities_line` to move to addons repository
===================================================================
D mesh_snap_utilities_line.py
===================================================================
diff --git a/mesh_snap_utilities_line.py b/mesh_snap_utilities_line.py
deleted file mode 100644
index c1d86e8c..00000000
--- a/mesh_snap_utilities_line.py
+++ /dev/null
@@ -1,1031 +0,0 @@
-### BEGIN GPL LICENSE BLOCK #####
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 3
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# Contact for more information about the Addon:
-# Email: germano.costa at ig.com.br
-# Twitter: wii_mano @mano_wii
-
-bl_info = {
- "name": "Snap_Utilities_Line",
- "author": "Germano Cavalcante",
- "version": (5, 7, 1),
- "blender": (2, 75, 0),
- "location": "View3D > TOOLS > Snap Utilities > snap utilities",
- "description": "Extends Blender Snap controls",
- "wiki_url" : "http://blenderartists.org/forum/showthread.php?363859-Addon-CAD-Snap-Utilities",
- "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
- "category": "Mesh"}
-
-import bpy, bgl, bmesh
-from mathutils import Vector
-from mathutils.geometry import (
- intersect_point_line,
- intersect_line_line,
- intersect_line_plane,
- intersect_ray_tri)
-
-def get_units_info(scale, unit_system, separate_units):
- if unit_system == 'METRIC':
- scale_steps = ((1000, 'km'), (1, 'm'), (1 / 100, 'cm'),
- (1 / 1000, 'mm'), (1 / 1000000, '\u00b5m'))
- elif unit_system == 'IMPERIAL':
- scale_steps = ((5280, 'mi'), (1, '\''),
- (1 / 12, '"'), (1 / 12000, 'thou'))
- scale /= 0.3048 # BU to feet
- else:
- scale_steps = ((1, ' BU'),)
- separate_units = False
-
- return (scale, scale_steps, separate_units)
-
-def convert_distance(val, units_info, precision = 5):
- scale, scale_steps, separate_units = units_info
- sval = val * scale
- idx = 0
- while idx < len(scale_steps) - 1:
- if sval >= scale_steps[idx][0]:
- break
- idx += 1
- factor, suffix = scale_steps[idx]
- sval /= factor
- if not separate_units or idx == len(scale_steps) - 1:
- dval = str(round(sval, precision)) + suffix
- else:
- ival = int(sval)
- dval = str(round(ival, precision)) + suffix
- fval = sval - ival
- idx += 1
- while idx < len(scale_steps):
- fval *= scale_steps[idx - 1][0] / scale_steps[idx][0]
- if fval >= 1:
- dval += ' ' \
- + ("%.1f" % fval) \
- + scale_steps[idx][1]
- break
- idx += 1
- return dval
-
-def location_3d_to_region_2d(region, rv3d, coord):
- prj = rv3d.perspective_matrix * Vector((coord[0], coord[1], coord[2], 1.0))
- width_half = region.width / 2.0
- height_half = region.height / 2.0
- return Vector((width_half + width_half * (prj.x / prj.w),
- height_half + height_half * (prj.y / prj.w),
- prj.z / prj.w
- ))
-
-def fac_nearest_to_segment_2d(co2v, v2d0, v2d1):
- u = v2d1.xy - v2d0.xy
- h = co2v.xy - v2d0.xy
- return u.dot(h) / u.length_squared
-
-def region_2d_to_orig_and_view_vector(region, rv3d, coord, clamp=None):
- viewinv = rv3d.view_matrix.inverted()
- persinv = rv3d.perspective_matrix.inverted()
-
- dx = (2.0 * coord[0] / region.width) - 1.0
- dy = (2.0 * coord[1] / region.height) - 1.0
-
- if rv3d.is_perspective:
- origin_start = viewinv.translation.copy()
-
- out = Vector((dx, dy, -0.5))
-
- w = out.dot(persinv[3].xyz) + persinv[3][3]
-
- view_vector = ((persinv * out) / w) - origin_start
- else:
- view_vector = -viewinv.col[2].xyz
-
- origin_start = ((persinv.col[0].xyz * dx) +
- (persinv.col[1].xyz * dy) +
- viewinv.translation)
-
- if clamp != 0.0:
- if rv3d.view_perspective != 'CAMERA':
- # this value is scaled to the far clip already
- origin_offset = persinv.col[2].xyz
- if clamp is not None:
- if clamp < 0.0:
- origin_offset.negate()
- clamp = -clamp
- if origin_offset.length > clamp:
- origin_offset.length = clamp
-
- origin_start -= origin_offset
-
- view_vector.normalize()
- return origin_start, view_vector
-
-def out_Location(rv3d, region, orig, vector):
- view_matrix = rv3d.view_matrix
- v1 = Vector((int(view_matrix[0][0]*1.5),int(view_matrix[0][1]*1.5),int(view_matrix[0][2]*1.5)))
- v2 = Vector((int(view_matrix[1][0]*1.5),int(view_matrix[1][1]*1.5),int(view_matrix[1][2]*1.5)))
-
- hit = intersect_ray_tri(Vector((1,0,0)), Vector((0,1,0)), Vector(), (vector), (orig), False)
- if hit == None:
- hit = intersect_ray_tri(v1, v2, Vector(), (vector), (orig), False)
- if hit == None:
- hit = intersect_ray_tri(v1, v2, Vector(), (-vector), (orig), False)
- if hit == None:
- hit = Vector()
- return hit
-
-class SnapCache():
- bvert = None
- vco = None
-
- bedge = None
- v0 = None
- v1 = None
- vmid = None
- vperp = None
- v2d0 = None
- v2d1 = None
- v2dmid = None
- v2dperp = None
-
- bface = None
- fmid = None
- fnor = None
-
- out_obj = None
- out_obmat = None
- out_obimat = None
-
-
-def snap_utilities(
- cache, context, obj_matrix_world,
- bm, mcursor,
- outer_verts = False,
- constrain = None,
- previous_vert = None,
- ignore_obj = None,
- increment = 0.0):
-
- rv3d = context.region_data
- region = context.region
- scene = context.scene
- is_increment = False
- r_loc = None
- r_type = None
- r_len = 0.0
- bm_geom = None
-
- if bm.select_history:
- bm.select_history[0].select = False
- bm.select_history.clear()
-
- bpy.ops.view3d.select(location = (int(mcursor.x), int(mcursor.y)))
-
- if bm.select_history:
- bm_geom = bm.select_history[0]
-
- if isinstance(bm_geom, bmesh.types.BMVert):
- r_type = 'VERT'
-
- if cache.bvert != bm_geom:
- cache.bvert = bm_geom
- cache.vco = obj_matrix_world * cache.bvert.co
- #cache.v2d = location_3d_to_region_2d(region, rv3d, cache.vco)
-
- if constrain:
- location = intersect_point_line(cache.vco, constrain[0], constrain[1])
- #factor = location[1]
- r_loc = location[0]
- else:
- r_loc = cache.vco
-
- elif isinstance(bm_geom, bmesh.types.BMEdge):
- if cache.bedge != bm_geom:
- cache.bedge = bm_geom
- cache.v0 = obj_matrix_world * bm_geom.verts[0].co
- cache.v1 = obj_matrix_world * bm_geom.verts[1].co
- cache.vmid = 0.5 * (cache.v0 + cache.v1)
- cache.v2d0 = location_3d_to_region_2d(region, rv3d, cache.v0)
- cache.v2d1 = location_3d_to_region_2d(region, rv3d, cache.v1)
- cache.v2dmid = location_3d_to_region_2d(region, rv3d, cache.vmid)
-
- if previous_vert and previous_vert not in bm_geom.verts:
- pvert_co = obj_matrix_world * previous_vert.co
- perp_point = intersect_point_line(pvert_co, cache.v0, cache.v1)
- cache.vperp = perp_point[0]
- #factor = point_perpendicular[1]
- cache.v2dperp = location_3d_to_region_2d(region, rv3d, perp_point[0])
-
- #else: cache.v2dperp = None
-
- if constrain:
- location = intersect_line_line(constrain[0], constrain[1], cache.v0, cache.v1)
- if location == None:
- is_increment = True
- orig, view_vector = region_2d_to_orig_and_view_vector(region, rv3d, mcursor)
- end = orig + view_vector
- location = intersect_line_line(constrain[0], constrain[1], orig, end)
- r_loc = location[0]
-
- elif cache.v2dperp and\
- abs(cache.v2dperp[0] - mcursor[0]) < 10 and abs(cache.v2dperp[1] - mcursor[1]) < 10:
- r_type = 'PERPENDICULAR'
- r_loc = cache.vperp
-
- elif abs(cache.v2dmid[0] - mcursor[0]) < 10 and abs(cache.v2dmid[1] - mcursor[1]) < 10:
- r_type = 'CENTER'
- r_loc = cache.vmid
-
- else:
- if increment and previous_vert in cache.bedge.verts:
- is_increment = True
-
- r_type = 'EDGE'
- fac = fac_nearest_to_segment_2d(mcursor, cache.v2d0, cache.v2d1)
- fac *= cache.v2d0.z / cache.v2d1.z #convert to fac3d
- r_loc = cache.v0 + fac * (cache.v1 - cache.v0)
-
- elif isinstance(bm_geom, bmesh.types.BMFace):
- is_increment = True
- r_type = 'FACE'
-
- if cache.bface != bm_geom:
- cache.bface = bm_geom
- cache.fmid = obj_matrix_world*bm_geom.calc_center_median()
- cache.fnor = bm_geom.normal*obj_matrix_world.inverted()
-
- orig, view_vector = region_2d_to_orig_and_view_vector(region, rv3d, mcursor)
- end = orig + view_vector
- r_loc = intersect_line_plane(orig, end, cache.fmid, cache.fnor, False)
-
- if constrain:
- is_increment = False
- r_loc = intersect_point_line(r_loc, constrain[0], constrain[1])[0]
-
- else: #OUT
- is_increment = True
- r_type =
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list