Commit Graph

15532 Commits

Author SHA1 Message Date
Pratik Borhade
ba2e567efb Grease Pencil: Drawing API functions to assign/remove vertex group data
Currently there is no python api function to assign/remove vertices to specific
vertex group. Traditional `object.vertex_groups[0].add/rna_VertexGroup_vertex_add`
didn't work, because Grease Pencil stores deform verts and vertex group
on individual drawings. Now intorduced a new function
`vertex_group_assign` and `vertex_group_remove` on `Drawing`.

Resolves #135281.
Resolves #134678.

Example (just add GP Suzanne):
```
import bpy

C = bpy.context

drawing = C.active_object.data.layers['Lines'].current_frame().drawing
drawing.vertex_group_assign(vgroup_name="Group", indices_ptr=[2, 6, 10, 18, 19, 20], weight = 0.9)
drawing.vertex_group_remove(vgroup_name="Group", indices_ptr=[2, 6, 10])
```

Pull Request: https://projects.blender.org/blender/blender/pulls/135283
2025-03-18 15:11:09 +01:00
Campbell Barton
3f9c08d960 Docs: add a doc-string for rotation_mode
Based on the report #135332, it's not obvious that rotation modes that
aren't selected aren't used, note this in the doc-string.

Ref !136103
2025-03-18 22:39:30 +11:00
Richard Antalik
d267ec3ec1 Fix #135968: Sound strip offset limit is hardcoded to 0
This seems to be remains of code from time when sound offsets were
clamped to non negative values and start/endstill offsets were used to
offset strip handles from sound content.

Since start/endstill offsets were merged with start/endofs, this limit
should have been removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/136015
2025-03-18 07:12:50 +01:00
Clément Foucault
894c7fa4e2 EEVEE: Remove EEVEE Next mention inside the code
This only changes file and function names.
The EEVEE identifier is still `BLENDER_EEVEE_NEXT`.

No functional changes.
2025-03-17 15:37:04 +01:00
Hans Goudey
835696f152 Geometry Nodes: Move import nodes out of experimental
The import nodes are considered complete enough to expose without
the experimental option. This commit removes the option so they will
be exposed in 4.5. There are still some possible future improvements,
including automatic caching, possibly exposing more input sockets,
and possibly including imported paths in the "Internal Dependencies"
panel. Those are considered non blocking though.

Pull Request: https://projects.blender.org/blender/blender/pulls/135957
2025-03-17 13:54:48 +01:00
Pablo Vazquez
46bd1cedf8 UI: Add unit to label in Glare (Simple Star) node
Add the unit (degree) symbol to "Rotate 45" label
to the Glare node Simple Star mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/135887
2025-03-17 13:49:43 +01:00
Julian Eisel
4499fad40e UI: Horizontal list view for asset browser
Part of #134755 / #134766.

The asset browser currently lacks a compact view that leaves names
readable. Especially when managing asset libraries (e.g. to prepare it
for sharing or set up a production library), this is quite a usability
issue. A column view like the file browser has can solve this, allowing
a quick overview and fast browsing of libraries, while keeping names
readable.

Adds a new "Horizontal List" display mode to the asset browser that
distributes assets over multiple columns, with horizontal scrolling.
Asset previews are shown in this mode, plus an asset type icon if
there's enough space. The size of previews and the columns can be
configured next to the display mode, for optimizing the display.

Pull Request: https://projects.blender.org/blender/blender/pulls/135306
2025-03-14 16:43:12 +01:00
Habib Gahbiche
d8d09cdadb Geometry Nodes: shortcuts for viewer nodes
Implement shortcuts for viewer nodes. Viewer nodes are now activated using the operator `bpy.ops.node.activate_viewer()` instead of activating the viewer by setting the node to active.

This also unifies the behavior with viewer shortcuts in the compositor (see attachment in the original PR).

Pull Request: https://projects.blender.org/blender/blender/pulls/134555
2025-03-14 11:26:57 +01:00
Julian Eisel
18c4df0243 I18N: Make some property disabled hints translatable
This text will show in tooltips to explain why a property is not
editable, it needs to be tagged for translation.
2025-03-14 10:55:36 +01:00
Bastien Montagne
ef1d5432cb RNA: LibraryWeakReference: make path and ID name editable.
There is no real reason to keep these read-only, they are not exposed in
the UI anyway, and being able to edit them can become necessary in a
pipeline mamangement context.
2025-03-12 17:50:50 +01:00
Bastien Montagne
4c4e3142df Cleanup: makesrna: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/135870
2025-03-12 17:19:06 +01:00
John Kiril Swenson
7356e72e1b VSE: Snap to Frame Range, Snap by Default
This patch adds the ability to snap to the frame range bounds in the VSE
timeline, on by default. End frame snap location is offset by 1 to
ensure the snap point aligns with the visible end frame boundary
(otherwise e.g. right handle of strip would be one frame short).

