コード例 #1
0
ファイル: ParticleEmitter.cpp プロジェクト: akurt5/AIEShit
void ParticleEmitter::updateDerivedBase()
{
	PX_ASSERT(mSpacingX > 0.0f);
	mSpacingY = mSpacingX * PxSqrt(3.0f) * 0.5f;
	mSpacingZ = mSpacingX;

	mNumX = 2*(int)floor(mExtentX/mSpacingX);
	mNumY = 2*(int)floor(mExtentY/mSpacingY);
	
	//SDS: limit minimal dimension to 1
	if (mNumX == 0)
	{
		mNumX = 1;
		mSpacingX = 0.0f;
	}
	if (mNumY == 0)
	{
		mNumY = 1;
		mSpacingY = 0.0f;
	}

	mNumSites = mNumX * mNumY;

	if (mShape == Shape::eELLIPSE) 
	{
		if (mNumX > 1) 
			mEllipseRadius2 = 0.5f - 1.0f/(mNumX-1);
		else			
			mEllipseRadius2 = 0.5f; 
		mEllipseRadius2 *= mEllipseRadius2;

		mEllipseConstX0 = (mNumX-0.5f) * 0.5f;
		mEllipseConstX1 = 1.0f/mNumX;
		mEllipseConstY0 = (mNumY-1.0f) * 0.5f;
		mEllipseConstY1 = PxSqrt(3.0f) * 0.5f / mNumY;
	}
	else 
	{
		mEllipseRadius2 = 0;
		mEllipseConstX0 = 0;
		mEllipseConstX1 = 0;
		mEllipseConstY0 = 0;
		mEllipseConstY1 = 0;
	}
}
コード例 #2
0
		void ProfileEventHandler::reportEvents(Ps::Array<PxBufferedProfilerCallback*>& callbacks)
		{
			PX_ASSERT(mProfileZoneInterface);

			for (PxU32 callbackIndex = callbacks.size(); callbackIndex--; )
			{
				PxBufferedProfilerCallback& callback = *callbacks[callbackIndex];
				reportCollection(callback, mCrossThreadCollection);
				for (PxU32 i = mThreadCollections.size(); i--;)
				{
					reportCollection(callback, mThreadCollections[i]);
				}

				reportCudaCollection(callback);
			}

			clear();
		}
