Commit Graph

48 Commits

Author SHA1 Message Date
Sebastián Barschkis
cd0a6ff5c4 Fluid: Diffusion settings now optional
For optimization purposes these settings need to be enabled explicitly from now on.
2020-03-05 12:36:00 +01:00
Sebastián Barschkis
4ccbbd3080 Fix T74446: Liquid Inflow Does Not Work
Somehow this was forgotton in the optimization patch a5c4a44df67e.
2020-03-05 11:41:09 +01:00
Sebastián Barschkis
a5c4a44df6 Fluid: Bounding boxes for effector objects
This commit adds bounding box support for emission objects - similarly to flow objects. Before, each effector object had to iterate over the entire domain. Bake times of scenes with multiple obstacles improved significantly with this optimization.

Other improvements that were implemented alongside the bbox feature:
- Option for subframe sampling for effector objects
- Option to enable / disable effectors (can be animated)
- Optimization for static objects. If a flow or effector object does not move and the adaptive domain is not in use, the bake time will be optimized further by reusing the flow / effector grids from the previous frame (no recalculation).
2020-03-04 18:46:48 +01:00
Sebastián Barschkis
3c74d45c9e Fluid: Added sanity grid initializations in smoke / liquid scripts
Just a sanity check.
2020-03-04 18:46:48 +01:00
Sebastián Barschkis
bf8a73b4a7 Fluid: Naming cleanup for flags grid
Use flags instead of obstacle to avoid confusion with obstacle levelset grid.
2020-03-04 18:46:48 +01:00
Sebastián Barschkis
6958ec3f7f Fluid: Added an option to delete fluid inside obstacles
Simple checkbox that - if enabled - will tell the solver to clear density or liquid particles in obstacle cells.
2020-03-04 18:46:48 +01:00
Sebastián Barschkis
b32fd73b24 Fluid: Optimization for extrapolation functions in smoke / liquid scripts
Too much extrapolation can become expensive. Reducing it here since extrapolating levelsets into a couple of cells should be sufficient.
2020-03-04 18:46:48 +01:00
Sebastián Barschkis
bc2ce31d79 Fluid: Improved behavior at open boundaries
Use greater boundary width for smoke simulations
2020-02-28 16:20:13 +01:00
Brecht Van Lommel
9085b7e847 Fix OpenVDB link error on Windows after recent changes 2020-02-26 19:24:20 +01:00
Brecht Van Lommel
78391def6e Cleanup: deduplicate OpenVDB library definitions/include/libs logic
This will more important when we start using OpenVDB in more modules.
2020-02-26 18:13:14 +01:00
Julian Eisel
fc81eb74e7 Mantaflow: Address precompiler warning and related cleanup
* Address warning because of undefined OPENVDB usage
* Remove unused WITH_FLUID definitions

Differential Revision: https://developer.blender.org/D6919
2020-02-24 13:01:13 +01:00
Sebastián Barschkis
888d180164 Fluid: Updated manta pp files
Updates in the files include:
- New manta files now use an platform independent gzopen function
- Adjusted argument name for vorticity
2020-02-19 18:58:48 +01:00
Sebastián Barschkis
8c5e36d0a9 Fluid: Fix typo that was made in 4453509d83dc 2020-02-19 15:33:36 +01:00
Sebastián Barschkis
4453509d83 Fix T73770: Mantaflow is unable to bake fluid simulations on non-ASCII file paths
Some fluid cache functions were not using Blender's more secure BLI_gzopen() function. On Windows there are some special cases which this function can handle compared to the plain gzopen().
2020-02-19 15:07:54 +01:00
Campbell Barton
60890ccf9d Fix T73862: Fluid Sim file handle resource leak 2020-02-17 16:04:04 +11:00
Sebastián Barschkis
d6d44ccc77 Fluid: Inflow object improvements
Various fixes for smoke / fire flow objects:
- Apply inflow at every subframe (new: also emit during adaptive steps in between frames)
- Fix issue with fire not being emitted on first frame
- Higher value range for smoke flow density variable
2020-02-14 14:22:36 +01:00
Ray Molenkamp
75a5ea01c1 Cleanup/MSVC: Enable C++ conformance mode on compiler versions that support it.
MSVC has a conformance mode (/permissive-) where the C++ standard is more strictly
enforced. This mode is available on MSVC 15.5+ [1]

