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

Implement Instancer LODs #604

Merged
merged 5 commits into from
Feb 17, 2025
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
11 changes: 11 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ help:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

install:
python -m venv .venv && \
. .venv/bin/activate && \
pip install -r requirements.txt && \
echo "Setup complete. Remember to run 'source .venv/bin/activate' to activate the virtual environment."

serve:
source ./.venv/bin/activate && \
make html && \
python -m http.server --directory _build/html
19 changes: 19 additions & 0 deletions doc/api/class_terrain3d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Properties
+-------------------------------------------------------------+----------------------------------------------------------------------------+-----------------+
| ``bool`` | :ref:`show_instancer_grid<class_Terrain3D_property_show_instancer_grid>` | ``false`` |
+-------------------------------------------------------------+----------------------------------------------------------------------------+-----------------+
| ``bool`` | :ref:`show_instances<class_Terrain3D_property_show_instances>` | ``true`` |
+-------------------------------------------------------------+----------------------------------------------------------------------------+-----------------+
| ``bool`` | :ref:`show_navigation<class_Terrain3D_property_show_navigation>` | ``false`` |
+-------------------------------------------------------------+----------------------------------------------------------------------------+-----------------+
| ``bool`` | :ref:`show_region_grid<class_Terrain3D_property_show_region_grid>` | ``false`` |
Expand Down Expand Up @@ -852,6 +854,23 @@ Alias for :ref:`Terrain3DMaterial.show_instancer_grid<class_Terrain3DMaterial_pr

----

.. _class_Terrain3D_property_show_instances:

.. rst-class:: classref-property

``bool`` **show_instances** = ``true`` :ref:`🔗<class_Terrain3D_property_show_instances>`

.. rst-class:: classref-property-setget

- |void| **set_show_instances**\ (\ value\: ``bool``\ )
- ``bool`` **get_show_instances**\ (\ )

Shows or hides all instancer meshes.

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

----

.. _class_Terrain3D_property_show_navigation:

.. rst-class:: classref-property
Expand Down
12 changes: 10 additions & 2 deletions doc/api/class_terrain3dinstancer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Data is currently stored in :ref:`Terrain3DRegion.instances<class_Terrain3DRegio

\ **The methods available for adding instances are:**\

- :ref:`add_instances<class_Terrain3DInstancer_method_add_instances>` - A feature rich function designed for hand editing via Terrain3DEditor.
- :ref:`add_transforms<class_Terrain3DInstancer_method_add_transforms>` - Accepts your list of transforms and parses them by region and cell location and stores in our data storage. Recommended for general API instancing.

- :ref:`add_multimesh<class_Terrain3DInstancer_method_add_multimesh>` - Pulls the transforms out of your MultiMesh and calls add_transforms.

- :ref:`add_transforms<class_Terrain3DInstancer_method_add_transforms>` - Accepts your list of transforms and parses them into our data storage.
- :ref:`add_instances<class_Terrain3DInstancer_method_add_instances>` - A feature rich function designed for hand editing via Terrain3DEditor.

- Creating your own instance data and inserting it directly into :ref:`Terrain3DRegion.instances<class_Terrain3DRegion_property_instances>`. It's not difficult to do this in GDScript, but a thorough understanding of the C++ code in this class is recommended.

Expand All @@ -37,8 +37,16 @@ Data is currently stored in :ref:`Terrain3DRegion.instances<class_Terrain3DRegio

- :ref:`clear_by_mesh<class_Terrain3DInstancer_method_clear_by_mesh>`, :ref:`clear_by_location<class_Terrain3DInstancer_method_clear_by_location>` - To erase large sections of instances

- Editing :ref:`Terrain3DRegion.instances<class_Terrain3DRegion_property_instances>` directly.

After modifying region data, run :ref:`force_update_mmis<class_Terrain3DInstancer_method_force_update_mmis>` to rebuild the MultiMeshInstance3Ds.

\ **Read More:**\

- **Tutorial:** `Foliage Instancing <https://terrain3d.readthedocs.io/en/stable/docs/instancer.html>`__\

- **Godot Reference:** `MultiMesh <https://docs.godotengine.org/en/stable/classes/class_multimesh.html>`__

.. rst-class:: classref-reftable-group

Methods
Expand Down
428 changes: 387 additions & 41 deletions doc/api/class_terrain3dmeshasset.rst

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions doc/doc_classes/Terrain3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@
<member name="show_instancer_grid" type="bool" setter="set_show_instancer_grid" getter="get_show_instancer_grid" default="false">
Alias for [member Terrain3DMaterial.show_instancer_grid].
</member>
<member name="show_instances" type="bool" setter="set_show_instances" getter="get_show_instances" default="true">
Shows or hides all instancer meshes.
</member>
<member name="show_navigation" type="bool" setter="set_show_navigation" getter="get_show_navigation" default="false">
Alias for [member Terrain3DMaterial.show_navigation].
</member>
Expand Down
8 changes: 6 additions & 2 deletions doc/doc_classes/Terrain3DInstancer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
This class places mesh instances defined in the Terrain3D asset dock into MultiMeshInstance3Ds on the ground.
Data is currently stored in [member Terrain3DRegion.instances] and loaded into MultiMeshInstances, which are attached to the scene tree and managed by this class.
[b]The methods available for adding instances are:[/b]
- [method add_instances] - A feature rich function designed for hand editing via Terrain3DEditor.
- [method add_transforms] - Accepts your list of transforms and parses them by region and cell location and stores in our data storage. Recommended for general API instancing.
- [method add_multimesh] - Pulls the transforms out of your MultiMesh and calls add_transforms.
- [method add_transforms] - Accepts your list of transforms and parses them into our data storage.
- [method add_instances] - A feature rich function designed for hand editing via Terrain3DEditor.
- Creating your own instance data and inserting it directly into [member Terrain3DRegion.instances]. It's not difficult to do this in GDScript, but a thorough understanding of the C++ code in this class is recommended.
[b]The methods available for removing instances are:[/b]
- [method remove_instances] - Like add_instances, this is can be used procedurally but is designed for hand editing.
- [method clear_by_mesh], [method clear_by_location] - To erase large sections of instances
- Editing [member Terrain3DRegion.instances] directly.
After modifying region data, run [method force_update_mmis] to rebuild the MultiMeshInstance3Ds.
[b]Read More:[/b]
- [b]Tutorial:[/b] [url=https://terrain3d.readthedocs.io/en/stable/docs/instancer.html]Foliage Instancing[/url]
- [b]Godot Reference:[/b] [url=https://docs.godotengine.org/en/stable/classes/class_multimesh.html]MultiMesh[/url]
</description>
<tutorials>
</tutorials>
Expand Down
Loading