Example #1
0
bool TriangleMesh::intersects(const Ray &ray, Intersection* inter) const {
	/* the first time its called, generate all triangles and cache it for reuse */
	if (!cache) {
		generateCache();
	}

	Intersection in, temp;
	in.t = INFINITY;
	bool intersected = false;
	for (int i = 0; i < numtriangles; i++) {
		if (cache[i].intersects(ray, &temp)) {
			if (temp.t < in.t) {
				in = temp;
				intersected = true;
			}
		}
	}

	if (intersected) {
		if (inter) {
			inter->copy(in);
			inter->object = (TriangleMesh*)this;
		}
		return true;
	}

	return false;
}
Example #2
0
void ImageView::queueGenerateCache()
{
  if (!m_item)
    return;

  if (!m_cachedPixmap.isNull())
    m_cachedPixmap = QPixmap();

  if (m_scaleFactor == 1.0) {
    if (m_cacheTimer) {
      m_cacheTimer->stop();
      delete m_cacheTimer;
      m_cacheTimer = 0;
    }

    return;
  }

  if (!m_cacheTimer) {
    m_cacheTimer = new QTimer();
    m_cacheTimer->setSingleShot(true);

    connect(m_cacheTimer, SIGNAL(timeout()), SLOT(generateCache()));
  }

  m_cacheTimer->start(20);
}
Example #3
0
Real TriangleMesh::getArea() const{
	if (!cache)
		generateCache();
	return area;
}