UStaticMeshComponent

StaticMeshComponent is used to create an instance of a [UStaticMesh](API\Runtime\Engine\Engine\UStaticMesh).

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

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

Include

#include "Components/StaticMeshComponent.h"

Syntax

class UStaticMeshComponent : public UMeshComponent

Remarks

StaticMeshComponent is used to create an instance of a UStaticMesh. A static mesh is a piece of geometry that consists of a static set of polygons.

Variables

Name Description

Public variable

uint8: 1

 

bCastDistanceFieldIndirectShadow

Whether to use the mesh distance field representation (when present) for shadowing indirect lighting (from lightmaps or skylight) on Movable components.

Public variable

uint8: 1

 

bCustomOverrideVertexColorPerLOD

The component has some custom painting on LODs or not.

Public variable

uint8: 1

 

bDisallowMeshPaintPerInstance

If true, mesh painting is disallowed on this instance.

Public variable

uint8: 1

 

bDisplayPhysicalMaterialMasks

Public variable

uint8: 1

 

bDisplayVertexColors

Public variable

uint8: 1

 

bDrawMeshCollisionIfComplex

Draw mesh collision if used for complex collision

Public variable

uint8: 1

 

bDrawMeshCollisionIfSimple

Draw mesh collision if used for simple collision

Public variable

uint8: 1

 

bEvaluateWorldPositionOffset

Public variable

uint8: 1

 

bForceNavigationObstacle

Allows overriding navigation export behavior per component: full collisions or dynamic obstacle

Public variable

uint8: 1

 

bIgnoreInstanceForTextureStreaming

Ignore this instance of this static mesh when calculating streaming information.

Public variable

uint8: 1

 

bOverrideDistanceFieldSelfShadowBias

Whether to override the DistanceFieldSelfShadowBias setting of the static mesh asset with the DistanceFieldSelfShadowBias of this component.

Public variable

uint8: 1

 

bOverrideLightMapRes

Whether to override the lightmap resolution defined in the static mesh.

Public variable

uint8: 1

 

bOverrideMinLOD

Whether to override the MinLOD setting of the static mesh asset with the MinLOD of this component.

Public variable

uint8: 1

 

bOverrideNavigationExport

If true, bForceNavigationObstacle flag will take priority over navigation data stored in StaticMesh

Public variable

uint8: 1

 

bOverrideWireframeColor

If true, WireframeColorOverride will be used.

Public variable

uint8: 1

 

bReverseCulling

Controls whether the static mesh component's backface culling should be reversed

Public variable

uint8: 1

 

bUseDefaultCollision

Use the collision profile specified in the StaticMesh asset.

Public variable

uint8: 1

 

bUseSubDivisions

Whether to use subdivisions or just the triangle's vertices.

Public variable

float

 

DistanceFieldIndirectShadowMinVisibility

Controls how dark the dynamic indirect shadow can be.

Public variable

float

 

DistanceFieldSelfShadowBias

Useful for reducing self shadowing from distance field methods when using world position offset to animate the mesh's vertices.

Public variable

int32

 

ForcedLodModel

If 0, auto-select LOD level. if >0, force to (ForcedLodModel-1).

Public variable

FLightmassPrimi...

 

LightmassSettings

The Lightmass settings for this object.

Public variable

TArray< struct ...

 

LODData

Static mesh LOD data. Contains static lighting data along with instanced mesh vertex colors.

Public variable

int32

 

MaterialIndexPreview

Index of the material to preview.

Public variable

TArray< uint32 ...

 

MaterialStreamingRelativeBoxes

Material Bounds used for texture streaming.

Public variable

int32

 

MinLOD

Specifies the smallest LOD that will be used for this component.

Public variable

int32

 

OverriddenLightMapRes

Light map resolution to use on this component, used if bOverrideLightMapRes is true and there is a valid StaticMesh.

Public variable

int32

 

SectionIndexPreview

Index of the section to preview.

Public variable

int32

 

SelectedEditorMaterial

The material currently selected in the Editor. Used for highlighting

Public variable

int32

 

SelectedEditorSection

The section currently selected in the Editor. Used for highlighting

Public variable

FString

 

StaticMeshDerivedDataKey

Derived data key of the static mesh, used to determine if an update from the source static mesh is required.

Public variable

int32

 

StaticMeshImportVersion

The import version of the static mesh when it was assign this is update when:

Public variable

float

 

StreamingDistanceMultiplier

Allows adjusting the desired streaming distance of streaming textures that uses UV 0.

Public variable

TArray< FStream...

 

StreamingTextureData

The list of texture, bounds and scales. As computed in the texture streaming build process.

Public variable

int32

 

SubDivisionStepSize

Subdivision step size for static vertex lighting.

Public variable

FColor

 

WireframeColorOverride

