Anim: implement "Copy Driver to Selected" operator #120936

Merged
Nathan Vegdahl merged 19 commits from nathanvegdahl/blender:copy_driver_to_selected_120518 into main 2024-04-29 18:35:06 +02:00
Member

Resolves #120518

The implementation is based on the "Copy to Selected" operator, just adapted to copy drivers instead.

For reviewers:

  • There is a TODO to make removing existing drivers more efficient. I think it probably makes sense to do that as a separate PR in the future if/when that becomes an actual performance issue.

Todo (from review comments):

  • Don't copy the driver to items that are already animated, since that puts those properties in a weird state (both animated and driven).
  • "Copy all" variant for array properties.
  • See if we can give a good explanatory message in the tool tip when the operator is disabled. (It seems like this is more trouble than it's worth, given current limitations of the relevant APIs.)
  • Add unit tests.
Resolves #120518 The implementation is based on the "Copy to Selected" operator, just adapted to copy drivers instead. For reviewers: - There is a TODO to make removing existing drivers more efficient. I think it probably makes sense to do that as a separate PR in the future if/when that becomes an actual performance issue. Todo (from review comments): - [x] Don't copy the driver to items that are already animated, since that puts those properties in a weird state (both animated and driven). - [x] "Copy all" variant for array properties. - ~~See if we can give a good explanatory message in the tool tip when the operator is disabled.~~ (It seems like this is more trouble than it's worth, given current limitations of the relevant APIs.) - [x] Add unit tests.
Nathan Vegdahl added 1 commit 2024-04-22 15:08:00 +02:00
Nathan Vegdahl added 1 commit 2024-04-22 18:22:05 +02:00
3d314b0ac7 Misc cleanup
No functional change.
Nathan Vegdahl added 1 commit 2024-04-22 18:24:02 +02:00
Nathan Vegdahl added 1 commit 2024-04-23 08:23:17 +02:00
1fe067f0c2 Remove unneeded function parameter from check function
I added it earlier while just getting things working, but the thing
it triggered can just be moved directly into the copy driver function.
Nathan Vegdahl added 1 commit 2024-04-23 09:16:12 +02:00
662ce765b5 Use the right function for finding the ID and RNA paths of properties
Apparently the "real" ID isn't the real ID in the sense I would have
expected.
Nathan Vegdahl added 1 commit 2024-04-23 09:53:19 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
d471340c81
Clean up code comments
Nathan Vegdahl changed title from WIP: Anim: implement "Copy Driver to Selected" operator to Anim: implement "Copy Driver to Selected" operator 2024-04-23 10:00:08 +02:00
Nathan Vegdahl requested review from Sybren A. Stüvel 2024-04-23 10:00:25 +02:00
Nathan Vegdahl requested review from Christoph Lendenfeld 2024-04-23 10:00:47 +02:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR120936) when ready.
Author
Member

@SimonThommes @Mets I've triggered a package build. When it's finished I would love some testing on this from you guys.

@SimonThommes @Mets I've triggered a package build. When it's finished I would love some testing on this from you guys.
Sybren A. Stüvel requested changes 2024-04-23 10:52:13 +02:00
Dismissed
Sybren A. Stüvel left a comment
Member

This seems to work well. There's one state that this operator can create that the Blender UI otherwise avoids, and that is having both animation and a driver on the same property. The UI does not handle this properly. Evaluation-wise the driver "wins", but when it comes to the background colour the FCurve "wins". This is not a good state to be in. Would be good to have a bit of a design discussion to figure out what should happen in this case.

This seems to work well. There's one state that this operator can create that the Blender UI otherwise avoids, and that is having both animation and a driver on the same property. The UI does not handle this properly. Evaluation-wise the driver "wins", but when it comes to the background colour the FCurve "wins". This is not a good state to be in. Would be good to have a bit of a design discussion to figure out what should happen in this case.
@ -1567,0 +1587,4 @@
* otherwise. Returns true in poll mode if a copy could be successfully made,
* and false otherwise.
*/
static bool copy_driver_to_selected_button(bContext *C, bool poll)

const bool

`const bool`
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1621,4 @@
* side data. */
std::optional<std::string> path;
bool use_path_from_id;
blender::Vector<PointerRNA> lb;

Don't use a modern container, but retain the old lb (for "ListBase") name.

