Commit Graph

102262 Commits

Author SHA1 Message Date
Julian Eisel
7fb58a33f0 Fix #111332: 4.0 files cannot be opened in 3.6, invalid region types
4.0 files now include asset shelf regions in 3D views. This region type is not
known to older Blender versions. So far, in such cases we would just change
the region type to be the first known region type and keep the region storage
otherwise. This was arbitrary, and in fact unsafe: the reused settings may
violate invariants/assumptions for a region type and worse, the
`ARegion.regiondata` can only be interpreted and correctly written to files
if the region type is known.

Make sure all invalid regions (regions where the type cannot be restored) are
removed on file read.

Committed to 3.6 release branch as e2d4403497.

Pull Request: https://projects.blender.org/blender/blender/pulls/111483
2023-08-29 14:10:43 +02:00
Weizhen Huang
dc9589d3e4 Cleanup: use utility function for LUTs parametrized by cos_theta and roughness
Pull Request: https://projects.blender.org/blender/blender/pulls/111651
2023-08-29 14:08:38 +02:00
Weizhen Huang
3876133ef5 Fix wrong factor in EEVEE multi-GGX average color
The original paper is assuming `f90 == 1`. However, it is just an
estimation, and the difference is really subtle.
2023-08-29 14:06:37 +02:00
Julian Eisel
567e3b9b19 Assets: Always use guarded allocator for weak references
Although I don't like the idea of using owning raw pointers in new APIs
like this (violates fundamental C++ good practises), this type is mostly
meant for writing to files via DNA. So we have to use Blender's memory
management via the guarded allocator here.

Considered making this an alternative function, but then we'd have to
duplicate logif or duplicate memory or so. Not worth it to me.
2023-08-29 13:49:58 +02:00
Philipp Oeser
cc01bb83f6 Fix #111490: paint radius set to 1 (shift-smoothing but brush missing)
This affected sculpt, vertex- and weightpaint.

So attempting to (temporarily) switching to the smooth/blur tools from
another tool using the "Shift" shortcut can fail if the corresponding
smooth/blur brush is not found/missing [which was the case in the report
because the brush was deleted].

In this case, brushes dont really get switched, but blender would still
try to cache the size (because the smooth/blur brush temporarily uses
the same size as the previous brush) of the smooth brush in
`StrokeCache` (see `smooth_brush_toggle_on`). Then in
`smooth_brush_toggle_off` it was assumed brushes were actually switched
and the (non-existing) size of the (missing) smooth brush was applied to
the **actual** brush.

Now restructure code a bit so in the case of a missing brush we can
early out (without affecting the **actual** brush then).

Pull Request: https://projects.blender.org/blender/blender/pulls/111516
2023-08-29 13:44:35 +02:00
Weizhen Huang
a69352824e Cleanup: simplify terms in EEVEE multiscatter GGX
Also update some comments

Pull Request: https://projects.blender.org/blender/blender/pulls/111634
2023-08-29 12:50:53 +02:00
Jacques Lucke
f518e86128 Cleanup: remove unused function
This exists now in `node_geo_switch.cc`.
2023-08-29 12:43:02 +02:00
Iliya Katueshenock
cbf8bb9eb9 Nodes: move more rna code to geometry node file
Continuation of 63fd2575e6.
Only geometry nodes with inline enum arrays, shared arrays and filter functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/111329
2023-08-29 12:15:40 +02:00
ChengduLittleA
0798aae01c Fix #111607: Do not unregister internal nodes
Registering a node with a `bl_idname` same as a built-in node will lead
to crash because `rna_Node_unregister` does not check `nt->rna_ext.data`
to see whether it's not null (which indicates whether this node is
registered with python or not). Now fixed.

