From 26ff340d47e3ee547dfe71211300bf1bb2c847d2 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 5 Jun 2023 19:21:59 +0200 Subject: [PATCH] Reorganized NavigationMesh. --- scene/resources/navigation_mesh.cpp | 36 ++++++------ scene/resources/navigation_mesh.h | 90 ++++++++++++++--------------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp index 5575ea0e0..7fce675b8 100644 --- a/scene/resources/navigation_mesh.cpp +++ b/scene/resources/navigation_mesh.cpp @@ -303,24 +303,6 @@ PoolVector NavigationMesh::get_vertices() const { return vertices; } -void NavigationMesh::_set_polygons(const Array &p_array) { - polygons.resize(p_array.size()); - for (int i = 0; i < p_array.size(); i++) { - polygons.write[i] = p_array[i]; - } - _change_notify(); -} - -Array NavigationMesh::_get_polygons() const { - Array ret; - ret.resize(polygons.size()); - for (int i = 0; i < ret.size(); i++) { - ret[i] = polygons[i]; - } - - return ret; -} - void NavigationMesh::add_polygon(const Vector &p_polygon) { polygons.push_back(p_polygon); navigation_mesh_dirty = true; @@ -375,6 +357,24 @@ const Vector> &NavigationMesh::get_polygons() const { return polygons; } +void NavigationMesh::_set_polygons(const Array &p_array) { + polygons.resize(p_array.size()); + for (int i = 0; i < p_array.size(); i++) { + polygons.write[i] = p_array[i]; + } + _change_notify(); +} + +Array NavigationMesh::_get_polygons() const { + Array ret; + ret.resize(polygons.size()); + for (int i = 0; i < ret.size(); i++) { + ret[i] = polygons[i]; + } + + return ret; +} + RID NavigationMesh::get_rid() const { if (navmesh_rid.is_valid()) { return navmesh_rid; diff --git a/scene/resources/navigation_mesh.h b/scene/resources/navigation_mesh.h index 4c972dc39..ee2768a0e 100644 --- a/scene/resources/navigation_mesh.h +++ b/scene/resources/navigation_mesh.h @@ -40,23 +40,6 @@ class NavigationMesh : public Resource { friend class NavigationMeshGenerator; - RID navmesh_rid; - - PoolVector vertices; - - Vector> polygons; - - Ref debug_mesh; - - bool navigation_mesh_dirty; - -protected: - static void _bind_methods(); - virtual void _validate_property(PropertyInfo &property) const; - - void _set_polygons(const Array &p_array); - Array _get_polygons() const; - public: enum SamplePartitionType { SAMPLE_PARTITION_WATERSHED = 0, @@ -79,34 +62,6 @@ public: SOURCE_GEOMETRY_MAX }; -protected: - float cell_size; - float cell_height; - float agent_height; - float agent_radius; - float agent_max_climb; - float agent_max_slope; - float region_min_size; - float region_merge_size; - float edge_max_length; - float edge_max_error; - float verts_per_poly; - float detail_sample_distance; - float detail_sample_max_error; - - SamplePartitionType partition_type; - ParsedGeometryType parsed_geometry_type; - uint32_t collision_mask; - - SourceGeometryMode source_geometry_mode; - StringName source_group_name; - - bool filter_low_hanging_obstacles; - bool filter_ledge_spans; - bool filter_walkable_low_height_spans; - AABB filter_baking_aabb; - Vector3 filter_baking_aabb_offset; - public: // Recast settings void set_sample_partition_type(SamplePartitionType p_value); @@ -197,6 +152,9 @@ public: void set_polygons(const Vector> &p_polygons); const Vector> &get_polygons() const; + void _set_polygons(const Array &p_array); + Array _get_polygons() const; + RID get_rid() const; #ifdef DEBUG_ENABLED @@ -205,6 +163,48 @@ public: NavigationMesh(); ~NavigationMesh(); + +protected: + static void _bind_methods(); + virtual void _validate_property(PropertyInfo &property) const; + + float cell_size; + float cell_height; + float agent_height; + float agent_radius; + float agent_max_climb; + float agent_max_slope; + float region_min_size; + float region_merge_size; + float edge_max_length; + float edge_max_error; + float verts_per_poly; + float detail_sample_distance; + float detail_sample_max_error; + + SamplePartitionType partition_type; + ParsedGeometryType parsed_geometry_type; + uint32_t collision_mask; + + SourceGeometryMode source_geometry_mode; + StringName source_group_name; + + bool filter_low_hanging_obstacles; + bool filter_ledge_spans; + bool filter_walkable_low_height_spans; + AABB filter_baking_aabb; + Vector3 filter_baking_aabb_offset; + +private: + RID navmesh_rid; + + PoolVector vertices; + + Vector> polygons; + + Ref debug_mesh; + + bool navigation_mesh_dirty; }; VARIANT_ENUM_CAST(NavigationMesh::SamplePartitionType);