Fix T50736: Zero streaks in Glare node.
Please never, ever use same DNA var for two different things. Even worse if they do not have same type and ranges! This is only ensuring issues (as described in report, but also if animating both RNA props using same DNA var... yuck). And we were not even saving any byte in DNA, could reuse some padding there to store the two new needed vars (yes, two, since we cannot re-use existing one if we want to keep backward *and* forward compatibility).
This commit is contained in:
parent
7359cc1060
commit
9dd194716b
Notes:
blender-bot
2023-02-14 07:11:56 +01:00
Referenced by issue #50736, Zero streaks in Glare node
|
@ -1575,6 +1575,29 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
|
|||
}
|
||||
}
|
||||
|
||||
/* Fix for T50736, Glare comp node using same var for two different things. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "NodeGlare", "char", "star_45")) {
|
||||
FOREACH_NODETREE(main, ntree, id) {
|
||||
if (ntree->type == NTREE_COMPOSIT) {
|
||||
ntreeSetTypes(NULL, ntree);
|
||||
for (bNode *node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == CMP_NODE_GLARE) {
|
||||
NodeGlare *ndg = node->storage;
|
||||
switch (ndg->type) {
|
||||
case 2: /* Grrrr! magic numbers :( */
|
||||
ndg->streaks = ndg->angle;
|
||||
break;
|
||||
case 0:
|
||||
ndg->star_45 = ndg->angle != 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} FOREACH_NODETREE_END
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1026,6 +1026,25 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
|
|||
{
|
||||
/* pass */
|
||||
}
|
||||
else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_GLARE)) {
|
||||
/* Simple forward compat for fix for T50736.
|
||||
* Not ideal (there is no ideal solution here), but should do for now. */
|
||||
NodeGlare *ndg = node->storage;
|
||||
/* Not in undo case. */
|
||||
if (!wd->current) {
|
||||
switch (ndg->type) {
|
||||
case 2: /* Grrrr! magic numbers :( */
|
||||
ndg->angle = ndg->streaks;
|
||||
break;
|
||||
case 0:
|
||||
ndg->angle = ndg->star_45;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
|
||||
}
|
||||
else {
|
||||
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
|
||||
}
|
||||
|
|
|
@ -44,18 +44,18 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil
|
|||
xp = x + i;
|
||||
tbuf1->read(c, x, y);
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf1->read(tc, (settings->angle ? xm : x), ym);
|
||||
tbuf1->read(tc, (settings->star_45 ? xm : x), ym);
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf1->read(tc, (settings->angle ? xp : x), yp);
|
||||
tbuf1->read(tc, (settings->star_45 ? xp : x), yp);
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf1->writePixel(x, y, c);
|
||||
|
||||
tbuf2->read(c, x, y);
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf2->read(tc, xm, (settings->angle ? yp : y));
|
||||
tbuf2->read(tc, xm, (settings->star_45 ? yp : y));
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf2->read(tc, xp, (settings->angle ? ym : y));
|
||||
tbuf2->read(tc, xp, (settings->star_45 ? ym : y));
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf2->writePixel(x, y, c);
|
||||
|
@ -73,18 +73,18 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil
|
|||
xp = x + i;
|
||||
tbuf1->read(c, x, y);
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf1->read(tc, (settings->angle ? xm : x), ym);
|
||||
tbuf1->read(tc, (settings->star_45 ? xm : x), ym);
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf1->read(tc, (settings->angle ? xp : x), yp);
|
||||
tbuf1->read(tc, (settings->star_45 ? xp : x), yp);
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf1->writePixel(x, y, c);
|
||||
|
||||
tbuf2->read(c, x, y);
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf2->read(tc, xm, (settings->angle ? yp : y));
|
||||
tbuf2->read(tc, xm, (settings->star_45 ? yp : y));
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf2->read(tc, xp, (settings->angle ? ym : y));
|
||||
tbuf2->read(tc, xp, (settings->star_45 ? ym : y));
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf2->writePixel(x, y, c);
|
||||
|
|
|
@ -28,7 +28,7 @@ void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile,
|
|||
int x, y, n;
|
||||
unsigned int nump = 0;
|
||||
float c1[4], c2[4], c3[4], c4[4];
|
||||
float a, ang = DEG2RADF(360.0f) / (float)settings->angle;
|
||||
float a, ang = DEG2RADF(360.0f) / (float)settings->streaks;
|
||||
|
||||
int size = inputTile->getWidth() * inputTile->getHeight();
|
||||
int size4 = size * 4;
|
||||
|
|
|
@ -668,7 +668,8 @@ typedef struct NodeScriptDict {
|
|||
/* qdn: glare node */
|
||||
typedef struct NodeGlare {
|
||||
char quality, type, iter;
|
||||
char angle, pad_c1, size, pad[2];
|
||||
/* XXX angle is only kept for backward/forward compatibility, was used for two different things, see T50736. */
|
||||
char angle DNA_DEPRECATED, pad_c1, size, star_45, streaks;
|
||||
float colmod, mix, threshold, fade;
|
||||
float angle_ofs, pad_f1;
|
||||
} NodeGlare;
|
||||
|
|
|
@ -5721,8 +5721,8 @@ static void def_cmp_glare(StructRNA *srna)
|
|||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "streaks", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "angle");
|
||||
RNA_def_property_range(prop, 2, 16);
|
||||
RNA_def_property_int_sdna(prop, NULL, "streaks");
|
||||
RNA_def_property_range(prop, 1, 16);
|
||||
RNA_def_property_ui_text(prop, "Streaks", "Total number of streaks");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
|
@ -5739,7 +5739,7 @@ static void def_cmp_glare(StructRNA *srna)
|
|||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_rotate_45", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "angle", 0);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "star_45", 0);
|
||||
RNA_def_property_ui_text(prop, "Rotate 45", "Simple star filter: add 45 degree rotation offset");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ static void node_composit_init_glare(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
ndg->colmod = 0.25;
|
||||
ndg->mix = 0;
|
||||
ndg->threshold = 1;
|
||||
ndg->angle = 4;
|
||||
ndg->star_45 = true;
|
||||
ndg->streaks = 4;
|
||||
ndg->angle_ofs = 0.0f;
|
||||
ndg->fade = 0.9;
|
||||
ndg->size = 8;
|
||||
|
|
Loading…
Reference in New Issue