[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49513] trunk/blender/source: code cleanup : double promotion warnings

Campbell Barton ideasman42 at gmail.com
Thu Aug 2 23:17:13 CEST 2012


Revision: 49513
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49513
Author:   campbellbarton
Date:     2012-08-02 21:17:12 +0000 (Thu, 02 Aug 2012)
Log Message:
-----------
code cleanup: double promotion warnings

Modified Paths:
--------------
    trunk/blender/source/blender/render/intern/raytrace/rayobject.cpp
    trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
    trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp

Modified: trunk/blender/source/blender/render/intern/raytrace/rayobject.cpp
===================================================================
--- trunk/blender/source/blender/render/intern/raytrace/rayobject.cpp	2012-08-02 20:30:23 UTC (rev 49512)
+++ trunk/blender/source/blender/render/intern/raytrace/rayobject.cpp	2012-08-02 21:17:12 UTC (rev 49513)
@@ -369,12 +369,12 @@
 
 	/* setup vars used on raycast */
 	for (i = 0; i < 3; i++) {
-		isec->idot_axis[i]      = 1.0f / isec->dir[i];
+		isec->idot_axis[i]          = 1.0f / isec->dir[i];
 		
-		isec->bv_index[2 * i]     = isec->idot_axis[i] < 0.0 ? 1 : 0;
+		isec->bv_index[2 * i]       = isec->idot_axis[i] < 0.0f ? 1 : 0;
 		isec->bv_index[2 * i + 1]   = 1 - isec->bv_index[2 * i];
 		
-		isec->bv_index[2 * i]     = i + 3 * isec->bv_index[2 * i];
+		isec->bv_index[2 * i]       = i + 3 * isec->bv_index[2 * i];
 		isec->bv_index[2 * i + 1]   = i + 3 * isec->bv_index[2 * i + 1];
 	}
 

Modified: trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp	2012-08-02 20:30:23 UTC (rev 49512)
+++ trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp	2012-08-02 21:17:12 UTC (rev 49513)
@@ -130,10 +130,10 @@
 void KX_BlenderMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
 {
 	if (mMaterial) {
-		*rgba++ = (unsigned char) (mMaterial->matcolor[0]*255.0);
-		*rgba++ = (unsigned char) (mMaterial->matcolor[1]*255.0);
-		*rgba++ = (unsigned char) (mMaterial->matcolor[2]*255.0);
-		*rgba++ = (unsigned char) (mMaterial->matcolor[3]*255.0);
+		*rgba++ = (unsigned char)(mMaterial->matcolor[0] * 255.0f);
+		*rgba++ = (unsigned char)(mMaterial->matcolor[1] * 255.0f);
+		*rgba++ = (unsigned char)(mMaterial->matcolor[2] * 255.0f);
+		*rgba++ = (unsigned char)(mMaterial->matcolor[3] * 255.0f);
 	} else
 		RAS_IPolyMaterial::GetMaterialRGBAColor(rgba);
 }

Modified: trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp	2012-08-02 20:30:23 UTC (rev 49512)
+++ trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp	2012-08-02 21:17:12 UTC (rev 49513)
@@ -748,10 +748,10 @@
 	 * Once we take the tangent of that angle, you have the verts coordinate corresponding to the verts on the side faces.
 	 * Then we need to multiply it by sqrt(2.0) to get the coordinate of the verts on the diagonal of the original cube.
 	 */
-	verts_height = tan((rad_ang/2) - (MT_PI/2))*M_SQRT2;
+	verts_height = tanf((rad_ang / 2.0f) - (float)(MT_PI / 2.0)) * (float)M_SQRT2;
 
-	uv_height = uv_ratio * ((verts_height/2) + 0.5);
-	uv_base = uv_ratio * (1.0 - ((verts_height/2) + 0.5));
+	uv_height = uv_ratio * (       (verts_height / 2.0f) + 0.5f);
+	uv_base   = uv_ratio * (1.0 - ((verts_height / 2.0f) + 0.5f));
 	
 	//creating faces for the env mapcube 180deg Dome
 	// Front Face - 2 triangles
