Commit Graph

99281 Commits

Author SHA1 Message Date
Sietse Brouwer
a7d652e459 Fix Unreported: GPencil grab tool doesn't work on strokes changed by modifiers
The grab tool in Grease Pencil sculpt mode doesn't work correctly on strokes affected by modifiers.
You had to grab over the original vertex positions to see any effect.

Pull Request: https://projects.blender.org/blender/blender/pulls/106744
2023-05-03 21:48:19 +02:00
Hans Goudey
367145209c Cleanup: Move attribute_math to proper blenkernel namespace
The fact that blenlib doesn't know about the set of attribute types is
actually an important detail right now that can influence how things
are designed. Longer term it would be good to consolidate many of
these attribute propagation algorithms anyway.
2023-05-03 12:10:54 -04:00
Hans Goudey
d9a7f1285f Cleanup: Rename field input classes to match UI names 2023-05-03 12:10:54 -04:00
Hans Goudey
7f040099e3 Cleanup: Deduplicate sampling at index in geometry nodes
The "Evaluate at Index" and "Sample Index" nodes are exactly the same
once they retrieve the values to copy and the indices (apart from the
clamping option anyway). This also allows devirtualizing the index input
in the evaluate at index node like the sample index node.
2023-05-03 12:10:54 -04:00
Hans Goudey
09c1a93c21 Cleanup: Simplify CurvesGeometry deletion copying
Use span slicing instead of the POINTER_OFFSET macro
2023-05-03 12:10:54 -04:00
Hans Goudey
1f76863f80 BLI: Remove clamping from generic span slicing
Similar to a5e7657cee
2023-05-03 12:10:54 -04:00
Sergey Sharybin
42cdd39618 Fix return of stack memory
The fix is suggested by Jacques.

Pull Request: https://projects.blender.org/blender/blender/pulls/107586
2023-05-03 17:59:12 +02:00
Bastien Montagne
ac1ac6be9a Fix #107573: Purging orphan data deletes used data.
The logic in the initial commit (97dd107070) was broken in some cases,
and would end up tagging as unused IDs that had valid usages. It is
reverted by this commit..

For this new solution to #98029 (deleting unused archipelagos of data),
the logic handling dependency loops detection is reworked to rely on a
new tag in the relations entry of the relevant IDs, instead of
pre-tagging as unused the ID itself.

Further more, when a dependency loop is detected, the IDs in it cannot
be immediately tagged as unused, since it may be that the entry point
of that loop is later detected as actually used. So their relations
entries are not tagged as processed, and only the entry point of the
potential archipelago can be checked in that case, outside of the
recursive processing of dependencies.

The other IDs of the archipelago will then be processed again later, in
a state where at least one ID in the archipelago has a known state for
sure, which then allows for a safe evaluation of the other related data.

This commit should be backported to 3.3LTS.
2023-05-03 16:32:33 +02:00
Michael Kowalski
109c1b92cd Fix #105621: USD export: incorrect texture alpha mapping
Fixed bug where texture alpha was incorrectly remapped to red when exporting material shaders.

Now connecting the UsdPreviewSurface 'opacity' input to the UsdUVTexture 'a' output if the Blender texture image node source socket identifier is 'Alpha'.

Changes include the following:

The InputSpec::source_name struct member was removed, as the connection source name is now determined at runtime based on the Blender node input socket identifier.

The traverse_channel() utility function now returns a bNodeLink*, so that the source socket identifier can be queried from the link.

In create_usd_preview_surface_materia(), the code for creating and connecting a UsdUVTexture shader was reorganized to group it within one conditional block, to make it easier to follow.  Also replaced a call to a deprecated version of UsdShadeInput::ConnectToSource().

Pull Request: https://projects.blender.org/blender/blender/pulls/107022
2023-05-03 16:12:52 +02:00
Hans Goudey
7ff752b789 Cleanup: Unify mesh sampling multifunctions
Change the implementation of the raycast and sample nearest surface
node to split separate loops into separate multi-functions. This
clarifies the task of each function, gives more information to the
field evaluator, and gives more opportunity for memory reuse.

