diff options
Diffstat (limited to 'intern/cycles/blender/blender_util.h')
-rw-r--r-- | intern/cycles/blender/blender_util.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index e79f2bbb27d..e606696fb7b 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -17,6 +17,8 @@ #ifndef __BLENDER_UTIL_H__ #define __BLENDER_UTIL_H__ +#include "mesh.h" + #include "util_map.h" #include "util_path.h" #include "util_set.h" @@ -561,6 +563,29 @@ static inline BL::DomainFluidSettings object_fluid_domain_find(BL::Object b_ob) return BL::DomainFluidSettings(PointerRNA_NULL); } +static inline Mesh::SubdivisionType object_subdivision_type(BL::Object& b_ob, bool preview, bool experimental) +{ + PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles"); + + if(cobj.data && b_ob.modifiers.length() > 0 && experimental) { + BL::Modifier mod = b_ob.modifiers[b_ob.modifiers.length()-1]; + bool enabled = preview ? mod.show_viewport() : mod.show_render(); + + if(enabled && mod.type() == BL::Modifier::type_SUBSURF && RNA_boolean_get(&cobj, "use_adaptive_subdivision")) { + BL::SubsurfModifier subsurf(mod); + + if(subsurf.subdivision_type() == BL::SubsurfModifier::subdivision_type_CATMULL_CLARK) { + return Mesh::SUBDIVISION_CATMULL_CLARK; + } + else { + return Mesh::SUBDIVISION_LINEAR; + } + } + } + + return Mesh::SUBDIVISION_NONE; +} + /* ID Map * * Utility class to keep in sync with blender data. |