Geometry Nodes: initial Volume Grid socket support #115270

Merged
Jacques Lucke merged 193 commits from LukasTonne/blender:volume-grid-sockets into main 2023-12-20 22:33:26 +01:00

193 Commits

Author SHA1 Message Date
Jacques Lucke bbb3f5681a use socket type instead of custom data type in get named grid node 2023-12-20 22:29:58 +01:00
Jacques Lucke 6ccde65001 cleanup 2023-12-20 22:09:02 +01:00
Jacques Lucke 8d46fb8492 Merge branch 'main' into volume-grid-sockets 2023-12-20 21:33:28 +01:00
Jacques Lucke 793769d7db Merge branch 'main' into volume-grid-sockets 2023-12-20 21:21:03 +01:00
Jacques Lucke da01246e8f avoid empty submenus in new volume nodes are disabled
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2023-12-20 16:08:05 +01:00
Jacques Lucke 39a059b330 Merge branch 'main' into volume-grid-sockets 2023-12-20 16:00:43 +01:00
Jacques Lucke d323738b07 only keep get/store nodes for now 2023-12-20 15:52:09 +01:00
Jacques Lucke e57b0b361d Merge branch 'main' into volume-grid-sockets 2023-12-20 15:35:34 +01:00
Jacques Lucke 2059966ad6 Merge branch 'main' into volume-grid-sockets 2023-12-18 22:46:40 +01:00
Jacques Lucke 63bdefe94d Merge branch 'main' into volume-grid-sockets 2023-12-18 22:32:23 +01:00
Jacques Lucke ace4ef1191 cleanup 2023-12-18 22:23:53 +01:00
Jacques Lucke ed25bbebfa lazy load test 2023-12-18 22:19:57 +01:00
Jacques Lucke 94c4899ef1 add tests 2023-12-18 22:11:41 +01:00
Jacques Lucke 4d6dc189aa fix compilation without openvdb 2023-12-18 21:14:24 +01:00
Jacques Lucke 7fa26a9f05 fixes 2023-12-18 20:29:25 +01:00
Jacques Lucke e1df224b08 hide value on grid sockets 2023-12-18 20:10:49 +01:00
Jacques Lucke a21457cb6f progress 2023-12-18 20:09:18 +01:00
Jacques Lucke cfee633887 progress 2023-12-18 20:05:37 +01:00
Jacques Lucke b648c4144d progress 2023-12-18 19:59:21 +01:00
Jacques Lucke d84d7be6bc progress 2023-12-18 19:55:57 +01:00
Jacques Lucke e486c48053 cleanup socket declaration 2023-12-18 19:49:49 +01:00
Jacques Lucke d2a8a1d98a progress 2023-12-18 19:44:55 +01:00
Jacques Lucke 7dfa5a1a54 progress 2023-12-18 19:27:27 +01:00
Jacques Lucke a8aea749d3 comment 2023-12-18 19:17:30 +01:00
Jacques Lucke 1107cf0034 comments 2023-12-18 19:13:44 +01:00
Jacques Lucke 9a176d5764 cleanup naming 2023-12-18 18:57:49 +01:00
Jacques Lucke 635d5f9a73 comments 2023-12-18 18:53:00 +01:00
Jacques Lucke 3ef227f98f progress 2023-12-18 17:49:52 +01:00
Jacques Lucke cd01dbad0d comments 2023-12-18 17:37:16 +01:00
Jacques Lucke 14ade7fcf8 cleanup 2023-12-18 15:00:00 +01:00
Jacques Lucke 6312123261 comments 2023-12-18 14:58:41 +01:00
Jacques Lucke db0c019b11 use simplify level in first evaluation after blend file load 2023-12-18 14:23:36 +01:00
Jacques Lucke 4e41558182 unload unused grids when volume is deleted 2023-12-18 14:12:51 +01:00
Jacques Lucke 4a42a6d858 improve file name 2023-12-18 13:50:03 +01:00
Jacques Lucke cd14f8b1d4 fix wrong transform with simplified grids 2023-12-18 13:28:25 +01:00
Jacques Lucke 1e0c5742cb cleanup 2023-12-18 13:09:05 +01:00
Jacques Lucke 11bb535631 remove outdated comment 2023-12-18 13:07:19 +01:00
Jacques Lucke 1a5e1e12d1 don't unload tree after computing bounding box 2023-12-18 13:07:11 +01:00
Jacques Lucke 82e7725ceb fix leak 2023-12-18 13:06:47 +01:00
Jacques Lucke ba49aebbbe remove include 2023-12-18 12:51:18 +01:00
Jacques Lucke 2085ee862d Merge branch 'main' into volume-grid-sockets2 2023-12-18 12:37:05 +01:00
Jacques Lucke 69d1908b97 cleanup 2023-12-17 19:46:12 +01:00
Jacques Lucke a5e486a4f0 cleanup naming 2023-12-17 19:32:23 +01:00
Jacques Lucke 6776ac7866 progress 2023-12-17 19:26:25 +01:00
Jacques Lucke 6125554b50 cleanup dealing with grid transforms 2023-12-17 19:21:24 +01:00
Jacques Lucke 9152f1e296 move some functions to forward declaration header 2023-12-17 19:12:38 +01:00
Jacques Lucke dcf458dfcf fixes for new socket storage 2023-12-17 16:22:13 +01:00
Jacques Lucke 71ca47cba7 Merge branch 'main' into volume-grid-sockets2 2023-12-17 15:00:28 +01:00
Jacques Lucke fdf11e4809 fixes 2023-12-14 22:04:17 +01:00
Jacques Lucke e7480faeff first successful compilation 2023-12-14 21:30:27 +01:00
Jacques Lucke 43a07718d3 progress 2023-12-14 15:31:01 +01:00
Jacques Lucke f145c5b8c2 add forward declaration header 2023-12-14 15:27:53 +01:00
Jacques Lucke e2d8611b0d fix 2023-12-14 15:24:41 +01:00
Jacques Lucke c790ba1e64 progress 2023-12-14 15:19:40 +01:00
Jacques Lucke 07864a1561 progress 2023-12-14 15:16:40 +01:00
Jacques Lucke 873ca6db97 support unloading tree data 2023-12-14 14:29:52 +01:00
Jacques Lucke 7f2ae9d938 progress 2023-12-14 14:04:09 +01:00
Jacques Lucke d29656f7ae cache grids in file 2023-12-14 13:47:54 +01:00
Jacques Lucke 04e59efd84 support preloading meta-data 2023-12-14 12:35:29 +01:00
Jacques Lucke 605c350a61 progress 2023-12-14 11:04:47 +01:00
Jacques Lucke 9c2d95b3eb remove old api 2023-12-13 22:35:14 +01:00
Jacques Lucke 4bcf283c26 add initial file cache 2023-12-13 22:30:22 +01:00
Jacques Lucke c6bee66e40 initial new api 2023-12-13 15:35:32 +01:00
Jacques Lucke 0f9331fb48 extract grid type traits to separate file 2023-12-13 14:25:31 +01:00
Jacques Lucke a93a7ac874 Merge branch 'main' into volume-grid-sockets 2023-12-13 13:48:17 +01:00
Jacques Lucke b59075471e Merge branch 'main' into volume-grid-sockets 2023-12-13 13:44:10 +01:00
Jacques Lucke 1c329e5964 Merge branch 'main' into volume-grid-sockets 2023-12-13 13:14:06 +01:00
Lukas Tönne fc60f30b4f Merge branch 'main' into volume-grid-sockets 2023-12-13 10:14:45 +01:00
Lukas Tönne 6c8211baf2 Fix for USD volume bounds calculation, have to load the grid first.
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
This pattern is not at all ideal but currently common: Any code that
wants to access grid data has to call BKE_volume_grid_load first to
ensure that the potential grid placeholder gets the full tree data.

