diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-05-22 07:45:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-05-22 07:45:46 +0400 |
commit | 612f3b326662498207e6e051feeceaac81e09343 (patch) | |
tree | cc2da1784826266a9cf16cf29df03f14c117d81a | |
parent | e191618cb5906ad50c7b6a75f52ad54cc6a812f7 (diff) |
Removed use of CrossVecs, DotVecs, CrossQuats and DotQuats
for all scripts except import_dxf and colladaImEx/translator.py
-rw-r--r-- | release/scripts/bpymodules/BPyMathutils.py | 3 | ||||
-rw-r--r-- | release/scripts/bpymodules/BPyMesh.py | 6 | ||||
-rw-r--r-- | release/scripts/bpymodules/BPyMesh_redux.py | 5 | ||||
-rw-r--r-- | release/scripts/bpymodules/BPyWindow.py | 2 | ||||
-rw-r--r-- | release/scripts/bpymodules/mesh_gradient.py | 6 | ||||
-rw-r--r-- | release/scripts/mesh_skin.py | 8 | ||||
-rw-r--r-- | release/scripts/mesh_unfolder.py | 6 | ||||
-rw-r--r-- | release/scripts/uvcalc_quad_clickproj.py | 4 | ||||
-rw-r--r-- | release/scripts/uvcalc_smart_project.py | 18 | ||||
-rw-r--r-- | release/scripts/vertexpaint_selfshadow_ao.py | 3 | ||||
-rw-r--r-- | release/scripts/wizard_curve2tree.py | 34 |
11 files changed, 45 insertions, 50 deletions
diff --git a/release/scripts/bpymodules/BPyMathutils.py b/release/scripts/bpymodules/BPyMathutils.py index bfa1dcc3c61..4882e9aaf21 100644 --- a/release/scripts/bpymodules/BPyMathutils.py +++ b/release/scripts/bpymodules/BPyMathutils.py @@ -132,7 +132,6 @@ modified for Blender/Mathutils by Campell Barton ###################################################################### # Public interface ###################################################################### -from Blender.Mathutils import DotVecs def convexHull(point_list_2d): """Calculate the convex hull of a set of vectors The vectors can be 3 or 4d but only the Xand Y are used. @@ -197,7 +196,7 @@ def plane2mat(plane, normalize= False): up= cent - ((plane[0]+plane[1])/2.0) right= cent - ((plane[1]+plane[2])/2.0) - z= CrossVecs(up, right) + z= up.cross(right) if normalize: up.normalize() diff --git a/release/scripts/bpymodules/BPyMesh.py b/release/scripts/bpymodules/BPyMesh.py index 6bbfaa463d0..292f7a4b91e 100644 --- a/release/scripts/bpymodules/BPyMesh.py +++ b/release/scripts/bpymodules/BPyMesh.py @@ -569,12 +569,11 @@ def face_edges(me): def facesPlanerIslands(me): - DotVecs= Blender.Mathutils.DotVecs def roundvec(v): return round(v[0], 4), round(v[1], 4), round(v[2], 4) - face_props= [(cent, no, roundvec(no), DotVecs(cent, no)) for f in me.faces for no, cent in ((f.no, f.cent),)] + face_props= [(cent, no, roundvec(no), cent.dot(no)) for f in me.faces for no, cent in ((f.no, f.cent),)] face_edge_users= face_edges(me) islands= [] @@ -607,7 +606,7 @@ def facesPlanerIslands(me): face_prop2= face_props[fidx2] # normals are the same? if face_prop1[2]==face_prop2[2]: - if abs(face_prop1[3] - DotVecs(face_prop1[1], face_prop2[0])) < 0.000001: + if abs(face_prop1[3] - face_prop1[1].dot(face_prop2[0])) < 0.000001: used_faces[fidx2]= 1 island.append(fidx2) islands.append([me.faces[i] for i in island]) @@ -616,7 +615,6 @@ def facesPlanerIslands(me): def facesUvIslands(me, PREF_IMAGE_DELIMIT=True): - DotVecs= Blender.Mathutils.DotVecs def roundvec(v): return round(v[0], 4), round(v[1], 4) diff --git a/release/scripts/bpymodules/BPyMesh_redux.py b/release/scripts/bpymodules/BPyMesh_redux.py index 1bcc6e9f7c8..5955d696fbd 100644 --- a/release/scripts/bpymodules/BPyMesh_redux.py +++ b/release/scripts/bpymodules/BPyMesh_redux.py @@ -25,7 +25,6 @@ import Blender import bpy Vector= Blender.Mathutils.Vector Ang= Blender.Mathutils.AngleBetweenVecs -CrossVecs= Blender.Mathutils.CrossVecs MidpointVecs= Blender.Mathutils.MidpointVecs import BPyMesh @@ -198,8 +197,8 @@ def redux(ob, REDUX=0.5, BOUNDRY_WEIGHT=2.0, REMOVE_DOUBLES=False, FACE_AREA_WEI # the point of collapsing. # Enlarge so we know they intersect: self.length*2 - cv1= CrossVecs(v1no, CrossVecs(v1no, v1co-v2co)) - cv2= CrossVecs(v2no, CrossVecs(v2no, v2co-v1co)) + cv1= v1no.cross(v1no.cross(v1co-v2co)) + cv2= v2no.cross(v2no.cross(v2co-v1co)) # Scale to be less then the edge lengths. cv2.length = cv1.length = 1 diff --git a/release/scripts/bpymodules/BPyWindow.py b/release/scripts/bpymodules/BPyWindow.py index f48f5dfc0ad..d3fd4fa88b5 100644 --- a/release/scripts/bpymodules/BPyWindow.py +++ b/release/scripts/bpymodules/BPyWindow.py @@ -1,6 +1,6 @@ import Blender from Blender import Mathutils, Window, Scene, Draw, Mesh -from Blender.Mathutils import CrossVecs, Matrix, Vector, Intersect +from Blender.Mathutils import Matrix, Vector, Intersect # DESCRIPTION: # screen_x, screen_y the origin point of the pick ray diff --git a/release/scripts/bpymodules/mesh_gradient.py b/release/scripts/bpymodules/mesh_gradient.py index 936f4958467..e582a30152b 100644 --- a/release/scripts/bpymodules/mesh_gradient.py +++ b/release/scripts/bpymodules/mesh_gradient.py @@ -6,7 +6,7 @@ import BPyWindow mouseViewRay= BPyWindow.mouseViewRay from Blender import Mathutils, Window, Scene, Draw, sys -from Blender.Mathutils import CrossVecs, Vector, Intersect, LineIntersect, AngleBetweenVecs +from Blender.Mathutils import Vector, Intersect, LineIntersect, AngleBetweenVecs LMB= Window.MButs['L'] def mouseup(): @@ -101,11 +101,11 @@ def vertexGradientPick(ob, MODE): # make a line 90d to the grad in screenspace. if (OriginA-OriginB).length <= eps: # Persp view. same origin different direction - cross_grad= CrossVecs(DirectionA, DirectionB) + cross_grad= DirectionA.cross(DirectionB) ORTHO= False else: # Ortho - Same direction, different origin - cross_grad= CrossVecs(DirectionA, OriginA-OriginB) + cross_grad= DirectionA.cross(OriginA-OriginB) ORTHO= True cross_grad.normalize() diff --git a/release/scripts/mesh_skin.py b/release/scripts/mesh_skin.py index a554e128b41..4a330a516fb 100644 --- a/release/scripts/mesh_skin.py +++ b/release/scripts/mesh_skin.py @@ -52,7 +52,7 @@ A pop-up will provide further options, if the results of a method are not adequa import Blender import bpy from Blender import Window -from Blender.Mathutils import MidpointVecs, Vector, CrossVecs +from Blender.Mathutils import MidpointVecs, Vector from Blender.Mathutils import AngleBetweenVecs as _AngleBetweenVecs_ import BPyMessages @@ -119,7 +119,7 @@ class edgeLoop(object): # GENERATE AN AVERAGE NORMAL FOR THE WHOLE LOOP. self.normal = Vector() for e in self.edges: - n = CrossVecs(self.centre-e.co1, self.centre-e.co2) + n = (self.centre-e.co1).cross(self.centre-e.co2) # Do we realy need tot normalize? n.normalize() self.normal += n @@ -149,7 +149,7 @@ class edgeLoop(object): a = n1-n2 b = n1-n3 - normal1 = CrossVecs(a,b) + normal1 = a.cross(b) normal1.normalize() n1 = e.co2 @@ -159,7 +159,7 @@ class edgeLoop(object): a = n1-n2 b = n1-n3 - normal2 = CrossVecs(a,b) + normal2 = a.cross(b) normal2.normalize() # Reuse normal1 var diff --git a/release/scripts/mesh_unfolder.py b/release/scripts/mesh_unfolder.py index 906e0f0a300..f5c19a92bd0 100644 --- a/release/scripts/mesh_unfolder.py +++ b/release/scripts/mesh_unfolder.py @@ -164,8 +164,8 @@ class Fold: sangle = Mathutils.AngleBetweenVecs(self.refPolyNormal, self.polyNormal) if(sangle!=sangle): sangle=0.0 - ncp = Mathutils.CrossVecs(self.refPolyNormal, self.polyNormal) - dp = Mathutils.DotVecs(ncp, self.edge.vector) + ncp = self.refPolyNormal.cross(self.polyNormal) + dp = ncp.dot(self.edge.vector) if(dp>0.0): return +sangle else: @@ -855,7 +855,7 @@ class Poly: p.resize3D() q = a-c q.resize3D() - return CrossVecs(p,q) + return p.cross(q) def makeEdges(self): self.edges = [] for i in xrange(self.nPoints()): diff --git a/release/scripts/uvcalc_quad_clickproj.py b/release/scripts/uvcalc_quad_clickproj.py index 130a7e5af77..298103e4d5f 100644 --- a/release/scripts/uvcalc_quad_clickproj.py +++ b/release/scripts/uvcalc_quad_clickproj.py @@ -46,7 +46,7 @@ import BPyWindow mouseViewRay= BPyWindow.mouseViewRay from Blender import Mathutils, Window, Scene, Draw, sys -from Blender.Mathutils import CrossVecs, Vector, Matrix, LineIntersect, Intersect #, AngleBetweenVecs, Intersect +from Blender.Mathutils import Vector, Matrix, LineIntersect, Intersect #, AngleBetweenVecs, Intersect LMB= Window.MButs.L RMB= Window.MButs.R @@ -229,7 +229,7 @@ def main(): y_axis_length = line_a_len x_axis_length = (line_isect_b_pair[1]-face_corner_main).length - proj_y_component = CrossVecs(proj_x_component, proj_z_component) + proj_y_component = proj_x_component.cross(proj_z_component) proj_y_component.length = 1/y_axis_length proj_x_component.length = 1/x_axis_length diff --git a/release/scripts/uvcalc_smart_project.py b/release/scripts/uvcalc_smart_project.py index 55d6ebfaa6f..9d9bd2aaefd 100644 --- a/release/scripts/uvcalc_smart_project.py +++ b/release/scripts/uvcalc_smart_project.py @@ -43,7 +43,7 @@ selected faces, or all faces. from Blender import Object, Draw, Window, sys, Mesh, Geometry -from Blender.Mathutils import CrossVecs, Matrix, Vector, RotationMatrix, DotVecs +from Blender.Mathutils import Matrix, Vector, RotationMatrix import bpy from math import cos @@ -96,7 +96,7 @@ def pointInTri2D(v, v1, v2, v3): side1 = v2 - v1 side2 = v3 - v1 - nor = CrossVecs(side1, side2) + nor = side1.cross(side2) l1 = [side1[0], side1[1], side1[2]] l2 = [side2[0], side2[1], side2[2]] @@ -804,11 +804,11 @@ def VectoMat(vec): a3 = vec.__copy__().normalize() up = Vector(0,0,1) - if abs(DotVecs(a3, up)) == 1.0: + if abs(a3.dot(up)) == 1.0: up = Vector(0,1,0) - a1 = CrossVecs(a3, up).normalize() - a2 = CrossVecs(a3, a1) + a1 = a3.cross(up).normalize() + a2 = a3.cross(a1) return Matrix([a1[0], a1[1], a1[2]], [a2[0], a2[1], a2[2]], [a3[0], a3[1], a3[2]]) @@ -1001,7 +1001,7 @@ def main(): for fIdx in xrange(len(tempMeshFaces)-1, -1, -1): # Use half the angle limit so we dont overweight faces towards this # normal and hog all the faces. - if DotVecs(newProjectVec, tempMeshFaces[fIdx].no) > USER_PROJECTION_LIMIT_HALF_CONVERTED: + if newProjectVec.dot(tempMeshFaces[fIdx].no) > USER_PROJECTION_LIMIT_HALF_CONVERTED: newProjectMeshFaces.append(tempMeshFaces.pop(fIdx)) # Add the average of all these faces normals as a projectionVec @@ -1027,7 +1027,7 @@ def main(): # Get the closest vec angle we are to. for p in projectVecs: - temp_angle_diff= DotVecs(p, tempMeshFaces[fIdx].no) + temp_angle_diff= p.dot(tempMeshFaces[fIdx].no) if angleDifference < temp_angle_diff: angleDifference= temp_angle_diff @@ -1066,14 +1066,14 @@ def main(): i = len(projectVecs) # Initialize first - bestAng = DotVecs(fvec, projectVecs[0]) + bestAng = fvec.dot(projectVecs[0]) bestAngIdx = 0 # Cycle through the remaining, first alredy done while i-1: i-=1 - newAng = DotVecs(fvec, projectVecs[i]) + newAng = fvec.dot(projectVecs[i]) if newAng > bestAng: # Reverse logic for dotvecs bestAng = newAng bestAngIdx = i diff --git a/release/scripts/vertexpaint_selfshadow_ao.py b/release/scripts/vertexpaint_selfshadow_ao.py index d641fd12111..54c67fd27e2 100644 --- a/release/scripts/vertexpaint_selfshadow_ao.py +++ b/release/scripts/vertexpaint_selfshadow_ao.py @@ -45,7 +45,6 @@ import BPyMesh def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY): Window.WaitCursor(1) - DotVecs = Mathutils.DotVecs Ang= Mathutils.AngleBetweenVecs BPyMesh.meshCalcNormals(me) @@ -63,7 +62,7 @@ def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PRE for v in f.v: vno=v.no # get a scaled down normal. - dot= DotVecs(vno, v.co) - DotVecs(vno, fc) + dot= vno.dot(v.co) - vno.dot(fc) vert_tone_count[v.index]+=1 try: a= Ang(vno, fno) diff --git a/release/scripts/wizard_curve2tree.py b/release/scripts/wizard_curve2tree.py index 1965f9a5070..07b45c1986f 100644 --- a/release/scripts/wizard_curve2tree.py +++ b/release/scripts/wizard_curve2tree.py @@ -39,7 +39,7 @@ __bpydoc__ = """\ import bpy import Blender import BPyMesh -from Blender.Mathutils import Vector, Matrix, CrossVecs, AngleBetweenVecs, LineIntersect, TranslationMatrix, ScaleMatrix, RotationMatrix, Rand +from Blender.Mathutils import Vector, Matrix, AngleBetweenVecs, LineIntersect, TranslationMatrix, ScaleMatrix, RotationMatrix, Rand from Blender.Geometry import ClosestPointOnLine from Blender.Noise import randuvec @@ -496,12 +496,12 @@ class tree: # Align this with the existing branch angle = AngleBetweenVecsSafe(zup, parent_pt.no) - cross = CrossVecs(zup, parent_pt.no) + cross = zup.cross(parent_pt.no) mat_align = RotationMatrix(angle, 3, 'r', cross) # Use the bend on the point to work out which way to make the branch point! - if parent_pt.prev: cross = CrossVecs(parent_pt.no, parent_pt.prev.no - parent_pt.no) - else: cross = CrossVecs(parent_pt.no, parent_pt.next.no - parent_pt.no) + if parent_pt.prev: cross = parent_pt.no.cross(parent_pt.prev.no - parent_pt.no) + else: cross = parent_pt.no.cross(parent_pt.next.no - parent_pt.no) if parent_pt.branch.parent_pt: angle = AngleBetweenVecsSafe(parent_pt.branch.parent_pt.no, parent_pt.no) @@ -1065,8 +1065,8 @@ class tree: l = line_normal.length - cross1 = CrossVecs( seg.no, line_normal ) - cross2 = CrossVecs( pt.no, line_normal ) + cross1 = seg.no.cross(line_normal) + cross2 = pt.no.cross(line_normal) angle_line = min(AngleBetweenVecsSafe(cross1, cross2), AngleBetweenVecsSafe(cross1, -cross2)) angle_leaf_no_diff = min(AngleBetweenVecsSafe(line_normal, seg.no), AngleBetweenVecsSafe(line_normal, -seg.no)) @@ -1914,8 +1914,8 @@ class tree: # endpoints dont rotate if pt.next != None: - cross1 = CrossVecs(zup, pt.no) # use this to offset the leaf later - cross2 = CrossVecs(cross1, pt.no) + cross1 = zup.cross(pt.no) # use this to offset the leaf later + cross2 = cross1.cross(pt.no) if odd_even ==0: mat_yaw = RotationMatrix(leaf_branch_angle, 3, 'r', cross2) else: @@ -1939,7 +1939,7 @@ class tree: # Randomize pitch and roll for the leaf # work out the axis to pitch and roll - cross1 = CrossVecs(zup, leaf_no) # use this to offset the leaf later + cross1 = zup.cross(leaf_no) # use this to offset the leaf later if leaf_branch_pitch_rand or leaf_branch_pitch_angle: angle = -leaf_branch_pitch_angle @@ -2480,7 +2480,7 @@ class bpoint(object): def calcVerts(self): if self.prev == None: if self.branch.parent_pt: - cross = CrossVecs(self.no, self.branch.parent_pt.no) * RotationMatrix(-45, 3, 'r', self.no) + cross = self.no.cross(self.branch.parent_pt.no) * RotationMatrix(-45, 3, 'r', self.no) else: # parentless branch - for best results get a cross thats not the same as the normal, in rare cases this happens. @@ -2493,9 +2493,9 @@ class bpoint(object): else: cross = xup else: - cross = CrossVecs(self.prev.vecs[0], self.no) + cross = self.prev.vecs[0].cross(self.no) - self.vecs[0] = Blender.Mathutils.CrossVecs(self.no, cross) + self.vecs[0] = self.no.cross(cross) self.vecs[0].length = abs(self.radius) mat = RotationMatrix(90, 3, 'r', self.no) self.vecs[1] = self.vecs[0] * mat @@ -2660,8 +2660,8 @@ class branch: self_normal = self.bpoints[1].co - self.parent_pt.co # We only want the angle in relation to the parent points normal # modify self_normal to make this so - cross = CrossVecs(self_normal, self.parent_pt.no) - self_normal = CrossVecs(self.parent_pt.no, cross) # CHECK + cross = self_normal.cross(self.parent_pt.no) + self_normal = self.parent_pt.no.cross(cross) # CHECK #try: angle = AngleBetweenVecs(parent_normal, self_normal) #except: return 0.0 @@ -2670,7 +2670,7 @@ class branch: # see if we need to rotate positive or negative # USE DOT PRODUCT! - cross = CrossVecs(parent_normal, self_normal) + cross = parent_normal.cross(self_normal) if AngleBetweenVecsSafe(cross, self.parent_pt.no) > 90: angle = -angle @@ -3018,7 +3018,7 @@ class branch: scales = [] for cos_ls in (cos1, cos2): - cross = CrossVecs(cos_ls[-1], zup) + cross = cos_ls[-1].cross(zup) mat = RotationMatrix(AngleBetweenVecsSafe(cos_ls[-1], zup), 3, 'r', cross) cos_ls[:] = [co*mat for co in cos_ls] @@ -3029,7 +3029,7 @@ class branch: for co in cos_ls: xy_nor.x += co.x xy_nor.y += co.y - cross = CrossVecs(xy_nor, xup) + cross = xy_nor.cross(xup) # Also scale them here so they are 1.0 tall always scale = 1.0/(cos_ls[0]-cos_ls[-1]).length |