Renamed NavigationPolygonInstance to NavigationRegion2D
This commit is contained in:
parent
2e0fb66c6f
commit
483994601d
13 changed files with 108 additions and 39 deletions
|
@ -4,7 +4,7 @@
|
|||
2D navigation and pathfinding node.
|
||||
</brief_description>
|
||||
<description>
|
||||
Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of [NavigationPolygon] resources. These are automatically collected from child [NavigationPolygonInstance] nodes.
|
||||
Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of [NavigationPolygon] resources. These are automatically collected from child [NavigationRegion2D] nodes.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
var outline = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
|
||||
polygon.add_outline(outline)
|
||||
polygon.make_polygons_from_outlines()
|
||||
$NavigationPolygonInstance.navpoly = polygon
|
||||
$NavigationRegion2D.navpoly = polygon
|
||||
[/codeblock]
|
||||
Using [method add_polygon] and indices of the vertices array.
|
||||
[codeblock]
|
||||
|
@ -20,7 +20,7 @@
|
|||
polygon.set_vertices(vertices)
|
||||
var indices = PackedInt32Array(0, 3, 1)
|
||||
polygon.add_polygon(indices)
|
||||
$NavigationPolygonInstance.navpoly = polygon
|
||||
$NavigationRegion2D.navpoly = polygon
|
||||
[/codeblock]
|
||||
</description>
|
||||
<tutorials>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationPolygonInstance" inherits="Node2D" version="4.0">
|
||||
<class name="NavigationRegion2D" inherits="Node2D" version="4.0">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
|
@ -1 +0,0 @@
|
|||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#a5b7f3" fill-opacity=".98824" fill-rule="evenodd" transform="translate(0 -1036.4)"><path d="m2 1a1.0001 1.0001 0 0 0 -1 1v12a1.0001 1.0001 0 0 0 1 1h4.9023a2.1002 2.1002 0 0 1 .13086-.73633l.47461-1.2637h-4.5078v-10h8.5859l-4.293 4.293a1.0001 1.0001 0 0 0 0 1.4141l1.3262 1.3262 1.4141-3.7695a2.1002 2.1002 0 0 1 1.9922-1.3613 2.1002 2.1002 0 0 1 .43555.050781l2.2461-2.2461a1.0001 1.0001 0 0 0 -.70703-1.707h-12z" transform="translate(0 1036.4)"/><path d="m15 1051.4-3-8-3 8 3-2z"/></g></svg>
|
Before Width: | Height: | Size: 586 B |
67
editor/icons/NavigationRegion2D.svg
Normal file
67
editor/icons/NavigationRegion2D.svg
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="1.0beta2 (unknown)"
|
||||
sodipodi:docname="icon_navigation_polygon_instance.svg"
|
||||
id="svg8"
|
||||
version="1.1"
|
||||
width="16"
|
||||
viewBox="0 0 16 16"
|
||||
height="16">
|
||||
<metadata
|
||||
id="metadata14">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs12" />
|
||||
<sodipodi:namedview
|
||||
inkscape:current-layer="svg8"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:window-y="18"
|
||||
inkscape:window-x="0"
|
||||
inkscape:cy="10.058435"
|
||||
inkscape:cx="5.8836841"
|
||||
inkscape:zoom="19.64431"
|
||||
showgrid="false"
|
||||
id="namedview10"
|
||||
inkscape:window-height="1041"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
guidetolerance="10"
|
||||
gridtolerance="10"
|
||||
objecttolerance="10"
|
||||
borderopacity="1"
|
||||
inkscape:document-rotation="0"
|
||||
bordercolor="#666666"
|
||||
pagecolor="#ffffff" />
|
||||
<g
|
||||
id="g6"
|
||||
transform="translate(0 -1036.4)"
|
||||
fill-rule="evenodd"
|
||||
fill-opacity=".98824"
|
||||
fill="#a5b7f3">
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path2"
|
||||
transform="translate(0,1036.4)"
|
||||
d="M 2,1 C 1.4477381,1.0000552 1.0000552,1.4477381 1,2 v 12 c 5.52e-5,0.552262 0.4477381,0.999945 1,1 h 4.9023 c -7.836e-4,-0.251296 0.043539,-0.500692 0.13086,-0.73633 l 0.47461,-1.2637 2.5254,-6.7362 c 0.311135,-0.8280197 1.107723,-1.3723398 1.9922,-1.3613 0.146558,0.00168 0.292536,0.018702 0.43555,0.050781 l 2.2461,-2.2461 c 0.629502,-0.6299963 0.18357,-1.7066217 -0.70703,-1.707 h -12 z" />
|
||||
<path
|
||||
id="path4"
|
||||
d="m15 1051.4-3-8-3 8 3-2z" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
|
@ -48,7 +48,7 @@ Node2D *NavigationPolygonEditor::_get_node() const {
|
|||
|
||||
void NavigationPolygonEditor::_set_node(Node *p_polygon) {
|
||||
|
||||
node = Object::cast_to<NavigationPolygonInstance>(p_polygon);
|
||||
node = Object::cast_to<NavigationRegion2D>(p_polygon);
|
||||
}
|
||||
|
||||
int NavigationPolygonEditor::_get_polygon_count() const {
|
||||
|
@ -127,5 +127,5 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) :
|
|||
}
|
||||
|
||||
NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) :
|
||||
AbstractPolygon2DEditorPlugin(p_node, memnew(NavigationPolygonEditor(p_node)), "NavigationPolygonInstance") {
|
||||
AbstractPolygon2DEditorPlugin(p_node, memnew(NavigationPolygonEditor(p_node)), "NavigationRegion2D") {
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class NavigationPolygonEditor : public AbstractPolygon2DEditor {
|
|||
|
||||
GDCLASS(NavigationPolygonEditor, AbstractPolygon2DEditor);
|
||||
|
||||
NavigationPolygonInstance *node;
|
||||
NavigationRegion2D *node;
|
||||
|
||||
Ref<NavigationPolygon> _ensure_navpoly() const;
|
||||
|
||||
|
|
|
@ -109,8 +109,8 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
|
|||
|
||||
Node *child2 = mi->get_child(j);
|
||||
|
||||
if (Object::cast_to<NavigationPolygonInstance>(child2))
|
||||
nav_poly = Object::cast_to<NavigationPolygonInstance>(child2)->get_navigation_polygon();
|
||||
if (Object::cast_to<NavigationRegion2D>(child2))
|
||||
nav_poly = Object::cast_to<NavigationRegion2D>(child2)->get_navigation_polygon();
|
||||
|
||||
if (Object::cast_to<LightOccluder2D>(child2))
|
||||
occluder = Object::cast_to<LightOccluder2D>(child2)->get_occluder_polygon();
|
||||
|
|
|
@ -370,7 +370,7 @@ NavigationPolygon::~NavigationPolygon() {
|
|||
memdelete(navmesh_generation);
|
||||
}
|
||||
|
||||
void NavigationPolygonInstance::set_enabled(bool p_enabled) {
|
||||
void NavigationRegion2D::set_enabled(bool p_enabled) {
|
||||
|
||||
if (enabled == p_enabled)
|
||||
return;
|
||||
|
@ -394,25 +394,25 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
|
|||
update();
|
||||
}
|
||||
|
||||
bool NavigationPolygonInstance::is_enabled() const {
|
||||
bool NavigationRegion2D::is_enabled() const {
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
#ifdef TOOLS_ENABLED
|
||||
Rect2 NavigationPolygonInstance::_edit_get_rect() const {
|
||||
Rect2 NavigationRegion2D::_edit_get_rect() const {
|
||||
|
||||
return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2();
|
||||
}
|
||||
|
||||
bool NavigationPolygonInstance::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
||||
bool NavigationRegion2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
||||
|
||||
return navpoly.is_valid() ? navpoly->_edit_is_selected_on_click(p_point, p_tolerance) : false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void NavigationPolygonInstance::_notification(int p_what) {
|
||||
void NavigationRegion2D::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
@ -496,7 +496,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
|
||||
void NavigationRegion2D::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
|
||||
|
||||
if (p_navpoly == navpoly) {
|
||||
return;
|
||||
|
@ -518,18 +518,18 @@ void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolyg
|
|||
update_configuration_warning();
|
||||
}
|
||||
|
||||
Ref<NavigationPolygon> NavigationPolygonInstance::get_navigation_polygon() const {
|
||||
Ref<NavigationPolygon> NavigationRegion2D::get_navigation_polygon() const {
|
||||
|
||||
return navpoly;
|
||||
}
|
||||
|
||||
void NavigationPolygonInstance::_navpoly_changed() {
|
||||
void NavigationRegion2D::_navpoly_changed() {
|
||||
|
||||
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()))
|
||||
update();
|
||||
}
|
||||
|
||||
String NavigationPolygonInstance::get_configuration_warning() const {
|
||||
String NavigationRegion2D::get_configuration_warning() const {
|
||||
|
||||
if (!is_visible_in_tree() || !is_inside_tree())
|
||||
return String();
|
||||
|
@ -547,24 +547,24 @@ String NavigationPolygonInstance::get_configuration_warning() const {
|
|||
c = Object::cast_to<Node2D>(c->get_parent());
|
||||
}
|
||||
|
||||
return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
|
||||
return TTR("NavigationRegion2D must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
|
||||
}
|
||||
|
||||
void NavigationPolygonInstance::_bind_methods() {
|
||||
void NavigationRegion2D::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navpoly"), &NavigationPolygonInstance::set_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationPolygonInstance::get_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navpoly"), &NavigationRegion2D::set_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationRegion2D::get_navigation_polygon);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationPolygonInstance::set_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationPolygonInstance::is_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion2D::set_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion2D::is_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_navpoly_changed"), &NavigationPolygonInstance::_navpoly_changed);
|
||||
ClassDB::bind_method(D_METHOD("_navpoly_changed"), &NavigationRegion2D::_navpoly_changed);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navpoly", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"), "set_navigation_polygon", "get_navigation_polygon");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
||||
}
|
||||
|
||||
NavigationPolygonInstance::NavigationPolygonInstance() {
|
||||
NavigationRegion2D::NavigationRegion2D() {
|
||||
|
||||
enabled = true;
|
||||
set_notify_transform(true);
|
||||
|
@ -573,6 +573,6 @@ NavigationPolygonInstance::NavigationPolygonInstance() {
|
|||
navigation = NULL;
|
||||
}
|
||||
|
||||
NavigationPolygonInstance::~NavigationPolygonInstance() {
|
||||
NavigationRegion2D::~NavigationRegion2D() {
|
||||
Navigation2DServer::get_singleton()->free(region);
|
||||
}
|
||||
|
|
|
@ -96,9 +96,9 @@ public:
|
|||
|
||||
class Navigation2D;
|
||||
|
||||
class NavigationPolygonInstance : public Node2D {
|
||||
class NavigationRegion2D : public Node2D {
|
||||
|
||||
GDCLASS(NavigationPolygonInstance, Node2D);
|
||||
GDCLASS(NavigationRegion2D, Node2D);
|
||||
|
||||
bool enabled;
|
||||
RID region;
|
||||
|
@ -125,8 +125,8 @@ public:
|
|||
|
||||
String get_configuration_warning() const;
|
||||
|
||||
NavigationPolygonInstance();
|
||||
~NavigationPolygonInstance();
|
||||
NavigationRegion2D();
|
||||
~NavigationRegion2D();
|
||||
};
|
||||
|
||||
#endif // NAVIGATIONPOLYGON_H
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef navigation_region_H
|
||||
#define navigation_region_H
|
||||
#ifndef NAVIGATION_REGION_H
|
||||
#define NAVIGATION_REGION_H
|
||||
|
||||
#include "scene/3d/spatial.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
|
@ -72,4 +72,4 @@ public:
|
|||
~NavigationRegion();
|
||||
};
|
||||
|
||||
#endif // navigation_region_H
|
||||
#endif // NAVIGATION_REGION_H
|
||||
|
|
|
@ -726,7 +726,7 @@ void register_scene_types() {
|
|||
|
||||
ClassDB::register_class<Navigation2D>();
|
||||
ClassDB::register_class<NavigationPolygon>();
|
||||
ClassDB::register_class<NavigationPolygonInstance>();
|
||||
ClassDB::register_class<NavigationRegion2D>();
|
||||
ClassDB::register_class<NavigationAgent2D>();
|
||||
ClassDB::register_class<NavigationObstacle2D>();
|
||||
|
||||
|
@ -746,6 +746,9 @@ void register_scene_types() {
|
|||
ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc");
|
||||
ClassDB::add_compatibility_class("NavigationMeshInstance", "NavigationRegion");
|
||||
ClassDB::add_compatibility_class("NavigationPolygonInstance", "NavigationRegion2D");
|
||||
ClassDB::add_compatibility_class("PlaneShape", "WorldMarginShape");
|
||||
#endif
|
||||
|
||||
OS::get_singleton()->yield(); //may take time to init
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef world_margin_shape_H
|
||||
#define world_margin_shape_H
|
||||
#ifndef WORLD_MARGIN_SHAPE_H
|
||||
#define WORLD_MARGIN_SHAPE_H
|
||||
|
||||
#include "scene/resources/shape.h"
|
||||
|
||||
|
@ -54,4 +54,4 @@ public:
|
|||
|
||||
WorldMarginShape();
|
||||
};
|
||||
#endif // world_margin_shape_H
|
||||
#endif // WORLD_MARGIN_SHAPE_H
|
||||
|
|
Loading…
Reference in a new issue