mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-23 17:47:17 +01:00
Backported from godot4: Fix typo and ensure backwards compatibility for changed property names
Changes to the name of the `navmesh` and `navpoly` properties on
`NavigationRegion` caused navigation data to be lost on load.
This PR creates uses `_set`/`_get` to handle compatibility with the
older names on load, preserving the data.
Also fixes a typo on `get_vertices_per_polygon` in `NavigationMesh`,
and renames the property to remove the `polygon_` prefix which doesn't
match the setter/getter.
- DarkKilauea, akien-mga
0572346985
This commit is contained in:
parent
6f3b1fac57
commit
43c11fcdf5
@ -147,7 +147,7 @@
|
|||||||
The name of the group to scan for geometry.
|
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].
|
Only used when [member geometry_source_geometry_mode] is [constant SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN] or [constant SOURCE_GEOMETRY_GROUPS_EXPLICIT].
|
||||||
</member>
|
</member>
|
||||||
<member name="polygon_vertices_per_polyon" type="float" setter="set_vertices_per_polyon" getter="get_vertices_per_polyon" default="6.0">
|
<member name="polygon_vertices_per_polygon" type="float" setter="set_vertices_per_polygon" getter="get_vertices_per_polygon" default="6.0">
|
||||||
The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.
|
The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.
|
||||||
</member>
|
</member>
|
||||||
<member name="region_merge_size" type="float" setter="set_region_merge_size" getter="get_region_merge_size" default="20.0">
|
<member name="region_merge_size" type="float" setter="set_region_merge_size" getter="get_region_merge_size" default="20.0">
|
||||||
|
@ -62,6 +62,12 @@ bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
|
|||||||
set_item_navigation_mesh(idx, p_value);
|
set_item_navigation_mesh(idx, p_value);
|
||||||
} else if (what == "navigation_mesh_transform") {
|
} else if (what == "navigation_mesh_transform") {
|
||||||
set_item_navigation_mesh_transform(idx, p_value);
|
set_item_navigation_mesh_transform(idx, p_value);
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
} else if (what == "navmesh") { // Renamed after 4.0
|
||||||
|
set_item_navigation_mesh(idx, p_value);
|
||||||
|
} else if (what == "navmesh_transform") { // Renamed after 4.0
|
||||||
|
set_item_navigation_mesh_transform(idx, p_value);
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -90,6 +96,12 @@ bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const {
|
|||||||
r_ret = get_item_navigation_mesh(idx);
|
r_ret = get_item_navigation_mesh(idx);
|
||||||
} else if (what == "navigation_mesh_transform") {
|
} else if (what == "navigation_mesh_transform") {
|
||||||
r_ret = get_item_navigation_mesh_transform(idx);
|
r_ret = get_item_navigation_mesh_transform(idx);
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
} else if (what == "navmesh") { // Renamed after 4.0
|
||||||
|
r_ret = get_item_navigation_mesh(idx);
|
||||||
|
} else if (what == "navmesh_transform") { // Renamed after 4.0
|
||||||
|
r_ret = get_item_navigation_mesh_transform(idx);
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
} else if (what == "preview") {
|
} else if (what == "preview") {
|
||||||
r_ret = get_item_preview(idx);
|
r_ret = get_item_preview(idx);
|
||||||
} else {
|
} else {
|
||||||
|
@ -598,7 +598,7 @@ void PandemoniumNavigationMeshGenerator::_static_bake_3d_from_source_geometry_da
|
|||||||
cfg.maxSimplificationError = p_navigation_mesh->get_edge_max_error();
|
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.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.mergeRegionArea = (int)(p_navigation_mesh->get_region_merge_size() * p_navigation_mesh->get_region_merge_size());
|
||||||
cfg.maxVertsPerPoly = (int)p_navigation_mesh->get_vertices_per_polyon();
|
cfg.maxVertsPerPoly = (int)p_navigation_mesh->get_vertices_per_polygon();
|
||||||
cfg.detailSampleDist = MAX(p_navigation_mesh->get_cell_size() * p_navigation_mesh->get_detail_sample_distance(), 0.1f);
|
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();
|
cfg.detailSampleMaxError = p_navigation_mesh->get_cell_height() * p_navigation_mesh->get_detail_sample_max_error();
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
|
|||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||||
set_physics_process_internal(false);
|
set_physics_process_internal(false);
|
||||||
|
|
||||||
_region_update_transform();
|
_region_update_transform();
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
@ -371,6 +371,25 @@ void NavigationPolygonInstance::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("bake_finished"));
|
ADD_SIGNAL(MethodInfo("bake_finished"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
//Renamed after 4.0
|
||||||
|
bool NavigationPolygonInstance::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
|
if (p_name == "navpoly") {
|
||||||
|
set_navigation_polygon(p_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NavigationPolygonInstance::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
|
if (p_name == "navpoly") {
|
||||||
|
r_ret = get_navigation_polygon();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
NavigationPolygonInstance::NavigationPolygonInstance() {
|
NavigationPolygonInstance::NavigationPolygonInstance() {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
use_edge_connections = true;
|
use_edge_connections = true;
|
||||||
|
@ -75,6 +75,11 @@ protected:
|
|||||||
void _validate_property(PropertyInfo &p_property) const;
|
void _validate_property(PropertyInfo &p_property) const;
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool _set(const StringName &p_name, const Variant &p_value);
|
||||||
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
virtual Rect2 _edit_get_rect() const;
|
virtual Rect2 _edit_get_rect() const;
|
||||||
|
@ -349,6 +349,25 @@ void NavigationMeshInstance::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("bake_finished"));
|
ADD_SIGNAL(MethodInfo("bake_finished"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
//Renamed after 4.0
|
||||||
|
bool NavigationMeshInstance::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
|
if (p_name == "navmesh") {
|
||||||
|
set_navigation_mesh(p_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NavigationMeshInstance::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
|
if (p_name == "navmesh") {
|
||||||
|
r_ret = get_navigation_mesh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
void NavigationMeshInstance::_changed_callback(Object *p_changed, const char *p_prop) {
|
void NavigationMeshInstance::_changed_callback(Object *p_changed, const char *p_prop) {
|
||||||
update_gizmos();
|
update_gizmos();
|
||||||
update_configuration_warning();
|
update_configuration_warning();
|
||||||
|
@ -75,6 +75,11 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _changed_callback(Object *p_changed, const char *p_prop);
|
void _changed_callback(Object *p_changed, const char *p_prop);
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool _set(const StringName &p_name, const Variant &p_value);
|
||||||
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_enabled(bool p_enabled);
|
void set_enabled(bool p_enabled);
|
||||||
bool is_enabled() const;
|
bool is_enabled() const;
|
||||||
|
@ -225,13 +225,13 @@ float NavigationMesh::get_edge_max_error() const {
|
|||||||
return edge_max_error;
|
return edge_max_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationMesh::set_vertices_per_polyon(float p_value) {
|
void NavigationMesh::set_vertices_per_polygon(float p_value) {
|
||||||
ERR_FAIL_COND(p_value < 3);
|
ERR_FAIL_COND(p_value < 3);
|
||||||
vertices_per_polyon = p_value;
|
vertices_per_polygon = p_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float NavigationMesh::get_vertices_per_polyon() const {
|
float NavigationMesh::get_vertices_per_polygon() const {
|
||||||
return vertices_per_polyon;
|
return vertices_per_polygon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationMesh::set_detail_sample_distance(float p_value) {
|
void NavigationMesh::set_detail_sample_distance(float p_value) {
|
||||||
@ -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("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("get_edge_max_error"), &NavigationMesh::get_edge_max_error);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_vertices_per_polyon", "vertices_per_polyon"), &NavigationMesh::set_vertices_per_polyon);
|
ClassDB::bind_method(D_METHOD("set_vertices_per_polygon", "vertices_per_polygon"), &NavigationMesh::set_vertices_per_polygon);
|
||||||
ClassDB::bind_method(D_METHOD("get_vertices_per_polyon"), &NavigationMesh::get_vertices_per_polyon);
|
ClassDB::bind_method(D_METHOD("get_vertices_per_polygon"), &NavigationMesh::get_vertices_per_polygon);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_detail_sample_distance", "detail_sample_dist"), &NavigationMesh::set_detail_sample_distance);
|
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);
|
ClassDB::bind_method(D_METHOD("get_detail_sample_distance"), &NavigationMesh::get_detail_sample_distance);
|
||||||
@ -594,8 +594,8 @@ void NavigationMesh::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "edge_max_length", PROPERTY_HINT_RANGE, "0.0,50.0,0.01,or_greater"), "set_edge_max_length", "get_edge_max_length");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "edge_max_length", PROPERTY_HINT_RANGE, "0.0,50.0,0.01,or_greater"), "set_edge_max_length", "get_edge_max_length");
|
||||||
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_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_GROUP("Polygons", "");
|
||||||
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_PROPERTY(PropertyInfo(Variant::REAL, "vertices_per_polygon", PROPERTY_HINT_RANGE, "3.0,12.0,1.0,or_greater"), "set_vertices_per_polygon", "get_vertices_per_polygon");
|
||||||
|
|
||||||
ADD_GROUP("Details", "detail_");
|
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");
|
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");
|
||||||
@ -640,6 +640,25 @@ void NavigationMesh::_validate_property(PropertyInfo &property) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
//Renamed after 4.0
|
||||||
|
bool NavigationMesh::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
|
if (p_name == "polygon_vertices_per_polyon") { // Renamed after 4.0
|
||||||
|
set_vertices_per_polygon(p_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NavigationMesh::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
|
if (p_name == "polygon_vertices_per_polyon") { // Renamed after 4.0
|
||||||
|
r_ret = get_vertices_per_polygon();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
NavigationMesh::NavigationMesh() {
|
NavigationMesh::NavigationMesh() {
|
||||||
cell_size = 0.25f; // Must match ProjectSettings default 3D cell_size and NavigationServer NavMap cell_size.
|
cell_size = 0.25f; // Must match ProjectSettings default 3D cell_size and NavigationServer NavMap cell_size.
|
||||||
cell_height = 0.25f; // Must match ProjectSettings default 3D cell_height and NavigationServer NavMap cell_height.
|
cell_height = 0.25f; // Must match ProjectSettings default 3D cell_height and NavigationServer NavMap cell_height.
|
||||||
@ -651,7 +670,7 @@ NavigationMesh::NavigationMesh() {
|
|||||||
region_merge_size = 20.0f;
|
region_merge_size = 20.0f;
|
||||||
edge_max_length = 0.0f;
|
edge_max_length = 0.0f;
|
||||||
edge_max_error = 1.3f;
|
edge_max_error = 1.3f;
|
||||||
vertices_per_polyon = 6.0f;
|
vertices_per_polygon = 6.0f;
|
||||||
detail_sample_distance = 6.0f;
|
detail_sample_distance = 6.0f;
|
||||||
detail_sample_max_error = 5.0f;
|
detail_sample_max_error = 5.0f;
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ public:
|
|||||||
void set_edge_max_error(float p_value);
|
void set_edge_max_error(float p_value);
|
||||||
float get_edge_max_error() const;
|
float get_edge_max_error() const;
|
||||||
|
|
||||||
void set_vertices_per_polyon(float p_value);
|
void set_vertices_per_polygon(float p_value);
|
||||||
float get_vertices_per_polyon() const;
|
float get_vertices_per_polygon() const;
|
||||||
|
|
||||||
void set_detail_sample_distance(float p_value);
|
void set_detail_sample_distance(float p_value);
|
||||||
float get_detail_sample_distance() const;
|
float get_detail_sample_distance() const;
|
||||||
@ -168,6 +168,11 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
virtual void _validate_property(PropertyInfo &property) const;
|
virtual void _validate_property(PropertyInfo &property) const;
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool _set(const StringName &p_name, const Variant &p_value);
|
||||||
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
float cell_size;
|
float cell_size;
|
||||||
float cell_height;
|
float cell_height;
|
||||||
float agent_height;
|
float agent_height;
|
||||||
@ -178,7 +183,7 @@ protected:
|
|||||||
float region_merge_size;
|
float region_merge_size;
|
||||||
float edge_max_length;
|
float edge_max_length;
|
||||||
float edge_max_error;
|
float edge_max_error;
|
||||||
float vertices_per_polyon;
|
float vertices_per_polygon;
|
||||||
float detail_sample_distance;
|
float detail_sample_distance;
|
||||||
float detail_sample_max_error;
|
float detail_sample_max_error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user