Commit Graph

128025 Commits

Author SHA1 Message Date
Campbell Barton
4790c6ac61 addon_utils: don't print a traceback when the add-on isn't found
This was already done for ImportError but missed, ModuleNotFoundError.
2023-09-15 17:23:08 +10:00
Campbell Barton
8d62b7c01c Fix fast-path addon_utils._initialize_once not being used on startup
Changes to initialization from [0] accidentally reverted renaming
_initialize to _initialize_once.

[0] 6de294a1915217c4711def25532d3d4b728b84d1
2023-09-15 17:00:46 +10:00
Campbell Barton
af81ee37b9 Fix divide by zero displaying characters with an unknown column width
The result of BLI_wcwidth wasn't checked before using the result to
calculate a width, this cause a negative return value to be multiplied
by the font size which divided by zero.
2023-09-15 16:05:29 +10:00
Campbell Barton
bc51449ff1 Fix cursor motion across characters with an unknown column width
BLI_str_utf8_char_width returns -1 for character without a known width.
This caused the right cursor motion to skip these characters.

While editable text should not contain control characters,
cursor motion should behave properly in cases when they do.
2023-09-15 16:04:28 +10:00
Campbell Barton
635a4eac05 Fix delete key setting a control character in wmEvent::utf8_buf
The check for control characters didn't account for delete (127).
This wasn't noticeable in most cases as delete is mapped to delete text.
Pressing Shift-Delete would enter 127 control character in the
text-editor, 3D text & Python console. This happened X11 & Wayland,
I didn't check other platforms.
2023-09-15 16:01:00 +10:00
Campbell Barton
67c9056bed Fix memory leak in PyC_Err_Format_Prefix for Python 3.12
In Python 3.12 Every PyErr_Fetch must have a matching PyErr_Restore
call, otherwise references are created and never de-referenced.
2023-09-15 14:26:49 +10:00
Campbell Barton
425cc82aff Cleanup: remove unnecessary PyC_Err_Format_Prefix use
In this case there is no error to prefix, use PyErr_Format instead.
2023-09-15 14:23:16 +10:00
Campbell Barton
9903a692cc Cleanup: clarify & simplify Python traceback extraction
- Remove duplicate PyErr_NormalizeException call.
- Avoid unnecessary traceback casts.
- Remove warning about #97731 which has been resolved.
- Clarify comments.
2023-09-15 13:17:12 +10:00
Hans Goudey
99f9a53321 Attributes: Expose "is required" read-only property to Python
This allows detecting if deleting the attribute will be possible
without actually trying to delete it, which can give warning
messages in the terminal.

As an example:
```
>>> [(item.name, item.is_required) for item in mesh.attributes]
[('Attribute', False),
 ('position', True),
 ('.edge_verts', True),
 ('sharp_face', False),
 ('.corner_vert', True),
 ('.corner_edge', True)]
```

Pull Request: https://projects.blender.org/blender/blender/pulls/111468
2023-09-15 04:56:27 +02:00
Campbell Barton
9d92f03536 Fix #112399: Memory leak with exceptions from scripts in the text editor
Regression in [0] caused the function to jump to the error in the text
editor not to restore the exception, using the trace-back being iterated
over instead of the original value.

[0]: 2d2baeaf04d481f284bc2f098fb6d7ee9268151f
2023-09-15 12:23:42 +10:00
Campbell Barton
bcda667d37 Fix crash executing a script when sys.modules doesn't contain __main__
While in practice sys.modules has __main__ module, the purpose of
PyC_MainModule_Backup/Restore is to temporarily override __main__.

Running code outside of the text editor (callbacks for timers for e.g.)
could remove the __main__ module which would then crash when running
a script from the text editor.
2023-09-15 12:23:41 +10:00
Campbell Barton
7516a9c0b6 Fix Python console command execution without a __main__ module
Account for sys.modules not to have a __main__ module, various other
minor improvements too.

- Use a context manager to temporarily override the __main__ module.
- Use a context manager to override the stdin when auto-completing.
- Remove `_BPY_MAIN_OWN` constant as the __main__ module is needed.
2023-09-15 12:23:40 +10:00
Campbell Barton
2c28f87230 Fix missing weight-paint overlay popover when mixing pose & weight-paint
Since [0] mixing weight-paint & pose modes made weight-paint overlay
options inaccessible. Display both popovers in the 3D view header
in this case.