コード例 #3
0
void CudaModuleScene::initCudaObj(ApexCudaFunc& func)
{
	for (int j = 0 ; j < numRegisteredFunctions ; j++)
	{
		const char* funcName = functionTable[j].funcName;
		if (func.testNameMatch(funcName))
		{
			ApexCudaModule* cudaModule = getCudaModule(functionTable[j].modIndex);
			PX_ASSERT(cudaModule->isValid());

			CUfunction cuFunc = 0;
			CUT_SAFE_CALL(cuModuleGetFunction(&cuFunc, cudaModule->getCuModule(), funcName));

			PxU16 id = getGpuDispatcher()->registerKernelNames( &funcName, 1 );
			func.init(this, funcName, cuFunc, cudaModule, id);
		}
	}
}
コード例 #4
0
//export this in the physx namespace so we can unit test it
PxQuat angularProject(PxU32 lockedDofs, const PxQuat& q, PxReal cosHalfTol, bool& truncated)
{
	PX_ASSERT(lockedDofs <= 7);
	truncated = false;

	switch (lockedDofs)
	{
	case 0: return q;
	case 1: return q;		// currently unimplemented
	case 2: return q;		// currently unimplemented
	case 3: return project(q, PxVec3(0, 0, 1), cosHalfTol, truncated);
	case 4: return q;		// currently unimplemented
	case 5: return project(q, PxVec3(0, 1, 0), cosHalfTol, truncated);
	case 6: return project(q, PxVec3(1, 0, 0), cosHalfTol, truncated);
	case 7: return truncate(q, cosHalfTol, truncated);
	default: return PxQuat(PxIdentity);
	}
}
コード例 #5
0
PxConvexMesh* createCylinderConvexMesh(const PxF32 width, const PxF32 radius, const PxU32 numCirclePoints, PxPhysics& physics, PxCooking& cooking)
{
#define  MAX_NUM_VERTS_IN_CIRCLE 16
	PX_ASSERT(numCirclePoints<MAX_NUM_VERTS_IN_CIRCLE);
	PxVec3 verts[2*MAX_NUM_VERTS_IN_CIRCLE];
	PxU32 numVerts=2*numCirclePoints;
	const PxF32 dtheta=2*PxPi/(1.0f*numCirclePoints);
	for(PxU32 i=0;i<MAX_NUM_VERTS_IN_CIRCLE;i++)
	{
		const PxF32 theta=dtheta*i;
		const PxF32 cosTheta=radius*PxCos(theta);
		const PxF32 sinTheta=radius*PxSin(theta);
		verts[2*i+0]=PxVec3(-0.5f*width, cosTheta, sinTheta);
		verts[2*i+1]=PxVec3(+0.5f*width, cosTheta, sinTheta);
	}

	return createConvexMesh(verts,numVerts,physics,cooking);
}
コード例 #6
0
ファイル: MaterialList.cpp プロジェクト: Tungrus/ApexTest
unsigned int MaterialList::addTexture(const char* /*directory*/, const char* prefix, const char* textureName)
{
	char saneFileName[128];
	physx::string::sprintf_s(saneFileName, 128, "%s%s", prefix, textureName);

	if (mTextureNames.find(saneFileName) != mTextureNames.end())
	{
		PX_ASSERT(!"duplicated texture found!");
	}
	else
	{
		TextureInfo info;
		info.fromPath = (unsigned int)mPaths.size();
		mTextureNames[saneFileName] = info;
		return 1;
	}

	return 0;
}
コード例 #7
0
//process value in range(0,1)
PX_FORCE_INLINE PxF32 processPositiveAnalogValue
(const PxF32 riseRate, const PxF32 fallRate,
 const PxF32 currentVal, const PxF32 targetVal,
 const PxF32 timestep)
{
	PX_ASSERT(targetVal>=-0.01f && targetVal<=1.01f);
	PxF32 val;
	if(currentVal<targetVal)
	{
		val=currentVal + riseRate*timestep;
		val=PxMin(val,targetVal);
	}
	else 
	{
		val=currentVal - fallRate*timestep;
		val=PxMax(val,targetVal);
	}
	return val;
}
コード例 #8
0
//GroupsMask64
void SampleApexResourceCallback::setApexSupport(nvidia::apex::ApexSDK& apexSDK)
{
	PX_ASSERT(!m_apexSDK);
	m_apexSDK	= &apexSDK;
#if APEX_USE_PARTICLES
	uint32_t count = m_apexSDK->getNbModules();
	nvidia::apex::Module **modules = m_apexSDK->getModules();
	for (uint32_t i=0; i<count; i++)
	{
		nvidia::apex::Module *m = modules[i];
		const char *name = m->getName();
		if ( strcmp(name,"Particles") == 0 )
		{
			mModuleParticles = static_cast< nvidia::apex::ModuleParticles *>(m);
			break;
		}
	}
#endif
}
コード例 #9
0
bool RTree::load(PxInputStream& stream, PxU32 meshVersion)
{
	PX_ASSERT((mFlags & IS_DYNAMIC) == 0);
	PX_UNUSED(meshVersion);

	release();

	PxI8 a, b, c, d;
	readChunk(a, b, c, d, stream);
	if(a!='R' || b!='T' || c!='R' || d!='E')
		return false;

	bool mismatch = (littleEndian() == 1);
	if(readDword(mismatch, stream) != mVersion)
		return false;

	readFloatBuffer(&mBoundsMin.x, 4, mismatch, stream);
	readFloatBuffer(&mBoundsMax.x, 4, mismatch, stream);
	readFloatBuffer(&mInvDiagonal.x, 4, mismatch, stream);
	readFloatBuffer(&mDiagonalScaler.x, 4, mismatch, stream);
	mPageSize = readDword(mismatch, stream);
	mNumRootPages = readDword(mismatch, stream);
	mNumLevels = readDword(mismatch, stream);
	mTotalNodes = readDword(mismatch, stream);
	mTotalPages = readDword(mismatch, stream);
	mUnused = readDword(mismatch, stream);

	mPages = static_cast<RTreePage*>(
		Ps::AlignedAllocator<128>().allocate(sizeof(RTreePage)*mTotalPages, __FILE__, __LINE__));
	Cm::markSerializedMem(mPages, sizeof(RTreePage)*mTotalPages);
	for (PxU32 j = 0; j < mTotalPages; j++)
	{
		readFloatBuffer(mPages[j].minx, RTreePage::SIZE, mismatch, stream);
		readFloatBuffer(mPages[j].miny, RTreePage::SIZE, mismatch, stream);
		readFloatBuffer(mPages[j].minz, RTreePage::SIZE, mismatch, stream);
		readFloatBuffer(mPages[j].maxx, RTreePage::SIZE, mismatch, stream);
		readFloatBuffer(mPages[j].maxy, RTreePage::SIZE, mismatch, stream);
		readFloatBuffer(mPages[j].maxz, RTreePage::SIZE, mismatch, stream);
		ReadDwordBuffer(mPages[j].ptrs, RTreePage::SIZE, mismatch, stream);
	}

	return true;
}
コード例 #10
0
ResID ApexResourceProvider::createResource(ResID nameSpace, const char* name, bool refCount)
{
	uint32_t nsIndex = getNSIndex(nameSpace);
	if (nsIndex < mNameSpaces.size())
	{
		NameSpace* ns = mNameSpaces[nsIndex];
		ResID id = ns->getOrCreateID(name, mResources[ns->getID()].name);
		PX_ASSERT(id < mResources.size());
		if (id < mResources.size() && refCount)
		{
			mResources[id].refCount++;
		}
		return id;
	}
	else
	{
		return INVALID_RESOURCE_ID;
	}
}
コード例 #11
0
ImpactEmitterAsset::ImpactEmitterAsset(ModuleEmitter* m, NxResourceList& list, const char* name) :
	mModule(m),
	mName(name),
	mIofxAssetTracker(m->mSdk, NX_IOFX_AUTHORING_TYPE_NAME),
	mIosAssetTracker(m->mSdk),
