summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmix8 <52464204+smix8@users.noreply.github.com>2022-05-06 02:33:10 +0200
committersmix8 <52464204+smix8@users.noreply.github.com>2022-05-06 02:33:10 +0200
commit868fe4942c70267387a116f2ce57d7bf1a7bbd5e (patch)
tree0cd0e2f64a37218c6fd385e7ac98f46fcb6cc8f5
parent066692b6d081f1577bc0ebcd84da204339218ec6 (diff)
Allow AStar2D/AStar3D zero point weight
Allow AStar2D/AStar3D zero point weight. Limit was set to 1 which seemed like an arbitrary value as lower values down to zero can be useful for common gameplay navigation elements like teleports.
-rw-r--r--core/math/a_star.cpp4
-rw-r--r--doc/classes/AStar2D.xml2
-rw-r--r--doc/classes/AStar3D.xml2
3 files changed, 4 insertions, 4 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 4212b43621..284b4294ea 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -47,7 +47,7 @@ int AStar3D::get_available_point_id() const {
void AStar3D::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) {
ERR_FAIL_COND_MSG(p_id < 0, vformat("Can't add a point with negative id: %d.", p_id));
- ERR_FAIL_COND_MSG(p_weight_scale < 1, vformat("Can't add a point with weight scale less than one: %f.", p_weight_scale));
+ ERR_FAIL_COND_MSG(p_weight_scale < 0.0, vformat("Can't add a point with weight scale less than 0.0: %f.", p_weight_scale));
Point *found_pt;
bool p_exists = points.lookup(p_id, found_pt);
@@ -96,7 +96,7 @@ void AStar3D::set_point_weight_scale(int p_id, real_t p_weight_scale) {
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND_MSG(!p_exists, vformat("Can't set point's weight scale. Point with id: %d doesn't exist.", p_id));
- ERR_FAIL_COND_MSG(p_weight_scale < 1, vformat("Can't set point's weight scale less than one: %f.", p_weight_scale));
+ ERR_FAIL_COND_MSG(p_weight_scale < 0.0, vformat("Can't set point's weight scale less than 0.0: %f.", p_weight_scale));
p->weight_scale = p_weight_scale;
}
diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml
index 4b65a64389..7a27568d30 100644
--- a/doc/classes/AStar2D.xml
+++ b/doc/classes/AStar2D.xml
@@ -33,7 +33,7 @@
<argument index="1" name="position" type="Vector2" />
<argument index="2" name="weight_scale" type="float" default="1.0" />
<description>
- Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger.
+ Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 0.0 or greater.
The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [code]weight_scale[/code]s to form a path.
[codeblocks]
[gdscript]
diff --git a/doc/classes/AStar3D.xml b/doc/classes/AStar3D.xml
index 3087b9e363..33407c3e74 100644
--- a/doc/classes/AStar3D.xml
+++ b/doc/classes/AStar3D.xml
@@ -62,7 +62,7 @@
<argument index="1" name="position" type="Vector3" />
<argument index="2" name="weight_scale" type="float" default="1.0" />
<description>
- Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger.
+ Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 0.0 or greater.
The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [code]weight_scale[/code]s to form a path.
[codeblocks]
[gdscript]