[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3487] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: BProjection: add a function like fast navigate it make the script a lot faster when rotating paning the view

geo kgeo kgeogeo at hotmail.com
Tue Jun 12 23:44:52 CEST 2012


Revision: 3487
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3487
Author:   kgeogeo
Date:     2012-06-12 21:44:34 +0000 (Tue, 12 Jun 2012)
Log Message:
-----------
BProjection: add a function like fast navigate it make the script a lot faster when rotating paning the view

Modified Paths:
--------------
    contrib/py/scripts/addons/space_view3d_paint_bprojection.py

Modified: contrib/py/scripts/addons/space_view3d_paint_bprojection.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-06-12 15:02:06 UTC (rev 3486)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-06-12 21:44:34 UTC (rev 3487)
@@ -75,7 +75,6 @@
                 d.image = img
                
         align_to_view(context)
-        print(len(uvdata))
         ob.data.update()
 
 # Function to update the properties
@@ -998,6 +997,7 @@
     key = ['']
  
     first_time = True
+    tmp_level = -1
     
     def vect_sphere(self, context, mx, my):
         width = context.area.regions[4].width
@@ -1128,7 +1128,9 @@
             self.pan = Vector((event.mouse_region_x, event.mouse_region_y))
             self.first_mouse = Vector((event.mouse_region_x, self.first_mouse.y))
                         
-        elif event.type == 'MIDDLEMOUSE'and event.value == 'RELEASE':       
+        elif event.type == 'MIDDLEMOUSE'and event.value == 'RELEASE':
+            if self.tmp_level > -1:
+                bpy.context.object.modifiers['Subsurf'].levels = self.tmp_level      
             
             return {'FINISHED'}
         
@@ -1148,7 +1150,10 @@
         context.window_manager.modal_handler_add(self)
         self.first_mouse = Vector((event.mouse_region_x,event.mouse_region_y))
         self.first_time = True
-        
+        for sub in context.object.modifiers:
+            if sub.type == 'SUBSURF':
+                self.tmp_level = bpy.context.object.modifiers['Subsurf'].levels
+                bpy.context.object.modifiers['Subsurf'].levels = 0
         return {'RUNNING_MODAL'}
 
 # Oprerator Class to pan the view3D
@@ -1157,6 +1162,7 @@
     bl_label = "Pan View3D"
     
     first_mouse = Vector((0,0))
+    tmp_level = -1
 
     def modal(self, context, event):
         ob = context.object
@@ -1187,6 +1193,8 @@
         self.first_mouse.y = event.mouse_region_y
 
         if event.type == 'MIDDLEMOUSE'and event.value == 'RELEASE':
+            if self.tmp_level > -1:
+                bpy.context.object.modifiers['Subsurf'].levels = self.tmp_level 
             return {'FINISHED'}
         
         return {'RUNNING_MODAL'}
@@ -1195,7 +1203,10 @@
         context.window_manager.modal_handler_add(self)
         self.first_mouse.x = event.mouse_region_x
         self.first_mouse.y = event.mouse_region_y   
-        
+        for sub in context.object.modifiers:
+            if sub.type == 'SUBSURF':
+                self.tmp_level = bpy.context.object.modifiers['Subsurf'].levels
+                bpy.context.object.modifiers['Subsurf'].levels = 0        
         return {'RUNNING_MODAL'}
 
     def execute(self, context):        
@@ -1295,4 +1306,4 @@
     bpy.utils.unregister_module(__name__)
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file



More information about the Bf-extensions-cvs mailing list