const double HitPoints::GetPhotonHitEfficency() {
	u_int surfaceHitPointsCount = 0;
	u_int hitPointsUpdatedCount = 0;
	for (u_int i = 0; i < GetSize(); ++i) {
		HitPoint *hp = &(*hitPoints)[i];

		if (hp->IsSurface()) {
			++surfaceHitPointsCount;

			if (hp->GetPhotonCount() > 0)
				++hitPointsUpdatedCount;
		}
	}

	return 100.0 * hitPointsUpdatedCount / surfaceHitPointsCount;
}
void HitPoints::UpdatePointsInformation() {
	// Calculate hit points bounding box
	BBox bbox;
	float maxr2, minr2, meanr2;
	u_int minp, maxp, meanp;
	u_int surfaceHits, constantHits, zeroHits;

	assert((*hitPoints).size() > 0);
	HitPoint *hp = &(*hitPoints)[0];

	if (hp->IsSurface()) {
		surfaceHits = 1;
		constantHits = 0;
		u_int pc = hp->GetPhotonCount();
		zeroHits = pc == 0 ? 1 : 0;
		bbox = hp->GetPosition();
		maxr2 = minr2 = meanr2 = hp->accumPhotonRadius2;
		minp = maxp = meanp = pc;
	} else {
		constantHits = 1;
		surfaceHits = 0;
		zeroHits = 0;
		maxr2 = 0.f;
		minr2 = INFINITY;
		meanr2 = 0.f;
		minp = maxp = meanp = 0;
	}

	for (u_int i = 1; i < (*hitPoints).size(); ++i) {
		hp = &(*hitPoints)[i];

		if (hp->IsSurface()) {
			u_int pc = hp->GetPhotonCount();
			if(pc == 0)
				++zeroHits;

			bbox = Union(bbox, hp->GetPosition());

			maxr2 = max<float>(maxr2, hp->accumPhotonRadius2);
			minr2 = min<float>(minr2, hp->accumPhotonRadius2);
			meanr2 += hp->accumPhotonRadius2;


			maxp = max<float>(maxp, pc);
			minp = min<float>(minp, pc);
			meanp += pc;

			++surfaceHits;
		}
		else
			++constantHits;
	}

	LOG(LUX_DEBUG, LUX_NOERROR) << "Hit points stats:";
	if (surfaceHits > 0) {
		LOG(LUX_DEBUG, LUX_NOERROR) << "\tbounding box: " << bbox;
		LOG(LUX_DEBUG, LUX_NOERROR) << "\tmin/max radius: " << sqrtf(minr2) << "/" << sqrtf(maxr2);
		LOG(LUX_DEBUG, LUX_NOERROR) << "\tmin/max photonCount: " << minp << "/" << maxp;
		LOG(LUX_DEBUG, LUX_NOERROR) << "\tmean radius/photonCount: " << sqrtf(meanr2 / surfaceHits) << "/" << meanp / surfaceHits;
	}
	LOG(LUX_DEBUG, LUX_NOERROR) << "\tconstant/zero hits: " << constantHits << "/" << zeroHits;

	hitPointBBox = bbox;
	maxHitPointRadius2 = maxr2;
}