This patch enables this mode on compilers that support it and cleans up the few violations it threw up in the process.

- Mantaflow was using M_PI without requesting them using the _USE_MATH_DEFINES define to opt in to non default behaviour.
- Collada did not include the right header for std::cerr, this seemingly was fixed for other platforms already but put inside a platform guard.
- Ghost had some scoping issues regarding uninitialized variables and goto behaviour

Second landing of this patch, earlier commit was reverted due to some compiler configurations having slipped though testing

[1] https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance

Differential Revision: https://developer.blender.org/D6824

Reviewed By: brecht
2020-02-13 17:13:07 -07:00
Ray Molenkamp
6022cd015f Revert "Cleanup/MSVC: Enable C++ conformance mode on compiler versions that support it."
It is breaking compilation on some configurations, revert for now while
i see what is wrong.

This reverts commit 9fe469c110940af5d2525158305d5d365bd15276.
2020-02-13 07:04:30 -07:00
Ray Molenkamp
9fe469c110 Cleanup/MSVC: Enable C++ conformance mode on compiler versions that support it.
MSVC has a conformance mode (/permissive-) where the C++ standard is more strictly
enforced. This mode is available on MSVC 15.5+ [1]

This patch enables this mode on compilers that support it and cleans up the few violations it threw up in the process.

- Mantaflow was using M_PI without requesting them using the _USE_MATH_DEFINES define to opt in to non default behaviour.
- Collada did not include the right header for std::cerr, this seemingly was fixed for other platforms already but put inside a platform guard.
- Ghost had some scoping issues regarding uninitialized variables and goto behaviour

[1] https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance

Differential Revision: https://developer.blender.org/D6824

Reviewed By: brecht
2020-02-12 12:49:34 -07:00
Campbell Barton
3e6e9ce01b Cleanup: extra semicolons, comma use, undeclared vars 2020-02-11 12:04:50 +11:00
Sebastián Barschkis
5e30bd43f8 Fluid: Optimization for fluid domain obstacle boundary handling
This fix should especially improve liquid obstacles boundaries, i.e. help with the problem of particles sticking to the surface.
2020-02-09 17:25:00 +01:00
Sebastián Barschkis
a048354e9f Fluid: Fixed file formats for script exporter
File formats in the exported scripts were using hardcoded file extensions and not the ones specified in the UI.
2020-02-09 17:17:24 +01:00
Sebastián Barschkis
86e24ea10c Fluid: Fixes for fluid guiding
Fluid guiding functionality was broken in the bake / read cache loop in fluid.c. Committing this to the release branch as otherwise fluid guiding would not have worked as expected (i.e. not at all).
2020-02-09 17:15:41 +01:00
Sebastián Barschkis
68221b7eba Fluid: Fixed cache reading issue with larger resolution noise grids
Important fix that needs to go into the release. The upscaled noise cache was not read into upscaled grids.
2020-02-07 19:37:44 +01:00
Sebastián Barschkis
ffcccf654c OpenVDB: Added missing macros in fluid wrapper file
These were needed to compile when WITH_FLUID=1 and WITH_OPENVDB=0.
2020-02-07 15:19:17 +01:00
Sebastián Barschkis
f12b4e53aa Fluid: Fixed try/catch exception issue and unsed variable issue
Sergey just pointed this out, fixing in it the release branch to avoid any compilation issues during the actual release. Thx!
2020-02-07 11:02:55 +01:00
Ray Molenkamp
763f117c48 Fix: Build error on windows in bf_intern_mantaflow
bf_intern_mantaflow lacked the `-DOPENVDB_STATICLIB` define
causing it to dynamically import openvdb, linked against
our static libs a happy time was not had by the linker.
2020-02-06 13:44:30 -07:00
Sebastián Barschkis
1bb702df1e OpenVDB: Fix IOError in try catch statement
Broader exception handling for OpenVDB IO errors.
2020-02-06 17:24:09 +01:00
Sebastián Barschkis
e7d71ce9cf Fluid: Fixed slow cache loading for smoke data
Cache files are currently loaded via the Manta Python API. With very big caches this can slow down the viewport playback. Especially smoke simulations, which just load grids and no meshes, can suffer from this. This fix solves this problem by directly loading the cache files from disk (no Python). This fix has been in the works for some time. The developer of this patch is ready to handle any potential fall-out of this patch quickly.
2020-02-06 16:53:00 +01:00
Sebastián Barschkis
3601924acb Fluid: More stable flow emission
Reverting some changes that were made in 33317b464777
2020-01-31 13:50:33 +01:00
Sebastián Barschkis
33317b4647 Fluid: Fixes for flow objects and initial velocities
This commit cleans up the flow emission code (i.e. the code that determines where flow is generated). It also addresses an issue with initial velocities.

