Commit: 5ef46c1ef12a6650e4d9b893d9912cc18363721c
Author: Mai Lavelle
Date:   Sun Sep 18 12:04:12 2016 -0400
Branches: blender-v2.78-release
https://developer.blender.org/rB5ef46c1ef12a6650e4d9b893d9912cc18363721c

Cycles: Fix update of subdivision meshes when global dice rates change

When subdivision settings were moved from meshes to objects this was missed,
should work fine now.

===================================================================

M       intern/cycles/blender/blender_mesh.cpp
M       intern/cycles/blender/blender_sync.cpp
M       intern/cycles/blender/blender_util.h

===================================================================

diff --git a/intern/cycles/blender/blender_mesh.cpp 
b/intern/cycles/blender/blender_mesh.cpp
index dba6897..ff1d49f 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -959,25 +959,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
 
                bool need_undeformed = mesh->need_attribute(scene, 
ATTR_STD_GENERATED);
 
-               mesh->subdivision_type = Mesh::SUBDIVISION_NONE;
-
-               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) {
-                                       mesh->subdivision_type = 
Mesh::SUBDIVISION_CATMULL_CLARK;
-                               }
-                               else {
-                                       mesh->subdivision_type = 
Mesh::SUBDIVISION_LINEAR;
-                               }
-                       }
-               }
+               mesh->subdivision_type = object_subdivision_type(b_ob, preview, 
experimental);
 
                BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, 
!preview, need_undeformed, mesh->subdivision_type);
 
diff --git a/intern/cycles/blender/blender_sync.cpp 
b/intern/cycles/blender/blender_sync.cpp
index e7e57b2..4ca202a 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -103,6 +103,27 @@ bool BlenderSync::sync_recalc()
                if(b_lamp->is_updated() || (b_lamp->node_tree() && 
b_lamp->node_tree().is_updated()))
                        shader_map.set_recalc(*b_lamp);
 
+       bool dicing_prop_changed = false;
+
+       if(experimental) {
+               PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
+
+               float updated_dicing_rate = preview ? RNA_float_get(&cscene, 
"preview_dicing_rate")
+                                                   : RNA_float_get(&cscene, 
"dicing_rate");
+
+               if(dicing_rate != updated_dicing_rate) {
+                       dicing_rate = updated_dicing_rate;
+                       dicing_prop_changed = true;
+               }
+
+               int updated_max_subdivisions = RNA_int_get(&cscene, 
"max_subdivisions");
+
+               if(max_subdivisions != updated_max_subdivisions) {
+                       max_subdivisions = updated_max_subdivisions;
+                       dicing_prop_changed = true;
+               }
+       }
+
        BL::BlendData::objects_iterator b_ob;
 
        for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
@@ -112,7 +133,9 @@ bool BlenderSync::sync_recalc()
                }
 
                if(object_is_mesh(*b_ob)) {
-                       if(b_ob->is_updated_data() || 
b_ob->data().is_updated()) {
+                       if(b_ob->is_updated_data() || b_ob->data().is_updated() 
||
+                          (dicing_prop_changed && 
object_subdivision_type(*b_ob, preview, experimental) != 
Mesh::SUBDIVISION_NONE))
+                       {
                                BL::ID key = BKE_object_is_modified(*b_ob)? 
*b_ob: b_ob->data();
                                mesh_map.set_recalc(key);
                        }
@@ -129,42 +152,14 @@ bool BlenderSync::sync_recalc()
                }
        }
 
-       bool dicing_prop_changed = false;
-
-       if(experimental) {
-               PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
-
-               float updated_dicing_rate = preview ? RNA_float_get(&cscene, 
"preview_dicing_rate")
-                                                   : RNA_float_get(&cscene, 
"dicing_rate");
-
-               if(dicing_rate != updated_dicing_rate) {
-                       dicing_rate = updated_dicing_rate;
-                       dicing_prop_changed = true;
-               }
-
-               int updated_max_subdivisions = RNA_int_get(&cscene, 
"max_subdivisions");
-
-               if(max_subdivisions != updated_max_subdivisions) {
-                       max_subdivisions = updated_max_subdivisions;
-                       dicing_prop_changed = true;
-               }
-       }
-
        BL::BlendData::meshes_iterator b_mesh;
 
        for(b_data.meshes.begin(b_mesh); b_mesh != b_data.meshes.end(); 
++b_mesh) {
                if(b_mesh->is_updated()) {
                        mesh_map.set_recalc(*b_mesh);
                }
-               else if(dicing_prop_changed) {
-                       PointerRNA cmesh = RNA_pointer_get(&b_mesh->ptr, 
"cycles");
-
-                       if(RNA_enum_get(&cmesh, "subdivision_type"))
-                               mesh_map.set_recalc(*b_mesh);
-               }
        }
 
-
        BL::BlendData::worlds_iterator b_world;
 
        for(b_data.worlds.begin(b_world); b_world != b_data.worlds.end(); 
++b_world) {
diff --git a/intern/cycles/blender/blender_util.h 
b/intern/cycles/blender/blender_util.h
index 5a88e4b..f17a61f 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"
@@ -560,6 +562,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.

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to