@@ -1325,7 +1325,7 @@
 
 	for (int i=0;i<3;i++) {
 		r = atan2(sqrt(verts[i][0]*verts[i][0] + verts[i][2]*verts[i][2]), verts[i][1]);
-		r /= m_radangle/2;
+		r /= (double)this->m_radangle / 2.0;
 
 		phi = atan2(verts[i][2], verts[i][0]);
 
@@ -1818,13 +1818,13 @@
 	else if (m_mode == DOME_TRUNCATED_FRONT)
 	{
 		ortho_width = 1.0;
-		ortho_height = 2 * ((float)can_height / can_width) - 1.0;
+		ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f;
 
 		glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0, 10.0);
 	}
 	else { //m_mode == DOME_TRUNCATED_REAR
 		ortho_width = 1.0;
-		ortho_height = 2 * ((float)can_height / can_width) - 1.0;
+		ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f;
 
 		glOrtho((-ortho_width), ortho_width, (-ortho_width), ortho_height, -20.0, 10.0);
 	}
@@ -1905,8 +1905,8 @@
 			ortho_height = (float)can_height/can_width;
 		}
 		else {
-			ortho_width = (float)can_width/can_height * 0.5;
-			ortho_height = 0.5;
+			ortho_width = (float)can_width / can_height * 0.5f;
+			ortho_height = 0.5f;
 		}
 		
 		glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0);

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2012-08-02 20:30:23 UTC (rev 49512)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2012-08-02 21:17:12 UTC (rev 49513)
@@ -261,12 +261,12 @@
 		// Make sure the objects have some scale
 		MT_Vector3 scale1 = NodeGetWorldScaling();
 		MT_Vector3 scale2 = obj->NodeGetWorldScaling();
