[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53112] trunk/blender/release/scripts/ templates/operator_modal_view3d_raycast.py: Fixed operator_modal_view3d_raycast. py template so that it uses hit points in world space to give correct selection .
luke frisken
l.frisken at gmail.com
Tue Dec 18 11:43:11 CET 2012
Revision: 53112
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53112
Author: lfrisken
Date: 2012-12-18 10:43:06 +0000 (Tue, 18 Dec 2012)
Log Message:
-----------
Fixed operator_modal_view3d_raycast.py template so that it uses hit points in world space to give correct selection. Also set selected object to active.
Modified Paths:
--------------
trunk/blender/release/scripts/templates/operator_modal_view3d_raycast.py
Modified: trunk/blender/release/scripts/templates/operator_modal_view3d_raycast.py
===================================================================
--- trunk/blender/release/scripts/templates/operator_modal_view3d_raycast.py 2012-12-18 09:13:04 UTC (rev 53111)
+++ trunk/blender/release/scripts/templates/operator_modal_view3d_raycast.py 2012-12-18 10:43:06 UTC (rev 53112)
@@ -16,7 +16,6 @@
ray_origin = view3d_utils.region_2d_to_origin_3d(region, rv3d, coord)
ray_target = ray_origin + (view_vector * ray_max)
- scene.cursor_location = ray_target
def visible_objects_and_duplis():
"""Loop over (object, matrix) pairs (mesh only)"""
@@ -58,7 +57,9 @@
if obj.type == 'MESH':
hit, normal, face_index = obj_ray_cast(obj, matrix)
if hit is not None:
- length_squared = (hit - ray_origin).length_squared
+ hit_world = matrix * hit
+ scene.cursor_location = hit_world
+ length_squared = (hit_world - ray_origin).length_squared
if length_squared < best_length_squared:
best_length_squared = length_squared
best_obj = obj
@@ -67,6 +68,7 @@
# we could do lots of stuff but for the example just select.
if best_obj is not None:
best_obj.select = True
+ context.scene.objects.active = best_obj
class ViewOperatorRayCast(bpy.types.Operator):
@@ -105,3 +107,4 @@
if __name__ == "__main__":
register()
+
More information about the Bf-blender-cvs
mailing list