Commit Graph

150077 Commits

Author SHA1 Message Date
Sean Kim
a2d6808a7a Revert "Fix: Sculpt: Correct asserts in previous commit"
This reverts commit 1602f82f28.

Original commit was correct, the affected functions are working on the
evaluated object, so we should assert that it is *not* the original
object.

Pull Request: https://projects.blender.org/blender/blender/pulls/126388
2024-08-16 06:50:16 +02:00
Campbell Barton
d777267982 Cleanup: use str.format instead of f-strings 2024-08-16 09:33:20 +10:00
Campbell Barton
d6c5010936 Cleanup: use deferred import for faster startup 2024-08-16 09:33:20 +10:00
Campbell Barton
d71d325692 Cleanup: spelling in comments, strings 2024-08-16 09:33:20 +10:00
Sean Kim
e48f98efb0 GPv3: Add ReprojectMode enum and DrawingPlacement constructor
Needed to implement GPv3 version of "Bake Object Transform to Grease
Pencil"

Doesn't implement the `Surface` option, as that is not used in the
previously mentioned operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/126255
2024-08-16 01:32:13 +02:00
Hans Goudey
f6141b3fa7 Cleanup: Formatting 2024-08-15 16:14:23 -04:00
Hans Goudey
1602f82f28 Fix: Sculpt: Correct asserts in previous commit 2024-08-15 16:02:13 -04:00
Hans Goudey
f04fd1fad7 Refactor: Sculpt: Require depsgraph to access mesh positions
Part of #118145.
Similar to cfe69e32bc.
The dependency graph is required to access the evaluated object.
2024-08-15 15:43:17 -04:00
Hans Goudey
220cf67172 Cleanup: Improve object argument name
These functions expect an evaluated object which wasn't clear.
2024-08-15 13:09:28 -04:00
Hans Goudey
4333277aa8 Cleanup: Formatting 2024-08-15 12:45:05 -04:00
Hans Goudey
0adeeae2c7 Fix: Sculpt: Performance regression in expand operator
Caused by calculating the enabled vertices per node
in dd1454a648.
2024-08-15 12:44:49 -04:00
Hans Goudey
e7e1fd8a20 Fix: Sculpt: Incorrect overlay visibility check
Caused by 9eb7e8bfd1.
2024-08-15 12:44:49 -04:00
Hans Goudey
b793347b1d Sculpt: Specialize expand symmetry, sphere falloff
Parallelize the spherical falloff creation and use just a single
loop over all vertices rather than one per symmetry iteration.
2024-08-15 12:44:49 -04:00
Hans Goudey
3324a27334 Fix: Sculpt: Crash in vertex boundary test 2024-08-15 12:44:49 -04:00
Hans Goudey
294ea108f3 Sculpt: Parallelize some loops in expand operator
Parallelize loops to calculate max falloff and transfer
falloff from vertices to faces. These aren't a bottleneck
but performance should be slightly improved anyway.
2024-08-15 12:44:49 -04:00
Jacques Lucke
ab26dc5817 Nodes: add operator to get node width from parent
This operator sets the new default group node width (from e842966c5e) based on
the parent group node. This makes it easier to initialize the value. Without
this, one had to create and delete the group node potentially many times to find
a good default width.

Pull Request: https://projects.blender.org/blender/blender/pulls/126239
2024-08-15 17:54:56 +02:00
Falk David
d09fb76caa Docs: Python API: Add section about using attributes
This adds a section at the top of the `bpy.type.Attribute` about
how to use the attribute API in python.

Pull Request: https://projects.blender.org/blender/blender/pulls/126367
2024-08-15 17:42:47 +02:00
Anthony Roberts
37e86dbf6f Build: Add patch to OIIO fixing Windows ARM64 + clang
Pull Request: https://projects.blender.org/blender/blender/pulls/126331
2024-08-15 17:27:15 +02:00
Hans Goudey
cfe69e32bc Refactor: Sculpt: Require object for position access
Part of #118145.
In preparation for removing the duplicated position arrays from the
pbvh::Tree structure, change the API functions that access the arrays
to require object arguments. This will allow retrieving data from the
original mesh or the evaluated deform mesh as necessary.

