Пример #1
0
NamedAllocator::~NamedAllocator() 
{
	Mutex::ScopedLock lock(getMutex());
	bool erased = getMap().erase(this);
	PX_FORCE_PARAMETER_REFERENCE(erased);
	PX_ASSERT(erased);
}
Пример #2
0
void MaterialList::addPath(const char* path)
{
	PX_FORCE_PARAMETER_REFERENCE(path);

#ifdef PX_WINDOWS
	const char* matPrefixes[2] = { "", "materials/" };

	PX_ASSERT(strlen(path) < 240);
	char fileMask[256];

	unsigned int materialsAdded = 0;

	for (unsigned int pass = 0; pass < 2; pass++)
	{
		physx::string::sprintf_s(fileMask, 255, "%s/%s*.xml", path, matPrefixes[pass]);

		WIN32_FIND_DATA ffd;
		HANDLE hFind = ::FindFirstFile(fileMask, &ffd);

		if (hFind != INVALID_HANDLE_VALUE)
		{
			do
			{
				materialsAdded += addMaterial(path, matPrefixes[pass], ffd.cFileName);
			}
			while (FindNextFile(hFind, &ffd) != 0);

			FindClose(hFind);
		}
	}


	const char* texPrefixes[2] = { "", "textures/" };
	const char* texSuffixes[2] = { "dds", "tga" };

	unsigned int texturesAdded = 0;

	for (unsigned int prefixes = 0; prefixes < 2; prefixes++)
	{
		for (unsigned int suffixes = 0; suffixes < 2; suffixes++)
		{
			physx::string::sprintf_s(fileMask, 255, "%s/%s*.%s", path, texPrefixes[prefixes], texSuffixes[suffixes]);

			WIN32_FIND_DATA ffd;
			HANDLE hFind = ::FindFirstFile(fileMask, &ffd);

			if (hFind != INVALID_HANDLE_VALUE)
			{
				do
				{
					texturesAdded += addTexture(path, texPrefixes[prefixes], ffd.cFileName);
				}
				while (FindNextFile(hFind, &ffd) != 0);

				FindClose(hFind);
			}
		}
	}
	
	if (materialsAdded > 0 || texturesAdded > 0)
	{
		mPaths.push_back(path);
	}

#if 0
	// verification step
	for (tMaterialNames::const_iterator it = mMaterialNames.begin(); it != mMaterialNames.end(); ++it)
	{
		if (!it->second.diffuseTexture.empty())
		{
			tTextureNames::const_iterator tex = mTextureNames.find(it->second.diffuseTexture);
			if (tex == mTextureNames.end())
			{
				PX_ASSERT(!"Texture not found");
			}
			else
			{
				PX_ASSERT(tex->second.fromPath <= it->second.fromPath);
			}
		}

		if (!it->second.normalTexture.empty())
		{
			tTextureNames::const_iterator tex = mTextureNames.find(it->second.normalTexture);
			if (tex == mTextureNames.end())
			{
				PX_ASSERT(!"Texture not found");
			}
			else
			{
				PX_ASSERT(tex->second.fromPath <= it->second.fromPath);
			}
		}
	}
#endif

#endif
}