[0]: 4fa4f5432d39b1d942d603436232a00a79db491d
2023-09-15 10:49:22 +10:00
Campbell Barton
a106760efa Cleanup: use variables for the 3D View header
Avoid re-accessing values already known.
2023-09-15 10:44:45 +10:00
Campbell Barton
0ed14c813f Cleanup: remove redundant checks from space_view3d.py
The context's mode implies having an active object in the mode
being checked.
2023-09-15 10:44:43 +10:00
Campbell Barton
3c6731969e Cleanup: simplify use of tool_settings in space_view3d.py
Assign early in and reuse, access directly from context.
2023-09-15 10:44:42 +10:00
Campbell Barton
def4a06fc9 Cleanup: format 2023-09-15 10:44:40 +10:00
Pablo Vazquez
4fa4f5432d UI: Viewport: Split object/mode overlays into own popover
Move object/mode-specific overlays into their own popover
in order to reduce scrolling and improve discoverability.

Pull Request: https://projects.blender.org/blender/blender/pulls/112156
2023-09-14 21:20:48 +02:00
Habib Gahbiche
64bd2091cf Realtime Compositor tests: enable keying tests.
Tests are not crashing anymore, so no reason to skip them.

Blend files are already available in svn. Reference images have been updated in svn revision `r63481`

Pull Request: https://projects.blender.org/blender/blender/pulls/112198
2023-09-14 20:27:31 +02:00
Philipp Oeser
4086ef986c Fix #112374: loading reference/background images filters out movies
Movies are perfectly fine for reference/background images, now allow for
loading them by adjusting the default filter for the filebrowser.

Pull Request: https://projects.blender.org/blender/blender/pulls/112378
2023-09-14 19:42:26 +02:00
Pablo Vazquez
2ec2e52a90 UI: Theme: Allow transparency when editing text in widgets
Allow transparency in both text and background color, to allow blending
the selected color with whatever is underneath. Making theming more
flexible, especially since the same property is used in different backgrounds.

Note: this doesn't affect the default themes since all of them have the alpha
component in inner at `1.0`.

Pull Request: https://projects.blender.org/blender/blender/pulls/112090
2023-09-14 19:28:30 +02:00
Brecht Van Lommel
42ed81b9ab Fix #112299: crash calling context.copy() in operator with popup
The context contained an invalid region pointer after closing the popup.
In the bug report this caused problems making a copy of context.property
which accesses the region, but doing other access to context.region was
a problem as well.
2023-09-14 18:59:10 +02:00
Brecht Van Lommel
89b3249c14 UV: when finding the best packing method, use area as tie breaker
When multiple packing methods results in effectively the same bounds,
prefer the packer that uses the smallest area. When all islands can
easily fit this is usually the box packer instead of alpaca. The zigzag
method of the latter has a tendendcy to take up more area and rotate
islands.

Fix #110724: smart UV project unnecessarily rotates islands

Pull Request: https://projects.blender.org/blender/blender/pulls/112295
2023-09-14 18:57:26 +02:00
Brecht Van Lommel
d4cc0d02cb UV: disable best fit rotation of all islands at end of UV packing
This has a tendency to place islands diagonally in the image which is
not usually wanted, even if it's maximimizing the number of pixels for
the island.

Fix #109906: UV unwrap packs island diagonally instead of straight

Pull Request: https://projects.blender.org/blender/blender/pulls/112295
2023-09-14 18:57:26 +02:00
Weizhen Huang
f014e44e8b Refactor: EEVEE: add utility function for 3D texture read
with manual trilinear interpolation. Currently only used for GGX BSDF LUT

Pull Request: https://projects.blender.org/blender/blender/pulls/112386
2023-09-14 18:46:07 +02:00
Hans Goudey
05045c3e50 Fix: Duplicate node tool catalog in point cloud edit mode
This isn't available in releases yet, but point cloud edit mode is
partially working with node group operators anyway.
2023-09-14 11:45:07 -04:00
Hans Goudey
cc83951951 Geometry Nodes: Update node tool menus dynamically
See #101778

Remove the requirement of restarting Blender to refresh the
extended 3D view menus for node group changes. Also avoid
rebuilding the tree of relevant assets and catalogs on every
redraw, since parsing asset libraries, etc. could become more
expensive than we want. Those two goals combined mean we
have to be more rigorous in how we invalidate the cached
catalog tree.

The first main change required is to clear the tree as asset libraries
are being read, similar to other dynamic asset menus. This is done
with a 3D view header listener rather than a menu listener in this case.

However, that isn't enough, because there is an issue with the asset
system where the "all" library isn't updated when the current file library
changes. The solution is to explicitly rebuild the "all" library's catalogs
when other asset libraries are changed.

