Page MenuHome

flow simulation element viewport size indicator strange after applying resize
Confirmed, NormalPublicBUG

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce RTX 2060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 445.87

Blender Version
Broken: version: 2.83 (sub 17), branch: master, commit date: 2020-05-19 23:15, hash: rBdfe8195dfe83
Worked: not known

Short description of error
Element size preview in viewport behaves unexpected.

Exact steps for others to reproduce the error

  1. Open Blender
  2. Apply Quick Smoke to cube
  3. scale up Smoke Domain by 20 in x and y direction while keep z scale unchanged (S+Shift Z+20). Notice that preview of element size in corner of Smoke Domain gets resized and becomes more flat. Maybe that is bug because I would have expected that fluid elements are always cubic. But maybe that is intended?
  4. Apply All transforms to Smoke Domain
  5. I would now expect that viewport showed a resized preview of element size for Smoke Domain that was cubic. Instead size preview completely disappears from Smoke Domain. Instead a preview element is shown in the Cube. See
    .

Why does a flow object, that is not a domain object, need a element size preview? I think this is a bug.
Also, why doesn't the Smoke Domain get a updated cubic element preview when the Smoke Domain object changes size? I think this is also a bug.

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.May 25 2020, 10:22 AM
Philipp Oeser (lichtwerk) claimed this task.
Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".

Can confirm (partially).
Applying size does not place the indicator at the corner (where it should be).
Also for non-uniform domains the resolution does not seems to be based on the longest side (as it should) -- also checking on this (this could be a display thing only though)

Yes, the issue is that the indicator cube is not placed in the corner of the domain.
In your case it lines up perfectly with the flow object - which gives the impression that it's part of it.

And yes, scaling is off too..

As for the size of the indicator cube, this seems to do the trick (we've got the cell_size precalculated already):

1
2
3diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
4index af54e524445..4ec2daa533f 100644
5--- a/source/blender/draw/engines/overlay/overlay_extra.c
6+++ b/source/blender/draw/engines/overlay/overlay_extra.c
7@@ -1373,9 +1373,9 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb,
8 madd_v3fl_v3fl_v3fl_v3i(min, mds->p0, mds->cell_size, mds->res_min);
9 float voxel_cubemat[4][4] = {{0.0f}};
10 /* scale small cube to voxel size */
11- voxel_cubemat[0][0] = 1.0f / (float)mds->base_res[0];
12- voxel_cubemat[1][1] = 1.0f / (float)mds->base_res[1];
13- voxel_cubemat[2][2] = 1.0f / (float)mds->base_res[2];
14+ voxel_cubemat[0][0] = mds->cell_size[0] / 2.0f;
15+ voxel_cubemat[1][1] = mds->cell_size[1] / 2.0f;
16+ voxel_cubemat[2][2] = mds->cell_size[2] / 2.0f;
17 voxel_cubemat[3][3] = 1.0f;
18 /* translate small cube to corner */
19 copy_v3_v3(voxel_cubemat[3], min);

As for the missing update when scaling is applied, a call to BKE_fluid_modifier_reset seems to be necessary.
Maybe this can be done in apply_objects_internal, however for this I think we need a design decision to be made first:

  • this is not only an issue when applying transforms
  • what happens if you move domain vertices in editmode (this just seems to scale the whole thing -- which seems wrong to me -- should this also result in a call to BKE_fluid_modifier_reset on modeswitch)?


Maybe @Jacques Lucke (JacquesLucke) has an opinion as well?

One other thing I noticed is that even with above patch, cell_size can actually end up not being of equal length:
Quite easily: if you have a domain 1m x 1m x 2m with a resolution of 11 set in the UI, you end up with a base_res 6x6x11 and a cell_size of 0.333333 0.333333 0.363636
And this is not a display issue only, this ends up in calculations everywhere, not sure if this can cause problems?

That seems to work better than the old version in my simple test as well. I think you can commit that fix.

I have committed rB9b0543389bf8: Fix domain voxel size indicator drawing, think we still need to think about when to actually call BKE_fluid_modifier_reset: on applying scale?, changes in editmode? (see my comment above), so will keep this report open.

So the last issue is a refresh issue inside the physics code. Untagging Viewport then.