Related issues (that might be fixed through this commit) are: T73422, T72949
2020-01-29 19:21:52 +01:00
Sebastián Barschkis
64b152c254 Fluid: Added resume cache boolean to standalone scripts
Exported Manta script was missing the new resume options in the data load functions.
2020-01-24 17:23:50 +01:00
Sergey Sharybin
517870a4a1 CMake: Refactor external dependencies handling
This is a more correct fix to the issue Brecht was fixing in D6600.

While the fix in that patch worked fine for linking it broke ASAN
runtime under some circumstances.
For example, `make full debug developer` would compile, but trying
to start blender will cause assert failure in ASAN (related on check
that ASAN is not running already).

Top-level idea: leave it to CMake to keep track of dependency graph.

The root of the issue comes to the fact that target like "blender" is
configured to use a lot of static libraries coming from Blender sources
and to use external static libraries. There is nothing which ensures
order between blender's and external libraries. Only order of blender
libraries is guaranteed.

It was possible that due to a cycle or other circumstances some of
blender libraries would have been passed to linker after libraries
it uses, causing linker errors.

For example, this order will likely fail:

  libbf_blenfont.a libfreetype6.a libbf_blenfont.a

This change makes it so blender libraries are explicitly provided
their dependencies to an external libraries, which allows CMake to
ensure they are always linked against them.

General rule here: if bf_foo depends on an external library it is
to be provided to LIBS for bf_foo.
For example, if bf_blenkernel depends on opensubdiv then LIBS in
blenkernel's CMakeLists.txt is to include OPENSUBDIB_LIBRARIES.

The change is made based on searching for used include folders
such as OPENSUBDIV_INCLUDE_DIRS and adding corresponding libraries
to LIBS ion that CMakeLists.txt. Transitive dependencies are not
simplified by this approach, but I am not aware of any downside of
this: CMake should be smart enough to simplify them on its side.
And even if not, this shouldn't affect linking time.

Benefit of not relying on transitive dependencies is that build
system is more robust towards future changes. For example, if
bf_intern_opensubiv is no longer depends on OPENSUBDIV_LIBRARIES
and all such code is moved to bf_blenkernel this will not break
linking.

The not-so-trivial part is change to blender_add_lib (and its
version in Cycles). The complexity is caused by libraries being
provided as a single list argument which doesn't allow to use
different release and debug libraries on Windows. The idea is:

- Have every library prefixed as "optimized" or "debug" if
  separation is needed (non-prefixed libraries will be considered
  "generic").

- Loop through libraries passed to function and do simple parsing
  which will look for "optimized" and "debug" words and specify
  following library to corresponding category.

