Commit Graph

120055 Commits

Author SHA1 Message Date
Clément Foucault
0c1cbc281f Fix #130497: Overlay-Next: GPencil selection mode overlay from edit mode visible in sculpt mode
Was testing the wrong selection_domain for sculpt.
2024-11-20 14:26:13 +01:00
Bastien Montagne
c51615923b Fix #130420: Undo/Redo broken when using Transfer Mode operator.
Regression from 9e0b673467.

Not sure why the extra undo step is required after changing active object
(maybe because the mode switching to Sculpt mode of the new object
generates a 'Sculpt' undo step and not a 'Global' one?).

Pull Request: https://projects.blender.org/blender/blender/pulls/130472
2024-11-20 12:43:12 +01:00
Jacques Lucke
e62aa986b2 Format: use fmt::format correctly with runtime format strings
The `fmt::format` can process the format string at compile time. Currently, we
don't seem to be using that as we don't use `FMT_STRING`. Starting with C++20,
that will be the default though, and one has to explicitly opt out in places
where the string is not known at compile time using `fmt::runtime(...)`.
Currently, our code does not compile as C++20 because of that. Unfortunately, we
have many places with runtime format strings, because of i18n.

Pull Request: https://projects.blender.org/blender/blender/pulls/130392
2024-11-20 10:41:29 +01:00
Jacques Lucke
251731accc Cleanup: Blenloader: simplify writing BHead
This adds a `write_bhead` utility function and also reduces the scope of
some `BHead` variables. The separate `write_bhead` function was quite
useful for #129751 and will likely be useful in a potential separate
implementation too.

Pull Request: https://projects.blender.org/blender/blender/pulls/130457
2024-11-20 10:39:58 +01:00
Jorn Visser
2bf7fac176 Creator: Ensure OpenMP runtime is initialized as soon as possible
This is to make sure duplicate libomp/libiomp5 runtime conflicts are
detected as soon as a second runtime is initialized. Otherwise, it may
not crash until Blender's OpenMP runtime is initialized by a feature
that uses it, making such issues possibly go unnoticed. Such a conflict
can happen when an add-on has a native module that uses OpenMP and links
to a different libomp runtime, as was the case in #125255.

Currently Blender only ships with libomp on MacOS.

---
When libomp detects such an issue it should abort and print the following message:
```
OMP: Error #15: Initializing libomp.a, but found libomp.dylib already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://openmp.llvm.org/
```

Pull Request: https://projects.blender.org/blender/blender/pulls/130407
2024-11-20 10:23:57 +01:00
ernst-ellert
73a3ebea56 Fix #129389: Lineart modifier updates when camera changes
The bug occurred when the user changed the camera of the scene.
The lineart modifier was not updating when changing the camera, but only
when changing other elements in the scene or moving the camera.

This is resolved by adding a depsgraph update for scene parameters, such
as when changing the camera.

Testing:
Add two cameras, add a Grease Pencil Collection Line Art, go into camera
perspective view and then switch to the other camera.
The Grease Pencil Line Art now updates automatically.

Co-authored-by: YimingWu <chengdulittlea@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/129935
2024-11-20 04:47:05 +01:00
Ray Molenkamp
536937b4d4 CMake: Windows: Fix CMP0177 policy warnings
CMake 3.31+ have begun emitting warnings when you feed install()
paths that are not normalized (ie have, '.' or '..' in them) easiest
fix is just not use them.

This cleans up the windows sections of the build system, the other
platform devs will have to take a look on their respective platforms.
2024-11-19 18:53:41 -07:00
Hans Goudey
c57ebc99eb Cleanup: Use StringRef instead of std::string in a few cases
Pull Request: https://projects.blender.org/blender/blender/pulls/130534
2024-11-19 19:47:27 +01:00
Charles Flèche
428ab699dc USD: Add option to merge transform and shape on export
Adds the option `merge_parent_xform` to the USD export operator and
panels so the transform and shapes are merged into a single USD Prim.

Without the option (existing default), a top-level mesh would be
exported as a top-level `Xform` that has a `Mesh` child:
```
def Xform "MyBlenderMeshObject"
{
  matrix4d xformOp:transform = ...

  def Mesh "MyBlenderMeshData"
  {
  }
}
```

