:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the MultiMesh.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_MultiMesh: MultiMesh ========= **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` Provides high-performance mesh instancing. Description ----------- MultiMesh provides low-level mesh instancing. Drawing thousands of :ref:`MeshInstance` nodes can be slow, since each object is submitted to the GPU then drawn individually. MultiMesh is much faster as it can draw thousands of instances with a single draw call, resulting in less API overhead. As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object). Since instances may have any behavior, the AABB used for visibility must be provided by the user. Tutorials --------- - :doc:`../tutorials/performance/vertex_animation/animating_thousands_of_fish` - :doc:`../tutorials/performance/using_multimesh` Properties ---------- +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`PackedFloat32Array` | :ref:`buffer` | ``PackedFloat32Array( )`` | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`PackedColorArray` | :ref:`color_array` | | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`PackedColorArray` | :ref:`custom_data_array` | | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`int` | :ref:`instance_count` | ``0`` | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`Mesh` | :ref:`mesh` | | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`PackedVector2Array` | :ref:`transform_2d_array` | | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`PackedVector3Array` | :ref:`transform_array` | | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`TransformFormat` | :ref:`transform_format` | ``0`` | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`bool` | :ref:`use_colors` | ``false`` | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`bool` | :ref:`use_custom_data` | ``false`` | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ | :ref:`int` | :ref:`visible_instance_count` | ``-1`` | +--------------------------------------------------------+--------------------------------------------------------------------------------+----------------------------+ Methods ------- +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`AABB` | :ref:`get_aabb` **(** **)** const | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_instance_color` **(** :ref:`int` instance **)** const | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_instance_custom_data` **(** :ref:`int` instance **)** const | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`get_instance_transform` **(** :ref:`int` instance **)** const | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform2D` | :ref:`get_instance_transform_2d` **(** :ref:`int` instance **)** const | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_instance_color` **(** :ref:`int` instance, :ref:`Color` color **)** | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_instance_custom_data` **(** :ref:`int` instance, :ref:`Color` custom_data **)** | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_instance_transform` **(** :ref:`int` instance, :ref:`Transform` transform **)** | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_instance_transform_2d` **(** :ref:`int` instance, :ref:`Transform2D` transform **)** | +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Enumerations ------------ .. _enum_MultiMesh_TransformFormat: .. _class_MultiMesh_constant_TRANSFORM_2D: .. _class_MultiMesh_constant_TRANSFORM_3D: enum **TransformFormat**: - **TRANSFORM_2D** = **0** --- Use this when using 2D transforms. - **TRANSFORM_3D** = **1** --- Use this when using 3D transforms. Property Descriptions --------------------- .. _class_MultiMesh_property_buffer: - :ref:`PackedFloat32Array` **buffer** +-----------+----------------------------+ | *Default* | ``PackedFloat32Array( )`` | +-----------+----------------------------+ | *Setter* | set_buffer(value) | +-----------+----------------------------+ | *Getter* | get_buffer() | +-----------+----------------------------+ ---- .. _class_MultiMesh_property_color_array: - :ref:`PackedColorArray` **color_array** ---- .. _class_MultiMesh_property_custom_data_array: - :ref:`PackedColorArray` **custom_data_array** ---- .. _class_MultiMesh_property_instance_count: - :ref:`int` **instance_count** +-----------+---------------------------+ | *Default* | ``0`` | +-----------+---------------------------+ | *Setter* | set_instance_count(value) | +-----------+---------------------------+ | *Getter* | get_instance_count() | +-----------+---------------------------+ Number of instances that will get drawn. This clears and (re)sizes the buffers. By default, all instances are drawn but you can limit this with :ref:`visible_instance_count`. ---- .. _class_MultiMesh_property_mesh: - :ref:`Mesh` **mesh** +----------+-----------------+ | *Setter* | set_mesh(value) | +----------+-----------------+ | *Getter* | get_mesh() | +----------+-----------------+ Mesh to be drawn. ---- .. _class_MultiMesh_property_transform_2d_array: - :ref:`PackedVector2Array` **transform_2d_array** ---- .. _class_MultiMesh_property_transform_array: - :ref:`PackedVector3Array` **transform_array** ---- .. _class_MultiMesh_property_transform_format: - :ref:`TransformFormat` **transform_format** +-----------+-----------------------------+ | *Default* | ``0`` | +-----------+-----------------------------+ | *Setter* | set_transform_format(value) | +-----------+-----------------------------+ | *Getter* | get_transform_format() | +-----------+-----------------------------+ Format of transform used to transform mesh, either 2D or 3D. ---- .. _class_MultiMesh_property_use_colors: - :ref:`bool` **use_colors** +-----------+-----------------------+ | *Default* | ``false`` | +-----------+-----------------------+ | *Setter* | set_use_colors(value) | +-----------+-----------------------+ | *Getter* | is_using_colors() | +-----------+-----------------------+ If ``true``, the ``MultiMesh`` will use color data (see :ref:`color_array`). ---- .. _class_MultiMesh_property_use_custom_data: - :ref:`bool` **use_custom_data** +-----------+----------------------------+ | *Default* | ``false`` | +-----------+----------------------------+ | *Setter* | set_use_custom_data(value) | +-----------+----------------------------+ | *Getter* | is_using_custom_data() | +-----------+----------------------------+ If ``true``, the ``MultiMesh`` will use custom data (see :ref:`custom_data_array`). ---- .. _class_MultiMesh_property_visible_instance_count: - :ref:`int` **visible_instance_count** +-----------+-----------------------------------+ | *Default* | ``-1`` | +-----------+-----------------------------------+ | *Setter* | set_visible_instance_count(value) | +-----------+-----------------------------------+ | *Getter* | get_visible_instance_count() | +-----------+-----------------------------------+ Limits the number of instances drawn, -1 draws all instances. Changing this does not change the sizes of the buffers. Method Descriptions ------------------- .. _class_MultiMesh_method_get_aabb: - :ref:`AABB` **get_aabb** **(** **)** const Returns the visibility axis-aligned bounding box. ---- .. _class_MultiMesh_method_get_instance_color: - :ref:`Color` **get_instance_color** **(** :ref:`int` instance **)** const Gets a specific instance's color. ---- .. _class_MultiMesh_method_get_instance_custom_data: - :ref:`Color` **get_instance_custom_data** **(** :ref:`int` instance **)** const Returns the custom data that has been set for a specific instance. ---- .. _class_MultiMesh_method_get_instance_transform: - :ref:`Transform` **get_instance_transform** **(** :ref:`int` instance **)** const Returns the :ref:`Transform` of a specific instance. ---- .. _class_MultiMesh_method_get_instance_transform_2d: - :ref:`Transform2D` **get_instance_transform_2d** **(** :ref:`int` instance **)** const Returns the :ref:`Transform2D` of a specific instance. ---- .. _class_MultiMesh_method_set_instance_color: - void **set_instance_color** **(** :ref:`int` instance, :ref:`Color` color **)** Sets the color of a specific instance. For the color to take effect, ensure that :ref:`use_colors` is ``true`` on the ``MultiMesh`` and :ref:`BaseMaterial3D.vertex_color_use_as_albedo` is ``true`` on the material. ---- .. _class_MultiMesh_method_set_instance_custom_data: - void **set_instance_custom_data** **(** :ref:`int` instance, :ref:`Color` custom_data **)** Sets custom data for a specific instance. Although :ref:`Color` is used, it is just a container for 4 floating point numbers. For the custom data to be used, ensure that :ref:`use_custom_data` is ``true``. ---- .. _class_MultiMesh_method_set_instance_transform: - void **set_instance_transform** **(** :ref:`int` instance, :ref:`Transform` transform **)** Sets the :ref:`Transform` for a specific instance. ---- .. _class_MultiMesh_method_set_instance_transform_2d: - void **set_instance_transform_2d** **(** :ref:`int` instance, :ref:`Transform2D` transform **)** Sets the :ref:`Transform2D` for a specific instance.