#if NX_SDK_VERSION_MAJOR == 2
	mExplosionAssetTracker(m->mSdk, NX_EXPLOSION_AUTHORING_TYPE_NAME),
#endif
	mDefaultActorParams(NULL),
	mDefaultPreviewParams(NULL)
{
	NxParameterized::Traits* traits = NiGetApexSDK()->getParameterizedTraits();
	mParams = (ImpactEmitterAssetParameters*)traits->createNxParameterized(ImpactEmitterAssetParameters::staticClassName());

	PX_ASSERT(mParams);

	mParams->setSerializationCallback(this);
	list.add(*this);
}
コード例 #12
0
Foundation* Foundation::createInstance(PxU32 version, PxErrorCallback& errc, PxAllocatorCallback& alloc)
{
	if (version != PX_PHYSICS_VERSION)
	{
		char* buffer = new char[256];
		physx::string::sprintf_s(buffer,256, "Wrong version: foundation version is 0x%08x, tried to create 0x%08x", PX_PHYSICS_VERSION, version);
		errc.reportError(PxErrorCode::eINVALID_PARAMETER, buffer, __FILE__, __LINE__);
		return 0;
	}

	if (!mInstance)
	{
		// if we don't assign this here, the Foundation object can't create member
		// subobjects which require the allocator

		mInstance = reinterpret_cast<Foundation*>( alloc.allocate( 
			sizeof(Foundation), "Foundation", __FILE__,__LINE__));

		if (mInstance)
		{
			PX_PLACEMENT_NEW(mInstance, Foundation)(errc, alloc);

			PX_ASSERT(mRefCount == 0);
			mRefCount = 1;

			//skip 0 which marks uninitialized timestaps in PX_WARN_ONCE
			mWarnOnceTimestap = (mWarnOnceTimestap == PX_MAX_U32) ? 1 : mWarnOnceTimestap + 1;

			return mInstance;
		}
		else
		{
			errc.reportError(PxErrorCode::eINTERNAL_ERROR, "Memory allocation for foundation object failed.", __FILE__, __LINE__);
		}
	}
	else
	{
		errc.reportError(PxErrorCode::eINVALID_OPERATION, "Foundation object exists already. Only one instance per process can be created.", __FILE__, __LINE__);
	}

	return 0;
}
コード例 #13
0
void ApexQuadricSimplifier::heapUpdate(uint32_t i)
{
	const uint32_t num = mHeap.size() - mNumDeletedHeapElements;
	PX_ASSERT(1 <= i && i < num);
	QuadricEdge* e = mHeap[i];
	while (i > 1)
	{
		uint32_t j = i >> 1;
		if (heapElementSmaller(e, mHeap[j]))
		{
			mHeap[i] = mHeap[j];
			mHeap[i]->heapPos = (int32_t)i;
			i = j;
		}
		else
		{
			break;
		}
	}

	while ((i << 1) < num)
	{
		uint32_t j = i << 1;
		if (j + 1 < num && heapElementSmaller(mHeap[j + 1], mHeap[j]))
		{
			j++;
		}

		if (heapElementSmaller(mHeap[j], e))
		{
			mHeap[i] = mHeap[j];
			mHeap[i]->heapPos = (int32_t)i;
			i = j;
		}
		else
		{
			break;
		}
	}
	mHeap[i] = e;
	mHeap[i]->heapPos = (int32_t)i;
}
コード例 #14
0
void CudaModuleScene::initCudaObj(ApexCudaVar& var)
{
	const char* varName = var.getName();

	for (int j = 0 ; j < numRegisteredVariables ; j++)
	{
		if (nvidia::strcmp(variableTable[j].varName, varName) == 0)
		{
			ApexCudaModule* cudaModule = getCudaModule(variableTable[j].modIndex);
			PX_ASSERT(cudaModule->isValid());

			CUdeviceptr cuDevPtr;
			size_t size;
			cuModuleGetGlobal(&cuDevPtr, &size, cudaModule->getCuModule(), varName);

			var.init(this, cudaModule, cuDevPtr, size, getGpuDispatcher()->getCudaContextManager());
			break;
		}
	}
}
コード例 #15
0
void SampleVehicle_VehicleManager::updateAndRecordTelemetryData
(const PxF32 timestep, const PxVec3& gravity, PxVehicleWheels* focusVehicle, PxVehicleTelemetryData* telemetryData)
{
	PX_ASSERT(focusVehicle && telemetryData);

	//Update the vehicle for which we want to record debug data.
	PxVehicleUpdateSingleVehicleAndStoreTelemetryData(timestep,gravity,*mSurfaceTirePairs,focusVehicle,*telemetryData);

	//Update the remaining vehicles.
	PxVehicleWheels* vehicles[MAX_NUM_4W_VEHICLES];
	PxU32 numVehicles=0;
	for(PxU32 i=0;i<mNumVehicles;i++)
	{
		if(focusVehicle!=mVehicles[i])
		{
			vehicles[numVehicles]=mVehicles[i];
			numVehicles++;
		}
	}
	PxVehicleUpdates(timestep,gravity,*mSurfaceTirePairs,numVehicles,vehicles);
}
コード例 #16
0
void ApexRenderSubmesh::setParams(SubmeshParameters* submeshParams, VertexBufferParameters* vertexBufferParams)
{

	if (vertexBufferParams == NULL && submeshParams != NULL)
	{
		vertexBufferParams = static_cast<VertexBufferParameters*>(submeshParams->vertexBuffer);
		PX_ASSERT(vertexBufferParams != NULL);
	}
	else if (submeshParams != NULL && submeshParams->vertexBuffer == NULL)
	{
		submeshParams->vertexBuffer = vertexBufferParams;
	}
	else if (mParams == NULL)
	{
		// Only emit this warning if mParams is empty yet (not on destruction of the object)
		APEX_INTERNAL_ERROR("Confliciting parameterized objects!");
	}
	mParams = submeshParams;

	mVertexBuffer.setParams(vertexBufferParams);
}
コード例 #17
0
PxStream& MemoryWriteBuffer::storeBuffer(const void* buffer, PxU32 size)
{
	PxU32 expectedSize = currentSize + size;
	if(expectedSize > maxSize)
	{
		maxSize = expectedSize + 4096;

		PxU8* newData = new PxU8[maxSize];
		PX_ASSERT(newData!=NULL);

		if(data)
		{
			memcpy(newData, data, currentSize);
			delete[] data;
		}
		data = newData;
	}
	memcpy(data+currentSize, buffer, size);
	currentSize += size;
	return *this;
}
コード例 #18
0
ファイル: PINT_CommonPhysX3.cpp プロジェクト: DevO2012/PEEL
PxU32 MemoryOutputStream::write(const void* src, PxU32 size)
{
	PxU32 expectedSize = mSize + size;
	if(expectedSize > mCapacity)
	{
		mCapacity = expectedSize + 4096;

		PxU8* newData = new PxU8[mCapacity];
		PX_ASSERT(newData!=NULL);

		if(newData)
		{
			memcpy(newData, mData, mSize);
			delete[] mData;
		}
		mData = newData;
	}
	memcpy(mData+mSize, src, size);
	mSize += size;
	return size;
}
コード例 #19
0
void Gu::GeometryUnion::set(const PxGeometry& g)
{
	switch(g.getType())
	{
	case PxGeometryType::eBOX :
		reinterpret_cast<PxBoxGeometry&>(geometry) = static_cast<const PxBoxGeometry&>(g);
		break;
	case PxGeometryType::eCAPSULE :
		reinterpret_cast<PxCapsuleGeometry&>(geometry) = static_cast<const PxCapsuleGeometry&>(g);
		break;
	case PxGeometryType::eSPHERE :
		reinterpret_cast<PxSphereGeometry&>(geometry) = static_cast<const PxSphereGeometry&>(g);
		reinterpret_cast<PxCapsuleGeometry&>(geometry).halfHeight = 0.0f;		//AM: make sphere geometry also castable as a zero height capsule.
		break;
	case PxGeometryType::ePLANE :
		reinterpret_cast<PxPlaneGeometry&>(geometry) = static_cast<const PxPlaneGeometry&>(g);
		break;
	case PxGeometryType::eCONVEXMESH :
		{
			reinterpret_cast<PxConvexMeshGeometry&>(geometry) = static_cast<const PxConvexMeshGeometry&>(g);
			reinterpret_cast<PxConvexMeshGeometryLL&>(geometry).hullData = &(Gu::getConvexMesh(get<PxConvexMeshGeometryLL>().convexMesh).getHull());
		}
		break;
	case PxGeometryType::eTRIANGLEMESH :
		{
			reinterpret_cast<PxTriangleMeshGeometry&>(geometry) = static_cast<const PxTriangleMeshGeometry&>(g);
			reinterpret_cast<PxTriangleMeshGeometryLL&>(geometry).meshData = &(Gu::getTriangleMesh(get<PxTriangleMeshGeometryLL>().triangleMesh).mesh.mData);
		}
		break;
	case PxGeometryType::eHEIGHTFIELD :
		{
			reinterpret_cast<PxHeightFieldGeometry&>(geometry) = static_cast<const PxHeightFieldGeometry&>(g);
			reinterpret_cast<PxHeightFieldGeometryLL&>(geometry).heightFieldData = &Gu::getHeightField(get<PxHeightFieldGeometryLL>().heightField).getData();
		}
		break;
	default :
		PX_ASSERT(0 && "geometry type not handled");
		break;
	}
}
コード例 #20
0
/* 
 * Called by the owner (Scene) to start simulating the task graph.
 * Dispatch all tasks with refCount == 1
 */
