Skip to content

Commit

Permalink
Merge pull request #89111 from AThousandShips/vec_use
Browse files Browse the repository at this point in the history
Use `Vector*` component-wise `min/max/clamp` functions where applicable
  • Loading branch information
akien-mga committed Mar 24, 2024
2 parents 33cca7c + 79ba22a commit cd4e4c0
Show file tree
Hide file tree
Showing 53 changed files with 95 additions and 176 deletions.
2 changes: 1 addition & 1 deletion core/math/aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct _NO_DISCARD_ AABB {
_FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */

_FORCE_INLINE_ AABB abs() const {
return AABB(Vector3(position.x + MIN(size.x, (real_t)0), position.y + MIN(size.y, (real_t)0), position.z + MIN(size.z, (real_t)0)), size.abs());
return AABB(position + size.min(Vector3()), size.abs());
}

Variant intersects_segment_bind(const Vector3 &p_from, const Vector3 &p_to) const;
Expand Down
12 changes: 3 additions & 9 deletions core/math/delaunay_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ class Delaunay3D {
}

Vector3i grid_pos = Vector3i(points[i] * ACCEL_GRID_SIZE);
grid_pos.x = CLAMP(grid_pos.x, 0, ACCEL_GRID_SIZE - 1);
grid_pos.y = CLAMP(grid_pos.y, 0, ACCEL_GRID_SIZE - 1);
grid_pos.z = CLAMP(grid_pos.z, 0, ACCEL_GRID_SIZE - 1);
grid_pos = grid_pos.clamp(Vector3i(), Vector3i(ACCEL_GRID_SIZE - 1, ACCEL_GRID_SIZE - 1, ACCEL_GRID_SIZE - 1));

for (List<Simplex *>::Element *E = acceleration_grid[grid_pos.x][grid_pos.y][grid_pos.z].front(); E;) {
List<Simplex *>::Element *N = E->next(); //may be deleted
Expand Down Expand Up @@ -339,12 +337,8 @@ class Delaunay3D {
Vector3 extents = Vector3(radius2, radius2, radius2);
Vector3i from = Vector3i((center - extents) * ACCEL_GRID_SIZE);
Vector3i to = Vector3i((center + extents) * ACCEL_GRID_SIZE);
from.x = CLAMP(from.x, 0, ACCEL_GRID_SIZE - 1);
from.y = CLAMP(from.y, 0, ACCEL_GRID_SIZE - 1);
from.z = CLAMP(from.z, 0, ACCEL_GRID_SIZE - 1);
to.x = CLAMP(to.x, 0, ACCEL_GRID_SIZE - 1);
to.y = CLAMP(to.y, 0, ACCEL_GRID_SIZE - 1);
to.z = CLAMP(to.z, 0, ACCEL_GRID_SIZE - 1);
from = from.clamp(Vector3i(), Vector3i(ACCEL_GRID_SIZE - 1, ACCEL_GRID_SIZE - 1, ACCEL_GRID_SIZE - 1));
to = to.clamp(Vector3i(), Vector3i(ACCEL_GRID_SIZE - 1, ACCEL_GRID_SIZE - 1, ACCEL_GRID_SIZE - 1));

for (int32_t x = from.x; x <= to.x; x++) {
for (int32_t y = from.y; y <= to.y; y++) {
Expand Down
9 changes: 2 additions & 7 deletions core/math/dynamic_bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,8 @@ void DynamicBVH::convex_query(const Plane *p_planes, int p_plane_count, const Ve
volume.min = p_points[0];
volume.max = p_points[0];
} else {
volume.min.x = MIN(volume.min.x, p_points[i].x);
volume.min.y = MIN(volume.min.y, p_points[i].y);
volume.min.z = MIN(volume.min.z, p_points[i].z);

volume.max.x = MAX(volume.max.x, p_points[i].x);
volume.max.y = MAX(volume.max.y, p_points[i].y);
volume.max.z = MAX(volume.max.z, p_points[i].z);
volume.min = volume.min.min(p_points[i]);
volume.max = volume.max.max(p_points[i]);
}
}

Expand Down
6 changes: 2 additions & 4 deletions core/math/geometry_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,8 @@ class Geometry2D {
Vector2 further_away_opposite(1e20, 1e20);

for (int i = 0; i < c; i++) {
further_away.x = MAX(p[i].x, further_away.x);
further_away.y = MAX(p[i].y, further_away.y);
further_away_opposite.x = MIN(p[i].x, further_away_opposite.x);
further_away_opposite.y = MIN(p[i].y, further_away_opposite.y);
further_away = further_away.max(p[i]);
further_away_opposite = further_away_opposite.min(p[i]);
}

// Make point outside that won't intersect with points in segment from p_point.
Expand Down
14 changes: 5 additions & 9 deletions core/math/rect2.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,12 @@ struct _NO_DISCARD_ Rect2 {
return Rect2();
}

new_rect.position.x = MAX(p_rect.position.x, position.x);
new_rect.position.y = MAX(p_rect.position.y, position.y);
new_rect.position = p_rect.position.max(position);

Point2 p_rect_end = p_rect.position + p_rect.size;
Point2 end = position + size;

new_rect.size.x = MIN(p_rect_end.x, end.x) - new_rect.position.x;
new_rect.size.y = MIN(p_rect_end.y, end.y) - new_rect.position.y;
new_rect.size = p_rect_end.min(end) - new_rect.position;

return new_rect;
}
Expand All @@ -172,11 +170,9 @@ struct _NO_DISCARD_ Rect2 {
#endif
Rect2 new_rect;

new_rect.position.x = MIN(p_rect.position.x, position.x);
new_rect.position.y = MIN(p_rect.position.y, position.y);
new_rect.position = p_rect.position.min(position);

new_rect.size.x = MAX(p_rect.position.x + p_rect.size.x, position.x + size.x);
new_rect.size.y = MAX(p_rect.position.y + p_rect.size.y, position.y + size.y);
new_rect.size = (p_rect.position + p_rect.size).max(position + size);

new_rect.size = new_rect.size - new_rect.position; // Make relative again.

Expand Down Expand Up @@ -282,7 +278,7 @@ struct _NO_DISCARD_ Rect2 {
}

_FORCE_INLINE_ Rect2 abs() const {
return Rect2(Point2(position.x + MIN(size.x, (real_t)0), position.y + MIN(size.y, (real_t)0)), size.abs());
return Rect2(position + size.min(Point2()), size.abs());
}

_FORCE_INLINE_ Rect2 round() const {
Expand Down
14 changes: 5 additions & 9 deletions core/math/rect2i.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,12 @@ struct _NO_DISCARD_ Rect2i {
return Rect2i();
}

new_rect.position.x = MAX(p_rect.position.x, position.x);
new_rect.position.y = MAX(p_rect.position.y, position.y);
new_rect.position = p_rect.position.max(position);

Point2i p_rect_end = p_rect.position + p_rect.size;
Point2i end = position + size;

new_rect.size.x = MIN(p_rect_end.x, end.x) - new_rect.position.x;
new_rect.size.y = MIN(p_rect_end.y, end.y) - new_rect.position.y;
new_rect.size = p_rect_end.min(end) - new_rect.position;

return new_rect;
}
Expand All @@ -115,11 +113,9 @@ struct _NO_DISCARD_ Rect2i {
#endif
Rect2i new_rect;

new_rect.position.x = MIN(p_rect.position.x, position.x);
new_rect.position.y = MIN(p_rect.position.y, position.y);
new_rect.position = p_rect.position.min(position);

new_rect.size.x = MAX(p_rect.position.x + p_rect.size.x, position.x + size.x);
new_rect.size.y = MAX(p_rect.position.y + p_rect.size.y, position.y + size.y);
new_rect.size = (p_rect.position + p_rect.size).max(position + size);

new_rect.size = new_rect.size - new_rect.position; // Make relative again.

Expand Down Expand Up @@ -217,7 +213,7 @@ struct _NO_DISCARD_ Rect2i {
}

_FORCE_INLINE_ Rect2i abs() const {
return Rect2i(Point2i(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0)), size.abs());
return Rect2i(position + size.min(Point2i()), size.abs());
}

_FORCE_INLINE_ void set_end(const Vector2i &p_end) {
Expand Down
3 changes: 1 addition & 2 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2812,8 +2812,7 @@ void TextureStorage::_render_target_allocate_sdf(RenderTarget *rt) {
}

rt->process_size = size * scale / 100;
rt->process_size.x = MAX(rt->process_size.x, 1);
rt->process_size.y = MAX(rt->process_size.y, 1);
rt->process_size = rt->process_size.max(Size2i(1, 1));

glGenTextures(2, rt->sdf_texture_process);
glBindTexture(GL_TEXTURE_2D, rt->sdf_texture_process[0]);
Expand Down
3 changes: 1 addition & 2 deletions drivers/vulkan/rendering_device_driver_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,7 @@ Error RenderingDeviceDriverVulkan::_check_device_capabilities() {
vrs_capabilities.max_texel_size.y = vrs_properties.maxFragmentShadingRateAttachmentTexelSize.height;

// We'll attempt to default to a texel size of 16x16.
vrs_capabilities.texel_size.x = CLAMP(16, vrs_capabilities.min_texel_size.x, vrs_capabilities.max_texel_size.x);
vrs_capabilities.texel_size.y = CLAMP(16, vrs_capabilities.min_texel_size.y, vrs_capabilities.max_texel_size.y);
vrs_capabilities.texel_size = Vector2i(16, 16).clamp(vrs_capabilities.min_texel_size, vrs_capabilities.max_texel_size);

print_verbose(String(" Attachment fragment shading rate") + String(", min texel size: (") + itos(vrs_capabilities.min_texel_size.x) + String(", ") + itos(vrs_capabilities.min_texel_size.y) + String(")") + String(", max texel size: (") + itos(vrs_capabilities.max_texel_size.x) + String(", ") + itos(vrs_capabilities.max_texel_size.y) + String(")"));
}
Expand Down
3 changes: 1 addition & 2 deletions editor/editor_atlas_packer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
Vector2 vtx = chart.vertices[chart.faces[j].vertex[k]];
vtx -= aabb.position;
vtx /= divide_by;
vtx.x = MIN(vtx.x, w - 1);
vtx.y = MIN(vtx.y, h - 1);
vtx = vtx.min(Vector2(w - 1, h - 1));
v[k] = vtx;
}

Expand Down
6 changes: 2 additions & 4 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ Size2 EditorProperty::get_minimum_size() const {
}

Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width, minsize.width);
ms.height = MAX(ms.height, minsize.height);
ms = ms.max(minsize);
}

if (keying) {
Expand Down Expand Up @@ -1463,8 +1462,7 @@ Size2 EditorInspectorSection::get_minimum_size() const {
continue;
}
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width, minsize.width);
ms.height = MAX(ms.height, minsize.height);
ms = ms.max(minsize);
}

Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_resource_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
preview_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
int thumbnail_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
thumbnail_size *= EDSCALE;
assign_button->set_custom_minimum_size(Size2(MAX(1, assign_button_min_size.x), MAX(thumbnail_size, assign_button_min_size.y)));
assign_button->set_custom_minimum_size(assign_button_min_size.max(Size2(1, thumbnail_size)));
}

preview_rect->set_texture(p_preview);
Expand Down
10 changes: 2 additions & 8 deletions editor/plugins/animation_state_machine_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && tool_select->is_pressed()) {
box_selecting = true;
box_selecting_from = box_selecting_to = state_machine_draw->get_local_mouse_position();
box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
MIN(box_selecting_from.y, box_selecting_to.y),
ABS(box_selecting_from.x - box_selecting_to.x),
ABS(box_selecting_from.y - box_selecting_to.y));
box_selecting_rect = Rect2(box_selecting_from.min(box_selecting_to), (box_selecting_from - box_selecting_to).abs());