This matches the Blender data model, where a transformable object
contains a geometric shape (like a mesh). This structure is also very
valid in USD, where we don't want to directly instantiate geometric
primitives[1]

However, "since number of prims on a stage is one of the primary factors
that governs how USD scale"[2], to reduce the number of prims in a
stage, geometric primitives *are transformable* themselves (see the
inheritence diagram[3]).

As such, the new export option allows to export geometric primitives
without the parent transform:
```
def Mesh "MyBlenderMeshObject"
{
  matrix4d xformOp:transform = ...
}
```

This MR adds a the `is_object_data_context` flag to the
`HierarchyContext` context structure. The point of this change is to
make unambiguous in `USDHierarchyIterator::create_usd_export_context`
the fact that an `object` or a `data` is currently being exported: the
new `merge_parent_xform` option is meaningless for `object`. Only `data`
can be exported with a parent `Xform` or as a child of said `Xform`.

Ideally this flag would not be needed at all: the final USD prim path
*could* be computed in an override of the virtual
`AbstractHierarchyIterator::get_object_data_path` method. However, this
would mean that an `object` and a `data` would have the same export path.
This does not currently play well with
`AbstractHierarchyIterator::ensure_writer`, where `writers` are cached
*by their export path*: it would cache a transform writer, but will skip
the subsequent data writer.

Additionally, another new `is_parent` flag is added to handle the case
where merging the Xform is invalid: objects that are parents to other
objects should remain unmerged as otherwise that would yield invalid USD
files.

[1] https://openusd.org/release/glossary.html#usdglossary-gprim
[2] https://openusd.org/release/glossary.html#usdglossary-instancing
[3] https://openusd.org/release/api/class_usd_geom_xformable.html

Co-authored-by: Odréanne Breton <odreanne.breton@ubisoft.com>
Co-authored-by: Sttevan Carnali Joga <sttevan.carnali-joga@ubisoft.com>
Co-authored-by: Charles Flèche <charles.fleche@ubisoft.com>
2024-11-19 19:18:53 +01:00
Miguel Pozo
acf82cb711 Overlay-Next: Add Texture Space support
Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/130528
2024-11-19 18:10:34 +01:00
Clément Foucault
2a35551ad3 Fix: Overlay-Next: Object center selection radius too big
The selection framebuffer can be very small which leads
to different pixel density than the regular viewport.
Under this circumstance, gl_PointSize is a multiplier
of the viewport size in terms of selection radius.

Make sure `gl_PointSize` is set to 1 for selection.
2024-11-19 18:06:23 +01:00
Clément Foucault
6aedb317b0 Fix: Overlay-Next: Origins are not selectable
The implementation was missing.
2024-11-19 17:55:41 +01:00
Clément Foucault
8762087114 Overlay-Next: Add Object Axes display 2024-11-19 17:52:02 +01:00
Bastien Montagne
716d2bd9e0 Fix #130428 3DView copy/paste: report total number of copied objects.
Code used to only report the number of explicitely copied objects (i.e.
the selected ones), while some dependency objects (e.g. parents) would
also be copied, and included in the reported number of pasted objects.
2024-11-19 17:18:34 +01:00
Falk David
c46dec5b3a Fix #130521: Grease Pencil: Selection not working when everything was selected
When everything is selected, the `.selection` attribute is removed as
an optimization. In `ed::greasepencil::selection_update` for
`SEL_OP_SET` and `SEL_OP_AND`, the current selection needs to
be set to `false`. The issue is that the code checked if the attribute
exists, but does nothing when it doesn't.

The fix ensures that the attribute is created and filled with `false`.

Pull Request: https://projects.blender.org/blender/blender/pulls/130522
2024-11-19 16:39:38 +01:00
Miguel Pozo
a54bbe0b92 Fix: Overlay: In Front support
Check OB_DRAW_IN_FRONT for all object types.
2024-11-19 16:37:56 +01:00
Jeroen Bakker
c2695e2dcc Vulkan: Add support for legacy platforms
Dynamic rendering is a Vulkan 1.3 feature. Most platforms have support
for them, but there are several legacy platforms that don't support dynamic
rendering or have driver bugs that don't allow us to use it.

This change will make dynamic rendering optional allowing legacy
platforms to use Vulkan.

**Limitations**

`GPU_LOADACTION_CLEAR` is implemented as clear attachments.
Render passes do support load clear, but adding support to it would
add complexity as it required multiple pipeline variations to support
suspend/resume rendering. It isn't clear when which variation should
be used what lead to compiling to many pipelines and branches in the
codebase. Using clear attachments doesn't require the complexity
for what is expected to be only used by platforms not supported by
the GPU vendors.

Subpass inputs and dual source blending are not supported as
Subpass inputs can alter the exact binding location of attachments.
Fixing this would add code complexity that is not used.

Ref: #129063

**Current state**

![image](/attachments/9ce012e5-2d88-4775-a636-2b74de812826)

Pull Request: https://projects.blender.org/blender/blender/pulls/129062
2024-11-19 16:30:31 +01:00
Clément Foucault
8c87732454 Overlay-Next: Object Name
Overlay that display object name
2024-11-19 15:56:48 +01:00
YimingWu
07e197ba8c Fix #130453: Handle empty drawing for GPv3 in Overlay Next
`grease_pencil_edit_batch_ensure` will not create a valid batch when
there's no visible edit geometries (e.g. Current frame is before any of
the GPv3 key frames), this would lead to GPv3 passes drawing an empty
batch. This fix prevent empty edit batch from being put in the pass
drawing command list.

Pull Request: https://projects.blender.org/blender/blender/pulls/130493
2024-11-19 15:47:48 +01:00
Clément Foucault
ee05765cc1 Fix: Overlay-Next: Do not draw object center on duplis
Also centralize instance these check into utility function.
2024-11-19 15:20:16 +01:00
Jacques Lucke
4ae1ca34a3 BLI: support constructing Map with items
This adds support for constructing a `Map` directly from key-value-pairs.
If the same key exists multiple times, only the first one is taken into account.

Note: the keys and values are copied into the map (not moved). This is because
an `std::initializer_list` is read-only. If move-behavior is needed, it is better to
use the existing `map.add*` functions.

