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/emitter | |
| 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/emitter')
67 files changed, 24113 insertions, 0 deletions
diff --git a/APEX_1.4/module/emitter/include/EmitterActorImpl.h b/APEX_1.4/module/emitter/include/EmitterActorImpl.h new file mode 100644 index 00000000..57200983 --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterActorImpl.h @@ -0,0 +1,361 @@ +/* + * 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 __EMITTER_ACTOR_IMPL_H__ +#define __EMITTER_ACTOR_IMPL_H__ + +#include "Apex.h" + +#include "EmitterActor.h" +#include "ApexActor.h" +#include "EmitterScene.h" +#include "EmitterLodParamDesc.h" +#include "ApexRWLockable.h" +#include "ApexRand.h" +#include "ReadCheck.h" +#include "WriteCheck.h" + +namespace nvidia +{ +namespace apex +{ +class EmitterAsset; +} +namespace emitter +{ +class EmitterAssetImpl; +class EmitterGeomBase; + +class EmitterActorImpl : public EmitterActor, public EmitterActorBase, public ApexResourceInterface, public ApexResource, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + /* EmitterActor methods */ + EmitterActorImpl(const EmitterActorDesc&, EmitterAssetImpl&, ResourceList&, EmitterScene&); + ~EmitterActorImpl(); + + EmitterAsset* getEmitterAsset() const; + PxMat44 getGlobalPose() const + { + READ_ZONE(); + return PxMat44(mPose); + } + void setCurrentPose(const PxTransform& pose) + { + WRITE_ZONE(); + mPose = pose; + } + void setCurrentPosition(const PxVec3& pos) + { + WRITE_ZONE(); + mPose.p = pos; + } + Renderable* getRenderable() + { + READ_ZONE(); + return NULL; + } + Actor* getActor() + { + READ_ZONE(); + return this; + } + void removeActorAtIndex(uint32_t index); + + 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) + { + WRITE_ZONE(); + ApexActor::setEnableDebugVisualization(state); + } + + EmitterGeomExplicit* isExplicitGeom(); + + const EmitterLodParamDesc& getLodParamDesc() const + { + READ_ZONE(); + return mLodParams; + } + void setLodParamDesc(const EmitterLodParamDesc& d); + + /* ApexResourceInterface, ApexResource */ + void release(); + uint32_t getListIndex() const + { + READ_ZONE(); + return m_listIndex; + } + void setListIndex(class ResourceList& list, uint32_t index) + { + WRITE_ZONE(); + m_list = &list; + m_listIndex = index; + } + + /* EmitterActorBase */ + void destroy(); + Asset* getOwner() const; + void visualize(RenderDebugInterface& renderDebug); + + void setPhysXScene(PxScene* s) + { + WRITE_ZONE(); + mPxScene = s; + } + PxScene* getPhysXScene() const + { + READ_ZONE(); + return mPxScene; + } + PxScene* mPxScene; + + void submitTasks(); + void setTaskDependencies(); + void fetchResults(); + + void setDensity(const float& r) + { + WRITE_ZONE(); + mDensity = r; + } + + void setRate(const float& r) + { + WRITE_ZONE(); + mRate = r; + } + + void setVelocityLow(const PxVec3& r) + { + WRITE_ZONE(); + mVelocityLow = r; + } + + void setVelocityHigh(const PxVec3& r) + { + WRITE_ZONE(); + mVelocityHigh = r; + } + + void setLifetimeLow(const float& r) + { + WRITE_ZONE(); + mLifetimeLow = r; + } + + void setLifetimeHigh(const float& r) + { + WRITE_ZONE(); + mLifetimeHigh = r; + } + + void getRate(float& r) const + { + READ_ZONE(); + r = mRate; + } + + void setOverlapTestCollisionGroups(uint32_t g) + { + WRITE_ZONE(); + mOverlapTestCollisionGroups = g; + } + + uint32_t getOverlapTestCollisionGroups() const + { + READ_ZONE(); + return mOverlapTestCollisionGroups; + } + + virtual void setDensityGridPosition(const PxVec3 &pos); + + virtual void setApexEmitterValidateCallback(EmitterValidateCallback *callback) + { + WRITE_ZONE(); + mEmitterValidateCallback = callback; + } + + PX_DEPRECATED void setObjectScale(float scale) + { + WRITE_ZONE(); + setCurrentScale(scale); + } + + PX_DEPRECATED float getObjectScale(void) const + { + READ_ZONE(); + return getObjectScale(); + } + + virtual void setCurrentScale(float scale) + { + WRITE_ZONE(); + mObjectScale = scale; + if (mInjector) + { + mInjector->setObjectScale(mObjectScale); + } + } + + virtual float getCurrentScale(void) const + { + READ_ZONE(); + return mObjectScale; + } + + void startEmit(bool persistent); + void stopEmit(); + bool isEmitting() const + { + READ_ZONE(); + return mDoEmit; + } + + void emitAssetParticles(bool enable) + { + WRITE_ZONE(); + mEmitAssetParticles = enable; + } + bool getEmitAssetParticles() const + { + READ_ZONE(); + return mEmitAssetParticles; + } + + void setAttachActor(PxActor* a) + { + WRITE_ZONE(); + mAttachActor = a; + } + const PxActor* getAttachActor() const + { + READ_ZONE(); + return mAttachActor; + } + PxActor* mAttachActor; + + void setAttachRelativePose(const PxTransform& p) + { + WRITE_ZONE(); + mAttachRelativePose = p; + } + + const PxMat44 getAttachRelativePose() const + { + READ_ZONE(); + return PxMat44(mAttachRelativePose); + } + float getObjectRadius() const + { + READ_ZONE(); + return mObjectRadius; + } + void setPreferredRenderVolume(nvidia::apex::RenderVolume*); + + static PxVec3 random(const PxVec3& low, const PxVec3& high, QDSRand& rand); + static float random(const float& low, const float& high, QDSRand& rand); + + void setSeed(uint32_t seed) + { + mRand.setSeed(seed); + } + + virtual uint32_t getSimParticlesCount() const + { + READ_ZONE(); + return mInjector->getSimParticlesCount(); + } + + virtual uint32_t getActiveParticleCount() const; + +protected: + uint32_t computeNbEmittedFromRate(float dt, float currate); + void emitObjects(const PxTransform& pose, uint32_t toEmitNum, bool useFullVolume); + void emitObjects(const physx::Array<PxVec3>& positions); + void tick(); + + EmitterValidateCallback *mEmitterValidateCallback; + IosInjectorIntl* mInjector; + InstancedObjectSimulationIntl *mIOS; + EmitterAssetImpl* mAsset; + EmitterScene* mScene; + PxBounds3 mOverlapAABB; + PxBounds3 mLastNonEmptyOverlapAABB; + + float mObjectScale; + /* runtime state */ + PxTransform mPose; + physx::Array<PxTransform> mPoses; + bool mFirstStartEmitCall; + bool mDoEmit; + bool mEmitAssetParticles; + bool mPersist; + float mRemainder; + float mEmitterVolume; + bool mIsOldPoseInitialized; + PxTransform mOldPose; + float mDensity; + float mRate; + PxVec3 mVelocityLow; + PxVec3 mVelocityHigh; + float mLifetimeLow; + float mLifetimeHigh; + float mObjectRadius; + float mEmitDuration; + float mDescEmitDuration; + uint32_t mOverlapTestCollisionGroups; + bool mShouldUseGroupsMask; + physx::Array<IosNewObject> mNewObjectArray; + physx::Array<PxVec3> mNewPositions; + physx::Array<PxVec3> mNewVelocities; + physx::Array<uint32_t> mNewUserData; + + EmitterGeomBase* mExplicitGeom; + EmitterLodParamDesc mLodParams; + PxTransform mAttachRelativePose; + + nvidia::QDSRand mRand; + + class ApexEmitterTickTask : public PxTask + { + private: + ApexEmitterTickTask& operator=(const ApexEmitterTickTask&); + + public: + ApexEmitterTickTask(EmitterActorImpl& actor) : mActor(actor) {} + + const char* getName() const + { + return "EmitterActorImpl::TickTask"; + } + void run() + { + mActor.tick(); + } + + protected: + EmitterActorImpl& mActor; + }; + ApexEmitterTickTask mTickTask; + + friend class EmitterScene; +}; + +} +} // end namespace nvidia + +#endif diff --git a/APEX_1.4/module/emitter/include/EmitterAssetImpl.h b/APEX_1.4/module/emitter/include/EmitterAssetImpl.h new file mode 100644 index 00000000..8621ea6b --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterAssetImpl.h @@ -0,0 +1,532 @@ +/* + * 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 EMITTER_ASSET_IMPL_H +#define EMITTER_ASSET_IMPL_H + +#include "Apex.h" +#include "EmitterAsset.h" +#include "EmitterGeomBase.h" +#include "ApexSDKHelpers.h" +#include "ApexAssetAuthoring.h" +#include "ApexAssetTracker.h" +#include "ApexString.h" +#include "ResourceProviderIntl.h" +#include "InstancedObjectSimulationIntl.h" +#include "EmitterLodParamDesc.h" +#include "ApexAuthorableObject.h" +#include "ApexEmitterAssetParameters.h" +#include "ApexEmitterActorParameters.h" +#include "EmitterAssetPreviewParameters.h" +#include "ApexUsingNamespace.h" +#include "CurveImpl.h" +#include "ApexRWLockable.h" +#include "ReadCheck.h" +#include "WriteCheck.h" +#include "ApexAuthorableObject.h" + +namespace nvidia +{ +namespace iofx +{ +class IofxAsset; +} + +namespace emitter +{ + +class EmitterActorImpl; +class ModuleEmitterImpl; + +/** + Descriptor used to create an ApexEmitter preview. +*/ +class EmitterPreviewDesc : public ApexDesc +{ +public: + PxTransform mPose; ///< pose of the preview renderer + float mScale; ///< scaling factor of renderable + + /** + \brief Constructor sets to default. + */ + PX_INLINE EmitterPreviewDesc() : ApexDesc() + { + setToDefault(); + } + + /** + \brief Sets to default values. + */ + PX_INLINE void setToDefault() + { + ApexDesc::setToDefault(); + + mPose = PxTransform(PxIdentity); + mScale = 1.0f; + } + + /** + \brief checks the valididty of parameters. + */ + PX_INLINE bool isValid() const + { + return ApexDesc::isValid(); + } +}; + + +class EmitterActorDesc : public ApexDesc +{ +public: + PxTransform initialPose; ///< the pose of the emitter immediately after addding to the scene. + + PxActor* attachActor; ///< the actor to which the emitter will be attatched. May be NULL to keep the emitter unattatched. + + PxTransform attachRelativePose; ///< the pose of the emitter in the space of the actor, to which it is attatched. Overrides the initial pose. + + uint32_t overlapTestCollisionGroups; ///< collision groups used to reject particles overlapping with the geometry + + bool emitAssetParticles; ///< indicates whether authored asset particle list will be emitted, defaults to true + + float emitterDuration; + + float initialScale; + + /** + \brief constructor sets to default. + */ + PX_INLINE EmitterActorDesc() : 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() + { + initialPose = PxTransform(PxIdentity); + attachActor = NULL; + attachRelativePose = PxTransform(PxIdentity); + overlapTestCollisionGroups = 0; + emitAssetParticles = true; + emitterDuration = PX_MAX_F32; + initialScale = 1.0f; + } +}; + +class EmitterAssetImpl : public EmitterAsset, + public ApexResourceInterface, + public ApexResource, + public NvParameterized::SerializationCallback, + public ApexRWLockable +{ + friend class ApexEmitterAssetDummyAuthoring; +public: + APEX_RW_LOCKABLE_BOILERPLATE + + EmitterAssetImpl(ModuleEmitterImpl*, ResourceList&, const char* name); + EmitterAssetImpl(ModuleEmitterImpl* module, + ResourceList& list, + NvParameterized::Interface* params, + const char* name); + + ~EmitterAssetImpl(); + + /* Asset */ + const char* getName() const + { + return mName.c_str(); + } + AuthObjTypeID getObjTypeID() const + { + READ_ZONE(); + return mAssetTypeID; + } + const char* getObjTypeName() const + { + return getClassName(); + } + uint32_t forceLoadAssets(); + + /* ApexInterface */ + virtual void release(); + + /* ApexResourceInterface, ApexResource */ + uint32_t getListIndex() const + { + return m_listIndex; + } + void setListIndex(class ResourceList& list, uint32_t index) + { + m_list = &list; + m_listIndex = index; + } + + /* EmitterAsset specific methods */ + + EmitterGeomExplicit* isExplicitGeom(); + const EmitterGeomExplicit* isExplicitGeom() const; + + const EmitterGeom* getGeom() const + { + return mGeom->getEmitterGeom(); + } + + const char* getInstancedObjectEffectsAssetName(void) const + { + READ_ZONE(); + return mParams->iofxAssetName->name(); + } + const char* getInstancedObjectSimulatorAssetName(void) const + { + READ_ZONE(); + return mParams->iosAssetName->name(); + } + const char* getInstancedObjectSimulatorTypeName(void) const + { + READ_ZONE(); + return mParams->iosAssetName->className(); + } + + const float & getDensity() const + { + READ_ZONE(); + return mParams->density; + } + + const float & getRate() const + { + READ_ZONE(); + return mParams->rate; + } + + const PxVec3 & getVelocityLow() const + { + READ_ZONE(); + return mParams->velocityLow; + } + + const PxVec3 & getVelocityHigh() const + { + READ_ZONE(); + return mParams->velocityHigh; + } + + const float & getLifetimeLow() const + { + READ_ZONE(); + return mParams->lifetimeLow; + } + + const float & getLifetimeHigh() const + { + READ_ZONE(); + return mParams->lifetimeHigh; + } + + uint32_t getMaxSamples() const + { + READ_ZONE(); + return mParams->maxSamples; + } + + float getEmitDuration() const + { + READ_ZONE(); + return mParams->emitterDuration; + } + + const EmitterLodParamDesc& getLodParamDesc() const + { + READ_ZONE(); + return mLodDesc; + } + + EmitterActor* createEmitterActor(const EmitterActorDesc&, const Scene&); + void releaseEmitterActor(EmitterActor&); + void destroy(); + + EmitterPreview* createEmitterPreview(const EmitterPreviewDesc& desc, AssetPreviewScene* previewScene); + void releaseEmitterPreview(EmitterPreview& preview); + + const NvParameterized::Interface* getAssetNvParameterized() const + { + READ_ZONE(); + return mParams; + } + /** + * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller. + */ + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + WRITE_ZONE(); + NvParameterized::Interface* ret = mParams; + mParams = NULL; + release(); + return ret; + } + + NvParameterized::Interface* getDefaultActorDesc(); + NvParameterized::Interface* getDefaultAssetPreviewDesc(); + virtual Actor* createApexActor(const NvParameterized::Interface& params, Scene& apexScene); + virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& params, AssetPreviewScene* previewScene); + virtual bool isValidForActorCreation(const ::NvParameterized::Interface& actorParams, Scene& /*apexScene*/) const; + + virtual bool isDirty() const + { + READ_ZONE(); + return false; + } + +protected: + /* Typical asset members */ + static const char* getClassName() + { + return EMITTER_AUTHORING_TYPE_NAME; + } + static AuthObjTypeID mAssetTypeID; + + IofxAsset* getIofxAsset(); // callable by actors + + /* NvParameterized Serialization callbacks */ + void preSerialize(void* userData_ = NULL) + { + PX_UNUSED(userData_); + } + void postDeserialize(void* userData_ = NULL); + + void copyLodDesc2(EmitterLodParamDesc& dst, + const ApexEmitterAssetParametersNS::emitterLodParamDesc_Type& src); + void copyLodDesc2(ApexEmitterAssetParametersNS::emitterLodParamDesc_Type& dst, + const EmitterLodParamDesc& src); + + + ApexEmitterAssetParameters* mParams; + ApexEmitterActorParameters* mDefaultActorParams; + EmitterAssetPreviewParameters* mDefaultPreviewParams; + + ModuleEmitterImpl* mModule; + ResourceList mEmitterActors; + ApexSimpleString mName; + + /* EmitterAsset specific asset members */ + EmitterGeomBase* mGeom; + + /* this lod is only for the getter and setter, it should mirror the parameterized lod desc */ + EmitterLodParamDesc mLodDesc; + + /* objects that assist in force loading and proper "assets own assets" behavior */ + ApexAssetTracker mIofxAssetTracker; + ApexAssetTracker mIosAssetTracker; + void initializeAssetNameTable(); + + CurveImpl mRateVsTimeCurve; + + friend class ModuleEmitterImpl; + friend class EmitterActorImpl; + friend class EmitterAssetPreview; + template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject; +}; + +#ifndef WITHOUT_APEX_AUTHORING +class EmitterAssetAuthoringImpl : public EmitterAssetImpl, public ApexAssetAuthoring, public EmitterAssetAuthoring +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + /* EmitterAssetAuthoring */ + EmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l) : + EmitterAssetImpl(m, l, "ApexEmitterAuthor") {} + + EmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l, const char* name) : + EmitterAssetImpl(m, l, name) {} + + EmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l, NvParameterized::Interface* params, const char* name) : + EmitterAssetImpl(m, l, params, name) {} + + ~EmitterAssetAuthoringImpl() {} + + EmitterGeomBox* setBoxGeom(); + EmitterGeomSphere* setSphereGeom(); + EmitterGeomSphereShell* setSphereShellGeom(); + EmitterGeomExplicit* setExplicitGeom(); + + void setInstancedObjectEffectsAssetName(const char*); + void setInstancedObjectSimulatorAssetName(const char*); + void setInstancedObjectSimulatorTypeName(const char*); + + void setDensity(const float& r) + { + mParams->density = r; + } + + void setRate(const float& r) + { + mParams->rate = r; + } + + // Noise parameters + void setVelocityLow(const PxVec3& v) + { + mParams->velocityLow.x = v.x; + mParams->velocityLow.y = v.y; + mParams->velocityLow.z = v.z; + } + void setVelocityHigh(const PxVec3& v) + { + mParams->velocityHigh.x = v.x; + mParams->velocityHigh.y = v.y; + mParams->velocityHigh.z = v.z; + } + + void setLifetimeLow(const float& l) + { + mParams->lifetimeLow = l; + } + + void setLifetimeHigh(const float& l) + { + mParams->lifetimeHigh = l; + } + + + /* Max samples is ignored if using explicit geometry */ + void setMaxSamples(uint32_t max) + { + mParams->maxSamples = max; + } + + void setLodParamDesc(const EmitterLodParamDesc& d) + { + mLodDesc = d; + copyLodDesc2(mParams->lodParamDesc, d); + } + + const EmitterGeom* getGeom() const + { + READ_ZONE(); + return EmitterAssetImpl::getGeom(); + } + const char* getInstancedObjectEffectsAssetName(void) const + { + return EmitterAssetImpl::getInstancedObjectEffectsAssetName(); + } + const char* getInstancedObjectSimulatorAssetName(void) const + { + return EmitterAssetImpl::getInstancedObjectSimulatorAssetName(); + } + const char* getInstancedObjectSimulatorTypeName(void) const + { + return EmitterAssetImpl::getInstancedObjectSimulatorTypeName(); + } + const float& getDensity() const + { + return EmitterAssetImpl::getDensity(); + } + const float& getRate() const + { + return EmitterAssetImpl::getRate(); + } + const PxVec3& getVelocityLow() const + { + return EmitterAssetImpl::getVelocityLow(); + } + const PxVec3& getVelocityHigh() const + { + return EmitterAssetImpl::getVelocityHigh(); + } + const float& getLifetimeLow() const + { + return EmitterAssetImpl::getLifetimeLow(); + } + const float& getLifetimeHigh() const + { + return EmitterAssetImpl::getLifetimeHigh(); + } + uint32_t getMaxSamples() const + { + return EmitterAssetImpl::getMaxSamples(); + } + const EmitterLodParamDesc& getLodParamDesc() const + { + READ_ZONE(); + return EmitterAssetImpl::getLodParamDesc(); + } + + /* AssetAuthoring */ + const char* getName(void) const + { + READ_ZONE(); + return EmitterAssetImpl::getName(); + } + const char* getObjTypeName() const + { + READ_ZONE(); + return EmitterAssetImpl::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); + } + 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 = getNvParameterized(); + mParams = NULL; + release(); + return ret; + } + + + /* ApexInterface */ + virtual void release(); +}; +#endif + +} +} // end namespace nvidia + +#endif // EMITTER_ASSET_IMPL_H diff --git a/APEX_1.4/module/emitter/include/EmitterAssetPreview.h b/APEX_1.4/module/emitter/include/EmitterAssetPreview.h new file mode 100644 index 00000000..7bad148e --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterAssetPreview.h @@ -0,0 +1,79 @@ +/* + * 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 __EMITTER_ASSET_PREVIEW_H__ +#define __EMITTER_ASSET_PREVIEW_H__ + +#include "ApexPreview.h" + +#include "ApexSDKIntl.h" +#include "EmitterPreview.h" +#include "RenderDebugInterface.h" +#include "EmitterAssetImpl.h" +#include "ApexRWLockable.h" + +namespace nvidia +{ +namespace emitter +{ + +class EmitterAssetPreview : public EmitterPreview, public ApexResource, public ApexPreview, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + EmitterAssetPreview(const EmitterPreviewDesc& pdesc, const EmitterAssetImpl& asset, AssetPreviewScene* previewScene, ApexSDK* myApexSDK); + + bool isValid() const; + + void drawEmitterPreview(void); + void drawPreviewAssetInfo(void); + void drawInfoLine(uint32_t lineNum, const char* str); + void destroy(); + + void setPose(const PxMat44& pose); // Sets the preview instance's pose. This may include scaling. + const PxMat44 getPose() const; + + // from RenderDataProvider + void lockRenderResources(void); + void unlockRenderResources(void); + void updateRenderResources(bool rewriteBuffers = false, void* userRenderData = 0); + + // from Renderable.h + void dispatchRenderResources(UserRenderer& renderer); + PxBounds3 getBounds(void) const; + + // from ApexResource.h + void release(void); + +private: + ~EmitterAssetPreview(); + + void toggleDrawPreview(); + void setDrawGroupsPose(); + + + AuthObjTypeID mModuleID; // the module ID of Emitter. + ApexSDK* mApexSDK; // pointer to the APEX SDK + RenderDebugInterface* mApexRenderDebug; // Pointer to the RenderLines class to draw the + PxMat44 mPose; // the pose for the preview rendering + float mScale; + const EmitterAssetImpl* mAsset; + int32_t mGroupID; + AssetPreviewScene* mPreviewScene; + + void setScale(float scale); +}; + +} +} // end namespace nvidia + +#endif // __EMITTER_ASSET_PREVIEW_H__ diff --git a/APEX_1.4/module/emitter/include/EmitterGeomBase.h b/APEX_1.4/module/emitter/include/EmitterGeomBase.h new file mode 100644 index 00000000..3df1f830 --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterGeomBase.h @@ -0,0 +1,68 @@ +/* + * 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 __EMITTER_GEOM_BASE_H__ +#define __EMITTER_GEOM_BASE_H__ + +#include "Apex.h" +#include "EmitterGeoms.h" +#include "PsArray.h" +#include "PsUserAllocated.h" +#include <ApexUsingNamespace.h> +#include "ApexRand.h" + +namespace nvidia +{ +namespace apex +{ +class RenderDebugInterface; +} +namespace emitter +{ + +/* Implementation base class for all EmitterGeom derivations */ + +class EmitterGeomBase : public UserAllocated +{ +public: + /* Asset callable functions */ + virtual EmitterGeom* getEmitterGeom() = 0; + virtual void destroy() = 0; + + /* ApexEmitterActor runtime access methods */ + virtual float computeEmitterVolume() const = 0; + virtual void computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform&, + const PxVec3&, + float, + PxBounds3& outBounds, + QDSRand& rand) const = 0; + + virtual PxVec3 randomPosInFullVolume(const PxMat44&, QDSRand&) const = 0; + + /* AssetPreview methods */ + virtual void drawPreview(float scale, RenderDebugInterface* renderDebug) const = 0; + + /* Optional override functions */ + virtual void visualize(const PxTransform&, RenderDebugInterface&) { } + + virtual float computeNewlyCoveredVolume(const PxMat44&, const PxMat44&, float, QDSRand&) const; + virtual PxVec3 randomPosInNewlyCoveredVolume(const PxMat44&, const PxMat44&, QDSRand&) const; + +protected: + virtual bool isInEmitter(const PxVec3& pos, const PxMat44& pose) const = 0; +}; + +} +} // end namespace nvidia + +#endif diff --git a/APEX_1.4/module/emitter/include/EmitterGeomBoxImpl.h b/APEX_1.4/module/emitter/include/EmitterGeomBoxImpl.h new file mode 100644 index 00000000..aa9be32e --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterGeomBoxImpl.h @@ -0,0 +1,94 @@ +/* + * 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 __EMITTER_GEOM_BOX_IMPL_H__ +#define __EMITTER_GEOM_BOX_IMPL_H__ + +#include "EmitterGeomBase.h" +#include "PsUserAllocated.h" +#include "EmitterGeomBoxParams.h" + +namespace NvParameterized +{ +class Interface; +}; + +namespace nvidia +{ +namespace emitter +{ + +class EmitterGeomBoxImpl : public EmitterGeomBox, public EmitterGeomBase +{ +public: + EmitterGeomBoxImpl(NvParameterized::Interface* params); + + /* Asset callable methods */ + EmitterGeom* getEmitterGeom(); + const EmitterGeomBox* isBoxGeom() const + { + return this; + } + EmitterType::Enum getEmitterType() const + { + return mType; + } + void setEmitterType(EmitterType::Enum t); + void setExtents(const PxVec3& extents) + { + *mExtents = extents; + } + PxVec3 getExtents() const + { + return *mExtents; + } + void destroy() + { + delete this; + } + + /* AssetPreview methods */ + void drawPreview(float scale, RenderDebugInterface* renderDebug) const; + + /* Actor callable methods */ + void visualize(const PxTransform& pose, RenderDebugInterface& renderDebug); + float computeNewlyCoveredVolume(const PxMat44&, const PxMat44&, float, QDSRand&) const; + + void computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform&, + const PxVec3&, + float, + PxBounds3& outBounds, + QDSRand& rand) const; + + float computeEmitterVolume() const; + PxVec3 randomPosInFullVolume( + const PxMat44& pose, + QDSRand& rand) const; + PxVec3 randomPosInNewlyCoveredVolume( + const PxMat44& pose, + const PxMat44& oldPose, + QDSRand& rand) const; + bool isInEmitter( + const PxVec3& pos, + const PxMat44& pose) const; + +protected: + EmitterType::Enum mType; + PxVec3* mExtents; + EmitterGeomBoxParams* mGeomParams; +}; + +} +} // end namespace nvidia + +#endif
\ No newline at end of file diff --git a/APEX_1.4/module/emitter/include/EmitterGeomCylinderImpl.h b/APEX_1.4/module/emitter/include/EmitterGeomCylinderImpl.h new file mode 100644 index 00000000..816c0628 --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterGeomCylinderImpl.h @@ -0,0 +1,94 @@ +/* + * 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 __EMITTER_GEOM_CYLINDER_IMPL_H__ +#define __EMITTER_GEOM_CYLINDER_IMPL_H__ + +#include "EmitterGeomBase.h" +#include "PsUserAllocated.h" +#include "EmitterGeomCylinderParams.h" + +namespace NvParameterized +{ +class Interface; +}; + +namespace nvidia +{ +namespace emitter +{ + +class EmitterGeomCylinderImpl : public EmitterGeomCylinder, public EmitterGeomBase +{ +public: + EmitterGeomCylinderImpl(NvParameterized::Interface* params); + + /* Asset callable methods */ + EmitterGeom* getEmitterGeom(); + const EmitterGeomCylinder* isCylinderGeom() const + { + return this; + } + EmitterType::Enum getEmitterType() const + { + return mType; + } + void setEmitterType(EmitterType::Enum t); + void setRadius(float radius) + { + *mRadius = radius; + } + float getRadius() const + { + return *mRadius; + } + void setHeight(float height) + { + *mHeight = height; + } + float getHeight() const + { + return *mHeight; + } + void destroy() + { + delete this; + } + + /* AssetPreview methods */ + void drawPreview(float scale, RenderDebugInterface* renderDebug) const; + + /* Actor callable methods */ + void visualize(const PxTransform& pose, RenderDebugInterface& renderDebug); + + void computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform&, + const PxVec3&, + float, + PxBounds3& outBounds, + QDSRand& rand) const; + + float computeEmitterVolume() const; + PxVec3 randomPosInFullVolume(const PxMat44& pose, QDSRand& rand) const; + bool isInEmitter(const PxVec3& pos, const PxMat44& pose) const; + +protected: + EmitterType::Enum mType; + float* mRadius; + float* mHeight; + EmitterGeomCylinderParams* mGeomParams; +}; + +} +} // end namespace nvidia + +#endif diff --git a/APEX_1.4/module/emitter/include/EmitterGeomExplicitImpl.h b/APEX_1.4/module/emitter/include/EmitterGeomExplicitImpl.h new file mode 100644 index 00000000..74156d45 --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterGeomExplicitImpl.h @@ -0,0 +1,256 @@ +/* + * 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 __EMITTER_GEOM_EXPLICIT_IMPL_H__ +#define __EMITTER_GEOM_EXPLICIT_IMPL_H__ + +#include "EmitterGeomBase.h" +#include "PsUserAllocated.h" +#include "EmitterGeomExplicitParams.h" +#include "ApexRand.h" + +namespace NvParameterized +{ +class Interface; +}; + +namespace nvidia +{ +namespace emitter +{ + + +class EmitterGeomExplicitImpl : public EmitterGeomExplicit, public EmitterGeomBase +{ + void updateAssetPoints(); + +public: + EmitterGeomExplicitImpl(NvParameterized::Interface* params); + EmitterGeomExplicitImpl(); + + virtual ~EmitterGeomExplicitImpl() {} + + /* Asset callable methods */ + EmitterGeom* getEmitterGeom(); + const EmitterGeomExplicit* isExplicitGeom() const + { + return this; + } + EmitterType::Enum getEmitterType() const + { + return EmitterType::ET_FILL; + } + void setEmitterType(EmitterType::Enum) {} // PX_ASSERT(t == EmitterType::ET_FILL); + void destroy() + { + delete this; + } + + /* AssetPreview methods */ + void drawPreview(float scale, RenderDebugInterface* renderDebug) const; + + /* Actor callable methods */ + void visualize(const PxTransform& pose, RenderDebugInterface& renderDebug); + void computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform& pose, + const PxVec3& scale, + float density, + PxBounds3& outBounds, + QDSRand& rand) const + { + computeFillPositions(positions, velocities, NULL, pose, scale, density, outBounds, rand); + } + + void computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + physx::Array<uint32_t>* userDataArrayPtr, + const PxTransform&, + const PxVec3&, + float, + PxBounds3& outBounds, + QDSRand& rand) const; + + /* Stubs */ + float computeNewlyCoveredVolume(const PxTransform&, const PxTransform&) const + { + return 0.0f; + } + float computeEmitterVolume() const + { + return 0.0f; + } + PxVec3 randomPosInFullVolume(const PxMat44&, QDSRand&) const + { + return PxVec3(0.0f, 0.0f, 0.0f); + } + PxVec3 randomPosInNewlyCoveredVolume(const PxMat44& , const PxMat44&, QDSRand&) const + { + return PxVec3(0.0f, 0.0f, 0.0f); + } + bool isInEmitter(const PxVec3&, const PxMat44&) const + { + return false; + } + + void resetParticleList() + { + mPoints.clear(); + mVelocities.clear(); + mPointsUserData.clear(); + + mSpheres.clear(); + mSphereVelocities.clear(); + + mEllipsoids.clear(); + mEllipsoidVelocities.clear(); + } + + void addParticleList(uint32_t count, + const PointParams* params, + const PxVec3* velocities = 0); + + void addParticleList(uint32_t count, + const PxVec3* positions, + const PxVec3* velocities = 0); + + void addParticleList(uint32_t count, + const PointListData& data); + + void addSphereList(uint32_t count, + const SphereParams* params, + const PxVec3* velocities = 0); + + void addEllipsoidList(uint32_t count, + const EllipsoidParams* params, + const PxVec3* velocities = 0); + + void getParticleList(const PointParams* ¶ms, + uint32_t& numPoints, + const PxVec3* &velocities, + uint32_t& numVelocities) const; + + void getSphereList(const SphereParams* ¶ms, + uint32_t& numSpheres, + const PxVec3* &velocities, + uint32_t& numVelocities) const; + + void getEllipsoidList(const EllipsoidParams* ¶ms, + uint32_t& numEllipsoids, + const PxVec3* &velocities, + uint32_t& numVelocities) const; + + uint32_t getParticleCount() const + { + return mPoints.size(); + } + PxVec3 getParticlePos(uint32_t index) const + { + return mPoints[ index ].position; + } + + uint32_t getSphereCount() const + { + return mSpheres.size(); + } + PxVec3 getSphereCenter(uint32_t index) const + { + return mSpheres[ index ].center; + } + float getSphereRadius(uint32_t index) const + { + return mSpheres[ index ].radius; + } + + uint32_t getEllipsoidCount() const + { + return mEllipsoids.size(); + } + PxVec3 getEllipsoidCenter(uint32_t index) const + { + return mEllipsoids[ index ].center; + } + float getEllipsoidRadius(uint32_t index) const + { + return mEllipsoids[ index ].radius; + } + PxVec3 getEllipsoidNormal(uint32_t index) const + { + return mEllipsoids[ index ].normal; + } + float getEllipsoidPolarRadius(uint32_t index) const + { + return mEllipsoids[ index ].polarRadius; + } + + float getDistance() const + { + return mDistance; + } + +protected: + mutable QDSRand mRand; + +# define MAX_COLLISION_SHAPES 5 + + struct CollisionList + { + uint32_t shapeIndices[MAX_COLLISION_SHAPES]; + uint32_t next; + + PX_INLINE CollisionList(): next(0) {} + + PX_INLINE void pushBack(uint32_t shapeIdx) + { + if (next >= MAX_COLLISION_SHAPES) + { + PX_ASSERT(0 && "Too many colliding shapes in explicit emitter"); + return; + } + + shapeIndices[next++] = shapeIdx; + } + }; + + // Collision table holds indices of shapes which collide with some shape + // Shape indexing: firstly go spheres, then ellipsoids, then points + physx::Array<CollisionList> mCollisions; + physx::Array<PxBounds3> mBboxes; + + void updateCollisions(); + bool isInside(const PxVec3& x, uint32_t shapeIdx) const; + + void AddParticle(physx::Array<PxVec3>& positions, physx::Array<PxVec3>& velocities, + physx::Array<uint32_t>* userDataArrayPtr, + const PxTransform& pose, float cutoff, PxBounds3& outBounds, + const PxVec3& pos, const PxVec3& vel, uint32_t userData, + uint32_t srcShapeIdx, + QDSRand& rand) const; + + physx::Array<SphereParams> mSpheres; + physx::Array<PxVec3> mSphereVelocities; + + physx::Array<EllipsoidParams> mEllipsoids; + physx::Array<PxVec3> mEllipsoidVelocities; + + physx::Array<PointParams> mPoints; + physx::Array<PxVec3> mVelocities; + physx::Array<uint32_t> mPointsUserData; + + float mDistance, mInvDistance; + + EmitterGeomExplicitParams* mGeomParams; +}; + +} +} // end namespace nvidia + +#endif
\ No newline at end of file diff --git a/APEX_1.4/module/emitter/include/EmitterGeomSphereImpl.h b/APEX_1.4/module/emitter/include/EmitterGeomSphereImpl.h new file mode 100644 index 00000000..f86923c3 --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterGeomSphereImpl.h @@ -0,0 +1,94 @@ +/* + * 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 __EMITTER_GEOM_SPHERE_IMPL_H__ +#define __EMITTER_GEOM_SPHERE_IMPL_H__ + +#include "EmitterGeomBase.h" +#include "PsUserAllocated.h" +#include "EmitterGeomSphereParams.h" + +namespace NvParameterized +{ +class Interface; +}; + +namespace nvidia +{ +namespace emitter +{ + +class EmitterGeomSphereImpl : public EmitterGeomSphere, public EmitterGeomBase +{ +public: + EmitterGeomSphereImpl(NvParameterized::Interface* params); + + /* Asset callable methods */ + EmitterGeom* getEmitterGeom(); + const EmitterGeomSphere* isSphereGeom() const + { + return this; + } + EmitterType::Enum getEmitterType() const + { + return mType; + } + void setEmitterType(EmitterType::Enum t); + void setRadius(float radius) + { + *mRadius = radius; + } + float getRadius() const + { + return *mRadius; + } + void setHemisphere(float hemisphere) + { + *mHemisphere = hemisphere; + } + float getHemisphere() const + { + return *mHemisphere; + } + void destroy() + { + delete this; + } + + /* AssetPreview methods */ + void drawPreview(float scale, RenderDebugInterface* renderDebug) const; + + /* Actor callable methods */ + void visualize(const PxTransform& pose, RenderDebugInterface& renderDebug); + + void computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform&, + const PxVec3&, + float, + PxBounds3& outBounds, + QDSRand& rand) const; + + float computeEmitterVolume() const; + PxVec3 randomPosInFullVolume(const PxMat44& pose, QDSRand& rand) const; + bool isInEmitter(const PxVec3& pos, const PxMat44& pose) const; + +protected: + EmitterType::Enum mType; + float* mRadius; + float* mHemisphere; + EmitterGeomSphereParams* mGeomParams; +}; + +} +} // end namespace nvidia + +#endif diff --git a/APEX_1.4/module/emitter/include/EmitterGeomSphereShellImpl.h b/APEX_1.4/module/emitter/include/EmitterGeomSphereShellImpl.h new file mode 100644 index 00000000..ce76042c --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterGeomSphereShellImpl.h @@ -0,0 +1,97 @@ +/* + * 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 __EMITTER_GEOM_SPHERE_SHELL_IMPL_H__ +#define __EMITTER_GEOM_SPHERE_SHELL_IMPL_H__ + +#include "EmitterGeomBase.h" +#include "PsUserAllocated.h" +#include "EmitterGeomSphereShellParams.h" + +namespace NvParameterized +{ +class Interface; +}; + +namespace nvidia +{ +namespace emitter +{ + +class EmitterGeomSphereShellImpl : public EmitterGeomSphereShell, public EmitterGeomBase +{ +public: + EmitterGeomSphereShellImpl(NvParameterized::Interface* params); + + /* Asset callable methods */ + EmitterGeom* getEmitterGeom(); + const EmitterGeomSphereShell* isSphereShellGeom() const + { + return this; + } + EmitterType::Enum getEmitterType() const + { + return mType; + } + void setEmitterType(EmitterType::Enum t); + void setRadius(float radius) + { + *mRadius = radius; + } + float getRadius() const + { + return *mRadius; + } + void setShellThickness(float thickness) + { + *mShellThickness = thickness; + } + float getShellThickness() const + { + return *mShellThickness; + } + void destroy() + { + delete this; + } + + /* AssetPreview methods */ + void drawPreview(float scale, RenderDebugInterface* renderDebug) const; + + /* Actor callable methods */ + void visualize(const PxTransform& pose, RenderDebugInterface& renderDebug); + + void computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform&, + const PxVec3&, + float, + PxBounds3& outBounds, + QDSRand& rand) const; + + float computeEmitterVolume() const; + PxVec3 randomPosInFullVolume(const PxMat44& pose, QDSRand& rand) const; + bool isInEmitter(const PxVec3& pos, const PxMat44& pose) const; + +protected: + PxVec3 randomPointOnUnitSphere(QDSRand& rand) const; + + EmitterType::Enum mType; + float* mRadius; + float* mShellThickness; + float* mHemisphere; + EmitterGeomSphereShellParams* mGeomParams; +}; + +} +} // end namespace nvidia + +#endif diff --git a/APEX_1.4/module/emitter/include/EmitterScene.h b/APEX_1.4/module/emitter/include/EmitterScene.h new file mode 100644 index 00000000..8cdf4a89 --- /dev/null +++ b/APEX_1.4/module/emitter/include/EmitterScene.h @@ -0,0 +1,141 @@ +/* + * 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 __EMITTER_SCENE_H__ +#define __EMITTER_SCENE_H__ + +#include "Apex.h" + +#include "ModuleEmitterImpl.h" +#include "ApexSDKIntl.h" +#include "ModuleIntl.h" +#include "ApexContext.h" +#include "ApexSDKHelpers.h" +#include "ApexActor.h" + +#include "DebugRenderParams.h" +#include "EmitterDebugRenderParams.h" + +#include "PxTask.h" + +namespace nvidia +{ +namespace apex +{ +class SceneIntl; +} +namespace emitter +{ + +class ModuleEmitterImpl; + + +/* Each Emitter Actor should derive this class, so the scene can deal with it */ +class EmitterActorBase : public ApexActor +{ +public: + virtual bool isValid() + { + return mValid; + } + virtual void tick() = 0; + virtual void visualize(RenderDebugInterface& renderDebug) = 0; + + virtual void submitTasks() = 0; + virtual void setTaskDependencies() = 0; + virtual void fetchResults() = 0; + +protected: + EmitterActorBase() : mValid(false) {} + + bool mValid; +}; + +class EmitterScene : public ModuleSceneIntl, public ApexContext, public ApexResourceInterface, public ApexResource +{ +public: + EmitterScene(ModuleEmitterImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list); + ~EmitterScene(); + + /* ModuleSceneIntl */ + void visualize(); + void setModulePhysXScene(PxScene* s); + PxScene* getModulePhysXScene() const + { + return mPhysXScene; + } + PxScene* mPhysXScene; + + Module* getModule() + { + return mModule; + } + + void fetchResults(); + + 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; + } + void release() + { + mModule->releaseModuleSceneIntl(*this); + } + + void submitTasks(float elapsedTime, float substepSize, uint32_t numSubSteps); + void setTaskDependencies(); + +protected: + void destroy(); + + ModuleEmitterImpl* mModule; + SceneIntl* mApexScene; + + float mSumBenefit; +private: + RenderDebugInterface* mDebugRender; + + DebugRenderParams* mDebugRenderParams; + EmitterDebugRenderParams* mEmitterDebugRenderParams; + + friend class ModuleEmitterImpl; + friend class EmitterActorImpl; + friend class GroundEmitterActorImpl; + friend class ImpactEmitterActorImpl; +}; + +} +} // end namespace nvidia + +#endif diff --git a/APEX_1.4/module/emitter/include/GroundEmitterActorImpl.h b/APEX_1.4/module/emitter/include/GroundEmitterActorImpl.h new file mode 100644 index 00000000..918feb67 --- /dev/null +++ b/APEX_1.4/module/emitter/include/GroundEmitterActorImpl.h @@ -0,0 +1,397 @@ +/* + * 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 __GROUND_EMITTER_ACTOR_IMPL_H__ +#define __GROUND_EMITTER_ACTOR_IMPL_H__ + +#include "GroundEmitterActor.h" +#include "GroundEmitterAssetImpl.h" +#include "EmitterScene.h" +#include "ApexActor.h" +#include "ApexFIFO.h" +#include "ApexSharedUtils.h" +#include "PsUserAllocated.h" +#include "PxPlane.h" + +namespace nvidia +{ +namespace emitter +{ + +template<typename T> +struct ApexVec2 +{ + T x; + T y; +}; + +class InjectorData : public UserAllocated +{ +public: + virtual ~InjectorData() + { + } + + IosInjectorIntl* mInjector; // For emitting + float mObjectRadius; + + ApexSimpleString iofxAssetName; + ApexSimpleString iosAssetName; + + physx::Array<IosNewObject> particles; + + class InjectTask : public PxTask + { + public: + InjectTask() {} + void run(); + const char* getName() const + { + return "GroundEmitterActor::InjectTask"; + } + GroundEmitterActorImpl* mActor; + InjectorData* mData; + }; + void initTask(GroundEmitterActorImpl& actor, InjectorData& data) + { + mTask.mActor = &actor; + mTask.mData = &data; + } + + InjectTask mTask; +}; + + +struct MaterialData +{ + physx::Array<uint32_t> injectorIndices; + physx::Array<float> accumWeights; + physx::Array<float> maxSlopeAngles; + + uint32_t chooseIOFX(float& maxSlopeAngle, QDSRand& rand) + { + PX_ASSERT(injectorIndices.size() == accumWeights.size()); + + float u = rand.getScaled(0, accumWeights.back()); + for (uint32_t i = 0; i < accumWeights.size(); i++) + { + if (u <= accumWeights[i]) + { + maxSlopeAngle = maxSlopeAngles[i]; + return injectorIndices[i]; + } + } + + PX_ALWAYS_ASSERT(); + return (uint32_t) - 1; + } +}; + + +class GroundEmitterActorImpl : public GroundEmitterActor, public EmitterActorBase, public ApexResourceInterface, public ApexResource, public ApexRWLockable +{ +private: + GroundEmitterActorImpl& operator=(const GroundEmitterActorImpl&); + +public: + APEX_RW_LOCKABLE_BOILERPLATE + + GroundEmitterActorImpl(const GroundEmitterActorDesc&, GroundEmitterAssetImpl&, ResourceList&, EmitterScene&); + ~GroundEmitterActorImpl(); + + Renderable* getRenderable() + { + return NULL; + } + Actor* getActor() + { + return this; + } + void removeActorAtIndex(uint32_t index); + + 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, ApexResource */ + void release(); + uint32_t getListIndex() const + { + return m_listIndex; + } + void setListIndex(class ResourceList& list, uint32_t index) + { + m_list = &list; + m_listIndex = index; + } + + /* EmitterActorBase */ + void destroy(); + Asset* getOwner() const; + void visualize(RenderDebugInterface& renderDebug); + + void setPhysXScene(PxScene*); + PxScene* getPhysXScene() const + { + return mPxScene; + } + PxScene* mPxScene; + + void submitTasks(); + void setTaskDependencies(); + void fetchResults(); + + GroundEmitterAsset* getEmitterAsset() const; + + const PxMat44 getPose() const; + void setPose(const PxMat44& pos); + + const PxVec3& getPosition() const + { + return mLocalPlayerPosition; + } + void setPosition(const PxVec3& pos); + const PxTransform& getRotation() const + { + return mPose; + } + void setRotation(const PxTransform& rotation); + const PxVec3 &getVelocityLow() const + { + return mAsset->getVelocityLow(); + } + const PxVec3 &getVelocityHigh() const + { + return mAsset->getVelocityHigh(); + } + const float &getLifetimeLow() const + { + return mAsset->getLifetimeLow(); + } + const float &getLifetimeHigh() const + { + return mAsset->getLifetimeHigh(); + } + uint32_t getRaycastCollisionGroups() const + { + READ_ZONE(); + return mRaycastCollisionGroups; + } + void setRaycastCollisionGroups(uint32_t g) + { + WRITE_ZONE(); + mRaycastCollisionGroups = g; + } + + const physx::PxFilterData* getRaycastCollisionGroupsMask() const + { + READ_ZONE(); + return mShouldUseGroupsMask ? &mRaycastCollisionGroupsMask : NULL; + } + void setRaycastCollisionGroupsMask(physx::PxFilterData*); + + void setMaterialLookupCallback(MaterialLookupCallback* mlc) + { + WRITE_ZONE(); + mMaterialCallback = mlc; + } + MaterialLookupCallback* getMaterialLookupCallback() const + { + READ_ZONE(); + return mMaterialCallback; + } + + void setAttachActor(PxActor* a) + { + WRITE_ZONE(); + mAttachActor = a; + } + const PxActor* getAttachActor() const + { + READ_ZONE(); + return mAttachActor; + } + PxActor* mAttachActor; + + void setAttachRelativePosition(const PxVec3& pos) + { + WRITE_ZONE(); + mAttachRelativePosition = pos; + } + + const PxVec3& getAttachRelativePosition() const + { + READ_ZONE(); + return mAttachRelativePosition; + } + + bool addMeshForGroundMaterial(const MaterialFactoryMappingDesc&, const EmitterLodParamDesc&); + void setDensity(const float& d) + { + READ_ZONE(); + mDensity = d; + } + void setMaxRaycastsPerFrame(uint32_t m) + { + WRITE_ZONE(); + mMaxNumRaycastsPerFrame = m; + } + void setRaycastHeight(float h) + { + WRITE_ZONE(); + mRaycastHeight = h; + } + void setSpawnHeight(float h) + { + WRITE_ZONE(); + mSpawnHeight = h; + } + void setRadius(float); + void setPreferredRenderVolume(nvidia::apex::RenderVolume*); + + + const float &getDensity() const + { + READ_ZONE(); + return mDensity; + } + float getRadius() const + { + READ_ZONE(); + return mRadius; + } + uint32_t getMaxRaycastsPerFrame() const + { + READ_ZONE(); + return mMaxNumRaycastsPerFrame; + } + float getRaycastHeight() const + { + READ_ZONE(); + return mRaycastHeight; + } + float getSpawnHeight() const + { + READ_ZONE(); + return mSpawnHeight; + } + + void setSeed(uint32_t seed) + { + mRand.setSeed(seed); + } + +protected: + /* internal methods */ + void submitRaycasts(); + void injectParticles(InjectorData& data); + void refreshCircle(bool edgeOnly); + void tick(); + + bool onRaycastQuery(uint32_t nbHits, const physx::PxRaycastHit* hits); + + GroundEmitterAssetImpl* mAsset; + EmitterScene* mScene; + + /* Actor modifiable versions of asset data */ + float mDensity; + float mRadius; + uint32_t mMaxNumRaycastsPerFrame; + float mRaycastHeight; + float mSpawnHeight; + PxVec3 mLocalUpDirection; + PxTransform mPose; + PxTransform mInversePose; + uint32_t mRaycastCollisionGroups; + physx::PxFilterData mRaycastCollisionGroupsMask; + + PxVec3 mAttachRelativePosition; + + MaterialLookupCallback* mMaterialCallback; + physx::Array<MaterialLookupCallback::MaterialRequest> mMaterialRequestArray; + + /* Actor local data */ + Bank<MaterialData, uint16_t> mPerMaterialData; + physx::Array<InjectorData*> mInjectorList; + physx::Array<InstancedObjectSimulationIntl*> mIosList; + float mGridCellSize; + uint32_t mTotalElapsedTimeMs; + + struct RaycastVisInfo + { + PxVec3 rayStart; + uint32_t timeSubmittedMs; // running time in milliseconds (should last for 50 days or so) + }; + physx::Array<RaycastVisInfo> mVisualizeRaycastsList; + + + // use FIFO so it does the earliest (that are probably the closest to the player first) + ApexFIFO<PxVec3> mToRaycast; + physx::Array<uint32_t> mCellLastRefreshSteps; + uint32_t mSimulationSteps; + ApexVec2<int32_t> mNextGridCell; + + /* runtime state members */ + + PxVec3 mLocalPlayerPosition; + PxVec3 mWorldPlayerPosition; + PxVec3 mOldLocalPlayerPosition; // used to determine when to clear per cell step counts + float mStepsize; + PxPlane mHorizonPlane; + + float mCurrentDensity; + float mRadius2; + float mCircleArea; + bool mShouldUseGroupsMask; + float mMaxStepSize; + bool mRefreshFullCircle; + + nvidia::Mutex mInjectorDataLock; + + nvidia::QDSRand mRand; + + class GroundEmitterTickTask : public PxTask + { + public: + GroundEmitterTickTask(GroundEmitterActorImpl& actor) : mActor(actor) {} + + const char* getName() const + { + return "GroundEmitterActor::TickTask"; + } + void run() + { + mActor.tick(); + } + + protected: + GroundEmitterActorImpl& mActor; + + private: + GroundEmitterTickTask& operator=(const GroundEmitterTickTask&); + }; + GroundEmitterTickTask mTickTask; + + friend class InjectorData::InjectTask; + friend class QueryReport; +}; + +} +} // end namespace nvidia + +#endif diff --git a/APEX_1.4/module/emitter/include/GroundEmitterAssetImpl.h b/APEX_1.4/module/emitter/include/GroundEmitterAssetImpl.h new file mode 100644 index 00000000..f6a3bf15 --- /dev/null +++ b/APEX_1.4/module/emitter/include/GroundEmitterAssetImpl.h @@ -0,0 +1,574 @@ +/* + * 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 GROUND_EMITTER_ASSET_IMPL_H +#define GROUND_EMITTER_ASSET_IMPL_H + +#include "GroundEmitterAsset.h" +#include "GroundEmitterActor.h" +#include "ApexSDKHelpers.h" +#include "ApexAssetAuthoring.h" +#include "ApexAssetTracker.h" +#include "ApexString.h" +#include "EmitterLodParamDesc.h" +#include "InstancedObjectSimulationIntl.h" +#include "ResourceProviderIntl.h" +#include "IofxAsset.h" +#include "ApexUsingNamespace.h" +// NvParam test +#include "nvparameterized/NvParameterized.h" +#include "ParamArray.h" +#include "GroundEmitterAssetParameters.h" +#include "GroundEmitterActorParameters.h" +#include "EmitterAssetPreviewParameters.h" +#include "ApexRWLockable.h" +#include "ReadCheck.h" +#include "WriteCheck.h" +#include "ApexAuthorableObject.h" + +namespace nvidia +{ +namespace apex +{ +class GroundEmitterActor; +class GroundEmitterPreview; +} +namespace emitter +{ + +class GroundEmitterActorImpl; +class ModuleEmitterImpl; + +///Class used to bind the emitter to a specific material +class MaterialFactoryMappingDesc : ApexDesc +{ +public: + /** \brief User defined material name. + * The ground emitter will convert this name into an + * MaterialID at runtime by a getResource() call to the named resource provider. + * Note this is the physical material, not rendering material. + */ + const char* physicalMaterialName; + + /** \brief The name of the instanced object effects asset that will render your particles */ + const char* instancedObjectEffectsAssetName; + + /** \brief The asset name of the particle system that will simulate your particles */ + const char* instancedObjectSimulationAssetName; + + /** \brief The asset type of the particle system that will simulate your particles, aka 'BasicIosAsset' */ + const char* instancedObjectSimulationTypeName; + + /** \brief The weight of this factory relative to other factories on the same material */ + float weight; + + /** \brief The maximum slope at which particles will be added to the surface in degrees where 0 is horizontal + * and 90 is vertical. + */ + float maxSlopeAngle; + + /** + \brief constructor sets to default. + */ + PX_INLINE MaterialFactoryMappingDesc() : 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; + } + + if (!physicalMaterialName || + !instancedObjectEffectsAssetName || + !instancedObjectSimulationAssetName || + !instancedObjectSimulationTypeName) + { + return false; + } + + if (maxSlopeAngle > 90.0f || maxSlopeAngle < 0.0f) + { + return false; + } + + return true; + } + +private: + + PX_INLINE void init() + { + physicalMaterialName = NULL; + instancedObjectEffectsAssetName = NULL; + instancedObjectSimulationAssetName = NULL; + instancedObjectSimulationTypeName = "BasicIosAsset"; + weight = 1.0f; + maxSlopeAngle = 90.0f; // in default, spawn on even vertical faces + } +}; + +///Ground Emitter actor descriptor. Used to create Ground Emitter actors +class GroundEmitterActorDesc : public ApexDesc +{ +public: + uint32_t raycastCollisionGroups; + + float radius; ///< The ground emitter actor will create objects within a circle of size 'radius'. + uint32_t maxRaycastsPerFrame; ///< The maximum raycasts number per frame. + float raycastHeight; ///< The height from which the ground emitter will cast rays at terrain/objects opposite of the 'upDirection'. + /** + \brief The height above the ground to emit particles. + If greater than 0, the ground emitter will refresh a disc above the player's position rather than + refreshing a circle around the player's position. + + */ + float density; + float spawnHeight; + ///< but it will back off to the minimum density if the actor is LOD resource limited. + PxActor* attachActor; ///< The actor to whuch the emitter will be attatched + + PxVec3 attachRelativePosition; ///< The position of the emitter in the space of the actor, to which it is attatched. + PxVec3 initialPosition; ///< The position of the emitter immediately after addding to the scene. + + /** + \brief Orientatiom of the emitter. + An identity matrix will result in a +Y up ground emitter, provide a + rotation if another orientation is desired. + */ + PxTransform rotation; + + + /** + \brief Pointer to callback that will be used to request materials from positions. Can be NULL; in such case a case ray will be cast + */ + MaterialLookupCallback* materialCallback; + + /** + \brief constructor sets to default. + */ + PX_INLINE GroundEmitterActorDesc() : 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; + } + + if (!rotation.p.isZero()) + { + return false; + } + + return true; + } + +private: + + PX_INLINE void init() + { + // authored values will be used if these defaults remain + raycastCollisionGroups = uint32_t(-1); + radius = 0.0f; + maxRaycastsPerFrame = 0; + raycastHeight = 0.0f; + spawnHeight = -1.0f; + + attachActor = NULL; + attachRelativePosition = PxVec3(0.0f); + initialPosition = PxVec3(0.0f); + rotation = PxTransform(PxIdentity); + + materialCallback = NULL; + } +}; + +/** + Descriptor used to create an ApexEmitter preview. +*/ +class GroundEmitterPreviewDesc : public ApexDesc +{ +public: + PxTransform mPose; // pose of the preview renderer + float mScale; // scaling factor of renderable + + /** + \brief Constructor sets to default. + */ + PX_INLINE GroundEmitterPreviewDesc() : ApexDesc() + { + setToDefault(); + } + + /** + \brief Sets parameters to default. + */ + PX_INLINE void setToDefault() + { + ApexDesc::setToDefault(); + + mPose = PxTransform(PxIdentity); + mScale = 1.0f; + } + + /** + \brief Cchecks the validity of the parameters. + */ + PX_INLINE bool isValid() const + { + return ApexDesc::isValid(); + } +}; + + +class GroundEmitterAssetImpl : public GroundEmitterAsset, + public ApexResourceInterface, + public ApexResource, + public ApexRWLockable +{ + friend class GroundEmitterAssetDummyAuthoring; +public: + APEX_RW_LOCKABLE_BOILERPLATE + + GroundEmitterAssetImpl(ModuleEmitterImpl*, ResourceList&, const char* name); + GroundEmitterAssetImpl(ModuleEmitterImpl* module, + ResourceList& list, + NvParameterized::Interface* params, + const char* name); + ~GroundEmitterAssetImpl(); + + /* Asset */ + const char* getName() const + { + return mName.c_str(); + } + AuthObjTypeID getObjTypeID() const + { + return mAssetTypeID; + } + const char* getObjTypeName() const + { + return getClassName(); + } + uint32_t forceLoadAssets(); + + /* ApexInterface */ + virtual void release(); + + /* ApexResourceInterface, ApexResource */ + uint32_t getListIndex() const + { + return m_listIndex; + } + void setListIndex(class ResourceList& list, uint32_t index) + { + m_list = &list; + m_listIndex = index; + } + + GroundEmitterActor* createActor(const GroundEmitterActorDesc&, Scene&); + void releaseActor(GroundEmitterActor&); + + GroundEmitterPreview* createEmitterPreview(const GroundEmitterPreviewDesc& desc, AssetPreviewScene* previewScene); + void releaseEmitterPreview(GroundEmitterPreview& preview); + + const float & getDensity() const + { + READ_ZONE(); + return mParams->density; + } + + const PxVec3 & getVelocityLow() const + { + READ_ZONE(); + return mParams->velocityLow; + } + + const PxVec3 & getVelocityHigh() const + { + READ_ZONE(); + return mParams->velocityHigh; + } + + const float & getLifetimeLow() const + { + READ_ZONE(); + return mParams->lifetimeLow; + } + + const float & getLifetimeHigh() const + { + READ_ZONE(); + return mParams->lifetimeHigh; + } + + float getRadius() const + { + READ_ZONE(); + return mParams->radius; + } + uint32_t getMaxRaycastsPerFrame() const + { + READ_ZONE(); + return mParams->maxRaycastsPerFrame; + } + float getRaycastHeight() const + { + READ_ZONE(); + return mParams->raycastHeight; + } + float getSpawnHeight() const + { + READ_ZONE(); + return mParams->spawnHeight; + } + const char* getRaycastCollisionGroupMaskName() const + { + READ_ZONE(); + return mParams->raycastCollisionGroupMaskName; + } + + /* objects that assist in force loading and proper "assets own assets" behavior */ + ApexAssetTracker mIofxAssetTracker; + ApexAssetTracker mIosAssetTracker; + + 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(); + NvParameterized::Interface* getDefaultAssetPreviewDesc(); + virtual Actor* createApexActor(const NvParameterized::Interface& parms, Scene& apexScene); + virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& params, AssetPreviewScene* previewScene); + + virtual bool isValidForActorCreation(const ::NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) const + { + return true; // TODO implement this method + } + + virtual bool isDirty() const + { + return false; + } + +protected: + /* Typical asset members */ + static const char* getClassName() + { + return GROUND_EMITTER_AUTHORING_TYPE_NAME; + } + static AuthObjTypeID mAssetTypeID; + + void postDeserialize(void* userData_ = NULL); + + void destroy(); + ModuleEmitterImpl* mModule; + ResourceList mEmitterActors; + ApexSimpleString mName; + + //GroundEmitterAssetParameters mParams; + PxFileBuf& serializeMaterialFactory(PxFileBuf& stream, uint32_t matFactoryIdx) const; + PxFileBuf& deserializeMaterialFactory(PxFileBuf& stream, + uint32_t matFactoryIdx, + uint32_t headerVersion, + uint32_t assetVersion); + + static void copyLodDesc(EmitterLodParamDesc& dst, const GroundEmitterAssetParametersNS::emitterLodParamDesc_Type& src); + static void copyLodDesc(GroundEmitterAssetParametersNS::emitterLodParamDesc_Type& dst, const EmitterLodParamDesc& src); + + ParamArray<GroundEmitterAssetParametersNS::materialFactoryMapping_Type> *mMaterialFactoryMaps; + + void initializeAssetNameTable(); + + + GroundEmitterAssetParameters* mParams; + GroundEmitterActorParameters* mDefaultActorParams; + EmitterAssetPreviewParameters* mDefaultPreviewParams; + + uint32_t mRaycastCollisionGroups; // cache lookup value + physx::PxFilterData mRaycastCollisionGroupsMask; + + bool mShouldUseGroupsMask; + + friend class ModuleEmitterImpl; + friend class GroundEmitterActorImpl; + friend class GroundEmitterAssetPreview; + template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject; +}; + +#ifndef WITHOUT_APEX_AUTHORING +class GroundEmitterAssetAuthoringImpl : public GroundEmitterAssetAuthoring, public ApexAssetAuthoring, public GroundEmitterAssetImpl +{ +protected: + APEX_RW_LOCKABLE_BOILERPLATE + + GroundEmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l) : + GroundEmitterAssetImpl(m, l, "GroundEmitterAuthor") {} + + GroundEmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l, const char* name) : + GroundEmitterAssetImpl(m, l, name) {} + + GroundEmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l, NvParameterized::Interface* params, const char* name) : + GroundEmitterAssetImpl(m, l, params, name) {} + + ~GroundEmitterAssetAuthoringImpl(); + + EmitterLodParamDesc mCurLodParamDesc; + +public: + void release(); + const char* getName(void) const + { + READ_ZONE(); + return GroundEmitterAssetImpl::getName(); + } + const char* getObjTypeName() const + { + READ_ZONE(); + return GroundEmitterAssetImpl::getClassName(); + } + virtual bool prepareForPlatform(nvidia::apex::PlatformTag) + { + WRITE_ZONE(); + APEX_INVALID_OPERATION("Not Implemented."); + return false; + } + void setToolString(const char* toolName, const char* toolVersion, uint32_t toolChangelist) + { + WRITE_ZONE(); + ApexAssetAuthoring::setToolString(toolName, toolVersion, toolChangelist); + } + + void setDensity(const float& d) + { + mParams->density = d; + } + + void setVelocityLow(const PxVec3& v) + { + mParams->velocityLow = v; + } + + void setVelocityHigh(const PxVec3& v) + { + mParams->velocityHigh = v; + } + + void setLifetimeLow(const float& l) + { + mParams->lifetimeLow = l; + } + + void setLifetimeHigh(const float& l) + { + mParams->lifetimeHigh = l; + } + + void setRadius(float r) + { + mParams->radius = r; + } + + void setMaxRaycastsPerFrame(uint32_t m) + { + mParams->maxRaycastsPerFrame = m; + } + + void setRaycastHeight(float h) + { + mParams->raycastHeight = h; + } + + void setSpawnHeight(float h) + { + mParams->spawnHeight = h; + } + + void setRaycastCollisionGroupMaskName(const char* n) + { + NvParameterized::Handle stringHandle(*mParams); + mParams->getParameterHandle("raycastCollisionGroupMaskName", stringHandle); + mParams->setParamString(stringHandle, n); + } + + void setCurLodParamDesc(const EmitterLodParamDesc& d) + { + mCurLodParamDesc = d; + } + void addMeshForGroundMaterial(const MaterialFactoryMappingDesc&); + + NvParameterized::Interface* getNvParameterized() const + { + READ_ZONE(); + return (NvParameterized::Interface*)getAssetNvParameterized(); + } + + /** + * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller. + */ + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + WRITE_ZONE(); + NvParameterized::Interface* ret = mParams; + mParams = NULL; + release(); + return ret; + } + + template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject; +}; +#endif + +} +} // end namespace nvidia + +#endif // GROUND_EMITTER_ASSET_IMPL_H diff --git a/APEX_1.4/module/emitter/include/GroundEmitterAssetPreview.h b/APEX_1.4/module/emitter/include/GroundEmitterAssetPreview.h new file mode 100644 index 00000000..8ca0350e --- /dev/null +++ b/APEX_1.4/module/emitter/include/GroundEmitterAssetPreview.h @@ -0,0 +1,88 @@ +/* + * 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 __GROUND_EMITTER_ASSET_PREVIEW_H__ +#define __GROUND_EMITTER_ASSET_PREVIEW_H__ + +#include "ApexPreview.h" + +#include "ApexSDKIntl.h" +#include "GroundEmitterPreview.h" +#include "RenderDebugInterface.h" +#include "GroundEmitterAssetImpl.h" +#include "ApexRWLockable.h" + +namespace nvidia +{ +namespace emitter +{ + +class GroundEmitterAssetPreview : public GroundEmitterPreview, public ApexResource, public ApexPreview, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + GroundEmitterAssetPreview(const GroundEmitterPreviewDesc& pdesc, const GroundEmitterAssetImpl& asset, ApexSDK* myApexSDK, AssetPreviewScene* previewScene) : + mApexSDK(myApexSDK), + mApexRenderDebug(0), + mScale(pdesc.mScale), + mAsset(&asset), + mPreviewScene(previewScene), + mGroupID(0) + { +#ifndef WITHOUT_DEBUG_VISUALIZE + setPose(pdesc.mPose); + drawEmitterPreview(); +#endif + }; + + bool isValid() const + { + return mApexRenderDebug != NULL; + } + void drawEmitterPreview(void); + void destroy(); + + void setPose(const PxMat44& pose); // Sets the preview instance's pose. This may include scaling. + const PxMat44 getPose() const; + + // from RenderDataProvider + void lockRenderResources(void); + void unlockRenderResources(void); + void updateRenderResources(bool rewriteBuffers = false, void* userRenderData = 0); + + // from Renderable.h + void dispatchRenderResources(UserRenderer& renderer); + PxBounds3 getBounds(void) const; + + // from ApexResource.h + void release(void); + +private: + ~GroundEmitterAssetPreview(); + + AuthObjTypeID mModuleID; // the module ID of Emitter. + UserRenderResourceManager* mRrm; // pointer to the users render resource manager + ApexSDK* mApexSDK; // pointer to the APEX SDK + RenderDebugInterface* mApexRenderDebug; // Pointer to the RenderLines class to draw the + PxTransform mPose; // the pose for the preview rendering + float mScale; + const GroundEmitterAssetImpl* mAsset; + int32_t mGroupID; + AssetPreviewScene* mPreviewScene; + + void setScale(float scale); +}; + +} +} // end namespace nvidia + +#endif // __APEX_EMITTER_ASSET_PREVIEW_H__ diff --git a/APEX_1.4/module/emitter/include/ImpactEmitterActorImpl.h b/APEX_1.4/module/emitter/include/ImpactEmitterActorImpl.h new file mode 100644 index 00000000..4480e834 --- /dev/null +++ b/APEX_1.4/module/emitter/include/ImpactEmitterActorImpl.h @@ -0,0 +1,267 @@ +/* + * 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 __IMPACT_EMITTER_ACTOR_IMPL_H__ +#define __IMPACT_EMITTER_ACTOR_IMPL_H__ + +//////////////////////////////////////////////////////////////////////////////// + +#include "ImpactEmitterActor.h" +#include "ImpactEmitterAssetImpl.h" +#include "EmitterScene.h" +#include "ApexActor.h" +#include "ApexFIFO.h" +#include "ApexSharedUtils.h" +#include "PsUserAllocated.h" +#include "ApexRand.h" +#include "ApexRWLockable.h" + +//////////////////////////////////////////////////////////////////////////////// + +class ImpactEmitterBaseEvent; + +namespace NvParameterized +{ +class Interface; +}; + +namespace nvidia +{ +namespace apex +{ +class InstancedObjectSimulationIntl; +} +namespace emitter +{ + +//////////////////////////////////////////////////////////////////////////////// + +struct ImpactEventTriggerParams +{ + PxVec3 hitPos; + PxVec3 hitDir; + PxVec3 hitNorm; + + ImpactEventTriggerParams() {} + ImpactEventTriggerParams(const PxVec3& p, const PxVec3& d, const PxVec3& n) : hitPos(p), hitDir(d), hitNorm(n) {} +}; + +class ImpactEmitterBaseEvent : public UserAllocated +{ +public: + ImpactEmitterBaseEvent(ImpactEmitterActorImpl* emitterActor) : mOwner(emitterActor), mValid(false) {} + virtual ~ImpactEmitterBaseEvent() {} + virtual void removeActorReference(ApexActor* a) = 0; + + virtual bool isValid() + { + return mValid; + } + virtual void trigger(const ImpactEventTriggerParams& params) = 0; + virtual void setPreferredRenderVolume(RenderVolume*) = 0; + + virtual void submitTasks(PxTaskManager*) {} + virtual void setTaskDependencies(PxTask*) {} + +protected: + ImpactEmitterActorImpl* mOwner; + bool mValid; +}; + +//////////////////////////////////////////////////////////////////////////////// + +class ImpactEmitterParticleEvent : public ImpactEmitterBaseEvent +{ +public: + static const size_t MAX_PARTICLES = 2048; + + enum eAxisType { AXIS_INCIDENT = 0, AXIS_NORMAL, AXIS_REFLECTION }; + + ImpactEmitterParticleEvent(NvParameterized::Interface* eventParamPtr, ImpactEmitterAssetImpl& asset, ImpactEmitterActorImpl* emitterActor); + + virtual ~ImpactEmitterParticleEvent(); + + virtual void removeActorReference(ApexActor* a) + { + if (mParticleInjector == a) + { + mParticleInjector = NULL; + } + } + + virtual void trigger(const ImpactEventTriggerParams& params); + + virtual void submitTasks(PxTaskManager* tm); + virtual void setTaskDependencies(PxTask* tickTask); + virtual void setPreferredRenderVolume(nvidia::apex::RenderVolume* vol); + +protected: + void run(); + + void trigger(const PxVec3& hitPos, const PxVec3& hitDir, const PxVec3& hitNorm); + void initParticle(const PxVec3& pos, const PxVec3 basis[], PxVec3& outPos, PxVec3& outVel, float& outLife); + + typedef physx::Array<ImpactEventTriggerParams> TriggerQueue; + TriggerQueue mTriggerQueue; + PxTask* mEventTask; + friend class ParticleEventTask; + + eAxisType mAxis; + float mMinAngle; + float mMaxAngle; + float mMinSpeed; + float mMaxSpeed; + float mMinLife; + float mMaxLife; + uint32_t mParticleSpawnCount; + IosInjectorIntl* mParticleInjector; +}; + +//////////////////////////////////////////////////////////////////////////////// + +class ImpactEmitterEventSet : public UserAllocated +{ +public: + struct EventSetEntry + { + float dly; + ImpactEmitterBaseEvent* evnt; + + EventSetEntry() : dly(0.0f), evnt(NULL) {}; + EventSetEntry(float d, ImpactEmitterBaseEvent* e) : dly(d), evnt(e) {}; + }; + + ImpactEmitterEventSet() {}; + virtual ~ImpactEmitterEventSet(); + + bool AddEvent(NvParameterized::Interface* eventParamPtr, ImpactEmitterAssetImpl& asset, ImpactEmitterActorImpl* emitterActor); + + physx::Array<EventSetEntry> entries; + +}; + +//////////////////////////////////////////////////////////////////////////////// + +class ImpactEmitterActorImpl : public ImpactEmitterActor, public EmitterActorBase, public ApexResourceInterface, public ApexResource, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + class QueuedImpactEvent + { + public: + QueuedImpactEvent() {}; + QueuedImpactEvent(const PxVec3& p, const PxVec3& d, const PxVec3& n, float t, ImpactEmitterBaseEvent* e) + : triggerParams(p, d, n), triggerTime(t), eventDef(e) {} + + bool trigger(float time); + + protected: + ImpactEventTriggerParams triggerParams; + float triggerTime; + ImpactEmitterBaseEvent* eventDef; + }; + typedef physx::Array<QueuedImpactEvent> ImpactEventQueue; + + ImpactEmitterActorImpl(const ImpactEmitterActorDesc&, ImpactEmitterAssetImpl&, ResourceList&, EmitterScene&); + ImpactEmitterActorImpl(const NvParameterized::Interface&, ImpactEmitterAssetImpl&, ResourceList&, EmitterScene&); + + ~ImpactEmitterActorImpl(); + + Renderable* getRenderable() + { + return NULL; + } + Actor* getActor() + { + return this; + } + + 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) + { + WRITE_ZONE(); + ApexActor::setEnableDebugVisualization(state); + } + + /* ApexResourceInterface, ApexResource */ + void release(); + uint32_t getListIndex() const + { + return m_listIndex; + } + void setListIndex(class ResourceList& list, uint32_t index) + { + m_list = &list; + m_listIndex = index; + } + + /* EmitterActorBase */ + void destroy(); + Asset* getOwner() const; + void visualize(RenderDebugInterface&); + + void setPhysXScene(PxScene*) {} + PxScene* getPhysXScene() const + { + return NULL; + } + + void submitTasks(); + void setTaskDependencies(); + void fetchResults(); + + SceneIntl* getApexScene() const; + void removeActorAtIndex(uint32_t index); + void setPreferredRenderVolume(nvidia::apex::RenderVolume*); + + ImpactEmitterAsset* getEmitterAsset() const; + + /* Override some asset settings at run time */ + + /* Actor callable methods */ + void registerImpact(const PxVec3& hitPos, const PxVec3& hitDir, const PxVec3& surfNorm, uint32_t surfType); + + void setSeed(uint32_t seed) + { + mRand.setSeed(seed); + } + +protected: + void tick(); + + float mTime; + physx::Array<ImpactEmitterEventSet> mEventSets; + + physx::Array<IosInjectorIntl*> mActiveParticleInjectors; + ImpactEventQueue mPendingEvents; + + ImpactEmitterAssetImpl* mAsset; + EmitterScene* mScene; + + PxTask* mTickTask; + friend class ImpactEmitterTickTask; + + nvidia::QDSRand mRand; + + friend class ImpactEmitterParticleEvent; +}; + +} +} // end namespace nvidia + +//////////////////////////////////////////////////////////////////////////////// +#endif diff --git a/APEX_1.4/module/emitter/include/ImpactEmitterAssetImpl.h b/APEX_1.4/module/emitter/include/ImpactEmitterAssetImpl.h new file mode 100644 index 00000000..1e91a8eb --- /dev/null +++ b/APEX_1.4/module/emitter/include/ImpactEmitterAssetImpl.h @@ -0,0 +1,318 @@ +/* + * 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 IMPACT_EMITTER_ASSET_IMPL_H +#define IMPACT_EMITTER_ASSET_IMPL_H + +#include "ImpactEmitterAsset.h" +#include "ApexSDKHelpers.h" +#include "ApexAssetAuthoring.h" +#include "ApexAssetTracker.h" +#include "ApexString.h" +#include "ResourceProviderIntl.h" +#include "ApexAuthorableObject.h" +#include "ImpactEmitterAssetParameters.h" +#include "ImpactEmitterActorParameters.h" +#include "EmitterAssetPreviewParameters.h" +#include "ImpactObjectEvent.h" +#include "ApexRWLockable.h" +#include "ReadCheck.h" +#include "WriteCheck.h" +#include "ApexAuthorableObject.h" + +#include "ApexUsingNamespace.h" + +namespace nvidia +{ +namespace emitter +{ + +class ImpactEmitterActorImpl; +class ModuleEmitterImpl; + +///Impact emitter actor descriptor. Used to create Impact emitter actors. +class ImpactEmitterActorDesc : public ApexDesc +{ +public: + + /** + \brief constructor sets to default. + */ + PX_INLINE ImpactEmitterActorDesc() : 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() + { + } +}; + + +/** + Descriptor used to create a Destructible preview. +*/ +class ImpactEmitterPreviewDesc : public ApexDesc +{ +public: + + /** + \brief Constructor sets to default. + */ + PX_INLINE ImpactEmitterPreviewDesc() + { + setToDefault(); + } + + + /** + \brief Resets descriptor to default settings. + */ + PX_INLINE void setToDefault() + { + ApexDesc::setToDefault(); + + mPose = PxIdentity; + mScale = 1.0f; + } + + /** + Returns true iff an object can be created using this descriptor. + */ + PX_INLINE bool isValid() const + { + return ApexDesc::isValid(); + } + + /** + Initial global pose of preview mesh + */ + PxMat44 mPose; + float mScale; +}; + + +class ImpactEmitterAssetImpl : public ImpactEmitterAsset, + public ApexResourceInterface, + public ApexResource, + public NvParameterized::SerializationCallback, + public ApexRWLockable +{ + friend class ImpactEmitterAssetDummyAuthoring; +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ImpactEmitterAssetImpl(ModuleEmitterImpl*, ResourceList&, const char* name); + ImpactEmitterAssetImpl(ModuleEmitterImpl* module, + ResourceList& list, + NvParameterized::Interface* params, + const char* name); + + ~ImpactEmitterAssetImpl(); + + /* Asset */ + const char* getName() const + { + READ_ZONE(); + return mName.c_str(); + } + AuthObjTypeID getObjTypeID() const + { + READ_ZONE(); + return mAssetTypeID; + } + const char* getObjTypeName() const + { + READ_ZONE(); + return getClassName(); + } + uint32_t forceLoadAssets(); + + /* ApexInterface */ + virtual void release(); + + /* ApexResourceInterface, ApexResource */ + uint32_t getListIndex() const + { + return m_listIndex; + } + void setListIndex(class ResourceList& list, uint32_t index) + { + m_list = &list; + m_listIndex = index; + } + + uint32_t querySetID(const char* setName); + void getSetNames(const char** outSetNames, uint32_t& inOutNameCount) const; + + const NvParameterized::Interface* getAssetNvParameterized() const + { + READ_ZONE(); + 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(); + NvParameterized::Interface* getDefaultAssetPreviewDesc(); + virtual Actor* createApexActor(const NvParameterized::Interface& parms, Scene& apexScene); + virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& params, AssetPreviewScene* previewScene); + virtual bool isValidForActorCreation(const ::NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) const + { + READ_ZONE(); + return true; // TODO implement this method + } + + virtual bool isDirty() const + { + READ_ZONE(); + return false; + } + +protected: + /* Typical asset members */ + static const char* getClassName() + { + return IMPACT_EMITTER_AUTHORING_TYPE_NAME; + } + static AuthObjTypeID mAssetTypeID; + void initializeAssetNameTable(); + void destroy(); + + /* NvParameterized Serialization callbacks */ + void preSerialize(void* userData_ = NULL); + void postDeserialize(void* userData_ = NULL); + void buildEventNameIndexMap(); + + ModuleEmitterImpl* mModule; + ResourceList mEmitterActors; + ApexSimpleString mName; + + /* objects that assist in force loading and proper "assets own assets" behavior */ + ApexAssetTracker mIofxAssetTracker; + ApexAssetTracker mIosAssetTracker; + + /* asset values */ + class EventNameIndexMap : public UserAllocated + { + public: + ApexSimpleString eventSetName; + physx::Array<uint16_t> eventIndices; + }; + + ImpactEmitterAssetParameters* mParams; + ImpactEmitterActorParameters* mDefaultActorParams; + EmitterAssetPreviewParameters* mDefaultPreviewParams; + physx::Array<EventNameIndexMap*> mEventNameIndexMaps; + + friend class ModuleEmitterImpl; + friend class ImpactEmitterActorImpl; + friend class ImpactEmitterParticleEvent; + + template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject; +}; + +#ifndef WITHOUT_APEX_AUTHORING +class ImpactEmitterAssetAuthoringImpl : public ImpactEmitterAssetAuthoring, public ApexAssetAuthoring, public ImpactEmitterAssetImpl +{ +protected: + APEX_RW_LOCKABLE_BOILERPLATE + + ImpactEmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l) : + ImpactEmitterAssetImpl(m, l, "ImpactEmitterAuthor") {} + + ImpactEmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l, const char* name) : + ImpactEmitterAssetImpl(m, l, name) {} + + ImpactEmitterAssetAuthoringImpl(ModuleEmitterImpl* m, ResourceList& l, NvParameterized::Interface* params, const char* name) : + ImpactEmitterAssetImpl(m, l, params, name) {} + +public: + void release(); + const char* getName(void) const + { + READ_ZONE(); + return ImpactEmitterAssetImpl::getName(); + } + const char* getObjTypeName() const + { + READ_ZONE(); + return ImpactEmitterAssetImpl::getClassName(); + } + virtual bool prepareForPlatform(nvidia::apex::PlatformTag) + { + WRITE_ZONE(); + APEX_INVALID_OPERATION("Not Implemented."); + return false; + } + void setToolString(const char* toolName, const char* toolVersion, uint32_t toolChangelist) + { + WRITE_ZONE(); + ApexAssetAuthoring::setToolString(toolName, toolVersion, toolChangelist); + } + + NvParameterized::Interface* getNvParameterized() const + { + READ_ZONE(); + return (NvParameterized::Interface*)getAssetNvParameterized(); + } + /** + * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller. + */ + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + WRITE_ZONE(); + NvParameterized::Interface* ret = mParams; + mParams = NULL; + release(); + return ret; + } + + template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject; +}; +#endif + +} +} // end namespace nvidia + +#endif // IMPACT_EMITTER_ASSET_IMPL_H diff --git a/APEX_1.4/module/emitter/include/ModuleEmitterImpl.h b/APEX_1.4/module/emitter/include/ModuleEmitterImpl.h new file mode 100644 index 00000000..059cc0be --- /dev/null +++ b/APEX_1.4/module/emitter/include/ModuleEmitterImpl.h @@ -0,0 +1,158 @@ +/* + * 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_EMITTER_IMPL_H__ +#define __MODULE_EMITTER_IMPL_H__ + +#include "Apex.h" +#include "ModuleEmitter.h" +#include "ApexSDKIntl.h" +#include "ModuleBase.h" +#include "ModuleIntl.h" +#include "EmitterAssetImpl.h" +#include "GroundEmitterAssetImpl.h" +#include "ModulePerfScope.h" +#include "ImpactObjectEvent.h" + +#include "ModuleEmitterRegistration.h" +#include "ApexRWLockable.h" +#include "ReadCheck.h" +#include "WriteCheck.h" + +namespace nvidia +{ +namespace emitter +{ + +class EmitterScene; + +class ModuleEmitterDesc : public ApexDesc +{ +public: + + /** + \brief constructor sets to default. + */ + PX_INLINE ModuleEmitterDesc() : 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 ModuleEmitterImpl : public ModuleEmitter, public ModuleIntl, public ModuleBase, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ModuleEmitterImpl(ApexSDKIntl* inSdk); + ~ModuleEmitterImpl(); + + void init(const ModuleEmitterDesc& moduleEmitterDesc); + + // base class methods + void init(NvParameterized::Interface&) {} + NvParameterized::Interface* getDefaultModuleDesc(); + void release() + { + ModuleBase::release(); + } + void destroy(); + const char* getName() const + { + READ_ZONE(); + return ModuleBase::getName(); + } + + RenderableIterator* createRenderableIterator(const Scene&); + ModuleSceneIntl* createInternalModuleScene(SceneIntl&, RenderDebugInterface*); + void releaseModuleSceneIntl(ModuleSceneIntl&); + uint32_t forceLoadAssets(); + + AuthObjTypeID getModuleID() const; + AuthObjTypeID getEmitterAssetTypeID() const; + + ApexActor* getApexActor(Actor*, AuthObjTypeID) const; + + float getRateScale() const + { + return mRateScale; + } + float getDensityScale() const + { + return mDensityScale; + } + float getGroundDensityScale() const + { + return mGroundDensityScale; + } + + void setRateScale(float rateScale) + { + mRateScale = rateScale; + } + void setDensityScale(float densityScale) + { + mDensityScale = densityScale; + } + void setGroundDensityScale(float groundDensityScale) + { + mGroundDensityScale = groundDensityScale; + } + +private: + EmitterScene* getEmitterScene(const Scene& apexScene); + ResourceList mAuthorableObjects; + ResourceList mEmitterScenes; + +private: + + EmitterModuleParameters* mModuleParams; + + float mRateScale; + float mDensityScale; + float mGroundDensityScale; + + friend class EmitterAssetImpl; + friend class GroundEmitterAssetImpl; + friend class GroundEmitterActorImpl; + friend class ImpactEmitterAssetImpl; + friend class ImpactEmitterActorImpl; +}; + +} +} // namespace nvidia::apex + +#endif // __MODULE_EMITTER_IMPL_H__ diff --git a/APEX_1.4/module/emitter/include/ModuleEventDefs.h b/APEX_1.4/module/emitter/include/ModuleEventDefs.h new file mode 100644 index 00000000..53a3b926 --- /dev/null +++ b/APEX_1.4/module/emitter/include/ModuleEventDefs.h @@ -0,0 +1,27 @@ +/* + * 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. + +DEFINE_EVENT(EmitterSceneBeforeTick) +DEFINE_EVENT(EmitterSceneFetchResults) + +DEFINE_EVENT(EmitterActorOverlapAABBSceneQuery) +DEFINE_EVENT(EmitterActorOverlapSphereSceneQuery) + +DEFINE_EVENT(GroundParticlesEmitterTick) +DEFINE_EVENT(GroundParticlesEmitterInjection) +DEFINE_EVENT(GroundParticlesEmitterRefreshCircle) +DEFINE_EVENT(GroundParticlesEmitterGridInspect) +DEFINE_EVENT(GroundParticlesEmitterRaycasts) +DEFINE_EVENT(GroundParticlesEmitterFetchResults) +DEFINE_EVENT(GroundParticlesEmitterOnRaycastQuery) + diff --git a/APEX_1.4/module/emitter/include/ModulePerfScope.h b/APEX_1.4/module/emitter/include/ModulePerfScope.h new file mode 100644 index 00000000..7e50b46f --- /dev/null +++ b/APEX_1.4/module/emitter/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 emitter +#include "ModuleProfileCommon.h" + +#endif
\ No newline at end of file diff --git a/APEX_1.4/module/emitter/include/autogen/ApexEmitterActorParameters.h b/APEX_1.4/module/emitter/include/autogen/ApexEmitterActorParameters.h new file mode 100644 index 00000000..1a3b2a2e --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/ApexEmitterActorParameters.h @@ -0,0 +1,236 @@ +// 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_ApexEmitterActorParameters_h +#define HEADER_ApexEmitterActorParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ApexEmitterActorParametersNS +{ + + + +struct ParametersStruct +{ + + physx::PxTransform initialPose; + float initialScale; + physx::PxTransform attachRelativePose; + bool emitAssetParticles; + NvParameterized::DummyStringStruct overlapTestGroupMaskName; + NvParameterized::DummyStringStruct overlapTestGroupsMask128Name; + float emitterDuration; + +}; + +static const uint32_t checksum[] = { 0x8bce9917, 0xda429410, 0xa3ec8f9b, 0x8e2223cf, }; + +} // namespace ApexEmitterActorParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ApexEmitterActorParameters : public NvParameterized::NvParameters, public ApexEmitterActorParametersNS::ParametersStruct +{ +public: + ApexEmitterActorParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ApexEmitterActorParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ApexEmitterActorParameters"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)2; + + 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(ApexEmitterActorParametersNS::checksum); + return ApexEmitterActorParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ApexEmitterActorParametersNS::ParametersStruct& parameters(void) const + { + ApexEmitterActorParameters* tmpThis = const_cast<ApexEmitterActorParameters*>(this); + return *(static_cast<ApexEmitterActorParametersNS::ParametersStruct*>(tmpThis)); + } + + ApexEmitterActorParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<ApexEmitterActorParametersNS::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 ApexEmitterActorParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ApexEmitterActorParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ApexEmitterActorParameters), ApexEmitterActorParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ApexEmitterActorParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ApexEmitterActorParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ApexEmitterActorParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ApexEmitterActorParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ApexEmitterActorParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ApexEmitterActorParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ApexEmitterActorParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ApexEmitterActorParameters 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 (ApexEmitterActorParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (ApexEmitterActorParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ApexEmitterActorParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ApexEmitterActorParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ApexEmitterActorParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/ApexEmitterAssetParameters.h b/APEX_1.4/module/emitter/include/autogen/ApexEmitterAssetParameters.h new file mode 100644 index 00000000..accfc5e8 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/ApexEmitterAssetParameters.h @@ -0,0 +1,269 @@ +// 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_ApexEmitterAssetParameters_h +#define HEADER_ApexEmitterAssetParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ApexEmitterAssetParametersNS +{ + +struct emitterLodParamDesc_Type; +struct rateVsTimeCurvePoint_Type; + +struct rateVsTimeCurvePoint_DynamicArray1D_Type +{ + rateVsTimeCurvePoint_Type* buf; + bool isAllocated; + int32_t elementSize; + int32_t arraySizes[1]; +}; + +struct emitterLodParamDesc_Type +{ + uint32_t version; + float maxDistance; + float distanceWeight; + float speedWeight; + float lifeWeight; + float separationWeight; + float bias; +}; +struct rateVsTimeCurvePoint_Type +{ + float x; + float y; +}; + +struct ParametersStruct +{ + + float density; + float rate; + float lifetimeLow; + float lifetimeHigh; + physx::PxVec3 velocityLow; + physx::PxVec3 velocityHigh; + uint32_t maxSamples; + emitterLodParamDesc_Type lodParamDesc; + NvParameterized::Interface* iofxAssetName; + NvParameterized::Interface* iosAssetName; + NvParameterized::Interface* geometryType; + float emitterDuration; + float emitterVelocityScale; + uint32_t minSamplingFPS; + rateVsTimeCurvePoint_DynamicArray1D_Type rateVsTimeCurvePoints; + +}; + +static const uint32_t checksum[] = { 0x1835d790, 0xa1bfdb02, 0xf76e9154, 0xae351ee1, }; + +} // namespace ApexEmitterAssetParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ApexEmitterAssetParameters : public NvParameterized::NvParameters, public ApexEmitterAssetParametersNS::ParametersStruct +{ +public: + ApexEmitterAssetParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ApexEmitterAssetParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ApexEmitterAssetParameters"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)8; + + 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(ApexEmitterAssetParametersNS::checksum); + return ApexEmitterAssetParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ApexEmitterAssetParametersNS::ParametersStruct& parameters(void) const + { + ApexEmitterAssetParameters* tmpThis = const_cast<ApexEmitterAssetParameters*>(this); + return *(static_cast<ApexEmitterAssetParametersNS::ParametersStruct*>(tmpThis)); + } + + ApexEmitterAssetParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<ApexEmitterAssetParametersNS::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 ApexEmitterAssetParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ApexEmitterAssetParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ApexEmitterAssetParameters), ApexEmitterAssetParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ApexEmitterAssetParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ApexEmitterAssetParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ApexEmitterAssetParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ApexEmitterAssetParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ApexEmitterAssetParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ApexEmitterAssetParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ApexEmitterAssetParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ApexEmitterAssetParameters 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 (ApexEmitterAssetParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (ApexEmitterAssetParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ApexEmitterAssetParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ApexEmitterAssetParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ApexEmitterAssetParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterAssetPreviewParameters.h b/APEX_1.4/module/emitter/include/autogen/EmitterAssetPreviewParameters.h new file mode 100644 index 00000000..eb5367d0 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterAssetPreviewParameters.h @@ -0,0 +1,231 @@ +// 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_EmitterAssetPreviewParameters_h +#define HEADER_EmitterAssetPreviewParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterAssetPreviewParametersNS +{ + + + +struct ParametersStruct +{ + + physx::PxTransform pose; + float scale; + +}; + +static const uint32_t checksum[] = { 0x13ebeb0d, 0xd2df2f41, 0x19fe6d06, 0x63eac053, }; + +} // namespace EmitterAssetPreviewParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterAssetPreviewParameters : public NvParameterized::NvParameters, public EmitterAssetPreviewParametersNS::ParametersStruct +{ +public: + EmitterAssetPreviewParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterAssetPreviewParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterAssetPreviewParameters"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)2; + + 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(EmitterAssetPreviewParametersNS::checksum); + return EmitterAssetPreviewParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterAssetPreviewParametersNS::ParametersStruct& parameters(void) const + { + EmitterAssetPreviewParameters* tmpThis = const_cast<EmitterAssetPreviewParameters*>(this); + return *(static_cast<EmitterAssetPreviewParametersNS::ParametersStruct*>(tmpThis)); + } + + EmitterAssetPreviewParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterAssetPreviewParametersNS::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 EmitterAssetPreviewParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterAssetPreviewParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterAssetPreviewParameters), EmitterAssetPreviewParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterAssetPreviewParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterAssetPreviewParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterAssetPreviewParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterAssetPreviewParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterAssetPreviewParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterAssetPreviewParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterAssetPreviewParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterAssetPreviewParameters 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 (EmitterAssetPreviewParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterAssetPreviewParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterAssetPreviewParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterAssetPreviewParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterAssetPreviewParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterDebugRenderParams.h b/APEX_1.4/module/emitter/include/autogen/EmitterDebugRenderParams.h new file mode 100644 index 00000000..d6b52119 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterDebugRenderParams.h @@ -0,0 +1,260 @@ +// 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_EmitterDebugRenderParams_h +#define HEADER_EmitterDebugRenderParams_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterDebugRenderParamsNS +{ + +struct ApexEmitterParameters_Type; +struct GroundEmitterParameters_Type; +struct ImpactEmitterParameters_Type; + +struct ApexEmitterParameters_Type +{ + bool VISUALIZE_APEX_EMITTER_ACTOR; + bool VISUALIZE_TOTAL_INJECTED_AABB; + bool VISUALIZE_APEX_EMITTER_ACTOR_POSE; + float THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_POSE; + bool VISUALIZE_APEX_EMITTER_ACTOR_NAME; + float THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_NAME; +}; +struct GroundEmitterParameters_Type +{ + bool VISUALIZE_GROUND_EMITTER_ACTOR; + bool VISUALIZE_GROUND_EMITTER_SPHERE; + bool VISUALIZE_GROUND_EMITTER_GRID; + bool VISUALIZE_GROUND_EMITTER_RAYCAST; + bool VISUALIZE_GROUND_EMITTER_ACTOR_POSE; + bool VISUALIZE_GROUND_EMITTER_ACTOR_NAME; +}; +struct ImpactEmitterParameters_Type +{ + bool VISUALIZE_IMPACT_EMITTER_ACTOR; + bool VISUALIZE_IMPACT_EMITTER_RAYCAST; + bool VISUALIZE_IMPACT_EMITTER_ACTOR_NAME; + float THRESHOLD_DISTANCE_IMPACT_EMITTER_ACTOR_NAME; +}; + +struct ParametersStruct +{ + + ApexEmitterParameters_Type apexEmitterParameters; + GroundEmitterParameters_Type groundEmitterParameters; + ImpactEmitterParameters_Type impactEmitterParameters; + +}; + +static const uint32_t checksum[] = { 0xbb1ad1fe, 0xd2ead5bd, 0x3bbab888, 0x61ee4e9a, }; + +} // namespace EmitterDebugRenderParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterDebugRenderParams : public NvParameterized::NvParameters, public EmitterDebugRenderParamsNS::ParametersStruct +{ +public: + EmitterDebugRenderParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterDebugRenderParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterDebugRenderParams"); + } + + 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(EmitterDebugRenderParamsNS::checksum); + return EmitterDebugRenderParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterDebugRenderParamsNS::ParametersStruct& parameters(void) const + { + EmitterDebugRenderParams* tmpThis = const_cast<EmitterDebugRenderParams*>(this); + return *(static_cast<EmitterDebugRenderParamsNS::ParametersStruct*>(tmpThis)); + } + + EmitterDebugRenderParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterDebugRenderParamsNS::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 EmitterDebugRenderParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterDebugRenderParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterDebugRenderParams), EmitterDebugRenderParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterDebugRenderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterDebugRenderParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterDebugRenderParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterDebugRenderParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterDebugRenderParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterDebugRenderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterDebugRenderParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterDebugRenderParams 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 (EmitterDebugRenderParams*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterDebugRenderParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterDebugRenderParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterDebugRenderParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterDebugRenderParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterGeomBoxParams.h b/APEX_1.4/module/emitter/include/autogen/EmitterGeomBoxParams.h new file mode 100644 index 00000000..c1ef1e56 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterGeomBoxParams.h @@ -0,0 +1,231 @@ +// 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_EmitterGeomBoxParams_h +#define HEADER_EmitterGeomBoxParams_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterGeomBoxParamsNS +{ + + + +struct ParametersStruct +{ + + const char* emitterType; + physx::PxVec3 extents; + +}; + +static const uint32_t checksum[] = { 0x27d775c2, 0xfe93d203, 0xcf7ddf42, 0x77074efc, }; + +} // namespace EmitterGeomBoxParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterGeomBoxParams : public NvParameterized::NvParameters, public EmitterGeomBoxParamsNS::ParametersStruct +{ +public: + EmitterGeomBoxParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterGeomBoxParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterGeomBoxParams"); + } + + 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(EmitterGeomBoxParamsNS::checksum); + return EmitterGeomBoxParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterGeomBoxParamsNS::ParametersStruct& parameters(void) const + { + EmitterGeomBoxParams* tmpThis = const_cast<EmitterGeomBoxParams*>(this); + return *(static_cast<EmitterGeomBoxParamsNS::ParametersStruct*>(tmpThis)); + } + + EmitterGeomBoxParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterGeomBoxParamsNS::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 EmitterGeomBoxParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterGeomBoxParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterGeomBoxParams), EmitterGeomBoxParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterGeomBoxParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomBoxParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterGeomBoxParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterGeomBoxParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterGeomBoxParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterGeomBoxParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomBoxParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterGeomBoxParams 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 (EmitterGeomBoxParams*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterGeomBoxParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterGeomBoxParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterGeomBoxParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterGeomBoxParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterGeomCylinderParams.h b/APEX_1.4/module/emitter/include/autogen/EmitterGeomCylinderParams.h new file mode 100644 index 00000000..3edf8bfe --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterGeomCylinderParams.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_EmitterGeomCylinderParams_h +#define HEADER_EmitterGeomCylinderParams_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterGeomCylinderParamsNS +{ + + + +struct ParametersStruct +{ + + const char* emitterType; + float radius; + float height; + +}; + +static const uint32_t checksum[] = { 0xeb300980, 0x72a774b1, 0xa1ae40e5, 0xb586df5e, }; + +} // namespace EmitterGeomCylinderParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterGeomCylinderParams : public NvParameterized::NvParameters, public EmitterGeomCylinderParamsNS::ParametersStruct +{ +public: + EmitterGeomCylinderParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterGeomCylinderParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterGeomCylinderParams"); + } + + 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(EmitterGeomCylinderParamsNS::checksum); + return EmitterGeomCylinderParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterGeomCylinderParamsNS::ParametersStruct& parameters(void) const + { + EmitterGeomCylinderParams* tmpThis = const_cast<EmitterGeomCylinderParams*>(this); + return *(static_cast<EmitterGeomCylinderParamsNS::ParametersStruct*>(tmpThis)); + } + + EmitterGeomCylinderParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterGeomCylinderParamsNS::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 EmitterGeomCylinderParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterGeomCylinderParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterGeomCylinderParams), EmitterGeomCylinderParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterGeomCylinderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomCylinderParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterGeomCylinderParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterGeomCylinderParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterGeomCylinderParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterGeomCylinderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomCylinderParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterGeomCylinderParams 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 (EmitterGeomCylinderParams*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterGeomCylinderParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterGeomCylinderParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterGeomCylinderParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterGeomCylinderParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterGeomExplicitParams.h b/APEX_1.4/module/emitter/include/autogen/EmitterGeomExplicitParams.h new file mode 100644 index 00000000..d7fb5575 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterGeomExplicitParams.h @@ -0,0 +1,305 @@ +// 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_EmitterGeomExplicitParams_h +#define HEADER_EmitterGeomExplicitParams_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterGeomExplicitParamsNS +{ + +struct PointParams_Type; +struct ExplicitPoints_Type; +struct SphereParams_Type; +struct ExplicitSpheres_Type; +struct EllipsoidParams_Type; +struct ExplicitEllipsoids_Type; + +struct PointParams_DynamicArray1D_Type +{ + PointParams_Type* buf; + bool isAllocated; + int32_t elementSize; + int32_t arraySizes[1]; +}; + +struct VEC3_DynamicArray1D_Type +{ + physx::PxVec3* buf; + bool isAllocated; + int32_t elementSize; + int32_t arraySizes[1]; +}; + +struct SphereParams_DynamicArray1D_Type +{ + SphereParams_Type* buf; + bool isAllocated; + int32_t elementSize; + int32_t arraySizes[1]; +}; + +struct EllipsoidParams_DynamicArray1D_Type +{ + EllipsoidParams_Type* buf; + bool isAllocated; + int32_t elementSize; + int32_t arraySizes[1]; +}; + +struct PointParams_Type +{ + physx::PxVec3 position; + bool doDetectOverlaps; +}; +struct ExplicitPoints_Type +{ + PointParams_DynamicArray1D_Type positions; + VEC3_DynamicArray1D_Type velocities; +}; +struct SphereParams_Type +{ + physx::PxVec3 center; + float radius; + bool doDetectOverlaps; +}; +struct EllipsoidParams_Type +{ + physx::PxVec3 center; + float radius; + physx::PxVec3 normal; + float polarRadius; + bool doDetectOverlaps; +}; +struct ExplicitEllipsoids_Type +{ + EllipsoidParams_DynamicArray1D_Type positions; + VEC3_DynamicArray1D_Type velocities; +}; +struct ExplicitSpheres_Type +{ + SphereParams_DynamicArray1D_Type positions; + VEC3_DynamicArray1D_Type velocities; +}; + +struct ParametersStruct +{ + + float distance; + ExplicitPoints_Type points; + ExplicitSpheres_Type spheres; + ExplicitEllipsoids_Type ellipsoids; + +}; + +static const uint32_t checksum[] = { 0xe09894f3, 0xce4efef3, 0x4e950875, 0x6ea40ff1, }; + +} // namespace EmitterGeomExplicitParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterGeomExplicitParams : public NvParameterized::NvParameters, public EmitterGeomExplicitParamsNS::ParametersStruct +{ +public: + EmitterGeomExplicitParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterGeomExplicitParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterGeomExplicitParams"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)1; + + 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(EmitterGeomExplicitParamsNS::checksum); + return EmitterGeomExplicitParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterGeomExplicitParamsNS::ParametersStruct& parameters(void) const + { + EmitterGeomExplicitParams* tmpThis = const_cast<EmitterGeomExplicitParams*>(this); + return *(static_cast<EmitterGeomExplicitParamsNS::ParametersStruct*>(tmpThis)); + } + + EmitterGeomExplicitParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterGeomExplicitParamsNS::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 EmitterGeomExplicitParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterGeomExplicitParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterGeomExplicitParams), EmitterGeomExplicitParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterGeomExplicitParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomExplicitParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterGeomExplicitParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterGeomExplicitParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterGeomExplicitParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterGeomExplicitParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomExplicitParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterGeomExplicitParams 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 (EmitterGeomExplicitParams*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterGeomExplicitParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterGeomExplicitParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterGeomExplicitParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterGeomExplicitParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterGeomSphereParams.h b/APEX_1.4/module/emitter/include/autogen/EmitterGeomSphereParams.h new file mode 100644 index 00000000..81d9ac99 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterGeomSphereParams.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_EmitterGeomSphereParams_h +#define HEADER_EmitterGeomSphereParams_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterGeomSphereParamsNS +{ + + + +struct ParametersStruct +{ + + const char* emitterType; + float radius; + float hemisphere; + +}; + +static const uint32_t checksum[] = { 0x79a261ec, 0x91a7400d, 0xfb6ba037, 0x3c13e11f, }; + +} // namespace EmitterGeomSphereParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterGeomSphereParams : public NvParameterized::NvParameters, public EmitterGeomSphereParamsNS::ParametersStruct +{ +public: + EmitterGeomSphereParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterGeomSphereParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterGeomSphereParams"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)1; + + 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(EmitterGeomSphereParamsNS::checksum); + return EmitterGeomSphereParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterGeomSphereParamsNS::ParametersStruct& parameters(void) const + { + EmitterGeomSphereParams* tmpThis = const_cast<EmitterGeomSphereParams*>(this); + return *(static_cast<EmitterGeomSphereParamsNS::ParametersStruct*>(tmpThis)); + } + + EmitterGeomSphereParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterGeomSphereParamsNS::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 EmitterGeomSphereParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterGeomSphereParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterGeomSphereParams), EmitterGeomSphereParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterGeomSphereParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomSphereParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterGeomSphereParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterGeomSphereParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterGeomSphereParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterGeomSphereParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomSphereParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterGeomSphereParams 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 (EmitterGeomSphereParams*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterGeomSphereParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterGeomSphereParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterGeomSphereParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterGeomSphereParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterGeomSphereShellParams.h b/APEX_1.4/module/emitter/include/autogen/EmitterGeomSphereShellParams.h new file mode 100644 index 00000000..ec0e7191 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterGeomSphereShellParams.h @@ -0,0 +1,233 @@ +// 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_EmitterGeomSphereShellParams_h +#define HEADER_EmitterGeomSphereShellParams_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterGeomSphereShellParamsNS +{ + + + +struct ParametersStruct +{ + + const char* emitterType; + float radius; + float shellThickness; + float hemisphere; + +}; + +static const uint32_t checksum[] = { 0xa7e5ed8e, 0xbce14b67, 0x71503704, 0x616eed9e, }; + +} // namespace EmitterGeomSphereShellParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterGeomSphereShellParams : public NvParameterized::NvParameters, public EmitterGeomSphereShellParamsNS::ParametersStruct +{ +public: + EmitterGeomSphereShellParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterGeomSphereShellParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterGeomSphereShellParams"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)1; + + 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(EmitterGeomSphereShellParamsNS::checksum); + return EmitterGeomSphereShellParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterGeomSphereShellParamsNS::ParametersStruct& parameters(void) const + { + EmitterGeomSphereShellParams* tmpThis = const_cast<EmitterGeomSphereShellParams*>(this); + return *(static_cast<EmitterGeomSphereShellParamsNS::ParametersStruct*>(tmpThis)); + } + + EmitterGeomSphereShellParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterGeomSphereShellParamsNS::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 EmitterGeomSphereShellParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterGeomSphereShellParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterGeomSphereShellParams), EmitterGeomSphereShellParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterGeomSphereShellParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomSphereShellParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterGeomSphereShellParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterGeomSphereShellParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterGeomSphereShellParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterGeomSphereShellParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterGeomSphereShellParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterGeomSphereShellParams 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 (EmitterGeomSphereShellParams*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterGeomSphereShellParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterGeomSphereShellParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterGeomSphereShellParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterGeomSphereShellParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/EmitterModuleParameters.h b/APEX_1.4/module/emitter/include/autogen/EmitterModuleParameters.h new file mode 100644 index 00000000..48c7bbf0 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/EmitterModuleParameters.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_EmitterModuleParameters_h +#define HEADER_EmitterModuleParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace EmitterModuleParametersNS +{ + + + +struct ParametersStruct +{ + + uint32_t unused; + +}; + +static const uint32_t checksum[] = { 0xa747fb88, 0x02cb8a6c, 0xc4b8a1de, 0x0263bab7, }; + +} // namespace EmitterModuleParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class EmitterModuleParameters : public NvParameterized::NvParameters, public EmitterModuleParametersNS::ParametersStruct +{ +public: + EmitterModuleParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~EmitterModuleParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("EmitterModuleParameters"); + } + + 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(EmitterModuleParametersNS::checksum); + return EmitterModuleParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const EmitterModuleParametersNS::ParametersStruct& parameters(void) const + { + EmitterModuleParameters* tmpThis = const_cast<EmitterModuleParameters*>(this); + return *(static_cast<EmitterModuleParametersNS::ParametersStruct*>(tmpThis)); + } + + EmitterModuleParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<EmitterModuleParametersNS::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 EmitterModuleParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + EmitterModuleParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(EmitterModuleParameters), EmitterModuleParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, EmitterModuleParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterModuleParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(EmitterModuleParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, EmitterModuleParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, EmitterModuleParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, EmitterModuleParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class EmitterModuleParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of EmitterModuleParameters 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 (EmitterModuleParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (EmitterModuleParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (EmitterModuleParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (EmitterModuleParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (EmitterModuleParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/GroundEmitterActorParameters.h b/APEX_1.4/module/emitter/include/autogen/GroundEmitterActorParameters.h new file mode 100644 index 00000000..7eaef20d --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/GroundEmitterActorParameters.h @@ -0,0 +1,238 @@ +// 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_GroundEmitterActorParameters_h +#define HEADER_GroundEmitterActorParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace GroundEmitterActorParametersNS +{ + + + +struct ParametersStruct +{ + + float density; + float radius; + physx::PxVec3 upDirection; + float raycastHeight; + float spawnHeight; + uint32_t maxRaycastsPerFrame; + NvParameterized::DummyStringStruct raycastCollisionGroupMaskName; + physx::PxVec3 attachRelativePosition; + physx::PxTransform globalPose; + +}; + +static const uint32_t checksum[] = { 0xd3e25aee, 0x7c2db6c5, 0x857bb739, 0xd8a21775, }; + +} // namespace GroundEmitterActorParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class GroundEmitterActorParameters : public NvParameterized::NvParameters, public GroundEmitterActorParametersNS::ParametersStruct +{ +public: + GroundEmitterActorParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~GroundEmitterActorParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("GroundEmitterActorParameters"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)3; + + 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(GroundEmitterActorParametersNS::checksum); + return GroundEmitterActorParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const GroundEmitterActorParametersNS::ParametersStruct& parameters(void) const + { + GroundEmitterActorParameters* tmpThis = const_cast<GroundEmitterActorParameters*>(this); + return *(static_cast<GroundEmitterActorParametersNS::ParametersStruct*>(tmpThis)); + } + + GroundEmitterActorParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<GroundEmitterActorParametersNS::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 GroundEmitterActorParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + GroundEmitterActorParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(GroundEmitterActorParameters), GroundEmitterActorParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, GroundEmitterActorParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class GroundEmitterActorParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(GroundEmitterActorParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, GroundEmitterActorParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, GroundEmitterActorParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, GroundEmitterActorParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class GroundEmitterActorParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of GroundEmitterActorParameters 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 (GroundEmitterActorParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (GroundEmitterActorParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (GroundEmitterActorParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (GroundEmitterActorParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (GroundEmitterActorParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/GroundEmitterAssetParameters.h b/APEX_1.4/module/emitter/include/autogen/GroundEmitterAssetParameters.h new file mode 100644 index 00000000..59204959 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/GroundEmitterAssetParameters.h @@ -0,0 +1,269 @@ +// 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_GroundEmitterAssetParameters_h +#define HEADER_GroundEmitterAssetParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace GroundEmitterAssetParametersNS +{ + +struct emitterLodParamDesc_Type; +struct materialFactoryMapping_Type; + +struct materialFactoryMapping_DynamicArray1D_Type +{ + materialFactoryMapping_Type* buf; + bool isAllocated; + int32_t elementSize; + int32_t arraySizes[1]; +}; + +struct emitterLodParamDesc_Type +{ + uint32_t version; + float maxDistance; + float distanceWeight; + float speedWeight; + float lifeWeight; + float separationWeight; + float bias; +}; +struct materialFactoryMapping_Type +{ + NvParameterized::Interface* iofxAssetName; + NvParameterized::Interface* iosAssetName; + NvParameterized::DummyStringStruct physMatName; + float weight; + float maxSlopeAngle; + emitterLodParamDesc_Type lodParamDesc; +}; + +struct ParametersStruct +{ + + float density; + float lifetimeLow; + float lifetimeHigh; + physx::PxVec3 velocityLow; + physx::PxVec3 velocityHigh; + float radius; + float raycastHeight; + float spawnHeight; + uint32_t maxRaycastsPerFrame; + NvParameterized::DummyStringStruct raycastCollisionGroupMaskName; + materialFactoryMapping_DynamicArray1D_Type materialFactoryMapList; + +}; + +static const uint32_t checksum[] = { 0xfc4571c0, 0x0157d03c, 0xb1fe5ac6, 0xd7d25449, }; + +} // namespace GroundEmitterAssetParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class GroundEmitterAssetParameters : public NvParameterized::NvParameters, public GroundEmitterAssetParametersNS::ParametersStruct +{ +public: + GroundEmitterAssetParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~GroundEmitterAssetParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("GroundEmitterAssetParameters"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)2; + + 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(GroundEmitterAssetParametersNS::checksum); + return GroundEmitterAssetParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const GroundEmitterAssetParametersNS::ParametersStruct& parameters(void) const + { + GroundEmitterAssetParameters* tmpThis = const_cast<GroundEmitterAssetParameters*>(this); + return *(static_cast<GroundEmitterAssetParametersNS::ParametersStruct*>(tmpThis)); + } + + GroundEmitterAssetParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<GroundEmitterAssetParametersNS::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 GroundEmitterAssetParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + GroundEmitterAssetParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(GroundEmitterAssetParameters), GroundEmitterAssetParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, GroundEmitterAssetParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class GroundEmitterAssetParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(GroundEmitterAssetParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, GroundEmitterAssetParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, GroundEmitterAssetParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, GroundEmitterAssetParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class GroundEmitterAssetParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of GroundEmitterAssetParameters 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 (GroundEmitterAssetParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (GroundEmitterAssetParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (GroundEmitterAssetParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (GroundEmitterAssetParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (GroundEmitterAssetParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/ImpactEmitterActorParameters.h b/APEX_1.4/module/emitter/include/autogen/ImpactEmitterActorParameters.h new file mode 100644 index 00000000..4e76bb85 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/ImpactEmitterActorParameters.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_ImpactEmitterActorParameters_h +#define HEADER_ImpactEmitterActorParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ImpactEmitterActorParametersNS +{ + + + +struct ParametersStruct +{ + + NvParameterized::Interface* explosionEnv; + +}; + +static const uint32_t checksum[] = { 0x6785e5a5, 0x2d0171c3, 0xecd991a6, 0xeebe4e58, }; + +} // namespace ImpactEmitterActorParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ImpactEmitterActorParameters : public NvParameterized::NvParameters, public ImpactEmitterActorParametersNS::ParametersStruct +{ +public: + ImpactEmitterActorParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ImpactEmitterActorParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ImpactEmitterActorParameters"); + } + + 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(ImpactEmitterActorParametersNS::checksum); + return ImpactEmitterActorParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ImpactEmitterActorParametersNS::ParametersStruct& parameters(void) const + { + ImpactEmitterActorParameters* tmpThis = const_cast<ImpactEmitterActorParameters*>(this); + return *(static_cast<ImpactEmitterActorParametersNS::ParametersStruct*>(tmpThis)); + } + + ImpactEmitterActorParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<ImpactEmitterActorParametersNS::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 ImpactEmitterActorParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ImpactEmitterActorParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ImpactEmitterActorParameters), ImpactEmitterActorParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ImpactEmitterActorParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactEmitterActorParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ImpactEmitterActorParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ImpactEmitterActorParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ImpactEmitterActorParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ImpactEmitterActorParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactEmitterActorParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ImpactEmitterActorParameters 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 (ImpactEmitterActorParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (ImpactEmitterActorParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ImpactEmitterActorParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ImpactEmitterActorParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ImpactEmitterActorParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/ImpactEmitterAssetParameters.h b/APEX_1.4/module/emitter/include/autogen/ImpactEmitterAssetParameters.h new file mode 100644 index 00000000..c931713a --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/ImpactEmitterAssetParameters.h @@ -0,0 +1,238 @@ +// 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_ImpactEmitterAssetParameters_h +#define HEADER_ImpactEmitterAssetParameters_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ImpactEmitterAssetParametersNS +{ + + +struct REF_DynamicArray1D_Type +{ + NvParameterized::Interface** buf; + bool isAllocated; + int32_t elementSize; + int32_t arraySizes[1]; +}; + + +struct ParametersStruct +{ + + REF_DynamicArray1D_Type eventSetList; + +}; + +static const uint32_t checksum[] = { 0x5b78e967, 0xd4e18888, 0xaac77873, 0xef2e1cba, }; + +} // namespace ImpactEmitterAssetParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ImpactEmitterAssetParameters : public NvParameterized::NvParameters, public ImpactEmitterAssetParametersNS::ParametersStruct +{ +public: + ImpactEmitterAssetParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ImpactEmitterAssetParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ImpactEmitterAssetParameters"); + } + + 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(ImpactEmitterAssetParametersNS::checksum); + return ImpactEmitterAssetParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ImpactEmitterAssetParametersNS::ParametersStruct& parameters(void) const + { + ImpactEmitterAssetParameters* tmpThis = const_cast<ImpactEmitterAssetParameters*>(this); + return *(static_cast<ImpactEmitterAssetParametersNS::ParametersStruct*>(tmpThis)); + } + + ImpactEmitterAssetParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<ImpactEmitterAssetParametersNS::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 ImpactEmitterAssetParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ImpactEmitterAssetParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ImpactEmitterAssetParameters), ImpactEmitterAssetParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ImpactEmitterAssetParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactEmitterAssetParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ImpactEmitterAssetParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ImpactEmitterAssetParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ImpactEmitterAssetParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ImpactEmitterAssetParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactEmitterAssetParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ImpactEmitterAssetParameters 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 (ImpactEmitterAssetParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (ImpactEmitterAssetParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ImpactEmitterAssetParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ImpactEmitterAssetParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ImpactEmitterAssetParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/ImpactExplosionEvent.h b/APEX_1.4/module/emitter/include/autogen/ImpactExplosionEvent.h new file mode 100644 index 00000000..44025781 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/ImpactExplosionEvent.h @@ -0,0 +1,233 @@ +// 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_ImpactExplosionEvent_h +#define HEADER_ImpactExplosionEvent_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ImpactExplosionEventNS +{ + + + +struct ParametersStruct +{ + + NvParameterized::DummyStringStruct eventSetName; + NvParameterized::Interface* explosionAssetName; + float delay; + float duration; + +}; + +static const uint32_t checksum[] = { 0x74920db4, 0x81c601e1, 0x4eda208e, 0xdc255cd6, }; + +} // namespace ImpactExplosionEventNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ImpactExplosionEvent : public NvParameterized::NvParameters, public ImpactExplosionEventNS::ParametersStruct +{ +public: + ImpactExplosionEvent(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ImpactExplosionEvent(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ImpactExplosionEvent"); + } + + 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(ImpactExplosionEventNS::checksum); + return ImpactExplosionEventNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ImpactExplosionEventNS::ParametersStruct& parameters(void) const + { + ImpactExplosionEvent* tmpThis = const_cast<ImpactExplosionEvent*>(this); + return *(static_cast<ImpactExplosionEventNS::ParametersStruct*>(tmpThis)); + } + + ImpactExplosionEventNS::ParametersStruct& parameters(void) + { + return *(static_cast<ImpactExplosionEventNS::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 ImpactExplosionEventFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ImpactExplosionEvent::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ImpactExplosionEvent), ImpactExplosionEvent::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ImpactExplosionEvent::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactExplosionEvent"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ImpactExplosionEvent)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ImpactExplosionEvent)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ImpactExplosionEvent::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ImpactExplosionEvent::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactExplosionEvent"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ImpactExplosionEvent 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 (ImpactExplosionEvent*)bufObj; + } + + virtual const char* getClassName() + { + return (ImpactExplosionEvent::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ImpactExplosionEvent::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ImpactExplosionEvent::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ImpactExplosionEvent::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/ImpactObjectEvent.h b/APEX_1.4/module/emitter/include/autogen/ImpactObjectEvent.h new file mode 100644 index 00000000..f40c7175 --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/ImpactObjectEvent.h @@ -0,0 +1,253 @@ +// 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_ImpactObjectEvent_h +#define HEADER_ImpactObjectEvent_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 emitter +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ImpactObjectEventNS +{ + +struct emitterLodParamDesc_Type; + +struct emitterLodParamDesc_Type +{ + uint32_t version; + float maxDistance; + float distanceWeight; + float speedWeight; + float lifeWeight; + float separationWeight; + float bias; +}; + +struct ParametersStruct +{ + + NvParameterized::DummyStringStruct eventSetName; + NvParameterized::Interface* iofxAssetName; + NvParameterized::Interface* iosAssetName; + float angleLow; + float angleHigh; + float speedLow; + float speedHigh; + float lifeLow; + float lifeHigh; + float delay; + uint32_t particleSpawnCount; + const char* impactAxis; + emitterLodParamDesc_Type lodParamDesc; + +}; + +static const uint32_t checksum[] = { 0x14e70046, 0x8f02f0ce, 0x13040374, 0x46d00400, }; + +} // namespace ImpactObjectEventNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ImpactObjectEvent : public NvParameterized::NvParameters, public ImpactObjectEventNS::ParametersStruct +{ +public: + ImpactObjectEvent(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ImpactObjectEvent(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ImpactObjectEvent"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)2; + + 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(ImpactObjectEventNS::checksum); + return ImpactObjectEventNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ImpactObjectEventNS::ParametersStruct& parameters(void) const + { + ImpactObjectEvent* tmpThis = const_cast<ImpactObjectEvent*>(this); + return *(static_cast<ImpactObjectEventNS::ParametersStruct*>(tmpThis)); + } + + ImpactObjectEventNS::ParametersStruct& parameters(void) + { + return *(static_cast<ImpactObjectEventNS::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 ImpactObjectEventFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ImpactObjectEvent::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ImpactObjectEvent), ImpactObjectEvent::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ImpactObjectEvent::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactObjectEvent"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ImpactObjectEvent)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ImpactObjectEvent)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ImpactObjectEvent::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ImpactObjectEvent::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ImpactObjectEvent"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ImpactObjectEvent 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 (ImpactObjectEvent*)bufObj; + } + + virtual const char* getClassName() + { + return (ImpactObjectEvent::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ImpactObjectEvent::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ImpactObjectEvent::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ImpactObjectEvent::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace emitter +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/emitter/include/autogen/ModuleEmitterRegistration.h b/APEX_1.4/module/emitter/include/autogen/ModuleEmitterRegistration.h new file mode 100644 index 00000000..f1a71eee --- /dev/null +++ b/APEX_1.4/module/emitter/include/autogen/ModuleEmitterRegistration.h @@ -0,0 +1,159 @@ +/* + * 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_MODULEEMITTERREGISTRATIONH_H +#define MODULE_MODULEEMITTERREGISTRATIONH_H + +#include "PsAllocator.h" +#include "NvRegistrationsForTraitsBase.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "PxAssert.h" +#include <stdint.h> + +// INCLUDE GENERATED FACTORIES +#include "ApexEmitterAssetParameters.h" +#include "EmitterGeomBoxParams.h" +#include "EmitterGeomExplicitParams.h" +#include "EmitterGeomSphereShellParams.h" +#include "EmitterGeomSphereParams.h" +#include "EmitterGeomCylinderParams.h" +#include "ApexEmitterActorParameters.h" +#include "ImpactEmitterActorParameters.h" +#include "GroundEmitterActorParameters.h" +#include "EmitterAssetPreviewParameters.h" +#include "EmitterDebugRenderParams.h" +#include "GroundEmitterAssetParameters.h" +#include "ImpactEmitterAssetParameters.h" +#include "ImpactExplosionEvent.h" +#include "ImpactObjectEvent.h" +#include "EmitterModuleParameters.h" + + +// INCLUDE GENERATED CONVERSION + + +namespace nvidia { +namespace emitter { + + +class ModuleEmitterRegistration : public NvParameterized::RegistrationsForTraitsBase +{ +public: + static void invokeRegistration(NvParameterized::Traits* parameterizedTraits) + { + if (parameterizedTraits) + { + ModuleEmitterRegistration().registerAll(*parameterizedTraits); + } + } + + static void invokeUnregistration(NvParameterized::Traits* parameterizedTraits) + { + if (parameterizedTraits) + { + ModuleEmitterRegistration().unregisterAll(*parameterizedTraits); + } + } + + void registerAvailableFactories(NvParameterized::Traits& parameterizedTraits) + { + ::NvParameterized::Factory* factoriesToRegister[] = { +// REGISTER GENERATED FACTORIES + new nvidia::emitter::ApexEmitterAssetParametersFactory(), + new nvidia::emitter::EmitterGeomBoxParamsFactory(), + new nvidia::emitter::EmitterGeomExplicitParamsFactory(), + new nvidia::emitter::EmitterGeomSphereShellParamsFactory(), + new nvidia::emitter::EmitterGeomSphereParamsFactory(), + new nvidia::emitter::EmitterGeomCylinderParamsFactory(), + new nvidia::emitter::ApexEmitterActorParametersFactory(), + new nvidia::emitter::ImpactEmitterActorParametersFactory(), + new nvidia::emitter::GroundEmitterActorParametersFactory(), + new nvidia::emitter::EmitterAssetPreviewParametersFactory(), + new nvidia::emitter::EmitterDebugRenderParamsFactory(), + new nvidia::emitter::GroundEmitterAssetParametersFactory(), + new nvidia::emitter::ImpactEmitterAssetParametersFactory(), + new nvidia::emitter::ImpactExplosionEventFactory(), + new nvidia::emitter::ImpactObjectEventFactory(), + new nvidia::emitter::EmitterModuleParametersFactory(), + + }; + + 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::emitter::ApexEmitterAssetParametersFactory(), + new nvidia::emitter::EmitterGeomBoxParamsFactory(), + new nvidia::emitter::EmitterGeomExplicitParamsFactory(), + new nvidia::emitter::EmitterGeomSphereShellParamsFactory(), + new nvidia::emitter::EmitterGeomSphereParamsFactory(), + new nvidia::emitter::EmitterGeomCylinderParamsFactory(), + new nvidia::emitter::ApexEmitterActorParametersFactory(), + new nvidia::emitter::ImpactEmitterActorParametersFactory(), + new nvidia::emitter::GroundEmitterActorParametersFactory(), + new nvidia::emitter::EmitterAssetPreviewParametersFactory(), + new nvidia::emitter::EmitterDebugRenderParamsFactory(), + new nvidia::emitter::GroundEmitterAssetParametersFactory(), + new nvidia::emitter::ImpactEmitterAssetParametersFactory(), + new nvidia::emitter::ImpactExplosionEventFactory(), + new nvidia::emitter::ImpactObjectEventFactory(), + new nvidia::emitter::EmitterModuleParametersFactory(), + + }; + + 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::emitter + +#endif diff --git a/APEX_1.4/module/emitter/src/EmitterActorImpl.cpp b/APEX_1.4/module/emitter/src/EmitterActorImpl.cpp new file mode 100644 index 00000000..bbfc509f --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterActorImpl.cpp @@ -0,0 +1,711 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ApexUsingNamespace.h" +#include "InstancedObjectSimulationIntl.h" +#include "EmitterActorImpl.h" +#include "EmitterAssetImpl.h" +#include "EmitterScene.h" +#include "EmitterGeomExplicitImpl.h" +#include "ApexSDKIntl.h" +#include "SceneIntl.h" +#include "RenderDebugInterface.h" + +#include "PxRigidDynamic.h" + +#include "ScopedPhysXLock.h" +#include "ReadCheck.h" + +#include "PsMathUtils.h" + +namespace nvidia +{ +namespace emitter +{ + +#pragma warning(disable: 4355) // 'this' : used in base member initializer list + +EmitterActorImpl::EmitterActorImpl(const EmitterActorDesc& desc, EmitterAssetImpl& asset, ResourceList& list, EmitterScene& scene) + : mPxScene(NULL) + , mAttachActor(NULL) + , mInjector(NULL) + , mAsset(&asset) + , mScene(&scene) + , mLastNonEmptyOverlapAABB(PxBounds3::empty()) + , mPose(desc.initialPose) + , mFirstStartEmitCall(true) + , mEmitAssetParticles(desc.emitAssetParticles) + , mPersist(false) + , mRemainder(0) + , mIsOldPoseInitialized(false) + , mOverlapTestCollisionGroups(desc.overlapTestCollisionGroups) + , mShouldUseGroupsMask(false) + , mExplicitGeom(NULL) + , mTickTask(*this) + , mObjectScale(desc.initialScale) +{ + mEmitterValidateCallback = NULL; + mIOS = NULL; + mRand.setSeed(scene.mApexScene->getSeed()); + + list.add(*this); // Add self to asset's list of actors + + mPoses.pushBack(mPose); + + /* Get initial values from authored asset */ + mDensity = mAsset->getDensity(); + mRate = mAsset->getRate(); + mVelocityLow = mAsset->getVelocityLow(); + mVelocityHigh = mAsset->getVelocityHigh(); + mLifetimeLow = mAsset->getLifetimeLow(); + mLifetimeHigh = mAsset->getLifetimeHigh(); + mAttachActor = desc.attachActor; + mAttachRelativePose = desc.attachRelativePose; + mDoEmit = mAsset->mGeom->getEmitterGeom()->getEmitterType() == EmitterType::ET_DENSITY_ONCE; + mEmitterVolume = mAsset->mGeom->computeEmitterVolume(); + + mEmitDuration = mDescEmitDuration = desc.emitterDuration; + + // create an instance of the explicit geometry for this actor's particles + // if the asset is an explicit emitter + if (mAsset->mGeom->getEmitterGeom()->isExplicitGeom()) + { + mExplicitGeom = PX_NEW(EmitterGeomExplicitImpl)(); + PX_ASSERT(mExplicitGeom); + } + + const char* iofxAssetName = mAsset->getInstancedObjectEffectsAssetName(); + IofxAsset* iofxAsset = static_cast<IofxAsset*>(mAsset->mIofxAssetTracker.getAssetFromName(iofxAssetName)); + IosAsset* iosAsset = mAsset->mIosAssetTracker.getIosAssetFromName(mAsset->getInstancedObjectSimulatorTypeName(), + mAsset->getInstancedObjectSimulatorAssetName()); + if (!iosAsset || !iofxAsset) + { + return; + } + + Actor* nxActor = iosAsset->createIosActor(*scene.mApexScene, iofxAsset); + InstancedObjectSimulationIntl* ios = NULL; + if (nxActor) + { + ApexActor* aa = GetInternalApexSDK()->getApexActor(nxActor); + if (aa) + { + ios = DYNAMIC_CAST(InstancedObjectSimulationIntl*)(aa); + } + } + if (!ios) + { + return; + } + + mObjectRadius = ios->getObjectRadius(); + mInjector = ios->allocateInjector(iofxAsset); + if (!mInjector) + { + return; + } + mIOS = ios; + mInjector->addSelfToContext(*this); + setLodParamDesc(mAsset->getLodParamDesc()); + + mInjector->setObjectScale(mObjectScale); + + addSelfToContext(*scene.mApexScene->getApexContext()); // Add self to ApexScene + addSelfToContext(scene); // Add self to EmitterScene's list of actors + + mValid = true; +} + +EmitterActorImpl::~EmitterActorImpl() +{ +} + +void EmitterActorImpl::setPreferredRenderVolume(nvidia::apex::RenderVolume* vol) +{ + WRITE_ZONE(); + if (mInjector) + { + mInjector->setPreferredRenderVolume(vol); + } +} + +void EmitterActorImpl::submitTasks() +{ + if (mInjector != 0) + { + mScene->mApexScene->getTaskManager()->submitUnnamedTask(mTickTask); + } +} + +void EmitterActorImpl::setTaskDependencies() +{ + if (mInjector != 0) + { + mTickTask.finishBefore(mInjector->getCompletionTaskID()); + mTickTask.finishBefore(mScene->mApexScene->getTaskManager()->getNamedTask(AST_PHYSX_SIMULATE)); + } +} + +void EmitterActorImpl::fetchResults() +{ +} + +void EmitterActorImpl::removeActorAtIndex(uint32_t index) +{ + // An injector has been deleted + PX_ASSERT(mInjector == (IosInjectorIntl*) mActorArray[index]); + mInjector = NULL; + ApexContext::removeActorAtIndex(index); + release(); +} + +/* Must be defined inside CPP file, since they require knowledge of asset class */ +Asset* EmitterActorImpl::getOwner() const +{ + READ_ZONE(); + return (Asset*) mAsset; +} +EmitterAsset* EmitterActorImpl::getEmitterAsset() const +{ + READ_ZONE(); + return mAsset; +} + +void EmitterActorImpl::release() +{ + if (mInRelease) + { + return; + } + mInRelease = true; + mAsset->releaseEmitterActor(*this); +} + + +void EmitterActorImpl::destroy() +{ + ApexActor::destroy(); + + if (mExplicitGeom) + { + mExplicitGeom->destroy(); + mExplicitGeom = 0; + } + + setPhysXScene(NULL); + + if (mInjector) + { + mInjector->release(); + } + mInjector = NULL; + mIOS = NULL; + + delete this; +} + +void EmitterActorImpl::setLodParamDesc(const EmitterLodParamDesc& d) +{ + WRITE_ZONE(); + mLodParams = d; + PX_ASSERT(mInjector); + if (mInjector) + mInjector->setLODWeights(d.maxDistance, d.distanceWeight, d.speedWeight, + d.lifeWeight, d.separationWeight, d.bias); +} + +void EmitterActorImpl::getLodRange(float& min, float& max, bool& intOnly) const +{ + READ_ZONE(); + PX_UNUSED(min); + PX_UNUSED(max); + PX_UNUSED(intOnly); + APEX_INVALID_OPERATION("not implemented"); +} + + +float EmitterActorImpl::getActiveLod() const +{ + READ_ZONE(); + APEX_INVALID_OPERATION("EmitterActor does not support this operation"); + return -1.0f; +} + + +void EmitterActorImpl::forceLod(float lod) +{ + WRITE_ZONE(); + PX_UNUSED(lod); + APEX_INVALID_OPERATION("not implemented"); +} + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterActorImpl::visualize(RenderDebugInterface&) +{ +} +#else +void EmitterActorImpl::visualize(RenderDebugInterface& renderDebug) +{ + if (!mScene->mEmitterDebugRenderParams->apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR) + { + return; + } + if ( !mEnableDebugVisualization ) return; + + using RENDER_DEBUG::DebugColors; + + if (mAsset->mGeom) + { + mAsset->mGeom->visualize(mPose, renderDebug); + } + + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentTextScale(2.0f); + + PxVec3 textLocation = this->getGlobalPose().column3.getXYZ(); + //visualize actor name + if (mScene->mEmitterDebugRenderParams->apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_NAME && + mScene->mEmitterDebugRenderParams->apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_NAME > + (-mScene->mApexScene->getEyePosition(0) + textLocation).magnitude()) + { + RENDER_DEBUG_IFACE(&renderDebug)->debugText(textLocation, " %s %s", this->getOwner()->getObjTypeName(), this->getOwner()->getName()); + } + //visualize actor pose + if (mScene->mEmitterDebugRenderParams->apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_POSE && + mScene->mEmitterDebugRenderParams->apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_POSE > + (-mScene->mApexScene->getEyePosition(0) + textLocation).magnitude()) + { + RENDER_DEBUG_IFACE(&renderDebug)->debugAxes(this->getGlobalPose(), 1); + } + + if (mScene->mEmitterDebugRenderParams->apexEmitterParameters.VISUALIZE_TOTAL_INJECTED_AABB) + { + if (!mOverlapAABB.isEmpty()) + { + mLastNonEmptyOverlapAABB.include(mOverlapAABB); + } + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::Red)); + RENDER_DEBUG_IFACE(&renderDebug)->debugBound(mLastNonEmptyOverlapAABB); + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); + } + + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +} +#endif + + +EmitterGeomExplicit* EmitterActorImpl::isExplicitGeom() +{ + WRITE_ZONE(); + if (mAsset->mGeom->getEmitterGeom()->isExplicitGeom()) + { + // return the actor's explicit geometry + return const_cast<EmitterGeomExplicit*>(mExplicitGeom->getEmitterGeom()->isExplicitGeom()); + } + else + { + return NULL; + } +} + + +void EmitterActorImpl::startEmit(bool persistent) +{ + WRITE_ZONE(); + // persistent remains a global setting + // simply store the current pose, emit all particles in the list for every pose + // fix bug: we don't want two poses on the first frame unless startEmit is called twice + if (mFirstStartEmitCall) + { + mFirstStartEmitCall = false; + mPoses.clear(); + } + + mPoses.pushBack(mPose); + + mEmitDuration = mDescEmitDuration; + + mDoEmit = true; + mPersist = persistent; +} + + +void EmitterActorImpl::stopEmit() +{ + WRITE_ZONE(); + mDoEmit = false; + mPersist = false; +} + + +void EmitterActorImpl::tick() +{ + mOverlapAABB = PxBounds3::empty(); + + // Clamp emission time to a min of 15FPS, to prevent extremely long frames + // from generating too many particles when rate emitters are in use. + float dt = PxMin(1 / 15.0f, mScene->mApexScene->getElapsedTime()); + + if (!mInjector || !mAsset->mGeom) + { + return; + } + + if (mAttachActor) + { + SCOPED_PHYSX_LOCK_WRITE(mScene->mApexScene); + + const PxTransform t = mAttachActor->is<physx::PxRigidDynamic>()->getGlobalPose(); + setCurrentPose(t * mAttachRelativePose); + } + + float curdensity = mAsset->getDensity() * mAsset->mModule->getDensityScale(); + float currate = mAsset->getRate() * mAsset->mModule->getRateScale(); + if (!mPersist && mDescEmitDuration > 0.0f && mDescEmitDuration < PX_MAX_F32) + { + uint32_t outCount; + if (mAsset->mRateVsTimeCurve.getControlPoints(outCount)) + { + const float time = 1.0f - (mEmitDuration / mDescEmitDuration); + currate *= mAsset->mRateVsTimeCurve.evaluate(time); + } + } + + EmitterGeom* nxGeom = mAsset->mGeom->getEmitterGeom(); + if (mDoEmit && nxGeom->isExplicitGeom()) + { + mNewPositions.clear(); + mNewVelocities.clear(); + mNewUserData.clear(); + + // compute the fill positions from both the asset's and actor's explicit geom + + for (uint32_t i = 0; i < mPoses.size(); i++) + { + PxTransform poseWithScale = mPoses[i]; + uint32_t velIdx = mNewVelocities.size(); + + if (mEmitAssetParticles) + { + DYNAMIC_CAST(EmitterGeomExplicitImpl*)(mAsset->mGeom)->computeFillPositions(mNewPositions, mNewVelocities, &mNewUserData, poseWithScale, PxVec3(mObjectScale), curdensity, mOverlapAABB, mRand); + } + DYNAMIC_CAST(EmitterGeomExplicitImpl*)(mExplicitGeom)->computeFillPositions(mNewPositions, mNewVelocities, &mNewUserData, poseWithScale, PxVec3(mObjectScale), curdensity, mOverlapAABB, mRand); + + for (; velIdx < mNewVelocities.size(); ++velIdx) + { + if (mNewVelocities[velIdx].isZero()) + { + mNewVelocities[velIdx] = poseWithScale.rotate(mRand.getScaled(mVelocityLow, mVelocityHigh)); + } + } + } + mPoses.clear(); + + if (mNewPositions.size() > 0) + { + uint32_t positionsSize = mNewPositions.size(); + PX_ASSERT(mNewVelocities.size() == positionsSize); + uint32_t userDataSize = mNewUserData.size(); + + mNewObjectArray.clear(); + mNewObjectArray.reserve(positionsSize); + for (uint32_t i = 0; i < positionsSize; i++) + { + IosNewObject& obj = mNewObjectArray.insert(); + + obj.initialPosition = mNewPositions[i]; + obj.initialVelocity = mNewVelocities[i]; + + obj.lifetime = mRand.getScaled(mLifetimeLow, mLifetimeHigh); + obj.iofxActorID = IofxActorIDIntl(0); + obj.lodBenefit = 0.0f; + + obj.userData = 0; + if (i < userDataSize) + { + obj.userData = mNewUserData[i]; + } + } + if (mNewObjectArray.size()) + { + mInjector->createObjects(mNewObjectArray.size(), &mNewObjectArray[0]); + } + } + + if (mPersist) + { + mDoEmit = true; + } + else if (mEmitDuration > 0.0f) + { + mEmitDuration = PxMax(0.0f, mEmitDuration - dt); + mDoEmit = (mEmitDuration > 0.0f); + } + else + { + mDoEmit = false; + } + + if (mDoEmit) + { + // set the last pose as the single pose in the list if we're persisting + mPoses.pushBack(mPose); + } + + return; + } + + if (mDoEmit) + { + uint32_t fillNumParticles; + fillNumParticles = (uint32_t)(curdensity * mEmitterVolume); + + switch (nxGeom->getEmitterType()) + { + case EmitterType::ET_RATE: + { + const uint32_t minSamplingFPS = mAsset->mParams->minSamplingFPS; + + uint32_t numSubSteps = 1; + if (minSamplingFPS > 0) + { + numSubSteps = uint32_t(physx::shdfnd::ceil(dt * minSamplingFPS)); + } + if (numSubSteps > 1) + { + const float dtSubStep = dt / numSubSteps; + + const PxQuat& originQ = mIsOldPoseInitialized ? mOldPose.q : mPose.q; + const PxVec3& originT = mIsOldPoseInitialized ? mOldPose.p : mPose.p; + for (uint32_t i = 0; i < numSubSteps; ++i) + { + const float s = (i + 1) / float(numSubSteps); + + PxTransform pose(physx::shdfnd::slerp(s, originQ, mPose.q)); + pose.p = originT * (1.0f - s) + mPose.p * s; + + emitObjects(pose, computeNbEmittedFromRate(dtSubStep, currate), true); + } + } + else + { + emitObjects(mPose, computeNbEmittedFromRate(dt, currate), true); + } + } + break; + + case EmitterType::ET_DENSITY_ONCE: + { + emitObjects(mPose, fillNumParticles, true); + } + break; + + case EmitterType::ET_DENSITY_BRUSH: + emitObjects(mPose, fillNumParticles, !mIsOldPoseInitialized); + break; + + case EmitterType::ET_FILL: + { + mNewPositions.clear(); + mNewVelocities.clear(); + + mAsset->mGeom->computeFillPositions(mNewPositions, mNewVelocities, mPose, PxVec3(mObjectScale), mObjectRadius, mOverlapAABB, mRand); + if (mNewPositions.size() > mAsset->getMaxSamples()) + { + mNewPositions.resize(mAsset->getMaxSamples()); + } + emitObjects(mNewPositions); + } + break; + + default: + PX_ASSERT(!"emitterType not supported."); + break; + } + + if (mPersist) + { + mDoEmit = true; + } + else if (mEmitDuration > 0.0f) + { + mEmitDuration = PxMax(0.0f, mEmitDuration - dt); + mDoEmit = (mEmitDuration > 0.0f); + } + else + { + mDoEmit = false; + } + } + + mOldPose = mPose; + mIsOldPoseInitialized = true; +} + + +uint32_t EmitterActorImpl::computeNbEmittedFromRate(float dt, float currate) +{ + // compute number of particles to be spawned + float nbEmittedReal = currate * dt; + nbEmittedReal += mRemainder; + uint32_t currentNbEmitted = (uint32_t) PxFloor(nbEmittedReal); + mRemainder = nbEmittedReal - (float) currentNbEmitted; + + return currentNbEmitted; +} + + +void EmitterActorImpl::emitObjects(const PxTransform& pose, uint32_t toEmitNum, bool useFullVolume) +{ + if (toEmitNum == 0) + { + return; + } + + if (!useFullVolume) + { + // compute newly covered volume + // SJB: Notes + // This is bizarre: we do 100 random samples to guess the amount of new area + // we have to work with, then generate that percentage of new particles? + float percent = mAsset->mGeom->computeNewlyCoveredVolume(mOldPose, pose, mObjectScale, mRand); + toEmitNum = (uint32_t)((float) toEmitNum * percent); + } + + PxVec3 emitterOrigin = getGlobalPose().getPosition(); + // TODO: This could obviously be more efficient + uint32_t emittedCount = 0; + mNewObjectArray.clear(); + mNewObjectArray.reserve(mAsset->getMaxSamples()); + for (uint32_t i = 0; i < mAsset->getMaxSamples(); i++) + { + PxVec3 pos; + if (useFullVolume) + { + pos = mAsset->mGeom->randomPosInFullVolume(pose, mRand); + } + else + { + pos = mAsset->mGeom->randomPosInNewlyCoveredVolume(pose, mOldPose, mRand); + } + + if ( mEmitterValidateCallback ) + { + if ( !mEmitterValidateCallback->validateEmitterPosition(emitterOrigin, pos)) + { + continue; + } + } + + + mOverlapAABB.include(pos); + + IosNewObject& obj = mNewObjectArray.insert(); + obj.initialPosition = pos; + obj.initialVelocity = pose.rotate(mRand.getScaled(mVelocityLow, mVelocityHigh)); + + obj.lifetime = mRand.getScaled(mLifetimeLow, mLifetimeHigh); + obj.iofxActorID = IofxActorIDIntl(0); + obj.lodBenefit = 0.0f; + obj.userData = 0; + + if (++emittedCount >= toEmitNum) + { + break; + } + } + + if (mNewObjectArray.size()) + { + mInjector->createObjects(mNewObjectArray.size(), &mNewObjectArray[0]); + } + + if (emittedCount < toEmitNum) + { + APEX_DEBUG_WARNING( + "\n Emitter asset name: %s." + "\n Ios asset name: %s." + "\n Iofx asset name: %s." + "\nMessage: Not all objects have been emitted. Possible reasons: " + "\n * Emitter may be failing overlap tests" + "\n * The individual object radius may be too big to fit in the emitter" + "\n * The emitter rate or density may have requested more than the asset's 'maxSamples' parameter\n", + mAsset->getName(), + mAsset->getInstancedObjectEffectsAssetName(), + mAsset->getInstancedObjectSimulatorAssetName()); + } +} + + +void EmitterActorImpl::emitObjects(const physx::Array<PxVec3>& positions) +{ + if (positions.empty()) + { + return; + } + + // TODO: This could obviously be more efficient + mNewObjectArray.clear(); + + PxVec3 emitterOrigin = getGlobalPose().getPosition(); + + for (uint32_t i = 0; i < positions.size(); i++) + { + PxVec3 position = positions[i]; + if ( mEmitterValidateCallback ) + { + if ( !mEmitterValidateCallback->validateEmitterPosition(emitterOrigin, position)) + { + continue; + } + } + IosNewObject& obj = mNewObjectArray.insert(); + obj.initialPosition = position; + obj.initialVelocity = mPose.rotate(mObjectScale * mRand.getScaled(mVelocityLow, mVelocityHigh)); + + obj.lifetime = mRand.getScaled(mLifetimeLow, mLifetimeHigh); + obj.iofxActorID = IofxActorIDIntl(0); + obj.lodBenefit = 0.0f; + obj.userData = 0; + } + + if (mNewObjectArray.size()) + { + mInjector->createObjects(mNewObjectArray.size(), &mNewObjectArray[0]); + } +} + +uint32_t EmitterActorImpl::getActiveParticleCount() const +{ + READ_ZONE(); + uint32_t ret = 0; + + if ( mInjector ) + { + ret = mInjector->getActivePaticleCount(); + } + + return ret; +} + +void EmitterActorImpl::setDensityGridPosition(const PxVec3 &pos) +{ + WRITE_ZONE(); + if ( mIOS ) + { + mIOS->setDensityOrigin(pos); + } +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterAssetImpl.cpp b/APEX_1.4/module/emitter/src/EmitterAssetImpl.cpp new file mode 100644 index 00000000..d716b7a3 --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterAssetImpl.cpp @@ -0,0 +1,742 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ModuleEmitterImpl.h" +#include "EmitterAssetImpl.h" +#include "EmitterActorImpl.h" +//#include "ApexSharedSerialization.h" + +#include "EmitterGeomBoxImpl.h" +#include "EmitterGeomSphereImpl.h" +#include "EmitterGeomSphereShellImpl.h" +#include "EmitterGeomCylinderImpl.h" +#include "EmitterGeomExplicitImpl.h" +#include "EmitterAssetPreview.h" + +#include "EmitterGeomBoxParams.h" +#include "EmitterGeomSphereParams.h" +#include "EmitterGeomSphereShellParams.h" +#include "EmitterGeomCylinderParams.h" +#include "EmitterGeomExplicitParams.h" + +#include "IofxAsset.h" + +namespace nvidia +{ +namespace emitter +{ + + +struct ApexEmitterGeomTypes +{ + enum Enum + { + GEOM_GROUND = 0, + GEOM_BOX, + GEOM_SPHERE, + GEOM_SPHERE_SHELL, + GEOM_EXLICIT, + }; +}; + +void EmitterAssetImpl::copyLodDesc2(EmitterLodParamDesc& dst, const ApexEmitterAssetParametersNS::emitterLodParamDesc_Type& src) +{ + PX_ASSERT(src.version == dst.current); + + dst.bias = src.bias; + dst.distanceWeight = src.distanceWeight; + dst.lifeWeight = src.lifeWeight; + dst.maxDistance = src.maxDistance; + dst.separationWeight = src.separationWeight; + dst.speedWeight = src.speedWeight; +} + +void EmitterAssetImpl::copyLodDesc2(ApexEmitterAssetParametersNS::emitterLodParamDesc_Type& dst, const EmitterLodParamDesc& src) +{ + dst.version = src.current; + dst.bias = src.bias; + dst.distanceWeight = src.distanceWeight; + dst.lifeWeight = src.lifeWeight; + dst.maxDistance = src.maxDistance; + dst.separationWeight = src.separationWeight; + dst.speedWeight = src.speedWeight; +} + +void EmitterAssetImpl::postDeserialize(void* userData_) +{ + PX_UNUSED(userData_); + + ApexSimpleString tmpStr; + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr; + + if (mParams->iofxAssetName == NULL) + { + NvParameterized::Handle h(mParams); + h.getParameter("iofxAssetName"); + h.initParamRef(h.parameterDefinition()->refVariantVal(0), true); + } + + if (mParams->iosAssetName == NULL) + { + NvParameterized::Handle h(mParams); + h.getParameter("iosAssetName"); + h.initParamRef(h.parameterDefinition()->refVariantVal(0), true); + } + + if (mParams->geometryType == NULL) + { + NvParameterized::Handle h(mParams); + h.getParameter("geometryType"); + h.initParamRef(h.parameterDefinition()->refVariantVal(0), true); + } + + + ApexSimpleString iofxName(mParams->iofxAssetName->name()); + ApexSimpleString iosName(mParams->iosAssetName->name()); + ApexSimpleString iosTypeName(mParams->iosAssetName->className()); + + if (!iofxName.len() || !iosName.len() || !iosTypeName.len()) + { + APEX_INTERNAL_ERROR("IOFX, IOS, or IOS type not initialized"); + return; + } + + if (mGeom) + { + mGeom->destroy(); + } + + mParams->getParameterHandle("geometryType", h); + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (!refPtr) + { + APEX_INTERNAL_ERROR("No emitter geometry specified"); + return; + } + + tmpStr = refPtr->className(); + + if (tmpStr == EmitterGeomBoxParams::staticClassName()) + { + EmitterGeomBoxImpl* exp = PX_NEW(EmitterGeomBoxImpl)(refPtr); + mGeom = exp; + } + else if (tmpStr == EmitterGeomSphereParams::staticClassName()) + { + EmitterGeomSphereImpl* exp = PX_NEW(EmitterGeomSphereImpl)(refPtr); + mGeom = exp; + } + else if (tmpStr == EmitterGeomSphereShellParams::staticClassName()) + { + EmitterGeomSphereShellImpl* exp = PX_NEW(EmitterGeomSphereShellImpl)(refPtr); + mGeom = exp; + } + else if (tmpStr == EmitterGeomCylinderParams::staticClassName()) + { + EmitterGeomCylinderImpl* exp = PX_NEW(EmitterGeomCylinderImpl)(refPtr); + mGeom = exp; + } + else if (tmpStr == EmitterGeomExplicitParams::staticClassName()) + { + EmitterGeomExplicitImpl* exp = PX_NEW(EmitterGeomExplicitImpl)(refPtr); + mGeom = exp; + } + else + { + PX_ASSERT(0 && "Invalid geometry type for APEX emitter"); + return; + } + + copyLodDesc2(mLodDesc, mParams->lodParamDesc); + + initializeAssetNameTable(); +} + + +void EmitterAssetImpl::initializeAssetNameTable() +{ + // clean up asset tracker list + mIosAssetTracker.removeAllAssetNames(); + mIofxAssetTracker.removeAllAssetNames(); + + mIosAssetTracker.addAssetName(mParams->iosAssetName->className(), + mParams->iosAssetName->name()); + + mIofxAssetTracker.addAssetName(mParams->iofxAssetName->name(), false); + + ParamArray<Vec2R> cp(mParams, "rateVsTimeCurvePoints", (ParamDynamicArrayStruct*)&mParams->rateVsTimeCurvePoints); + for (uint32_t i = 0; i < cp.size(); i++) + { + mRateVsTimeCurve.addControlPoint(cp[i]); + } +} + +EmitterAssetImpl::EmitterAssetImpl(ModuleEmitterImpl* module, ResourceList& list, const char* name): + mDefaultActorParams(NULL), + mDefaultPreviewParams(NULL), + mModule(module), + mName(name), + mGeom(NULL), + mIofxAssetTracker(module->mSdk, IOFX_AUTHORING_TYPE_NAME), + mIosAssetTracker(module->mSdk) +{ + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + mParams = static_cast<ApexEmitterAssetParameters*>(traits->createNvParameterized(ApexEmitterAssetParameters::staticClassName())); + + PX_ASSERT(mParams); + + mParams->setSerializationCallback(this); + list.add(*this); +} + +EmitterAssetImpl::EmitterAssetImpl(ModuleEmitterImpl* module, + ResourceList& list, + NvParameterized::Interface* params, + const char* name) : + mParams(static_cast<ApexEmitterAssetParameters*>(params)), + mDefaultActorParams(NULL), + mDefaultPreviewParams(NULL), + mModule(module), + mName(name), + mGeom(NULL), + mIofxAssetTracker(module->mSdk, IOFX_AUTHORING_TYPE_NAME), + mIosAssetTracker(module->mSdk) +{ + // this may no longer make any sense + mParams->setSerializationCallback(this); + + // call this now to "initialize" the asset + postDeserialize(); + + list.add(*this); +} + +EmitterAssetImpl::~EmitterAssetImpl() +{ +} + +void EmitterAssetImpl::release() +{ + mModule->mSdk->releaseAsset(*this); +} + +void EmitterAssetImpl::destroy() +{ + /* Assets that were forceloaded or loaded by actors will be automatically + * released by the ApexAssetTracker member destructors. + */ + + if (mGeom) + { + mGeom->destroy(); + } + mGeom = NULL; + + if (mDefaultActorParams) + { + mDefaultActorParams->destroy(); + mDefaultActorParams = 0; + } + + if (mDefaultPreviewParams) + { + mDefaultPreviewParams->destroy(); + mDefaultPreviewParams = 0; + } + + if (mParams) + { + mParams->destroy(); + mParams = NULL; + } + + /* Actors are automatically cleaned up on deletion by ResourceList dtor */ + delete this; +} + +EmitterGeomExplicit* EmitterAssetImpl::isExplicitGeom() +{ + READ_ZONE(); + return const_cast<EmitterGeomExplicit*>(mGeom->getEmitterGeom()->isExplicitGeom()); +} + +const EmitterGeomExplicit* EmitterAssetImpl::isExplicitGeom() const +{ + return mGeom->getEmitterGeom()->isExplicitGeom(); +} + +NvParameterized::Interface* EmitterAssetImpl::getDefaultActorDesc() +{ + WRITE_ZONE(); + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + PX_ASSERT(traits); + if (!traits) + { + return NULL; + } + + // create if not yet created + if (!mDefaultActorParams) + { + const char* className = ApexEmitterActorParameters::staticClassName(); + NvParameterized::Interface* param = traits->createNvParameterized(className); + mDefaultActorParams = static_cast<ApexEmitterActorParameters*>(param); + + PX_ASSERT(param); + if (!param) + { + return NULL; + } + } + + if (mDefaultActorParams) + { + mDefaultActorParams->emitterDuration = mParams->emitterDuration; + } + + return mDefaultActorParams; +} + +NvParameterized::Interface* EmitterAssetImpl::getDefaultAssetPreviewDesc() +{ + WRITE_ZONE(); + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + PX_ASSERT(traits); + if (!traits) + { + return NULL; + } + + // create if not yet created + if (!mDefaultPreviewParams) + { + const char* className = EmitterAssetPreviewParameters::staticClassName(); + NvParameterized::Interface* param = traits->createNvParameterized(className); + mDefaultPreviewParams = static_cast<EmitterAssetPreviewParameters*>(param); + + PX_ASSERT(param); + if (!param) + { + return NULL; + } + } + + return mDefaultPreviewParams; +} + +Actor* EmitterAssetImpl::createApexActor(const NvParameterized::Interface& parms, Scene& apexScene) +{ + WRITE_ZONE(); + if (!isValidForActorCreation(parms, apexScene)) + { + return NULL; + } + + Actor* ret = 0; + + const char* className = parms.className(); + if (nvidia::strcmp(className, ApexEmitterActorParameters::staticClassName()) == 0) + { + EmitterActorDesc desc; + const ApexEmitterActorParameters* pDesc = static_cast<const ApexEmitterActorParameters*>(&parms); + + desc.attachRelativePose = pDesc->attachRelativePose; + desc.initialPose = pDesc->initialPose; + desc.emitAssetParticles = pDesc->emitAssetParticles; + desc.emitterDuration = pDesc->emitterDuration; + desc.initialScale = pDesc->initialScale; + + /* Resolve the authored collision group mask name into the actual ID */ + if (pDesc->overlapTestGroupMaskName != NULL && + pDesc->overlapTestGroupMaskName[0] != 0) + { + ResourceProviderIntl* nrp = mModule->mSdk->getInternalResourceProvider(); + ResID cgmns = mModule->mSdk->getCollisionGroupMaskNameSpace(); + ResID cgresid = nrp->createResource(cgmns, pDesc->overlapTestGroupMaskName); + desc.overlapTestCollisionGroups = (uint32_t)(size_t) nrp->getResource(cgresid); + } + + ret = createEmitterActor(desc, apexScene); + } + + return ret; +} + + + +AssetPreview* EmitterAssetImpl::createApexAssetPreview(const NvParameterized::Interface& parms, AssetPreviewScene* previewScene) +{ + WRITE_ZONE(); + AssetPreview* ret = 0; + + const char* className = parms.className(); + if (nvidia::strcmp(className, EmitterAssetPreviewParameters::staticClassName()) == 0) + { + EmitterPreviewDesc desc; + const EmitterAssetPreviewParameters* pDesc = static_cast<const EmitterAssetPreviewParameters*>(&parms); + + desc.mPose = pDesc->pose; + desc.mScale = pDesc->scale; + + ret = createEmitterPreview(desc, previewScene); + } + + return ret; +} + + +EmitterActor* EmitterAssetImpl::createEmitterActor(const EmitterActorDesc& desc, const Scene& scene) +{ + if (!desc.isValid()) + { + return NULL; + } + + EmitterScene* es = mModule->getEmitterScene(scene); + EmitterActorImpl* actor = PX_NEW(EmitterActorImpl)(desc, *this, mEmitterActors, *es); + if (!actor->isValid()) + { + actor->destroy(); + return NULL; + } + return actor; +} + +void EmitterAssetImpl::releaseEmitterActor(EmitterActor& nxactor) +{ + EmitterActorImpl* actor = DYNAMIC_CAST(EmitterActorImpl*)(&nxactor); + actor->destroy(); +} + +EmitterPreview* EmitterAssetImpl::createEmitterPreview(const EmitterPreviewDesc& desc, AssetPreviewScene* previewScene) +{ + if (!desc.isValid()) + { + return NULL; + } + + EmitterAssetPreview* p = PX_NEW(EmitterAssetPreview)(desc, *this, previewScene, GetApexSDK()); + if (p && !p->isValid()) + { + p->destroy(); + p = NULL; + } + return p; +} + +void EmitterAssetImpl::releaseEmitterPreview(EmitterPreview& nxpreview) +{ + EmitterAssetPreview* preview = DYNAMIC_CAST(EmitterAssetPreview*)(&nxpreview); + preview->destroy(); +} + + +uint32_t EmitterAssetImpl::forceLoadAssets() +{ + uint32_t assetLoadedCount = 0; + + assetLoadedCount += mIofxAssetTracker.forceLoadAssets(); + assetLoadedCount += mIosAssetTracker.forceLoadAssets(); + + return assetLoadedCount; +} + +bool EmitterAssetImpl::isValidForActorCreation(const ::NvParameterized::Interface& /*actorParams*/, Scene& /*apexScene*/) const +{ + READ_ZONE(); + if (!mGeom) + { + return false; + } + + const EmitterGeomExplicit* explicitGeom = isExplicitGeom(); + if (explicitGeom) + { + // Velocity array must be same size as positions or 0 + + const EmitterGeomExplicit::PointParams* points; + const PxVec3* velocities; + uint32_t numPoints, numVelocities; + explicitGeom->getParticleList(points, numPoints, velocities, numVelocities); + if (!(numPoints == numVelocities || 0 == numVelocities)) + { + return false; + } + + const EmitterGeomExplicit::SphereParams* spheres; + uint32_t numSpheres; + explicitGeom->getSphereList(spheres, numSpheres, velocities, numVelocities); + if (!(numSpheres == numVelocities || 0 == numVelocities)) + { + return false; + } + + const EmitterGeomExplicit::EllipsoidParams* ellipsoids; + uint32_t numEllipsoids; + explicitGeom->getEllipsoidList(ellipsoids, numEllipsoids, velocities, numVelocities); + if (!(numEllipsoids == numVelocities || 0 == numVelocities)) + { + return false; + } + + // Radiuses are > 0 + + for (uint32_t i = 0; i < numSpheres; ++i) + if (explicitGeom->getSphereRadius(i) <= 0) + { + return false; + } + + for (uint32_t i = 0; i < numEllipsoids; ++i) + if (explicitGeom->getEllipsoidRadius(i) <= 0) + { + return false; + } + + /* // Normals are normalized + + for(uint32_t i = 0; i < numEllipsoids; ++i) + if( !explicitGeom->getEllipsoidNormal(i).isNormalized() ) + return false; + */ + // Distance >= 0 + + if (explicitGeom->getDistance() < 0) + { + return false; + } + + // Distance > 0 if we have shapes + + if ((numSpheres || numEllipsoids) && !explicitGeom->getDistance()) + { + return false; + } + } + + return true; +} + +/*=============== Asset Authoring =================*/ +#ifndef WITHOUT_APEX_AUTHORING +void EmitterAssetAuthoringImpl::setInstancedObjectEffectsAssetName(const char* iofxname) +{ + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr; + + mParams->getParameterHandle("iofxAssetName", h); + mParams->initParamRef(h, NULL, true); + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (refPtr) + { + refPtr->setName(iofxname); + } + +} + + +void EmitterAssetAuthoringImpl::setInstancedObjectSimulatorAssetName(const char* iosname) +{ + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr; + + mParams->getParameterHandle("iosAssetName", h); + mParams->initParamRef(h, NULL, true); + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (refPtr) + { + refPtr->setName(iosname); + } +} + + +void EmitterAssetAuthoringImpl::setInstancedObjectSimulatorTypeName(const char* iostname) +{ + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr; + + mParams->getParameterHandle("iosAssetName", h); + mParams->initParamRef(h, iostname, true); + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (refPtr) + { + refPtr->setClassName(iostname); + } +} + + +void EmitterAssetAuthoringImpl::release() +{ + mModule->mSdk->releaseAssetAuthoring(*this); +} + + +EmitterGeomBox* EmitterAssetAuthoringImpl::setBoxGeom() +{ + if (mGeom) + { + mGeom->destroy(); + if (mParams->geometryType) + { + mParams->geometryType->destroy(); + mParams->geometryType = NULL; + } + } + + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr = 0; + mParams->getParameterHandle("geometryType", h); + + mParams->getParamRef(h, refPtr); + if (refPtr) + { + refPtr->destroy(); + mParams->setParamRef(h, 0); + } + + mParams->initParamRef(h, EmitterGeomBoxParams::staticClassName(), true); + + refPtr = 0; + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (!refPtr) + { + return NULL; + } + + EmitterGeomBoxImpl* box = PX_NEW(EmitterGeomBoxImpl)(refPtr); + mGeom = box; + return box; +} + +EmitterGeomSphere* EmitterAssetAuthoringImpl::setSphereGeom() +{ + if (mGeom) + { + mGeom->destroy(); + if (mParams->geometryType) + { + mParams->geometryType->destroy(); + mParams->geometryType = NULL; + } + } + + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr = 0; + mParams->getParameterHandle("geometryType", h); + + mParams->getParamRef(h, refPtr); + if (refPtr) + { + refPtr->destroy(); + mParams->setParamRef(h, 0); + } + + mParams->initParamRef(h, EmitterGeomSphereParams::staticClassName(), true); + + refPtr = 0; + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (!refPtr) + { + return NULL; + } + + EmitterGeomSphereImpl* sphere = PX_NEW(EmitterGeomSphereImpl)(refPtr); + mGeom = sphere; + return sphere; +} + +EmitterGeomSphereShell* EmitterAssetAuthoringImpl::setSphereShellGeom() +{ + if (mGeom) + { + mGeom->destroy(); + if (mParams->geometryType) + { + mParams->geometryType->destroy(); + mParams->geometryType = NULL; + } + } + + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr = 0; + mParams->getParameterHandle("geometryType", h); + + mParams->getParamRef(h, refPtr); + if (refPtr) + { + refPtr->destroy(); + mParams->setParamRef(h, 0); + } + + mParams->initParamRef(h, EmitterGeomSphereShellParams::staticClassName(), true); + + refPtr = 0; + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (!refPtr) + { + return NULL; + } + + EmitterGeomSphereShellImpl* sphereshell = PX_NEW(EmitterGeomSphereShellImpl)(refPtr); + mGeom = sphereshell; + return sphereshell; +} + +EmitterGeomExplicit* EmitterAssetAuthoringImpl::setExplicitGeom() +{ + if (mGeom) + { + mGeom->destroy(); + if (mParams->geometryType) + { + mParams->geometryType->destroy(); + mParams->geometryType = NULL; + } + } + + NvParameterized::Handle h(*mParams); + NvParameterized::Interface* refPtr = 0; + mParams->getParameterHandle("geometryType", h); + + mParams->getParamRef(h, refPtr); + if (refPtr) + { + refPtr->destroy(); + mParams->setParamRef(h, 0); + } + + mParams->initParamRef(h, EmitterGeomExplicitParams::staticClassName(), true); + + refPtr = 0; + mParams->getParamRef(h, refPtr); + PX_ASSERT(refPtr); + if (!refPtr) + { + return NULL; + } + + EmitterGeomExplicitImpl* exp = PX_NEW(EmitterGeomExplicitImpl)(refPtr); + mGeom = exp; + return exp; +} +#endif + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterAssetPreview.cpp b/APEX_1.4/module/emitter/src/EmitterAssetPreview.cpp new file mode 100644 index 00000000..8bf99098 --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterAssetPreview.cpp @@ -0,0 +1,206 @@ +/* + * 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. + */ + + +#include "EmitterPreview.h" +#include "EmitterAssetPreview.h" + +#define ASSET_INFO_XPOS (-0.9f) // left position of the asset info +#define ASSET_INFO_YPOS ( 0.9f) // top position of the asset info +#define DEBUG_TEXT_HEIGHT (0.4f) // in screen space + +namespace nvidia +{ +namespace emitter +{ + +bool EmitterAssetPreview::isValid() const +{ + return mApexRenderDebug != NULL; +} + +void EmitterAssetPreview::drawEmitterPreview(void) +{ + WRITE_ZONE(); +#ifndef WITHOUT_DEBUG_VISUALIZE + if (!mApexRenderDebug) + { + return; + } + + //asset preview init + if (mGroupID == 0) + { + mGroupID = RENDER_DEBUG_IFACE(mApexRenderDebug)->beginDrawGroup(PxMat44(PxIdentity)); + mAsset->mGeom->drawPreview(mScale, mApexRenderDebug); + RENDER_DEBUG_IFACE(mApexRenderDebug)->endDrawGroup(); + } + + toggleDrawPreview(); + setDrawGroupsPose(); +#endif +} + +void EmitterAssetPreview::drawPreviewAssetInfo(void) +{ + if (!mApexRenderDebug) + { + return; + } + + char buf[128]; + buf[sizeof(buf) - 1] = 0; + + ApexSimpleString myString; + ApexSimpleString floatStr; + uint32_t lineNum = 0; + + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(mApexRenderDebug)->pushRenderState(); + // RENDER_DEBUG_IFACE(&mApexRenderDebug)->addToCurrentState(RENDER_DEBUG::DebugRenderState::ScreenSpace); + RENDER_DEBUG_IFACE(mApexRenderDebug)->addToCurrentState(RENDER_DEBUG::DebugRenderState::NoZbuffer); + RENDER_DEBUG_IFACE(mApexRenderDebug)->setCurrentTextScale(2.0f); + RENDER_DEBUG_IFACE(mApexRenderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(mApexRenderDebug)->getDebugColor(DebugColors::Yellow)); + + // asset name + APEX_SPRINTF_S(buf, sizeof(buf) - 1, "%s %s", mAsset->getObjTypeName(), mAsset->getName()); + drawInfoLine(lineNum++, buf); + lineNum++; + + RENDER_DEBUG_IFACE(mApexRenderDebug)->popRenderState(); +} + + +void EmitterAssetPreview::drawInfoLine(uint32_t lineNum, const char* str) +{ +#ifdef WITHOUT_DEBUG_VISUALIZE + PX_UNUSED(lineNum); + PX_UNUSED(str); +#else + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(mApexRenderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(mApexRenderDebug)->getDebugColor(DebugColors::Green)); + PxVec3 textLocation = mPose.getPosition(); + PxMat44 cameraMatrix = mPreviewScene->getCameraMatrix(); + textLocation += cameraMatrix.column1.getXYZ() * (ASSET_INFO_YPOS - (lineNum * DEBUG_TEXT_HEIGHT)); + RENDER_DEBUG_IFACE(mApexRenderDebug)->debugText(textLocation, str); +#endif +} + + +void EmitterAssetPreview::destroy(void) +{ + ApexPreview::destroy(); + delete this; +} + +EmitterAssetPreview::~EmitterAssetPreview(void) +{ +} + +void EmitterAssetPreview::setScale(float scale) +{ + WRITE_ZONE(); + mScale = scale; + drawEmitterPreview(); +} + +void EmitterAssetPreview::setPose(const PxMat44& pose) +{ + WRITE_ZONE(); + mPose = pose; + setDrawGroupsPose(); +} + +const PxMat44 EmitterAssetPreview::getPose() const +{ + READ_ZONE(); + return mPose; +} + +void EmitterAssetPreview::setDrawGroupsPose() +{ + if (mApexRenderDebug) + { + RENDER_DEBUG_IFACE(mApexRenderDebug)->setDrawGroupPose(mGroupID, mPose); + } +} + +void EmitterAssetPreview::toggleDrawPreview() +{ + if (mApexRenderDebug) + { + //asset preview set visibility + RENDER_DEBUG_IFACE(mApexRenderDebug)->setDrawGroupVisible(mGroupID, true); + } +} + + +// from RenderDataProvider +void EmitterAssetPreview::lockRenderResources(void) +{ + ApexRenderable::renderDataLock(); +} + +void EmitterAssetPreview::unlockRenderResources(void) +{ + ApexRenderable::renderDataUnLock(); +} + +void EmitterAssetPreview::updateRenderResources(bool /*rewriteBuffers*/, void* /*userRenderData*/) +{ + if (mApexRenderDebug) + { + mApexRenderDebug->updateRenderResources(); + } +} + +// from Renderable.h +void EmitterAssetPreview::dispatchRenderResources(UserRenderer& renderer) +{ + if (mApexRenderDebug) + { + drawPreviewAssetInfo(); + mApexRenderDebug->dispatchRenderResources(renderer); + } +} + +PxBounds3 EmitterAssetPreview::getBounds(void) const +{ + READ_ZONE(); + return mApexRenderDebug->getBounds(); +} + +void EmitterAssetPreview::release(void) +{ + if (mInRelease) + { + return; + } + mInRelease = true; + const_cast<EmitterAssetImpl*>(mAsset)->releaseEmitterPreview(*this); +} + + EmitterAssetPreview::EmitterAssetPreview(const EmitterPreviewDesc& pdesc, const EmitterAssetImpl& asset, AssetPreviewScene* previewScene, ApexSDK* myApexSDK) : + mApexSDK(myApexSDK), + mScale(pdesc.mScale), + mAsset(&asset), + mPreviewScene(previewScene), + mGroupID(0), + mApexRenderDebug(0) + { +#ifndef WITHOUT_DEBUG_VISUALIZE + setPose(pdesc.mPose); + drawPreviewAssetInfo(); + drawEmitterPreview(); +#endif + }; + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterGeomBase.cpp b/APEX_1.4/module/emitter/src/EmitterGeomBase.cpp new file mode 100644 index 00000000..5ae761cb --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterGeomBase.cpp @@ -0,0 +1,56 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "EmitterGeomBase.h" + +namespace nvidia +{ +namespace emitter +{ + +/* Return percentage of new volume not covered by old volume */ +float EmitterGeomBase::computeNewlyCoveredVolume( + const PxMat44& oldPose, + const PxMat44& newPose, + float scale, + QDSRand& rand) const +{ + // estimate by sampling + const uint32_t numSamples = 100; + uint32_t numOutsideOldVolume = 0; + for (uint32_t i = 0; i < numSamples; i++) + { + if (!isInEmitter(randomPosInFullVolume(PxMat44(newPose) * scale, rand), PxMat44(oldPose) * scale)) + { + numOutsideOldVolume++; + } + } + + return (float) numOutsideOldVolume / numSamples; +} + + +// TODO make better, this is very slow when emitter moves slowly +// SJB: I'd go one further, this seems mildly retarted +PxVec3 EmitterGeomBase::randomPosInNewlyCoveredVolume(const PxMat44& pose, const PxMat44& oldPose, QDSRand& rand) const +{ + PxVec3 pos; + do + { + pos = randomPosInFullVolume(pose, rand); + } + while (isInEmitter(pos, oldPose)); + return pos; +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterGeomBoxImpl.cpp b/APEX_1.4/module/emitter/src/EmitterGeomBoxImpl.cpp new file mode 100644 index 00000000..15633f24 --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterGeomBoxImpl.cpp @@ -0,0 +1,229 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ApexUsingNamespace.h" +#include "EmitterAsset.h" +#include "EmitterGeomBoxImpl.h" +//#include "ApexSharedSerialization.h" +#include "RenderDebugInterface.h" +#include "RenderDebugInterface.h" +#include "ApexPreview.h" +#include "EmitterGeomBoxParams.h" + +namespace nvidia +{ +namespace emitter +{ + + + +EmitterGeomBoxImpl::EmitterGeomBoxImpl(NvParameterized::Interface* params) +{ + NvParameterized::Handle eh(*params); + const NvParameterized::Definition* paramDef; + const char* enumStr = 0; + + mGeomParams = (EmitterGeomBoxParams*)params; + mExtents = (PxVec3*)(&(mGeomParams->parameters().extents)); + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + mGeomParams->getParamEnum(eh, enumStr); + paramDef = eh.parameterDefinition(); + + mType = EmitterType::ET_RATE; + for (int i = 0; i < paramDef->numEnumVals(); ++i) + { + if (!nvidia::strcmp(paramDef->enumVal(i), enumStr)) + { + mType = (EmitterType::Enum)i; + break; + } + } +} + +EmitterGeom* EmitterGeomBoxImpl::getEmitterGeom() +{ + return this; +} + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomBoxImpl::visualize(const PxTransform& , RenderDebugInterface&) +{ +} +#else +void EmitterGeomBoxImpl::visualize(const PxTransform& pose, RenderDebugInterface& renderDebug) +{ + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::DarkGreen)); + RENDER_DEBUG_IFACE(&renderDebug)->setPose(pose); + RENDER_DEBUG_IFACE(&renderDebug)->debugBound(PxBounds3(PxVec3(0.0f), 2.0f * *mExtents)); + RENDER_DEBUG_IFACE(&renderDebug)->setPose(PxIdentity); + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +} +#endif + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomBoxImpl::drawPreview(float , RenderDebugInterface*) const +{ +} +#else +void EmitterGeomBoxImpl::drawPreview(float scale, RenderDebugInterface* renderDebug) const +{ + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen), + RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen)); + RENDER_DEBUG_IFACE(renderDebug)->debugBound(PxBounds3(-(*mExtents) * scale, *mExtents * scale)); + RENDER_DEBUG_IFACE(renderDebug)->popRenderState(); +} +#endif + + +void EmitterGeomBoxImpl::setEmitterType(EmitterType::Enum t) +{ + mType = t; + + NvParameterized::Handle eh(*mGeomParams); + const NvParameterized::Definition* paramDef; + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + paramDef = eh.parameterDefinition(); + + mGeomParams->setParamEnum(eh, paramDef->enumVal((int)mType)); +} + +/* ApexEmitterActor callable methods */ + + +float EmitterGeomBoxImpl::computeEmitterVolume() const +{ + return 8.0f * mExtents->x * mExtents->y * mExtents->z; +} + + +/* Return percentage of new volume not covered by old volume */ +float EmitterGeomBoxImpl::computeNewlyCoveredVolume( + const PxMat44& oldPose, + const PxMat44& newPose, + float scale, + QDSRand& rand) const +{ + // estimate by sampling + const uint32_t numSamples = 100; + uint32_t numOutsideOldVolume = 0; + for (uint32_t i = 0; i < numSamples; i++) + { + if (!isInEmitter(randomPosInFullVolume(PxMat44(newPose) * scale, rand), PxMat44(oldPose) * scale)) + { + numOutsideOldVolume++; + } + } + + return (float) numOutsideOldVolume / numSamples; +} + + +void EmitterGeomBoxImpl::computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform& pose, + const PxVec3& scale, + float objRadius, + PxBounds3& outBounds, + QDSRand&) const +{ + // we're not doing anything with the velocities array + PX_UNUSED(velocities); + PX_UNUSED(scale); + + // we don't want anything outside the emitter + uint32_t numX = (uint32_t)PxFloor(mExtents->x / objRadius); + numX -= numX % 2; + uint32_t numY = (uint32_t)PxFloor(mExtents->y / objRadius); + numY -= numY % 2; + uint32_t numZ = (uint32_t)PxFloor(mExtents->z / objRadius); + numZ -= numZ % 2; + + for (float x = -(numX * objRadius); x <= mExtents->x - objRadius; x += 2 * objRadius) + { + for (float y = -(numY * objRadius); y <= mExtents->y - objRadius; y += 2 * objRadius) + { + for (float z = -(numZ * objRadius); z <= mExtents->z - objRadius; z += 2 * objRadius) + { + positions.pushBack(pose.transform(PxVec3(x, y, z))); + outBounds.include(positions.back()); + } + } + } +} + +/* internal methods */ + +PxVec3 EmitterGeomBoxImpl::randomPosInFullVolume(const PxMat44& pose, QDSRand& rand) const +{ + float u = rand.getScaled(-mExtents->x, mExtents->x); + float v = rand.getScaled(-mExtents->y, mExtents->y); + float w = rand.getScaled(-mExtents->z, mExtents->z); + + PxVec3 pos(u, v, w); + return pose.transform(pos); +} + +bool EmitterGeomBoxImpl::isInEmitter(const PxVec3& pos, const PxMat44& pose) const +{ + PxVec3 localPos = pose.inverseRT().transform(pos); + + if (localPos.x < -mExtents->x) + { + return false; + } + if (localPos.x > mExtents->x) + { + return false; + } + if (localPos.y < -mExtents->y) + { + return false; + } + if (localPos.y > mExtents->y) + { + return false; + } + if (localPos.z < -mExtents->z) + { + return false; + } + if (localPos.z > mExtents->z) + { + return false; + } + + return true; +} + +PxVec3 EmitterGeomBoxImpl::randomPosInNewlyCoveredVolume(const PxMat44& pose, const PxMat44& oldPose, QDSRand& rand) const +{ + // TODO make better, this is very slow when emitter moves slowly + // SJB: I'd go one further, this seems mildly retarted + PxVec3 pos; + do + { + pos = randomPosInFullVolume(pose, rand); + } + while (isInEmitter(pos, oldPose)); + return pos; +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterGeomCylinderImpl.cpp b/APEX_1.4/module/emitter/src/EmitterGeomCylinderImpl.cpp new file mode 100644 index 00000000..d9237cb0 --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterGeomCylinderImpl.cpp @@ -0,0 +1,218 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ApexUsingNamespace.h" +#include "EmitterGeomCylinderImpl.h" +//#include "ApexSharedSerialization.h" +#include "RenderDebugInterface.h" +#include "ApexPreview.h" +#include "EmitterGeomCylinderParams.h" + +namespace nvidia +{ +namespace emitter +{ + + + +EmitterGeomCylinderImpl::EmitterGeomCylinderImpl(NvParameterized::Interface* params) +{ + NvParameterized::Handle eh(*params); + const NvParameterized::Definition* paramDef; + const char* enumStr = 0; + + mGeomParams = (EmitterGeomCylinderParams*)params; + mRadius = &(mGeomParams->parameters().radius); + mHeight = &(mGeomParams->parameters().height); + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + mGeomParams->getParamEnum(eh, enumStr); + paramDef = eh.parameterDefinition(); + + mType = EmitterType::ET_RATE; + for (int i = 0; i < paramDef->numEnumVals(); ++i) + { + if (!nvidia::strcmp(paramDef->enumVal(i), enumStr)) + { + mType = (EmitterType::Enum)i; + break; + } + } +} + +EmitterGeom* EmitterGeomCylinderImpl::getEmitterGeom() +{ + return this; +} + + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomCylinderImpl::visualize(const PxTransform& , RenderDebugInterface&) +{ +} +#else +void EmitterGeomCylinderImpl::visualize(const PxTransform& pose, RenderDebugInterface& renderDebug) +{ + PxVec3 p0, p1; + p0 = PxVec3(0.0f, -*mHeight / 2.0f, 0.0f); + p1 = PxVec3(0.0f, *mHeight / 2.0f, 0.0f); + + p0 = pose.transform(p0); + p1 = pose.transform(p1); + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::DarkGreen)); + + RENDER_DEBUG_IFACE(&renderDebug)->debugCylinder(p0, p1, *mRadius); + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +} +#endif + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomCylinderImpl::drawPreview(float , RenderDebugInterface*) const +{ +} +#else +void EmitterGeomCylinderImpl::drawPreview(float scale, RenderDebugInterface* renderDebug) const +{ + PxVec3 p0, p1; + // where should we put this thing??? + p0 = PxVec3(0.0f, -*mHeight / 2.0f, 0.0f); + p1 = PxVec3(0.0f, *mHeight / 2.0f, 0.0f); + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen), + RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen)); + + RENDER_DEBUG_IFACE(renderDebug)->debugCylinder(p0, p1, *mRadius * scale); + RENDER_DEBUG_IFACE(renderDebug)->popRenderState(); +} +#endif + +void EmitterGeomCylinderImpl::setEmitterType(EmitterType::Enum t) +{ + mType = t; + + NvParameterized::Handle eh(*mGeomParams); + const NvParameterized::Definition* paramDef; + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + paramDef = eh.parameterDefinition(); + + mGeomParams->setParamEnum(eh, paramDef->enumVal((int)mType)); +} + +float EmitterGeomCylinderImpl::computeEmitterVolume() const +{ + return (*mHeight) * (*mRadius) * (*mRadius) * PxPi; +} + + +PxVec3 EmitterGeomCylinderImpl::randomPosInFullVolume(const PxMat44& pose, QDSRand& rand) const +{ + PxVec3 pos; + + float u, v, w; + do + { + u = rand.getNext(); + w = rand.getNext(); + } + while (u * u + w * w > 1.0f); + + v = *mHeight / 2 * rand.getNext(); + + pos = PxVec3(u * (*mRadius), v, w * (*mRadius)); + +#if _DEBUG + PxMat44 tmpPose(PxIdentity); + PX_ASSERT(isInEmitter(pos, tmpPose)); +#endif + + return pose.transform(pos); +} + + +bool EmitterGeomCylinderImpl::isInEmitter(const PxVec3& pos, const PxMat44& pose) const +{ + PxVec3 localPos = pose.inverseRT().transform(pos); + + if (localPos.x < -*mRadius) + { + return false; + } + if (localPos.x > *mRadius) + { + return false; + } + if (localPos.y < -*mHeight / 2.0f) + { + return false; + } + if (localPos.y > *mHeight / 2.0f) + { + return false; + } + if (localPos.z < -*mRadius) + { + return false; + } + if (localPos.z > *mRadius) + { + return false; + } + + return true; +} + + +void EmitterGeomCylinderImpl::computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform& pose, + const PxVec3& scale, + float objRadius, + PxBounds3& outBounds, + QDSRand&) const +{ + // we're not doing anything with the velocities array + PX_UNUSED(velocities); + PX_UNUSED(scale); + + float halfHeight = *mHeight / 2; + + uint32_t numX = (uint32_t)PxFloor(*mRadius / objRadius); + numX -= numX % 2; + uint32_t numY = (uint32_t)PxFloor(halfHeight / objRadius); + numY -= numY % 2; + uint32_t numZ = (uint32_t)PxFloor(*mRadius / objRadius); + numZ -= numZ % 2; + + for (float x = -(numX * objRadius); x <= *mRadius - objRadius; x += 2 * objRadius) + { + for (float y = -(numY * objRadius); y <= halfHeight - objRadius; y += 2 * objRadius) + { + for (float z = -(numZ * objRadius); z <= *mRadius - objRadius; z += 2 * objRadius) + { + if (x * x + z * z < (*mRadius - objRadius) * (*mRadius - objRadius)) + { + positions.pushBack(pose.transform(PxVec3(x, y, z))); + outBounds.include(positions.back()); + } + } + } + } +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterGeomExplicitImpl.cpp b/APEX_1.4/module/emitter/src/EmitterGeomExplicitImpl.cpp new file mode 100644 index 00000000..ed63cc79 --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterGeomExplicitImpl.cpp @@ -0,0 +1,830 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ApexUsingNamespace.h" +#include "PsSort.h" +#include "PsMathUtils.h" +#include "PsHashSet.h" +#include "EmitterAsset.h" +#include "EmitterGeomExplicitImpl.h" +//#include "ApexSharedSerialization.h" +#include "RenderDebugInterface.h" +#include "RenderDebugInterface.h" +#include "ApexPreview.h" +#include "EmitterGeomExplicitParams.h" +#include "ParamArray.h" + +namespace nvidia +{ +namespace emitter +{ + +PX_INLINE static void GetNormals(const PxVec3& n, PxVec3& t1, PxVec3& t2) +{ + PxVec3 nabs(PxAbs(n.x), PxAbs(n.y), PxAbs(n.z)); + + t1 = nabs.x <= nabs.y && nabs.x <= nabs.z + ? PxVec3(0, -n.z, n.y) + : nabs.y <= nabs.x && nabs.y <= nabs.z ? PxVec3(-n.z, 0, n.x) + : PxVec3(-n.y, n.x, 0); + t1.normalize(); + + t2 = n.cross(t1); + t2.normalize(); +} + +EmitterGeomExplicitImpl::EmitterGeomExplicitImpl(NvParameterized::Interface* params) +{ + mGeomParams = (EmitterGeomExplicitParams*)params; + + mDistance = mGeomParams->distance; + if (mDistance < PX_EPS_F32) + { + mInvDistance = PX_MAX_F32; + } + else + { + mInvDistance = 1 / mDistance; + } + + // get points + mPoints.resize((uint32_t)mGeomParams->points.positions.arraySizes[0]); + if (!mPoints.empty()) + { + PX_COMPILE_TIME_ASSERT(sizeof(PointParams) == sizeof(mGeomParams->points.positions.buf[0])); + memcpy(&mPoints[0], mGeomParams->points.positions.buf, mPoints.size() * sizeof(PointParams)); + } + + // get point velocities + for (uint32_t i = 0; i < (uint32_t)mGeomParams->points.velocities.arraySizes[0]; i++) + { + mVelocities.pushBack(mGeomParams->points.velocities.buf[i]); + } + + // get spheres + mSpheres.resize((uint32_t)mGeomParams->spheres.positions.arraySizes[0]); + if (!mSpheres.empty()) + { + PX_COMPILE_TIME_ASSERT(sizeof(SphereParams) == sizeof(mGeomParams->spheres.positions.buf[0])); + memcpy(&mSpheres[0], mGeomParams->spheres.positions.buf, mSpheres.size() * sizeof(SphereParams)); + } + + // get sphere velocities + for (int32_t i = 0; i < mGeomParams->spheres.velocities.arraySizes[0]; i++) + { + mSphereVelocities.pushBack(mGeomParams->spheres.velocities.buf[i]); + } + + // get ellipsoids + mEllipsoids.resize((uint32_t)mGeomParams->ellipsoids.positions.arraySizes[0]); + if (!mEllipsoids.empty()) + { + PX_COMPILE_TIME_ASSERT(sizeof(EllipsoidParams) == sizeof(mGeomParams->ellipsoids.positions.buf[0])); + memcpy(&mEllipsoids[0], mGeomParams->ellipsoids.positions.buf, mEllipsoids.size() * sizeof(EllipsoidParams)); + } + + // get ellipsoid velocities + for (int32_t i = 0; i < mGeomParams->ellipsoids.velocities.arraySizes[0]; i++) + { + mEllipsoidVelocities.pushBack(mGeomParams->ellipsoids.velocities.buf[i]); + } + + updateCollisions(); +} + +EmitterGeomExplicitImpl::EmitterGeomExplicitImpl() : + mDistance(0.0f), + mInvDistance(PX_MAX_F32), + mGeomParams(NULL) +{} + +EmitterGeom* EmitterGeomExplicitImpl::getEmitterGeom() +{ + return this; +} + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomExplicitImpl::visualize(const PxTransform& , RenderDebugInterface&) +{ +} +#else +void EmitterGeomExplicitImpl::visualize(const PxTransform& pose, RenderDebugInterface& renderDebug) +{ + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::DarkGreen)); + + RENDER_DEBUG_IFACE(&renderDebug)->setPose(pose); + + PxVec3 pos; + for (uint32_t i = 0; i < mPoints.size(); ++i) + { + RENDER_DEBUG_IFACE(&renderDebug)->debugPoint(pos, 0.01f); + } + + for (uint32_t i = 0; i < mSpheres.size(); ++i) + { + RENDER_DEBUG_IFACE(&renderDebug)->debugSphere(mSpheres[i].center, mSpheres[i].radius); + } + + for (uint32_t i = 0; i < mEllipsoids.size(); ++i) + { + PxVec3 n = mEllipsoids[i].normal, t1, t2; + GetNormals(n, t1, t2); + + PxMat44 unitSphereToEllipsoid( + mEllipsoids[i].radius * t1, + mEllipsoids[i].radius * t2, + mEllipsoids[i].polarRadius * n, + mEllipsoids[i].center + ); + + RENDER_DEBUG_IFACE(&renderDebug)->setPose(pose * PxTransform(unitSphereToEllipsoid)); + + RENDER_DEBUG_IFACE(&renderDebug)->debugSphere(PxVec3(0.0f), 1.0f); + } + + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +} +#endif + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomExplicitImpl::drawPreview(float , RenderDebugInterface*) const +{ +} +#else +void EmitterGeomExplicitImpl::drawPreview(float scale, RenderDebugInterface* renderDebug) const +{ + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen), + RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen)); + + PxVec3 pos; + for (uint32_t i = 0 ; i < mPoints.size() ; i++) + { + pos = mPoints[i].position; + RENDER_DEBUG_IFACE(renderDebug)->debugPoint(pos, scale); + } + + for (uint32_t i = 0; i < mSpheres.size(); ++i) + { + RENDER_DEBUG_IFACE(renderDebug)->debugSphere(mSpheres[i].center, mSpheres[i].radius * scale); + } + + for (uint32_t i = 0; i < mEllipsoids.size(); ++i) + { + PxVec3 n = mEllipsoids[i].normal, t1, t2; + GetNormals(n, t1, t2); + + PxMat44 unitSphereToEllipsoid( + mEllipsoids[i].radius * t1, + mEllipsoids[i].radius * t2, + mEllipsoids[i].polarRadius * n, + mEllipsoids[i].center + ); + + RENDER_DEBUG_IFACE(renderDebug)->setPose(unitSphereToEllipsoid); + + RENDER_DEBUG_IFACE(renderDebug)->debugSphere(PxVec3(0.0f), scale); + } + + RENDER_DEBUG_IFACE(renderDebug)->popRenderState(); +} +#endif + +/* ApexEmitterActor callable methods */ + +void EmitterGeomExplicitImpl::updateAssetPoints() +{ + if (!mGeomParams) + { + return; + } + + // just copy the position and velocity lists to mGeomParams + + NvParameterized::Handle h(*mGeomParams); + NvParameterized::ErrorType pError; + + // Update positions + + pError = mGeomParams->getParameterHandle("points.positions", h); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + pError = h.resizeArray((int32_t)mPoints.size()); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + PX_COMPILE_TIME_ASSERT(sizeof(PointParams) == sizeof(mGeomParams->points.positions.buf[0])); + memcpy(&mGeomParams->points.positions.buf[0], &mPoints[0], mPoints.size()); + + // velocities may or may not exist, handle this + pError = mGeomParams->getParameterHandle("velocities", h); + if (pError == NvParameterized::ERROR_NONE) + { + pError = mGeomParams->resizeArray(h, (int32_t)mVelocities.size()); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + pError = h.setParamVec3Array(&mVelocities[0], (int32_t)mVelocities.size()); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + } +} + +void EmitterGeomExplicitImpl::addParticleList( + uint32_t count, + const PointParams* params, + const PxVec3* velocities) +{ + if (velocities) + { + mVelocities.resize(mPoints.size(), PxVec3(0.0f)); + } + + for (uint32_t i = 0 ; i < count ; i++) + { + mPoints.pushBack(*params++); + + if (velocities) + { + mVelocities.pushBack(*velocities++); + } + } + + updateCollisions(); + updateAssetPoints(); +} + +void EmitterGeomExplicitImpl::addParticleList(uint32_t count, + const PxVec3* positions, + const PxVec3* velocities) +{ + if (velocities) + { + mVelocities.resize(mPoints.size(), PxVec3(0.0f)); + } + + for (uint32_t i = 0 ; i < count ; i++) + { + PointParams params = { positions[i], false }; + mPoints.pushBack(params); + + if (velocities) + { + mVelocities.pushBack(velocities[i]); + } + } + + updateCollisions(); + updateAssetPoints(); +} + +void EmitterGeomExplicitImpl::addParticleList(uint32_t count, + const PointListData& data) +{ + if (data.velocityStart != NULL) + { + mVelocities.resize(mPoints.size(), PxVec3(0.0f)); + } + if (data.userDataStart != NULL) + { + mPointsUserData.resize(mPoints.size(), 0); + } + + const uint8_t* positionCurr = static_cast<const uint8_t*>(data.positionStart); + const uint8_t* velocityCurr = static_cast<const uint8_t*>(data.velocityStart); + const uint8_t* userDataCurr = static_cast<const uint8_t*>(data.userDataStart); + + for (uint32_t i = 0 ; i < count ; i++) + { + const PxVec3& position = *reinterpret_cast<const PxVec3*>(positionCurr); + positionCurr += data.positionStrideBytes; + + PointParams params = { position, false }; + mPoints.pushBack(params); + + if (velocityCurr != NULL) + { + const PxVec3& velocity = *reinterpret_cast<const PxVec3*>(velocityCurr); + velocityCurr += data.velocityStrideBytes; + + mVelocities.pushBack(velocity); + } + if (userDataCurr != NULL) + { + const uint32_t userData = *reinterpret_cast<const uint32_t*>(userDataCurr); + userDataCurr += data.userDataStrideBytes; + + mPointsUserData.pushBack(userData); + } + } + + updateCollisions(); + updateAssetPoints(); +} + +void EmitterGeomExplicitImpl::addSphereList( + uint32_t count, + const SphereParams* params, + const PxVec3* velocities) +{ + if (velocities) + { + mSphereVelocities.resize(mSpheres.size(), PxVec3(0.0f)); + } + + for (uint32_t i = 0 ; i < count ; i++) + { + mSpheres.pushBack(*params++); + + if (velocities) + { + mSphereVelocities.pushBack(*velocities++); + } + } + + updateCollisions(); + + // just copy the position and velocity lists to mGeomParams + if (!mGeomParams) + { + return; + } + + NvParameterized::Handle h(*mGeomParams); + NvParameterized::ErrorType pError; + + // Update positions + + pError = mGeomParams->getParameterHandle("spheres.positions", h); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + pError = h.resizeArray((int32_t)mSpheres.size()); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + PX_COMPILE_TIME_ASSERT(sizeof(SphereParams) == sizeof(mGeomParams->spheres.positions.buf[0])); + memcpy(mGeomParams->spheres.positions.buf, &mSpheres[0], mSpheres.size() * sizeof(SphereParams)); + + // velocities may or may not exist, handle this + pError = mGeomParams->getParameterHandle("spheres.velocities", h); + if (pError == NvParameterized::ERROR_NONE) + { + pError = mGeomParams->resizeArray(h, (int32_t)mSphereVelocities.size()); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + h.setParamVec3Array(&mSphereVelocities[0], (int32_t)mSphereVelocities.size()); + } +} + +void EmitterGeomExplicitImpl::addEllipsoidList( + uint32_t count, + const EllipsoidParams* params, + const PxVec3* velocities) +{ + if (velocities) + { + mEllipsoidVelocities.resize(mEllipsoids.size(), PxVec3(0.0f)); + } + + for (uint32_t i = 0 ; i < count ; i++) + { + mEllipsoids.pushBack(*params++); + + if (velocities) + { + mEllipsoidVelocities.pushBack(*velocities++); + } + } + + updateCollisions(); + + // just copy the position and velocity lists to mGeomParams + if (!mGeomParams) + { + return; + } + + NvParameterized::Handle h(*mGeomParams); + NvParameterized::ErrorType pError; + + // Update positions + + pError = mGeomParams->getParameterHandle("ellipsoids.positions", h); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + pError = h.resizeArray((int32_t)mEllipsoids.size()); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + PX_COMPILE_TIME_ASSERT(sizeof(EllipsoidParams) == sizeof(mGeomParams->ellipsoids.positions.buf[0])); + memcpy(mGeomParams->ellipsoids.positions.buf, &mEllipsoids[0], mEllipsoids.size() * sizeof(EllipsoidParams)); + + // velocities may or may not exist, handle this + pError = mGeomParams->getParameterHandle("ellipsoids.velocities", h); + if (pError == NvParameterized::ERROR_NONE) + { + pError = mGeomParams->resizeArray(h, (int32_t)mEllipsoidVelocities.size()); + PX_ASSERT(pError == NvParameterized::ERROR_NONE); + + h.setParamVec3Array(&mEllipsoidVelocities[0], (int32_t)mEllipsoidVelocities.size()); + } +} + +void EmitterGeomExplicitImpl::getParticleList( + const PointParams* ¶ms, + uint32_t& numPoints, + const PxVec3* &velocities, + uint32_t& numVelocities) const +{ + numPoints = mPoints.size(); + params = numPoints ? &mPoints[0] : 0; + + numVelocities = mVelocities.size(); + velocities = numVelocities ? &mVelocities[0] : 0; +} + +void EmitterGeomExplicitImpl::getSphereList( + const SphereParams* ¶ms, + uint32_t& numSpheres, + const PxVec3* &velocities, + uint32_t& numVelocities) const +{ + numSpheres = mSpheres.size(); + params = numSpheres ? &mSpheres[0] : 0; + + numVelocities = mSphereVelocities.size(); + velocities = numVelocities ? &mSphereVelocities[0] : 0; +} + +void EmitterGeomExplicitImpl::getEllipsoidList( + const EllipsoidParams* ¶ms, + uint32_t& numEllipsoids, + const PxVec3* &velocities, + uint32_t& numVelocities) const +{ + numEllipsoids = mEllipsoids.size(); + params = numEllipsoids ? &mEllipsoids[0] : 0; + + numVelocities = mSphereVelocities.size(); + velocities = numVelocities ? &mSphereVelocities[0] : 0; +} + +#define EPS 0.001f + +bool EmitterGeomExplicitImpl::isInside(const PxVec3& x, uint32_t shapeIdx) const +{ + if (!mBboxes[shapeIdx].contains(x)) + { + return false; + } + + uint32_t nspheres = mSpheres.size(), + nellipsoids = mEllipsoids.size(); + + if (shapeIdx < nspheres) // Sphere + { + const SphereParams& sphere = mSpheres[shapeIdx]; + return PxAbs((x - sphere.center).magnitudeSquared() - sphere.radius * sphere.radius) < EPS; + } + else if (shapeIdx < nspheres + nellipsoids) // Ellipsoid + { + const EllipsoidParams& ellipsoid = mEllipsoids[shapeIdx - nspheres]; + + PxVec3 y(x - ellipsoid.center); + + PxVec3 n(ellipsoid.normal); + n.normalize(); + + float normalProj = y.dot(n); + + PxVec3 planeProj = y - normalProj * n; + float planeProjMag2 = planeProj.magnitudeSquared(); + + float R2 = ellipsoid.radius * ellipsoid.radius, + Rp2 = ellipsoid.polarRadius * ellipsoid.polarRadius; + + if (planeProjMag2 > R2 + EPS) + { + return false; + } + + return normalProj * normalProj < EPS + Rp2 * (1.0f - 1.0f / R2 * planeProjMag2); + } + else // Point + { + return (x - mPoints[shapeIdx - nspheres - nellipsoids].position).magnitudeSquared() < EPS; + } +} + +void EmitterGeomExplicitImpl::AddParticle( + physx::Array<PxVec3>& positions, physx::Array<PxVec3>& velocities, + physx::Array<uint32_t>* userDataArrayPtr, + const PxTransform& pose, float cutoff, PxBounds3& outBounds, + const PxVec3& pos, const PxVec3& vel, uint32_t userData, + uint32_t srcShapeIdx, + QDSRand& rand) const +{ + float r = rand.getScaled(0, 1); + if (r > cutoff) + { + return; + } + + PxVec3 randPos = pos + PxVec3( + rand.getScaled(-mDistance, mDistance), + rand.getScaled(-mDistance, mDistance), + rand.getScaled(-mDistance, mDistance)); + + // Check collisions + for (uint32_t i = 0; i < mCollisions[srcShapeIdx].next; ++i) + { + uint32_t collisionShapeIdx = mCollisions[srcShapeIdx].shapeIndices[i]; + + // If colliding body was already processed and point lies in this body + if (collisionShapeIdx < srcShapeIdx && isInside(pos, collisionShapeIdx)) + { + return; + } + } + + /* if absolute positions are submitted, pose will be at origin */ + if (pose == PxTransform(PxIdentity)) + { + positions.pushBack(randPos); + velocities.pushBack(vel); + } + else + { + positions.pushBack(pose.transform(randPos)); + velocities.pushBack(pose.rotate(vel)); + } + + if (userDataArrayPtr) + { + userDataArrayPtr->pushBack(userData); + } + + outBounds.include(positions.back()); +} + +void EmitterGeomExplicitImpl::computeFillPositions( + physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + physx::Array<uint32_t>* userDataArrayPtr, + const PxTransform& pose, + const PxVec3& scale, + float density, + PxBounds3& outBounds, + QDSRand& rand) const +{ + PX_UNUSED(scale); + uint32_t shapeIdx = 0; // Global shape index + + for (uint32_t i = 0; i < mPoints.size(); ++i, ++shapeIdx) + { + const uint32_t pointUserData = i < mPointsUserData.size() ? mPointsUserData[i] : 0; + + AddParticle( + positions, velocities, userDataArrayPtr, + pose, density, outBounds, + mPoints[i].position, i >= mVelocities.size() ? PxVec3(0.0f) : mVelocities[i], pointUserData, + shapeIdx, + rand + ); + } + + for (uint32_t i = 0; i < mSpheres.size(); ++i, ++shapeIdx) + { + PxVec3 c = mSpheres[i].center; + float R = mSpheres[i].radius; + + const uint32_t sphereUserData = 0; + + float RR = R * R; + + int32_t nx = (int32_t)(R * mInvDistance); + + for (int32_t j = -nx; j < nx; ++j) + { + float x = j * mDistance, + xx = x * x; + + float yext = PxSqrt(PxMax(0.0f, RR - xx)); + int32_t ny = (int32_t)(yext * mInvDistance); + + for (int32_t k = -ny; k < ny; ++k) + { + float y = k * mDistance; + + float zext = PxSqrt(PxMax(0.0f, RR - xx - y * y)); + int32_t nz = (int32_t)(zext * mInvDistance); + + for (int32_t l = -nz; l < nz; ++l) + { + float z = l * mDistance; + + AddParticle( + positions, velocities, userDataArrayPtr, + pose, density, outBounds, + c + PxVec3(x, y, z), + i >= mSphereVelocities.size() ? PxVec3(0.0f) : mSphereVelocities[i], sphereUserData, + shapeIdx, + rand + ); + } //l + } //k + } //j + } //i + + for (uint32_t i = 0; i < mEllipsoids.size(); ++i, ++shapeIdx) + { + PxVec3 c = mEllipsoids[i].center, + n = mEllipsoids[i].normal; + + const uint32_t ellipsoidUserData = 0; + + // TODO: precompute this stuff? + + float R = mEllipsoids[i].radius, + Rp = mEllipsoids[i].polarRadius; + + PxVec3 t1, t2; + GetNormals(n, t1, t2); + + float RR = R * R, + Rp_R = PxAbs(Rp / R); + + int32_t nx = (int32_t)(R * mInvDistance); + for (int32_t j = -nx; j <= nx ; ++j) + { + float x = j * mDistance, + xx = x * x; + + float yext = PxSqrt(PxMax(0.0f, RR - xx)); + int32_t ny = (int32_t)(yext * mInvDistance); + + for (int32_t k = -ny; k <= ny; ++k) + { + float y = k * mDistance; + + float zext = Rp_R * PxSqrt(PxMax(0.0f, RR - xx - y * y)); + int32_t nz = (int32_t)(zext * mInvDistance); + + int32_t lmax = Rp < 0 ? 0 : nz; // Check for half-ellipsoid + for (int32_t l = -nz; l <= lmax; ++l) + { + float z = l * mDistance; + + AddParticle( + positions, velocities, userDataArrayPtr, + pose, density, outBounds, + c + x * t1 + y * t2 + z * n, + i >= mEllipsoidVelocities.size() ? PxVec3(0.0f) : mEllipsoidVelocities[i], ellipsoidUserData, + shapeIdx, + rand + ); + } //l + } //k + } //j + } //i +} + +struct EndPoint +{ + float val; + + uint32_t boxIdx; + bool isLeftPoint; + + EndPoint(float v, uint32_t idx, bool left) + : val(v), boxIdx(idx), isLeftPoint(left) {} + + PX_INLINE static bool isLessThan(const EndPoint& p1, const EndPoint& p2) + { + if (p1.val < p2.val) + { + return true; + } + + // Adjacent shapes do intersect + if (p1.val == p2.val) + { + return p1.isLeftPoint && !p2.isLeftPoint; + } + + return false; + } +}; + +void EmitterGeomExplicitImpl::updateCollisions() +{ + uint32_t npoints = mPoints.size(), + nspheres = mSpheres.size(), + nellipsoids = mEllipsoids.size(); + + mCollisions.reset(); + + uint32_t ntotal = npoints + nspheres + nellipsoids; + if (!ntotal) + { + return; + } + + mBboxes.resize(ntotal); + mCollisions.resize(ntotal); + + physx::Array<bool> doDetectOverlaps(ntotal); + + // TODO: use custom axis instead of Ox + // E.g. (sx, sy, sz) or simply choose the best of Ox, Oy, Oz + + for (uint32_t i = 0; i < nspheres; ++i) + { + PxVec3 r3(mSpheres[i].radius); + + mBboxes[i] = PxBounds3(mSpheres[i].center - r3, mSpheres[i].center + r3); + doDetectOverlaps[i] = mSpheres[i].doDetectOverlaps; + } + + for (uint32_t i = 0; i < nellipsoids; ++i) + { + PxVec3 r3(mEllipsoids[i].radius, mEllipsoids[i].radius, mEllipsoids[i].polarRadius); + PxBounds3 localBox(-r3, r3); + + PxVec3 n = mEllipsoids[i].normal; + n.normalize(); + + PxMat33 T = physx::shdfnd::rotFrom2Vectors(PxVec3(0, 0, 1), n); + + if(!localBox.isValid()) + { + localBox.setEmpty(); + } + + localBox = PxBounds3::transformFast(T, localBox); + localBox.minimum += mEllipsoids[i].center; + localBox.maximum += mEllipsoids[i].center; + + mBboxes[nspheres + i] = localBox; + doDetectOverlaps[nspheres + i] = mEllipsoids[i].doDetectOverlaps; + } + + for (uint32_t i = 0; i < npoints; ++i) + { + mBboxes[nspheres + nellipsoids + i] = PxBounds3(mPoints[i].position, mPoints[i].position); + doDetectOverlaps[nspheres + nellipsoids + i] = mPoints[i].doDetectOverlaps; + } + + physx::Array<EndPoint> endPoints; + endPoints.reserve(2 * ntotal); + for (uint32_t i = 0; i < ntotal; ++i) + { + endPoints.pushBack(EndPoint(mBboxes[i].minimum.x, i, true)); + endPoints.pushBack(EndPoint(mBboxes[i].maximum.x, i, false)); + } + + nvidia::sort(&endPoints[0], endPoints.size(), EndPoint::isLessThan); + + nvidia::HashSet<uint32_t> openedBoxes; + for (uint32_t i = 0; i < endPoints.size(); ++i) + { + uint32_t boxIdx = endPoints[i].boxIdx; + + if (endPoints[i].isLeftPoint) + { + for (nvidia::HashSet<uint32_t>::Iterator j = openedBoxes.getIterator(); !j.done(); ++j) + { + if (!doDetectOverlaps[boxIdx] || !doDetectOverlaps[*j]) + { + break; + } + + if (!mBboxes[*j].intersects(mBboxes[boxIdx])) + { + continue; + } + + mCollisions[boxIdx].pushBack(*j); + mCollisions[*j].pushBack(boxIdx); + } //j + + openedBoxes.insert(boxIdx); + } + else + { + PX_ASSERT(openedBoxes.contains(boxIdx)); + openedBoxes.erase(boxIdx); + } + } //i +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterGeomSphereImpl.cpp b/APEX_1.4/module/emitter/src/EmitterGeomSphereImpl.cpp new file mode 100644 index 00000000..3aaa9cf8 --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterGeomSphereImpl.cpp @@ -0,0 +1,262 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ApexUsingNamespace.h" +#include "EmitterGeomSphereImpl.h" +//#include "ApexSharedSerialization.h" +#include "RenderDebugInterface.h" +#include "RenderDebugInterface.h" +#include "ApexPreview.h" +#include "EmitterGeomSphereParams.h" + +namespace nvidia +{ +namespace emitter +{ + + + +EmitterGeomSphereImpl::EmitterGeomSphereImpl(NvParameterized::Interface* params) +{ + NvParameterized::Handle eh(*params); + const NvParameterized::Definition* paramDef; + const char* enumStr = 0; + + mGeomParams = (EmitterGeomSphereParams*)params; + mRadius = &(mGeomParams->parameters().radius); + mHemisphere = &(mGeomParams->parameters().hemisphere); + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + mGeomParams->getParamEnum(eh, enumStr); + paramDef = eh.parameterDefinition(); + + mType = EmitterType::ET_RATE; + for (int i = 0; i < paramDef->numEnumVals(); ++i) + { + if (!nvidia::strcmp(paramDef->enumVal(i), enumStr)) + { + mType = (EmitterType::Enum)i; + break; + } + } +} + +EmitterGeom* EmitterGeomSphereImpl::getEmitterGeom() +{ + return this; +} + + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomSphereImpl::visualize(const PxTransform& , RenderDebugInterface&) +{ +} +#else +void EmitterGeomSphereImpl::visualize(const PxTransform& pose, RenderDebugInterface& renderDebug) +{ + const float radius = *mRadius; + const float radiusSquared = radius * radius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -radius + 2 * radius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(&renderDebug)->setPose(pose); + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::DarkGreen)); + RENDER_DEBUG_IFACE(&renderDebug)->debugSphere(PxVec3(0.0f), *mRadius); + if(hemisphere > 0.0f) + { + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::DarkPurple)); + PxMat44 circlePose = PxMat44(PxIdentity); + circlePose.setPosition(PxVec3(0.0f, sphereCapBaseHeight, 0.0f)); + RENDER_DEBUG_IFACE(&renderDebug)->setPose(circlePose); + RENDER_DEBUG_IFACE(&renderDebug)->debugCircle(PxVec3(0.0f), sphereCapBaseRadius, 3); + RENDER_DEBUG_IFACE(&renderDebug)->debugLine(PxVec3(0.0f), PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + for(float t = 0.0f; t < 2 * PxPi; t += PxPi / 3) + { + PxVec3 offset(PxSin(t) * sphereCapBaseRadius, 0.0f, PxCos(t) * sphereCapBaseRadius); + RENDER_DEBUG_IFACE(&renderDebug)->debugLine(offset, PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + } + RENDER_DEBUG_IFACE(&renderDebug)->setPose(PxIdentity); + } + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +} +#endif + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomSphereImpl::drawPreview(float , RenderDebugInterface*) const +{ +} +#else +void EmitterGeomSphereImpl::drawPreview(float scale, RenderDebugInterface* renderDebug) const +{ + const float radius = *mRadius; + const float radiusSquared = radius * radius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -radius + 2 * radius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen), + RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen)); + RENDER_DEBUG_IFACE(renderDebug)->debugSphere(PxVec3(0.0f), *mRadius * scale); + if(hemisphere > 0.0f) + { + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkPurple)); + PxMat44 circlePose = PxMat44(PxIdentity); + circlePose.setPosition(PxVec3(0.0f, sphereCapBaseHeight, 0.0f)); + RENDER_DEBUG_IFACE(renderDebug)->setPose(circlePose); + RENDER_DEBUG_IFACE(renderDebug)->debugCircle(PxVec3(0.0f), sphereCapBaseRadius, 3); + RENDER_DEBUG_IFACE(renderDebug)->debugLine(PxVec3(0.0f), PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + for(float t = 0.0f; t < 2 * PxPi; t += PxPi / 3) + { + PxVec3 offset(PxSin(t) * sphereCapBaseRadius, 0.0f, PxCos(t) * sphereCapBaseRadius); + RENDER_DEBUG_IFACE(renderDebug)->debugLine(offset, PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + } + RENDER_DEBUG_IFACE(renderDebug)->setPose(PxIdentity); + } + RENDER_DEBUG_IFACE(renderDebug)->popRenderState(); +} +#endif + +void EmitterGeomSphereImpl::setEmitterType(EmitterType::Enum t) +{ + mType = t; + + NvParameterized::Handle eh(*mGeomParams); + const NvParameterized::Definition* paramDef; + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + paramDef = eh.parameterDefinition(); + + mGeomParams->setParamEnum(eh, paramDef->enumVal((int)mType)); +} + +float EmitterGeomSphereImpl::computeEmitterVolume() const +{ + PX_ASSERT(*mHemisphere >= 0.0f); + PX_ASSERT(*mHemisphere <= 1.0f); + float radius = *mRadius; + float hemisphere = 2 * radius * (*mHemisphere); + bool moreThanHalf = true; + if (hemisphere > radius) + { + hemisphere -= radius; + moreThanHalf = false; + } + const float halfSphereVolume = 2.0f / 3.0f * PxPi * radius * radius * radius; + const float sphereCapVolume = 1.0f / 3.0f * PxPi * hemisphere * hemisphere * (3 * radius - hemisphere); + if (moreThanHalf) + { + return halfSphereVolume + sphereCapVolume; + } + else + { + return sphereCapVolume; + } +} + +PxVec3 EmitterGeomSphereImpl::randomPosInFullVolume(const PxMat44& pose, QDSRand& rand) const +{ + PX_ASSERT(*mHemisphere >= 0.0f); + PX_ASSERT(*mHemisphere <= 1.0f); + + const float radius = *mRadius; + const float radiusSquared = radius * radius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -radius + 2 * radius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + const float horizontalExtents = hemisphere < 0.5f ? radius : sphereCapBaseRadius; + /* bounding box for a sphere cap */ + const PxBounds3 boundingBox(PxVec3(-horizontalExtents, sphereCapBaseHeight, -horizontalExtents), + PxVec3(horizontalExtents, radius, horizontalExtents)); + + PxVec3 pos; + do + { + pos = rand.getScaled(boundingBox.minimum, boundingBox.maximum); + } + while (pos.magnitudeSquared() > radiusSquared); + + return pose.transform(pos); +} + + +bool EmitterGeomSphereImpl::isInEmitter(const PxVec3& pos, const PxMat44& pose) const +{ + const PxVec3 localPos = pose.inverseRT().transform(pos); + const float radius = *mRadius; + const float radiusSquared = radius * radius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -radius + 2 * radius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + const float horizontalExtents = hemisphere < 0.5f ? radius : sphereCapBaseRadius; + /* bounding box for a sphere cap */ + const PxBounds3 boundingBox(PxVec3(-horizontalExtents, sphereCapBaseHeight, -horizontalExtents), + PxVec3(horizontalExtents, radius, horizontalExtents)); + + bool isInSphere = localPos.magnitudeSquared() <= radiusSquared; + bool isInBoundingBox = boundingBox.contains(localPos); + + return isInSphere & isInBoundingBox; +} + + +void EmitterGeomSphereImpl::computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform& pose, + const PxVec3& scale, + float objRadius, + PxBounds3& outBounds, + QDSRand&) const +{ + // we're not doing anything with the velocities array + PX_UNUSED(velocities); + PX_UNUSED(scale); + + const float radius = *mRadius; + const float radiusSquared = radius * radius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -radius + 2 * radius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + const float horizontalExtents = hemisphere < 0.5f ? radius : sphereCapBaseRadius; + + uint32_t numX = (uint32_t)PxFloor(horizontalExtents / objRadius); + numX -= numX % 2; + uint32_t numY = (uint32_t)PxFloor((radius - sphereCapBaseHeight) / objRadius); + numY -= numY % 2; + uint32_t numZ = (uint32_t)PxFloor(horizontalExtents / objRadius); + numZ -= numZ % 2; + + const float radiusMinusObjRadius = radius - objRadius; + const float radiusMinusObjRadiusSquared = radiusMinusObjRadius * radiusMinusObjRadius; + for (float x = -(numX * objRadius); x <= radiusMinusObjRadius; x += 2 * objRadius) + { + for (float y = sphereCapBaseHeight; y <= radiusMinusObjRadius; y += 2 * objRadius) + { + for (float z = -(numZ * objRadius); z <= radiusMinusObjRadius; z += 2 * objRadius) + { + const PxVec3 p(x, y, z); + if (p.magnitudeSquared() < radiusMinusObjRadiusSquared) + { + positions.pushBack(pose.transform(PxVec3(x, y, z))); + outBounds.include(positions.back()); + } + } + } + } +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterGeomSphereShellImpl.cpp b/APEX_1.4/module/emitter/src/EmitterGeomSphereShellImpl.cpp new file mode 100644 index 00000000..6c03060d --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterGeomSphereShellImpl.cpp @@ -0,0 +1,344 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ApexUsingNamespace.h" +#include "EmitterGeomSphereShellImpl.h" +//#include "ApexSharedSerialization.h" +#include "RenderDebugInterface.h" +#include "RenderDebugInterface.h" +#include "ApexPreview.h" +#include "EmitterGeomSphereShellParams.h" + +namespace nvidia +{ +namespace emitter +{ + + + +EmitterGeomSphereShellImpl::EmitterGeomSphereShellImpl(NvParameterized::Interface* params) +{ + NvParameterized::Handle eh(*params); + const NvParameterized::Definition* paramDef; + const char* enumStr = 0; + + mGeomParams = (EmitterGeomSphereShellParams*)params; + mRadius = &(mGeomParams->parameters().radius); + mShellThickness = &(mGeomParams->parameters().shellThickness); + mHemisphere = &(mGeomParams->parameters().hemisphere); + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + mGeomParams->getParamEnum(eh, enumStr); + paramDef = eh.parameterDefinition(); + + mType = EmitterType::ET_RATE; + for (int i = 0; i < paramDef->numEnumVals(); ++i) + { + if (!nvidia::strcmp(paramDef->enumVal(i), enumStr)) + { + mType = (EmitterType::Enum)i; + break; + } + } +} + +EmitterGeom* EmitterGeomSphereShellImpl::getEmitterGeom() +{ + return this; +} + + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomSphereShellImpl::visualize(const PxTransform& , RenderDebugInterface&) +{ +} +#else +void EmitterGeomSphereShellImpl::visualize(const PxTransform& pose, RenderDebugInterface& renderDebug) +{ + using RENDER_DEBUG::DebugColors; + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::DarkGreen)); + + // outer sphere + RENDER_DEBUG_IFACE(&renderDebug)->setPose(pose); + RENDER_DEBUG_IFACE(&renderDebug)->debugSphere(PxVec3(0.0f), *mRadius); + + // intter sphere + RENDER_DEBUG_IFACE(&renderDebug)->debugSphere(PxVec3(0.0f), *mRadius + *mShellThickness); + + const float radius = *mRadius + *mShellThickness; + const float radiusSquared = radius * radius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -radius + 2 * radius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + // cone depicting the hemisphere + if(hemisphere > 0.0f) + { + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::DarkPurple)); + PxMat44 circlePose = PxMat44(PxIdentity); + circlePose.setPosition(PxVec3(0.0f, sphereCapBaseHeight, 0.0f)); + RENDER_DEBUG_IFACE(&renderDebug)->setPose(circlePose); + RENDER_DEBUG_IFACE(&renderDebug)->debugCircle(PxVec3(0.0f), sphereCapBaseRadius, 3); + RENDER_DEBUG_IFACE(&renderDebug)->debugLine(circlePose.getPosition(), circlePose.getPosition() + PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + for(float t = 0.0f; t < 2 * PxPi; t += PxPi / 3) + { + PxVec3 offset(PxSin(t) * sphereCapBaseRadius, 0.0f, PxCos(t) * sphereCapBaseRadius); + RENDER_DEBUG_IFACE(&renderDebug)->debugLine(circlePose.getPosition() + offset, circlePose.getPosition() + PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + } + RENDER_DEBUG_IFACE(&renderDebug)->setPose(PxIdentity); + } + + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +} +#endif + + +#ifdef WITHOUT_DEBUG_VISUALIZE +void EmitterGeomSphereShellImpl::drawPreview(float , RenderDebugInterface*) const +{ +} +#else +void EmitterGeomSphereShellImpl::drawPreview(float scale, RenderDebugInterface* renderDebug) const +{ + using RENDER_DEBUG::DebugColors; + + RENDER_DEBUG_IFACE(renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::Yellow), + RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::Yellow)); + + RENDER_DEBUG_IFACE(renderDebug)->debugSphere(PxVec3(0.0f), *mRadius * scale); + + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen), + RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkGreen)); + + RENDER_DEBUG_IFACE(renderDebug)->debugSphere(PxVec3(0.0f), (*mRadius + *mShellThickness) * scale); + + const float radius = *mRadius + *mShellThickness; + const float radiusSquared = radius * radius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -radius + 2 * radius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + if(hemisphere > 0.0f) + { + RENDER_DEBUG_IFACE(renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(renderDebug)->getDebugColor(DebugColors::DarkPurple)); + PxMat44 circlePose = PxMat44(PxIdentity); + circlePose.setPosition(PxVec3(0.0f, sphereCapBaseHeight, 0.0f)); + RENDER_DEBUG_IFACE(renderDebug)->setPose(circlePose); + RENDER_DEBUG_IFACE(renderDebug)->debugCircle(PxVec3(0.0f), sphereCapBaseRadius, 3); + RENDER_DEBUG_IFACE(renderDebug)->debugLine(PxVec3(0.0f), PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + for(float t = 0.0f; t < 2 * PxPi; t += PxPi / 3) + { + PxVec3 offset(PxSin(t) * sphereCapBaseRadius, 0.0f, PxCos(t) * sphereCapBaseRadius); + RENDER_DEBUG_IFACE(renderDebug)->debugLine(offset, PxVec3(0.0f, radius - sphereCapBaseHeight, 0.0f)); + } + RENDER_DEBUG_IFACE(renderDebug)->setPose(PxIdentity); + } + RENDER_DEBUG_IFACE(renderDebug)->popRenderState(); +} +#endif + +void EmitterGeomSphereShellImpl::setEmitterType(EmitterType::Enum t) +{ + mType = t; + + NvParameterized::Handle eh(*mGeomParams); + const NvParameterized::Definition* paramDef; + + //error check + mGeomParams->getParameterHandle("emitterType", eh); + paramDef = eh.parameterDefinition(); + + mGeomParams->setParamEnum(eh, paramDef->enumVal((int)mType)); +} + +float EmitterGeomSphereShellImpl::computeEmitterVolume() const +{ + const float radius = *mRadius; + const float bigRadius = *mRadius + *mShellThickness; + float hemisphere = 2 * radius * (*mHemisphere); + float bigHemisphere = 2 * bigRadius * (*mHemisphere); + + bool moreThanHalf = true; + + if (hemisphere > radius) + { + hemisphere -= radius; + bigHemisphere -= bigRadius; + moreThanHalf = false; + } + + const float volumeBigSphere = 4.0f / 3.0f * PxPi * bigRadius * bigRadius * bigRadius; + const float volumeSmallSphere = 4.0f / 3.0f * PxPi * *mRadius * *mRadius * *mRadius; + const float halfSphereShellVolume = (volumeBigSphere - volumeSmallSphere) / 2.0f; + + const float bigCapVolume = 1.0f / 3.0f * PxPi * bigHemisphere * bigHemisphere * (3 * bigRadius - bigHemisphere); + const float smallCapVolume = 1.0f / 3.0f * PxPi * hemisphere * hemisphere * (3 * radius - hemisphere); + + const float sphereShellCapVolume = bigCapVolume - smallCapVolume; + + if (moreThanHalf) + { + return halfSphereShellVolume + sphereShellCapVolume; + } + else + { + return sphereShellCapVolume; + } +} + + +PxVec3 EmitterGeomSphereShellImpl::randomPosInFullVolume(const PxMat44& pose, QDSRand& rand) const +{ + float hemisphere = 2.0f * *mHemisphere - 1.0f; + + bool moreThanHalf = true; + + if (*mHemisphere > 0.5f) + { + moreThanHalf = false; + } + + // There are two cases here - 1-st for hemisphere cut above the center of the sphere + // and 2-nd for hemisphere cut below the center of the sphere. + // The reason for this is that in case very high hemisphere cut is set, so the area + // of the actual emitter is very small in compare to the whole sphere emitter, it would take too + // much time [on average] to generate suitable point using randomPointOnUnitSphere + // function, so in this case it is more efficient to use another method. + // in case we have at least half of the sphere shell present the randomPointOnUnitSphere should + // be sufficient. + PxVec3 pos; + if(!moreThanHalf) + { + // 1-st case : + // * generate random unit vector within a cone + // * clamp to big radius + const float sphereCapBaseHeight = -1.0f + 2 * (*mHemisphere); + const float phi = rand.getScaled(0.0f, PxTwoPi); + const float cos_theta = sphereCapBaseHeight; + const float z = rand.getScaled(cos_theta, 1.0f); + const float oneMinusZSquared = PxSqrt(1.0f - z * z); + pos = PxVec3(oneMinusZSquared * PxCos(phi), z, oneMinusZSquared * PxSin(phi)); + } + else + { + // 2-nd case : + // * get random pos on unit sphere, until its height is above hemisphere cut + do + { + pos = randomPointOnUnitSphere(rand); + } while(pos.y < hemisphere); + } + + // * add negative offset withing the thickness + // * solve edge case [for the 1-st case] - regenerate offset from the previous step + // in case point is below hemisphere cut + + PxVec3 tmp; + const float sphereCapBaseHeight = -(*mRadius + *mShellThickness) + 2 * (*mRadius + *mShellThickness) * (*mHemisphere); + do + { + float thickness = rand.getScaled(0, *mShellThickness); + tmp = pos * (*mRadius + *mShellThickness - thickness); + } while(tmp.y < sphereCapBaseHeight); + + pos = tmp; + pos += pose.getPosition(); + + return pos; +} + + +bool EmitterGeomSphereShellImpl::isInEmitter(const PxVec3& pos, const PxMat44& pose) const +{ + PxVec3 localPos = pose.inverseRT().transform(pos); + const float sphereCapBaseHeight = -(*mRadius + *mShellThickness) + 2 * (*mRadius + *mShellThickness) * (*mHemisphere); + float d2 = localPos.x * localPos.x + localPos.y * localPos.y + localPos.z * localPos.z; + bool isInBigSphere = d2 < (*mRadius + *mShellThickness) * (*mRadius + *mShellThickness); + bool isInSmallSphere = d2 < *mRadius * *mRadius; + bool higherThanHemisphereCut = pos.y > sphereCapBaseHeight; + return isInBigSphere && !isInSmallSphere && higherThanHemisphereCut; +} + + +void EmitterGeomSphereShellImpl::computeFillPositions(physx::Array<PxVec3>& positions, + physx::Array<PxVec3>& velocities, + const PxTransform& pose, + const PxVec3& scale, + float objRadius, + PxBounds3& outBounds, + QDSRand&) const +{ + PX_UNUSED(scale); + + const float bigRadius = *mRadius + *mShellThickness; + const float radiusSquared = bigRadius * bigRadius; + const float hemisphere = *mHemisphere; + const float sphereCapBaseHeight = -bigRadius + 2 * bigRadius * hemisphere; + const float sphereCapBaseRadius = PxSqrt(radiusSquared - sphereCapBaseHeight * sphereCapBaseHeight); + const float horizontalExtents = hemisphere < 0.5f ? bigRadius : sphereCapBaseRadius; + + // we're not doing anything with the velocities array + PX_UNUSED(velocities); + + // we don't want anything outside the emitter + uint32_t numX = (uint32_t)PxFloor(horizontalExtents / objRadius); + numX -= numX % 2; + uint32_t numY = (uint32_t)PxFloor((bigRadius - sphereCapBaseHeight) / objRadius); + numY -= numY % 2; + uint32_t numZ = (uint32_t)PxFloor(horizontalExtents / objRadius); + numZ -= numZ % 2; + + for (float x = -(numX * objRadius); x <= bigRadius - objRadius; x += 2 * objRadius) + { + for (float y = -(numY * objRadius); y <= bigRadius - objRadius; y += 2 * objRadius) + { + for (float z = -(numZ * objRadius); z <= bigRadius - objRadius; z += 2 * objRadius) + { + const float magnitudeSquare = PxVec3(x, y, z).magnitudeSquared(); + if ((magnitudeSquare > (*mRadius + objRadius) * (*mRadius + objRadius)) && + (magnitudeSquare < (bigRadius - objRadius) * (bigRadius - objRadius))) + { + positions.pushBack(pose.transform(PxVec3(x, y, z))); + outBounds.include(positions.back()); + } + } + } + } +} + + +PxVec3 EmitterGeomSphereShellImpl::randomPointOnUnitSphere(QDSRand& rand) const +{ + // uniform distribution on the sphere around pos (Cook, Marsaglia Method. TODO: is other method cheaper?) + float x0, x1, x2, x3, div; + do + { + x0 = rand.getNext(); + x1 = rand.getNext(); + x2 = rand.getNext(); + x3 = rand.getNext(); + div = x0 * x0 + x1 * x1 + x2 * x2 + x3 * x3; + } + while (div >= 1.0f); + + // coordinates on unit sphere + float x = 2 * (x1 * x3 + x0 * x2) / div; + float y = 2 * (x2 * x3 - x0 * x1) / div; + float z = (x0 * x0 + x3 * x3 - x1 * x1 - x2 * x2) / div; + + return PxVec3(x, y, z); +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/EmitterScene.cpp b/APEX_1.4/module/emitter/src/EmitterScene.cpp new file mode 100644 index 00000000..876ea2c4 --- /dev/null +++ b/APEX_1.4/module/emitter/src/EmitterScene.cpp @@ -0,0 +1,135 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "ApexUsingNamespace.h" +#include "EmitterScene.h" +#include "SceneIntl.h" +#include "ModulePerfScope.h" + +#include "Lock.h" + +namespace nvidia +{ +namespace emitter +{ + +EmitterScene::EmitterScene(ModuleEmitterImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list) : + mSumBenefit(0.0f), + mDebugRender(debugRender) +{ + mModule = &module; + mApexScene = &scene; + list.add(*this); // Add self to module's list of EmitterScenes + + /* Initialize reference to EmitterDebugRenderParams */ + { + READ_LOCK(*mApexScene); + mDebugRenderParams = DYNAMIC_CAST(DebugRenderParams*)(mApexScene->getDebugRenderParams()); + } + PX_ASSERT(mDebugRenderParams); + NvParameterized::Handle handle(*mDebugRenderParams), memberHandle(*mDebugRenderParams); + int size; + + if (mDebugRenderParams->getParameterHandle("moduleName", handle) == NvParameterized::ERROR_NONE) + { + handle.getArraySize(size, 0); + handle.resizeArray(size + 1); + if (handle.getChildHandle(size, memberHandle) == NvParameterized::ERROR_NONE) + { + memberHandle.initParamRef(EmitterDebugRenderParams::staticClassName(), true); + } + } + + /* Load reference to EmitterDebugRenderParams */ + NvParameterized::Interface* refPtr = NULL; + memberHandle.getParamRef(refPtr); + mEmitterDebugRenderParams = DYNAMIC_CAST(EmitterDebugRenderParams*)(refPtr); + PX_ASSERT(mEmitterDebugRenderParams); +} + +EmitterScene::~EmitterScene() +{ +} + +void EmitterScene::visualize() +{ +#ifndef WITHOUT_DEBUG_VISUALIZE + for (uint32_t i = 0 ; i < mActorArray.size() ; i++) + { + EmitterActorBase* actor = DYNAMIC_CAST(EmitterActorBase*)(mActorArray[ i ]); + actor->visualize(*mDebugRender); + } +#endif +} + +void EmitterScene::destroy() +{ + removeAllActors(); + mApexScene->moduleReleased(*this); + delete this; +} + +void EmitterScene::setModulePhysXScene(PxScene* scene) +{ + if (scene) + { + for (uint32_t i = 0 ; i < mActorArray.size() ; i++) + { + EmitterActorBase* actor = DYNAMIC_CAST(EmitterActorBase*)(mActorArray[ i ]); + actor->setPhysXScene(scene); + } + } + else + { + for (uint32_t i = 0 ; i < mActorArray.size() ; i++) + { + EmitterActorBase* actor = DYNAMIC_CAST(EmitterActorBase*)(mActorArray[ i ]); + actor->setPhysXScene(NULL); + } + } + + mPhysXScene = scene; +} + +void EmitterScene::submitTasks(float /*elapsedTime*/, float /*substepSize*/, uint32_t /*numSubSteps*/) +{ + for (uint32_t i = 0 ; i < mActorArray.size() ; i++) + { + EmitterActorBase* actor = DYNAMIC_CAST(EmitterActorBase*)(mActorArray[ i ]); + actor->submitTasks(); + } +} + +void EmitterScene::setTaskDependencies() +{ + for (uint32_t i = 0 ; i < mActorArray.size() ; i++) + { + EmitterActorBase* actor = DYNAMIC_CAST(EmitterActorBase*)(mActorArray[ i ]); + actor->setTaskDependencies(); + } +} + +// Called by ApexScene simulation thread after PhysX scene is stepped. All +// actors in the scene are render-locked. +void EmitterScene::fetchResults() +{ + PX_PROFILE_ZONE("EmitterSceneFetchResults", GetInternalApexSDK()->getContextId()); + + for (uint32_t i = 0 ; i < mActorArray.size() ; i++) + { + EmitterActorBase* actor = DYNAMIC_CAST(EmitterActorBase*)(mActorArray[ i ]); + actor->fetchResults(); + } +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/GroundEmitterActorImpl.cpp b/APEX_1.4/module/emitter/src/GroundEmitterActorImpl.cpp new file mode 100644 index 00000000..1bd098d6 --- /dev/null +++ b/APEX_1.4/module/emitter/src/GroundEmitterActorImpl.cpp @@ -0,0 +1,1166 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "GroundEmitterAsset.h" +#include "SceneIntl.h" +#include "RenderDebugInterface.h" +#include "InstancedObjectSimulationIntl.h" +#include "GroundEmitterAssetImpl.h" +#include "GroundEmitterActorImpl.h" +#include "EmitterScene.h" +#include "ApexUsingNamespace.h" +#include "ApexRand.h" + +#include "ScopedPhysXLock.h" +#include "PxRigidDynamic.h" + +namespace nvidia +{ +namespace emitter +{ + +using namespace physx; + +void InjectorData::InjectTask::run() +{ + mActor->injectParticles(*mData); +} + +// this function will 'a'+'b' and wrap it around the max value back to 0 if necessary +// not safe when 'a' + 'b' > 2*max, or something like that +static inline int32_t INCREMENT_CELL(int32_t& a, int32_t b, int32_t max) +{ + if (a + b > max) + { + return ((a + b) - max - 1); + } + else + { + return a + b; + } +} + +#pragma warning(disable: 4355) + +GroundEmitterActorImpl::GroundEmitterActorImpl(const GroundEmitterActorDesc& desc, GroundEmitterAssetImpl& asset, ResourceList& list, EmitterScene& scene) + : mAsset(&asset) + , mScene(&scene) + , mLocalUpDirection(PxVec3(0.0f, 1.0f, 0.0f)) + , mGridCellSize(0.0f) + , mTotalElapsedTimeMs(0) + , mShouldUseGroupsMask(false) + , mTickTask(*this) +{ + mRand.setSeed(scene.mApexScene->getSeed()); + + GroundEmitterActorDesc defaults; + + /* Read default values from descriptor or authored asset */ + if (desc.raycastCollisionGroups == defaults.raycastCollisionGroups) + { + setRaycastCollisionGroups(mAsset->mRaycastCollisionGroups); + } + else + { + setRaycastCollisionGroups(desc.raycastCollisionGroups); + } + if (desc.radius == defaults.radius) + { + setRadius(mAsset->getRadius()); + } + else + { + setRadius(desc.radius); + } + if (desc.maxRaycastsPerFrame == 0) + { + setMaxRaycastsPerFrame(mAsset->getMaxRaycastsPerFrame()); + } + else + { + setMaxRaycastsPerFrame(desc.maxRaycastsPerFrame); + } + if (desc.raycastHeight == 0.0f) + { + setRaycastHeight(mAsset->getRaycastHeight()); + } + else + { + setRaycastHeight(desc.raycastHeight); + } + if (desc.density == 0.0f) + { + mDensity = mAsset->getDensity(); + } + else + { + mDensity = desc.density; + } + if (desc.attachActor) + { + setAttachActor(desc.attachActor); + setAttachRelativePosition(desc.attachRelativePosition); + } + else + { + mAttachActor = NULL; + } + if (desc.spawnHeight >= 0.0f) + { + setSpawnHeight(desc.spawnHeight); + } + else + { + setSpawnHeight(mAsset->getSpawnHeight()); + } + + mOldLocalPlayerPosition = PxVec3(0.0f); + mPose = PxTransform(PxIdentity); + setRotation(desc.rotation); + setPosition(desc.initialPosition); + + mMaterialCallback = desc.materialCallback; + + mRaycastCollisionGroupsMask = PxFilterData(0, 0, 0, 0); + + mRefreshFullCircle = true; + mSimulationSteps = 0; + + for (uint32_t i = 0 ; i < mAsset->mMaterialFactoryMaps->size() ; i++) + { + MaterialFactoryMappingDesc factoryDesc; + factoryDesc.instancedObjectEffectsAssetName = (*mAsset->mMaterialFactoryMaps)[i].iofxAssetName->name(); + factoryDesc.instancedObjectSimulationTypeName = (*mAsset->mMaterialFactoryMaps)[i].iosAssetName->className(); + factoryDesc.instancedObjectSimulationAssetName = (*mAsset->mMaterialFactoryMaps)[i].iosAssetName->name(); + factoryDesc.physicalMaterialName = (*mAsset->mMaterialFactoryMaps)[i].physMatName; + factoryDesc.weight = (*mAsset->mMaterialFactoryMaps)[i].weight; + factoryDesc.maxSlopeAngle = (*mAsset->mMaterialFactoryMaps)[i].maxSlopeAngle; + EmitterLodParamDesc lodParamDesc; + GroundEmitterAssetImpl::copyLodDesc(lodParamDesc, (*mAsset->mMaterialFactoryMaps)[i].lodParamDesc); + if (!addMeshForGroundMaterial(factoryDesc, lodParamDesc)) + { + return; + } + } + + list.add(*this); // Add self to asset's list of actors + addSelfToContext(*scene.mApexScene->getApexContext()); // Add self to ApexScene + addSelfToContext(scene); // Add self to EmitterScene's list of actors + + mValid = true; +} + +GroundEmitterActorImpl::~GroundEmitterActorImpl() +{ +} + +void GroundEmitterActorImpl::submitTasks() +{ + float dt; + bool stepPhysX = mScene->mApexScene->physXElapsedTime(dt); + + PxTaskManager* tm = mScene->mApexScene->getTaskManager(); + + for (uint32_t i = 0; i < mInjectorList.size(); i++) + { + tm->submitUnnamedTask(mInjectorList[i]->mTask); + } + + if (stepPhysX) + { + tm->submitUnnamedTask(mTickTask); + } +} + +void GroundEmitterActorImpl::setTaskDependencies() +{ + float dt; + bool stepPhysX = mScene->mApexScene->physXElapsedTime(dt); + + PxTaskManager* tm = mScene->mApexScene->getTaskManager(); + + for (uint32_t i = 0; i < mInjectorList.size(); i++) + { + PxTask* injectTask = &mInjectorList[i]->mTask; + + injectTask->finishBefore(mInjectorList[i]->mInjector->getCompletionTaskID()); + + if (stepPhysX) + { + mTickTask.startAfter(injectTask->getTaskID()); + } + } + + if (stepPhysX) + { + mTickTask.finishBefore(tm->getNamedTask(AST_PHYSX_SIMULATE)); + } +} + + +Asset* GroundEmitterActorImpl::getOwner() const +{ + READ_ZONE(); + return (Asset*) mAsset; +} +GroundEmitterAsset* GroundEmitterActorImpl::getEmitterAsset() const +{ + READ_ZONE(); + return mAsset; +} + +void GroundEmitterActorImpl::setRaycastCollisionGroupsMask(physx::PxFilterData* m) +{ + WRITE_ZONE(); + if (!m) + { + mShouldUseGroupsMask = false; + } + else + { + mRaycastCollisionGroupsMask = *m; + mShouldUseGroupsMask = true; + } +} + + +void GroundEmitterActorImpl::setPreferredRenderVolume(nvidia::apex::RenderVolume* vol) +{ + WRITE_ZONE(); + for (uint32_t i = 0 ; i < mInjectorList.size() ; i++) + { + InjectorData* data = mInjectorList[i]; + if (data->mInjector) + { + data->mInjector->setPreferredRenderVolume(vol); + } + } +} + +void GroundEmitterActorImpl::setPhysXScene(physx::PxScene* s) +{ + mPxScene = s; +} + +void GroundEmitterActorImpl::getLodRange(float& min, float& max, bool& intOnly) const +{ + PX_UNUSED(min); + PX_UNUSED(max); + PX_UNUSED(intOnly); + APEX_INVALID_OPERATION("not implemented"); +} + + +float GroundEmitterActorImpl::getActiveLod() const +{ + APEX_INVALID_OPERATION("GroundEmitterActor does not support this operation"); + return -1.0f; +} + + +void GroundEmitterActorImpl::forceLod(float lod) +{ + PX_UNUSED(lod); + APEX_INVALID_OPERATION("not implemented"); +} + + +void GroundEmitterActorImpl::release() +{ + if (mInRelease) + { + return; + } + mInRelease = true; + mAsset->releaseActor(*this); +} + + +void GroundEmitterActorImpl::destroy() +{ + /* Order is important here, pay attention */ + + // Remove ourselves from all contexts, so they don't get stuck trying to release us + ApexActor::destroy(); + + for (uint32_t i = 0; i < mInjectorList.size(); i++) + { + // Release our actor first + if (mInjectorList[i]->mInjector) + { + mInjectorList[i]->mInjector->release(); + } + + delete mInjectorList[i]; + } + mInjectorList.clear(); + + delete this; +} + + +void GroundEmitterActorImpl::removeActorAtIndex(uint32_t index) +{ + // One of our injectors has been released + for (uint32_t i = 0; i < mInjectorList.size(); i++) + { + if (mInjectorList[i]->mInjector == mActorArray[ index ]) + { + mInjectorList[i]->mInjector = NULL; + } + } + + ApexContext::removeActorAtIndex(index); + release(); +} + +const PxMat44 GroundEmitterActorImpl::getPose() const +{ + READ_ZONE(); + PxMat44 mat44 = PxMat44(mPose); + mat44.setPosition(mWorldPlayerPosition); + return mat44; +} + +void GroundEmitterActorImpl::setPose(const PxMat44& pos) +{ + WRITE_ZONE(); + PxMat44 rotation = pos; + rotation.setPosition(PxVec3(0.0f)); + + mWorldPlayerPosition = pos.getPosition(); + + setRotation(PxTransform(rotation)); +} + + +void GroundEmitterActorImpl::setRotation(const PxTransform& rotation) +{ + PX_ASSERT(mPose.p == PxVec3(0.0f)); + mPose.q = rotation.q; + mInversePose = mPose.getInverse(); + setPosition(mWorldPlayerPosition); +} + +void GroundEmitterActorImpl::setPosition(const PxVec3& worldPlayerPosition) +{ + // put the world player position in the ground emitter's space + mLocalPlayerPosition = mInversePose.transform(worldPlayerPosition); + + mHorizonPlane = PxPlane(mLocalPlayerPosition, mLocalUpDirection); + PxVec3 dir = mLocalPlayerPosition - mHorizonPlane.project(mLocalPlayerPosition); + mStepsize = dir.normalize(); + + mWorldPlayerPosition = worldPlayerPosition; + + // keep track of when we move 1/2 a grid cell in distance + float dist = (mOldLocalPlayerPosition - mLocalPlayerPosition).magnitudeSquared(); + if (dist > (mGridCellSize * mGridCellSize * 0.25)) + { + mOldLocalPlayerPosition = mLocalPlayerPosition; + } +} + + +void GroundEmitterActorImpl::setRadius(float r) +{ + WRITE_ZONE(); + mRadius = r; + mRadius2 = mRadius * mRadius; + mMaxStepSize = 2 * mRadius; + mCircleArea = PxPi * mRadius2; +} + +#ifdef WITHOUT_DEBUG_VISUALIZE +void GroundEmitterActorImpl::visualize(RenderDebugInterface&) +{ +} +#else +void GroundEmitterActorImpl::visualize(RenderDebugInterface& renderDebug) +{ + if (!mScene->mEmitterDebugRenderParams->groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR) + { + return; + } + if ( !mEnableDebugVisualization ) return; + + using RENDER_DEBUG::DebugColors; + + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::Green), RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::Yellow)); + + if (mScene->mEmitterDebugRenderParams->groundEmitterParameters.VISUALIZE_GROUND_EMITTER_SPHERE) + { + RENDER_DEBUG_IFACE(&renderDebug)->debugSphere(mWorldPlayerPosition, mRadius); + } + + + // Determine bounds of grid cells around the player + PxVec3 pos = mHorizonPlane.project(mLocalPlayerPosition); + PxVec3 max = mHorizonPlane.project(mLocalPlayerPosition + PxVec3(mRadius)); + PxVec3 min = mHorizonPlane.project(mLocalPlayerPosition - PxVec3(mRadius)); + + if (mGridCellSize == 0.0f) + { + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); + return; + } + + if (mScene->mEmitterDebugRenderParams->groundEmitterParameters.VISUALIZE_GROUND_EMITTER_RAYCAST) + { + + if (mVisualizeRaycastsList.size() > 0) + { + PxVec3 rayOffset = mRaycastHeight * mLocalUpDirection; + + //NOTE: this array should be processed whenever it has stuff in it, even if vis has been disabled, otherwise it may never get cleared! + for (physx::Array<RaycastVisInfo>::Iterator i = mVisualizeRaycastsList.begin(); i != mVisualizeRaycastsList.end(); i++) + { + //was it deleted less than a second ago? If yes, draw it, otherwise remove it from the array. + uint32_t timeAdded = (*i).timeSubmittedMs; + if (timeAdded + 1000 < mTotalElapsedTimeMs) + { + mVisualizeRaycastsList.replaceWithLast(static_cast<uint32_t>(i - mVisualizeRaycastsList.begin())); + i--; + } + else + { + PxVec3 worldStart, worldStop, localStop; + worldStart = mPose.transform((*i).rayStart + rayOffset); + localStop = (*i).rayStart; + localStop.y = 0.0f; + worldStop = mPose.transform(localStop); + RENDER_DEBUG_IFACE(&renderDebug)->debugLine(worldStart, worldStop); + } + } + } + + // put the raycast direction on top of the grid (2 around the center) +#define GE_DEBUG_RAY_THICKNESS (0.05f) + + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentArrowSize(GE_DEBUG_RAY_THICKNESS * 4); + + PxVec3 localPlayerZeroedPosition(mLocalPlayerPosition.x, 0.0f, mLocalPlayerPosition.z); + PxVec3 worldRayStart, worldRayStop; + PxVec3 localRayStart(localPlayerZeroedPosition + PxVec3(mGridCellSize, mRaycastHeight + mLocalPlayerPosition.y, mGridCellSize)); + PxVec3 localRayStop(localPlayerZeroedPosition + PxVec3(mGridCellSize, 0.0f, mGridCellSize)); + + worldRayStart = mPose.transform(localRayStart); + worldRayStop = mPose.transform(localRayStop); + RENDER_DEBUG_IFACE(&renderDebug)->debugThickRay(worldRayStart, worldRayStop, GE_DEBUG_RAY_THICKNESS); + + localRayStart = PxVec3(localPlayerZeroedPosition + PxVec3(-mGridCellSize, mRaycastHeight + mLocalPlayerPosition.y, -mGridCellSize)); + localRayStop = PxVec3(localPlayerZeroedPosition + PxVec3(-mGridCellSize, 0.0f, -mGridCellSize)); + + worldRayStart = mPose.transform(localRayStart); + worldRayStop = mPose.transform(localRayStop); + RENDER_DEBUG_IFACE(&renderDebug)->debugThickRay(worldRayStart, worldRayStop, GE_DEBUG_RAY_THICKNESS); + } + + if (mScene->mEmitterDebugRenderParams->groundEmitterParameters.VISUALIZE_GROUND_EMITTER_GRID) + { + // draw a grid on the ground plane representing the emitter grid and one at mRaycastHeight + playerHeight + // draw two grids, one at 0 + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::Yellow), RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::Yellow)); + for (uint32_t i = 0; i < 2; i++) + { + float gridY = i * (mRaycastHeight + mLocalPlayerPosition.y); + for (float x = min.x; x <= max.x; x += mGridCellSize) + { + // draw "vertical lines" (on a piece of paper) + PxVec3 p0(x, gridY, min.z), p1(x, gridY, max.z), worldP0, worldP1; + + worldP0 = mPose.transform(p0); + worldP1 = mPose.transform(p1); + + RENDER_DEBUG_IFACE(&renderDebug)->debugLine(worldP0, worldP1); + } + for (float z = min.z; z <= max.z; z += mGridCellSize) + { + // draw "horizontal lines" (on a piece of paper) + PxVec3 p0(min.x, gridY, z), p1(max.x, gridY, z), worldP0, worldP1; + + worldP0 = mPose.transform(p0); + worldP1 = mPose.transform(p1); + + RENDER_DEBUG_IFACE(&renderDebug)->debugLine(worldP0, worldP1); + } + } + + // draw a big box around the grids + PxVec3 bmin(min.x, 0.0f, min.z), + bmax(max.x, mRaycastHeight + mLocalPlayerPosition.y, max.z), + bWorldMin, + bWorldMax; + + bWorldMin = mPose.transform(bmin); + bWorldMax = mPose.transform(bmax); + + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(DebugColors::Yellow)); + RENDER_DEBUG_IFACE(&renderDebug)->debugBound(PxBounds3(bWorldMin, bWorldMax)); + } + + if (mScene->mEmitterDebugRenderParams->groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_NAME) + { + PxVec3 bLocalMax(max.x, mRaycastHeight, max.z); + PxVec3 bWorldMax; + bWorldMax = mPose.transform(bLocalMax); + + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentTextScale(2.0f); + + PxVec3 textLocation = bWorldMax; + RENDER_DEBUG_IFACE(&renderDebug)->debugText(textLocation, " %s %s", this->getOwner()->getObjTypeName(), this->getOwner()->getName()); + + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); + } + + if (mScene->mEmitterDebugRenderParams->groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_POSE) + { + PxMat44 groundEmitterAxes = getRotation(); + groundEmitterAxes.setPosition(getPosition()); + RENDER_DEBUG_IFACE(&renderDebug)->debugAxes(groundEmitterAxes, 1); + } + + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +} +#endif + + +/** + * Add an IOFX/IOS pair to a material. + */ +bool GroundEmitterActorImpl::addMeshForGroundMaterial( + const MaterialFactoryMappingDesc& desc, + const EmitterLodParamDesc& lodDesc) +{ + ApexSDKIntl* sdk = mAsset->mModule->mSdk; + ResourceProviderIntl* nrp = sdk->getInternalResourceProvider(); + + /* Resolve the actual MaterialIndex from the provided name */ + ResID pmns = sdk->getPhysicalMaterialNameSpace(); + ResID matresid = nrp->createResource(pmns, desc.physicalMaterialName); + PxMaterialTableIndex groundMaterialIndex = (PxMaterialTableIndex)(size_t) nrp->getResource(matresid); + + uint32_t injectorIndex; + for (injectorIndex = 0; injectorIndex < mInjectorList.size(); injectorIndex++) + { + if (mInjectorList[injectorIndex]->iofxAssetName == desc.instancedObjectEffectsAssetName && + mInjectorList[injectorIndex]->iosAssetName == desc.instancedObjectSimulationAssetName) + { + break; + } + } + + if (injectorIndex >= mInjectorList.size()) + { + InjectorData* data = PX_NEW(InjectorData)(); + data->initTask(*this, *data); + + const char* iofxAssetName = desc.instancedObjectEffectsAssetName; + IofxAsset* iofxAsset = static_cast<IofxAsset*>(mAsset->mIofxAssetTracker.getAssetFromName(iofxAssetName)); + IosAsset* iosAsset = mAsset->mIosAssetTracker.getIosAssetFromName( + desc.instancedObjectSimulationTypeName, + desc.instancedObjectSimulationAssetName); + + if (!iosAsset || !iofxAsset) + { + delete data; + return false; + } + + Actor* nxActor = iosAsset->createIosActor(*mScene->mApexScene, iofxAsset); + InstancedObjectSimulationIntl* ios = NULL; + if (nxActor) + { + ApexActor* aa = GetInternalApexSDK()->getApexActor(nxActor); + if (aa) + { + ios = DYNAMIC_CAST(InstancedObjectSimulationIntl*)(aa); + } + } + if (!ios) + { + APEX_DEBUG_INFO("IOS asset retrieval failure: %s", desc.instancedObjectSimulationAssetName); + delete data; + return false; + } + + /* Keep list of unique ios pointers */ + uint32_t i; + for (i = 0 ; i < mIosList.size() ; i++) + { + if (mIosList[i] == ios) + { + break; + } + } + if (i == mIosList.size()) + { + mIosList.pushBack(ios); + } + + data->mInjector = ios->allocateInjector(iofxAsset); + if (!data->mInjector) + { + delete data; + return false; + } + + data->mInjector->addSelfToContext(*this); + data->mObjectRadius = ios->getObjectRadius(); + if (!data->mInjector) + { + APEX_DEBUG_INFO("IOS injector allocation failure"); + delete data; + return false; + } + + data->mInjector->setLODWeights(lodDesc.maxDistance, lodDesc.distanceWeight, lodDesc.speedWeight, + lodDesc.lifeWeight, lodDesc.separationWeight, lodDesc.bias); + + mInjectorList.pushBack(data); + } + + mPerMaterialData.use(groundMaterialIndex); + MaterialData& data = mPerMaterialData.direct(groundMaterialIndex); + + data.injectorIndices.pushBack(injectorIndex); + float weight = desc.weight; + if (data.accumWeights.size() > 0) + { + weight += data.accumWeights.back(); + } + data.accumWeights.pushBack(weight); + // Store the sine of the complimentary angle for comparison + float angleCompSin = PxSin((90.0f - desc.maxSlopeAngle) * PxPi / 180.0f); + data.maxSlopeAngles.pushBack(angleCompSin); + + return true; +} + +/** + * Submit up to mMaxNumRaycastsPerFrame raycasts to the PhysX engine. These will be + * processed asynchronously and we'll get the results in fetchResults(). + */ +void GroundEmitterActorImpl::submitRaycasts() +{ + PX_PROFILE_ZONE("GroundParticlesEmitterRaycasts", GetInternalApexSDK()->getContextId()); + + /* Avoid raycasts if we have material callback and spawn height */ + if (mMaterialCallback && mSpawnHeight > 0.0f && mToRaycast.size()) + { + uint32_t nbHits = mToRaycast.size(); + mMaterialRequestArray.resize(nbHits); + MaterialLookupCallback::MaterialRequest* matRequest = &mMaterialRequestArray[0]; + for (uint32_t i = 0 ; i < nbHits ; i++) + { + PxVec3 position; + if (mToRaycast.popFront(position)) + { + matRequest[i].samplePosition = mPose.transform(position); + } + } + + mMaterialCallback->requestMaterialLookups(nbHits, matRequest); + + nvidia::Mutex::ScopedLock scopeLock(mInjectorDataLock); + + for (uint32_t i = 0 ; i < nbHits ; i++) + { + uint16_t matIndex = (uint16_t) matRequest[i].outMaterialID; + + if (!mPerMaterialData.isValid(matIndex)) + { + continue; + } + if (!mPerMaterialData.isUsed(matIndex)) + { + continue; + } + + MaterialData& data = mPerMaterialData.direct(matIndex); + float maxSlopeAngle; + uint32_t particleFactoryIndex = data.chooseIOFX(maxSlopeAngle, mRand); + InjectorData& injectorData = *mInjectorList[ particleFactoryIndex ]; + + PX_ASSERT(mLocalUpDirection == PxVec3(0, 1, 0)); + + IosNewObject particle; + + // the spawn height must be added to the "up axis", so transform pos back to local, + // offset, then back to world + PxVec3 localPosition, worldPosition; + localPosition = mInversePose.transform(matRequest[i].samplePosition); + localPosition += PxVec3(0.0f, mSpawnHeight, 0.0f); + particle.initialPosition = mPose.transform(localPosition); + + particle.lodBenefit = 0; + particle.iofxActorID = IofxActorIDIntl(0); + particle.userData = 0; + + particle.initialVelocity = mRand.getScaled(getVelocityLow(), getVelocityHigh()); + particle.lifetime = mRand.getScaled(getLifetimeLow(), getLifetimeHigh()); + injectorData.particles.pushBack(particle); + } + } + else + { + physx::PxFilterData* groupsMask = (mShouldUseGroupsMask) ? &mRaycastCollisionGroupsMask : NULL; + PxVec3 rayOffset = mRaycastHeight * mLocalUpDirection; + uint32_t numRaycastsDone = 0; + + PxVec3 orig; + PxVec3 dir; + PxRaycastHit hit; + PxVec3 worldUpDirection; + worldUpDirection = mPose.transform(mLocalUpDirection); + dir = -worldUpDirection; + + PxVec3 newPos; + static const int DefaultRaycastHitNum = 256; + int raycastHitNum = DefaultRaycastHitNum; + int nbHits; + PxRaycastHit hitsStatck[DefaultRaycastHitNum]; + PxRaycastHit* hits = hitsStatck; + PxQueryFilterData filterData(PxQueryFlag::eSTATIC); + if (groupsMask) + filterData.data = *groupsMask; + while (mToRaycast.popFront(newPos)) + { + PxVec3 rotatedPosition; + rotatedPosition = mPose.transform(newPos + rayOffset); + orig = rotatedPosition; + + for(;;) + { + PxRaycastBuffer rcBuffer(hits, DefaultRaycastHitNum); + mPxScene->raycast(orig, dir, PX_MAX_F32, rcBuffer, + PxHitFlag::ePOSITION|PxHitFlag::eNORMAL|PxHitFlag::eDISTANCE|PxHitFlag::eUV, + filterData); + nbHits = (int32_t)rcBuffer.getNbAnyHits(); + if (nbHits != -1) + break; + + if (hitsStatck != hits) + { + PX_FREE(hits); + } + raycastHitNum <<= 1; // *2 + hits = (PxRaycastHit*)PX_ALLOC(sizeof(PxRaycastHit)*raycastHitNum, PX_DEBUG_EXP("GroundEmitterActor_PxRaycastHit")); + } + + if (!onRaycastQuery((uint32_t)nbHits, hits)) + break; + + if (++numRaycastsDone >= mMaxNumRaycastsPerFrame) + { + break; + } + } + if (hits != hitsStatck) + { + PX_FREE(hits); + } + } +} + + +/** + * Called during ApexScene::fetchResults() to get raycast results + * from the PhysX engine. + */ +void GroundEmitterActorImpl::fetchResults() +{ +} + + +/** + * Inject all queued particles/objects into their IOS + */ +void GroundEmitterActorImpl::injectParticles(InjectorData& data) +{ + PX_PROFILE_ZONE("GroundParticlesEmitterInjection", GetInternalApexSDK()->getContextId()); + + nvidia::Mutex::ScopedLock scopeLock(mInjectorDataLock); + + if (data.particles.size() > 0) + { + data.mInjector->createObjects(data.particles.size(), &data.particles[0]); + data.particles.clear(); + } +} + + +/** + * Iterate over all the objects spawned by this emitter actor (by iterating over its IOFX + * instances) and determine where new objects need to be spawned. We do this by defining a + * 2D grid and determining the object density in each cell. If the cell is below the appropriate + * density, and the cell is in the appropriate refresh area, we spawn new objects to bring that + * cell up to our density requirement. + */ +void GroundEmitterActorImpl::refreshCircle(bool edgeOnly) +{ + PX_PROFILE_ZONE("GroundParticlesEmitterRefreshCircle", GetInternalApexSDK()->getContextId()); + + // Voluntarily throttle myself if any injector already + // has a backlog of particles. + for (uint32_t i = 0 ; i < mInjectorList.size() ; i++) + { + if (mInjectorList[ i ]->mInjector->isBacklogged()) + { + return; + } + } + + // Simulation steps required before a grid can be re-refreshed. There's a trade-off here + // between constant refresh for areas that have a high slope and cannot support particles + // and between players out-running the refresh radius. This number must be > 2 in order to + // protect against multi-frame particle emission latencies. +#define MIN_CELL_REFRESH_STEPS 12 + + // Hack, for now, to simplify the math so we can debug functionality + // DoD and SimpleVegetation are both Y up. + PX_ASSERT(mLocalUpDirection == PxVec3(0, 1, 0)); + + mCurrentDensity = mAsset->getDensity() * mAsset->mModule->getGroundDensityScale(); + + // Calculate grid size based on mCurrentDensity and mRadius + float gridSize = mRadius / 4; + while (mCurrentDensity * gridSize * gridSize < 20) + { + gridSize *= 1.5; + } + + while (mCurrentDensity * gridSize * gridSize > 40) + { + gridSize *= 0.5; + } + + // clear the mCellLastRefreshSteps list and the grid/cell loop counters if the grid size changes + if (gridSize != mGridCellSize) + { + for (uint32_t i = 0; i < mCellLastRefreshSteps.size(); i++) + { + mCellLastRefreshSteps[i] = 0; + } + mNextGridCell.x = 0; + mNextGridCell.y = 0; + } + + // clear the mCellLastRefreshSteps list if the player moves more than 1/2 a grid cell in distance + if (mOldLocalPlayerPosition == mLocalPlayerPosition && mStepsize > 0.0f) + { + for (uint32_t i = 0; i < mCellLastRefreshSteps.size(); i++) + { + mCellLastRefreshSteps[i] = 0; + } + } + + // persist grid size + mGridCellSize = gridSize; + + // Determine bounds of grid cells around the player + float heightFudge = mSpawnHeight / 5; // this should be authorable... + PxVec3 pos = mHorizonPlane.project(mLocalPlayerPosition); + PxVec3 max = mHorizonPlane.project(mLocalPlayerPosition + PxVec3(mRadius)); + PxVec3 min = mHorizonPlane.project(mLocalPlayerPosition - PxVec3(mRadius)); + int32_t xMin, xMax, yMin, yMax; + + xMin = (int32_t) PxFloor(min.x / gridSize); + xMax = (int32_t) PxCeil(max.x / gridSize); + + yMin = (int32_t) PxFloor(min.z / gridSize); + yMax = (int32_t) PxCeil(max.z / gridSize); + + // Allocate grid of uint32_t counters based on grid size and mRadius + uint32_t gridDim = (uint32_t)PxMax(yMax - yMin, xMax - xMin); + uint32_t totalGrids = gridDim * gridDim; + uint32_t* grids = (uint32_t*) mAsset->mModule->mSdk->getTempMemory(totalGrids * sizeof(uint32_t)); + mCellLastRefreshSteps.resize(totalGrids, (uint32_t) - MIN_CELL_REFRESH_STEPS); + memset(grids, 0, totalGrids * sizeof(uint32_t)); + + // This loop should be in a CUDA kernel + for (uint32_t i = 0; i < mIosList.size(); i++) + { + uint32_t count, stride; + InstancedObjectSimulationIntl* ios = mIosList[i]; + const PxVec3* positions = ios->getRecentPositions(count, stride); + const char* ptr = reinterpret_cast<const char*>(positions); + const PxVec3* worldPositionPtr; + PxVec3 localPosition; + + for (uint32_t j = 0 ; j < count ; j++) + { + worldPositionPtr = reinterpret_cast<const PxVec3*>(ptr); + localPosition = mInversePose.transform(*worldPositionPtr); + ptr += stride; + PxVec3 proj = mHorizonPlane.project(localPosition); + int32_t cx = (int32_t) PxFloor(proj.x / gridSize) - xMin; + if (cx < 0 || cx >= (int32_t) gridDim) + { + continue; + } + + int32_t cy = (int32_t) PxFloor(proj.z / gridSize) - yMin; + if (cy < 0 || cy >= (int32_t) gridDim) + { + continue; + } + + float dist = localPosition.y - mLocalPlayerPosition.y; + if ((mSpawnHeight > 0.0f) && + ((dist < (mSpawnHeight - heightFudge)) || (dist > (mSpawnHeight + heightFudge)))) + { + continue; + } + + grids[ cy * gridDim + cx ]++; + } + } + + { + PX_PROFILE_ZONE("GroundParticlesEmitterGridInspect", GetInternalApexSDK()->getContextId()); + // Iterate over grid. For each under density threshold, generate + // new particles to bring it up to spec. + uint32_t neededOccupancy = (uint32_t) PxCeil(mCurrentDensity * gridSize * gridSize * 0.10f); + + bool stopScanningGridCells = false; + + for (int32_t x = 0 ; x < (int32_t) gridDim ; x++) + { + if (stopScanningGridCells) + { + break; + } + + int32_t cellx = INCREMENT_CELL(mNextGridCell.x, x, (int32_t)(gridDim - 1)); + + float fx = (cellx + xMin) * gridSize; + for (int32_t y = 0 ; y < (int32_t) gridDim ; y++) + { + int32_t celly = INCREMENT_CELL(mNextGridCell.y, y, (int32_t)(gridDim - 1)); + float fy = (celly + yMin) * gridSize; + + if (edgeOnly) + { + // Ignore grids that do not include the radius. This is a horseshoe calculation + // that tests whether the grid center is more than gridSize from the radius. + float cx = (fx + gridSize * 0.5f) - pos.x; + float cy = (fy + gridSize * 0.5f) - pos.z; + float distsq = cx * cx + cy * cy; + if (fabs(distsq - mRadius2) > gridSize * gridSize) + { + continue; + } + } + + uint32_t gridID = (uint32_t) celly * gridDim + cellx; + uint32_t gridOccupancy = grids[ gridID ]; + if (gridOccupancy >= neededOccupancy) + { + continue; + } + + // Do not refresh a grid more often than once every half second + if (mSimulationSteps - mCellLastRefreshSteps[ gridID ] < MIN_CELL_REFRESH_STEPS) + { + continue; + } + + // Refresh this grid + uint32_t numRaycasts = (uint32_t) PxCeil(mCurrentDensity * gridSize * gridSize) - gridOccupancy; + + // If this cell pushes us over the max raycast count, take what we can from the cell and run + // it again next frame. This does not apply to the first frame (edgeOnly) + if (!mRefreshFullCircle && ((mToRaycast.size() + numRaycasts) > getMaxRaycastsPerFrame())) + { + if (mToRaycast.size() > getMaxRaycastsPerFrame()) + { + numRaycasts = 0; + } + else + { + numRaycasts = getMaxRaycastsPerFrame() - mToRaycast.size(); + } + } + + // compute the positions of the new raycasts + bool visualizeRaycasts = mScene->mEmitterDebugRenderParams->groundEmitterParameters.VISUALIZE_GROUND_EMITTER_RAYCAST && + mScene->mDebugRenderParams->Enable; + // safety valve, in case no one is actually rendering + if (mVisualizeRaycastsList.size() > 16 * 1024) + { + visualizeRaycasts = false; + } + + for (uint32_t j = 0; j < numRaycasts; j++) + { + float tmpx = mRand.getScaled(0, gridSize); + float tmpy = mRand.getScaled(0, gridSize); + mToRaycast.pushBack(PxVec3(fx + tmpx, mLocalPlayerPosition.y, fy + tmpy)); + + if (visualizeRaycasts) + { + RaycastVisInfo& raycastInfo = mVisualizeRaycastsList.insert(); + raycastInfo.rayStart = PxVec3(fx + tmpx, mLocalPlayerPosition.y, fy + tmpy); + raycastInfo.timeSubmittedMs = mTotalElapsedTimeMs; + } + } + + // break out if the raycast buffer will grow beyond the max raycasts per frame + if (!mRefreshFullCircle && (mToRaycast.size() >= getMaxRaycastsPerFrame())) + { + // save the next cell in the grid to continue scanning + if (cellx == (int32_t)gridDim - 1 && celly == (int32_t)gridDim - 1) + { + mNextGridCell.x = mNextGridCell.y = 0; + } + else if (cellx == (int32_t)gridDim - 1) + { + mNextGridCell.x = INCREMENT_CELL(cellx, 1, (int32_t)(gridDim - 1)); + } + else + { + mNextGridCell.x = cellx; + } + + mNextGridCell.y = INCREMENT_CELL(celly, 1, (int32_t)(gridDim - 1)); + + stopScanningGridCells = true; + break; + } + + mCellLastRefreshSteps[ gridID ] = mSimulationSteps; + } + } + } + + mAsset->mModule->mSdk->releaseTempMemory(grids); +} + +void GroundEmitterActorImpl::tick() +{ + float dt = mScene->mApexScene->getElapsedTime(); + + mTotalElapsedTimeMs = mTotalElapsedTimeMs + (uint32_t)(1000.0f * dt); + PX_PROFILE_ZONE("GroundParticlesEmitterTick", GetInternalApexSDK()->getContextId()); + + mSimulationSteps++; + + //TODO: make more localize locks + SCOPED_PHYSX_LOCK_WRITE(mScene->mApexScene); + + if (mAttachActor) + { + PxTransform t = mAttachActor->is<physx::PxRigidDynamic>()->getGlobalPose(); + setPosition(t.p + mAttachRelativePosition); + } + + // generate new raycast positions based on refresh requirements + refreshCircle((mStepsize < mMaxStepSize) && (mSpawnHeight == 0.0f) && !mRefreshFullCircle); + mRefreshFullCircle = false; + + if (mToRaycast.size()) + { + submitRaycasts(); + } +} + + +/** + * Raycast callback which is triggered by calling mQueryObject->finish() + */ +bool GroundEmitterActorImpl::onRaycastQuery(uint32_t nbHits, const PxRaycastHit* hits) +{ + PX_UNUSED(userData); + + PX_PROFILE_ZONE("GroundParticlesEmitterOnRaycastQuery", GetInternalApexSDK()->getContextId()); + + if (!nbHits) + { + return true; + } + + MaterialLookupCallback::MaterialRequest* matRequest = NULL; + if (mMaterialCallback) + { + mMaterialRequestArray.resize(nbHits); + matRequest = &mMaterialRequestArray[0]; + for (uint32_t i = 0 ; i < nbHits ; i++) + { + matRequest[i].samplePosition = hits[i].position; + } + mMaterialCallback->requestMaterialLookups(nbHits, matRequest); + } + + nvidia::Mutex::ScopedLock scopeLock(mInjectorDataLock); + + PxVec3 worldUpDirection; + worldUpDirection = getPose().rotate(mLocalUpDirection); + + for (uint32_t i = 0; i < nbHits; i++) + { + const PxRaycastHit& hit = hits[i]; + + // TODO 3.0 apan, check matRequest!! + //this->mScene->mPhysXScene->getPhysics().getNbMaterials +// PxMaterial* materail = hit.shape->getMaterialFromInternalFaceIndex(hit.faceIndex); + uint16_t matIndex = matRequest ? (uint16_t) matRequest[i].outMaterialID : (uint16_t) 0;//materail; // apan, fixme, hard code to 0 + if (mPerMaterialData.isValid(matIndex) && + mPerMaterialData.isUsed(matIndex)) + { + PX_ASSERT(PxAbs(1.0f - hit.normal.magnitude()) < 0.001f); // assert normal is normalized + + MaterialData& data = mPerMaterialData.direct(matIndex); + float maxSlopeAngle = 0.0f; + uint32_t particleFactoryIndex = data.chooseIOFX(maxSlopeAngle, mRand); + + float upNormal = hit.normal.dot(worldUpDirection); + if (upNormal < maxSlopeAngle) + { + continue; + } + + InjectorData& injectorData = *mInjectorList[particleFactoryIndex]; + IosNewObject particle; + + if (mSpawnHeight <= 0.0f) + { + particle.initialPosition = hit.position; + particle.initialPosition += injectorData.mObjectRadius * hit.normal; + } + else + { + PX_ASSERT(mLocalUpDirection == PxVec3(0, 1, 0)); + particle.initialPosition.x = hit.position.x; + particle.initialPosition.z = hit.position.z; + particle.initialPosition.y = mLocalPlayerPosition.y + mSpawnHeight; + } + + particle.initialVelocity = mRand.getScaled(getVelocityLow(), getVelocityHigh()); + particle.lifetime = mRand.getScaled(getLifetimeLow(), getLifetimeHigh()); + + particle.lodBenefit = 0; + particle.iofxActorID = IofxActorIDIntl(0); + particle.userData = 0; + + injectorData.particles.pushBack(particle); + } + } + + return true; +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/GroundEmitterAssetImpl.cpp b/APEX_1.4/module/emitter/src/GroundEmitterAssetImpl.cpp new file mode 100644 index 00000000..c03d4eb4 --- /dev/null +++ b/APEX_1.4/module/emitter/src/GroundEmitterAssetImpl.cpp @@ -0,0 +1,431 @@ +/* + * 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. + */ + + +#include "Apex.h" + +#include "ApexSDKIntl.h" +#include "GroundEmitterAsset.h" +#include "GroundEmitterPreview.h" +#include "IofxAsset.h" +#include "GroundEmitterAssetImpl.h" +#include "GroundEmitterActorImpl.h" +#include "GroundEmitterAssetPreview.h" +//#include "ApexSharedSerialization.h" +#include "EmitterScene.h" +#include "nvparameterized/NvParamUtils.h" + +namespace nvidia +{ +namespace emitter +{ + +void GroundEmitterAssetImpl::copyLodDesc(EmitterLodParamDesc& dst, const GroundEmitterAssetParametersNS::emitterLodParamDesc_Type& src) +{ + if (src.version != dst.current) + { + APEX_DEBUG_WARNING("EmitterLodParamDesc version mismatch"); + } + dst.bias = src.bias; + dst.distanceWeight = src.distanceWeight; + dst.lifeWeight = src.lifeWeight; + dst.maxDistance = src.maxDistance; + dst.separationWeight = src.separationWeight; + dst.speedWeight = src.speedWeight; +} + +void GroundEmitterAssetImpl::copyLodDesc(GroundEmitterAssetParametersNS::emitterLodParamDesc_Type& dst, const EmitterLodParamDesc& src) +{ + dst.version = src.current; + dst.bias = src.bias; + dst.distanceWeight = src.distanceWeight; + dst.lifeWeight = src.lifeWeight; + dst.maxDistance = src.maxDistance; + dst.separationWeight = src.separationWeight; + dst.speedWeight = src.speedWeight; +} + + +void GroundEmitterAssetImpl::postDeserialize(void* userData_) +{ + PX_UNUSED(userData_); + + /* Resolve the authored collision group name into the actual ID */ + if (mParams->raycastCollisionGroupMaskName != NULL && + mParams->raycastCollisionGroupMaskName[0] != 0) + { + ResourceProviderIntl* nrp = mModule->mSdk->getInternalResourceProvider(); + ResID cgmns128 = mModule->mSdk->getCollisionGroup128NameSpace(); + ResID cgmresid128 = nrp->createResource(cgmns128, mParams->raycastCollisionGroupMaskName); + void* tmpCGM = nrp->getResource(cgmresid128); + if (tmpCGM) + { + mRaycastCollisionGroupsMask = *(static_cast<physx::PxFilterData*>(tmpCGM)); + mShouldUseGroupsMask = true; + } + } + else + { + mRaycastCollisionGroups = 0xFFFFFFFF; + } + + initializeAssetNameTable(); +} + +void GroundEmitterAssetImpl::initializeAssetNameTable() +{ + /* initialize the iofx and ios asset name to resID tables */ + for (uint32_t i = 0; i < (*mMaterialFactoryMaps).size(); i++) + { + mIofxAssetTracker.addAssetName((*mMaterialFactoryMaps)[i].iofxAssetName->name(), false); + mIosAssetTracker.addAssetName((*mMaterialFactoryMaps)[i].iosAssetName->className(), + (*mMaterialFactoryMaps)[i].iosAssetName->name()); + } +} + +uint32_t GroundEmitterAssetImpl::forceLoadAssets() +{ + uint32_t assetLoadedCount = 0; + + assetLoadedCount += mIofxAssetTracker.forceLoadAssets(); + assetLoadedCount += mIosAssetTracker.forceLoadAssets(); + + return assetLoadedCount; +} + +GroundEmitterAssetImpl::GroundEmitterAssetImpl(ModuleEmitterImpl* m, ResourceList& list, const char* name) : + mIofxAssetTracker(m->mSdk, IOFX_AUTHORING_TYPE_NAME), + mIosAssetTracker(m->mSdk), + mModule(m), + mName(name), + mDefaultActorParams(NULL), + mDefaultPreviewParams(NULL), + mShouldUseGroupsMask(false) +{ + using namespace GroundEmitterAssetParametersNS; + + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + mParams = (GroundEmitterAssetParameters*)traits->createNvParameterized(GroundEmitterAssetParameters::staticClassName()); + + PX_ASSERT(mParams); + + mMaterialFactoryMaps = + PX_NEW(ParamArray<materialFactoryMapping_Type>)(mParams, + "materialFactoryMapList", + (ParamDynamicArrayStruct*) & (mParams->materialFactoryMapList)); + list.add(*this); +} + +GroundEmitterAssetImpl::GroundEmitterAssetImpl(ModuleEmitterImpl* m, + ResourceList& list, + NvParameterized::Interface* params, + const char* name) : + mIofxAssetTracker(m->mSdk, IOFX_AUTHORING_TYPE_NAME), + mIosAssetTracker(m->mSdk), + mModule(m), + mName(name), + mParams((GroundEmitterAssetParameters*)params), + mDefaultActorParams(NULL), + mDefaultPreviewParams(NULL), + mShouldUseGroupsMask(false) +{ + using namespace GroundEmitterAssetParametersNS; + + mMaterialFactoryMaps = + PX_NEW(ParamArray<materialFactoryMapping_Type>)(mParams, + "materialFactoryMapList", + (ParamDynamicArrayStruct*) & (mParams->materialFactoryMapList)); + PX_ASSERT(mMaterialFactoryMaps); + + postDeserialize(); + + list.add(*this); +} + + +void GroundEmitterAssetImpl::destroy() +{ + /* Assets that were forceloaded or loaded by actors will be automatically + * released by the ApexAssetTracker member destructors. + */ + + delete mMaterialFactoryMaps; + if (mParams) + { + mParams->destroy(); + mParams = NULL; + } + + if (mDefaultActorParams) + { + mDefaultActorParams->destroy(); + mDefaultActorParams = 0; + } + + if (mDefaultPreviewParams) + { + mDefaultPreviewParams->destroy(); + mDefaultPreviewParams = 0; + } + + delete this; +} + +GroundEmitterAssetImpl::~GroundEmitterAssetImpl() +{ +} + +NvParameterized::Interface* GroundEmitterAssetImpl::getDefaultActorDesc() +{ + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + PX_ASSERT(traits); + if (!traits) + { + return NULL; + } + + // create if not yet created + if (!mDefaultActorParams) + { + const char* className = GroundEmitterActorParameters::staticClassName(); + NvParameterized::Interface* param = traits->createNvParameterized(className); + mDefaultActorParams = static_cast<GroundEmitterActorParameters*>(param); + + PX_ASSERT(param); + if (!param) + { + return NULL; + } + } + + // copy the parameters from the asset parameters + mDefaultActorParams->density = mParams->density; + mDefaultActorParams->radius = mParams->radius; + mDefaultActorParams->raycastHeight = mParams->raycastHeight; + mDefaultActorParams->spawnHeight = mParams->spawnHeight; + mDefaultActorParams->maxRaycastsPerFrame = mParams->maxRaycastsPerFrame; + + NvParameterized::setParamString(*mDefaultActorParams, "raycastCollisionGroupMaskName", mParams->raycastCollisionGroupMaskName); + + return mDefaultActorParams; +} + +NvParameterized::Interface* GroundEmitterAssetImpl::getDefaultAssetPreviewDesc() +{ + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + PX_ASSERT(traits); + if (!traits) + { + return NULL; + } + + // create if not yet created + if (!mDefaultPreviewParams) + { + const char* className = EmitterAssetPreviewParameters::staticClassName(); + NvParameterized::Interface* param = traits->createNvParameterized(className); + mDefaultPreviewParams = static_cast<EmitterAssetPreviewParameters*>(param); + + PX_ASSERT(param); + if (!param) + { + return NULL; + } + } + + return mDefaultPreviewParams; +} + +Actor* GroundEmitterAssetImpl::createApexActor(const NvParameterized::Interface& parms, Scene& apexScene) +{ + if (!isValidForActorCreation(parms, apexScene)) + { + return NULL; + } + + Actor* ret = 0; + + const char* className = parms.className(); + if (nvidia::strcmp(className, GroundEmitterActorParameters::staticClassName()) == 0) + { + GroundEmitterActorDesc desc; + const GroundEmitterActorParameters* pDesc = static_cast<const GroundEmitterActorParameters*>(&parms); + + desc.density = pDesc->density; + desc.radius = pDesc->radius; + desc.raycastHeight = pDesc->raycastHeight; + desc.spawnHeight = pDesc->spawnHeight; + desc.maxRaycastsPerFrame = pDesc->maxRaycastsPerFrame; + desc.attachRelativePosition = pDesc->attachRelativePosition; + desc.initialPosition = pDesc->globalPose.p; + desc.rotation = pDesc->globalPose; + desc.rotation.p = PxVec3(0.0f); + + /* Resolve the authored collision group mask name into the actual ID */ + + ret = createActor(desc, apexScene); + + /* Resolve the authored collision group name into the actual ID */ + physx::PxFilterData* raycastGroupsMask = 0; + if (pDesc->raycastCollisionGroupMaskName != NULL && + pDesc->raycastCollisionGroupMaskName[0] != 0) + { + ResourceProviderIntl* nrp = mModule->mSdk->getInternalResourceProvider(); + ResID cgmns = mModule->mSdk->getCollisionGroup128NameSpace(); + ResID cgresid = nrp->createResource(cgmns, pDesc->raycastCollisionGroupMaskName); + raycastGroupsMask = static_cast<physx::PxFilterData*>(nrp->getResource(cgresid)); + } + else if (mShouldUseGroupsMask) + { + raycastGroupsMask = &mRaycastCollisionGroupsMask; + } + + // check the physx::PxFilterData specified in parms, set in actor if diff than default + if (raycastGroupsMask && ret ) + { + GroundEmitterActor* gea = static_cast<GroundEmitterActor*>(ret); + gea->setRaycastCollisionGroupsMask(raycastGroupsMask); + } + } + + return ret; +} + + +AssetPreview* GroundEmitterAssetImpl::createApexAssetPreview(const NvParameterized::Interface& parms, AssetPreviewScene* previewScene) +{ + AssetPreview* ret = 0; + + const char* className = parms.className(); + if (nvidia::strcmp(className, EmitterAssetPreviewParameters::staticClassName()) == 0) + { + GroundEmitterPreviewDesc desc; + const EmitterAssetPreviewParameters* pDesc = static_cast<const EmitterAssetPreviewParameters*>(&parms); + + desc.mPose = pDesc->pose; + desc.mScale = pDesc->scale; + + ret = createEmitterPreview(desc, previewScene); + } + + return ret; +} + + +GroundEmitterActor* GroundEmitterAssetImpl::createActor(const GroundEmitterActorDesc& desc, Scene& scene) +{ + if (!desc.isValid()) + { + return NULL; + } + EmitterScene* es = mModule->getEmitterScene(scene); + GroundEmitterActorImpl* ret = PX_NEW(GroundEmitterActorImpl)(desc, *this, mEmitterActors, *es); + + if (!ret->isValid()) + { + ret->destroy(); + return NULL; + } + + return ret; +} + +void GroundEmitterAssetImpl::releaseActor(GroundEmitterActor& nxactor) +{ + GroundEmitterActorImpl* actor = DYNAMIC_CAST(GroundEmitterActorImpl*)(&nxactor); + actor->destroy(); +} + +GroundEmitterPreview* GroundEmitterAssetImpl::createEmitterPreview(const GroundEmitterPreviewDesc& desc, AssetPreviewScene* previewScene) +{ + if (!desc.isValid()) + { + return NULL; + } + + GroundEmitterAssetPreview* p = PX_NEW(GroundEmitterAssetPreview)(desc, *this, GetApexSDK(), previewScene); + if (p && !p->isValid()) + { + p->destroy(); + p = NULL; + } + return p; +} + +void GroundEmitterAssetImpl::releaseEmitterPreview(GroundEmitterPreview& nxpreview) +{ + GroundEmitterAssetPreview* preview = DYNAMIC_CAST(GroundEmitterAssetPreview*)(&nxpreview); + preview->destroy(); +} + + +void GroundEmitterAssetImpl::release() +{ + mModule->mSdk->releaseAsset(*this); +} + +#ifndef WITHOUT_APEX_AUTHORING +void GroundEmitterAssetAuthoringImpl::release() +{ + mModule->mSdk->releaseAssetAuthoring(*this); +} + +void GroundEmitterAssetAuthoringImpl::addMeshForGroundMaterial(const MaterialFactoryMappingDesc& desc) +{ + NvParameterized::Handle arrayHandle(*mParams), indexHandle(*mParams), childHandle(*mParams); + NvParameterized::Interface* refPtr; + // resize map array + uint32_t newIdx = (*mMaterialFactoryMaps).size(); + (*mMaterialFactoryMaps).resize(newIdx + 1); + + // copy new desc in place + // floats + (*mMaterialFactoryMaps)[ newIdx ].weight = desc.weight; + (*mMaterialFactoryMaps)[ newIdx ].maxSlopeAngle = desc.maxSlopeAngle; + + // lod params + copyLodDesc((*mMaterialFactoryMaps)[ newIdx ].lodParamDesc, mCurLodParamDesc); + + // strings + // get a handle for the material factory map for this index into the dynamic array + mParams->getParameterHandle("materialFactoryMapList", arrayHandle); + arrayHandle.getChildHandle((int32_t)newIdx, indexHandle); + + indexHandle.getChildHandle(mParams, "iofxAssetName", childHandle); + mParams->initParamRef(childHandle, NULL, true); + mParams->getParamRef(childHandle, refPtr); + PX_ASSERT(refPtr); + if (refPtr) + { + refPtr->setName(desc.instancedObjectEffectsAssetName); + } + + indexHandle.getChildHandle(mParams, "iosAssetName", childHandle); + mParams->initParamRef(childHandle, desc.instancedObjectSimulationTypeName, true); + mParams->getParamRef(childHandle, refPtr); + PX_ASSERT(refPtr); + if (refPtr) + { + refPtr->setName(desc.instancedObjectSimulationAssetName); + } + + //setParamString( childHandle, desc.instancedObjectSimulationAssetName ); + + indexHandle.getChildHandle(mParams, "physMatName", childHandle); + mParams->setParamString(childHandle, desc.physicalMaterialName); +} + +GroundEmitterAssetAuthoringImpl::~GroundEmitterAssetAuthoringImpl() +{ +} +#endif + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/GroundEmitterAssetPreview.cpp b/APEX_1.4/module/emitter/src/GroundEmitterAssetPreview.cpp new file mode 100644 index 00000000..163fda49 --- /dev/null +++ b/APEX_1.4/module/emitter/src/GroundEmitterAssetPreview.cpp @@ -0,0 +1,134 @@ +/* + * 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. + */ + + +#include "RenderDebugInterface.h" +#include "GroundEmitterPreview.h" +#include "GroundEmitterAssetPreview.h" +#include "ApexPreview.h" +#include "ApexUsingNamespace.h" +#include "WriteCheck.h" +#include "ReadCheck.h" + +namespace nvidia +{ +namespace emitter +{ + +void GroundEmitterAssetPreview::drawEmitterPreview(void) +{ + WRITE_ZONE(); +#ifndef WITHOUT_DEBUG_VISUALIZE + if (!mApexRenderDebug) + { + return; + } + PxVec3 tmpUpDirection(0.0f, 1.0f, 0.0f); + + using RENDER_DEBUG::DebugColors; + + //asset preview init + if (mGroupID == 0) + { + mGroupID = RENDER_DEBUG_IFACE(mApexRenderDebug)->beginDrawGroup(PxMat44(PxIdentity)); + // Cylinder that describes the refresh radius, upDirection, and spawnHeight + RENDER_DEBUG_IFACE(mApexRenderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(mApexRenderDebug)->getDebugColor(DebugColors::Green)); + RENDER_DEBUG_IFACE(mApexRenderDebug)->debugCylinder( + PxVec3(0.0f), + tmpUpDirection * (mAsset->getSpawnHeight() + mAsset->getRaycastHeight() + 0.01f), + mAsset->getRadius()); + + // Ray that describes the raycast spawn height + RENDER_DEBUG_IFACE(mApexRenderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(mApexRenderDebug)->getDebugColor(DebugColors::Yellow), + RENDER_DEBUG_IFACE(mApexRenderDebug)->getDebugColor(DebugColors::Yellow)); + RENDER_DEBUG_IFACE(mApexRenderDebug)->setCurrentArrowSize(mScale); + RENDER_DEBUG_IFACE(mApexRenderDebug)->debugRay(tmpUpDirection * mAsset->getRaycastHeight(), PxVec3(0.0f)); + RENDER_DEBUG_IFACE(mApexRenderDebug)->endDrawGroup(); + } + + //asset preview set pose + PxMat44 groupPose = mPose; + RENDER_DEBUG_IFACE(mApexRenderDebug)->setDrawGroupPose(mGroupID, groupPose); + + //asset preview set visibility + RENDER_DEBUG_IFACE(mApexRenderDebug)->setDrawGroupVisible(mGroupID, true); +#endif +} + +void GroundEmitterAssetPreview::destroy(void) +{ + mApexRenderDebug = NULL; + ApexPreview::destroy(); + delete this; +} + +GroundEmitterAssetPreview::~GroundEmitterAssetPreview(void) +{ +} + +void GroundEmitterAssetPreview::setPose(const PxMat44& pose) +{ + WRITE_ZONE(); + mPose = PxTransform(pose); + drawEmitterPreview(); +} + +void GroundEmitterAssetPreview::setScale(float scale) +{ + WRITE_ZONE(); + mScale = scale; + drawEmitterPreview(); +} + +const PxMat44 GroundEmitterAssetPreview::getPose() const +{ + READ_ZONE(); + return(mPose); +} + +// from RenderDataProvider +void GroundEmitterAssetPreview::lockRenderResources(void) +{ + ApexRenderable::renderDataLock(); +} + +void GroundEmitterAssetPreview::unlockRenderResources(void) +{ + ApexRenderable::renderDataUnLock(); +} + +void GroundEmitterAssetPreview::updateRenderResources(bool /*rewriteBuffers*/, void* /*userRenderData*/) +{ + mApexRenderDebug->updateRenderResources(); +} + +// from Renderable.h +void GroundEmitterAssetPreview::dispatchRenderResources(UserRenderer& renderer) +{ + mApexRenderDebug->dispatchRenderResources(renderer); +} + +PxBounds3 GroundEmitterAssetPreview::getBounds(void) const +{ + return mApexRenderDebug->getBounds(); +} + +void GroundEmitterAssetPreview::release(void) +{ + if (mInRelease) + { + return; + } + mInRelease = true; + const_cast<GroundEmitterAssetImpl*>(mAsset)->releaseEmitterPreview(*this); +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/ImpactEmitterActorImpl.cpp b/APEX_1.4/module/emitter/src/ImpactEmitterActorImpl.cpp new file mode 100644 index 00000000..dce3b343 --- /dev/null +++ b/APEX_1.4/module/emitter/src/ImpactEmitterActorImpl.cpp @@ -0,0 +1,604 @@ +/* + * 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. + */ + + +#include "Apex.h" + +#include "ImpactEmitterAsset.h" +#include "ImpactEmitterActor.h" +#include "SceneIntl.h" +#include "RenderDebugInterface.h" +#include "InstancedObjectSimulationIntl.h" +#include "ImpactEmitterAssetImpl.h" +#include "ImpactEmitterActorImpl.h" +#include "EmitterScene.h" +#include "IofxAsset.h" + +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParamUtils.h" + +#include "ImpactObjectEvent.h" +#include "ParamArray.h" +#include "PsMathUtils.h" + +#include "ReadCheck.h" +#include "WriteCheck.h" + +//////////////////////////////////////////////////////////////////////////////// + +#define PI (3.1415926535897932384626433832795f) + +//////////////////////////////////////////////////////////////////////////////// +namespace nvidia +{ +namespace emitter +{ + +bool ImpactEmitterActorImpl::QueuedImpactEvent::trigger(float time) +{ + if (time > triggerTime) + { + eventDef->trigger(triggerParams); + return true; + } + else + { + return false; + } +} + +//////////////////////////////////////////////////////////////////////////////// +class ParticleEventTask : public PxTask, public UserAllocated +{ +public: + ParticleEventTask(ImpactEmitterParticleEvent* owner) : mOwner(owner) {} + + const char* getName() const + { + return "ImpactEmitterActorImpl::ParticleEventTask"; + } + void run() + { + mOwner->run(); + } + +protected: + ImpactEmitterParticleEvent* mOwner; +}; + + +void ImpactEmitterParticleEvent::trigger(const ImpactEventTriggerParams& params) +{ + if (mEventTask != NULL) + { + mTriggerQueue.pushBack(params); + } +} + +void ImpactEmitterParticleEvent::run() +{ + for (TriggerQueue::ConstIterator it = mTriggerQueue.begin(); it != mTriggerQueue.end(); ++it) + { + const ImpactEventTriggerParams& params = *it; + trigger(params.hitPos, params.hitDir, params.hitNorm); + } + mTriggerQueue.clear(); +} + +void ImpactEmitterParticleEvent::submitTasks(PxTaskManager* tm) +{ + if (mEventTask != NULL && mTriggerQueue.size() > 0) + { + tm->submitUnnamedTask(*mEventTask); + } +} + +void ImpactEmitterParticleEvent::setTaskDependencies(PxTask*) +{ + if (mEventTask != NULL && mTriggerQueue.size() > 0) + { + //mEventTask->startAfter( tickTask->getTaskID() ); + mEventTask->finishBefore(mParticleInjector->getCompletionTaskID()); + } +} + +ImpactEmitterParticleEvent::ImpactEmitterParticleEvent(NvParameterized::Interface* eventParamPtr, ImpactEmitterAssetImpl& asset, ImpactEmitterActorImpl* emitterActor): + ImpactEmitterBaseEvent(emitterActor), + mParticleInjector(NULL) + +{ + PX_ASSERT(eventParamPtr); + PX_ASSERT(!nvidia::strcmp(eventParamPtr->className(), ImpactObjectEvent::staticClassName())); + + mEventTask = NULL; + + ImpactObjectEvent* eventPtr = (ImpactObjectEvent*)eventParamPtr; + NvParameterized::Handle hEnum(*eventPtr); + + mAxis = AXIS_REFLECTION; + eventPtr->getParameterHandle("impactAxis", hEnum); + PX_ASSERT(hEnum.isValid()); + + // this assumes that the enums line up correctly, they do + int32_t axisInt = hEnum.parameterDefinition()->enumValIndex(eventPtr->impactAxis); + if (-1 != axisInt) + { + mAxis = (eAxisType)axisInt; + } + + mMinAngle = physx::shdfnd::degToRad(eventPtr->parameters().angleLow); + mMaxAngle = physx::shdfnd::degToRad(eventPtr->parameters().angleHigh); + mMinSpeed = eventPtr->parameters().speedLow; + mMaxSpeed = eventPtr->parameters().speedHigh; + mMinLife = eventPtr->parameters().lifeLow; + mMaxLife = eventPtr->parameters().lifeHigh; + mParticleSpawnCount = eventPtr->parameters().particleSpawnCount; + + + const char* iofxAssetName = eventPtr->parameters().iofxAssetName->name(); + IofxAsset* iofxAsset = static_cast<IofxAsset*>(asset.mIofxAssetTracker.getAssetFromName(iofxAssetName)); + IosAsset* iosAsset = asset.mIosAssetTracker.getIosAssetFromName(eventPtr->parameters().iosAssetName->className(), + eventPtr->parameters().iosAssetName->name()); + if (!iosAsset || !iofxAsset) + { + return; + } + + Actor* nxActor = iosAsset->createIosActor(*(mOwner->getApexScene()), iofxAsset); + InstancedObjectSimulationIntl* iosActor = NULL; + if (nxActor) + { + ApexActor* aa = GetInternalApexSDK()->getApexActor(nxActor); + if (aa) + { + iosActor = DYNAMIC_CAST(InstancedObjectSimulationIntl*)(aa); + } + } + if (!iosActor) + { + return; + } + + mParticleInjector = iosActor->allocateInjector(iofxAsset); + if (mParticleInjector) + { + mParticleInjector->setLODWeights( eventPtr->parameters().lodParamDesc.maxDistance, + eventPtr->parameters().lodParamDesc.distanceWeight, + eventPtr->parameters().lodParamDesc.speedWeight, + eventPtr->parameters().lodParamDesc.lifeWeight, + eventPtr->parameters().lodParamDesc.separationWeight, + eventPtr->parameters().lodParamDesc.bias); + + mParticleInjector->addSelfToContext(*mOwner); + mEventTask = PX_NEW(ParticleEventTask)(this); + PX_ASSERT(mEventTask); + + mOwner->mActiveParticleInjectors.pushBack(mParticleInjector); + } + else + { + return; + } + + mValid = true; +} + +ImpactEmitterParticleEvent::~ImpactEmitterParticleEvent() +{ + if (mEventTask) + { + delete mEventTask; + } + mEventTask = NULL; + + if (mParticleInjector) + { + mOwner->mActiveParticleInjectors.findAndReplaceWithLast(mParticleInjector); + + mParticleInjector->release(); + } + mParticleInjector = NULL; +} + +void ImpactEmitterParticleEvent::trigger(const PxVec3& hitPos, const PxVec3& hitDir, const PxVec3& hitNorm) +{ + if (!mParticleInjector) + { + return; + } + + PxVec3 eventBasis[3]; + if (mAxis == AXIS_INCIDENT) + { + eventBasis[0] = -hitDir; + } + else if (mAxis == AXIS_NORMAL) + { + eventBasis[0] = hitNorm; + } + else if (mAxis == AXIS_REFLECTION) + { + // this is also found in PxRay::ComputeReflexionVector() + eventBasis[0] = hitDir - (2 * hitDir.dot(hitNorm) * hitNorm); + } + else + { + // Error + return; + } + eventBasis[0].normalize(); + eventBasis[1] = PxVec3(eventBasis[0].y, eventBasis[0].z, eventBasis[0].x).cross(eventBasis[0]); + eventBasis[1].normalize(); + eventBasis[2] = eventBasis[1].cross(eventBasis[0]); + eventBasis[2].normalize(); + + IosNewObject* particles = (IosNewObject*) PX_ALLOC(sizeof(IosNewObject) * mParticleSpawnCount, PX_DEBUG_EXP("IosNewObject")); + IosNewObject* currParticle = particles; + for (int i = 0; i < (int)mParticleSpawnCount; ++i, ++currParticle) + { + initParticle(hitPos, eventBasis, currParticle->initialPosition, currParticle->initialVelocity, currParticle->lifetime); + + currParticle->iofxActorID = IofxActorIDIntl(0); + currParticle->lodBenefit = 0.0f; + currParticle->userData = 0; + } + mParticleInjector->createObjects(mParticleSpawnCount, particles); + + PX_FREE(particles); +} + +void ImpactEmitterParticleEvent::initParticle(const PxVec3& pos, const PxVec3 basis[], PxVec3& outPos, PxVec3& outVel, float& outLife) +{ + float theta = mOwner->mRand.getScaled(0.0f, 2.0f * PI); + float phi = mOwner->mRand.getScaled(mMinAngle, mMaxAngle); + float speed = mOwner->mRand.getScaled(mMinSpeed, mMaxSpeed); + + PxVec3 vel = speed * (PxCos(phi) * basis[0] + PxSin(phi) * PxCos(theta) * basis[1] + PxSin(phi) * PxSin(theta) * basis[2]); + + outPos = pos; + outVel = vel; + outLife = mOwner->mRand.getScaled(mMinLife, mMaxLife); +} + +void ImpactEmitterParticleEvent::setPreferredRenderVolume(nvidia::apex::RenderVolume* vol) +{ + if (mParticleInjector) + { + mParticleInjector->setPreferredRenderVolume(vol); + } +} + +//////////////////////////////////////////////////////////////////////////////// + +ImpactEmitterEventSet::~ImpactEmitterEventSet() +{ + for (uint32_t e = 0; e < entries.size(); ++e) + { + delete entries[e].evnt; + } +} + +//////////////////////////////////////////////////////////////////////////////// + +bool ImpactEmitterEventSet::AddEvent(NvParameterized::Interface* eventParamPtr, ImpactEmitterAssetImpl& asset, ImpactEmitterActorImpl* emitterActor) +{ + ImpactEmitterBaseEvent* e = NULL; + float delay = 0; + + PX_ASSERT(eventParamPtr); + + if(!nvidia::strcmp(eventParamPtr->className(), ImpactObjectEvent::staticClassName())) + { + e = PX_NEW(ImpactEmitterParticleEvent)(eventParamPtr, asset, emitterActor); + if (!e->isValid()) + { + PX_DELETE(e); + return false; + } + ImpactObjectEvent* objEvent = (ImpactObjectEvent*)eventParamPtr; + delay = objEvent->parameters().delay; + } + + if (e != NULL) + { + entries.pushBack(EventSetEntry(delay, e)); + } + else + { + return false; + } + + return true; +} + + +//////////////////////////////////////////////////////////////////////////////// + +class ImpactEmitterTickTask : public PxTask, public UserAllocated +{ +public: + ImpactEmitterTickTask(ImpactEmitterActorImpl* actor) : mActor(actor) {} + + const char* getName() const + { + return "ImpactEmitterActorImpl::TickTask"; + } + void run() + { + mActor->tick(); + } + +protected: + ImpactEmitterActorImpl* mActor; +}; + +ImpactEmitterActorImpl::ImpactEmitterActorImpl(const NvParameterized::Interface& desc, ImpactEmitterAssetImpl& asset, ResourceList& list, EmitterScene& scene) : + mTime(0.0f), + mAsset(&asset), + mScene(&scene), + mTickTask(NULL) +{ + mRand.setSeed(scene.mApexScene->getSeed()); + + /* Read default values from descriptor or authored asset */ + if (nvidia::strcmp(desc.className(), ImpactEmitterActorParameters::staticClassName()) == 0) + { + } + else + { + APEX_INVALID_OPERATION("%s is not a valid descriptor class", desc.className()); + } + + + // Insert self into data structures + list.add(*this); // Add self to asset's list of actors + addSelfToContext(*scene.mApexScene->getApexContext()); // Add self to ApexScene + addSelfToContext(scene); // Add self to EmitterScene's list of actors + + // Initialize data members + mTime = 0.f; + + ParamArray<NvParameterized::Interface*> assetEventSets(asset.mParams, + "eventSetList", + (ParamDynamicArrayStruct*) & (asset.mParams->eventSetList)); + //mEventSets.resize( asset.mEventSets.size() ); + mEventSets.resize(asset.mEventNameIndexMaps.size()); + + for (uint32_t s = 0; s < asset.mEventNameIndexMaps.size(); ++s) + { + for (uint32_t e = 0; e < asset.mEventNameIndexMaps[s]->eventIndices.size(); ++e) + { + uint32_t t = asset.mEventNameIndexMaps[s]->eventIndices[e]; + + if (!mEventSets[s].AddEvent(assetEventSets[t], asset, this)) + { + return; + } + } + } + + mTickTask = PX_NEW(ImpactEmitterTickTask)(this); + PX_ASSERT(mTickTask); + + mValid = true; +} + +ImpactEmitterActorImpl::~ImpactEmitterActorImpl() +{ + delete mTickTask; +} + +void ImpactEmitterActorImpl::setPreferredRenderVolume(RenderVolume* vol) +{ + WRITE_ZONE(); + for (uint32_t i = 0 ; i < mEventSets.size() ; i++) + { + for (uint32_t e = 0 ; e < mEventSets[i].entries.size() ; e++) + { + mEventSets[i].entries[e].evnt->setPreferredRenderVolume(vol); + } + } +} + +void ImpactEmitterActorImpl::submitTasks() +{ + float dt = mScene->mApexScene->getElapsedTime(); + mTime += dt; + + // Check queued events, triggering and removing those that have reached their trigger time + for (uint32_t e = 0; e < mPendingEvents.size();) + { + if (mPendingEvents[e].trigger(mTime)) + { + mPendingEvents.replaceWithLast(e); + } + else + { + e++; + } + } + + // + PxTaskManager* tm = mScene->mApexScene->getTaskManager(); + + tm->submitUnnamedTask(*mTickTask); + + // submitTasks for events + for (uint32_t i = 0 ; i < mEventSets.size() ; i++) + { + ImpactEmitterEventSet& set = mEventSets[i]; + for (uint32_t s = 0 ; s < set.entries.size() ; s++) + { + ImpactEmitterEventSet::EventSetEntry& entry = set.entries[s]; + entry.evnt->submitTasks(tm); + } + } +} + +void ImpactEmitterActorImpl::setTaskDependencies() +{ + PxTaskManager* tm = mScene->mApexScene->getTaskManager(); + + PxTaskID completionTaskID = tm->getNamedTask(AST_PHYSX_SIMULATE); + mTickTask->finishBefore(completionTaskID); + + // setTaskDependencies for events + for (uint32_t i = 0 ; i < mEventSets.size() ; i++) + { + ImpactEmitterEventSet& set = mEventSets[i]; + for (uint32_t s = 0 ; s < set.entries.size() ; s++) + { + ImpactEmitterEventSet::EventSetEntry& entry = set.entries[s]; + entry.evnt->setTaskDependencies(mTickTask); + } + } +} + +void ImpactEmitterActorImpl::fetchResults() +{ +} + + +Asset* ImpactEmitterActorImpl::getOwner() const +{ + READ_ZONE(); + return (Asset*) mAsset; +} + +ImpactEmitterAsset* ImpactEmitterActorImpl::getEmitterAsset() const +{ + READ_ZONE(); + return mAsset; +} + +SceneIntl* ImpactEmitterActorImpl::getApexScene() const +{ + return mScene->mApexScene; +} + +void ImpactEmitterActorImpl::getLodRange(float& min, float& max, bool& intOnly) const +{ + READ_ZONE(); + PX_UNUSED(min); + PX_UNUSED(max); + PX_UNUSED(intOnly); + APEX_INVALID_OPERATION("not implemented"); +} + +float ImpactEmitterActorImpl::getActiveLod() const +{ + READ_ZONE(); + APEX_INVALID_OPERATION("ImpactEmitterActor does not support this operation"); + return -1.0f; +} + +void ImpactEmitterActorImpl::forceLod(float lod) +{ + WRITE_ZONE(); + PX_UNUSED(lod); + APEX_INVALID_OPERATION("not implemented"); +} + +void ImpactEmitterActorImpl::release() +{ + if (mInRelease) + { + return; + } + mInRelease = true; + destroy(); +} + + +void ImpactEmitterActorImpl::destroy() +{ + /* Order is important here, pay attention */ + + // Remove ourselves from all contexts, so they don't get stuck trying to release us + ApexActor::destroy(); + + ApexContext::removeAllActors(); + + delete this; +} + +void ImpactEmitterActorImpl::removeActorAtIndex(uint32_t index) +{ + // A particle injector has been removed + for (uint32_t i = 0 ; i < mEventSets.size() ; i++) + { + ImpactEmitterEventSet& set = mEventSets[i]; + for (uint32_t s = 0 ; s < set.entries.size() ; s++) + { + ImpactEmitterEventSet::EventSetEntry& entry = set.entries[s]; + entry.evnt->removeActorReference(mActorArray[ index ]); + } + } + + ApexContext::removeActorAtIndex(index); + + release(); +} + +void ImpactEmitterActorImpl::tick() +{ +} + +void ImpactEmitterActorImpl::registerImpact(const PxVec3& hitPos, const PxVec3& hitDir, const PxVec3& surfNorm, uint32_t surfType) +{ + WRITE_ZONE(); + if (surfType < (uint32_t) mEventSets.size()) + { + // Check for non finite values (even in release build) + bool hitPosFinite = hitPos.isFinite(); + bool hitDirFinite = hitDir.isFinite(); + bool surfNormFinite = surfNorm.isFinite(); + if (hitPosFinite && hitDirFinite && surfNormFinite) + { + ImpactEmitterEventSet& eventSet = mEventSets[surfType]; + for (uint32_t e = 0; e < eventSet.entries.size(); ++e) + { + QueuedImpactEvent newEvent(hitPos, hitDir, surfNorm, mTime + eventSet.entries[e].dly, eventSet.entries[e].evnt); + mPendingEvents.pushBack(newEvent); + } + } + else + { + // Release and debug builds should output a warning message + + APEX_INVALID_PARAMETER("Asset Name: %s, hitPos: %s, hitDir: %s, surfNorm: %s, surface type: %d", + mAsset->mName.c_str(), + hitPosFinite ? "finite" : "nonFinite", + hitDirFinite ? "finite" : "nonFinite", + surfNormFinite ? "finite" : "nonFinite", + surfType); + + // We really want debug builds to catch the culprits here + PX_ASSERT(hitPos.isFinite()); + PX_ASSERT(hitDir.isFinite()); + PX_ASSERT(surfNorm.isFinite()); + } + } +} + +void ImpactEmitterActorImpl::visualize(RenderDebugInterface& renderDebug) +{ + if ( !mEnableDebugVisualization ) return; +#ifdef WITHOUT_DEBUG_VISUALIZE + PX_UNUSED(renderDebug); +#else + RENDER_DEBUG_IFACE(&renderDebug)->pushRenderState(); + RENDER_DEBUG_IFACE(&renderDebug)->setCurrentColor(RENDER_DEBUG_IFACE(&renderDebug)->getDebugColor(RENDER_DEBUG::DebugColors::Orange)); + RENDER_DEBUG_IFACE(&renderDebug)->popRenderState(); +#endif +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/ImpactEmitterAssetImpl.cpp b/APEX_1.4/module/emitter/src/ImpactEmitterAssetImpl.cpp new file mode 100644 index 00000000..e399e7c8 --- /dev/null +++ b/APEX_1.4/module/emitter/src/ImpactEmitterAssetImpl.cpp @@ -0,0 +1,361 @@ +/* + * 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. + */ + + +#include "Apex.h" +#include "IofxAsset.h" + +#include "ImpactEmitterAssetImpl.h" +#include "ImpactEmitterActorImpl.h" +#include "PsMemoryBuffer.h" + +#include "nvparameterized/NvParamUtils.h" +#include "ApexUsingNamespace.h" + +namespace nvidia +{ +namespace emitter +{ + + + +void ImpactEmitterAssetImpl::initializeAssetNameTable() +{ + /* initialize the exlosion, iofx, and ios asset names to resID tables */ + NvParameterized::Handle eventSetHandle(*mParams); + int numSets; + + mParams->getParameterHandle("eventSetList", eventSetHandle); + PX_ASSERT(eventSetHandle.isValid()); + + mParams->getArraySize(eventSetHandle, numSets); + for (int i = 0; i < numSets; i++) + { + NvParameterized::Handle ih(*mParams); + NvParameterized::Interface* eventPtr = 0; + + eventSetHandle.getChildHandle(i, ih); + PX_ASSERT(ih.isValid()); + + mParams->getParamRef(ih, eventPtr); + PX_ASSERT(eventPtr); + + ApexSimpleString tmpClassName(eventPtr->className()); + + + if (tmpClassName == "ImpactExplosionEvent") + { + APEX_DEBUG_WARNING("Invalid asset. ImpactExplosionEvent is not supported under PhysX 3."); + PX_ALWAYS_ASSERT(); + } + else if (tmpClassName == "ImpactObjectEvent") + { + ImpactObjectEvent* paramPtr = (ImpactObjectEvent*)eventPtr; + + mIofxAssetTracker.addAssetName(paramPtr->parameters().iofxAssetName->name(), false); + mIosAssetTracker.addAssetName(paramPtr->parameters().iosAssetName->className(), + paramPtr->parameters().iosAssetName->name()); + } + } +} + +void ImpactEmitterAssetImpl::preSerialize(void* userData_) +{ + PX_UNUSED(userData_); +} + +void ImpactEmitterAssetImpl::postDeserialize(void* userData_) +{ + PX_UNUSED(userData_); + initializeAssetNameTable(); + buildEventNameIndexMap(); +} + +void ImpactEmitterAssetImpl::buildEventNameIndexMap() +{ + // destroy old mappings + for (uint32_t j = 0; j < mEventNameIndexMaps.size(); j++) + { + if (mEventNameIndexMaps[j]) + { + delete mEventNameIndexMaps[j]; + } + } + + // loop through all event sets, build a mapping for each new name found + // and store all indices for that event set + ParamArray<NvParameterized::Interface*> assetEventSets(mParams, + "eventSetList", + (ParamDynamicArrayStruct*) & (mParams->eventSetList)); + + for (uint32_t i = 0; i < assetEventSets.size(); i++) + { + NvParameterized::Handle hEventSetName(*assetEventSets[i]); + const char* paramEventSetName = 0; + + NvParameterized::getParamString(*(assetEventSets[i]), "eventSetName", paramEventSetName); + if (!paramEventSetName) + { + APEX_DEBUG_WARNING("Invalid eventSetName from Impact Emitter event sets"); + continue; + } + + /* first see if the name is already here */ + bool foundEventSet = false; + for (uint32_t j = 0; j < mEventNameIndexMaps.size(); j++) + { + if (mEventNameIndexMaps[j]->eventSetName == paramEventSetName) + { + // add index to list + mEventNameIndexMaps[j]->eventIndices.pushBack((uint16_t)i); + foundEventSet = true; + } + } + + if (!foundEventSet) + { + /* now add it to the list */ + EventNameIndexMap* newMap = PX_NEW(EventNameIndexMap)(); + newMap->eventSetName = paramEventSetName; + newMap->eventIndices.pushBack((uint16_t)i); + mEventNameIndexMaps.pushBack(newMap); + } + } +} + +ImpactEmitterAssetImpl::ImpactEmitterAssetImpl(ModuleEmitterImpl* m, ResourceList& list, const char* name) : + mModule(m), + mName(name), + mIofxAssetTracker(m->mSdk, IOFX_AUTHORING_TYPE_NAME), + mIosAssetTracker(m->mSdk), + mDefaultActorParams(NULL), + mDefaultPreviewParams(NULL) +{ + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + mParams = (ImpactEmitterAssetParameters*)traits->createNvParameterized(ImpactEmitterAssetParameters::staticClassName()); + + PX_ASSERT(mParams); + + mParams->setSerializationCallback(this); + list.add(*this); +} + +ImpactEmitterAssetImpl::ImpactEmitterAssetImpl(ModuleEmitterImpl* m, + ResourceList& list, + NvParameterized::Interface* params, + const char* name) : + mModule(m), + mName(name), + mIofxAssetTracker(m->mSdk, IOFX_AUTHORING_TYPE_NAME), + mIosAssetTracker(m->mSdk), + mParams((ImpactEmitterAssetParameters*)params), + mDefaultActorParams(NULL), + mDefaultPreviewParams(NULL) +{ + // this may no longer make any sense + mParams->setSerializationCallback(this); + + // call this now to "initialize" the asset + postDeserialize(); + + list.add(*this); +} + +void ImpactEmitterAssetImpl::destroy() +{ + /* Assets that were forceloaded or loaded by actors will be automatically + * released by the ApexAssetTracker member destructors. + */ + + if (mParams) + { + mParams->destroy(); + mParams = NULL; + } + + if (mDefaultActorParams) + { + mDefaultActorParams->destroy(); + mDefaultActorParams = 0; + } + + if (mDefaultPreviewParams) + { + mDefaultPreviewParams->destroy(); + mDefaultPreviewParams = 0; + } + + delete this; +} + +ImpactEmitterAssetImpl::~ImpactEmitterAssetImpl() +{ + // cleanup the eventset name to indices map + for (uint32_t j = 0; j < mEventNameIndexMaps.size(); j++) + { + if (mEventNameIndexMaps[j]) + { + delete mEventNameIndexMaps[j]; + } + } +} + +NvParameterized::Interface* ImpactEmitterAssetImpl::getDefaultActorDesc() +{ + WRITE_ZONE(); + NvParameterized::ErrorType error = NvParameterized::ERROR_NONE; + PX_UNUSED(error); + + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + PX_ASSERT(traits); + if (!traits) + { + return NULL; + } + + // create if not yet created + if (!mDefaultActorParams) + { + const char* className = ImpactEmitterActorParameters::staticClassName(); + NvParameterized::Interface* param = traits->createNvParameterized(className); + mDefaultActorParams = static_cast<ImpactEmitterActorParameters*>(param); + + PX_ASSERT(param); + if (!param) + { + return NULL; + } + } + NvParameterized::Handle hDest(*mDefaultActorParams); + + return mDefaultActorParams; +} + +NvParameterized::Interface* ImpactEmitterAssetImpl::getDefaultAssetPreviewDesc() +{ + WRITE_ZONE(); + NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits(); + PX_ASSERT(traits); + if (!traits) + { + return NULL; + } + + // create if not yet created + if (!mDefaultPreviewParams) + { + const char* className = EmitterAssetPreviewParameters::staticClassName(); + NvParameterized::Interface* param = traits->createNvParameterized(className); + mDefaultPreviewParams = static_cast<EmitterAssetPreviewParameters*>(param); + + PX_ASSERT(param); + if (!param) + { + return NULL; + } + } + + return mDefaultPreviewParams; +} + +Actor* ImpactEmitterAssetImpl::createApexActor(const NvParameterized::Interface& parms, Scene& apexScene) +{ + WRITE_ZONE(); + if (!isValidForActorCreation(parms, apexScene)) + { + return NULL; + } + + Actor* ret = 0; + + const char* className = parms.className(); + if (nvidia::strcmp(className, ImpactEmitterActorParameters::staticClassName()) == 0) + { + EmitterScene* es = mModule->getEmitterScene(apexScene); + ImpactEmitterActorImpl* actor = PX_NEW(ImpactEmitterActorImpl)(parms, *this, mEmitterActors, *es); + if (!actor->isValid()) + { + actor->destroy(); + return NULL; + } + + ret = actor; + } + else + { + APEX_INVALID_OPERATION("%s is not a valid descriptor class, expecting %s", className, ImpactEmitterActorParameters::staticClassName()); + } + + return ret; +} + +AssetPreview* ImpactEmitterAssetImpl::createApexAssetPreview(const NvParameterized::Interface& /*params*/, AssetPreviewScene* /*previewScene*/) +{ + WRITE_ZONE(); + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; +} + +uint32_t ImpactEmitterAssetImpl::querySetID(const char* setName) +{ + WRITE_ZONE(); + for (uint32_t i = 0; i < mEventNameIndexMaps.size(); ++i) + { + if (mEventNameIndexMaps[i]->eventSetName == setName) + { + return i; + } + } + return 0; // return the default event set if no match is found +} + +void ImpactEmitterAssetImpl::getSetNames(const char** outSetNames, uint32_t& inOutNameCount) const +{ + READ_ZONE(); + if (mEventNameIndexMaps.size() > inOutNameCount) + { + inOutNameCount = 0xffffffff; + return; + } + + inOutNameCount = mEventNameIndexMaps.size(); + for (uint32_t i = 0; i < mEventNameIndexMaps.size(); ++i) + { + outSetNames[i] = mEventNameIndexMaps[i]->eventSetName.c_str(); + } +} + +uint32_t ImpactEmitterAssetImpl::forceLoadAssets() +{ + WRITE_ZONE(); + uint32_t assetLoadedCount = 0; + + assetLoadedCount += mIofxAssetTracker.forceLoadAssets(); + assetLoadedCount += mIosAssetTracker.forceLoadAssets(); + + return assetLoadedCount; +} + + +void ImpactEmitterAssetImpl::release() +{ + mModule->mSdk->releaseAsset(*this); +} + +#ifndef WITHOUT_APEX_AUTHORING +void ImpactEmitterAssetAuthoringImpl::release() +{ + mModule->mSdk->releaseAssetAuthoring(*this); +} + +#endif + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/ModuleEmitterImpl.cpp b/APEX_1.4/module/emitter/src/ModuleEmitterImpl.cpp new file mode 100644 index 00000000..4ff3b3fc --- /dev/null +++ b/APEX_1.4/module/emitter/src/ModuleEmitterImpl.cpp @@ -0,0 +1,510 @@ +/* + * 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. + */ + + +#include "ApexDefs.h" +#include "ModuleIntl.h" +#include "ModuleEmitterImpl.h" +#include "ModuleEmitterRegistration.h" +#include "EmitterAssetImpl.h" +#include "GroundEmitterAssetImpl.h" +#include "ImpactEmitterAssetImpl.h" +#include "SceneIntl.h" +#include "EmitterScene.h" +#include "PsMemoryBuffer.h" +#include "EmitterActorImpl.h" +#include "GroundEmitterActorImpl.h" +#include "ImpactEmitterActorImpl.h" +#include "ModulePerfScope.h" +using namespace emitter; + +#include "Apex.h" +#include "ApexSDKIntl.h" +#include "ApexUsingNamespace.h" + +namespace nvidia +{ +namespace apex +{ + +#if defined(_USRDLL) + +/* Modules don't have to link against the framework, they keep their own */ +ApexSDKIntl* gApexSdk = 0; +ApexSDK* GetApexSDK() +{ + return gApexSdk; +} +ApexSDKIntl* GetInternalApexSDK() +{ + return gApexSdk; +} + +APEX_API Module* CALL_CONV createModule( + ApexSDKIntl* inSdk, + ModuleIntl** niRef, + uint32_t APEXsdkVersion, + uint32_t PhysXsdkVersion, + ApexCreateError* errorCode) +{ + if (APEXsdkVersion != APEX_SDK_VERSION) + { + if (errorCode) + { + *errorCode = APEX_CE_WRONG_VERSION; + } + return NULL; + } + + if (PhysXsdkVersion != PX_PHYSICS_VERSION) + { + if (errorCode) + { + *errorCode = APEX_CE_WRONG_VERSION; + } + return NULL; + } + + gApexSdk = inSdk; + initModuleProfiling(inSdk, "Emitter"); + ModuleEmitter* impl = PX_NEW(ModuleEmitter)(inSdk); + *niRef = (ModuleIntl*) impl; + return (Module*) impl; +} + +#else /* !_USRDLL */ + +/* Statically linking entry function */ +void instantiateModuleEmitter() +{ + ApexSDKIntl* sdk = GetInternalApexSDK(); + emitter::ModuleEmitterImpl* impl = PX_NEW(emitter::ModuleEmitterImpl)(sdk); + sdk->registerExternalModule((Module*) impl, (ModuleIntl*) impl); +} + +#endif +} +namespace emitter +{ +/* === ModuleEmitter Implementation === */ + +AuthObjTypeID EmitterAssetImpl::mAssetTypeID; +AuthObjTypeID GroundEmitterAssetImpl::mAssetTypeID; +AuthObjTypeID ImpactEmitterAssetImpl::mAssetTypeID; + +AuthObjTypeID ModuleEmitterImpl::getModuleID() const +{ + return EmitterAssetImpl::mAssetTypeID; +} +AuthObjTypeID ModuleEmitterImpl::getEmitterAssetTypeID() const +{ + return EmitterAssetImpl::mAssetTypeID; +} + +#ifdef WITHOUT_APEX_AUTHORING + +class ApexEmitterAssetDummyAuthoring : public AssetAuthoring, public UserAllocated +{ +public: + ApexEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) + { + PX_UNUSED(module); + PX_UNUSED(list); + PX_UNUSED(params); + PX_UNUSED(name); + } + + ApexEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list, const char* name) + { + PX_UNUSED(module); + PX_UNUSED(list); + PX_UNUSED(name); + } + + ApexEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list) + { + PX_UNUSED(module); + PX_UNUSED(list); + } + + virtual void setToolString(const char* /*toolName*/, const char* /*toolVersion*/, uint32_t /*toolChangelist*/) + { + + } + + + virtual void release() + { + destroy(); + } + + // internal + void destroy() + { + delete this; + } + + /** + * \brief Returns the name of this APEX authorable object type + */ + virtual const char* getObjTypeName() const + { + return EmitterAssetImpl::getClassName(); + } + + /** + * \brief Prepares a fully authored Asset Authoring object for a specified platform + */ + virtual bool prepareForPlatform(nvidia::apex::PlatformTag) + { + PX_ASSERT(0); + return false; + } + + const char* getName(void) const + { + return NULL; + } + + /** + * \brief Save asset's NvParameterized interface, may return NULL + */ + virtual NvParameterized::Interface* getNvParameterized() const + { + PX_ASSERT(0); + return NULL; + } + + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + PX_ALWAYS_ASSERT(); + return NULL; + } +}; + +class GroundEmitterAssetDummyAuthoring : public AssetAuthoring, public UserAllocated +{ +public: + GroundEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) + { + PX_UNUSED(module); + PX_UNUSED(list); + PX_UNUSED(params); + PX_UNUSED(name); + } + + GroundEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list, const char* name) + { + PX_UNUSED(module); + PX_UNUSED(list); + PX_UNUSED(name); + } + + GroundEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list) + { + PX_UNUSED(module); + PX_UNUSED(list); + } + + virtual void setToolString(const char* /*toolName*/, const char* /*toolVersion*/, uint32_t /*toolChangelist*/) + { + + } + + + virtual void release() + { + destroy(); + } + + // internal + void destroy() + { + delete this; + } + + /** + * \brief Returns the name of this APEX authorable object type + */ + virtual const char* getObjTypeName() const + { + return GroundEmitterAssetImpl::getClassName(); + } + + /** + * \brief Prepares a fully authored Asset Authoring object for a specified platform + */ + virtual bool prepareForPlatform(nvidia::apex::PlatformTag) + { + PX_ASSERT(0); + return false; + } + + const char* getName(void) const + { + return NULL; + } + + /** + * \brief Save asset's NvParameterized interface, may return NULL + */ + virtual NvParameterized::Interface* getNvParameterized() const + { + PX_ASSERT(0); + return NULL; + } + + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + PX_ALWAYS_ASSERT(); + return NULL; + } +}; + +class ImpactEmitterAssetDummyAuthoring : public AssetAuthoring, public UserAllocated +{ +public: + ImpactEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) + { + PX_UNUSED(module); + PX_UNUSED(list); + PX_UNUSED(params); + PX_UNUSED(name); + } + + ImpactEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list, const char* name) + { + PX_UNUSED(module); + PX_UNUSED(list); + PX_UNUSED(name); + } + + ImpactEmitterAssetDummyAuthoring(ModuleEmitterImpl* module, ResourceList& list) + { + PX_UNUSED(module); + PX_UNUSED(list); + } + + virtual void setToolString(const char* /*toolName*/, const char* /*toolVersion*/, uint32_t /*toolChangelist*/) + { + + } + + + virtual void release() + { + destroy(); + } + + // internal + void destroy() + { + delete this; + } + + const char* getName(void) const + { + return NULL; + } + + /** + * \brief Returns the name of this APEX authorable object type + */ + virtual const char* getObjTypeName() const + { + return ImpactEmitterAssetImpl::getClassName(); + } + + /** + * \brief Prepares a fully authored Asset Authoring object for a specified platform + */ + virtual bool prepareForPlatform(nvidia::apex::PlatformTag) + { + PX_ASSERT(0); + return false; + } + + /** + * \brief Save asset's NvParameterized interface, may return NULL + */ + virtual NvParameterized::Interface* getNvParameterized() const + { + PX_ASSERT(0); + return NULL; + } + + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + PX_ALWAYS_ASSERT(); + return NULL; + } +}; + + + +typedef ApexAuthorableObject<ModuleEmitterImpl, EmitterAssetImpl, ApexEmitterAssetDummyAuthoring> ApexEmitterAO; +typedef ApexAuthorableObject<ModuleEmitterImpl, GroundEmitterAssetImpl, GroundEmitterAssetDummyAuthoring> GroundEmitterAO; +typedef ApexAuthorableObject<ModuleEmitterImpl, ImpactEmitterAssetImpl, ImpactEmitterAssetDummyAuthoring> ImpactEmitterAO; + +#else +typedef ApexAuthorableObject<ModuleEmitterImpl, EmitterAssetImpl, EmitterAssetAuthoringImpl> ApexEmitterAO; +typedef ApexAuthorableObject<ModuleEmitterImpl, GroundEmitterAssetImpl, GroundEmitterAssetAuthoringImpl> GroundEmitterAO; +typedef ApexAuthorableObject<ModuleEmitterImpl, ImpactEmitterAssetImpl, ImpactEmitterAssetAuthoringImpl> ImpactEmitterAO; +#endif + +ModuleEmitterImpl::ModuleEmitterImpl(ApexSDKIntl* inSdk) +{ + mName = "Emitter"; + mSdk = inSdk; + mApiProxy = this; + mModuleParams = NULL; + + /* Register asset type and create a namespace for its assets */ + const char* pName = ApexEmitterAssetParameters::staticClassName(); + ApexEmitterAO* eAO = PX_NEW(ApexEmitterAO)(this, mAuthorableObjects, pName); + + pName = GroundEmitterAssetParameters::staticClassName(); + GroundEmitterAO* geAO = PX_NEW(GroundEmitterAO)(this, mAuthorableObjects, pName); + + pName = ImpactEmitterAssetParameters::staticClassName(); + ImpactEmitterAO* ieAO = PX_NEW(ImpactEmitterAO)(this, mAuthorableObjects, pName); + + EmitterAssetImpl::mAssetTypeID = eAO->getResID(); + GroundEmitterAssetImpl::mAssetTypeID = geAO->getResID(); + ImpactEmitterAssetImpl::mAssetTypeID = ieAO->getResID(); + + mRateScale = 1.f; + mDensityScale = 1.f; + mGroundDensityScale = 1.f; + + /* Register the NvParameterized factories */ + NvParameterized::Traits* traits = mSdk->getParameterizedTraits(); + ModuleEmitterRegistration::invokeRegistration(traits); +} + +ApexActor* ModuleEmitterImpl::getApexActor(Actor* nxactor, AuthObjTypeID type) const +{ + if (type == EmitterAssetImpl::mAssetTypeID) + { + return (EmitterActorImpl*) nxactor; + } + else if (type == GroundEmitterAssetImpl::mAssetTypeID) + { + return (GroundEmitterActorImpl*) nxactor; + } + else if (type == ImpactEmitterAssetImpl::mAssetTypeID) + { + return (ImpactEmitterActorImpl*) nxactor; + } + + return NULL; +} + +NvParameterized::Interface* ModuleEmitterImpl::getDefaultModuleDesc() +{ + WRITE_ZONE(); + NvParameterized::Traits* traits = mSdk->getParameterizedTraits(); + + if (!mModuleParams) + { + mModuleParams = DYNAMIC_CAST(EmitterModuleParameters*) + (traits->createNvParameterized("EmitterModuleParameters")); + PX_ASSERT(mModuleParams); + } + else + { + mModuleParams->initDefaults(); + } + + return mModuleParams; +} + +void ModuleEmitterImpl::init(const ModuleEmitterDesc& desc) +{ + WRITE_ZONE(); + PX_UNUSED(desc); +} + +ModuleEmitterImpl::~ModuleEmitterImpl() +{ +} + +void ModuleEmitterImpl::destroy() +{ + NvParameterized::Traits* traits = mSdk->getParameterizedTraits(); + + if (mModuleParams) + { + mModuleParams->destroy(); + mModuleParams = NULL; + } + + ModuleBase::destroy(); + + if (traits) + { + ModuleEmitterRegistration::invokeUnregistration(traits); + } + + delete this; +} + +ModuleSceneIntl* ModuleEmitterImpl::createInternalModuleScene(SceneIntl& scene, RenderDebugInterface* debugRender) +{ + return PX_NEW(EmitterScene)(*this, scene, debugRender, mEmitterScenes); +} + +void ModuleEmitterImpl::releaseModuleSceneIntl(ModuleSceneIntl& scene) +{ + EmitterScene* es = DYNAMIC_CAST(EmitterScene*)(&scene); + es->destroy(); +} + +uint32_t ModuleEmitterImpl::forceLoadAssets() +{ + uint32_t loadedAssetCount = 0; + + for (uint32_t i = 0; i < mAuthorableObjects.getSize(); i++) + { + AuthorableObjectIntl* ao = static_cast<AuthorableObjectIntl*>(mAuthorableObjects.getResource(i)); + loadedAssetCount += ao->forceLoadAssets(); + } + + return loadedAssetCount; +} + +EmitterScene* ModuleEmitterImpl::getEmitterScene(const Scene& apexScene) +{ + for (uint32_t i = 0 ; i < mEmitterScenes.getSize() ; i++) + { + EmitterScene* es = DYNAMIC_CAST(EmitterScene*)(mEmitterScenes.getResource(i)); + if (es->mApexScene == &apexScene) + { + return es; + } + } + + PX_ASSERT(!"Unable to locate an appropriate EmitterScene"); + return NULL; +} + +RenderableIterator* ModuleEmitterImpl::createRenderableIterator(const Scene& apexScene) +{ + EmitterScene* es = getEmitterScene(apexScene); + if (es) + { + return es->createRenderableIterator(); + } + + return NULL; +} + +} +} // namespace nvidia::apex diff --git a/APEX_1.4/module/emitter/src/autogen/ApexEmitterActorParameters.cpp b/APEX_1.4/module/emitter/src/autogen/ApexEmitterActorParameters.cpp new file mode 100644 index 00000000..7b0b69a9 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/ApexEmitterActorParameters.cpp @@ -0,0 +1,490 @@ +// 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 + + +#include "ApexEmitterActorParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace ApexEmitterActorParametersNS; + +const char* const ApexEmitterActorParametersFactory::vptr = + NvParameterized::getVptr<ApexEmitterActorParameters, ApexEmitterActorParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 8; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, 4, 5, 6, 7, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 7 }, + { TYPE_TRANSFORM, false, (size_t)(&((ParametersStruct*)0)->initialPose), NULL, 0 }, // initialPose + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->initialScale), NULL, 0 }, // initialScale + { TYPE_TRANSFORM, false, (size_t)(&((ParametersStruct*)0)->attachRelativePose), NULL, 0 }, // attachRelativePose + { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->emitAssetParticles), NULL, 0 }, // emitAssetParticles + { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->overlapTestGroupMaskName), NULL, 0 }, // overlapTestGroupMaskName + { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->overlapTestGroupsMask128Name), NULL, 0 }, // overlapTestGroupsMask128Name + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->emitterDuration), NULL, 0 }, // emitterDuration +}; + + +bool ApexEmitterActorParameters::mBuiltFlag = false; +NvParameterized::MutexType ApexEmitterActorParameters::mBuiltFlagMutex; + +ApexEmitterActorParameters::ApexEmitterActorParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &ApexEmitterActorParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +ApexEmitterActorParameters::~ApexEmitterActorParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void ApexEmitterActorParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~ApexEmitterActorParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* ApexEmitterActorParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* ApexEmitterActorParameters::getParameterDefinitionTree(void) const +{ + ApexEmitterActorParameters* tmpParam = const_cast<ApexEmitterActorParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType ApexEmitterActorParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType ApexEmitterActorParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void ApexEmitterActorParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ApexEmitterActorParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void ApexEmitterActorParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void ApexEmitterActorParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class is used for creating EmitterActor instances", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="initialPose" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("initialPose", TYPE_TRANSFORM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The initial pose where the emitter actor will be put into the scene", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="initialScale" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("initialScale", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The space scale of the emitter", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="attachRelativePose" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("attachRelativePose", TYPE_TRANSFORM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The emitter will offset this value from the attach actor pose.", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="emitAssetParticles" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("emitAssetParticles", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "In case this emitter has EmitterGeomExplicit geometry type, it can store a particle list in its asset and also in its actor instance.\nSo if this parameter equals to true, then both particle lists from asset and actor instance will be emitted.\nAnd if this paramater equals to false, then only particle list from actor instance will be emitterd.\n", true); + HintTable[1].init("shortDescription", "Indicates whether authored asset particle list will be emitted, defaults to true (Used only in case of EmitterGeomExplicit type)", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=5, longName="overlapTestGroupMaskName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5]; + ParamDef->init("overlapTestGroupMaskName", TYPE_STRING, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "This name resolves to a 32-bit bitmask of collision groups for overlap tests when particles are \nspawned. It is resolved by a call to the named resource provider using the 'NSCollisionGroupMask' \nnamespace. If none is provided, the raycast will hit everything in the scene. \nThis avoids storing fragile enums in asset files. \n", true); + HintTable[1].init("shortDescription", "Overlap Test Collision Group Mask Name", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=6, longName="overlapTestGroupsMask128Name" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6]; + ParamDef->init("overlapTestGroupsMask128Name", TYPE_STRING, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "This name resolves to a 128-bit GroupsMask used for overlap tests when particles are spawned.\nIt is resolved by a call to the named resource provider using the 'NSCollisionGroup128' \n", true); + HintTable[1].init("shortDescription", "Overlap Test 128-bit Collision Groups Mask", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=7, longName="emitterDuration" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7]; + ParamDef->init("emitterDuration", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("min", uint64_t(0), true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "Specifies a duration (in seconds) that the emitter will emit for after being enabled.\nAfter the specified duration, the emitter will turn off, unless it has already been explicitly turned off via an API call.\nThe special value 0.0f means there is no duration, and the emitter will remain on until explicitly turned off.", true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Emitter duration time (in seconds)", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[7]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + Children[3] = PDEF_PTR(4); + Children[4] = PDEF_PTR(5); + Children[5] = PDEF_PTR(6); + Children[6] = PDEF_PTR(7); + + ParamDefTable[0].setChildren(Children, 7); + } + + mBuiltFlag = true; + +} +void ApexEmitterActorParameters::initStrings(void) +{ + overlapTestGroupMaskName.isAllocated = true; + overlapTestGroupMaskName.buf = NULL; + overlapTestGroupsMask128Name.isAllocated = true; + overlapTestGroupsMask128Name.buf = NULL; +} + +void ApexEmitterActorParameters::initDynamicArrays(void) +{ +} + +void ApexEmitterActorParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + initialPose = physx::PxTransform(physx::PxIdentity); + initialScale = float(1.0); + attachRelativePose = physx::PxTransform(physx::PxIdentity); + emitAssetParticles = bool(true); + emitterDuration = float(PX_MAX_F32); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void ApexEmitterActorParameters::initReferences(void) +{ +} + +void ApexEmitterActorParameters::freeDynamicArrays(void) +{ +} + +void ApexEmitterActorParameters::freeStrings(void) +{ + + if (overlapTestGroupMaskName.isAllocated && overlapTestGroupMaskName.buf) + { + mParameterizedTraits->strfree((char*)overlapTestGroupMaskName.buf); + } + + if (overlapTestGroupsMask128Name.isAllocated && overlapTestGroupsMask128Name.buf) + { + mParameterizedTraits->strfree((char*)overlapTestGroupsMask128Name.buf); + } +} + +void ApexEmitterActorParameters::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/ApexEmitterAssetParameters.cpp b/APEX_1.4/module/emitter/src/autogen/ApexEmitterAssetParameters.cpp new file mode 100644 index 00000000..5005f2a7 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/ApexEmitterAssetParameters.cpp @@ -0,0 +1,1159 @@ +// 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 + + +#include "ApexEmitterAssetParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace ApexEmitterAssetParametersNS; + +const char* const ApexEmitterAssetParametersFactory::vptr = + NvParameterized::getVptr<ApexEmitterAssetParameters, ApexEmitterAssetParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 26; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, 4, 5, 6, 7, 8, 16, 17, 18, 19, 20, 21, 22, 9, 10, 11, 12, 13, 14, 15, 23, + 24, 25, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 15 }, + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->density), NULL, 0 }, // density + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->rate), NULL, 0 }, // rate + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->lifetimeLow), NULL, 0 }, // lifetimeLow + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->lifetimeHigh), NULL, 0 }, // lifetimeHigh + { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->velocityLow), NULL, 0 }, // velocityLow + { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->velocityHigh), NULL, 0 }, // velocityHigh + { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->maxSamples), NULL, 0 }, // maxSamples + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->lodParamDesc), CHILDREN(15), 7 }, // lodParamDesc + { TYPE_U32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->version), NULL, 0 }, // lodParamDesc.version + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->maxDistance), NULL, 0 }, // lodParamDesc.maxDistance + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->distanceWeight), NULL, 0 }, // lodParamDesc.distanceWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->speedWeight), NULL, 0 }, // lodParamDesc.speedWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->lifeWeight), NULL, 0 }, // lodParamDesc.lifeWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->separationWeight), NULL, 0 }, // lodParamDesc.separationWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->bias), NULL, 0 }, // lodParamDesc.bias + { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->iofxAssetName), NULL, 0 }, // iofxAssetName + { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->iosAssetName), NULL, 0 }, // iosAssetName + { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->geometryType), NULL, 0 }, // geometryType + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->emitterDuration), NULL, 0 }, // emitterDuration + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->emitterVelocityScale), NULL, 0 }, // emitterVelocityScale + { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->minSamplingFPS), NULL, 0 }, // minSamplingFPS + { TYPE_ARRAY, true, (size_t)(&((ParametersStruct*)0)->rateVsTimeCurvePoints), CHILDREN(22), 1 }, // rateVsTimeCurvePoints + { TYPE_STRUCT, false, 1 * sizeof(rateVsTimeCurvePoint_Type), CHILDREN(23), 2 }, // rateVsTimeCurvePoints[] + { TYPE_F32, false, (size_t)(&((rateVsTimeCurvePoint_Type*)0)->x), NULL, 0 }, // rateVsTimeCurvePoints[].x + { TYPE_F32, false, (size_t)(&((rateVsTimeCurvePoint_Type*)0)->y), NULL, 0 }, // rateVsTimeCurvePoints[].y +}; + + +bool ApexEmitterAssetParameters::mBuiltFlag = false; +NvParameterized::MutexType ApexEmitterAssetParameters::mBuiltFlagMutex; + +ApexEmitterAssetParameters::ApexEmitterAssetParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &ApexEmitterAssetParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +ApexEmitterAssetParameters::~ApexEmitterAssetParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void ApexEmitterAssetParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~ApexEmitterAssetParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* ApexEmitterAssetParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* ApexEmitterAssetParameters::getParameterDefinitionTree(void) const +{ + ApexEmitterAssetParameters* tmpParam = const_cast<ApexEmitterAssetParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType ApexEmitterAssetParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType ApexEmitterAssetParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void ApexEmitterAssetParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ApexEmitterAssetParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void ApexEmitterAssetParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void ApexEmitterAssetParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "This class contains the parameters for the APEX Emitter asset. The APEX Emitter is sometimes described\nas a shaped APEX Emitter because it contains the box, sphere, and sphere shell shapes. It also\nincludes an explicit shape that allows for preauthored particles positions and velocities and runtime\nparticle injections.\n", true); + HintTable[1].init("shortDescription", "APEX Emitter Asset Parameters", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="density" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("density", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("tweakable", "true", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "For an explicit emitter, the density is actually a spawn probability. For the shaped emitters, it represents the density of the particles per unit volume.\n", true); + HintTable[1].init("shortDescription", "Desired density of spawned particles per unit of volume.", true); + HintTable[2].init("tweakable", "true", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="rate" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("rate", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("tweakable", "true", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "TODO\n", true); + HintTable[1].init("shortDescription", "TODO", true); + HintTable[2].init("tweakable", "true", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="lifetimeLow" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("lifetimeLow", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("tweakable", "true", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "The emitter actor will create particles with a random lifetime (in seconds) within the lifetime range.\n", true); + HintTable[1].init("shortDescription", "Low value of particle lifetime", true); + HintTable[2].init("tweakable", "true", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="lifetimeHigh" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("lifetimeHigh", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("tweakable", "true", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "The emitter actor will create particles with a random lifetime (in seconds) within the lifetime range.\n", true); + HintTable[1].init("shortDescription", "High value of particle lifetime", true); + HintTable[2].init("tweakable", "true", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=5, longName="velocityLow" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5]; + ParamDef->init("velocityLow", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("tweakable", "true", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("longDescription", "The emitter actor will create particles with a random velocity within the velocity range.\n", true); + HintTable[2].init("shortDescription", "Random velocity given within range", true); + HintTable[3].init("tweakable", "true", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=6, longName="velocityHigh" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6]; + ParamDef->init("velocityHigh", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("tweakable", "true", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("longDescription", "The emitter actor will create particles with a random velocity within the velocity range.\n", true); + HintTable[2].init("shortDescription", "Random velocity given within range", true); + HintTable[3].init("tweakable", "true", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=7, longName="maxSamples" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7]; + ParamDef->init("maxSamples", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("longDescription", "For an explicit emitter, Max Samples is ignored. For shaped emitters, it is the maximum number of particles spawned in a step.\n", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Shaped emitter only. Max particles spawned each step.", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=8, longName="lodParamDesc" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8]; + ParamDef->init("lodParamDesc", TYPE_STRUCT, "emitterLodParamDesc", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("tweakable", "true", true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("shortDescription", "Bias given to this emitter when sharing IOS with another emitter", true); + HintTable[1].init("tweakable", "true", true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=9, longName="lodParamDesc.version" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9]; + ParamDef->init("version", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("shortDescription", "Helpful documentation goes here", true); + ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=10, longName="lodParamDesc.maxDistance" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[10]; + ParamDef->init("maxDistance", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Objects greater than this distance from the player will be culled more aggressively", true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=11, longName="lodParamDesc.distanceWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[11]; + ParamDef->init("distanceWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to distance parameter in LOD function", true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=12, longName="lodParamDesc.speedWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[12]; + ParamDef->init("speedWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to velocity parameter in LOD function", true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=13, longName="lodParamDesc.lifeWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[13]; + ParamDef->init("lifeWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to life remain parameter in LOD function", true); + ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=14, longName="lodParamDesc.separationWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[14]; + ParamDef->init("separationWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to separation parameter in LOD function", true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=15, longName="lodParamDesc.bias" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[15]; + ParamDef->init("bias", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Bias given to objects spawned by this emitter, relative to other emitters in the same IOS", true); + ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=16, longName="iofxAssetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[16]; + ParamDef->init("iofxAssetName", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("DISPLAY_NAME", "Graphics Effect (IOFX)", true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("DISPLAY_NAME", "Graphics Effect (IOFX)", true); + HintTable[1].init("shortDescription", "The name of the instanced object effects asset that will render particles", true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "IOFX" }; + ParamDefTable[16].setRefVariantVals((const char**)RefVariantVals, 1); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=17, longName="iosAssetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[17]; + ParamDef->init("iosAssetName", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("DISPLAY_NAME", "Particle Simulation (IOS)", true); + ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("DISPLAY_NAME", "Particle Simulation (IOS)", true); + HintTable[1].init("shortDescription", "The asset name of the IOS and the type of IOS that will simulate particles", true); + ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "BasicIosAsset", "ParticleIosAsset" }; + ParamDefTable[17].setRefVariantVals((const char**)RefVariantVals, 2); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=18, longName="geometryType" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[18]; + ParamDef->init("geometryType", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + HintTable[1].init("longDescription", "Specifies the geometry type of the emitter", true); + HintTable[2].init("shortDescription", "Geometry Type", true); + ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "EmitterGeomBoxParams", "EmitterGeomSphereParams", "EmitterGeomSphereShellParams", "EmitterGeomCylinderParams", "EmitterGeomExplicitParams" }; + ParamDefTable[18].setRefVariantVals((const char**)RefVariantVals, 5); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=19, longName="emitterDuration" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[19]; + ParamDef->init("emitterDuration", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("min", uint64_t(0), true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "Specifies a duration (in seconds) that the emitter will emit for after being enabled.\nAfter the specified duration, the emitter will turn off, unless it has already been explicitly turned off via an API call.\nThe special value 0.0f means there is no duration, and the emitter will remain on until explicitly turned off.", true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Emitter duration time (in seconds)", true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=20, longName="emitterVelocityScale" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[20]; + ParamDef->init("emitterVelocityScale", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "Scaling value to control how much the velocity of the emitter affects the velocity of the particles.\nA value of 0 means no effect (legacy mode). A value of 1 will add the emitter actor velocity to the velocity produced by velocityRange.", true); + HintTable[1].init("shortDescription", "Scaling value to control how much the velocity of the emitter affects the velocity of the particles.", true); + ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=21, longName="minSamplingFPS" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[21]; + ParamDef->init("minSamplingFPS", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("longDescription", "It is used to reduce discontinuity in case of fast moving Emitters, by limiting particles generation step max. time by inverse of this value.\n", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Defines minimum FPS at which particles are generating (0-value means no limit in FPS)", true); + ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=22, longName="rateVsTimeCurvePoints" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[22]; + ParamDef->init("rateVsTimeCurvePoints", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("DISPLAY_NAME", "rateVsEmitterDurationCurvePoints", true); + HintTable[1].init("editorCurve", uint64_t(1), true); + HintTable[2].init("xAxisLabel", "Emitter Duration", true); + HintTable[3].init("yAxisLabel", "Rate", true); + ParamDefTable[22].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#else + + static HintImpl HintTable[5]; + static Hint* HintPtrTable[5] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], &HintTable[4], }; + HintTable[0].init("DISPLAY_NAME", "rateVsEmitterDurationCurvePoints", true); + HintTable[1].init("editorCurve", uint64_t(1), true); + HintTable[2].init("shortDescription", "Control points for rate vs emitter duration curve", true); + HintTable[3].init("xAxisLabel", "Emitter Duration", true); + HintTable[4].init("yAxisLabel", "Rate", true); + ParamDefTable[22].setHints((const NvParameterized::Hint**)HintPtrTable, 5); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + } + + // Initialize DefinitionImpl node: nodeIndex=23, longName="rateVsTimeCurvePoints[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[23]; + ParamDef->init("rateVsTimeCurvePoints", TYPE_STRUCT, "rateVsTimeCurvePoint", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("DISPLAY_NAME", "rateVsEmitterDurationCurvePoints", true); + HintTable[1].init("editorCurve", uint64_t(1), true); + HintTable[2].init("xAxisLabel", "Emitter Duration", true); + HintTable[3].init("yAxisLabel", "Rate", true); + ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#else + + static HintImpl HintTable[5]; + static Hint* HintPtrTable[5] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], &HintTable[4], }; + HintTable[0].init("DISPLAY_NAME", "rateVsEmitterDurationCurvePoints", true); + HintTable[1].init("editorCurve", uint64_t(1), true); + HintTable[2].init("shortDescription", "Control points for rate vs emitter duration curve", true); + HintTable[3].init("xAxisLabel", "Emitter Duration", true); + HintTable[4].init("yAxisLabel", "Rate", true); + ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 5); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=24, longName="rateVsTimeCurvePoints[].x" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[24]; + ParamDef->init("x", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("max", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[24].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("max", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Time", true); + ParamDefTable[24].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=25, longName="rateVsTimeCurvePoints[].y" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[25]; + ParamDef->init("y", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Rate", true); + ParamDefTable[25].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[15]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + Children[3] = PDEF_PTR(4); + Children[4] = PDEF_PTR(5); + Children[5] = PDEF_PTR(6); + Children[6] = PDEF_PTR(7); + Children[7] = PDEF_PTR(8); + Children[8] = PDEF_PTR(16); + Children[9] = PDEF_PTR(17); + Children[10] = PDEF_PTR(18); + Children[11] = PDEF_PTR(19); + Children[12] = PDEF_PTR(20); + Children[13] = PDEF_PTR(21); + Children[14] = PDEF_PTR(22); + + ParamDefTable[0].setChildren(Children, 15); + } + + // SetChildren for: nodeIndex=8, longName="lodParamDesc" + { + static Definition* Children[7]; + Children[0] = PDEF_PTR(9); + Children[1] = PDEF_PTR(10); + Children[2] = PDEF_PTR(11); + Children[3] = PDEF_PTR(12); + Children[4] = PDEF_PTR(13); + Children[5] = PDEF_PTR(14); + Children[6] = PDEF_PTR(15); + + ParamDefTable[8].setChildren(Children, 7); + } + + // SetChildren for: nodeIndex=22, longName="rateVsTimeCurvePoints" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(23); + + ParamDefTable[22].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=23, longName="rateVsTimeCurvePoints[]" + { + static Definition* Children[2]; + Children[0] = PDEF_PTR(24); + Children[1] = PDEF_PTR(25); + + ParamDefTable[23].setChildren(Children, 2); + } + + mBuiltFlag = true; + +} +void ApexEmitterAssetParameters::initStrings(void) +{ +} + +void ApexEmitterAssetParameters::initDynamicArrays(void) +{ + rateVsTimeCurvePoints.buf = NULL; + rateVsTimeCurvePoints.isAllocated = true; + rateVsTimeCurvePoints.elementSize = sizeof(rateVsTimeCurvePoint_Type); + rateVsTimeCurvePoints.arraySizes[0] = 0; +} + +void ApexEmitterAssetParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + density = float(1); + rate = float(1); + lifetimeLow = float(1); + lifetimeHigh = float(1); + velocityLow = physx::PxVec3(init(0, 0, 0)); + velocityHigh = physx::PxVec3(init(0, 0, 0)); + maxSamples = uint32_t(0); + lodParamDesc.version = uint32_t(0); + lodParamDesc.maxDistance = float(0); + lodParamDesc.distanceWeight = float(1); + lodParamDesc.speedWeight = float(0); + lodParamDesc.lifeWeight = float(0); + lodParamDesc.separationWeight = float(0); + lodParamDesc.bias = float(1); + emitterDuration = float(PX_MAX_F32); + emitterVelocityScale = float(0); + minSamplingFPS = uint32_t(0); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void ApexEmitterAssetParameters::initReferences(void) +{ + iofxAssetName = NULL; + + iosAssetName = NULL; + + geometryType = NULL; + +} + +void ApexEmitterAssetParameters::freeDynamicArrays(void) +{ + if (rateVsTimeCurvePoints.isAllocated && rateVsTimeCurvePoints.buf) + { + mParameterizedTraits->free(rateVsTimeCurvePoints.buf); + } +} + +void ApexEmitterAssetParameters::freeStrings(void) +{ +} + +void ApexEmitterAssetParameters::freeReferences(void) +{ + if (iofxAssetName) + { + iofxAssetName->destroy(); + } + + if (iosAssetName) + { + iosAssetName->destroy(); + } + + if (geometryType) + { + geometryType->destroy(); + } + +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterAssetPreviewParameters.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterAssetPreviewParameters.cpp new file mode 100644 index 00000000..9e42d9e9 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterAssetPreviewParameters.cpp @@ -0,0 +1,343 @@ +// 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 + + +#include "EmitterAssetPreviewParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterAssetPreviewParametersNS; + +const char* const EmitterAssetPreviewParametersFactory::vptr = + NvParameterized::getVptr<EmitterAssetPreviewParameters, EmitterAssetPreviewParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 3; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 2 }, + { TYPE_TRANSFORM, false, (size_t)(&((ParametersStruct*)0)->pose), NULL, 0 }, // pose + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->scale), NULL, 0 }, // scale +}; + + +bool EmitterAssetPreviewParameters::mBuiltFlag = false; +NvParameterized::MutexType EmitterAssetPreviewParameters::mBuiltFlagMutex; + +EmitterAssetPreviewParameters::EmitterAssetPreviewParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterAssetPreviewParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterAssetPreviewParameters::~EmitterAssetPreviewParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterAssetPreviewParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterAssetPreviewParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterAssetPreviewParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterAssetPreviewParameters::getParameterDefinitionTree(void) const +{ + EmitterAssetPreviewParameters* tmpParam = const_cast<EmitterAssetPreviewParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterAssetPreviewParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterAssetPreviewParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterAssetPreviewParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterAssetPreviewParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterAssetPreviewParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterAssetPreviewParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class is used for creating APEX Emitter Preview instances (shaped, ground, or impact emitters)", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="pose" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("pose", TYPE_TRANSFORM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The preview actor's position and rotation", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="scale" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("scale", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The preview actor's scale", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[2]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + + ParamDefTable[0].setChildren(Children, 2); + } + + mBuiltFlag = true; + +} +void EmitterAssetPreviewParameters::initStrings(void) +{ +} + +void EmitterAssetPreviewParameters::initDynamicArrays(void) +{ +} + +void EmitterAssetPreviewParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + pose = physx::PxTransform(physx::PxIdentity); + scale = float(1); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterAssetPreviewParameters::initReferences(void) +{ +} + +void EmitterAssetPreviewParameters::freeDynamicArrays(void) +{ +} + +void EmitterAssetPreviewParameters::freeStrings(void) +{ +} + +void EmitterAssetPreviewParameters::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterDebugRenderParams.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterDebugRenderParams.cpp new file mode 100644 index 00000000..b679e652 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterDebugRenderParams.cpp @@ -0,0 +1,756 @@ +// 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 + + +#include "EmitterDebugRenderParams.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterDebugRenderParamsNS; + +const char* const EmitterDebugRenderParamsFactory::vptr = + NvParameterized::getVptr<EmitterDebugRenderParams, EmitterDebugRenderParams::ClassAlignment>(); + +const uint32_t NumParamDefs = 20; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 8, 15, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 3 }, + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->apexEmitterParameters), CHILDREN(3), 6 }, // apexEmitterParameters + { TYPE_BOOL, false, (size_t)(&((ApexEmitterParameters_Type*)0)->VISUALIZE_APEX_EMITTER_ACTOR), NULL, 0 }, // apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR + { TYPE_BOOL, false, (size_t)(&((ApexEmitterParameters_Type*)0)->VISUALIZE_TOTAL_INJECTED_AABB), NULL, 0 }, // apexEmitterParameters.VISUALIZE_TOTAL_INJECTED_AABB + { TYPE_BOOL, false, (size_t)(&((ApexEmitterParameters_Type*)0)->VISUALIZE_APEX_EMITTER_ACTOR_POSE), NULL, 0 }, // apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_POSE + { TYPE_F32, false, (size_t)(&((ApexEmitterParameters_Type*)0)->THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_POSE), NULL, 0 }, // apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_POSE + { TYPE_BOOL, false, (size_t)(&((ApexEmitterParameters_Type*)0)->VISUALIZE_APEX_EMITTER_ACTOR_NAME), NULL, 0 }, // apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_NAME + { TYPE_F32, false, (size_t)(&((ApexEmitterParameters_Type*)0)->THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_NAME), NULL, 0 }, // apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_NAME + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->groundEmitterParameters), CHILDREN(9), 6 }, // groundEmitterParameters + { TYPE_BOOL, false, (size_t)(&((GroundEmitterParameters_Type*)0)->VISUALIZE_GROUND_EMITTER_ACTOR), NULL, 0 }, // groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR + { TYPE_BOOL, false, (size_t)(&((GroundEmitterParameters_Type*)0)->VISUALIZE_GROUND_EMITTER_SPHERE), NULL, 0 }, // groundEmitterParameters.VISUALIZE_GROUND_EMITTER_SPHERE + { TYPE_BOOL, false, (size_t)(&((GroundEmitterParameters_Type*)0)->VISUALIZE_GROUND_EMITTER_GRID), NULL, 0 }, // groundEmitterParameters.VISUALIZE_GROUND_EMITTER_GRID + { TYPE_BOOL, false, (size_t)(&((GroundEmitterParameters_Type*)0)->VISUALIZE_GROUND_EMITTER_RAYCAST), NULL, 0 }, // groundEmitterParameters.VISUALIZE_GROUND_EMITTER_RAYCAST + { TYPE_BOOL, false, (size_t)(&((GroundEmitterParameters_Type*)0)->VISUALIZE_GROUND_EMITTER_ACTOR_POSE), NULL, 0 }, // groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_POSE + { TYPE_BOOL, false, (size_t)(&((GroundEmitterParameters_Type*)0)->VISUALIZE_GROUND_EMITTER_ACTOR_NAME), NULL, 0 }, // groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_NAME + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->impactEmitterParameters), CHILDREN(15), 4 }, // impactEmitterParameters + { TYPE_BOOL, false, (size_t)(&((ImpactEmitterParameters_Type*)0)->VISUALIZE_IMPACT_EMITTER_ACTOR), NULL, 0 }, // impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_ACTOR + { TYPE_BOOL, false, (size_t)(&((ImpactEmitterParameters_Type*)0)->VISUALIZE_IMPACT_EMITTER_RAYCAST), NULL, 0 }, // impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_RAYCAST + { TYPE_BOOL, false, (size_t)(&((ImpactEmitterParameters_Type*)0)->VISUALIZE_IMPACT_EMITTER_ACTOR_NAME), NULL, 0 }, // impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_ACTOR_NAME + { TYPE_F32, false, (size_t)(&((ImpactEmitterParameters_Type*)0)->THRESHOLD_DISTANCE_IMPACT_EMITTER_ACTOR_NAME), NULL, 0 }, // impactEmitterParameters.THRESHOLD_DISTANCE_IMPACT_EMITTER_ACTOR_NAME +}; + + +bool EmitterDebugRenderParams::mBuiltFlag = false; +NvParameterized::MutexType EmitterDebugRenderParams::mBuiltFlagMutex; + +EmitterDebugRenderParams::EmitterDebugRenderParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterDebugRenderParamsFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterDebugRenderParams::~EmitterDebugRenderParams() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterDebugRenderParams::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterDebugRenderParams(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterDebugRenderParams::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterDebugRenderParams::getParameterDefinitionTree(void) const +{ + EmitterDebugRenderParams* tmpParam = const_cast<EmitterDebugRenderParams*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterDebugRenderParams::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterDebugRenderParams::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterDebugRenderParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterDebugRenderParams::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterDebugRenderParams::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterDebugRenderParams::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class contains debug rendering parameters for the emitter module.", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="apexEmitterParameters" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("apexEmitterParameters", TYPE_STRUCT, "ApexEmitterParameters", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("VISUALIZE_APEX_EMITTER_ACTOR", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Enables/Disables visualization of all emitter actors. This parameter also switches on visualization of emitter's shape (each green grid encompasses emitter).", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="apexEmitterParameters.VISUALIZE_TOTAL_INJECTED_AABB" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("VISUALIZE_TOTAL_INJECTED_AABB", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws red box which represents AABB boundary. All new particles are injected inside it.", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_POSE" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("VISUALIZE_APEX_EMITTER_ACTOR_POSE", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "For visualizing emitter's position. Draws arrows which represent axes. Blue arrow stands for Z axis, green - for Y and red - X. ", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=5, longName="apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_POSE" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5]; + ParamDef->init("THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_POSE", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Defines maximum distance, from which actor's position's visualization could be seen.", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=6, longName="apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_NAME" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6]; + ParamDef->init("VISUALIZE_APEX_EMITTER_ACTOR_NAME", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws the emitter's asset's name next to the emitter.", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=7, longName="apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_NAME" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7]; + ParamDef->init("THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_NAME", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Defines maximum distance, from which actor name's visualization could be seen.", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=8, longName="groundEmitterParameters" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8]; + ParamDef->init("groundEmitterParameters", TYPE_STRUCT, "GroundEmitterParameters", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=9, longName="groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9]; + ParamDef->init("VISUALIZE_GROUND_EMITTER_ACTOR", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Enables/Disables visualization of all ground emitter actors", true); + ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=10, longName="groundEmitterParameters.VISUALIZE_GROUND_EMITTER_SPHERE" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[10]; + ParamDef->init("VISUALIZE_GROUND_EMITTER_SPHERE", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws green sphere which bounds ground emitter. ", true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=11, longName="groundEmitterParameters.VISUALIZE_GROUND_EMITTER_GRID" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[11]; + ParamDef->init("VISUALIZE_GROUND_EMITTER_GRID", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws yellow grid which bounds ground emitter. ", true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=12, longName="groundEmitterParameters.VISUALIZE_GROUND_EMITTER_RAYCAST" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[12]; + ParamDef->init("VISUALIZE_GROUND_EMITTER_RAYCAST", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws vertical green lines where new particles are generated. ", true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=13, longName="groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_POSE" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[13]; + ParamDef->init("VISUALIZE_GROUND_EMITTER_ACTOR_POSE", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "For visualizing emitter's position. Draws arrows which represent axes. Blue arrow stands for Z axis, green - for Y and red - X. ", true); + ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=14, longName="groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_NAME" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[14]; + ParamDef->init("VISUALIZE_GROUND_EMITTER_ACTOR_NAME", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws the emitter's asset's name next to the emitter.", true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=15, longName="impactEmitterParameters" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[15]; + ParamDef->init("impactEmitterParameters", TYPE_STRUCT, "ImpactEmitterParameters", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=16, longName="impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_ACTOR" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[16]; + ParamDef->init("VISUALIZE_IMPACT_EMITTER_ACTOR", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Enables/Disables visualization of all impact emitter actors", true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=17, longName="impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_RAYCAST" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[17]; + ParamDef->init("VISUALIZE_IMPACT_EMITTER_RAYCAST", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws vertical line on the point of impact. ", true); + ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=18, longName="impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_ACTOR_NAME" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[18]; + ParamDef->init("VISUALIZE_IMPACT_EMITTER_ACTOR_NAME", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Draws the emitter's asset's name next to the emitter.", true); + ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=19, longName="impactEmitterParameters.THRESHOLD_DISTANCE_IMPACT_EMITTER_ACTOR_NAME" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[19]; + ParamDef->init("THRESHOLD_DISTANCE_IMPACT_EMITTER_ACTOR_NAME", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Defines maximum distance, from which actor's names's visualization could be seen.", true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[3]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(8); + Children[2] = PDEF_PTR(15); + + ParamDefTable[0].setChildren(Children, 3); + } + + // SetChildren for: nodeIndex=1, longName="apexEmitterParameters" + { + static Definition* Children[6]; + Children[0] = PDEF_PTR(2); + Children[1] = PDEF_PTR(3); + Children[2] = PDEF_PTR(4); + Children[3] = PDEF_PTR(5); + Children[4] = PDEF_PTR(6); + Children[5] = PDEF_PTR(7); + + ParamDefTable[1].setChildren(Children, 6); + } + + // SetChildren for: nodeIndex=8, longName="groundEmitterParameters" + { + static Definition* Children[6]; + Children[0] = PDEF_PTR(9); + Children[1] = PDEF_PTR(10); + Children[2] = PDEF_PTR(11); + Children[3] = PDEF_PTR(12); + Children[4] = PDEF_PTR(13); + Children[5] = PDEF_PTR(14); + + ParamDefTable[8].setChildren(Children, 6); + } + + // SetChildren for: nodeIndex=15, longName="impactEmitterParameters" + { + static Definition* Children[4]; + Children[0] = PDEF_PTR(16); + Children[1] = PDEF_PTR(17); + Children[2] = PDEF_PTR(18); + Children[3] = PDEF_PTR(19); + + ParamDefTable[15].setChildren(Children, 4); + } + + mBuiltFlag = true; + +} +void EmitterDebugRenderParams::initStrings(void) +{ +} + +void EmitterDebugRenderParams::initDynamicArrays(void) +{ +} + +void EmitterDebugRenderParams::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR = bool(false); + apexEmitterParameters.VISUALIZE_TOTAL_INJECTED_AABB = bool(false); + apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_POSE = bool(true); + apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_POSE = float(3.402823466e+038); + apexEmitterParameters.VISUALIZE_APEX_EMITTER_ACTOR_NAME = bool(true); + apexEmitterParameters.THRESHOLD_DISTANCE_APEX_EMITTER_ACTOR_NAME = float(3.402823466e+038); + groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR = bool(true); + groundEmitterParameters.VISUALIZE_GROUND_EMITTER_SPHERE = bool(false); + groundEmitterParameters.VISUALIZE_GROUND_EMITTER_GRID = bool(false); + groundEmitterParameters.VISUALIZE_GROUND_EMITTER_RAYCAST = bool(false); + groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_POSE = bool(false); + groundEmitterParameters.VISUALIZE_GROUND_EMITTER_ACTOR_NAME = bool(false); + impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_ACTOR = bool(false); + impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_RAYCAST = bool(true); + impactEmitterParameters.VISUALIZE_IMPACT_EMITTER_ACTOR_NAME = bool(true); + impactEmitterParameters.THRESHOLD_DISTANCE_IMPACT_EMITTER_ACTOR_NAME = float(3.402823466e+038); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterDebugRenderParams::initReferences(void) +{ +} + +void EmitterDebugRenderParams::freeDynamicArrays(void) +{ +} + +void EmitterDebugRenderParams::freeStrings(void) +{ +} + +void EmitterDebugRenderParams::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterGeomBoxParams.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterGeomBoxParams.cpp new file mode 100644 index 00000000..38e3b41f --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterGeomBoxParams.cpp @@ -0,0 +1,348 @@ +// 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 + + +#include "EmitterGeomBoxParams.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterGeomBoxParamsNS; + +const char* const EmitterGeomBoxParamsFactory::vptr = + NvParameterized::getVptr<EmitterGeomBoxParams, EmitterGeomBoxParams::ClassAlignment>(); + +const uint32_t NumParamDefs = 3; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 2 }, + { TYPE_ENUM, false, (size_t)(&((ParametersStruct*)0)->emitterType), NULL, 0 }, // emitterType + { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->extents), NULL, 0 }, // extents +}; + + +bool EmitterGeomBoxParams::mBuiltFlag = false; +NvParameterized::MutexType EmitterGeomBoxParams::mBuiltFlagMutex; + +EmitterGeomBoxParams::EmitterGeomBoxParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterGeomBoxParamsFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterGeomBoxParams::~EmitterGeomBoxParams() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterGeomBoxParams::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterGeomBoxParams(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterGeomBoxParams::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterGeomBoxParams::getParameterDefinitionTree(void) const +{ + EmitterGeomBoxParams* tmpParam = const_cast<EmitterGeomBoxParams*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterGeomBoxParams::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterGeomBoxParams::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterGeomBoxParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterGeomBoxParams::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterGeomBoxParams::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterGeomBoxParams::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="emitterType" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("emitterType", TYPE_ENUM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "rate", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", "rate", true); + HintTable[1].init("longDescription", "rate - The emitter will emit at the rate specified by the asset's rateRange\\n\ndensityOnce - The emitter will fill the geometry according to the asset's densityRange\\n\ndensityBrush - As the emitter moves, the emitter will fill the volume that is not already covered by the previous position\\n\nfill - The emitter will fill the volume with particles based on the particle size\\n\n", true); + HintTable[2].init("shortDescription", "Emitter Type", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + static const char* const EnumVals[] = { "rate", "densityOnce", "densityBrush", "fill" }; + ParamDefTable[1].setEnumVals((const char**)EnumVals, 4); + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="extents" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("extents", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "Box Extents", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[2]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + + ParamDefTable[0].setChildren(Children, 2); + } + + mBuiltFlag = true; + +} +void EmitterGeomBoxParams::initStrings(void) +{ +} + +void EmitterGeomBoxParams::initDynamicArrays(void) +{ +} + +void EmitterGeomBoxParams::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + emitterType = (const char*)"rate"; + extents = physx::PxVec3(init(1, 1, 1)); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterGeomBoxParams::initReferences(void) +{ +} + +void EmitterGeomBoxParams::freeDynamicArrays(void) +{ +} + +void EmitterGeomBoxParams::freeStrings(void) +{ +} + +void EmitterGeomBoxParams::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterGeomCylinderParams.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterGeomCylinderParams.cpp new file mode 100644 index 00000000..92604390 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterGeomCylinderParams.cpp @@ -0,0 +1,387 @@ +// 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 + + +#include "EmitterGeomCylinderParams.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterGeomCylinderParamsNS; + +const char* const EmitterGeomCylinderParamsFactory::vptr = + NvParameterized::getVptr<EmitterGeomCylinderParams, EmitterGeomCylinderParams::ClassAlignment>(); + +const uint32_t NumParamDefs = 4; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 3 }, + { TYPE_ENUM, false, (size_t)(&((ParametersStruct*)0)->emitterType), NULL, 0 }, // emitterType + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->radius), NULL, 0 }, // radius + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->height), NULL, 0 }, // height +}; + + +bool EmitterGeomCylinderParams::mBuiltFlag = false; +NvParameterized::MutexType EmitterGeomCylinderParams::mBuiltFlagMutex; + +EmitterGeomCylinderParams::EmitterGeomCylinderParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterGeomCylinderParamsFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterGeomCylinderParams::~EmitterGeomCylinderParams() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterGeomCylinderParams::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterGeomCylinderParams(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterGeomCylinderParams::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterGeomCylinderParams::getParameterDefinitionTree(void) const +{ + EmitterGeomCylinderParams* tmpParam = const_cast<EmitterGeomCylinderParams*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterGeomCylinderParams::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterGeomCylinderParams::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterGeomCylinderParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterGeomCylinderParams::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterGeomCylinderParams::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterGeomCylinderParams::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="emitterType" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("emitterType", TYPE_ENUM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "rate", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", "rate", true); + HintTable[1].init("longDescription", "rate - The emitter will emit at the rate specified by the asset's rateRange\\n\ndensityOnce - The emitter will fill the geometry according to the asset's densityRange\\n\ndensityBrush - As the emitter moves, the emitter will fill the volume that is not already covered by the previous position\\n\nfill - The emitter will fill the volume with particles based on the particle size\\n\n", true); + HintTable[2].init("shortDescription", "Emitter Type", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + static const char* const EnumVals[] = { "rate", "densityOnce", "densityBrush", "fill" }; + ParamDefTable[1].setEnumVals((const char**)EnumVals, 4); + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="radius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("radius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Cylinder Radius", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="height" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("height", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Cylinder Height", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[3]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + + ParamDefTable[0].setChildren(Children, 3); + } + + mBuiltFlag = true; + +} +void EmitterGeomCylinderParams::initStrings(void) +{ +} + +void EmitterGeomCylinderParams::initDynamicArrays(void) +{ +} + +void EmitterGeomCylinderParams::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + emitterType = (const char*)"rate"; + radius = float(1.0f); + height = float(1.0f); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterGeomCylinderParams::initReferences(void) +{ +} + +void EmitterGeomCylinderParams::freeDynamicArrays(void) +{ +} + +void EmitterGeomCylinderParams::freeStrings(void) +{ +} + +void EmitterGeomCylinderParams::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterGeomExplicitParams.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterGeomExplicitParams.cpp new file mode 100644 index 00000000..162200be --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterGeomExplicitParams.cpp @@ -0,0 +1,1150 @@ +// 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 + + +#include "EmitterGeomExplicitParams.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterGeomExplicitParamsNS; + +const char* const EmitterGeomExplicitParamsFactory::vptr = + NvParameterized::getVptr<EmitterGeomExplicitParams, EmitterGeomExplicitParams::ClassAlignment>(); + +const uint32_t NumParamDefs = 27; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 9, 17, 3, 7, 4, 5, 6, 8, 10, 15, 11, 12, 13, 14, 16, 18, 25, 19, 20, 21, 22, + 23, 24, 26, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 4 }, + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->distance), NULL, 0 }, // distance + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->points), CHILDREN(4), 2 }, // points + { TYPE_ARRAY, true, (size_t)(&((ExplicitPoints_Type*)0)->positions), CHILDREN(6), 1 }, // points.positions + { TYPE_STRUCT, false, 1 * sizeof(PointParams_Type), CHILDREN(7), 2 }, // points.positions[] + { TYPE_VEC3, false, (size_t)(&((PointParams_Type*)0)->position), NULL, 0 }, // points.positions[].position + { TYPE_BOOL, false, (size_t)(&((PointParams_Type*)0)->doDetectOverlaps), NULL, 0 }, // points.positions[].doDetectOverlaps + { TYPE_ARRAY, true, (size_t)(&((ExplicitPoints_Type*)0)->velocities), CHILDREN(9), 1 }, // points.velocities + { TYPE_VEC3, false, 1 * sizeof(physx::PxVec3), NULL, 0 }, // points.velocities[] + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->spheres), CHILDREN(10), 2 }, // spheres + { TYPE_ARRAY, true, (size_t)(&((ExplicitSpheres_Type*)0)->positions), CHILDREN(12), 1 }, // spheres.positions + { TYPE_STRUCT, false, 1 * sizeof(SphereParams_Type), CHILDREN(13), 3 }, // spheres.positions[] + { TYPE_VEC3, false, (size_t)(&((SphereParams_Type*)0)->center), NULL, 0 }, // spheres.positions[].center + { TYPE_F32, false, (size_t)(&((SphereParams_Type*)0)->radius), NULL, 0 }, // spheres.positions[].radius + { TYPE_BOOL, false, (size_t)(&((SphereParams_Type*)0)->doDetectOverlaps), NULL, 0 }, // spheres.positions[].doDetectOverlaps + { TYPE_ARRAY, true, (size_t)(&((ExplicitSpheres_Type*)0)->velocities), CHILDREN(16), 1 }, // spheres.velocities + { TYPE_VEC3, false, 1 * sizeof(physx::PxVec3), NULL, 0 }, // spheres.velocities[] + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->ellipsoids), CHILDREN(17), 2 }, // ellipsoids + { TYPE_ARRAY, true, (size_t)(&((ExplicitEllipsoids_Type*)0)->positions), CHILDREN(19), 1 }, // ellipsoids.positions + { TYPE_STRUCT, false, 1 * sizeof(EllipsoidParams_Type), CHILDREN(20), 5 }, // ellipsoids.positions[] + { TYPE_VEC3, false, (size_t)(&((EllipsoidParams_Type*)0)->center), NULL, 0 }, // ellipsoids.positions[].center + { TYPE_F32, false, (size_t)(&((EllipsoidParams_Type*)0)->radius), NULL, 0 }, // ellipsoids.positions[].radius + { TYPE_VEC3, false, (size_t)(&((EllipsoidParams_Type*)0)->normal), NULL, 0 }, // ellipsoids.positions[].normal + { TYPE_F32, false, (size_t)(&((EllipsoidParams_Type*)0)->polarRadius), NULL, 0 }, // ellipsoids.positions[].polarRadius + { TYPE_BOOL, false, (size_t)(&((EllipsoidParams_Type*)0)->doDetectOverlaps), NULL, 0 }, // ellipsoids.positions[].doDetectOverlaps + { TYPE_ARRAY, true, (size_t)(&((ExplicitEllipsoids_Type*)0)->velocities), CHILDREN(25), 1 }, // ellipsoids.velocities + { TYPE_VEC3, false, 1 * sizeof(physx::PxVec3), NULL, 0 }, // ellipsoids.velocities[] +}; + + +bool EmitterGeomExplicitParams::mBuiltFlag = false; +NvParameterized::MutexType EmitterGeomExplicitParams::mBuiltFlagMutex; + +EmitterGeomExplicitParams::EmitterGeomExplicitParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterGeomExplicitParamsFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterGeomExplicitParams::~EmitterGeomExplicitParams() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterGeomExplicitParams::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterGeomExplicitParams(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterGeomExplicitParams::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterGeomExplicitParams::getParameterDefinitionTree(void) const +{ + EmitterGeomExplicitParams* tmpParam = const_cast<EmitterGeomExplicitParams*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterGeomExplicitParams::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterGeomExplicitParams::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterGeomExplicitParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterGeomExplicitParams::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterGeomExplicitParams::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterGeomExplicitParams::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="distance" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("distance", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + HintTable[2].init("shortDescription", "Average distance between particles", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="points" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("points", TYPE_STRUCT, "ExplicitPoints", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="points.positions" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("positions", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of point positions", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="points.positions[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("positions", TYPE_STRUCT, "PointParams", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of point positions", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=5, longName="points.positions[].position" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5]; + ParamDef->init("position", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "Initial position", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=6, longName="points.positions[].doDetectOverlaps" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6]; + ParamDef->init("doDetectOverlaps", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "false", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", "false", true); + HintTable[1].init("shortDescription", "Avoid overlaps with other shapes?", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=7, longName="points.velocities" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7]; + ParamDef->init("velocities", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of initial velocities", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + } + + // Initialize DefinitionImpl node: nodeIndex=8, longName="points.velocities[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8]; + ParamDef->init("velocities", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of initial velocities", true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=9, longName="spheres" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9]; + ParamDef->init("spheres", TYPE_STRUCT, "ExplicitSpheres", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=10, longName="spheres.positions" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[10]; + ParamDef->init("positions", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of sphere positions", true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + } + + // Initialize DefinitionImpl node: nodeIndex=11, longName="spheres.positions[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[11]; + ParamDef->init("positions", TYPE_STRUCT, "SphereParams", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of sphere positions", true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=12, longName="spheres.positions[].center" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[12]; + ParamDef->init("center", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "Sphere centers", true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=13, longName="spheres.positions[].radius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[13]; + ParamDef->init("radius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + HintTable[2].init("shortDescription", "Sphere radiuses", true); + ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=14, longName="spheres.positions[].doDetectOverlaps" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[14]; + ParamDef->init("doDetectOverlaps", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "false", true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", "false", true); + HintTable[1].init("shortDescription", "Avoid overlaps with other shapes?", true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=15, longName="spheres.velocities" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[15]; + ParamDef->init("velocities", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of initial velocities for particles in sphere", true); + ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + } + + // Initialize DefinitionImpl node: nodeIndex=16, longName="spheres.velocities[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[16]; + ParamDef->init("velocities", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of initial velocities for particles in sphere", true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=17, longName="ellipsoids" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[17]; + ParamDef->init("ellipsoids", TYPE_STRUCT, "ExplicitEllipsoids", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=18, longName="ellipsoids.positions" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[18]; + ParamDef->init("positions", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of ellipsoid positions", true); + ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + } + + // Initialize DefinitionImpl node: nodeIndex=19, longName="ellipsoids.positions[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[19]; + ParamDef->init("positions", TYPE_STRUCT, "EllipsoidParams", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of ellipsoid positions", true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=20, longName="ellipsoids.positions[].center" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[20]; + ParamDef->init("center", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "Sphere centers", true); + ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=21, longName="ellipsoids.positions[].radius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[21]; + ParamDef->init("radius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + HintTable[2].init("shortDescription", "Sphere radiuses", true); + ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=22, longName="ellipsoids.positions[].normal" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[22]; + ParamDef->init("normal", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Normal to equatorial planes", true); + ParamDefTable[22].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=23, longName="ellipsoids.positions[].polarRadius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[23]; + ParamDef->init("polarRadius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("min", double(0.0f), true); + HintTable[2].init("shortDescription", "Polar radius", true); + ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=24, longName="ellipsoids.positions[].doDetectOverlaps" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[24]; + ParamDef->init("doDetectOverlaps", TYPE_BOOL, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "false", true); + ParamDefTable[24].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", "false", true); + HintTable[1].init("shortDescription", "Avoid overlaps with other shapes?", true); + ParamDefTable[24].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=25, longName="ellipsoids.velocities" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[25]; + ParamDef->init("velocities", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[25].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of initial velocities for particles in ellipsoid", true); + ParamDefTable[25].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + } + + // Initialize DefinitionImpl node: nodeIndex=26, longName="ellipsoids.velocities[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[26]; + ParamDef->init("velocities", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("gameScale", "true", true); + ParamDefTable[26].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("shortDescription", "List of initial velocities for particles in ellipsoid", true); + ParamDefTable[26].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[4]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(9); + Children[3] = PDEF_PTR(17); + + ParamDefTable[0].setChildren(Children, 4); + } + + // SetChildren for: nodeIndex=2, longName="points" + { + static Definition* Children[2]; + Children[0] = PDEF_PTR(3); + Children[1] = PDEF_PTR(7); + + ParamDefTable[2].setChildren(Children, 2); + } + + // SetChildren for: nodeIndex=3, longName="points.positions" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(4); + + ParamDefTable[3].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=4, longName="points.positions[]" + { + static Definition* Children[2]; + Children[0] = PDEF_PTR(5); + Children[1] = PDEF_PTR(6); + + ParamDefTable[4].setChildren(Children, 2); + } + + // SetChildren for: nodeIndex=7, longName="points.velocities" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(8); + + ParamDefTable[7].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=9, longName="spheres" + { + static Definition* Children[2]; + Children[0] = PDEF_PTR(10); + Children[1] = PDEF_PTR(15); + + ParamDefTable[9].setChildren(Children, 2); + } + + // SetChildren for: nodeIndex=10, longName="spheres.positions" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(11); + + ParamDefTable[10].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=11, longName="spheres.positions[]" + { + static Definition* Children[3]; + Children[0] = PDEF_PTR(12); + Children[1] = PDEF_PTR(13); + Children[2] = PDEF_PTR(14); + + ParamDefTable[11].setChildren(Children, 3); + } + + // SetChildren for: nodeIndex=15, longName="spheres.velocities" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(16); + + ParamDefTable[15].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=17, longName="ellipsoids" + { + static Definition* Children[2]; + Children[0] = PDEF_PTR(18); + Children[1] = PDEF_PTR(25); + + ParamDefTable[17].setChildren(Children, 2); + } + + // SetChildren for: nodeIndex=18, longName="ellipsoids.positions" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(19); + + ParamDefTable[18].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=19, longName="ellipsoids.positions[]" + { + static Definition* Children[5]; + Children[0] = PDEF_PTR(20); + Children[1] = PDEF_PTR(21); + Children[2] = PDEF_PTR(22); + Children[3] = PDEF_PTR(23); + Children[4] = PDEF_PTR(24); + + ParamDefTable[19].setChildren(Children, 5); + } + + // SetChildren for: nodeIndex=25, longName="ellipsoids.velocities" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(26); + + ParamDefTable[25].setChildren(Children, 1); + } + + mBuiltFlag = true; + +} +void EmitterGeomExplicitParams::initStrings(void) +{ +} + +void EmitterGeomExplicitParams::initDynamicArrays(void) +{ + points.positions.buf = NULL; + points.positions.isAllocated = true; + points.positions.elementSize = sizeof(PointParams_Type); + points.positions.arraySizes[0] = 0; + points.velocities.buf = NULL; + points.velocities.isAllocated = true; + points.velocities.elementSize = sizeof(physx::PxVec3); + points.velocities.arraySizes[0] = 0; + spheres.positions.buf = NULL; + spheres.positions.isAllocated = true; + spheres.positions.elementSize = sizeof(SphereParams_Type); + spheres.positions.arraySizes[0] = 0; + spheres.velocities.buf = NULL; + spheres.velocities.isAllocated = true; + spheres.velocities.elementSize = sizeof(physx::PxVec3); + spheres.velocities.arraySizes[0] = 0; + ellipsoids.positions.buf = NULL; + ellipsoids.positions.isAllocated = true; + ellipsoids.positions.elementSize = sizeof(EllipsoidParams_Type); + ellipsoids.positions.arraySizes[0] = 0; + ellipsoids.velocities.buf = NULL; + ellipsoids.velocities.isAllocated = true; + ellipsoids.velocities.elementSize = sizeof(physx::PxVec3); + ellipsoids.velocities.arraySizes[0] = 0; +} + +void EmitterGeomExplicitParams::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterGeomExplicitParams::initReferences(void) +{ +} + +void EmitterGeomExplicitParams::freeDynamicArrays(void) +{ + if (points.positions.isAllocated && points.positions.buf) + { + mParameterizedTraits->free(points.positions.buf); + } + if (points.velocities.isAllocated && points.velocities.buf) + { + mParameterizedTraits->free(points.velocities.buf); + } + if (spheres.positions.isAllocated && spheres.positions.buf) + { + mParameterizedTraits->free(spheres.positions.buf); + } + if (spheres.velocities.isAllocated && spheres.velocities.buf) + { + mParameterizedTraits->free(spheres.velocities.buf); + } + if (ellipsoids.positions.isAllocated && ellipsoids.positions.buf) + { + mParameterizedTraits->free(ellipsoids.positions.buf); + } + if (ellipsoids.velocities.isAllocated && ellipsoids.velocities.buf) + { + mParameterizedTraits->free(ellipsoids.velocities.buf); + } +} + +void EmitterGeomExplicitParams::freeStrings(void) +{ +} + +void EmitterGeomExplicitParams::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterGeomSphereParams.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterGeomSphereParams.cpp new file mode 100644 index 00000000..c5fb51b5 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterGeomSphereParams.cpp @@ -0,0 +1,389 @@ +// 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 + + +#include "EmitterGeomSphereParams.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterGeomSphereParamsNS; + +const char* const EmitterGeomSphereParamsFactory::vptr = + NvParameterized::getVptr<EmitterGeomSphereParams, EmitterGeomSphereParams::ClassAlignment>(); + +const uint32_t NumParamDefs = 4; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 3 }, + { TYPE_ENUM, false, (size_t)(&((ParametersStruct*)0)->emitterType), NULL, 0 }, // emitterType + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->radius), NULL, 0 }, // radius + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->hemisphere), NULL, 0 }, // hemisphere +}; + + +bool EmitterGeomSphereParams::mBuiltFlag = false; +NvParameterized::MutexType EmitterGeomSphereParams::mBuiltFlagMutex; + +EmitterGeomSphereParams::EmitterGeomSphereParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterGeomSphereParamsFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterGeomSphereParams::~EmitterGeomSphereParams() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterGeomSphereParams::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterGeomSphereParams(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterGeomSphereParams::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterGeomSphereParams::getParameterDefinitionTree(void) const +{ + EmitterGeomSphereParams* tmpParam = const_cast<EmitterGeomSphereParams*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterGeomSphereParams::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterGeomSphereParams::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterGeomSphereParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterGeomSphereParams::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterGeomSphereParams::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterGeomSphereParams::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="emitterType" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("emitterType", TYPE_ENUM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "rate", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", "rate", true); + HintTable[1].init("longDescription", "rate - The emitter will emit at the rate specified by the asset's rateRange\\n\ndensityOnce - The emitter will fill the geometry according to the asset's densityRange\\n\ndensityBrush - As the emitter moves, the emitter will fill the volume that is not already covered by the previous position\\n\nfill - The emitter will fill the volume with particles based on the particle size\\n\n", true); + HintTable[2].init("shortDescription", "Emitter Type", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + static const char* const EnumVals[] = { "rate", "densityOnce", "densityBrush", "fill" }; + ParamDefTable[1].setEnumVals((const char**)EnumVals, 4); + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="radius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("radius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Sphere Radius", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="hemisphere" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("hemisphere", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("gameScale", "false", true); + HintTable[2].init("max", uint64_t(1), true); + HintTable[3].init("min", uint64_t(0), true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#else + + static HintImpl HintTable[5]; + static Hint* HintPtrTable[5] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], &HintTable[4], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("gameScale", "false", true); + HintTable[2].init("max", uint64_t(1), true); + HintTable[3].init("min", uint64_t(0), true); + HintTable[4].init("shortDescription", "Sphere Hemisphere", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 5); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[3]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + + ParamDefTable[0].setChildren(Children, 3); + } + + mBuiltFlag = true; + +} +void EmitterGeomSphereParams::initStrings(void) +{ +} + +void EmitterGeomSphereParams::initDynamicArrays(void) +{ +} + +void EmitterGeomSphereParams::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + emitterType = (const char*)"rate"; + radius = float(1.0f); + hemisphere = float(0.0f); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterGeomSphereParams::initReferences(void) +{ +} + +void EmitterGeomSphereParams::freeDynamicArrays(void) +{ +} + +void EmitterGeomSphereParams::freeStrings(void) +{ +} + +void EmitterGeomSphereParams::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterGeomSphereShellParams.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterGeomSphereShellParams.cpp new file mode 100644 index 00000000..d100123c --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterGeomSphereShellParams.cpp @@ -0,0 +1,424 @@ +// 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 + + +#include "EmitterGeomSphereShellParams.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterGeomSphereShellParamsNS; + +const char* const EmitterGeomSphereShellParamsFactory::vptr = + NvParameterized::getVptr<EmitterGeomSphereShellParams, EmitterGeomSphereShellParams::ClassAlignment>(); + +const uint32_t NumParamDefs = 5; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, 4, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 4 }, + { TYPE_ENUM, false, (size_t)(&((ParametersStruct*)0)->emitterType), NULL, 0 }, // emitterType + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->radius), NULL, 0 }, // radius + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->shellThickness), NULL, 0 }, // shellThickness + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->hemisphere), NULL, 0 }, // hemisphere +}; + + +bool EmitterGeomSphereShellParams::mBuiltFlag = false; +NvParameterized::MutexType EmitterGeomSphereShellParams::mBuiltFlagMutex; + +EmitterGeomSphereShellParams::EmitterGeomSphereShellParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterGeomSphereShellParamsFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterGeomSphereShellParams::~EmitterGeomSphereShellParams() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterGeomSphereShellParams::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterGeomSphereShellParams(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterGeomSphereShellParams::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterGeomSphereShellParams::getParameterDefinitionTree(void) const +{ + EmitterGeomSphereShellParams* tmpParam = const_cast<EmitterGeomSphereShellParams*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterGeomSphereShellParams::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterGeomSphereShellParams::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterGeomSphereShellParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterGeomSphereShellParams::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterGeomSphereShellParams::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterGeomSphereShellParams::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="emitterType" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("emitterType", TYPE_ENUM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "rate", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", "rate", true); + HintTable[1].init("longDescription", "rate - The emitter will emit at the rate specified by the asset's rateRange\\n\ndensityOnce - The emitter will fill the geometry according to the asset's densityRange\\n\ndensityBrush - As the emitter moves, the emitter will fill the volume that is not already covered by the previous position\\n\nfill - The emitter will fill the volume with particles based on the particle size\\n\n", true); + HintTable[2].init("shortDescription", "Emitter Type", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + static const char* const EnumVals[] = { "rate", "densityOnce", "densityBrush", "fill" }; + ParamDefTable[1].setEnumVals((const char**)EnumVals, 4); + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="radius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("radius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Sphere Radius", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="shellThickness" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("shellThickness", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", double(0.1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", double(0.1), true); + HintTable[1].init("gameScale", "true", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Sphere Shell Thickness", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="hemisphere" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("hemisphere", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("gameScale", "false", true); + HintTable[2].init("max", double(0.99999), true); + HintTable[3].init("min", uint64_t(0), true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#else + + static HintImpl HintTable[5]; + static Hint* HintPtrTable[5] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], &HintTable[4], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("gameScale", "false", true); + HintTable[2].init("max", double(0.99999), true); + HintTable[3].init("min", uint64_t(0), true); + HintTable[4].init("shortDescription", "Sphere Shell Hemisphere", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 5); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[4]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + Children[3] = PDEF_PTR(4); + + ParamDefTable[0].setChildren(Children, 4); + } + + mBuiltFlag = true; + +} +void EmitterGeomSphereShellParams::initStrings(void) +{ +} + +void EmitterGeomSphereShellParams::initDynamicArrays(void) +{ +} + +void EmitterGeomSphereShellParams::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + emitterType = (const char*)"rate"; + radius = float(1.0f); + shellThickness = float(0.1f); + hemisphere = float(0.0f); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterGeomSphereShellParams::initReferences(void) +{ +} + +void EmitterGeomSphereShellParams::freeDynamicArrays(void) +{ +} + +void EmitterGeomSphereShellParams::freeStrings(void) +{ +} + +void EmitterGeomSphereShellParams::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/EmitterModuleParameters.cpp b/APEX_1.4/module/emitter/src/autogen/EmitterModuleParameters.cpp new file mode 100644 index 00000000..f70c1351 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/EmitterModuleParameters.cpp @@ -0,0 +1,318 @@ +// 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 + + +#include "EmitterModuleParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace EmitterModuleParametersNS; + +const char* const EmitterModuleParametersFactory::vptr = + NvParameterized::getVptr<EmitterModuleParameters, EmitterModuleParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 2; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 1 }, + { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->unused), NULL, 0 }, // unused +}; + + +bool EmitterModuleParameters::mBuiltFlag = false; +NvParameterized::MutexType EmitterModuleParameters::mBuiltFlagMutex; + +EmitterModuleParameters::EmitterModuleParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &EmitterModuleParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +EmitterModuleParameters::~EmitterModuleParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void EmitterModuleParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~EmitterModuleParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* EmitterModuleParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* EmitterModuleParameters::getParameterDefinitionTree(void) const +{ + EmitterModuleParameters* tmpParam = const_cast<EmitterModuleParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType EmitterModuleParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType EmitterModuleParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void EmitterModuleParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<EmitterModuleParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void EmitterModuleParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void EmitterModuleParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class is used for initializing the ModuleEmitter.", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="unused" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("unused", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "No parameters necessary", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(1); + + ParamDefTable[0].setChildren(Children, 1); + } + + mBuiltFlag = true; + +} +void EmitterModuleParameters::initStrings(void) +{ +} + +void EmitterModuleParameters::initDynamicArrays(void) +{ +} + +void EmitterModuleParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + unused = uint32_t(0); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void EmitterModuleParameters::initReferences(void) +{ +} + +void EmitterModuleParameters::freeDynamicArrays(void) +{ +} + +void EmitterModuleParameters::freeStrings(void) +{ +} + +void EmitterModuleParameters::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/GroundEmitterActorParameters.cpp b/APEX_1.4/module/emitter/src/autogen/GroundEmitterActorParameters.cpp new file mode 100644 index 00000000..d7640652 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/GroundEmitterActorParameters.cpp @@ -0,0 +1,550 @@ +// 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 + + +#include "GroundEmitterActorParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace GroundEmitterActorParametersNS; + +const char* const GroundEmitterActorParametersFactory::vptr = + NvParameterized::getVptr<GroundEmitterActorParameters, GroundEmitterActorParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 10; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 9 }, + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->density), NULL, 0 }, // density + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->radius), NULL, 0 }, // radius + { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->upDirection), NULL, 0 }, // upDirection + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->raycastHeight), NULL, 0 }, // raycastHeight + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->spawnHeight), NULL, 0 }, // spawnHeight + { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->maxRaycastsPerFrame), NULL, 0 }, // maxRaycastsPerFrame + { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->raycastCollisionGroupMaskName), NULL, 0 }, // raycastCollisionGroupMaskName + { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->attachRelativePosition), NULL, 0 }, // attachRelativePosition + { TYPE_TRANSFORM, false, (size_t)(&((ParametersStruct*)0)->globalPose), NULL, 0 }, // globalPose +}; + + +bool GroundEmitterActorParameters::mBuiltFlag = false; +NvParameterized::MutexType GroundEmitterActorParameters::mBuiltFlagMutex; + +GroundEmitterActorParameters::GroundEmitterActorParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &GroundEmitterActorParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +GroundEmitterActorParameters::~GroundEmitterActorParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void GroundEmitterActorParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~GroundEmitterActorParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* GroundEmitterActorParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* GroundEmitterActorParameters::getParameterDefinitionTree(void) const +{ + GroundEmitterActorParameters* tmpParam = const_cast<GroundEmitterActorParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType GroundEmitterActorParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType GroundEmitterActorParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void GroundEmitterActorParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<GroundEmitterActorParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void GroundEmitterActorParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void GroundEmitterActorParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class is used for creating GroundEmitterActor instances", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="density" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("density", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "Density", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="radius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("radius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", uint64_t(10), true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(10), true); + HintTable[1].init("longDescription", "The ground emitter actor will create objects within a circle of size 'radius'.\n", true); + HintTable[2].init("shortDescription", "Radius", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="upDirection" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("upDirection", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "The ground emitter asset needs to know what direction is 'up'.\n", true); + HintTable[1].init("shortDescription", "Up Direction", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="raycastHeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("raycastHeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "The height from which the ground emitter will cast rays at terrain/objects opposite of the 'upDirection'.\n", true); + HintTable[1].init("shortDescription", "Raycast Height", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=5, longName="spawnHeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5]; + ParamDef->init("spawnHeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("longDescription", "The height above the ground to emit particles. If greater than 0, the ground emitter will refresh a disc above the player's position rather than refreshing a circle around the player's position.\n", true); + HintTable[2].init("shortDescription", "Spawn Height", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=6, longName="maxRaycastsPerFrame" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6]; + ParamDef->init("maxRaycastsPerFrame", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "UINT32_MAX", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", "UINT32_MAX", true); + HintTable[1].init("longDescription", "The maximum raycasts per frame.\n", true); + HintTable[2].init("shortDescription", "Maximum Raycasts per Frame", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=7, longName="raycastCollisionGroupMaskName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7]; + ParamDef->init("raycastCollisionGroupMaskName", TYPE_STRING, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "This name resolves to a 32-bit bitmask of collision groups for raycasts around the player. \nIt is resolved by a call to the named resource provider using the 'NSCollisionGroupMask' \nand 'NSCollisionGroup128' namespaces. If none is provided, the raycast will hit everything in the scene. \nThis avoids storing fragile enums in asset files. \n", true); + HintTable[1].init("shortDescription", "Raycast Collision Group Mask Name", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=8, longName="attachRelativePosition" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8]; + ParamDef->init("attachRelativePosition", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "The ground emitter will offset this value from the attach actor position.\n", true); + HintTable[1].init("shortDescription", "Attach Relative Position", true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=9, longName="globalPose" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9]; + ParamDef->init("globalPose", TYPE_TRANSFORM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "An identity rotation matrix will result in a +Y up ground emitter, provide a rotation if another orientation is desired.\n", true); + HintTable[1].init("shortDescription", "The actor's pose", true); + ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[9]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + Children[3] = PDEF_PTR(4); + Children[4] = PDEF_PTR(5); + Children[5] = PDEF_PTR(6); + Children[6] = PDEF_PTR(7); + Children[7] = PDEF_PTR(8); + Children[8] = PDEF_PTR(9); + + ParamDefTable[0].setChildren(Children, 9); + } + + mBuiltFlag = true; + +} +void GroundEmitterActorParameters::initStrings(void) +{ + raycastCollisionGroupMaskName.isAllocated = true; + raycastCollisionGroupMaskName.buf = NULL; +} + +void GroundEmitterActorParameters::initDynamicArrays(void) +{ +} + +void GroundEmitterActorParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + density = float(1); + radius = float(10.0f); + upDirection = physx::PxVec3(init(0, 1, 0)); + raycastHeight = float(10.0f); + spawnHeight = float(0.0f); + maxRaycastsPerFrame = uint32_t(UINT32_MAX); + attachRelativePosition = physx::PxVec3(init(0, 0, 0)); + globalPose = physx::PxTransform(physx::PxIdentity); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void GroundEmitterActorParameters::initReferences(void) +{ +} + +void GroundEmitterActorParameters::freeDynamicArrays(void) +{ +} + +void GroundEmitterActorParameters::freeStrings(void) +{ + + if (raycastCollisionGroupMaskName.isAllocated && raycastCollisionGroupMaskName.buf) + { + mParameterizedTraits->strfree((char*)raycastCollisionGroupMaskName.buf); + } +} + +void GroundEmitterActorParameters::freeReferences(void) +{ +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/GroundEmitterAssetParameters.cpp b/APEX_1.4/module/emitter/src/autogen/GroundEmitterAssetParameters.cpp new file mode 100644 index 00000000..0923dd10 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/GroundEmitterAssetParameters.cpp @@ -0,0 +1,1099 @@ +// 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 + + +#include "GroundEmitterAssetParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace GroundEmitterAssetParametersNS; + +const char* const GroundEmitterAssetParametersFactory::vptr = + NvParameterized::getVptr<GroundEmitterAssetParameters, GroundEmitterAssetParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 26; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 11 }, + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->density), NULL, 0 }, // density + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->lifetimeLow), NULL, 0 }, // lifetimeLow + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->lifetimeHigh), NULL, 0 }, // lifetimeHigh + { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->velocityLow), NULL, 0 }, // velocityLow + { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->velocityHigh), NULL, 0 }, // velocityHigh + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->radius), NULL, 0 }, // radius + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->raycastHeight), NULL, 0 }, // raycastHeight + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->spawnHeight), NULL, 0 }, // spawnHeight + { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->maxRaycastsPerFrame), NULL, 0 }, // maxRaycastsPerFrame + { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->raycastCollisionGroupMaskName), NULL, 0 }, // raycastCollisionGroupMaskName + { TYPE_ARRAY, true, (size_t)(&((ParametersStruct*)0)->materialFactoryMapList), CHILDREN(11), 1 }, // materialFactoryMapList + { TYPE_STRUCT, false, 1 * sizeof(materialFactoryMapping_Type), CHILDREN(12), 6 }, // materialFactoryMapList[] + { TYPE_REF, false, (size_t)(&((materialFactoryMapping_Type*)0)->iofxAssetName), NULL, 0 }, // materialFactoryMapList[].iofxAssetName + { TYPE_REF, false, (size_t)(&((materialFactoryMapping_Type*)0)->iosAssetName), NULL, 0 }, // materialFactoryMapList[].iosAssetName + { TYPE_STRING, false, (size_t)(&((materialFactoryMapping_Type*)0)->physMatName), NULL, 0 }, // materialFactoryMapList[].physMatName + { TYPE_F32, false, (size_t)(&((materialFactoryMapping_Type*)0)->weight), NULL, 0 }, // materialFactoryMapList[].weight + { TYPE_F32, false, (size_t)(&((materialFactoryMapping_Type*)0)->maxSlopeAngle), NULL, 0 }, // materialFactoryMapList[].maxSlopeAngle + { TYPE_STRUCT, false, (size_t)(&((materialFactoryMapping_Type*)0)->lodParamDesc), CHILDREN(18), 7 }, // materialFactoryMapList[].lodParamDesc + { TYPE_U32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->version), NULL, 0 }, // materialFactoryMapList[].lodParamDesc.version + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->maxDistance), NULL, 0 }, // materialFactoryMapList[].lodParamDesc.maxDistance + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->distanceWeight), NULL, 0 }, // materialFactoryMapList[].lodParamDesc.distanceWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->speedWeight), NULL, 0 }, // materialFactoryMapList[].lodParamDesc.speedWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->lifeWeight), NULL, 0 }, // materialFactoryMapList[].lodParamDesc.lifeWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->separationWeight), NULL, 0 }, // materialFactoryMapList[].lodParamDesc.separationWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->bias), NULL, 0 }, // materialFactoryMapList[].lodParamDesc.bias +}; + + +bool GroundEmitterAssetParameters::mBuiltFlag = false; +NvParameterized::MutexType GroundEmitterAssetParameters::mBuiltFlagMutex; + +GroundEmitterAssetParameters::GroundEmitterAssetParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &GroundEmitterAssetParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +GroundEmitterAssetParameters::~GroundEmitterAssetParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void GroundEmitterAssetParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~GroundEmitterAssetParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* GroundEmitterAssetParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* GroundEmitterAssetParameters::getParameterDefinitionTree(void) const +{ + GroundEmitterAssetParameters* tmpParam = const_cast<GroundEmitterAssetParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType GroundEmitterAssetParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType GroundEmitterAssetParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void GroundEmitterAssetParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<GroundEmitterAssetParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ +/* [1,0] - materialFactoryMapList.iofxAssetName */ +/* [1,1] - materialFactoryMapList.iosAssetName */ +/* [1,2] - materialFactoryMapList.physMatName */ + +void GroundEmitterAssetParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void GroundEmitterAssetParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class is parameter storage for the GroundEmitterAsset", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="density" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("density", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "The ground emitter actor will use the maximum density in the range, but it will back off to the minimum density if the actor is LOD resource limited.\n", true); + HintTable[1].init("shortDescription", "Desired density of spawned particles per unit of volume.", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="lifetimeLow" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("lifetimeLow", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("tweakable", "true", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "The emitter actor will create particles with a random lifetime (in seconds) within the lifetime range.\n", true); + HintTable[1].init("shortDescription", "Low value of particle lifetime", true); + HintTable[2].init("tweakable", "true", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="lifetimeHigh" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("lifetimeHigh", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("tweakable", "true", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "The emitter actor will create particles with a random lifetime (in seconds) within the lifetime range.\n", true); + HintTable[1].init("shortDescription", "High value of particle lifetime", true); + HintTable[2].init("tweakable", "true", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="velocityLow" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("velocityLow", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("tweakable", "true", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("longDescription", "The emitter actor will create particles with a random velocity within the velocity range.\n", true); + HintTable[2].init("shortDescription", "Random velocity given within range", true); + HintTable[3].init("tweakable", "true", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=5, longName="velocityHigh" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5]; + ParamDef->init("velocityHigh", TYPE_VEC3, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("tweakable", "true", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("gameScale", "true", true); + HintTable[1].init("longDescription", "The emitter actor will create particles with a random velocity within the velocity range.\n", true); + HintTable[2].init("shortDescription", "Random velocity given within range", true); + HintTable[3].init("tweakable", "true", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=6, longName="radius" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6]; + ParamDef->init("radius", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(10), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(10), true); + HintTable[1].init("longDescription", "The ground emitter actor will create objects within a circle of size 'radius'.\n", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Radius", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=7, longName="raycastHeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7]; + ParamDef->init("raycastHeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("min", uint64_t(0), true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("longDescription", "The height from which the ground emitter will cast rays at terrain/objects opposite of the 'upDirection'.\n", true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Raycast Height", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=8, longName="spawnHeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8]; + ParamDef->init("spawnHeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("longDescription", "The height above the ground to emit particles. If greater than 0, the ground emitter will refresh a disc above the player's position rather than refreshing a circle around the player's position.\n", true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Spawn Height", true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=9, longName="maxRaycastsPerFrame" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9]; + ParamDef->init("maxRaycastsPerFrame", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "The maximum raycasts per frame.\n", true); + HintTable[1].init("shortDescription", "Maximum Raycasts per Frame", true); + ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=10, longName="raycastCollisionGroupMaskName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[10]; + ParamDef->init("raycastCollisionGroupMaskName", TYPE_STRING, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "Defines a bitmask of collision groups for the raycasts around the player. If none is provided, \nthe raycast will hit everything in the scene. This name will be resolved into a bitmask of \ncollision group IDs by a call to the named resource provider using both the 'NSCollisionGroupMask' \nand 'NSCollisionGroup128' namespaces. This avoids storing fragile enums in asset files. The collision \ngroups and collision group mask and 128 bit GroupsMask can be set directly on GroundEmitterActors.\n", true); + HintTable[1].init("shortDescription", "Raycast Collision Group Mask Name", true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=11, longName="materialFactoryMapList" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[11]; + ParamDef->init("materialFactoryMapList", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "This dynamic array contains a list of IOFX/IOS to PhysX Material mappings.\n", true); + HintTable[1].init("shortDescription", "Material Factory Map List", true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + ParamDef->setArraySize(-1); + static const uint8_t dynHandleIndices[6] = { 1, 0, 1, 1, 1, 2, }; + ParamDef->setDynamicHandleIndicesMap(dynHandleIndices, 6); + + } + + // Initialize DefinitionImpl node: nodeIndex=12, longName="materialFactoryMapList[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[12]; + ParamDef->init("materialFactoryMapList", TYPE_STRUCT, "materialFactoryMapping", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("longDescription", "This dynamic array contains a list of IOFX/IOS to PhysX Material mappings.\n", true); + HintTable[1].init("shortDescription", "Material Factory Map List", true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=13, longName="materialFactoryMapList[].iofxAssetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[13]; + ParamDef->init("iofxAssetName", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The name of the instanced object effects asset that will render your particles", true); + ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "IOFX" }; + ParamDefTable[13].setRefVariantVals((const char**)RefVariantVals, 1); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=14, longName="materialFactoryMapList[].iosAssetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[14]; + ParamDef->init("iosAssetName", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The asset name of the particle system that will simulate your particles", true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "BasicIosAsset", "ParticleIosAsset" }; + ParamDefTable[14].setRefVariantVals((const char**)RefVariantVals, 2); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=15, longName="materialFactoryMapList[].physMatName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[15]; + ParamDef->init("physMatName", TYPE_STRING, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "User defined material name. The ground emitter will convert this name into an * MaterialID at runtime by a getResource() call to the named resource provider under the namespace \"NSPhysicalMaterial\" * Note this is the physical material, not rendering material.", true); + ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=16, longName="materialFactoryMapList[].weight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[16]; + ParamDef->init("weight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "The weight of this factory relative to other factories on the same material", true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=17, longName="materialFactoryMapList[].maxSlopeAngle" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[17]; + ParamDef->init("maxSlopeAngle", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(90), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(90), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "The maximum slope at which particles will be added to the surface in degrees where 0 is horizontal and 90 is vertical.", true); + ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=18, longName="materialFactoryMapList[].lodParamDesc" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[18]; + ParamDef->init("lodParamDesc", TYPE_STRUCT, "emitterLodParamDesc", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=19, longName="materialFactoryMapList[].lodParamDesc.version" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[19]; + ParamDef->init("version", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("shortDescription", "Helpful documentation goes here", true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=20, longName="materialFactoryMapList[].lodParamDesc.maxDistance" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[20]; + ParamDef->init("maxDistance", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Objects greater than this distance from the player will be culled more aggressively", true); + ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=21, longName="materialFactoryMapList[].lodParamDesc.distanceWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[21]; + ParamDef->init("distanceWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to distance parameter in LOD function", true); + ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=22, longName="materialFactoryMapList[].lodParamDesc.speedWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[22]; + ParamDef->init("speedWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[22].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to velocity parameter in LOD function", true); + ParamDefTable[22].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=23, longName="materialFactoryMapList[].lodParamDesc.lifeWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[23]; + ParamDef->init("lifeWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to life remain parameter in LOD function", true); + ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=24, longName="materialFactoryMapList[].lodParamDesc.separationWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[24]; + ParamDef->init("separationWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[24].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to separation parameter in LOD function", true); + ParamDefTable[24].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=25, longName="materialFactoryMapList[].lodParamDesc.bias" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[25]; + ParamDef->init("bias", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[25].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Bias given to objects spawned by this emitter, relative to other emitters in the same IOS", true); + ParamDefTable[25].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[11]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + Children[3] = PDEF_PTR(4); + Children[4] = PDEF_PTR(5); + Children[5] = PDEF_PTR(6); + Children[6] = PDEF_PTR(7); + Children[7] = PDEF_PTR(8); + Children[8] = PDEF_PTR(9); + Children[9] = PDEF_PTR(10); + Children[10] = PDEF_PTR(11); + + ParamDefTable[0].setChildren(Children, 11); + } + + // SetChildren for: nodeIndex=11, longName="materialFactoryMapList" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(12); + + ParamDefTable[11].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=12, longName="materialFactoryMapList[]" + { + static Definition* Children[6]; + Children[0] = PDEF_PTR(13); + Children[1] = PDEF_PTR(14); + Children[2] = PDEF_PTR(15); + Children[3] = PDEF_PTR(16); + Children[4] = PDEF_PTR(17); + Children[5] = PDEF_PTR(18); + + ParamDefTable[12].setChildren(Children, 6); + } + + // SetChildren for: nodeIndex=18, longName="materialFactoryMapList[].lodParamDesc" + { + static Definition* Children[7]; + Children[0] = PDEF_PTR(19); + Children[1] = PDEF_PTR(20); + Children[2] = PDEF_PTR(21); + Children[3] = PDEF_PTR(22); + Children[4] = PDEF_PTR(23); + Children[5] = PDEF_PTR(24); + Children[6] = PDEF_PTR(25); + + ParamDefTable[18].setChildren(Children, 7); + } + + mBuiltFlag = true; + +} +void GroundEmitterAssetParameters::initStrings(void) +{ + raycastCollisionGroupMaskName.isAllocated = true; + raycastCollisionGroupMaskName.buf = NULL; +} + +void GroundEmitterAssetParameters::initDynamicArrays(void) +{ + materialFactoryMapList.buf = NULL; + materialFactoryMapList.isAllocated = true; + materialFactoryMapList.elementSize = sizeof(materialFactoryMapping_Type); + materialFactoryMapList.arraySizes[0] = 0; +} + +void GroundEmitterAssetParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + density = float(1); + lifetimeLow = float(1); + lifetimeHigh = float(1); + velocityLow = physx::PxVec3(init(0, 0, 0)); + velocityHigh = physx::PxVec3(init(0, 0, 0)); + radius = float(10.0f); + raycastHeight = float(10.0f); + spawnHeight = float(0.0f); + maxRaycastsPerFrame = uint32_t(0xffffffff); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void GroundEmitterAssetParameters::initReferences(void) +{ +} + +void GroundEmitterAssetParameters::freeDynamicArrays(void) +{ + if (materialFactoryMapList.isAllocated && materialFactoryMapList.buf) + { + mParameterizedTraits->free(materialFactoryMapList.buf); + } +} + +void GroundEmitterAssetParameters::freeStrings(void) +{ + + if (raycastCollisionGroupMaskName.isAllocated && raycastCollisionGroupMaskName.buf) + { + mParameterizedTraits->strfree((char*)raycastCollisionGroupMaskName.buf); + } + + for (int i = 0; i < materialFactoryMapList.arraySizes[0]; ++i) + { + if (materialFactoryMapList.buf[i].physMatName.isAllocated && materialFactoryMapList.buf[i].physMatName.buf) + { + mParameterizedTraits->strfree((char*)materialFactoryMapList.buf[i].physMatName.buf); + } + } +} + +void GroundEmitterAssetParameters::freeReferences(void) +{ + + for (int i = 0; i < materialFactoryMapList.arraySizes[0]; i++) + { + if (materialFactoryMapList.buf[i].iofxAssetName) + { + materialFactoryMapList.buf[i].iofxAssetName->destroy(); + } + if (materialFactoryMapList.buf[i].iosAssetName) + { + materialFactoryMapList.buf[i].iosAssetName->destroy(); + } + } +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/ImpactEmitterActorParameters.cpp b/APEX_1.4/module/emitter/src/autogen/ImpactEmitterActorParameters.cpp new file mode 100644 index 00000000..cf8c8cc9 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/ImpactEmitterActorParameters.cpp @@ -0,0 +1,333 @@ +// 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 + + +#include "ImpactEmitterActorParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace ImpactEmitterActorParametersNS; + +const char* const ImpactEmitterActorParametersFactory::vptr = + NvParameterized::getVptr<ImpactEmitterActorParameters, ImpactEmitterActorParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 2; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 1 }, + { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->explosionEnv), NULL, 0 }, // explosionEnv +}; + + +bool ImpactEmitterActorParameters::mBuiltFlag = false; +NvParameterized::MutexType ImpactEmitterActorParameters::mBuiltFlagMutex; + +ImpactEmitterActorParameters::ImpactEmitterActorParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &ImpactEmitterActorParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +ImpactEmitterActorParameters::~ImpactEmitterActorParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void ImpactEmitterActorParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~ImpactEmitterActorParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* ImpactEmitterActorParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* ImpactEmitterActorParameters::getParameterDefinitionTree(void) const +{ + ImpactEmitterActorParameters* tmpParam = const_cast<ImpactEmitterActorParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType ImpactEmitterActorParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType ImpactEmitterActorParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void ImpactEmitterActorParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ImpactEmitterActorParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void ImpactEmitterActorParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void ImpactEmitterActorParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class is used for creating ImpactEmitterActor instances", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="explosionEnv" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("explosionEnv", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + HintTable[1].init("longDescription", "Explosion actors created by this impact emitter actor will be passed these parameters", true); + HintTable[2].init("shortDescription", "Explosion Actor Environment Settings", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "ExplosionEnvParameters" }; + ParamDefTable[1].setRefVariantVals((const char**)RefVariantVals, 1); + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(1); + + ParamDefTable[0].setChildren(Children, 1); + } + + mBuiltFlag = true; + +} +void ImpactEmitterActorParameters::initStrings(void) +{ +} + +void ImpactEmitterActorParameters::initDynamicArrays(void) +{ +} + +void ImpactEmitterActorParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void ImpactEmitterActorParameters::initReferences(void) +{ + explosionEnv = NULL; + +} + +void ImpactEmitterActorParameters::freeDynamicArrays(void) +{ +} + +void ImpactEmitterActorParameters::freeStrings(void) +{ +} + +void ImpactEmitterActorParameters::freeReferences(void) +{ + if (explosionEnv) + { + explosionEnv->destroy(); + } + +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/ImpactEmitterAssetParameters.cpp b/APEX_1.4/module/emitter/src/autogen/ImpactEmitterAssetParameters.cpp new file mode 100644 index 00000000..f3076227 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/ImpactEmitterAssetParameters.cpp @@ -0,0 +1,386 @@ +// 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 + + +#include "ImpactEmitterAssetParameters.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace ImpactEmitterAssetParametersNS; + +const char* const ImpactEmitterAssetParametersFactory::vptr = + NvParameterized::getVptr<ImpactEmitterAssetParameters, ImpactEmitterAssetParameters::ClassAlignment>(); + +const uint32_t NumParamDefs = 3; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 1 }, + { TYPE_ARRAY, true, (size_t)(&((ParametersStruct*)0)->eventSetList), CHILDREN(1), 1 }, // eventSetList + { TYPE_REF, false, 1 * sizeof(NvParameterized::Interface*), NULL, 0 }, // eventSetList[] +}; + + +bool ImpactEmitterAssetParameters::mBuiltFlag = false; +NvParameterized::MutexType ImpactEmitterAssetParameters::mBuiltFlagMutex; + +ImpactEmitterAssetParameters::ImpactEmitterAssetParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &ImpactEmitterAssetParametersFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +ImpactEmitterAssetParameters::~ImpactEmitterAssetParameters() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void ImpactEmitterAssetParameters::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~ImpactEmitterAssetParameters(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* ImpactEmitterAssetParameters::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* ImpactEmitterAssetParameters::getParameterDefinitionTree(void) const +{ + ImpactEmitterAssetParameters* tmpParam = const_cast<ImpactEmitterAssetParameters*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType ImpactEmitterAssetParameters::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType ImpactEmitterAssetParameters::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void ImpactEmitterAssetParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ImpactEmitterAssetParameters::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ +/* [0] - eventSetList (not an array of structs) */ + +void ImpactEmitterAssetParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void ImpactEmitterAssetParameters::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "This class is parameter storage for the Impact Emitter", true); + ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="eventSetList" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("eventSetList", TYPE_ARRAY, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + HintTable[1].init("longDescription", "This dynamic array contains a list of events (particle or explosion spawning).", true); + HintTable[2].init("shortDescription", "Event Set List", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "ImpactObjectEvent", "ImpactExplosionEvent" }; + ParamDefTable[1].setRefVariantVals((const char**)RefVariantVals, 2); + + + ParamDef->setArraySize(-1); + static const uint8_t dynHandleIndices[1] = { 0, }; + ParamDef->setDynamicHandleIndicesMap(dynHandleIndices, 1); + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="eventSetList[]" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("eventSetList", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("INCLUDED", uint64_t(1), true); + HintTable[1].init("longDescription", "This dynamic array contains a list of events (particle or explosion spawning).", true); + HintTable[2].init("shortDescription", "Event Set List", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "ImpactObjectEvent", "ImpactExplosionEvent" }; + ParamDefTable[2].setRefVariantVals((const char**)RefVariantVals, 2); + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(1); + + ParamDefTable[0].setChildren(Children, 1); + } + + // SetChildren for: nodeIndex=1, longName="eventSetList" + { + static Definition* Children[1]; + Children[0] = PDEF_PTR(2); + + ParamDefTable[1].setChildren(Children, 1); + } + + mBuiltFlag = true; + +} +void ImpactEmitterAssetParameters::initStrings(void) +{ +} + +void ImpactEmitterAssetParameters::initDynamicArrays(void) +{ + eventSetList.buf = NULL; + eventSetList.isAllocated = true; + eventSetList.elementSize = sizeof(NvParameterized::Interface*); + eventSetList.arraySizes[0] = 0; +} + +void ImpactEmitterAssetParameters::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void ImpactEmitterAssetParameters::initReferences(void) +{ +} + +void ImpactEmitterAssetParameters::freeDynamicArrays(void) +{ + if (eventSetList.isAllocated && eventSetList.buf) + { + mParameterizedTraits->free(eventSetList.buf); + } +} + +void ImpactEmitterAssetParameters::freeStrings(void) +{ +} + +void ImpactEmitterAssetParameters::freeReferences(void) +{ + + for (int i = 0; i < eventSetList.arraySizes[0]; ++i) + { + if (eventSetList.buf[i]) + { + eventSetList.buf[i]->destroy(); + } + } +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/ImpactExplosionEvent.cpp b/APEX_1.4/module/emitter/src/autogen/ImpactExplosionEvent.cpp new file mode 100644 index 00000000..0c2559d3 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/ImpactExplosionEvent.cpp @@ -0,0 +1,413 @@ +// 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 + + +#include "ImpactExplosionEvent.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace ImpactExplosionEventNS; + +const char* const ImpactExplosionEventFactory::vptr = + NvParameterized::getVptr<ImpactExplosionEvent, ImpactExplosionEvent::ClassAlignment>(); + +const uint32_t NumParamDefs = 5; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, 4, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 4 }, + { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->eventSetName), NULL, 0 }, // eventSetName + { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->explosionAssetName), NULL, 0 }, // explosionAssetName + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->delay), NULL, 0 }, // delay + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->duration), NULL, 0 }, // duration +}; + + +bool ImpactExplosionEvent::mBuiltFlag = false; +NvParameterized::MutexType ImpactExplosionEvent::mBuiltFlagMutex; + +ImpactExplosionEvent::ImpactExplosionEvent(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &ImpactExplosionEventFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +ImpactExplosionEvent::~ImpactExplosionEvent() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void ImpactExplosionEvent::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~ImpactExplosionEvent(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* ImpactExplosionEvent::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* ImpactExplosionEvent::getParameterDefinitionTree(void) const +{ + ImpactExplosionEvent* tmpParam = const_cast<ImpactExplosionEvent*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType ImpactExplosionEvent::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType ImpactExplosionEvent::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void ImpactExplosionEvent::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ImpactExplosionEvent::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void ImpactExplosionEvent::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void ImpactExplosionEvent::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="eventSetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("eventSetName", TYPE_STRING, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The name of the event set (you can put multiple events in an event set)", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="explosionAssetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("explosionAssetName", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The asset name of the explosion that will optionally accompany the impact event", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "ExplosionAsset" }; + ParamDefTable[2].setRefVariantVals((const char**)RefVariantVals, 1); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="delay" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("delay", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "The delay (in seconds) after impact to wait before triggering", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="duration" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("duration", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "The length (in seconds) of the explosion", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[4]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + Children[3] = PDEF_PTR(4); + + ParamDefTable[0].setChildren(Children, 4); + } + + mBuiltFlag = true; + +} +void ImpactExplosionEvent::initStrings(void) +{ + eventSetName.isAllocated = true; + eventSetName.buf = NULL; +} + +void ImpactExplosionEvent::initDynamicArrays(void) +{ +} + +void ImpactExplosionEvent::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + delay = float(0); + duration = float(1); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void ImpactExplosionEvent::initReferences(void) +{ + explosionAssetName = NULL; + +} + +void ImpactExplosionEvent::freeDynamicArrays(void) +{ +} + +void ImpactExplosionEvent::freeStrings(void) +{ + + if (eventSetName.isAllocated && eventSetName.buf) + { + mParameterizedTraits->strfree((char*)eventSetName.buf); + } +} + +void ImpactExplosionEvent::freeReferences(void) +{ + if (explosionAssetName) + { + explosionAssetName->destroy(); + } + +} + +} // namespace emitter +} // namespace nvidia diff --git a/APEX_1.4/module/emitter/src/autogen/ImpactObjectEvent.cpp b/APEX_1.4/module/emitter/src/autogen/ImpactObjectEvent.cpp new file mode 100644 index 00000000..3baea436 --- /dev/null +++ b/APEX_1.4/module/emitter/src/autogen/ImpactObjectEvent.cpp @@ -0,0 +1,887 @@ +// 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 + + +#include "ImpactObjectEvent.h" +#include <string.h> +#include <stdlib.h> + +using namespace NvParameterized; + +namespace nvidia +{ +namespace emitter +{ + +using namespace ImpactObjectEventNS; + +const char* const ImpactObjectEventFactory::vptr = + NvParameterized::getVptr<ImpactObjectEvent, ImpactObjectEvent::ClassAlignment>(); + +const uint32_t NumParamDefs = 21; +static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs]; + + +static const size_t ParamLookupChildrenTable[] = +{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, +}; + +#define TENUM(type) nvidia::##type +#define CHILDREN(index) &ParamLookupChildrenTable[index] +static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] = +{ + { TYPE_STRUCT, false, 0, CHILDREN(0), 13 }, + { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->eventSetName), NULL, 0 }, // eventSetName + { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->iofxAssetName), NULL, 0 }, // iofxAssetName + { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->iosAssetName), NULL, 0 }, // iosAssetName + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->angleLow), NULL, 0 }, // angleLow + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->angleHigh), NULL, 0 }, // angleHigh + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->speedLow), NULL, 0 }, // speedLow + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->speedHigh), NULL, 0 }, // speedHigh + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->lifeLow), NULL, 0 }, // lifeLow + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->lifeHigh), NULL, 0 }, // lifeHigh + { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->delay), NULL, 0 }, // delay + { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->particleSpawnCount), NULL, 0 }, // particleSpawnCount + { TYPE_ENUM, false, (size_t)(&((ParametersStruct*)0)->impactAxis), NULL, 0 }, // impactAxis + { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->lodParamDesc), CHILDREN(13), 7 }, // lodParamDesc + { TYPE_U32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->version), NULL, 0 }, // lodParamDesc.version + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->maxDistance), NULL, 0 }, // lodParamDesc.maxDistance + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->distanceWeight), NULL, 0 }, // lodParamDesc.distanceWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->speedWeight), NULL, 0 }, // lodParamDesc.speedWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->lifeWeight), NULL, 0 }, // lodParamDesc.lifeWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->separationWeight), NULL, 0 }, // lodParamDesc.separationWeight + { TYPE_F32, false, (size_t)(&((emitterLodParamDesc_Type*)0)->bias), NULL, 0 }, // lodParamDesc.bias +}; + + +bool ImpactObjectEvent::mBuiltFlag = false; +NvParameterized::MutexType ImpactObjectEvent::mBuiltFlagMutex; + +ImpactObjectEvent::ImpactObjectEvent(NvParameterized::Traits* traits, void* buf, int32_t* refCount) : + NvParameters(traits, buf, refCount) +{ + //mParameterizedTraits->registerFactory(className(), &ImpactObjectEventFactoryInst); + + if (!buf) //Do not init data if it is inplace-deserialized + { + initDynamicArrays(); + initStrings(); + initReferences(); + initDefaults(); + } +} + +ImpactObjectEvent::~ImpactObjectEvent() +{ + freeStrings(); + freeReferences(); + freeDynamicArrays(); +} + +void ImpactObjectEvent::destroy() +{ + // We cache these fields here to avoid overwrite in destructor + bool doDeallocateSelf = mDoDeallocateSelf; + NvParameterized::Traits* traits = mParameterizedTraits; + int32_t* refCount = mRefCount; + void* buf = mBuffer; + + this->~ImpactObjectEvent(); + + NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf); +} + +const NvParameterized::DefinitionImpl* ImpactObjectEvent::getParameterDefinitionTree(void) +{ + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +const NvParameterized::DefinitionImpl* ImpactObjectEvent::getParameterDefinitionTree(void) const +{ + ImpactObjectEvent* tmpParam = const_cast<ImpactObjectEvent*>(this); + + if (!mBuiltFlag) // Double-checked lock + { + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + if (!mBuiltFlag) + { + tmpParam->buildTree(); + } + } + + return(&ParamDefTable[0]); +} + +NvParameterized::ErrorType ImpactObjectEvent::getParameterHandle(const char* long_name, Handle& handle) const +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +NvParameterized::ErrorType ImpactObjectEvent::getParameterHandle(const char* long_name, Handle& handle) +{ + ErrorType Ret = NvParameters::getParameterHandle(long_name, handle); + if (Ret != ERROR_NONE) + { + return(Ret); + } + + size_t offset; + void* ptr; + + getVarPtr(handle, ptr, offset); + + if (ptr == NULL) + { + return(ERROR_INDEX_OUT_OF_RANGE); + } + + return(ERROR_NONE); +} + +void ImpactObjectEvent::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const +{ + ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ImpactObjectEvent::ParametersStruct*>(¶meters()), handle, offset); +} + + +/* Dynamic Handle Indices */ + +void ImpactObjectEvent::freeParameterDefinitionTable(NvParameterized::Traits* traits) +{ + if (!traits) + { + return; + } + + if (!mBuiltFlag) // Double-checked lock + { + return; + } + + NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex); + + if (!mBuiltFlag) + { + return; + } + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + ParamDefTable[i].~DefinitionImpl(); + } + + traits->free(ParamDefTable); + + mBuiltFlag = false; +} + +#define PDEF_PTR(index) (&ParamDefTable[index]) + +void ImpactObjectEvent::buildTree(void) +{ + + uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs; + ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize)); + memset(ParamDefTable, 0, allocSize); + + for (uint32_t i = 0; i < NumParamDefs; ++i) + { + NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits); + } + + // Initialize DefinitionImpl node: nodeIndex=0, longName="" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0]; + ParamDef->init("", TYPE_STRUCT, "STRUCT", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=1, longName="eventSetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1]; + ParamDef->init("eventSetName", TYPE_STRING, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The name of the event set (you can put multiple events in an event set)", true); + ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=2, longName="iofxAssetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2]; + ParamDef->init("iofxAssetName", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The name of the instanced object effects asset that will render the particles", true); + ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "IOFX" }; + ParamDefTable[2].setRefVariantVals((const char**)RefVariantVals, 1); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=3, longName="iosAssetName" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3]; + ParamDef->init("iosAssetName", TYPE_REF, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The asset name of the particle system that will simulate the particles", true); + ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + static const char* const RefVariantVals[] = { "BasicIosAsset", "ParticleIosAsset" }; + ParamDefTable[3].setRefVariantVals((const char**)RefVariantVals, 2); + + + + } + + // Initialize DefinitionImpl node: nodeIndex=4, longName="angleLow" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4]; + ParamDef->init("angleLow", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The particle emission angle range in degrees", true); + ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=5, longName="angleHigh" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5]; + ParamDef->init("angleHigh", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The particle emission angle range in degrees", true); + ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=6, longName="speedLow" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6]; + ParamDef->init("speedLow", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The particle emission speed range", true); + ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=7, longName="speedHigh" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7]; + ParamDef->init("speedHigh", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The particle emission speed range", true); + ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=8, longName="lifeLow" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8]; + ParamDef->init("lifeLow", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The particle life range in seconds", true); + ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=9, longName="lifeHigh" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9]; + ParamDef->init("lifeHigh", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + +#else + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("shortDescription", "The particle life range in seconds", true); + ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=10, longName="delay" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[10]; + ParamDef->init("delay", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "The delay (in seconds) after impact to wait before triggering", true); + ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=11, longName="particleSpawnCount" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[11]; + ParamDef->init("particleSpawnCount", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(10), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(10), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "The number of particles emitted per impact", true); + ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=12, longName="impactAxis" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[12]; + ParamDef->init("impactAxis", TYPE_ENUM, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", "reflection", true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", "reflection", true); + HintTable[1].init("shortDescription", "The method used to emit particles at the point of impact", true); + ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + static const char* const EnumVals[] = { "incident", "normal", "reflection" }; + ParamDefTable[12].setEnumVals((const char**)EnumVals, 3); + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=13, longName="lodParamDesc" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[13]; + ParamDef->init("lodParamDesc", TYPE_STRUCT, "emitterLodParamDesc", true); + + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=14, longName="lodParamDesc.version" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[14]; + ParamDef->init("version", TYPE_U32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[1]; + static Hint* HintPtrTable[1] = { &HintTable[0], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 1); + +#else + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("shortDescription", "Helpful documentation goes here", true); + ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=15, longName="lodParamDesc.maxDistance" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[15]; + ParamDef->init("maxDistance", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Objects greater than this distance from the player will be culled more aggressively", true); + ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=16, longName="lodParamDesc.distanceWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[16]; + ParamDef->init("distanceWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to distance parameter in LOD function", true); + ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=17, longName="lodParamDesc.speedWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[17]; + ParamDef->init("speedWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to velocity parameter in LOD function", true); + ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=18, longName="lodParamDesc.lifeWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[18]; + ParamDef->init("lifeWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to life remain parameter in LOD function", true); + ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=19, longName="lodParamDesc.separationWeight" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[19]; + ParamDef->init("separationWeight", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#else + + static HintImpl HintTable[4]; + static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], }; + HintTable[0].init("defaultValue", uint64_t(0), true); + HintTable[1].init("max", uint64_t(1), true); + HintTable[2].init("min", uint64_t(0), true); + HintTable[3].init("shortDescription", "Weight given to separation parameter in LOD function", true); + ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 4); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // Initialize DefinitionImpl node: nodeIndex=20, longName="lodParamDesc.bias" + { + NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[20]; + ParamDef->init("bias", TYPE_F32, NULL, true); + +#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS + + static HintImpl HintTable[2]; + static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 2); + +#else + + static HintImpl HintTable[3]; + static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], }; + HintTable[0].init("defaultValue", uint64_t(1), true); + HintTable[1].init("min", uint64_t(0), true); + HintTable[2].init("shortDescription", "Bias given to objects spawned by this emitter, relative to other emitters in the same IOS", true); + ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 3); + +#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */ + + + + + + } + + // SetChildren for: nodeIndex=0, longName="" + { + static Definition* Children[13]; + Children[0] = PDEF_PTR(1); + Children[1] = PDEF_PTR(2); + Children[2] = PDEF_PTR(3); + Children[3] = PDEF_PTR(4); + Children[4] = PDEF_PTR(5); + Children[5] = PDEF_PTR(6); + Children[6] = PDEF_PTR(7); + Children[7] = PDEF_PTR(8); + Children[8] = PDEF_PTR(9); + Children[9] = PDEF_PTR(10); + Children[10] = PDEF_PTR(11); + Children[11] = PDEF_PTR(12); + Children[12] = PDEF_PTR(13); + + ParamDefTable[0].setChildren(Children, 13); + } + + // SetChildren for: nodeIndex=13, longName="lodParamDesc" + { + static Definition* Children[7]; + Children[0] = PDEF_PTR(14); + Children[1] = PDEF_PTR(15); + Children[2] = PDEF_PTR(16); + Children[3] = PDEF_PTR(17); + Children[4] = PDEF_PTR(18); + Children[5] = PDEF_PTR(19); + Children[6] = PDEF_PTR(20); + + ParamDefTable[13].setChildren(Children, 7); + } + + mBuiltFlag = true; + +} +void ImpactObjectEvent::initStrings(void) +{ + eventSetName.isAllocated = true; + eventSetName.buf = NULL; +} + +void ImpactObjectEvent::initDynamicArrays(void) +{ +} + +void ImpactObjectEvent::initDefaults(void) +{ + + freeStrings(); + freeReferences(); + freeDynamicArrays(); + angleLow = float(0); + angleHigh = float(90); + speedLow = float(0); + speedHigh = float(1); + lifeLow = float(5); + lifeHigh = float(10); + delay = float(0); + particleSpawnCount = uint32_t(10); + impactAxis = (const char*)"reflection"; + lodParamDesc.version = uint32_t(0); + lodParamDesc.maxDistance = float(0); + lodParamDesc.distanceWeight = float(1); + lodParamDesc.speedWeight = float(0); + lodParamDesc.lifeWeight = float(0); + lodParamDesc.separationWeight = float(0); + lodParamDesc.bias = float(1); + + initDynamicArrays(); + initStrings(); + initReferences(); +} + +void ImpactObjectEvent::initReferences(void) +{ + iofxAssetName = NULL; + + iosAssetName = NULL; + +} + +void ImpactObjectEvent::freeDynamicArrays(void) +{ +} + +void ImpactObjectEvent::freeStrings(void) +{ + + if (eventSetName.isAllocated && eventSetName.buf) + { + mParameterizedTraits->strfree((char*)eventSetName.buf); + } +} + +void ImpactObjectEvent::freeReferences(void) +{ + if (iofxAssetName) + { + iofxAssetName->destroy(); + } + + if (iosAssetName) + { + iosAssetName->destroy(); + } + +} + +} // namespace emitter +} // namespace nvidia |