Skip to content

Commit

Permalink
Fix #291 - Expose control pixel converters to GDScript. Pull funcs ou…
Browse files Browse the repository at this point in the history
…t of Util class into namespace.
  • Loading branch information
TokisanGames committed Mar 12, 2024
1 parent 6200d21 commit 4943cfb
Show file tree
Hide file tree
Showing 20 changed files with 746 additions and 291 deletions.
5 changes: 3 additions & 2 deletions Terrain3D.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<ClInclude Include="src\terrain_3d.h" />
<ClInclude Include="src\terrain_3d_editor.h" />
<ClInclude Include="src\logger.h" />
<ClInclude Include="src\util.h" />
<ClInclude Include="src\terrain_3d_util.h" />
<ClInclude Include="src\terrain_3d_material.h" />
<ClInclude Include="src\terrain_3d_storage.h" />
<ClInclude Include="src\terrain_3d_texture.h" />
Expand All @@ -162,7 +162,7 @@
<ClCompile Include="src\terrain_3d_storage.cpp" />
<ClCompile Include="src\terrain_3d_texture.cpp" />
<ClCompile Include="src\terrain_3d_texture_list.cpp" />
<ClCompile Include="src\util.cpp" />
<ClCompile Include="src\terrain_3d_util.cpp" />
</ItemGroup>
<ItemGroup>
<None Include=".github\actions\base-deps\action.yml" />
Expand Down Expand Up @@ -228,6 +228,7 @@
<Xml Include="doc\classes\Terrain3DStorage.xml" />
<Xml Include="doc\classes\Terrain3DTexture.xml" />
<Xml Include="doc\classes\Terrain3DTextureList.xml" />
<Xml Include="doc\classes\Terrain3DUtil.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
7 changes: 5 additions & 2 deletions Terrain3D.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<ClInclude Include="src\logger.h">
<Filter>4. Headers</Filter>
</ClInclude>
<ClInclude Include="src\util.h">
<ClInclude Include="src\terrain_3d_util.h">
<Filter>4. Headers</Filter>
</ClInclude>
</ItemGroup>
Expand Down Expand Up @@ -89,7 +89,7 @@
<ClCompile Include="src\generated_tex.cpp">
<Filter>5. C++</Filter>
</ClCompile>
<ClCompile Include="src\util.cpp">
<ClCompile Include="src\terrain_3d_util.cpp">
<Filter>5. C++</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -275,5 +275,8 @@
<Xml Include="doc\classes\Terrain3DTextureList.xml">
<Filter>2. Docs\XML</Filter>
</Xml>
<Xml Include="doc\classes\Terrain3DUtil.xml">
<Filter>2. Docs\XML</Filter>
</Xml>
</ItemGroup>
</Project>
106 changes: 17 additions & 89 deletions doc/api/class_terrain3d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,23 @@ Methods
.. table::
:widths: auto