Like in other places (Cycles, viewport drawing) the code first checks
if the volume grid is a placeholder, and in that case unloads the grid
again after getting the bounds.

Eventually grids should automatically be loaded when accessing the
internal OpenVDB grid data. This would remove the need for
BKE_volume_grid_load, but it does not cover the case of automatic
unloading after use. Some transient struct that unloads a placeholder
grid after going out of scope might handle this.
2023-12-12 17:26:51 +01:00
Lukas Tönne 2f2a784fbd Fix cycles test: Replace the grid when unloading instead of new tree.
Cycles "steals" the OpenVDB grid from the VolumeGrid when constructing
the scene and then unloads the grid again. This unloading was replacing
the tree pointer inside the grid, breaking cycles volume rendering.

Do what the old cache did and replace the entire OpenVDB grid in case
some code holds a reference to the pointer. This is not great but it
keeps things working.
2023-12-12 16:40:08 +01:00
Lukas Tönne 6d7effb088 Unnamed grids are valid, ignore grid names in file cache keys.
This is to fix the blendfile_versioning test which loads a vdb file
with an unnamed grid.
2023-12-12 16:17:02 +01:00
Lukas Tönne 7d84a84d2f Merge branch 'main' into volume-grid-sockets 2023-12-12 13:54:46 +01:00
Lukas Tönne 869cf6bb30 Reimplemented the file cache for volume grids.
The file cache stores VolumeGrid implicit sharing data now. It uses
a combination of file path, grid name, and the simplification leve as
the key. That way simplified grids can be handled as cached data without
complicated internal refcounting. Generated grids will not have cached
simplification, but that is expected and in line with other caching
systems in Blender.