The pbvh code isn't really the right place for this, but neither is the
sculpt or paint code in my opinion, since this concept is not specific
to sculpting or painting. For now keep the API in the same place. It
probably makes sense to move a bunch of these functions at some point.

Pull Request: https://projects.blender.org/blender/blender/pulls/126370
2024-08-15 17:07:36 +02:00
David Murmann
58aa349f68 Fix #126354: Cycles: Calculate correct bounds for hair objects
Hair objects did not take the curves into account that could go
outside the bounds set by the keys of the curves. These bounds
are used in the dynamic bvh, leading to clipped curves in the
viewport.

Pull Request: https://projects.blender.org/blender/blender/pulls/126157
2024-08-15 16:39:15 +02:00
Hans Goudey
df6034c869 Cleanup: Sculpt: Make positions span const 2024-08-15 09:53:22 -04:00
Aras Pranckevicius
8903205dd9 Fix: incorrect ffmpeg video length estimation logic
71f2229b0 added a workaround for video files that contain entirely
incorrect stream duration, and corrects that by using container
duration instead. However it used math of `seconds=frames*rate` instead
`seconds=frames/rate`, effectively always ending up falling back to
container instead of stream duration.

Pull Request: https://projects.blender.org/blender/blender/pulls/126368
2024-08-15 15:47:01 +02:00
Lukas Tönne
4e6dff2995 Cleanup: Use boolean operator to combine booleans instead of bitwise OR
There is a reason for the bitwise operator but it's not explained:
The attribute_foreach function callback has side-effects that the
compiler does not know about (everything is const). Simply replacing
the bitwise operator will cause the second term to be skipped, which
breaks tests due to missing attributes.

Now the term is explicitly evaluated first, then combined with actual
boolean operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/126366
2024-08-15 15:05:02 +02:00
Patrick Mours
013a2ce765 Cycles: Change OptiX curve vertex data generation to use more compact representation
OptiX has accepted Catmull-Rom curve data natively since OptiX 7.4, but due to the previous conversion to B-Spline code, the format that data is fed to OptiX wasn't optimal.

Each curve segment was put in the vertex buffer as four independent control points, even though continuous segments actually share control points between each other. This patch compacts that so shared control points only occur once in the vertex buffer.
This compact form uses less memory and also allows OptiX to easily identify segments that belong together into a curve (those where the step between indices is one).

Pull Request: https://projects.blender.org/blender/blender/pulls/125899
2024-08-15 15:00:56 +02:00
Sergey Sharybin
d8913812ef Cleanup: Code format 2024-08-15 14:37:53 +02:00
YimingWu
4f4add5406 Fix #125426: Update paths in animation when renaming IDProperty
Previously when renaming an IDProperty the existing paths in the
animation/driver system isn't updated, this leads to missing animation
after renaming the property. Now `BKE_animdata_fix_paths_rename_all`
will be called so the animation system records the updated name.

Pull Request: https://projects.blender.org/blender/blender/pulls/125474
2024-08-15 13:56:17 +02:00
Campbell Barton
bd4e535009 CMake: fail with an error if wayland-scanner can't be found 2024-08-15 21:50:46 +10:00
Campbell Barton
b0ec4bba70 CMake: library path reference for PLATFORM_ENV_BUILD on unix & macos
The value used for the the library path was being evaluated by CMake
instead of forwarding the value to the shell expression (as intended).

This meant any build-time binaries that depended on the environments
library-path would failed to run.
2024-08-15 21:50:46 +10:00
Jacques Lucke
bda4c8a220 Tools: improve error handling in GDB pretty printers 2024-08-15 13:40:05 +02:00
Christoph Lendenfeld
0a4b5d93c5 Fix #126125: Pose Slider not working with layered actions
The issues was that the `get_item_transform_flags` iterated over the `curves`
list of the action, ignoring the new structure.

