mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-30 21:09:19 +01:00
Ported from godot4: Fix Navigation API abbreviations inconsistency
Schema for navigation to name user facing API with "navigation" without abbreviation and e.g. NavigationServer internals with abbr "nav".
- smix8
34e7628f5f
This commit is contained in:
parent
ebfba6a379
commit
8485b37515
@ -623,7 +623,7 @@
|
||||
Set the region's navigation layers. This allows selecting regions from a path request (when using [method Navigation2DServer.map_get_path]).
|
||||
</description>
|
||||
</method>
|
||||
<method name="region_set_navpoly">
|
||||
<method name="region_set_navigation_polygon">
|
||||
<return type="void" />
|
||||
<argument index="0" name="region" type="RID" />
|
||||
<argument index="1" name="nav_poly" type="NavigationPolygon" />
|
||||
|
@ -184,7 +184,7 @@
|
||||
The maximum speed that an agent can move.
|
||||
</member>
|
||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||
A bitfield determining all navigation map layers the [NavigationAgent] belongs to. On path requests the agent will ignore navmeshes without at least one matching layer.
|
||||
A bitfield determining all navigation map layers the [NavigationAgent] belongs to. On path requests the agent will ignore navigation meshes without at least one matching layer.
|
||||
</member>
|
||||
<member name="neighbor_distance" type="float" setter="set_neighbor_distance" getter="get_neighbor_distance" default="1.0">
|
||||
The distance to search for other agents.
|
||||
|
@ -184,7 +184,7 @@
|
||||
The maximum speed that an agent can move.
|
||||
</member>
|
||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||
A bitfield determining all navigation map layers the [NavigationAgent2D] belongs to. On path requests the agent will ignore navmeshes without at least one matching layer.
|
||||
A bitfield determining all navigation map layers the [NavigationAgent2D] belongs to. On path requests the agent will ignore navigation meshes without at least one matching layer.
|
||||
</member>
|
||||
<member name="neighbor_distance" type="float" setter="set_neighbor_distance" getter="get_neighbor_distance" default="500.0">
|
||||
The distance to search for other agents.
|
||||
|
@ -143,11 +143,11 @@
|
||||
<member name="geometry_source_geometry_mode" type="int" setter="set_source_geometry_mode" getter="get_source_geometry_mode" enum="NavigationMesh.SourceGeometryMode" default="0">
|
||||
The source of the geometry used when baking. See [enum SourceGeometryMode] for possible values.
|
||||
</member>
|
||||
<member name="geometry_source_group_name" type="StringName" setter="set_source_group_name" getter="get_source_group_name" default="@"navmesh"">
|
||||
<member name="geometry_source_group_name" type="StringName" setter="set_source_group_name" getter="get_source_group_name" default="@"navigation_mesh_source_group"">
|
||||
The name of the group to scan for geometry.
|
||||
Only used when [member geometry_source_geometry_mode] is [constant SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN] or [constant SOURCE_GEOMETRY_GROUPS_EXPLICIT].
|
||||
</member>
|
||||
<member name="polygon_verts_per_poly" type="float" setter="set_verts_per_poly" getter="get_verts_per_poly" default="6.0">
|
||||
<member name="polygon_vertices_per_polyon" type="float" setter="set_vertices_per_polyon" getter="get_vertices_per_polyon" default="6.0">
|
||||
The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.
|
||||
</member>
|
||||
<member name="region_merge_size" type="float" setter="set_region_merge_size" getter="get_region_merge_size" default="20.0">
|
||||
@ -187,6 +187,7 @@
|
||||
Represents the size of the [enum ParsedGeometryType] enum.
|
||||
</constant>
|
||||
<constant name="SOURCE_GEOMETRY_ROOT_NODE_CHILDREN" value="0" enum="SourceGeometryMode">
|
||||
Scans the child nodes of the root node recursively for geometry.
|
||||
</constant>
|
||||
<constant name="SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN" value="1" enum="SourceGeometryMode">
|
||||
Scans nodes in a group and their child nodes recursively for geometry. The group is specified by [member geometry_source_group_name].
|
||||
|
@ -4,7 +4,7 @@
|
||||
An instance of a [NavigationMesh]. It tells the [Navigation] node what can be navigated and what cannot, based on the [NavigationMesh] resource.
|
||||
By default this node will register to the default [World3D] navigation map. If this node is a child of a [Navigation] node it will register to the navigation map of the navigation node.
|
||||
Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using [method NavigationServer.map_set_edge_connection_margin].
|
||||
[b]Note:[/b] Overlapping two regions' navmeshes is not enough for connecting two regions. They must share a similar edge.
|
||||
[b]Note:[/b] Overlapping two regions' navigation meshes is not enough for connecting two regions. They must share a similar edge.
|
||||
The cost of entering this region from another region can be controlled with the [member enter_cost] value.
|
||||
[b]Note[/b]: This value is not added to the path cost when the start position is already inside this region.
|
||||
The cost of traveling distances inside this region can be controlled with the [member travel_cost] multiplier.
|
||||
@ -63,16 +63,16 @@
|
||||
Determines if the [NavigationMeshInstance] is enabled or disabled.
|
||||
</member>
|
||||
<member name="enter_cost" type="float" setter="set_enter_cost" getter="get_enter_cost" default="0.0">
|
||||
When pathfinding enters this regions navmesh from another regions navmesh the [code]enter_cost[/code] value is added to the path distance for determining the shortest path.
|
||||
When pathfinding enters this regions navigation mesh from another regions navigation mesh the [code]enter_cost[/code] value is added to the path distance for determining the shortest path.
|
||||
</member>
|
||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||
A bitfield determining all navigation map layers the [NavigationMesh] belongs to. On path requests with [method NavigationServer.map_get_path] navmeshes without matching layers will be ignored and the navigation map will only proximity merge different navmeshes with matching layers.
|
||||
A bitfield determining all navigation map layers the [NavigationMesh] belongs to. On path requests with [method NavigationServer.map_get_path] navigation meshes without matching layers will be ignored and the navigation map will only proximity merge different navigation meshes with matching layers.
|
||||
</member>
|
||||
<member name="navmesh" type="NavigationMesh" setter="set_navigation_mesh" getter="get_navigation_mesh">
|
||||
<member name="navigation_mesh" type="NavigationMesh" setter="set_navigation_mesh" getter="get_navigation_mesh">
|
||||
The [NavigationMesh] resource to use.
|
||||
</member>
|
||||
<member name="travel_cost" type="float" setter="set_travel_cost" getter="get_travel_cost" default="1.0">
|
||||
When pathfinding moves inside this regions navmesh the traveled distances are multiplied with [code]travel_cost[/code] for determining the shortest path.
|
||||
When pathfinding moves inside this regions navigation mesh the traveled distances are multiplied with [code]travel_cost[/code] for determining the shortest path.
|
||||
</member>
|
||||
<member name="use_edge_connections" type="bool" setter="set_use_edge_connections" getter="get_use_edge_connections" default="true">
|
||||
If enabled the navigation region will use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
|
||||
|
@ -84,16 +84,16 @@
|
||||
Determines if the [NavigationPolygonInstance] is enabled or disabled.
|
||||
</member>
|
||||
<member name="enter_cost" type="float" setter="set_enter_cost" getter="get_enter_cost" default="0.0">
|
||||
When pathfinding enters this regions navmesh from another regions navmesh the [code]enter_cost[/code] value is added to the path distance for determining the shortest path.
|
||||
When pathfinding enters this regions navigation mesh from another regions navigation mesh the [code]enter_cost[/code] value is added to the path distance for determining the shortest path.
|
||||
</member>
|
||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||
A bitfield determining all navigation map layers the [NavigationPolygon] belongs to. On path requests with [method Navigation2DServer.map_get_path] navmeshes without matching layers will be ignored and the navigation map will only proximity merge different navmeshes with matching layers.
|
||||
A bitfield determining all navigation map layers the [NavigationPolygon] belongs to. On path requests with [method Navigation2DServer.map_get_path] navigation meshes without matching layers will be ignored and the navigation map will only proximity merge different navigation meshes with matching layers.
|
||||
</member>
|
||||
<member name="navpoly" type="NavigationPolygon" setter="set_navigation_polygon" getter="get_navigation_polygon">
|
||||
<member name="navigation_polygon" type="NavigationPolygon" setter="set_navigation_polygon" getter="get_navigation_polygon">
|
||||
The [NavigationPolygon] resource to use.
|
||||
</member>
|
||||
<member name="travel_cost" type="float" setter="set_travel_cost" getter="get_travel_cost" default="1.0">
|
||||
When pathfinding moves inside this regions navmesh the traveled distances are multiplied with [code]travel_cost[/code] for determining the shortest path.
|
||||
When pathfinding moves inside this regions navigation mesh the traveled distances are multiplied with [code]travel_cost[/code] for determining the shortest path.
|
||||
</member>
|
||||
<member name="use_edge_connections" type="bool" setter="set_use_edge_connections" getter="get_use_edge_connections" default="true">
|
||||
If enabled the navigation region will use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
|
||||
|
@ -704,10 +704,10 @@
|
||||
Set the region's navigation layers. This allows selecting regions from a path request (when using [method NavigationServer.map_get_path]).
|
||||
</description>
|
||||
</method>
|
||||
<method name="region_set_navmesh">
|
||||
<method name="region_set_navigation_mesh">
|
||||
<return type="void" />
|
||||
<argument index="0" name="region" type="RID" />
|
||||
<argument index="1" name="nav_mesh" type="NavigationMesh" />
|
||||
<argument index="1" name="navigation_mesh" type="NavigationMesh" />
|
||||
<description>
|
||||
Sets the navigation mesh for the region.
|
||||
</description>
|
||||
|
@ -531,7 +531,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, RBMap<Ref<Mes
|
||||
}
|
||||
}
|
||||
|
||||
} else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance>(p_node)) {
|
||||
} else if (_teststr(name, "navigation_mesh") && Object::cast_to<MeshInstance>(p_node)) {
|
||||
if (isroot) {
|
||||
return p_node;
|
||||
}
|
||||
@ -542,7 +542,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, RBMap<Ref<Mes
|
||||
ERR_FAIL_COND_V(mesh.is_null(), nullptr);
|
||||
NavigationMeshInstance *nmi = memnew(NavigationMeshInstance);
|
||||
|
||||
nmi->set_name(_fixstr(name, "navmesh"));
|
||||
nmi->set_name(_fixstr(name, "navigation_mesh"));
|
||||
Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
|
||||
nmesh->create_from_mesh(mesh);
|
||||
nmi->set_navigation_mesh(nmesh);
|
||||
|
@ -3566,10 +3566,10 @@ int NavigationMeshSpatialGizmoPlugin::get_priority() const {
|
||||
}
|
||||
|
||||
void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||
NavigationMeshInstance *navmesh_instance = Object::cast_to<NavigationMeshInstance>(p_gizmo->get_spatial_node());
|
||||
NavigationMeshInstance *navigation_mesh_instance = Object::cast_to<NavigationMeshInstance>(p_gizmo->get_spatial_node());
|
||||
|
||||
p_gizmo->clear();
|
||||
Ref<NavigationMesh> navigationmesh = navmesh_instance->get_navigation_mesh();
|
||||
Ref<NavigationMesh> navigationmesh = navigation_mesh_instance->get_navigation_mesh();
|
||||
if (navigationmesh.is_null()) {
|
||||
return;
|
||||
}
|
||||
@ -3693,7 +3693,7 @@ void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||
}
|
||||
|
||||
debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, face_mesh_array);
|
||||
p_gizmo->add_mesh(debug_mesh, navmesh_instance->is_enabled() ? get_material("face_material", p_gizmo) : get_material("face_material_disabled", p_gizmo));
|
||||
p_gizmo->add_mesh(debug_mesh, navigation_mesh_instance->is_enabled() ? get_material("face_material", p_gizmo) : get_material("face_material_disabled", p_gizmo));
|
||||
|
||||
// if enabled build geometry edge line surface
|
||||
bool enabled_edge_lines = NavigationServer::get_singleton()->get_debug_navigation_enable_edge_lines();
|
||||
@ -3713,7 +3713,7 @@ void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||
line_vertex_array.push_back(vertices[polygon[0]]);
|
||||
}
|
||||
|
||||
p_gizmo->add_lines(line_vertex_array, navmesh_instance->is_enabled() ? get_material("edge_material", p_gizmo) : get_material("edge_material_disabled", p_gizmo));
|
||||
p_gizmo->add_lines(line_vertex_array, navigation_mesh_instance->is_enabled() ? get_material("edge_material", p_gizmo) : get_material("edge_material_disabled", p_gizmo));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@
|
||||
</methods>
|
||||
<members>
|
||||
<member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false">
|
||||
If [code]true[/code], this GridMap uses cell navmesh resources to create navigation regions.
|
||||
If [code]true[/code], this GridMap uses cell navigation mesh resources to create navigation regions.
|
||||
</member>
|
||||
<member name="cell_center_x" type="bool" setter="set_center_x" getter="get_center_x" default="true">
|
||||
If [code]true[/code], grid items are centered on the X axis.
|
||||
|
@ -59,14 +59,14 @@
|
||||
Returns the item's name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_item_navmesh" qualifiers="const">
|
||||
<method name="get_item_navigation_mesh" qualifiers="const">
|
||||
<return type="NavigationMesh" />
|
||||
<argument index="0" name="id" type="int" />
|
||||
<description>
|
||||
Returns the item's navigation mesh.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_item_navmesh_transform" qualifiers="const">
|
||||
<method name="get_item_navigation_mesh_transform" qualifiers="const">
|
||||
<return type="Transform" />
|
||||
<argument index="0" name="id" type="int" />
|
||||
<description>
|
||||
@ -126,18 +126,18 @@
|
||||
This name is shown in the editor. It can also be used to look up the item later using [method find_item_by_name].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_item_navmesh">
|
||||
<method name="set_item_navigation_mesh">
|
||||
<return type="void" />
|
||||
<argument index="0" name="id" type="int" />
|
||||
<argument index="1" name="navmesh" type="NavigationMesh" />
|
||||
<argument index="1" name="navigation_mesh" type="NavigationMesh" />
|
||||
<description>
|
||||
Sets the item's navigation mesh.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_item_navmesh_transform">
|
||||
<method name="set_item_navigation_mesh_transform">
|
||||
<return type="void" />
|
||||
<argument index="0" name="id" type="int" />
|
||||
<argument index="1" name="navmesh" type="Transform" />
|
||||
<argument index="1" name="navigation_mesh" type="Transform" />
|
||||
<description>
|
||||
Sets the transform to apply to the item's navigation mesh.
|
||||
</description>
|
||||
|
@ -233,7 +233,7 @@ void GridMap::set_navigation_map(RID p_navigation_map) {
|
||||
for (RBMap<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
|
||||
Octant &g = *(E->get());
|
||||
|
||||
for (RBMap<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
|
||||
for (RBMap<IndexKey, Octant::NavigationCell>::Element *F = g.navigation_cell_ids.front(); F; F = F->next()) {
|
||||
if (F->get().region.is_valid()) {
|
||||
NavigationServer::get_singleton()->region_set_map(F->get().region, nav_map);
|
||||
}
|
||||
@ -489,12 +489,12 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
|
||||
|
||||
// update transform for NavigationServer regions and navigation debugmesh instances
|
||||
if (bake_navigation) {
|
||||
for (RBMap<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
|
||||
for (RBMap<IndexKey, Octant::NavigationCell>::Element *E = g.navigation_cell_ids.front(); E; E = E->next()) {
|
||||
if (E->get().region.is_valid()) {
|
||||
NavigationServer::get_singleton()->region_set_transform(E->get().region, get_global_transform() * E->get().xform);
|
||||
}
|
||||
if (E->get().navmesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->instance_set_transform(E->get().navmesh_debug_instance, get_global_transform() * E->get().xform);
|
||||
if (E->get().navigation_mesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->instance_set_transform(E->get().navigation_mesh_debug_instance, get_global_transform() * E->get().xform);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -520,16 +520,16 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
}
|
||||
|
||||
//erase navigation
|
||||
for (RBMap<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
|
||||
for (RBMap<IndexKey, Octant::NavigationCell>::Element *E = g.navigation_cell_ids.front(); E; E = E->next()) {
|
||||
if (E->get().region.is_valid()) {
|
||||
NavigationServer::get_singleton()->free(E->get().region);
|
||||
E->get().region = RID();
|
||||
}
|
||||
if (E->get().navmesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->free(E->get().navmesh_debug_instance);
|
||||
if (E->get().navigation_mesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->free(E->get().navigation_mesh_debug_instance);
|
||||
}
|
||||
}
|
||||
g.navmesh_ids.clear();
|
||||
g.navigation_cell_ids.clear();
|
||||
|
||||
//erase multimeshes
|
||||
|
||||
@ -601,17 +601,17 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
}
|
||||
}
|
||||
|
||||
// add the item's navmesh at given xform to GridMap's Navigation ancestor
|
||||
Ref<NavigationMesh> navmesh = mesh_library->get_item_navmesh(c.item);
|
||||
if (navmesh.is_valid()) {
|
||||
Octant::NavMesh nm;
|
||||
nm.xform = xform * mesh_library->get_item_navmesh_transform(c.item);
|
||||
// add the item's navigation_mesh at given xform to GridMap's Navigation ancestor
|
||||
Ref<NavigationMesh> navigation_mesh = mesh_library->get_item_navigation_mesh(c.item);
|
||||
if (navigation_mesh.is_valid()) {
|
||||
Octant::NavigationCell nm;
|
||||
nm.xform = xform * mesh_library->get_item_navigation_mesh_transform(c.item);
|
||||
|
||||
if (bake_navigation) {
|
||||
RID region = NavigationServer::get_singleton()->region_create();
|
||||
NavigationServer::get_singleton()->region_set_owner_id(region, get_instance_id());
|
||||
NavigationServer::get_singleton()->region_set_navigation_layers(region, navigation_layers);
|
||||
NavigationServer::get_singleton()->region_set_navmesh(region, navmesh);
|
||||
NavigationServer::get_singleton()->region_set_navigation_mesh(region, navigation_mesh);
|
||||
NavigationServer::get_singleton()->region_set_transform(region, get_global_transform() * nm.xform);
|
||||
if (is_inside_tree()) {
|
||||
NavigationServer::get_singleton()->region_set_map(region, get_navigation_map());
|
||||
@ -622,19 +622,19 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
// add navigation debugmesh visual instances if debug is enabled
|
||||
SceneTree *st = SceneTree::get_singleton();
|
||||
if (st && st->is_debugging_navigation_hint()) {
|
||||
if (!nm.navmesh_debug_instance.is_valid()) {
|
||||
RID navmesh_debug_rid = navmesh->get_debug_mesh()->get_rid();
|
||||
nm.navmesh_debug_instance = RS::get_singleton()->instance_create();
|
||||
RS::get_singleton()->instance_set_base(nm.navmesh_debug_instance, navmesh_debug_rid);
|
||||
if (!nm.navigation_mesh_debug_instance.is_valid()) {
|
||||
RID navigation_mesh_debug_rid = navigation_mesh->get_debug_mesh()->get_rid();
|
||||
nm.navigation_mesh_debug_instance = RS::get_singleton()->instance_create();
|
||||
RS::get_singleton()->instance_set_base(nm.navigation_mesh_debug_instance, navigation_mesh_debug_rid);
|
||||
}
|
||||
if (is_inside_tree()) {
|
||||
RS::get_singleton()->instance_set_scenario(nm.navmesh_debug_instance, get_world_3d()->get_scenario());
|
||||
RS::get_singleton()->instance_set_transform(nm.navmesh_debug_instance, get_global_transform() * nm.xform);
|
||||
RS::get_singleton()->instance_set_scenario(nm.navigation_mesh_debug_instance, get_world_3d()->get_scenario());
|
||||
RS::get_singleton()->instance_set_transform(nm.navigation_mesh_debug_instance, get_global_transform() * nm.xform);
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
}
|
||||
g.navmesh_ids[E->get()] = nm;
|
||||
g.navigation_cell_ids[E->get()] = nm;
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,14 +725,14 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
|
||||
}
|
||||
|
||||
if (bake_navigation && mesh_library.is_valid()) {
|
||||
for (RBMap<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
|
||||
for (RBMap<IndexKey, Octant::NavigationCell>::Element *E = g.navigation_cell_ids.front(); E; E = E->next()) {
|
||||
if (cell_map.has(E->key()) && E->get().region.is_valid() == false) {
|
||||
Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[E->key()].item);
|
||||
Ref<NavigationMesh> nm = mesh_library->get_item_navigation_mesh(cell_map[E->key()].item);
|
||||
if (nm.is_valid()) {
|
||||
RID region = NavigationServer::get_singleton()->region_create();
|
||||
NavigationServer::get_singleton()->region_set_owner_id(region, get_instance_id());
|
||||
NavigationServer::get_singleton()->region_set_navigation_layers(region, navigation_layers);
|
||||
NavigationServer::get_singleton()->region_set_navmesh(region, nm);
|
||||
NavigationServer::get_singleton()->region_set_navigation_mesh(region, nm);
|
||||
NavigationServer::get_singleton()->region_set_transform(region, get_global_transform() * E->get().xform);
|
||||
NavigationServer::get_singleton()->region_set_map(region, get_navigation_map());
|
||||
E->get().region = region;
|
||||
@ -769,14 +769,14 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
|
||||
RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
|
||||
}
|
||||
|
||||
for (RBMap<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
|
||||
for (RBMap<IndexKey, Octant::NavigationCell>::Element *E = g.navigation_cell_ids.front(); E; E = E->next()) {
|
||||
if (E->get().region.is_valid()) {
|
||||
NavigationServer::get_singleton()->free(E->get().region);
|
||||
E->get().region = RID();
|
||||
}
|
||||
if (E->get().navmesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->free(E->get().navmesh_debug_instance);
|
||||
E->get().navmesh_debug_instance = RID();
|
||||
if (E->get().navigation_mesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->free(E->get().navigation_mesh_debug_instance);
|
||||
E->get().navigation_mesh_debug_instance = RID();
|
||||
}
|
||||
}
|
||||
|
||||
@ -813,15 +813,15 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
|
||||
}
|
||||
|
||||
// Erase navigation
|
||||
for (RBMap<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
|
||||
for (RBMap<IndexKey, Octant::NavigationCell>::Element *E = g.navigation_cell_ids.front(); E; E = E->next()) {
|
||||
if (E->get().region.is_valid()) {
|
||||
NavigationServer::get_singleton()->free(E->get().region);
|
||||
}
|
||||
if (E->get().navmesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->free(E->get().navmesh_debug_instance);
|
||||
if (E->get().navigation_mesh_debug_instance.is_valid()) {
|
||||
RS::get_singleton()->free(E->get().navigation_mesh_debug_instance);
|
||||
}
|
||||
}
|
||||
g.navmesh_ids.clear();
|
||||
g.navigation_cell_ids.clear();
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (bake_navigation) {
|
||||
@ -1422,7 +1422,7 @@ void GridMap::_update_octant_navigation_debug_edge_connections_mesh(const Octant
|
||||
|
||||
Vector<Vector3> vertex_array;
|
||||
|
||||
for (RBMap<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
|
||||
for (RBMap<IndexKey, Octant::NavigationCell>::Element *E = g.navigation_cell_ids.front(); E; E = E->next()) {
|
||||
if (cell_map.has(E->key()) && E->get().region.is_valid()) {
|
||||
int connections_count = NavigationServer::get_singleton()->region_get_connections_count(E->get().region);
|
||||
if (connections_count == 0) {
|
||||
|
@ -87,10 +87,10 @@ class GridMap : public Spatial {
|
||||
* A GridMap can have multiple Octants.
|
||||
*/
|
||||
struct Octant {
|
||||
struct NavMesh {
|
||||
struct NavigationCell {
|
||||
RID region;
|
||||
Transform xform;
|
||||
RID navmesh_debug_instance;
|
||||
RID navigation_mesh_debug_instance;
|
||||
};
|
||||
|
||||
struct MultimeshInstance {
|
||||
@ -116,7 +116,7 @@ class GridMap : public Spatial {
|
||||
|
||||
bool dirty;
|
||||
RID static_body;
|
||||
RBMap<IndexKey, NavMesh> navmesh_ids;
|
||||
RBMap<IndexKey, NavigationCell> navigation_cell_ids;
|
||||
};
|
||||
|
||||
union OctantKey {
|
||||
|
@ -58,10 +58,10 @@ bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
|
||||
_set_item_shapes(idx, p_value);
|
||||
} else if (what == "preview") {
|
||||
set_item_preview(idx, p_value);
|
||||
} else if (what == "navmesh") {
|
||||
set_item_navmesh(idx, p_value);
|
||||
} else if (what == "navmesh_transform") {
|
||||
set_item_navmesh_transform(idx, p_value);
|
||||
} else if (what == "navigation_mesh") {
|
||||
set_item_navigation_mesh(idx, p_value);
|
||||
} else if (what == "navigation_mesh_transform") {
|
||||
set_item_navigation_mesh_transform(idx, p_value);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -86,10 +86,10 @@ bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
r_ret = get_item_mesh_transform(idx);
|
||||
} else if (what == "shapes") {
|
||||
r_ret = _get_item_shapes(idx);
|
||||
} else if (what == "navmesh") {
|
||||
r_ret = get_item_navmesh(idx);
|
||||
} else if (what == "navmesh_transform") {
|
||||
r_ret = get_item_navmesh_transform(idx);
|
||||
} else if (what == "navigation_mesh") {
|
||||
r_ret = get_item_navigation_mesh(idx);
|
||||
} else if (what == "navigation_mesh_transform") {
|
||||
r_ret = get_item_navigation_mesh_transform(idx);
|
||||
} else if (what == "preview") {
|
||||
r_ret = get_item_preview(idx);
|
||||
} else {
|
||||
@ -106,8 +106,8 @@ void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, name + ("mesh"), PROPERTY_HINT_RESOURCE_TYPE, "Mesh"));
|
||||
p_list->push_back(PropertyInfo(Variant::TRANSFORM, name + ("mesh_transform")));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, name + ("shapes")));
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, name + ("navmesh"), PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"));
|
||||
p_list->push_back(PropertyInfo(Variant::TRANSFORM, name + ("navmesh_transform")));
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, name + ("navigation_mesh"), PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"));
|
||||
p_list->push_back(PropertyInfo(Variant::TRANSFORM, name + ("navigation_mesh_transform")));
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, name + ("preview"), PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER));
|
||||
}
|
||||
}
|
||||
@ -151,18 +151,18 @@ void MeshLibrary::set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes)
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
void MeshLibrary::set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh) {
|
||||
void MeshLibrary::set_item_navigation_mesh(int p_item, const Ref<NavigationMesh> &p_navigation_mesh) {
|
||||
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
|
||||
item_map[p_item].navmesh = p_navmesh;
|
||||
item_map[p_item].navigation_mesh = p_navigation_mesh;
|
||||
_change_notify();
|
||||
notify_change_to_owners();
|
||||
emit_changed();
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
void MeshLibrary::set_item_navmesh_transform(int p_item, const Transform &p_transform) {
|
||||
void MeshLibrary::set_item_navigation_mesh_transform(int p_item, const Transform &p_transform) {
|
||||
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
|
||||
item_map[p_item].navmesh_transform = p_transform;
|
||||
item_map[p_item].navigation_mesh_transform = p_transform;
|
||||
notify_change_to_owners();
|
||||
emit_changed();
|
||||
_change_notify();
|
||||
@ -195,14 +195,14 @@ Vector<MeshLibrary::ShapeData> MeshLibrary::get_item_shapes(int p_item) const {
|
||||
return item_map[p_item].shapes;
|
||||
}
|
||||
|
||||
Ref<NavigationMesh> MeshLibrary::get_item_navmesh(int p_item) const {
|
||||
Ref<NavigationMesh> MeshLibrary::get_item_navigation_mesh(int p_item) const {
|
||||
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<NavigationMesh>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
|
||||
return item_map[p_item].navmesh;
|
||||
return item_map[p_item].navigation_mesh;
|
||||
}
|
||||
|
||||
Transform MeshLibrary::get_item_navmesh_transform(int p_item) const {
|
||||
Transform MeshLibrary::get_item_navigation_mesh_transform(int p_item) const {
|
||||
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Transform(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
|
||||
return item_map[p_item].navmesh_transform;
|
||||
return item_map[p_item].navigation_mesh_transform;
|
||||
}
|
||||
|
||||
Ref<Texture> MeshLibrary::get_item_preview(int p_item) const {
|
||||
@ -311,15 +311,15 @@ void MeshLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_item_name", "id", "name"), &MeshLibrary::set_item_name);
|
||||
ClassDB::bind_method(D_METHOD("set_item_mesh", "id", "mesh"), &MeshLibrary::set_item_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_item_mesh_transform", "id", "mesh_transform"), &MeshLibrary::set_item_mesh_transform);
|
||||
ClassDB::bind_method(D_METHOD("set_item_navmesh", "id", "navmesh"), &MeshLibrary::set_item_navmesh);
|
||||
ClassDB::bind_method(D_METHOD("set_item_navmesh_transform", "id", "navmesh"), &MeshLibrary::set_item_navmesh_transform);
|
||||
ClassDB::bind_method(D_METHOD("set_item_navigation_mesh", "id", "navigation_mesh"), &MeshLibrary::set_item_navigation_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_item_navigation_mesh_transform", "id", "navigation_mesh"), &MeshLibrary::set_item_navigation_mesh_transform);
|
||||
ClassDB::bind_method(D_METHOD("set_item_shapes", "id", "shapes"), &MeshLibrary::_set_item_shapes);
|
||||
ClassDB::bind_method(D_METHOD("set_item_preview", "id", "texture"), &MeshLibrary::set_item_preview);
|
||||
ClassDB::bind_method(D_METHOD("get_item_name", "id"), &MeshLibrary::get_item_name);
|
||||
ClassDB::bind_method(D_METHOD("get_item_mesh", "id"), &MeshLibrary::get_item_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_item_mesh_transform", "id"), &MeshLibrary::get_item_mesh_transform);
|
||||
ClassDB::bind_method(D_METHOD("get_item_navmesh", "id"), &MeshLibrary::get_item_navmesh);
|
||||
ClassDB::bind_method(D_METHOD("get_item_navmesh_transform", "id"), &MeshLibrary::get_item_navmesh_transform);
|
||||
ClassDB::bind_method(D_METHOD("get_item_navigation_mesh", "id"), &MeshLibrary::get_item_navigation_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_item_navigation_mesh_transform", "id"), &MeshLibrary::get_item_navigation_mesh_transform);
|
||||
ClassDB::bind_method(D_METHOD("get_item_shapes", "id"), &MeshLibrary::_get_item_shapes);
|
||||
ClassDB::bind_method(D_METHOD("get_item_preview", "id"), &MeshLibrary::get_item_preview);
|
||||
ClassDB::bind_method(D_METHOD("remove_item", "id"), &MeshLibrary::remove_item);
|
||||
|
@ -53,9 +53,9 @@ public:
|
||||
Ref<Mesh> mesh;
|
||||
Vector<ShapeData> shapes;
|
||||
Ref<Texture> preview;
|
||||
Transform navmesh_transform;
|
||||
Transform navigation_mesh_transform;
|
||||
Transform mesh_transform;
|
||||
Ref<NavigationMesh> navmesh;
|
||||
Ref<NavigationMesh> navigation_mesh;
|
||||
};
|
||||
|
||||
RBMap<int, Item> item_map;
|
||||
@ -75,15 +75,15 @@ public:
|
||||
void set_item_name(int p_item, const String &p_name);
|
||||
void set_item_mesh(int p_item, const Ref<Mesh> &p_mesh);
|
||||
void set_item_mesh_transform(int p_item, const Transform &p_transform);
|
||||
void set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh);
|
||||
void set_item_navmesh_transform(int p_item, const Transform &p_transform);
|
||||
void set_item_navigation_mesh(int p_item, const Ref<NavigationMesh> &p_navigation_mesh);
|
||||
void set_item_navigation_mesh_transform(int p_item, const Transform &p_transform);
|
||||
void set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes);
|
||||
void set_item_preview(int p_item, const Ref<Texture> &p_preview);
|
||||
String get_item_name(int p_item) const;
|
||||
Ref<Mesh> get_item_mesh(int p_item) const;
|
||||
Transform get_item_mesh_transform(int p_item) const;
|
||||
Ref<NavigationMesh> get_item_navmesh(int p_item) const;
|
||||
Transform get_item_navmesh_transform(int p_item) const;
|
||||
Ref<NavigationMesh> get_item_navigation_mesh(int p_item) const;
|
||||
Transform get_item_navigation_mesh_transform(int p_item) const;
|
||||
Vector<ShapeData> get_item_shapes(int p_item) const;
|
||||
Ref<Texture> get_item_preview(int p_item) const;
|
||||
|
||||
|
@ -170,23 +170,23 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
|
||||
|
||||
p_library->set_item_shapes(id, collisions);
|
||||
|
||||
Ref<NavigationMesh> navmesh;
|
||||
Transform navmesh_transform;
|
||||
Ref<NavigationMesh> navigation_mesh;
|
||||
Transform navigation_mesh_transform;
|
||||
for (int j = 0; j < mi->get_child_count(); j++) {
|
||||
Node *child2 = mi->get_child(j);
|
||||
if (!Object::cast_to<NavigationMeshInstance>(child2)) {
|
||||
continue;
|
||||
}
|
||||
NavigationMeshInstance *sb = Object::cast_to<NavigationMeshInstance>(child2);
|
||||
navmesh = sb->get_navigation_mesh();
|
||||
navmesh_transform = sb->get_transform();
|
||||
if (!navmesh.is_null()) {
|
||||
navigation_mesh = sb->get_navigation_mesh();
|
||||
navigation_mesh_transform = sb->get_transform();
|
||||
if (!navigation_mesh.is_null()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!navmesh.is_null()) {
|
||||
p_library->set_item_navmesh(id, navmesh);
|
||||
p_library->set_item_navmesh_transform(id, navmesh_transform);
|
||||
if (!navigation_mesh.is_null()) {
|
||||
p_library->set_item_navigation_mesh(id, navigation_mesh);
|
||||
p_library->set_item_navigation_mesh_transform(id, navigation_mesh_transform);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,8 +284,8 @@ void FORWARD_2(region_set_navigation_layers, RID, p_region, uint32_t, p_navigati
|
||||
uint32_t FORWARD_1_C(region_get_navigation_layers, RID, p_region, rid_to_rid);
|
||||
void FORWARD_2(region_set_transform, RID, p_region, Transform2D, p_transform, rid_to_rid, trf2_to_trf3);
|
||||
|
||||
void PandemoniumNavigation2DServer::region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) {
|
||||
NavigationServer::get_singleton()->region_set_navmesh(p_region, poly_to_mesh(p_nav_mesh));
|
||||
void PandemoniumNavigation2DServer::region_set_navigation_polygon(RID p_region, Ref<NavigationPolygon> p_navigation_mesh) {
|
||||
NavigationServer::get_singleton()->region_set_navigation_mesh(p_region, poly_to_mesh(p_navigation_mesh));
|
||||
}
|
||||
|
||||
int FORWARD_1_C(region_get_connections_count, RID, p_region, rid_to_rid);
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
virtual void region_set_transform(RID p_region, Transform2D p_transform);
|
||||
|
||||
/// Set the navigation poly of this region.
|
||||
virtual void region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh);
|
||||
virtual void region_set_navigation_polygon(RID p_region, Ref<NavigationPolygon> p_navigation_mesh);
|
||||
|
||||
/// Get a list of a region's connection to other regions.
|
||||
virtual int region_get_connections_count(RID p_region) const;
|
||||
|
@ -499,11 +499,11 @@ uint32_t PandemoniumNavigationServer::region_get_navigation_layers(RID p_region)
|
||||
return region->get_navigation_layers();
|
||||
}
|
||||
|
||||
COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
|
||||
COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref<NavigationMesh>, p_navigation_mesh) {
|
||||
NavRegion *region = region_owner.getornull(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
|
||||
region->set_mesh(p_nav_mesh);
|
||||
region->set_mesh(p_navigation_mesh);
|
||||
}
|
||||
|
||||
int PandemoniumNavigationServer::region_get_connections_count(RID p_region) const {
|
||||
|
@ -154,7 +154,7 @@ public:
|
||||
COMMAND_2(region_set_navigation_layers, RID, p_region, uint32_t, p_navigation_layers);
|
||||
virtual uint32_t region_get_navigation_layers(RID p_region) const;
|
||||
COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform);
|
||||
COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh);
|
||||
COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref<NavigationMesh>, p_navigation_mesh);
|
||||
|
||||
virtual int region_get_connections_count(RID p_region) const;
|
||||
virtual Vector3 region_get_connection_pathway_start(RID p_region, int p_connection_id) const;
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#include "scene/resources/navigation_polygon.h"
|
||||
|
||||
void DummyNavigation2DServer::region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) {
|
||||
void DummyNavigation2DServer::region_set_navigation_polygon(RID p_region, Ref<NavigationPolygon> p_navigation_mesh) {
|
||||
}
|
||||
|
||||
NavigationUtilities::PathQueryResult2D DummyNavigation2DServer::_query_path(const NavigationUtilities::PathQueryParameters2D &p_parameters) const {
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
virtual void region_set_navigation_layers(RID p_region, uint32_t p_navigation_layers) {}
|
||||
virtual uint32_t region_get_navigation_layers(RID p_region) const { return 0; }
|
||||
virtual void region_set_transform(RID p_region, Transform2D p_transform) {}
|
||||
virtual void region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh);
|
||||
virtual void region_set_navigation_polygon(RID p_region, Ref<NavigationPolygon> p_navigation_mesh);
|
||||
virtual int region_get_connections_count(RID p_region) const { return 0; }
|
||||
virtual Vector2 region_get_connection_pathway_start(RID p_region, int p_connection_id) const { return Vector2(); }
|
||||
virtual Vector2 region_get_connection_pathway_end(RID p_region, int p_connection_id) const { return Vector2(); }
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "scene/resources/navigation_mesh.h"
|
||||
|
||||
void DummyNavigationServer::region_set_navmesh(RID p_region, Ref<NavigationMesh> p_nav_mesh) {
|
||||
void DummyNavigationServer::region_set_navigation_mesh(RID p_region, Ref<NavigationMesh> p_navigation_mesh) {
|
||||
}
|
||||
|
||||
NavigationUtilities::PathQueryResult DummyNavigationServer::_query_path(const NavigationUtilities::PathQueryParameters &p_parameters) const {
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
virtual void region_set_navigation_layers(RID p_region, uint32_t p_navigation_layers) {}
|
||||
virtual uint32_t region_get_navigation_layers(RID p_region) const { return 0; }
|
||||
virtual void region_set_transform(RID p_region, Transform p_transform) {}
|
||||
virtual void region_set_navmesh(RID p_region, Ref<NavigationMesh> p_nav_mesh);
|
||||
virtual void region_set_navigation_mesh(RID p_region, Ref<NavigationMesh> p_navigation_mesh);
|
||||
virtual int region_get_connections_count(RID p_region) const { return 0; }
|
||||
virtual Vector3 region_get_connection_pathway_start(RID p_region, int p_connection_id) const { return Vector3(); }
|
||||
virtual Vector3 region_get_connection_pathway_end(RID p_region, int p_connection_id) const { return Vector3(); }
|
||||
|
@ -45,13 +45,13 @@
|
||||
#include "servers/navigation/navigation_mesh_generator.h"
|
||||
#include "scene/gui/separator.h"
|
||||
|
||||
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
|
||||
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
|
||||
if (!navpoly.is_valid()) {
|
||||
navpoly = Ref<NavigationPolygon>(memnew(NavigationPolygon));
|
||||
node->set_navigation_polygon(navpoly);
|
||||
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navigation_polygon() const {
|
||||
Ref<NavigationPolygon> navigation_polygon = node->get_navigation_polygon();
|
||||
if (!navigation_polygon.is_valid()) {
|
||||
navigation_polygon = Ref<NavigationPolygon>(memnew(NavigationPolygon));
|
||||
node->set_navigation_polygon(navigation_polygon);
|
||||
}
|
||||
return navpoly;
|
||||
return navigation_polygon;
|
||||
}
|
||||
|
||||
Node2D *NavigationPolygonEditor::_get_node() const {
|
||||
@ -63,52 +63,52 @@ void NavigationPolygonEditor::_set_node(Node *p_polygon) {
|
||||
}
|
||||
|
||||
int NavigationPolygonEditor::_get_polygon_count() const {
|
||||
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
|
||||
if (navpoly.is_valid()) {
|
||||
return navpoly->get_outline_count();
|
||||
Ref<NavigationPolygon> navigation_polygon = node->get_navigation_polygon();
|
||||
if (navigation_polygon.is_valid()) {
|
||||
return navigation_polygon->get_outline_count();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Variant NavigationPolygonEditor::_get_polygon(int p_idx) const {
|
||||
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
|
||||
if (navpoly.is_valid()) {
|
||||
return navpoly->get_outline(p_idx);
|
||||
Ref<NavigationPolygon> navigation_polygon = node->get_navigation_polygon();
|
||||
if (navigation_polygon.is_valid()) {
|
||||
return navigation_polygon->get_outline(p_idx);
|
||||
} else {
|
||||
return Variant(Vector<Vector2>());
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
navpoly->set_outline(p_idx, p_polygon);
|
||||
Ref<NavigationPolygon> navigation_polygon = _ensure_navigation_polygon();
|
||||
navigation_polygon->set_outline(p_idx, p_polygon);
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_action_add_polygon(const Variant &p_polygon) {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
Ref<NavigationPolygon> navigation_polygon = _ensure_navigation_polygon();
|
||||
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
||||
undo_redo->create_action("Add Navigation Polygon");
|
||||
undo_redo->add_do_method(navpoly.ptr(), "add_outline", p_polygon);
|
||||
undo_redo->add_undo_method(navpoly.ptr(), "remove_outline", navpoly->get_outline_count());
|
||||
undo_redo->add_do_method(navigation_polygon.ptr(), "add_outline", p_polygon);
|
||||
undo_redo->add_undo_method(navigation_polygon.ptr(), "remove_outline", navigation_polygon->get_outline_count());
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_action_remove_polygon(int p_idx) {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
Ref<NavigationPolygon> navigation_polygon = _ensure_navigation_polygon();
|
||||
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
||||
undo_redo->create_action("Remove Navigation Polygon");
|
||||
undo_redo->add_do_method(navpoly.ptr(), "remove_outline", p_idx);
|
||||
undo_redo->add_undo_method(navpoly.ptr(), "add_outline_at_index", navpoly->get_outline(p_idx), p_idx);
|
||||
undo_redo->add_do_method(navigation_polygon.ptr(), "remove_outline", p_idx);
|
||||
undo_redo->add_undo_method(navigation_polygon.ptr(), "add_outline_at_index", navigation_polygon->get_outline(p_idx), p_idx);
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
Ref<NavigationPolygon> navigation_polygon = _ensure_navigation_polygon();
|
||||
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
||||
undo_redo->create_action("Set Navigation Polygon");
|
||||
undo_redo->add_do_method(navpoly.ptr(), "set_outline", p_idx, p_polygon);
|
||||
undo_redo->add_undo_method(navpoly.ptr(), "set_outline", p_idx, p_previous);
|
||||
undo_redo->add_do_method(navigation_polygon.ptr(), "set_outline", p_idx, p_polygon);
|
||||
undo_redo->add_undo_method(navigation_polygon.ptr(), "set_outline", p_idx, p_previous);
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class NavigationPolygonEditor : public AbstractPolygon2DEditor {
|
||||
|
||||
NavigationPolygonInstance *node = nullptr;
|
||||
|
||||
Ref<NavigationPolygon> _ensure_navpoly() const;
|
||||
Ref<NavigationPolygon> _ensure_navigation_polygon() const;
|
||||
|
||||
AcceptDialog *err_dialog = nullptr;
|
||||
|
||||
|
@ -108,10 +108,10 @@ void PandemoniumNavigationMeshGenerator::process() {
|
||||
}
|
||||
|
||||
void PandemoniumNavigationMeshGenerator::cleanup() {
|
||||
_baking_navpolys.clear();
|
||||
_baking_navigation_polygons.clear();
|
||||
_geometry_2d_parsers.clear();
|
||||
#ifndef _3D_DISABLED
|
||||
_baking_navmeshes.clear();
|
||||
_baking_navigation_meshes.clear();
|
||||
_geometry_3d_parsers.clear();
|
||||
#endif // _3D_DISABLED
|
||||
}
|
||||
@ -188,8 +188,8 @@ void PandemoniumNavigationMeshGenerator::_process_2d_bake_cleanup_tasks() {
|
||||
_2d_running_jobs.remove_unordered(i);
|
||||
--i;
|
||||
|
||||
int indx = _baking_navpolys.find(e->navigation_polygon);
|
||||
_baking_navpolys.remove_unordered(indx);
|
||||
int indx = _baking_navigation_polygons.find(e->navigation_polygon);
|
||||
_baking_navigation_polygons.remove_unordered(indx);
|
||||
|
||||
e->call_callback();
|
||||
}
|
||||
@ -228,18 +228,18 @@ void PandemoniumNavigationMeshGenerator::bake_2d_from_source_geometry_data(Ref<N
|
||||
ERR_FAIL_COND_MSG(!p_navigation_polygon.is_valid(), "Invalid navigation mesh.");
|
||||
ERR_FAIL_COND_MSG(!p_source_geometry_data.is_valid(), "Invalid NavigationMeshSourceGeometryData2D.");
|
||||
ERR_FAIL_COND_MSG(p_navigation_polygon->get_outline_count() == 0 && !p_source_geometry_data->has_data(), "NavigationMeshSourceGeometryData2D is empty. Parse source geometry first.");
|
||||
ERR_FAIL_COND_MSG(_baking_navpolys.find(p_navigation_polygon) >= 0, "NavigationPolygon is already baking. Wait for current bake task to finish.");
|
||||
ERR_FAIL_COND_MSG(_baking_navigation_polygons.find(p_navigation_polygon) >= 0, "NavigationPolygon is already baking. Wait for current bake task to finish.");
|
||||
|
||||
_generator_mutex.lock();
|
||||
_baking_navpolys.push_back(p_navigation_polygon);
|
||||
_baking_navigation_polygons.push_back(p_navigation_polygon);
|
||||
_generator_mutex.unlock();
|
||||
|
||||
_static_bake_2d_from_source_geometry_data(p_navigation_polygon, p_source_geometry_data);
|
||||
|
||||
_generator_mutex.lock();
|
||||
int64_t navigation_polygon_index = _baking_navpolys.find(p_navigation_polygon);
|
||||
int64_t navigation_polygon_index = _baking_navigation_polygons.find(p_navigation_polygon);
|
||||
if (navigation_polygon_index >= 0) {
|
||||
_baking_navpolys.remove_unordered(navigation_polygon_index);
|
||||
_baking_navigation_polygons.remove_unordered(navigation_polygon_index);
|
||||
}
|
||||
_generator_mutex.unlock();
|
||||
}
|
||||
@ -443,11 +443,11 @@ void PandemoniumNavigationMeshGenerator::_static_bake_2d_from_source_geometry_da
|
||||
}
|
||||
|
||||
void PandemoniumNavigationMeshGenerator::parse_and_bake_2d(Ref<NavigationPolygon> p_navigation_polygon, Node *p_root_node, Ref<FuncRef> p_callback) {
|
||||
ERR_FAIL_COND_MSG(_baking_navpolys.find(p_navigation_polygon) >= 0, "NavigationPolygon was already added to baking queue. Wait for current bake task to finish.");
|
||||
ERR_FAIL_COND_MSG(_baking_navigation_polygons.find(p_navigation_polygon) >= 0, "NavigationPolygon was already added to baking queue. Wait for current bake task to finish.");
|
||||
ERR_FAIL_COND_MSG(p_root_node == nullptr, "NavigationPolygon requires a valid root node.");
|
||||
|
||||
_generator_mutex.lock();
|
||||
_baking_navpolys.push_back(p_navigation_polygon);
|
||||
_baking_navigation_polygons.push_back(p_navigation_polygon);
|
||||
_generator_mutex.unlock();
|
||||
|
||||
Ref<NavigationGeneratorTask2D> navigation_generator_task;
|
||||
@ -466,7 +466,7 @@ void PandemoniumNavigationMeshGenerator::parse_and_bake_2d(Ref<NavigationPolygon
|
||||
|
||||
bool PandemoniumNavigationMeshGenerator::is_navigation_polygon_baking(Ref<NavigationPolygon> p_navigation_polygon) const {
|
||||
ERR_FAIL_COND_V(!p_navigation_polygon.is_valid(), false);
|
||||
return _baking_navpolys.find(p_navigation_polygon) >= 0;
|
||||
return _baking_navigation_polygons.find(p_navigation_polygon) >= 0;
|
||||
}
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
@ -542,8 +542,8 @@ void PandemoniumNavigationMeshGenerator::_process_3d_bake_cleanup_tasks() {
|
||||
_3d_running_jobs.remove_unordered(i);
|
||||
--i;
|
||||
|
||||
int indx = _baking_navpolys.find(e->navigation_mesh);
|
||||
_baking_navpolys.remove_unordered(indx);
|
||||
int indx = _baking_navigation_polygons.find(e->navigation_mesh);
|
||||
_baking_navigation_polygons.remove_unordered(indx);
|
||||
|
||||
e->call_callback();
|
||||
}
|
||||
@ -598,7 +598,7 @@ void PandemoniumNavigationMeshGenerator::_static_bake_3d_from_source_geometry_da
|
||||
cfg.maxSimplificationError = p_navigation_mesh->get_edge_max_error();
|
||||
cfg.minRegionArea = (int)(p_navigation_mesh->get_region_min_size() * p_navigation_mesh->get_region_min_size());
|
||||
cfg.mergeRegionArea = (int)(p_navigation_mesh->get_region_merge_size() * p_navigation_mesh->get_region_merge_size());
|
||||
cfg.maxVertsPerPoly = (int)p_navigation_mesh->get_verts_per_poly();
|
||||
cfg.maxVertsPerPoly = (int)p_navigation_mesh->get_vertices_per_polyon();
|
||||
cfg.detailSampleDist = MAX(p_navigation_mesh->get_cell_size() * p_navigation_mesh->get_detail_sample_distance(), 0.1f);
|
||||
cfg.detailSampleMaxError = p_navigation_mesh->get_cell_height() * p_navigation_mesh->get_detail_sample_max_error();
|
||||
|
||||
@ -760,11 +760,11 @@ void PandemoniumNavigationMeshGenerator::_static_bake_3d_from_source_geometry_da
|
||||
}
|
||||
|
||||
void PandemoniumNavigationMeshGenerator::parse_and_bake_3d(Ref<NavigationMesh> p_navigation_mesh, Node *p_root_node, Ref<FuncRef> p_callback) {
|
||||
ERR_FAIL_COND_MSG(_baking_navmeshes.find(p_navigation_mesh) >= 0, "NavigationMesh was already added to baking queue. Wait for current bake task to finish.");
|
||||
ERR_FAIL_COND_MSG(_baking_navigation_meshes.find(p_navigation_mesh) >= 0, "NavigationMesh was already added to baking queue. Wait for current bake task to finish.");
|
||||
ERR_FAIL_COND_MSG(p_root_node == nullptr, "avigationMesh requires a valid root node.");
|
||||
|
||||
_generator_mutex.lock();
|
||||
_baking_navmeshes.push_back(p_navigation_mesh);
|
||||
_baking_navigation_meshes.push_back(p_navigation_mesh);
|
||||
_generator_mutex.unlock();
|
||||
|
||||
Ref<NavigationGeneratorTask3D> navigation_generator_task;
|
||||
@ -785,7 +785,7 @@ void PandemoniumNavigationMeshGenerator::parse_and_bake_3d(Ref<NavigationMesh> p
|
||||
|
||||
bool PandemoniumNavigationMeshGenerator::is_navigation_mesh_baking(Ref<NavigationMesh> p_navigation_mesh) const {
|
||||
ERR_FAIL_COND_V(!p_navigation_mesh.is_valid(), false);
|
||||
return _baking_navmeshes.find(p_navigation_mesh) >= 0;
|
||||
return _baking_navigation_meshes.find(p_navigation_mesh) >= 0;
|
||||
}
|
||||
|
||||
void PandemoniumNavigationMeshGenerator::register_geometry_parser_3d(Ref<NavigationGeometryParser3D> p_geometry_parser) {
|
||||
@ -820,18 +820,18 @@ void PandemoniumNavigationMeshGenerator::bake_3d_from_source_geometry_data(Ref<N
|
||||
ERR_FAIL_COND_MSG(!p_navigation_mesh.is_valid(), "Invalid navigation mesh.");
|
||||
ERR_FAIL_COND_MSG(!p_source_geometry_data.is_valid(), "Invalid NavigationMeshSourceGeometryData3D.");
|
||||
ERR_FAIL_COND_MSG(!p_source_geometry_data->has_data(), "NavigationMeshSourceGeometryData3D is empty. Parse source geometry first.");
|
||||
ERR_FAIL_COND_MSG(_baking_navmeshes.find(p_navigation_mesh) >= 0, "NavigationMesh is already baking. Wait for current bake task to finish.");
|
||||
ERR_FAIL_COND_MSG(_baking_navigation_meshes.find(p_navigation_mesh) >= 0, "NavigationMesh is already baking. Wait for current bake task to finish.");
|
||||
|
||||
_generator_mutex.lock();
|
||||
_baking_navmeshes.push_back(p_navigation_mesh);
|
||||
_baking_navigation_meshes.push_back(p_navigation_mesh);
|
||||
_generator_mutex.unlock();
|
||||
|
||||
_static_bake_3d_from_source_geometry_data(p_navigation_mesh, p_source_geometry_data);
|
||||
|
||||
_generator_mutex.lock();
|
||||
int64_t navigation_mesh_index = _baking_navmeshes.find(p_navigation_mesh);
|
||||
int64_t navigation_mesh_index = _baking_navigation_meshes.find(p_navigation_mesh);
|
||||
if (navigation_mesh_index >= 0) {
|
||||
_baking_navmeshes.remove_unordered(navigation_mesh_index);
|
||||
_baking_navigation_meshes.remove_unordered(navigation_mesh_index);
|
||||
}
|
||||
_generator_mutex.unlock();
|
||||
}
|
||||
|
@ -170,14 +170,14 @@ private:
|
||||
|
||||
LocalVector<Ref<NavigationGeometryParser2D>> _geometry_2d_parsers;
|
||||
|
||||
LocalVector<Ref<NavigationPolygon>> _baking_navpolys;
|
||||
LocalVector<Ref<NavigationPolygon>> _baking_navigation_polygons;
|
||||
LocalVector<Ref<NavigationGeneratorTask2D>> _2d_parse_jobs;
|
||||
LocalVector<Ref<NavigationGeneratorTask2D>> _2d_running_jobs;
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
LocalVector<Ref<NavigationGeometryParser3D>> _geometry_3d_parsers;
|
||||
|
||||
LocalVector<Ref<NavigationMesh>> _baking_navmeshes;
|
||||
LocalVector<Ref<NavigationMesh>> _baking_navigation_meshes;
|
||||
LocalVector<Ref<NavigationGeneratorTask3D>> _3d_parse_jobs;
|
||||
LocalVector<Ref<NavigationGeneratorTask3D>> _3d_running_jobs;
|
||||
#endif // _3D_DISABLED
|
||||
|
@ -44,13 +44,13 @@
|
||||
#include "servers/navigation_server.h"
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
void TileMap::Quadrant::clear_navpoly() {
|
||||
for (RBMap<PosKey, Quadrant::NavPoly>::Element *E = navpoly_ids.front(); E; E = E->next()) {
|
||||
void TileMap::Quadrant::clear_navigation_polygon() {
|
||||
for (RBMap<PosKey, Quadrant::NavPoly>::Element *E = navigation_polygon_ids.front(); E; E = E->next()) {
|
||||
RID region = E->get().region;
|
||||
Navigation2DServer::get_singleton()->region_set_map(region, RID());
|
||||
Navigation2DServer::get_singleton()->free(region);
|
||||
}
|
||||
navpoly_ids.clear();
|
||||
navigation_polygon_ids.clear();
|
||||
}
|
||||
|
||||
int TileMap::_get_quadrant_size() const {
|
||||
@ -96,7 +96,7 @@ void TileMap::_notification(int p_what) {
|
||||
for (RBMap<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
|
||||
Quadrant &q = E->get();
|
||||
if (bake_navigation) {
|
||||
q.clear_navpoly();
|
||||
q.clear_navigation_polygon();
|
||||
}
|
||||
|
||||
if (collision_parent) {
|
||||
@ -181,7 +181,7 @@ void TileMap::_update_quadrant_transform() {
|
||||
}
|
||||
|
||||
if (bake_navigation) {
|
||||
for (RBMap<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
|
||||
for (RBMap<PosKey, Quadrant::NavPoly>::Element *F = q.navigation_polygon_ids.front(); F; F = F->next()) {
|
||||
Navigation2DServer::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform);
|
||||
}
|
||||
}
|
||||
@ -427,7 +427,7 @@ void TileMap::update_dirty_quadrants() {
|
||||
int shape_idx = 0;
|
||||
|
||||
if (bake_navigation) {
|
||||
q.clear_navpoly();
|
||||
q.clear_navigation_polygon();
|
||||
}
|
||||
|
||||
for (RBMap<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
|
||||
@ -680,17 +680,17 @@ void TileMap::update_dirty_quadrants() {
|
||||
}
|
||||
|
||||
if (bake_navigation) {
|
||||
Ref<NavigationPolygon> navpoly;
|
||||
Ref<NavigationPolygon> navigation_polygon;
|
||||
Vector2 npoly_ofs;
|
||||
if (tile_set->tile_get_tile_mode(c.id) == TileSet::AUTO_TILE || tile_set->tile_get_tile_mode(c.id) == TileSet::ATLAS_TILE) {
|
||||
navpoly = tile_set->autotile_get_navigation_polygon(c.id, Vector2(c.autotile_coord_x, c.autotile_coord_y));
|
||||
navigation_polygon = tile_set->autotile_get_navigation_polygon(c.id, Vector2(c.autotile_coord_x, c.autotile_coord_y));
|
||||
npoly_ofs = Vector2();
|
||||
} else {
|
||||
navpoly = tile_set->tile_get_navigation_polygon(c.id);
|
||||
navigation_polygon = tile_set->tile_get_navigation_polygon(c.id);
|
||||
npoly_ofs = tile_set->tile_get_navigation_polygon_offset(c.id);
|
||||
}
|
||||
|
||||
if (navpoly.is_valid()) {
|
||||
if (navigation_polygon.is_valid()) {
|
||||
Transform2D xform;
|
||||
xform.set_origin(offset.floor() + q.pos + tile_ofs);
|
||||
_fix_cell_transform(xform, c, npoly_ofs, s);
|
||||
@ -704,11 +704,11 @@ void TileMap::update_dirty_quadrants() {
|
||||
}
|
||||
Navigation2DServer::get_singleton()->region_set_navigation_layers(region, navigation_layers);
|
||||
Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform);
|
||||
Navigation2DServer::get_singleton()->region_set_navpoly(region, navpoly);
|
||||
Navigation2DServer::get_singleton()->region_set_navigation_polygon(region, navigation_polygon);
|
||||
Quadrant::NavPoly np;
|
||||
np.region = region;
|
||||
np.xform = xform;
|
||||
q.navpoly_ids[E->key()] = np;
|
||||
q.navigation_polygon_ids[E->key()] = np;
|
||||
|
||||
if (debug_navigation) {
|
||||
RID debug_navigation_item = RID_PRIME(vs->canvas_item_create());
|
||||
@ -717,7 +717,7 @@ void TileMap::update_dirty_quadrants() {
|
||||
vs->canvas_item_set_z_index(debug_navigation_item, RS::CANVAS_ITEM_Z_MAX - 2); // Display one below collision debug
|
||||
|
||||
if (debug_navigation_item.is_valid()) {
|
||||
PoolVector<Vector2> navigation_polygon_vertices = navpoly->get_vertices();
|
||||
PoolVector<Vector2> navigation_polygon_vertices = navigation_polygon->get_vertices();
|
||||
int vsize = navigation_polygon_vertices.size();
|
||||
|
||||
if (vsize > 2) {
|
||||
@ -747,8 +747,8 @@ void TileMap::update_dirty_quadrants() {
|
||||
|
||||
Vector<int> indices;
|
||||
|
||||
for (int j = 0; j < navpoly->get_polygon_count(); j++) {
|
||||
Vector<int> polygon = navpoly->get_polygon(j);
|
||||
for (int j = 0; j < navigation_polygon->get_polygon_count(); j++) {
|
||||
Vector<int> polygon = navigation_polygon->get_polygon(j);
|
||||
|
||||
for (int k = 2; k < polygon.size(); k++) {
|
||||
int kofs[3] = { 0, k - 1, k };
|
||||
@ -922,7 +922,7 @@ void TileMap::_erase_quadrant(RBMap<PosKey, Quadrant>::Element *Q) {
|
||||
}
|
||||
|
||||
if (bake_navigation) {
|
||||
q.clear_navpoly();
|
||||
q.clear_navigation_polygon();
|
||||
}
|
||||
|
||||
for (RBMap<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
|
||||
|
@ -156,12 +156,12 @@ private:
|
||||
Transform2D xform;
|
||||
};
|
||||
|
||||
RBMap<PosKey, NavPoly> navpoly_ids;
|
||||
RBMap<PosKey, NavPoly> navigation_polygon_ids;
|
||||
RBMap<PosKey, Occluder> occluder_instances;
|
||||
|
||||
VSet<PosKey> cells;
|
||||
|
||||
void clear_navpoly();
|
||||
void clear_navigation_polygon();
|
||||
|
||||
void operator=(const Quadrant &q) {
|
||||
pos = q.pos;
|
||||
@ -169,7 +169,7 @@ private:
|
||||
body = q.body;
|
||||
shape_owner_id = q.shape_owner_id;
|
||||
cells = q.cells;
|
||||
navpoly_ids = q.navpoly_ids;
|
||||
navigation_polygon_ids = q.navigation_polygon_ids;
|
||||
occluder_instances = q.occluder_instances;
|
||||
}
|
||||
Quadrant(const Quadrant &q) :
|
||||
@ -180,7 +180,7 @@ private:
|
||||
shape_owner_id = q.shape_owner_id;
|
||||
cells = q.cells;
|
||||
occluder_instances = q.occluder_instances;
|
||||
navpoly_ids = q.navpoly_ids;
|
||||
navigation_polygon_ids = q.navigation_polygon_ids;
|
||||
}
|
||||
Quadrant() :
|
||||
dirty_list(this) {}
|
||||
|
@ -104,8 +104,8 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
||||
}
|
||||
p.pop_front();
|
||||
}
|
||||
} else if (what == "navpoly_map") {
|
||||
tile_map[id].autotile_data.navpoly_map.clear();
|
||||
} else if (what == "navigation_polygon_map") {
|
||||
tile_map[id].autotile_data.navigation_polygon_map.clear();
|
||||
Array p = p_value;
|
||||
Vector2 last_coord;
|
||||
while (p.size() > 0) {
|
||||
@ -260,9 +260,9 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
p.push_back(E->value());
|
||||
}
|
||||
r_ret = p;
|
||||
} else if (what == "navpoly_map") {
|
||||
} else if (what == "navigation_polygon_map") {
|
||||
Array p;
|
||||
for (RBMap<Vector2, Ref<NavigationPolygon>>::Element *E = tile_map[id].autotile_data.navpoly_map.front(); E; E = E->next()) {
|
||||
for (RBMap<Vector2, Ref<NavigationPolygon>>::Element *E = tile_map[id].autotile_data.navigation_polygon_map.front(); E; E = E->next()) {
|
||||
p.push_back(E->key());
|
||||
p.push_back(E->value());
|
||||
}
|
||||
@ -342,7 +342,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "autotile/tile_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, pre + "autotile/spacing", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/occluder_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/navpoly_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/navigation_polygon_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/priority_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/z_index_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
} else if (tile_get_tile_mode(id) == ATLAS_TILE) {
|
||||
@ -350,7 +350,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "autotile/tile_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, pre + "autotile/spacing", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/occluder_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/navpoly_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/navigation_polygon_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/priority_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/z_index_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
}
|
||||
@ -976,27 +976,27 @@ const RBMap<Vector2, Ref<OccluderPolygon2D>> &TileSet::autotile_get_light_oclusi
|
||||
void TileSet::autotile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon, const Vector2 &p_coord) {
|
||||
ERR_FAIL_COND_MSG(!tile_map.has(p_id), vformat("The TileSet doesn't have a tile with ID '%d'.", p_id));
|
||||
if (p_navigation_polygon.is_null()) {
|
||||
if (tile_map[p_id].autotile_data.navpoly_map.has(p_coord)) {
|
||||
tile_map[p_id].autotile_data.navpoly_map.erase(p_coord);
|
||||
if (tile_map[p_id].autotile_data.navigation_polygon_map.has(p_coord)) {
|
||||
tile_map[p_id].autotile_data.navigation_polygon_map.erase(p_coord);
|
||||
}
|
||||
} else {
|
||||
tile_map[p_id].autotile_data.navpoly_map[p_coord] = p_navigation_polygon;
|
||||
tile_map[p_id].autotile_data.navigation_polygon_map[p_coord] = p_navigation_polygon;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<NavigationPolygon> TileSet::autotile_get_navigation_polygon(int p_id, const Vector2 &p_coord) const {
|
||||
ERR_FAIL_COND_V_MSG(!tile_map.has(p_id), Ref<NavigationPolygon>(), vformat("The TileSet doesn't have a tile with ID '%d'.", p_id));
|
||||
if (!tile_map[p_id].autotile_data.navpoly_map.has(p_coord)) {
|
||||
if (!tile_map[p_id].autotile_data.navigation_polygon_map.has(p_coord)) {
|
||||
return Ref<NavigationPolygon>();
|
||||
} else {
|
||||
return tile_map[p_id].autotile_data.navpoly_map[p_coord];
|
||||
return tile_map[p_id].autotile_data.navigation_polygon_map[p_coord];
|
||||
}
|
||||
}
|
||||
|
||||
const RBMap<Vector2, Ref<NavigationPolygon>> &TileSet::autotile_get_navigation_map(int p_id) const {
|
||||
static RBMap<Vector2, Ref<NavigationPolygon>> dummy;
|
||||
ERR_FAIL_COND_V_MSG(!tile_map.has(p_id), dummy, vformat("The TileSet doesn't have a tile with ID '%d'.", p_id));
|
||||
return tile_map[p_id].autotile_data.navpoly_map;
|
||||
return tile_map[p_id].autotile_data.navigation_polygon_map;
|
||||
}
|
||||
|
||||
void TileSet::tile_set_occluder_offset(int p_id, const Vector2 &p_offset) {
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
Vector2 icon_coord;
|
||||
RBMap<Vector2, uint32_t> flags;
|
||||
RBMap<Vector2, Ref<OccluderPolygon2D>> occluder_map;
|
||||
RBMap<Vector2, Ref<NavigationPolygon>> navpoly_map;
|
||||
RBMap<Vector2, Ref<NavigationPolygon>> navigation_polygon_map;
|
||||
RBMap<Vector2, int> priority_map;
|
||||
RBMap<Vector2, int> z_index_map;
|
||||
FallbackMode fallback_mode;
|
||||
|
@ -168,11 +168,11 @@ RID NavigationPolygonInstance::get_region_rid() const {
|
||||
/////////////////////////////
|
||||
#ifdef TOOLS_ENABLED
|
||||
Rect2 NavigationPolygonInstance::_edit_get_rect() const {
|
||||
return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2();
|
||||
return navigation_polygon.is_valid() ? navigation_polygon->_edit_get_rect() : Rect2();
|
||||
}
|
||||
|
||||
bool NavigationPolygonInstance::_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;
|
||||
return navigation_polygon.is_valid() ? navigation_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -258,7 +258,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
|
||||
} break;
|
||||
case NOTIFICATION_DRAW: {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || Navigation2DServer::get_singleton()->get_debug_navigation_enabled()) && navpoly.is_valid()) {
|
||||
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || Navigation2DServer::get_singleton()->get_debug_navigation_enabled()) && navigation_polygon.is_valid()) {
|
||||
_update_debug_mesh();
|
||||
_update_debug_edge_connections_mesh();
|
||||
}
|
||||
@ -267,27 +267,27 @@ void NavigationPolygonInstance::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
|
||||
if (p_navpoly == navpoly) {
|
||||
void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolygon> &p_navigation_polygon) {
|
||||
if (p_navigation_polygon == navigation_polygon) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (navpoly.is_valid()) {
|
||||
navpoly->disconnect(CoreStringNames::get_singleton()->changed, this, "_navigation_polygon_changed");
|
||||
if (navigation_polygon.is_valid()) {
|
||||
navigation_polygon->disconnect(CoreStringNames::get_singleton()->changed, this, "_navigation_polygon_changed");
|
||||
}
|
||||
|
||||
navpoly = p_navpoly;
|
||||
Navigation2DServer::get_singleton()->region_set_navpoly(region, p_navpoly);
|
||||
navigation_polygon = p_navigation_polygon;
|
||||
Navigation2DServer::get_singleton()->region_set_navigation_polygon(region, p_navigation_polygon);
|
||||
|
||||
if (navpoly.is_valid()) {
|
||||
navpoly->connect(CoreStringNames::get_singleton()->changed, this, "_navigation_polygon_changed");
|
||||
if (navigation_polygon.is_valid()) {
|
||||
navigation_polygon->connect(CoreStringNames::get_singleton()->changed, this, "_navigation_polygon_changed");
|
||||
}
|
||||
|
||||
_navigation_polygon_changed();
|
||||
}
|
||||
|
||||
Ref<NavigationPolygon> NavigationPolygonInstance::get_navigation_polygon() const {
|
||||
return navpoly;
|
||||
return navigation_polygon;
|
||||
}
|
||||
|
||||
void NavigationPolygonInstance::set_navigation_map(RID p_navigation_map) {
|
||||
@ -319,24 +319,24 @@ void NavigationPolygonInstance::bake_navigation_polygon(bool p_on_thread) {
|
||||
}
|
||||
baking_started = true;
|
||||
|
||||
navpoly->clear();
|
||||
navigation_polygon->clear();
|
||||
if (p_on_thread && OS::get_singleton()->can_use_threads()) {
|
||||
Ref<FuncRef> f;
|
||||
f.instance();
|
||||
f->set_instance(this);
|
||||
f->set_function("_bake_finished");
|
||||
|
||||
NavigationMeshGenerator::get_singleton()->parse_and_bake_2d(navpoly, this, f);
|
||||
NavigationMeshGenerator::get_singleton()->parse_and_bake_2d(navigation_polygon, this, f);
|
||||
} else {
|
||||
Ref<NavigationMeshSourceGeometryData2D> source_geometry_data = NavigationMeshGenerator::get_singleton()->parse_2d_source_geometry_data(navpoly, this);
|
||||
NavigationMeshGenerator::get_singleton()->bake_2d_from_source_geometry_data(navpoly, source_geometry_data);
|
||||
Ref<NavigationMeshSourceGeometryData2D> source_geometry_data = NavigationMeshGenerator::get_singleton()->parse_2d_source_geometry_data(navigation_polygon, this);
|
||||
NavigationMeshGenerator::get_singleton()->bake_2d_from_source_geometry_data(navigation_polygon, source_geometry_data);
|
||||
_bake_finished();
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonInstance::_bake_finished() {
|
||||
baking_started = false;
|
||||
set_navigation_polygon(navpoly);
|
||||
set_navigation_polygon(navigation_polygon);
|
||||
emit_signal("bake_finished");
|
||||
}
|
||||
|
||||
@ -344,14 +344,14 @@ void NavigationPolygonInstance::_navigation_polygon_changed() {
|
||||
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) {
|
||||
update();
|
||||
}
|
||||
if (navpoly.is_valid()) {
|
||||
Navigation2DServer::get_singleton()->region_set_navpoly(region, navpoly);
|
||||
if (navigation_polygon.is_valid()) {
|
||||
Navigation2DServer::get_singleton()->region_set_navigation_polygon(region, navigation_polygon);
|
||||
}
|
||||
|
||||
_update_avoidance_constrain();
|
||||
|
||||
emit_signal("navigation_polygon_changed");
|
||||
_change_notify("navpoly");
|
||||
_change_notify("navigation_polygon");
|
||||
|
||||
update_configuration_warning();
|
||||
}
|
||||
@ -379,7 +379,7 @@ String NavigationPolygonInstance::get_configuration_warning() const {
|
||||
}
|
||||
|
||||
String warning = Node2D::get_configuration_warning();
|
||||
if (!navpoly.is_valid()) {
|
||||
if (!navigation_polygon.is_valid()) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
@ -415,7 +415,7 @@ void NavigationPolygonInstance::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_travel_cost", "travel_cost"), &NavigationPolygonInstance::set_travel_cost);
|
||||
ClassDB::bind_method(D_METHOD("get_travel_cost"), &NavigationPolygonInstance::get_travel_cost);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navpoly"), &NavigationPolygonInstance::set_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navigation_polygon"), &NavigationPolygonInstance::set_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationPolygonInstance::get_navigation_polygon);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationPolygonInstance::set_navigation_map);
|
||||
@ -426,7 +426,7 @@ void NavigationPolygonInstance::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_region_rid"), &NavigationPolygonInstance::get_region_rid);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navpoly", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"), "set_navigation_polygon", "get_navigation_polygon");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navigation_polygon", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"), "set_navigation_polygon", "get_navigation_polygon");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_edge_connections"), "set_use_edge_connections", "get_use_edge_connections");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
|
||||
@ -505,15 +505,15 @@ void NavigationPolygonInstance::_update_avoidance_constrain() {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<NavigationPolygon> _navpoly = get_navigation_polygon();
|
||||
int _outline_count = _navpoly->get_outline_count();
|
||||
Ref<NavigationPolygon> _navigation_polygon = get_navigation_polygon();
|
||||
int _outline_count = _navigation_polygon->get_outline_count();
|
||||
if (_outline_count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int outline_index(0); outline_index < _outline_count; outline_index++) {
|
||||
//TODO navpoly should probably use normal vectors internally
|
||||
const PoolVector<Vector2> &_outline = _navpoly->get_outline(outline_index);
|
||||
//TODO navigation_polygon should probably use normal vectors internally
|
||||
const PoolVector<Vector2> &_outline = _navigation_polygon->get_outline(outline_index);
|
||||
|
||||
Vector<Vector2> outline;
|
||||
outline.resize(_outline.size());
|
||||
@ -605,7 +605,7 @@ bool NavigationPolygonInstance::get_avoidance_layer_value(int p_layer_number) co
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
void NavigationPolygonInstance::_update_debug_mesh() {
|
||||
PoolVector<Vector2> navigation_polygon_vertices = navpoly->get_vertices();
|
||||
PoolVector<Vector2> navigation_polygon_vertices = navigation_polygon->get_vertices();
|
||||
if (navigation_polygon_vertices.size() < 3) {
|
||||
return;
|
||||
}
|
||||
@ -627,9 +627,9 @@ void NavigationPolygonInstance::_update_debug_mesh() {
|
||||
|
||||
RandomPCG rand;
|
||||
|
||||
for (int i = 0; i < navpoly->get_polygon_count(); i++) {
|
||||
for (int i = 0; i < navigation_polygon->get_polygon_count(); i++) {
|
||||
// An array of vertices for this polygon.
|
||||
Vector<int> polygon = navpoly->get_polygon(i);
|
||||
Vector<int> polygon = navigation_polygon->get_polygon(i);
|
||||
|
||||
Vector<Vector2> debug_polygon_vertices;
|
||||
debug_polygon_vertices.resize(polygon.size());
|
||||
|
@ -47,7 +47,7 @@ class NavigationPolygonInstance : public Node2D {
|
||||
RID region;
|
||||
RID map_override;
|
||||
Navigation2D *navigation;
|
||||
Ref<NavigationPolygon> navpoly;
|
||||
Ref<NavigationPolygon> navigation_polygon;
|
||||
bool baking_started;
|
||||
|
||||
real_t enter_cost;
|
||||
@ -101,7 +101,7 @@ public:
|
||||
void set_travel_cost(real_t p_travel_cost);
|
||||
real_t get_travel_cost() const;
|
||||
|
||||
void set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly);
|
||||
void set_navigation_polygon(const Ref<NavigationPolygon> &p_navigation_polygon);
|
||||
Ref<NavigationPolygon> get_navigation_polygon() const;
|
||||
|
||||
void set_constrain_avoidance(bool p_enabled);
|
||||
|
@ -245,21 +245,21 @@ void NavigationMeshInstance::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void NavigationMeshInstance::set_navigation_mesh(const Ref<NavigationMesh> &p_navigation_mesh) {
|
||||
if (navmesh.is_valid()) {
|
||||
navmesh->disconnect(CoreStringNames::get_singleton()->changed, this, "_navigation_mesh_changed");
|
||||
if (navigation_mesh.is_valid()) {
|
||||
navigation_mesh->disconnect(CoreStringNames::get_singleton()->changed, this, "_navigation_mesh_changed");
|
||||
}
|
||||
|
||||
navmesh = p_navigation_mesh;
|
||||
navigation_mesh = p_navigation_mesh;
|
||||
|
||||
if (navmesh.is_valid()) {
|
||||
navmesh->connect(CoreStringNames::get_singleton()->changed, this, "_navigation_mesh_changed");
|
||||
if (navigation_mesh.is_valid()) {
|
||||
navigation_mesh->connect(CoreStringNames::get_singleton()->changed, this, "_navigation_mesh_changed");
|
||||
}
|
||||
|
||||
_navigation_mesh_changed();
|
||||
}
|
||||
|
||||
Ref<NavigationMesh> NavigationMeshInstance::get_navigation_mesh() const {
|
||||
return navmesh;
|
||||
return navigation_mesh;
|
||||
}
|
||||
|
||||
void NavigationMeshInstance::set_navigation_map(RID p_navigation_map) {
|
||||
@ -289,7 +289,7 @@ void NavigationMeshInstance::bake_navigation_mesh(bool p_on_thread) {
|
||||
}
|
||||
baking_started = true;
|
||||
|
||||
navmesh->clear();
|
||||
navigation_mesh->clear();
|
||||
|
||||
if (p_on_thread && OS::get_singleton()->can_use_threads()) {
|
||||
Ref<FuncRef> f;
|
||||
@ -297,22 +297,22 @@ void NavigationMeshInstance::bake_navigation_mesh(bool p_on_thread) {
|
||||
f->set_instance(this);
|
||||
f->set_function("_bake_finished");
|
||||
|
||||
NavigationMeshGenerator::get_singleton()->parse_and_bake_3d(navmesh, this, f);
|
||||
NavigationMeshGenerator::get_singleton()->parse_and_bake_3d(navigation_mesh, this, f);
|
||||
} else {
|
||||
Ref<NavigationMeshSourceGeometryData3D> source_geometry_data = NavigationMeshGenerator::get_singleton()->parse_3d_source_geometry_data(navmesh, this);
|
||||
NavigationMeshGenerator::get_singleton()->bake_3d_from_source_geometry_data(navmesh, source_geometry_data);
|
||||
_bake_finished(navmesh);
|
||||
Ref<NavigationMeshSourceGeometryData3D> source_geometry_data = NavigationMeshGenerator::get_singleton()->parse_3d_source_geometry_data(navigation_mesh, this);
|
||||
NavigationMeshGenerator::get_singleton()->bake_3d_from_source_geometry_data(navigation_mesh, source_geometry_data);
|
||||
_bake_finished(navigation_mesh);
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationMeshInstance::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
|
||||
void NavigationMeshInstance::_bake_finished(Ref<NavigationMesh> p_navigation_mesh) {
|
||||
baking_started = false;
|
||||
set_navigation_mesh(p_nav_mesh);
|
||||
set_navigation_mesh(p_navigation_mesh);
|
||||
emit_signal("bake_finished");
|
||||
}
|
||||
|
||||
void NavigationMeshInstance::_navigation_mesh_changed() {
|
||||
NavigationServer::get_singleton()->region_set_navmesh(region, navmesh);
|
||||
NavigationServer::get_singleton()->region_set_navigation_mesh(region, navigation_mesh);
|
||||
|
||||
update_gizmos();
|
||||
update_configuration_warning();
|
||||
@ -321,7 +321,7 @@ void NavigationMeshInstance::_navigation_mesh_changed() {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (is_inside_tree() && NavigationServer::get_singleton()->get_debug_navigation_enabled()) {
|
||||
if (navmesh.is_valid()) {
|
||||
if (navigation_mesh.is_valid()) {
|
||||
_update_debug_mesh();
|
||||
_update_debug_edge_connections_mesh();
|
||||
} else {
|
||||
@ -349,7 +349,7 @@ String NavigationMeshInstance::get_configuration_warning() const {
|
||||
return String();
|
||||
}
|
||||
|
||||
if (!navmesh.is_valid()) {
|
||||
if (!navigation_mesh.is_valid()) {
|
||||
return TTR("A NavigationMesh resource must be set or created for this node to work.");
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ void NavigationMeshInstance::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_use_edge_connections", "enabled"), &NavigationMeshInstance::set_use_edge_connections);
|
||||
ClassDB::bind_method(D_METHOD("get_use_edge_connections"), &NavigationMeshInstance::get_use_edge_connections);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationMeshInstance::set_navigation_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navigation_mesh"), &NavigationMeshInstance::set_navigation_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationMeshInstance::get_navigation_mesh);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationMeshInstance::set_navigation_map);
|
||||
@ -393,7 +393,7 @@ void NavigationMeshInstance::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_navigation_map_changed"), &NavigationMeshInstance::_navigation_map_changed);
|
||||
#endif
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), "set_navigation_mesh", "get_navigation_mesh");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navigation_mesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), "set_navigation_mesh", "get_navigation_mesh");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_edge_connections"), "set_use_edge_connections", "get_use_edge_connections");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
|
||||
@ -436,8 +436,8 @@ NavigationMeshInstance::NavigationMeshInstance() {
|
||||
}
|
||||
|
||||
NavigationMeshInstance::~NavigationMeshInstance() {
|
||||
if (navmesh.is_valid()) {
|
||||
navmesh->disconnect(CoreStringNames::get_singleton()->changed, this, "_navigation_mesh_changed");
|
||||
if (navigation_mesh.is_valid()) {
|
||||
navigation_mesh->disconnect(CoreStringNames::get_singleton()->changed, this, "_navigation_mesh_changed");
|
||||
}
|
||||
|
||||
ERR_FAIL_NULL(NavigationServer::get_singleton());
|
||||
@ -480,7 +480,7 @@ void NavigationMeshInstance::_update_debug_mesh() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!navmesh.is_valid()) {
|
||||
if (!navigation_mesh.is_valid()) {
|
||||
if (debug_instance.is_valid()) {
|
||||
RS::get_singleton()->instance_set_visible(debug_instance, false);
|
||||
}
|
||||
@ -497,12 +497,12 @@ void NavigationMeshInstance::_update_debug_mesh() {
|
||||
|
||||
debug_mesh->clear_surfaces();
|
||||
|
||||
PoolVector<Vector3> vertices = navmesh->get_vertices();
|
||||
PoolVector<Vector3> vertices = navigation_mesh->get_vertices();
|
||||
if (vertices.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int polygon_count = navmesh->get_polygon_count();
|
||||
int polygon_count = navigation_mesh->get_polygon_count();
|
||||
if (polygon_count == 0) {
|
||||
return;
|
||||
}
|
||||
@ -514,7 +514,7 @@ void NavigationMeshInstance::_update_debug_mesh() {
|
||||
int line_count = 0;
|
||||
|
||||
for (int i = 0; i < polygon_count; i++) {
|
||||
const Vector<int> &polygon = navmesh->get_polygon(i);
|
||||
const Vector<int> &polygon = navigation_mesh->get_polygon(i);
|
||||
int polygon_size = polygon.size();
|
||||
if (polygon_size < 3) {
|
||||
continue;
|
||||
@ -549,7 +549,7 @@ void NavigationMeshInstance::_update_debug_mesh() {
|
||||
Vector3 *line_vertex_array_ptrw = line_vertex_array.ptrw();
|
||||
|
||||
for (int polygon_index = 0; polygon_index < polygon_count; polygon_index++) {
|
||||
const Vector<int> &polygon_indices = navmesh->get_polygon(polygon_index);
|
||||
const Vector<int> &polygon_indices = navigation_mesh->get_polygon(polygon_index);
|
||||
int polygon_indices_size = polygon_indices.size();
|
||||
if (polygon_indices_size < 3) {
|
||||
continue;
|
||||
@ -657,7 +657,7 @@ void NavigationMeshInstance::_update_debug_edge_connections_mesh() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!navmesh.is_valid()) {
|
||||
if (!navigation_mesh.is_valid()) {
|
||||
if (debug_edge_connections_instance.is_valid()) {
|
||||
RS::get_singleton()->instance_set_visible(debug_edge_connections_instance, false);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class NavigationMeshInstance : public Spatial {
|
||||
|
||||
RID region;
|
||||
RID map_override;
|
||||
Ref<NavigationMesh> navmesh;
|
||||
Ref<NavigationMesh> navigation_mesh;
|
||||
|
||||
Transform current_global_transform;
|
||||
|
||||
@ -94,7 +94,7 @@ public:
|
||||
void set_travel_cost(real_t p_travel_cost);
|
||||
real_t get_travel_cost() const;
|
||||
|
||||
void set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh);
|
||||
void set_navigation_mesh(const Ref<NavigationMesh> &p_navigation_mesh);
|
||||
Ref<NavigationMesh> get_navigation_mesh() const;
|
||||
|
||||
void set_navigation_map(RID p_navigation_map);
|
||||
@ -105,7 +105,7 @@ public:
|
||||
/// Bakes the navigation mesh; once done, automatically
|
||||
/// sets the new navigation mesh and emits a signal
|
||||
void bake_navigation_mesh(bool p_on_thread = true);
|
||||
void _bake_finished(Ref<NavigationMesh> p_nav_mesh);
|
||||
void _bake_finished(Ref<NavigationMesh> p_navigation_mesh);
|
||||
void _navigation_mesh_changed();
|
||||
|
||||
String get_configuration_warning() const;
|
||||
|
@ -225,13 +225,13 @@ float NavigationMesh::get_edge_max_error() const {
|
||||
return edge_max_error;
|
||||
}
|
||||
|
||||
void NavigationMesh::set_verts_per_poly(float p_value) {
|
||||
void NavigationMesh::set_vertices_per_polyon(float p_value) {
|
||||
ERR_FAIL_COND(p_value < 3);
|
||||
verts_per_poly = p_value;
|
||||
vertices_per_polyon = p_value;
|
||||
}
|
||||
|
||||
float NavigationMesh::get_verts_per_poly() const {
|
||||
return verts_per_poly;
|
||||
float NavigationMesh::get_vertices_per_polyon() const {
|
||||
return vertices_per_polyon;
|
||||
}
|
||||
|
||||
void NavigationMesh::set_detail_sample_distance(float p_value) {
|
||||
@ -331,19 +331,19 @@ void NavigationMesh::commit_changes() {
|
||||
if (navigation_mesh_dirty) {
|
||||
navigation_mesh_dirty = false;
|
||||
/*
|
||||
Vector<Vector3> new_navmesh_vertices;
|
||||
Vector<Vector<int32_t>> new_navmesh_polygons;
|
||||
new_navmesh_vertices.resize(vertices.size());
|
||||
new_navmesh_polygons.resize(polygons.size());
|
||||
Vector3 *new_navmesh_vertices_ptrw = new_navmesh_vertices.ptrw();
|
||||
Vector<int32_t> *new_navmesh_polygons_ptrw = new_navmesh_polygons.ptrw();
|
||||
Vector<Vector3> new_navigation_mesh_vertices;
|
||||
Vector<Vector<int32_t>> new_navigation_mesh_polygons;
|
||||
new_navigation_mesh_vertices.resize(vertices.size());
|
||||
new_navigation_mesh_polygons.resize(polygons.size());
|
||||
Vector3 *new_navigation_mesh_vertices_ptrw = new_navigation_mesh_vertices.ptrw();
|
||||
Vector<int32_t> *new_navigation_mesh_polygons_ptrw = new_navigation_mesh_polygons.ptrw();
|
||||
for (int i = 0; i < vertices.size(); i++) {
|
||||
new_navmesh_vertices_ptrw[i] = vertices[i];
|
||||
new_navigation_mesh_vertices_ptrw[i] = vertices[i];
|
||||
}
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
new_navmesh_polygons_ptrw[i] = polygons[i];
|
||||
new_navigation_mesh_polygons_ptrw[i] = polygons[i];
|
||||
}
|
||||
NavigationServer3D::get_singleton()->navmesh_set_data(navmesh_rid, new_navmesh_vertices, new_navmesh_polygons);
|
||||
NavigationServer3D::get_singleton()->navigation_mesh_set_data(navigation_mesh_rid, new_navigation_mesh_vertices, new_navigation_mesh_polygons);
|
||||
*/
|
||||
emit_changed();
|
||||
}
|
||||
@ -376,8 +376,8 @@ Array NavigationMesh::_get_polygons() const {
|
||||
}
|
||||
|
||||
RID NavigationMesh::get_rid() const {
|
||||
if (navmesh_rid.is_valid()) {
|
||||
return navmesh_rid;
|
||||
if (navigation_mesh_rid.is_valid()) {
|
||||
return navigation_mesh_rid;
|
||||
}
|
||||
return RID();
|
||||
}
|
||||
@ -526,8 +526,8 @@ void NavigationMesh::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_edge_max_error", "edge_max_error"), &NavigationMesh::set_edge_max_error);
|
||||
ClassDB::bind_method(D_METHOD("get_edge_max_error"), &NavigationMesh::get_edge_max_error);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_verts_per_poly", "verts_per_poly"), &NavigationMesh::set_verts_per_poly);
|
||||
ClassDB::bind_method(D_METHOD("get_verts_per_poly"), &NavigationMesh::get_verts_per_poly);
|
||||
ClassDB::bind_method(D_METHOD("set_vertices_per_polyon", "vertices_per_polyon"), &NavigationMesh::set_vertices_per_polyon);
|
||||
ClassDB::bind_method(D_METHOD("get_vertices_per_polyon"), &NavigationMesh::get_vertices_per_polyon);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_detail_sample_distance", "detail_sample_dist"), &NavigationMesh::set_detail_sample_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_detail_sample_distance"), &NavigationMesh::get_detail_sample_distance);
|
||||
@ -595,7 +595,7 @@ void NavigationMesh::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "edge_max_error", PROPERTY_HINT_RANGE, "0.1,3.0,0.01,or_greater"), "set_edge_max_error", "get_edge_max_error");
|
||||
|
||||
ADD_GROUP("Polygons", "polygon_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "polygon_verts_per_poly", PROPERTY_HINT_RANGE, "3.0,12.0,1.0,or_greater"), "set_verts_per_poly", "get_verts_per_poly");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "polygon_vertices_per_polyon", PROPERTY_HINT_RANGE, "3.0,12.0,1.0,or_greater"), "set_vertices_per_polyon", "get_vertices_per_polyon");
|
||||
|
||||
ADD_GROUP("Details", "detail_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "detail_sample_distance", PROPERTY_HINT_RANGE, "0.1,16.0,0.01,or_greater"), "set_detail_sample_distance", "get_detail_sample_distance");
|
||||
@ -651,7 +651,7 @@ NavigationMesh::NavigationMesh() {
|
||||
region_merge_size = 20.0f;
|
||||
edge_max_length = 0.0f;
|
||||
edge_max_error = 1.3f;
|
||||
verts_per_poly = 6.0f;
|
||||
vertices_per_polyon = 6.0f;
|
||||
detail_sample_distance = 6.0f;
|
||||
detail_sample_max_error = 5.0f;
|
||||
|
||||
@ -659,18 +659,18 @@ NavigationMesh::NavigationMesh() {
|
||||
parsed_geometry_type = PARSED_GEOMETRY_MESH_INSTANCES;
|
||||
collision_mask = 0xFFFFFFFF;
|
||||
source_geometry_mode = SOURCE_GEOMETRY_ROOT_NODE_CHILDREN;
|
||||
source_group_name = "navmesh";
|
||||
source_group_name = "navigation_mesh";
|
||||
filter_low_hanging_obstacles = false;
|
||||
filter_ledge_spans = false;
|
||||
filter_walkable_low_height_spans = false;
|
||||
|
||||
navigation_mesh_dirty = true;
|
||||
|
||||
//navmesh_rid = NavigationServer3D::get_singleton()->navmesh_create();
|
||||
//navigation_mesh_rid = NavigationServer3D::get_singleton()->navigation_mesh_create();
|
||||
call_deferred("commit_changes");
|
||||
}
|
||||
|
||||
NavigationMesh::~NavigationMesh() {
|
||||
//ERR_FAIL_NULL(NavigationServer::get_singleton());
|
||||
//NavigationServer::get_singleton()->free(navmesh_rid);
|
||||
//NavigationServer::get_singleton()->free(navigation_mesh_rid);
|
||||
}
|
@ -112,8 +112,8 @@ public:
|
||||
void set_edge_max_error(float p_value);
|
||||
float get_edge_max_error() const;
|
||||
|
||||
void set_verts_per_poly(float p_value);
|
||||
float get_verts_per_poly() const;
|
||||
void set_vertices_per_polyon(float p_value);
|
||||
float get_vertices_per_polyon() const;
|
||||
|
||||
void set_detail_sample_distance(float p_value);
|
||||
float get_detail_sample_distance() const;
|
||||
@ -178,7 +178,7 @@ protected:
|
||||
float region_merge_size;
|
||||
float edge_max_length;
|
||||
float edge_max_error;
|
||||
float verts_per_poly;
|
||||
float vertices_per_polyon;
|
||||
float detail_sample_distance;
|
||||
float detail_sample_max_error;
|
||||
|
||||
@ -196,7 +196,7 @@ protected:
|
||||
Vector3 filter_baking_aabb_offset;
|
||||
|
||||
private:
|
||||
RID navmesh_rid;
|
||||
RID navigation_mesh_rid;
|
||||
|
||||
PoolVector<Vector3> vertices;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
// kept root node transform here on the geometry data
|
||||
// if we add this transform to all exposed functions we need to break comp on all functions later
|
||||
// when navmesh changes from global transfrom to relative to navregion
|
||||
// when navigation_mesh changes from global transfrom to relative to navregion
|
||||
// but if it stays here we can just remove it and change the internal functions only
|
||||
Transform2D root_node_transform;
|
||||
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
public:
|
||||
// kept root node transform here on the geometry data
|
||||
// if we add this transform to all exposed functions we need to break comp on all functions later
|
||||
// when navmesh changes from global transfrom to relative to navregion
|
||||
// when navigation_mesh changes from global transfrom to relative to navregion
|
||||
// but if it stays here we can just remove it and change the internal functions only
|
||||
Transform root_node_transform;
|
||||
|
||||
|
@ -153,7 +153,7 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
RID navmesh_rid;
|
||||
RID navigation_mesh_rid;
|
||||
|
||||
real_t agent_radius;
|
||||
|
||||
|
@ -78,7 +78,7 @@ void Navigation2DServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("region_set_navigation_layers", "region", "navigation_layers"), &Navigation2DServer::region_set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("region_get_navigation_layers", "region"), &Navigation2DServer::region_get_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &Navigation2DServer::region_set_transform);
|
||||
ClassDB::bind_method(D_METHOD("region_set_navpoly", "region", "nav_poly"), &Navigation2DServer::region_set_navpoly);
|
||||
ClassDB::bind_method(D_METHOD("region_set_navigation_polygon", "region", "nav_poly"), &Navigation2DServer::region_set_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("region_get_connections_count", "region"), &Navigation2DServer::region_get_connections_count);
|
||||
ClassDB::bind_method(D_METHOD("region_get_connection_pathway_start", "region", "connection"), &Navigation2DServer::region_get_connection_pathway_start);
|
||||
ClassDB::bind_method(D_METHOD("region_get_connection_pathway_end", "region", "connection"), &Navigation2DServer::region_get_connection_pathway_end);
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
virtual void region_set_transform(RID p_region, Transform2D p_transform) = 0;
|
||||
|
||||
/// Set the navigation poly of this region.
|
||||
virtual void region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) = 0;
|
||||
virtual void region_set_navigation_polygon(RID p_region, Ref<NavigationPolygon> p_navigation_mesh) = 0;
|
||||
|
||||
/// Get a list of a region's connection to other regions.
|
||||
virtual int region_get_connections_count(RID p_region) const = 0;
|
||||
|
@ -99,7 +99,7 @@ void NavigationServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("region_get_navigation_layers", "region"), &NavigationServer::region_get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer::region_set_transform);
|
||||
ClassDB::bind_method(D_METHOD("region_set_navmesh", "region", "nav_mesh"), &NavigationServer::region_set_navmesh);
|
||||
ClassDB::bind_method(D_METHOD("region_set_navigation_mesh", "region", "navigation_mesh"), &NavigationServer::region_set_navigation_mesh);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("region_get_connections_count", "region"), &NavigationServer::region_get_connections_count);
|
||||
ClassDB::bind_method(D_METHOD("region_get_connection_pathway_start", "region", "connection"), &NavigationServer::region_get_connection_pathway_start);
|
||||
@ -241,7 +241,7 @@ NavigationServer::NavigationServer() {
|
||||
_debug_navigation_avoidance_enable_obstacles_static = GLOBAL_DEF("debug/shapes/avoidance/enable_obstacles_static", true);
|
||||
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
// enable NavigationServer when in Editor or else navmesh edge connections are invisible
|
||||
// enable NavigationServer when in Editor or else navigation_mesh edge connections are invisible
|
||||
// on runtime tests SceneTree has "Visible Navigation" set and main iteration takes care of this
|
||||
set_debug_enabled(true);
|
||||
set_debug_navigation_enabled(true);
|
||||
|
@ -150,7 +150,7 @@ public:
|
||||
virtual void region_set_transform(RID p_region, Transform p_transform) = 0;
|
||||
|
||||
/// Set the navigation mesh of this region.
|
||||
virtual void region_set_navmesh(RID p_region, Ref<NavigationMesh> p_nav_mesh) = 0;
|
||||
virtual void region_set_navigation_mesh(RID p_region, Ref<NavigationMesh> p_navigation_mesh) = 0;
|
||||
|
||||
/// Get a list of a region's connection to other regions.
|
||||
virtual int region_get_connections_count(RID p_region) const = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user