The `is_loaded` flag has been replaced with a more explicit enum
`VolumeTreeSource` to make more transparent decisions about what should
happen to grids on load/unload, simplification, copy, etc.
2023-12-12 12:57:28 +01:00
Lukas Tönne e834b3498a Merge branch 'main' into volume-grid-sockets 2023-12-12 09:28:48 +01:00
Lukas Tönne 0c788585ca Return grid pointer directly when extracting grid inputs.
The `as_grid` function will construct an empty grid if none is present.
That is not usually what we want when extracting an input, since a
nullptr grid is a valid pointer and can be used as the default input.

For example, using a mask grid can be optional, and the input should be
a nullptr when no mask is used. With the as_grid method the result would
always be a (empty) grid rather than nullptr.
2023-12-11 10:36:10 +01:00
Lukas Tönne 7af2717b1c Remove potential grid copy in VolumeGridPtr accessors.
The `grid`/`grid_for_write` getters are shortcuts to the internal
VolumeGrid data. They are useful because VolumeGrid is always un-typed,
so getting a typed openvdb::Grid from volume grid requires a second cast
to the type already known by VolumeGridPtr<T>. But the grid accessors
should work the same ways as accessing the openvdb::Grid from VolumeGrid
and leave copy-on-write to higher level methods.

VolumeGridPtr might be better off untyped, with typed grid accessors
inside VolumeGrid. But that is for a later change.
2023-12-11 10:36:10 +01:00
Lukas Tönne d1ea5b7164 Merge branch 'main' into volume-grid-sockets 2023-12-11 09:52:35 +01:00
Lukas Tönne ace3f99d02 Merge branch 'main' into volume-grid-sockets 2023-12-09 11:24:26 +01:00
Lukas Tönne 868bc66fd6 Cleanup: formatting. 2023-12-07 10:07:19 +01:00
Lukas Tönne 870c11fa58 Default return value if the "apply" operator returns a value. 2023-12-07 10:06:00 +01:00
Lukas Tönne 6818919bb2 Change friend class declaration to struct. 2023-12-07 10:05:26 +01:00
Lukas Tönne 348a469b88 grid_for_write accessor in VolumeGridPtr can be const. 2023-12-07 10:04:56 +01:00
Lukas Tönne ad248cea56 Merge branch 'main' into volume-grid-sockets 2023-12-07 09:54:17 +01:00
Lukas Tönne 1b311a30a3 Added some basic unit tests for volumes and pointer behavior. 2023-12-05 13:56:14 +01:00
Lukas Tönne 3d5b151366 Increment user count in cast constructor instead of `typed()` method.
The constructor also becomes private since it shouldn't be called
outside of the downcast function.
2023-12-05 13:55:13 +01:00
Lukas Tönne 163bab64c0 Merge branch 'main' into volume-grid-sockets 2023-12-05 10:07:27 +01:00
Lukas Tönne 5ee032a2f7 Sanity check in drawing code trying to access optional volume bounds. 2023-12-05 10:05:30 +01:00
Lukas Tönne 0ce7d5dc18 Fix VolumeGrid copy function: make an actual deep grid copy. 2023-12-05 10:04:20 +01:00
Lukas Tönne 0bc33f3f88 Fix Store Named Grid node with mutable VolumeGrid.
Volume API now has a "move" function for inserting an existing
VolumeGrid into the Volume. Store Named Grid node now creates a correct
mutable grid to store.
2023-12-05 10:04:20 +01:00
Lukas Tönne 1068df47e9 Add back missing destructor for VolumeGridPtrCommon. 2023-12-05 10:04:20 +01:00
Lukas Tönne 4ea0196b6f Remove unnecessary check after BKE_volume_grid_get_for_write.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-12-04 17:23:37 +01:00
Lukas Tönne b802677898 Make sure volume grid API functions create mutable data copies when needed. 2023-12-04 17:17:57 +01:00
Lukas Tönne 16edee566a Comment explaining the user count of the openvdb shared_ptr. 2023-12-04 16:31:33 +01:00
Lukas Tönne b7e781d133 Don't try to increment user count when the pointer is null. 2023-12-04 15:33:45 +01:00
Lukas Tönne 2b62f77202 Set output values before removing grid from volume. 2023-12-04 15:30:54 +01:00
Lukas Tönne 6a4b095f33 Removed the unused make_implicit_sharing_ptr utility function. 2023-12-04 15:26:17 +01:00
Lukas Tönne 6caba1d201 Call tag_ensured_mutable after checking for mutable grid data. 2023-12-04 15:08:47 +01:00
Lukas Tönne 898cf929d4 Use `void` instead of a generic MaskTree to indicate that string attributes are unsupported. 2023-12-04 15:05:59 +01:00
Lukas Tönne a10bdafb71 Updated description. 2023-12-04 14:58:44 +01:00
Lukas Tönne 22875e3b05 Remove virtual destructor for VolumeGridPtrCommon. 2023-12-04 14:54:50 +01:00
Lukas Tönne bad819c4d6 Mention concrete subclasses of VolumeGridPtrCommon. 2023-12-04 14:50:26 +01:00
Lukas Tönne df0a15212b Remove copy constructor from non-copyable VolumeGrid. 2023-12-04 14:42:05 +01:00
Lukas Tönne 1e83478304 Use a single Converter template with two methods instead of separate converters. 2023-12-04 14:36:11 +01:00
Lukas Tönne d4315578c2 Move some internal includes to the source file. 2023-12-04 14:24:00 +01:00
Lukas Tönne 37eac000e6 Cleanup: formatting. 2023-12-04 12:39:08 +01:00
Lukas Tönne b3666bea3a Merge branch 'main' into volume-grid-sockets 2023-12-04 12:38:32 +01:00
Lukas Tönne bc591770c4 Hide values on grid input sockets. 2023-12-04 12:36:17 +01:00
Lukas Tönne 64fca45ab7 Ensure all outputs are written in the grid store node. 2023-12-04 12:29:48 +01:00
Lukas Tönne 365e7eea6c Return the default value if grid sockets are used as values. 2023-12-04 12:21:19 +01:00
Lukas Tönne 56eb0045c7 Fix refcount when creating a typed copy of a grid pointer. 2023-12-04 12:09:20 +01:00
Lukas Tönne 821d98d0f1 Added a dedicated constructor function for making volume grid pointers. 2023-12-04 11:12:52 +01:00
Lukas Tönne 3d2f8001a3 Partial: revert volume API changes and return plain VolumeGrid pointers. 2023-12-03 13:22:33 +01:00
Lukas Tönne 0a1cc3fb5d Fix outputs when getting grid from volume is not found. 2023-12-03 10:11:19 +01:00
Lukas Tönne f1566e278b Handle empty volume bounds return value in drawing code. 2023-12-03 09:52:01 +01:00
Lukas Tönne 88f30df8b6 Fixed empty grid constructor. 2023-12-03 09:30:59 +01:00
Lukas Tönne e46a918533 Partial: Make ImplicitSharingPtr a base class of the volume gri pointers. 2023-12-01 15:45:26 +01:00
Lukas Tönne 5c4e58d5a2 Fixed build issues due to ImplicitSharingPtr always storing const data now. 2023-12-01 14:57:50 +01:00
Lukas Tönne 2f98d49922 Merge branch 'main' into volume-grid-sockets 2023-12-01 12:19:09 +01:00
Lukas Tönne 0336ed9273 Fixed copy-on-write grids in dilate/erode nodes.
If the grid type is correct, `grid_for_write` should always return a
valid grid. Also have to make sure to output the new grid pointer
instead of just copying the existing input.
2023-12-01 12:16:47 +01:00
Lukas Tönne 9a0aa23729 Update description of sample grid node. 2023-12-01 11:53:58 +01:00
Lukas Tönne d180cf731a Renamed BKE_volume_types.hh to BKE_volume_enums.hh. 2023-12-01 11:52:35 +01:00
Lukas Tönne 221b4abc88 Return a std::optional value for the grid background. 2023-12-01 11:48:26 +01:00
Lukas Tönne c2e55e2950 Simplified converter templates for grid values. 2023-12-01 11:39:11 +01:00
Lukas Tönne c9a99c2602 Merge branch 'main' into volume-grid-sockets 2023-12-01 10:21:49 +01:00
Lukas Tönne d70ad119a0 Merge branch 'main' into volume-grid-sockets 2023-11-30 12:09:10 +01:00
Lukas Tönne ff9030b7f0 Merge branch 'main' into volume-grid-sockets 2023-11-30 08:21:13 +01:00
Lukas Tönne a1c879a0c8 Fix mismatching storage type in the Sample Grid node. 2023-11-29 21:57:56 +01:00
Lukas Tönne c0f112a70a Merge branch 'main' into volume-grid-sockets 2023-11-29 16:40:45 +01:00
Lukas Tönne 6de20875f9 Added some asserts to VolumeGridPtr constructors. 2023-11-29 16:17:57 +01:00
Lukas Tönne 5be0a53c86 Fixed build errors with USD enabled. 2023-11-29 14:35:02 +01:00
Lukas Tönne ab047c04d4 Hide new nodes behind the experimental flag for now. 2023-11-29 12:37:21 +01:00
Lukas Tönne 6a2919c91e Merge branch 'main' into volume-grid-sockets 2023-11-29 12:16:11 +01:00
Lukas Tönne 4fb9c33074 New sampling node that works directly with grids instead of volumes. 2023-11-29 12:01:23 +01:00
Lukas Tönne 48391544b8 More utility functions for handling grid sockets. 2023-11-28 10:35:48 +01:00
Lukas Tönne a1424cc7c2 Sanity check when trying to store named grids. 2023-11-27 19:39:59 +01:00
Lukas Tönne 6fc068802e Sanity check for bounding box when creating texspace for volumes. 2023-11-27 18:25:26 +01:00
Lukas Tönne 080fe7f997 Merge branch 'main' into volume-grid-sockets 2023-11-27 15:54:08 +01:00
Lukas Tönne 7d9783c727 Make the "local" grid protected to enforce cached access. 2023-11-27 13:08:57 +01:00
Lukas Tönne a968855a28 Fix circular header include for VolumeGrid. 2023-11-27 12:31:59 +01:00
Lukas Tönne f34032ca03 Link TBB and OpenVDB against makesrna. 2023-11-27 11:50:41 +01:00
Lukas Tönne c0164c1d44 Removed redundant WITH_OPENVDB section from makesrna cmake file. 2023-11-27 11:21:38 +01:00
Lukas Tönne e345cd77ce Merge branch 'main' into volume-grid-sockets 2023-11-27 10:23:52 +01:00
Lukas Tönne 5e5c990582 Fix linking issues in makesrna caused by missing TBB linking. 2023-11-26 11:46:44 +01:00
Lukas Tönne f75280098b Merge branch 'main' into volume-grid-sockets 2023-11-26 09:29:05 +01:00
Lukas Tönne 81f57efdc2 Build fixes for Volume API changes. 2023-11-25 17:15:01 +01:00
Lukas Tönne c0421fced0 Temp: Return shared ptrs from volume API to avoid unintentional copies. 2023-11-24 18:03:28 +01:00
Lukas Tönne 4b67f5edfc Merge branch 'main' into volume-grid-sockets 2023-11-24 16:14:09 +01:00
Lukas Tönne 189dfd9669 Cleanup: renamed leftover instances of VolumeGridSharedData. 2023-11-24 16:10:51 +01:00
Lukas Tönne 1f5526b6b4 Renamed structs to VolumeGrid, VolumeGridPtr, GVolumeGridPtr. 2023-11-24 16:01:10 +01:00
Lukas Tönne 1127ac2e61 Restructured volume grid data types to separate shared data and pointers.
The VolumeGrid class will become the primary ImplicitSharingData, while
the VolumeGridPtr<T> and GVolumeGridPtr are ImplicitSharingPtrs.
Casing only happens on the pointer side, otherwise the casting would
create a deep copy of the data each time.
2023-11-24 15:37:31 +01:00
Lukas Tönne d123afbd31 Revert "Store ImplicitSharingPtr to grids in VolumeGridVector."
This reverts commit b5741095cb.

