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
| Type | Name | Description |
|---|---|---|
bool | enabled | Default true. |
Material* | material | Primary 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> | ownedMaterial | Strong 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. |
Mat4 | primaryLocalTransform | Node 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). |
bool | hasPrimaryLocalTransform | Default false. |
bool | primaryCollisionOnly | The primary submesh is a collision piece (see MeshSubmesh::collisionOnly). Default false. |
std::vector<MeshSubmesh> | additionalSubmeshes | Submeshes beyond index 0 (empty for primitives / single-mesh imports). |
std::string | modelPath | VFS 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::string | meshType | Primitive type name ("cube", "sphere", "cone", etc.) — empty for file-based meshes. Used by runtime to create primitive meshes without editor resource cache. |
int32_t | modelNodeIndex | Index 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> | meshAsset | Asset reference (non-empty when loaded from asset pipeline) |
std::string | materialPath | Optional 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> | materialSlotPaths | Overrides 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* | materialOverride | Resolved cache for materialPath (null until resolved; re-resolved when materialPath changes). RUNTIME_ONLY — never serialized. Default nullptr. |
std::string | resolvedMaterialPath | guards re-resolve |
std::vector<Material*> | slotMaterialOverrides | The same pair per further slot, sized with materialSlotPaths. |
std::vector<std::string> | resolvedSlotPaths | |
uint32_t | lightChannels | Light 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. |
bool | castShadows | Whether 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. |
bool | receiveShadows | Whether 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. |
bool | renderCustomDepth | UE'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_t | customStencil | Default 0. |
bool | receiveDecals | UE'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. |
bool | castCapsuleShadows | UE'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. |
float | capsuleRadiusScale | Default 1.0f. |
Public functions
| Returns | Name | Description |
|---|---|---|
void | AdoptMaterial | The view is set FROM the Ref, never the reverse (see MaterialComponent). |
bool | IsApproxIdentity | 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). |
void | AssignFromMeshAsset | Replace all submeshes from a loaded MeshAsset. |
void | ClearAdditionalSubmeshes | Drop 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