WIP: Testing realtime clock branch in combination with simulation nodes #106309

Draft
Lukas Tönne wants to merge 195 commits from LukasTonne/blender:geometry-nodes-simulation-realtime-clock into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

No response

_No response_
Lukas Tönne added 152 commits 2023-03-30 14:48:28 +02:00
"Delta Time" was set instead of "Elapsed Time" output.
It's the output node that decides whether to requiest the values
from the nodes inside the simulation, so it makes more sense
for it to be there. This is part of a general effort to have less
redundancy in the options.
This is a temporary option anyway, the caches will be controlled in a
more unified place at the object or scene level. But for now the name
can be a bit better anyway.
Just allows multiple simulation "frames"/regions/contexts to be drawn
in the editor, doesn't include any changes to caching yet.
Until we can add both nodes at the same time, or we find
an improve simulation to link the two nodes
The caches now hash the identifier of the output node as well.
- Cache is accessed with a string identifier, allowing multiple sockets in the future
- Cache is meant to be stored in a simple array, not sparsely like before
- Persistent cache and temporary "last run" cache are separated more clearly
- Use a "Time Point" class instead of integers, to maybe clarify adding subframe support in the future
- Use a different "sim" namespace (not sure if that will last)
- The value from the last frame is moved, to avoid a copy when no persistent cache is used

I don't think this works now, at least I haven't tested it.
Edge cases not really tested still though
Since this is theoretically redundant with simulating a float
with the delta time value, we decided to remove it for now to
make the whole interface simpler.
I will keep it internally, but for the simulation MVP we want to focus
on the most basic "last frame's cache" features at first.
These aren't theoretically necessary, since you can just created them
as regular outputs. Maybe we will eventually add them back for
convenience, but that's not clear.
Note: Still unstable. Simulation resets when playback stops bug.

Since the "Run" behavior can basically be implemented with the switch
node already, it's just adding unnecessary complexity to the interface
now, when it's use case isn't clear. We decided to remove it for now,
and only consider it later as a possible convenience feature, rather
than an essential part of the design.

Also, the simulation nodes are now considered "side effect nodes"
for the evaluator, meaning they are *always* evaluated, even if they
aren't needed because of switch nodes, etc. This was the best way
we thought of to make simulations run consistently even through
situations like that.
Output time in seconds rather than frame units
After switching over to using start_frame / end_frame, scaling an NLA strip didn't scale the strip, it just repeated the action.

Now withing the NLA transform code, we look for TFM_TIME_EXTEND / TFM_TIME_SCALE transform mode, and handle the update to strip scale accordingly
This was missing some paths setup in the environment, ctest
normally sets this up before running the tests from the CLI
but that does not help the IDE all that much.
The function was highly related to the apply modifier operator,
and only used once. This was too specific to be in the blenkernel,
especially in a mesh conversion file.
Use C++ casts, decrease variable scope, use references, use const.
This patch was already accepted upstream, so this is temporary until we update
to a new OpenVDB release that includes it.
Differential Revision: https://developer.blender.org/D16784
This patch allows skipping the automatic insertion of nodes on top of
links when the transform operator ends. When putting nodes into small
spaces this often gets in the way and wastes time. Now, when holding
`alt`, this is turned off.

The header text is also improved to add this shortcut and to remove
the Dx and Dy values and improve the formatting a bit.

Making this functionality optional might allow us to use it in more
places in the future, like for the nodes added by link-drag-search.

Differential Revision: https://developer.blender.org/D16230
If the resulting geometry from applying a geometry nodes modifier
contains no mesh, give an error message. This gives people something to
search and makes the behavior more purposeful.

Also remove the `modifyMesh` implementation from the geometry nodes
modifier, since it isn't necessary anymore. And remove the existing
"Modifier returned error, skipping apply" message which was cryptic
and redundant if applying returns an actual error message.

Resolves T103229

Differential Revision: https://developer.blender.org/D16782
Attributes are unifying around a name-based API, and we would like to
be able to move away from CustomData in the future. This patch moves
the identification of active and fallback (render) color attributes
to strings on the mesh from flags on CustomDataLayer. This also
removes some ugliness used to retrieve these attributes and maintain
the active status.

The design is described more here: T98366

The patch keeps forward compatibility working until 4.0 with
the same method as the mesh struct of array refactors (T95965).

The strings are allowed to not correspond to an attribute, to allow
setting the active/default attribute independently of actually filling
its data. When applying a modifier, if the strings don't match an
attribute, they will be removed.

The realize instances / join node and join operator take the names from
the first / active input mesh. While other heuristics may be helpful
(and could be a future improvement), just using the first is simple
and predictable.

Differential Revision: https://developer.blender.org/D15169
The logic here is not ideal but was unintentionally changed in refactoring
for path guiding, now restore it back to 3.3 behavior again.
Replace ../lib/linux_centos7_x86_64 with ../lib/linux_x86_64_glibc_228,
built with Rocky8 Linux, compatible with the VFX platform CY2023,
see: T99618.

