Commit Graph

5025 Commits

Author SHA1 Message Date
Germano Cavalcante
ba6b4d4553 Fix: mixed snap not working on geometry generated by curves
`snap_polygon` and `snap_edge_points` were, for no reason, limited to
Mesh type Objects.
2024-12-12 13:10:36 -03:00
Laurynas Duburas
3cbeb8ff2b Curves: Remove usage of IndexMask::operator[] in transform
Removes usage of `IndexMask::operator[]` in transform
function `curve_populate_trans_data_structs`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131784
2024-12-12 15:36:24 +01:00
Hans Goudey
4bf34d9591 Nodes: Simplify location storage, remove hidden offfsets
Currently each node's position is stored in the coordinate space of
its parent. To find the location of a node on the canvas, we have to
apply the translation of each of its parents. Also, nodes have hidden
"offset" values used while transforming frame nodes. Together,
those made the system much more complicated than necessary,
and they made the Python API ineffective.

This commit removes usage of the offset values and moves nodes
to be stored in the "global" space of the node canvas. It also resolves
some weird behavior when resizing frame nodes, and fixes a few bugs.

The change is forward compatible, so we still write files with nodes in
the old parent-space format. In 5.0 the conversion when writing can be
removed. The existing Python API also stays the same. A new
"location_absolute" property gives node locations in global space,
and changing the old property also moves the child nodes of frames.

Resolves #92458, #72904.

Pull Request: https://projects.blender.org/blender/blender/pulls/131335
2024-12-11 21:06:41 +01:00
Laurynas Duburas
8dcb76b6ad Fix #130688: Grease Pencil: Multiframe Editing not applying falloff for rotation & scale
Fixes rotation and scale in multi frame editing.

Pull Request: https://projects.blender.org/blender/blender/pulls/131634
2024-12-10 17:21:06 +01:00
Lukas Tönne
d6e78d05c9 Transform: Crazyspace support in edit mode for Curves and Grease Pencil
Edit mode for curves and Grease Pencil was using the plain object transform for
all points without support for individual crazyspace transforms. This patch adds
support for the local rotation matrices, so editing curves on top of modifiers
converts offsets into original geometry space.

