Commit Graph

101839 Commits

Author SHA1 Message Date
Jacques Lucke
868ae1092c Cleanup: move some node rna definitions to node files
This is a continuation of f7c0ef1f73.

Pull Request: https://projects.blender.org/blender/blender/pulls/110987
2023-08-10 00:01:21 +02:00
Jacques Lucke
08a8825827 Cleanup: use actual function type instead of void* in declaration
This updates the signature of `RNA_def_property_update_runtime`
which previously just has a `const void *` input. This made it difficult
to know what function signature is expected and also does not result
in compile errors when a wrong function is provided.

There is one case which required a different signature, so now there
is a separat function for that case.
2023-08-09 22:40:39 +02:00
Jacques Lucke
19912457c6 Nodes: use auto registration for nodes
The goal here is to reduce the number of files that need to be edited when
adding a new node. To register a node, one currently has to add a line to
`node_geometry_register.cc` and `node_geometry_register.hh` (for geometry
nodes). Those files can be generated automatically.

There is a new `NOD_REGISTER_NODE` macro that nodes can use to register
themselves. The macro is then discovered by `discover_nodes.py` that generates
code that calls all the registration functions. The script also works when the
register functions are in arbitrary namespaces. This allows simplifying the node
code as well.

In the past I tried a few times to get auto-registration working without resorting to
code generation, but that never ended up working. The general idea for that would
be to use non-trivial initialization for static variables. The issue always ends up
being that the linker just discards those variables, because they are unused and it
doesn't care if there are side effects in the initialization.

Related discussion regarding using Python for code generation:
https://devtalk.blender.org/t/code-generation-with-python/30558

Pull Request: https://projects.blender.org/blender/blender/pulls/110686
2023-08-09 22:01:03 +02:00
Germano Cavalcante
262b67d61d Fix Weld modifier generating invalid mesh
Bug identified in #110942.

In cases where the last corners of a polygon are out of context, the
`weld_iter_loop_of_poly_next` iterator skips these corners.

This means that some corners of the resulting mesh do not have the
value set, which can even result in infinite loops.

The solution was not simple. The iterator had to be practically redone
to not use the `loop_end` member (which caused the problem).

Fortunately the code is more simplified with this change.
2023-08-09 15:38:37 -03:00
Bastien Montagne
a37ff68334 Fix (partially) wrong RNA path for 'ViewShading' data.
This commit fixes the RNA path reported from the struct owned by the
Scene.display data. Paths generated for the View3D space remain
completely broken (but whole 'space' paths are broken anyway).
2023-08-09 20:18:25 +02:00
Clément Foucault
15124fe490 GPU: Avoid silent errors during shader compilation
To this end, replace some printf by std::cerr.
2023-08-09 18:15:36 +02:00
Clément Foucault
4d74b91d5c Fix EEVEE-Next: Shadow: Missing shadow on first frame
This was caused by the free unused data pass in the
init phase that would reset the clip data of the first
tilemap.

Uploading and checking for an invalid index fixes the
issue.
2023-08-09 18:15:36 +02:00
Amelie Fondevilla
d5b2960a07 GPv3: Include summary and datablock keyframes in the grease pencil dopesheet
This patch includes keyframes for both the summary channel, and grease pencil data-block channels.
It also includes selection in these channels, in the same modes as the ones implemented for grease pencil keyframes.

Pull Request: https://projects.blender.org/blender/blender/pulls/110962
2023-08-09 17:07:31 +02:00
Falk David
9e172b9e2e Cleanup: GPv3: Use int64_t for indices
Instead of `int` use `int64_t`.
2023-08-09 16:47:25 +02:00
Sergey Sharybin
ba81908a2d Color management: Improve no-op color space detection
Make it so transform between color spaces which is a no-op does not
peroform any calculations.

This was initially found when working on #110941, but the issue can
be replicated easily by renaming "Linear" to "Linear Rec.709" and
adding alias as "Linear".

Doing so would result in a failure of the compositor_matte_test.
The reason for that is due to the image data-block still referring
to the "Linear" color space, the name-based comparison not detecting
that "Linear" and "Linear Rec.709" are the same spaces, and that the
cryptomatte requires bit-perfect floating point values.

