Allow editing NavigationObstacle2D shape

Add _get_polygon and _set_polygon overrides for NavigationObstacle2DEditor, so AbstractPolygon2DEditor can access the vertex information.

Fixes #91795
This commit is contained in:
aaronp64 2024-05-12 08:40:43 -04:00
parent bdc0316217
commit 3b30c65880
2 changed files with 11 additions and 0 deletions

View File

@ -41,6 +41,14 @@ void NavigationObstacle2DEditor::_set_node(Node *p_polygon) {
node = Object::cast_to<NavigationObstacle2D>(p_polygon); node = Object::cast_to<NavigationObstacle2D>(p_polygon);
} }
Variant NavigationObstacle2DEditor::_get_polygon(int p_idx) const {
return node->get_vertices();
}
void NavigationObstacle2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
node->set_vertices(p_polygon);
}
void NavigationObstacle2DEditor::_action_add_polygon(const Variant &p_polygon) { void NavigationObstacle2DEditor::_action_add_polygon(const Variant &p_polygon) {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->add_do_method(node, "set_vertices", p_polygon); undo_redo->add_do_method(node, "set_vertices", p_polygon);

View File

@ -43,6 +43,9 @@ protected:
virtual Node2D *_get_node() const override; virtual Node2D *_get_node() const override;
virtual void _set_node(Node *p_polygon) override; virtual void _set_node(Node *p_polygon) override;
virtual Variant _get_polygon(int p_idx) const override;
virtual void _set_polygon(int p_idx, const Variant &p_polygon) const override;
virtual void _action_add_polygon(const Variant &p_polygon) override; virtual void _action_add_polygon(const Variant &p_polygon) override;
virtual void _action_remove_polygon(int p_idx) override; virtual void _action_remove_polygon(int p_idx) override;
virtual void _action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) override; virtual void _action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) override;