For Curves objects these matrices are currently only computed by the surface
deformation node, so editing on top of a surface deformation is the only case
that works currently.
For Grease Pencil the armature modifier is supported and more should be added
in future (see overview task #131599).

Pull Request: https://projects.blender.org/blender/blender/pulls/131619
2024-12-10 10:16:56 +01:00
Philipp Oeser
c67e96e8ea Fix #131585: UV translation wrong in header when constraints are used
For a bit of (somewhat related) history, check 8d590e4b86.

The real problem here is that for non square images, the
`applyAspectRatio` works with "wrong" vectors if translation constraints
(`CON_APPLY`) are used. Then, the passed vector might actually have axis
changed, e.g. constraining to the Y axis does not hold the Y translation
value in dvec[1], but in dvec[0]. This is expected by design, but
`applyAspectRatio` is not aware of this and does wrong things.

The easy way around this is to actually call `applyAspectRatio` before
the `CON_APPLY` stuff takes place.

NOTE: future improvement might be to split (or rename)
`removeAspectRatio` / `applyAspectRatio` becaues these functions also
handle the "conversion" to pixel values which is not obvious atm.

Pull Request: https://projects.blender.org/blender/blender/pulls/131608
2024-12-09 19:55:43 +01:00
Laurynas Duburas
b68be2aedd Fix #131451: Crash moving Grease Pencil points
Proportional editing expects `IndexMask` from all Bezier points not only from selection as it affects not only selected curves.
Therefore `selected_editable_strokes` changed `editable_strokes` and initialized with `retrieve_editable_strokes`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131519
2024-12-09 12:48:02 +01:00
Laurynas Duburas
cfa63bfefa Fix #130688: Grease Pencil: Multiframe Editing not applying falloff curve
Mutliframe editing wasn't using the falloff.

The fix adds a new field `Vector<float> grease_pencil_falloffs` to
`struct CurvesTransformData`. References it's values with `TransData.extra`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131147
2024-12-09 10:40:08 +01:00
Jesse Yurkovich
aef11435b9 Cleanup: Move MAX_DUPLI_RECUR define from DNA to BKE
Moving MAX_DUPLI_RECUR from `DNA_object_types` to `BKE_duplilist` is
more correct organizationally and it allows some downstream consumers to
remove the inclusion of a large and unnecessary DNA header.

Archaeology reference: https://archive.blender.org/developer/D8222

Pull Request: https://projects.blender.org/blender/blender/pulls/131274
2024-12-07 03:14:49 +01:00
Sybren A. Stüvel
81beebe4b8 Fix #131299: Grease Pencil: Moving keyframes doesn't update viewport
Grease Pencil animation data is stored in the object-data, not the
`AnimData` of the Grease Pencil ID. This meant that the object was
not properly tagged for an update, because the code assumed that
the object had an `adt`.

The fix calls `ANIM_id_update` to directly tag the Grease Pencil
ID for an update (which will also update the Grease Pencil frames
animation data).
2024-12-05 15:00:03 +01:00
Hans Goudey
024d7d12e2 Mesh: Move BVH storage to shared cache system
Avoid rebuilding BVH trees when meshes are copied.
Similar to the other uses of the shared cache system,
this can arbitrarily improve performance when meshes
are copied but not deformed and BVH building is the
main bottleneck. In a simple test file I got a 6x speedup.

The amount of code is also reduced and the system is
much simpler overall-- built out of common threading
patterns like `SharedCache` with its double-checked lock.
RAII is used in a few places to simplify memory management
too.

The downside is storing more `SharedCache` items in the
mesh runtime struct. That has a slight cost when copying
a small mesh many times, but we have ideas to improve that
in the future anyway (#104327).

Pull Request: https://projects.blender.org/blender/blender/pulls/130865
2024-12-04 00:17:17 +01:00
Germano Cavalcante
99e54df9f5 Fix #131215: Snap to Grid not working in x-ray
Caused by commit b4154c6a0e, which incorrectly removed the
`(snap_to_flag & SCE_SNAP_TO_GRID)` condition.
2024-12-01 23:22:03 -03:00
Philipp Oeser
e104735eeb Fix: Grease Pencil: issues with the transform keyframes system
Oversight in 09d2108bf5

For one, numinput for keyframes would be broken unless the mouse is moved first.
Secondly, redo would also be broken (using the `Adjust Last Operation` panel or the `Repeat Last` operator).

Above commit did a check for `TRANS_RUNNING` before calling `grease_pencil_layer_update_trans_data`.
This isnt set in any of the above scenarios (it only gets set once the moues moves).

This PR removes `TRANS_RUNNING` check to have proper calls to `grease_pencil_layer_update_trans_data`.
It has one downside: you now get a `grease_pencil_layer_update_trans_data` as soon as you hit `G`.
So it does remove_frame / add_frame unnecessarily (since we are still on the same frame), but only once, sees harmless in comparison to the two regression it fixes.

Fixes #131092
Fixes #130793

Pull Request: https://projects.blender.org/blender/blender/pulls/131143
2024-11-29 15:40:51 +01:00
Campbell Barton
b9f055459a Cleanup: ensure trailing space around comment blocks 2024-11-27 19:01:00 +11:00
Bastien Montagne
4bf5a2f5cb Cleanup: PointerRNA: Remove 'C-style' zero-initializations.
These are useless now that PointerRNA has explicit default values, and
become a problem when real constructors are added to this struct. Simply
use the default empty value initialization instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/130927
2024-11-25 19:09:56 +01:00
Germano Cavalcante
18d758d7b5 Fix #130864: Snap toggle is enabled if operation has snap option enabled
Add the condition that snapping was not enabled via properties.
2024-11-25 10:20:18 -03:00
Campbell Barton
0de8ae8046 Cleanup: spelling in comments 2024-11-25 13:24:46 +11:00
Habib Gahbiche
35ea495bb6 UI: Nodes: Remove some snapping options
Compositor: UI: remove snapping to nodes.

Snapping nodes to other nodes behaves in a very unpredictable way, which makes most snapping options useless.

The patch removes the following:
- Snapping options `Node X`, `Node Y` and `Node XY`
- Menu `Snap Node Element`
- Menu `Snap Target`

New behavior:
- Activating `Snap` always acts as 'Snap to Grid'

Part of https://projects.blender.org/blender/blender/issues/128612

Pull Request: https://projects.blender.org/blender/blender/pulls/127667
2024-11-24 14:30:22 +01:00
Hans Goudey
421e1a0c24 Cleanup: Replace some uses of GSet and GHash with C++ classes
For type safety and potentially improved performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/130796
2024-11-23 17:00:21 +01:00
Hans Goudey
129a2aa0f4 Refactor: Move region runtime data out of DNA
Pull Request: https://projects.blender.org/blender/blender/pulls/130303
2024-11-21 19:34:53 +01:00
Nathan Vegdahl
1dcd435a87 Fix #130216: GPv3: Crash in render due to slotted Actions
The root cause of this bug can be traced to:

- `ANIM_nla_mapping_get(ac, ale)` conditionally returns an `AnimData *adt`.
- This can be `nullptr` in various cases, depending on the editor (in `ac`) and
  the type & source of data (in `ale`).
- This `nullptr` has different meanings:
  1. There is not enough information to return an `adt` (like `ac` or `ale`
     being `nullptr` themselves).
  2. NLA time remapping should not be done. For example for NLA control F-Curves
     (like animated strip influence), or Grease Pencil (because that doesn't use
     the NLA).
- The above-returned `adt` is passed to other functions. Some of them are aware
  of the "`nullptr` means no NLA time remapping" scenario, and gracefully handle
  it. Other code, however, just gets "an adt" from the caller and handles it as
  normal (and likely crashes on `nullptr`). Other cases start out as the first,
  but somewhere in the call stack shift over to the second.

The approach taken in this PR to fix the bug is to (generally) stop signaling
"do not use NLA time remapping" via `adt = nullptr`, and instead explicitly
indicate/check whether remapping should be done.

In most cases this means passing a `bAnimListElem *` instead of an `AnimData *`,
because the former has the information needed to determine if time remapping
should be done or not. However, in some cases there is no `bAnimListElem *` to
pass, and instead other information determines whether remapping is needed. In
those cases we add a `bool` parameter or field in the appropriate place so that
calling code can explicitly indicate whether remapping should be done or not.

To accomplish this a variety of functions have been added to help handle things
correctly.  Of particular note:

- `AnimData *ANIM_nla_mapping_get(ac, ale)` (that conditionally returned an
  `adt`) has been removed entirely in favor of the new
  `bool ANIM_nla_mapping_allowed(ale)` function that simply returns whether
  nla remapping should be done or not.
- `ANIM_nla_tweakedit_remap(ale, …)` has been added, which wraps
  `BKE_nla_tweakedit_remap(adt, …)` and only performs the remapping when
  `ANIM_nla_mapping_allowed()` indicates that it's allowed.
- `ANIM_nla_mapping_apply_if_needed_fcurve(ale, …)` has been added, which is an
  alternative to `ANIM_nla_mapping_apply_fcurve(adt, …)` that also only performs
  the remapping when `ANIM_nla_mapping_allowed()` indicates that it's allowed.

Note that even with this PR there are still a couple of places remaining that
use `adt = nullptr` to indicate "don't remap", because they appear to be correct
and would require larger changes to make explicit. In those cases comments have
been added to explain the situation, with a reference to this PR.  In the future
we way want to take the time to change those as well.

Also of minor note: this PR moves the definition of the type `slot_handle_t`
from ANIM_action.hh to BKE_action.hh. This is due to `BKE_nla.hh` (which needs
that definition) now being included directly and indirectly in a lot more
places. Moving the definition to BKE_action.hh prevents all of those new places
from gaining dependencies on the animrig module.

Co-authored-by: Sybren A. Stüvel <sybren@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/130440
2024-11-21 16:37:13 +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
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
Germano Cavalcante
607b2dd826 Fix: assert failure when snapping to geometry with only vertices
These geometries do not have "EDGE_ENDPOINT".
2024-11-18 11:18:09 -03:00
Hans Goudey
75ab1c2daf Cleanup: Grease Pencil: Remove unused code and indirect include in header
- Remove now-unused runtime data from the legacy GP structs.
- Remove the `DNA_brush_types.h` include from the GP header.

Pull Request: https://projects.blender.org/blender/blender/pulls/130280
2024-11-14 16:59:55 +01:00
Jacques Lucke
64a9260921 Core: remove WITH_CXX_GUARDEDALLOC option
This implements the proposal from #124512. For that it contains the following
changes:
* Remove the global override of `new`/`delete` when `WITH_CXX_GUARDEDALLOC` was
  enabled.
* Always use `MEM_CXX_CLASS_ALLOC_FUNCS` where it is currently used. This used
  to be guarded by `WITH_CXX_GUARDEDALLOC` in some but not all cases. This means
  that a few classes which didn't use our guarded allocator by default before,
  are now using it.

Pull Request: https://projects.blender.org/blender/blender/pulls/130181
2024-11-13 13:39:49 +01:00
Bastien Montagne
b325142d17 Merge branch 'blender-v4.3-release' 2024-11-12 16:55:40 +01:00
Bastien Montagne
0b3a7cbe69 Cleanup: Move BKE_image.h and related headers to C++.
NOTE: This also required some changes to Cycles code itself, who is now
directly including `BKE_image.hh` instead of declaring a few prototypes
of these functions in its `blender/utils.h` header (due to C++ functions
names mangling, this was not working anymore).

Pull Request: https://projects.blender.org/blender/blender/pulls/130174
2024-11-12 16:53:54 +01:00
Thomas Dinges
ea72c6468e Merge branch 'blender-v4.3-release' 2024-11-12 16:53:17 +01:00
Laurynas Duburas
f9d89a0dfb Fix: Prevent bezier handle attribute creation on transform
Prevents Bezier handle attribute creation on transform for
`CurvesGeometry` instances without Bezier curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/130165
2024-11-12 16:51:54 +01:00
Falk David
f28bbfc702 Merge branch 'blender-v4.3-release' 2024-11-12 10:22:32 +01:00
Sybren A. Stüvel
ae5717905b Fix #130090: Grease Pencil object in NLA cause Blender to crash
Add some missing `nullptr` and `ale->type` checks to ensure the
assmptions the rest of the code makes holds.

The direct cause of this issue is likely
822907a68d. The root cause is the hard to
predict behaviour of the animation filtering system combined with a lot
of pointer casts without testing whether the data is actually of the
expected type.

Pull Request: https://projects.blender.org/blender/blender/pulls/130148
2024-11-12 10:19:27 +01:00
Germano Cavalcante
e79ffa3ae9 Merge remote-tracking branch 'origin/blender-v4.3-release' 2024-11-11 10:30:18 -03:00
Germano Cavalcante
b4154c6a0e Fix #130078: Snap to Grid ignored if occluded in Add Object Tool
The snap cursor internally snaps to the Face to define the occlusion of
the Grid or to calculate the "Surface" orientation set by the tool.

Even though this is not the snap point enabled by the user, this
internal Snap to Face takes precedence over the Snap to Grid that is
enabled by the user.

To solve this, the solution is to do a second snap test but now only to
Grid and using the hit point as a reference for the closest grid.

Also fixes Absolute Increment Snap not being detected as Grid by the
tool.

Pull Request: https://projects.blender.org/blender/blender/pulls/130092
2024-11-11 14:26:52 +01:00
Richard Antalik
b193684b5d VSE: Use snapping for retiming keys
Retiming keys now can be used as snap sources or targets. Snapping to
keys can be disabled similar to other targets.

Pull Request: https://projects.blender.org/blender/blender/pulls/129709
2024-11-06 05:43:34 +01:00
Campbell Barton
96ac7b7ff3 Merge branch 'blender-v4.3-release' 2024-11-06 10:51:53 +11:00
Campbell Barton
6ccbafc5dc Cleanup: spelling in comments 2024-11-06 10:49:51 +11:00
Falk David
a4e0b799c8 Merge branch 'blender-v4.3-release' 2024-11-04 17:04:09 +01:00
Sybren A. Stüvel
6f0cd39eab Fix: GPv3: Crash in transform snapping code
Fix a crash in transform snapping code, where NLA retiming was attempted
on Grease Pencil frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/129808
2024-11-04 16:44:18 +01:00
Hans Goudey
a804320138 Cleanup: Remove unused grease pencil legacy handling in some operators
See #123468.
2024-11-02 23:14:41 +01:00
Hans Goudey
a8f41a618c Cleanup: Remove unused GP V2 transform, curve edit code
See #123468.

Pull Request: https://projects.blender.org/blender/blender/pulls/129731
2024-11-02 22:24:59 +01:00
Campbell Barton
15c207a294 Merge branch 'blender-v4.3-release' 2024-11-02 17:34:00 +11:00
Campbell Barton
4df285ccd5 Cleanup: move function comments into headers or implementation notes
For C/C++ doc-strings should be located in headers,
move function comments into the headers, in some cases merging
with existing doc-strings, in other cases, moving implementation
notes into the function body.
2024-11-02 17:27:09 +11:00
Hans Goudey
9a17a6a154 Fix: Deduplicate/correct curves point selection calculation
The grease pencil version of the code had a race condition, appending
to a vector from multiple threads.
2024-11-01 16:59:52 +01:00
Laurynas Duburas
c806f885d4 Curves: Align handles in transform operator
Aligns Bezier handles when both handles are of the`BEZIER_HANDLE_ALIGN`
type. If the left handle is selected, then the right one is aligned
with it. The left handle is aligned with the right handle only if the
left handle is not selected.

Rel #105038

Pull Request: https://projects.blender.org/blender/blender/pulls/128726
2024-10-31 11:25:41 +01:00
Laurynas Duburas
229e0a8cae Curves: Convert handle types when transforming
Converts Bezier handle types when transforming starts.
If single BEZIER_HANDLE_AUTO handle is transformed it becomes
BEZIER_HANDLE_ALIGN. If single BEZIER_HANDLE_VECTOR handle is
transformed it becomes BEZIER_HANDLE_FREE.

https://docs.blender.org/manual/en/latest/modeling/curves/structure.html

Rel #105038

Pull Request: https://projects.blender.org/blender/blender/pulls/128638
2024-10-31 10:42:24 +01:00
Campbell Barton
44f9df305e Merge branch 'blender-v4.3-release' 2024-10-31 18:52:03 +11:00