[SCM] yafaray/upstream: Imported Upstream version 0.1.2

mfv-guest at users.alioth.debian.org mfv-guest at users.alioth.debian.org
Fri Mar 30 15:02:27 UTC 2012


The following commit has been merged in the upstream branch:
commit d9a016551d8404a59467ffeee519a0d966e7a6a4
Author: Matteo F. Vescovi <mfv.debian at gmail.com>
Date:   Fri Mar 30 16:36:09 2012 +0200

    Imported Upstream version 0.1.2

diff --git a/include/core_api/object3d.h b/include/core_api/object3d.h
index 5287c4c..8b9e5d7 100644
--- a/include/core_api/object3d.h
+++ b/include/core_api/object3d.h
@@ -25,7 +25,7 @@ class YAFRAYCORE_EXPORT object3d_t
 		virtual int numPrimitives() const = 0;
 		/*! write the primitive pointers to the given array
 			\return number of written primitives */
-		virtual int getPrimitives(const primitive_t **prims) const { return NULL; }
+		virtual int getPrimitives(const primitive_t **prims) const { return 0; }
 		/*! set a light source to be associated with this object */
 		virtual void setLight(const light_t *l){ light=l; }
 		/*! query whether object surface can be sampled right now */
diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc
index 10b40d6..10f7bc3 100644
--- a/src/image_handlers/tifHandler.cc
+++ b/src/image_handlers/tifHandler.cc
@@ -132,7 +132,7 @@ bool tifHandler_t::saveToFile(const std::string &name)
     	
 		if(TIFFWriteScanline(out, scanline, y, 0) < 0)
 		{
-			Y_ERROR << handlerName << ": An error ocurred while writting TIFF file" << yendl;
+			Y_ERROR << handlerName << ": An error occurred while writing TIFF file" << yendl;
 			TIFFClose(out);
 			_TIFFfree(scanline);
 
@@ -174,7 +174,7 @@ bool tifHandler_t::saveToFile(const std::string &name)
 			
 			if(TIFFWriteScanline(out, scanline16, y, 0) < 0)
 			{
-				Y_ERROR << handlerName << ": An error ocurred while writting TIFF file" << yendl;
+				Y_ERROR << handlerName << ": An error occurred while writing TIFF file" << yendl;
 				TIFFClose(out);
 				_TIFFfree(scanline16);
 
diff --git a/src/materials/coatedglossy.cc b/src/materials/coatedglossy.cc
index 722dce0..e7654e9 100644
--- a/src/materials/coatedglossy.cc
+++ b/src/materials/coatedglossy.cc
@@ -142,12 +142,12 @@ float coatedGlossyMat_t::OrenNayar(const vector3d_t &wi, const vector3d_t &wo, c
 	if(cos_to >= cos_ti)
 	{
 		sin_alpha = fSqrt(1.f - cos_ti*cos_ti);
-		tan_beta = fSqrt(1.f - cos_to*cos_to) / cos_to;
+		tan_beta = fSqrt(1.f - cos_to*cos_to) / (cos_to == 0.f)?1e-8f:cos_to; // white (black on windows) dots fix for oren-nayar, could happen with bad normals
 	}
 	else
 	{
 		sin_alpha = fSqrt(1.f - cos_to*cos_to);
-		tan_beta = fSqrt(1.f - cos_ti*cos_ti) / cos_ti;
+		tan_beta = fSqrt(1.f - cos_ti*cos_ti) / (cos_ti == 0.f)?1e-8f:cos_ti; // white (black on windows) dots fix for oren-nayar, could happen with bad normals
 	}
 	
 	return orenA + orenB * maxcos_f * sin_alpha * tan_beta;
diff --git a/src/materials/glossy_mat.cc b/src/materials/glossy_mat.cc
index 627198a..97abc53 100644
--- a/src/materials/glossy_mat.cc
+++ b/src/materials/glossy_mat.cc
@@ -120,12 +120,12 @@ float glossyMat_t::OrenNayar(const vector3d_t &wi, const vector3d_t &wo, const v
 	if(cos_to >= cos_ti)
 	{
 		sin_alpha = fSqrt(1.f - cos_ti*cos_ti);
-		tan_beta = fSqrt(1.f - cos_to*cos_to) / cos_to;
+		tan_beta = fSqrt(1.f - cos_to*cos_to) / (cos_to == 0.f)?1e-8f:cos_to; // white (black on windows) dots fix for oren-nayar, could happen with bad normals
 	}
 	else
 	{
 		sin_alpha = fSqrt(1.f - cos_to*cos_to);
-		tan_beta = fSqrt(1.f - cos_ti*cos_ti) / cos_ti;
+		tan_beta = fSqrt(1.f - cos_ti*cos_ti) / (cos_ti == 0.f)?1e-8f:cos_ti; // white (black on windows) dots fix for oren-nayar, could happen with bad normals
 	}
 	
 	return orenA + orenB * maxcos_f * sin_alpha * tan_beta;
diff --git a/src/materials/shinydiff.cc b/src/materials/shinydiff.cc
index 1cf1b58..4af91eb 100644
--- a/src/materials/shinydiff.cc
+++ b/src/materials/shinydiff.cc
@@ -192,12 +192,12 @@ CFLOAT shinyDiffuseMat_t::OrenNayar(const vector3d_t &wi, const vector3d_t &wo,
 	if(cos_to >= cos_ti)
 	{
 		sin_alpha = fSqrt(1.f - cos_ti*cos_ti);
-		tan_beta = fSqrt(1.f - cos_to*cos_to) / cos_to;
+		tan_beta = fSqrt(1.f - cos_to*cos_to) / (cos_to == 0.f)?1e-8f:cos_to; // white (black on windows) dots fix for oren-nayar, could happen with bad normals
 	}
 	else
 	{
 		sin_alpha = fSqrt(1.f - cos_to*cos_to);
-		tan_beta = fSqrt(1.f - cos_ti*cos_ti) / cos_ti;
+		tan_beta = fSqrt(1.f - cos_ti*cos_ti) / (cos_ti == 0.f)?1e-8f:cos_ti; // white (black on windows) dots fix for oren-nayar, could happen with bad normals
 	}
 	
 	return A + B * maxcos_f * sin_alpha * tan_beta;
diff --git a/src/textures/basicnodes.cc b/src/textures/basicnodes.cc
index 632e648..1e43c64 100644
--- a/src/textures/basicnodes.cc
+++ b/src/textures/basicnodes.cc
@@ -69,7 +69,21 @@ inline point3d_t spheremap(const point3d_t &p)
 inline point3d_t cubemap(const point3d_t &p, const vector3d_t &n)
 {
 	const int ma[3][3] = { {1, 2, 0}, {0, 2, 1}, {0, 1, 2} };
-	int axis = std::fabs(n.x) > std::fabs(n.y) ? (std::fabs(n.x) > std::fabs(n.z) ? 0 : 2) : (std::fabs(n.y) > std::fabs(n.z) ? 1 : 2);
+	// int axis = std::fabs(n.x) > std::fabs(n.y) ? (std::fabs(n.x) > std::fabs(n.z) ? 0 : 2) : (std::fabs(n.y) > std::fabs(n.z) ? 1 : 2);
+	// no functionality changes, just more readable code
+
+	int axis;
+
+	if (std::fabs(n.z) >= std::fabs(n.x) && std::fabs(n.z) >= std::fabs(n.y)) {
+		axis= 2;
+	}
+	else if (std::fabs(n.y) >= std::fabs(n.x) && std::fabs(n.y) >= std::fabs(n.z)) {
+		axis= 1;
+	}
+	else {
+		axis= 0;
+	}
+
 	return point3d_t(p[ma[axis][0]], p[ma[axis][1]], p[ma[axis][2]]);
 }
 
@@ -120,7 +134,7 @@ void textureMapper_t::getCoords(point3d_t &texpt, vector3d_t &Ng, const surfaceP
 	{
 		case TXC_UV:	texpt = eval_uv(sp); Ng = sp.Ng; break;
 		case TXC_ORCO:	texpt = sp.orcoP; Ng = sp.orcoNg; break;
-		case TXC_TRAN:	texpt = mtx * sp.P; Ng = sp.Ng; break;
+		case TXC_TRAN:	texpt = mtx * sp.P; Ng = mtx * sp.Ng; break;  // apply 4x4 matrix of object for mapping also to true surface normals
 		case TXC_WIN:	texpt = state.cam->screenproject(sp.P); Ng = sp.Ng; break;
 		case TXC_STICK:	// Not implemented yet use GLOB
 		case TXC_STRESS:// Not implemented yet use GLOB
@@ -137,7 +151,7 @@ void textureMapper_t::eval(nodeStack_t &stack, const renderState_t &state, const
 	point3d_t texpt(0.f);
 	vector3d_t Ng(0.f);
 
-	getCoords(texpt, Ng, sp,state);
+	getCoords(texpt, Ng, sp, state);
 
 	texpt = doMapping(texpt, Ng);
 	

-- 
yafaray packaging



More information about the pkg-multimedia-commits mailing list