diff --git a/release/scripts/bpymodules/BPyWindow.py b/release/scripts/bpymodules/BPyWindow.py index b1b8fdc22cf..9309a9a6084 100755 --- a/release/scripts/bpymodules/BPyWindow.py +++ b/release/scripts/bpymodules/BPyWindow.py @@ -2,7 +2,6 @@ import Blender from Blender import Mathutils, Window, Scene, Draw, Mesh from Blender.Mathutils import CrossVecs, Matrix, Vector, Intersect, LineIntersect - # DESCRIPTION: # screen_x, screen_y the origin point of the pick ray # it is either the mouse location @@ -44,7 +43,7 @@ def mouseViewRay(screen_x, screen_y, localMatrix=None, useMid = False): # sorry - i cannot explain here what they all do # - if you're not familiar with all those matrices take a look at an introduction to OpenGL... pm = Window.GetPerspMatrix() # the prespective matrix - pmi = pm.inverted() # the inverted perspective matrix + pmi = Matrix(pm); pmi.invert() # the inverted perspective matrix if (1.0 - epsilon < pmi[3][3] < 1.0 + epsilon): # pmi[3][3] is 1.0 if the 3dwin is in ortho-projection mode (toggled with numpad 5) @@ -54,7 +53,7 @@ def mouseViewRay(screen_x, screen_y, localMatrix=None, useMid = False): # ortho mode: is a bit strange - actually there's no definite location of the camera ... # but the camera could be displaced anywhere along the viewing direction. - ortho_d[:] = Window.GetViewVector() + ortho_d.x, ortho_d.y, ortho_d.z = Window.GetViewVector() ortho_d.w = 0 # all rays are parallel in ortho mode - so the direction vector is simply the viewing direction @@ -73,7 +72,7 @@ def mouseViewRay(screen_x, screen_y, localMatrix=None, useMid = False): # is used in sculpt_mesh to initialize backface culling...) else: # PERSPECTIVE MODE: here everything is well defined - all rays converge at the camera's location - vmi = Window.GetViewMatrix().inverted() # the inverse viewing matrix + vmi = Matrix(Window.GetViewMatrix()); vmi.invert() # the inverse viewing matrix fp = mouseViewRay.fp dx = pm[3][3] * (((screen_x-win_min_x)/win_size_x)-1.0) - pm[3][0] @@ -104,9 +103,13 @@ def mouseViewRay(screen_x, screen_y, localMatrix=None, useMid = False): # Do we want to return a direction in object's localspace? if localMatrix: - localInvMatrix = localMatrix.inverted() + localInvMatrix = Matrix(localMatrix) + localInvMatrix.invert() p = p*localInvMatrix - d = d*localInvMatrix.rotationPart() # normalize_v3 + d = d*localInvMatrix # normalize_v3 + p.x += localInvMatrix[3][0] + p.y += localInvMatrix[3][1] + p.z += localInvMatrix[3][2] #else: # Worldspace, do nothing @@ -124,6 +127,37 @@ mouseViewRay.fp = Vector(0,0,0) mouseViewRay.hms = Vector(0,0,0,0) # ortho only 4d mouseViewRay.ortho_d = Vector(0,0,0,0) # ortho only 4d + +LMB= Window.MButs['L'] +def mouseup(): + # Loop until click + mouse_buttons = Window.GetMouseButtons() + while not mouse_buttons & LMB: + Blender.sys.sleep(10) + mouse_buttons = Window.GetMouseButtons() + while mouse_buttons & LMB: + Blender.sys.sleep(10) + mouse_buttons = Window.GetMouseButtons() + + +if __name__=='__main__': + mouseup() + x,y= Window.GetMouseCoords() + isect, point, dir= mouseViewRay(x,y) + if isect: + scn= Blender.Scene.GetCurrent() + me = Blender.Mesh.New() + ob= Blender.Object.New('Mesh') + ob.link(me) + scn.link(ob) + ob.sel= 1 + me.verts.extend([point, dir]) + me.verts[0].sel= 1 + + print isect, point, dir + + + def spaceRect(): ''' Returns the space rect diff --git a/release/scripts/bpymodules/mesh_gradient.py b/release/scripts/bpymodules/mesh_gradient.py index 1cb958cf69c..e365d285ea3 100755 --- a/release/scripts/bpymodules/mesh_gradient.py +++ b/release/scripts/bpymodules/mesh_gradient.py @@ -108,8 +108,9 @@ def vertexGradientPick(ob, MODE): else: # Ortho - Same direction, different origin cross_grad= CrossVecs(DirectionA, OriginA-OriginB) ORTHO= True - - cross_grad= cross_grad.normalized() * 100 + + cross_grad.normalize() + cross_grad= cross_grad * 100 lineA= (OriginA, OriginA+(DirectionA*100)) lineB= (OriginB, OriginB+(DirectionB*100)) diff --git a/release/scripts/bvh_import.py b/release/scripts/bvh_import.py index 2dfe1878858..e9d952b9c15 100644 --- a/release/scripts/bvh_import.py +++ b/release/scripts/bvh_import.py @@ -513,7 +513,7 @@ def bvh_node_dict2armature(bvh_nodes, IMPORT_START_FRAME= 1): if bvh_node.has_loc: # Set the Location, simple too pose_bone.loc= (\ - TranslationMatrix(Vector(lx*10, ly*10, lz*10)) *\ + TranslationMatrix(Vector(lx, ly, lz)) *\ bone_rest_matrix_inv).translationPart() # WHY * 10? - just how pose works # Get the transform @@ -587,7 +587,7 @@ def bvh_node_dict2armature(bvh_nodes, IMPORT_START_FRAME= 1): return tuple((bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).toQuat()) # qw,qx,qy,qz def pose_loc(anim_data): - return tuple((TranslationMatrix(Vector(anim_data[0]*10, anim_data[1]*10, anim_data[2]*10)) * bone_rest_matrix_inv).translationPart()) + return tuple((TranslationMatrix(Vector(anim_data[0], anim_data[1], anim_data[2])) * bone_rest_matrix_inv).translationPart()) last_frame= len(bvh_node.anim_data)+IMPORT_START_FRAME-1 diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c index a36f79a7660..084bf6eddc6 100644 --- a/source/blender/python/api2_2x/matrix.c +++ b/source/blender/python/api2_2x/matrix.c @@ -234,7 +234,6 @@ PyObject *Matrix_Invert(MatrixObject * self) f = Matrix_Determinant(self); det = (float)PyFloat_AS_DOUBLE(f); /*Increfs, so we need to decref*/ Py_DECREF(f); - det= 10.0; if(det != 0) { /*calculate the classical adjoint*/