if (mb->is_command_or_control_pressed() || mb->is_shift_pressed()) {
previous_selected = selected_nodes;
Expand Down Expand Up @@ -423,10 +420,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
if (mm.is_valid() && box_selecting) {
box_selecting_to = state_machine_draw->get_local_mouse_position();

box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
MIN(box_selecting_from.y, box_selecting_to.y),
ABS(box_selecting_from.x - box_selecting_to.x),
ABS(box_selecting_from.y - box_selecting_to.y));
box_selecting_rect = Rect2(box_selecting_from.min(box_selecting_to), (box_selecting_from - box_selecting_to).abs());

for (int i = 0; i < node_rects.size(); i++) {
bool in_box = node_rects[i].node.intersects(box_selecting_rect);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/editor_preview_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const Ref<Resource> &p_from,
if (new_size.y > p_size.y) {
new_size = Vector2(new_size.x * p_size.y / new_size.y, p_size.y);
}
Vector2i new_size_i(MAX(1, (int)new_size.x), MAX(1, (int)new_size.y));
Vector2i new_size_i = Vector2i(new_size).max(Vector2i(1, 1));
img->resize(new_size_i.x, new_size_i.y, Image::INTERPOLATE_CUBIC);
post_process_preview(img);

Expand Down
6 changes: 2 additions & 4 deletions editor/plugins/skeleton_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,8 @@ void Skeleton3DEditor::_file_selected(const String &p_file) {
position_max = Vector2(grest.origin.x, grest.origin.y);
position_min = Vector2(grest.origin.x, grest.origin.y);
} else {
position_max.x = MAX(grest.origin.x, position_max.x);
position_max.y = MAX(grest.origin.y, position_max.y);
position_min.x = MIN(grest.origin.x, position_min.x);
position_min.y = MIN(grest.origin.y, position_min.y);
position_max = position_max.max(Vector2(grest.origin.x, grest.origin.y));
position_min = position_min.min(Vector2(grest.origin.x, grest.origin.y));
}
}

Expand Down
3 changes: 1 addition & 2 deletions editor/plugins/tiles/tile_atlas_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ Vector2i TileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos, bool p
// Clamp.
if (p_clamp) {
Vector2i size = tile_set_atlas_source->get_atlas_grid_size();
ret.x = CLAMP(ret.x, 0, size.x - 1);
ret.y = CLAMP(ret.y, 0, size.y - 1);
ret = ret.clamp(Vector2i(), size - Vector2i(1, 1));
}

return ret;
Expand Down
3 changes: 1 addition & 2 deletions editor/plugins/version_control_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_ba
if (!available_plugins.is_empty()) {
Size2 popup_size = Size2(400, 100);
Size2 window_size = p_gui_base->get_viewport_rect().size;
popup_size.x = MIN(window_size.x * 0.5, popup_size.x);
popup_size.y = MIN(window_size.y * 0.5, popup_size.y);
popup_size = popup_size.min(window_size * 0.5);

_populate_available_vcs_names();

Expand Down
3 changes: 1 addition & 2 deletions modules/lightmapper_rd/lightmapper_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
MeshInstance &mi = mesh_instances.write[m_i];
Size2i s = Size2i(mi.data.albedo_on_uv2->get_width(), mi.data.albedo_on_uv2->get_height());
sizes.push_back(s);
atlas_size.width = MAX(atlas_size.width, s.width + 2);
atlas_size.height = MAX(atlas_size.height, s.height + 2);
atlas_size = atlas_size.max(s + Size2i(2, 2));
}

int max = nearest_power_of_2_templated(atlas_size.width);
Expand Down
9 changes: 3 additions & 6 deletions platform/linuxbsd/x11/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1995,8 +1995,7 @@ void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window
Size2i wsize = window_get_size(p_window);
wpos += srect.position;
if (srect != Rect2i()) {
wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - wsize.width / 3);
wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - wsize.height / 3);
wpos = wpos.clamp(srect.position, srect.position + srect.size - wsize / 3);
}
window_set_position(wpos, p_window);
}
Expand Down Expand Up @@ -2224,8 +2223,7 @@ void DisplayServerX11::window_set_size(const Size2i p_size, WindowID p_window) {
ERR_FAIL_COND(!windows.has(p_window));

Size2i size = p_size;
size.x = MAX(1, size.x);
size.y = MAX(1, size.y);
size = size.max(Size2i(1, 1));

WindowData &wd = windows[p_window];

Expand Down Expand Up @@ -5451,8 +5449,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
} else {
Rect2i srect = screen_get_usable_rect(rq_screen);
Point2i wpos = p_rect.position;
wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - p_rect.size.width / 3);
wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - p_rect.size.height / 3);
wpos = wpos.clamp(srect.position, srect.position + srect.size - p_rect.size / 3);

