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.
This commit is contained in:
Mai Lavelle 2016-09-18 12:04:12 -04:00
parent 799454821e
commit 940f360479
3 changed files with 54 additions and 52 deletions

@ -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);

@ -103,32 +103,6 @@ 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);
BL::BlendData::objects_iterator b_ob;
for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
if(b_ob->is_updated()) {
object_map.set_recalc(*b_ob);
light_map.set_recalc(*b_ob);
}
if(object_is_mesh(*b_ob)) {
if(b_ob->is_updated_data() || b_ob->data().is_updated()) {
BL::ID key = BKE_object_is_modified(*b_ob)? *b_ob: b_ob->data();
mesh_map.set_recalc(key);
}
}
else if(object_is_light(*b_ob)) {
if(b_ob->is_updated_data() || b_ob->data().is_updated())
light_map.set_recalc(*b_ob);
}
if(b_ob->is_updated_data()) {
BL::Object::particle_systems_iterator b_psys;
for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys)
particle_system_map.set_recalc(*b_ob);
}
}
bool dicing_prop_changed = false;
if(experimental) {
@ -150,21 +124,42 @@ bool BlenderSync::sync_recalc()
}
}
BL::BlendData::objects_iterator b_ob;
for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
if(b_ob->is_updated()) {
object_map.set_recalc(*b_ob);
light_map.set_recalc(*b_ob);
}
if(object_is_mesh(*b_ob)) {
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);
}
}
else if(object_is_light(*b_ob)) {
if(b_ob->is_updated_data() || b_ob->data().is_updated())
light_map.set_recalc(*b_ob);
}
if(b_ob->is_updated_data()) {
BL::Object::particle_systems_iterator b_psys;
for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys)
particle_system_map.set_recalc(*b_ob);
}
}
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) {

@ -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.