VolumeGridVector now stores plain GVolumeGrid instances again instead of
ImplicitSharingPtr. The shared pointers will get moved inside the
VolumeGrid struct, so that they can be casted as lightweight wrappers
without having to do deep copies of the data.
2023-11-23 17:24:49 +01:00
Lukas Tönne d5a98e0079 Another wrapper type around openvdb grid pointers.
The type structure for VolumeGrid needs to change: Casting from a
generic GVolumeGrid to a typed VolumeGrid<T> and vice versa would mean
constructing a new instance, which means deep copies of data because the
VolumeGrid is not just a reference but the ImplicitSharingData itself.

To fix this the structure should be:
1. `SharedGrid<GridType>`: A wrapper around some openvdb::Grid (can be
    GridBase).
2. `VolumeGrid<T>`/`GVolumeGrid`: Stores a `ImplicitSharingPtr` to a
    `SharedGrid`.
3. `VolumeGridVector` goes back to storing the `VolumeGrid` themselves,
    no need for another indirection here.
2023-11-23 17:02:30 +01:00
Lukas Tönne cd9f6363ab Renamed the FieldValueGrid and related types to VolumeGrid etc. 2023-11-23 16:11:43 +01:00
Lukas Tönne b2c9503996 Rename VolumeGrid type alias to GVolumeGrid.
This is to avoid name conflicts once the FieldValueGrid gets renamed.
2023-11-23 15:57:53 +01:00
Lukas Tönne da5f3b725b Make FieldValueGrid based on VolumeGridCommon. 2023-11-23 15:51:07 +01:00
Lukas Tönne 3b3cc31141 Fix unexpected data destruction by making constructor explicit.
The ImplicitSharingPtr had an implicit constructor for raw pointers.
This had unintended effects when comparing an ImplicitSharingPtr to a
raw pointer: The raw pointer was implicitly converted to the shared
pointer (without change in refcount) and when going out of scope would
decrement user count, eventually freeing the data.