Fixed by using the `action_foreach_fcurve` and modifying that to work on legacy actions as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/126357
2024-08-15 13:35:28 +02:00
Campbell Barton
da94978cc4 Cleanup: format 2024-08-15 21:26:12 +10:00
Campbell Barton
b5e0b59736 Cleanup: remove space around identifiers in C-style comments 2024-08-15 20:46:00 +10:00
Anthony Roberts
b664ece0fe Build: Upgrade sse2neon
Pull Request: https://projects.blender.org/blender/blender/pulls/126237
2024-08-15 12:31:26 +02:00
Jacques Lucke
bb8460da9e Tests: support generating code coverage report
This only works with GCC and has only been tested on Linux. The main goal is to
automatically generate the code coverage reports on the buildbot and to publish
them. With some luck, this motivates people to increase test coverage in their
respective areas. Nevertheless, it should be easy to generate the reports
locally too (at least on supported software stacks).

Usage:
1. Create a **debug** build using **GCC** with **WITH_COMPILER_CODE_COVERAGE**
   enabled.
2. Run tests. This automatically generates `.gcda` files in the build directory.
3. Run `make/ninja coverage-report` in the build directory.

If everything is successful, this will open a browser with the final report
which is stored in `build-dir/coverage/report/`. For a bit more control one can
also run `coverage.py` script directly. This allows passing in the
`--no-browser` option which may be benefitial when running it on the buildbot.
Running `make/ninja coverage-reset` deletes all `.gcda` files which resets the
line execution counts.

The final report has a main entry point (`index.html`) and a separate `.html`
file for every source code file that coverage data was available for. This also
contains some code that is not in Blender's git repository. We could filter
those out, but it also seems interesting (to me anyway), so I just kept it in.

Doing the analysis and writing the report takes ~1 min. The slow part is running
all tests in a debug build which takes ~12 min for me. Since the coverage data
is fairly large and the report also includes the entire source code, file
compression is used in two places:
* The intermediate analysis results for each file are stored in compressed zip
  files. This data is still independent from the report html and could be used
  to build other tools on top of. I could imagine storing the analysis data for
  each day for example to gather greater insights into how coverage changes over
  time in different parts of the code.
* The analysis data and source code is compressed and base64 encoded embedded
  into the `.html` files. This makes them much smaller than embedding the data
  without compression (5-10x).

Pull Request: https://projects.blender.org/blender/blender/pulls/126181
2024-08-15 12:17:55 +02:00
Falk David
ed3c16624b GPv3: High level python API
This extends the `GreasePencilDrawing` rna type using python.
The goal is to add an API that allows developers to transition to
the new grease pencil API a bit more smoothly.

Adds the following endpoints to the `GreasePencilDrawing`:
* `drawing.strokes`: Returns a list/slice of `GreasePencilStroke`s in the drawing.

Adds a python class `GreasePencilStroke`:
* `stroke.points`: Returns a list/slice of `GreasePencilStrokePoint`s.
* Getters/Setters of attributes for this stroke:
   * `stroke.cyclic`
   * `stroke.material_index`
   * `stroke.select`
   * `stroke.softness` (used to be `hardness`)
   * `stroke.start_cap`
   * `stroke.end_cap`
   * `stroke.curve_type`: The type of curve: `POLY`,`BEZIER`,`CATMULL_ROM`,`NURBS`.
   * `stroke.aspect_ratio`
   * `stroke.fill_opacity`
   * `stroke.fill_color`
   * `stroke.time_start`
* High-level functions:
   * `stroke.add_points(count)`: Adds `count` points at the end of the stroke.
  * `stroke.remove_points(count)`: Removes `count` points from the end of the stroke. Note that this will not remove the stroke if the count is greater than the number of points in the stroke. A stroke has at least 1 point. Removing strokes can be done from the drawing.

