Commit Graph

104896 Commits

Author SHA1 Message Date
Hans Goudey
7020a4ff1a Cleanup: Remove unused voxel sampling functions
Last used in Blender internal renderer.
2023-11-28 13:30:18 -05:00
Hans Goudey
573b4728cb Cleanup: Remove unused BLI voronoi code
Unused after 75c947a467
2023-11-28 13:24:45 -05:00
Habib Gahbiche
ff083c1595 Compositor: UI: better node visibility for default node tree
Create default compositor node tree centred around x-axis, and with lower y-offset for better visibility

Pull Request: https://projects.blender.org/blender/blender/pulls/115439
2023-11-28 18:45:37 +01:00
Hans Goudey
81abaaad6b Fix #115521: Voxel remesh resets smooth with attribute propagation off
Add a special case for the sharp_face attribute to use the sharpness
of the first face, the same as before ba1c8fe6a5
2023-11-28 12:45:14 -05:00
Hans Goudey
321c1af26e Cleanup: Remove unnecessary mesh C-API functions 2023-11-28 12:26:51 -05:00
Hans Goudey
f2467f75b3 Cleanup: Remove mesh "vert coords" functions
Inlining the functions is simpler nowadays, since there are utility
functions to copy spans and tag the mesh caches dirty. Also use an
array instead of a raw pointer for multires.
Resolves #103789
2023-11-28 12:26:51 -05:00
Nathan Vegdahl
32e56879b7 Fix: missed some version bump code 2023-11-28 18:12:21 +01:00
Nathan Vegdahl
c9093332e0 Fix #115434: custom bone colors invisible in stick mode
The issue was that bone colors are only specified with 3 channels (RGB),
but they're stored as 4 channels for some reason.  So the fourth bogus
channel gets initialized to zero by default, which was then being
interpreted as zero alpha in some drawing modes.

This fixes the issue by ensuring that the fourth unused channel always
gets initialized to 255, and therefore can be validly interpreted as an
alpha channel.