- Update build-bot configuration.
- Remove unnecessary check for Blosc, this is part of OpenVDB lib now.
- Remove WITH_CXX11_ABI, always use new C++11 ABI now
- Replace centos7 by glibc_228 everywhere

Note that existing builds with cached paths pointing to
"../lib/linux_centos7_x86_64" will need to be updated.

Includes contributions by Brecht.
Upon conversion, the newly-created UV map with default name "UVMap"
should be translated.

Reviewed By: mont29

Maniphest Tasks: T103183

Differential Revision: https://developer.blender.org/D16775
Revert [0] and enable the editable flag as the intent for [1] was that
these values would be editable.

[0]: e58f5422c3
[1]: 6514bb05ea
When migrating to the new packing API, pin_unselected was not
implemented correctly.

Regression from rB143e74c0b8eb, rBe3075f3cf7ce, rB0ce18561bc82.

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

Reviewed By: Campbell Barton

Duplicated in blender-v3.4-release as rB3dcd9992676a
Small roundoff errors during UV editing can sometimes occur, most likely
due to so-called "catastrophic cancellation".

Here we set a tolerance around zero when using Constrain-To-Bounds and UV Scaling.

The tolerance is set at one quarter of a texel, on a 65536 x 65536 texture.

TODO: If this fix holds, we should formalize the tolerance into the UV editing
subsystem, perhaps as a helper function, and investigate where else it needs
to be applied.

Differential Revision: https://developer.blender.org/D16702
For some reason SNDFILE now builds without this workaround,
which broke building FFMPEG.
The paint cursor was continuously set which meant hiding the cursor
while interacting with buttons would immediately show it again.

This exposed cursor warping.
Recent reverting of changes to cursor grabbing intended to match
Blender 3.3 release. This is the case for 3.4x branch, however there is
an additional change to grabbing on WIN32 by Germano [0] which is a
significant improvement on old grabbing logic for Windows.
So instead of matching 3.3x behavior, restore logic that keeps
the cursor centered while grabbing & hidden.

This re-introduces T102792 issue displaying the paint-brush while
dragging buttons, this will have to be solved separately.

Re-apply [1] & [2], revert [3] & [4].

[4]: a3a9459050
[0]: 9fd6dae793
[1]: 4cac8025f0
[2]: 230744d6fd
[3]: 0240b89599
Restrict the condition under which paint cursors read use the cursor
location from the the operating-system.

This caused a glitch when dragging UI elements in painting context
popup. Since the paint cursor would display using mouse motion
which was clamped to the window center - an internal detail of hidden
cursor grabbing.

Now only read the cursor coordinates when clamped to a region which
is used for the transform cursor to stay visible even when the cursor
wraps around.
* Dim default input values.
* Print default input values instead of type name.
* Add node/socket names to group input/output nodes.
When the centos7 library dir is found, warn when the values of cached
variables reference it, listing the variables and their values.
Even when building without OpenImageIO and OpenVDB, USD depends on these
libraries.

Ensure these libraries are copied when building with USD.
Switching viewport denoising causes kernels to be reloaded with a new
feature mask, which would destroy the existing OptiX pipelines. But OSL
kernels were not reloaded as well, leaving the shading pipeline
uninitialized and therefore causing an error when it is later attempted to
execute it. This fixes that by ensuring OSL kernels are always reloaded
when the normal kernels are too.
Materials without connections to the output node would crash with OSL
in OptiX, since the Cycles `OSLCompiler` generates an empty shader
group reference for them, which resulted in the OptiX device
implementation setting an empty SBT entry for the corresponding direct
callables, which then crashed when calling those direct callables was
attempted in `osl_eval_nodes`. This fixes that by setting the SBT entries
for empty shader groups to a dummy direct callable that does nothing.
Expands Color Mix nodes with new Exclusion mode.

Similar to Difference but produces less contrast.

Requested by Pierre Schiller @3D_director and
@OmarSquircleArt on twitter.

Differential Revision: https://developer.blender.org/D16543
6514bb05ea missed a null check when accessing the active
and default color attribute names, since the CustomData API does not
do that check itself.
This code was duplicated from `pbvh_uv_islands.hh`,
which was the version that was actually used.
Avoid utility function call that would query the file system, this was a
bottleneck. The path joining was also problematic. See patch for more
details.

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

Reviewed by: Jacques Lucke
Patch from @dupoxy

Differential Revision: https://developer.blender.org/D16796
Previously, the code tried to keep node groups working even if some of
their input/output sockets had undefined type. This caused some
complexity with no benefit because not all places outside of this file
would handle the case correctly. Now node groups with undefined
interface sockets are disabled and have to be fixed manually before
they work again.

Undefined interface sockets are mostly caused by invalid Python
API usage and incomplete forward compatibility (e.g. when newer
versions introduce new socket types that the older version does
not know).
Links that are currently being dragged are now stored outside
of the node tree, so we don't need a flag to distinguish them
from "proper" links.
Clarify that the dragged links aren't stored in the tree, use a
separate function for cancelling vs. applying the links to the tree.
This reverts commit 468f43c7a6.

Revert "Add initial dynamic declarations"

This reverts commit 50a2c77c4e.

Revert "Add initial simulation state items array to output node"

This reverts commit 3f1027567d.
Fixes after merge
Some checks failed
buildbot/vexp-code-experimental-coordinator Build done.
6f56fee3bb
Merge branch 'main' into geometry-nodes-simulation
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
9241ab1d7c
Merge branch 'main' into geometry-nodes-simulation
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
b2e508f7af
- Use dynamic declarations to build simulation node sockets
- Fixes in some node code for futher use of dynamic declarations
- Copying, freeing, reading, and writing of simulation state array
- Add simulation state items with link drag operator

The new sockets won't do anything yet, only geometry sockets are
supported, and there is no way to remove sockets yet.
Support for multiple sockets will be slightly more complete now too,
but that part hasn't been tested.
Multiple clocks can run at the same time, using the same animtimer.
The `active_clock` flags show which clocks are running. If any clock
is running (`active_clock != 0`) the `animtimer` must also exist.
Since the timer is now shared, the existence of the pointer alone is not enough
to determine if animation playback is running. The screen flag (or better:
the ED_screen_animation_is_playing function) should be used for such checks.
Running clocks are identified by the `active_clock` flags now,
the `animtimer` pointer is not sufficient any longer to determine if
animation playback is running.
If separate operators are used they will have to return pass-through and,
more importantly, we won't be easily able to ensure a single depsgraph
update.
The bool return value of the ED_ functions got converted to 1, which
is the operator return value for modal operators.
The original `BKE_scene_graph_update_for_newframe` function sets the scene frame
and only tags the scene time source. The new function supports all clock types
while still ensuring only one actual depsgraph evaluation.

It would be nicer if this could be split such that the update passes are more
agnostic towards the specific clock types. The current update pass loop is
quite complicated and handles a lot of corner cases.
The most important part of this change is that the simulation
state at a specific point in time is more self contained now.
This way, only the modifier has to deal with finding the old/new
simulation states and not every simulation individually.

Furthermore, this also includes some simple cache invalidation
when the user changes something that might affect the result.
Simulation Nodes: indicate which frames are cached in timeline
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
d98988d872
This is necessary to have a reliable persistent frame value from which
simulations can compute a "delta time". The `realtime_clock.frame` value
in `Scene` is currently never reset, this should be supported eventually.
Multiple clocks exist now to give a "current time" value for computing
time steps and for checking if a simulation needs to be reset.
The `prev_simulation_state` is looked up before and needs to stay valid.
To make this work the cache now is pruned up to the last state, rather
than cleared entirely. It will contain at most 2 states at any time.
The `active_clock` flags need to be checked using bitwise operators,
not a switch statement, since both clocks can be running at the same time.
The value 0.0 counts a special "start frame" which causes the
simulation cache to be invalidated.
The depsgraph time source node for the realtime clock needs to be updated to
the current clock time before evaluation. This currently happens after operators
through the `ND_FRAME` notifier for the scene frame. The realtime clock needs its
own notfier so that operators can ensure the clock value is correct.

Without this update the simulation nodes see an old clock value and don't find a
"previous state" until the simulation is past that frame again. It will never
insert a new frame until that point and delta time will remain 0.0.
This is not a great solution yet, it relies on an explicit depsgraph update
to ensure that the modifier eval sees a frame 0.0 value.
Instead of relying on the depsgraph update and a "frame == 0" test,
the operator now explicitly invalidates all caches. This requires
looping over the scene, but as a one-off user operation that is
acceptable.

This reverts commit d95a33d6ac.
Disable cache invalidation on manual modifier changes.
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
2bf3c7cd41
This may be ok for scene playback, but it means the simulation is reset
entirely whenever any dependency is changed, for example moving an object
whose transform is used with an Object Info node.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added this to the Nodes & Physics project 2023-04-20 10:53:33 +02:00
Lukas Tönne force-pushed geometry-nodes-simulation-realtime-clock from ca669472f1 to 8cb5c172a3 2023-04-25 12:03:41 +02:00 Compare
This pull request has changes conflicting with the target branch.
  • release/datafiles/userdef/userdef_default_theme.c
  • scripts/startup/bl_operators/geometry_nodes.py
  • scripts/startup/bl_operators/node.py
  • scripts/startup/bl_ui/node_add_menu.py
  • scripts/startup/bl_ui/space_node.py
  • scripts/startup/bl_ui/space_view3d.py
  • source/blender/blenkernel/BKE_modifier.h
  • source/blender/blenkernel/BKE_node.h
  • source/blender/blenkernel/BKE_node_runtime.hh
  • source/blender/blenkernel/BKE_node_tree_zones.hh

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u geometry-nodes-simulation-realtime-clock:LukasTonne-geometry-nodes-simulation-realtime-clock
git checkout LukasTonne-geometry-nodes-simulation-realtime-clock
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#106309
No description provided.