diff options
author | Luke Frisken <l.frisken@gmail.com> | 2012-12-18 14:43:06 +0400 |
---|---|---|
committer | Luke Frisken <l.frisken@gmail.com> | 2012-12-18 14:43:06 +0400 |
commit | fa617f1d2ab5fda23c48b043607dc8416b49c083 (patch) | |
tree | 63c9b9fcb92306bd81fcc54d89b32a9bebd7ed35 /release/scripts/templates | |
parent | b7e39671340f980ff5761329f40042b3aea3f973 (diff) |
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.
Diffstat (limited to 'release/scripts/templates')
-rw-r--r-- | release/scripts/templates/operator_modal_view3d_raycast.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/release/scripts/templates/operator_modal_view3d_raycast.py b/release/scripts/templates/operator_modal_view3d_raycast.py index 3236c08cc8c..eac76922187 100644 --- a/release/scripts/templates/operator_modal_view3d_raycast.py +++ b/release/scripts/templates/operator_modal_view3d_raycast.py @@ -16,7 +16,6 @@ def main(context, event, ray_max=10000.0): 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 @@ def main(context, event, ray_max=10000.0): 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 @@ def main(context, event, ray_max=10000.0): # 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 @@ def unregister(): if __name__ == "__main__": register() + |