From 0a485fc30aae693e942a5984f149c7aa69f397d7 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Fri, 2 Feb 2024 23:07:53 +0100 Subject: [PATCH] Add HeightMapShape3D functions to get min / max height Adds HeightMapShape3D functions to get min / max height. --- doc/classes/HeightMapShape3D.xml | 16 +++++++++++++++- scene/resources/height_map_shape_3d.cpp | 10 ++++++++++ scene/resources/height_map_shape_3d.h | 3 +++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/classes/HeightMapShape3D.xml b/doc/classes/HeightMapShape3D.xml index ff120fa557f..ba79cbc89a5 100644 --- a/doc/classes/HeightMapShape3D.xml +++ b/doc/classes/HeightMapShape3D.xml @@ -9,9 +9,23 @@ + + + + + Returns the largest height value found in [member map_data]. Recalculates only when [member map_data] changes. + + + + + + Returns the smallest height value found in [member map_data]. Recalculates only when [member map_data] changes. + + + - Height map data, pool array must be of [member map_width] * [member map_depth] size. + Height map data. The array's size must be equal to [member map_width] multiplied by [member map_depth]. Number of vertices in the depth of the height map. Changing this will resize the [member map_data]. diff --git a/scene/resources/height_map_shape_3d.cpp b/scene/resources/height_map_shape_3d.cpp index 718d701811f..35c905bd432 100644 --- a/scene/resources/height_map_shape_3d.cpp +++ b/scene/resources/height_map_shape_3d.cpp @@ -179,6 +179,14 @@ Vector HeightMapShape3D::get_map_data() const { return map_data; } +real_t HeightMapShape3D::get_min_height() const { + return min_height; +} + +real_t HeightMapShape3D::get_max_height() const { + return max_height; +} + void HeightMapShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_map_width", "width"), &HeightMapShape3D::set_map_width); ClassDB::bind_method(D_METHOD("get_map_width"), &HeightMapShape3D::get_map_width); @@ -186,6 +194,8 @@ void HeightMapShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_map_depth"), &HeightMapShape3D::get_map_depth); ClassDB::bind_method(D_METHOD("set_map_data", "data"), &HeightMapShape3D::set_map_data); ClassDB::bind_method(D_METHOD("get_map_data"), &HeightMapShape3D::get_map_data); + ClassDB::bind_method(D_METHOD("get_min_height"), &HeightMapShape3D::get_min_height); + ClassDB::bind_method(D_METHOD("get_max_height"), &HeightMapShape3D::get_max_height); ADD_PROPERTY(PropertyInfo(Variant::INT, "map_width", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_map_width", "get_map_width"); ADD_PROPERTY(PropertyInfo(Variant::INT, "map_depth", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_map_depth", "get_map_depth"); diff --git a/scene/resources/height_map_shape_3d.h b/scene/resources/height_map_shape_3d.h index 5fe00ec0b1a..eff025c816b 100644 --- a/scene/resources/height_map_shape_3d.h +++ b/scene/resources/height_map_shape_3d.h @@ -54,6 +54,9 @@ public: void set_map_data(Vector p_new); Vector get_map_data() const; + real_t get_min_height() const; + real_t get_max_height() const; + virtual Vector get_debug_mesh_lines() const override; virtual real_t get_enclosing_radius() const override;