Don't use a modern container, but retain the old `lb` (for "ListBase") name.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1628,4 @@
/* Copy the driver to the list of target properties. */
int copy_count = 0;
for (PointerRNA &link : lb) {

Same here, no link (because of old ListBase again), but name after what's in there.

Same here, no `link` (because of old ListBase again), but name after what's in there.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1695,4 @@
static bool copy_driver_to_selected_button_poll(bContext *C)
{
return copy_driver_to_selected_button(C, true);

The poll function should use CTX_wm_operator_poll_msg_set() (or CTX_wm_operator_poll_msg_set_dynamic()) to explain why the operator is disabled. I think this can be done relatively easily by making copy_driver_to_selected_button() return a std::optional<std::string> (or maybe std::optional<StringRef>) that contains the explanation when nothing could be copied.

So instead of return false; it would be return "You didn't fry an egg this morning";, and return true; becomes return {}; (or have some const std::optional<StringRef> it_was_all_ok to return a more explicit 'ok' thing).

The poll function should use `CTX_wm_operator_poll_msg_set()` (or `CTX_wm_operator_poll_msg_set_dynamic()`) to explain why the operator is disabled. I think this can be done relatively easily by making `copy_driver_to_selected_button()` return a `std::optional<std::string>` (or maybe `std::optional<StringRef>`) that contains the explanation when nothing could be copied. So instead of `return false;` it would be `return "You didn't fry an egg this morning";`, and `return true;` becomes `return {};` (or have some `const std::optional<StringRef> it_was_all_ok` to return a more explicit 'ok' thing).
Author
Member

I gave this a shot, but the explanatory message in the popup always ended up being the string for when a valid property to copy from isn't found at all, which was... weird.

With a little debugging, it turns out that the poll function is being passed different things in the following two cases:

  1. To determine whether the Copy Driver to Selected menu item is enabled or not. In this case it gets passed the button for the property we were hovering over (e.g. the X location of the active object).
  2. To determine the contents of the tool tip for Copy Driver to Selected. As far as I can tell from tracing the execution, in this case it gets passed the button for the Copy Driver to Selected menu item itself, which of course doesn't have a valid property associated with it.

I'm not sure if this is a limitation of Blender's internal APIs (e.g. in case number 2 the user is, indeed, hovering over the Copy Driver to Selected menu item at that point), or if my code is doing something wrong (e.g. I'm registering the operator incorrectly, or adding it to the menu wrong, etc.).

I gave this a shot, but the explanatory message in the popup always ended up being the string for when a valid property to copy from isn't found at all, which was... weird. With a little debugging, it turns out that the poll function is being passed different things in the following two cases: 1. To determine whether the `Copy Driver to Selected` menu item is enabled or not. In this case it gets passed the button for the property we were hovering over (e.g. the X location of the active object). 2. To determine the contents of the tool tip for `Copy Driver to Selected`. As far as I can tell from tracing the execution, in this case it gets passed the button for the `Copy Driver to Selected` menu item *itself*, which of course doesn't have a valid property associated with it. I'm not sure if this is a limitation of Blender's internal APIs (e.g. in case number 2 the user is, indeed, hovering over the `Copy Driver to Selected` menu item at that point), or if my code is doing something wrong (e.g. I'm registering the operator incorrectly, or adding it to the menu wrong, etc.).

Then let's not go there (yet). If this is to be addressed, it can wait until another PR.

Then let's not go there (yet). If this is to be addressed, it can wait until another PR.
dr.sybren marked this conversation as resolved
@ -1567,0 +1700,4 @@
static int copy_driver_to_selected_button_exec(bContext *C, wmOperator * /* op */)
{
if (copy_driver_to_selected_button(C, false)) {

Flip condition, return early.

Flip condition, return early.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1703,4 @@
if (copy_driver_to_selected_button(C, false)) {
DEG_relations_tag_update(CTX_data_main(C));
/* TODO: ask someone in-the-know whether this call is needed or not.

Notifiers are necessary here, and given that Paste Driver also uses these, they're fine to use here too.

In the long term, we need to untangle the use of ND_KEY... for drivers, but that's for another day.

Notifiers are necessary here, and given that Paste Driver also uses these, they're fine to use here too. In the long term, we need to untangle the use of `ND_KEY...` for drivers, but that's for another day.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1723,4 @@
static void UI_OT_copy_driver_to_selected_button(wmOperatorType *ot)
{
/* identifiers */

Capitalisation & period.

Capitalisation & period.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1727,4 @@
ot->name = "Copy Driver to Selected";
ot->idname = "UI_OT_copy_driver_to_selected_button";
ot->description =
"Copy the property's driver from the active item to the same property of all selected items "

Comma after "selected items"?

Comma after "selected items"?
nathanvegdahl marked this conversation as resolved
Nathan Vegdahl added 1 commit 2024-04-23 11:15:50 +02:00
Nathan Vegdahl added 1 commit 2024-04-23 11:20:45 +02:00
Christoph Lendenfeld approved these changes 2024-04-23 12:16:38 +02:00
Christoph Lendenfeld left a comment
Member

lgtm and super useful to have
I agree with optimizing the case of finding a driver FCurve later. Even though it is quadratic the amount of driver curves will likely stay quite low.
Also very nice to have that comment on top of copy_driver_to_selected_button.

lgtm and super useful to have I agree with optimizing the case of finding a driver FCurve later. Even though it is quadratic the amount of driver curves will likely stay quite low. Also very nice to have that comment on top of `copy_driver_to_selected_button`.
Member

Awesome! Thank you for the implementation, it worked great in my tests!

I do think it would be useful to have a split into single/all for arrays. Especially for colors it can be tedious to open the color picker and do it per component. Right now this operator also doesn't show up in the context menu of a color property, since there is no all version. I think it should work the same way how the general Copy to Selected functionality works.

Awesome! Thank you for the implementation, it worked great in my tests! I do think it would be useful to have a split into single/all for arrays. Especially for colors it can be tedious to open the color picker and do it per component. Right now this operator also doesn't show up in the context menu of a color property, since there is no `all` version. I think it should work the same way how the general `Copy to Selected` functionality works.
Nathan Vegdahl added 1 commit 2024-04-23 16:06:23 +02:00
Author
Member

Ah, that's a good point about color properties. I wanted to avoid cluttering the context menu even further (it's already really full of stuff), but maybe that's unavoidable.

In any case, that should be pretty easy to add.

Ah, that's a good point about color properties. I wanted to avoid cluttering the context menu even further (it's already really full of stuff), but maybe that's unavoidable. In any case, that should be pretty easy to add.
Author
Member

A slight hiccup in implementing the "all" variant of the menu item: if we want to have just one operator with an "all" parameter (like Copy to Selected does), the poll function that determines if the menu item is enabled/disabled has to be the same for both menu items. This is because the poll function doesn't get access to operator parameters.

For the Copy to Selected operator this doesn't matter, because it's just copying values, which always exist. But for the Copy Drivers to Selected operator there may be drivers on only some of the elements of an array property. This leads to the odd situation where if the user right-clicks on one of the elements without a driver, there is a conflict between the two menu items: ideally the 'single' menu item is disabled and the 'all' menu item is enabled... but that's not possible.

I discussed with @SimonThommes and we agreed that (probably) the least weird option is for both menu items to be disabled in that case, following whether there's a driver on the specific element you right-clicked on. So I'll implement it that way. If that turns out to be especially weird, it will be easy to swap.

A slight hiccup in implementing the "all" variant of the menu item: if we want to have just one operator with an "all" parameter (like `Copy to Selected` does), the `poll` function that determines if the menu item is enabled/disabled has to be the same for both menu items. This is because the `poll` function doesn't get access to operator parameters. For the `Copy to Selected` operator this doesn't matter, because it's just copying values, which always exist. But for the `Copy Drivers to Selected` operator there may be drivers on only some of the elements of an array property. This leads to the odd situation where if the user right-clicks on one of the elements *without* a driver, there is a conflict between the two menu items: ideally the 'single' menu item is disabled and the 'all' menu item is enabled... but that's not possible. I discussed with @SimonThommes and we agreed that (probably) the least weird option is for both menu items to be disabled in that case, following whether there's a driver on the specific element you right-clicked on. So I'll implement it that way. If that turns out to be especially weird, it will be easy to swap.
Nathan Vegdahl added 1 commit 2024-04-25 16:14:44 +02:00
Nathan Vegdahl added 1 commit 2024-04-25 17:54:13 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
75e330e8a9
Refactor get/paste driver code out into separate functions
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR120936) when ready.
Author
Member

@SimonThommes @Mets I've triggered another package build, now with "Copy All" implemented for array properties. When it's done building and you get the chance, I would appreciate it if you could give it another spin.

@SimonThommes @Mets I've triggered another package build, now with "Copy All" implemented for array properties. When it's done building and you get the chance, I would appreciate it if you could give it another spin.
Member

Awesome, ready to be merged imo 👍

Awesome, ready to be merged imo 👍
Sybren A. Stüvel requested changes 2024-04-26 15:04:22 +02:00
Dismissed
Sybren A. Stüvel left a comment
Member

Buncha notes.

Buncha notes.
@ -761,3 +776,4 @@
ICON_DRIVER,
"ANIM_OT_driver_button_edit");
}
else {

This goes with the if (!is_whole_array) . Usually I try to avoid a negation + an else, so it might be better to just swap the two conditional blocks and use if (is_whole_array).

This goes with the `if (!is_whole_array) `. Usually I try to avoid a negation + an `else`, so it might be better to just swap the two conditional blocks and use `if (is_whole_array)`.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1572,4 @@
* \{ */
/**
* Gets the driver(s) of the given property.

AFAIK the preferred style is the imperative, so "Get the driver(s)..."

AFAIK the preferred style is the imperative, so "Get the driver(s)..."
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1598,4 @@
const bool is_array_prop = RNA_property_array_check(prop);
if (r_is_array_prop != nullptr) {
*r_is_array_prop = is_array_prop;

This code being here means that r_is_array_prop is set even when the precondition checks below fail. I think it's better to push the assignment to *r_is_array_prop further down, when actual data can be returned. This will reduce the number of "states" that can be returned (i.e. either "nothing is returned" or "useful info is returned"; the latter can still mean an empty vector of course).

I would move the call to RNA_property_array_check() to just above where is_array_prop is used, and the assignment to *r_is_array_prop to as low as makes sense in this function. This of course depends on how the caller has to deal with the *r_is_array_prop value.

This code being here means that `r_is_array_prop` is set even when the precondition checks below fail. I think it's better to push the assignment to `*r_is_array_prop` further down, when actual data can be returned. This will reduce the number of "states" that can be returned (i.e. either "nothing is returned" or "useful info is returned"; the latter can still mean an empty vector of course). I would move the call to `RNA_property_array_check()` to just above where `is_array_prop` is used, and the assignment to `*r_is_array_prop` to as low as makes sense in this function. This of course depends on how the caller has to deal with the `*r_is_array_prop` value.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1613,4 @@
blender::Vector<FCurve *> drivers = {};
if (!is_array_prop) {
drivers.append(BKE_fcurve_find(&adt->drivers, path->c_str(), index));

Here I actuall agree with the negation + else order, as the first thing you read is the simplest one; this makes the whole easier to digest.

Here I actuall agree with the negation + `else` order, as the first thing you read is the simplest one; this makes the whole easier to digest.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1617,4 @@
}
else {
/* For array properties, we always allocate space for all elements of an
* array property, and the unused ones just remain null. */

Good choice.

Good choice.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1626,4 @@
}
}
/* If we didn't get any drivers to copy, early-out. */

I think here the "early out" isn't the most relevant. I think this would be clearer:

"If we didn't get any drivers to copy, instead of returning a vector of all nullptr, return an empty vector for clarity. That way the caller gets either a useful result or an empty one."

I think here the "early out" isn't the most relevant. I think this would be clearer: "If we didn't get any drivers to copy, instead of returning a vector of all nullptr, return an empty vector for clarity. That way the caller gets either a useful result or an empty one."
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1647,4 @@
*
* Note: intended to be used in conjunction with `get_property_drivers()` above.
*
* \param src_drivers The array of drivers to paste. If `is_array_prop`

since this is not an array in the C++ type sense of the word, I think it's clearer to just write "The span of drivers" instead.

since this is not an array in the C++ type sense of the word, I think it's clearer to just write "The span of drivers" instead.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1653,4 @@
* \param is_array_prop Whether `src_drivers` are drivers for the elements
* of an array property.
* \param dst_ptr The RNA pointer for the destination property.
* \param dist_prop The destination property RNA.

Just for clarity, you may want to add "If src_drivers has more than one element, it is assumed that this is an array property of equal length of src_drivers" or something along those lines. Just to drive the point home that, if it is an array, it is assumed that these two match.

Just for clarity, you may want to add "If src_drivers has more than one element, it is assumed that this is an array property of equal length of src_drivers" or something along those lines. Just to drive the point home that, if it is an array, it is assumed that these two match.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1669,4 @@
/* Get the RNA path and relevant animdata for the property we're copying to. */
const std::optional<std::string> dst_path = RNA_path_from_ID_to_property(dst_ptr, dst_prop);
if (!dst_path.has_value()) {
return 0;

Do you think it makes sense to distinguish between "no drivers copied" and "could not actually get to the point where we can copy drivers"?

Do you think it makes sense to distinguish between "no drivers copied" and "could not actually get to the point where we can copy drivers"?
Author
Member

I definitely do think that makes sense, but for the time being I think this fine. Distinguishing those kinds of failure cases is exactly what I want something like we've discussed in the error handling devtalk thread for. Trying to propagate that information up the call chain would be a bit awkward and bespoke right now.

I definitely do think that makes sense, but for the time being I think this fine. Distinguishing those kinds of failure cases is exactly what I want something like we've discussed in [the error handling devtalk thread](https://devtalk.blender.org/t/developer-discussion-handling-errors/33054) for. Trying to propagate that information up the call chain would be a bit awkward and bespoke right now.
dr.sybren marked this conversation as resolved
@ -1567,0 +1684,4 @@
}
const int dst_index = is_array_prop ? i : -1;
/* If it's already animated by something other than a driver, skip. */

Add a comment that explains why. Before I looked into this in more detail, I also didn't know that the UI is actually blocking the "both driver and animation" case.

Add a comment that explains why. Before I looked into this in more detail, I also didn't know that the UI is actually blocking the "both driver and animation" case.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1701,4 @@
* drivers to find one that matches. We should be able to make this more
* efficient with a little cleverness .*/
{
FCurve *old_driver = BKE_fcurve_find(&dst_adt->drivers, dst_path->c_str(), dst_index);

You might be able to skip this when driven above is false?

You might be able to skip this when `driven` above is `false`?
Author
Member

Yeah, it looks like we can do that. One caveat, however, is that the way that BKE_fcurve_find_by_rna() works internally (which you have to dive a couple of function calls deep to find out) is that driven only gets set to true if the property isn't also animated. In other words, if the property is both animated and driven, driven remains false despite there being a driver (which takes precedence in evaluation!).

But since we skip adding the driver if it's animated, that's fine in this case.

(Another odd thing about BKE_fcurve_find_by_rna(), and the only reason I created the driven variable initially, is that despite appearances the r_driven parameter isn't null safe. All assignments to the other r_* parameters are guarded behind nullptr checks, but there's one place where it looks like someone forgot a guard for r_driven. That should also be fixed, but not in this PR. I'll make another PR for that after this one lands.)

Yeah, it looks like we can do that. One caveat, however, is that the way that `BKE_fcurve_find_by_rna()` works internally (which you have to dive a couple of function calls deep to find out) is that `driven` only gets set to true if the property isn't also animated. In other words, if the property is both animated *and* driven, `driven` remains false despite there being a driver (which takes precedence in evaluation!). But since we skip adding the driver if it's animated, that's fine in this case. (Another odd thing about `BKE_fcurve_find_by_rna()`, and the only reason I created the `driven` variable initially, is that despite appearances the `r_driven` parameter isn't null safe. All assignments to the other `r_*` parameters are guarded behind nullptr checks, but there's one place where it looks like someone forgot a guard for `r_driven`. That should also be fixed, but not in this PR. I'll make another PR for that after this one lands.)
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1709,4 @@
}
/* Create the new driver. */
FCurve *new_driver = BKE_fcurve_copy(src_drivers[i]);

This IMO should not be here, but in a BKE_driver_copy() function.

This IMO should not be here, but in a `BKE_driver_copy()` function.
Author
Member

These four lines are doing the following things:

  • Duplicating the driver.
  • Adding that duplicate to the animdata.
  • Changing the driver's RNA path.

I don't think the name BKE_copy_driver() appropriately captures that. And I don't think tying all three of those things together in a single function makes sense. Maybe just the first two, but then I don't think we're gaining much clarity or meaningfully reducing code duplication.

However, I do think something like a "BKE_set_driver_rna_path()" could help the clarity here, since as-is we're doing raw memory freeing and string handling, which certainly makes the intent a bit unclear.

What do you think?

These four lines are doing the following things: - Duplicating the driver. - Adding that duplicate to the animdata. - Changing the driver's RNA path. I don't think the name `BKE_copy_driver()` appropriately captures that. And I don't think tying all three of those things together in a single function makes sense. Maybe just the first two, but then I don't think we're gaining much clarity or meaningfully reducing code duplication. However, I do think something like a "BKE_set_driver_rna_path()" could help the clarity here, since as-is we're doing raw memory freeing and string handling, which certainly makes the intent a bit unclear. What do you think?

Sure, I didn't mean to suggest that this name was perfect, just wanted to say that such functionality would be better placed in another function instead of as part of this one.

I agree it would be nice to split up, something like:

FCurve *BKE_driver_copy_to(AnimData &adt, FCurve &driver);
void BKE_fcurve_rnapath_set(FCurve &fcurve, StringRef rna_path);

And with all of that, I also agree that it's probably not worth the effort to write that first one, as it would only replace two lines that are fairly simple anway. It's indeed the freeing & string handling that's the most desirable to clean up.

Sure, I didn't mean to suggest that this name was perfect, just wanted to say that such functionality would be better placed in another function instead of as part of this one. I agree it would be nice to split up, something like: ```cpp FCurve *BKE_driver_copy_to(AnimData &adt, FCurve &driver); void BKE_fcurve_rnapath_set(FCurve &fcurve, StringRef rna_path); ``` And with all of that, I also agree that it's probably not worth the effort to write that first one, as it would only replace two lines that are fairly simple anway. It's indeed the freeing & string handling that's the most desirable to clean up.
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1732,4 @@
* bool to switch between exec and poll behavior. This isn't great, but seems
* like the lesser evil under the circumstances.
*
* \param all If true, copies drivers of all elements of an array property.

I think copy_entire_array or do_entire_array would be better than all

I think `copy_entire_array` or `do_entire_array` would be better than `all`
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1806,4 @@
const int paste_count = paste_property_drivers(
src_drivers.as_span(), is_array_prop, &dst_ptr, dst_prop);
if (paste_count > 0) {

I'm wondering what I'd like more -- this approach, or:

    if (paste_count == 0) {
      continue;
    }

    RNA_property_update(C, &dst_ptr, dst_prop);
    total_copy_count += paste_count;
I'm wondering what I'd like more -- this approach, or: ```cpp if (paste_count == 0) { continue; } RNA_property_update(C, &dst_ptr, dst_prop); total_copy_count += paste_count; ```
Author
Member

Yeah, I like that better. Thanks!

Yeah, I like that better. Thanks!
nathanvegdahl marked this conversation as resolved
@ -1567,0 +1842,4 @@
ot->description =
"Copy the property's driver from the active item to the same property of all selected "
"items, "
"if the same property exists";

This should be rewrapped.

This should be rewrapped.
nathanvegdahl marked this conversation as resolved
Nathan Vegdahl added 1 commit 2024-04-29 10:41:48 +02:00
Sybren A. Stüvel approved these changes 2024-04-29 11:48:37 +02:00
Sybren A. Stüvel left a comment
Member

LGTM!

LGTM!
Nathan Vegdahl added 1 commit 2024-04-29 12:08:07 +02:00
Nathan Vegdahl added 2 commits 2024-04-29 16:59:36 +02:00
Nathan Vegdahl added 1 commit 2024-04-29 17:00:59 +02:00
Nathan Vegdahl added 1 commit 2024-04-29 17:17:58 +02:00
Nathan Vegdahl added 1 commit 2024-04-29 17:43:41 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
a493f63ce6
Minor cleanup of fcurve rna path rename code

@blender-bot build

@blender-bot build
Nathan Vegdahl added 1 commit 2024-04-29 18:30:27 +02:00
Nathan Vegdahl merged commit bd3518946e into main 2024-04-29 18:35:06 +02:00
Nathan Vegdahl deleted branch copy_driver_to_selected_120518 2024-04-29 18:35:09 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#120936
No description provided.