Sampling mesh attributes with triangle barycentric weights is now
implemented in a single place. Two other new multi-functions
handle conversion of sampled positions into barycentric weights.
Normalizing the ray directions for the raycast node is split out
too, so it can be skipped in some cases in the future.

The mesh attribute interpolator helper class is also removed,
since it didn't give much benefit over a more functional approach.

I didn't notice a performance improvement from this change.

Pull Request: https://projects.blender.org/blender/blender/pulls/107563
2023-05-03 15:07:16 +02:00
Hong Shin
743f57e95e Cleanup: Move draw_manager_profiling to C++
See: #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/107508
2023-05-03 14:30:58 +02:00
Hong Shin
642e18e889 Cleanup: Move node_util.h to C++
Ref: #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/107569
2023-05-03 14:21:14 +02:00
Jacques Lucke
0de54b84c6 Geometry Nodes: add simulation support
This adds support for building simulations with geometry nodes. A new
`Simulation Input` and `Simulation Output` node allow maintaining a
simulation state across multiple frames. Together these two nodes form
a `simulation zone` which contains all the nodes that update the simulation
state from one frame to the next.

A new simulation zone can be added via the menu
(`Simulation > Simulation Zone`) or with the node add search.

The simulation state contains a geometry by default. However, it is possible
to add multiple geometry sockets as well as other socket types. Currently,
field inputs are evaluated and stored for the preceding geometry socket in
the order that the sockets are shown. Simulation state items can be added
by linking one of the empty sockets to something else. In the sidebar, there
is a new panel that allows adding, removing and reordering these sockets.

The simulation nodes behave as follows:
* On the first frame, the inputs of the `Simulation Input` node are evaluated
  to initialize the simulation state. In later frames these sockets are not
  evaluated anymore. The `Delta Time` at the first frame is zero, but the
  simulation zone is still evaluated.
* On every next frame, the `Simulation Input` node outputs the simulation
  state of the previous frame. Nodes in the simulation zone can edit that
  data in arbitrary ways, also taking into account the `Delta Time`. The new
  simulation state has to be passed to the `Simulation Output` node where it
  is cached and forwarded.
* On a frame that is already cached or baked, the nodes in the simulation
  zone are not evaluated, because the `Simulation Output` node can return
  the previously cached data directly.

It is not allowed to connect sockets from inside the simulation zone to the
outside without going through the `Simulation Output` node. This is a necessary
restriction to make caching and sub-frame interpolation work. Links can go into
the simulation zone without problems though.

Anonymous attributes are not propagated by the simulation nodes unless they
are explicitly stored in the simulation state. This is unfortunate, but
currently there is no practical and reliable alternative. The core problem
is detecting which anonymous attributes will be required for the simulation
and afterwards. While we can detect this for the current evaluation, we can't
look into the future in time to see what data will be necessary. We intend to
make it easier to explicitly pass data through a simulation in the future,
even if the simulation is in a nested node group.

There is a new `Simulation Nodes` panel in the physics tab in the properties
editor. It allows baking all simulation zones on the selected objects. The
baking options are intentially kept at a minimum for this MVP. More features
for simulation baking as well as baking in general can be expected to be added
separately.

All baked data is stored on disk in a folder next to the .blend file. #106937
describes how baking is implemented in more detail. Volumes can not be baked
yet and materials are lost during baking for now. Packing the baked data into
the .blend file is not yet supported.

The timeline indicates which frames are currently cached, baked or cached but
invalidated by user-changes.

Simulation input and output nodes are internally linked together by their
`bNode.identifier` which stays the same even if the node name changes. They
are generally added and removed together. However, there are still cases where
"dangling" simulation nodes can be created currently. Those generally don't
cause harm, but would be nice to avoid this in more cases in the future.

Co-authored-by: Hans Goudey <h.goudey@me.com>
Co-authored-by: Lukas Tönne <lukas@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/104924
2023-05-03 13:18:59 +02:00
Thomas Dinges
8775cf804e Fix compilation on Windows after f30434ac99. 2023-05-03 11:55:24 +02:00
Jason Fielder
88ace032a6 Metal: Storage buffer and explicit bind location support
Adds support for Storage buffers, including changes to the resource
binding model to ensure explicit resource bind locations are supported
for all resource types.

Storage buffer support also includes required changes for shader
source generation and SSBO wrapper support for other resource
types such as GPUVertBuf, GPUIndexBuf and GPUUniformBuf.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/107175
2023-05-03 11:46:30 +02:00
Campbell Barton
bcedbdcf6f Cleanup: improve code-comments, naming, use defines, correct spelling 2023-05-03 17:34:27 +10:00
Campbell Barton
5f0a5c9b15 Cleanup: remove redundant path splitting in font loading
BLI_path_split_file_part ran for every filename comparison,
replace with BLI_path_basename and run once.

Also rename FaceDetails::name -> filename.
2023-05-03 17:23:19 +10:00
Campbell Barton
e5e17c5a81 Cleanup: rename "name" to "filepath"
Missed in recent cleanup.
2023-05-03 17:13:42 +10:00
Campbell Barton
7ec1456b43 Cleanup: remove BLI_path_abs call on ImBuf path when saving a sequence 2023-05-03 17:12:25 +10:00
Campbell Barton
d824030782 Fix blend file relative path being copied into ImBuf::filepath
ImBuf paths don't support blend file relative prefix,
make absolute after copying.
2023-05-03 16:54:30 +10:00
Campbell Barton
f9fbbd8f80 Cleanup: expand on code-comments
Rename layout_old to layout_ref as the layout is a reference
(the old layout has been freed).
Also use boolean for save_copy argument.
2023-05-03 16:31:37 +10:00
Campbell Barton
b690b8c16f Fix incorrect buffer size copying to StudioLight::filepath
Use STRNCPY macro so these don't get out of sync.
2023-05-03 16:26:42 +10:00
Campbell Barton
d770fd5ac4 Cleanup: remove unused BLI_dir_* functions
Loading a font in BLF would search a list of directory presets
however these presets were never used.
Remove them as all callers pass in full paths.

Also rename FontBLF::name to mem_name as it's only needed as an ID
for in-memory fonts (to prevent them being loaded multiple times).

Non-unique font loading now compares against the filepath or mem_name
when loading from files or memory (before both used `name` which was
often the filepath, sometimes the full ID-name).
2023-05-03 16:08:31 +10:00
Campbell Barton
6b9a500a3a Cleanup: disambiguate terms "name", "file" & "str" / "string"
- Rename name/filename/path to filepath when it's used for full paths.
- Rename name/path to dirpath when it refers to a directory.
- Rename file to filepath or path (when it may be a file or dir).
- Rename ImBuf::name & anim::name to filepath.
2023-05-03 15:26:14 +10:00
Campbell Barton
1f96fa1129 Cleanup: rename BLI_make_existing_file for clarity
Rename BLI_make_existing_file to BLI_file_ensure_parent_dir_exists.
The previous name read as if it would make (touch) the file,
where as it ensures the directory component of the path exists.

Move from BLI_path to BLI_fileops as path utilities should only
manipulate paths and not deal with file IO creation
(this has more in common with BLI_file_touch for e.g.).
2023-05-03 11:49:47 +10:00
Campbell Barton
bb341eaf12 BLI_path: use module prefix for BLI_filename_make_safe
Rename BLI_filename_make_safe -> BLI_path_make_safe_filename.
2023-05-03 11:48:52 +10:00
Campbell Barton
01aead42fc Cleanup: re-order split prefix/suffix return arguments last 2023-05-03 11:25:30 +10:00
Campbell Barton
947465c511 Cleanup: rename BLI_split_name_num, order return arguments last 2023-05-03 11:25:30 +10:00
Campbell Barton
f30434ac99 BLI_string_utils: BLI_uniquename no longer accepts NULL defname
A NULL defname would early exit (doing nothing) this isn't good behavior
as this function should always make the name unique and a NULL defname
is likely an error in the code which would allow duplicate names.
This is also inconsistent with BLI_uniquename_cb which always
wrote the defname into the name if it was empty.

