I’m using the ray_cast on objects and by default it does the ray_cast on the object with modifiers taken into account. I’m trying to figure out how to do with ray_cast as if the modifiers were disabled.
Thanks!!!
I’m using the ray_cast on objects and by default it does the ray_cast on the object with modifiers taken into account. I’m trying to figure out how to do with ray_cast as if the modifiers were disabled.
Thanks!!!
I’m guessing that you want to do raycast on geometry before modifiers, even if they’re enabled in the viewport?
I don’t think the ray_cast()
function tied to the object allows using cage or undeformed geometry. However a ray_cast()
from a bvhtree does. Alternatively, using the ray_cast()
from the original scene also works.
Bvhtree version:
dg = context.evaluated_depsgraph_get()
bv = mathutils.bvhtree.BVHTree.FromObject(context.object, dg, cage=True)
ret = bv.ray_cast(ray_origin, view_vector)
Orig scene version:
dg = context.evaluated_depsgraph_get()
orig_scene = context.scene.evaluated_get(dg)
ret = orig_scene.ray_cast(context.view_layer, ray_origin, view_vector)
I’m a bit new to 2.8 python so forgive me…
I’m not seeing context.evaluated_depsgraph_get() in the API.
I was thinking I could just go into the console and do:
bpy.context.evalu…
What am I missing?
Ah, you probably don’t have the latest build.
That function call is no more than a week old. They removed bpy.context.depsgraph
and replaced it with context.evaluated_depsgraph_get()
.
You can still access the depsgraph in both older and newer builds using context.view_layer.depsgraph
. The resulting depsgraph has the same hash afaik.