Commit Graph

150077 Commits

Author SHA1 Message Date
Bastien Montagne
2900cfa50a MEM_guardedalloc: Add template 'type-safe' versions of MEM_mallocN.
Same thing as for `MEM_callocN<T>` and `MEM_freeN<T>` in dd168a35c5,
allows to reduce type verbosity, and increase type safety.
2025-03-05 19:35:50 +01:00
Guillermo Venegas
82e2a57dcd Core: RNA: Use VectorSet for StructRNA properties lookup
Replace the  `Ghash` `prophash` properties map in RNA containers by a
`CustomIDVectorSet` `prop_lookup_set`.

This commit also allows for runtime-defined RNA Struct types to use
`CustomIDVectorSet` for properties lookup, instead of only relying on linear
search in the ListBase property list.

NOTE: This also simplifies a bit the code compared to using Ghash, since the
string key is contained whiting the property, and not stored separately as in the
GHash. It also means that the string key (the property identifier)  is 'automatically'
updated in the VectorSet when updated in the property itself. This avoids the
need to re-insert the property when its identifier string is duplicated into a new
memory address. However, modifying the property identifier would cause
undefined behavior if the property is not removed from the vector set first.

-----

While its an impractical example, the following custom PropertyGroup example shows the potential slowdowns just
of looking through the ListBase

``` py
import bpy

test_properties_script = "import bpy\nclass TestProperties(bpy.types.PropertyGroup):"

property_count=10000
for x in range(property_count):
    test_properties_script+="\n    prop_{0} : bpy.props.IntProperty(name=\"Prop {0}\")".format(x)

exec(test_properties_script)

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Test in the text editor side panel to test ui perfomance"""
    bl_label = "Test"
    bl_category = "Test"
    bl_idname = "TEXT_PT_test"
    bl_space_type = 'TEXT_EDITOR'
    bl_region_type = 'UI'

    def draw(self, context):
        layout = self.layout
        layout.use_property_split=True
        layout.use_property_decorate=False
        for x in range(property_count):
            row = layout.row()
            row.prop(bpy.data.scenes['Scene'].test_pointer, "prop_{}".format(x))

classes = [
    TestProperties,
    LayoutDemoPanel,
]

if hasattr(bpy.types.Scene,'test_pointer'):
    del bpy.types.Scene.test_pointer

class_register, class_unregister = bpy.utils.register_classes_factory(classes)

class_register()

bpy.types.Scene.test_pointer = bpy.props.PointerProperty(type=TestProperties)
```

<video src="attachments/95e36a02-b781-44b1-9a18-9e453f8a1432" title="2025-02-03 14-12-47.mp4" controls></video>

Pull Request: https://projects.blender.org/blender/blender/pulls/134000
2025-03-05 19:34:19 +01:00
Miguel Pozo
97055868a3 Merge branch 'blender-v4.4-release' 2025-03-05 16:44:06 +01:00
Miguel Pozo
6c697a48f4 Fix #135325: Overlay-Next: Replicate the old face x-ray behavior
Replicate the Overlay-Legacy behavior for selected face overlays in
X-Ray mode:

Use depth testing for `edit_mesh_faces_ps_` when X-Ray is fully opaque.

X-Ray is always considered fully opaque in Preview/Render mode since
X-Ray transparency is not supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/135524
2025-03-05 16:42:59 +01:00
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +01:00
Brecht Van Lommel
65889672e2 Fix #135432: Cycles world light and shadow catcher bug after recent changes
Caused by #134846, e813e46327.

