MultiMesh

Provides high-performance mesh instancing.

MultiMesh provides low-level mesh instancing. Drawing thousands of 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 from each other, performance may be reduced as every single instance will always render (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.

@GodotBaseClass
struct MultiMesh {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

ColorFormat
enum ColorFormat
Constants
enum Constants
CustomDataFormat
enum CustomDataFormat
TransformFormat
enum TransformFormat

Functions

_getColorArray
PoolColorArray _getColorArray()
_getCustomDataArray
PoolColorArray _getCustomDataArray()
_getTransform2dArray
PoolVector2Array _getTransform2dArray()
_getTransformArray
PoolVector3Array _getTransformArray()
_setColorArray
void _setColorArray(PoolColorArray arg0)
_setCustomDataArray
void _setCustomDataArray(PoolColorArray arg0)
_setTransform2dArray
void _setTransform2dArray(PoolVector2Array arg0)
_setTransformArray
void _setTransformArray(PoolVector3Array arg0)
getAabb
AABB getAabb()

Returns the visibility axis-aligned bounding box in local space. See also VisualInstance.getTransformedAabb.

getColorFormat
MultiMesh.ColorFormat getColorFormat()
getCustomDataFormat
MultiMesh.CustomDataFormat getCustomDataFormat()
getInstanceColor
Color getInstanceColor(long instance)

Gets a specific instance's color.

getInstanceCount
long getInstanceCount()
getInstanceCustomData
Color getInstanceCustomData(long instance)

Returns the custom data that has been set for a specific instance.

getInstanceTransform
Transform getInstanceTransform(long instance)

Returns the Transform of a specific instance.

getInstanceTransform2d
Transform2D getInstanceTransform2d(long instance)

Returns the Transform2D of a specific instance.

getMesh
Ref!Mesh getMesh()
getTransformFormat
MultiMesh.TransformFormat getTransformFormat()
getVisibleInstanceCount
long getVisibleInstanceCount()
opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(MultiMesh other)
opEquals
bool opEquals(typeof(null) n)
setAsBulkArray
void setAsBulkArray(PoolRealArray array)

Sets all data related to the instances in one go. This is especially useful when loading the data from disk or preparing the data from GDNative. All data is packed in one large float array. An array may look like this: Transform for instance 1, color data for instance 1, custom data for instance 1, transform for instance 2, color data for instance 2, etc... Transform is stored as 12 floats, Transform2D is stored as 8 floats, COLOR_8BIT / CUSTOM_DATA_8BIT is stored as 1 float (4 bytes as is) and COLOR_FLOAT / CUSTOM_DATA_FLOAT is stored as 4 floats.

setColorFormat
void setColorFormat(long format)
setCustomDataFormat
void setCustomDataFormat(long format)
setInstanceColor
void setInstanceColor(long instance, Color color)

Sets the color of a specific instance by multiplying the mesh's existing vertex colors. For the color to take effect, ensure that colorFormat is non-null on the MultiMesh and SpatialMaterial.vertexColorUseAsAlbedo is true on the material.

setInstanceCount
void setInstanceCount(long count)
setInstanceCustomData
void setInstanceCustomData(long instance, Color custom_data)

Sets custom data for a specific instance. Although Color is used, it is just a container for 4 floating point numbers. The format of the number can change depending on the customdataformat used.

setInstanceTransform
void setInstanceTransform(long instance, Transform transform)

Sets the Transform for a specific instance.

setInstanceTransform2d
void setInstanceTransform2d(long instance, Transform2D transform)

Sets the Transform2D for a specific instance.

setMesh
void setMesh(Mesh mesh)
setTransformFormat
void setTransformFormat(long format)
setVisibleInstanceCount
void setVisibleInstanceCount(long count)
toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

colorArray
PoolColorArray colorArray [@property getter]
PoolColorArray colorArray [@property setter]
colorFormat
MultiMesh.ColorFormat colorFormat [@property getter]
long colorFormat [@property setter]

Format of colors in color array that gets passed to shader.

customDataArray
PoolColorArray customDataArray [@property getter]
PoolColorArray customDataArray [@property setter]
customDataFormat
MultiMesh.CustomDataFormat customDataFormat [@property getter]
long customDataFormat [@property setter]

Format of custom data in custom data array that gets passed to shader.

instanceCount
long instanceCount [@property getter]
long instanceCount [@property setter]

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 visibleInstanceCount.

mesh
Mesh mesh [@property getter]
Mesh mesh [@property setter]

Mesh to be drawn.

transform2dArray
PoolVector2Array transform2dArray [@property getter]
PoolVector2Array transform2dArray [@property setter]
transformArray
PoolVector3Array transformArray [@property getter]
PoolVector3Array transformArray [@property setter]
transformFormat
MultiMesh.TransformFormat transformFormat [@property getter]
long transformFormat [@property setter]

Format of transform used to transform mesh, either 2D or 3D.

visibleInstanceCount
long visibleInstanceCount [@property getter]
long visibleInstanceCount [@property setter]

Limits the number of instances drawn, -1 draws all instances. Changing this does not change the sizes of the buffers.

Static functions

_new
MultiMesh _new()

Construct a new instance of MultiMesh. Note: use memnew!MultiMesh instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta