void Room::addToNearRoomsList(std::shared_ptr<Room> r) { if(r && !isInNearRoomsList(*r) && id != r->id && !isOverlapped(r.get())) { near_room_list.push_back(r); } }
static struct psl *readPartition(struct pslInput *pi) /* read next set of overlapping psls */ { int minStart, maxEnd; struct psl *pslPart = pslInputNext(pi); struct psl *psl; if (pslPart == NULL) return NULL; /* no more */ minStart = pslPart->tStart; maxEnd = pslPart->tEnd; /* add more psls while they overlap, easy since input is sorted */ while ((psl = pslInputNext(pi)) != NULL) { if (isOverlapped(psl, pslPart, minStart, maxEnd)) { minStart = min(minStart, psl->tStart); maxEnd = max(maxEnd, psl->tEnd); slAddHead(&pslPart, psl); } else { pslInputPutBack(pi, psl); break; } } slReverse(&pslPart); return pslPart; }
void Room::buildOverlappedRoomsList() { overlapped_room_list.clear(); for(auto r : engine_world.rooms) { if(isOverlapped(r.get())) { overlapped_room_list.push_back(r); } } }
uint32_t MxField::monteCarlo(uint32_t stepMax) const { uint32_t positive = 0; double rmin = NitroDiameter / 2.0; // std::vector<Cell> clusters = cells(); // std::cout << clusters.size() << std::endl; // std::vector<std::vector<std::vector<std::vector<Cell> > > > grid; // grid.resize(m_sides.x); // for (uint32_t x = 0; x < m_sides.x; ++x) { // grid[x].resize(m_sides.y); // for (uint32_t y = 0; y < m_sides.y; ++y) { // grid[x][y].resize(m_sides.z); // } // } // for (const Cell& cell : clusters) { // grid[uint32_t(cell.coord().x * m_sides.x / m_sizes.x)] // [uint32_t(cell.coord().y * m_sides.y / m_sizes.y)] // [uint32_t(cell.coord().z * m_sides.z / m_sizes.z)].push_back(cell); // } for (uint32_t i = 0; i < stepMax; ) { int32_t rx = rand() % int32_t(m_sides.x); int32_t ry = rand() % int32_t(m_sides.y); int32_t rz = rand() % int32_t(m_sides.z); if (m_field[size_t(rx)][size_t(ry)][size_t(rz)] != 0) { Cell curr(new FSphere(radius()), dCoord(rx * side(), ry * side(), rz * side())); // uint32_t rcluster = rand() % (uint32_t(clusters.size())); // const Cell& curr = clusters[rcluster]; double xc = curr.coord().x; double yc = curr.coord().y; double zc = curr.coord().z; double rc = curr.figure()->radius(); //spheric! double teta = 2.0 * M_PI * (rand() / double(RAND_MAX)); double phi = 2.0 * M_PI * (rand() / double(RAND_MAX)); double ixc = xc + (rc + rmin) * sin(teta) * cos(phi); double iyc = yc + (rc + rmin) * sin(teta) * sin(phi); double izc = zc + (rc + rmin) * cos(teta); Cell cell(new FSphere(rmin), dCoord(ixc, iyc, izc)); bool overlap = false; for (int32_t ix = rx - 2; ix < rx + 2; ++ix) { if (overlap) { break; } for (int32_t iy = ry - 2; iy < ry + 2; ++iy) { if (overlap) { break; } for (int32_t iz = rz - 2; iz < rz + 2; ++iz) { if (ix != rx && iy != ry && iz != rz) { Cell temp(new FSphere(radius()), dCoord((uint32_t(ix + int32_t(m_sides.x)) % m_sides.x) * side(), (uint32_t(iy + int32_t(m_sides.y)) % m_sides.y) * side(), (uint32_t(iz + int32_t(m_sides.z)) % m_sides.z) * side())); if (isOverlapped(&temp, &cell)) { overlap = true; break; } } } } } // for (size_t ic = 0; ic < clusters.size(); ++ic) { // if (ic != rcluster) { // if (is_overlapped(clusters[ic], cell)) { // overlap = true; // break; // } // } // } if (!overlap) { ++positive; } ++i; } } return positive; }
//widget's coordinates; scroll within rect; only update widget void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) { Q_Q(QWidget); QWidget *tlw = q->window(); QTLWExtra* x = tlw->d_func()->topData(); if (x->inTopLevelResize) return; QWidgetBackingStore *wbs = x->backingStore.data(); if (!wbs) return; static int accelEnv = -1; if (accelEnv == -1) { accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0; } QRect scrollRect = rect & clipRect(); bool overlapped = false; bool accelerateScroll = accelEnv && isOpaque && !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft()))); if (!accelerateScroll) { if (overlapped) { QRegion region(scrollRect); subtractOpaqueSiblings(region); invalidateBuffer(region); }else { invalidateBuffer(scrollRect); } } else { const QPoint toplevelOffset = q->mapTo(tlw, QPoint()); const QRect destRect = scrollRect.translated(dx, dy) & scrollRect; const QRect sourceRect = destRect.translated(-dx, -dy); QRegion childExpose(scrollRect); if (sourceRect.isValid()) { if (wbs->bltRect(sourceRect, dx, dy, q)) childExpose -= destRect; } if (inDirtyList) { if (rect == q->rect()) { dirty.translate(dx, dy); } else { QRegion dirtyScrollRegion = dirty.intersected(scrollRect); if (!dirtyScrollRegion.isEmpty()) { dirty -= dirtyScrollRegion; dirtyScrollRegion.translate(dx, dy); dirty += dirtyScrollRegion; } } } if (!q->updatesEnabled()) return; if (!childExpose.isEmpty()) { wbs->markDirty(childExpose, q); isScrolled = true; } // Instead of using native scroll-on-screen, we copy from // backingstore, giving only one screen update for each // scroll, and a solid appearance wbs->markDirtyOnScreen(destRect, q, toplevelOffset); } }
//parent's coordinates; move whole rect; update parent and widget //assume the screen blt has already been done, so we don't need to refresh that part void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy) { Q_Q(QWidget); if (!q->isVisible() || (dx == 0 && dy == 0)) return; QWidget *tlw = q->window(); QTLWExtra* x = tlw->d_func()->topData(); if (x->inTopLevelResize) return; static int accelEnv = -1; if (accelEnv == -1) { accelEnv = qgetenv("QT_NO_FAST_MOVE").toInt() == 0; } QWidget *pw = q->parentWidget(); QPoint toplevelOffset = pw->mapTo(tlw, QPoint()); QWidgetPrivate *pd = pw->d_func(); QRect clipR(pd->clipRect()); const QRect newRect(rect.translated(dx, dy)); QRect destRect = rect.intersected(clipR); if (destRect.isValid()) destRect = destRect.translated(dx, dy).intersected(clipR); const QRect sourceRect(destRect.translated(-dx, -dy)); const QRect parentRect(rect & clipR); bool accelerateMove = accelEnv && isOpaque #ifndef QT_NO_GRAPHICSVIEW // No accelerate move for proxy widgets. && !tlw->d_func()->extra->proxyWidget #endif && !isOverlapped(sourceRect) && !isOverlapped(destRect); if (!accelerateMove) { QRegion parentR(effectiveRectFor(parentRect)); if (!extra || !extra->hasMask) { parentR -= newRect; } else { // invalidateBuffer() excludes anything outside the mask parentR += newRect & clipR; } pd->invalidateBuffer(parentR); invalidateBuffer((newRect & clipR).translated(-data.crect.topLeft())); } else { QWidgetBackingStore *wbs = x->backingStore.data(); QRegion childExpose(newRect & clipR); if (sourceRect.isValid() && wbs->bltRect(sourceRect, dx, dy, pw)) childExpose -= destRect; if (!pw->updatesEnabled()) return; const bool childUpdatesEnabled = q->updatesEnabled(); if (childUpdatesEnabled && !childExpose.isEmpty()) { childExpose.translate(-data.crect.topLeft()); wbs->markDirty(childExpose, q); isMoved = true; } QRegion parentExpose(parentRect); parentExpose -= newRect; if (extra && extra->hasMask) parentExpose += QRegion(newRect) - extra->mask.translated(data.crect.topLeft()); if (!parentExpose.isEmpty()) { wbs->markDirty(parentExpose, pw); pd->isMoved = true; } if (childUpdatesEnabled) { QRegion needsFlush(sourceRect); needsFlush += destRect; wbs->markDirtyOnScreen(needsFlush, pw, toplevelOffset); } } }