Fix T52299: X resolution of 4 causes nodes to collapse

Was caused by numeric overflow when calculating preview dimensions.
Now we try to avoid really insance preview resolutions by fitting
aspect into square.
This commit is contained in:
Sergey Sharybin 2017-09-13 18:29:37 +05:00
parent 32449e1b21
commit 6f633dec5d
Notes: blender-bot 2023-02-14 06:42:57 +01:00
Referenced by issue #53683, 2.79a release
Referenced by issue #52752, Blender 2.79 - Cycles Compute Device doesn't detect my AMD GPU
Referenced by issue #52741, New Depsgraph - Empties have follow track constraint on them, scaling the depth object fast causes blender to crash
Referenced by issue #52749, New Depsgraph - Render View Mask is not initialized correctly
Referenced by issue #52299, Setting resolution X to 4 pixels causes some input compositing nodes to be partially collapsed
1 changed files with 14 additions and 2 deletions

View File

@ -64,9 +64,21 @@ void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rende
/* Make sure node tree has previews.
* Don't create previews in advance, this is done when adding preview operations.
* Reserved preview size is determined by render output for now.
*
* We fit the aspect into COM_PREVIEW_SIZE x COM_PREVIEW_SIZE image to avoid
* insane preview resolution, which might even overflow preview dimensions.
*/
float aspect = rd->xsch > 0 ? (float)rd->ysch / (float)rd->xsch : 1.0f;
BKE_node_preview_init_tree(editingtree, COM_PREVIEW_SIZE, (int)(COM_PREVIEW_SIZE * aspect), false);
const float aspect = rd->xsch > 0 ? (float)rd->ysch / (float)rd->xsch : 1.0f;
int preview_width, preview_height;
if (aspect < 1.0f) {
preview_width = COM_PREVIEW_SIZE;
preview_height = (int)(COM_PREVIEW_SIZE * aspect);
}
else {
preview_width = (int)(COM_PREVIEW_SIZE / aspect);
preview_height = COM_PREVIEW_SIZE;
}
BKE_node_preview_init_tree(editingtree, preview_width, preview_height, false);
/* initialize workscheduler, will check if already done. TODO deinitialize somewhere */
bool use_opencl = (editingtree->flag & NTREE_COM_OPENCL) != 0;