Skip to content

Commit

Permalink
Merge pull request #60811 from smix8/astar_zero_point_weight_4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored May 6, 2022
2 parents f70085a + 868fe49 commit f70dd61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/math/a_star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/AStar2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/AStar3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit f70dd61

Please sign in to comment.