Godot Version
4.4 - 4.8.x
Question
Would you please review this extensive pull request?
master ← 402-have-svg-imports-respect-the-inkscapetransform-center-xy-attributes
opened 01:54PM - 31 Aug 26 UTC
- [x] Add setting: mark ScalableVectorShape2D as an edit group (Default=Off) `se… t_meta("_edit_group_", true)`
- [x] make locking possible even when not imported as ScalableVectorShape2D
- [x] maybe print warning when file was changed while scene was closed
- [x] extensive regression tests
- [x] write a comprehensive section about synchronized imports in readme (make clear that Reimport button is needed when file was changed while scene was closed)
Just download it as a zip from this branch and tell me what you think of the importer and synchronization (I tried to mimic what the .blend synchronization can do but for SVG files) and the support for the pivots you set using Inkscape:
The original issues:
opened 11:51PM - 22 Aug 26 UTC
enhancement
contributions-via-fork
When importing an SVG, groups all have their positions set to (0,0) unless the g… roup itself is transformed. This does not match Inkscape, which always rotates around the center of all objects in a selected group unless a pivot is set. This makes in much harder to animate an SVG, requiring the use of Skeleton2D even when individual vector pieces do not need to deform. It would be nice if the already present automatic centering also applied to groups.
## Proposed solution
- [ ] nodes will be positioned around the middle of the bounding rect based on their common bounding boxes in stead of the svg image's or group node's top/left position
- [ ] for backward compatibility a checkbox is added to the import tab: 'centered groups', flagged on by default. (Maybe not?)
- [ ] when the `inkscape:transform-center-*` is present in a group, it will be repositioned relative to this center and it's children will adapt their position accordingly
- [ ] when the `inkscape:transform-center-*` is present on a shape, its points are repositioned accordingly
And:
opened 07:14PM - 21 Aug 26 UTC
enhancement
long spike
As it stands, importing an SVG is a one time action. Once it has been imported, … editing the SVG will not affect the in game assets. However, one of the main advantages of SVG is the ability to go back in later and fix things. It would be nice to have a node that imports SVGs in `_ready`.
Ideally, this node would also show the imported SVG in the editor as an instanced scene with editable children. This would allow for animating the SVG while still maintaining the connection (since the animation player only relies on node names). This node would also reimport if the file is edited for quick asset iteration.
The lack of such a feature can of course be worked around by editing assets in the Godot editor, but that lacks convenience features such as layering hotkeys and indexed color that exist in Inkscape. Moreover, outside artists would be more able to work on projects without having to learn Godot this way.
## Proposed Solution (draft)
Implementing a custom resource format using c++ will probably __not__ be necessary (which is frankly a bit of a relief). When a @tool node is in edit-mode it can register a listener one of the signals in the: [`EditorFileSystem`](https://docs.godotengine.org/en/stable/classes/class_editorfilesystem.html#signals) class. This way it can detect whether the assigned `svg` file of this new tool has changed, triggering a replacement of the existing imported nodes.
- [x] a new option (default Off) is added to the SVG importer: keep synchronized with `SyncedSVGRoot`
- [x] the `SyncedSVGRoot` cannot directly reference plugin code nor `EditorInterface`, so that will have to be managed by `curved_lines_2d.gd` by scanning the tree for this node whene scene_changed was emitted.
- [x] plugin code can't be referenced at runtime so this issue must be delivered: #223
- [x] when a scene with a `SyncedSVGRoot` is opened it will check md5sum equality to the source file to test whether a reimport is required
- [x] `SyncedSVGRoot` retains a copy of the chosen import settings
- [x] a reimport simply means removing all child nodes and loading in the replacement nodes with the import settings stored in the `StoredSVGRoot` properties
- [x] In editor inspector for `SyncedSVGRoot` add a "Reimport" button (also necessary when changing settings)
- [ ] ideally any skeleton / bone assignment of a ScalableVectorShape2D node that is to be replaced is retained and reassigned after reimport (viability check required)
- [ ] ideally something can be done with separate scene+editable children to protect nodes from removal/ being rearranged (iterative testing)
I always forget mentioning, you’d be contributing to my precious plugin: