Refactor: remove ReportList argument from insert_key
#120784
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120784
Loading…
Reference in New Issue
No description provided.
Delete Branch "ChrisLend/blender:refactor_remove_reports_from_key_fn"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The insert key function in
animrig/keyframing.cc
took aReportList
argument which it used to print messages in case of failures.
Instead this now returns a
CombinedKeyingResult
and the caller isresponsible for creating reports out of that.
To make that simpler the
ID
argument has been changed from a pointer to a reference.The calling functions now make sure that it's not a
nullptr
.This has the effect that there will be less messages printed in the Info panel when e.g. inserting keys with a keyingset.
This still doesn't make an error message pop up though.
Related to: #119776: Refactor keyframing.cc in animrig
@blender-bot build
Failed to start build, can't connect to buildbot.
Over-all looks good! Just a handful of comments.
(One thing that's a little unfortunate about this is losing the specificity about what exactly failed to get keyed, which might occasionally be useful in troubleshooting. But I think that's just a general aspect of shifting over to this style of error reporting, which overall is a big win for the common case IMO. So I still think it's good to move forward with this.)
@ -129,1 +129,4 @@
if (this->get_count(SingleKeyingResult::ID_NOT_EDITABLE) > 0) {
const int error_count = this->get_count(SingleKeyingResult::ID_NOT_EDITABLE);
if (error_count == 1) {
This pattern of printing one message if
count == 1
and a different message otherwise is repeated over and over again here. So my first instinct was to try to factor that repetition out.However, thinking about it more, I think it's likely that factoring it out wouldn't meaningfully simplify the code nor make it easier to understand or work with, and would instead just end up forcing people to jump around the file to follow the flow of the code. It's of course possible there's a good way to factor it out that I'm not thinking of, but I just wanted to leave an explicit note that as far as I can tell this particular case of repetition is probably fine as-is.
@ -130,0 +131,4 @@
const int error_count = this->get_count(SingleKeyingResult::ID_NOT_EDITABLE);
if (error_count == 1) {
errors.append(
fmt::format("{} ID has been skipped because it is not editable.", error_count));
Maybe adding "Key insertion for" at the front of these strings would be good, so if it's the only error it's still explicit in the message itself that the error was about inserting key frames.
Also, for the
count == 1
case I think it reads more clearly if you just skip usingfmt::format()
and replace{}
with an explicit "1". Seeing the{}
kept making me think, "Any number can go here... wait, that would read weird with anything other than 1... oh, right".good point about the
fmt
with error_count 1.Changed it to also spell out
one
so it is consistent with the previous error messages.Instead of "Key insertion for" I went with "Inserting keys for". Felt a bit easier to understand for me
@ -100,6 +100,10 @@ bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
void autokeyframe_object(bContext *C, Scene *scene, Object *ob, Span<std::string> rna_paths)
{
ID *id = &ob->id;
if (id == nullptr) {
I think(?) this code path will never actually be taken, unless via some weird undefined behavior: the
id
field is just a struct directly inside theObject
type, so taking its address should never be null.However, in theory
ob
itself could be null. So we can check for that. But it looks like that isn't supposed to ever happen, so I would just make an assert for it (and possibly document it as an invariant in the function's doc comment, if it isn't already). Same with theC
andscene
parameters, for that matter.yeah you are right. In that case I'll remove the check.
@ -211,6 +219,10 @@ void autokeyframe_pose_channel(bContext *C,
AnimData *adt = ob->adt;
bAction *act = (adt) ? adt->action : nullptr;
if (id == nullptr) {
Same here: I don't think(?) this code path is possible. Should be replaced by an assert that
ob
is non-null.@ -271,3 +277,1 @@
&anim_eval_context,
eBezTriple_KeyframeType(ts->keyframe_type),
flag);
insert_keyframe(bmain,
Do we not need to accumulate and handle the returned
CombinedKeyingResult
here?good point, the function didn't handle the return argument before, but of course now we would be missing the messages
Looks good to me!