Commit Graph

3791 Commits

Author SHA1 Message Date
Brecht Van Lommel
4786fbe774 Refactor: Remove extern "C" from most headers
The only remaining code in source/blender that must be compiled as C
is now datatoc generated code and the DNA defaults that use designated
initializers.

Pull Request: https://projects.blender.org/blender/blender/pulls/134469
2025-02-13 18:58:08 +01:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Omar Emara
a8141f47cf Merge branch 'blender-v4.4-release' 2025-02-10 13:59:08 +02:00
Pratik Borhade
f75126a253 Fix #134284: Grease Pencil: Build modifier natural drawing speed fails
Natural drawing speed fails for strokes that are pasted or duplicated.
This is due to the `init_time` attribute being transferred from previous stroke
to the new, resulted in the same values. This further calculates wrong
`build_factor` inside `get_factor_from_draw_speed`. To further explain
this, `gap_delta_time = -prev_end_time` which evaluates `start_time=0` for
the duplicated curve. To avoid this situation, make sure `gap_delta_time`
is positive. So `start_time` will be > 0.

Pull Request: https://projects.blender.org/blender/blender/pulls/134329
2025-02-10 11:38:33 +01:00
Bastien Montagne
87a4c0d3a8 Refactor: Make Library.runtime an allocated pointer.
Move `Library.runtime` to be a pointer, move the related
`LibraryRuntime` struct to `BKE_library.hh`. Similar to e.g.
Mesh.runtime, that pointer is expected to always be valid, and is
allocated at readtime or when creating a new Library ID.

Related smaller changes:
* Write code now uses standard ID writing codepath for Library IDs too.
  * Runtime pointer is reset to nullptr before writing.
* Looking up a library by its absolute path is now handled through a
  dedicated utils, `search_filepath_abs`, instead of using
  `BLI_findstring`.

Pull Request: https://projects.blender.org/blender/blender/pulls/134188
2025-02-07 17:47:16 +01:00
YimingWu
fc43f4e1e8 Fix #134035: Grease Pencil: Correct index for multistroke modifier
The stroke index was wrong when a influence filter is active in the
modifier, this would lead to crashes. Now corrected this by only
iterating duplicated strokes in front of the curves geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/134038
2025-02-06 15:08:07 +01:00
Falk David
8af27ce27e Fix #133969: Crazyspace broken with bezier curves and armature modifier
The issue was that the topology of the drawing changes when the bezier
curves get resampled to poly curves in the armature modifier.
This means that the crazyspace code fails to find deformed positions
with the same length as the original positions.

The fix does multiple things:
* First, we make sure that we create an `GeometryComponentEditData` in
  weight paint mode.
* When the armature modifier runs, we remember the current positions in
  this component.
* Then, we store the curve offsets and weights _before_ converting the
   bezier curves.
* Finally we deform the positions stored in the edit hint component
   (which have the same length as the original positions).

Since the resampling just adds new points, there might be a way to
avoid running the armature deformation a second time on the edit
hints, but I'll leave that for another day as a performance improvement.
In any case, this is only done when we actually need the deformation
(e.g. in weight paint mode when we paint the weights).

Pull Request: https://projects.blender.org/blender/blender/pulls/134030
2025-02-06 11:15:32 +01:00
Aaron Carlisle
3369d12abb UI: Fix "Levels" Consistency between Subdiv and Multires Modifiers
The Subdivision Modifier used "Levels" and the Multiresolution Modifier used "Level". This difference is changed to be "Levels" for both, which aligns with similar UI terminology where plural forms indicate adjustable values, such as "Render Samples".

Ref blender/blender-manual#105098
2025-02-02 20:13:39 -05:00
Hans Goudey
59f9e93413 Mesh: Avoid computing vertex normals for corner normals
The algorithm to calculate face corner normals had a vertex normal
input, with the intention to pre-populate corner normals for vertices
with no sharp connected edges. However corner normals are calculated
separately for these fully sharp vertices later anyway, so this whole
step was completely redundant. Removing the vertex normals calculation
reduces memory usage and improves performance. In a test file with a
character with custom normals, this changed improved the playback FPS
by 15%, from 41 to 47 FPS. The impact will usually be lower than that
but it should be noticeable in other scenes too.

Pull Request: https://projects.blender.org/blender/blender/pulls/133884
2025-01-31 19:59:28 +01:00
Brecht Van Lommel
260dbe4cff Cleanup: Various clang-tidy warnings in modifiers
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Jacques Lucke
517768074b Fix #133693: use-after-free in screw modifier
The mesh was tagged as changed after it has been freed.
It's freed in the call to `mesh_remove_doubles_on_axis`.
2025-01-28 11:06:37 +01:00
Bastien Montagne
9c237af041 Refactor: RNA: add discrete suffix to RNA_pointer_create.
This is a noisy preliminary step to the 'RNA ancestors' change. The
rename helps clearly tell what each `pointer_create` function does.

Pull Request: https://projects.blender.org/blender/blender/pulls/133475
2025-01-24 16:45:32 +01:00
Philipp Oeser
e4c125400f Fix #133055: Some Grease Pencil modifiers ignore "Invert Vertex Group"
The handling of influence vertexgroups was incomplete/inconsistent.
Some prior work was already done in 08539618cd, c452d5d9e8,
782a4c9d85, 0fd3f3c216, 434f94b254, 82ea972834, f6b820ccb7,
00968fe6db .

Now that the inverting is handled consistently, we can move that part
out of specific modifier code an into the generic retrieval function
`greasepencil::get_influence_vertex_weights` -- resulting in all
modifiers using it behaving the same.

There were some modifiers already handling
`GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP`, however even those still
had one issue: if no vertexgroup was set, invert would still have been
calculated (this issue is also resolved with this PR).

Remaining modifiers that were offering influence vertexgroups (e.g.
Noise) but ignoring it now work correctly.

NOTE: there are still modifiers handling influence vertexgroups outside
of `greasepencil::get_influence_vertex_weights`:
- Armature (has own code for this in
`BKE_armature_deform_coords_with_curves`)
- Shrinkwrap (has own code for this in `shrinkwrapParams_deform`)
- Thickness (this rather special behavior is untouched)

Pull Request: https://projects.blender.org/blender/blender/pulls/133426
2025-01-24 14:47:33 +01:00
Miguel Pozo
49404a042e Fix: Nodes: Only look for compute contexts in geo-node trees
`find_socket_log_contexts` tries to look for `ComputeContext`s
regardless of the tree type.
This doesn't currently cause any problem in main because no other node
editor has zones, but it causes crashes in the NPR branch, and will
crash in main when other tree types add zones support.