Timeline and preview snapping is also turned on by default using the
same versioning block.

Pull Request: https://projects.blender.org/blender/blender/pulls/135753
2025-03-12 03:36:32 +01:00
Sybren A. Stüvel
2cdd75def0 Merge remote-tracking branch 'origin/blender-v4.4-release' 2025-03-11 10:38:55 +01:00
Sybren A. Stüvel
064421a02d Anim: expose Action Slot users to RNA
Add a new RNA function `ActionSlot.users()` that returns the
data-blocks that are animated by this slot.

This covers direct assignment of the action & slot, but also use in
the NLA and in Action constraints.

```python
>>> D.actions['SuzanneAction'].slots['OBSuzanne'].users()
[bpy.data.objects['Suzanne']]
```

This was implemented as a function, and not a collection property,
because Blender's bookkeeping of the slot users can be marked 'dirty'.
In that case the slot user list needs to be rebuilt, which happens for
all Actions and all their slots simultaneously. This was considered
too broad a data-changing action to 'hide' inside a getter of a
property. Also it needs a `bmain` pointer, which is not available in
getters, but is available in functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/135734
2025-03-11 10:36:59 +01:00
Jesse Yurkovich
05c7fb1eae Merge branch 'blender-v4.4-release' 2025-03-10 22:25:42 -07:00
Jesse Yurkovich
a5b80c06bc Fix #134764: Increase range of allowed node locations
The bug was caused because the new node's location was being clamped to
the [-100000, 100000] range. Expand this by 10x further.

Pull Request: https://projects.blender.org/blender/blender/pulls/134887
2025-03-11 06:22:34 +01:00
Campbell Barton
bd06baf6e6 WM: rename WM_report* to WM_global_report*, note it's often bad practice
WM_report was originally added for special cases however new code
has been using this in operators for example, where reports should be
sent to the operator via BKE_report, so the caller can handle,
and so Python can catch the errors.

Rename the functions to make them less easily confused with BKE_report
and add a code-comment on why their use should be avoided.
2025-03-11 12:36:17 +11:00
Sean Kim
45ff1619f3 Fix: Editor changes to tool-settings push unnecessary undo steps
When users make changes to certain settings from the editor (e.g.
changing the Proportional Edit or Snapping settings), an undo step is
created in the undo stack that has no effect when undone. These steps
should not be created, therefore this commit clears the `STRUCT_UNDO`
tag from the `ToolSettings` struct and any structs that it contains.
A prior commit, 0dd326592a, introduced filtering on the `STRUCT_UNDO`
flag for changes being applied from the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/134836
2025-03-10 18:11:37 +01:00
Hans Goudey
9104cc3406 Merge branch 'blender-v4.4-release' 2025-03-10 11:58:51 -04:00
Hans Goudey
6eb5566104 Fix: Allow RNA functions to return collection properties
Possibly broken by acd1b0b7f9.
Though returning a collection property from an RNA function doesn't
seem to have been used before. The mistakes are relatively obvious.
The RNA parameter list data isn't initialized so placement new and
calling the CollectionVector destructor manually are necessary.

This fix is necessary for #135734 which is targeted at 4.4.

Pull Request: https://projects.blender.org/blender/blender/pulls/135746
2025-03-10 16:57:13 +01:00
Falk David
6c0bd4ebce Merge branch 'blender-v4.4-release' 2025-03-10 16:29:26 +01:00
Sean Kim
4d50e00914 Fix #135328: Grease Pencil: Unable to set default eraser
Incorrectly changed in 9e8c037375.

The Grease Pencil `eraser_brush` property is still accessed and set
directly from Python, we cannot remove setting access to the property in
favor of the `AssetWeakReference` without first making other changes.
For now, this patch re-adds the RNA definitions for the property to make
it editable again.

Pull Request: https://projects.blender.org/blender/blender/pulls/135743
2025-03-10 16:28:50 +01:00
Falk David
3bbf7aed91 Merge branch 'blender-v4.4-release' 2025-03-10 16:14:37 +01:00
Philipp Oeser
1f780a5caa Fix #135711: Setting Grease Pencil modifier materials are not refcounted
When setting these materials, then removing the modifier, usercount
would be decreased, resulting in possible dataloss on reload

Affected were:
- all Grease Pencil modifiers material influence materials
- `LineartModifier` `target_material`
- `OutlineModifier`  `outline_material`

These were all using `IDWALK_CB_USER` which ends up decrementing
usercount in `modifier_free_data_id_us_cb` when the modifier is removed

So to resolve, decrement/increment material usercount in
`rna_GreasePencilModifier_material_set` appropriately

