/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include namespace Blast { class BlastFamily; //! Interface that creates new actors and calculates necessary parts of actor description class BlastActorFactory { public: virtual ~BlastActorFactory() = default; //! Creates actor based on a description. Caller has to call DestroyActor on the actor afterwards. virtual BlastActor* CreateActor(const BlastActorDesc& desc) = 0; //! Destroys an existing actor. virtual void DestroyActor(BlastActor* actor) = 0; //! Calculate chunks that are going to simulate this actor. See more at BlastActorDesc::m_chunkIndices. virtual AZStd::vector CalculateVisibleChunks( const BlastFamily& blastFamily, const Nv::Blast::TkActor& tkActor) const = 0; //! Calculate whether an actor represented by a single leaf chunk. See more at BlastActorDesc::m_isLeafChunk. virtual bool CalculateIsLeafChunk( const Nv::Blast::TkActor& tkActor, const AZStd::vector& chunkIndices) const = 0; //! Calculate whether actor should be simulated by a static or dynamic rigid body. See more at //! BlastActorDesc::m_isStatic. virtual bool CalculateIsStatic( const BlastFamily& blastFamily, const Nv::Blast::TkActor& tkActor, const AZStd::vector& chunkIndices) const = 0; //! Calculate components that the entity simulating the actor should have on it. See more at //! BlastActorDesc::m_entity. virtual AZStd::vector CalculateComponents(bool isStatic) const = 0; }; class BlastActorFactoryImpl : public BlastActorFactory { public: BlastActor* CreateActor(const BlastActorDesc& desc) override; void DestroyActor(BlastActor* actor) override; AZStd::vector CalculateVisibleChunks( const BlastFamily& blastFamily, const Nv::Blast::TkActor& tkActor) const override; bool CalculateIsLeafChunk( const Nv::Blast::TkActor& tkActor, const AZStd::vector& chunkIndices) const override; bool CalculateIsStatic( const BlastFamily& blastFamily, const Nv::Blast::TkActor& tkActor, const AZStd::vector& chunkIndices) const override; AZStd::vector CalculateComponents(bool isStatic) const override; private: bool SupportGraphHasStaticActor(const BlastFamily& blastFamily, const Nv::Blast::TkActor& tkActor) const; bool VisibleChunksHasStaticActor( const BlastFamily& blastFamily, const AZStd::vector& chunkIndices) const; }; } // namespace Blast