Pull Request: https://projects.blender.org/blender/blender/pulls/111615
2023-08-29 09:35:45 +02:00
Campbell Barton
ebd4d1e2d6 Fix dangling pointer while scrubbing in the sequencer
SeqCache::last_key could be set to freed memory while scrubbing
two images in the sequencer.
2023-08-29 17:19:49 +10:00
Campbell Barton
941dbbc175 Cleanup: various minor C++ changes 2023-08-29 16:43:20 +10:00
Campbell Barton
d06da5a6ad License headers: add missing header 2023-08-29 16:32:25 +10:00
Campbell Barton
eec449ffe8 Cleanup: correct spelling, comments
Hyphenate words in GLSL code-comments.
2023-08-29 15:55:09 +10:00
Harley Acheson
1e0ddab5b8 Cleanup: Make format
Just formatting changes in mesh_merge_by_distance.cc
2023-08-28 21:38:38 -07:00
Harley Acheson
04285c2d0e UI: Node Grid Adjustments for Line Width
Have Line Width change Node Grid point size but NOT grid spacing.

Pull Request: https://projects.blender.org/blender/blender/pulls/111640
2023-08-29 06:33:21 +02:00
Hans Goudey
0b23816d5c Cleanup: Use Map instead of std::map for USD mesh writer 2023-08-28 22:45:10 -04:00
Hans Goudey
59d1fc4b61 Cleanup: Simplify USD export mesh data access
- Copy positions with a single copy for the entire array
- Use a utility function to copy face sizes
- Use simple copy for corner vertex indices instead of face iteration
2023-08-28 22:45:04 -04:00
Hans Goudey
df7f22d28e Cleanup: Simplify mesh primitive grid and cuboid quad creation
Fill face offsets in one multithreaded loop with an offset indices
utility function instead of keeping track of the index and setting
the offset for each face.
2023-08-28 21:57:22 -04:00
Rawalanche
411cd827b7 Nodes: Move Auto-Offset toggle to User Preferences
Move Auto-Offset toggle from Node Editor View menu
into the Editing > Node Editor section of User Preferences,
to reflect its use as a workflow option not configured
per editor or per file.

Pull Request: https://projects.blender.org/blender/blender/pulls/111589
2023-08-29 01:18:33 +02:00
Iliya Katueshenock
226359ec48 Mesh: Parallelize vertex and edge to corner topology map creation
Change the algorithm to make better use of multiple CPU cores. First
offsets are created by counting the number of elements using each
vertex. Those offsets are used during the next phase that adds indices
to each group in parallel. Atomic increments are used to add elements
to each group. Since the order in each group is non-deterministic,
they are sorted in parallel afterwards.

The performance improvement depends on the number of cores, CPU caches,
memory bandwidth, single threaded performance, and mesh topology. In
our tests, performance improved by 3-4.5x for large grid-like meshes.

See [1] for investigation of this algorithm and potential alternatives.

1. https://hackmd.io/@s0TMIS4lTAGwHVO20ECwpw/build_edge_to_loop_map_tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/110707
2023-08-28 22:32:31 +02:00
Miguel Pozo
ee7e187b7f Fix #111561: Workbench-Next: Overlay in-front compositing
Copy the in-front depth buffer to `DefaultTextureList::depth_in_front` for
correct overlay compositing.

Pull Request: https://projects.blender.org/blender/blender/pulls/111630
2023-08-28 21:01:56 +02:00
Miguel Pozo
0fa8b099a5 EEVEE-Next: Move the transmittance LUT to the Utility Texture
Saves one texture slot for forward materials.

Pull Request: https://projects.blender.org/blender/blender/pulls/111535
2023-08-28 21:01:08 +02:00
Germano Cavalcante
a0c5467b7d Fix #111592: Merge modifier may crash in some cases
The count of faces destroyed could be wrong when more than one groups
of vertices on the same face resulted in the face collapsing.

The solution is to break the loop on the first collapsed face
detection.

Caused by 6ec842c43c.
2023-08-28 14:33:48 -03:00
Miguel Pozo
3acda70d8c Fix: Workbench-Next: Viewport Image Render 2023-08-28 18:12:39 +02:00
Bastien Montagne
5ba692898e I18N/UI messages fixes. 2023-08-28 18:02:31 +02:00
Almaz-Shinbay
60560c7da5 Cleanup: remove irrelevant comment in TreeElementModifier
The comment doesn't provide any useful information, as it wasn't removed
before the merge of 28f4bb2007.

Pull Request: https://projects.blender.org/blender/blender/pulls/111621
2023-08-28 17:32:50 +02:00
Bastien Montagne
a931c7e7b4 Writefile: Enable some checks systematically when writing blendfile.
These checks (shape keys and ID names) cost less than 1ms in Pets
production files, so think they are OK to run systematically.

