Merge pull request #87881 from smix8/height_min_max_helpers

Add HeightMapShape3D functions to get min / max height
This commit is contained in:
Rémi Verschelde 2024-02-05 14:51:02 +01:00
commit fbd203401b
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 28 additions and 1 deletions

View file

@ -9,9 +9,23 @@
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_max_height" qualifiers="const">
<return type="float" />
<description>
Returns the largest height value found in [member map_data]. Recalculates only when [member map_data] changes.
</description>
</method>
<method name="get_min_height" qualifiers="const">
<return type="float" />
<description>
Returns the smallest height value found in [member map_data]. Recalculates only when [member map_data] changes.
</description>
</method>
</methods>
<members>
<member name="map_data" type="PackedFloat32Array" setter="set_map_data" getter="get_map_data" default="PackedFloat32Array(0, 0, 0, 0)">
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].
</member>
<member name="map_depth" type="int" setter="set_map_depth" getter="get_map_depth" default="2">
Number of vertices in the depth of the height map. Changing this will resize the [member map_data].

View file

@ -179,6 +179,14 @@ Vector<real_t> 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");

View file

@ -54,6 +54,9 @@ public:
void set_map_data(Vector<real_t> p_new);
Vector<real_t> get_map_data() const;
real_t get_min_height() const;
real_t get_max_height() const;
virtual Vector<Vector3> get_debug_mesh_lines() const override;
virtual real_t get_enclosing_radius() const override;