void PxTaskMgr::startSimulation()
{
    PX_ASSERT( mCpuDispatcher );

	if( mGpuDispatcher )
	{
		mGpuDispatcher->startSimulation();
	}

	/* Handle empty task graph */
	if( mPendingTasks == 0 )
    {

		return;
    }

    bool gpuDispatch = false;
    for( PxTaskID i = 0 ; i < mTaskTable.size() ; i++ )
    {
		if(	mTaskTable[ i ].mType == PxTaskType::TT_COMPLETED )
		{
			continue;
		}
		if( !shdfnd::atomicDecrement( &mTaskTable[ i ].mRefCount ) )
		{
			mStartDispatch.pushBack(i);
		}
	}
	for( uint32_t i=0; i<mStartDispatch.size(); ++i)
	{
		gpuDispatch |= dispatchTask( mStartDispatch[i], gpuDispatch );
	}
	//mStartDispatch.resize(0);
	mStartDispatch.forceSize_Unsafe(0);

    if( mGpuDispatcher && gpuDispatch )
	{
        mGpuDispatcher->finishGroup();
	}
}
コード例 #21
0
	PxStream& MemoryStream::storeBuffer(const void* buffer, PxU32 size)
	{
		unsigned int newPos = mCurrentPos + size;
		if(newPos > mMaxSize)
		{	//resize
			mMaxSize = newPos + BUFFER_RESIZE_STEP;

			unsigned char* newData = new unsigned char[mMaxSize];
			PX_ASSERT(newData != nullptr);

			if(mData)
			{
				memcpy(newData, mData, mCurrentPos);
				delete[] mData;
			}
			mData = newData;
		}

		memcpy(mData + mCurrentPos, buffer, size);
		mCurrentPos += size;
		return *this;
	}
