Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HeightMapShape3D functions to get min / max height #87881

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion doc/classes/HeightMapShape3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
10 changes: 10 additions & 0 deletions scene/resources/height_map_shape_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,23 @@ 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);
ClassDB::bind_method(D_METHOD("set_map_depth", "height"), &HeightMapShape3D::set_map_depth);
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");
Expand Down
3 changes: 3 additions & 0 deletions scene/resources/height_map_shape_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class HeightMapShape3D : public Shape3D {
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;

Expand Down
Loading