Fix #36327: cycles render layers exclude layers animation did not work well.

This is kind of another way to animate layers which is disabled, but add an
exception to make this case work.
This commit is contained in:
Brecht Van Lommel 2013-09-10 20:26:34 +00:00
parent 92d94ccb08
commit 734eaab545
3 changed files with 48 additions and 28 deletions

View File

@ -49,6 +49,7 @@
#include "BKE_context.h"
#include "BKE_idcode.h"
#include "BKE_idprop.h"
#include "BKE_fcurve.h"
#include "BKE_main.h"
#include "BKE_report.h"
@ -1512,14 +1513,24 @@ bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
return (prop->flag & PROP_EDITABLE) != 0;
}
bool RNA_property_animated(PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop))
bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop)
{
/* would need to ask animation system */
int len = 1, index;
bool driven;
if (!prop)
return false;
if (RNA_property_array_check(prop))
len = RNA_property_array_length(ptr, prop);
for (index = 0; index < len; index++)
if (rna_get_fcurve(ptr, prop, index, NULL, &driven))
return true;
return false;
}
/* this function is to check if its possible to create a valid path from the ID
* its slow so don't call in a loop */
bool RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop)

View File

@ -318,38 +318,22 @@ static int node_animation_properties(bNodeTree *ntree, bNode *node)
lb = RNA_struct_type_properties(ptr.type);
for (link = lb->first; link; link = link->next) {
int len = 1, index;
bool driven;
prop = (PropertyRNA *)link;
if (RNA_property_array_check(prop))
len = RNA_property_array_length(&ptr, prop);
for (index = 0; index < len; index++) {
if (rna_get_fcurve(&ptr, prop, index, NULL, &driven)) {
nodeUpdate(ntree, node);
return 1;
}
if (RNA_property_animated(&ptr, prop)) {
nodeUpdate(ntree, node);
return 1;
}
}
/* now check node sockets */
for (sock = node->inputs.first; sock; sock = sock->next) {
int len = 1, index;
bool driven;
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
prop = RNA_struct_find_property(&ptr, "default_value");
if (prop) {
if (RNA_property_array_check(prop))
len = RNA_property_array_length(&ptr, prop);
for (index = 0; index < len; index++) {
if (rna_get_fcurve(&ptr, prop, index, NULL, &driven)) {
nodeUpdate(ntree, node);
return 1;
}
}
if (RNA_property_animated(&ptr, prop)) {
nodeUpdate(ntree, node);
return 1;
}
}

View File

@ -49,6 +49,8 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "RNA_access.h"
#ifdef WITH_PYTHON
#include "BPY_extern.h"
#endif
@ -392,6 +394,17 @@ RenderData *RE_engine_get_render_data(Render *re)
/* Render */
static bool render_layer_exclude_animated(Scene *scene, SceneRenderLayer *srl)
{
PointerRNA ptr;
PropertyRNA *prop;
RNA_pointer_create(&scene->id, &RNA_SceneRenderLayer, srl, &ptr);
prop = RNA_struct_find_property(&ptr, "layers_exclude");
return RNA_property_animated(&ptr, prop);
}
int RE_engine_render(Render *re, int do_all)
{
RenderEngineType *type = RE_engines_find(re->r.engine);
@ -420,13 +433,25 @@ int RE_engine_render(Render *re, int do_all)
if (re->r.scemode & R_SINGLE_LAYER) {
srl = BLI_findlink(&re->r.layers, re->r.actlay);
if (srl)
if (srl) {
non_excluded_lay |= ~srl->lay_exclude;
/* in this case we must update all because animation for
* the scene has not been updated yet, and so may not be
* up to date until after BKE_scene_update_for_newframe */
if (render_layer_exclude_animated(re->scene, srl))
non_excluded_lay |= ~0;
}
}
else {
for (srl = re->r.layers.first; srl; srl = srl->next)
if (!(srl->layflag & SCE_LAY_DISABLE))
for (srl = re->r.layers.first; srl; srl = srl->next) {
if (!(srl->layflag & SCE_LAY_DISABLE)) {
non_excluded_lay |= ~srl->lay_exclude;
if (render_layer_exclude_animated(re->scene, srl))
non_excluded_lay |= ~0;
}
}
}
lay &= non_excluded_lay;