The other necessity for dynamic updates is clearing the catalog tree
to be rebuilt when the node group "asset traits" are changed. This is
done with a new notifier type (with the goal of being a bit selective
about when we re-read assets). This _also_ requires running the
"presave" callback that builds asset metadata when updating the
property. Otherwise saving the file and sending the notifier is
necessary, which is too confusing.

Pull Request: https://projects.blender.org/blender/blender/pulls/112166
2023-09-14 17:43:33 +02:00
Hans Goudey
d2d4de8c71 Geometry Nodes: Show uncategorized assets in separate menus
In the add modifier menu, 3D viewport menus for node tools, and the node
editor add menu, assets not in catalogs are added to an "No Catalog"
menu rather than not being accessible at all.

This makes the default behavior when adding a node tool "not broken"
so at least something happens by default. The question of "How do I
add a catalog?" is much better than "Why didn't anything happen?"

Implements #111529
See #101778

---

![image](/attachments/b943e2c4-f660-4812-b9ab-f7c116b68b98)
![image](/attachments/e6ee94d7-cd14-475f-8fa6-abcc6774fd7e)
![image](/attachments/b1718d0c-4182-49c5-867a-1399082e98f0)

Pull Request: https://projects.blender.org/blender/blender/pulls/112355
2023-09-14 17:35:24 +02:00
Lukas Tönne
4aa3735d0f Node drawing: Fix unused variables in release builds
Pull Request: https://projects.blender.org/blender/blender/pulls/112384
2023-09-14 16:33:08 +02:00
Weizhen Huang
d10a87da48 Fix: EEVEE: wrong reflectance at IOR == 0.0
should be 1 instead of 0
2023-09-14 16:13:14 +02:00
Lukas Tönne
9433a1701a Nodes: Support for input/output sockets in same vertical space
Declarations can use the `add_input_output` method to create a combined input/output socket. The drawing code supports moving sockets up one vertical slot to align them with the predecessor.

Closes #112235

Pull Request: https://projects.blender.org/blender/blender/pulls/112250
2023-09-14 16:08:04 +02:00
Weizhen Huang
5baf652374 Cleanup: EEVEE: rename glass BTDF to BSDF at several places
because it contains reflectance and transmittance, so BSDF would be a
morep proper name.
Also rename BSDF to BRDF at places where only reflectance is returned.
2023-09-14 16:06:26 +02:00
Weizhen Huang
4e00410d9e Fix: EEVEE: use inverse IOR in BSDF LUT refract()
the `refract()` function require the relative IOR of the media where V
is in to the media where L is in. Because this only affects the
visibility term, the difference is quite small
2023-09-14 16:06:26 +02:00
Julian Eisel
bb7a220e89 UI: Improve/correct vertical widget positioning in header-like regions
There was code to vertically offset layouts in header-like regions to
ensure widgets are centered properly. It wasn't clear why this was
necessary so far. I noticed this is region alignment dependent though:
The offset is only needed when the upper region edge matches the upper
area edge. I'm not entirely sure if it is the edge drawing or a slightly
smaller drawable surface of the region (clipped to be 1px less than the
area height), think it is the latter. But either way, this offsetting
makes a lot more sense now. Fix is to only apply the offset for regions
sharing the upper edge with the area. Edges at the window differ a bit,
so the offset is not applied there.

Fixes the slightly off vertical positioning of widgets in the asset
shelf header.
2023-09-14 15:47:53 +02:00
Christoph Lendenfeld
1bf789c4f4 Animation: Graph Editor locked key drawing
As people have pointed out, the changes to key drawing
in #106052 are not ideal under all conditions.

The fact that an X is drawn to indicate a key
can't be manipulated adds too much noise
on dense data and is generally confusing.

To combat that, the drawing style changed it back to dots,
but this time in gray ( the same color as disabled curves)
and slightly smaller.

This was discussed in the A&R module meeting on 2023-09-07

Pull Request: https://projects.blender.org/blender/blender/pulls/111986
2023-09-14 15:09:08 +02:00
Christoph Lendenfeld
8f1bd71992 Fix #112085: Not able to insert keys on subframes
When subframes were enabled, and the time cursor was at a subframe position,
the keying would still insert the key at the full frame.

This was because the value passed to the key insertion
functions was just the full frame value and not the subframe part.
Fixing it by using `BKE_scene_frame_get()` which
returns the floating point frame including the subframe part.