コード例 #22
0
const char* SampleApexResourceCallback::mapHackyPath(const char* path)
{
	const char* mappedPath = path;
	static const HackyPath map[] =
	{
		// John, fix the apex debug renderer to allow the user to specify the material path...
		{ "ApexSolidShaded", "materials/simple_lit_color.xml"   },
		{ "ApexWireframe",   "materials/simple_unlit.xml"       },
	};
	const uint32_t mapSize = PX_ARRAY_SIZE(map);
	for (uint32_t i = 0; i < mapSize; i++)
	{
		const HackyPath& hp = map[i];
		if (!strcmp(hp.original, mappedPath))
		{
			mappedPath = hp.mapped;
			break;
		}
	}
	PX_ASSERT(mappedPath == path && "IF YOU HIT THIS ASSET IT MEANS A HACKY PATH WAS MAPPED, FIX YOUR F-ING ASSET FILES!!!");
	return mappedPath;
}
コード例 #23
0
ファイル: prefetch.c プロジェクト: gengx060/ReadSideCache
PathEntry* readfetchconf() // (PathEntry* pe_p)
{
	FILE* fp = fopen("/px/conf/fetch.conf", "r");
	if(fp == NULL)
	{
		return NULL;
	}

	PathEntry* pe = NULL;
	PathEntry* petail = NULL;

	char buf[PATH_MAX];
	while (readLine(fp, buf))
	{
		char tmp[PATH_MAX];
		PathEntry* pet = NULL;
		if((pet = parseentry(buf, PATHDIR_T, tmp)) == NULL)
			pet = parseentry(buf, PATHFILE_T, tmp);

		if(pe == NULL)
		{
			pe = pet;
			petail = pet;
		}
		else
		{
			if(petail)
			{
				petail->next = pet;
				petail = pet;
			}
		}
		continue;
	}

	PX_ASSERT(fclose(fp) == 0);

	return pe;
}
コード例 #24
0
	physx::PxU32 write(const void* src, physx::PxU32 size)
	{
		physx::PxU32 expectedSize = mSize + size;
		if (expectedSize > mCapacity)
		{
			mCapacity = expectedSize + 4096;

			physx::PxU8* newData = new physx::PxU8[mCapacity];
			PX_ASSERT(newData != nullptr);

			if (newData)
			{
				memcpy(newData, mData, mSize);
				delete[] mData;
			}
			mData = newData;
		}
		memcpy(mData + mSize, src, size);
		mSize += size;

		return size;
	}