This isn't something particularly great. Alternative would be to
use target_link_libraries() directly, which sounds like more code
but which is more explicit and allows to have more flexibility
and control comparing to wrapper approach.

Tested the following configurations on Linux, macOS and Windows:

- make full debug developer
- make full release developer
- make lite debug developer
- make lite release developer

NOTE: Linux libraries needs to be compiled with D6641 applied,
otherwise, depending on configuration, it's possible to run into
duplicated zlib symbols error.

Differential Revision: https://developer.blender.org/D6642
2020-01-23 16:59:18 +01:00
Sebastián Barschkis
ca7bd3f1c3 Fluid: Cleaned up functions that deal with Python objects (C-API)
This commit belongs to T72894. It's related to (my) previous commits on pointer exchanges (today + yesterday). It cleans up the functions by describing their usage in the comments, adds additional nullptr checks, and fixes the reference count responsibilities of newly created PyObjects.
2020-01-22 18:31:19 +01:00
Sebastián Barschkis
be7571a5e4 Fluid: Refactored Mantaflow <-> Blender pointer exchange once more 2020-01-22 16:45:57 +01:00
Sebastián Barschkis
96fa613639 Fix T73311: Mantaflow > Liquid: Enabling Initial Velocity on Inflow / Outflow crashes Blender 2020-01-22 11:40:04 +01:00
Sebastián Barschkis
c4b5279bbc Fix T72894: Mantaflow: several crashes due to null pointers
Incorporated LazyDodo's suggestions from the task.
2020-01-22 11:17:54 +01:00
Sebastián Barschkis
6c50e82efb Fluid: Refactored the Mantaflow <-> Blender pointer exchange function and switched to from NULL to nullptr in cpp files 2020-01-21 18:31:10 +01:00
Sebastián Barschkis
153a96472a Fluid: Fix typo in smoke script 2020-01-20 12:34:38 +01:00
Sebastián Barschkis
c7596cd820 Fluid: Improved cache file loading
Cache file loading for mesh and particle files now works through the direct update_structures functions. The final cache mode now also only bakes the most essential files and is therefore not resumable anymore.
2020-01-19 23:44:56 +01:00
Sebastián Barschkis
d4261760c7 Fluid: Fix for mesh velocities
Was using incorrect file format when reading mesh velocities from cache
2020-01-16 15:33:15 +01:00
Sebastián Barschkis
68462a9419 Fix T73111: Bake data of fluid causes crash of Blender 2020-01-15 17:22:00 +01:00
Sebastián Barschkis
adcc9d014c Fluid: Moved grid reset loop for inner obstacle cells from blenkernel code into Mantaflow
Having this loop in directly Manta is faster and potentially fixes issues T72783 and T72894.
2020-01-15 16:28:56 +01:00
Sebastián Barschkis
4d0a91d03d Fluid: Ensure GIL in conversion function 2019-12-21 00:35:23 +01:00
Sergey Sharybin
bde06da223 Manta: Fix using path as an input and output
It is not guaranteed that the function will give correct result
in such an overlapping inputs.

@sebbas please verify this.
2019-12-17 09:47:12 +01:00
Campbell Barton
ca277d7d60 Cleanup: renaming guiding -> guide
The term guide makes sense on it's own in this context.
2019-12-17 14:00:19 +11:00
Campbell Barton
bcd38b398c Cleanup: remove contributors, license begin/end & doxy file argument
This had already been removed for all source files,
recent patches re-introduced them.
2019-12-17 09:27:01 +11:00
Sebastián Barschkis
2aa4301c88 Mantaflow [Part 2]: Added fluid wrapper files
Files from /intern/mantaflow handle the communication between core Blender code and Mantaflow itself. It's the bridge to communicate with Mantas Python functions.

Code from /intern/mantaflow/intern/strings/ is pure Manta code and would likely need less attention in the review.

Reviewed By: sergey

Maniphest Tasks: T59995

Differential Revision: https://developer.blender.org/D3851
2019-12-16 16:29:08 +01:00