Page MenuHome

Curves: Add initial undo system
ClosedPublic

Authored by Falk David (filedescriptor) on Wed, Jan 11, 5:57 PM.

Details

Summary

For now this will only save the current CurvesGeometry for every step.

Diff Detail

Repository
rB Blender
Branch
curves-undo-system (branched from master)
Build Status
Buildable 25325
Build 25325: arc lint + arc unit

Event Timeline

Falk David (filedescriptor) requested review of this revision.Wed, Jan 11, 5:57 PM
Falk David (filedescriptor) created this revision.

Remove parts of other diff

Falk David (filedescriptor) retitled this revision from Curves: Add initial undo system to Curves: Add initial undo system (WIP).Wed, Jan 11, 6:04 PM
Falk David (filedescriptor) edited the summary of this revision. (Show Details)

Nice that this is relatively straightforward, thanks for working on it!

source/blender/editors/curves/intern/curves_undo.cc
28–143

Might be nicer to put all this in the blender::ed::curves namespace and add a using to ED_curves_undosys_type

71–72
94

Nitpicky thing

  • Add namespace and fix minor issues
  • Merge branch 'master' into curves-undo-system
  • Cleanup
  • Make sure to use the undo system only in edit mode
  • Fix memory leaks
Falk David (filedescriptor) retitled this revision from Curves: Add initial undo system (WIP) to Curves: Add initial undo system.Fri, Jan 13, 6:37 PM
source/blender/editors/curves/intern/curves_undo.cc
32

bke::CurvesGeometry here, right? Then the casting wouldn't be necessary to delete it below.

69
124

NULL -> nullptr

source/blender/editors/curves/intern/curves_undo.cc
69

The compiler says that a static cast is not possible here.

Hans Goudey (HooglyBoogly) requested changes to this revision.Mon, Jan 16, 4:26 PM

Looking at this a bit deeper, IMO it's copying the structure of the existing edit mode implementations a bit more than it needs to. I think with some cleanups possible with C++, the code becomes simpler.

I did changes not mentioned in inline comments here P3445:

  • Use term "objects" instead of "elems"
  • Use Array to store data for each object rather than raw allocation
  • Remove redundant blender:: namespace specification
  • Store bke::CurvesGeometry by value rather than by pointer
  • Remove comments that just said what the next line does
  • Tweak whitespace
  • Add parallelism over multiple objects (not really needed now, but why not!)

My point isn't that each of these things is essential, but just that we should push a bit further to make the code semantically correct and to use some of the tools we have for simplifying basic things.

source/blender/editors/curves/intern/curves_undo.cc
30–50

Since these structs are in the ed::curves namespace, theoretically their names could be simplified.
At the extreme, in an ed::curves::undo namespace, the names could be Step, etc.

52–65

There is a lot of redundancy in these checks right now. For example, a null active object and checking the object type and checking if it's editable happen multiple times.
Ideally functions would be reused properly such that each check is only done one. To me it looks like the new part here is checking for edit mode as well. I'd suggest adding a function like editable_curves_in_edit_mode_poll near the others

69

Ah, right, then reinterpret_cast is the way to go. The main point is avoiding C-style casts.

This revision now requires changes to proceed.Mon, Jan 16, 4:26 PM
Falk David (filedescriptor) marked 5 inline comments as done.Mon, Jan 16, 4:31 PM
  • Merge branch 'master' into curves-undo-system
  • Address feedback
source/blender/editors/curves/intern/curves_undo.cc
52–57

Not sure I agree with how this is written right now. It feels like it's "forcing" the RAII paradigm, but using a C API. I'm all for using more RAII, but maybe ED_undo_editmode_objects_from_view_layer should be converted to C++ first, or a new C++ API added.

Thanks!

source/blender/editors/curves/intern/curves_undo.cc
52–57

Reverting that part is fine with me. It is a bit complex. The part I like more is storing bke::CurvesGeometry by value next to UndoRefID_Object, I think that's more reasonable

139

Is this kept for a specific reason? just curious

This revision is now accepted and ready to land.Thu, Jan 19, 6:25 PM
Falk David (filedescriptor) marked 4 inline comments as done.Thu, Jan 19, 6:26 PM
  • Revert name changes to sculpt selection operators
  • Revert use of BLI_SCOPED_DEFER
This revision was automatically updated to reflect the committed changes.