Commit Graph

104543 Commits

Author SHA1 Message Date
Campbell Barton
7d99be77f7 Cleanup: rename data -> ghost_data in wm_playanim
Follow naming convention used elsewhere in wm_playanim.cc.
2023-11-11 19:52:30 +11:00
Germano Cavalcante
172221e7fb Fix #114714: Rotating the View can drastically change the view's position when Auto Depth or Orbit Arround Select is set
Caused by 6faa39edb7

In that commit it was assumed that the view offset does not need to be
updated if the operator is `V3D_OP_MODE_ROTATE` instead of simply
checking `this->use_dyn_ofs`.

Since `use_dyn_ofs` is always `True` when using Auto Depth or Orbit
Arround Select, the offset should always be updated in these cases.
2023-11-10 19:07:25 -03:00
Iliya Katueshenock
8618547dfe Cleanup: Geometry Nodes: General topology map creation in Shortest Edge Paths
Use general util to build mesh topology map instead of array of vectors.
This util can be optimized in future by better multithreading and new
algorithms with better CPU catch heuristics. For now this will provide
better usage of memory without a lot of small allocations.

Pull Request: https://projects.blender.org/blender/blender/pulls/114683
2023-11-10 15:20:56 +01:00
Jeroen Bakker
2a24e29241 Vulkan: Convert 3 Component Texture Formats
3 component texture formats are often not supported by vulkan devices.
Sometimes the support is less than 5%. The 4 components variants have
more than 90% support.

This PR builds on top of the existing vulkan data conversion to add
the ability to convert between RGB16F<=>RGBA16F and RGB32F<=>RGBA32F
texture formats.

This allows using color management other then Standard/sRGB. Most places
the 3 component texture formats are phased out, but OCIO, external
render engines and real time compositor uses them.

Pull Request: https://projects.blender.org/blender/blender/pulls/114708
2023-11-10 15:19:24 +01:00
Hans Goudey
5052e0d407 Mesh: Make vertex normal calculation deterministic
Currently, atomic additions in vertex normal calculation introduce
non-determinism that can influence the result of other operations,
sometimes causing non-reproduceable renders (in cases like #100250
and #101726). This is because the order used during threading when
accumulating face normals changes.

This commit fixes that non-determinism, using a vertex to face topology
map to calculate vertex normals without atomics. When the map is already
available, this can be faster too.

In the longer term future, this method of vertex normal calculation
means it will be easier to do partial recalculations when only part
of a mesh changes. That might be essential for cases like transforming
small selections in a non-BMesh edit mode.

As an experiment I tried a "fast" code path that avoids weighting face
normals by the corresponding corner angle when averaging them to
create vertex normals. This significantly reduces the necessary
computation and memory bandwidth for vertex normal calculation.
The results are shown below too, but it's not part of this PR.

I measured the FPS with two smooth shaded 16 million face grids:
|                                  | Before | After | After (fast) |
| -------------------------------- | ------ | ----- | ------------ |
| Created from scratch every frame | 0.96   | 0.91  | 0.92         |
| Deformed by geometry nodes       | 0.99   | 1.32  | 1.40         |

Though many other things besides normals are being tested here,
it's clear that the performance difference isn't that large either way,
though there is an observable regression with meshes created from
scratch, and there is a noticeable improvement when the topology
stays the same and is persistent.

Pull Request: https://projects.blender.org/blender/blender/pulls/111718
2023-11-10 15:19:01 +01:00
Bastien Montagne
cb5f650a5a Merge branch 'blender-v4.0-release' 2023-11-10 14:41:46 +01:00
Bastien Montagne
c688b03847 Fix (studio-reported) VSE prefetch process taking seconds to stop.
When VSE cache is invalidated (on most VSE edit operation e.g.), or
Blender quits, in some cases (complex and very long edits), the
prefetch job would block several seconds after being requested to stop.

This was because one codepath would keep looping over all frames without
checking for the `stop` flag.
2023-11-10 14:29:44 +01:00
Hans Goudey
70074a7d46 Cleanup: Follow style guide in new math function, use std:: namespace 2023-11-10 14:21:43 +01:00
Germano Cavalcante
9bf673a37d Fix #114215: Scanfill sometimes fails to identify holes
The problem is in the way of identifying "fast" intersections through bounds.

In the existing code, before testing the intersections (to identify
holes) the polys are sorted according to the bounds
(in the order x1 < x2 || y1 < y2).

Then a for loop is used on the order returned by sort.

Each time the bound of a polygon intersects with another, it is joined
and the bound is added.

The problem with this solution is that some bounds may not intersect
with the first, but could intersect one that is joined to the first,
which, as it is cleared, makes the intersection undetected.

The solution is to remove this code with `qsort` and create a
"target_map" that identifies a source polygon and a dest polygon.

Pull Request: https://projects.blender.org/blender/blender/pulls/114600
2023-11-10 12:56:20 +01:00
Jeroen Bakker
cc04bcd792 Vulkan: Reusing Textures from Pool
This PR solves an issue when using texture pools with textures that are not
natively supported by the device. In the previous implementation the
internal `Texture::format_` was changed. Any check if the texture could
be reused would fail as its format would be different that the requested one.

This PR fixes this by separating the requested format `Texture::format_` and
how it is stored on the GPU `VKTexture::device_format_`.

This solves the next artifacts:
* Workbench flickering artifacts on AMD/Intel GPUs
* Workbench TAA on AMD/Intel GPUs
* Overlays were not always drawn fully solid

Pull Request: https://projects.blender.org/blender/blender/pulls/114697
2023-11-10 12:52:34 +01:00
Jeroen Bakker
0c9433bf44 Vulkan: Retarget Depth Range
OpenGL uses a depth range between -1 and 1, which is then normalized.
Metal & Vulkan uses a depth range between 0 and 1, which is already normalized.

The final plan would be to default to a depth range between 0 and 1, but
for now the depth ranges are retargetted so they won't be clipped away.

This solves the next issues for users:
- Navigate control will be rendered correctly
- Ortographic view clipping artifacts
- EEVEE light evaluation

Retargetting happens at the end of the vertex stage or when a geometry
stage is present at the end of the geometry stage. Derivatives using
depth would have a different value compared to OpenGL, but would match
Metal backend. OpenGL performs clipping and generates derivatives based
on the original depth value.

`gl_FragCoord` and clipping would have some precision differences as clipping
and normalizing are done in a different order but would match Metal.

Geometry shaders should use `gpu_EmitVertex` to ensure that the retargetting
is done per vertex.

Pull Request: https://projects.blender.org/blender/blender/pulls/114669
2023-11-10 12:32:06 +01:00
Christoph Lendenfeld
06bcbc644c Refactor: extract function from insert_keyframe_value
No functional changes.

Extract code from the function `insert_keyframe_value`
to make it easier to use in other places.
I created a new function `remap_driver_frame` that
removes 3 parameters from the function.
And I removed the requirement for a `ReportList`
by just returning false and letting the caller
create a message.

Pull Request: https://projects.blender.org/blender/blender/pulls/114700
2023-11-10 12:22:45 +01:00
Pratik Borhade
66bd65c5f2 Merge branch 'blender-v4.0-release' 2023-11-10 16:19:08 +05:30
Pratik Borhade
ab2198d77b Fix #114687: Orbit opposite changes view to perspective
When `VIEWOPS_FLAG_PERSP_ENSURE` is set, it switches view to
perspective in `ED_view3d_persp_ensure` which is incorrect for orbit
operation.

Pull Request: https://projects.blender.org/blender/blender/pulls/114698
2023-11-10 11:41:28 +01:00
Pratik Borhade
270fc860cf Fix #114685: GP time offset modifier doesn't work if the animation is 1 frame long
This is due to the early return of current frame when start and end of
custom range is same
2023-11-10 16:07:05 +05:30
Julian Eisel
9638dfbe43 Merge branch 'blender-v4.0-release' 2023-11-10 11:34:16 +01:00
Julian Eisel
c05faeb053 Fix #114432: Custom themes overridden by default theme
Code was copying the default theme over the active theme, instead of
selectively updating a single theme option to fix #113683.

Pull Request: https://projects.blender.org/blender/blender/pulls/114675
2023-11-10 11:33:15 +01:00
Jeroen Bakker
672f14fee5 Cleanup: Make format 2023-11-10 11:07:04 +01:00
Hans Goudey
cda624032d Merge branch 'blender-v4.0-release' 2023-11-10 09:19:03 +01:00
Hans Goudey
821060f75a Fix #114686: Cannot execute node tool operators
A stupid mistake in 871c717c6e caused node tools to trigger
the unsupported warning for data-blocks for geometry sockets as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/114693
2023-11-10 09:18:04 +01:00
nutti
cf41153798 Docs: include cls in bpy.utils.unregister_class
Ref: !114523
2023-11-10 14:32:23 +11:00
Germano Cavalcante
78943edc5d Transform: Custom modifier to navigate while transforming
Discussed in #114646.

This commit transforms the "alt_navigation" option of the transform
operators into a new modal key item. "PASSTHROUGH_NAVIGATE"

In addition to cleaning up a lot of the code, it allows you to
customize the key chosen to navigate while transforming.
2023-11-09 21:33:34 -03:00
Campbell Barton
a615dcdfa8 Cleanup: add missing header to CMake, sort file lists 2023-11-10 09:40:05 +11:00
Campbell Barton
3841addab3 Cleanup: spelling in comments 2023-11-10 09:24:19 +11:00
Jesse Yurkovich
7d375793bd Merge branch 'blender-v4.0-release' 2023-11-09 11:08:38 -08:00
Jesse Yurkovich
360684d5a4 Fix #114047: Use correct collection during USD import
Ensure that the view layer is properly synced before trying to get the
active collection.

Without the sync, imported objects typically get placed in the global
Scene Collection rather than the new collection that was just created
for the import.

Pull Request: https://projects.blender.org/blender/blender/pulls/114650
2023-11-09 20:07:51 +01:00
Brecht Van Lommel
7b26c3d517 Merge branch 'blender-v4.0-release' into main 2023-11-09 18:24:05 +01:00
Christoph Lendenfeld
cd90e04347 Refactor: arguments for get_normalized_fcurve_bounds
No functional changes.

In order for the function `get_normalized_fcurve_bounds` to be
reusable in [#114407: WIP: Anim: View FCurve of Property in the Graph Editor](https://projects.blender.org/blender/blender/pulls/114407)
the arguments need to be simplified.

Pull Request: https://projects.blender.org/blender/blender/pulls/114679
2023-11-09 17:17:07 +01:00
Christoph Lendenfeld
6e7af8ceff Refactor: More specific arguments for ANIM_get_normalization_flags
No functional changes.

`ANIM_get_normalization_flags` had the argument type of `bAnimContext *`.
That made it more difficult than it needs to be to reuse that function.
Pass a `SpaceLink *` instead since that is what the function actually uses.

Pull Request: https://projects.blender.org/blender/blender/pulls/114676
2023-11-09 17:02:13 +01:00
Sergey Sharybin
43c2c1844f Cleanup: Remove unused arguments from sculpt automasking API
Pull Request: https://projects.blender.org/blender/blender/pulls/114674
2023-11-09 16:15:54 +01:00
Jeroen Bakker
8c7f927ec8 Vulkan: Workbench Shadow Drawing
There were some issues with workbench shadow drawing. This PR
does some tweaks to fix the shadow drawing on vulkan.

* Framebuffer stencil clearing when write stencil is disabled
* Tweaks to stencil operation and tests
* Disable restart for line adjacency

Pull Request: https://projects.blender.org/blender/blender/pulls/114673
2023-11-09 16:07:26 +01:00
Sergey Sharybin
9125848f2a Cleanup: Remove unused pointer to PBVH node
Pull Request: https://projects.blender.org/blender/blender/pulls/114672
2023-11-09 15:57:35 +01:00
Christoph Lendenfeld
b670e7a82c Fix #114588: Graph Editor increment snap not working
Restoring the behavior while transforming keys and pressing `Ctrl`

The regular snapping code has the feature that
when you press `Ctrl` you can toggle the snapping on and off.
Prior to 4.0 the snapping for the Graph Editor used a
completely different system, including a different flag to toggle snapping.

Because of that, the flag that the regular snapping
code uses was never set by default. So the system thought it was disabled.

Now when you press `Ctrl` you would enable that
flag and the snapping code would run.
It would snap to increments because that is the mode that
is returned for the Graph Editor space type.
(Note that this is the mode of the generic snapping
system, not of the Graph Editor specific one)

However at the same time, doing that would disable the
Graph Editor specific snapping code.
So the snapped values from the original system would bubble through.

This did not occur in the Dope Sheet and NLA Editor,
because those never returned a snapping mode.
Those still have a different behavior to 3.6 where they
now snap to seconds, instead of not snapping at all.

Pull Request: https://projects.blender.org/blender/blender/pulls/114607
2023-11-09 14:38:30 +01:00
Sergey Sharybin
bf8728f99e Cleanup: Remove unneeded extern "C" linkage for C++ code
Pull Request: https://projects.blender.org/blender/blender/pulls/114663
2023-11-09 13:23:41 +01:00
Hans Goudey
d0ce1ca173 Merge branch 'blender-v4.0-release' 2023-11-09 11:58:29 +01:00
Hans Goudey
16553c2a44 Geometry Nodes: Support top-level instance meshes in boolean node
During the 2.93 to 3.0 transition, instance handling was made more
explicit in general. However, we forgot to change the boolean node,
which still implicitly gathered all the instanced meshes and fed them
to the boolean algorithm separately. We waited for the next breaking
release, 4.0 to "correct" this, and did it in fc06a471f1.
However, in that commit it was assumed that the "Self Intersection"
mode would be able to address the use case. The idea was also to push
some complexity outside of the boolean code, which is already one of
the more complex areas in Blender. Though it's possible to have a
"Group ID" or "Shape ID" input in the future as well, it's also
reasonable to expect some instances to be processed by the node,
even though it isn't quite consistent.

This commit makes a compromise by processing meshes contained by
top-level instances. We do it at this stage of the release to avoid the
breaking change.

Pull Request: https://projects.blender.org/blender/blender/pulls/114632
2023-11-09 11:54:41 +01:00
Jeroen Bakker
59a21a63bb Cleanup: Remove unused r_data_format parameter
The r_data_format parameter from imb_gpu_get_format is always ignored
or overwritten by the r_data_format parameter from imb_gpu_get_data.

It makes more sense to just use the result from the imb_gpu_get_data
function for to determine the data format.

Pull Request: https://projects.blender.org/blender/blender/pulls/114662
2023-11-09 11:21:56 +01:00
Jeroen Bakker
7e95bfbba8 Merge branch 'blender-v4.0-release' 2023-11-09 11:05:48 +01:00
Jason Fielder
ed540b4d3a Fix #114414: Alternative fix for greyscale textures retaining perf
Alternative solution to #114414 which reduces the scope of
textures for which single-channel greyscale optimization
is removed from.

Some byte buffers are converted to float buffers during
color management. These cases should retain support in
the optimal path.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/114611
2023-11-09 11:02:20 +01:00
Sergey Sharybin
a4f4cb6c4a Cleanup: Sculpt, use C++ types for PBVH proxy node API
- Use float3 for coordinates inside of proxy
- Use Vector for storing coordinates and proxy nodes
- Use MutableSpan in the API to access proxy nodes

Pull Request: https://projects.blender.org/blender/blender/pulls/114638
2023-11-09 11:00:58 +01:00
Jeroen Bakker
b51027ea0c Vulkan: Fix Issues surrounding Grease Pencil Drawing
Some minor tweaks to the vulkan backend to support grease pencil
drawing. The changes include:

* Add support for GPU_DATA_10_11_11_REV clearing
* Use correct index buffer start and count

Anti aliasing isn't working as they require different samplers being
configured and that require some design work.
Effects haven't been tested.

Pull Request: https://projects.blender.org/blender/blender/pulls/114659
2023-11-09 11:00:09 +01:00
Sergey Sharybin
c3609ec435 Cleanup: Sculpt, use C++ vector types in internal types
Only converted value types in the structures.

The pointer values are left unchanged as it requires more careful look
to avoid possible alignment mismatch.

Function arguments are left unchanged as well.

Only float[3] is converted as the float[4] will likely need to be
converted to some C++ rotation class. And float[4][4] often did not
compile when change is only done in the header.

Pull Request: https://projects.blender.org/blender/blender/pulls/114636
2023-11-09 10:05:24 +01:00
Campbell Barton
fdbf235ba3 Merge branch 'blender-v4.0-release' 2023-11-09 18:45:17 +11:00
Thomas Barlow
1058a93994 Fix #106696: Invalid flag combinations used in #PyObject_GetBuffer
Code using #PyObject_GetBuffer was combining the `PyBUF_FORMAT` and
`PyBUF_SIMPLE` flags, but the documentation specifies that
`PyBUF_FORMAT` can be |'d to any of the flags except `PyBUF_SIMPLE`
because the latter already implies format `B` (unsigned bytes).

The flags in such cases have been replaced with
`PyBUF_ND | PyBUF_FORMAT`, which has the additional requirement that the
buffer must provide it's `shape` field.

This fixes `memoryview` objects raising a `BufferError` when requested,
due to the invalid combination of flags making them be considered
invalid buffers when they would otherwise be valid.

Ref: !106697
2023-11-09 18:43:05 +11:00
Thomas Dinges
801c3275f5 Release: Bump Blender 4.0 to RC, Bcon4 2023-11-09 08:17:55 +01:00
Campbell Barton
536e5323f5 Cleanup: suppress UBSAN undefined behavior warnings 2023-11-09 17:28:39 +11:00
Campbell Barton
8ee209cb77 Fix #114614: Reload scripts leaks memory
Address regression in [0] which allowed wmKeyMapItem::properties to
remain set when a valid wmKeyMapItem::ptr can't be created because the
wmOperatorType isn't available (temporarily in the case of reloading).

Resolve by freeing wmKeyMapItem::properties when the `ptr` isn't set.

Also add null pointer check not to assume wmKeyMapItem::properties
implies an allocated wmKeyMapItem::ptr. Something which is already
accounted for everywhere else.

[0]: 08e5f94a70
2023-11-09 15:48:07 +11:00
Campbell Barton
33e6e5aed1 Fix #114614: Reload scripts leaks memory
Also add null pointer check not to assume wmKeyMapItem::properties
implies an allocated wmKeyMapItem::ptr. Something which is already
accounted for everywhere else.
2023-11-09 15:37:40 +11:00
Campbell Barton
59264115ce Merge branch 'blender-v4.0-release' 2023-11-09 14:52:29 +11:00
Campbell Barton
7e12d92f40 Fix invalid value for ENUM_OPERATORS(...) macro
Use defines for multiple flags.
2023-11-09 14:51:33 +11:00