UInstancedStaticMeshComponent

A component that efficiently renders multiple instances of the same StaticMesh.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Components/InstancedStaticMeshComponent.h

Include

#include "Components/InstancedStaticMeshComponent.h"

Syntax

class UInstancedStaticMeshComponent : public UStaticMeshComponent

Remarks

A component that efficiently renders multiple instances of the same StaticMesh.

Variables

Name Description

Protected variable

TArray< FInstan...

 

CachedMappings

The mappings for all the instances of this component.

Protected variable

friend

 

FInstancedLightMap2D

Protected variable

friend

 

FInstancedShadowMap2D

Protected variable

friend

 

FStaticLightingTextureMapping_InstancedStaticMesh

Public variable

TArray< FBodyIn...

 

InstanceBodies

Physics representation of the instance bodies.

Public variable

TUniquePtr< FSt...

 

InstanceDataBuffers

Buffers with per-instance data laid out for rendering.

Public variable

int32

 

InstanceEndCullDistance

Distance from camera at which each instance completely fades out.

Public variable

TArray< int32 >

 

InstanceReorderTable

Mapping from PerInstanceSMData order to instance render buffer order.

Public variable

int32

 

InstanceStartCullDistance

Distance from camera at which each instance begins to fade out.

Public variable

FInstanceUpdate...

 

InstanceUpdateCmdBuffer

Recorded modifications to per-instance data

Public variable

int32

 

InstancingRandomSeed

Value used to seed the random number stream that generates random numbers for each of this mesh's instances.

Public variable

int32

 

NumCustomDataFloats

Defines the number of floats that will be available per instance for custom data

Protected variable

int32

 

NumPendingLightmaps

