diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/module/basicios/include | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'APEX_1.4/module/basicios/include')
17 files changed, 3121 insertions, 0 deletions
diff --git a/APEX_1.4/module/basicios/include/BasicIosActorCPU.h b/APEX_1.4/module/basicios/include/BasicIosActorCPU.h new file mode 100644 index 00000000..c2aae8a6 --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosActorCPU.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_ACTOR_CPU_H__ +#define __BASIC_IOS_ACTOR_CPU_H__ + +#include "Apex.h" + +#if ENABLE_TEST +#include "BasicIosTestActor.h" +#endif +#include "BasicIosActorImpl.h" +#include "BasicIosAssetImpl.h" +#include "InstancedObjectSimulationIntl.h" +#include "BasicIosSceneCPU.h" +#include "ApexActor.h" +#include "ApexContext.h" +#include "ApexFIFO.h" +#include "ApexRWLockable.h" +#include "PxTask.h" + +namespace nvidia +{ +namespace apex +{ +class RenderVolume; +} +namespace basicios +{ + +#if ENABLE_TEST +#define BASIC_IOS_ACTOR BasicIosTestActor +#else +#define BASIC_IOS_ACTOR BasicIosActorImpl +#endif + +class BasicIosActorCPU : public BASIC_IOS_ACTOR +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + BasicIosActorCPU(ResourceList&, BasicIosAssetImpl&, BasicIosScene&, nvidia::apex::IofxAsset&); + ~BasicIosActorCPU(); + + virtual void submitTasks(); + virtual void setTaskDependencies(); + virtual void fetchResults(); + +protected: + /* Internal utility functions */ + void simulateParticles(); + + static const uint32_t HISTOGRAM_BIN_COUNT = 1024; + uint32_t computeHistogram(uint32_t dataCount, float dataMin, float dataMax, uint32_t& bound); + +private: + /* particle data (output to the IOFX actors, and some state) */ + + physx::Array<uint32_t> mNewIndices; + + class SimulateTask : public PxTask + { + public: + SimulateTask(BasicIosActorCPU& actor) : mActor(actor) {} + + const char* getName() const + { + return "BasicIosActorCPU::SimulateTask"; + } + void run() + { + mActor.simulateParticles(); + } + + protected: + BasicIosActorCPU& mActor; + + private: + SimulateTask& operator=(const SimulateTask&); + }; + SimulateTask mSimulateTask; + + nvidia::apex::ApexCpuInplaceStorage mSimulationStorage; + + friend class BasicIosAssetImpl; +}; + +} +} // namespace nvidia + +#endif // __BASIC_IOS_ACTOR_CPU_H__ diff --git a/APEX_1.4/module/basicios/include/BasicIosActorGPU.h b/APEX_1.4/module/basicios/include/BasicIosActorGPU.h new file mode 100644 index 00000000..866df869 --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosActorGPU.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_ACTOR_GPU_H__ +#define __BASIC_IOS_ACTOR_GPU_H__ + +#include "Apex.h" + +#if ENABLE_TEST +#include "BasicIosTestActor.h" +#endif +#include "BasicIosActorImpl.h" +#include "BasicIosAssetImpl.h" +#include "InstancedObjectSimulationIntl.h" +#include "BasicIosSceneGPU.h" +#include "ApexActor.h" +#include "ApexContext.h" +#include "ApexFIFO.h" +#include "FieldSamplerQueryIntl.h" + +#include "PxGpuTask.h" + +namespace nvidia +{ +namespace IOFX +{ +class IofxActor; +class RenderVolume; +} + +namespace basicios +{ + +#if ENABLE_TEST +#define BASIC_IOS_ACTOR BasicIosTestActor +#else +#define BASIC_IOS_ACTOR BasicIosActorImpl +#endif + +class BasicIosActorGPU : public BASIC_IOS_ACTOR +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + BasicIosActorGPU(ResourceList&, BasicIosAssetImpl&, BasicIosScene&, nvidia::apex::IofxAsset&, const ApexMirroredPlace::Enum defaultPlace = ApexMirroredPlace::GPU); + ~BasicIosActorGPU(); + + virtual void submitTasks(); + virtual void setTaskDependencies(); + virtual void fetchResults(); + +protected: + bool launch(CUstream stream, int kernelIndex); + + PxGpuCopyDescQueue mCopyQueue; + + ApexMirroredArray<uint32_t> mHoleScanSum; + ApexMirroredArray<uint32_t> mMoveIndices; + + ApexMirroredArray<uint32_t> mTmpReduce; + ApexMirroredArray<uint32_t> mTmpHistogram; + ApexMirroredArray<uint32_t> mTmpScan; + ApexMirroredArray<uint32_t> mTmpScan1; + + ApexMirroredArray<uint32_t> mTmpOutput; + ApexMirroredArray<uint32_t> mTmpOutput1; + + class LaunchTask : public PxGpuTask + { + public: + LaunchTask(BasicIosActorGPU& actor) : mActor(actor) {} + const char* getName() const + { + return "BasicIosActorGPU::LaunchTask"; + } + void run() + { + PX_ALWAYS_ASSERT(); + } + bool launchInstance(CUstream stream, int kernelIndex) + { + return mActor.launch(stream, kernelIndex); + } + PxGpuTaskHint::Enum getTaskHint() const + { + return PxGpuTaskHint::Kernel; + } + + protected: + BasicIosActorGPU& mActor; + + private: + LaunchTask& operator=(const LaunchTask&); + }; + + static PX_CUDA_CALLABLE PX_INLINE PxMat44 inverse(const PxMat44& in); + static float distance(PxVec4 a, PxVec4 b); + + LaunchTask mLaunchTask; +}; + +} +} // namespace nvidia + +#endif // __BASIC_IOS_ACTOR_GPU_H__ diff --git a/APEX_1.4/module/basicios/include/BasicIosActorImpl.h b/APEX_1.4/module/basicios/include/BasicIosActorImpl.h new file mode 100644 index 00000000..8a738ec4 --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosActorImpl.h @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_ACTOR_IMPL_H__ +#define __BASIC_IOS_ACTOR_IMPL_H__ + +#include "Apex.h" + +#include "BasicIosActor.h" +#include "IofxActor.h" +#include "BasicIosAssetImpl.h" +#include "InstancedObjectSimulationIntl.h" +#include "BasicIosScene.h" +#include "ApexActor.h" +#include "ApexContext.h" +#include "ApexFIFO.h" +#include "BasicIosCommon.h" +#include "BasicIosCommonSrc.h" +#include "InplaceStorage.h" +#include "ApexMirroredArray.h" +#include "ApexRand.h" + +#include <PxFiltering.h> + +#define MAX_CONVEX_PLANES_COUNT 4096 +#define MAX_CONVEX_VERTS_COUNT 4096 +#define MAX_CONVEX_POLYGONS_DATA_SIZE 16384 + +#define MAX_TRIMESH_VERTS_COUNT 4096 +#define MAX_TRIMESH_INDICES_COUNT 16384 + +namespace nvidia +{ +namespace apex +{ + class FieldSamplerQueryIntl; + class FieldSamplerCallbackIntl; +} +namespace iofx +{ + class RenderVolume; +} + +namespace basicios +{ + +/* Class for managing the interactions with each emitter */ +class BasicParticleInjector : public IosInjectorIntl, public ApexResourceInterface, public ApexResource +{ +public: + void setPreferredRenderVolume(nvidia::apex::RenderVolume* volume); + float getLeastBenefitValue() const + { + return 0.0f; + } + bool isBacklogged() const + { + return false; + } + + void createObjects(uint32_t count, const IosNewObject* createList); +#if APEX_CUDA_SUPPORT + void createObjects(ApexMirroredArray<const IosNewObject>& createArray); +#endif + + void setLODWeights(float maxDistance, float distanceWeight, float speedWeight, float lifeWeight, float separationWeight, float bias); + + PxTaskID getCompletionTaskID() const; + + virtual void release(); + void destroy(); + + // ApexResourceInterface methods + void setListIndex(ResourceList& list, uint32_t index); + uint32_t getListIndex() const + { + return m_listIndex; + } + + virtual void setPhysXScene(PxScene*) {} + virtual PxScene* getPhysXScene() const + { + return NULL; + } + + void assignSimParticlesCount(uint32_t input) + { + mSimulatedParticlesCount = input; + } + + virtual uint32_t getSimParticlesCount() const + { + return mSimulatedParticlesCount; + } + + virtual uint32_t getActivePaticleCount() const + { + return mSimulatedParticlesCount; + } + + virtual void setObjectScale(float objectScale); + +protected: + BasicIosActorImpl* mIosActor; + IofxManagerClientIntl* mIofxClient; + nvidia::apex::RenderVolume* mVolume; + physx::Array<uint16_t> mRandomActorClassIDs; + uint32_t mLastRandomID; + uint16_t mVolumeID; + + uint32_t mInjectorID; + uint32_t mSimulatedParticlesCount; + + /* insertion buffer */ + ApexFIFO<IosNewObject> mInjectedParticles; + + QDSRand mRand; + + BasicParticleInjector(ResourceList& list, BasicIosActorImpl& actor, uint32_t injectorID); + ~BasicParticleInjector(); + + void init(nvidia::apex::IofxAsset* iofxAsset); + + friend class BasicIosActorImpl; +}; + + +class BasicIosActorImpl : public InstancedObjectSimulationIntl, + public BasicIosActor, + public ApexResourceInterface, + public ApexResource, + public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + BasicIosActorImpl(ResourceList& list, BasicIosAssetImpl& asset, BasicIosScene& scene, nvidia::apex::IofxAsset& iofxAsset, bool isDataOnDevice); + ~BasicIosActorImpl(); + + // ApexInterface API + void release(); + void destroy(); + + // Actor API + void setPhysXScene(PxScene* s); + PxScene* getPhysXScene() const; + virtual void putInScene(PxScene* scene); + + Asset* getOwner() const + { + return static_cast<Asset*>(mAsset); + } + + // ApexContext + void getLodRange(float& min, float& max, bool& intOnly) const; + float getActiveLod() const; + void forceLod(float lod); + /** + \brief Selectively enables/disables debug visualization of a specific APEX actor. Default value it true. + */ + virtual void setEnableDebugVisualization(bool state) + { + ApexActor::setEnableDebugVisualization(state); + } + + // ApexResourceInterface methods + void setListIndex(ResourceList& list, uint32_t index) + { + m_listIndex = index; + m_list = &list; + } + uint32_t getListIndex() const + { + return m_listIndex; + } + + // IOSIntl + float getObjectRadius() const + { + return mAsset->getParticleRadius(); + } + float getObjectDensity() const + { + return mAsset->getRestDensity(); + } + + // BasicIosActor + float getParticleRadius() const + { + READ_ZONE(); + return mAsset->getParticleRadius(); + } + float getRestDensity() const + { + READ_ZONE(); + return mAsset->getRestDensity(); + } + uint32_t getParticleCount() const + { + READ_ZONE(); + return mParticleCount; + } + PX_INLINE void setOnStartFSCallback(FieldSamplerCallbackIntl* callback) + { + if (mFieldSamplerQuery) + { + mFieldSamplerQuery->setOnStartCallback(callback); + } + } + PX_INLINE void setOnFinishIOFXCallback(IofxManagerCallbackIntl* callback) + { + if (mIofxMgr) + { + mIofxMgr->setOnFinishCallback(callback); + } + } + + const PxVec3* getRecentPositions(uint32_t& count, uint32_t& stride) const; + + PxVec3 getGravity() const; + void setGravity(PxVec3& gravity); + + void visualize(); + virtual void submitTasks() = 0; + virtual void setTaskDependencies() = 0; + virtual void fetchResults(); + + IosInjectorIntl* allocateInjector(IofxAsset* iofxAsset); + void releaseInjector(IosInjectorIntl&); + + virtual void setDensityOrigin(const PxVec3& v) + { + mDensityOrigin = v; + } + + +protected: + //Member functions below have implemented in test actor + virtual bool checkBenefit(uint32_t totalCount) {PX_UNUSED(totalCount); return true;}; + virtual bool checkHoles(uint32_t totalCount) {PX_UNUSED(totalCount); return true;}; + virtual bool checkInState(uint32_t totalCount) {PX_UNUSED(totalCount); return true;}; + virtual bool checkHistogram(uint32_t /*bound*/, uint32_t /*beg*/, uint32_t /*back*/) {return true;}; + + virtual void removeFromScene(); + + void injectNewParticles(); + + void initStorageGroups(InplaceStorage& storage); + + void setTaskDependencies(PxTask* iosTask, bool isDataOnDevice); + + void FillCollisionData(CollisionData& baseData, PxShape* shape); + + BasicIosAssetImpl* mAsset; + BasicIosScene* mBasicIosScene; + + IofxManagerIntl* mIofxMgr; + IosBufferDescIntl mBufDesc; + + ResourceList mInjectorList; + + PxVec3 mGravityVec; + PxVec3 mUp; + float mGravity; + float mTotalElapsedTime; //AM: People, methinks this will backfire eventually due to floating point precision loss! + + uint32_t mMaxParticleCount; + uint32_t mMaxTotalParticleCount; + + uint32_t mParticleCount; + uint32_t mParticleBudget; + + uint32_t mInjectedCount; + float mInjectedBenefitSum; + float mInjectedBenefitMin; + float mInjectedBenefitMax; + + uint32_t mLastActiveCount; + float mLastBenefitSum; + float mLastBenefitMin; + float mLastBenefitMax; + + ApexMirroredArray<float> mLifeSpan; + ApexMirroredArray<float> mLifeTime; + ApexMirroredArray<uint32_t> mInjector; + ApexMirroredArray<float> mBenefit; + + ApexMirroredArray<PxPlane> mConvexPlanes; + ApexMirroredArray<PxVec4> mConvexVerts; + ApexMirroredArray<uint32_t> mConvexPolygonsData; + + ApexMirroredArray<PxVec4> mTrimeshVerts; + ApexMirroredArray<uint32_t> mTrimeshIndices; + + ApexMirroredArray<uint32_t> mInjectorsCounters; + + ApexMirroredArray<float> mGridDensityGrid; + ApexMirroredArray<float> mGridDensityGridLowPass; + + GridDensityParams mGridDensityParams; + // Particle Density Origin + PxVec3 mDensityOrigin; + PxMat44 mDensityDebugMatInv; + + // If true we are + bool mTrackGravityChanges; + + // Only for use by the IOS Asset, the actor is unaware of this + bool mIsMesh; + + FieldSamplerQueryIntl* mFieldSamplerQuery; + ApexMirroredArray<PxVec4> mField; + + PxFilterData mCollisionFilterData; + Array<physx::PxOverlapHit> mOverlapHits; + + InplaceStorageGroup mSimulationStorageGroup; + InplaceHandle<SimulationParams> mSimulationParamsHandle; + + PxTask* mInjectTask; + + FieldSamplerCallbackIntl* mOnStartCallback; + IofxManagerCallbackIntl* mOnFinishCallback; + + friend class BasicIosInjectTask; + + friend class BasicIosAssetImpl; + friend class BasicParticleInjector; +}; + +} +} // namespace nvidia + +#endif // __BASIC_IOS_ACTOR_IMPL_H__ diff --git a/APEX_1.4/module/basicios/include/BasicIosAssetImpl.h b/APEX_1.4/module/basicios/include/BasicIosAssetImpl.h new file mode 100644 index 00000000..766858c1 --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosAssetImpl.h @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef BASIC_IOS_ASSET_IMPL_H +#define BASIC_IOS_ASSET_IMPL_H + +#include "ApexUsingNamespace.h" +#include "Apex.h" +#include "IofxAsset.h" +#include "BasicIosAsset.h" +#include "InstancedObjectSimulationIntl.h" +#include "ApexSDKHelpers.h" +#include "ApexAssetAuthoring.h" +#include "ApexString.h" +#include "ResourceProviderIntl.h" +#include "ApexAuthorableObject.h" +#include "BasicIOSAssetParam.h" +#include "ApexAssetTracker.h" +#include "ApexRand.h" +#include "ApexRWLockable.h" + +#include "ReadCheck.h" +#include "ApexAuthorableObject.h" + +namespace nvidia +{ +namespace IOFX +{ +class IofxAsset; +} + +namespace basicios +{ + +class ModuleBasicIosImpl; +class BasicIosActorImpl; + +/** +\brief Descriptor needed to create a BasicIOS Actor +*/ +class BasicIosActorDesc : public ApexDesc +{ +public: + ///Radius of a particle (overrides authered value) + float radius; + ///Density of a particle (overrides authered value) + float density; + + /** + \brief constructor sets to default. + */ + PX_INLINE BasicIosActorDesc() : ApexDesc() + { + init(); + } + + /** + \brief sets members to default values. + */ + PX_INLINE void setToDefault() + { + ApexDesc::setToDefault(); + init(); + } + + /** + \brief checks if this is a valid descriptor. + */ + PX_INLINE bool isValid() const + { + if (!ApexDesc::isValid()) + { + return false; + } + + return true; + } + +private: + + PX_INLINE void init() + { + // authored values will be used where these default values remain + radius = 0.0f; + density = 0.0f; + } +}; + +class BasicIosAssetImpl : public BasicIosAsset, + public ApexResourceInterface, + public ApexResource, + public ApexRWLockable +{ + friend class BasicIosAssetDummyAuthoring; +public: + APEX_RW_LOCKABLE_BOILERPLATE + + BasicIosAssetImpl(ModuleBasicIosImpl*, ResourceList&, const char*); + BasicIosAssetImpl(ModuleBasicIosImpl* module, ResourceList&, NvParameterized::Interface*, const char*); + ~BasicIosAssetImpl(); + + // Asset + void release(); + const char* getName(void) const + { + return mName.c_str(); + } + AuthObjTypeID getObjTypeID() const + { + return mAssetTypeID; + } + const char* getObjTypeName() const + { + return getClassName(); + } + // TODO: implement forceLoadAssets + uint32_t forceLoadAssets(); + + Actor* createIosActor(Scene& scene, IofxAsset* iofxAsset); + void releaseIosActor(Actor&); + bool getSupportsDensity() const; + + // Private API for this module only + BasicIosActorImpl* getIosActorInScene(Scene& scene, bool mesh) const; + + // ApexResourceInterface methods + void setListIndex(ResourceList& list, uint32_t index) + { + m_listIndex = index; + m_list = &list; + } + uint32_t getListIndex() const + { + return m_listIndex; + } + + float getParticleRadius() const + { + READ_ZONE(); + return mParams->particleRadius; + } + float getRestDensity() const + { + READ_ZONE(); + return mParams->restDensity; + } + float getMaxInjectedParticleCount() const + { + READ_ZONE(); + return mParams->maxInjectedParticleCount; + } + uint32_t getMaxParticleCount() const + { + READ_ZONE(); + return mParams->maxParticleCount; + } + float getSceneGravityScale() const + { + return mParams->sceneGravityScale; + } + PxVec3& getExternalAcceleration() const + { + return mParams->externalAcceleration; + } + float getParticleMass() const; + + const NvParameterized::Interface* getAssetNvParameterized() const + { + return mParams; + } + /** + * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller. + */ + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + NvParameterized::Interface* ret = mParams; + mParams = NULL; + release(); + return ret; + } + + NvParameterized::Interface* getDefaultActorDesc() + { + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + + NvParameterized::Interface* getDefaultAssetPreviewDesc() + { + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + + virtual Actor* createApexActor(const NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) + { + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + + virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& /*params*/, AssetPreviewScene* /*previewScene*/) + { + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + + virtual bool isValidForActorCreation(const ::NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) const + { + return true; // TODO implement this method + } + + virtual bool isDirty() const + { + return false; + } + +protected: + virtual void destroy(); + + static AuthObjTypeID mAssetTypeID; + static const char* getClassName() + { + return BASIC_IOS_AUTHORING_TYPE_NAME; + } + + ResourceList mIosActorList; + + ModuleBasicIosImpl* mModule; + ApexSimpleString mName; + + BasicIOSAssetParam* mParams; + + mutable QDSRand mSRand; + mutable QDNormRand mNormRand; + + enum + { + UNIFORM, + NORMAL + } mMassDistribType; + + void processParams(); + + friend class ModuleBasicIosImpl; + friend class BasicIosActorImpl; + friend class BasicIosActorCPU; + friend class BasicIosActorGPU; + template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject; + friend class BasicIosAuthorableObject; +}; + +#ifndef WITHOUT_APEX_AUTHORING +class BasicIosAssetAuthoringImpl : public BasicIosAssetAuthoring, public ApexAssetAuthoring, public BasicIosAssetImpl +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list); + BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list, const char* name); + BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name); + + virtual void release(); + + const char* getName(void) const + { + return BasicIosAssetImpl::getName(); + } + const char* getObjTypeName() const + { + return BasicIosAssetImpl::getClassName(); + } + virtual bool prepareForPlatform(nvidia::apex::PlatformTag) + { + APEX_INVALID_OPERATION("Not Implemented."); + return false; + } + void setToolString(const char* toolName, const char* toolVersion, uint32_t toolChangelist) + { + ApexAssetAuthoring::setToolString(toolName, toolVersion, toolChangelist); + } + + void setParticleRadius(float radius) + { + mParams->particleRadius = radius; + } + void setRestDensity(float density) + { + mParams->restDensity = density; + } + void setMaxInjectedParticleCount(float count) + { + mParams->maxInjectedParticleCount = count; + } + void setMaxParticleCount(uint32_t count) + { + mParams->maxParticleCount = count; + } + void setParticleMass(float mass) + { + mParams->particleMass.center = mass; + } + + void setCollisionGroupName(const char* collisionGroupName); + void setCollisionGroupMaskName(const char* collisionGroupMaskName); + + NvParameterized::Interface* getNvParameterized() const + { + return (NvParameterized::Interface*)getAssetNvParameterized(); + } + /** + * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller. + */ + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + NvParameterized::Interface* ret = mParams; + mParams = NULL; + release(); + return ret; + } +}; +#endif + +} +} // namespace nvidia + +#endif // BASIC_IOS_ASSET_IMPL_H diff --git a/APEX_1.4/module/basicios/include/BasicIosCommon.h b/APEX_1.4/module/basicios/include/BasicIosCommon.h new file mode 100644 index 00000000..8b038518 --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosCommon.h @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_COMMON_H__ +#define __BASIC_IOS_COMMON_H__ + +#include "PxMat44.h" +#include "PxBounds3.h" +#include "PxVec3.h" +#include "InplaceTypes.h" + +namespace nvidia +{ + namespace apex + { + class ApexCpuInplaceStorage; + } + namespace basicios + { + +//struct InjectorParams +#define INPLACE_TYPE_STRUCT_NAME InjectorParams +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(float, mLODMaxDistance) \ + INPLACE_TYPE_FIELD(float, mLODDistanceWeight) \ + INPLACE_TYPE_FIELD(float, mLODSpeedWeight) \ + INPLACE_TYPE_FIELD(float, mLODLifeWeight) \ + INPLACE_TYPE_FIELD(float, mLODBias) \ + INPLACE_TYPE_FIELD(uint32_t, mLocalIndex) +#include INPLACE_TYPE_BUILD() + + typedef InplaceArray<InjectorParams> InjectorParamsArray; + +//struct CollisionData +#define INPLACE_TYPE_STRUCT_NAME CollisionData +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(PxVec3, bodyCMassPosition) \ + INPLACE_TYPE_FIELD(PxVec3, bodyLinearVelocity) \ + INPLACE_TYPE_FIELD(PxVec3, bodyAngluarVelocity) \ + INPLACE_TYPE_FIELD(float, materialRestitution) +#include INPLACE_TYPE_BUILD() + +//struct CollisionSphereData +#define INPLACE_TYPE_STRUCT_NAME CollisionSphereData +#define INPLACE_TYPE_STRUCT_BASE CollisionData +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(PxBounds3, aabb) \ + INPLACE_TYPE_FIELD(PxTransform, pose) \ + INPLACE_TYPE_FIELD(PxTransform, inversePose) \ + INPLACE_TYPE_FIELD(float, radius) +#include INPLACE_TYPE_BUILD() + +//struct CollisionCapsuleData +#define INPLACE_TYPE_STRUCT_NAME CollisionCapsuleData +#define INPLACE_TYPE_STRUCT_BASE CollisionData +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(PxBounds3, aabb) \ + INPLACE_TYPE_FIELD(PxTransform, pose) \ + INPLACE_TYPE_FIELD(PxTransform, inversePose) \ + INPLACE_TYPE_FIELD(float, halfHeight) \ + INPLACE_TYPE_FIELD(float, radius) +#include INPLACE_TYPE_BUILD() + +//struct CollisionBoxData +#define INPLACE_TYPE_STRUCT_NAME CollisionBoxData +#define INPLACE_TYPE_STRUCT_BASE CollisionData +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(PxBounds3, aabb) \ + INPLACE_TYPE_FIELD(PxTransform, pose) \ + INPLACE_TYPE_FIELD(PxTransform, inversePose) \ + INPLACE_TYPE_FIELD(PxVec3, halfSize) +#include INPLACE_TYPE_BUILD() + +//struct CollisionHalfSpaceData +#define INPLACE_TYPE_STRUCT_NAME CollisionHalfSpaceData +#define INPLACE_TYPE_STRUCT_BASE CollisionData +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(PxVec3, normal) \ + INPLACE_TYPE_FIELD(PxVec3, origin) +#include INPLACE_TYPE_BUILD() + +//struct CollisionConvexMeshData +#define INPLACE_TYPE_STRUCT_NAME CollisionConvexMeshData +#define INPLACE_TYPE_STRUCT_BASE CollisionData +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(PxBounds3, aabb) \ + INPLACE_TYPE_FIELD(PxTransform, pose) \ + INPLACE_TYPE_FIELD(PxTransform, inversePose) \ + INPLACE_TYPE_FIELD(uint32_t, numPolygons) \ + INPLACE_TYPE_FIELD(uint32_t, firstPlane) \ + INPLACE_TYPE_FIELD(uint32_t, firstVertex) \ + INPLACE_TYPE_FIELD(uint32_t, polygonsDataOffset) +#include INPLACE_TYPE_BUILD() + +//struct CollisionTriMeshData +#define INPLACE_TYPE_STRUCT_NAME CollisionTriMeshData +#define INPLACE_TYPE_STRUCT_BASE CollisionData +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(PxBounds3, aabb) \ + INPLACE_TYPE_FIELD(PxTransform, pose) \ + INPLACE_TYPE_FIELD(PxTransform, inversePose) \ + INPLACE_TYPE_FIELD(uint32_t, numTriangles) \ + INPLACE_TYPE_FIELD(uint32_t, firstIndex) \ + INPLACE_TYPE_FIELD(uint32_t, firstVertex) +#include INPLACE_TYPE_BUILD() + +//struct SimulationParams +#define INPLACE_TYPE_STRUCT_NAME SimulationParams +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(float, collisionThreshold) \ + INPLACE_TYPE_FIELD(float, collisionDistance) \ + INPLACE_TYPE_FIELD(InplaceArray<CollisionBoxData>, boxes) \ + INPLACE_TYPE_FIELD(InplaceArray<CollisionSphereData>, spheres) \ + INPLACE_TYPE_FIELD(InplaceArray<CollisionCapsuleData>, capsules) \ + INPLACE_TYPE_FIELD(InplaceArray<CollisionHalfSpaceData>, halfSpaces) \ + INPLACE_TYPE_FIELD(InplaceArray<CollisionConvexMeshData>, convexMeshes) \ + INPLACE_TYPE_FIELD(InplaceArray<CollisionTriMeshData>, trimeshes) \ + INPLACE_TYPE_FIELD(PxPlane*, convexPlanes) \ + INPLACE_TYPE_FIELD(PxVec4*, convexVerts) \ + INPLACE_TYPE_FIELD(uint32_t*, convexPolygonsData) \ + INPLACE_TYPE_FIELD(PxVec4*, trimeshVerts) \ + INPLACE_TYPE_FIELD(uint32_t*, trimeshIndices) +#define INPLACE_TYPE_STRUCT_LEAVE_OPEN 1 +#include INPLACE_TYPE_BUILD() + + APEX_CUDA_CALLABLE PX_INLINE SimulationParams() : convexPlanes(NULL), convexVerts(NULL), convexPolygonsData(NULL) {} + }; + + + struct GridDensityParams + { + bool Enabled; + float GridSize; + uint32_t GridMaxCellCount; + uint32_t GridResolution; + PxVec3 DensityOrigin; + GridDensityParams(): Enabled(false) {} + }; + + struct GridDensityFrustumParams + { + float nearDimX; + float farDimX; + float nearDimY; + float farDimY; + float dimZ; + }; + +#ifdef __CUDACC__ + +#define SIM_FETCH_PLANE(plane, name, idx) { float4 f4 = tex1Dfetch(KERNEL_TEX_REF(name), idx); plane = PxPlane(f4.x, f4.y, f4.z, f4.w); } +#define SIM_FETCH(name, idx) tex1Dfetch(KERNEL_TEX_REF(name), idx) +#define SIM_FLOAT4 float4 +#define SIM_INT_AS_FLOAT(x) __int_as_float(x) +#define SIM_INJECTOR_ARRAY const InjectorParamsArray& +#define SIM_FETCH_INJECTOR(injectorArray, injParams, injector) injectorArray.fetchElem(INPLACE_STORAGE_ARGS_VAL, injParams, injector) + + __device__ PX_INLINE float splitFloat4(PxVec3& v3, const SIM_FLOAT4& f4) + { + v3.x = f4.x; + v3.y = f4.y; + v3.z = f4.z; + return f4.w; + } + __device__ PX_INLINE SIM_FLOAT4 combineFloat4(const PxVec3& v3, float w) + { + return make_float4(v3.x, v3.y, v3.z, w); + } +#else + +#define SIM_FETCH_PLANE(plane, name, idx) plane = mem##name[idx]; +#define SIM_FETCH(name, idx) mem##name[idx] +#define SIM_FLOAT4 PxVec4 +#define SIM_INT_AS_FLOAT(x) *(const float*)(&x) +#define SIM_INJECTOR_ARRAY const InjectorParams* +#define SIM_FETCH_INJECTOR(injectorArray, injParams, injector) injParams = injectorArray[injector]; + + PX_INLINE float splitFloat4(PxVec3& v3, const SIM_FLOAT4& f4) + { + v3 = f4.getXYZ(); + return f4.w; + } + PX_INLINE SIM_FLOAT4 combineFloat4(const PxVec3& v3, float w) + { + return PxVec4(v3.x, v3.y, v3.z, w); + } + +#endif + + } +} // namespace nvidia + +#endif diff --git a/APEX_1.4/module/basicios/include/BasicIosCommonSrc.h b/APEX_1.4/module/basicios/include/BasicIosCommonSrc.h new file mode 100644 index 00000000..2d1458ce --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosCommonSrc.h @@ -0,0 +1,598 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_COMMON_SRC_H__ +#define __BASIC_IOS_COMMON_SRC_H__ + +namespace nvidia +{ + namespace basicios + { + + PX_CUDA_CALLABLE PX_INLINE void updateCollisionVelocity(const CollisionData& data, const PxVec3& normal, const PxVec3& position, PxVec3& velocity) + { + PxVec3 bodyVelocity = data.bodyLinearVelocity + data.bodyAngluarVelocity.cross(position - data.bodyCMassPosition); + + velocity -= bodyVelocity; + float normalVelocity = normal.dot(velocity); + if (normalVelocity < 0.0f) + { + velocity -= normal * ((1.0f + data.materialRestitution) * normalVelocity); + } + velocity += bodyVelocity; + } + + + PX_CUDA_CALLABLE PX_INLINE void calculatePointSegmentSquaredDist(const PxVec3& a, const PxVec3& b, const PxVec3& point, float& distanceSquared, PxVec3& nearestPoint) // a, b - segment points + { + PxVec3 v, w, temp; //vectors + float c1, c2, ratio; //constants + v = a - b; + w = point - b; + float distSquared = 0; + + c1 = w.dot(v); + if(c1 <= 0) + { + distSquared = (point.x - b.x) * (point.x - b.x) + (point.y - b.y) * (point.y - b.y) + (point.z - b.z) * (point.z - b.z); + nearestPoint = b; + } + else + { + c2 = v.dot(v); + if(c2 <= c1) + { + distSquared = (point.x - a.x) * (point.x - a.x) + (point.y - a.y) * (point.y - a.y) + (point.z - a.z) * (point.z - a.z); + nearestPoint = a; + } + else + { + ratio = c1 / c2; + temp = b + ratio * v; + distSquared = (point.x - temp.x) * (point.x - temp.x) + (point.y - temp.y) * (point.y - temp.y) + (point.z - temp.z) * (point.z - temp.z); + nearestPoint = temp; + } + } + + distanceSquared = distSquared; + } + +#ifdef __CUDACC__ + __device__ +#endif + PX_INLINE float checkTriangleCollision(const PxVec4* memTrimeshVerts, const uint32_t* memTrimeshIndices, const CollisionTriMeshData& data, float radius, PxVec3 localPosition, PxVec3 &normal) + { + float minDistSquared = PX_MAX_F32; + PxVec3 localNormal(0); + + for(uint32_t j = 0 ; j < data.numTriangles; j++) + { + PxVec3 p0, p1, p2; + uint32_t i0, i1, i2; + i0 = SIM_FETCH(TrimeshIndices, data.firstIndex + 3 * j); + i1 = SIM_FETCH(TrimeshIndices, data.firstIndex + 3 * j + 1); + i2 = SIM_FETCH(TrimeshIndices, data.firstIndex + 3 * j + 2); + splitFloat4(p0, SIM_FETCH(TrimeshVerts, data.firstVertex + i0)); + splitFloat4(p1, SIM_FETCH(TrimeshVerts, data.firstVertex + i1)); + splitFloat4(p2, SIM_FETCH(TrimeshVerts, data.firstVertex + i2)); + + //localNormal = (p1 - p0).cross(p2 - p0); + //if(radius > 0) localNormal += localPosition; + + PxBounds3 aabb( (p0.minimum(p1.minimum(p2))), (p0.maximum(p1.maximum(p2))) ); + aabb.fattenFast( radius ); + if( !aabb.contains(localPosition) ) continue; + + p0 = p0 - localPosition; + p1 = p1 - localPosition; + p2 = p2 - localPosition; + + PxVec3 a(p1 - p0); + PxVec3 b(p2 - p0); + PxVec3 n = a.cross(b); + n.normalize(); + + //check if point far away from the triangle's plane, then give up + if(n.x * p0.x + n.y * p0.y + n.z * p0.z > radius) continue; + + //check if the nearest point is one of the triangle's vertices + PxVec3 closestPoint; // closest point + + float det1p0p1, det2p0p2, det2p1p2, det0p0p1, det0p0p2, det1p1p2; + //i = 0 + det1p0p1 = p0.dot(-(p1 - p0)); + det2p0p2 = p0.dot(-(p2 - p0)); + //i = 1 + det0p0p1 = p1.dot(p1 - p0); + det2p1p2 = p1.dot(-(p2 - p1)); + //i = 2 + det0p0p2 = p2.dot(p2 - p0); + det1p1p2 = p2.dot(p2 - p1); + + if(det1p0p1 <= 0 && det2p0p2 <= 0) closestPoint = p0; + else if(det0p0p1 <= 0 && det2p1p2 <= 0) closestPoint = p1; + else if(det0p0p2 <= 0 && det1p1p2 <= 0) closestPoint = p2; + else + { + //check if the nearest point is internal point of one of the triangle's edges + float det0p0p1p2, det1p0p1p2, det2p0p1p2; + det0p0p1p2 = det0p0p1 * det1p1p2 + det2p1p2 * p2.dot(p1 - p0); + det1p0p1p2 = det1p0p1 * det0p0p2 - det2p0p2 * p2.dot(p1 - p0); + det2p0p1p2 = det2p0p2 * det0p0p1 - det1p0p1 * p1.dot(p2 - p0); + + if(det0p0p1p2 <= 0) closestPoint = (p1 * det1p1p2 + p2 * det2p1p2) / (det1p1p2 + det2p1p2); + else if(det1p0p1p2 <= 0) closestPoint = (p0 * det0p0p2 + p2 * det2p0p2) / (det0p0p2 + det2p0p2); + else if(det2p0p1p2 <= 0) closestPoint = (p0 * det0p0p1 + p1 * det1p0p1) / (det0p0p1 + det1p0p1); + //point is inside the triangle + else closestPoint = (p0 * det0p0p1p2 + p1 * det1p0p1p2 + p2 * det2p0p1p2) / (det0p0p1p2 + det1p0p1p2 + det2p0p1p2); + } + + float distSquared = closestPoint.x * closestPoint.x + closestPoint.y * closestPoint.y + closestPoint.z * closestPoint.z; + if(distSquared > radius * radius) + { + continue; + } + + if(distSquared < minDistSquared) + { + minDistSquared = distSquared; + localNormal = n; + } + } + normal = localNormal; + + return minDistSquared; + } + + INPLACE_TEMPL_ARGS_DEF +#ifdef __CUDACC__ + __device__ +#endif + PX_INLINE uint32_t handleCollisions(const SimulationParams* params, INPLACE_STORAGE_ARGS_DEF, PxVec3& position, PxVec3& velocity, PxVec3& normal) + { + const PxPlane* memConvexPlanes = params->convexPlanes; + const PxVec4* memConvexVerts = params->convexVerts; + const uint32_t* memConvexPolygonsData = params->convexPolygonsData; + + // Algorithms are similar to CPU version + const PxVec4* memTrimeshVerts = params->trimeshVerts; + const uint32_t* memTrimeshIndices = params->trimeshIndices; + + float collisionRadius = params->collisionDistance + params->collisionThreshold; + + uint32_t numTriMeshes = params->trimeshes.getSize(); + for (uint32_t i = 0; i < numTriMeshes; ++i) + { + CollisionTriMeshData data; + params->trimeshes.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i); + + if (!data.aabb.contains(position)) //check coarse bounds + { + continue; + } + + PxVec3 localPosition = data.inversePose.transform(position); + + PxVec3 localNormal; + float minDistSquared = checkTriangleCollision(memTrimeshVerts, memTrimeshIndices, data, collisionRadius, localPosition, localNormal); + if (minDistSquared == PX_MAX_F32) + { + continue; + } + + float penDepth = params->collisionDistance - PxSqrt(minDistSquared); + + if( penDepth > 0 ) + { + localPosition += localNormal * penDepth; + normal = data.pose.rotate(localNormal); + position = data.pose.transform(localPosition); + updateCollisionVelocity(data, normal, position, velocity); + } + return 1; + } + + uint32_t numConvexMeshes = params->convexMeshes.getSize(); + for (uint32_t i = 0; i < numConvexMeshes; ++i) + { + CollisionConvexMeshData data; + params->convexMeshes.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i); + + if (!data.aabb.contains(position)) //check coarse bounds + { + continue; + } + + PxVec3 localPosition = data.inversePose.transform(position); + + float penDepth = UINT32_MAX; + PxVec3 localNormal(0); + + bool insideConvex = true; + bool insidePolygon = true; + float distSquaredMin = UINT32_MAX; + PxVec3 nearestPointMin; + + uint32_t polygonsDataOffset = data.polygonsDataOffset; + for (uint32_t polyId = 0; polyId < data.numPolygons; polyId++) // for each polygon + { + PxPlane plane; + SIM_FETCH_PLANE(plane, ConvexPlanes, data.firstPlane + polyId); + + uint32_t vertCount = SIM_FETCH(ConvexPolygonsData, polygonsDataOffset); + + float dist = (localPosition.dot(plane.n) + plane.d); + if (dist > 0) //outside convex + { + insideConvex = false; + + if (dist > collisionRadius) + { + insidePolygon = false; + distSquaredMin = dist * dist; + break; + } + + insidePolygon = true; + PxVec3 polygonNormal = plane.n; + + uint32_t begVertId = SIM_FETCH(ConvexPolygonsData, polygonsDataOffset + vertCount); + PxVec3 begVert; splitFloat4(begVert, SIM_FETCH(ConvexVerts, data.firstVertex + begVertId)); + for (uint32_t vertId = 1; vertId <= vertCount; ++vertId) //for each vertex + { + uint32_t endVertId = SIM_FETCH(ConvexPolygonsData, polygonsDataOffset + vertId); + PxVec3 endVert; splitFloat4(endVert, SIM_FETCH(ConvexVerts, data.firstVertex + endVertId)); + + PxVec3 segment = endVert - begVert; + PxVec3 segmentNormal = polygonNormal.cross(segment); + float sign = segmentNormal.dot(localPosition - begVert); + if (sign < 0) + { + insidePolygon = false; + + float distSquared; + PxVec3 nearestPoint; + calculatePointSegmentSquaredDist(begVert, endVert, localPosition, distSquared, nearestPoint); + if (distSquared < distSquaredMin) + { + distSquaredMin = distSquared; + nearestPointMin = nearestPoint; + } + } + + begVert = endVert; + } + if (insidePolygon) + { + penDepth = params->collisionDistance - dist; + localNormal = polygonNormal; + break; + } + } + + if (insideConvex) + { + float penDepthPlane = params->collisionDistance - dist; //dist is negative inside + if (penDepthPlane < penDepth) //inside convex + { + penDepth = penDepthPlane; + localNormal = plane.n; + } + } + polygonsDataOffset += (vertCount + 1); + } + + if (!insideConvex && !insidePolygon) + { + if (distSquaredMin > collisionRadius * collisionRadius) + { + continue; //no intersection, too far away + } + float dist = PxSqrt(distSquaredMin); + + localNormal = localPosition - nearestPointMin; + localNormal *= (1 / dist); //normalize + + penDepth = params->collisionDistance - dist; + } + + if (penDepth > 0) + { + localPosition += localNormal * penDepth; + normal = data.pose.rotate(localNormal); + position = data.pose.transform(localPosition); + updateCollisionVelocity(data, normal, position, velocity); + } + return 1; + } + + uint32_t numBoxes = params->boxes.getSize(); + for (uint32_t i = 0; i < numBoxes; ++i) + { + CollisionBoxData data; + params->boxes.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i); + + if (!data.aabb.contains(position)) + { + continue; + } + + PxVec3 localPosition = data.inversePose.transform(position); + + + PxVec3 closestPoint = PxVec3(PxClamp(localPosition.x, -data.halfSize.x, data.halfSize.x), PxClamp(localPosition.y, -data.halfSize.y, data.halfSize.y), PxClamp(localPosition.z, -data.halfSize.z, data.halfSize.z)); + PxVec3 v = localPosition - closestPoint; + float vMagnitudeSquared = v.magnitudeSquared(); + if(vMagnitudeSquared > collisionRadius * collisionRadius) continue; //no intersection + + PxBounds3 bounds = PxBounds3(-data.halfSize, data.halfSize); + float penDepth; + + PxVec3 localNormal(0); + if(vMagnitudeSquared > 0) + { + float vMagnitude = PxSqrt(vMagnitudeSquared); + localNormal = v * (1 / vMagnitude); + + penDepth = params->collisionDistance - vMagnitude; + } + else + { + PxVec3 penDepth3D = PxVec3( + data.halfSize.x - PxAbs(localPosition.x), + data.halfSize.y - PxAbs(localPosition.y), + data.halfSize.z - PxAbs(localPosition.z) + ); + float penDepth3Dmin = penDepth3D.minElement(); + + if (penDepth3Dmin == penDepth3D.x) + { + localNormal.x = localPosition.x < 0 ? -1.0f : 1.0f; + } + else if (penDepth3Dmin == penDepth3D.y) + { + localNormal.y = localPosition.y < 0 ? -1.0f : 1.0f; + } + else if (penDepth3Dmin == penDepth3D.z) + { + localNormal.z = localPosition.z < 0 ? -1.0f : 1.0f; + } + + penDepth = params->collisionDistance + penDepth3Dmin; + } + + normal = data.pose.rotate(localNormal); + + if (penDepth > 0) + { + localPosition += localNormal * penDepth; + position = data.pose.transform(localPosition); + + updateCollisionVelocity(data, normal, position, velocity); + } + return 1; + } + + uint32_t numCapsules = params->capsules.getSize(); + for (uint32_t i = 0; i < numCapsules; ++i) + { + CollisionCapsuleData data; + params->capsules.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i); + + if (!data.aabb.contains(position)) + { + continue; + } + + PxVec3 localPosition = data.inversePose.transform(position); + + // Capsule is Minkowski sum of sphere with segment + const float closestX = PxClamp(localPosition.x, -data.halfHeight, data.halfHeight); + PxVec3 localNormal(localPosition.x - closestX, localPosition.y, localPosition.z); + + float distance = localNormal.magnitude(); + float penDepth = (data.radius - distance); + // No intersection? + if (-penDepth > params->collisionThreshold) + { + continue; + } + if (distance > 0) // avoid division by zero + { + localNormal /= distance; + } + normal = data.pose.rotate(localNormal); + + if (penDepth > 0) + { + localPosition = data.radius * localNormal; + localPosition.x += closestX; + + position = data.pose.transform(localPosition); + + updateCollisionVelocity(data, normal, position, velocity); + } + return 1; + } + + uint32_t numSpheres = params->spheres.getSize(); + for (uint32_t i = 0; i < numSpheres; ++i) + { + CollisionSphereData data; + params->spheres.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i); + + if (!data.aabb.contains(position)) + { + continue; + } + + PxVec3 localNormal = data.inversePose.transform(position); + float distance = localNormal.magnitude(); + + float penDepth = (data.radius - distance); + // No intersection? + if (-penDepth > params->collisionThreshold) + { + continue; + } + localNormal /= distance; + normal = data.pose.rotate(localNormal); + + if (penDepth > 0) + { + position = data.pose.transform(data.radius * localNormal); + + updateCollisionVelocity(data, normal, position, velocity); + } + return 1; + } + + uint32_t numHalfSpaces = params->halfSpaces.getSize(); + for (uint32_t i = 0; i < numHalfSpaces; ++i) + { + CollisionHalfSpaceData data; + params->halfSpaces.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i); + + float penDepth = (data.origin - position).dot(data.normal); + + // No intersection? + if (-penDepth > params->collisionThreshold) + { + continue; + } + + normal = data.normal; + if (penDepth > 0) + { + position += penDepth * data.normal; + + updateCollisionVelocity(data, normal, position, velocity); + } + return 1; + } + + return 0; + } + + + +#ifdef __CUDACC__ + __device__ +#endif + PX_INLINE float calcParticleBenefit( + const InjectorParams& inj, const PxVec3& eyePos, + const PxVec3& pos, const PxVec3& vel, float life) + { + float benefit = inj.mLODBias; + //distance term + float distance = (eyePos - pos).magnitude(); + benefit += inj.mLODDistanceWeight * (1.0f - PxMin(1.0f, distance / inj.mLODMaxDistance)); + //velocity term, TODO: clamp velocity + float velMag = vel.magnitude(); + benefit += inj.mLODSpeedWeight * velMag; + //life term + benefit += inj.mLODLifeWeight * life; + + return PxClamp(benefit, 0.0f, 1.0f); + } + + INPLACE_TEMPL_VA_ARGS_DEF(typename FieldAccessor) +#ifdef __CUDACC__ + __device__ +#endif + PX_INLINE float simulateParticle( + const SimulationParams* params, INPLACE_STORAGE_ARGS_DEF, SIM_INJECTOR_ARRAY injectorArray, + float deltaTime, PxVec3 gravity, PxVec3 eyePos, + bool isNewParticle, unsigned int srcIdx, unsigned int dstIdx, + SIM_FLOAT4* memPositionMass, SIM_FLOAT4* memVelocityLife, IofxActorIDIntl* memIofxActorIDs, + float* memLifeSpan, float* memLifeTime, unsigned int* memInjector, SIM_FLOAT4* memCollisionNormalFlags, uint32_t* memUserData, + FieldAccessor& fieldAccessor, unsigned int &injIndex + ) + { + //read + PxVec3 position; + PxVec3 velocity; + float mass = splitFloat4(position, SIM_FETCH(PositionMass, srcIdx)); + splitFloat4(velocity, SIM_FETCH(VelocityLife, srcIdx)); + float lifeSpan = SIM_FETCH(LifeSpan, srcIdx); + unsigned int injector = SIM_FETCH(Injector, srcIdx); + IofxActorIDIntl iofxActorID = IofxActorIDIntl(SIM_FETCH(IofxActorIDs, srcIdx)); + + PxVec3 collisionNormal(0.0f); + uint32_t collisionFlags = 0; + + float lifeTime = lifeSpan; + if (!isNewParticle) + { + using namespace nvidia::apex; + + lifeTime = SIM_FETCH(LifeTime, srcIdx); + + //collide using the old state + collisionFlags = handleCollisions INPLACE_TEMPL_ARGS_VAL (params, INPLACE_STORAGE_ARGS_VAL, position, velocity, collisionNormal); + + //advance to a new state + PxVec3 velocityDelta = deltaTime * gravity; + fieldAccessor(srcIdx, velocityDelta); + + velocity += velocityDelta; + position += deltaTime * velocity; + + lifeTime = PxMax(lifeTime - deltaTime, 0.0f); + } + + InjectorParams injParams; + SIM_FETCH_INJECTOR(injectorArray, injParams, injector); + injIndex = injParams.mLocalIndex; + // injParams.mLODBias == FLT_MAX if injector was released! + // and IOFX returns IofxActorIDIntl::NO_VOLUME for homeless/dead particles + bool validActorID = (injParams.mLODBias < FLT_MAX) + && (isNewParticle || (iofxActorID.getVolumeID() != IofxActorIDIntl::NO_VOLUME)) + && position.isFinite() && velocity.isFinite(); + if (!validActorID) + { + iofxActorID.setActorClassID(IofxActorIDIntl::IPX_ACTOR); + injIndex = UINT32_MAX; + } + + //write + memLifeTime[dstIdx] = lifeTime; + + if (!isNewParticle || dstIdx != srcIdx) + { + memPositionMass[dstIdx] = combineFloat4(position, mass); + memVelocityLife[dstIdx] = combineFloat4(velocity, lifeTime / lifeSpan); + } + if (!validActorID || dstIdx != srcIdx) + { + memIofxActorIDs[dstIdx] = iofxActorID; + } + if (dstIdx != srcIdx) + { + memLifeSpan[dstIdx] = lifeSpan; + memInjector[dstIdx] = injector; + + memUserData[dstIdx] = SIM_FETCH(UserData, srcIdx); + } + memCollisionNormalFlags[dstIdx] = combineFloat4(collisionNormal, SIM_INT_AS_FLOAT(collisionFlags)); + + float benefit = -FLT_MAX; + if (validActorID && lifeTime > 0.0f) + { + benefit = calcParticleBenefit(injParams, eyePos, position, velocity, lifeTime / lifeSpan); + } + return benefit; + } + } + +} // namespace nvidia + +#endif diff --git a/APEX_1.4/module/basicios/include/BasicIosScene.h b/APEX_1.4/module/basicios/include/BasicIosScene.h new file mode 100644 index 00000000..32691b3f --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosScene.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_SCENE_H__ +#define __BASIC_IOS_SCENE_H__ + +#include "Apex.h" +#include "ModuleBasicIos.h" +#include "ApexSDKIntl.h" +#include "ModuleIntl.h" +#include "ModuleBasicIosImpl.h" +#include "ApexSharedUtils.h" +#include "ApexSDKHelpers.h" +#include "ApexContext.h" +#include "ApexActor.h" +#include "ModulePerfScope.h" + +#include "PsTime.h" + +#include "DebugRenderParams.h" +#include "BasicIosDebugRenderParams.h" + +#include "BasicIosCommon.h" +#include "BasicIosCommonSrc.h" + +#include "FieldSamplerQueryIntl.h" + +#if APEX_CUDA_SUPPORT +#include "../cuda/include/common.h" + +#include "ApexCudaWrapper.h" +#include "CudaModuleScene.h" + +#define SCENE_CUDA_OBJ(scene, name) static_cast<BasicIosSceneGPU&>(scene).APEX_CUDA_OBJ_NAME(name) + +#endif + +namespace nvidia +{ +namespace apex +{ +class RenderDebugInterface; +class FieldSamplerManagerIntl; +} +namespace basicios +{ + +class BasicIosInjectorStorage +{ +public: + virtual bool growInjectorStorage(uint32_t newSize) = 0; +}; +class BasicIosInjectorAllocator +{ +public: + BasicIosInjectorAllocator(BasicIosInjectorStorage* storage) : mStorage(storage) + { + mFreeInjectorListStart = NULL_INJECTOR_INDEX; + mReleasedInjectorListStart = NULL_INJECTOR_INDEX; + } + + uint32_t allocateInjectorID(); + void releaseInjectorID(uint32_t); + void flushReleased(); + + static const uint32_t NULL_INJECTOR_INDEX = 0xFFFFFFFFu; + static const uint32_t USED_INJECTOR_INDEX = 0xFFFFFFFEu; + +private: + BasicIosInjectorStorage* mStorage; + + physx::Array<uint32_t> mInjectorList; + uint32_t mFreeInjectorListStart; + uint32_t mReleasedInjectorListStart; +}; + + +class BasicIosScene : public ModuleSceneIntl, public ApexContext, public ApexResourceInterface, public ApexResource, protected BasicIosInjectorStorage +{ +public: + BasicIosScene(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* renderDebug, ResourceList& list); + ~BasicIosScene(); + + /* ModuleSceneIntl */ + void release() + { + mModule->releaseModuleSceneIntl(*this); + } + + PxScene* getModulePhysXScene() const + { + return mPhysXScene; + } + void setModulePhysXScene(PxScene*); + PxScene* mPhysXScene; + + void visualize(); + + virtual Module* getModule() + { + return mModule; + } + + virtual SceneStats* getStats() + { + return 0; + } + + bool lockRenderResources() + { + renderLockAllActors(); // Lock options not implemented yet + return true; + } + + bool unlockRenderResources() + { + renderUnLockAllActors(); // Lock options not implemented yet + return true; + } + + /* ApexResourceInterface */ + uint32_t getListIndex() const + { + return m_listIndex; + } + void setListIndex(ResourceList& list, uint32_t index) + { + m_listIndex = index; + m_list = &list; + } + + virtual BasicIosActorImpl* createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset) = 0; + + virtual void submitTasks(float elapsedTime, float substepSize, uint32_t numSubSteps); + virtual void setTaskDependencies(); + virtual void fetchResults(); + + FieldSamplerManagerIntl* getInternalFieldSamplerManager(); + + SceneIntl& getApexScene() const + { + return *mApexScene; + } + + PX_INLINE BasicIosInjectorAllocator& getInjectorAllocator() + { + return mInjectorAllocator; + } + virtual void fetchInjectorParams(uint32_t injectorID, InjectorParams& injParams) = 0; + virtual void updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams) = 0; + +protected: + virtual void onSimulationStart() {} + virtual void onSimulationFinish() + { + mInjectorAllocator.flushReleased(); + } + + + ModuleBasicIosImpl* mModule; + SceneIntl* mApexScene; + + void destroy(); + + float computeAABBDistanceSquared(const PxBounds3& aabb); + + RenderDebugInterface* mDebugRender; + float mSumBenefit; + + DebugRenderParams* mDebugRenderParams; + BasicIosDebugRenderParams* mBasicIosDebugRenderParams; + + FieldSamplerManagerIntl* mFieldSamplerManager; + + BasicIosInjectorAllocator mInjectorAllocator; + + friend class BasicIosActorImpl; + friend class BasicIosAssetImpl; + friend class ModuleBasicIosImpl; +}; + + +} +} // namespace nvidia + +#endif // __BASIC_IOS_SCENE_H__ diff --git a/APEX_1.4/module/basicios/include/BasicIosSceneCPU.h b/APEX_1.4/module/basicios/include/BasicIosSceneCPU.h new file mode 100644 index 00000000..d0c5913f --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosSceneCPU.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_SCENE_CPU_H__ +#define __BASIC_IOS_SCENE_CPU_H__ + +#if ENABLE_TEST +#include "BasicIosTestScene.h" +#endif +#include "BasicIosScene.h" + +namespace nvidia +{ +namespace basicios +{ + +#if ENABLE_TEST +#define BASIC_IOS_SCENE BasicIosTestScene +#else +#define BASIC_IOS_SCENE BasicIosScene +#endif + +class BasicIosSceneCPU : public BASIC_IOS_SCENE +{ + class TimerCallback : public FieldSamplerCallbackIntl, public IofxManagerCallbackIntl, public UserAllocated + { + shdfnd::Time mTimer; + float mMinTime, mMaxTime; + public: + TimerCallback() {} + void operator()(void* stream = NULL); + void reset(); + float getElapsedTime() const; + }; +public: + BasicIosSceneCPU(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list); + ~BasicIosSceneCPU(); + + virtual BasicIosActorImpl* createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset); + + virtual void fetchInjectorParams(uint32_t injectorID, InjectorParams& injParams) + { + PX_ASSERT(injectorID < mInjectorParamsArray.size()); + injParams = mInjectorParamsArray[ injectorID ]; + } + virtual void updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams) + { + PX_ASSERT(injectorID < mInjectorParamsArray.size()); + mInjectorParamsArray[ injectorID ] = injParams; + } + + void fetchResults(); + +protected: + virtual void setCallbacks(BasicIosActorCPU* actor); + virtual bool growInjectorStorage(uint32_t newSize) + { + mInjectorParamsArray.resize(newSize); + return true; + } + +private: + physx::Array<InjectorParams> mInjectorParamsArray; + TimerCallback mTimerCallback; + + friend class BasicIosActorCPU; +}; + +} +} // namespace nvidia + +#endif // __BASIC_IOS_SCENE_H__ diff --git a/APEX_1.4/module/basicios/include/BasicIosSceneGPU.h b/APEX_1.4/module/basicios/include/BasicIosSceneGPU.h new file mode 100644 index 00000000..26fa5f51 --- /dev/null +++ b/APEX_1.4/module/basicios/include/BasicIosSceneGPU.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __BASIC_IOS_SCENE_GPU_H__ +#define __BASIC_IOS_SCENE_GPU_H__ + +#if ENABLE_TEST +#include "BasicIosTestScene.h" +#endif +#include "BasicIosScene.h" + +#include "../cuda/include/common.h" + +#include "ApexCudaWrapper.h" +#include "CudaModuleScene.h" + +#define SCENE_CUDA_OBJ(scene, name) static_cast<BasicIosSceneGPU&>(scene).APEX_CUDA_OBJ_NAME(name) + +namespace nvidia +{ +namespace basicios +{ + +#if ENABLE_TEST +#define BASIC_IOS_SCENE BasicIosTestScene +#else +#define BASIC_IOS_SCENE BasicIosScene +#endif + +class BasicIosSceneGPU : public BASIC_IOS_SCENE, public CudaModuleScene +{ + class EventCallback : public FieldSamplerCallbackIntl, public IofxManagerCallbackIntl, public UserAllocated + { + void* mEvent; + public: + EventCallback(); + void init(); + virtual ~EventCallback(); + void operator()(void* stream); + PX_INLINE void* getEvent() + { + return mEvent; + } + bool mIsCalled; + }; +public: + BasicIosSceneGPU(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list); + ~BasicIosSceneGPU(); + + virtual BasicIosActorImpl* createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset); + + virtual void fetchInjectorParams(uint32_t injectorID, InjectorParams& injParams); + virtual void updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams); + + virtual void fetchResults(); + + void* getHeadCudaObj() + { + return CudaModuleScene::getHeadCudaObj(); + } + +//CUDA module objects +#include "../cuda/include/moduleList.h" + +protected: + virtual void setCallbacks(BasicIosActorGPU* actor); + virtual bool growInjectorStorage(uint32_t newSize); + + void onSimulationStart(); + +private: + ApexCudaConstMemGroup mInjectorConstMemGroup; + InplaceHandle<InjectorParamsArray> mInjectorParamsArrayHandle; + + EventCallback mOnSimulationStart; + physx::Array<EventCallback*> mOnStartCallbacks; + physx::Array<EventCallback*> mOnFinishCallbacks; + + friend class BasicIosActorGPU; +}; + +} +} // namespace nvidia + +#endif // __BASIC_IOS_SCENE_H__ diff --git a/APEX_1.4/module/basicios/include/ModuleBasicIosImpl.h b/APEX_1.4/module/basicios/include/ModuleBasicIosImpl.h new file mode 100644 index 00000000..c0543e77 --- /dev/null +++ b/APEX_1.4/module/basicios/include/ModuleBasicIosImpl.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __MODULE_BASIC_IOS_IMPL_H__ +#define __MODULE_BASIC_IOS_IMPL_H__ + +#include "Apex.h" +#include "ModuleBasicIos.h" +#include "ApexSDKIntl.h" +#include "ModuleBase.h" +#include "ModuleIntl.h" +#include "ResourceProviderIntl.h" +#include "ApexSharedUtils.h" +#include "ApexSDKHelpers.h" +#include "ModulePerfScope.h" +#include "ApexAuthorableObject.h" +#include "BasicIosAssetImpl.h" +#include "ModuleBasicIosRegistration.h" +#include "ApexRWLockable.h" + +namespace nvidia +{ +namespace apex +{ +class ModuleIofxIntl; +class ModuleFieldSamplerIntl; +} +namespace basicios +{ + +class BasicIosScene; + +/** +\brief ModuleBase descriptor for BasicIOS module +*/ +class ModuleBasicIosDesc : public ApexDesc +{ +public: + + /** + \brief constructor sets to default. + */ + PX_INLINE ModuleBasicIosDesc() : ApexDesc() + { + init(); + } + + /** + \brief sets members to default values. + */ + PX_INLINE void setToDefault() + { + ApexDesc::setToDefault(); + init(); + } + + /** + \brief checks if this is a valid descriptor. + */ + PX_INLINE bool isValid() const + { + bool retVal = ApexDesc::isValid(); + return retVal; + } + +private: + + PX_INLINE void init() + { + } +}; + +class ModuleBasicIosImpl : public ModuleBasicIos, public ModuleIntl, public ModuleBase, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ModuleBasicIosImpl(ApexSDKIntl* sdk); + ~ModuleBasicIosImpl(); + + void init(const ModuleBasicIosDesc& desc); + + // base class methods + void init(NvParameterized::Interface&); + NvParameterized::Interface* getDefaultModuleDesc(); + void release() + { + ModuleBase::release(); + } + void destroy(); + const char* getName() const + { + return ModuleBase::getName(); + } + + //BasicIosActor * getApexActor( Scene* scene, AuthObjTypeID type ) const; + ApexActor* getApexActor(Actor* nxactor, AuthObjTypeID type) const; + + ModuleSceneIntl* createInternalModuleScene(SceneIntl&, RenderDebugInterface*); + void releaseModuleSceneIntl(ModuleSceneIntl&); + uint32_t forceLoadAssets(); + AuthObjTypeID getModuleID() const; + RenderableIterator* createRenderableIterator(const Scene&); + + virtual const char* getBasicIosTypeName(); + + BasicIosScene* getBasicIosScene(const Scene& scene); + const BasicIosScene* getBasicIosScene(const Scene& scene) const; + + ModuleIofxIntl* getInternalModuleIofx(); + ModuleFieldSamplerIntl* getInternalModuleFieldSampler(); + + const TestBase* getTestBase(Scene* apexScene) const; + +protected: + + ResourceList mBasicIosSceneList; + ResourceList mAuthorableObjects; + + friend class BasicIosScene; +private: + BasicIosModuleParameters* mModuleParams; + + ModuleIofxIntl* mIofxModule; + ModuleFieldSamplerIntl* mFieldSamplerModule; +}; + +} +} // namespace nvidia + +#endif // __MODULE_BASIC_IOS_IMPL_H__ diff --git a/APEX_1.4/module/basicios/include/ModuleEventDefs.h b/APEX_1.4/module/basicios/include/ModuleEventDefs.h new file mode 100644 index 00000000..cf9f4171 --- /dev/null +++ b/APEX_1.4/module/basicios/include/ModuleEventDefs.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +// This file is used to define a list of AgPerfMon events. +// +// This file is included exclusively by AgPerfMonEventSrcAPI.h +// and by AgPerfMonEventSrcAPI.cpp, for the purpose of building +// an enumeration (enum xx) and an array of strings () +// that contain the list of events. +// +// This file should only contain event definitions, using the +// DEFINE_EVENT macro. E.g.: +// +// DEFINE_EVENT(sample_name_1) +// DEFINE_EVENT(sample_name_2) +// DEFINE_EVENT(sample_name_3) + +DEFINE_EVENT(BasicIosSceneFetchResults) +DEFINE_EVENT(BasicIosCreateObjects) +DEFINE_EVENT(BasicIosFetchResults) + + diff --git a/APEX_1.4/module/basicios/include/ModuleName.h b/APEX_1.4/module/basicios/include/ModuleName.h new file mode 100644 index 00000000..6620ac06 --- /dev/null +++ b/APEX_1.4/module/basicios/include/ModuleName.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __MODULE_NAME_H___ +#define __MODULE_NAME_H___ + +#define MODULE_NAMESPACE basicios + +#endif
\ No newline at end of file diff --git a/APEX_1.4/module/basicios/include/ModulePerfScope.h b/APEX_1.4/module/basicios/include/ModulePerfScope.h new file mode 100644 index 00000000..fe58f327 --- /dev/null +++ b/APEX_1.4/module/basicios/include/ModulePerfScope.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + +#ifndef __MODULE_PERF_SCOPE_H___ +#define __MODULE_PERF_SCOPE_H___ + +#define MODULE_NAMESPACE basicios +#include "ModuleProfileCommon.h" + +#endif
\ No newline at end of file diff --git a/APEX_1.4/module/basicios/include/autogen/BasicIOSAssetParam.h b/APEX_1.4/module/basicios/include/autogen/BasicIOSAssetParam.h new file mode 100644 index 00000000..4e66e462 --- /dev/null +++ b/APEX_1.4/module/basicios/include/autogen/BasicIOSAssetParam.h @@ -0,0 +1,282 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved. + +// This file was generated by NvParameterized/scripts/GenParameterized.pl + + +#ifndef HEADER_BasicIOSAssetParam_h +#define HEADER_BasicIOSAssetParam_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace basicios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace BasicIOSAssetParamNS +{ + +struct RandomF32_Type; +struct GridDensityParams_Type; +struct ParticleToGridCouplingParams_Type; +struct GridToParticleCouplingParams_Type; + +struct ParticleToGridCouplingParams_Type +{ + float accelTimeConstant; + float decelTimeConstant; + float thresholdMultiplier; +}; +struct GridDensityParams_Type +{ + bool Enabled; + const char* Resolution; + float GridSize; + uint32_t MaxCellCount; +}; +struct GridToParticleCouplingParams_Type +{ + float accelTimeConstant; + float decelTimeConstant; + float thresholdMultiplier; +}; +struct RandomF32_Type +{ + float center; + float spread; + const char* type; +}; + +struct ParametersStruct +{ + + float restDensity; + float particleRadius; + uint32_t maxParticleCount; + float maxInjectedParticleCount; + uint32_t maxCollidingObjects; + float sceneGravityScale; + physx::PxVec3 externalAcceleration; + RandomF32_Type particleMass; + NvParameterized::DummyStringStruct collisionFilterDataName; + NvParameterized::DummyStringStruct fieldSamplerFilterDataName; + bool staticCollision; + float restitutionForStaticShapes; + bool dynamicCollision; + float restitutionForDynamicShapes; + float collisionDistanceMultiplier; + float collisionThreshold; + bool collisionWithConvex; + bool collisionWithTriangleMesh; + GridDensityParams_Type GridDensity; + bool enableTemperatureBuffer; + bool enableDensityBuffer; + bool enableCouplingOverride; + ParticleToGridCouplingParams_Type particleToGridCoupling; + GridToParticleCouplingParams_Type gridToParticleCoupling; + +}; + +static const uint32_t checksum[] = { 0xd1ae20ca, 0xe79f585e, 0x9ab86d65, 0x9964607a, }; + +} // namespace BasicIOSAssetParamNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class BasicIOSAssetParam : public NvParameterized::NvParameters, public BasicIOSAssetParamNS::ParametersStruct +{ +public: + BasicIOSAssetParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~BasicIOSAssetParam(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("BasicIOSAssetParam"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)1 << 16) + (uint32_t)4; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(BasicIOSAssetParamNS::checksum); + return BasicIOSAssetParamNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const BasicIOSAssetParamNS::ParametersStruct& parameters(void) const + { + BasicIOSAssetParam* tmpThis = const_cast<BasicIOSAssetParam*>(this); + return *(static_cast<BasicIOSAssetParamNS::ParametersStruct*>(tmpThis)); + } + + BasicIOSAssetParamNS::ParametersStruct& parameters(void) + { + return *(static_cast<BasicIOSAssetParamNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class BasicIOSAssetParamFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + BasicIOSAssetParam::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(BasicIOSAssetParam), BasicIOSAssetParam::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, BasicIOSAssetParam::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIOSAssetParam"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(BasicIOSAssetParam)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, BasicIOSAssetParam)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, BasicIOSAssetParam::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, BasicIOSAssetParam::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIOSAssetParam"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of BasicIOSAssetParam here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (BasicIOSAssetParam*)bufObj; + } + + virtual const char* getClassName() + { + return (BasicIOSAssetParam::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (BasicIOSAssetParam::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (BasicIOSAssetParam::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (BasicIOSAssetParam::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace basicios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/basicios/include/autogen/BasicIosDebugRenderParams.h b/APEX_1.4/module/basicios/include/autogen/BasicIosDebugRenderParams.h new file mode 100644 index 00000000..caca5349 --- /dev/null +++ b/APEX_1.4/module/basicios/include/autogen/BasicIosDebugRenderParams.h @@ -0,0 +1,232 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved. + +// This file was generated by NvParameterized/scripts/GenParameterized.pl + + +#ifndef HEADER_BasicIosDebugRenderParams_h +#define HEADER_BasicIosDebugRenderParams_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace basicios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace BasicIosDebugRenderParamsNS +{ + + + +struct ParametersStruct +{ + + bool VISUALIZE_BASIC_IOS_ACTOR; + bool VISUALIZE_BASIC_IOS_COLLIDE_SHAPES; + bool VISUALIZE_BASIC_IOS_GRID_DENSITY; + +}; + +static const uint32_t checksum[] = { 0xfdf6893d, 0xf8944ef9, 0x2d74bc9a, 0x7fb067bf, }; + +} // namespace BasicIosDebugRenderParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class BasicIosDebugRenderParams : public NvParameterized::NvParameters, public BasicIosDebugRenderParamsNS::ParametersStruct +{ +public: + BasicIosDebugRenderParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~BasicIosDebugRenderParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("BasicIosDebugRenderParams"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(BasicIosDebugRenderParamsNS::checksum); + return BasicIosDebugRenderParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const BasicIosDebugRenderParamsNS::ParametersStruct& parameters(void) const + { + BasicIosDebugRenderParams* tmpThis = const_cast<BasicIosDebugRenderParams*>(this); + return *(static_cast<BasicIosDebugRenderParamsNS::ParametersStruct*>(tmpThis)); + } + + BasicIosDebugRenderParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<BasicIosDebugRenderParamsNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class BasicIosDebugRenderParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + BasicIosDebugRenderParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(BasicIosDebugRenderParams), BasicIosDebugRenderParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, BasicIosDebugRenderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosDebugRenderParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(BasicIosDebugRenderParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, BasicIosDebugRenderParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, BasicIosDebugRenderParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, BasicIosDebugRenderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosDebugRenderParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of BasicIosDebugRenderParams here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (BasicIosDebugRenderParams*)bufObj; + } + + virtual const char* getClassName() + { + return (BasicIosDebugRenderParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (BasicIosDebugRenderParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (BasicIosDebugRenderParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (BasicIosDebugRenderParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace basicios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/basicios/include/autogen/BasicIosModuleParameters.h b/APEX_1.4/module/basicios/include/autogen/BasicIosModuleParameters.h new file mode 100644 index 00000000..6a382a80 --- /dev/null +++ b/APEX_1.4/module/basicios/include/autogen/BasicIosModuleParameters.h @@ -0,0 +1,230 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved. + +// This file was generated by NvParameterized/scripts/GenParameterized.pl + + +#ifndef HEADER_BasicIosModuleParameters_h +#define HEADER_BasicIosModuleParameters_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace basicios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace BasicIosModuleParametersNS +{ + + + +struct ParametersStruct +{ + + uint32_t unused; + +}; + +static const uint32_t checksum[] = { 0x3fbae874, 0x2a648c69, 0x7ac9c757, 0x46be4dcd, }; + +} // namespace BasicIosModuleParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class BasicIosModuleParameters : public NvParameterized::NvParameters, public BasicIosModuleParametersNS::ParametersStruct +{ +public: + BasicIosModuleParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~BasicIosModuleParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("BasicIosModuleParameters"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(BasicIosModuleParametersNS::checksum); + return BasicIosModuleParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const BasicIosModuleParametersNS::ParametersStruct& parameters(void) const + { + BasicIosModuleParameters* tmpThis = const_cast<BasicIosModuleParameters*>(this); + return *(static_cast<BasicIosModuleParametersNS::ParametersStruct*>(tmpThis)); + } + + BasicIosModuleParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<BasicIosModuleParametersNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class BasicIosModuleParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + BasicIosModuleParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(BasicIosModuleParameters), BasicIosModuleParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, BasicIosModuleParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosModuleParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(BasicIosModuleParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, BasicIosModuleParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, BasicIosModuleParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, BasicIosModuleParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosModuleParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of BasicIosModuleParameters here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (BasicIosModuleParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (BasicIosModuleParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (BasicIosModuleParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (BasicIosModuleParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (BasicIosModuleParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace basicios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/basicios/include/autogen/ModuleBasicIosRegistration.h b/APEX_1.4/module/basicios/include/autogen/ModuleBasicIosRegistration.h new file mode 100644 index 00000000..e5324edf --- /dev/null +++ b/APEX_1.4/module/basicios/include/autogen/ModuleBasicIosRegistration.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#ifndef MODULE_MODULEBASICIOSREGISTRATIONH_H +#define MODULE_MODULEBASICIOSREGISTRATIONH_H + +#include "PsAllocator.h" +#include "NvRegistrationsForTraitsBase.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "PxAssert.h" +#include <stdint.h> + +// INCLUDE GENERATED FACTORIES +#include "BasicIOSAssetParam.h" +#include "BasicIosDebugRenderParams.h" +#include "BasicIosModuleParameters.h" + + +// INCLUDE GENERATED CONVERSION + + +namespace nvidia { +namespace basicios { + + +class ModuleBasicIosRegistration : public NvParameterized::RegistrationsForTraitsBase +{ +public: + static void invokeRegistration(NvParameterized::Traits* parameterizedTraits) + { + if (parameterizedTraits) + { + ModuleBasicIosRegistration().registerAll(*parameterizedTraits); + } + } + + static void invokeUnregistration(NvParameterized::Traits* parameterizedTraits) + { + if (parameterizedTraits) + { + ModuleBasicIosRegistration().unregisterAll(*parameterizedTraits); + } + } + + void registerAvailableFactories(NvParameterized::Traits& parameterizedTraits) + { + ::NvParameterized::Factory* factoriesToRegister[] = { +// REGISTER GENERATED FACTORIES + new nvidia::basicios::BasicIOSAssetParamFactory(), + new nvidia::basicios::BasicIosDebugRenderParamsFactory(), + new nvidia::basicios::BasicIosModuleParametersFactory(), + + }; + + for (size_t i = 0; i < sizeof(factoriesToRegister)/sizeof(factoriesToRegister[0]); ++i) + { + parameterizedTraits.registerFactory(*factoriesToRegister[i]); + } + } + + virtual void registerAvailableConverters(NvParameterized::Traits& parameterizedTraits) + { +// REGISTER GENERATED CONVERSION +PX_UNUSED(parameterizedTraits); + + } + + void unregisterAvailableFactories(NvParameterized::Traits& parameterizedTraits) + { + struct FactoryDesc + { + const char* name; + uint32_t version; + }; + + ::NvParameterized::Factory* factoriesToUnregister[] = { +// UNREGISTER GENERATED FACTORIES + new nvidia::basicios::BasicIOSAssetParamFactory(), + new nvidia::basicios::BasicIosDebugRenderParamsFactory(), + new nvidia::basicios::BasicIosModuleParametersFactory(), + + }; + + for (size_t i = 0; i < sizeof(factoriesToUnregister)/sizeof(factoriesToUnregister[0]); ++i) + { + ::NvParameterized::Factory* removedFactory = parameterizedTraits.removeFactory(factoriesToUnregister[i]->getClassName(), factoriesToUnregister[i]->getVersion()); + if (!removedFactory) + { + PX_ASSERT_WITH_MESSAGE(0, "Factory can not be removed!"); + } + else + { + removedFactory->freeParameterDefinitionTable(¶meterizedTraits); + delete removedFactory; + delete factoriesToUnregister[i]; + } + } + } + + virtual void unregisterAvailableConverters(NvParameterized::Traits& parameterizedTraits) + { +// UNREGISTER GENERATED CONVERSION +PX_UNUSED(parameterizedTraits); + + } + +}; + + +} +} //nvidia::basicios + +#endif |