Conversion from raw pointer to shared pointer should not happen
implicitly. The constructor is made explicit now. This requires a little
more boilerplate when constructing a sharing pointer. A special
constructor for the nullptr is added so comparison with nullptr can
still happen without writing out a constructor.
2023-11-23 14:55:43 +01:00
Lukas Tönne b5741095cb Store ImplicitSharingPtr to grids in VolumeGridVector.
Implicit sharing means that grids should not be allocated and freed
by the grid vector, otherwise they will not get deallocated properly.
2023-11-23 12:38:00 +01:00
Lukas Tönne 0858c6992b Make VolumeGridCommon an ImplicitSharingMixing class.
This currently breaks storage of grids in Volume, because the std::list
will allocate and decallocate grids, which does not respect the user
count of implicit sharing. Have to change the container to use pointers.
2023-11-23 11:27:36 +01:00
Lukas Tönne cc8a86ac8c Move file cache properties of VolumeGrid into a common base class. 2023-11-23 11:10:49 +01:00
Lukas Tönne cb88e6c113 Added dummy struct in RNA to act as a placeholder for GVolumeGrid.
DummyVolumeGrid is used as a stand-in for the actual VolumeGrid struct.
RNA callback wrappers around `rna_VolumeGrid_load` and
`rna_VolumeGrid_unload` need a C struct as the main "self" argument.
The struct does not have to be an actual DNA struct.
- VolumeGrid is a type alias ("using") that cannot be used directly for
  this purpose.
