Skip to content

Commit 3552c30

Browse files
committed
Improve HeightMapShape3D documentation
See also godotengine/godot-docs#7471
1 parent c0c1c68 commit 3552c30

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

doc/classes/HeightMapShape3D.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<class name="HeightMapShape3D" inherits="Shape3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
33
<brief_description>
4-
A 3D height map shape used for physics collision.
4+
A 3D heightmap shape used for physics collision.
55
</brief_description>
66
<description>
7-
A 3D heightmap shape, intended for use in physics. Usually used to provide a shape for a [CollisionShape3D]. This type is most commonly used for terrain with vertices placed in a fixed width grid. Due to the nature of the heightmap, it cannot be used to model overhangs or caves, which would require multiple vertices at the same vertical location. Holes can be punched through the collision by assigning [constant @GDScript.NAN] to the height of the desired vertices (this is supported in both GodotPhysics3D and Jolt Physics). You could then insert meshes with their own separate collision to provide overhangs, caves, and so on.
7+
A 3D heightmap shape, intended for use in physics to provide a shape for a [CollisionShape3D]. This type is most commonly used for terrain with vertices placed in a fixed width grid.
8+
The heightmap is represented as a 2D grid of height values, which represent the position of grid points on the Y axis. Grid points are spaced 1 unit apart on the X and Z axes, and the grid is centered on the origin of the [HeightMapShape3D] node. Internally, each grid square is divided into two triangles.
9+
Due to the nature of the heightmap, it cannot be used to model overhangs or caves, which would require multiple vertices at the same vertical location. Holes can be punched through the collision by assigning [constant @GDScript.NAN] to the height of the desired vertices (this is supported in both GodotPhysics3D and Jolt Physics). You could then insert meshes with their own separate collision to provide overhangs, caves, and so on.
810
[b]Performance:[/b] [HeightMapShape3D] is faster to check collisions against than [ConcavePolygonShape3D], but it is significantly slower than primitive shapes like [BoxShape3D].
911
A heightmap collision shape can also be built by using an [Image] reference:
1012
[codeblocks]
@@ -19,6 +21,7 @@
1921
update_map_data_from_image(heightmap_image, height_min, height_max)
2022
[/gdscript]
2123
[/codeblocks]
24+
[b]Note:[/b] If you need to use a spacing different than 1 unit, you can adjust the [member Node3D.scale] of the shape. However, keep in mind that GodotPhysics3D does not support non-uniform scaling: you'll need to scale the Y axis by the same amount as the X and Z axes, which means the values in [member map_data] will need to be pre-scaled by the inverse of that scale. Also note that GodotPhysics3D does not support scaling at all for dynamic bodies (that is, non-frozen [RigidBody3D]); to use a scaled [HeightMapShape3D] with those, you will need to use Jolt Physics.
2225
</description>
2326
<tutorials>
2427
</tutorials>
@@ -50,13 +53,13 @@
5053
</methods>
5154
<members>
5255
<member name="map_data" type="PackedFloat32Array" setter="set_map_data" getter="get_map_data" default="PackedFloat32Array(0, 0, 0, 0)">
53-
Height map data. The array's size must be equal to [member map_width] multiplied by [member map_depth].
56+
Heightmap data. The array's size must be equal to [member map_width] multiplied by [member map_depth].
5457
</member>
5558
<member name="map_depth" type="int" setter="set_map_depth" getter="get_map_depth" default="2">
56-
Number of vertices in the depth of the height map. Changing this will resize the [member map_data].
59+
Number of vertices in the depth of the heightmap. Changing this will resize the [member map_data].
5760
</member>
5861
<member name="map_width" type="int" setter="set_map_width" getter="get_map_width" default="2">
59-
Number of vertices in the width of the height map. Changing this will resize the [member map_data].
62+
Number of vertices in the width of the heightmap. Changing this will resize the [member map_data].
6063
</member>
6164
</members>
6265
</class>

0 commit comments

Comments
 (0)