The library consistency one is way more expensive (~200ms), so keeping
it behind the G_DEBUG_IO debug option for now.
2023-08-28 15:44:36 +02:00
Jeroen Bakker
779bfe2734 Cleanup: Make format 2023-08-28 15:31:20 +02:00
Gilberto Rodrigues
fb6687a790 Viewport: Add toggle for edit mode overlays fresnel
Adds a userpref toggle for the edit mode overlays fresnel.
The edit mode fresnel is only a bit useful in edge cases, like
very dense photogrametry, and the problem is that it causes
more eye strain when modeling for many hours. And it's
benefit on shape readability is small compared to it's negative
impact on selection visibility. It makes the selection color to a
darker less saturated color instead of the theme color, which
leads to worse contrast between the selection and the mesh
or with the background, and also makes the unselected (black)
brighter, also reducing contrast. So it's off by default.

This was split up from https://projects.blender.org/blender/blender/pulls/110097

Pull Request: https://projects.blender.org/blender/blender/pulls/111494
2023-08-28 15:29:25 +02:00
Bastien Montagne
52300ccc87 Writefile: Add validation of ID names as part of pre-write checks.
NOTE: This code remains only executed in 'unlikely' case `G_DEBUG_IO` is
enabled. Think this should be systematically done, even though it can
have a non-neglectable cost... Will submit design task first though.
2023-08-28 15:18:50 +02:00
Hans Goudey
3db523ab3e Cleanup: Move BLO headers to C++
Except for BLO_readfile.h, which is still included by C files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111610
2023-08-28 15:01:05 +02:00
Bastien Montagne
66c05fe368 Fix RNA collection accessor (string search) not checking for null key pointer.
While in a way one could argue calling code could check for such case,
in practice it is way handier for the search code itself to just return
'not found' value in such case, rather than crash!
2023-08-28 13:18:11 +02:00
Bastien Montagne
47672bd06a Readfile: Add validation call for invalid ID naming.
Add a call to `BKE_main_namemap_validate_and_fix` in the 'general
sanity validation' `after_liblink_merged_bmain_process` function.

This will detect, fix and report invalid ID naming issues (case found in
an early Gold production file).
2023-08-28 13:18:11 +02:00
Bastien Montagne
c4a0bd7d50 Fix BLI_findstring_ptr & co. potentially accessing NULL pointer.
By definition, unlike in `BLI_findstring` & co, there is no guarantee
that the `const char *id_iter` pointer here is not a NULL one.
2023-08-28 13:18:11 +02:00
Sergey Sharybin
42473099b4 Cleanup: Braces around initialization
Pull Request: https://projects.blender.org/blender/blender/pulls/111605
2023-08-28 12:46:27 +02:00
Jeroen Bakker
3806febb15 Cleanup: Make format 2023-08-28 11:12:40 +02:00
Gilberto Rodrigues
1f4c7a36df Wireframe color option for all shading modes
Enables three options of wireframe color for all shading modes: theme color, object color
and random color.  Previously this was exclusive to the wireframe shading mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/111502
2023-08-28 11:04:40 +02:00
Campbell Barton
35a5297ae6 Cleanup: replace magic number with sizeof(..) 2023-08-28 18:56:25 +10:00
ChengduLittleA
02406e17a0 Fix #111601: VSE strip modifier copy ensure unique name
Previously `SEQ_modifier_list_copy` in append mode does not ensure
unique strip name, which will result in duplicated names in target
modifier list, then `strip_modifier_remove(name="something")` can remove
the wrong one later on. Now fixed using `BLI_uniquename`.

Pull Request: https://projects.blender.org/blender/blender/pulls/111602
2023-08-28 10:05:22 +02:00
Campbell Barton
c388ff6f89 Viewport: show fractional FPS playback values
When the scenes FPS is not a whole number - display the fractional FPS
in the viewport. Previously, 29.97 FPS would round to 30 FPS for e.g.
2023-08-28 17:25:18 +10:00
Weizhen Huang
8a735d0aa4 Fix: EEVEE: Incorrect GGX BRDF pdf and BTDF evaluation
* Using standard NDF and Smith shadowing-masking terms. The previous
`xxxx_opti()` functions were faster to evaluate, but confusing and
error-prone.
* After correcting the BRDF pdf, the prefiltered environment LOD bias
needs to be adjusted to avoid overblurred reflections.
* Corrected the half-vector computation in BTDF evaluation, added check
for invalid configuration due to total internal reflection or `eta == 1`.
* Use `saturate()` instead of `max()` when no division is needed because
the former is faster.
* Indirectly fixes EEVEE-Next refraction denoising.

Pull Request: https://projects.blender.org/blender/blender/pulls/111591
2023-08-27 20:51:32 +02:00
Campbell Barton
6538a58725 Correct missing include from 7458d68b35
This worked on Linux but failed on WIN32 & macOS.
2023-08-27 19:13:14 +10:00
Campbell Barton
0e2f4046c6 Fix #111579: erratic viewport FPS at high frame rate
Setting the FPS to 120 caused the FPS to flicker erratically between
130 & 140 FPS.

This also impacted lower frame-rates with 23.98 playing back at 24.03
FPS on my system, 30 FPS played back at 30.13 FPS.
This problem was hidden by the FPS display rounding to an integer.

Regression in 2.5x series (worked in 2.49).

Resolve by clamping the sleep time in the main event loop so the 5ms
sleep doesn't result in sleeping when timers are scheduled to run.

There is still some visible FPS jitter that can be solved by using a
higher resolution sleep interval but that's out of scope for this fix.
2023-08-27 17:26:05 +10:00
Campbell Barton
7458d68b35 Scene: increase the number of FPS samples, use fixed-point arithmetic
Using a higher number of samples (enough samples to account for the last
second or two of playback for e.g.) can be useful when comparing minor
changes in overall playback speed, where the behavior of multi-threaded
operations can make the value jitter with 8 samples (default).

Using fixed-point arithmetic means the average FPS can be updated
by subtracting the oldest FPS sample before adding the new value,
instead of having to average an array of floats every draw.
Increasing the number of samples now only uses a little more memory
(20kb at most).

The error margin from using fixed-point arithmetic is under 0.5
microseconds per frame - more than enough precision for FPS display.
A commented define is included that shows the error margin when enabled.
2023-08-27 12:25:32 +10:00
Weizhen Huang
03071e8c02 Cleanup: remove unused test file
This file was committed by mistake. There is no lightprobe test
2023-08-26 21:09:04 +02:00
Campbell Barton
b274952694 Cleanup: move scene FPS calculation into it's own file
Defining ED_scene_* functions in screen_edit.cc didn't make much sense.
Also make ScreenFrameRateInfo a private struct.
2023-08-26 19:02:02 +10:00
Campbell Barton
19850496cb Cleanup: remove unused function, format 2023-08-26 17:05:19 +10:00
Weizhen Huang
67843e188b Fix: EEVEE-Next: incorrect GGX BRDF LUT coordinates 2023-08-26 00:23:00 +02:00
Rawalanche
d86d2a41e0 Fix #94148: Top bar, Status bar Header Colors Differ from Theme Setting
Fixes the Top and Status bars having their specified theme colors
incorrectly modified by highlight effect intended for active editor
headers only

Pull Request: https://projects.blender.org/blender/blender/pulls/111265
2023-08-26 00:16:20 +02:00
Hans Goudey
383a145a19 Mesh: Share normals caches by splitting vertex and face calculation
Since vertex and face normals can be calculated separately, it simplifies
things to further separate the two caches. This makes it easier to use
`SharedCache` to avoid recalculating normals when copying meshes.

Sharing vertex normal caches with meshes with the same positions and
topology allows completely skipping recomputation as meshes are
copied. The effects are similar to e8f4010611, but normals are much
more expensive, so the benefit is larger.

In a simple test changing a large grid's generic attribute with geometry
nodes, I observed a performance improvement from 12 to 17 FPS.
Most real world situations will have smaller changes though.

Completely splitting face and vertex calculation is slightly slower
when face normals aren't already calculated, so I kept the option
to recalculate them together as well.

This simplifies investigating the changes in #105920 which resolve
non-determinism in the vertex normal calculation. If we can make the
topology map creation fast enough, that might allow simplifying this
code more in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/110479
2023-08-25 23:06:06 +02:00