Number of pending lightmaps still to be calculated (Apply()'d).

Public variable

TSharedPtr< FPe...

 

PerInstanceRenderData

Render data will be initialized on PostLoad or on demand. Released on the rendering thread.

Public variable

TArray< float >

 

PerInstanceSMCustomData

Array of custom data for instances.

Public variable

TArray< FInstan...

 

PerInstanceSMData

Array of instances, bulk serialized.

Public variable

SIZE_T

 

ProxySize

Tracks outstanding proxysize, as this is a bit hard to do with the fire-and-forget grass.

Public variable

TBitArray

 

SelectedInstances

One bit per instance if the instance is selected.

Constructors

Name Description

Public function

UInstancedStaticMeshComponent

(
    const FObjectInitializer& ObjectIn...
)

Public function

UInstancedStaticMeshComponent

(
    FVTableHelper& Helper
)

Needs implementation in InstancedStaticMesh.cpp to compile UniquePtr for forward declared class

Destructors

Functions

Name Description

Public function Virtual

int32

 

AddInstance

(
    const FTransform& InstanceTransfor...
)

Add an instance to this component. Transform is given in local space of this component.

Protected function

int32

 

AddInstanceInternal

(
    int32 InstanceIndex,
    FInstancedStaticMeshInstanceData&#...,
    const FTransform& InstanceTransfor...
)

Internal version of AddInstance

Public function

int32

 

AddInstanceWorldSpace

(
    const FTransform& WorldTransform
)

Add an instance to this component. Transform is given in world space.

Public function Virtual

void

 

ApplyComponentInstanceData

Applies the cached component instance data to a newly blueprint constructed component.

Protected function

void

 

ApplyLightMapping

(
    FStaticLightingTextureMapping_Insta...,
    ULevel* LightingScenario
)

Public function Virtual

bool

 

BatchUpdateInstancesData

(
    int32 StartInstanceIndex,
    int32 NumInstances,
    FInstancedStaticMeshInstanceData&#...,
    bool bMarkRenderStateDirty,
    bool bTeleport
)

Public function Virtual

bool

 

BatchUpdateInstancesTransform

(
    int32 StartInstanceIndex,
    int32 NumInstances,
    const FTransform& NewInstancesTran...,
    bool bWorldSpace,
    bool bMarkRenderStateDirty,
    bool bTeleport
)

Update the transform for a number of instances.

Public function Virtual

bool

 

BatchUpdateInstancesTransforms

(
    int32 StartInstanceIndex,
    const TArray< FTransform >& NewIns...,
    bool bWorldSpace,
    bool bMarkRenderStateDirty,
    bool bTeleport
)

Update the transform for an array of instances.

Protected function

void

 

BuildRenderData

(
    FStaticMeshInstanceData& OutData,
    TArray< TRefCountPtr< HHitProxy >> ...
)

Build instance buffer for rendering from current component data.

Protected function

void

 

ClearAllInstanceBodies()

Terminate all body instances owned by this component.

Public function Virtual

void

 

ClearInstances()

Clear all instances being rendered by this component.

Public function

void

 

ClearInstanceSelection()

Deselect all instances.

Protected function

void

 

CreateAllInstanceBodies()

Creates body instances for all instances owned by this component.

Protected function

void

 

CreateHitProxyData

(
    TArray< TRefCountPtr< HHitProxy >> ...
)

Public function Const

int32

 

GetInstanceCount()

Get the number of instances in this component.

Public function Const

void

 

GetInstancesMinMaxScale

(
    FVector& MinScale,
    FVector& MaxScale
)

Public function Virtual Const

TArray< int3...

 

GetInstancesOverlappingBox

(
    const FBox& Box,
    bool bBoxInWorldSpace
)

Returns the instances with instance bounds overlapping the specified box.

Public function Virtual Const

TArray< int3...

 

GetInstancesOverlappingSphere

(
    const FVector& Center,
    float Radius,
    bool bSphereInWorldSpace
)

Returns the instances with instance bounds overlapping the specified sphere.

Public function Const

bool

 

GetInstanceTransform

(
    int32 InstanceIndex,
    FTransform& OutInstanceTransform,
    bool bWorldSpace
)

Get the transform for the instance specified.

Protected function Virtual Const

void

 

GetNavigationPerInstanceTransforms

(
    const FBox& AreaBox,
    TArray< FTransform >& InstanceData
)

Handles request from navigation system to gather instance transforms in a specific area box.

Public function Virtual Const

int32

 

GetNumRenderInstances()

Number of instances in the render-side instance buffer.

Public function Const

int32

 

GetRenderIndex

(
    int32 InInstanceIndex
)

Returns the render instance buffer index.

Protected function

void

 

InitInstanceBody

(
    int32 InstanceIdx,
    FBodyInstance* InBodyInstance
)

Initializes the body instance for the specified instance of the static mesh.

Public function

void

 

InitPerInstanceRenderData

(
    bool InitializeFromCurrentData,
    FStaticMeshInstanceData* InSha...,
    bool InRequireCPUAccess
)

Initialize the Per Instance Render Data

Public function Const

bool

 

IsInstanceSelected

(
    int32 InInstanceIndex
)

Check to see if an instance is selected.

Protected function Virtual

void

 

OnPostLoadPerInstanceData()

Creates rendering buffer from serialized data, if any

Protected function Virtual

void

 

PartialNavigationUpdate

(
    int32 InstanceIdx
)

Request to navigation system to update only part of navmesh occupied by specified instance.

Public function Virtual

void

 

PreAllocateInstancesMemory

(
    int32 AddedInstanceCount
)

Preallocated memory to include the new added instances count, to prevent reallloc during the add operation.

Public function

void

 

ReleasePerInstanceRenderData()

Transfers ownership of instance render data to a render thread.

Public function Virtual

bool

 

RemoveInstance

(
    int32 InstanceIndex
)

Remove the instance specified.

Protected function

bool

 

RemoveInstanceInternal

(
    int32 InstanceIndex,
    bool InstanceAlreadyRemoved
)

Internal version of RemoveInstance

Public function

void

 

SelectInstance

(
    bool bInSelected,
    int32 InInstanceIndex,
    int32 InInstanceCount
)

Select/deselect an instance or group of instances.

Protected function

void

 

SerializeRenderData

(
    FArchive& Ar
)

Serialize instance buffer that is used for rendering. Only for cooked content

Public function

void

 

SetCullDistances

(
    int32 StartCullDistance,
    int32 EndCullDistance
)

Sets the fading start and culling end distances for this component.

Public function Virtual

bool

 

SetCustomData

(
    int32 InstanceIndex,
    const TArray< float >& CustomDataF...,
    bool bMarkRenderStateDirty
)

Per Instance Custom Data

Public function Virtual

bool

 

SetCustomDataValue

(
    int32 InstanceIndex,
    int32 CustomDataIndex,
    float CustomDataValue,
    bool bMarkRenderStateDirty
)

Update custom data for specific instance

Public function Virtual

bool

 

UpdateInstanceTransform

(
    int32 InstanceIndex,
    const FTransform& NewInstanceTrans...,
    bool bWorldSpace,
    bool bMarkRenderStateDirty,
    bool bTeleport
)

Update the transform for the instance specified.

Overridden from UStaticMeshComponent

Name Description

Public function Virtual

void

 

GetStaticLightingInfo

(
    FStaticLightingPrimitiveInfo& OutP...,
    const TArray< ULightComponent*...,
    const FLightingBuildOptions& Optio...
)

Public function Virtual Const

float

 

GetTextureStreamingTransformScale()

Get the scale comming form the component, when computing StreamingTexture data.

Overridden from UMeshComponent

Name Description

Public function Virtual Const

bool

 

GetMaterialStreamingData

(
    int32 MaterialIndex,
    FPrimitiveMaterialInfo& MaterialDa...
)

Get material, UV density and bounds for a given material index.

Overridden from UPrimitiveComponent

Name Description

Public function Virtual

bool

 

BuildTextureStreamingData

(
    ETextureStreamingBuildType BuildTyp...,
    EMaterialQualityLevel::Type Quality...,
    ERHIFeatureLevel::Type FeatureLevel,
    TSet< FGuid >& DependentResources
)

Build the data to compute accuracte StreaminTexture data.

Public function Virtual

bool

 

CanEditSimulatePhysics()

Determines whether or not the simulate physics setting can be edited interactively on this component

Public function Virtual

FPrimitiveSc...

 

CreateSceneProxy()

Creates a proxy to represent the primitive to the scene manager in the rendering thread.

Public function Virtual Const

bool

 

DoCustomNavigableGeometryExport

(
    FNavigableGeometryExport& GeomExpo...
)

Collects custom navigable geometry of component.

Public function Virtual Const

void

 

GetLightAndShadowMapMemoryUsage

(
    int32& LightMapMemoryUsage,
    int32& ShadowMapMemoryUsage
)

Returns the light and shadow map memory for this primitive in its out variables.

Public function Virtual Const

void

 

GetStreamingRenderAssetInfo

Get the StreaminTexture data.

Public function Virtual Const

bool

 

SupportsStaticLighting()

Whether the component type supports static lighting.

Overridden from USceneComponent

Name Description

Public function Virtual Const

FBoxSphereBo...

 

CalcBounds

(
    const FTransform& LocalToWorld
)

Calculate the bounds of the component. Default behavior is a bounding box/sphere of zero size.

Public function Virtual

void

 

OnUpdateTransform

(
    EUpdateTransformFlags UpdateTransfo...,
    ETeleportType Teleport
)

Native callback when this component is moved

Public function Virtual

void

 

PropagateLightingScenarioChange()

Updates any visuals after the lighting has changed

Overridden from UActorComponent

Name Description

Public function Virtual Const

TStructOnSco...

 

GetComponentInstanceData()

Called before we throw away components during RerunConstructionScripts, to cache any data we wish to persist across that operation

Public function Virtual

void

 

OnComponentCreated()

Called when a component is created (not loaded). This can happen in the editor or during gameplay

Protected function Virtual

void

 

OnCreatePhysicsState()

Used to create any physics engine information for this component

Protected function Virtual

void

 

OnDestroyPhysicsState()

Used to shut down and physics engine structure for this component

Public function Virtual Const

bool

 

ShouldCreatePhysicsState()

Return true if CreatePhysicsState() should be called.

Overridden from UObject

Name Description

Public function Virtual

void

 

BeginDestroy()

Called before destroying the object.

Public function Virtual

void

 

GetResourceSizeEx

(
    FResourceSizeEx& CumulativeResourc...
)

Get the size of the object/resource for use in memory tools or to display to artists/LDs in the Editor This is the extended version which separates up the used memory into different memory regions (the actual definition of which may be platform specific).

Public function Virtual

void

 

PostDuplicate

(
    bool bDuplicateForPIE
)

Called after duplication & serialization and before PostLoad.

Public function Virtual

void

 

PostEditChangeChainProperty

(
    FPropertyChangedChainEvent& Proper...
)

This alternate version of PostEditChange is called when properties inside structs are modified.

Public function Virtual

void

 

PostEditUndo()

Called after applying a transaction to the object.

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Overridden from INavRelevantInterface

Name Description

Public function Virtual Const

FBox

 

GetNavigationBounds()

Get bounds for navigation octree

Public function Virtual Const

void

 

GetNavigationData

(
    FNavigationRelevantData& Data
)

Prepare navigation modifiers

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss