Commit Graph

34 Commits

Author SHA1 Message Date
Guillermo Venegas
7682258ff9 Refactor: UI: Use a Vector to store buttons in UI blocks
This changes the ui-blocks buttons storage from Listbase to Vector.

Major changes that might cause a performance considerations are
in `ui_but_update_from_old_block` that requires to track buttons when restoring
button state between block redraws or in  `uiItemFullR` that may needs to insert
uiButs in the middle of the vector to add decorators. This might not be as fast as
removing or inserting elements in the middle of a listbase container. Also buttons currently
don't know its position in the container, so to get the previous and next
button its required to make a lookup of the button in the container.

`UI_block_update_from_old> ui_but_update_from_old_block` restores the state
of buttons between frames, this is done by sequentially testing if a button is the
same as an old button, however since UI can be created procedurally some old buttons
may not be drawn while editing other button data, this requires an extra track of what
buttons may not match to a new button while comparing for restoring state, but still
this buttons may be candidates to match to an new button.

Not functional changes expected.
Ref: #117604

Co-authored-by: Julian Eisel <julian@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/127128
2025-02-14 15:29:26 +01:00
Hans Goudey
c6f5c44350 Cleanup: Remove unused includes in editors modules
Pull Request: https://projects.blender.org/blender/blender/pulls/133166
2025-01-16 23:17:51 +01:00
Campbell Barton
0de8ae8046 Cleanup: spelling in comments 2024-11-25 13:24:46 +11: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
Sybren A. Stüvel
1c34e00ce1 Anim: draw prop as 'orange' when changed value with stashed Actions present
Properties that are animated, but have different values than their
animation data, are drawn in orange. This was skipped whenever any NLA
tracks were active (likely because this would re-evaluate the NLA for
every property drawn, which is a performance bottleneck).

This commit lifts this limitation slightly, and only skips the "has this
changed?" check if there are any non-muted NLA tracks. This means that
using the NLA purely as a stash of Actions is now possible without
losing the 'orange means it changed' indicators in the UI.

Fixes: #129968

Pull Request: https://projects.blender.org/blender/blender/pulls/130130
2024-11-18 12:58:36 +01:00
Christoph Lendenfeld
b38d8ecb86 Refactor: move keyingsets to animrig
No functional changes intended.

This patch moves the relevant keying set code from editors to animrig.
All functions are in the animrig namespace, and as such have lost their
`ANIM_` prefix.
Other than that, the code has been moved as is into `animrig/intern/keyingsets.cc`

Note that I also had to move `id_frame_has_keyframe` and `fcurve_frame_has_keyframe`.
I moved that into `ANIM_keyframing.hh` and `ANIM_fcurve.hh` since I found that more fitting.

Due to Windows defining `DELETE` as macro I had to rename `ModifyKeyMode::DELETE`
to `ModifyKeyMode::DELETE_KEY`

As a result of this two includes from animrig to editors were removed.

This is part of #121336

Pull Request: https://projects.blender.org/blender/blender/pulls/129980
2024-11-15 10:51:41 +01:00
Sybren A. Stüvel
636d83fbea Refactor: convert BKE_nla.h to C++
Rename `BKE_nla.h` to `BKE_nla.hh` and remove C-isms.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/127395
2024-09-10 13:41:01 +02:00
Falk David
a11335d19a Cleanup: Move BKE_fcurve.h to C++
No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119094
2024-03-05 18:39:08 +01:00
Campbell Barton
b372ebae68 Cleanup: unused headers for source/blender/editors
Remove 1317 includes from editors.
2024-02-13 10:02:53 +11:00
Bastien Montagne
54618dbae3 Cleanup: Make BKE_global.h a Cpp header. 2024-02-10 18:25:14 +01:00
Hans Goudey
f04bc75f8c Cleanup: Use std::string for some RNA function return values
This significantly simplifies memory management, mostly by avoiding
the need to free the memory manually. It may also improve performance,
since std::string has an inline buffer that can prevent heap
allocations and it stores the size.

Pull Request: https://projects.blender.org/blender/blender/pulls/117695
2024-01-31 17:08:09 +01:00
Sybren A. Stüvel
51c6dc06a0 Refactor: reduce indentation of ui_but_anim_flag()
Reduce cognitive complexity of `ui_but_anim_flag()`. Early returns, less
indentation, and variable declarations close to where they are used.

No functional changes.
2024-01-29 15:51:50 +01:00
Bastien Montagne
3acb64e7ac BKE_main: move header to be a fully CPP one.
Pull Request: https://projects.blender.org/blender/blender/pulls/115681
2023-12-01 20:38:54 +01:00
Hans Goudey
3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Christoph Lendenfeld
3792c2720d Refactor: remove ED_ prefix from autokeying functions
No functional changes

Since the functions now live in a namespace,
they no longer need the prefix

as a result there are now 2 functions named
`autokeyframe_object`
which is fine because they take different parameters

If both are needed is for a future patch to investigate

Pull Request: https://projects.blender.org/blender/blender/pulls/113612
2023-10-12 16:32:29 +02:00
Christoph Lendenfeld
a3831fe7af Refactor: Move autokeyframing functions to animrig
No functional changes

