SHyperedge *Cube::Pop() { QueueItem item = m_queue.top(); m_queue.pop(); CreateNeighbours(*item.second); return item.first; }
static EERIE_3DOBJ * TheoToEerie_Fast(const res::path & texpath, const res::path & file, bool pbox) { EERIE_3DOBJ * ret = ARX_FTL_Load(file); if(ret) { if(pbox) { EERIE_PHYSICS_BOX_Create(ret); } return ret; } #if !BUILD_EDIT_LOADSAVE ARX_UNUSED(texpath); #else ret = GetExistingEerie(file); if(ret) { ret = Eerie_Copy(ret); } if(!ret) { size_t size = 0; char * adr = resources->readAlloc(file, size); if(!adr) { LogWarning << "Object not found: " << file; return NULL; } ret = TheoToEerie(adr, size, texpath, file); if(!ret) { free(adr); return NULL; } EERIE_OBJECT_CenterObjectCoordinates(ret); free(adr); } CreateNeighbours(ret); EERIEOBJECT_AddClothesData(ret); KillNeighbours(ret); if(ret->cdata) { EERIE_COLLISION_SPHERES_Create(ret); // Must be out of the Neighbours zone } if(pbox) { EERIE_PHYSICS_BOX_Create(ret); } ARX_FTL_Save(fs::paths.user / file.string(), ret); #endif // BUILD_EDIT_LOADSAVE return ret; }
void World::CalculateDensity() { Neighbourhood &n2 = mNeighbourhood; Neighbourhood &n1 = mNeighbourhood; if(GetAsyncKeyState(VK_SHIFT)) { n2.Reset(); for(int i=0; i<NumParticles; ++i) { Particle &p = mParticles[i]; float density = 0; float nearDensity = 0; p.mDensity = 0; p.mNearDensity = 0; p.mNeighbourCount = 0; p.mNeighbourListIndex = n2.mCurrentNeighbour; for(int j=i+1; j<NumParticles; ++j) { Particle &q = mParticles[j]; CreateNeighbours(n2, p, q, density, nearDensity); } p.mDensity += density; p.mNearDensity += nearDensity; } } else { n1.Reset(); for(int y = 0; y < mGrid.mHeight; ++y) { int cminy = y; int maxy = y + 1; int cmaxy = min(mGrid.mHeight - 1, maxy); for(int x = 0; x < mGrid.mWidth; ++x) { int maxx = x + 1; int cmaxx = min(mGrid.mWidth - 1, maxx); GridCell &cell = mGrid.GetCell(x, y); int end = cell.mStart + cell.mLength; for(int i = cell.mStart; i < end; ++i) { Particle &p = mParticles[mGrid.mIndices[i]]; float density = 0; float nearDensity = 0; p.mDensity = 0; p.mNearDensity = 0; p.mNeighbourCount = 0; p.mNeighbourListIndex = n1.mCurrentNeighbour; // unique visitation of that particle for(int j = i + 1; j < end; ++j) { Particle &q = mParticles[mGrid.mIndices[j]]; CreateNeighbours(n1, p, q, density, nearDensity); } for(int y1 = cminy; y1 <= cmaxy; ++y1) { int Xoffset = x + (y - y1); int cxo = max(Xoffset, 0); cxo = min(cxo, mGrid.mWidth); for(int x1 = cxo; x1 <= cmaxx; ++x1) { if(x1 != x || y1 != y) { GridCell &cell2 = mGrid.GetCell(x1, y1); if(cell2.mLength > 0) { int end = cell2.mStart + cell2.mLength; for(int j = cell2.mStart; j < end; ++j) { Particle &q = mParticles[mGrid.mIndices[j]]; CreateNeighbours(n1, p, q, density, nearDensity); } } } } } p.mDensity += density; p.mNearDensity += nearDensity; } } } } //int gh = 4; //int gw = 4; //for(int y = 0; y < gh; ++y) //{ // int miny = y; // int maxy = y + 1; // int cminy = max(0, miny); // int cmaxy = min(gh - 1, maxy); // for(int x = 0; x < gw; ++x) // { // int maxx = x + 1; // int cmaxx = min(gw - 1, maxx); // for(int y1 = cminy; y1 <= cmaxy; ++y1) // { // int Xoffset = x + (y - y1); // int cxo = max(Xoffset, 0); // cxo = min(cxo, gw-1); // for(int x1 = cxo; x1 <= cmaxx; ++x1) // { // if(x1 != x || y1 != y) // { // TRACE("%d,%d,%d,%d\n", x,y,x1,y1); // } // } // } // } //} }