Pull Request: https://projects.blender.org/blender/blender/pulls/110959
2023-08-09 16:24:49 +02:00
Falk David
5eef5b0d61 Fix #110447: Curves random selection is reversed
In edit mode, the "Select Random" operator selected the inverse.
For a probability of 1, no elements were selected and vice versa.

This was because the selection actually deselects elements, but used a
mask of elements that was not inverted.

The fix takes the complement of the mask of elements, so the deselection
now does the right thing.

Pull Request: https://projects.blender.org/blender/blender/pulls/110963
2023-08-09 16:14:33 +02:00
Falk David
827a71fe7e GPv3: Refactor: replace remove_frame_at function
Instead of removing frames one by one, the `GreasePencil::remove_frames`
function now expects a span of frame numbers, replacing the
`GreasePencil::remove_frame_at` function.
Now, when drawings need to be deleted, we shrink the array only once.

Pull Request: https://projects.blender.org/blender/blender/pulls/110957
2023-08-09 16:12:45 +02:00
Aras Pranckevicius
3bf2757b47 OBJ: fix import of files with really large polygons (e.g. 7000 vertices in one poly)
Bug report #110948: a file with a polygon so large that a single line
is 140 kilobytes. The previous limit was 64kb, increase the read file
chunk limit to 256kb. Still not fully robust, would need a more
complex fix to support arbitrarily large line length limits.
2023-08-09 17:06:37 +03:00
Lukas Tönne
63115218d8 Nodes: Fixed accidental typo. 2023-08-09 16:04:59 +02:00
Lukas Tönne
063294932a Nodes: fix for silenced variable, used the wrong name. 2023-08-09 16:00:30 +02:00
Lukas Tönne
f1ec9f7190 Silence unused variable warning, from an intermediate PR.
The first part of the node panels PR has an unused API call that will be
reenabled with the next stages (#110885).
2023-08-09 15:58:23 +02:00
Jason Fielder
2367ed2ef2 macOS: Enable support for EDR rendering
Add a High Dynamic Range option in the Color Management > Display panel.
This enables display of extended color ranges above 1.0 for the 3D
viewport, image editor and render previews.

This requires a monitor that can display HDR colors, and a view
transform designed for HDR output. The Standard view transform works,
but Filmic does not as it was designed to bring values into the 0..1
range for SDR displays.

This patch is limited to allowing the display to visualize extended
colors, but does not include future looking work to better integrate HDR
into the full workflow.

It is implemented by rendering to high bit-depth texture formats for
the user interface, and uncapping the color range in color management.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/105662
2023-08-09 14:25:15 +02:00
Colin Marmond
c63bcbf906 Nodes: Hide the node preview button when the overlays are disabled
When the overlays are hidden or the previews overlays are hidden, it is
more consistent to have the preview toggle button hidden than shown.

This patch also removes the preview rendering when the previews are
hidden.

Pull Request: https://projects.blender.org/blender/blender/pulls/110949
2023-08-09 14:04:11 +02:00
Sergey Sharybin
6afbb66a53 Cleanup: Noisy warnings caused by different defines for sse2neon
The issue is visible on Apple Silicon when building Cycles.

Cycles includes sse2neon.h via two code paths: own CPU headers and
Blender's headers. The Blender headers will request higher precision
defines and Cycles does not need it (not for the kernel anyway, as
it has measurable performance penalty).

The solution is to wrap defines in the BLI_simd.h with check, so
that the flags are not re-defined.

The Blender's integration in Cycles does not really care if those
operations are precise or not, as the actual computations are done
elsewhere.

Pull Request: https://projects.blender.org/blender/blender/pulls/110953
2023-08-09 13:12:53 +02:00
Jacques Lucke
f7c0ef1f73 Nodes: define rna of nodes in node file instead of rna_nodetree.cc
The goal is to be able to define a node in as few files as possible. Currently,
RNA definitions for nodes are put in `rna_nodetree.cc`. However, it seems
surprisingly simple to move them from there to the node files. Of course this
means that `makesrna.cc` won't generate these properties and their accessor
functions anymore. Fortunately, C++ lambdas and the preprocessor make it
fairly straight forward to generate those without the `makesrna` preprocessor.
Using the preprocessor here is not great of course, but I'd argue that it feels
less magical than it was before, so it's an improvement.

This patch changes a few files to test the feasibility of this approach. Eventually,
this approach should be used by all nodes. It can't be used for shader nodes for
now, because cycles still relies on the C++ API generated by RNA.

Right now, only properties are defined the node files. The `StructRNA` is still
generated by `makesrna`. It seems feasible to generate it at runtime as well
though with potentially minor RNA API changes. This is related to #75724.

Pull Request: https://projects.blender.org/blender/blender/pulls/110840
2023-08-09 12:47:58 +02:00
Campbell Barton
f940eb7739 Cleanup: quiet compiler warnings, also correct typo & pep8 formatting 2023-08-09 20:24:24 +10:00
Campbell Barton
31cb31d736 PyAPI: add-on name-spacing for extension repositories
Support name-spaced add-ons, exposed via user configurable extension
repositories.

Directories for add-ons can be added at run-time and are name-spaced to
avoid name-collisions with Python modules or add-ons from other
repositories.

This is exposed as an experimental feature "Extension Repositories".

Details:

- A `bUserExtensionRepo` type which represents a repository which is
  listed in the add-ons repository.

- `JunctionModuleHandle` class to manage a package with sub-modules
  which can point to arbitrary locations.

- `bpy.app.handlers._extension_repos_update_{pre/post}` internal
  callbacks run before/after changes to extension repositories,
  callbacks are used to sync the changes to the Python package that
  exposes these to add-ons.

- The size of an add-on name has been increased so a user-defined package
  prefix can be included without enforcing shorter add-on names.

- Functionality relating to package management has been left out of this
  change and will be developed separately.

Further work:

- While a repository can be renamed, enabled add-ons aren't renamed.
  Eventually we might want to support this although we could also
  disallow renaming repositories with add-ons enabled as the name isn't
  all that significant.

- Removing a repository should remove all the add-ons located in this
  repository.

- Sub-module names are currently restricted to `[A-Za-z]+[A-Za-z0-9_]*`
  we might want to relax this to allow unicode characters (we might
  still want to disallow `-` or any characters that would prevent
  attribute access in code).

Ref !110869.

Reviewed By: brecht
2023-08-09 20:24:24 +10:00
Pratik Borhade
ffafc183ba GPv3: Include other channel selection modes
Support extend and extend range channel selection.

Some channeltype don't have active channel and they don't support
`extend range`. This is done in `animchannel_has_active_of_type`.
Add switch case for new GPv3 channels in above `ANIM_is_active_channel`
to detect active channels and support `extend range`

Part of #110056

Pull Request: https://projects.blender.org/blender/blender/pulls/110791
2023-08-09 12:23:58 +02:00
Sergey Sharybin
8141ee90f4 Fix #109201: Consistent mapping boundaries of brush textures
This fix makes it so the circular brush is fitted into the square
texture. This seems to be the most straightforward way to resolve
confusion of the inter-dependencies between different brush and
texture options.

Pull Request: https://projects.blender.org/blender/blender/pulls/110896
2023-08-09 11:39:58 +02:00
Bastien Montagne
23835a393c Remove compatibility code for blendfiles from early 2.80 development era.
Remove the 'SceneCollection' structure definition from DNA, and the
compatibility code converting it to the 'modern' viewlayer system.

'SceneCollection' was part at some point of the new collection system
during 2.80 development, but was never in any published Blender release.
So this code was only ensuring compatibility with a few potential
Blender files saved from in-development builds over four years ago.

Implements #110918.

Pull Request: https://projects.blender.org/blender/blender/pulls/110926
2023-08-09 11:15:27 +02:00
Sergey Sharybin
db4f926c92 Cleanup: LIST_SWAP re-definition warning
Happens on Apple M2 platform. Caused by indirectly included queue.h
via tbb, which has its own LIST_SWAP.

Rename our macro to `LISTBASE_SWAP` to avoid conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110943
2023-08-09 10:23:08 +02:00
Lukas Tönne
090f365cbd Node panels: New DNA and C++ API for node group interfaces
Part 1/3 of #109135, #110272

Adds a new DNA structure for defining node group interfaces without
using `bNodeSocket` and with additional node UI item types.

Node group interfaces are organized as a hierarchy of "items", which
can be sockets or panels. Panels can contain both sockets and other
panels (although nested panels beyond the root panel may be disabled to
avoid complexity on the user level).

Sockets can be added to the interface in any order, not just the
conventional outputs..inputs order. Sockets can be marked as both input
and output, generating 2 sockets on node instances.

The C++ API in the DNA struct allows manipulating the interface
declaration by adding and removing items, moving them inside the
interface or into a different panel.

Pull Request: https://projects.blender.org/blender/blender/pulls/110885
2023-08-09 10:06:31 +02:00
Campbell Barton
0df7d100a3 Fix #110632: context.temp_override(area=context.area) fails to restore
A context area/region override would be left cleared when the context
manager exited - if the overriding value matched the current value.

- `self->ctx_init.*_is_set` members would be set even if the those
  arguments weren't passed in, because the values would compare
  as different to NULL (unset).

- When restoring the context, setting a window clears the area & region,
  setting the area clears the region.
  This wasn't taken into account - only the members that were
  overridden were restored.

In the case of #110632, the window & region were detected as changed,
even though neither were overridden.
So the window & region were restored. The area however was set to it's
self and not marked as changed, so the area was left cleared from the
call that restored the window.

Resolve by fixing the check for overridden members & restoring
context members that will have been cleared indirectly.
2023-08-09 16:52:51 +10:00
Philipp Oeser
36cd1755d2 Fix #110721: "show_gizmo" does not switch off all gizmos
Not all gizmos were hidden when "show_gizmo" was disabled (most notably
python defined gizmos).
This was working in the 3DView and the Sequencer, but not respected in
the Clip Editor and Image/UV Editors.

Now check the flag prior to `WM_gizmomap_draw`.

Probably good for LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/110932
2023-08-09 08:31:15 +02:00
Campbell Barton
0b49379e43 Cleanup: use EXIT_{SUCCESS/FAILURE} for readability in makesrna 2023-08-09 13:47:18 +10:00
Campbell Barton
ab0bf117c9 Cleanup: use bool in makesrna 2023-08-09 13:41:32 +10:00
Campbell Barton
bff7962c80 Cleanup: remove redundant struct/void in C++, function style casts 2023-08-09 13:37:37 +10:00
Campbell Barton
8d0268b09c Cleanup: spelling in comments 2023-08-09 11:20:59 +10:00
Campbell Barton
e68302d49e Cleanup: use block-comments for multi-line comments 2023-08-09 11:17:04 +10:00
Campbell Barton
8198de0b0b Cleanup: format disabled code (missed in recent cleanup) 2023-08-09 11:13:55 +10:00
Campbell Barton
564f56ec14 Cleanup: workaround clang-format issue with LISTBASE_FOREACH macro
Surrounding LISTBASE_FOREACH by braces causes bad formatting in some
cases, workaround this with dummy statements.
2023-08-09 11:06:42 +10:00
Campbell Barton
1a675d0c47 Cleanup: format disabled code 2023-08-09 10:49:53 +10:00
Campbell Barton
faaac97239 Cleanup: format 2023-08-09 10:46:10 +10:00
Germano Cavalcante
5cdec2f12a Fix #110931: Knife Tool does not work with extreme clip distances
Due to precision issues, when clip distance is too large,
`ED_view3d_unproject_v3` may return values `inf`, `nan` or close to
`FLT_MAX` when NDC is `1.0`.

Resolve this issue by using `ED_view3d_win_to_segment_clipped` instead.
2023-08-08 17:16:29 -03:00
Brecht Van Lommel
ddf7f9a5ad Cleanup: compiler warning 2023-08-08 18:38:21 +02:00
Brecht Van Lommel
ca87897ecd Cleanup: use nullptr instead of NULL 2023-08-08 17:40:32 +02:00
Brecht Van Lommel
6e6716c180 Cleanup: compiler warnings 2023-08-08 17:37:24 +02:00
Colin Marmond
b8eb7d18e9 Nodes: experimental node previews in the shader editor
First implementation of node previews in the shader node editor. Using
the same user interface as compositor node previews, most shader nodes
can now be previewed (except group in/output and material output).

This is currently still an experimental feature, as polishing of the
user experience and performance improvements are planned. These will
be easier to do as incremental changes on this implementation.

See #110353 for details on the work that remains to be done and known
limitations.

Implementation notes:

We take advantage of the `RenderResult` available as `ImBuf` images to
store a `Render` for every viewed nested node tree present in a
`SpaceNode`. The computation is initiated at the moment of drawing nodes
overlays.

One render is started for the current nodetree, having a `ViewLayer`
associated with each previewed node. We separate the previewed nodes in
two categories: the shader ones and the non-shader ones.
- For non-shader nodes, we use AOVs which highly speed up the rendering
  process by rendering every non-shader nodes at the same time. They are
  rendered in the first `ViewLayer`.
- For shader nodes, we render them each in a different `ViewLayer`, by
  rerouting the node to the output of the material in the preview scene.

The preview scene takes the same aspect as the Material preview scene,
and the same preview object is used.

At the moment of drawing the node overlay, we take the `Render` of the
viewed node tree and extract the `ImBuf` of the wanted viewlayer/pass
for each previewed node.

Pull Request: https://projects.blender.org/blender/blender/pulls/110065
2023-08-08 17:36:06 +02:00
Clément Foucault
983ff8e616 GPU: Framebuffer: Add multi viewport support
This add the possibility to define different
viewports inside a single framebuffer and
let the vertex shader decide which viewport
to render to.

This only contain the GL and VK implementation.
The Vulkan implementation works but still
has a validation error related to shader features
and extension. The test passes nonetheless.

Pull Request: https://projects.blender.org/blender/blender/pulls/110923
2023-08-08 17:12:49 +02:00
Bastien Montagne
e1b1b2a8b4 Fix (unreported) collection 'readfile' expand incorrect assertion.
Naming is bad and confusing, but the 'expander' code path from readfile
can also be used outside of the reading context (see e.g.
`BKE_blendfile_write_partial` code). So code cannot assume that it is
exclusively working on data freshly read from file.

This should be renamed - but should also be probably replaced by
proper usage of the more generic 'foreach_id' code anyway, see #105134.

Found while investigating #109588.
2023-08-08 15:55:17 +02:00
Bastien Montagne
5dfd3e3c28 Fix (unreported) missing handling of ViewLayer IDProperties in foreach_id code.
Yet another 'obviously' missing bit in foreach_id processing found and fixed.
2023-08-08 15:24:20 +02:00
Hoshinova
b880485492 Nodes: add Floored Modulo mode to Math nodes
Both the `Math` node and the `Vector Math` currently only explicitly
support modulo using truncated division which is oftentimes not the
type of modulo desired as it behaves differently for negative numbers
and positive numbers.

Floored Modulo can be created by either using the `Wrap` operation or
a combination of multiple `Math` nodes. However both methods obfuscate
the actual intend of the artist and the math operation that is actually
used.

This patch adds modulo using floored division to the scalar `Math` node,
explicitly stating the intended math operation and renames the already
existing `"Modulo"` operation to `"Truncated Modulo"` to avoid confusion.
Only the ui name is changed, so this should not break compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/110728
2023-08-08 12:13:00 +02:00
Pratik Borhade
6e66125f34 GPv3: New is_layer_active function
New Grease Pencil function to determine whether the layer
is active.

Pull Request: https://projects.blender.org/blender/blender/pulls/110890
2023-08-08 11:26:22 +02:00
Philipp Oeser
12ef20990b Fix #103410: name collisions between vertex groups and attributes
These name collisions should be avoided with attributes, all sorts of
issues can arise from those. We already warned in the attributes
(but not the vertex groups) list if those were found.

Previously, creating a vertex group with the same name as an already
existing attribute would allow this (and give said warning), and creating
an attribute with the same name as an already existing vertex group
would silently fail (as in: not return a layer) -- and then due to an oversight
in 101d04f41f (which assumed a valid layer would always be returned
by `BKE_id_attribute_new`) would even crash.

Now name collisions between vertex groups and attributes are avoided,
unique names will be found across attributes and vertex groups if either
`BKE_id_attribute_calc_unique_name` or `BKE_object_defgroup_unique_name`
is called.

This is done by unifying the checks and callbacks for both into a single.

Pull Request: https://projects.blender.org/blender/blender/pulls/109910
2023-08-08 10:11:10 +02:00
Michael Kowalski
ecb3262bf0 USD export: prototype invoking Python chasers
This commit allows invoking user-defined Python 'hook' functions to extend
the USD export functionality.

Added support for registering subclasses of a new bpy.types.USDHook
type which may implement the hooks as member functions.  Supported
hook functions are on_export() and on_material_export().  Also added
definitions and Python registration for USDSceneExportContext and
USDMaterialExportContext structs that encapsulate arguments
to these functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/108823
2023-08-07 23:02:47 +02:00