The following functions have been moved
`autokeyframe_cfra_can_key`
`autokeyframe_object`
`ED_autokeyframe_object`
`ED_autokeyframe_pchan`
`ED_autokeyframe_property`

they are all in a new file
keyframing_auto.cc
while the declarations are in
ANIM_keyframing.cc

The autokeyframe makros also have been moved

Pull Request: https://projects.blender.org/blender/blender/pulls/113607
2023-10-12 15:44:58 +02:00
Hans Goudey
867f99c2af Cleanup: Move depsgraph headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110816
2023-09-22 03:18:17 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Jacques Lucke
cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Hans Goudey
ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00
Hans Goudey
bc8c892c65 Cleanup: Move WM headers to C++
Also move a few more headers that included WM headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/110815
2023-08-04 23:11:22 +02:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton
3958ae7241 Cleanup: use STRNCPY, SNPRINTF macros 2023-05-09 14:08:19 +10:00
Campbell Barton
df54b627b3 Cleanup: use of the term 'len' & 'maxlen'
Only use the term len & maxlen when they represent the length & maximum
length of a string. Instead of the available bytes to use.

Also include the data they're referencing as a suffix, otherwise it's
not always clear what the length is in reference to.
2023-05-07 16:46:37 +10:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Sybren A. Stüvel
e84ae56621 Refactor: remove enum eAnimFilterFlags
Remove `enum eAnimFilterFlags` from `ED_keyframing.h`, the function
parameters that pass them around, and the code that uses them to filter
things.

Only one of the enum values was actually used, `ANIMFILTER_KEYS_LOCAL`.
It indicates whether to only consider keys on the datablock itself (when
set), or in the case of objects, also consider keys on its materials or
shapekeys (when cleared). However, this flag was *always* set, making it
possible to remove the code that handled it.

Finally there was only one function that received a `filters` parameter
that could be different across calls: it would either have value
`ANIMFILTER_KEYS_LOCAL` or `0`. However, the only flag it actually tested
for was `ANIMFILTER_KEYS_MUTED`, which was never actually set. So all of
that could be removed as well.

Just for grepping-through-history sake, these are the flags that were
removed:

- `ANIMFILTER_KEYS_LOCAL`
- `ANIMFILTER_KEYS_MUTED`
- `ANIMFILTER_KEYS_ACTIVE`
- `ANIMFILTER_KEYS_NOMAT`
- `ANIMFILTER_KEYS_NOSKEY`

Note: this is NOT about the flags defined in `ED_anim_api.h`, in `enum
eAnimFilter_Flags`. Note the different names, the one that's removed
doesn't have an `_`.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/106028
2023-03-23 13:00:56 +01:00
Campbell Barton
91346755ce Cleanup: use '#' prefix for issues instead of 'T'
Match the convention from Gitea instead of Phabricator's T for tasks.
2023-02-12 14:56:05 +11:00
Campbell Barton
0381fe7bfe Cleanup: update username in code-comments: campbellbarton -> ideasman42
Gitea migration changed my username, update code-comments.
2023-02-09 11:33:48 +11:00
Julian Eisel
d204830107 UI: Make uiBut safe for non-trivial construction
No user-visible changes expected.

Essentially, this makes it possible to use C++ types like `std::function`
inside `uiBut`. This has plenty of benefits, for example this should help
significantly reducing unsafe `void *` use (since a `std::function` can hold
arbitrary data while preserving types).

----

I wanted to use a non-trivially-constructible C++ type (`std::function`) inside
`uiBut`. But this would mean we can't use `MEM_cnew()` like allocation anymore.

Rather than writing worse code, allow non-trivial construction for `uiBut`.
Member-initializing all members is annoying since there are so many, but rather
safe than sorry. As we use more C++ types (e.g. convert callbacks to use
`std::function`), this should become less since they initialize properly on
default construction.

Also use proper C++ inheritance for `uiBut` subtypes, the old way to allocate
based on size isn't working anymore.

Differential Revision: https://developer.blender.org/D17164

Reviewed by: Hans Goudey
2023-02-03 16:35:51 +01:00
Hans Goudey
08b2d04021 Cleanup: Use std::swap instead of macro in C++ code 2023-01-09 11:30:36 -05:00
Hans Goudey
4ecc7cf14a Cleanup: Move interface_intern.hh
The entire interface directory is now compiled as C++ files.
2022-11-26 10:12:58 -06:00
Hans Goudey
97746129d5 Cleanup: replace UNUSED macro with commented args in C++ code
This is the conventional way of dealing with unused arguments in C++,
since it works on all compilers.

Regex find and replace: `UNUSED\((\w+)\)` -> `/*$1*/`
2022-10-03 17:38:16 -05:00
Campbell Barton
c7a7aee004 Cleanup: use own username in code-comment tags 2022-08-09 14:18:18 +10:00
Hans Goudey
599a7ddf17 Cleanup: Move five interface files to C++
Builds on all four platforms on the buildbot. Includes clang tidy fixes.
2022-07-29 23:22:31 -05:00