Scene.h
Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 //
00026 // Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 
00030 #ifndef SCENE_H
00031 #define SCENE_H
00032 
00038 #include "ApexDesc.h"
00039 #include "Renderable.h"
00040 #include "RenderDebugInterface.h"
00041 #include "Context.h"
00042 #include "foundation/PxVec3.h"
00043 #include <ApexDefs.h>
00044 
00045 #if PX_PHYSICS_VERSION_MAJOR == 3
00046 #include "PxFiltering.h"
00047 #endif
00048 #include "MirrorScene.h"
00049 
00050 namespace NvParameterized
00051 {
00052 class Interface;
00053 }
00054 
00055 namespace physx
00056 {
00057     class PxBaseTask;
00058     class PxTaskManager;
00059     class PxCpuDispatcher;
00060     class PxGpuDispatcher;
00061 }
00062 
00063 namespace nvidia
00064 {
00065 namespace apex
00066 {
00067 // Forward declaration for the PhysX3Interface::setContactReportFlags() callback
00068 class DestructibleActor;
00069 
00070 PX_PUSH_PACK_DEFAULT
00071 
00072 #if PX_PHYSICS_VERSION_MAJOR == 3
00073 
00076 class PhysX3Interface
00077 {
00078 public:
00084     virtual void setContactReportFlags(PxShape* shape, physx::PxPairFlags flags, DestructibleActor* actor, uint16_t actorChunkIndex) = 0;
00085 
00090     virtual physx::PxPairFlags getContactReportFlags(const physx::PxShape* shape) const = 0;
00091 };
00092 #endif
00093 
00097 class SceneDesc : public ApexDesc
00098 {
00099 public:
00100 
00101     PX_INLINE SceneDesc() : ApexDesc()
00102     {
00103         init();
00104     }
00105 
00106     PX_INLINE void setToDefault()
00107     {
00108         ApexDesc::setToDefault();
00109         init();
00110     }
00111 
00112 
00119     PxScene* scene;
00120 
00123     RenderDebugInterface* debugInterface;
00124 
00125 #if PX_PHYSICS_VERSION_MAJOR == 0
00126 
00133     PxCpuDispatcher* cpuDispatcher;
00134 
00141     PxGpuDispatcher* gpuDispatcher;
00142 
00143 #elif PX_PHYSICS_VERSION_MAJOR == 3
00144 
00147     PhysX3Interface* physX3Interface;
00148 
00149 #endif
00150 
00157     bool    useDebugRenderable;
00158 
00162     bool    debugVisualizeRemotely;
00163 
00167     bool    debugVisualizeLocally;
00168 
00172     bool    useCuda;
00173 
00174 private:
00175     PX_INLINE void init()
00176     {
00177 #if PX_PHYSICS_VERSION_MAJOR == 0
00178         cpuDispatcher = 0;
00179         gpuDispatcher = 0;
00180 #elif PX_PHYSICS_VERSION_MAJOR == 3
00181         physX3Interface = 0;
00182 #endif
00183         scene = 0;
00184         debugInterface = 0;
00185         useDebugRenderable = false;
00186         debugVisualizeRemotely = false;
00187         debugVisualizeLocally = true;
00188 #if APEX_CUDA_SUPPORT
00189         useCuda = true;
00190 #else
00191         useCuda = false;
00192 #endif
00193     }
00194 };
00195 
00196 
00200 struct StatDataType
00201 {
00205     enum Enum
00206     {
00207         INVALID = 0,
00208         STRING  = 1,
00209         INT     = 2,
00210         FLOAT   = 3,
00211         ENUM    = 4,
00212         BOOL    = 5,
00213     };
00214 };
00215 
00219 typedef struct oaValueStruct
00220 {
00221     union
00222     {
00223         char*           String;
00224         int32_t         Int;
00225         float           Float;
00226         char*           Enum;
00227         bool            Bool;
00228     };
00229 } StatValue;
00230 
00234 typedef struct
00235 {
00237     const char*         StatName;
00238 
00240     StatDataType::Enum  StatType;
00241 
00243     StatValue           StatCurrentValue;
00244 } StatsInfo;
00245 
00249 struct SceneStats
00250 {
00253     uint32_t            numApexStats;
00256     StatsInfo*          ApexStatsInfoPtr;
00257 };
00258 
00267 struct ViewMatrixType
00268 {
00272     enum Enum
00273     {
00274         USER_CUSTOMIZED = 0,
00275         LOOK_AT_RH,
00276         LOOK_AT_LH,
00277     };
00278 };
00279 
00286 struct ProjMatrixType
00287 {
00291     enum Enum
00292     {
00293         USER_CUSTOMIZED = 0,
00294     };
00295 };
00296 
00300 struct UserBoundingBoxFlags
00301 {
00305     enum Enum
00306     {
00307         NONE    = 1 << 0,
00308         ENTER   = 1 << 1,
00309         LEAVE   = 1 << 2
00310     };
00311 };
00312 
00316 class Scene : public Renderable, public Context, public ApexInterface
00317 {
00318 public:
00319 
00320 #if PX_PHYSICS_VERSION_MAJOR == 3
00321 
00329     virtual void setPhysXScene(PxScene* s) = 0;
00330 
00334     virtual PxScene* getPhysXScene() const = 0;
00335 
00336 #endif
00337 
00341     virtual const SceneStats* getStats(void) const = 0;
00342 
00369     virtual void simulate(float elapsedTime, 
00370                           bool finalStep = true, 
00371                           PxBaseTask *completionTask = NULL,
00372                           void* scratchMemBlock = 0, 
00373                           uint32_t scratchMemBlockSize = 0) = 0;
00374 
00384     virtual bool fetchResults(bool block, uint32_t* errorState) = 0;
00385 
00389     virtual const PxRenderBuffer* getRenderBuffer() const = 0;
00390 
00394     virtual const PxRenderBuffer* getRenderBufferScreenSpace() const = 0;
00395 
00402     virtual bool checkResults(bool block) const = 0;
00403 
00417     virtual uint32_t allocViewMatrix(ViewMatrixType::Enum) = 0;
00418 
00431     virtual uint32_t allocProjMatrix(ProjMatrixType::Enum) = 0;
00432 
00436     virtual uint32_t getNumViewMatrices() const = 0;
00437 
00441     virtual uint32_t getNumProjMatrices() const = 0;
00442 
00450     virtual void setViewMatrix(const PxMat44& viewTransform, const uint32_t viewID = 0) = 0;
00451 
00457     virtual PxMat44 getViewMatrix(const uint32_t viewID = 0) const = 0;
00458 
00465     virtual void setProjMatrix(const PxMat44& projTransform, const uint32_t projID = 0) = 0;
00466 
00472     virtual PxMat44 getProjMatrix(const uint32_t projID = 0) const = 0;
00473 
00477     virtual void setUseViewProjMatrix(const uint32_t viewID = 0, const uint32_t projID = 0) = 0;
00478 
00484     virtual void setViewParams(const PxVec3& eyePosition, const PxVec3& eyeDirection, const PxVec3& worldUpDirection = PxVec3(0, 1, 0), const uint32_t viewID = 0) = 0;
00485 
00491     virtual void setProjParams(float nearPlaneDistance, float farPlaneDistance, float fieldOfViewDegree, uint32_t viewportWidth, uint32_t viewportHeight, const uint32_t projID = 0) = 0;
00492 
00499     virtual PxVec3 getEyePosition(const uint32_t viewID = 0) const = 0;
00500 
00507     virtual PxVec3 getEyeDirection(const uint32_t viewID = 0) const = 0;
00508 
00512     virtual PxTaskManager* getTaskManager() const = 0;
00513 
00517     virtual void setUseDebugRenderable(bool state) = 0;
00518 
00522     virtual ::NvParameterized::Interface* getDebugRenderParams() const = 0;
00523 
00527     virtual ::NvParameterized::Interface* getModuleDebugRenderParams(const char* name) const = 0;
00528 
00532     virtual PxVec3 getGravity() const = 0;
00533 
00537     virtual void setGravity(const PxVec3& gravity) = 0;
00538 
00539 
00540 #if PX_PHYSICS_VERSION_MAJOR == 3
00541 
00549     virtual void lockRead(const char *fileName,uint32_t lineo) = 0;
00550 
00559     virtual void lockWrite(const char *fileName,uint32_t lineno) = 0;
00560 
00564     virtual void unlockRead() = 0;
00565 
00569     virtual void unlockWrite() = 0;
00570 
00583     virtual void addActorPair(PxActor *actor0,PxActor *actor1) = 0;
00584 
00591     virtual void removeActorPair(PxActor *actor0,PxActor *actor1) = 0;
00592 
00604     virtual bool findActorPair(PxActor *actor0,PxActor *actor1) const = 0;
00605 
00606 
00617     virtual MirrorScene *createMirrorScene(nvidia::apex::Scene &mirrorScene,
00618         MirrorScene::MirrorFilter &mirrorFilter,
00619         float mirrorStaticDistance,
00620         float mirrorDynamicDistance,
00621         float mirrorRefreshDistance) = 0;
00622 #endif
00623 
00624 
00633     virtual void addBoundingBox(const PxBounds3& bounds, UserBoundingBoxFlags::Enum flags) = 0;
00634 
00641     virtual const PxBounds3 getBoundingBox(const uint32_t index) const = 0;
00642 
00649     virtual UserBoundingBoxFlags::Enum getBoundingBoxFlags(const uint32_t index) const = 0;
00650 
00654     virtual uint32_t getBoundingBoxCount() const = 0;
00655 
00661     virtual void  removeBoundingBox(const uint32_t index) = 0;
00662 
00666     virtual void  removeAllBoundingBoxes() = 0;
00667 
00671     virtual void* getCudaTestManager() const = 0;
00672     
00676     virtual void* getCudaProfileManager() const = 0;
00677 
00683     virtual void setCudaKernelCheckEnabled(bool enabled) = 0;
00684     
00688     virtual bool getCudaKernelCheckEnabled() const = 0;
00689 
00690 #if APEX_UE4
00691 
00694     virtual void updateGravity() = 0;
00695 #endif
00696 };
00697 
00698 
00699 PX_POP_PACK
00700 
00701 }
00702 } // end namespace nvidia::apex
00703 
00704 #endif // SCENE_H

Generated on Sat Dec 1 2018 15:52:06

Copyright © 2012-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.