- blender::bke::GVolumeGrid is the actual struct but C++ namespaces also
  don't work.
This dummy struct is used as a placeholder for the callbacks and
reinterpreted as the actual VolumeGrid type.
2023-11-23 09:59:50 +01:00
Lukas Tönne 2f35ca5a91 Temp: Move VolumeGrid into bke namespace.
VolumeGrid -> blender::bke::GVolumeGrid

A type alias is added to existing volume code outside of bke working
with the existing type name. Unfortunately this does not work for RNA
where a plain C struct in the global namespace is needed.
2023-11-22 18:06:02 +01:00
Lukas Tönne cd5a15d5c1 Revert "Renamed VolumeGrid to GVolumeGrid as a generic grid wrapper."
This reverts commit 021121382b.
2023-11-22 17:38:41 +01:00
Lukas Tönne 021121382b Renamed VolumeGrid to GVolumeGrid as a generic grid wrapper.
VolumeGrid<T> will be a template for typed grid wrappers.
2023-11-22 17:35:22 +01:00
Lukas Tönne bca4dffe22 Cleanup: Moved VolumeGrid into BKE_volume_grid.hh.
The BKE_grid_types header becomes BKE_volume_grid. The VolumeGrid struct
will be the main wrapper around openvdb::Grid. GVolumeGrid will be a
generic base class and VolumeGrid<T> the type variants.
2023-11-22 17:23:41 +01:00
Lukas Tönne 68e5c1257d Cleanup: Move FieldValueTreeImpl into the detail namespace. 2023-11-22 16:01:18 +01:00
Lukas Tönne 02016f813e Cleanup: Removed unused static dispatch utility function. 2023-11-22 15:55:51 +01:00
Lukas Tönne a19915b67b Cleanup: Single namespace statement. 2023-11-22 15:51:29 +01:00
Lukas Tönne c1f100c58e Cleanup: moved OpenVDB forward declarations to a dedicated file. 2023-11-22 15:46:30 +01:00
Lukas Tönne 8cc6f785b5 Sanity check before accessing internal grid pointer. 2023-11-22 14:19:29 +01:00
Lukas Tönne 9f45d22858 Use implicit sharing to create deep copies of grids when needed.
This allows branching from a node socket to multiple inputs.
2023-11-22 13:57:48 +01:00
Lukas Tönne af34235642 Merge branch 'main' into volume-grid-sockets 2023-11-22 10:45:02 +01:00
Lukas Tönne 8e1988c91b Added dilate and erode nodes. 2023-11-21 17:47:36 +01:00
Lukas Tönne 6026941ab4 Merge branch 'main' into volume-grid-sockets 2023-11-21 16:16:10 +01:00
Lukas Tönne 91f0b8e20f Support storing grids in empty volumes. 2023-11-21 15:52:35 +01:00
Lukas Tönne a484bcd99d Implementation of Store Grid node. 2023-11-21 14:46:53 +01:00
Lukas Tönne 625590a08c Implemented the "remove" feature when getting a grid from a volume. 2023-11-21 13:37:32 +01:00
Lukas Tönne e0b324c959 Fix linker errors due to missing FieldValueGrid CPPType definition.
This shouldn't be necessary.
2023-11-21 13:08:53 +01:00
Lukas Tönne c837056e45 Constructor fix for ValueOrField. 2023-11-21 12:46:55 +01:00
Lukas Tönne 8c9ad29d46 Use ImplicitSharingPtr for the field value grid. 2023-11-21 12:33:07 +01:00
Lukas Tönne c404eadd44 Merge branch 'main' into volume-grid-sockets 2023-11-21 10:41:54 +01:00
Lukas Tönne 71375eec57 Fixed user count cleanup when releasing the FieldValueGrid. 2023-11-21 10:30:28 +01:00
Lukas Tönne b73a2aaf96 Temp: clear user count of the grid pointer when releasing ValueOrField. 2023-11-21 09:57:04 +01:00
Lukas Tönne dfd006e92f Implementation of "get grid" node that writes to ValueOrField. 2023-11-20 18:13:38 +01:00
Lukas Tönne 18b72fd4f3 Grid wrapper class that works as ImplicitSharindMixin. 2023-11-20 16:31:27 +01:00
Lukas Tönne 7f78bdfbd0 Use grid background value as the field value. 2023-11-20 13:59:00 +01:00
Lukas Tönne e9d78c65b0 Added a Grid pointer to the ValueOrField struct.
This will be used for grid sockets to pass grid data at runtime.
The GridType is a forward-declared OpenVDB grid class, with a template
parameter that matches Blender math types and gets swapped with a
matching OpenVDB type for the actual grid.
2023-11-20 11:37:07 +01:00
Lukas Tönne 4cec91d7d2 Merge branch 'main' into volume-grid-sockets 2023-11-20 10:29:09 +01:00
Lukas Tönne 869bfe44fe Merge branch 'main' into volume-grid-sockets 2023-11-18 16:28:46 +01:00
Lukas Tönne 999b08ca3a Move ValueOrField into BKE.
This struct is used for geometry nodes sockets only and only used by
the geometry nodes module (with an indirect dependency via simulation
zone baking). It currently lives in the functions namespace, which is
problematic when adding grids in future, which should not be part of
the functions module.
2023-11-18 10:53:35 +01:00
Lukas Tönne 7c87888c4a Use regular float/vector/etc. sockets to represent grids.
The socket value will be extended from ValueOrField to
"ValueOrFieldOrGrid" (with a nicer name). The data type is the same,
and the socket shape will be updated later when inferencing supports
grid data.
2023-11-17 14:51:56 +01:00
Lukas Tönne 12bd80f507 Stub nodes for testing new grid socket. 2023-11-17 13:58:23 +01:00
Lukas Tönne 5ef682bf67 Restructured Volume node menu like other geometry menus. 2023-11-17 13:02:50 +01:00
Lukas Tönne 5bed953f85 Utility BKE header for forward-declaring OpenVDB grid types. 2023-11-17 13:02:12 +01:00