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/include/EmitterActorImpl.h | |
| 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/include/EmitterActorImpl.h')
| -rw-r--r-- | APEX_1.4/module/emitter/include/EmitterActorImpl.h | 361 |
1 files changed, 361 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 |