You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
4.1 KiB
C++
107 lines
4.1 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LmbrCentral/Dependency/DependencyMonitor.h>
|
|
#include <AzCore/Component/Component.h>
|
|
#include <AzCore/Component/TransformBus.h>
|
|
#include <LmbrCentral/Shape/ShapeComponentBus.h>
|
|
#include <LmbrCentral/Dependency/DependencyNotificationBus.h>
|
|
#include <Vegetation/Ebuses/AreaNotificationBus.h>
|
|
#include <Vegetation/Ebuses/AreaBlenderRequestBus.h>
|
|
#include <Vegetation/AreaComponentBase.h>
|
|
|
|
namespace LmbrCentral
|
|
{
|
|
template<typename, typename>
|
|
class EditorWrappedComponentBase;
|
|
}
|
|
|
|
namespace Vegetation
|
|
{
|
|
class AreaBlenderConfig
|
|
: public AreaConfig
|
|
{
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(AreaBlenderConfig, AZ::SystemAllocator, 0);
|
|
AZ_RTTI(AreaBlenderConfig, "{ED57731E-2821-4AA6-9BD6-9203ED0B6AB0}", AreaConfig);
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
bool m_inheritBehavior = true;
|
|
bool m_propagateBehavior = true;
|
|
AZStd::vector<AZ::EntityId> m_vegetationAreaIds;
|
|
|
|
size_t GetNumAreas() const;
|
|
AZ::EntityId GetAreaEntityId(int index) const;
|
|
void RemoveAreaEntityId(int index);
|
|
void AddAreaEntityId(AZ::EntityId entityId);
|
|
};
|
|
|
|
static const AZ::Uuid AreaBlenderComponentTypeId = "{899AA751-BC3F-45D8-9D66-07CE72FDC86D}";
|
|
|
|
/**
|
|
* Placement logic for combined vegetation areas
|
|
*/
|
|
class AreaBlenderComponent
|
|
: public AreaComponentBase
|
|
, private AreaBlenderRequestBus::Handler
|
|
{
|
|
public:
|
|
template<typename, typename> friend class LmbrCentral::EditorWrappedComponentBase;
|
|
AZ_COMPONENT(AreaBlenderComponent, AreaBlenderComponentTypeId, AreaComponentBase);
|
|
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
|
|
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
|
|
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
|
|
AreaBlenderComponent(const AreaBlenderConfig& configuration);
|
|
AreaBlenderComponent() = default;
|
|
~AreaBlenderComponent() = default;
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// AZ::Component interface implementation
|
|
void Activate() override;
|
|
void Deactivate() override;
|
|
bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
|
|
bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// AreaRequestBus
|
|
bool PrepareToClaim(EntityIdStack& stackIds) override;
|
|
void ClaimPositions(EntityIdStack& stackIds, ClaimContext& context) override;
|
|
void UnclaimPosition(const ClaimHandle handle) override;
|
|
|
|
// AreaInfoBus
|
|
AZ::Aabb GetEncompassingAabb() const override;
|
|
AZ::u32 GetProductCount() const override;
|
|
|
|
protected:
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// AreaBlenderRequestBus
|
|
AZ::u32 GetAreaPriority() const override;
|
|
void SetAreaPriority(AZ::u32 priority) override;
|
|
AZ::u32 GetAreaLayer() const override;
|
|
void SetAreaLayer(AZ::u32 layer) override;
|
|
AZ::u32 GetAreaProductCount() const override;
|
|
bool GetInheritBehavior() const override;
|
|
void SetInheritBehavior(bool value) override;
|
|
bool GetPropagateBehavior() const override;
|
|
void SetPropagateBehavior(bool value) override;
|
|
size_t GetNumAreas() const override;
|
|
AZ::EntityId GetAreaEntityId(int index) const override;
|
|
void RemoveAreaEntityId(int index) override;
|
|
void AddAreaEntityId(AZ::EntityId entityId) override;
|
|
|
|
private:
|
|
AreaBlenderConfig m_configuration;
|
|
LmbrCentral::DependencyMonitor m_dependencyMonitor;
|
|
mutable bool m_isRequestInProgress = false; //prevent recursion in case user attaches cyclic dependences
|
|
|
|
void SetupDependencies();
|
|
};
|
|
}
|