Add Bresenham Line Algorithm to GridMap Drawing#105292
Add Bresenham Line Algorithm to GridMap Drawing#105292Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
|
Cool. I want to say this is a great enhancement. Will see if I can expedite review somehow. |
Calinou
left a comment
There was a problem hiding this comment.
This PR fails to compile when rebased on top of master:
Compiling modules/gridmap/editor/grid_map_editor_plugin.cpp ...
Compiling editor/scene/3d/gizmos/.scu/scu_editor_scene_3d_gizmos.gen.cpp ...
modules/gridmap/editor/grid_map_editor_plugin.cpp: In member function 'bool GridMapEditor::do_input_action(Camera3D*, const Point2&, bool)':
modules/gridmap/editor/grid_map_editor_plugin.cpp:442:54: error: 'class LocalVector<GridMapEditor::SetItem>' has no member named 'back'
442 | Vector3i last_si = set_items.back()->get().position;
| ^~~~
Generating core/version_hash.gen.cpp ...
scons: *** [bin/obj/modules/gridmap/editor/grid_map_editor_plugin.linuxbsd.editor.x86_64.o] Error 1
scons: building terminated because of errors.
This is due to set_items now being a LocalVector since https://docs.godotengine.org/en/stable/contributing/workflow/pr_workflow.html#the-interactive-rebase was merged. LocalVector does not have a back() method (see #99955), so you need to replace it with something else.
See this page for instructions on rebasing the PR.
569291f to
b261acd
Compare
Calinou
left a comment
There was a problem hiding this comment.
Tested locally on all edit axes, it works as expected. Code looks good to me.
Top is drawn without this PR, bottom is drawn with this PR (at a similar mouse speed for each). The editor is capped at 30 FPS for this demonstration, which will make the issue more noticeable (the lower the FPS, the more likely your cursor will be missing tiles).
Note that visible polygon edges will occur at low FPS, given your mouse cursor position is only sampled once per rendered frame. A more extensive solution could disable input accumulation when drawing in the GridMap editor, then using all the input positions recorded in a single frame to draw the tiles at the mouse's real position, which should lead to smoother curves. That said, this is not essential for an initial implementation, as it already helps a lot, especially when drawing straight (or mostly straight) lines.
b261acd to
42d61ce
Compare
|
I've implemented changes, rebased on master and tested for general functionally one more time. Unless there are any other notes/changes, it should be ready for merging once it passes CI/CD. |
|
Could you rebase your PR? See our pull request guidelines for more information |
42d61ce to
56af7b6
Compare
|
@Repiteo I've rebased it ^^ seems to work fine |
56af7b6 to
3ee7bf4
Compare
|
Thanks! Congratulations on your first merged contribution! 🎉 |
Implements #11995 for painting and erasing in GridMap.
Before:

This PR:
