瀏覽代碼

Fixed packDouble2x32 on XCode 4.5, issue #37

Christophe Riccio 13 年之前
父節點
當前提交
37e380ca9b
共有 2 個文件被更改,包括 33 次插入2 次删除
  1. 32 2
      glm/core/func_packing.inl
  2. 1 0
      readme.txt

+ 32 - 2
glm/core/func_packing.inl

@@ -136,12 +136,42 @@ namespace glm
 
 
 	GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
 	GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
 	{
 	{
-		return *(double*)&v;
+		struct uint32_pair
+		{
+			detail::uint32 x;
+			detail::uint32 y;
+		};
+
+		union helper
+		{
+			uint32_pair input;
+			double output;
+		} Helper;
+
+		Helper.input.x = v.x;
+		Helper.input.y = v.y;
+
+		return Helper.output;
+		//return *(double*)&v;
 	}
 	}
 
 
 	GLM_FUNC_QUALIFIER detail::tvec2<uint> unpackDouble2x32(double const & v)
 	GLM_FUNC_QUALIFIER detail::tvec2<uint> unpackDouble2x32(double const & v)
 	{
 	{
-		return *(detail::tvec2<uint>*)&v;
+		struct uint32_pair
+		{
+			detail::uint32 x;
+			detail::uint32 y;
+		};
+
+		union helper
+		{
+			double input;
+			uint32_pair output;
+		} Helper;
+
+		Helper.input = v;
+
+		return detail::tvec2<uint>(Helper.output.x, Helper.output.y);
 	}
 	}
 
 
 	GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)
 	GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)

+ 1 - 0
readme.txt

@@ -44,6 +44,7 @@ GLM 0.9.4.2: 2013-01-XX
 - Fixed isnan and isinf for CUDA compiler
 - Fixed isnan and isinf for CUDA compiler
 - Fixed GLM_FORCE_RADIANS on glm::perspective
 - Fixed GLM_FORCE_RADIANS on glm::perspective
 - Fixed GCC warnings
 - Fixed GCC warnings
+- Fixed packDouble2x32 on XCode
 
 
 ================================================================================
 ================================================================================
 GLM 0.9.4.1: 2012-12-22
 GLM 0.9.4.1: 2012-12-22