Removed use of CrossVecs, DotVecs, CrossQuats and DotQuats
authorCampbell Barton <ideasman42@gmail.com>
Fri, 22 May 2009 03:45:46 +0000 (03:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 22 May 2009 03:45:46 +0000 (03:45 +0000)
for all scripts except import_dxf and colladaImEx/translator.py

release/scripts/bpymodules/BPyMathutils.py
release/scripts/bpymodules/BPyMesh.py
release/scripts/bpymodules/BPyMesh_redux.py
release/scripts/bpymodules/BPyWindow.py
release/scripts/bpymodules/mesh_gradient.py
release/scripts/mesh_skin.py
release/scripts/mesh_unfolder.py
release/scripts/uvcalc_quad_clickproj.py
release/scripts/uvcalc_smart_project.py
release/scripts/vertexpaint_selfshadow_ao.py
release/scripts/wizard_curve2tree.py

index bfa1dcc3c615716f088ceeafef8cf9f44270eaaa..4882e9aaf217b597203c17493ac6b95ac5ab2cd6 100644 (file)
@@ -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()
index 6bbfaa463d0e835ef82815e1febf2bda22abbd54..292f7a4b91e2d050d192fc2551c302e76e03704d 100644 (file)
@@ -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)
        
index 1bcc6e9f7c847fa45d6d516855c710b068e26b18..5955d696fbdca700edfc5864e90c1abfd5bf9936 100644 (file)
@@ -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
index f48f5dfc0adfcab3983a8ff04686acc1b5d42d68..d3fd4fa88b5ec02954970125271ed506abfabb47 100644 (file)
@@ -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
index 936f4958467ca63a334ae578b26256b9ea8434ee..e582a30152b076a6e1cf656ff49e3d22286b7e82 100644 (file)
@@ -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()
index a554e128b4148a2235a9f9db1a89164a02ff91cb..4a330a516fbdec90cadd6a9d75983f8670711844 100644 (file)
@@ -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
index 906e0f0a3006828daac9ae3d2d022335c3bb226f..f5c19a92bd027af76c3acacf9cae28a324c01c61 100644 (file)
@@ -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()):
index 130a7e5af7729e83fa1680e43ad5f9b7f451e381..298103e4d5f5363271661b06296c3cf28b6840a7 100644 (file)
@@ -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
index 55d6ebfaa6fc90013a3e6916a7351ba9d8adab6c..9d9bd2aaefd91c19d31c25d47d059ab1ef61751a 100644 (file)
@@ -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
index d641fd12111d00dbf3a1313a556fdcab0f3902ae..54c67fd27e21cfa7fd7a071b9ac77eb257e00194 100644 (file)
@@ -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)
index 1965f9a50708c73119c8ac9733527f7549b25c3b..07b45c1986f9e8625f84dc3cc6b4a40c93c686b1 100644 (file)
@@ -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