예제 #1
0
파일: MeshHash.cpp 프로젝트: gbaumgart/vt
// ----------------------------------------------------------------------------------------------------------
void MeshHash::query(const NxBounds3 &bounds, NxArray<int> &itemIndices, int maxIndices)
{
	int x1,y1,z1;
	int x2,y2,z2;
	int x,y,z;

	cellCoordOf(bounds.min, x1,y1,z1);
	cellCoordOf(bounds.max, x2,y2,z2);

	itemIndices.clear();

	for (x = x1; x <= x2; x++)
  {
		for (y = y1; y <= y2; y++)
	  {
			for (z = z1; z <= z2; z++)
		  {
				int h = hashFunction(x,y,z);
				MeshHashRoot &r = mHashIndex[h];
				if (r.timeStamp != mTime) continue;
				int i = r.first;
				while (i >= 0)
			  {
					MeshHashEntry &entry = mEntries[i];
					itemIndices.push_back(entry.itemIndex);
					if (maxIndices >= 0 && (int)itemIndices.size() >= maxIndices) return;
					i = entry.next;
				}
			}
		}
	}
}
예제 #2
0
파일: MeshHash.cpp 프로젝트: gbaumgart/vt
// -------------------------------------------------------------------------------------
void MeshHash::add(const NxBounds3 &bounds, int itemIndex)
{
	int x1,y1,z1;
	int x2,y2,z2;
	int x,y,z;
	cellCoordOf(bounds.min, x1,y1,z1);
	cellCoordOf(bounds.max, x2,y2,z2);
	MeshHashEntry entry;
	entry.itemIndex = itemIndex;

	for (x = x1; x <= x2; x++) {
		for (y = y1; y <= y2; y++) {
			for (z = z1; z <= z2; z++) {
				int h = hashFunction(x,y,z);
				MeshHashRoot &r = mHashIndex[h];
				int n = mEntries.size();
				if (r.timeStamp != mTime || r.first < 0)
					entry.next = -1;
				else
					entry.next = r.first;
				r.first = n;
				r.timeStamp = mTime;
				mEntries.push_back(entry);
			}
		}
	}
}
예제 #3
0
// ----------------------------------------------------------------------------------------------------------
void MeshHash::query(const NxVec3 &pos, std::vector<int> &itemIndices, int maxIndices)
{
	int x,y,z;
	cellCoordOf(pos, x,y,z);
	itemIndices.clear();

	int h = hashFunction(x,y,z);
	MeshHashRoot &r = mHashIndex[h];
	if (r.timeStamp != mTime) return;
	int i = r.first;
	while (i >= 0) {
		MeshHashEntry &entry = mEntries[i];
		itemIndices.push_back(entry.itemIndex);
		if (maxIndices >= 0 && (int)itemIndices.size() >= maxIndices) return;
		i = entry.next;
	}
}
예제 #4
0
파일: MeshHash.cpp 프로젝트: gbaumgart/vt
// -------------------------------------------------------------------------------------
void MeshHash::add(const NxVec3 &pos, int itemIndex)
{
	int x,y,z;
	cellCoordOf(pos, x,y,z);
	MeshHashEntry entry;
	entry.itemIndex = itemIndex;

	int h = hashFunction(x,y,z);
	MeshHashRoot &r = mHashIndex[h];
	int n = mEntries.size();
	if (r.timeStamp != mTime || r.first < 0)
		entry.next = -1;
	else
		entry.next = r.first;
	r.first = n;
	r.timeStamp = mTime;
	mEntries.push_back(entry);
}