Adds a python class `GreasePencilStrokePoint`:
* Getters/Setters of attributes for this point:
   * `position`
   * `radius`
   * `opacity`
   * `select`
   * `vertex_color`
   * `rotation`
   * `delta_time`

Note that `GreasePencilStroke` and `GreasePencilStrokePoint` are not stored in the file and don't have an RNA API. This means that they are not compatible with e.g. `layout.prop`.

This API should not be used for performance critical code. It's likely
even slower than the python API from 4.2.

There will be migration documentation for addon developers here:
https://developer.blender.org/docs/release_notes/4.3/grease_pencil/#python-api-changes

Pull Request: https://projects.blender.org/blender/blender/pulls/125599
2024-08-15 10:58:21 +02:00
Jacques Lucke
a8667aa03f Core: introduce MemoryCounter API
We often have the situation where it would be good if we could easily estimate
the memory usage of some value (e.g. a mesh, or volume). Examples of where we
ran into this in the past:
* Undo step size.
* Caching of volume grids.
* Caching of loaded geometries for import geometry nodes.

Generally, most caching systems would benefit from the ability to know how much
memory they currently use to make better decisions about which data to free and
when. The goal of this patch is to introduce a simple general API to count the
memory usage that is independent of any specific caching system. I'm doing this
to "fix" the chicken and egg problem that caches need to know the memory usage,
but we don't really need to count the memory usage without using it for caches.
Implementing caching and memory counting at the same time make both harder than
implementing them one after another.

The main difficulty with counting memory usage is that some memory may be shared
using implicit sharing. We want to avoid double counting such memory. How
exactly shared memory is treated depends a bit on the use case, so no specific
assumptions are made about that in the API. The gathered memory usage is not
expected to be exact. It's expected to be a decent approximation. It's neither a
lower nor an upper bound unless specified by some specific type. Cache systems
generally build on top of heuristics to decide when to free what anyway.

There are two sides to this API:
1. Get the amount of memory used by one or more values. This side is used by
   caching systems and/or systems that want to present the used memory to the
   user.
2. Tell the caller how much memory is used. This side is used by all kinds of
   types that can report their memory usage such as meshes.

```cpp
/* Get how much memory is used by two meshes together. */
MemoryCounter memory;
mesh_a->count_memory(memory);
mesh_b->count_memory(memory);
int64_t bytes_used = memory.counted_bytes();

/* Tell the caller how much memory is used. */
void Mesh::count_memory(blender::MemoryCounter &memory) const
{
  memory.add_shared(this->runtime->face_offsets_sharing_info,
                    this->face_offsets().size_in_bytes());

  /* Forward memory counting to lower level types. This should be fairly common. */
  CustomData_count_memory(this->vert_data, this->verts_num, memory);
}

void CustomData_count_memory(const CustomData &data,
                             const int totelem,
                             blender::MemoryCounter &memory)
{
  for (const CustomDataLayer &layer : Span{data.layers, data.totlayer}) {
    memory.add_shared(layer.sharing_info, [&](blender::MemoryCounter &shared_memory) {
      /* Not quite correct for all types, but this is only a rough approximation anyway. */
      const int64_t elem_size = CustomData_get_elem_size(&layer);
      shared_memory.add(totelem * elem_size);
    });
  }
}
```

Pull Request: https://projects.blender.org/blender/blender/pulls/126295
2024-08-15 10:54:21 +02:00
Sean Kim
f0c2d4eeed Cleanup: Add int8_t specifier to ED_grease_pencil.hh enum classes
Since these enums won't have more than 255 values, add the `int8_t` specifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/126326
2024-08-15 10:15:06 +02:00
Christoph Lendenfeld
0f5dd1c55c Refactor: pose_utils.cc
No functional changes expected.

This PR refactors the code by:
* passing things by reference if they cannot be a `nullptr`
* Managing indentation by returning early or continuing.
* Cleaning up comments
* Indicating ListBase element types in the declaration

