For now this will only save the current CurvesGeometry for every step.
Details
Diff Detail
- Repository
- rB Blender
- Branch
- curves-undo-system (branched from master)
- Build Status
Buildable 25325 Build 25325: arc lint + arc unit
Event Timeline
- Merge branch 'master' into curves-undo-system
- Cleanup
- Make sure to use the undo system only in edit mode
- Fix memory leaks
| 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 | Use static cast here (https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast) | |
| 124 | NULL -> nullptr | |
| source/blender/editors/curves/intern/curves_undo.cc | ||
|---|---|---|
| 69 | The compiler says that a static cast is not possible here. | |
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. | |
| 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. | |
| 69 | Ah, right, then reinterpret_cast is the way to go. The main point is avoiding C-style casts. | |
| 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. | |