win_rect.position = wpos;
}
Expand Down
9 changes: 3 additions & 6 deletions platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@
Rect2i srect = screen_get_usable_rect(rq_screen);
Point2i wpos = p_rect.position;
if (srect != Rect2i()) {
wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - p_rect.size.width / 3);
wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - p_rect.size.height / 3);
wpos = wpos.clamp(srect.position, srect.position + srect.size - p_rect.size / 3);
}
// macOS native y-coordinate relative to _get_screens_origin() is negative,
// Godot passes a positive value.
Expand Down Expand Up @@ -1877,8 +1876,7 @@
Size2i wsize = window_get_size(p_window);
wpos += srect.position;

wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - wsize.width / 3);
wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - wsize.height / 3);
wpos = wpos.clamp(srect.position, srect.position + srect.size - wsize / 3);
window_set_position(wpos, p_window);

if (was_fullscreen) {
Expand Down Expand Up @@ -2309,8 +2307,7 @@
WindowData &wd = windows[p_window];
float scale = screen_get_max_scale();
wd.wb_offset = p_offset / scale;
wd.wb_offset.x = MAX(wd.wb_offset.x, 12);
wd.wb_offset.y = MAX(wd.wb_offset.y, 12);
wd.wb_offset = wd.wb_offset.max(Vector2i(12, 12));
if (wd.window_button_view) {
[wd.window_button_view setOffset:NSMakePoint(wd.wb_offset.x, wd.wb_offset.y)];
}
Expand Down
9 changes: 3 additions & 6 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRE

static BOOL CALLBACK _MonitorEnumProcOrigin(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
EnumPosData *data = (EnumPosData *)dwData;
data->pos.x = MIN(data->pos.x, lprcMonitor->left);
data->pos.y = MIN(data->pos.y, lprcMonitor->top);
data->pos = data->pos.min(Point2(lprcMonitor->left, lprcMonitor->top));

return TRUE;
}
Expand Down Expand Up @@ -1637,8 +1636,7 @@ void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_wi
Size2i wsize = window_get_size(p_window);
wpos += srect.position;

wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - wsize.width / 3);
wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - wsize.height / 3);
wpos = wpos.clamp(srect.position, srect.position + srect.size - wsize / 3);
window_set_position(wpos, p_window);
}
}
Expand Down Expand Up @@ -5076,8 +5074,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
Rect2i srect = screen_get_usable_rect(rq_screen);
Point2i wpos = p_rect.position;
if (srect != Rect2i()) {
wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - p_rect.size.width / 3);
wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - p_rect.size.height / 3);
wpos = wpos.clamp(srect.position, srect.position + srect.size - p_rect.size / 3);
}

