You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ERR_FAIL_COND_MSG(dirty, "Grid is not initialized. Call the update method.");
160
+
ERR_FAIL_COND_MSG(!is_in_boundsv(p_id), vformat("Can't set point's weight scale. Point out of bounds (%s/%s, %s/%s).", p_id.x, size.width, p_id.y, size.height));
161
+
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));
ERR_FAIL_COND_V_MSG(dirty, 0, "Grid is not initialized. Call the update method.");
167
+
ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_id), 0, vformat("Can't get point's weight scale. Point out of bounds (%s/%s, %s/%s).", p_id.x, size.width, p_id.y, size.height));
168
+
return points[p_id.y][p_id.x].weight_scale;
169
+
}
170
+
158
171
AStarGrid2D::Point *AStarGrid2D::_jump(Point *p_from, Point *p_to) {
159
172
if (!p_to || p_to->solid) {
160
173
returnnullptr;
@@ -388,7 +401,10 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point) {
388
401
_get_nbors(p, nbors);
389
402
for (List<Point *>::Element *E = nbors.front(); E; E = E->next()) {
390
403
Point *e = E->get(); // The neighbour point.
404
+
real_t weight_scale = 1.0;
405
+
391
406
if (jumping_enabled) {
407
+
// TODO: Make it works with weight_scale.
392
408
e = _jump(p, e);
393
409
if (!e || e->closed_pass == pass) {
394
410
continue;
@@ -397,9 +413,10 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point) {
Returns the weight scale of the point associated with the given [param id].
77
+
</description>
78
+
</method>
72
79
<methodname="is_dirty"qualifiers="const">
73
80
<returntype="bool" />
74
81
<description>
@@ -106,6 +113,15 @@
106
113
[b]Note:[/b] Calling [method update] is not needed after the call of this function.
107
114
</description>
108
115
</method>
116
+
<methodname="set_point_weight_scale">
117
+
<returntype="void" />
118
+
<paramindex="0"name="id"type="Vector2i" />
119
+
<paramindex="1"name="weight_scale"type="float" />
120
+
<description>
121
+
Sets the [param weight_scale] for the point with the given [param id]. The [param weight_scale] 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.
122
+
[b]Note:[/b] Calling [method update] is not needed after the call of this function.
The offset of the grid which will be applied to calculate the resulting point position returned by [method get_point_path]. If changed, [method update] needs to be called before finding the next path.
0 commit comments