Ejemplo n.º 1
0
void MonteCarloRayTracer::threadRender(int tId, float *pixels, const Octree &tree, const Camera &cam, int row, const int NUM_THREADS) {

	int *tex = new int[_W * _H * 3];
	for (int u = 0; u < _W / NUM_THREADS; ++u) {

		glm::vec3 accumDiffColor(0.0f,0.0f,0.0f);

		float randU, randV;
		for(int rpp=1; rpp<=_raysPerPixel; ++rpp) {

			randU = _rgen.nextFloat() / 1.f;
			randV = _rgen.nextFloat() / 1.f;
				
			float u2 = u * NUM_THREADS + tId + randU;
			float v2 = row + randV;
				
			float x;
			float y;
			calculateXnY(u2, v2, x, y);
			Ray r = cam.createRay(x, y);
			IntersectionPoint ip;
				
			if (tree.intersect(r, ip)) {
				Ray ray(ip.getPoint() + r.getDirection() * 0.00001f, r.getDirection());
				glm::vec3 color = iterateRay(ray, tree, 0, false);
				accumDiffColor += color;
			}
			addToCount();
				
			ProgressBar::printTimedProgBar(_rayCounter, _W * _H * _raysPerPixel, "Carlo");

		}
			
		int id = calculateId(u * NUM_THREADS + tId, row);

		pixels[id + 0] = accumDiffColor.x/float(_raysPerPixel);
		pixels[id + 1] = accumDiffColor.y/float(_raysPerPixel);
		pixels[id + 2] = accumDiffColor.z/float(_raysPerPixel);

		
	}
	threadDone[tId] = true;
	delete tex;
}
Ejemplo n.º 2
0
void Class::registerClass()
{
	id = calculateId();

	//LogDebug("Registering class: '%s' with id '%u'", klass->name, klass->id);

	// Register as child class in the parent class.
	if (parent) parent->childs.Push(this);

	// Register the class id in the map.
	ClassIdMap& ids = Class::GetIdMap();

	if( ids.Find(id) != ids.End() )
	{
		LogError("Class with the same id already exists: '%s'", name);
		return;
	}

	ids[id] = this;
}
Ejemplo n.º 3
0
void QPProblemFromLCCQP::SetIsEqualityOnZ(const vector<int>& isEqualityOnZ)
{
    mIsEqualityOnZ = isEqualityOnZ;
    calculateId();
}