I've added unit tests to ensure that inserting keys at subframe values doesn't cause issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/112131
2023-09-14 15:07:08 +02:00
456d65b00a Show FCurve modifier toggle widget as 'inactive' when there are no modifiers
In the animation editors, show the FCurve Modifier toggle widget (the
wrench) as 'inactive' when the FCurve has no modifiers on it. Previously
the (lack of) existence of FCurve modifiers was not reflected in the
wrench icon at all.

Note: this only affects FCurves, and not FCurve *Groups*.

Pull Request: https://projects.blender.org/blender/blender/pulls/106214
2023-09-14 15:03:34 +02:00
Lukas Tönne
d2f4ebcd6a Fix #112331: Add update tags directly in bNodeTreeInterface API methods
Calling an API function after the node panels patch does not internally
tag the node tree with `NTREE_CHANGED_INTERFACE` any more, because the
node tree is not directly accessible from `bNodeTreeInterface`. Before
node panels the API functions for interfaces could tag the tree directly
for later update consideration, which now requires explicit tagging
calls.

The fix is to add a flag and mutex directly to `bNodeTreeInterface`, so
API methods can tag after updates. This mostly copies runtime data
concepts from `bNodeTree`. The `ensure_interface_cache` method is
equivalent to `ensure_topology_cache` and should be called before
accessing `interface_inputs` and similar cache data.

Pull Request: https://projects.blender.org/blender/blender/pulls/111741
2023-09-14 14:13:07 +02:00
Jacques Lucke
346b83ca01 Fix #112333: assert when creating node group with unavailable link 2023-09-14 12:41:43 +02:00
Christoph Lendenfeld
8a387d8ed6 Fix: Graph Editor first key handles not drawn
The first keyframe's handle wasn't drawn due to the recent optimizations.
This PR fixes the issue by moving `prevbezt` out of the loop again.
That is needed due to the checks in within the loop having special cases
for the first loop where `prevbezt` is a `nullptr`

Was caused by #112126

Pull Request: https://projects.blender.org/blender/blender/pulls/112365
2023-09-14 12:14:34 +02:00
Jacques Lucke
340b3ca9cb Fix #112094: negative delta time values in simulation nodes 2023-09-14 12:03:24 +02:00
Jacques Lucke
e09ee01848 Fix #112094: pass through simulation before first simulated frame
This is more expected than outputting empty data.
2023-09-14 12:02:13 +02:00
Jacques Lucke
e914004678 Fix #111411: crash with group node that references linked-but-not-found group
These group nodes currently don't have a socket declaration for every socket.
Instead we just don't touch the sockets at all so that things have not changed
when the node group is found again.
2023-09-14 11:51:05 +02:00
Jacques Lucke
11b2ac54a6 Fix #111166: crash when enabling render pass with equally named AOV
There were two issues:
* The check for conflicting AOVs was done after the Render Layer node
  was updated. This led to an unexpected state in the node.
* The check for conflicting AOVs did not work, because AOVs that already
  had the conflict-flag set were ignored.
2023-09-14 11:26:25 +02:00
Jacques Lucke
726bd3887f Fix #112335: particle instance modifier outputs wrong attributes
This was caused by a mistake in 16fbadde36.
2023-09-14 10:24:47 +02:00
Campbell Barton
d2fac8ba84 Cleanup: remove redundant text access (missed in review) 2023-09-14 16:51:53 +10:00
Matheus Santos
96339fc313 Text Editor: Auto Close Pairs on Selected Text
When the auto-close preference is enabled & brackets or quotes are
entered with a selection, the selection is surrounded by those
characters - instead of replacing the selection.

Match functionality from visual-studio code.

Ref !111900.
2023-09-14 16:25:36 +10:00
Campbell Barton
b3f9663011 Cleanup: use a mask combining all pie menu directions
Avoid looping over buttons to check which directions are in use.
2023-09-14 16:10:36 +10:00
Campbell Barton
a8db828618 UI: remove unnecessarily dead zones for pie menus
Previously when there were 5 or more menu items in a pie menu
the acceptable angle to select an item was limited to 45 degrees.

This makes sense when all 8 menu items are set, however it unnecessarily
restricts the range for menu items that don't have adjacent items.

Resolve using a 90 degree angle range then checking of the adjacent
buttons exist and are a better match.

This also resolves a very small dead-zone between adjacent buttons
for both 4 or 8 button pie menus. It was possible for a direction to
select neither. Compare the direction enum as a tie breaker.

Ref !112311.
2023-09-14 15:43:33 +10:00
Campbell Barton
c7cd1c8d0b Cleanup: use enum literals for space_type & region_type arguments
Also remove unique names for grease pencil keymaps.
There was not advantage in having separate names for each grease pencil
key-map.
2023-09-14 13:36:34 +10:00