Wireframe color to use if bOverrideWireframeColor is true

Constructors

Name Description

Public function

UStaticMeshComponent

(
    const FObjectInitializer& ObjectIn...
)

Destructors

Name Description

Public function Virtual

~UStaticMeshComponent()

Functions

Name Description

Public function Static

void

 

AddReferencedObjects

(
    UObject* InThis,
    FReferenceCollector& Collector
)

Public function Virtual

FStaticMeshS...

 

AllocateStaticLightingMesh

(
    int32 LODIndex,
    const TArray< ULightComponent*...
)

Allocates an implementation of FStaticLightingMesh that will handle static lighting for this component

Public function

void

 

ApplyComponentInstanceData

Public function

void

 

CachePaintedDataIfNecessary()

Save off the data painted on to this mesh per LOD if necessary

Public function

void

 

CopyInstanceVertexColorsIfCompatible

(
    UStaticMeshComponent* SourceCo...
)

Copies instance vertex colors from the SourceComponent into this component

Public function

bool

 

FixupOverrideColorsIfNecessary

(
    bool bRebuildingStaticMesh
)

Update the vertex override colors if necessary (i.e. vertices from source mesh have changed from override colors)

Public function Const

int32

 

GetBlueprintCreatedComponentIndex()

Get this components index in its parents blueprint created components array (used for matching instance data)

Public function Virtual Const

bool

 

GetEstimatedLightAndShadowMapMemoryUsage

(
    int32& TextureLightMapMemoryUsage,
    int32& TextureShadowMapMemoryUsage,
    int32& VertexLightMapMemoryUsage,
    int32& VertexShadowMapMemoryUsage,
    int32& StaticLightingResolution,
    bool& bIsUsingTextureMapping,
    bool& bHasLightmapTexCoords
)

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

Public function Virtual Const

void

 

GetEstimatedLightMapResolution

(
    int32& Width,
    int32& Height
)

Returns the lightmap resolution used for this primitive instance in the case of it supporting texture light/ shadow maps.

Public function Const

void

 

GetLocalBounds

(
    FVector& Min,
    FVector& Max
)

Get Local bounds

Public function Static

const FName

 

GetMemberNameChecked_StaticMesh()

Helper function to get the FName of the private static mesh member

Public function Const

const FMeshM...

 

GetMeshMapBuildData

(
    const FStaticMeshComponentLODInfo&...,
    bool bCheckForResourceCluster
)

Public function Const

UStaticMeshS...

 

GetSocketByName

(
    FName InSocketName
)

Returns the named socket on the static mesh component.

Public function Virtual

void

 

GetStaticLightingInfo

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

Public function Const

UStaticMesh ...

 

GetStaticMesh()

Get the StaticMesh used by this instance.

Public function Virtual Const

void

 

GetTextureLightAndShadowMapMemoryUsage

(
    int32 InWidth,
    int32 InHeight,
    int32& OutLightMapMemoryUsage,
    int32& OutShadowMapMemoryUsage
)

Get the memory used for texture-based light and shadow maps of the given width and height

Public function Virtual Const

float

 

GetTextureStreamingTransformScale()

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

Public function Const

FColor

 

GetWireframeColor()

Returns the wireframe color to use for this component.

Public function Virtual Const

bool

 

HasLightmapTextureCoordinates()

Returns true if the static mesh the component uses has valid lightmap texture coordinates

Public function

void

 

OnRep_StaticMesh

(
    UStaticMesh* OldStaticMesh
)

Public function Virtual

FOnStaticMes...

 

OnStaticMeshChanged()

Public function

void

 

ReleaseResources()

Public function

void

 

RemoveInstanceVertexColors()

Removes instance vertex colors from all LODs

Public function

void

 

RemoveInstanceVertexColorsFromLOD

(
    int32 LODToRemoveColorsFrom
)

Removes instance vertex colors from the specified LOD

Public function

bool

 

RequiresOverrideVertexColorsFixup()

Determines whether any of the component's LODs require override vertex color fixups

Public function

void

 

SetDistanceFieldSelfShadowBias

(
    float NewValue
)

Sets the component's DistanceFieldSelfShadowBias.

Public function

void

 

SetEvaluateWorldPositionOffsetInRayTracing

(
    bool NewValue
)

Public function

void

 

SetForcedLodModel

(
    int32 NewForcedLodModel
)

Public function

bool

 

SetLODDataCount

(
    const uint32 MinSize,
    const uint32 MaxSize
)

Add or remove elements to have the size in the specified range.

Public function

void

 

SetMaterialPreview

(
    int32 InMaterialIndexPreview
)

Sets the value of the MaterialIndexPreview flag and reattaches the component as necessary.

Public function

void

 

SetReverseCulling

(
    bool ReverseCulling
)

Set forced reverse culling

Public function

void

 