NOTE: previously, it was also doing `id_lib_extern` on the object?!
(should be on the material, no?)

NOTE: still not 100% sure where we actually use refcounting (esp. in
modifiers) and where we dont, another alternative is to just drop it and
use IDWALK_CB_NOP` (instead of `IDWALK_CB_USER`) for these materials.

Pull Request: https://projects.blender.org/blender/blender/pulls/135729
2025-03-10 16:12:32 +01:00
Falk David
3f4e4963b4 Merge branch 'blender-v4.4-release' 2025-03-10 11:04:08 +01:00
Falk David
785c9c9720 Fix #135273: Grease Pencil: Crash when disabling mutliframe editing
The issue was that the multiframe editing toggle is a tool setting and not
stored in the object data anymore (which was changed in 4.3 so that users
don't have to toggle it in every object).

The batch caches of all Grease Pencils will include the multiframes even
when they are not active.
This leads to the issue that inactive objects don't rebuild their batch cache
when the setting is toggled and we access memory that is out of bounds.

To fix this (for now), toggling the multiframe setting tags all the Grease Pencil
IDs for an update. Obviously this is less than ideal, but the safest option as
of right now.

In the future, we should create a batch cache for each frame.
Then the render engine can request each frame when it's needed,
and we no longer need to tag all the objects for an update when
the setting changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135636
2025-03-10 11:03:36 +01:00
Bastien Montagne
00de07f752 I/O: Smoothgroups: Add option to also consider 'sharp vertices'.
According to reports and testing in blender/blender-addons#104434, DCCs
tend to behave badly when rebuilding normals from 'bitflags'
smoothgroups, if different smoothgroups using the same bitflag value share
(are connected by) some common vertices, even if there are no common
edges between them.

This commit adds a new option to the RNA API generating smooth groups,
to also consider smooth groups only sharing vertices as neighbors.

It also makes related required change to implementation, and some
refactor of the API, splitting public functions between 'normal' and
'bitflags' versions.

This should make changes proposed in blender/blender-addons#105516
much simpler, and allow for a matching behavior in smoothgroups
generated by the OBJ exporter as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/135248
2025-03-07 11:24:37 +01:00
Falk David
e39c83c881 Merge branch 'blender-v4.4-release' 2025-03-06 21:19:31 +01:00
John Kiril Swenson
993f9b2d30 VSE: Report one-time property changes
This patch adds warnings when view transform or FPS values are changed
by dragging in an initial strip with "Set Scene Frame Rate" or "Set View
Transform" enabled.

In the case that both occur at the same time, reports are not
interweaved but both still show up in the info viewer -- this is a
limitation of `BKE_report` itself. Future work could modify the report
system to support queuing, but this is still an improvement over
previous behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/135494
2025-03-06 21:13:12 +01:00
Hans Goudey
9287bb759b Geometry Nodes: Import Text node
As a small addition to the import node features for 4.5,
this simple node imports a text file as a string. Potential
use cases include retrieving text for motion graphics.

Currently this just allows .txt files. More extensions could
be allowed in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/135459
2025-03-06 18:47:30 +01:00
Falk David
5f464b2de0 Fix #135235: Grease Pencil: Crash when removing layers in python API
When iterating over the layers in a Grease Pencil object,
removing the layers can lead to crashes.

This PR is a better alternative to !135253.

Instead of checking if the layer is valid, simply fetch the latest layer
cache for each iteration and check if the index is valid.

This means that we will skip over layers if they get removed during
iteration, but we no longer can crash. If users want to remove multiple
layers at once, it's better to do this in two passes. E.g. by first
collecting the names of the layers to remove, iterating over
these names and then removing the layers by getting it by its name.

Pull Request: https://projects.blender.org/blender/blender/pulls/135574
2025-03-06 16:30:35 +01:00
Richard Antalik
68abed543b Refactor: Remove module prefix form symbols in sequnecer namespaces
Remove
SEQ_ prefix for blender::seq namespace and
ED_sequencer for blender::ed::vse namespace

Pull Request: https://projects.blender.org/blender/blender/pulls/135560
2025-03-06 13:04:39 +01:00
Richard Antalik
a08246a1a2 Refactor: Move VSE code to namespaces
This PR creates 2 namespaces for VSE code:
- `blender::seq` for sequencer core code
- `blender::ed::vse` for editor code

These names are chosen to not be in conflict with each other.
No namespace was used for RNA.

Finally, file `BKE_sequencer_offscreen.h` was moved from BKE to sequencer.

Pull Request: https://projects.blender.org/blender/blender/pulls/135500
2025-03-06 06:22:14 +01:00
Campbell Barton
d951428422 Cleanup: spelling in comments
Address warnings from check_spelling.py
2025-03-06 10:49:51 +11: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
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
Campbell Barton
c7cde524fb Revert "PyAPI: document never none pointer/collection properties"
This reverts commit
48abc7aabc &
62599317dd.

Revert !126755 as it was only meant to impact document generation
but it infact made functional changes, see: !135352.
2025-03-04 22:20:40 +11:00
Aras Pranckevicius
cc2c6692c0 Cleanup: Name more IMB things as "byte" or "float" instead of "rect" and "rectFloat"
- IB_rect -> IB_byte_data
- IB_rectfloat -> IB_float_data
- Rename some functions:
	- IMB_get_rect_len -> IMB_get_pixel_count
	- IMB_rect_from_float -> IMB_byte_from_float
	- IMB_float_from_rect_ex -> IMB_float_from_byte_ex
	- IMB_float_from_rect -> IMB_float_from_byte
	- imb_addrectImBuf -> IMB_alloc_byte_pixels
	- imb_freerectImBuf -> IMB_free_byte_pixels
	- imb_addrectfloatImBuf -> IMB_alloc_float_pixels
	- imb_freerectfloatImBuf -> IMB_free_float_pixels
	- imb_freemipmapImBuf -> IMB_free_mipmaps
	- imb_freerectImbuf_all -> IMB_free_all_data
- Remove IB_multiview (not used at all)
- Remove obsolete "module" comments in public IMB headers

Pull Request: https://projects.blender.org/blender/blender/pulls/135348
2025-03-03 17:11:45 +01:00
Hans Goudey
8b297ab168 Cleanup: Use bNodeTree all_nodes() accessor method
This is always built at runtime.

Pull Request: https://projects.blender.org/blender/blender/pulls/135321
2025-02-28 22:12:34 +01:00
Falk David
2822777f13 Nodes: support boolean inputs as toggles in panel headers
Adds the option to create a boolean socket that can be used as a panel toggle.
This allows creating simpler and more compact node group UIs when a panel
can be "disabled".

The toggle input is a normal input socket that is just drawn a bit differently in
the UI. Whether a boolean is a toggle input or not does not affect evaluation.

Also see #133936 for guides on how to add and remove panel toggles.

Pull Request: https://projects.blender.org/blender/blender/pulls/133936
2025-02-28 19:07:02 +01:00
Philipp Oeser
a95753b36a Merge branch 'blender-v4.4-release' 2025-02-28 17:31:29 +01:00
Philipp Oeser
65288e4130 Attempt to fix build error
introduced in 9855c11d2c
2025-02-28 17:30:11 +01:00
Philipp Oeser
b0d63ff8e1 Merge branch 'blender-v4.4-release' 2025-02-28 17:14:34 +01:00
Philipp Oeser
9855c11d2c Fix #135217: ColorManage Settings RNA paths incomplete/wrong
`ColorManagedDisplaySettings`, `ColorManagedViewSettings`,
`ColorManagedInputColorspaceSettings` were affected since these are used
from multiple places (Scene, File output nodes, ..).

Similar to how we are getting the path for `ImageFormatSettings` (which
pretty much has the distinction logic already), we can do so for the
ColorManage Settings as well (piggbacking on the already correct path to
the `ImageFormatSettings`.

With this, we can also remove these "known failures" from the test
introduced in 4032b853c3.

Pull Request: https://projects.blender.org/blender/blender/pulls/135238
2025-02-28 17:13:43 +01:00
Bastien Montagne
f6ad99c648 Merge branch 'blender-v4.4-release' 2025-02-28 15:48:13 +01:00
Damien Picard
e76d997b44 I18n: Disambiguate "Clip"
Volumes' "Sequence Mode" recently got the "Sequence" context in
2b3f0d0110. The intention was to disambiguate the "Extend" enum item,
but this caused another item, "Clip" to also get this context. That
one already existed and referred to a sequencer clip.

Use the more specific "Volume" context instead.

Reported by Gabriel Gazzán.
2025-02-28 15:46:33 +01:00
Bastien Montagne
e5d1cf96fd Merge branch 'blender-v4.4-release' 2025-02-28 15:45:36 +01:00
Andrej730
25922344e5 RNA: WM API: fileselect_add - document filter_glob operator property usage
Pull Request: https://projects.blender.org/blender/blender/pulls/135288
2025-02-28 15:44:45 +01:00
Sebastian Parborg
1fc2daf3e2 Merge branch 'blender-v4.4-release' 2025-02-27 15:16:37 +01:00
Pratik Borhade
9d12ac29ea Fix: Grease Pencil: Add channel_color RNA prop to layer groups
Property wasn't added to earlier because it was part of tree-node.
But it was moved to tree-node just in main, see: 3ef2ee7c53
Failing right now in 4.4.

Pull Request: https://projects.blender.org/blender/blender/pulls/135225
2025-02-27 13:32:35 +01:00