/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/RendererCore/Meshes/LodMeshComponent.h
89 строк
4 KB
C-Core
Render instance data refactor (#1713)
19 ноя 2025, 20:31
Не верифицирован
19 ноя 2025, 20:31
b8e6103
Код
Авторство
О чём код?
#pragma once #include <Core/World/World.h> #include <RendererCore/Meshes/MeshComponentBase.h> using ezLodMeshComponentManager = ezComponentManager<class ezLodMeshComponent, ezBlockStorageType::Compact>; struct ezLodMeshLod { ezMeshResourceHandle m_hMesh; // [ property ] float m_fThreshold; // [ property ] }; EZ_DECLARE_REFLECTABLE_TYPE(EZ_RENDERERCORE_DLL, ezLodMeshLod); /// \brief Renders one of several level-of-detail meshes depending on the distance to the camera. /// /// This component is very similar to the ezLodComponent, please read it's description for details. /// The difference is, that this component doesn't switch child object on and off, but rather only selects between different render-meshes. /// As such there is less performance impact for switching between meshes and also the memory overhead for storing LOD information is smaller. /// If it is only desired to switch between meshes, it is also more convenient to work with just a single component. /// /// The component does not allow to place the LOD meshes differently, they all need to have the same origin. /// Compared with the regular ezMeshComponent there is also no way to override the used materials, since each LOD mesh may use different materials. class EZ_RENDERERCORE_DLL ezLodMeshComponent : public ezRenderComponent { EZ_DECLARE_COMPONENT_TYPE(ezLodMeshComponent, ezRenderComponent, ezLodMeshComponentManager); ////////////////////////////////////////////////////////////////////////// // ezComponent public: virtual void OnDeactivated() override; virtual void SerializeComponent(ezWorldWriter& inout_stream) const override; virtual void DeserializeComponent(ezWorldReader& inout_stream) override; ////////////////////////////////////////////////////////////////////////// // ezRenderComponent public: virtual ezResult GetLocalBounds(ezBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, ezMsgUpdateLocalBounds& ref_msg) override; ////////////////////////////////////////////////////////////////////////// // ezLodMeshComponent public: ezLodMeshComponent(); ~ezLodMeshComponent(); /// \brief An additional tint color passed to the renderer to modify the mesh. void SetColor(const ezColor& color); // [ property ] const ezColor& GetColor() const; // [ property ] /// \brief An additional vec4 passed to the renderer that can be used by custom material shaders for effects. void SetCustomData(const ezVec4& vData); // [ property ] const ezVec4& GetCustomData() const; // [ property ] /// \brief The sorting depth offset allows to tweak the order in which this mesh is rendered relative to other meshes. /// /// This is mainly useful for transparent objects to render them before or after other meshes. void SetSortingDepthOffset(float fOffset); // [ property ] float GetSortingDepthOffset() const; // [ property ] /// \brief Enables text output to show the current coverage value and selected LOD. void SetShowDebugInfo(bool bShow); // [ property ] bool GetShowDebugInfo() const; // [ property ] /// \brief Disabling the LOD range overlap functionality can make it easier to determine the desired coverage thresholds. void SetOverlapRanges(bool bOverlap); // [ property ] bool GetOverlapRanges() const; // [ property ] void OnMsgSetColor(ezMsgSetColor& ref_msg); // [ msg handler ] void OnMsgSetCustomData(ezMsgSetCustomData& ref_msg); // [ msg handler ] protected: void UpdateSelectedLod(const ezView& view) const; void OnMsgExtractRenderData(ezMsgExtractRenderData& msg) const; ezDynamicArray<ezLodMeshLod> m_Meshes; ezColor m_Color = ezColor::White; ezVec4 m_vCustomData = ezVec4(0, 1, 0, 1); float m_fSortingDepthOffset = 0.0f; ezVec3 m_vBoundsOffset = ezVec3::MakeZero(); float m_fBoundsRadius = 1.0f; mutable ezInt32 m_iCurLod = 0; mutable ezInstanceDataOffset m_InstanceDataOffset; };