SetSectionPreview

(
    int32 InSectionIndexPreview
)

Sets the value of the SectionIndexPreview flag and reattaches the component as necessary.

Public function Virtual

bool

 

SetStaticLightingMapping

(
    bool bTextureMapping,
    int32 ResolutionToUse
)

Switches the static mesh component to use either Texture or Vertex static lighting.

Public function Virtual

bool

 

SetStaticMesh

(
    UStaticMesh* NewMesh
)

Change the StaticMesh used by this instance.

Public function Virtual

bool

 

SupportsDefaultCollision()

Whether or not the component supports default collision from its static mesh asset

Public function Virtual

bool

 

SupportsDitheredLODTransitions

(
    ERHIFeatureLevel::Type FeatureLevel
)

Whether we can support dithered LOD transitions (default behavior checks all materials).

Public function

void

 

UpdateCollisionFromStaticMesh()

Sets the BodyInstance to use the mesh's body setup for external collision information

Public function Virtual Const

bool

 

UsesTextureLightmaps

(
    int32 InWidth,
    int32 InHeight
)

Returns true if the component uses texture lightmaps

Overridden from UMeshComponent

Name Description

Public function Virtual Const

int32

 

GetMaterialIndex

(
    FName MaterialSlotName
)

Public function Virtual Const

TArray< FNam...

 

GetMaterialSlotNames()

Public function Virtual Const

bool

 

GetMaterialStreamingData

(
    int32 MaterialIndex,
    FPrimitiveMaterialInfo& MaterialDa...
)

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

Public function Virtual Const

bool

 

IsMaterialSlotNameValid

(
    FName MaterialSlotName
)

Overridden from UPrimitiveComponent

Name Description

Public function Virtual Const

void

 

AddMapBuildDataGUIDs

(
    TSet< FGuid >& InGUIDs
)

Add the used GUIDs from UMapBuildDataRegistry::MeshBuildData.

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 Const

bool

 

ComponentIsTouchingSelectionBox

(
    const FBox& InSelBBox,
    const FEngineShowFlags& ShowFlags,
    const bool bConsiderOnlyBSP,
    const bool bMustEncompassEntireComp...
)

Determines whether the supplied bounding box intersects with the component.

Public function Virtual Const

bool

 

ComponentIsTouchingSelectionFrustum

(
    const FConvexVolume& InFrustum,
    const FEngineShowFlags& ShowFlags,
    const bool bConsiderOnlyBSP,
    const bool bMustEncompassEntireComp...
)

Determines whether the supplied frustum intersects with the 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

UBodySetup &...

 

GetBodySetup()

Return the BodySetup to use for this PrimitiveComponent (single body case)

Public function Virtual Const

float

 

GetDiffuseBoost

(
    int32 ElementIndex
)

Gets the diffuse boost for the primitive component.

Public function Virtual Const

float

 

GetEmissiveBoost

(
    int32 ElementIndex
)

Gets the emissive boost for the primitive 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

bool

 

GetLightMapResolution

(
    int32& Width,
    int32& Height
)

Returns the lightmap resolution used for this primitive instance in the case of it supporting texture light/ shadow maps.

Public function Virtual Const

UMaterialInt...

 

GetMaterial

(
    int32 ElementIndex
)

Returns the material used by the element at the specified index

Public function Virtual Const

UMaterialInt...

 

GetMaterialFromCollisionFaceIndex

(
    int32 FaceIndex,
    int32& SectionIndex
)

Try and retrieve the material applied to a particular collision face of mesh.

Public function Virtual Const

int32

 

GetNumMaterials()

Return number of material elements in this primitive

Public function Virtual Const

bool

 

GetShadowIndirectOnly()

Disable dynamic shadow casting if the primitive only casts indirect shadows, since dynamic shadows are always shadowing direct lighting

Public function Virtual Const

ELightMapInt...

 

GetStaticLightingType()

Requests whether the component will use texture, vertex or no lightmaps.

Public function Virtual Const

int32

 

GetStaticLightMapResolution()

Returns the static lightmap resolution used for this primitive.

Public function Virtual Const

void

 

GetStreamingRenderAssetInfo

Get the StreaminTexture data.

Public function Virtual Const

void

 

GetUsedMaterials

(
    TArray< UMaterialInterface* > ...,
    bool bGetDebugMaterials
)

Retrieves the materials used in this component

Public function Virtual Const

bool

 

HasValidSettingsForStaticLighting

(
    bool bOverlookInvalidComponents
)

Returns true if the component is static AND has the right static mesh setup to support lightmaps.

Public function Virtual

void

 

SetCollisionProfileName

(
    FName InCollisionProfileName,
    bool bUpdateOverlaps
)

Set Collision Profile Name This function is called by constructors when they set ProfileName This will change current CollisionProfileName to be this, and overwrite Collision Setting