This is in service of #126125 for which the `get_item_transform_flags`
needs to be passed a slot handle as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/126291
2024-08-15 09:47:14 +02:00
Jeroen Bakker
00be586a82 Fix #124565: EEVEE Environment Render Pass
There were a couple of regressions when using the environment render
pass.

- Not working when film transparency was enabled
- Deferred geometry didn't occlude the background

This PR splits the world background shader (eevee_surf_world) into two
shaders. One clears background and render passes and a second one that renders
the background and the environment render pass.

The second shader is moved after the deferred pipeline and an early
depth test is used to occlude the background and environment pass.

NOTE: render test reference images needs to be updated.
Pull Request: https://projects.blender.org/blender/blender/pulls/126274
2024-08-15 08:58:41 +02:00
Jeroen Bakker
925753c83b Fix #125618: EEVEE: Cryptomatte Material Layer Incorrect
Missing oversight in previous fix where incorrect name size where
used to generate the cryptomatte hash.

Pull Request: https://projects.blender.org/blender/blender/pulls/126352
2024-08-15 08:41:12 +02:00
YimingWu
04c5a9f053 Fix #126136: Show GUI message box for unsupported GPUs on X11
On X11 windowing systems there's no `MessageBox` prompt like on
win32 that could show users that they have unsupported GPUs,
this leads to confusion to them as they typically don't open
blender from a command line so none of the messages could be
available. This patch utilizes `system->showMessageBox` to display
a GUI message box telling the user that the GPU is unsupported.

Pull Request: https://projects.blender.org/blender/blender/pulls/126220
2024-08-15 08:37:03 +02:00
Campbell Barton
74fae7f943 Presets: remove poll functions that scan the file-system
The poll functions for theme & key-map preset operators used functions
documented not to be used on redraw draw and could make the interface
slow when extensions (for example) are stored on a network file-system.

While the file-system lookups are typically cached, it can still cause
occasional stuttering or hanging. In general scanning the file-system
on poll should be avoided.
2024-08-15 16:06:17 +10:00
Campbell Barton
9e09351b5b Fix active theme behavior when adding/removing themes
Regression in [0] which displays the filename for the active
theme but still used the label internally.

This meant actions such as removing the theme would not always apply
to the name being displayed.

- Adding a new theme was not setting it active.
- Detecting if a theme was built-in used the run-time label as a lookup.
- Theme removal first require it to be re-selected.

[0]: 0bb6317035
2024-08-15 16:06:13 +10:00
Campbell Barton
9f931ee3d2 Presets: consider presets within the extensions repo to be "built-in"
It was possible to remove a preset defined within an extension,
the only way to restore it was to uninstall & re-install the extension.
2024-08-15 16:06:11 +10:00
Campbell Barton
f42713ab1d Fix unhandled permissions exception in bpy.utils.is_path_builtin
An excepting would be raised when the parent/child paths didn't
have permissions to access.
2024-08-15 16:06:10 +10:00
Campbell Barton
5f9be675f0 Cleanup: move bpy.utils parent-path check into a function 2024-08-15 16:06:08 +10:00
Hans Goudey
6ca352a7b6 Refactor: Sculpt: Remove mesh pointer from BVH tree, pass to drawing code
Part of #118145.
Similar in concept to recent commits removing the usage of
this mesh pointer in favor of fetching the data as necessary.
Also see recent discussion in a recent fix for this area:
https://projects.blender.org/blender/blender/pulls/122850.

And also note the comment for `Tree::mesh_` was incorrect.
The mesh was the original mesh, not the evaluated mesh.
2024-08-15 00:24:12 -04:00
Hans Goudey
b7cbe4d959 Refactor: Sculpt: Pass object instead of SculptSession to vertex access
Part of #118145.
This makes it possible to remove the vertex position array from
the sculpt BVH tree.
2024-08-15 00:17:44 -04:00
Hans Goudey
ae8ecd6e4e Cleanup: Remove unused variables 2024-08-15 00:00:44 -04:00
Hans Goudey
0c0a9d7714 Cleanup: Remove unused variables 2024-08-14 23:58:07 -04:00