// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Math/Transform.h" #include "Engine/Core/Math/BoundingSphere.h" #include "Engine/Renderer/DrawCall.h" #include "Engine/Level/Scene/Lightmap.h" /// /// Foliage instanced mesh instance. Packed data with very little of logic. Managed by the foliage chunks and foliage actor itself. /// API_STRUCT(NoPod) struct FLAXENGINE_API FoliageInstance { DECLARE_SCRIPTING_TYPE_NO_SPAWN(FoliageInstance); /// /// The local-space transformation of the mesh relative to the foliage actor. /// API_FIELD() Transform Transform; /// /// The model drawing state. /// GeometryDrawStateData DrawState; /// /// The foliage type index. Foliage types are hold in foliage actor and shared by instances using the same model. /// API_FIELD() int32 Type; /// /// The per-instance random value from range [0;1]. /// API_FIELD() float Random; /// /// The cull distance for this instance. /// float CullDistance; /// /// The cached instance bounds (in world space). /// API_FIELD() BoundingSphere Bounds; /// /// The lightmap entry for the foliage instance. /// LightmapEntry Lightmap; public: bool operator==(const FoliageInstance& v) const { return Type == v.Type && Math::NearEqual(Random, v.Random) && Transform == v.Transform; } /// /// Determines whether this foliage instance has valid lightmap data. /// FORCE_INLINE bool HasLightmap() const { return Lightmap.TextureIndex != INVALID_INDEX; } /// /// Removes the lightmap data from the foliage instance. /// FORCE_INLINE void RemoveLightmap() { Lightmap.TextureIndex = INVALID_INDEX; } };