Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2019-05-21 16:21:33 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2019-05-21 17:39:48 +0300
commit4f6d6f982ff5e81bcd5a8828f88fbbde2b3c7d22 (patch)
treeded1841ea5d6bbb9ecc11912f20bca2a5a2d202c /release/scripts/templates_py
parenta25b8f531a7abab33fdbe9beedcfe53cc1132c0a (diff)
python templates: update operator_modal_view3d_raycast to 2.8
Reviewers: JacquesLucke, sergey Differential Revision: https://developer.blender.org/D4914
Diffstat (limited to 'release/scripts/templates_py')
-rw-r--r--release/scripts/templates_py/operator_modal_view3d_raycast.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/release/scripts/templates_py/operator_modal_view3d_raycast.py b/release/scripts/templates_py/operator_modal_view3d_raycast.py
index 2c596b3b356..7569477af68 100644
--- a/release/scripts/templates_py/operator_modal_view3d_raycast.py
+++ b/release/scripts/templates_py/operator_modal_view3d_raycast.py
@@ -19,19 +19,15 @@ def main(context, event):
def visible_objects_and_duplis():
"""Loop over (object, matrix) pairs (mesh only)"""
- for obj in context.visible_objects:
- if obj.type == 'MESH':
+ depsgraph = bpy.context.evaluated_depsgraph_get()
+ for dup in depsgraph.object_instances:
+ if dup.is_instance: # Real dupli instance
+ obj = dup.instance_object
+ yield (obj, dup.matrix_world.copy())
+ else: # Usual object
+ obj = dup.object
yield (obj, obj.matrix_world.copy())
- if obj.instance_type != 'NONE':
- obj.dupli_list_create(scene)
- for dob in obj.dupli_list:
- obj_dupli = dob.object
- if obj_dupli.type == 'MESH':
- yield (obj_dupli, dob.matrix.copy())
-
- obj.dupli_list_clear()
-
def obj_ray_cast(obj, matrix):
"""Wrapper for ray casting that moves the ray into object space"""
@@ -67,8 +63,11 @@ def main(context, event):
# now we have the object under the mouse cursor,
# we could do lots of stuff but for the example just select.
if best_obj is not None:
- best_obj.select_set(True)
- context.view_layer.objects.active = best_obj
+ # for selection etc. we need the original object,
+ # evaluated objects are not in viewlayer
+ best_original = best_obj.original
+ best_original.select_set(True)
+ context.view_layer.objects.active = best_original
class ViewOperatorRayCast(bpy.types.Operator):