[Bf-blender-cvs] [95d885b] master: Quiet float conversion warnings when building cycles standalone

Campbell Barton noreply at git.blender.org
Sat May 3 19:27:58 CEST 2014


Commit: 95d885b3f431284b2e1eb8640771cab00b201437
Author: Campbell Barton
Date:   Sun May 4 03:15:20 2014 +1000
https://developer.blender.org/rB95d885b3f431284b2e1eb8640771cab00b201437

Quiet float conversion warnings when building cycles standalone

===================================================================

M	intern/cycles/app/cycles_standalone.cpp
M	intern/cycles/app/cycles_xml.cpp
M	intern/cycles/app/cycles_xml.h
M	intern/cycles/util/util_view.cpp

===================================================================

diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp
index 839275e..074d640 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -208,11 +208,11 @@ static void motion(int x, int y, int button)
 
 		/* Rotate */
 		else if(button == 2) {
-			float4 r1= make_float4(x * 0.1f, 0.0f, 1.0f, 0.0f);
-			matrix = matrix * transform_rotate(r1.x * M_PI/180.0f, make_float3(r1.y, r1.z, r1.w));
+			float4 r1= make_float4((float)x * 0.1f, 0.0f, 1.0f, 0.0f);
+			matrix = matrix * transform_rotate(DEG2RADF(r1.x), make_float3(r1.y, r1.z, r1.w));
 
-			float4 r2 = make_float4(y * 0.1, 1.0f, 0.0f, 0.0f);
-			matrix = matrix * transform_rotate(r2.x * M_PI/180.0f, make_float3(r2.y, r2.z, r2.w));
+			float4 r2 = make_float4(y * 0.1f, 1.0f, 0.0f, 0.0f);
+			matrix = matrix * transform_rotate(DEG2RADF(r2.x), make_float3(r2.y, r2.z, r2.w));
 		}
 
 		/* Update and Reset */
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 1faf290..d5ef30e 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -105,7 +105,7 @@ static bool xml_read_float(float *value, pugi::xml_node node, const char *name)
 	pugi::xml_attribute attr = node.attribute(name);
 
 	if(attr) {
-		*value = atof(attr.value());
+		*value = (float)atof(attr.value());
 		return true;
 	}
 
@@ -121,7 +121,7 @@ static bool xml_read_float_array(vector<float>& value, pugi::xml_node node, cons
 		string_split(tokens, attr.value());
 
 		foreach(const string& token, tokens)
-			value.push_back(atof(token.c_str()));
+			value.push_back((float)atof(token.c_str()));
 
 		return true;
 	}
@@ -322,7 +322,7 @@ static void xml_read_camera(const XMLReadState& state, pugi::xml_node node)
 	xml_read_int(&cam->height, node, "height");
 
 	if(xml_read_float(&cam->fov, node, "fov"))
-		cam->fov *= M_PI/180.0f;
+		cam->fov = DEG2RADF(cam->fov);
 
 	xml_read_float(&cam->nearclip, node, "nearclip");
 	xml_read_float(&cam->farclip, node, "farclip");
@@ -1032,7 +1032,7 @@ static void xml_read_transform(pugi::xml_node node, Transform& tfm)
 	if(node.attribute("rotate")) {
 		float4 rotate = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 		xml_read_float4(&rotate, node, "rotate");
-		tfm = tfm * transform_rotate(rotate.x*M_PI/180.0f, make_float3(rotate.y, rotate.z, rotate.w));
+		tfm = tfm * transform_rotate(DEG2RADF(rotate.x), make_float3(rotate.y, rotate.z, rotate.w));
 	}
 
 	if(node.attribute("scale")) {
diff --git a/intern/cycles/app/cycles_xml.h b/intern/cycles/app/cycles_xml.h
index 1e3ed41..2d225f3 100644
--- a/intern/cycles/app/cycles_xml.h
+++ b/intern/cycles/app/cycles_xml.h
@@ -23,6 +23,10 @@ class Scene;
 
 void xml_read_file(Scene *scene, const char *filepath);
 
+/* macros for importing */
+#define RAD2DEGF(_rad) ((_rad) * (float)(180.0 / M_PI))
+#define DEG2RADF(_deg) ((_deg) * (float)(M_PI / 180.0))
+
 CCL_NAMESPACE_END
 
 #endif /* __CYCLES_XML__ */
diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp
index 5e3d84c..6bf9c9e 100644
--- a/intern/cycles/util/util_view.cpp
+++ b/intern/cycles/util/util_view.cpp
@@ -80,8 +80,8 @@ void view_display_info(const char *info)
 
 void view_display_help()
 {
-	const int w = V.width / 1.15;
-	const int h = V.height / 1.15;
+	const int w = (int)((float)V.width  / 1.15f);
+	const int h = (int)((float)V.height / 1.15f);
 
 	const int x1 = (V.width - w) / 2;
 	const int x2 = x1 + w;




More information about the Bf-blender-cvs mailing list