diff --git a/doc/classes/Portal.xml b/doc/classes/Portal.xml index 5b6ad44bb..8a83020f1 100644 --- a/doc/classes/Portal.xml +++ b/doc/classes/Portal.xml @@ -17,7 +17,8 @@ - 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. diff --git a/doc/classes/Room.xml b/doc/classes/Room.xml index d07131334..ce1d6a00d 100644 --- a/doc/classes/Room.xml +++ b/doc/classes/Room.xml @@ -18,7 +18,8 @@ - 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. diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp index b0ee2d2e8..6529c960d 100644 --- a/scene/3d/portal.cpp +++ b/scene/3d/portal.cpp @@ -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(); diff --git a/scene/3d/room.cpp b/scene/3d/room.cpp index 134592239..0c9883698 100644 --- a/scene/3d/room.cpp +++ b/scene/3d/room.cpp @@ -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); diff --git a/scene/resources/occluder_shape.cpp b/scene/resources/occluder_shape.cpp index bd01ef40a..b1192c679 100644 --- a/scene/resources/occluder_shape.cpp +++ b/scene/resources/occluder_shape.cpp @@ -210,29 +210,30 @@ void OccluderShapeSphere::set_spheres(const Vector &p_spheres) { } void OccluderShapeSphere::set_sphere_position(int p_idx, const Vector3 &p_position) { - if ((p_idx >= 0) && (p_idx < _spheres.size())) { - Plane p = _spheres[p_idx]; - p.normal = p_position; - _spheres.set(p_idx, p); + 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(); + _update_aabb(); #endif - update_shape_to_rendering_server(); - notify_change_to_owners(); - } + 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())) { - Plane p = _spheres[p_idx]; - p.d = MAX(p_radius, _min_radius); - _spheres.set(p_idx, p); + ERR_FAIL_INDEX(p_idx, _spheres.size()); + + Plane p = _spheres[p_idx]; + p.d = MAX(p_radius, _min_radius); + _spheres.set(p_idx, p); #ifdef TOOLS_ENABLED - _update_aabb(); + _update_aabb(); #endif - update_shape_to_rendering_server(); - notify_change_to_owners(); - } + update_shape_to_rendering_server(); + notify_change_to_owners(); } OccluderShapeSphere::OccluderShapeSphere() { diff --git a/scene/resources/occluder_shape_polygon.cpp b/scene/resources/occluder_shape_polygon.cpp index ce274b1b9..7e4eafb8a 100644 --- a/scene/resources/occluder_shape_polygon.cpp +++ b/scene/resources/occluder_shape_polygon.cpp @@ -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();