Mark this argument as never-NULL.
2023-05-03 11:25:30 +10:00
Campbell Barton
4115fcbc38 Cleanup: update, add function attributes for BLI_string & BLI_path
Explicitly list ATTR_NONNULL indices in most cases so it's explicit
that arguments aren't NULL (and adding new arguments that can be NULL
isn't such a hassle).
2023-05-03 11:25:30 +10:00
Campbell Barton
381de3bd9e Cleanup: format 2023-05-03 11:25:30 +10:00
Hans Goudey
d5fc1b9ba4 Fix #107505: Temporary stack not cleared in BMesh normal calculation
Mistake in f8eebd3b25.
2023-05-02 17:24:00 -04:00
Hans Goudey
c2a2c2dcab Cleanup: Use array and span in weighted normal modifier 2023-05-02 17:08:14 -04:00
Hans Goudey
2e50e0a849 Fix #107514: Broken normals wtih weighted normal "keep sharp" option
The data indices for all loops in a fan weren't set, only the first.
2023-05-02 17:08:14 -04:00
Christoph Lendenfeld
f865e67593 Refactor: Replace move_key with BKE_fcurve_keyframe_move_value_with_handles
The helper function `move_key` did exactly the same things as `BKE_fcurve_keyframe_move_value_with_handles`
It was only created because I wasn't aware that such logic already existed
No functional changes

Pull Request: https://projects.blender.org/blender/blender/pulls/107402
2023-05-02 22:12:54 +02:00
Christoph Lendenfeld
dc0251df72 Fix: Graph Editor - add operator flags for cursor wrapping
The slider operators in the Graph Editor were missing operator flags for the cursor wrapping to work.
I've added it to the operators that allow overshoot, because for those it is really important to have no limits on scrolling.

Pull Request: https://projects.blender.org/blender/blender/pulls/107435
2023-05-02 21:38:57 +02:00
Hans Goudey
b3a3b94976 Cleanup: Avoid allocating extra array in sample nearest node
The distances array was filled but never used.
2023-05-02 15:07:52 -04:00
Harley Acheson
22245115fd Fix #107499: Text Object Selection with Scale To Fit Mode
Allow mouse text selection and cursor positioning to work correctly
when the text box has overflow mode set to "Scale to Fit."

Pull Request: https://projects.blender.org/blender/blender/pulls/107510
2023-05-02 19:32:47 +02:00
illua1
71e4f48180 Nodes: Improve link drag search value moving
Now, when link drag search is used to create new input value nodes, it
also moves socket values into node storage. This means, by design, that
result of evaluation on node tree will not be changed. For data blocks,
the original value is set to null, thus avoiding the existence of
unused pointers.

Right now a few nodes (in shader in many cases) are implemented without
node storage, but by storing value in socket itself. Float value input
node is unsupported in this way too.

Pull Request: https://projects.blender.org/blender/blender/pulls/107470
2023-05-02 18:50:34 +02:00
Philipp Oeser
dc73b63460 Fix: crash baking empty rigid body world
Found investigating #107420.

Steps to reproduce were:
- remove all objects from the scene
- add rigid body world
- bake
- crash

BKE_ptcache_bake would assume a cache can always be found, but with an
empty rigid body world this is not the case -- accessing flags would then
crash.

Now just check if we actually have a cache.

Pull Request: https://projects.blender.org/blender/blender/pulls/107537
2023-05-02 17:57:21 +02:00
Philipp Oeser
d0c6117196 Fix #107420: crash getting PTCacheID when baking scene rigid body world
`ptcache_baker_create` falsely assumed the PointCache owner id is always
an **object**, but when baking rigid body world it is a **scene**. Code
would cast the ID to an object and passed that to `BKE_ptcache_id_find` /
`BKE_ptcache_ids_from_object` (which can get terribly wrong -- reading
_something_ on the scene as something from the assumed object).