-		if (fabs(scale2[0]) < FLT_EPSILON || 
-			fabs(scale2[1]) < FLT_EPSILON || 
-			fabs(scale2[2]) < FLT_EPSILON || 
-			fabs(scale1[0]) < FLT_EPSILON || 
-			fabs(scale1[1]) < FLT_EPSILON || 
-			fabs(scale1[2]) < FLT_EPSILON) { return; }
+		if (fabs(scale2[0]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(scale2[1]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(scale2[2]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(scale1[0]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(scale1[1]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(scale1[2]) < (MT_Scalar)FLT_EPSILON) { return; }
 
 		// Remove us from our old parent and set our new parent
 		RemoveParent(scene);
@@ -931,7 +931,7 @@
 		return;
 	}
 	
-	if (fac<=0.0) {
+	if (fac <= 0.0f) {
 		return;
 	}
 	
@@ -944,10 +944,10 @@
 			ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis
 			if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector parallel to the pivot?
 				ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot!
-			if (fac == 1.0) {
+			if (fac == 1.0f) {
 				x = vect;
 			} else {
-				x = (vect * fac) + ((orimat * MT_Vector3(1.0, 0.0, 0.0)) * (1-fac));
+				x = (vect * fac) + ((orimat * MT_Vector3(1.0, 0.0, 0.0)) * (1.0f - fac));
 				len = x.length();
 				if (MT_fuzzyZero(len)) x = vect;
 				else x /= len;
@@ -959,10 +959,10 @@
 			ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]);
 			if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
 				ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]);
-			if (fac == 1.0) {
+			if (fac == 1.0f) {
 				y = vect;
 			} else {
-				y = (vect * fac) + ((orimat * MT_Vector3(0.0, 1.0, 0.0)) * (1-fac));
+				y = (vect * fac) + ((orimat * MT_Vector3(0.0, 1.0, 0.0)) * (1.0f - fac));
 				len = y.length();
 				if (MT_fuzzyZero(len)) y = vect;
 				else y /= len;
@@ -974,10 +974,10 @@
 			ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]);
 			if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
 				ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]);
-			if (fac == 1.0) {
+			if (fac == 1.0f) {
 				z = vect;
 			} else {
-				z = (vect * fac) + ((orimat * MT_Vector3(0.0, 0.0, 1.0)) * (1-fac));
+				z = (vect * fac) + ((orimat * MT_Vector3(0.0, 0.0, 1.0)) * (1.0f - fac));
 				len = z.length();
 				if (MT_fuzzyZero(len)) z = vect;
 				else z /= len;
@@ -1162,9 +1162,9 @@
 	{
 		// Make sure the objects have some scale
 		MT_Vector3 p_scale = parent->GetWorldScaling();
-		if (fabs(p_scale[0]) < FLT_EPSILON ||
-			fabs(p_scale[1]) < FLT_EPSILON ||
-			fabs(p_scale[2]) < FLT_EPSILON)
+		if (fabs(p_scale[0]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(p_scale[1]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(p_scale[2]) < (MT_Scalar)FLT_EPSILON)
 		{ 
 			return; 
 		}
@@ -1190,9 +1190,9 @@
 	{
 		// Make sure the objects have some scale
 		MT_Vector3 scale = parent->GetWorldScaling();
-		if (fabs(scale[0]) < FLT_EPSILON ||
-			fabs(scale[1]) < FLT_EPSILON ||
-			fabs(scale[2]) < FLT_EPSILON)
+		if (fabs(scale[0]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(scale[1]) < (MT_Scalar)FLT_EPSILON ||
+			fabs(scale[2]) < (MT_Scalar)FLT_EPSILON)
 		{ 
 			return; 
 		}
@@ -1940,7 +1940,7 @@
 {
 	KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 	KX_IPhysicsController *spc = self->GetPhysicsController();
-	return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0f);
+	return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0);
 }
 
 int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -1948,7 +1948,7 @@
 	KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 	KX_IPhysicsController *spc = self->GetPhysicsController();
 	MT_Scalar val = PyFloat_AsDouble(value);
-	if (val < 0.0f) { /* also accounts for non float */
+	if (val < 0.0) { /* also accounts for non float */
 		PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above");
 		return PY_SET_ATTR_FAIL;
 	}
@@ -1971,7 +1971,7 @@
 	KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 	KX_IPhysicsController *spc = self->GetPhysicsController();
 	MT_Scalar val = PyFloat_AsDouble(value);
-	if (val < 0.0f) { /* also accounts for non float */
+	if (val < 0.0) { /* also accounts for non float */
 		PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above");
 		return PY_SET_ATTR_FAIL;
 	}
@@ -1994,7 +1994,7 @@
 	KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 	KX_IPhysicsController *spc = self->GetPhysicsController();
 	MT_Scalar val = PyFloat_AsDouble(value);
-	if (val < 0.0f) { /* also accounts for non float */
+	if (val < 0.0) { /* also accounts for non float */
 		PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above");
 		return PY_SET_ATTR_FAIL;
 	}
@@ -2360,8 +2360,8 @@
 	KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 	if (self->GetSGNode()) {
 		MT_Scalar val = PyFloat_AsDouble(value);
-		SG_Node* sg_parent= self->GetSGNode()->GetSGParent();
-		if (val < 0.0f) { /* also accounts for non float */
+		SG_Node *sg_parent= self->GetSGNode()->GetSGParent();
+		if (val < 0.0) { /* also accounts for non float */
 			PyErr_SetString(PyExc_AttributeError, "gameOb.timeOffset = float: KX_GameObject, expected a float zero or above");
 			return PY_SET_ATTR_FAIL;
 		}
@@ -2644,7 +2644,7 @@
 	return PyObjectFrom(dummy_point);
 	*/
 	
-	return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
+	return Py_BuildValue("fff", 0.0, 0.0, 0.0);
 	
 }
 
@@ -2761,18 +2761,18 @@
 {
 	PyObject* pyvect;
 	int axis = 2; //z axis is the default
-	float fac = 1.0;
+	float fac = 1.0f;
 	
 	if (PyArg_ParseTuple(args,"O|if:alignAxisToVect",&pyvect,&axis, &fac))
 	{
 		MT_Vector3 vect;
-		if (PyVecTo(pyvect, vect))
-		{
-			if (fac<=0.0) Py_RETURN_NONE; // Nothing to do.

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list