Main Page   Class List   Class Members  

  • Main Page
  • User's Guide
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

sdk/extensions/physx/source/physics/NvBlastExtPxFamilyImpl.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 #ifndef NVBLASTEXTPXFAMILYIMPL_H
00030 #define NVBLASTEXTPXFAMILYIMPL_H
00031 
00032 #include "NvBlastExtPxFamily.h"
00033 #include "NvBlastArray.h"
00034 #include "NvBlastHashSet.h"
00035 #include "PxTransform.h"
00036 #include "NvBlastTkEvent.h"
00037 
00038 
00039 using namespace physx;
00040 
00041 
00042 namespace Nv
00043 {
00044 namespace Blast
00045 {
00046 
00047 // Forward declarations
00048 class ExtPxManagerImpl;
00049 class ExtPxActorImpl;
00050 struct PxActorCreateInfo;
00051 
00052 
00053 class ExtPxFamilyImpl final : public ExtPxFamily, TkEventListener
00054 {
00055     NV_NOCOPY(ExtPxFamilyImpl)
00056 
00057 public:
00058     friend ExtPxActorImpl;
00059     friend ExtPxManagerImpl;
00060 
00062 
00063     ExtPxFamilyImpl(ExtPxManagerImpl& manager, TkFamily& tkFamily, ExtPxAsset& pxAsset);
00064     ~ExtPxFamilyImpl();
00065 
00066     virtual void release() override;
00067 
00068 
00070 
00071 //  virtual bool                            spawn(const PxTransform& pose, const ExtPxSpawnSettings& settings) override;
00072     virtual bool                            spawn(const physx::PxTransform& pose, const physx::PxVec3& scale, const ExtPxSpawnSettings& settings) override;
00073     virtual bool                            despawn() override;
00074 
00075 
00076     virtual uint32_t                        getActorCount() const override
00077     {
00078         return m_actors.size();
00079     }
00080 
00081     virtual uint32_t                        getActors(ExtPxActor** buffer, uint32_t bufferSize) const override
00082     {
00083         uint32_t index = 0;
00084         for (auto it = const_cast<ExtPxFamilyImpl*>(this)->m_actors.getIterator(); !it.done() && index < bufferSize; ++it)
00085         {
00086             buffer[index++] = *it;
00087         }
00088         return index;
00089     }
00090 
00091     virtual TkFamily&                       getTkFamily() const override
00092     {
00093         return m_tkFamily;
00094     }
00095 
00096     virtual const physx::PxShape* const*    getSubchunkShapes() const override
00097     {
00098         return m_subchunkShapes.begin();
00099     }
00100 
00101     virtual ExtPxAsset&                     getPxAsset() const override
00102     {
00103         return m_pxAsset;
00104     }
00105 
00106     virtual void                            setMaterial(PxMaterial& material) override
00107     {
00108         m_spawnSettings.material = &material;
00109     }
00110 
00111     virtual void                            setPxShapeDescTemplate(const ExtPxShapeDescTemplate* pxShapeDesc) override
00112     {
00113         m_pxShapeDescTemplate = pxShapeDesc;
00114     }
00115 
00116     virtual const ExtPxShapeDescTemplate*   getPxShapeDescTemplate() const override
00117     {
00118         return m_pxShapeDescTemplate;
00119     }
00120 
00121     virtual void                            setPxActorDesc(const ExtPxActorDescTemplate* pxActorDesc) override
00122     {
00123         m_pxActorDescTemplate = pxActorDesc;
00124     }
00125 
00126     virtual const ExtPxActorDescTemplate*   getPxActorDesc() const override
00127     {
00128         return m_pxActorDescTemplate;
00129     }
00130 
00131     virtual const NvBlastExtMaterial*       getMaterial() const override
00132     {
00133         return m_material;
00134     }
00135 
00136     virtual void                            setMaterial(const NvBlastExtMaterial* material) override
00137     {
00138         m_material = material;
00139     }
00140 
00141     virtual void                            subscribe(ExtPxListener& listener) override
00142     {
00143         m_listeners.pushBack(&listener);
00144     }
00145 
00146     virtual void                            unsubscribe(ExtPxListener& listener) override
00147     {
00148         m_listeners.findAndReplaceWithLast(&listener);
00149     }
00150 
00151     virtual void                            postSplitUpdate() override;
00152 
00154 
00155     virtual void                            receive(const TkEvent* events, uint32_t eventCount) override;
00156 
00157 
00159 
00160     void                                    dispatchActorCreated(ExtPxActor& actor);
00161     void                                    dispatchActorDestroyed(ExtPxActor& actor);
00162 
00163 
00164 private:
00166 
00167     void                                    createActors(TkActor** tkActors, const PxActorCreateInfo* pxActorInfos, uint32_t count);
00168     void                                    destroyActors(ExtPxActor** actors, uint32_t count);
00169 
00171 
00172     ExtPxManagerImpl&                       m_manager;
00173     TkFamily&                               m_tkFamily;
00174     ExtPxAsset&                             m_pxAsset;
00175     ExtPxSpawnSettings                      m_spawnSettings;
00176     const ExtPxShapeDescTemplate*           m_pxShapeDescTemplate;
00177     const ExtPxActorDescTemplate*           m_pxActorDescTemplate;
00178     const NvBlastExtMaterial*               m_material;
00179     bool                                    m_isSpawned;
00180     PxTransform                             m_initialTransform;
00181     PxVec3                                  m_initialScale;
00182     HashSet<ExtPxActor*>::type              m_actors;
00183     Array<TkActor*>::type                   m_culledActors;
00184     InlineArray<ExtPxListener*, 4>::type    m_listeners;
00185     Array<PxShape*>::type                   m_subchunkShapes;
00186     Array<TkActor*>::type                   m_newActorsBuffer;
00187     Array<PxActorCreateInfo>::type          m_newActorCreateInfo;
00188     Array<PxActor*>::type                   m_physXActorsBuffer;
00189     Array<ExtPxActor*>::type                m_actorsBuffer;
00190     Array<uint32_t>::type                   m_indicesScratch;
00191 };
00192 
00193 } // namespace Blast
00194 } // namespace Nv
00195 
00196 
00197 #endif // ifndef NVBLASTEXTPXFAMILYIMPL_H
Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com