Public function Virtual Const

bool

 

ShouldRecreateProxyOnUpdateTransform()

Determines whether the proxy for this primitive type needs to be recreated whenever the primitive moves.

Public function Virtual Const

bool

 

ShouldRenderSelected()

Return true if the owner is selected and this component is selectable

Protected function Virtual Const

bool

 

SupportsStaticLighting()

Whether the component type supports static lighting.

Public function Virtual Const

bool

 

UsesOnlyUnlitMaterials()

Returns true if only unlit materials are used for rendering, false otherwise.

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 Const

bool

 

DoesSocketExist

(
    FName InSocketName
)

Return true if socket with the given name exists

Public function Virtual Const

FTransform

 

GetSocketTransform

(
    FName InSocketName,
    ERelativeTransformSpace TransformSp...
)

Get world-space socket transform.

Public function Virtual Const

bool

 

HasAnySockets()

Returns true if this component has any sockets

Public function Virtual Const

bool

 

IsPrecomputedLightingValid()

True if our precomputed lighting is up to date

Public function Virtual

void

 

PropagateLightingScenarioChange()

Updates any visuals after the lighting has changed

Public function Virtual Const

void

 

QuerySupportedSockets

Get a list of sockets this component contains

Public function Virtual Const

bool

 

ShouldCollideWhenPlacing()

If true, bounds should be used when placing component/actor in level. Does not affect spawning.

Overridden from UActorComponent

Name Description

Public function Virtual Const

UObject cons...

 

AdditionalStatObject()

Give a readable name for this component, including asset name if applicable

Public function Virtual

void

 

CheckForErrors()

Function that gets called from within Map_Check to allow this actor component to check itself for any potential errors and register them with map check dialog.

Protected function Virtual

void

 

CreateRenderState_Concurrent

(
    FRegisterComponentContext* Con...
)

Used to create any rendering thread information for this component

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

 

InvalidateLightingCacheDetailed

(
    bool bInvalidateBuildEnqueuedLighti...,
    bool bTranslationOnly
)

Called when this actor component has moved, allowing it to discard statically cached lighting information.

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

Protected function Virtual

void

 

OnRegister()

Called when a component is registered, after Scene is set, but before CreateRenderState_Concurrent or OnCreatePhysicsState are called.

Protected function Virtual

void

 

OnUnregister()

Called when a component is unregistered.

Overridden from UObject

Name Description

Public function Virtual Const

bool

 

AreNativePropertiesIdenticalTo

(
    UObject* Other
)

Returns whether native properties are identical to the one of the passed in component.

Public function Virtual

void

 

BeginDestroy()

Called before destroying the object.

Public function Virtual Const

bool

 

CanEditChange

(
    const FProperty* InProperty
)

Called by the editor to query whether a property of this object is allowed to be modified.

Public function Virtual

void

 

ExportCustomProperties

(
    FOutputDevice& Out,
    uint32 Indent
)

Exports the property values for the specified object as text to the output device.

Public function Virtual Const

FString

 

GetDetailedInfoInternal()

This function actually does the work for the GetDetailedInfo() and is virtual.

Public function Virtual

void

 

ImportCustomProperties

(
    const TCHAR* SourceText,
    FFeedbackContext* Warn
)

Exports the property values for the specified object as text to the output device.

Public function Virtual Const

bool

 

IsPostLoadThreadSafe()

Called during async load to determine if PostLoad can be called on the loading thread.

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Public function Virtual

void

 

PostEditUndo()

Called after applying a transaction to the object.

Public function Virtual

void

 

PostInitProperties()

Called after the C++ constructor and after the properties have been initialized, including those loaded from config.

Public function Virtual

void

 

PostLoad()

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

Public function Virtual

void

 

PreEditUndo()

Called before applying a transaction to the object.

Public function Virtual

void

 

PreSave

(
    const ITargetPlatform* TargetP...
)

Presave function.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Overridden from INavRelevantInterface

Name Description

Public function Virtual Const

void

 

GetNavigationData

(
    FNavigationRelevantData& Data
)

Prepare navigation modifiers

Public function Virtual Const

bool

 

IsNavigationRelevant()

Are modifiers active?

Classes

Name

Description

Public class

FOnStaticMeshChanged

Called when the static mesh changes

Deprecated Variables

Name Description

Public variable

TArray< FGuid >

 

IrrelevantLights_DEPRECATED

Public variable

int32

 

PreviousLODLevel_DEPRECATED

LOD that was desired for rendering this StaticMeshComponent last frame.

Deprecated Functions

Name Description

Public function

void

 

UpdatePreCulledData

(
    int32 LODIndex,
    const TArray< uint32 >& PreCulledD...,
    const TArray< int32 >& NumTriangle...
)

This function is no longer used

See Also

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