diff options
-rw-r--r-- | intern/cycles/kernel/osl/osl_globals.h | 1 | ||||
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.cpp | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires_reshape.c | 6 |
3 files changed, 12 insertions, 3 deletions
diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h index c06c9abd4c1..caca3c28c8d 100644 --- a/intern/cycles/kernel/osl/osl_globals.h +++ b/intern/cycles/kernel/osl/osl_globals.h @@ -90,6 +90,7 @@ struct OSLTraceData { ShaderData sd; bool setup; bool init; + bool hit; }; /* thread key for thread specific data lookup */ diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp index 5292b5f8055..aee1e3a244e 100644 --- a/intern/cycles/kernel/osl/osl_services.cpp +++ b/intern/cycles/kernel/osl/osl_services.cpp @@ -1481,6 +1481,7 @@ bool OSLRenderServices::trace(TraceOpt &options, tracedata->ray = ray; tracedata->setup = false; tracedata->init = true; + tracedata->hit = false; tracedata->sd.osl_globals = sd->osl_globals; KernelGlobals *kg = sd->osl_globals; @@ -1492,7 +1493,8 @@ bool OSLRenderServices::trace(TraceOpt &options, /* Raytrace, leaving out shadow opaque to avoid early exit. */ uint visibility = PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE; - return scene_intersect(kg, &ray, visibility, &tracedata->isect); + tracedata->hit = scene_intersect(kg, &ray, visibility, &tracedata->isect); + return tracedata->hit; } bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, @@ -1506,9 +1508,9 @@ bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, if (source == u_trace && tracedata->init) { if (name == u_hit) { - return set_attribute_int((tracedata->isect.prim != PRIM_NONE), type, derivatives, val); + return set_attribute_int(tracedata->hit, type, derivatives, val); } - else if (tracedata->isect.prim != PRIM_NONE) { + else if (tracedata->hit) { if (name == u_hitdist) { float f[3] = {tracedata->isect.t, 0.0f, 0.0f}; return set_attribute_float(f, type, derivatives, val); diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c index 64cc9130e25..f9383a46be0 100644 --- a/source/blender/blenkernel/intern/multires_reshape.c +++ b/source/blender/blenkernel/intern/multires_reshape.c @@ -189,6 +189,12 @@ void multiresModifier_subdivide_to_level(struct Object *object, } Mesh *coarse_mesh = object->data; + if (coarse_mesh->totloop == 0) { + /* If there are no loops in the mesh inplies there is no CD_MDISPS as well. So can early output + * from here as there is nothing to subdivide. */ + return; + } + MultiresReshapeContext reshape_context; /* There was no multires at all, all displacement is at 0. Can simply make sure all mdisps grids |