(See https://projects.blender.org/pragma37/npr-tracker/issues/13)

Pull Request: https://projects.blender.org/blender/blender/pulls/133447
2025-01-23 15:34:12 +01:00
Hans Goudey
a704d47a04 Fix #133429: Bevel modifier crash with empty mesh
Attribute domain interpolation would fail in this case. Instead of
checking for that, just add an empty check at the modifier entry point.
2025-01-22 10:32:09 -05:00
Campbell Barton
e8ebbce9c5 Cleanup: update naming for dualcon: rename loop corner_verts
These weren't the equivalent of MLoop's even with the old naming
this was misleading, especially `DualConInput::mloop`.
2025-01-22 19:59:03 +11:00
Campbell Barton
6c05859b12 UI: mitigate problem where remesh could accidentally hang/crash
Having a small voxel size meant typing in zero would clamp the
voxel size to a small number which was often small enough to hang
calculating large voxels which would eventually fail to allocate
memory & crash.

Instead, allow a zero value but bypass calculation.

See #130526.
2025-01-22 19:46:16 +11:00
Philipp Oeser
00968fe6db Fix: Grease pencil inconsistent inverting of influence vertex groups
Behavior was not consistent across modifiers

- Opacity
-- strokes were using inverted weights only when
MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR was OFF, fills however
when MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR was ON
- Tint
-- strokes and fills were using inverted weights only when
MOD_GREASE_PENCIL_TINT_USE_WEIGHT_AS_FACTOR was ON
- others (Envelope, Lattice, Noise, Offset ) were ignoring inverting the
influence vertex group alltogether (but that is reported in #133055 and
will be handled separately, see below)
- others (Hook, ... ) were always inverting it, which is correct

This pull requeset only corrects this for Opacity and Tint (in the way
that now weights are always inverted, no matter if "Use Weight As
Factor" is used).
This also paves the way to a more general fix for #133055 (which intends
to move the weight inversion to the very general
greasepencil::get_influence_vertex_weights)

Pull Request: https://projects.blender.org/blender/blender/pulls/133310
2025-01-22 09:15:53 +01:00
Jacques Lucke
80441190c6 Nodes: automatically gray out input values that don't affect the output
This patch automatically grays out input values which can't affect the output
currently. It works with inputs of group nodes, geometry nodes modifiers and
node tools.

To achieve this, it analyses the node tree and partially evaluates it to figure
out which group inputs are currently not linked to an output or are disabled by e.g.
some switch node.

Original proposal: https://devtalk.blender.org/t/dynamic-socket-visibility/31874
Related info in blog post:
https://code.blender.org/2023/11/geometry-nodes-workshop-november-2023/#dynamic-socket-visibility

Follow up task for designing a UI that allows hiding sockets: #132706

Limitations:
* The inferencing does not update correctly when a socket starts being
  animated/driven. I haven't found a good way to invalidate the cache in a good
  way reliably yet. It's only a very short term problem though. It fixes itself
  after the next modification of the node tree and is only noticeable when
  animating some specific sockets such as the switch node condition.
* Whether a socket is grayed out is not exposed in the Python API yet. That will
  be done separately.
* Only a partial evaluation is done to determine if an input affects an output.
  There should be no cases where a socket is found to be unused when it can actually
  affect the output. However, there can be cases where a socket is inferenced to be used
  even if it is not due to some complex condition. Depending on the exact circumstances,
  this can either be improved or the condition in the node tree should be simplified.

Pull Request: https://projects.blender.org/blender/blender/pulls/132219
2025-01-21 12:53:24 +01:00
Philipp Oeser
f6b820ccb7 Fix #133296: Grease Pencil influence VG affects stroke but not fill
This was true for Opacity or Tint modifiers where influence vertexgroups
were having an effect on strokes, but were ignored for fills.

This was also the case for GPv2 / 4.2, but there is no apparent reason
for not doing this on fills (if we are doing it for strokes).

NOTE: it was actually in use if "Use Weight as Factor" was used (but
that only means weights should be used directly, otherwise [when used as
influence], weights should be multiplied).

Pull Request: https://projects.blender.org/blender/blender/pulls/133306
2025-01-20 13:33:56 +01:00
Philipp Oeser
82ea972834 Fix #133295: Grease Pencil tint influence vertexgroup has no effect
The weights were only used when "Use Weight as Factor" was used (this is
wrong though, that button uses the weights directly, otherwise the
Factor has to be multiplied by the weights -- as done in all other
modifiers [and in 4.2])

Pull Request: https://projects.blender.org/blender/blender/pulls/133297
2025-01-20 11:36:17 +01:00
Philipp Oeser
434f94b254 Fix #133211: Grease pencil Smooth modifier ignores influence vertexgroup
To resolve, multiply the modifier `Factor` by influence vertex groups
weights (if a vertexgroup is used).

Pull Request: https://projects.blender.org/blender/blender/pulls/133213
2025-01-17 18:00:43 +01:00
Philipp Oeser
0fd3f3c216 Fix #133207: Grease Pencil Opacity modifier "Use Weight As Factor" wrong
Two things not behaving as in GPv2:
- points outside the influence vertexgroup were getting zero opacity (as
opposed to 1.0 in GPv2)
- Opacity Factor was multiplied in (even though it shouldnt and is
rightfully greyed out)

I assume the a misunderstanding in c02f3c94d9.

Pull Request: https://projects.blender.org/blender/blender/pulls/133208
2025-01-17 17:56:49 +01:00
Philipp Oeser
782a4c9d85 Fix #133194: Grease Pencil Vertex Weight Angle influence vertexgroup has no effect
The weights were just not used at all.

Stumbled over this checking on #133055

Pull Request: https://projects.blender.org/blender/blender/pulls/133195
2025-01-17 13:39:26 +01:00
Philipp Oeser
36269ab3a3 Fix #133091: Grease Pencil Vertex Weight Proximity wrong with "flipped" distances
One should be able to set the modifier `Highest` value lower then the
`Lowest`, in fact this is probably the more common usecase (getting high
values in the vertexgroup when something is close by and getting lower
values the further away from the target we get).

Now change code so we do exactly like we do for meshes.

NOTE: for grease pencil (as opposed to meshes), the Vertex Weight
Proximity modifier has a button to flip the output values, this can
probably stay for convenience.

Stumbled over this checking on #133055

Pull Request: https://projects.blender.org/blender/blender/pulls/133092
2025-01-16 12:06:27 +01:00
Philipp Oeser
c452d5d9e8 Fix #133099: Remove GP TextureMapping modifier vertexgroup influence
If I read code correctly, at least offset/translation and scale happen
in the Curve domain only in GPv3, so having vertexgroups influence per
point does not really make sense for this modifier.

Therefor, remove the influence vertexgroup from this modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/133102
2025-01-16 11:54:04 +01:00
Philipp Oeser
08539618cd Fix #133097: GP Vertex Weight Proximity wrong with influence VG
The modifier would write to all weights, not respecting if a vertex was
not part of the influence vertex group.
If the vertex is not part of the influence vertex group (its weight is
0.0), dont touch the existing weights (just continue happily).

Pull Request: https://projects.blender.org/blender/blender/pulls/133098
2025-01-15 15:55:49 +01:00
Campbell Barton
68f14db441 Cleanup: add checks to the array modifier to skip empty mesh data
Add checks that ensure mesh data copying blocks only run when the
array's aren't empty.

Also note why an early return isn't used.
2025-01-14 15:30:09 +11:00
Campbell Barton
3acbd93779 Fix #132991: Array modifier + X-Ray crash selecting an empty meshes
Resolve regression introduced in [0] intended to fix another regression
introduced in [1] to resolve an assert from [2] (a C++ cleanup).

Recent changes made the array modifier return early with the start-cap's
mesh however this meant the required custom-data layers wouldn't
necessarily exist on the returned mesh, causing selection to crash.
Besides this the same logic was missing from the end-cap.

Resolve by restoring the logic from before [1],
adding a check to prevent the assert.

[0]: 9ad6957574
[1]: 8b2556e8d8
[2]: cb62ab5b28
2025-01-14 15:29:10 +11:00
Damien Picard
c9a1008d51 I18n: Disambiguate "Strength"
- "Strength" in the context of Grease Pencil, deals with opacity, and
  adjusts the brush stroke alpha.
- "Strength" can mean measurable units like 'noise', 'light', etc.
- Anything else using physical strength in a generic concept.

Issue reported by Hoang Duy Tran.
2025-01-13 12:40:45 +01:00
Damien Picard
f67911cb47 I18n: Disambiguate "Fill"
- In the context of mesh extrusion, "Fill" means "Fill the rim of an
  extruded edge loop" (verb).
- In the context of the file browser, it means select every file
  between beginning and end.
- In the context of an image, fill the tile with  generated image.

Issue reported by Hoang Duy Tran.
2025-01-13 12:40:45 +01:00
Brecht Van Lommel
89b793f130 Cleanup: Compiler warning 2025-01-13 10:07:37 +01:00
Pratik Borhade
d2418b89c3 UI: Meshcache modifier boolean flip axis property
`flip_axis` is currently an enum RNA property. This makes impossible to
toggle the individual axis. Now fixed by converting the property to
boolean. UI drawing code is same as done for mirror modifier.
New enum values are introduced for each axis

Resolves #70237

Pull Request: https://projects.blender.org/blender/blender/pulls/132849
2025-01-12 09:58:30 +01:00
Hans Goudey
eb7df01ef3 Cleanup: Reduce unnecessary includes in curves headers
Pull Request: https://projects.blender.org/blender/blender/pulls/132925
2025-01-10 23:31:49 +01:00
Pratik Borhade
eb57878bec Grease Pencil: Support Boolean property in modifier panel header
A separate function is declared/defined `uiLayoutPanelPropWithBoolHeader`,
it will add a boolean property to the panel.header.
Clear decorate and separator flag, otherwise they will offset the panel
header horizontally and also adds animate decorator on the right side.

Resolves #131623.

Pull Request: https://projects.blender.org/blender/blender/pulls/132726
2025-01-10 14:51:19 +01:00
Hans Goudey
f2c9fccee0 Cleanup: Move legacy node integer types defines to separate header
Moving these defines to a separate header makes their "legacy" status
more obvious. This commit just adds the include wherever necessary.

Followup to 971c96a92c.

Pull Request: https://projects.blender.org/blender/blender/pulls/132875
2025-01-09 20:03:08 +01:00
Jacques Lucke
6ddebc0888 Fix #132831: memory leak when deleting simulation zone
The leak happened because the bake data of the removed zone was only partially freed.

Pull Request: https://projects.blender.org/blender/blender/pulls/132867
2025-01-09 18:19:53 +01:00
Falk David
d413b0064f Cleanup: Move BKE_material.h to C++
The `BKE_material.h` is only renamed to `.hh` to preserve
the history of the file. Changes to the file are done in
the following commit.
2025-01-09 18:11:46 +01:00
Jacques Lucke
971c96a92c Nodes: rename integer type of nodes to type_legacy
The new description for `bNode.type_legacy`:
```
  /**
   * Legacy integer type for nodes. It does not uniquely identify a node type, only the `idname`
   * does that. For example, all custom nodes use #NODE_CUSTOM but do have different idnames.
   * This is mainly kept for compatibility reasons.
   *
   * Currently, this type is also used in many parts of Blender, but that should slowly be phased
   * out by either relying on idnames, accessor methods like `node.is_reroute()`.
   *
   * A main benefit of this integer type over using idnames currently is that integer comparison is
   * much cheaper than string comparison, especially if many idnames have the same prefix (e.g.
   * "GeometryNode"). Eventually, we could introduce cheap-to-compare runtime identifier for node
   * types. That could mean e.g. using `ustring` for idnames (where string comparison is just
   * pointer comparison), or using a run-time generated integer that is automatically assigned when
   * node types are registered.
   */
```

Pull Request: https://projects.blender.org/blender/blender/pulls/132858
2025-01-09 15:28:57 +01:00
Yahia
de9d021830 Fix #119557: XYZ labels on vector outputs missing if Single Value is disabled
Pull Request: https://projects.blender.org/blender/blender/pulls/132144
2025-01-07 15:48:43 +01:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Hans Goudey
64087c70d5 Cleanup: Move some mesh normals functions to C++ API
Use C++ namespace, reference instead of pointer, and span instead
of raw pointers, mainly to make these functions easier to use in a
few more places.

Pull Request: https://projects.blender.org/blender/blender/pulls/132561
2025-01-02 20:32:47 +01:00
Ray Molenkamp
5783950ac5 Revert: 0dc484f9cc bf_rna modernisation
This caused build errors on the docs builder, I can't seem to reproduce
locally, so revert for now and have another look at some point in the
future.

Sadly as these changes usually go, this took 5c515e26bb and
2f0fc7fc9f with it as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/132559
2025-01-02 19:56:24 +01:00
Campbell Barton
5c515e26bb Cleanup: remove trailing space, ensure a newline at EOF 2025-01-02 15:11:18 +11:00
Ray Molenkamp
0dc484f9cc Cleanup: CMake: Modernize bf_rna dependencies
Pretty straightforward

- Remove any bf_rna 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/132413
2024-12-31 18:23:25 +01:00
Ray molenkamp
10c5493746 Cleanup: CMake: Modernize bf_geometry dependencies
Pretty straightforward

- Remove any bf_geometry 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/132375
2024-12-28 19:58:14 +01:00
Ray Molenkamp
167c15e0c0 Cleanup: CMake: Modernize bf_nodes dependencies
Pretty straightforward

- Remove any bf_nodes 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/132356
2024-12-26 19:52:49 +01:00
Ray Molenkamp
16eb4430f5 Cleanup: CMake: Modernize bf_render dependencies
Pretty straightforward

- Remove any bf_render 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/132355
2024-12-26 18:50:53 +01:00
Ray Molenkamp
4dcef4421c 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/132335
2024-12-25 19:46:31 +01:00
Ray Molenkamp
a23aab3ddc Cleanup: CMake: Modernize bf_blenloader dependencies
Pretty straightforward

- Remove any bf_blenloader 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/132334
2024-12-25 18:40:41 +01:00