コード例 #25
0
uint32_t ApexVertexBuffer::getAllocationSize() const
{
	uint32_t size = sizeof(ApexVertexBuffer);

	for (uint32_t index = 0; (int32_t)index < mParams->buffers.arraySizes[0]; ++index)
	{
		PX_ASSERT(index < getFormat().getBufferCount());
		if (index >= getFormat().getBufferCount())
		{
			break;
		}
		const uint32_t dataSize = RenderDataFormat::getFormatDataSize(getFormat().getBufferFormat(index));
		NvParameterized::Interface* buffer = mParams->buffers.buf[index];
		if (buffer != NULL)
		{
			BufferU8x1* particularBuffer = DYNAMIC_CAST(BufferU8x1*)(buffer);
			size += particularBuffer->data.arraySizes[0] * dataSize;
		}
	}

	return size;
}
コード例 #26
0
ファイル: ApexParticles.cpp プロジェクト: Tungrus/ApexTest
void ApexParticles::CreateEmitter(NxApexSDK* gApexSDK, NxApexScene* gApexScene)
{
    NxApexEmitterAsset* emitterAsset;
    physx::apex::NxApexAsset* asset = reinterpret_cast<physx::apex::NxApexAsset*>(gApexSDK->getNamedResourceProvider()->getResource(NX_APEX_EMITTER_AUTHORING_TYPE_NAME, "testSpriteEmitter4ParticleFluidIos"));
    if (asset)
    {
        emitterAsset = static_cast<NxApexEmitterAsset*> (asset);
    }
    //NxApexEmitterAsset* emitterAsset = static_cast<NxApexEmitterAsset*> (gApexSDK->createAsset(asParams, "testMeshEmitter4ParticleIos.apb"));
    gApexSDK->forceLoadAssets();

    NxParameterized::Interface* descParams = emitterAsset->getDefaultActorDesc();
    PX_ASSERT(descParams);
    if (!descParams)
    {
        return;
    }

    // Set Actor pose
    //NxParameterized::setParamMat44( *descParams, "initialPose", pose );
    NxApexEmitterActor* emitterActor;
    if(descParams->areParamsOK())
    {
        emitterActor = static_cast<NxApexEmitterActor*>(emitterAsset->createApexActor(*descParams,*gApexScene));
        if(emitterActor)
        {
            emitterActor->setCurrentPosition(PxVec3(0.0f, 1.0f, 0.0f));
            emitterActor->startEmit( true );
            //emitterActor->setLifetimeRange(physx::apex::NxRange<PxF32>(1,5));
            //emitterActor->setRateRange(physx::apex::NxRange<PxF32>(10, 10));
        }
    }

    PxBounds3 b;
    b.setInfinite();

    mRenderVolume = mIofxModule->createRenderVolume(*gApexScene, b, 0, true );
    emitterActor->setPreferredRenderVolume( mRenderVolume );
}
コード例 #27
0
TextRenderResourceManager::TextRenderResourceManager(int verbosity, const char* outputFilename) :
	mVerbosity(verbosity),
	mOutputFile(NULL),
	mVertexBufferCount(0),
	mIndexBufferCount(0),
	mBoneBufferCount(0),
	mInstanceBufferCount(0),
	mSpriteBufferCount(0),
	mRenderResourceCount(0)
{
	if (outputFilename != NULL)
	{
		mOutputFile = fopen(outputFilename, "w");
	}
	else
	{
		mOutputFile = stdout;
	}
	PX_ASSERT(mOutputFile != NULL);
	
	mIO = new Writer(mOutputFile);
}
コード例 #28
0
void Foundation::errorImpl(PxErrorCode::Enum e, const char* file, int line, const char* messageFmt, va_list va)
{
	PX_ASSERT(messageFmt);
	if (e & mErrorMask)
	{
		//this function is reentrant but user's error callback may not be, so...
		Mutex::ScopedLock lock(mErrorMutex);	

		// using a static fixed size buffer here because:
		// 1. vsnprintf return values differ between platforms
		// 2. va_start is only usable in functions with ellipses
		// 3. ellipses (...) cannot be passed to called function
		// which would be necessary to dynamically grow the buffer here

		const int bufSize = 1024;
		static char stringBuffer[bufSize+1];

		vsnprintf(stringBuffer, (size_t)bufSize, messageFmt, va);
		stringBuffer[bufSize] = 0; // make sure there is a null termination character on all platforms

		mInteralErrorHandler.reportError(e, stringBuffer, file, line);
	}
}
コード例 #29
0
void PxcFsGetImpulseSelfResponse(const PxcFsData& matrix, 
								 PxU32 linkID0, 
								 const PxcSIMDSpatial& impulse0,
								 PxcSIMDSpatial& deltaV0,
								 PxU32 linkID1,
								 const PxcSIMDSpatial& impulse1,
								 PxcSIMDSpatial& deltaV1)
{
	typedef PxcArticulationFnsSimd<PxcArticulationFnsSimdBase> Fns;

	PX_ASSERT(linkID0 != linkID1);

	const PxcFsRow* rows = getFsRows(matrix);
	const PxcFsRowAux* aux = getAux(matrix);
	const PxcFsJointVectors* jointVectors = getJointVectors(matrix);

	// standard case: parent-child limit
	if(matrix.parent[linkID1] == linkID0)
	{
		Vec3V SZ;
		PxcSIMDSpatial Z = impulse0 - Fns::propagateImpulse(rows[linkID1], jointVectors[linkID1], SZ, -impulse1, aux[linkID1]);
		PxcFsGetImpulseResponse(matrix, linkID0, Z, deltaV0);
		deltaV1 = Fns::propagateVelocity(rows[linkID1], jointVectors[linkID1], SZ, deltaV0, aux[linkID1]);
	}
	else
		getImpulseResponseSlow(matrix, linkID0, impulse0, deltaV0, linkID1, impulse1, deltaV1);

#if PXC_ARTICULATION_DEBUG_VERIFY
	Cm::SpatialVector V[PXC_ARTICULATION_MAX_SIZE];
	for(PxU32 i=0;i<matrix.linkCount;i++) V[i] = Cm::SpatialVector::zero();
	PxcArticulationRef::applyImpulse(matrix,V,linkID0, reinterpret_cast<const Cm::SpatialVector&>(impulse0));
	PxcArticulationRef::applyImpulse(matrix,V,linkID1, reinterpret_cast<const Cm::SpatialVector&>(impulse1));

	Cm::SpatialVector refV0 = V[linkID0];
	Cm::SpatialVector refV1 = V[linkID1];
#endif
}
コード例 #30
0
	virtual void processRenderDebug(const DebugPrimitive **dplist,
									PxU32 pcount,
									RenderDebugInterface *iface,
									PxProcessRenderDebug::DisplayType type)
	{
		if ( !mReadAccess )
		{
			PX_ASSERT(pcount);
			if ( mFrameStart == 0 )
			{
				PxU32 pv = 0;
				mFrameStart = mFileBuffer->tellWrite();
				mFileBuffer->storeDword(pv);
				mFileBuffer->storeDword(pv);
			}

			if ( type != mLastDisplayType )
			{
				flushDisplayType(mLastDisplayType);
				beginDisplayType(type);
			}

			mTypeHeaders[type].mPrimitiveCount+=pcount;

			for (PxU32 i=0; i<pcount; i++)
			{
				const DebugPrimitive *dp = dplist[i];
				PxU32 plen = DebugCommand::getPrimtiveSize(*dp);
				mFileBuffer->write(dp,plen);
			}
			mFrameItemCount+=pcount;
		}
		if ( mEchoLocally )
		{
			mEchoLocally->processRenderDebug(dplist,pcount,iface,type);
		}
	}