Pull Request: https://projects.blender.org/blender/blender/pulls/135440
2025-03-05 16:27:49 +01:00
Clément Foucault
077115e936 Cleanup: DRW: Remove ViewMatrix legacy GLSL macros
Pull Request: https://projects.blender.org/blender/blender/pulls/135416
2025-03-05 15:31:36 +01:00
Clément Foucault
bacc58b142 Cleanup: DRW: Remove duplicated glsl library 2025-03-05 15:31:35 +01:00
Clément Foucault
9bddb57960 Cleanup: DRW: Relace drw_view macros by function calls 2025-03-05 15:31:35 +01:00
Clément Foucault
a92f6ebf13 Cleanup: DRW: Remove ModelMatrix legacy GLSL macros 2025-03-05 15:31:35 +01:00
Clément Foucault
5916c39fa4 Cleanup: DRW: Simplify resource id and custom id 2025-03-05 15:31:35 +01:00
Clément Foucault
580c02c053 Fix #135497: Auto-Depth Operation are affecterd by Retopology offset
Setting the offset to 0 for these cases fixes the issue.
We still want to draw the edit face in this case to a be able
to zoom on the retopo surface. We just don't want the offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/135511
2025-03-05 15:08:12 +01:00
Clément Foucault
edd3781584 Fix: DRW: Fix the fix
The `tmp_object.runtime` is getting overwritten by the shallow
copy.
Caused by b4b1d010fb
2025-03-05 14:57:59 +01:00
Clément Foucault
b4b1d010fb Fix: DRW: Asan crash because of use after free
Caused by 2038ba699d
2025-03-05 14:49:22 +01:00
Omar Emara
97ada4f307 Cleanup: Compositor: Remove operation stream cache
This patch removes the operation stream cache code from the compositor.
This code path has been disabled already since 4137fdf555, so this patch
just removes the dead code.

Pull Request: https://projects.blender.org/blender/blender/pulls/135513
2025-03-05 14:01:12 +01:00
Sybren A. Stüvel
d620f7605c Merge remote-tracking branch 'origin/blender-v4.4-release'
ch.cc
2025-03-05 13:28:16 +01:00
Jonas Holzman
32f8863b0c Fix #134260: Color Picker components partially resetting when pressing Backspace
Previously, when pressing the Backspace key inside an open color picker,
the HSV and Hex field components would not refresh. Only the RGB
components would.

Fixed by calling the attached button function callbacks which propagates
the color changes to the other color picker buttons from the RGB values.

Pull Request: https://projects.blender.org/blender/blender/pulls/135131
2025-03-05 12:41:32 +01:00
Campbell Barton
1efcf7d729 Cleanup: correct flag check in remesh operator
Inclusion of other flags would make this check fail.
2025-03-05 22:27:53 +11:00
Campbell Barton
f54eeaf2aa Fix #135490: Incorrect allocation size with MEM_new (naming collisions)
Resolve naming collisions for structs which could cause the wrong size
to be used allocating the `LaplacianSystem` when calculating mesh
weights from an armature.

Ref !135491
2025-03-05 22:26:55 +11:00
Falk David
a4ac52d0d0 Fix #135312: Grease Pencil: Crash when drawing while animation is playing
While we can avoid this crash by enforcing that the animation can't
play while drawing, this PR fixes the problem by remembering the
drawing that the operation was started on.

This seems like the right thing to do in general because there might be
other ways that the frame can be changed.

From my tests this seems to work even in cases where we use multi
frame editing.

Pull Request: https://projects.blender.org/blender/blender/pulls/135451
2025-03-05 12:21:28 +01:00
Sybren A. Stüvel
aada31c041 Anim: Fix issue where F-Curves were half-initialized when importing USD
Fix an issue where imported F-Curves were allocated but not zeroed out,
when importing skeletal animation from USD.

When growing the F-Curve array, `BKE_fcurve_bezt_resize()` will now zero
out new array elements, instead of leaving the initialisation to the
caller. There are many fields in `BezTriple`, and the caller is likely
to only set those that can be imported (like the keyframe coordinates &
handles).

This fixes an issue introduced in 857743db9d.

Pull Request: https://projects.blender.org/blender/blender/pulls/135448
2025-03-05 12:20:40 +01:00
Sybren A. Stüvel
a03077c22d UI: show '+ New' button in Action Slot selector when no slot is selected
In any Action Slot selector, when there is no slot selected yet, replace
the 'Duplicate' and 'Unassign' buttons with a large 'New' button. This
is consistent with the ID selector, which does the same thing.

Care is taken to ensure this is only applied to the use case of
selecting Action Slots, in order to minimize the UI changes in Blender
4.4.

The only other use case of `template_search()` that I could find, is the
View Layer selector in the top-right corner of the window. However, even
without the "_is this an Action Slot selector_" guard, it would not show
these changes, as Blender guarantees there is always a view layer
assigned. Add-ons may still use `template_search()` in other ways,
though, so it's still good to keep this guard in place.

Pull Request: https://projects.blender.org/blender/blender/pulls/135443
2025-03-05 12:20:11 +01:00
Clément Foucault
04fcf2f907 Merge branch 'blender-v4.4-release' 2025-03-05 12:06:00 +01:00
Clément Foucault
326ce59961 Fix #134509: GPU: Add workaround for Intel ARC nodelink driver bug
This disables the instancing optimization for this specific
hardware.

Pull Request: https://projects.blender.org/blender/blender/pulls/135458
2025-03-05 12:05:34 +01:00
Lukas Tönne
1b8185db79 Merge branch 'blender-v4.4-release' 2025-03-05 12:04:12 +01:00
Lukas Tönne
70473d7589 Fix: Grease Pencil forward declaration of RandomNumberGenerator.
This is a class, was forward-declared as struct.
2025-03-05 12:02:58 +01:00
Nika Kutsniashvili
e35582b73c Fix #135346: Cavity missing from Workbench render properties
Commit 9627bdfab3 moved Cavity properties to a new panel, but forgot to
include it in Workbench render properties as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/135504
2025-03-05 11:45:00 +01:00
Hans Goudey
b8d547ab1a Fix #134876: Wireframe overlay incorrectly skips some edit mode objects
The detection of when the wireframe is drawn by the edit mode overlays
instead was incorrect and didn't handle recent changes to avoid drawing
edit mode overlay data for invalid evaluated/original edit mesh mappings.
See code comments for more detail.

Pull Request: https://projects.blender.org/blender/blender/pulls/135402
2025-03-05 11:18:26 +01:00
илья _
02281dd26a Cleanup: BKE: Nodes: improve node label functions
Slight cleanup of function naming, return types and related things like early return.

Pull Request: https://projects.blender.org/blender/blender/pulls/135351
2025-03-05 11:17:50 +01:00
Pratik Borhade
c2a5fb28d7 Fix #135344: Extra space in node editor group panel
Remove extra padding from panel when it doesn't have toggle socket. It
was added in 2822777f13

Pull Request: https://projects.blender.org/blender/blender/pulls/135424
2025-03-05 11:16:56 +01:00
Omar Emara
117b47840a Refactor: Compositor: Remove use of auto_resource_location
This patch removes the use of auto_resource_location during shader
operation material compilation. Instead, we assign slot locations
explicitly. Output images are just assigned incremental indices, while
input samplers are also assigned incremental indices, but starting from
the number of textures in the material, because color bands might be
reserving slots already.

Pull Request: https://projects.blender.org/blender/blender/pulls/135453
2025-03-05 09:12:52 +01:00
Lukas Tönne
b66bfa345d Merge branch 'blender-v4.4-release' 2025-03-05 08:50:10 +01:00
Lukas Tönne
dc3a652d5b Fix #134606: Grease Pencil: Randomization of attributes in primitive tools
Primitive tools were not using the brush randomization options.

This moves the randomization functions into the editor utilities for Grease Pencil
and enables primitive curve generation to use them.

Pull Request: https://projects.blender.org/blender/blender/pulls/135454
2025-03-05 08:49:27 +01:00
YimingWu
8b8b0837a0 Fix #135002: Sculpt/Paint: Grease Pencil stabilization toggling during a stroke
Prior to 4.3, it is possible to toggle Stabilize Stroke during a Grease
Pencil stroke with shift key, however this is broken by brush system
changes. Now this behaviour is re-implemented.

Note: Shift-toggling of Stabilize Stroke is only for Grease Pencil for
now, as mesh sculpt mode will use shift key for smooth brush instead of
pointer smoothing.

Pull Request: https://projects.blender.org/blender/blender/pulls/135024
2025-03-05 07:14:13 +01:00
Campbell Barton
214d6edcc0 Merge branch 'blender-v4.4-release' 2025-03-05 15:38:03 +11:00
Campbell Barton
378cc32efa Fix #83819: Toolbar tooltip missing with custom-keymap
When accessing the key-map for tooltips it's important to use
the final "user" keymap, combine from "active" & "default".

Using the active keyconfig would only keys from key-maps that had
been modified.
2025-03-05 15:34:45 +11:00
Campbell Barton
a79b7323fa Merge branch 'blender-v4.4-release' 2025-03-05 13:22:25 +11:00
Campbell Barton
b889cc66ca Unbreak building with CLANG & WITH_GMP=OFF 2025-03-05 13:18:29 +11:00
Harley Acheson
6a7fa2fc0f Merge branch 'blender-v4.4-release' 2025-03-04 16:11:22 -08:00
Harley Acheson
4da5377e17 Fix #135421: BLF Show Most Control Characters as Space
Prior versions of Blender showed control characters as spaces, but
since we recently made fallback optional they are no longer visible.
This is because with fallback we are guaranteed to return a glyph, but
without fallback the current font will not have entries for these. This
PR just shows them as spaces, just like before. But does not do so for
carriage return and line feed.

Pull Request: https://projects.blender.org/blender/blender/pulls/135484
2025-03-05 01:09:53 +01:00
Jacques Lucke
f9e02b5925 Geometry Nodes: support opening images in modifier
Previously, it was unnecessarily complicated to open an image that is passed
into Geometry Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135352
2025-03-04 23:59:22 +01:00
Jacques Lucke
c233955ef9 Geometry Nodes: support custom delimiter in Import CSV node
Previously, only `,` was a valid delimiter, but it's also common to have e.g.
tab or semicolon. Only single characters are supported as delimiters. A few
characters are not allowed because they have other meanings: `\n`, `\r`, `"`,
`\\`.

Note: The best way to get a tab character is the use the Special Characters node
currently.

Pull Request: https://projects.blender.org/blender/blender/pulls/135468
2025-03-04 23:58:02 +01:00
Harley Acheson
0ee642611c UI: Add Specific Icon to Represent Preview While Loading
Rather than continuing to use ICON_TEMP, meant to represent temporary
locations, this PR adds a specific one - ICON_PREVIEW_LOADING - for
this purpose. Just a copy of ICON_TEMP for now, but with all parts at
40% opacity, matching how we use it now. Not only gives us an icon we
can later change, but also removes our special handling of reducing
opacity for one icon id.

Pull Request: https://projects.blender.org/blender/blender/pulls/135463
2025-03-04 23:35:30 +01:00
Christoph Lendenfeld
0399134406 Fix #135260: Snap stuck when dragging time cursor
Caused by ac549dcfde. Snap is meant to be not saved, but the breaking
commit introduced a new property below the `snap` property so it was
no longer applied.

Pull Request: https://projects.blender.org/blender/blender/pulls/135433
2025-03-04 21:21:04 +01:00
Hans Goudey
c560cdc8cc Cleanup: Use StringRef for layout panel API functions 2025-03-04 14:29:15 -05:00
Hans Goudey
a48d155c87 Geometry Nodes: Add "Face" option to Mesh to Curve node
Adds a mode option to the node to choose between the existing
behavior and new behavior that converts each face to a cyclic curve.
Generally this is much faster than the existing mode because it's
easy to parallelize and because curve offsets and face and corner
attributes can be implicitly shared to avoid copies.
Resolves #134671.

Pull Request: https://projects.blender.org/blender/blender/pulls/134773
2025-03-04 19:16:36 +01:00
Hans Goudey
c821b7d2e7 Fix #135413: Potential invalid normals in sculpt mode node tools
Another case of special handling needed for normals caches in sculpt mode.
2025-03-04 12:43:44 -05:00
Philipp Oeser
6e76741e6c Merge branch 'blender-v4.4-release' 2025-03-04 18:24:56 +01:00
Philipp Oeser
f3161149db Fix #135370: Crash when baking textures with a modified UV map
The report was storing a non-2D-Vector attribute with geometry nodes
over a valid UVMap, resulting in the evaluated mesh not having a valid
`CD_PROP_FLOAT2` layer anymore. There is already a check to early out
for the original mesh in case it has no UVs, but as mentioned, not for
the **evaluated** (cage/multi-no-res) mesh which is actually/rightfully
used to get the UVs.

To resolve, check again if we have UVs right after getting he mesh that
is actually used.
(we might even want to remove the first check, seems redundant now -
even though it would early out a bit sooner...)

Pull Request: https://projects.blender.org/blender/blender/pulls/135388
2025-03-04 18:24:39 +01:00
Clément Foucault
3dfec1ff73 Depth Picking: Do not include non-selectable object in depth picking
This allow to make transparent object not interfere with
navigation.

Rel #134784

Pull Request: https://projects.blender.org/blender/blender/pulls/135109
2025-03-04 18:13:48 +01:00