Commit Graph

99057 Commits

Author SHA1 Message Date
151a53110c Realtime Compositor: Implement Texture node
This patch implements the Texture node for the realtime compositor. The
evaluation of the texture is not GPU accelerated, but is cached as a
form of temporary implementation since the Texture node is deprecated
and will be removed in the future. Furthermore, texture node evaluation
is not supported for now.

This patch also introduces the concept of an ID static cache, which
uses the DrawDataList mechanism to invalidate the cache as needed,
consequently, a DrawDataList was added to the Tex ID structure.

An improvement that should be implemented outside of this patch is to
implement support for proxy textures in results to avoid redundant
copies in the execute method of the texture node. This should be
straightforward bit will be implemented in a separate patch.

Pull Request: blender/blender#107291
2023-04-25 09:04:35 +02:00
2cbf536605 Cleanup: Use consistent enum type in header
Fixes a warning on GCC 13 about `uint` being used in the declaration and
the proper enum type `eDupli_ID_Flags` being used in the definition for
`BKE_id_copy_for_duplicate`.
2023-04-24 21:45:12 -04:00
30f8e688c3 Fix: Wrong crease accessed for multires reshape
Also fix one more case of incorrect conversions from char to float.
2023-04-24 21:42:12 -04:00
9f78530d80 Multires: Use cached loose edge information
Avoids iterating over poly and corner edge index arrays.
2023-04-24 21:39:50 -04:00
3507431c30 Subdiv: Optimize coarse position extraction with cache
The coarse positions given to the evaluator are skipped if there are
vertices not attached to faces. Use the cache from 8e967cfeaf
to skip that topology query, or even to tell if there are no such vertices,
so we can skip a copy completely. I observed a 12x improvement for this
step, from 7.5 ms to 0.6 ms on a 1 million vertex grid.
2023-04-24 17:01:12 -04:00
c4e4184c50 Sculpt: Fix #107092: ss->filter_cache not being null'd on free 2023-04-24 12:20:03 -07:00
a649ff7b98 Fix broken 'replace object in collection' code.
Code was not handling properly the case where the new object that should
replace the old one in given collection is already in the collection. In
such case, remove the old object from the collection, but do not attempt
to add the new one again.
2023-04-24 19:35:11 +02:00
4f08eeae9c Nodes: Make spacings unitless in String to Curves node
The String to Curves node allows selecting various metrics for the
characters. Size is the absolute height between two lines, and is
correctly marked as a distance. Character, Word and Line Spacing, on
the other hand, do not represent any distance, but are proportional to
the base size and should not have distance units.

This commit simply removes the properties' `PROP_DISTANCE` subtype.

Pull Request: blender/blender#106660
2023-04-24 18:31:25 +02:00
aeb15e4e76 Cleanup: fix compiler warning
Warning C4551: function call missing argument list.

Pull Request: blender/blender#107237
2023-04-24 17:37:31 +02:00
4504a13bd9 Fix #107262: snap source of type Active Element sometimes fails
Remove micro optimization that seeks to reuse the active center 
alculation.

This operation is lightweight and reusing its result only adds an
unnecessary dependency.
2023-04-24 11:41:40 -03:00
9a671c401d Fix several issues in recent changes to ID swap and lib_query.
Fix #107297: Crash on undoing "Use Nodes" step.
Fix (unreported) crash on undoing certain type of data deletion (like
collections) in some specific cases.

Main serious issues were in new handling of embedded IDs in ID swap code
(#107297), and in general in lib_query remapping code from
`BKE_lib_id_swap_full` in readfile code in undo case which could access
other IDs data, when it is not guaranteed to be valid at this point in
code.

Added an option flag to lib_query code to forbid access to the original
ID pointers in such cases.
2023-04-24 15:49:59 +02:00
d9621add55 Vulkan: Initialize Device Capabilities.
Load the device capabilities into the context. This makes sure
that GPU framework already takes care of the capabilities.

Pull Request: blender/blender#107302
2023-04-24 15:35:27 +02:00
b94a0ec8db WindowManager: Context Creation
Currently window manager always tried to create an OpenGL context.
This is incorrect and will fail when using Vulkan. Somehow this
doesn't fail for Metal.

This PR creates a context based on the current selected backend.

Pull Request: blender/blender#107301
2023-04-24 15:33:35 +02:00
26147b29a7 Vulkan: Construct a Vulkan 1.2 Context.
Apparently we always constructed a Vulkan 1.0 Context, although we
are targetting Vulkan 1.2. This also lead to incorrect expectations
when using the Vulkan Memory allocator.

Pull Request: blender/blender#107300
2023-04-24 15:32:17 +02:00
b68b3e7b8f Cleanup: Add missing domain priority for mask nodes
This patch adds missing domain priority specifications for the Box and
Ellipse mask. This is a non-functional change because the inputs
happened to be properly ordered anyways.
2023-04-24 14:05:50 +02:00
85ed2e8c36 Animation: add function for deduplicating FCurve keys
Introduce `BKE_fcurve_deduplicate_keys()` to merge keys that are on the
same time, or within the time comparison threshold (1/100th of a frame).

When merging two consecutive keys, the last one 'wins' and determines
the final key *value*. The first key's *time* is retained, to ensure the
reference point for the next comparisons is stable. The only exception
here is when there is a key exactly on an integer frame number, in which
case that one is preferred.

The function is exposed in RNA as `fcurve.keyframe_points.deduplicate()`

This commit also introduces a new function `BKE_fcurve_bezt_shrink(fcu,
new_totvert);` that can reallocate the `bezt` array to ensure removed
keys no longer take up memory.

The RNA function `fcurve.update()` currently performs two steps, which
are now exposed to RNA as well, as `keyframe_points.sort()` and
`keyframe_points.handles_recalc()`. This is so that Python code can
sort, deduplicate, and then recalculate the handles only once (calling
`update` + `deduplicate` would do the latter twice).

In Blender 4.0 the deduplication will also be part of `fcurve.update()`,
see #107126.

Reviewed on blender/blender#107089
2023-04-24 12:07:28 +02:00
92ab89c6d9 Anim: add simple unit test for stability of sort_time_fcurve()
The `sort_time_fcurve()` function should be stable, i.e. not change the
relative order of keys that have the same X-coordinate. This is now
enforced by a unit test.

I want to build a new function that can deduplicate the keyframes after
sorting, for which it's important that the 'last key wins' to get reliable
results.
2023-04-24 12:07:28 +02:00
017d83790c Refactor: move keyframe-adding function from RNA to editors/animation
The RNA function `fcurve.keyframe_points.add(N)` was purely implemented
in the RNA wrapper. It now sits in `ED_keyframes_add(fcu, N)` where it
can be used by other C code as well.

It's in the editors code, as regular keyframe insertion is there as
well.

No functional changes.
2023-04-24 12:07:28 +02:00
e4afa06dab Fix #107261: bpy.types.Text (region_as_string/region_from_string) crash
These two didnt check if keywords were passed in, crashed on running
`PyDict_GET_SIZE` on NULL (in case of no keywords).

Oversight in ee292a1d66.

Now just check if keywords are actually passed in.

Pull Request: blender/blender#107285
2023-04-24 11:48:22 +02:00
ca32fb604e Geometry Nodes: support outputting field without computing full node
Many nodes output anonymous attributes (e.g. the top selection in the
Cylinder node). The actual data is only contained in the geometry output
though. The field output just contains a reference to this data (essentially
just the generated name of an attribute). This data can be output even
without computing the geometry itself.

As of right now, this only simplifies the code a bit, but does not have a
bigger impact, because to use the anonymous attribute, you always need
the geometry anyway. However, with the upcoming simulation nodes,
it's possible to create the anonymous attribute in one frame and to access
it in another frame. In the other frame we only need the anonymous
attribute reference and don't have to create the actual geometry again.
Skipping creating the actual attribute on the geometry can have a
significant performance benefit.
2023-04-24 11:42:05 +02:00
10fc2d6d96 Cleanup: remove basepath argument from BLI_path_normalize{_dir}
Keep these operations separate to simplify path handling logic & docs.
Many callers passed NULL and there were times paths were passed in which
didn't make any sense (where the paths had already been made absolute).
2023-04-24 12:23:04 +10:00
20eb682967 Cleanup: rename main_name to main_filepath
It wasn't clear this is a file-path, previous name was left over from
when the blend files path was called `name`.
2023-04-24 12:11:40 +10:00
6ab225074d Cleanup: minor changes to BLI_path_normalize
- Don't attempt to skip the WIN32 drive component on relative paths
  it's possible this would have unexpected behavior but paths like
  are already unlikely to work as expected, e.g. "//C:\".
- Remove early returns for empty paths as there is no need for special
  handling.
- Add path normalize NOP tests
2023-04-24 11:58:47 +10:00
2166fd2685 Geometry Nodes: Delete value moving for drag and drop group inputs
Initially, this function was for node data. At Simon's suggestion, it
was extended to a node group inputs as well. However, this overlaps with
another function. It has been missing for a while, but has recently been
fixed by blender/blender#107179. Now this functionality is redundant.

Pull Request: blender/blender#107255
2023-04-24 03:54:59 +02:00
8b1c54cd50 Cleanup: remove redundant path functions
- BLI_path_normalize ran BLI_path_abs on a path that had already
  been made absolute.
- BLI_path_slash_ensure was called after BLI_path_normalize_dir
  which already ensures a slash.
2023-04-24 11:25:56 +10:00
993d24c174 Cleanup: Miscellaneous improvements to subdivision geometry nodes
- Implement mesh creation in GeometrySet agnostic way, with less context
- Remove useless comments
- Use a field to clamp crease values instead of clamping when copying
- Small variable name tweaks
- Use `BKE_subdiv_new_from_mesh` instead of "update"
- Remove crease layers before writing, avoiding potential copy
2023-04-23 15:27:20 -04:00
e7eb8fd908 Cleanup: Remove unused includes, correct comments 2023-04-23 15:27:20 -04:00
54072154c5 Subdiv: Tag result mesh with no loose edges/verts
Avoid possible calculations of loose edges later on if the coarse mesh
doesn't have loose edges or vertices. We expect these counts to be
cached already since `BKE_subdiv_converter_init_for_mesh` calls
`verts_no_face()` and `loose_edges()` already.

Related commits:
- 63689e4756
- 8e967cfeaf
2023-04-23 15:27:20 -04:00
473bb8a8b0 Cleanup: Remove else after return in subdiv modifier code 2023-04-23 15:27:20 -04:00
5bed959e81 Cleanup: Avoid magic number for bits per integer 2023-04-23 15:27:20 -04:00
aa327e4ea5 Cleanup: Simplify subdiv check for crease usage
Now that crease arrays are separate arrays, we can just
not set the array pointers when crease usage is turned off.
2023-04-23 15:27:20 -04:00
2f581a779c Cleanup: Use utility constructor to create field operations 2023-04-23 15:27:20 -04:00
18291930ce Cleanup: Avoid redundant custom data lookups
We pass false for the "selected" argument, so the boolean layer values
aren't used anyway.
2023-04-23 15:27:20 -04:00
c5702ee87d Fix: Wrong conversion for crease type in multires reshape
a8a454287a missed a few places when
moving edge creases out of the MEdge struct.
2023-04-23 15:27:20 -04:00
3389cc8083 Fix: Incorrect mesh cache tagging causing excess calculation
8e967cfeaf only meant to tag the "verts no face" cache
calculated eagerly if both loose edges and loose verts were already
calculated. Instead it caused the calculation of one of the caches.
2023-04-23 15:27:20 -04:00
2ed6f738da BLI_path: support normalizing relative paths
Follow Python's os.path.normpath's handing on relative paths in more
situations.

- Leading './' is always stripped.
- Relative paths such as `//./a` & `///a` normalize to `//a`.
- Support for trailing `/..` on the end of paths.
- Avoid empty paths for relative paths that would otherwise
  resolve to an empty string, e.g:  `a/b/c/../../..` resolves to `.`.
2023-04-23 22:22:08 +10:00
1e5f2698af Cleanup: minor improvements to BLI_path_normalize
- Calculate spans of redundant `//` & `/./` before calling `memmove`.
- Loop backwards when removing path elements for greater efficiency.
- When removing `/../` components, avoid continuously searching from
  the start of the path and instead search from the last found '/../'.
2023-04-23 14:35:09 +10:00
651f9404a1 Cleanup: rename path_util 'Clean' tests to 'Normalize'
The function was renamed from `clean` but the tests weren't.
2023-04-23 14:30:52 +10:00
ac251cbe25 BLI_path: de-duplicate WIN32 logic for BLI_path_normalize
The only WIN32 specific behavior the drive or UNC prefix is skipped
(except for it's slash), allowing WIN32 & Unix paths to share the same
code-path.

Note that this changes behavior for WIN32 when there are too many parent
directories, where ".." that move before the root directory are removed
instead of being left in the path. e.g:
`C:\a\..\..\b` resolved to `C:\..\b` whereas now the result is `C:\b`.
This matches Python's `os.path.normpath`.
2023-04-23 14:30:51 +10:00
a9f02cd8d8 Geometry Nodes: add map from bsocket index to lf socket index
The socket indices in `bNode` and their corresponding `lf::Node`
don't match exactly, because `lf::Node` does not contain the
unavailable sockets. A simple mapping from `bNodeSocket` index
to `lf::Socket` index is required for future work. For now it
only removes the need for various tempory vectors.
2023-04-22 16:14:45 +02:00
1e81e27557 Cleanup: use hash value that fits into int to fix compile error 2023-04-22 15:28:26 +02:00
8523e361e8 BLI: use decay_t to determine type to hash
Goal is to fix a compile error on macos.
2023-04-22 15:01:56 +02:00
8e967cfeaf Mesh: Cache loose vertices
Similar to the cache of loose edges added in 1ea169d90e,
cache the number of loose vertices and which are loose in a bit map.
This can save significant time when drawing large meshes in the
viewport, because recalculations can be avoided when the data doesn't
change, and because many geometry nodes set the loose geometry
caches eagerly when the meshes contain no loose elements.

There are two types of loose vertices:
1. Vertices not used by any edges or faces
   `Mesh.loose_verts()`
2. Vertices not used by any faces (may be used by loose edges)
   `Mesh.verts_no_face()`

Because both are used by Blender in various places, because the cost
is only a bit per vertex (or constant at best) and for design consistency,
we cache both types of loose elements. The bit maps will only be
allocated when they're actually used, but they are already accessed
in a few important places:
- Attribute domain interpolation
- Subdivision surface modifier
- Viewport drawing

Just skipping viewport drawing calculation after certain geometry
nodes setups can have a large impact. Here is the time taken by
viewport loose geometry extraction before and after the change:
- 4 million vertex grid node: 28 ms to 0 ms
- Large molecular nodes setup (curve to mesh node): 104 ms to 0 ms
- Realize instances with 1 million cubes: 131 ms to 0 ms

Pull Request: blender/blender#105567
2023-04-22 13:46:11 +02:00
8fbf0a79fc Geometry Nodes: replace more maps with array
This is the same as 8b6777edc2 but for node groups instead
of built-in nodes.
2023-04-22 13:36:58 +02:00
15f9e42c4f Geometry Nodes: new Index of Nearest node
The node outputs the index of the closest element to itself. See #102387
for the original design.

This is different from the Sample Nearest node in two important ways:
* It does not have a geometry input, instead the geometry is taken from the
  field evaluation context.
* The node can exclude the "current" element from the search.
* The group id input can be used to build subsets of elements that only
  consider each other as neighbors and ignore elements with other ids.

Pull Request: blender/blender#104619
2023-04-22 13:11:51 +02:00
8b6777edc2 Geometry Nodes: replace multiple maps with single array
The goal here is to avoid creating to many `Map` which are fairly
large compared to simple arrays. Also, access in arrays is more
efficient.
2023-04-22 13:01:28 +02:00
0e82510ea2 Sculpt: Fix #107068: Crash in multires unsubdivide
A BMesh customdata offset was being pulled from
the base mesh's customdata.
2023-04-21 18:08:42 -07:00
21b51e7b88 Cleanup: Use function ref instead of pointer for transform gizmo
Avoid the need to cast to and from `void *` and use
lambda capture to make things a bit more automatic.

Pull Request: blender/blender#107225
2023-04-21 21:41:35 +02:00
c547ff1ebd Fix VSE thumbnails are displayed from incorrect scene
Add scene to rendering context, so it can be used for cache hashing.
2023-04-21 20:33:52 +02:00
968ecf6f8b Fix #106993: Slowness with Orbiting around select + Mesh Symmetry
The issue happens because the algorithm used to calculate the center of
the selection first needs to create a TransData array. In this array,
the code calculates the "mirrored" elements which can be quite slow in
dense meshes.

The solution is replace this slow algorithm used for calculating the pivot
point with the fast algorithm used to calculate the position of transform
gizmos.

Pull Request: blender/blender#107203
2023-04-21 20:07:05 +02:00