struct

MeshRendererComponent

Engine-level mesh renderer component for scene rendering

Module
SceneTypes
Header
#include "SceneTypes/Components/MeshRendererComponent.h"
Namespace
Mowo
Reflection
Reflected by MowoHeaderTool

Properties

TypeNameDescription
boolenabledDefault true.
Material*materialPrimary submesh — kept as direct fields for primitives and back-compat. For multi-submesh models, this is index 0. material is a VIEW: it may point at an asset-owned material (ModelResource/MaterialAsset keep those alive) or at an inline per-entity material, whose allocation lives in ownedMaterial below. Default nullptr.
Ref<GPUMesh>gpuMesh
Ref<Material>ownedMaterialStrong reference to an inline (non-asset) material. MaterialComponent and MeshRenderer hold ONE object through it and the last component to die frees it — with its GPU texture refs, exactly once — instead of leaking it for the process lifetime. Null whenever material views an asset-owned material: the asset holds that Ref and a reimport keeps the object in place, so the view stays valid.
Mat4primaryLocalTransformNode transform of the primary submesh (the source model's root axis/ unit correction lands here for flat model_path assignments). Identity for primitives. Default Mat4(1.0f).
boolhasPrimaryLocalTransformDefault false.
boolprimaryCollisionOnlyThe primary submesh is a collision piece (see MeshSubmesh::collisionOnly). Default false.
std::vector<MeshSubmesh>additionalSubmeshesSubmeshes beyond index 0 (empty for primitives / single-mesh imports).
std::stringmodelPathVFS path of the source model (empty for primitives). Used for serialization round-trip through the Asset system. Every inspector field carries a category: Details lays a component whose fields are all categorised out as one section per category (Static Mesh, Materials, Lighting, Rendering), the way UE shows a static mesh.
std::stringmeshTypePrimitive type name ("cube", "sphere", "cone", etc.) — empty for file-based meshes. Used by runtime to create primitive meshes without editor resource cache.
int32_tmodelNodeIndexIndex into the source model's node tree (ModelResource::GetNodes) when this entity is one node of a model instantiated as a hierarchy (UE-style FBX with several mesh objects). -1 = whole model on a single entity (the flat default, back-compat). When >= 0 the resolver pulls ONLY that node's submeshes and leaves their local transforms at identity — the node's own placement lives in this entity's TransformComponent and the parent chain, so the node transform must not be baked in a second time. Default -1.
AssetHandle<MeshAsset>meshAssetAsset reference (non-empty when loaded from asset pipeline)
std::stringmaterialPathOptional material-asset override (.mdfmat). When set, replaces the material the model imported with for the PRIMARY submesh — this is how a MaterialAsset / material instance gets dropped onto a mesh from the editor (the inspector renders an asset slot for any MOWO_ASSET_REF string field). Empty = use the model's own material. Lazy-resolved into materialOverride at render time (Scene::OnRender), mirroring decals. Hidden from the generic rows: Details edits it as Element 0 of the Materials section, beside the model's other slots.
std::vector<std::string>materialSlotPathsOverrides for the model's further material slots: entry i replaces the material of submesh i + 1 (slot 0 is materialPath). An empty entry keeps the model's own material.
Material*materialOverrideResolved cache for materialPath (null until resolved; re-resolved when materialPath changes). RUNTIME_ONLY — never serialized. Default nullptr.
std::stringresolvedMaterialPathguards re-resolve
std::vector<Material*>slotMaterialOverridesThe same pair per further slot, sized with materialSlotPaths.
std::vector<std::string>resolvedSlotPaths
uint32_tlightChannelsLight channel bitmask — the mesh is only lit by lights whose own channel mask shares a bit. Default 1 (channel 0) matches the default light mask. Enforced per pixel in the deferred pass: the low 4 bits ride the G-Buffer's RT3.B low nibble. 0 means "all channels". Default 1.
boolcastShadowsWhether this mesh renders into shadow maps (CSM, local atlas, VSM). Rides every DrawCommand the entity submits; the actor-level MStaticMeshComponent mirrors its own castShadows into this field. Default true.
boolreceiveShadowsWhether shadows fall ON this mesh. Rides the draw into the G-Buffer as the RT3.B anisotropy sentinel (FLightChannels), so the deferred and MegaLights passes skip every shadow term for its pixels — a first-person weapon or a ground card that must not catch the world's shadows. The trade is that an opted-out surface shades isotropically. Default true.
boolrenderCustomDepthUE's Render CustomDepth Pass / CustomDepth Stencil Value: the mesh also rasterises into the custom depth target, depth-tested only against the other opted-in meshes, with its stencil value in the R8 companion. A post-process material reads both (Scene Depth / Custom Depth / Custom Stencil nodes) — outlines, x-ray, "highlight the objective through the wall" all key on this — and the CustomDepth / CustomStencil view modes show them. Off by default: the targets are allocated on first use. Default false.
uint32_tcustomStencilDefault 0.
boolreceiveDecalsUE's Receives Decals. Off, the mesh rasterises into the decal receiver mask and every projector discards on its pixels — a character walking through a scorch mark keeps its own surface. Default true.
boolcastCapsuleShadowsUE's Cast Capsule Shadows (skeletal meshes only — a static mesh has no bones to build capsules from): the posed skeleton casts soft capsule occlusion on the sky light and a soft sun shadow, which is what grounds a character the shadow map is too coarse to. The radius scale thickens or thins every capsule (1 = a capsule about a fifth as thick as its bone is long). Default false.
floatcapsuleRadiusScaleDefault 1.0f.

Public functions

ReturnsNameDescription
voidAdoptMaterialThe view is set FROM the Ref, never the reverse (see MaterialComponent).
boolIsApproxIdentityTrue when a transform differs from identity by more than a small epsilon — lets the flat-drop path skip the per-submesh multiply (and keep AABB picking exact) for models whose node transform is identity (legacy v1 .mmodel with no node tree, primitives).
voidAssignFromMeshAssetReplace all submeshes from a loaded MeshAsset.
voidClearAdditionalSubmeshesDrop only the multi-submesh data, leaving primary mesh/material in place.

Function details

AdoptMaterial

C++
void AdoptMaterial(Ref<Material> mat)

The view is set FROM the Ref, never the reverse (see MaterialComponent).

IsApproxIdentity

C++
static bool IsApproxIdentity(const Mat4& m)

True when a transform differs from identity by more than a small epsilon — lets the flat-drop path skip the per-submesh multiply (and keep AABB picking exact) for models whose node transform is identity (legacy v1 .mmodel with no node tree, primitives).

AssignFromMeshAsset

C++
void AssignFromMeshAsset(const Ref<MeshAsset>& asset)

Replace all submeshes from a loaded MeshAsset. Drops a model into the primary slot + additional slots in one shot, so every submesh of the imported model becomes visible.

ClearAdditionalSubmeshes

C++
void ClearAdditionalSubmeshes()

Drop only the multi-submesh data, leaving primary mesh/material in place. Used when switching to a primitive or clearing a model assignment.

Generated from SceneTypes/Components/MeshRendererComponent.h via scenetypes.json · Nov 4, 2026Version 1.0.0