```cpp
Map<int, std::string> map = {{1, "where"}, {3, "when"}, {5, "why"}};
````

Pull Request: https://projects.blender.org/blender/blender/pulls/130470
2024-11-19 14:47:58 +01:00
Jacques Lucke
1125d6ee15 Cleanup: Attributes: rename AttributeKind to AttributeDomainAndType
There is not really a good definition for what an "attribute kind". There are
many possibilities, it could include domain, type, geometry type, default value,
usage, ...

So it's better not to use this generic name. With the current name, one always
has to look at the definition again to be sure what it contains and what it does
not.

The name `AttributeDomainAndType` is way more explicit and does not have the
same problems. It's a bit longer, but that does not seem to be a problem in the
places where we use it.

Pull Request: https://projects.blender.org/blender/blender/pulls/130505
2024-11-19 14:31:19 +01:00
Jacques Lucke
4da580236b Refactor: Attributes: split attribute accessors to separate files
Previously, the attribute accessor were defined in the `geometry_component_*.cc`
files. This made sense back in the day, because this attribute API was only used
through `GeometryComponent`. However, nowadays this attribute API is independent
of `GeometryComponent`. E.g. one can use `mesh.attributes()` without ever
creating a component.

The refactor contains the following changes:
* Move attribute accessors to separate files for each geometry type. E.g. from
  `geometry_component_mesh.cc` to `mesh_attributes.cc`.
* Move implementations of e.g. `Mesh::attributes()` to `mesh.cc`.
* Provide access to the `AttributeAccessorFunctions` without actually having a
  geometry. This will be useful to e.g. implement
  `attribute_is_builtin_on_component_type` without dummy components.

Pull Request: https://projects.blender.org/blender/blender/pulls/130516
2024-11-19 14:28:01 +01:00
Jeroen Bakker
a5f8dbe9b5 Fix: Incorrect assert introduced in recent commit 2024-11-19 13:59:09 +01:00
Falk David
c4febb68b8 Fix: Compiler warning
Introduced in 5d2405f6cd.
Forgot to remove the local variable.
2024-11-19 13:45:58 +01:00
Jeroen Bakker
8b9b67f2d3 Cleanup: Vulkan: Don't over-allocate render areas/viewports
In multiple parts (framebuffer and shader) the render areas/viewport could be
copied in an array of 16 structs, when only one is needed. This PR will use builder
patters so we don't over-allocate. Would spend less CPU cycles when constructing
render info, render passes/framebuffers, shaders.

Cleanup was part of !129062

Pull Request: https://projects.blender.org/blender/blender/pulls/130515
2024-11-19 13:40:12 +01:00
Jeroen Bakker
b9dab68ce2 Vulkan: Support clearing GPU_DATA_2_10_10_10_REV textures
Using floats to clear GPU_DATA_2_10_10_10_REV textures were not
supported. It will be needed to support legacy platforms.

Detected during development of !129062

Pull Request: https://projects.blender.org/blender/blender/pulls/130511
2024-11-19 13:39:36 +01:00
Jeroen Bakker
9ff98de6b4 Vulkan: Fix workbench XRay
XRay also uses depth only shaders, where the framebuffer has empty
attachment slots. This is not compatible with Vulkan render passes and
should be phased out.

Ref: !130258

Pull Request: https://projects.blender.org/blender/blender/pulls/130510
2024-11-19 13:38:58 +01:00
Jeroen Bakker
a499c711a9 Vulkan: Refactor descriptor set bindings
Shader interface used shader create info bind types to communicate bind
types to descriptor sets. However Vulkan supports more bind types than
Blender exposes in its API. Current implementation resulted that next to
the bind type the actual resource was queried to find out what needed to
be done.

This PR makes it more clear to convert the shader create info bind type
to `VKBindType` that contains the vulkan bind types we support.

Pull Request: https://projects.blender.org/blender/blender/pulls/130509
2024-11-19 13:38:13 +01:00
Jeroen Bakker
560c75e59c Cleanup: Vulkan: Remove unused code
Code is a left over and should not be used. It has been replaced by `VKResourceBinding`

Pull Request: https://projects.blender.org/blender/blender/pulls/130507
2024-11-19 13:35:47 +01:00
Jeroen Bakker
4018e52d30 GPU: OpenGL&Vulkan incorrect workarounds GLSL
OpenGL & Vulkan has workarounds when gl_Layer/gl_ViewportIndex isn't
supported. In this case a geometry shader will is generated. This
geometry shader doesn't follow the GLSL standard and doesn't work on
some platforms. This has not been an issue as the platforms that
don't support gl_Layer/gl_ViewportIndex don't show the issue.

According to the specs gl_Layer and gl_ViewportIndex should be set for
each call to EmitVertex. A shader should not rely on that EmitVertex
reuses the same memory.

Ref https://www.khronos.org/opengl/wiki/Geometry_Shader#Layered_rendering
```
Warning: gl_Layer and gl_ViewportIndex are GS output variables. As such, every time
you call EmitVertex, their values will become undefined. Therefore, you must set
these variables every time you loop over outputs.
```

Issue detected during development of !129062

Pull Request: https://projects.blender.org/blender/blender/pulls/130506
2024-11-19 13:35:09 +01:00
Falk David
5d2405f6cd Fix: Grease Pencil: Double drawing user increment
The `add_layers_with_empty_drawings_for_eval` function incremented the
user count of the drawings twice because `add_empty_drawings` creates
drawings with one user.

Pull Request: https://projects.blender.org/blender/blender/pulls/130514
2024-11-19 12:52:15 +01:00
Pratik Borhade
26c6c8ff98 Fix: GPv3: Sample weight crash
Crash due to nullptr when unified weight is disabled.
Wrong `toolsetting->paint` was passed to `BKE_paint_brush`.

Pull Request: https://projects.blender.org/blender/blender/pulls/130495
2024-11-19 12:20:14 +01:00
YimingWu
07a4e656e0 Fix #130501: Duplicated black materials adding GPv3 stroke
When adding GPv3 "Stroke" object into the scene from object add menu,
there was a duplicated black material being added. Probably a typo.

Pull Request: https://projects.blender.org/blender/blender/pulls/130508
2024-11-19 12:08:05 +01:00
Pratik Borhade
6314b55ab2 Fix #130475: GPv3: Update object data after changing subdivision levels
Changing subdivision levels in subdiv modifier does not update object
and viewport stats. This is due to missing depsgraph update.

Pull Request: https://projects.blender.org/blender/blender/pulls/130490
2024-11-19 11:53:27 +01:00
Omar Emara
54fa1f9bb7 Compositor: Implement Cryptomatte for new CPU compositor
Reference #125968.
2024-11-19 12:47:23 +02:00
Jacques Lucke
8528407a18 Cleanup: rename ComponentAttributeProviders to GeometryAttributeProviders
This API is used even without `GeometryComponent` nowadays.
2024-11-19 11:37:29 +01:00
Iliya Katueshenock
ae0ab14716 Cleanup: BLI: Binary search first_if and last_if utils
Cleanup to simplify code by using common terms like _first_ and _last_ in context
of predicate applying in a range just like we do for spans and range containers.

Pull Request: https://projects.blender.org/blender/blender/pulls/130380
2024-11-19 11:05:57 +01:00
Thomas Dinges
e16cc94c5c Merge branch 'blender-v4.3-release' 2024-11-19 10:05:45 +01:00
Sean Kim
2b18cad88b Fix #130459: Select tools do not work in Weight Paint
Introduced in 23cd299ba7

Pull Request: https://projects.blender.org/blender/blender/pulls/130480
2024-11-19 09:52:10 +01:00
Jesse Yurkovich
7788c85472 Cleanup: USD: remove dead fields from ImportSettings struct
Looks like the initial version of this struct was copied from Alembic.
Remove the fields that were never ultimately used and initialize the
remaining fields inline.

Pull Request: https://projects.blender.org/blender/blender/pulls/130492
2024-11-19 08:16:09 +01:00
YimingWu
911ccac5f8 Fix #130198: GPv3 build modifier timing for nature drawing speed
GPv3 build modifier in "Nature Drawing Speed" mode didn't finish
building a frame when the time it took to draw those strokes by hand is
greater than the frame duration. Previous fix #129894 is only effective
for "Number of Frames" build mode. This fix moved the timing scaling
into `get_build_factor` and `get_factor_from_draw_speed` for more
granulated control in different modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/130199
2024-11-19 05:16:16 +01:00
Germano Cavalcante
9b3fb99bc9 Fix #116551: gpu.types.Buffer always returning 'FLOAT' type on MacOS
The issue involves using const on a variable that is later modified.
2024-11-18 23:24:48 -03:00
Sean Kim
54c0699413 Fix: Assert when undoing sculpt deformation
Pull Request: https://projects.blender.org/blender/blender/pulls/130477
2024-11-18 22:29:17 +01:00
Clément Foucault
eeeac09241 DRW: Update reference for pass_all_commands and manager_sync tests
These were not updated after functional changes.
2024-11-18 21:33:17 +01:00
Germano Cavalcante
dc653b94cc Cleanup: merge transform_data.hh into transform.hh
What's in one ends up mixing with the other. There's no need to keep
the two headers separate.
2024-11-18 17:13:35 -03:00
Germano Cavalcante
cc293577d6 Cleanup: Replace TRANSDATABASIC macro with explicit struct 2024-11-18 17:13:35 -03:00
Germano Cavalcante
1cc113dd5c Refactor: Transform - Remove the member 'TransData::ob'
This member was only really used by `transform_convert_object.cc` and
`transform_convert_object_texspace.cc`.

So instead of using a super-specialized member, use `TransData::extra`
instead.
2024-11-18 17:13:34 -03:00
Germano Cavalcante
ba3d017929 Transform: remove unused "GPENCIL_SHRINKFATTEN"
Since `c986aa03b9`, this mode is no longer used and is quite difficult
to access, as in version 4.3, `ob->data` should never be of type
`bGPdata *`.

Pull Request: https://projects.blender.org/blender/blender/pulls/130406
2024-11-18 21:09:07 +01:00
Lukas Tönne
8e8d21a8ca Fix #130456: GP Render engine crash due to C/C++ mix
1d48d842 introduced a float4x4 matrix in the GPencil render data, but that
struct must be trivially initializable. Use a conventional C matrix to avoid
crashes.

Pull Request: https://projects.blender.org/blender/blender/pulls/130468
2024-11-18 19:42:43 +01:00