+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Mesh<class_Mesh>` | :ref:`bake_mesh<class_Terrain3D_method_bake_mesh>` **(** :ref:`int<class_int>` lod, :ref:`HeightFilter<enum_Terrain3DStorage_HeightFilter>` filter **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedVector3Array<class_PackedVector3Array>` | :ref:`generate_nav_mesh_source_geometry<class_Terrain3D_method_generate_nav_mesh_source_geometry>` **(** :ref:`AABB<class_AABB>` global_aabb, :ref:`bool<class_bool>` require_nav=true **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Camera3D<class_Camera3D>` | :ref:`get_camera<class_Terrain3D_method_get_camera>` **(** **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Image<class_Image>` | :ref:`get_filled_image<class_Terrain3D_method_get_filled_image>` **(** :ref:`Vector2i<class_Vector2i>` size, :ref:`Color<class_Color>` color, :ref:`bool<class_bool>` create_mipmaps, :ref:`Format<enum_Image_Format>` format **)** |static| |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`get_intersection<class_Terrain3D_method_get_intersection>` **(** :ref:`Vector3<class_Vector3>` src_pos, :ref:`Vector3<class_Vector3>` direction **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`get_min_max<class_Terrain3D_method_get_min_max>` **(** :ref:`Image<class_Image>` image **)** |static| |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`EditorPlugin<class_EditorPlugin>` | :ref:`get_plugin<class_Terrain3D_method_get_plugin>` **(** **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Image<class_Image>` | :ref:`get_thumbnail<class_Terrain3D_method_get_thumbnail>` **(** :ref:`Image<class_Image>` image, :ref:`Vector2i<class_Vector2i>` size=Vector2i(256, 256) **)** |static| |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Image<class_Image>` | :ref:`pack_image<class_Terrain3D_method_pack_image>` **(** :ref:`Image<class_Image>` src_rgb, :ref:`Image<class_Image>` src_r, :ref:`bool<class_bool>` invert_green_channel=false **)** |static| |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_camera<class_Terrain3D_method_set_camera>` **(** :ref:`Camera3D<class_Camera3D>` camera **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_plugin<class_Terrain3D_method_set_plugin>` **(** :ref:`EditorPlugin<class_EditorPlugin>` plugin **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`update_aabbs<class_Terrain3D_method_update_aabbs>` **(** **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Mesh<class_Mesh>` | :ref:`bake_mesh<class_Terrain3D_method_bake_mesh>` **(** :ref:`int<class_int>` lod, :ref:`HeightFilter<enum_Terrain3DStorage_HeightFilter>` filter **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedVector3Array<class_PackedVector3Array>` | :ref:`generate_nav_mesh_source_geometry<class_Terrain3D_method_generate_nav_mesh_source_geometry>` **(** :ref:`AABB<class_AABB>` global_aabb, :ref:`bool<class_bool>` require_nav=true **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Camera3D<class_Camera3D>` | :ref:`get_camera<class_Terrain3D_method_get_camera>` **(** **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`get_intersection<class_Terrain3D_method_get_intersection>` **(** :ref:`Vector3<class_Vector3>` src_pos, :ref:`Vector3<class_Vector3>` direction **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`EditorPlugin<class_EditorPlugin>` | :ref:`get_plugin<class_Terrain3D_method_get_plugin>` **(** **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_camera<class_Terrain3D_method_set_camera>` **(** :ref:`Camera3D<class_Camera3D>` camera **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_plugin<class_Terrain3D_method_set_plugin>` **(** :ref:`EditorPlugin<class_EditorPlugin>` plugin **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`update_aabbs<class_Terrain3D_method_update_aabbs>` **(** **)** |
+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

.. rst-class:: classref-section-separator

Expand Down Expand Up @@ -498,28 +490,6 @@ Returns the camera the terrain is currently snapping to.

----

.. _class_Terrain3D_method_get_filled_image:

.. rst-class:: classref-method

:ref:`Image<class_Image>` **get_filled_image** **(** :ref:`Vector2i<class_Vector2i>` size, :ref:`Color<class_Color>` color, :ref:`bool<class_bool>` create_mipmaps, :ref:`Format<enum_Image_Format>` format **)** |static|

A utility function that returns an Image filled with a specified color and format.

If ``color.a < 0``, its filled with a checkered pattern multiplied by ``color.rgb``.

The behavior changes if a compressed format is requested:

- If the editor is running and the format is DXT1, DXT5, or BPTC_RGBA, it returns a filled image in the requested color and format.

- All other compressed formats return a blank image in that format.

The reason for this is the Image compression library is available only in the editor. And it is unreliable, offering little control over the output format, choosing automatically and often wrong. We have selected a few compressed formats it gets right.

.. rst-class:: classref-item-separator

----

.. _class_Terrain3D_method_get_intersection:

.. rst-class:: classref-method
Expand All @@ -546,18 +516,6 @@ It does require the use of an editor render layer (21-32) that should be dedicat

----

.. _class_Terrain3D_method_get_min_max:

.. rst-class:: classref-method

:ref:`Vector2<class_Vector2>` **get_min_max** **(** :ref:`Image<class_Image>` image **)** |static|

A utility function that returns the minimum and maximum r channel values of an Image. Used for heightmaps.

.. rst-class:: classref-item-separator

----

.. _class_Terrain3D_method_get_plugin:

.. rst-class:: classref-method
Expand All @@ -570,36 +528,6 @@ Returns the EditorPlugin connected to Terrain3D.

----

.. _class_Terrain3D_method_get_thumbnail:

.. rst-class:: classref-method

:ref:`Image<class_Image>` **get_thumbnail** **(** :ref:`Image<class_Image>` image, :ref:`Vector2i<class_Vector2i>` size=Vector2i(256, 256) **)** |static|

A utility function that returns an Image normalized and converted to RGB8. Used for creating a human viewable thumbnail of a heightmap.

.. rst-class:: classref-item-separator

----

.. _class_Terrain3D_method_pack_image:

.. rst-class:: classref-method

:ref:`Image<class_Image>` **pack_image** **(** :ref:`Image<class_Image>` src_rgb, :ref:`Image<class_Image>` src_r, :ref:`bool<class_bool>` invert_green_channel=false **)** |static|

A utility function that returns an Image with the following content:

- RGB channels from ``src_rgb``.

- A channel from ``src_r``.

- G inverted, if specified (eg for converting normal maps between DirectX and OpenGL).

.. rst-class:: classref-item-separator

----

.. _class_Terrain3D_method_set_camera:

.. rst-class:: classref-method
Expand Down
Loading

0 comments on commit 4943cfb

Please sign in to comment.