Prior to f61ff22967 this was less likely to be a problem, but that
commit introduced a `DrawDataList` into the `struct Scene`. In the file
from the report, this would lead to `foreach_object_particle_ptcache`
now recognizing garbage memory as a particle system, accessing its
`ParticleSettings` `phystype` would then crash (buffer-overflow).

Now pass a NULL object to `BKE_ptcache_id_find` in case we are having a
scene, following code still handles rigid bodies just fine (the scene is
actually passed separately as well).

Pull Request: https://projects.blender.org/blender/blender/pulls/107536
2023-05-02 17:56:17 +02:00
Omar Emara
88d03d15c1 Realtime Compositor: Implement Stabilize 2D node
This patch implements the Stabilize 2D node for the realtime compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/107401
2023-05-02 17:11:59 +02:00
Hong Shin
1a5ad33a57 Cleanup: Move pipeline.h to C++
Ref: #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/107516
2023-05-02 16:55:45 +02:00
Bastien Montagne
9954a5d07c Cleanup: Remove left-over debug prints in own previous commits.
Sorry for the noise.
2023-05-02 16:21:00 +02:00
Jeroen Bakker
96dcdbfc51 Vulkan: Correct Aspectbits for Depth Textures
Vulkan spec only wants to have a single aspect bit when a texture
contains both a stencil and a depth part. As for Blender depth
is more used than stencil we standardize to depth aspect.

Pull Request: https://projects.blender.org/blender/blender/pulls/107542
2023-05-02 16:20:25 +02:00
Bastien Montagne
5095ecc67b Cleanup: Rename LibOverride-related enum flags/tags.
Mainly use a shorter, straight-forward prefix (`LIBOVERRIDE`), and
unify/make these enum names more consistant. No functional changes
expected here.
2023-05-02 16:14:53 +02:00
Bastien Montagne
9ea2170cce LibOverride: Resync: Fix some issues with partial resync.
In some cases, some partial resync roots would be missed during the
partial resync process, leading to incomplete resync of all the needed
data.

This was caused by tagging some liboverrides for resync _after_ they had
already be evaluated as part of parenting hierarchy of other
liboverrides. Fix is simply to split both steps apart, such that all IDs
that need it are tagged to resync first, and then hierarchies are
evaluated to find the required partial resync roots whithin a hierarchy.
2023-05-02 16:14:53 +02:00
Bastien Montagne
ba9ca7afb6 LibOverride: Resync: Delete non-user-edited 'isolated from root' liboverrides.
These should not be needed anymore. Follow-up to previous commit.
2023-05-02 16:14:53 +02:00
Bastien Montagne
5574a1bfc1 LibOverride: Fix/Improve resync behavior in some complex cases.
This commit mainly addresses issues when a part of an override hierarchy
does not match anymore the linked reference data, and gets isolated form
the hierarchy root (there is no parenting chain to the root anymore).

The typical case being an object or sub-collection being moved to
another subcollection in the linked data.

Case identified while working on some Pets production files.

Note that in some cases this isolated chunk of the hierarchy will be
linked back into the appropriate place, in others it should be fully
removed (instead of staying as unused data). The later will be handled
in a another future commit.

This commit mainly detect and use a new tag for such cases, and correct
the checks to take it into account.

It also does a bit of cleanup, and replaces some asserts by `CLOG_ERROR`
reports.
2023-05-02 16:14:53 +02:00
Bastien Montagne
b724015840 LibOverride: Fix wrong assert in some cases in RNA tracks handling.
Due to index-only referencing in insertion of new NLA tracks in
liboverride data, it may happen that the source of an inserted track
cannot be found.

This index-only based handling of NLA tracks in liboverrides is very
weak, in the future this will be solved by ensure uniqueness of their
names, then name-based reference can be used instead, as already done with
modifiers, constraints, etc.
2023-05-02 16:14:53 +02:00