Ported: Improve error messages and classref for occluders and portals

Misused functions would previously produce no error messages which was confusing for users.
- lawnjelly
5a0cb54b3a
This commit is contained in:
Relintai 2023-02-07 02:28:29 +01:00
parent 2e7ee5cef6
commit 1f20512f8c
6 changed files with 25 additions and 30 deletions

View File

@ -17,7 +17,8 @@
<argument index="0" name="index" type="int" />
<argument index="1" name="position" type="Vector2" />
<description>
Sets individual points. Primarily for use by the editor.
Sets individual points.
[b]Note:[/b] This function will not resize the point array. Set [member points] to set the number of points.
</description>
</method>
</methods>

View File

@ -18,7 +18,8 @@
<argument index="0" name="index" type="int" />
<argument index="1" name="position" type="Vector3" />
<description>
Sets individual points. Primarily for use by the editor.
Sets individual points.
[b]Note:[/b] This function will not resize the point array. Set [member points] to set the number of points.
</description>
</method>
</methods>

View File

@ -117,9 +117,7 @@ String Portal::get_configuration_warning() const {
}
void Portal::set_point(int p_idx, const Vector2 &p_point) {
if (p_idx >= _pts_local_raw.size()) {
return;
}
ERR_FAIL_INDEX_MSG(p_idx, _pts_local_raw.size(), "Index out of bounds. Call set_points() to set the size of the array.");
_pts_local_raw.set(p_idx, p_point);
_sanitize_points();

View File

@ -132,9 +132,7 @@ void Room::set_use_default_simplify(bool p_use) {
}
void Room::set_point(int p_idx, const Vector3 &p_point) {
if (p_idx >= _bound_pts.size()) {
return;
}
ERR_FAIL_INDEX_MSG(p_idx, _bound_pts.size(), "Index out of bounds. Call set_points() to set the size of the array.");
_bound_pts.set(p_idx, p_point);

View File

@ -210,20 +210,22 @@ void OccluderShapeSphere::set_spheres(const Vector<Plane> &p_spheres) {
}
void OccluderShapeSphere::set_sphere_position(int p_idx, const Vector3 &p_position) {
if ((p_idx >= 0) && (p_idx < _spheres.size())) {
ERR_FAIL_INDEX(p_idx, _spheres.size());
Plane p = _spheres[p_idx];
p.normal = p_position;
_spheres.set(p_idx, p);
#ifdef TOOLS_ENABLED
_update_aabb();
#endif
update_shape_to_rendering_server();
notify_change_to_owners();
}
}
void OccluderShapeSphere::set_sphere_radius(int p_idx, real_t p_radius) {
if ((p_idx >= 0) && (p_idx < _spheres.size())) {
ERR_FAIL_INDEX(p_idx, _spheres.size());
Plane p = _spheres[p_idx];
p.d = MAX(p_radius, _min_radius);
_spheres.set(p_idx, p);
@ -232,7 +234,6 @@ void OccluderShapeSphere::set_sphere_radius(int p_idx, real_t p_radius) {
#endif
update_shape_to_rendering_server();
notify_change_to_owners();
}
}
OccluderShapeSphere::OccluderShapeSphere() {

View File

@ -102,9 +102,7 @@ void OccluderShapePolygon::_sanitize_points() {
}
void OccluderShapePolygon::set_polygon_point(int p_idx, const Vector2 &p_point) {
if (p_idx >= _poly_pts_local_raw.size()) {
return;
}
ERR_FAIL_INDEX_MSG(p_idx, _poly_pts_local_raw.size(), "Index out of bounds. Call set_polygon_points() to set the size of the array.");
_poly_pts_local_raw.set(p_idx, p_point);
_sanitize_points();
@ -113,9 +111,7 @@ void OccluderShapePolygon::set_polygon_point(int p_idx, const Vector2 &p_point)
}
void OccluderShapePolygon::set_hole_point(int p_idx, const Vector2 &p_point) {
if (p_idx >= _hole_pts_local_raw.size()) {
return;
}
ERR_FAIL_INDEX_MSG(p_idx, _hole_pts_local_raw.size(), "Index out of bounds. Call set_hole_points() to set the size of the array.");
_hole_pts_local_raw.set(p_idx, p_point);
_sanitize_points();