WindowRect.left = wpos.x;
Expand Down
3 changes: 1 addition & 2 deletions scene/2d/sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const {
q.y = texture->get_size().height - q.y - 1;
}
} else {
q.x = MIN(q.x, texture->get_size().width - 1);
q.y = MIN(q.y, texture->get_size().height - 1);
q = q.min(texture->get_size() - Vector2(1, 1));
}

return texture->is_pixel_opaque((int)q.x, (int)q.y);
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/decal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "decal.h"

void Decal::set_size(const Vector3 &p_size) {
size = Vector3(MAX(0.001, p_size.x), MAX(0.001, p_size.y), MAX(0.001, p_size.z));
size = p_size.max(Vector3(0.001, 0.001, 0.001));
RS::get_singleton()->decal_set_size(decal, size);
update_gizmos();
}
Expand Down
4 changes: 1 addition & 3 deletions scene/3d/fog_volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ bool FogVolume::_get(const StringName &p_name, Variant &r_property) const {

void FogVolume::set_size(const Vector3 &p_size) {
size = p_size;
size.x = MAX(0.0, size.x);
size.y = MAX(0.0, size.y);
size.z = MAX(0.0, size.z);
size = size.max(Vector3());
RS::get_singleton()->fog_volume_set_size(_get_volume(), size);
update_gizmos();
}
Expand Down
Loading

0 comments on commit cd4e4c0

Please sign in to comment.