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/src | |
| 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/src')
32 files changed, 16371 insertions, 0 deletions
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 |