Pull Request: https://projects.blender.org/blender/blender/pulls/115477
2023-11-28 18:04:11 +01:00
Hans Goudey
21a2390f4c BLI: Add utility to reverse index mask
This utility was already duplicated in two places and planned to be used
more. While we should usually avoid creating arrays the size of the
indexed array (rather than the size of the mask), sometimes it does seem
to be the best option, and we're helped by the fact that most memory
stays unintialized for a small mask (allocating but not writing to memory
pages at all generally isn't too expensive).

Pull Request: https://projects.blender.org/blender/blender/pulls/115491
2023-11-28 17:32:17 +01:00
Hans Goudey
ed23989e2e Geometry Nodes: Remove drag & drop requirement of geometry input
Generator node groups don't need to have a geometry input, and the error
will be displayed in the modifier after it's added if it really matters.
2023-11-28 11:06:54 -05:00
Antonio Vazquez
b9fba005bd GPv3: Lock unselect materials operator
Conversion of GPv2 operator

Pull Request: https://projects.blender.org/blender/blender/pulls/115278
2023-11-28 16:38:59 +01:00
Julian Eisel
86362f14f9 UI: Improve description of custom asset library type
Description added in 9c2330d821.

It is unclear what "external" in this case means, why these asset
libraries are considered "normal" (are the others not "normal"?) and the
term "asset repository" is wrong (should be "asset library").

I think this isn't actually shown in the UI currently in fact.
2023-11-28 16:22:30 +01:00
Julian Eisel
0156169a9c Fix #115431: Crash on right click on string button inside menu
Problem is the `UI_context_active_but_get()` lookup doesn't respect menu
regions, unlike the earier call to `UI_context_active_but_prop_get()`
(which is also used to validate the existence of an active button).

Using `UI_context_active_but_get_respect_menu()` instead would work, but
in fact the earlier lookup returns the active button if any, we just
didn't use that.
2023-11-28 16:03:01 +01:00
Julian Eisel
e3b3399bcb Cleanup: Add constructor/destructor for drag data to avoid includes
`wmDragActiveDropState` contains a `bContextStore` unique pointer, so
when constructing/destructing an object of this type `BKE_context.hh`
had to be included. It wouldn't be obvious why this include is necessary
in some cases. And the pointer is otherwise managed internally in the
source file, so the need for this include shouldn't bleed into other
files.

Make sure the unique pointer construction/destruction happens in the
translation unit of the source file that otherwise also manages it.

Avoids include in #107230.
2023-11-28 15:26:39 +01:00
Christoph Lendenfeld
265aebd7be Fix: FCurve colors on bones
New FCurves for bones were not automatically set to `FCURVE_COLOR_AUTO_RGB`
because the RNA path couldn't be resolved.

That was because the `PointerRNA` passed into the function points to the bone,
but the rna path is relative to the ID.
Fixed by resolving the path from the bones owner ID

Pull Request: https://projects.blender.org/blender/blender/pulls/115517
2023-11-28 13:29:46 +01:00
Campbell Barton
d96cdb2231 Cleanup: simplify Python API use running scripts
- Remove unnecessary exception if Py_CompileStringObject fails.
- Remove unnecessary PyErr_Occurred check if Py_CompileStringObject
  succeeds (based on incorrect assumption from [0]).
- Pass closeit=1 to PyRun_FileExFlags so it's responsible for closing
  the file before executing code.
- Remove unnecessary temporary ReportList.

[0]: b9f6d66328
2023-11-28 22:33:09 +11:00
Philipp Oeser
ed556113ce Fix #114557: UI scrollbar "focus bubble" interaction wrong in cases
Some Editors like the Filebrowser or Spreadsheet set up custom masks for
scrollbars (they dont cover the whole region width or height, some rows
or colums are excluded here -- e.g. the "index" column in the
Spreadsheet), this was working fine for drawing, but mouse interaction
was ignoring these custom masks.

Symptoms were that clicking on the "focus bubble" of the scrollbar and
dragging would not result in smooth scrolling [because internally code
would assume the mouse was clicking outside], instead scroll by 1 'page'
was happening [was perceived as a massive lag]. Especially noticable
with many rows/columns (where the "focus bubble" gets small).

So for drawing (`UI_view2d_scrollers_draw`) this wasnt a problem, masks
were passed in for `view2d_scrollers_calc`.
But for interaction (`scroller_activate_init`) `view2d_scrollers_calc`
is called again and a NULL mask was passed.

The already set up rects need to be considered though, otherwise coords
for `mouse_in_scroller_handle` later are not compatible.
To fix this, use existing `View2D` rects fors scrollbars, and pass a
union of those as `mask_custom` to `view2d_scrollers_calc`.

NOTE: this can temporarily extend the `View2D` scrollbar rect by a
pixel, the next draw call will correct this again though.

Pull Request: https://projects.blender.org/blender/blender/pulls/114631
2023-11-28 12:12:18 +01:00
Philipp Oeser
a4b8d214c6 Fix #115140: Crash undoing painting on linked image from 3DView
Related commit: 82aa300e1c / 5596f79821

82aa300e1c made it so that if only linked images are used, painting
would be prohibited. But since painting in Material mode actualy paints
across all materials it could happen that one particular image is linked
whereas another image isnt. In this case, painting on the linked image
would not be prohibited.

Two issues:

- [1] logic in above commit(s) seems slightly wrong, we could still pass
the check for linked images (also no image here should also not result
in a positive check I think).

- [2] code in `project_paint_prepare_all_faces` would still work with
linked images in slots, so
-- `ProjPaintState` -> `image_tot` was incremented
-- `ProjPaintImage` was created
-- this then ends up in the undo push - and crashes on undo

So now [1] is rectified and for [2] we skip faces with associated linked
images.

In addition, slots with linked images are now also greyed out in the UI
(`VIEW3D_PT_slots_projectpaint`) to give some sort of hint. For the
future it would probably also be good to dissallow selection of such
paint slots, but that is for another commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/115263
2023-11-28 12:05:07 +01:00
Philipp Oeser
09be0915c3 Fix #115363: Scrollbars for template_lists in popups update issue
Scrollbars in popups need UI layout refresh to update the right items to
show correctly.

Pull Request: https://projects.blender.org/blender/blender/pulls/115364
2023-11-28 09:14:28 +01:00
Philipp Oeser
451a765ab3 Fix #115471: Crash opening files with particle boid goal objects
Exposed/caused by b53c7a804a

`particle_settings_foreach_id` only processed object IDs for `avoid`
(but not `goal`) -- `BoidRuleGoalAvoid` is used for both though.

Pull Request: https://projects.blender.org/blender/blender/pulls/115482
2023-11-28 09:11:11 +01:00
Campbell Barton
41739cd3fd PyAPI: remove use of stub script to execute files on WIN32
Workaround potential C-API `FILE` incompatibility by reading the
file data into memory, compiling & running it - matching existing logic
for text buffers text buffers. This replaces the in-lined stub-script
that re-opened the file from Python.

While the down-side of the stub-script was minor, it required some
non-obvious logic and had the disadvantage of requiring 2x scripts to
execute whenever a file was executed on WIN32.

Expose BLI_file_read_data_as_mem_from_handle as a public function
since it's useful to be able to read an existing FILE into memory.
2023-11-28 17:50:28 +11:00
Campbell Barton
48bc74953c PyAPI: raise an error when executing a directory on non-Windows systems
Passing a directory to --python would run it as a script without errors
since the directory would read as an empty file.

Raise an error instead because this is what Python it's self does.

This would already happen on WIN32 because the stub script was
executing the file from Python.
2023-11-28 17:40:07 +11:00
Campbell Barton
d71c449d25 PyAPI: use binary file access running scripts on non-WIN32 platforms
Python itself uses binary file access when opening files so this
shouldn't cause any problems.
2023-11-28 16:59:52 +11:00
Campbell Barton
5486c70aae Fix #115056: man-page fails to build with non-portable install
This effectively reverts [0] which required the installed Blender
along with the `bpy` module to load for the install target to generate
the man-page. It turns out running a full Blender at install time can be
quite involved.

Now the man-page generator runs `blender --help` & `blender --version`,
converting the output into a man-page from a Python script.

Some minor changes have also been made:

- Use PYTHON_EXECUTABLE so the systems Python
  (which may not be compatible) isn't used.
- Remove leading blender version from the description
  which was unintentionally being included.

[0]: 61d99d450e
2023-11-28 16:55:53 +11:00
Campbell Barton
9dda667fd4 Cleanup: spelling in comments 2023-11-28 15:19:20 +11:00
Campbell Barton
65022ad1cf Cleanup: remove redundant exception/report handling from FreeStyle
`BPY_run_*` functions print & clear the errors making any calls
afterwards that attempt to extract exception messages into NOOP's.
2023-11-28 13:30:04 +11:00
Campbell Barton
2e1486da60 PyAPI: call 'sys.excepthook' for text editor exceptions
Resolves #115090, where exceptions from the text editor called
`sys.excepthook` in v3.6 but not in v4.0.

The error was caused by PyC_ExceptionBuffer calling PyErr_Display
instead of PyErr_Print.

While technically a regression in [0], the behavior in 3.6x wasn't
working properly either since a user-defined `sys.excepthook` could
prevent PyC_ExceptionBuffer from accessing the exception text.

Resolve with the following changes:

- BPy_errors_to_report has been updated not to print errors.
  Previously BPy_errors_to_report would *sometimes* print the error,
  which complicated situations where the caller wanted predictable
  behavior (always printing or never printing).

- `PyErr_Print()` must be used to display errors to the output,
  this will call `sys.excepthook` as it used to.

It's better not to rely on side effects of BPy_errors_to_report()
for error handling.

[0]: 6a0f98aeef
2023-11-28 13:13:41 +11:00
Campbell Barton
1e84a028b3 Fix shadowing error causing a value to be assigned to it's self 2023-11-28 12:35:36 +11:00
Ray molenkamp
dbb2844ed9 Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115427
2023-11-28 01:14:15 +01:00
Ray molenkamp
94817f64b9 Cleanup: CMake: Modernize bf_intern_utfconv dependencies
- Remove any bf_intern_utfconv paths from INC
- Add a dependency though LIB when missing
- an empty target is created for non windows builds, so we don't have to
if(WIN32) this all over the place

context: https://devtalk.blender.org/t/cmake-cleanup/30260
Pull Request: https://projects.blender.org/blender/blender/pulls/115373
2023-11-28 01:11:15 +01:00
Charles Wardlaw
a9c8bf305b Cleanup: USD: Fix unused declaration and argument
Pull Request: https://projects.blender.org/blender/blender/pulls/115495
2023-11-27 21:08:17 +01:00
Damien Picard
5e38f7faf0 I18n: translate new text object body
After VFont has been updated to use the BLF API in 604ee2d036, it can
use the fallback font stack and display text in many scripts.

This change means the default text for font objects can now be
translated, instead of always being the English word 'Text'.
Translation will only occur if the user has enabled translation of new
data in the preferences.
2023-11-27 20:44:48 +01:00
Hans Goudey
721de99571 Cleanup: Add missing return 2023-11-27 13:36:20 -05:00
Hans Goudey
367423a31c Cleanup: Make format 2023-11-27 13:36:20 -05:00
Bastien Montagne
dad1eea511 Move BKE_main_idmap and BKE_main_namemap to be fully cpp headers.
NOTE: `BKE_main.h` is currently used by `writeffmpeg.c`, so not trivial
to make it a full CPP header file for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/115485
2023-11-27 18:09:27 +01:00
Hans Goudey
f1c0bce651 Cleanup: Use optional for original indices in extrude node
This is simpler than checking if spans are empty in separate lines.
2023-11-27 12:09:06 -05:00
Charles Wardlaw
925fb66693 USD: Improved texture coordinate translation (UsdTransform2d)
The UsdTransform2d shader was previously ignored, and the material
read would stop when it found these nodes. This resulted in many
surfaces having their textures mapped incorrectly when imported
into Blender, and worse, resulted in the loss of that data when
round-tripping back out of Blender.

This patch adds support for the Transform 2D node and also ensures
that the wrap modes are similarly written correctly.

Co-authored-by: Charles Wardlaw <kattkieru@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/114821
2023-11-27 17:18:46 +01:00
Hans Goudey
c31718649d Geometry Nodes: Rewrite parts of extrude mesh node
The node is still a bit non-standard in that it resizes an existing
mesh rather than creating a new one, but this commit makes the extrude
node a bit more similar to other mesh operations and makes other
miscellaneous improvements, including:
- Less use of intermediate states (compared to initial or final)
- Topology map building is no longer reimplemented for the node
- Attribute interpolation happens in a more familiar way
- Some topology maps can be skipped if a domain is empty
- More use of `IndexMask` instead of an array of indices
- Logarithmic cost index mask lookup is avoided
- Build index maps instead of implementing attribute propagation
  separately for every type

Overall these changes might improve performance in a few cases, and
they reduce Blender's binary size by 58 KB. Edge indices are different
in some cases of the edge mode, so the test files are updated.
2023-11-27 10:57:06 -05:00
Ray Molenkamp
55f19cc872 CMake: fix shader_builder build error
needed bf::imbuf got missed in a recent cmake cleanup
2023-11-27 08:33:54 -07:00
Hans Goudey
14e3523ac2 Refactor: Further improvements to geometry bounds
Implement the next phases of bounds improvement design #96968.
Mainly the following changes:

Don't use `Object.runtime.bb` for performance caching volume bounds.
This is redundant with the cache in most geometry data-block types.
Instead, this becomes `Object.runtime.bounds_eval`, and is only used
where it's actually needed: syncing the bounds from the evaluated
geometry in the active depsgraph to the original object.

Remove all redundant functions to access geometry bounds with an
Object argument. These make the whole design confusing, since they
access geometry bounds at an object level.

Use `std::optional<Bounds<float3>>` to pass and store bounds instead
of an allocated `BoundBox` struct. This uses less space, avoids
small heap allocations, and generally simplifies code, since we
usually only want the min and max anyway.

After this, to avoid performance regressions, we should also cache
bounds in volumes, and maybe the legacy curve and GP data types
(though it might not be worth the effort for those legacy types).

Pull Request: https://projects.blender.org/blender/blender/pulls/114933
2023-11-27 16:14:49 +01:00
Wannes Malfait
b162281caf Mesh: add index-independent test for mesh equality
This adds a new function, `compare_meshes`,
as a replacement for `BKE_mesh_cmp`.

The main benefits of the new version are the following:
- The code is written in c++, and makes use of the new attributes API.
- It adds an additional check, to see if the meshes only differ by
  their indices. This is useful to verify correctness of new algorithmic
  changes in mesh code, which might produce mesh elements in a different
  order than the original algorithm. The tests will still fail, but the
  error will show that the indices changed.

Some downsides:
- The code is more complex, due to having to be index-independent.
- The code is probably slower due to having to do comparisons "index-
  independently". I have not tested this, as correctness was my priority
  for this patch. A future update could look to improve the speed,
  if that is desired.
- This is technically a breaking API change, since it changes the
  returned values of `rna_Mesh_unit_test_compare`. I don't think that
  there are many people (if any) using this, besides our own unit tests.

All tests that pass with `BKE_mesh_cmp` still pass with the new version.

**NOTE:**
Currently, mesh edge indices are allowed to be different in the
comparison, because `BKE_mesh_cmp` also allowed this. There are some
tests which would fail otherwise. These tests should be updated, and
then the corresponding code as well.

I wrote up a more detailed explanation of the algorithm here:
https://hackmd.io/@bo-JY945TOmvepQ1tAWy6w/SyuaFtay6

Pull Request: https://projects.blender.org/blender/blender/pulls/112794
2023-11-27 16:10:43 +01:00
Lukas Tönne
227a4eae77 Make ImplicitSharingPtr constructor from data pointer explicit
The ImplicitSharingPtr has an implicit constructor for raw pointers.
This has unintended effects when comparing an ImplicitSharingPtr to a
raw pointer: The raw pointer is implicitly converted to the shared
pointer (without change in refcount) and when going out of scope will
decrement user count, eventually freeing the data.

Conversion from raw pointer to shared pointer should not happen
implicitly. The constructor is made explicit now. This requires a little
more boilerplate when constructing a sharing pointer. A special
constructor for the nullptr is added so comparison with nullptr can
still happen without writing out a constructor.

Pull Request: https://projects.blender.org/blender/blender/pulls/115476
2023-11-27 15:53:29 +01:00
Jacques Lucke
cf9987d548 Cleanup: remove line accidentally added in previous commit 2023-11-27 15:24:23 +01:00
Jacques Lucke
d46770703a Fix: assert when randomizing mesh with zero faces 2023-11-27 15:20:53 +01:00
Hans Goudey
eb399678f5 Fix #115366: Missing task isolation subdividing loose edges
Nowadays we have the loose edge cache which can tell us if there will be
any loose edges to subdivide. This means the topology map creation that
included multi-threading doesn't need to be behind a lock anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/115480
2023-11-27 15:19:44 +01:00
Falk David
3a743018b1 Fix: GPv3: Wrong location in paint_init_pivot
The `paint_init_pivot` calculates the `location` based
on the midpoint of the bounds of the object. For grease pencil
the bounds depend on the current frame (for original data).

This fixes the issue by making the `bounds_min_max` function
dependent on the `frame` and by introducing a `bounds_min_max_eval`
for evaluated data.
2023-11-27 15:06:38 +01:00
Falk David
8dc9a9a0e3 Fix: GPv3: Uninitialized runtime variable
The `eval_frame` was not initialized to a default value,
causing a crash in some situations on windows.
This at least avoids a crash even if the outcome of
whatever uses the `eval_frame` might not be correct.
2023-11-27 15:06:38 +01:00
Miguel Pozo
fe90c82b20 EEVEE-Next: Fix ObjectHandle::recalc
Implement the EEVEE side of #114112.
Use ObjectRuntime::last_update to compute the ObjectHandle::recalc
flags.

Fix #114135
Fix #114696
Fix #114170

Pull Request: https://projects.blender.org/blender/blender/pulls/115243
2023-11-27 12:23:18 +01:00
Jeroen Bakker
8ae80abe5f Fix: Various Small GLSL Material Tweaks
We should use explicit casting. Although it is not always needed it
is a best practise in order to support the shaders on Metal.

* `float max(float, int)` is not supported on Metal and fails with a compilation error

Pull Request: https://projects.blender.org/blender/blender/pulls/115464
2023-11-27 12:06:28 +01:00
Miguel Pozo
78de9138e5 Core: Add ObjectRuntime::last_update transform, geometry and shading
Track the last time an object or its dependencies were evaluated by the
dependency graph.
These values can be compared against DEG_get_update_count().
Implemented following the design from #114112

Pull Request: https://projects.blender.org/blender/blender/pulls/115196
2023-11-27 12:03:17 +01:00