From 4460f3af29281bb32d9bca46d7f584d0d54de932 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 14 Apr 2010 13:27:44 +0100 Subject: [PATCH] Added experimental files --- sample/CMakeLists.txt | 0 wip/half/half.cpp | 4 + wip/half/half.h | 119 + wip/half/half.inl | 0 wip/half/half_test.cpp | 39 + wip/half/half_test.h | 6 + wip/sign.cpp | 5 + wip/simd/sse.cpp | 1378 +++++++++ wip/simd/sse.h | 13 + wip/simd/sse_mat4.cpp | 61 + wip/simd/sse_mat4.h | 1280 +++++++++ wip/simd/sse_mat4array.cpp | 1 + wip/simd/sse_mat4array.h | 0 wip/simd/sse_vec4.cpp | 53 + wip/simd/sse_vec4.h | 290 ++ wip/simd/sse_vec4array.cpp | 1 + wip/simd/sse_vec4array.h | 0 wip/sse/glm/core/_bvec2.h | 54 + wip/sse/glm/core/_bvec2.inl | 159 ++ wip/sse/glm/core/_bvec3.h | 67 + wip/sse/glm/core/_bvec3.inl | 224 ++ wip/sse/glm/core/_bvec4.h | 91 + wip/sse/glm/core/_bvec4.inl | 335 +++ wip/sse/glm/core/_cvec2.h | 113 + wip/sse/glm/core/_cvec2.inl | 253 ++ wip/sse/glm/core/_cvec3.h | 217 ++ wip/sse/glm/core/_cvec3.inl | 849 ++++++ wip/sse/glm/core/_cvec4.h | 489 ++++ wip/sse/glm/core/_cvec4.inl | 2450 +++++++++++++++++ wip/sse/glm/core/_cvecx.h | 54 + wip/sse/glm/core/_func.h | 359 +++ wip/sse/glm/core/_func.inl | 2247 +++++++++++++++ wip/sse/glm/core/_swizzle.h | 1742 ++++++++++++ wip/sse/glm/core/_swizzle.inl | 20 + wip/sse/glm/core/_xmat2.h | 173 ++ wip/sse/glm/core/_xmat2.inl | 416 +++ wip/sse/glm/core/_xmat2x3.h | 143 + wip/sse/glm/core/_xmat2x3.inl | 379 +++ wip/sse/glm/core/_xmat2x4.h | 144 + wip/sse/glm/core/_xmat2x4.inl | 392 +++ wip/sse/glm/core/_xmat3.h | 176 ++ wip/sse/glm/core/_xmat3.inl | 546 ++++ wip/sse/glm/core/_xmat3x2.h | 145 + wip/sse/glm/core/_xmat3x2.inl | 451 +++ wip/sse/glm/core/_xmat3x4.h | 145 + wip/sse/glm/core/_xmat3x4.inl | 434 +++ wip/sse/glm/core/_xmat4.h | 178 ++ wip/sse/glm/core/_xmat4.inl | 633 +++++ wip/sse/glm/core/_xmat4x2.h | 146 + wip/sse/glm/core/_xmat4x2.inl | 440 +++ wip/sse/glm/core/_xmat4x3.h | 146 + wip/sse/glm/core/_xmat4x3.inl | 460 ++++ wip/sse/glm/core/_xref2.h | 38 + wip/sse/glm/core/_xref2.inl | 107 + wip/sse/glm/core/_xref3.h | 39 + wip/sse/glm/core/_xref3.inl | 118 + wip/sse/glm/core/_xref4.h | 40 + wip/sse/glm/core/_xref4.inl | 129 + wip/sse/glm/core/_xvec2.h | 260 ++ wip/sse/glm/core/_xvec2.inl | 802 ++++++ wip/sse/glm/core/_xvec3.h | 283 ++ wip/sse/glm/core/_xvec3.inl | 694 +++++ wip/sse/glm/core/_xvec4.h | 241 ++ wip/sse/glm/core/_xvec4.inl | 1242 +++++++++ wip/sse/glm/ext/gtx.h | 81 + wip/sse/glm/ext/gtx/associated_min_max.h | 518 ++++ wip/sse/glm/ext/gtx/associated_min_max.inl | 911 ++++++ wip/sse/glm/ext/gtx/bit.h | 76 + wip/sse/glm/ext/gtx/bit.inl | 242 ++ wip/sse/glm/ext/gtx/closest_point.h | 54 + wip/sse/glm/ext/gtx/closest_point.inl | 31 + wip/sse/glm/ext/gtx/color_cast.h | 165 ++ wip/sse/glm/ext/gtx/color_cast.inl | 737 +++++ wip/sse/glm/ext/gtx/color_space.h | 51 + wip/sse/glm/ext/gtx/color_space.inl | 149 + wip/sse/glm/ext/gtx/compatibility.h | 298 ++ wip/sse/glm/ext/gtx/compatibility.inl | 132 + wip/sse/glm/ext/gtx/component_wise.h | 49 + wip/sse/glm/ext/gtx/component_wise.inl | 85 + wip/sse/glm/ext/gtx/determinant.h | 45 + wip/sse/glm/ext/gtx/determinant.inl | 47 + wip/sse/glm/ext/gtx/double.h | 80 + wip/sse/glm/ext/gtx/double.inl | 13 + wip/sse/glm/ext/gtx/epsilon.h | 100 + wip/sse/glm/ext/gtx/epsilon.inl | 131 + wip/sse/glm/ext/gtx/euler_angles.h | 54 + wip/sse/glm/ext/gtx/euler_angles.inl | 97 + wip/sse/glm/ext/gtx/extend.h | 41 + wip/sse/glm/ext/gtx/extend.inl | 38 + wip/sse/glm/ext/gtx/extented_min_max.h | 105 + wip/sse/glm/ext/gtx/extented_min_max.inl | 155 ++ wip/sse/glm/ext/gtx/fast_exponential.h | 84 + wip/sse/glm/ext/gtx/fast_exponential.inl | 265 ++ wip/sse/glm/ext/gtx/fast_square_root.h | 72 + wip/sse/glm/ext/gtx/fast_square_root.inl | 165 ++ wip/sse/glm/ext/gtx/fast_trigonometry.h | 80 + wip/sse/glm/ext/gtx/fast_trigonometry.inl | 243 ++ wip/sse/glm/ext/gtx/flexible_mix.h | 47 + wip/sse/glm/ext/gtx/flexible_mix.inl | 58 + wip/sse/glm/ext/gtx/gpu_shader4.h | 169 ++ wip/sse/glm/ext/gtx/gpu_shader4.inl | 949 +++++++ wip/sse/glm/ext/gtx/half.h | 405 +++ wip/sse/glm/ext/gtx/half.inl | 1248 +++++++++ wip/sse/glm/ext/gtx/handed_coordinate_space.h | 45 + .../glm/ext/gtx/handed_coordinate_space.inl | 23 + wip/sse/glm/ext/gtx/hyperbolic.h | 75 + wip/sse/glm/ext/gtx/hyperbolic.inl | 219 ++ wip/sse/glm/ext/gtx/inertia.h | 55 + wip/sse/glm/ext/gtx/inertia.inl | 82 + wip/sse/glm/ext/gtx/integer.h | 104 + wip/sse/glm/ext/gtx/integer.inl | 284 ++ wip/sse/glm/ext/gtx/intersect.h | 107 + wip/sse/glm/ext/gtx/intersect.inl | 148 + wip/sse/glm/ext/gtx/inverse.h | 61 + wip/sse/glm/ext/gtx/inverse.inl | 184 ++ wip/sse/glm/ext/gtx/inverse_transpose.h | 43 + wip/sse/glm/ext/gtx/inverse_transpose.inl | 101 + wip/sse/glm/ext/gtx/mat4x3.h | 134 + wip/sse/glm/ext/gtx/mat4x3.inl | 405 +++ wip/sse/glm/ext/gtx/matrix_access.h | 43 + wip/sse/glm/ext/gtx/matrix_access.inl | 83 + wip/sse/glm/ext/gtx/matrix_cross_product.h | 43 + wip/sse/glm/ext/gtx/matrix_cross_product.inl | 37 + wip/sse/glm/ext/gtx/matrix_major_storage.h | 65 + wip/sse/glm/ext/gtx/matrix_major_storage.inl | 170 ++ wip/sse/glm/ext/gtx/matrix_projection.h | 53 + wip/sse/glm/ext/gtx/matrix_projection.inl | 135 + wip/sse/glm/ext/gtx/matrix_query.h | 62 + wip/sse/glm/ext/gtx/matrix_query.inl | 255 ++ wip/sse/glm/ext/gtx/matrix_selection.h | 51 + wip/sse/glm/ext/gtx/matrix_selection.inl | 63 + wip/sse/glm/ext/gtx/matx.h | 184 ++ wip/sse/glm/ext/gtx/matx.inl | 479 ++++ wip/sse/glm/ext/gtx/mixed_product.h | 54 + wip/sse/glm/ext/gtx/mixed_product.inl | 28 + wip/sse/glm/ext/gtx/mul.h | 48 + wip/sse/glm/ext/gtx/mul.inl | 85 + wip/sse/glm/ext/gtx/norm.h | 58 + wip/sse/glm/ext/gtx/norm.inl | 47 + wip/sse/glm/ext/gtx/normal.h | 41 + wip/sse/glm/ext/gtx/normal.inl | 17 + wip/sse/glm/ext/gtx/normalize_dot.h | 52 + wip/sse/glm/ext/gtx/normalize_dot.inl | 54 + wip/sse/glm/ext/gtx/number_precision.h | 265 ++ wip/sse/glm/ext/gtx/number_precision.inl | 13 + wip/sse/glm/ext/gtx/optimum_pow.h | 55 + wip/sse/glm/ext/gtx/optimum_pow.inl | 58 + wip/sse/glm/ext/gtx/orthonormalize.h | 43 + wip/sse/glm/ext/gtx/orthonormalize.inl | 36 + wip/sse/glm/ext/gtx/outer_product.h | 45 + wip/sse/glm/ext/gtx/outer_product.inl | 64 + wip/sse/glm/ext/gtx/perpendicular.h | 47 + wip/sse/glm/ext/gtx/perpendicular.inl | 29 + wip/sse/glm/ext/gtx/polar_coordinates.h | 47 + wip/sse/glm/ext/gtx/polar_coordinates.inl | 35 + wip/sse/glm/ext/gtx/projection.h | 45 + wip/sse/glm/ext/gtx/projection.inl | 29 + wip/sse/glm/ext/gtx/quaternion.h | 175 ++ wip/sse/glm/ext/gtx/quaternion.inl | 847 ++++++ wip/sse/glm/ext/gtx/random.h | 157 ++ wip/sse/glm/ext/gtx/random.inl | 627 +++++ wip/sse/glm/ext/gtx/rotate_vector.h | 60 + wip/sse/glm/ext/gtx/rotate_vector.inl | 119 + wip/sse/glm/ext/gtx/round.h | 51 + wip/sse/glm/ext/gtx/round.inl | 39 + wip/sse/glm/ext/gtx/spline.h | 46 + wip/sse/glm/ext/gtx/spline.inl | 48 + wip/sse/glm/ext/gtx/statistics_operation.h | 71 + wip/sse/glm/ext/gtx/statistics_operation.inl | 81 + wip/sse/glm/ext/gtx/transform.h | 107 + wip/sse/glm/ext/gtx/transform.inl | 334 +++ wip/sse/glm/ext/gtx/transform2.h | 69 + wip/sse/glm/ext/gtx/transform2.inl | 136 + wip/sse/glm/ext/gtx/transpose.h | 45 + wip/sse/glm/ext/gtx/transpose.inl | 66 + wip/sse/glm/ext/gtx/unsigned_int.h | 47 + wip/sse/glm/ext/gtx/unsigned_int.inl | 40 + wip/sse/glm/ext/gtx/vector_access.h | 64 + wip/sse/glm/ext/gtx/vector_access.inl | 82 + wip/sse/glm/ext/gtx/vector_angle.h | 56 + wip/sse/glm/ext/gtx/vector_angle.inl | 82 + wip/sse/glm/ext/gtx/vector_comp_mult.h | 56 + wip/sse/glm/ext/gtx/vector_comp_mult.inl | 38 + wip/sse/glm/ext/gtx/vector_query.h | 69 + wip/sse/glm/ext/gtx/vector_query.inl | 233 ++ wip/sse/glm/ext/gtx/vecx.h | 221 ++ wip/sse/glm/ext/gtx/vecx.inl | 866 ++++++ wip/sse/glm/ext/gtx/verbose_operator.h | 45 + wip/sse/glm/ext/gtx/verbose_operator.inl | 29 + wip/sse/glm/glm.h | 180 ++ wip/sse/glm/glmext.h | 20 + wip/sse/glm/glmsetup.h | 128 + wip/sse/main.cpp | 137 + wip/sse/precompiled.cpp | 1 + wip/sse/precompiled.h | 7 + wip/sse/rdtsc.cpp | 1 + wip/sse/rdtsc.h | 0 wip/sse/sse.cpp | 1378 +++++++++ wip/sse/sse.h | 13 + wip/sse/sse.sln | 23 + wip/sse/sse.vcproj | 276 ++ wip/sse/sse_mat4.cpp | 60 + wip/sse/sse_mat4.h | 1280 +++++++++ wip/sse/sse_mat4array.cpp | 1 + wip/sse/sse_mat4array.h | 0 wip/sse/sse_vec4.cpp | 52 + wip/sse/sse_vec4.h | 290 ++ wip/sse/sse_vec4array.cpp | 1 + wip/sse/sse_vec4array.h | 0 209 files changed, 44725 insertions(+) create mode 100644 sample/CMakeLists.txt create mode 100644 wip/half/half.cpp create mode 100644 wip/half/half.h create mode 100644 wip/half/half.inl create mode 100644 wip/half/half_test.cpp create mode 100644 wip/half/half_test.h create mode 100644 wip/sign.cpp create mode 100644 wip/simd/sse.cpp create mode 100644 wip/simd/sse.h create mode 100644 wip/simd/sse_mat4.cpp create mode 100644 wip/simd/sse_mat4.h create mode 100644 wip/simd/sse_mat4array.cpp create mode 100644 wip/simd/sse_mat4array.h create mode 100644 wip/simd/sse_vec4.cpp create mode 100644 wip/simd/sse_vec4.h create mode 100644 wip/simd/sse_vec4array.cpp create mode 100644 wip/simd/sse_vec4array.h create mode 100644 wip/sse/glm/core/_bvec2.h create mode 100644 wip/sse/glm/core/_bvec2.inl create mode 100644 wip/sse/glm/core/_bvec3.h create mode 100644 wip/sse/glm/core/_bvec3.inl create mode 100644 wip/sse/glm/core/_bvec4.h create mode 100644 wip/sse/glm/core/_bvec4.inl create mode 100644 wip/sse/glm/core/_cvec2.h create mode 100644 wip/sse/glm/core/_cvec2.inl create mode 100644 wip/sse/glm/core/_cvec3.h create mode 100644 wip/sse/glm/core/_cvec3.inl create mode 100644 wip/sse/glm/core/_cvec4.h create mode 100644 wip/sse/glm/core/_cvec4.inl create mode 100644 wip/sse/glm/core/_cvecx.h create mode 100644 wip/sse/glm/core/_func.h create mode 100644 wip/sse/glm/core/_func.inl create mode 100644 wip/sse/glm/core/_swizzle.h create mode 100644 wip/sse/glm/core/_swizzle.inl create mode 100644 wip/sse/glm/core/_xmat2.h create mode 100644 wip/sse/glm/core/_xmat2.inl create mode 100644 wip/sse/glm/core/_xmat2x3.h create mode 100644 wip/sse/glm/core/_xmat2x3.inl create mode 100644 wip/sse/glm/core/_xmat2x4.h create mode 100644 wip/sse/glm/core/_xmat2x4.inl create mode 100644 wip/sse/glm/core/_xmat3.h create mode 100644 wip/sse/glm/core/_xmat3.inl create mode 100644 wip/sse/glm/core/_xmat3x2.h create mode 100644 wip/sse/glm/core/_xmat3x2.inl create mode 100644 wip/sse/glm/core/_xmat3x4.h create mode 100644 wip/sse/glm/core/_xmat3x4.inl create mode 100644 wip/sse/glm/core/_xmat4.h create mode 100644 wip/sse/glm/core/_xmat4.inl create mode 100644 wip/sse/glm/core/_xmat4x2.h create mode 100644 wip/sse/glm/core/_xmat4x2.inl create mode 100644 wip/sse/glm/core/_xmat4x3.h create mode 100644 wip/sse/glm/core/_xmat4x3.inl create mode 100644 wip/sse/glm/core/_xref2.h create mode 100644 wip/sse/glm/core/_xref2.inl create mode 100644 wip/sse/glm/core/_xref3.h create mode 100644 wip/sse/glm/core/_xref3.inl create mode 100644 wip/sse/glm/core/_xref4.h create mode 100644 wip/sse/glm/core/_xref4.inl create mode 100644 wip/sse/glm/core/_xvec2.h create mode 100644 wip/sse/glm/core/_xvec2.inl create mode 100644 wip/sse/glm/core/_xvec3.h create mode 100644 wip/sse/glm/core/_xvec3.inl create mode 100644 wip/sse/glm/core/_xvec4.h create mode 100644 wip/sse/glm/core/_xvec4.inl create mode 100644 wip/sse/glm/ext/gtx.h create mode 100644 wip/sse/glm/ext/gtx/associated_min_max.h create mode 100644 wip/sse/glm/ext/gtx/associated_min_max.inl create mode 100644 wip/sse/glm/ext/gtx/bit.h create mode 100644 wip/sse/glm/ext/gtx/bit.inl create mode 100644 wip/sse/glm/ext/gtx/closest_point.h create mode 100644 wip/sse/glm/ext/gtx/closest_point.inl create mode 100644 wip/sse/glm/ext/gtx/color_cast.h create mode 100644 wip/sse/glm/ext/gtx/color_cast.inl create mode 100644 wip/sse/glm/ext/gtx/color_space.h create mode 100644 wip/sse/glm/ext/gtx/color_space.inl create mode 100644 wip/sse/glm/ext/gtx/compatibility.h create mode 100644 wip/sse/glm/ext/gtx/compatibility.inl create mode 100644 wip/sse/glm/ext/gtx/component_wise.h create mode 100644 wip/sse/glm/ext/gtx/component_wise.inl create mode 100644 wip/sse/glm/ext/gtx/determinant.h create mode 100644 wip/sse/glm/ext/gtx/determinant.inl create mode 100644 wip/sse/glm/ext/gtx/double.h create mode 100644 wip/sse/glm/ext/gtx/double.inl create mode 100644 wip/sse/glm/ext/gtx/epsilon.h create mode 100644 wip/sse/glm/ext/gtx/epsilon.inl create mode 100644 wip/sse/glm/ext/gtx/euler_angles.h create mode 100644 wip/sse/glm/ext/gtx/euler_angles.inl create mode 100644 wip/sse/glm/ext/gtx/extend.h create mode 100644 wip/sse/glm/ext/gtx/extend.inl create mode 100644 wip/sse/glm/ext/gtx/extented_min_max.h create mode 100644 wip/sse/glm/ext/gtx/extented_min_max.inl create mode 100644 wip/sse/glm/ext/gtx/fast_exponential.h create mode 100644 wip/sse/glm/ext/gtx/fast_exponential.inl create mode 100644 wip/sse/glm/ext/gtx/fast_square_root.h create mode 100644 wip/sse/glm/ext/gtx/fast_square_root.inl create mode 100644 wip/sse/glm/ext/gtx/fast_trigonometry.h create mode 100644 wip/sse/glm/ext/gtx/fast_trigonometry.inl create mode 100644 wip/sse/glm/ext/gtx/flexible_mix.h create mode 100644 wip/sse/glm/ext/gtx/flexible_mix.inl create mode 100644 wip/sse/glm/ext/gtx/gpu_shader4.h create mode 100644 wip/sse/glm/ext/gtx/gpu_shader4.inl create mode 100644 wip/sse/glm/ext/gtx/half.h create mode 100644 wip/sse/glm/ext/gtx/half.inl create mode 100644 wip/sse/glm/ext/gtx/handed_coordinate_space.h create mode 100644 wip/sse/glm/ext/gtx/handed_coordinate_space.inl create mode 100644 wip/sse/glm/ext/gtx/hyperbolic.h create mode 100644 wip/sse/glm/ext/gtx/hyperbolic.inl create mode 100644 wip/sse/glm/ext/gtx/inertia.h create mode 100644 wip/sse/glm/ext/gtx/inertia.inl create mode 100644 wip/sse/glm/ext/gtx/integer.h create mode 100644 wip/sse/glm/ext/gtx/integer.inl create mode 100644 wip/sse/glm/ext/gtx/intersect.h create mode 100644 wip/sse/glm/ext/gtx/intersect.inl create mode 100644 wip/sse/glm/ext/gtx/inverse.h create mode 100644 wip/sse/glm/ext/gtx/inverse.inl create mode 100644 wip/sse/glm/ext/gtx/inverse_transpose.h create mode 100644 wip/sse/glm/ext/gtx/inverse_transpose.inl create mode 100644 wip/sse/glm/ext/gtx/mat4x3.h create mode 100644 wip/sse/glm/ext/gtx/mat4x3.inl create mode 100644 wip/sse/glm/ext/gtx/matrix_access.h create mode 100644 wip/sse/glm/ext/gtx/matrix_access.inl create mode 100644 wip/sse/glm/ext/gtx/matrix_cross_product.h create mode 100644 wip/sse/glm/ext/gtx/matrix_cross_product.inl create mode 100644 wip/sse/glm/ext/gtx/matrix_major_storage.h create mode 100644 wip/sse/glm/ext/gtx/matrix_major_storage.inl create mode 100644 wip/sse/glm/ext/gtx/matrix_projection.h create mode 100644 wip/sse/glm/ext/gtx/matrix_projection.inl create mode 100644 wip/sse/glm/ext/gtx/matrix_query.h create mode 100644 wip/sse/glm/ext/gtx/matrix_query.inl create mode 100644 wip/sse/glm/ext/gtx/matrix_selection.h create mode 100644 wip/sse/glm/ext/gtx/matrix_selection.inl create mode 100644 wip/sse/glm/ext/gtx/matx.h create mode 100644 wip/sse/glm/ext/gtx/matx.inl create mode 100644 wip/sse/glm/ext/gtx/mixed_product.h create mode 100644 wip/sse/glm/ext/gtx/mixed_product.inl create mode 100644 wip/sse/glm/ext/gtx/mul.h create mode 100644 wip/sse/glm/ext/gtx/mul.inl create mode 100644 wip/sse/glm/ext/gtx/norm.h create mode 100644 wip/sse/glm/ext/gtx/norm.inl create mode 100644 wip/sse/glm/ext/gtx/normal.h create mode 100644 wip/sse/glm/ext/gtx/normal.inl create mode 100644 wip/sse/glm/ext/gtx/normalize_dot.h create mode 100644 wip/sse/glm/ext/gtx/normalize_dot.inl create mode 100644 wip/sse/glm/ext/gtx/number_precision.h create mode 100644 wip/sse/glm/ext/gtx/number_precision.inl create mode 100644 wip/sse/glm/ext/gtx/optimum_pow.h create mode 100644 wip/sse/glm/ext/gtx/optimum_pow.inl create mode 100644 wip/sse/glm/ext/gtx/orthonormalize.h create mode 100644 wip/sse/glm/ext/gtx/orthonormalize.inl create mode 100644 wip/sse/glm/ext/gtx/outer_product.h create mode 100644 wip/sse/glm/ext/gtx/outer_product.inl create mode 100644 wip/sse/glm/ext/gtx/perpendicular.h create mode 100644 wip/sse/glm/ext/gtx/perpendicular.inl create mode 100644 wip/sse/glm/ext/gtx/polar_coordinates.h create mode 100644 wip/sse/glm/ext/gtx/polar_coordinates.inl create mode 100644 wip/sse/glm/ext/gtx/projection.h create mode 100644 wip/sse/glm/ext/gtx/projection.inl create mode 100644 wip/sse/glm/ext/gtx/quaternion.h create mode 100644 wip/sse/glm/ext/gtx/quaternion.inl create mode 100644 wip/sse/glm/ext/gtx/random.h create mode 100644 wip/sse/glm/ext/gtx/random.inl create mode 100644 wip/sse/glm/ext/gtx/rotate_vector.h create mode 100644 wip/sse/glm/ext/gtx/rotate_vector.inl create mode 100644 wip/sse/glm/ext/gtx/round.h create mode 100644 wip/sse/glm/ext/gtx/round.inl create mode 100644 wip/sse/glm/ext/gtx/spline.h create mode 100644 wip/sse/glm/ext/gtx/spline.inl create mode 100644 wip/sse/glm/ext/gtx/statistics_operation.h create mode 100644 wip/sse/glm/ext/gtx/statistics_operation.inl create mode 100644 wip/sse/glm/ext/gtx/transform.h create mode 100644 wip/sse/glm/ext/gtx/transform.inl create mode 100644 wip/sse/glm/ext/gtx/transform2.h create mode 100644 wip/sse/glm/ext/gtx/transform2.inl create mode 100644 wip/sse/glm/ext/gtx/transpose.h create mode 100644 wip/sse/glm/ext/gtx/transpose.inl create mode 100644 wip/sse/glm/ext/gtx/unsigned_int.h create mode 100644 wip/sse/glm/ext/gtx/unsigned_int.inl create mode 100644 wip/sse/glm/ext/gtx/vector_access.h create mode 100644 wip/sse/glm/ext/gtx/vector_access.inl create mode 100644 wip/sse/glm/ext/gtx/vector_angle.h create mode 100644 wip/sse/glm/ext/gtx/vector_angle.inl create mode 100644 wip/sse/glm/ext/gtx/vector_comp_mult.h create mode 100644 wip/sse/glm/ext/gtx/vector_comp_mult.inl create mode 100644 wip/sse/glm/ext/gtx/vector_query.h create mode 100644 wip/sse/glm/ext/gtx/vector_query.inl create mode 100644 wip/sse/glm/ext/gtx/vecx.h create mode 100644 wip/sse/glm/ext/gtx/vecx.inl create mode 100644 wip/sse/glm/ext/gtx/verbose_operator.h create mode 100644 wip/sse/glm/ext/gtx/verbose_operator.inl create mode 100644 wip/sse/glm/glm.h create mode 100644 wip/sse/glm/glmext.h create mode 100644 wip/sse/glm/glmsetup.h create mode 100644 wip/sse/main.cpp create mode 100644 wip/sse/precompiled.cpp create mode 100644 wip/sse/precompiled.h create mode 100644 wip/sse/rdtsc.cpp create mode 100644 wip/sse/rdtsc.h create mode 100644 wip/sse/sse.cpp create mode 100644 wip/sse/sse.h create mode 100644 wip/sse/sse.sln create mode 100644 wip/sse/sse.vcproj create mode 100644 wip/sse/sse_mat4.cpp create mode 100644 wip/sse/sse_mat4.h create mode 100644 wip/sse/sse_mat4array.cpp create mode 100644 wip/sse/sse_mat4array.h create mode 100644 wip/sse/sse_vec4.cpp create mode 100644 wip/sse/sse_vec4.h create mode 100644 wip/sse/sse_vec4array.cpp create mode 100644 wip/sse/sse_vec4array.h diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt new file mode 100644 index 00000000..e69de29b diff --git a/wip/half/half.cpp b/wip/half/half.cpp new file mode 100644 index 00000000..9c7c19b8 --- /dev/null +++ b/wip/half/half.cpp @@ -0,0 +1,4 @@ +#include "precompiled.h" +#include "half.h" + + diff --git a/wip/half/half.h b/wip/half/half.h new file mode 100644 index 00000000..52133950 --- /dev/null +++ b/wip/half/half.h @@ -0,0 +1,119 @@ +#ifndef __HALF_H__ +#define __HALF_H__ + +namespace dev +{ +/* namespace detail + { + class _halfGTX; + + struct hdata + { + hdata() : data(0) {} + hdata(const hdata& value); + //hdata(float value); + + hdata& operator=(_halfGTX s); + hdata& operator=(float s); + hdata& operator=(double s); + + //operator float(); + //operator const float() const; + + short data; + }; + + float _toFloat32(hdata value); + hdata _toFloat16(float value); + + union uif + { + int i; + float f; + }; + + class _halfGTX + { + public: + // Constructors + _halfGTX(); + _halfGTX(float s); + _halfGTX(double s); + _halfGTX(int s); + _halfGTX(bool s); + _halfGTX(detail::hdata value) : + data(value) + {} + + operator float() const; + operator double() const; + operator int() const; + operator detail::hdata() const; + + // Operators + _halfGTX& operator=(_halfGTX s); + _halfGTX& operator=(float s); + _halfGTX operator+ (_halfGTX s) const; + _halfGTX& operator+= (_halfGTX s); + _halfGTX operator+ (float s) const; + _halfGTX& operator+= (float s); + _halfGTX operator- (_halfGTX s) const; + _halfGTX& operator-= (_halfGTX s); + _halfGTX operator- (float s) const; + _halfGTX& operator-= (float s); + _halfGTX operator* (_halfGTX s) const; + _halfGTX& operator*= (_halfGTX s); + _halfGTX operator* (float s) const; + _halfGTX& operator*= (float s); + _halfGTX operator/ (_halfGTX s) const; + _halfGTX& operator/= (_halfGTX s); + _halfGTX operator/ (float s) const; + _halfGTX& operator/= (float s); + _halfGTX operator- () const; + _halfGTX operator++ (); + _halfGTX operator++ (int n) const; + _halfGTX operator-- (); + _halfGTX operator-- (int n) const; + + bool operator< (const _halfGTX& s) const; + bool operator> (const _halfGTX& s) const; + bool operator<=(const _halfGTX& s) const; + bool operator>=(const _halfGTX& s) const; + bool operator==(const _halfGTX& s) const; + bool operator!=(const _halfGTX& s) const; + + detail::hdata _data() const{return data;} + + private: + detail::hdata data; + }; + + class _hvec2GTX + { + public: + typedef _halfGTX value_type; + typedef int size_type; + static const size_type value_size; + + union + { + struct{detail::hdata x, y;}; + struct{detail::hdata r, g;}; + struct{detail::hdata s, t;}; + }; + + _hvec2GTX() + {} + + _hvec2GTX(const _halfGTX x, const _halfGTX y) : + x(x._data()), + y(y._data()) + {} + }; + } +*/ +} + +//#include "half.inl" + +#endif//__HALF_H__ diff --git a/wip/half/half.inl b/wip/half/half.inl new file mode 100644 index 00000000..e69de29b diff --git a/wip/half/half_test.cpp b/wip/half/half_test.cpp new file mode 100644 index 00000000..1e538674 --- /dev/null +++ b/wip/half/half_test.cpp @@ -0,0 +1,39 @@ +#include "precompiled.h" +#include "half_test.h" +#include "half.h" + +void test_hdata() +{ + //dev::detail::hdata HdataA(dev::detail::_toFloat16(1.0f)); + //dev::detail::hdata HdataB(dev::detail::_toFloat16(2.0f)); + //float FloatA = float(dev::detail::_toFloat32(HdataA) + dev::detail::_toFloat32(HdataB)); + //float FloatB = _toFloat32(HdataA) + _toFloat32(HdataB); + //float FloatC = _toFloat32(HdataA); + //float FloatD = _toFloat32(HdataB); + + //dev::detail::_halfGTX HalfA(HdataA); + //dev::detail::_halfGTX HalfB(HdataB); + //float FloatE = float(HalfA); + //float FloatF = float(HalfB); + //dev::detail::_halfGTX HalfC(FloatE); + //dev::detail::_halfGTX HalfD(FloatF); + //float FloatG = float(HalfC); + //float FloatH = float(HalfD); + + //dev::detail::_hvec2GTX hvec2A(HalfA, HalfB); + //dev::detail::_hvec2GTX hvec2B(HalfC, HalfD); + + //HdataA = HalfA; + //HdataB = 4.0f; + //HdataB = 4.0; + + //float FloatI = float(dev::detail::_halfGTX(HdataA)); + //float FloatJ = float(dev::detail::_halfGTX(HdataB)); + + int end = 0; +} + +void test_half_full() +{ + test_hdata(); +} diff --git a/wip/half/half_test.h b/wip/half/half_test.h new file mode 100644 index 00000000..5312d46e --- /dev/null +++ b/wip/half/half_test.h @@ -0,0 +1,6 @@ +#ifndef __HALF_TEST_H__ +#define __HALF_TEST_H__ + +void test_half_full(); + +#endif//__HALF_TEST_H__ diff --git a/wip/sign.cpp b/wip/sign.cpp new file mode 100644 index 00000000..709e7926 --- /dev/null +++ b/wip/sign.cpp @@ -0,0 +1,5 @@ +template <> +inline bool sign(float const & f) +{ + return (*((int *)(&f)) & 0x80000000) == 0; +} diff --git a/wip/simd/sse.cpp b/wip/simd/sse.cpp new file mode 100644 index 00000000..f68aaa32 --- /dev/null +++ b/wip/simd/sse.cpp @@ -0,0 +1,1378 @@ +#include "precompiled.h" +#include "sse.h" + +//namespace sse +//{ +// // some defines first +// union ieee754_QNAN +// { +// const float f; +// struct +// { +// const unsigned int mantissa:23, exp:8, sign:1; +// }; +// +// ieee754_QNAN() : f(0.0), mantissa(0x7FFFFF), exp(0xFF), sign(0x0) {} +// }; +// +// namespace detail +// { +// union ieee754 +// { +// ieee754() : +// f(0.0f) +// {} +// +// ieee754(float f) : +// f(f) +// {} +// +// ieee754(unsigned int mantissa, unsigned int exp, unsigned int sign) : +// mantissa(mantissa), exp(exp), sign(sign) +// {} +// +// float f; +// struct +// { +// unsigned int mantissa:23, exp:8, sign:1; +// }; +// }; +// +// _MM_ALIGN16 const ieee754 qnan(0x7FFFFF, 0xFF, 0x0); +// } +// +// float load(unsigned int mantissa, unsigned int exp, unsigned int sign) +// { +// sse::detail::ieee754 value(mantissa, exp, sign); +// return value.f; +// } +// +// _MM_ALIGN16 const sse::detail::ieee754 qnan(0x7FFFFF, 0xFF, 0x0); +// +// _MM_ALIGN16 const ieee754_QNAN absMask; +// //static const __m128 abs4Mask = _mm_load1_ps( &absMask.f); +// static const __m128 abs4Mask = _mm_set_ps1(absMask.f); +// +// __m128 _mm_neg_ps(__m128 v) +// { +// return _mm_sub_ps(_mm_setzero_ps(), v); +// } +// +// __m128 fast_pow(__m128 base, __m128 exponent) +// { +// __m128 denom = _mm_mul_ps( exponent, base); +// denom = _mm_sub_ps( exponent, denom); +// denom = _mm_add_ps( base, denom); +// return _mm_mul_ps( base, _mm_rcp_ps(denom)); +// } +// +// static const __m128 zero = _mm_setzero_ps(); +// static const __m128 one = _mm_set_ps1(1.0f); +// static const __m128 two = _mm_set_ps1(2.0f); +// static const __m128 pi = _mm_set_ps1(3.1415926535897932384626433832795f); +// static const __m128 hundred_eighty = _mm_set_ps1(180.f); +// static const __m128 pi_over_hundred_eighty = _mm_set_ps1(0.017453292519943295769236907684886f); +// static const __m128 hundred_eighty_over_pi = _mm_set_ps1(57.295779513082320876798154814105f); +// +// //vec4 radians(vec4 degrees) +// //{ +// // const float pi = float(3.1415926535897932384626433832795); +// // return degrees * (pi / 180.f); +// //} +// __m128 radians(__m128 degrees) +// { +// return _mm_mul_ps(degrees, pi_over_hundred_eighty); +// } +// +// __m128 _mm_rad_ss(__m128 degrees) +// { +// return _mm_mul_ss(degrees, pi_over_hundred_eighty); +// } +// +// __m128 _mm_rad_ps(__m128 degrees) +// { +// return _mm_mul_ps(degrees, pi_over_hundred_eighty); +// } +// +// //vec4 degrees(vec4 radians) +// //{ +// // const float pi = float(3.1415926535897932384626433832795); +// // return radians * (180.f / pi); +// //} +// __m128 degrees(__m128 radians) +// { +// return _mm_mul_ps(radians, hundred_eighty_over_pi); +// } +// +// __m128 _mm_deg_ss(__m128 radians) +// { +// return _mm_mul_ss(radians, hundred_eighty_over_pi); +// } +// +// __m128 _mm_deg_ps(__m128 radians) +// { +// return _mm_mul_ps(radians, hundred_eighty_over_pi); +// } +// +// //vec4 sqrt(vec4 v) +// //{ +// // return vec4(sqrt(v.x), sqrt(v.y), sqrt(v.z), sqrt(v.w)); +// //} +// __m128 sqrt(__m128 v) +// { +// return _mm_sqrt_ps(v); +// } +// +// //vec4 inversesqrt(vec4 x) +// //{ +// // return vec4(1.0f) / sqrt(x); +// //} +// __m128 inversesqrt(__m128 v) +// { +// return _mm_rsqrt_ps(v); +// } +// +// //vec4 abs(vec4 x) +// //{ +// // return x >= T(0) ? x : -x; +// //} +// __m128 abs(__m128 x) +// { +// return _mm_and_ps(abs4Mask, x); +// } +// +// //__m128 _mm_abs_ss(__m128 x) +// //{ +// // return _mm_and_ss(abs4Mask, x); +// //} +// +// __m128 _mm_abs_ps(__m128 x) +// { +// return _mm_and_ps(abs4Mask, x); +// } +// +// //vec4 sign(vec4 x) +// //{ +// // vec4 result; +// // if(x > vec4(0)) +// // result = vec4(1); +// // else if(x < T(0)) +// // result = vec4(-1); +// // else +// // result = vec4(0); +// // return result; +// //} +// __m128 sign(__m128 x) +// { +// __m128 result; +// __m128 cmp0 = _mm_cmpeq_ps(x, zero); +// if(_mm_movemask_ps(cmp0) == 0) +// result = zero; +// else +// { +// __m128 cmp1 = _mm_cmpge_ps(x, zero); +// //__m128 cmp2 = _mm_cmple_ps(x, zero); +// if(_mm_movemask_ps(cmp1) > 0) +// result = one; +// else //if(_mm_movemask_ps(cmp2) > 0) +// result = minus_one; +// } +// return result; +// } +// +// __m128 _mm_sgn_ss(__m128 x) +// { +// __m128 result; +// __m128 cmp0 = _mm_cmpeq_ss(x, zero); +// if(_mm_movemask_ss(cmp0) == 0) +// result = zero; +// else +// { +// __m128 cmp1 = _mm_cmpge_ss(x, zero); +// //__m128 cmp2 = _mm_cmple_ss(x, zero); +// if(_mm_movemask_ss(cmp1) > 0) +// result = one; +// else //if(_mm_movemask_ss(cmp2) > 0) +// result = minus_one; +// } +// return result; +// } +// +// __m128 _mm_sgn_ps(__m128 x) +// { +// __m128 cmp0 = _mm_cmpeq_ps(x, zero); +// __m128 cmp1 = _mm_cmple_ps(x, zero); +// __m128 cmp2 = _mm_cmpge_ps(x, zero) +// +// __m128 result; +// __m128 cmp0 = _mm_cmpeq_ps(x, zero); +// if(_mm_movemask_ps(cmp0) == 0) +// result = zero; +// else +// { +// __m128 cmp1 = _mm_cmpge_ps(x, zero); +// //__m128 cmp2 = _mm_cmple_ps(x, zero); +// if(_mm_movemask_ps(cmp1) > 0) +// result = one; +// else //if(_mm_movemask_ps(cmp2) > 0) +// result = minus_one; +// } +// return result; +// } +// +// //vec4 floor(vec4 x) +// //{ +// // return ::std::floor(x); +// //} +// +// __m128 floor(__m128 v) +// { +// +// } +// +// __m128 _mm_flr_ss(__m128 v) +// { +// +// } +// +// __m128 _mm_flr_ps(__m128 v) +// { +// +// } +// +// //vec4 ceil(vec4 x) +// //{ +// // return ::std::ceil(vec4); +// //} +// +// +// +// //vec4 fract(vec4 x) +// //{ +// // return x - floor(x); +// //} +// __m128 fract(__m128 x) +// { +// __m128 flr0 = floor(x); +// __m128 sub0 = _mm_sub_ps(x, flr0); +// return sub0; +// } +// +// __m128 _mm_frc_ss(__m128 x) +// { +// __m128 flr0 = _mm_flr_ss(x); +// __m128 sub0 = _mm_sub_ss(x, flr0); +// return sub0; +// } +// +// __m128 _mm_frc_ps(__m128 x) +// { +// __m128 flr0 = _mm_flr_ps(x); +// __m128 sub0 = _mm_sub_ps(x, flr0); +// return sub0; +// } +// +// //vec4 mod(vec4 x, vec4 y) +// //{ +// // return x - y * floor(x / y); +// //} +// __m128 mod(__m128 x, __m128 y) +// { +// __m128 div0 = _mm_div_ps(x, y); +// __m128 flr0 = _mm_flr_ps(div0); +// __m128 mul0 = _mm_mul_ps(y, flr0); +// __m128 sub0 = _mm_sub_ps(x, mul0); +// return sub0; +// } +// +// __m128 _mm_mod_ss(__m128 x, __m128 y) +// { +// __m128 div0 = _mm_div_ss(x, y); +// __m128 flr0 = _mm_flr_ss(div0); +// __m128 mul0 = _mm_mul_ss(y, flr0); +// __m128 sub0 = _mm_sub_ss(x, mul0); +// return sub0; +// } +// +// __m128 _mm_mod_ps(__m128 x, __m128 y) +// { +// __m128 div0 = _mm_div_ps(x, y); +// __m128 flr0 = _mm_flr_ps(div0); +// __m128 mul0 = _mm_mul_ps(y, flr0); +// __m128 sub0 = _mm_sub_ps(x, mul0); +// return sub0; +// } +// +// //vec4 min(vec4 x, vec4 y) +// //{ +// // return x < y ? x : y; +// //} +// __m128 min(__m128 v1, __m128 v2) +// { +// return _mm_min_ps(v1, v2); +// } +// +// //vec4 max(vec4 x, vec4 y) +// //{ +// // return x > y ? x : y; +// //} +// __m128 max(__m128 v1, __m128 v2) +// { +// return _mm_max_ps(v1, v2); +// } +// +// //vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal) +// //{ +// // return max(min(v, maxVal), minVal); +// //} +// __m128 clamp(__m128 v, __m128 minVal, __m128 maxVal) +// { +// return _mm_max_ps(_mm_min_ps(v, maxVal), minVal); +// } +// +// __m128 _mm_clp_ss(__m128 v, __m128 minVal, __m128 maxVal) +// { +// __m128 min0 = _mm_min_ss(v, maxVal); +// __m128 max0 = _mm_max_ss(min0, minVal); +// return max0; +// } +// +// __m128 _mm_clp_ps(__m128 v, __m128 minVal, __m128 maxVal) +// { +// __m128 min0 = _mm_min_ps(v, maxVal); +// __m128 max0 = _mm_max_ps(min0, minVal); +// return max0; +// } +// +// //vec4 mix(vec4 x, vec4 y, vec4 a) +// //{ +// // return x * (vec4(1) - a) + y * a; +// //} +// __m128 mix(__m128 v1, __m128 v2, __m128 a) +// { +// __m128 sub0 = _mm_sub_ps(one, a); +// __m128 mul0 = _mm_mul_ps(v1, sub0); +// __m128 mul1 = _mm_mul_ps(v2, a); +// __m128 add0 = _mm_add_ps(mul0, mul1); +// return add0; +// } +// +// __m128 _mm_lerp_ss(__m128 v1, __m128 v2, __m128 a) +// { +// __m128 sub0 = _mm_sub_ss(one, a); +// __m128 mul0 = _mm_mul_ss(v1, sub0); +// __m128 mul1 = _mm_mul_ss(v2, a); +// __m128 add0 = _mm_add_ss(mul0, mul1); +// return add0; +// } +// +// __m128 _mm_lerp_ps(__m128 v1, __m128 v2, __m128 a) +// { +// __m128 sub0 = _mm_sub_ps(one, a); +// __m128 mul0 = _mm_mul_ps(v1, sub0); +// __m128 mul1 = _mm_mul_ps(v2, a); +// __m128 add0 = _mm_add_ps(mul0, mul1); +// return add0; +// } +// +// //vec4 step(vec4 edge, vec4 x) +// //{ +// // return x <= edge ? vec4(0) : vec4(1); +// //} +// __m128 step(__m128 edge, __m128 x) +// { +// __m128 cmp = _mm_cmple_ps(x, edge); +// if(_mm_movemask_ps(cmp) == 0) +// return one; +// else +// return zero; +// } +// +// __m128 _mm_step_ss(__m128 edge, __m128 x) +// { +// __m128 cmp = _mm_cmple_ss(x, edge); +// if(_mm_movemask_ss(cmp) == 0) +// return one; +// else +// return zero; +// } +// +// __m128 _mm_step_ps(__m128 edge, __m128 x) +// { +// __m128 cmp = _mm_cmple_ps(x, edge); +// if(_mm_movemask_ps(cmp) == 0) +// return one; +// else +// return zero; +// } +// +// //vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x) +// //{ +// // vec4 tmp = clamp((x - edge0) / (edge1 - edge0), vec4(0), vec4(1)); +// // return tmp * tmp * (vec4(3) - vec4(2) * tmp); +// //} +// __m128 smoothstep(__m128 edge0, __m128 edge1, __m128 x) +// { +// __m128 sub0 = _mm_sub_ps(x, edge0); +// __m128 sub1 = _mm_sub_ps(edge1, edge0); +// __m128 div0 = _mm_sub_ps(sub0, sub1); +// __m128 clp0 = _mm_clp_ps(div0, zero, one); +// __m128 mul0 = _mm_mul_ps(two, clp0); +// __m128 sub2 = _mm_sub_ps(three, mul0); +// __m128 mul1 = _mm_mul_ps(clp0, clp0); +// __m128 mul2 = _mm_mul_ps(mul1, sub2); +// return mul2; +// } +// +// __m128 _mm_ssp_ss(__m128 edge0, __m128 edge1, __m128 x) +// { +// __m128 sub0 = _mm_sub_ss(x, edge0); +// __m128 sub1 = _mm_sub_ss(edge1, edge0); +// __m128 div0 = _mm_sub_ss(sub0, sub1); +// __m128 clp0 = _mm_clp_ss(div0, zero, one); +// __m128 mul0 = _mm_mul_ss(two, clp0); +// __m128 sub2 = _mm_sub_ss(three, mul0); +// __m128 mul1 = _mm_mul_ss(clp0, clp0); +// __m128 mul2 = _mm_mul_ss(mul1, sub2); +// return mul2; +// } +// +// __m128 _mm_ssp_ps(__m128 edge0, __m128 edge1, __m128 x) +// { +// __m128 sub0 = _mm_sub_ps(x, edge0); +// __m128 sub1 = _mm_sub_ps(edge1, edge0); +// __m128 div0 = _mm_sub_ps(sub0, sub1); +// __m128 clp0 = _mm_clp_ps(div0, zero, one); +// __m128 mul0 = _mm_mul_ps(two, clp0); +// __m128 sub2 = _mm_sub_ps(three, mul0); +// __m128 mul1 = _mm_mul_ps(clp0, clp0); +// __m128 mul2 = _mm_mul_ps(mul1, sub2); +// return mul2; +// } +// +// //float length(vec4 x) +// //{ +// // float sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; +// // return sqrt(sqr); +// //} +// __m128 length(__m128 x) +// { +// __m128 dot0 = dot(x, x); +// __m128 sqt0 = _mm_sqrt_ps(dot0); +// return sqt0; +// } +// +// __m128 _mm_len_ss(__m128 x) +// { +// __m128 dot0 = _mm_dot_ss(x, x); +// __m128 sqt0 = _mm_sqrt_ss(dot0); +// return sqt0; +// } +// +// __m128 _mm_len_ps(__m128 x) +// { +// __m128 dot0 = _mm_dot_ps(x, x); +// __m128 sqt0 = _mm_sqrt_ps(dot0); +// return sqt0; +// } +// +// //float distance(vec4 p0, vec4 p1) +// //{ +// // return length(p1 - p0); +// //} +// __m128 distance(__m128 p0, __m128 p1) +// { +// __m128 sub0 = _mm_sub_ps(p0, p1); +// __m128 len0 = _mm_len_ps(sub0); +// return len0; +// } +// +// __m128 _mm_dst_ss(__m128 p0, __m128 p1) +// { +// __m128 sub0 = _mm_sub_ps(p0, p1); +// __m128 len0 = _mm_len_ps(sub0); +// return len0; +// } +// +// __m128 _mm_dst_ps(__m128 p0, __m128 p1) +// { +// __m128 sub0 = _mm_sub_ps(p0, p1); +// __m128 len0 = _mm_len_ps(sub0); +// return len0; +// } +// +// //vec4 dot(vec4 x, vec4 y) +// //{ +// // return vec4(x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w); +// //} +// __m128 dot(__m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v1, v2); +// __m128 swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1)); +// __m128 add0 = _mm_add_ps(mul0, swp0); +// __m128 swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3)); +// __m128 add1 = _mm_add_ps(add0, swp1); +// return add1; +// } +// +// __m128 _mm_dot_ss(__m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v1, v2); +// __m128 swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1)); +// __m128 add0 = _mm_add_ps(mul0, swp0); +// __m128 swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3)); +// __m128 add1 = _mm_add_ps(add0, swp1); +// return add1; +// } +// +// __m128 _mm_dot_ps(__m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v1, v2); +// __m128 swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1)); +// __m128 add0 = _mm_add_ps(mul0, swp0); +// __m128 swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3)); +// __m128 add1 = _mm_add_ps(add0, swp1); +// return add1; +// } +// +// //vec3 cross(vec3 x, vec3 y) +// //{ +// // return vec3( +// // x.y * y.z - y.y * x.z, +// // x.z * y.x - y.z * x.x, +// // x.x * y.y - y.x * x.y); +// //} +// __m128 cross(__m128 v1, __m128 v2) +// { +// __m128 swp0 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp1 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 swp2 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp3 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 mul0 = _mm_mul_ps(swp0, swp3); +// __m128 mul1 = _mm_mul_ps(swp1, swp2); +// __m128 sub0 = _mm_sub_ps(mul0, mul1); +// return sub0; +// } +// +// __m128 _mm_xpd_ps(__m128 v1, __m128 v2) +// { +// __m128 swp0 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp1 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 swp2 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp3 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 mul0 = _mm_mul_ps(swp0, swp3); +// __m128 mul1 = _mm_mul_ps(swp1, swp2); +// __m128 sub0 = _mm_sub_ps(mul0, mul1); +// return sub0; +// } +// +// //vec4 normalize(vec4 x) +// //{ +// // float sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; +// // return x * inversesqrt(sqr); +// //} +// __m128 normalize(__m128 v) +// { +// __m128 dot0 = dot(v, v); +// __m128 isr0 = _mm_rsqrt_ps(dot0); +// __m128 mul0 = _mm_mul_ps(v, isr0); +// return mul0; +// } +// +// __m128 _mm_nrm_ps(__m128 v) +// { +// __m128 dot0 = dot(v, v); +// __m128 isr0 = _mm_rsqrt_ps(dot0); +// __m128 mul0 = _mm_mul_ps(v, isr0); +// return mul0; +// } +// +// __m128 rcp(__m128 v) +// { +// return _mm_rcp_ps(v); +// } +// +// //vec4 mad(vec4 v0, vec4 v1, vec4 v2) +// //{ +// // return v0 * v1 + v2; +// //} +// __m128 mad(__m128 v0, __m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v0, v1); +// __m128 add0 = _mm_add_ps(mul0, v2); +// return add0; +// } +// +// __m128 _mm_mad_ss(__m128 v0, __m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ss(v0, v1); +// __m128 add0 = _mm_add_ss(mul0, v2); +// return add0; +// } +// +// __m128 _mm_mad_ps(__m128 v0, __m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v0, v1); +// __m128 add0 = _mm_add_ps(mul0, v2); +// return add0; +// } +// +// //vec4 reflect(vec4 I, vec4 N) +// //{ +// // return I - N * dot(N, I) * 2.0f; +// //} +// __m128 reflect(__m128 I, __m128 N) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(N, I); +// __m128 mul1 = _mm_mul_ps(mul0, two); +// __m128 sub0 = _mm_sub_ps(I, mul1); +// return sub0; +// } +// +// __m128 _mm_rfe_ps(__m128 I, __m128 N) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(N, I); +// __m128 mul1 = _mm_mul_ps(mul0, two); +// __m128 sub0 = _mm_sub_ps(I, mul1); +// return sub0; +// } +// +// //vec4 refract(vec4 I, vec4 N, T eta) +// //{ +// // float dotValue = dot(N, I); +// // float k = 1.0f - eta * eta * (1.0f - dotValue * dotValue); +// // if(k < 0.0f) +// // return vec4(0.0f); +// // return eta * I - (eta * dotValue + sqrt(k)) * N; +// //} +// __m128 refract(__m128 I, __m128 N, __m128 eta) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(eta, eta); +// __m128 mul1 = _mm_mul_ps(dot0, dot0); +// __m128 sub0 = _mm_sub_ps(one, mul0); +// __m128 sub1 = _mm_sub_ps(one, mul1); +// __m128 mul2 = _mm_mul_ps(sub0, sub1); +// +// if(_mm_movemask_ps(_mm_cmplt_ss(mul2, zero)) == 0) +// return zero; +// +// __m128 sqt0 = _mm_sqrt_ps(mul2); +// __m128 mul3 = _mm_mul_ps(eta, dot0); +// __m128 add0 = _mm_add_ps(mul3, sqt0); +// __m128 mul4 = _mm_mul_ps(add0, N); +// __m128 mul5 = _mm_mul_ps(eta, I); +// __m128 sub2 = _mm_sub_ps(mul5, mul4); +// +// return sub2; +// } +// +// __m128 _mm_rfa_ps(__m128 I, __m128 N, __m128 eta) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(eta, eta); +// __m128 mul1 = _mm_mul_ps(dot0, dot0); +// __m128 sub0 = _mm_sub_ps(one, mul0); +// __m128 sub1 = _mm_sub_ps(one, mul1); +// __m128 mul2 = _mm_mul_ps(sub0, sub1); +// +// if(_mm_movemask_ps(_mm_cmplt_ss(mul2, zero)) == 0) +// return zero; +// +// __m128 sqt0 = _mm_sqrt_ps(mul2); +// __m128 mul3 = _mm_mul_ps(eta, dot0); +// __m128 add0 = _mm_add_ps(mul3, sqt0); +// __m128 mul4 = _mm_mul_ps(add0, N); +// __m128 mul5 = _mm_mul_ps(eta, I); +// __m128 sub2 = _mm_sub_ps(mul5, mul4); +// +// return sub2; +// } +// +// +// struct vec4; +// typedef const vec4& vec4_param; +// +// template +// class comp +// { +// public: +// comp(int i) : +// index(i) +// { +// assert(i < N && i >= 0); +// } +// +// operator const int() const{return index;} +// +// private: +// int index; +// }; +// +// typedef comp<4> comp4_t; +// +// struct vec4 +// { +// vec4(); +// vec4(float s); +// vec4(float x, float y, float z, float w); +// vec4(float v[4]); +// +// explicit vec4(__m128 data); +// +// vec4& operator= (vec4_param v); +// vec4& operator+=(float s); +// vec4& operator+=(vec4_param v); +// vec4& operator-=(float s); +// vec4& operator-=(vec4_param v); +// vec4& operator*=(float s); +// vec4& operator*=(vec4_param v); +// vec4& operator/=(float s); +// vec4& operator/=(vec4_param v); +// vec4& operator++(); +// vec4& operator--(); +// +// union +// { +// __m128 data; +// struct{float x, y, z, w;}; +// float array[4]; +// }; +// }; +// +// vec4::vec4() : +// data(_mm_setzero_ps()) +// {} +// +// vec4::vec4(float s) : +// data(_mm_load_ps1(&s)) +//// data(_mm_set_ps1(s)) +// {} +// +// vec4::vec4(float v[4]) : +// data(_mm_load_ps(v)) +// {} +// +// vec4::vec4(float x, float y, float z, float w) : +//// data(_mm_setr_ps(x, y, z, w)) +// data(_mm_set_ps(w, z, y, x)) +// {} +// +// vec4::vec4(__m128 data) : +// data(data) +// {} +// +// vec4& vec4::operator= (vec4_param v) +// { +// this->data = v.data; +// return *this; +// } +// +// vec4& vec4::operator+=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_add_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator+=(vec4_param v) +// { +// this->data = _mm_add_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator-=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_sub_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator-=(vec4_param v) +// { +// this->data = _mm_sub_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator*=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_mul_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator*=(vec4_param v) +// { +// this->data = _mm_mul_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator/=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_div_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator/=(vec4_param v) +// { +// this->data = _mm_div_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator++() +// { +// static __m128 inc = _mm_set_ps1(1.0f); +// this->data = _mm_add_ps(this->data , inc); +// return *this; +// } +// +// vec4& vec4::operator--() +// { +// static __m128 inc = _mm_set_ps1(1.0f); +// this->data = _mm_sub_ps(this->data , inc); +// return *this; +// } +// +// vec4 operator+ (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_add_ps(v1.data , v2.data)); +// } +// +// vec4 operator+ (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_add_ps(v1.data , v2.data)); +// } +// +// vec4 operator+ (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_add_ps(v1.data , v2.data)); +// } +// +// vec4 operator- (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_sub_ps(v1.data , v2.data)); +// } +// +// vec4 operator- (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_sub_ps(v1.data , v2.data)); +// } +// +// vec4 operator- (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_sub_ps(v1.data , v2.data)); +// } +// +// vec4 operator* (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_mul_ps(v1.data , v2.data)); +// } +// +// vec4 operator* (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_mul_ps(v1.data , v2.data)); +// } +// +// vec4 operator* (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_mul_ps(v1.data , v2.data)); +// } +// +// vec4 operator/ (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_div_ps(v1.data , v2.data)); +// } +// +// vec4 operator/ (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_div_ps(v1.data , v2.data)); +// } +// +// vec4 operator/ (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_div_ps(v1.data , v2.data)); +// } +// +// vec4 load(const vec4& v, const comp4_t component) +// { +// switch(component) +// { +// default: +// case 3: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(0, 0, 0, 0))); +// case 2: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(1, 1, 1, 1))); +// case 1: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(2, 2, 2, 2))); +// case 0: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(3, 3, 3, 3))); +// } +// } +// +// vec4 rcp(vec4_param v) +// { +// return vec4(_mm_rcp_ps(v.data)); +// } +// +// vec4 sqrt(vec4_param v) +// { +// return vec4(_mm_sqrt_ps(v.data)); +// } +// +// vec4 inversesqrt(vec4_param v) +// { +// return vec4(_mm_rsqrt_ps(v.data)); +// } +// +// vec4 min(vec4_param v1, vec4_param v2) +// { +// return vec4(_mm_min_ps(v1.data, v2.data)); +// } +// +// vec4 max(vec4_param v1, vec4_param v2) +// { +// return vec4(_mm_max_ps(v1.data, v2.data)); +// } +// +// vec4 clamp(vec4_param v, float minVal, float maxVal) +// { +// vec4 v1(minVal); +// vec4 v2(maxVal); +// return vec4(_mm_min_ps(_mm_max_ps(v.data, v2.data), v1.data)); +// } +// +// vec4 clamp(vec4_param v, vec4_param minVal, vec4_param maxVal) +// { +// return vec4(_mm_min_ps(_mm_max_ps(v.data, maxVal.data), minVal.data)); +// } +// +// vec4 mix(vec4_param x, vec4_param y, vec4_param a) +// { +// __m128 one = _mm_set_ps1(1.0f); +// __m128 b = _mm_sub_ps(one, a.data); +// __m128 mul1 = _mm_mul_ps(x.data, b); +// __m128 mul2 = _mm_mul_ps(y.data, a.data); +// __m128 addFinal = _mm_add_ps(mul1, mul2); +// return vec4(addFinal); +// +// +//// __m128 b = _mm_sub_ps(_mm_set_ps1(1.0f), a.data); +//// return vec4(_mm_add_ps(_mm_mul_ps(x.data, b), _mm_mul_ps(y.data, a.data))); +// } +// +// float dot(vec4_param x, vec4_param y) +// { +// float result = 0.0f; +// _mm_store_ss(&result, dot(x.data, y.data)); +// return result; +// } +// +// vec4 reflect(vec4_param I, vec4_param N) +// { +// __m128 Normal = N.data; +// __m128 Inc = I.data; +// __m128 Two = _mm_set_ps1(2.0f); +// __m128 Mul = _mm_mul_ps(Normal, dot(Normal, Inc)); +// return vec4(_mm_sub_ps(Inc, _mm_mul_ps(Mul, Two))); +// } +// +// vec4 refract(vec4_param I, vec4_param N, float eta) +// { +// __m128 zero = _mm_set_ps1(0.0f); +// __m128 eta1 = _mm_set_ps1(eta); +// __m128 eta2 = _mm_mul_ps(eta1, eta1); +// __m128 one = _mm_set_ps1(1.0f); +// __m128 dotValue = dot(I.data, N.data); +// __m128 dotValue2 = _mm_mul_ps(dotValue, dotValue); +// __m128 k = _mm_sub_ps(one, _mm_mul_ps(eta2, _mm_sub_ps(one, dotValue2))); +// __m128 isnull = _mm_cmplt_ss(k, zero); +// if(_mm_movemask_ps(isnull) == 0) +// return vec4(zero); +// else +// { +// __m128 temp0 = _mm_add_ps(_mm_mul_ps(eta1, dotValue), sqrt(k)); +// __m128 temp1 = _mm_shuffle_ps(temp0, temp0, _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 temp2 = _mm_mul_ps(temp1, N.data); +// __m128 temp3 = _mm_mul_ps(eta1, I.data); +// return vec4(_mm_sub_ps(temp3, temp2)); +// } +// } +// +// +//}; +// +//namespace glm +//{ +// glm::vec4 rcp(const glm::vec4& v) +// { +// return 1.0f / v; +// } +//} +// +//namespace cpu +//{ +// void sincos(float a, float &s, float &c) +// { +// _asm +// { +// fld a +// fsincos +// mov ecx, c +// mov edx, s +// fstp dword ptr [ecx] +// fstp dword ptr [edx] +// } +// } +// +// void sincos(double a, double& s, double& c) +// { +// _asm +// { +// fld a +// fsincos +// mov ecx, c +// mov edx, s +// fstp qword ptr [ecx] +// fstp qword ptr [edx] +// } +// } +// +// float sin(float s) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s +// fsin +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// +// //float result = 0.0f; +// //_asm +// //{ +// // fld s +// // fsin +// // mov ecx, result +// // fstp dword ptr [ecx] +// //} +// //return result; +// } +// +// float abs(float s) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s +// fabs +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// +// //float result = 0.0f; +// //_asm +// //{ +// // fld s +// // fsin +// // mov ecx, result +// // fstp dword ptr [ecx] +// //} +// //return result; +// } +// +// float add(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fadd +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +// +// float sub(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fsub +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +// +// float mul(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fmul +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +// +// float div(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fdiv +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +//} +// +//void test_asm() +//{ +// float sin0 = cpu::sin(1.0f); +// float sin1 = glm::sin(1.0f); +// float add0 = cpu::add(1.0f, 2.0f); +// float sub0 = cpu::sub(1.0f, 2.0f); +// +// +// float end = 1.0f; +//} +// +//void test_clamp() +//{ +// sse::vec4 v(0.5f, 0.5f, 9.5f, 9.5f); +// sse::vec4 minVal(1.0f, 2.0f, 3.0f, 4.0f); +// sse::vec4 maxVal(5.0f, 6.0f, 7.0f, 8.0f); +// +// __m128 clamp0 = sse::clamp( +// v.data, +// minVal.data, +// maxVal.data); +// +// glm::vec4 clamp1 = glm::clamp( +// glm::vec4(0.5f, 0.5f, 9.5f, 9.5f), +// glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), +// glm::vec4(5.0f, 6.0f, 7.0f, 8.0f)); +// +// __m128 end = _mm_setzero_ps(); +//} +// +//#define DECLARE_EPI32_CONST(name) \ +// extern const _MM_ALIGN16 int _epi32_##name[4]; +//#define IMPLEMENT_EPI32_CONST(name,x) \ +// const _MM_ALIGN16 int _epi32_##name[4]={x,x,x,x}; +//#define IMPLEMENT_EPI32_CONST4(name,x,y,z,w) \ +// const _MM_ALIGN16 int _epi32_##name[4]={w,z,y,x}; +// +//#define DECLARE_PS_CONST(name) \ +// extern const _MM_ALIGN16 float _ps_##name[4]; +//#define IMPLEMENT_PS_CONST(name,x) \ +// const _MM_ALIGN16 float _ps_##name[4]={x,x,x,x}; +//#define IMPLEMENT_PS_CONST4(name,x,y,z,w) \ +// const _MM_ALIGN16 float _ps_##name[4]={w,z,y,x}; +// +////IMPLEMENT_PS_CONST(sincos_p0, 0.15707963267948963959e1f) +////IMPLEMENT_PS_CONST(sincos_p1, -0.64596409750621907082e0f) +////IMPLEMENT_PS_CONST(sincos_p2, 0.7969262624561800806e-1f) +////IMPLEMENT_PS_CONST(sincos_p3, -0.468175413106023168e-2f) +// +//IMPLEMENT_EPI32_CONST(sign_mask,0x80000000) +//IMPLEMENT_EPI32_CONST(inv_sign_mask,0x7FFFFFFF) +//IMPLEMENT_EPI32_CONST(mant_mask,0x7F800000) +//IMPLEMENT_EPI32_CONST(inv_mant_mask,0x807FFFFF) +//IMPLEMENT_EPI32_CONST(min_norm_pos,0x00800000) +//IMPLEMENT_EPI32_CONST(1,1) +//IMPLEMENT_EPI32_CONST(2,2) +//IMPLEMENT_EPI32_CONST(7,7) +//IMPLEMENT_EPI32_CONST(127,127) +//IMPLEMENT_EPI32_CONST(ninf,0xFF800000) +//IMPLEMENT_EPI32_CONST(pinf,0x7F800000) +// +//IMPLEMENT_PS_CONST(1_3,0.33333333333333333333333333333333f) +//IMPLEMENT_PS_CONST(0p5,0.5f) +//IMPLEMENT_PS_CONST(1,1.0f) +//IMPLEMENT_PS_CONST(m1,-1.0f) +//IMPLEMENT_PS_CONST(2,2.0f) +//IMPLEMENT_PS_CONST(3,3.0f) +//IMPLEMENT_PS_CONST(127,127.0f) +//IMPLEMENT_PS_CONST(255,255.0f) +//IMPLEMENT_PS_CONST(2pow23,8388608.0f) +// +//IMPLEMENT_PS_CONST4(1_0_0_0,1.0f,0.0f,0.0f,0.0f) +//IMPLEMENT_PS_CONST4(0_1_0_0,0.0f,1.0f,0.0f,0.0f) +//IMPLEMENT_PS_CONST4(0_0_1_0,0.0f,0.0f,1.0f,0.0f) +//IMPLEMENT_PS_CONST4(0_0_0_1,0.0f,0.0f,0.0f,1.0f) +// +//IMPLEMENT_PS_CONST(pi, 3.1415926535897932384626433832795f) +//IMPLEMENT_PS_CONST(pi2, 6.283185307179586476925286766560f) +//IMPLEMENT_PS_CONST(2_pi, 0.63661977236758134307553505349006f) +//IMPLEMENT_PS_CONST(pi_2, 1.5707963267948966192313216916398f) +//IMPLEMENT_PS_CONST(4_pi, 1.2732395447351626861510701069801f) +//IMPLEMENT_PS_CONST(pi_4, 0.78539816339744830961566084581988f) +// +//IMPLEMENT_PS_CONST(sincos_p0, 0.15707963267948963959e1f) +//IMPLEMENT_PS_CONST(sincos_p1, -0.64596409750621907082e0f) +//IMPLEMENT_PS_CONST(sincos_p2, 0.7969262624561800806e-1f) +//IMPLEMENT_PS_CONST(sincos_p3, -0.468175413106023168e-2f) +//IMPLEMENT_PS_CONST(tan_p0, -1.79565251976484877988e7f) +//IMPLEMENT_PS_CONST(tan_p1, 1.15351664838587416140e6f) +//IMPLEMENT_PS_CONST(tan_p2, -1.30936939181383777646e4f) +//IMPLEMENT_PS_CONST(tan_q0, -5.38695755929454629881e7f) +//IMPLEMENT_PS_CONST(tan_q1, 2.50083801823357915839e7f) +//IMPLEMENT_PS_CONST(tan_q2, -1.32089234440210967447e6f) +//IMPLEMENT_PS_CONST(tan_q3, 1.36812963470692954678e4f) +//IMPLEMENT_PS_CONST(tan_poleval,3.68935e19f) +//IMPLEMENT_PS_CONST(atan_t0, -0.91646118527267623468e-1f) +//IMPLEMENT_PS_CONST(atan_t1, -0.13956945682312098640e1f) +//IMPLEMENT_PS_CONST(atan_t2, -0.94393926122725531747e2f) +//IMPLEMENT_PS_CONST(atan_t3, 0.12888383034157279340e2f) +//IMPLEMENT_PS_CONST(atan_s0, 0.12797564625607904396e1f) +//IMPLEMENT_PS_CONST(atan_s1, 0.21972168858277355914e1f) +//IMPLEMENT_PS_CONST(atan_s2, 0.68193064729268275701e1f) +//IMPLEMENT_PS_CONST(atan_s3, 0.28205206687035841409e2f) +// +//IMPLEMENT_PS_CONST(exp_hi, 88.3762626647949f) +//IMPLEMENT_PS_CONST(exp_lo, -88.3762626647949f) +//IMPLEMENT_PS_CONST(exp_rln2, 1.4426950408889634073599f) +//IMPLEMENT_PS_CONST(exp_p0, 1.26177193074810590878e-4f) +//IMPLEMENT_PS_CONST(exp_p1, 3.02994407707441961300e-2f) +//IMPLEMENT_PS_CONST(exp_q0, 3.00198505138664455042e-6f) +//IMPLEMENT_PS_CONST(exp_q1, 2.52448340349684104192e-3f) +//IMPLEMENT_PS_CONST(exp_q2, 2.27265548208155028766e-1f) +//IMPLEMENT_PS_CONST(exp_q3, 2.00000000000000000009e0f) +//IMPLEMENT_PS_CONST(exp_c1, 6.93145751953125e-1f) +//IMPLEMENT_PS_CONST(exp_c2, 1.42860682030941723212e-6f) +//IMPLEMENT_PS_CONST(exp2_hi, 127.4999961853f) +//IMPLEMENT_PS_CONST(exp2_lo, -127.4999961853f) +//IMPLEMENT_PS_CONST(exp2_p0, 2.30933477057345225087e-2f) +//IMPLEMENT_PS_CONST(exp2_p1, 2.02020656693165307700e1f) +//IMPLEMENT_PS_CONST(exp2_p2, 1.51390680115615096133e3f) +//IMPLEMENT_PS_CONST(exp2_q0, 2.33184211722314911771e2f) +//IMPLEMENT_PS_CONST(exp2_q1, 4.36821166879210612817e3f) +//IMPLEMENT_PS_CONST(log_p0, -7.89580278884799154124e-1f) +//IMPLEMENT_PS_CONST(log_p1, 1.63866645699558079767e1f) +//IMPLEMENT_PS_CONST(log_p2, -6.41409952958715622951e1f) +//IMPLEMENT_PS_CONST(log_q0, -3.56722798256324312549e1f) +//IMPLEMENT_PS_CONST(log_q1, 3.12093766372244180303e2f) +//IMPLEMENT_PS_CONST(log_q2, -7.69691943550460008604e2f) +//IMPLEMENT_PS_CONST(log_c0, 0.693147180559945f) +//IMPLEMENT_PS_CONST(log2_c0, 1.44269504088896340735992f) +// +//#define GLM_NAKED __declspec(naked) __cdecl +// +//__m128 GLM_NAKED _mm_cos_ps(__m128 x) +//{ +// __asm +// { +// andps xmm0, _epi32_inv_sign_mask +// addps xmm0, _ps_pi_2 +// mulps xmm0, _ps_2_pi +// pxor xmm3, xmm3 +// movdqa xmm5, _epi32_1 +// movaps xmm4, _ps_1 +// cvttps2dq xmm2, xmm0 +// pand xmm5, xmm2 +// pcmpeqd xmm5, xmm3 +// cvtdq2ps xmm6, xmm2 +// pand xmm2, _epi32_2 +// pslld xmm2, 30 +// subps xmm0, xmm6 +// minps xmm0, xmm4 +// subps xmm4, xmm0 +// andps xmm0, xmm5 +// andnps xmm5, xmm4 +// orps xmm0, xmm5 +// movaps xmm1, xmm0 +// mulps xmm0, xmm0 +// orps xmm1, xmm2 +// movaps xmm7, xmm0 +// mulps xmm0, _ps_sincos_p3 +// addps xmm0, _ps_sincos_p2 +// mulps xmm0, xmm7 +// addps xmm0, _ps_sincos_p1 +// mulps xmm0, xmm7 +// addps xmm0, _ps_sincos_p0 +// mulps xmm0, xmm1 +// ret +// } +//} +// +//void test_sse() +//{ +// sse::vec4 v1(1.0f, 2.0f, 3.0f, 4.0f); +// sse::vec4 v2(5.0f, 6.0f, 7.0f, 8.0f); +// sse::vec4 v3(9.0f); +// sse::vec4 v4(0.5f, 0.5f, 0.5f, 0.5f); +// __m128 v5 = sse::mix(v1.data, v2.data, v4.data); +// __m128 dot0 = sse::dot(v1.data, v2.data); +// float dot1 = sse::dot(v1, v2); +// __m128 rcp0 = sse::rcp(v1.data); +// glm::vec4 rcp1 = rcp(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); +// +// // cross +// { +// sse::vec4 v1(4.0f, 2.0f, 2.0f, 0.0f); +// sse::vec4 v2(1.0f, 2.0f, 3.0f, 0.0f); +// __m128 crs0 = sse::cross(v1.data, v2.data); +// +// glm::vec3 v3(4.0f, 2.0f, 2.0f); +// glm::vec3 v4(1.0f, 2.0f, 3.0f); +// glm::vec3 crs1 = glm::cross(v3, v4); +// +// __m128 end = _mm_set_ps1(1.0f); +// } +// +// // ieee754 +// { +// sse::detail::ieee754 one(1.f); +// float f = sse::load(one.mantissa, one.exp, one.sign); +// +// __m128 end = _mm_set_ps1(1.0f); +// } +// +// test_clamp(); +// test_asm(); +// +// __m128 cos0 = _mm_cos_ps(_mm_set_ps1(1.0f)); +// glm::vec4 cos1 = glm::cos(glm::vec4(1.0f)); +// +// float f = glm::dot(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f)); +// sse::vec4 end(9.0f); +// +// //sse::vec4 vComp = sse::load(sse::vec4(1.0f, 2.0f, 3.0f, 4.0f), 1); +// //vComp += sse::vec4(1.0f); +// //--vComp; +// //sse::vec4 vMixed = sse::mix(vComp, sse::vec4(-0.5f), sse::vec4(0.5f)); +// //float sDot = sse::dot(sse::vec4(1.0f), sse::vec4(2.0f)); +// //float cDot = glm::dot(glm::vec4(1.0f), glm::vec4(2.0f)); +//} diff --git a/wip/simd/sse.h b/wip/simd/sse.h new file mode 100644 index 00000000..72ef15d3 --- /dev/null +++ b/wip/simd/sse.h @@ -0,0 +1,13 @@ +#ifndef GLM_SSE_H +#define GLM_SSE_H + +#ifdef _WIN32 +#include +#endif + +#include "../glm/glm.h" +#include "../glm/glmext.h" + +void test_sse(); + +#endif//GLM_SSE_H diff --git a/wip/simd/sse_mat4.cpp b/wip/simd/sse_mat4.cpp new file mode 100644 index 00000000..21a651b0 --- /dev/null +++ b/wip/simd/sse_mat4.cpp @@ -0,0 +1,61 @@ +#include "precompiled.h" +#include "sse_mat4.h" +/* +void test_sse_mat4() +{ + { + glm::sse::mat4 m( + glm::sse::vec4(0, 1, 2, 3), + glm::sse::vec4(4, 5, 6, 7), + glm::sse::vec4(8, 9, 10, 11), + glm::sse::vec4(12, 13, 14, 15)); + glm::sse::mat4 n = glm::sse::transpose(m); + m.transpose(); + glm::sse::mat4 m_end; + } + + { + glm::sse::mat4 m0; + glm::sse::mat4 m1(3.f); + glm::sse::mat4 m2( + glm::sse::vec4(1), + glm::sse::vec4(2), + glm::sse::vec4(3), + glm::sse::vec4(4)); + glm::sse::mat4 m3 = m1 + 1.0f; + glm::sse::mat4 m4 = 1.0f + m1; + glm::sse::mat4 m5 = m2 * m2; + + glm::sse::vec4 v0 = glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::sse::vec4 v1 = glm::sse::vec4(5.0f, 6.0f, 7.0f, 8.0f); + glm::sse::vec4 v2 = glm::sse::mat4(v0, v1, v0, v1) * glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::sse::vec4 v3 = glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f) * glm::sse::mat4(v0, v1, v0, v1); + glm::sse::vec4 v_end; + } + + { + glm::mat4 m0; + glm::mat4 m1(3.f); + glm::mat4 m2( + glm::vec4(1), + glm::vec4(2), + glm::vec4(3), + glm::vec4(4)); + glm::mat4 m3 = m1 + 1.0f; + glm::mat4 m4 = 1.0f + m1; + glm::mat4 m5 = m2 * m2; + + glm::vec4 v0 = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::vec4 v1 = glm::vec4(5.0f, 6.0f, 7.0f, 8.0f); + glm::vec4 v2 = glm::mat4(v0, v1, v0, v1) * glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::vec4 v3 = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) * glm::mat4(v0, v1, v0, v1); + glm::vec4 v_end; + } + + { + int a[][4] = {{0, 0, 1, 2}, {0, 0, 1, 2}}; + } + + glm::sse::mat4 m_end; +} +*/ diff --git a/wip/simd/sse_mat4.h b/wip/simd/sse_mat4.h new file mode 100644 index 00000000..2b564c74 --- /dev/null +++ b/wip/simd/sse_mat4.h @@ -0,0 +1,1280 @@ +#ifdef GLM_SSE_MAT4_H +#define GLM_SSE_MAT4_H + +#include +#include +#include "sse_vec4.h" + +namespace glm{ +namespace sse{ + +const __m128i maskX = _mm_set_epi32(0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF); +const __m128i maskY = _mm_set_epi32(0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000); +const __m128i maskZ = _mm_set_epi32(0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000); +const __m128i maskW = _mm_set_epi32(0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000); + +GLM_ALIGN(16) struct mat4 +{ + enum ENoInit + { + NO_INIT + }; + + union + { + __m128 data[4]; + }; + + mat4(); + mat4(ENoInit NoInit); + mat4(float s); + mat4(const vec4& x, const vec4& y, const vec4& z, const vec4& w); + + mat4& operator+=(const float s); + + mat4& operator+=(const mat4& m); + mat4& operator*=(const mat4& m); + + void mat4::transpose(); +}; + +__forceinline mat4::mat4() +{ + void* address = this; + + __asm + { + mov esi, address + xorps xmm0, xmm0 + movaps [esi+0x00], xmm0 + movaps [esi+0x10], xmm0 + movaps [esi+0x20], xmm0 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4::mat4(ENoInit NoInit) +{} + +__forceinline mat4::mat4(float s) +{ + void* address = this; + + __asm + { + mov esi, address + movss xmm0, s + shufps xmm0, xmm0, 0 + xorps xmm1, xmm1 + movaps [esi+0x00], xmm1 + movaps [esi+0x10], xmm1 + movaps [esi+0x20], xmm1 + movaps [esi+0x30], xmm1 + movss [esi+0x00], xmm0 + movss [esi+0x14], xmm0 + movss [esi+0x28], xmm0 + movss [esi+0x3C], xmm0 + } +} + +__forceinline mat4::mat4(const vec4& x, const vec4& y, const vec4& z, const vec4& w) +{ + void* address = this; + + __asm + { + mov esi, address + + mov edi, x + movaps xmm0, [edi] + movaps [esi+0x00], xmm0 + + mov edi, y + movaps xmm0, [edi] + movaps [esi+0x10], xmm0 + + mov edi, z + movaps xmm0, [edi] + movaps [esi+0x20], xmm0 + + mov edi, w + movaps xmm0, [edi] + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator+(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + addps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + addps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + addps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + addps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator+(float s, const mat4& m) +{ + return m + s; +} + +__forceinline mat4 operator-(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + subps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + subps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + subps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + subps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator-(float s, const mat4& m) +{ + __asm + { + movss xmm2, s + shufps xmm2, xmm2, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x00], xmm1 + + movaps xmm0, [esi+0x10] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x10], xmm1 + + movaps xmm0, [esi+0x20] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x20], xmm1 + + movaps xmm0, [esi+0x30] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x30], xmm1 + } +} + +__forceinline mat4 operator*(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + mulps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + mulps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + mulps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + mulps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator*(float s, const mat4& m) +{ + return m * s; +} + +__forceinline mat4 operator/(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + divps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + divps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + divps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + divps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator/(float s, const mat4& m) +{ + __asm + { + movss xmm2, s + shufps xmm2, xmm2, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x00], xmm1 + + movaps xmm0, [esi+0x10] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x10], xmm1 + + movaps xmm0, [esi+0x20] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x20], xmm1 + + movaps xmm0, [esi+0x30] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x30], xmm1 + } +} + +__forceinline vec4 operator*(const mat4& m, const vec4& v) +{ + vec4 result(vec4::NO_INIT); + + // SSE2 + __asm + { + mov esi, [m] + mov edi, [v] + movaps xmm4, [edi] + + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result, xmm0 + } + + return result; +} + +__forceinline vec4 operator*(const vec4& v, const mat4& m) +{ + vec4 result(vec4::NO_INIT); + + // SSE1 + __asm + { + mov esi, [m] + mov edi, [v] + movaps xmm4, [edi] // xmm4: v[3], v[2], v[1], v[0] + + movaps xmm0, [esi+0x00] // xmm0: m[0][3], m[0][2], m[0][1], m[0][0] + movaps xmm1, [esi+0x10] // xmm1: m[1][3], m[1][2], m[1][1], m[1][0] + movaps xmm2, [esi+0x20] // xmm2: m[2][3], m[2][2], m[2][1], m[2][0] + movaps xmm3, [esi+0x30] // xmm3: m[3][3], m[3][2], m[3][1], m[3][0] + + mulps xmm0, xmm4 // xmm0: m[0][3]*v[3], m[0][2]*v[2], m[0][1]*v[1], m[0][0]*v[0] + mulps xmm1, xmm4 // xmm1: m[1][3]*v[3], m[1][2]*v[2], m[1][1]*v[1], m[1][0]*v[0] + mulps xmm2, xmm4 // xmm2: m[2][3]*v[3], m[2][2]*v[2], m[2][1]*v[1], m[2][0]*v[0] + mulps xmm3, xmm4 // xmm2: m[3][3]*v[3], m[3][2]*v[2], m[3][1]*v[1], m[3][0]*v[0] + + movaps xmm4, xmm0 // xmm4: m[0][3]*v[3], m[0][2]*v[2], m[0][1]*v[1], m[0][0]*v[0] + movhlps xmm0, xmm1 // xmm0: m[0][3]*v[3], m[0][2]*v[2], m[1][3]*v[3], m[1][2]*v[2] + movlhps xmm1, xmm4 // xmm1: m[0][1]*v[1], m[0][0]*v[0], m[1][1]*v[1], m[1][0]*v[0] + addps xmm0, xmm1 + + movaps xmm5, xmm2 + movhlps xmm2, xmm3 + movlhps xmm3, xmm5 + addps xmm2, xmm3 + + movaps xmm1, xmm0 + shufps xmm0, xmm2, _MM_SHUFFLE(0, 2, 0, 2) //_MM_SHUFFLE(2, 0, 2, 0) + shufps xmm1, xmm2, _MM_SHUFFLE(1, 3, 1, 3) //_MM_SHUFFLE(3, 1, 3, 1) + addps xmm0, xmm1 + + movaps result, xmm0 + } + + return result; +} + +// 289000 +/* +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + next: + movaps xmm7, [edi] + + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm4 + + pshufd xmm4, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm4 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm4 + + pshufd xmm4, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm4 + + addps xmm2, xmm3 + addps xmm0, xmm1 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +// 288000 +/* +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + next: + movaps xmm7, [edi] + + movaps xmm0, [esi+0x00] + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm5 + + movaps xmm1, [esi+0x10] + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + + movaps xmm2, [esi+0x20] + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm5 + + movaps xmm3, [esi+0x30] + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ +/* +// 290000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm4 + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm4 + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 295000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm4 + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm4 + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 290000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm0, xmm4 + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm2, xmm4 + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 288000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm0, xmm4 + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm2, xmm4 + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 298000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + const int int0x10 = 0x10; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov edx, int0x10 + + // First column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, edx + add eax, edx + + // Second column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, edx + add eax, edx + + // Third column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, edx + add eax, edx + + // Forth column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + } + + return result; +} +*/ + +// 294000 +__forceinline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result(mat4::NO_INIT); + + // SSE2 + __asm + { + mov esi, m + mov edi, n + + // First column + movaps xmm4, [edi+0x00] + + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x00], xmm0 + + // Second column + movaps xmm4, [edi+0x10] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x10], xmm0 + + // Third column + movaps xmm4, [edi+0x20] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x20], xmm0 + + // Forth column + movaps xmm4, [edi+0x30] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x30], xmm0 + } + + return result; +} + +static const __m128 sign1010 = _mm_set_ps( 1.0f,-1.0f, 1.0f,-1.0f); +static const __m128 sign0101 = _mm_set_ps(-1.0f, 1.0f,-1.0f, 1.0f); +static const __m128i mask1010 = _mm_set_epi32(0x00000000, 0x80000000, 0x00000000, 0x80000000); +static const __m128i mask0101 = _mm_set_epi32(0x80000000, 0x00000000, 0x80000000, 0x00000000); + +__forceinline mat4 inverse(const mat4& m) +{ + mat4 result(mat4::NO_INIT); + + vec4 m0a; + vec4 m0b; + vec4 m0c; + + vec4 m1a; + vec4 m1b; + vec4 m1c; + + vec4 m2a; + vec4 m2b; + vec4 m2c; + + vec4 m3a; + vec4 m3b; + vec4 m3c; + + __asm + { + mov esi, m + + ////////////////////////////////////////////////////////////////////////////////////////////// + //R00 = +1 * m11*(m22*m33 - m32*m23) -1 * m12*(m23*m31 - m33*m21) +1 * m13*(m21*m32 - m31*m22) + //R01 = -1 * m12*(m23*m30 - m33*m20) +1 * m13*(m20*m32 - m30*m22) -1 * m10*(m22*m33 - m32*m23) + //R02 = +1 * m13*(m20*m31 - m30*m21) -1 * m10*(m21*m33 - m31*m23) +1 * m11*(m23*m30 - m33*m20) + //R03 = -1 * m10*(m21*m32 - m31*m22) +1 * m11*(m22*m30 - m32*m20) -1 * m12*(m20*m31 - m30*m21) + + movaps xmm6, [esi+20] // xmm6: m23, m22, m21, m20 + movaps xmm7, [esi+30] // xmm7: m33, m32, m31, m30 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm0: m21, m20, m23, m22 (movhlps optimization possible) + pshufd xmm1, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm1: m30, m33, m32, m31 + pshufd xmm2, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm2: m20, m23, m22, m21 + pshufd xmm3, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm3: m31, m30, m33, m32 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m21*m30, m20*m33, m23*m32, m22*m31 + mulps xmm3, xmm2 // xmm2: m20*m31, m23*m30, m22*m33, m21*m32 + subps xmm3, xmm0 // xmm2: m20*m31-m21*m30, m23*m30-m20*m33, m22*m33-m23*m32, m21*m32-m22*m31 + movaps xmm4, xmm3 // xmm4: m20*m31-m21*m30, m23*m30-m20*m33, m22*m33-m23*m32, m21*m32-m22*m31 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm0: m22, m21, m20, m23 + // Reuse xmm1: pshufd xmm1, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm1: m30, m33, m32, m31 + // Reuse xmm2: pshufd xmm2, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm2: m20, m23, m22, m21 + pshufd xmm3, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm3: m32, m31, m30, m33 + + mulps xmm1, xmm0 // xmm1: m30*m22, m33*m21, m32*m20, m31*m23 + mulps xmm2, xmm3 // xmm2: m20*m32, m23*m31, m22*m30, m21*m33 + subps xmm1, xmm2 // xmm1: m30*m22-m20*m32, m33*m21-m23*m31, m32*m20-m22*m30, m31*m23-m21*m33 + movaps xmm5, xmm2 // xmm5: m30*m22-m20*m32, m33*m21-m23*m31, m32*m20-m22*m30, m31*m23-m21*m33 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + // Reuse xmm0: pshufd xmm0, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm0: m22, m21, m20, m23 + pshufd xmm1, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm1: m31, m30, m33, m32 (movhlps optimization possible) + pshufd xmm2, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm2: m21, m20, m23, m22 (movhlps optimization possible) + // Reuse xmm3: pshufd xmm3, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm3: m32, m31, m30, m33 + + mulps xmm0, xmm1 // xmm1: m22*m31, m21*m30, m20*m33, m23*m32 + mulps xmm2, xmm3 // xmm2: m21*m32, m20*m31, m23*m30, m22*m33 + subps xmm2, xmm0 // xmm2: m23*m32-m22*m33, m20*m33-m23*m30, m21*m30-m20*m31, m22*m31-m21*m32 + movaps xmm6, xmm0 // xmm6: m23*m32-m22*m33, m20*m33-m23*m30, m21*m30-m20*m31, m22*m31-m21*m32 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + movaps xmm0, [esi+10] // m13, m12, m11, m10 + + pshufd xmm1, xmm0, _MM_SHUFFLE(2, 1, 0, 3) + xorps xmm1, mask1010 //-m12, m11,-m10, m13 + mulaps xmm4, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(1, 0, 3, 2) // (movhlps optimization possible) + xorps xmm1, mask0101 // m11,-m10, m13,-m12 + mulaps xmm5, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(0, 3, 2, 1) + xorps xmm1, mask1010 //-m10, m13,-m12, m10 + mulaps xmm6, xmm1 + + mulaps xmm6, xmm5 + mulaps xmm6, xmm4 + movaps result[0x00], xmm6 + + ////////////////////////////////////////////////////////////////////////////////////////////// + //R10 = -1 * m21*(m32*m03 – m02*m33) +1 * m22*(m33*m01 – m03*m31) –1 * m23*(m31*m02 – m01*m32) + //R11 = +1 * m22*(m33*m00 – m03*m30) –1 * m23*(m30*m02 – m00*m32) +1 * m20*(m32*m03 – m02*m33) + //R12 = -1 * m23*(m30*m01 – m00*m31) +1 * m20*(m31*m03 – m01*m33) -1 * m21*(m33*m00 – m03*m30) + //R13 = +1 * m20*(m31*m02 – m01*m32) -1 * m21*(m32*m00 – m02*m30) +1 * m22*(m30*m01 – m00*m31) + + movaps xmm6, [esi+00] // xmm6: m03, m02, m01, m00 + // Reuse xmm7 movaps xmm7, [esi+30] // xmm7: m33, m32, m31, m30 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm0: m00, m03, m02, m01 + pshufd xmm1, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm1: m31, m30, m33, m32 (movhlps optimization possible) + pshufd xmm2, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm2: m01, m00, m03, m02 (movhlps optimization possible) + pshufd xmm3, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm3: m30, m33, m32, m31 + + mulps xmm0, xmm1 // xmm0: m31*m00, m30*m03, m33*m02, m32*m01 + mulps xmm3, xmm2 // xmm3: m30*m01, m33*m00, m32*m03, m31*m02 + subps xmm3, xmm0 // xmm3: m30*m01-m31*m00, m33*m00-m30*m03, m32*m03-m33*m02, m31*m02-m32*m01 + movaps xmm4, xmm3 // xmm4: m30*m01-m31*m00, m33*m00-m30*m03, m32*m03-m33*m02, m31*m02-m32*m01 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + // Reuse xmm0 pshufd xmm0, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm0: m00, m03, m02, m01 + pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + // Reuse xmm3 pshufd xmm3, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm3: m30, m33, m32, m31 + + mulps xmm0, xmm1 // xmm0: m00*m32, m03*m31, m02*m30, m01*m33 + mulps xmm3, xmm2 // xmm3: m30*m02, m33*m01, m32*m00, m31*m03 + subps xmm0, xmm3 // xmm3: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + movaps xmm5, xmm0 // xmm4: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(3, 0, 3, 2) // xmm0: m01, m00, m03, m02 (movhlps optimization possible) + // Reuse xmm1: pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + // Reuse xmm2: pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + pshufd xmm3, xmm7, _MM_SHUFFLE(3, 0, 3, 2) // xmm3: m31, m30, m33, m32 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m01*m32, m00*m31, m03*m30, m02*m33 + mulps xmm3, xmm2 // xmm3: m02*m31, m01*m30, m00*m33, m03*m32 + subps xmm3, xmm0 // xmm3: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + movaps xmm6, xmm3 // xmm6: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + movaps xmm0, [esi+20] // m23, m22, m21, m20 + + pshufd xmm1, xmm0, _MM_SHUFFLE(2, 1, 0, 3) + xorps xmm1, mask0101 //-m22, m21,-m20, m23 + mulaps xmm4, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(1, 0, 3, 2) // (movhlps optimization possible) + xorps xmm1, mask1010 // m21,-m20, m23,-m22 + mulaps xmm5, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(0, 3, 2, 1) + xorps xmm1, mask0101 //-m20, m23,-m22, m21 + mulaps xmm6, xmm1 + + mulaps xmm6, xmm5 + mulaps xmm6, xmm4 + movaps result[0x10], xmm6 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + //R20 = +1 * m31*(m02*m13 - m12*m03) -1 * m32*(m03*m11 – m13*m01) +1 * m33*(m01*m12 - m11*m02) + //R21 = -1 * m32*(m03*m10 - m13*m00) +1 * m33*(m00*m12 – m10*m02) -1 * m30*(m02*m13 - m12*m03) + //R22 = +1 * m33*(m00*m11 - m10*m01) -1 * m30*(m01*m13 – m11*m03) +1 * m31*(m03*m10 - m13*m00) + //R23 = -1 * m30*(m01*m12 - m11*m02) +1 * m31*(m02*m10 – m12*m00) -1 * m32*(m00*m11 - m10*m01) + + //Reuse xmm6: movaps xmm6, [esi+00] // xmm6: m03, m02, m01, m00 + movaps xmm7, [esi+10] // xmm7: m13, m12, m11, m10 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm0: m11, m10, m13, m12 (movhlps optimization possible) + pshufd xmm1, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm1: m00, m03, m02, m01 + pshufd xmm2, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm2: m10, m13, m12, m11 + pshufd xmm3, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm3: m01, m00, m03, m02 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m11*m00, m10*m03, m13*m02, m12*m01 + mulps xmm3, xmm2 // xmm3: m01*m10, m00*m13, m03*m12, m02*m11 + subps xmm3, xmm0 // xmm3: m11*m00-m01*m10, m10*m03-m00*m13, m13*m02-m03*m12, m12*m01-m02*m11 + movaps xmm4, xmm3 // xmm4: m11*m00-m01*m10, m10*m03-m00*m13, m13*m02-m03*m12, m12*m01-m02*m11 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + + + + + + + // Reuse xmm0 pshufd xmm0, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm0: m00, m03, m02, m01 + pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + // Reuse xmm3 pshufd xmm3, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm3: m30, m33, m32, m31 + + mulps xmm0, xmm1 // xmm0: m00*m32, m03*m31, m02*m30, m01*m33 + mulps xmm3, xmm2 // xmm3: m30*m02, m33*m01, m32*m00, m31*m03 + subps xmm0, xmm3 // xmm3: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + movaps xmm5, xmm0 // xmm4: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(3, 0, 3, 2) // xmm0: m01, m00, m03, m02 (movhlps optimization possible) + // Reuse xmm1: pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + // Reuse xmm2: pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + pshufd xmm3, xmm7, _MM_SHUFFLE(3, 0, 3, 2) // xmm3: m31, m30, m33, m32 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m01*m32, m00*m31, m03*m30, m02*m33 + mulps xmm3, xmm2 // xmm3: m02*m31, m01*m30, m00*m33, m03*m32 + subps xmm3, xmm0 // xmm3: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + movaps xmm6, xmm3 // xmm6: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + movaps xmm0, [esi+20] // m23, m22, m21, m20 + + pshufd xmm1, xmm0, _MM_SHUFFLE(2, 1, 0, 3) + xorps xmm1, mask0101 //-m22, m21,-m20, m23 + mulaps xmm4, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(1, 0, 3, 2) // (movhlps optimization possible) + xorps xmm1, mask1010 // m21,-m20, m23,-m22 + mulaps xmm5, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(0, 3, 2, 1) + xorps xmm1, mask0101 //-m20, m23,-m22, m21 + mulaps xmm6, xmm1 + + mulaps xmm6, xmm5 + mulaps xmm6, xmm4 + movaps result[0x10], xmm6 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + + } + + return result; +} + +__forceinline mat4 transpose(const mat4& m) +{ + mat4 result(mat4::NO_INIT); + + __asm + { + mov esi, m + + movaps xmm4, [esi+0x00] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x10] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movaps xmm0, xmm5 + movhlps xmm1, xmm5 + + movaps xmm2, xmm4 + movhlps xmm3, xmm4 + + movaps xmm4, [esi+0x20] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x30] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movlhps xmm0, xmm5 + movlhps xmm2, xmm4 + + movhlps xmm7, xmm5 + movhlps xmm6, xmm4 + + movlhps xmm1, xmm7 + movlhps xmm3, xmm6 + + movaps result[0x00], xmm0 + movaps result[0x10], xmm1 + movaps result[0x20], xmm2 + movaps result[0x30], xmm3 + } + + return result; +} + +__forceinline void mat4::transpose() +{ + void* address = this; + + __asm + { + mov esi, address + + movaps xmm4, [esi+0x00] + movaps xmm6, [esi+0x10] + movaps xmm5, xmm4 + + unpcklps xmm5, xmm6 + movaps xmm0, xmm5 + movhlps xmm1, xmm5 + + unpckhps xmm4, xmm6 + movaps xmm2, xmm4 + movhlps xmm3, xmm4 + + movaps xmm4, [esi+0x20] + movaps xmm6, [esi+0x30] + movaps xmm5, xmm4 + + unpcklps xmm5, xmm6 + movlhps xmm0, xmm5 + movhlps xmm2, xmm5 + movlhps xmm1, xmm5 + + unpckhps xmm4, xmm6 + movlhps xmm2, xmm4 + movhlps xmm4, xmm4 + movlhps xmm3, xmm4 + + movaps [esi+0x00], xmm0 + movaps [esi+0x10], xmm1 + movaps [esi+0x20], xmm2 + movaps [esi+0x30], xmm3 + } +} + + +/* +inline mat4 transpose(const mat4& m) +{ + mat4 result; + + __asm + { + mov esi, m + + movaps xmm4, [esi+0x00] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x10] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movaps xmm0, xmm5 + movhlps xmm1, xmm5 + + movaps xmm2, xmm4 + movhlps xmm3, xmm4 + + movaps xmm4, [esi+0x20] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x30] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movlhps xmm0, xmm5 + movhlps xmm7, xmm5 + movlhps xmm1, xmm7 + + movlhps xmm2, xmm4 + movhlps xmm6, xmm4 + movlhps xmm3, xmm6 + + movaps result[0x00], xmm0 + movaps result[0x10], xmm1 + movaps result[0x20], xmm2 + movaps result[0x30], xmm3 + } + + return result; +} +*/ +}//namespace sse +}//namespace glm + +void test_sse_mat4(); + +#endif//GLM_SSE_MAT4_H diff --git a/wip/simd/sse_mat4array.cpp b/wip/simd/sse_mat4array.cpp new file mode 100644 index 00000000..5f656a45 --- /dev/null +++ b/wip/simd/sse_mat4array.cpp @@ -0,0 +1 @@ +#include "precompiled.h" diff --git a/wip/simd/sse_mat4array.h b/wip/simd/sse_mat4array.h new file mode 100644 index 00000000..e69de29b diff --git a/wip/simd/sse_vec4.cpp b/wip/simd/sse_vec4.cpp new file mode 100644 index 00000000..71371503 --- /dev/null +++ b/wip/simd/sse_vec4.cpp @@ -0,0 +1,53 @@ +#include "precompiled.h" +#include "sse_vec4.h" +/* +void test_shufps(const glm::sse::vec4& v1, const glm::sse::vec4& v2) +{ + glm::sse::vec4 Result0; + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm0, [esi] + movaps xmm1, [edi] + shufps xmm0, xmm1, _MM_SHUFFLE(3, 2, 1, 0) + movaps Result0, xmm0 + } + + glm::sse::vec4 Result1; + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm2, [esi] + movaps xmm3, [edi] + pshufd xmm2, xmm3, _MM_SHUFFLE(3, 2, 1, 0) + movaps Result1, xmm2 + } + + glm::sse::vec4 end; +} + +void test_sse_vec4() +{ + test_shufps( + glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f), + glm::sse::vec4(5.0f, 6.0f, 7.0f, 8.0f)); + + glm::sse::vec4 v0; + glm::sse::vec4 v1(76.f); + glm::sse::vec4 v2(5.f, 1.f, 2.f, 3.f); + v2 += v1; + glm::sse::vec4 v3 = v2; + glm::sse::vec4 v4(1.0f); + float dot = glm::sse::dot(v4, v1); + ++v4; + glm::sse::vec4 v5 = -v4; + glm::sse::vec4 v6(2.f); + glm::sse::vec4 v7 = glm::sse::cross(v2, v6); + glm::vec3 v8 = glm::cross(glm::vec3(5.f, 1.f, 2.f), glm::vec3(2.f)); + //printf("vec4(%f, %f, %f, %f)\n", v4.x, v4.y, v4.z, v4.w); + glm::sse::vec4 v9 = glm::sse::normalize(glm::sse::vec4(1.0f, 1.0f, 1.0f, 0.0f)); + glm::sse::vec4 vx; +} +*/ \ No newline at end of file diff --git a/wip/simd/sse_vec4.h b/wip/simd/sse_vec4.h new file mode 100644 index 00000000..0f0c7451 --- /dev/null +++ b/wip/simd/sse_vec4.h @@ -0,0 +1,290 @@ +#ifndef GLM_SSE_VEC4_H +#define GLM_SSE_VEC4_H + +#include +#include + +namespace glm{ +namespace sse{ + +#define GLM_SHUFFLE(fp3,fp2,fp1,fp0) (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | ((fp0))) + +const __m128 zero = _mm_setzero_ps(); +const __m128 one = _mm_set_ps1(1.0f); +const __m128 two = _mm_set_ps1(2.0f); +const __m128 three = _mm_set_ps1(3.0f); +const __m128 pouet = _mm_set_ps(2.0f, 4.0f, 6.0f, 8.0f); + +#define GLM_ALIGN(x) __declspec(align(x)) + +GLM_ALIGN(16) struct vec4 +{ + enum ENoInit + { + NO_INIT + }; + + union + { + __m128 data; + struct s{float x, y, z, w;}; + float array[4]; + }; + + vec4(); + vec4(ENoInit NoInit); + vec4(float s); + vec4(float x, float y, float z, float w); + vec4(float v[4]); + + vec4& operator+=(const float s); + + vec4& operator+=(const vec4& v); + vec4& operator*=(const vec4& v); + + vec4& operator++(); +}; + +__forceinline vec4::vec4() +{ + void* address = this; + + __asm + { + mov eax, [address] + xorps xmm0, xmm0 + movaps [eax], xmm0 + } +} + +__forceinline vec4::vec4(ENoInit NoInit) +{} + +__forceinline vec4::vec4(float s) +{ + void* address = this; + + __asm + { + mov esi, [address] + movss xmm0, s + shufps xmm0, xmm0, 0 + movaps [esi], xmm0 + } +} + +__forceinline vec4::vec4(float x, float y, float z, float w) +{ + void* address = this; + + __asm + { + mov esi, address + movss xmm0, x + movss xmm1, y + movss xmm2, z + movss xmm3, w + unpcklps xmm0, xmm1 + unpcklps xmm2, xmm3 + movlhps xmm0, xmm2 + movaps [esi], xmm0 + } +} + +__forceinline vec4::vec4(float v[4]) +{ + void* address = this; + + __asm + { + mov eax, [address] + mov ebx, [v] + movups xmm0, [ebx] + movaps [eax], xmm0 + } +} + +__forceinline vec4& vec4::operator+=(const float s) +{ + void* address = this; + + __asm + { + mov eax, [address] + movss xmm1, s + shufps xmm1, xmm1, 0 + movaps xmm0, [eax] + addps xmm0, xmm1 + movaps [eax], xmm0 + } + + return *this; +} + +__forceinline vec4& vec4::operator+=(const vec4& v) +{ + void* address = this; + + __asm + { + mov eax, [address] + mov ebx, [v] + movaps xmm0, [eax] + addps xmm0, [ebx] + movaps [eax], xmm0 + } + + return *this; +} + +__forceinline vec4& vec4::operator*=(const vec4& v) +{ + void* address = this; + + __asm + { + mov esi, address + mov edi, v + movaps xmm0, esi + mulps xmm0, edi + movaps [esi], xmm0 + } + + return *this; +} + +__forceinline vec4& vec4::operator++() +{ + void* address = this; + + __asm + { + mov eax, [address] + movaps xmm0, [eax] + addps xmm0, one + movaps [eax], xmm0 + } + + return *this; +} + +__forceinline const vec4 operator- (const vec4& v) +{ + vec4 result(vec4::NO_INIT); + + __asm + { + mov esi, v + xorps xmm0, xmm0 + subps xmm0, [esi] + movaps result, xmm0 + } + + result; +} + +__forceinline vec4 cross(const vec4& v1, const vec4& v2) +{ + vec4 result(vec4::NO_INIT); + + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm0, [esi] + movaps xmm1, [edi] + shufps xmm0, xmm0, _MM_SHUFFLE(3, 0, 2, 1) + movaps xmm2, xmm0 + shufps xmm0, xmm0, _MM_SHUFFLE(3, 1, 0, 2) + shufps xmm1, xmm1, _MM_SHUFFLE(3, 0, 2, 1) + movaps xmm3, xmm1 + shufps xmm1, xmm1, _MM_SHUFFLE(3, 1, 0, 2) + mulps xmm0, xmm3 + mulps xmm1, xmm2 + subps xmm0, xmm1 + movaps result, xmm0 + } + + return result; +} + +__forceinline float dot(const vec4& v1, const vec4& v2) +{ + float result; + + // All component processed + //__asm + //{ + // mov esi, v1 + // mov edi, v2 + // movaps xmm0, [esi] + // movaps xmm1, [edi] + // mulps xmm0, xmm1 + // movaps xmm1, xmm0 + // shufps xmm0, xmm0, _MM_SHUFFLE(2, 3, 0, 1) + // addps xmm0, xmm1 + // movaps xmm1, xmm0 + // shufps xmm0, xmm0, _MM_SHUFFLE(0, 1, 2, 3) + // addps xmm0, xmm1 + // movss result, xmm0 + //} + + // SSE + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm0, [esi] // w1, z1, y1, x1 + mulps xmm0, [edi] // w1 * w2, z1 * z2, y1 * y2, x1 * x2 + movhlps xmm1, xmm0 // XX, XX, w1 * w2, z1 * z2 + addps xmm0, xmm1 // XX, XX, y1 * y2 + w1 * w2, x1 * x2 + z1 * z2 + pshufd xmm1, xmm0, 1 // XX, XX, XX, y1 * y2 + w1 * w2 + addss xmm0, xmm1 // y1 * y2 + w1 * w2 + x1 * x2 + z1 * z2 + movss result, xmm0 + } + + // SSE 3 + + // SSE 4.1 + //__asm + //{ + // mov esi, v1 + // mov edi, v2 + // movaps xmm0, [esi] + // dpps xmm0, [edi] + // movss result, xmm0 + //} + + return result; +} + +__forceinline vec4 normalize(const vec4& v) +{ + vec4 result(vec4::NO_INIT); + + __asm + { + mov esi, v + movaps xmm2, [esi] + movaps xmm0, xmm2 + mulps xmm0, xmm0 + movaps xmm1, xmm0 + shufps xmm0, xmm0, _MM_SHUFFLE(2, 3, 0, 1) + addps xmm0, xmm1 + movaps xmm1, xmm0 + shufps xmm0, xmm0, _MM_SHUFFLE(0, 1, 2, 3) + addps xmm0, xmm1 + rsqrtps xmm0, xmm0 + mulps xmm2, xmm0 + movaps result, xmm2 + } + + return result; +} + +}//namespace sse +}//namespace glm + +void test_sse_vec4(); + +#endif//GLM_SSE_VEC4_H diff --git a/wip/simd/sse_vec4array.cpp b/wip/simd/sse_vec4array.cpp new file mode 100644 index 00000000..c08ca1f1 --- /dev/null +++ b/wip/simd/sse_vec4array.cpp @@ -0,0 +1 @@ +#include "precompiled.h" \ No newline at end of file diff --git a/wip/simd/sse_vec4array.h b/wip/simd/sse_vec4array.h new file mode 100644 index 00000000..e69de29b diff --git a/wip/sse/glm/core/_bvec2.h b/wip/sse/glm/core/_bvec2.h new file mode 100644 index 00000000..8c7e8b12 --- /dev/null +++ b/wip/sse/glm/core/_bvec2.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_bvec2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_bvec2__ +#define __glm_core_bvec2__ + +#include "./_cvec2.inl" + +namespace glm{ +namespace detail{ + + class _bvec2 : public _cvec2 > + { + public: + // Common constructors + _bvec2(); + _bvec2(const _bvec2& v); + + // Swizzle constructors + _bvec2(const _xref2& r); + + // Bool constructors + explicit _bvec2(const bool a); + explicit _bvec2(const bool a, const bool b); + explicit _bvec2(const bool a, const _bvec2& b); + explicit _bvec2(const bool a, const _bvec3& b); + explicit _bvec2(const bool a, const _bvec4& b); + explicit _bvec2(const _bvec3& a); + explicit _bvec2(const _bvec4& a); + + // U constructors + template explicit _bvec2(const U x); + template explicit _bvec2(const U a, const U b); + template explicit _bvec2(const U a, const _xvec2& b); + template explicit _bvec2(const U a, const _xvec3& b); + template explicit _bvec2(const U a, const _xvec4& b); + template explicit _bvec2(const _xvec3& a); + template explicit _bvec2(const _xvec4& a); + + // Operators + _bvec2& operator=(const _bvec2& v); + //_bvec2 operator! () const; + }; + +} //namespace detail +} //namespace glm + +#endif//__glm_core_bvec2__ diff --git a/wip/sse/glm/core/_bvec2.inl b/wip/sse/glm/core/_bvec2.inl new file mode 100644 index 00000000..f9ce3087 --- /dev/null +++ b/wip/sse/glm/core/_bvec2.inl @@ -0,0 +1,159 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : _bvec2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __bvec2_inl__ +#define __bvec2_inl__ + +#include "./_bvec2.h" +#include "./_bvec3.h" +#include "./_bvec4.h" +#include "./_xref2.h" +#include "./_xref3.h" +#include "./_xref4.h" +#include "./_swizzle.inl" + +namespace glm{ +namespace detail{ + + ////////////////////////////////////////////////////////////// + // Common constructors + + inline _bvec2::_bvec2() : + _cvec2(false, false) + {} + + inline _bvec2::_bvec2(const _bvec2& v) : + _cvec2(v.x, v.y) + {} + + ////////////////////////////////////////////////////////////// + // Swizzle constructors + inline _bvec2::_bvec2(const _xref2& r) : + _cvec2(r.x, r.y) + {} + + ////////////////////////////////////////////////////////////// + // Bool constructors + + inline _bvec2::_bvec2(const bool a) : + _cvec2(a, a) + {} + + inline _bvec2::_bvec2(const bool a, const bool b) : + _cvec2(a, b) + {} + + inline _bvec2::_bvec2(const bool a, const _bvec2& b) : + _cvec2(a, b.x) + {} + + inline _bvec2::_bvec2(const bool a, const _bvec3& b) : + _cvec2(a, b.x) + {} + + inline _bvec2::_bvec2(const bool a, const _bvec4& b) : + _cvec2(a, b.x) + {} + + inline _bvec2::_bvec2(const _bvec3& a) : + _cvec2(a.x, a.y) + {} + + inline _bvec2::_bvec2(const _bvec4& a) : + _cvec2(a.x, a.y) + {} + + ////////////////////////////////////////////////////////////// + // U constructors + + template + inline _bvec2::_bvec2(const U a) : + _cvec2(bool(a), bool(a)) + {} + + template + inline _bvec2::_bvec2(const U a, const U b) : + _cvec2(bool(a), bool(b)) + {} + + template + inline _bvec2::_bvec2(const U a, const _xvec2& b) : + _cvec2(bool(a), bool(b.x)) + {} + + template + inline _bvec2::_bvec2(const U a, const _xvec3& b) : + _cvec2(bool(a), bool(b.x)) + {} + + template + inline _bvec2::_bvec2(const U a, const _xvec4& b) : + _cvec2(bool(a), bool(b.x)) + {} + + template + inline _bvec2::_bvec2(const _xvec3& a) : + _cvec2(bool(a.x), bool(a.y)) + {} + + template + inline _bvec2::_bvec2(const _xvec4& a) : + _cvec2(bool(a.x), bool(a.y)) + {} + + ////////////////////////////////////////////////////////////// + // bvec2 operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + inline _bvec2& _bvec2::operator=(const _bvec2& x) + { + this->x = x.x; + this->y = x.y; + return *this; + } +/* + inline _bvec2 _bvec2::operator--() + { + x = !x; + y = !y; + return *this; + } + + inline _bvec2 _bvec2::operator++() + { + x = !x; + y = !y; + return *this; + } + + inline const _bvec2 _bvec2::operator--(int n) const + { + return _bvec2( + !this->x, + !this->y); + } + + inline const _bvec2 _bvec2::operator++(int n) const + { + return _bvec2( + !this->x, + !this->y); + } +*/ + //inline _bvec2 _bvec2::operator!() const + //{ + // return _bvec2( + // !this->x, + // !this->y); + //} + +} //namespace detail +} //namespace glm + +#endif //__bvec2_inl__ diff --git a/wip/sse/glm/core/_bvec3.h b/wip/sse/glm/core/_bvec3.h new file mode 100644 index 00000000..92d96609 --- /dev/null +++ b/wip/sse/glm/core/_bvec3.h @@ -0,0 +1,67 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_bvec3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_bvec3__ +#define __glm_core_bvec3__ + +#include "./_cvec3.inl" + +namespace glm{ +namespace detail{ + + class _bvec3 : public _cvec3, _xref3 > + { + public: + // Common constructors + _bvec3(); + _bvec3(const _bvec3& v); + + // Swizzle constructors + _bvec3(const _xref3& r); + + // Bool constructors + explicit _bvec3(const bool a); + explicit _bvec3(const bool a, const bool b, const bool c); + explicit _bvec3(const bool a, const bool b, const _bvec2& c); + explicit _bvec3(const bool a, const bool b, const _bvec3& c); + explicit _bvec3(const bool a, const bool b, const _bvec4& c); + explicit _bvec3(const bool a, const _bvec2& b); + explicit _bvec3(const bool a, const _bvec3& b); + explicit _bvec3(const bool a, const _bvec4& b); + explicit _bvec3(const _bvec2& a, bool b); + explicit _bvec3(const _bvec2& a, const _bvec2& b); + explicit _bvec3(const _bvec2& a, const _bvec3& b); + explicit _bvec3(const _bvec2& a, const _bvec4& b); + explicit _bvec3(const _bvec4& a); + + // U constructors + template explicit _bvec3(const U x); + template explicit _bvec3(const U a, const U b, const U c); + template explicit _bvec3(const U a, const U b, const _xvec2& c); + template explicit _bvec3(const U a, const U b, const _xvec3& c); + template explicit _bvec3(const U a, const U b, const _xvec4& c); + template explicit _bvec3(const U a, const _xvec2& b); + template explicit _bvec3(const U a, const _xvec3& b); + template explicit _bvec3(const U a, const _xvec4& b); + template explicit _bvec3(const _xvec2& a, U b); + template explicit _bvec3(const _xvec2& a, const _xvec2& b); + template explicit _bvec3(const _xvec2& a, const _xvec3& b); + template explicit _bvec3(const _xvec2& a, const _xvec4& b); + template explicit _bvec3(const _xvec3& a); + template explicit _bvec3(const _xvec4& a); + + // Operators + _bvec3& operator=(const _bvec3& x); + //_bvec3 operator! () const; + }; + +} //namespace detail +} //namespace glm + +#endif//__glm_core_bvec3__ diff --git a/wip/sse/glm/core/_bvec3.inl b/wip/sse/glm/core/_bvec3.inl new file mode 100644 index 00000000..842d2b7b --- /dev/null +++ b/wip/sse/glm/core/_bvec3.inl @@ -0,0 +1,224 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : _bvec3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __bvec3_inl__ +#define __bvec3_inl__ + +#include "./_bvec2.h" +#include "./_bvec3.h" +#include "./_bvec4.h" +#include "./_xref2.h" +#include "./_xref3.h" +#include "./_xref4.h" +#include "./_swizzle.inl" + +namespace glm{ +namespace detail{ + + ////////////////////////////////////////////////////////////// + // Common constructors + + inline _bvec3::_bvec3() : + _cvec3(false, false, false) + {} + + inline _bvec3::_bvec3(const _bvec3& v) : + _cvec3(v.x, v.y, v.z) + {} + + ////////////////////////////////////////////////////////////// + // Swizzle constructors + inline _bvec3::_bvec3(const _xref3& r) : + _cvec3(r.x, r.y, r.z) + {} + + ////////////////////////////////////////////////////////////// + // Bool constructors + + inline _bvec3::_bvec3(const bool a) : + _cvec3(a, a, a) + {} + + inline _bvec3::_bvec3(const bool a, const bool b, const bool c) : + _cvec3(a, b, c) + {} + + inline _bvec3::_bvec3(const bool a, const bool b, const _bvec2& c) : + _cvec3(a, b, c.x) + {} + + inline _bvec3::_bvec3(const bool a, const bool b, const _bvec3& c) : + _cvec3(a, b, c.x) + {} + + inline _bvec3::_bvec3(const bool a, const bool b, const _bvec4& c) : + _cvec3(a, b, c.x) + {} + + inline _bvec3::_bvec3(const bool a, const _bvec2& b) : + _cvec3(a, b.x, b.y) + {} + + inline _bvec3::_bvec3(const bool a, const _bvec3& b) : + _cvec3(a, b.x, b.y) + {} + + inline _bvec3::_bvec3(const bool a, const _bvec4& b) : + _cvec3(a, b.x, b.y) + {} + + inline _bvec3::_bvec3(const _bvec2& a, bool b) : + _cvec3(a.x, a.y, b) + {} + + inline _bvec3::_bvec3(const _bvec2& a, const _bvec2& b) : + _cvec3(a.x, a.y, b.x) + {} + + inline _bvec3::_bvec3(const _bvec2& a, const _bvec3& b) : + _cvec3(a.x, a.y, b.x) + {} + + inline _bvec3::_bvec3(const _bvec2& a, const _bvec4& b) : + _cvec3(a.x, a.y, b.x) + {} + + inline _bvec3::_bvec3(const _bvec4& a) : + _cvec3(a.x, a.y, a.z) + {} + + ////////////////////////////////////////////////////////////// + // U constructors + + template + inline _bvec3::_bvec3(const U a) : + _cvec3(bool(a), bool(a), bool(a)) + {} + + template + inline _bvec3::_bvec3(const U a, const U b, const U c) : + _cvec3(bool(a), bool(b), bool(c)) + {} + + template + inline _bvec3::_bvec3(const U a, const U b, const _xvec2& c) : + _cvec3(bool(a), bool(b), bool(c.x)) + {} + + template + inline _bvec3::_bvec3(const U a, const U b, const _xvec3& c) : + _cvec3(bool(a), bool(b), bool(c.x)) + {} + + template + inline _bvec3::_bvec3(const U a, const U b, const _xvec4& c) : + _cvec3(bool(a), bool(b), bool(c.x)) + {} + + template + inline _bvec3::_bvec3(const U a, const _xvec2& b) : + _cvec3(bool(a), bool(b.x), bool(b.y)) + {} + + template + inline _bvec3::_bvec3(const U a, const _xvec3& b) : + _cvec3(bool(a), bool(b.x), bool(b.y)) + {} + + template + inline _bvec3::_bvec3(const U a, const _xvec4& b) : + _cvec3(bool(a), bool(b.x), bool(b.y)) + {} + + template + inline _bvec3::_bvec3(const _xvec2& a, U b) : + _cvec3(bool(a.x), bool(a.y), bool(b)) + {} + + template + inline _bvec3::_bvec3(const _xvec2& a, const _xvec2& b) : + _cvec3(bool(a.x), bool(a.y), bool(b.x)) + {} + + template + inline _bvec3::_bvec3(const _xvec2& a, const _xvec3& b) : + _cvec3(bool(a.x), bool(a.y), bool(b.x)) + {} + + template + inline _bvec3::_bvec3(const _xvec2& a, const _xvec4& b) : + _cvec3(bool(a.x), bool(a.y), bool(b.x)) + {} + + template + inline _bvec3::_bvec3(const _xvec3& a) : + _cvec3(bool(a.x), bool(a.y), bool(a.z)) + {} + + template + inline _bvec3::_bvec3(const _xvec4& a) : + _cvec3(bool(a.x), bool(a.y), bool(a.z)) + {} + + ////////////////////////////////////////////////////////////// + // bvec3 operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + inline _bvec3& _bvec3::operator=(const _bvec3& x) + { + this->x = x.x; + this->y = x.y; + this->z = x.z; + return *this; + } +/* + inline _bvec3 _bvec3::operator--() + { + this->x = !x; + this->y = !y; + this->z = !z; + return *this; + } + + inline _bvec3 _bvec3::operator++() + { + this->x = !x; + this->y = !y; + this->z = !z; + return *this; + } + + inline const _bvec3 _bvec3::operator--(int n) const + { + return _bvec3( + !this->x, + !this->y, + !this->z); + } + + inline const _bvec3 _bvec3::operator++(int n) const + { + return _bvec3( + !this->x, + !this->y, + !this->z); + } +*/ + //inline _bvec3 _bvec3::operator!() const + //{ + // return _bvec3( + // !this->x, + // !this->y, + // !this->z); + //} + +} //namespace detail +} //namespace glm + +#endif//__bvec3_inl__ diff --git a/wip/sse/glm/core/_bvec4.h b/wip/sse/glm/core/_bvec4.h new file mode 100644 index 00000000..62796934 --- /dev/null +++ b/wip/sse/glm/core/_bvec4.h @@ -0,0 +1,91 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_bvec4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_bvec4__ +#define __glm_core_bvec4__ + +#include "./_cvec4.inl" + +namespace glm{ +namespace detail{ + + class _bvec4 : public _cvec4, _xref3, _xref4 > + { + public: + // Common constructors + _bvec4(); + _bvec4(const _bvec4& v); + + // Swizzle constructors + _bvec4(const _xref4& r); + + // Bool constructors + explicit _bvec4(const bool x); + explicit _bvec4(const bool a, const bool b, const bool c, const bool d); + explicit _bvec4(const bool a, const bool b, const bool c, const _bvec2& d); + explicit _bvec4(const bool a, const bool b, const bool c, const _bvec3& d); + explicit _bvec4(const bool a, const bool b, const bool c, const _bvec4& d); + explicit _bvec4(const bool a, const bool b, const _bvec2& c); + explicit _bvec4(const bool a, const bool b, const _bvec3& c); + explicit _bvec4(const bool a, const bool b, const _bvec4& c); + explicit _bvec4(const bool a, const _bvec2& b, const bool c); + explicit _bvec4(const bool a, const _bvec2& b, const _bvec2& c); + explicit _bvec4(const bool a, const _bvec2& b, const _bvec3& c); + explicit _bvec4(const bool a, const _bvec2& b, const _bvec4& c); + explicit _bvec4(const bool a, const _bvec3& b); + explicit _bvec4(const bool a, const _bvec4& b); + explicit _bvec4(const _bvec2& a, const bool b, const bool c); + explicit _bvec4(const _bvec2& a, const bool b, const _bvec2& c); + explicit _bvec4(const _bvec2& a, const bool b, const _bvec3& c); + explicit _bvec4(const _bvec2& a, const bool b, const _bvec4& c); + explicit _bvec4(const _bvec2& a, const _bvec2& b); + explicit _bvec4(const _bvec2& a, const _bvec3& b); + explicit _bvec4(const _bvec2& a, const _bvec4& b); + explicit _bvec4(const _bvec3& a, const bool b); + explicit _bvec4(const _bvec3& a, const _bvec2& b); + explicit _bvec4(const _bvec3& a, const _bvec3& b); + explicit _bvec4(const _bvec3& a, const _bvec4& b); + + // U constructors + template explicit _bvec4(const U x); + template explicit _bvec4(const U a, const U b, const U c, const U d); + template explicit _bvec4(const U a, const U b, const U c, const _xvec2& d); + template explicit _bvec4(const U a, const U b, const U c, const _xvec3& d); + template explicit _bvec4(const U a, const U b, const U c, const _xvec4& d); + template explicit _bvec4(const U a, const U b, const _xvec2& c); + template explicit _bvec4(const U a, const U b, const _xvec3& c); + template explicit _bvec4(const U a, const U b, const _xvec4& c); + template explicit _bvec4(const U a, const _xvec2& b, const U c); + template explicit _bvec4(const U a, const _xvec2& b, const _xvec2& c); + template explicit _bvec4(const U a, const _xvec2& b, const _xvec3& c); + template explicit _bvec4(const U a, const _xvec2& b, const _xvec4& c); + template explicit _bvec4(const U a, const _xvec3& b); + template explicit _bvec4(const U a, const _xvec4& b); + template explicit _bvec4(const _xvec2& a, const U b, const U c); + template explicit _bvec4(const _xvec2& a, const U b, const _xvec2& c); + template explicit _bvec4(const _xvec2& a, const U b, const _xvec3& c); + template explicit _bvec4(const _xvec2& a, const U b, const _xvec4& c); + template explicit _bvec4(const _xvec2& a, const _xvec2& b); + template explicit _bvec4(const _xvec2& a, const _xvec3& b); + template explicit _bvec4(const _xvec2& a, const _xvec4& b); + template explicit _bvec4(const _xvec3& a, const U b); + template explicit _bvec4(const _xvec3& a, const _xvec2& b); + template explicit _bvec4(const _xvec3& a, const _xvec3& b); + template explicit _bvec4(const _xvec3& a, const _xvec4& b); + template explicit _bvec4(const _xvec4& a); + + // Operators + _bvec4& operator=(const _bvec4& x); + //_bvec4 operator!() const ; + }; + +} //namespace detail +} //namespace glm + +#endif//__glm_core_bvec4__ diff --git a/wip/sse/glm/core/_bvec4.inl b/wip/sse/glm/core/_bvec4.inl new file mode 100644 index 00000000..6fb72743 --- /dev/null +++ b/wip/sse/glm/core/_bvec4.inl @@ -0,0 +1,335 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : _bvec4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __bvec4_inl__ +#define __bvec4_inl__ + +#include "./_bvec2.h" +#include "./_bvec3.h" +#include "./_bvec4.h" +#include "./_xref2.h" +#include "./_xref3.h" +#include "./_xref4.h" +#include "./_swizzle.inl" + +namespace glm{ +namespace detail{ + + ////////////////////////////////////////////////////////////// + // bvec4 constructors + + inline _bvec4::_bvec4() : + _cvec4(false, false, false, false) + {} + + inline _bvec4::_bvec4(const _bvec4& v) : + _cvec4(v.x, v.y, v.z, v.w) + {} + + ////////////////////////////////////////////////////////////// + // Swizzle constructors + inline _bvec4::_bvec4(const _xref4& r) : + _cvec4(r.x, r.y, r.z, r.w) + {} + + // Bool constructors + inline _bvec4::_bvec4(const bool a) : + _cvec4(a, a, a, a) + {} + + inline _bvec4::_bvec4(const bool a, const bool b, const bool c, const bool d) : + _cvec4(a, b, c, d) + {} + + inline _bvec4::_bvec4(const bool a, const bool b, const bool c, const _bvec2& d) : + _cvec4(a, b, c, d.x) + {} + + inline _bvec4::_bvec4(const bool a, const bool b, const bool c, const _bvec3& d) : + _cvec4(a, b, c, d.x) + {} + + inline _bvec4::_bvec4(const bool a, const bool b, const bool c, const _bvec4& d) : + _cvec4(a, b, c, d.x) + {} + + inline _bvec4::_bvec4(const bool a, const bool b, const _bvec2& c) : + _cvec4(a, b, c.x, c.y) + {} + + inline _bvec4::_bvec4(const bool a, const bool b, const _bvec3& c) : + _cvec4(a, b, c.x, c.y) + {} + + inline _bvec4::_bvec4(const bool a, const bool b, const _bvec4& c) : + _cvec4(a, b, c.x, c.y) + {} + + inline _bvec4::_bvec4(const bool a, const _bvec2& b, const bool c) : + _cvec4(a, b.x, b.y, c) + {} + + inline _bvec4::_bvec4(const bool a, const _bvec2& b, const _bvec2& c) : + _cvec4(a, b.x, b.y, c.x) + {} + + inline _bvec4::_bvec4(const bool a, const _bvec2& b, const _bvec3& c) : + _cvec4(a, b.x, b.y, c.x) + {} + + inline _bvec4::_bvec4(const bool a, const _bvec2& b, const _bvec4& c) : + _cvec4(a, b.x, b.y, c.x) + {} + + inline _bvec4::_bvec4(const bool a, const _bvec3& b) : + _cvec4(a, b.x, b.y, b.z) + {} + + inline _bvec4::_bvec4(const bool a, const _bvec4& b) : + _cvec4(a, b.x, b.y, b.z) + {} + + inline _bvec4::_bvec4(const _bvec2& a, const bool b, const bool c) : + _cvec4(a.x, a.y, b, c) + {} + + inline _bvec4::_bvec4(const _bvec2& a, const bool b, const _bvec2& c) : + _cvec4(a.x, a.y, b, c.x) + {} + + inline _bvec4::_bvec4(const _bvec2& a, const bool b, const _bvec3& c) : + _cvec4(a.x, a.y, b, c.x) + {} + + inline _bvec4::_bvec4(const _bvec2& a, const bool b, const _bvec4& c) : + _cvec4(a.x, a.y, b, c.x) + {} + + inline _bvec4::_bvec4(const _bvec2& a, const _bvec2& b) : + _cvec4(a.x, a.y, b.x, b.y) + {} + + inline _bvec4::_bvec4(const _bvec2& a, const _bvec3& b) : + _cvec4(a.x, a.y, b.x, b.y) + {} + + inline _bvec4::_bvec4(const _bvec2& a, const _bvec4& b) : + _cvec4(a.x, a.y, b.x, b.y) + {} + + inline _bvec4::_bvec4(const _bvec3& a, const bool b) : + _cvec4(a.x, a.y, a.z, b) + {} + + inline _bvec4::_bvec4(const _bvec3& a, const _bvec2& b) : + _cvec4(a.x, a.y, a.z, b.x) + {} + + inline _bvec4::_bvec4(const _bvec3& a, const _bvec3& b) : + _cvec4(a.x, a.y, a.z, b.x) + {} + + inline _bvec4::_bvec4(const _bvec3& a, const _bvec4& b) : + _cvec4(a.x, a.y, a.z, b.x) + {} + + ////////////////////////////////////////////////////////////// + // U constructors + template + inline _bvec4::_bvec4(const U a) : + _cvec4(bool(a), bool(a), bool(a), bool(a)) + {} + + template + inline _bvec4::_bvec4(const U a, const U b, const U c, const U d) : + _cvec4(bool(a), bool(b), bool(c), bool(d)) + {} + + template + inline _bvec4::_bvec4(const U a, const U b, const U c, const _xvec2& d) : + _cvec4(bool(a), bool(b), bool(c), bool(d.x)) + {} + + template + inline _bvec4::_bvec4(const U a, const U b, const U c, const _xvec3& d) : + _cvec4(bool(a), bool(b), bool(c), bool(d.x)) + {} + + template + inline _bvec4::_bvec4(const U a, const U b, const U c, const _xvec4& d) : + _cvec4(bool(a), bool(b), bool(c), bool(d.x)) + {} + + template + inline _bvec4::_bvec4(const U a, const U b, const _xvec2& c) : + _cvec4(bool(a), bool(b), bool(c.x), bool(c.y)) + {} + + template + inline _bvec4::_bvec4(const U a, const U b, const _xvec3& c) : + _cvec4(bool(a), bool(b), bool(c.x), bool(c.y)) + {} + + template + inline _bvec4::_bvec4(const U a, const U b, const _xvec4& c) : + _cvec4(bool(a), bool(b), bool(c.x), bool(c.y)) + {} + + template + inline _bvec4::_bvec4(const U a, const _xvec2& b, const U c) : + _cvec4(bool(a), bool(b.x), bool(b.y), bool(c)) + {} + + template + inline _bvec4::_bvec4(const U a, const _xvec2& b, const _xvec2& c) : + _cvec4(bool(a), bool(b.x), bool(b.y), bool(c.x)) + {} + + template + inline _bvec4::_bvec4(const U a, const _xvec2& b, const _xvec3& c) : + _cvec4(bool(a), bool(b.x), bool(b.y), bool(c.x)) + {} + + template + inline _bvec4::_bvec4(const U a, const _xvec2& b, const _xvec4& c) : + _cvec4(bool(a), bool(b.x), bool(b.y), bool(c.x)) + {} + + template + inline _bvec4::_bvec4(const U a, const _xvec3& b) : + _cvec4(bool(a), bool(b.x), bool(b.y), bool(b.z)) + {} + + template + inline _bvec4::_bvec4(const U a, const _xvec4& b) : + _cvec4(bool(a), bool(b.x), bool(b.y), bool(b.z)) + {} + + template + inline _bvec4::_bvec4(const _xvec2& a, const U b, const U c) : + _cvec4(bool(a.x), bool(a.y), bool(b), bool(c)) + {} + + template + inline _bvec4::_bvec4(const _xvec2& a, const U b, const _xvec2& c) : + _cvec4(bool(a.x), bool(a.y), bool(b), bool(c.x)) + {} + + template + inline _bvec4::_bvec4(const _xvec2& a, const U b, const _xvec3& c) : + _cvec4(bool(a.x), bool(a.y), bool(b), bool(c.x)) + {} + + template + inline _bvec4::_bvec4(const _xvec2& a, const U b, const _xvec4& c) : + _cvec4(bool(a.x), bool(a.y), bool(b), bool(c.x)) + {} + + template + inline _bvec4::_bvec4(const _xvec2& a, const _xvec2& b) : + _cvec4(bool(a.x), bool(a.y), bool(b.x), bool(b.y)) + {} + + template + inline _bvec4::_bvec4(const _xvec2& a, const _xvec3& b) : + _cvec4(bool(a.x), bool(a.y), bool(b.x), bool(b.y)) + {} + + template + inline _bvec4::_bvec4(const _xvec2& a, const _xvec4& b) : + _cvec4(bool(a.x), bool(a.y), bool(b.x), bool(b.y)) + {} + + template + inline _bvec4::_bvec4(const _xvec3& a, const U b) : + _cvec4(bool(a.x), bool(a.y), bool(a.z), bool(b)) + {} + + template + inline _bvec4::_bvec4(const _xvec3& a, const _xvec2& b) : + _cvec4(bool(a.x), bool(a.y), bool(a.z), bool(b.x)) + {} + + template + inline _bvec4::_bvec4(const _xvec3& a, const _xvec3& b) : + _cvec4(bool(a.x), bool(a.y), bool(a.z), bool(b.x)) + {} + + template + inline _bvec4::_bvec4(const _xvec3& a, const _xvec4& b) : + _cvec4(bool(a.x), bool(a.y), bool(a.z), bool(b.x)) + {} + + template + inline _bvec4::_bvec4(const _xvec4& a) : + _cvec4(bool(a.x), bool(a.y), bool(a.z), bool(a.w)) + {} + + ////////////////////////////////////////////////////////////// + // bvec4 operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + inline _bvec4& _bvec4::operator=(const _bvec4& v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + this->w = v.w; + return *this; + } +/* + inline _bvec4 _bvec4::operator--() + { + this->x = !x; + this->y = !y; + this->z = !z; + this->w = !w; + return *this; + } + + inline _bvec4 _bvec4::operator++() + { + this->x = !x; + this->y = !y; + this->z = !z; + this->w = !w; + return *this; + } + + inline const _bvec4 _bvec4::operator--(int n) const + { + return _bvec4( + !this->x, + !this->y, + !this->z, + !this->w); + } + + inline const _bvec4 _bvec4::operator++(int n) const + { + return _bvec4( + !this->x, + !this->y, + !this->z, + !this->w); + } +*/ + //inline _bvec4 _bvec4::operator!() const + //{ + // return _bvec4( + // !this->x, + // !this->y, + // !this->z, + // !this->w); + //} + +} //namespace detail +} //namespace glm + +#endif//__bvec4_inl__ diff --git a/wip/sse/glm/core/_cvec2.h b/wip/sse/glm/core/_cvec2.h new file mode 100644 index 00000000..aeb75204 --- /dev/null +++ b/wip/sse/glm/core/_cvec2.h @@ -0,0 +1,113 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-12 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_cvec2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_cvec2__ +#define __glm_core_cvec2__ + +#include "_cvecx.h" + +namespace glm{ +namespace detail{ + + template + class _cvec2 + { + public: + typedef T value_type; + typedef int size_type; + static const size_type value_size; + + // Data + /* ISO C++ version unavailable with VC7.1 ... + union{T x, r, s;}; + union{T y, g, t;}; + */ + // Solution away from ISO C++ but available with VC7.1 and GCC without -pedantic +/* + union + { + struct{T x, y;}; + struct{T r, g;}; + struct{T s, t;}; + }; +*/ +#ifndef GLM_SINGLE_COMP_NAME +#ifdef GLM_COMPILER_GCC + union {T x, r, s;}; + union {T y, g, t;}; +#endif//GLM_COMPILER_GCC + +#ifdef GLM_COMPILER_VC + union + { + struct{T x, y;}; + struct{T r, g;}; + struct{T s, t;}; + }; +#endif//GLM_COMPILER_VC + +#else + T x, y; +#endif//GLM_SINGLE_COMP_NAME + + // Conclassor + _cvec2(){} + _cvec2(const T x, const T y); + + // Accesses + T& operator[](size_type i); + const T operator[](size_type i) const; + operator T*(); + operator const T*() const; + +#if defined(GLM_SWIZZLE) + // Left hand side 2 components common swizzle operators + REF2 _xy(); + REF2 _yx(); + + // Right hand side 2 components common swizzle operators + const VEC2 _xx() const; + const VEC2 _yx() const; + VEC2 _xy() const; + const VEC2 _yy() const; + + // Right hand side 3 components common swizzle operators + const VEC3 _xxx() const; + const VEC3 _yxx() const; + const VEC3 _xyx() const; + const VEC3 _yyx() const; + const VEC3 _xxy() const; + const VEC3 _yxy() const; + const VEC3 _xyy() const; + const VEC3 _yyy() const; + + // Right hand side 4 components common swizzle operators + const VEC4 _xxxx() const; + const VEC4 _yxxx() const; + const VEC4 _xyxx() const; + const VEC4 _yyxx() const; + const VEC4 _xxyx() const; + const VEC4 _yxyx() const; + const VEC4 _xyyx() const; + const VEC4 _yyyx() const; + const VEC4 _xxxy() const; + const VEC4 _yxxy() const; + const VEC4 _xyxy() const; + const VEC4 _yyxy() const; + const VEC4 _xxyy() const; + const VEC4 _yxyy() const; + const VEC4 _xyyy() const; + const VEC4 _yyyy() const; +#endif// defined(GLM_SWIZZLE) + }; + +} //namespace detail +} //namespace glm + +#endif //__glm_core_cvec2__ diff --git a/wip/sse/glm/core/_cvec2.inl b/wip/sse/glm/core/_cvec2.inl new file mode 100644 index 00000000..3c74ae1d --- /dev/null +++ b/wip/sse/glm/core/_cvec2.inl @@ -0,0 +1,253 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-15 +// Updated : 2007-01-15 +// Licence : This source is under GNU LGPL licence +// File : _cvec2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __cvec2_inl__ +#define __cvec2_inl__ + +#include "_cvec2.h" + +namespace glm{ +namespace detail{ + + template + const int _cvec2::value_size = 2; + + ////////////////////////////////////////////////////////////// + // _cvec2 constructor + + template + inline _cvec2::_cvec2(const T x, const T y) : + x(x), y(y) + {} + + ////////////////////////////////////////////////////////////// + // vec2 and ivec2 accesses + + template + inline T& _cvec2::operator [] (int i) + { + return (&x)[i]; + } + + template + inline const T _cvec2::operator [] (int i) const + { + return (&x)[i]; + } + + template + inline _cvec2::operator T* () + { + return &x; + } + + template + inline _cvec2::operator const T* () const + { + return &x; + } + +#if defined(GLM_SWIZZLE) + ////////////////////////////////////////////////////////////// + // Left hand side 2 components common swizzle operator + + template + inline REF2 _cvec2::_xy() + { + return REF2(this->x, this->y); + } + + template + inline REF2 _cvec2::_yx() + { + return REF2(this->y, this->x); + } + + ////////////////////////////////////////////////////////////// + // Right hand side 2 components common swizzle operators + + template + inline const VEC2 _cvec2::_xx() const + { + return VEC2(this->x, this->x); + } + + template + inline const VEC2 _cvec2::_yx() const + { + return VEC2(this->y, this->x); + } + + template + inline VEC2 _cvec2::_xy() const + { + return VEC2(this->x, this->y); + } + + template + inline const VEC2 _cvec2::_yy() const + { + return VEC2(this->y, this->y); + } + + ////////////////////////////////////////////////////////////// + // Right hand side 3 components common swizzle operators + + template + inline const VEC3 _cvec2::_xxx() const + { + return VEC3(this->x, this->x, this->x); + } + + template + inline const VEC3 _cvec2::_yxx() const + { + return VEC3(this->y, this->x, this->x); + } + + template + inline const VEC3 _cvec2::_xyx() const + { + return VEC3(this->x, this->y, this->x); + } + + template + inline const VEC3 _cvec2::_yyx() const + { + return VEC3(this->y, this->y, this->x); + } + + template + inline const VEC3 _cvec2::_xxy() const + { + return VEC3(this->x, this->x, this->y); + } + + template + inline const VEC3 _cvec2::_yxy() const + { + return VEC3(this->y, this->x, this->y); + } + + template + inline const VEC3 _cvec2::_xyy() const + { + return VEC3(this->x, this->y, this->y); + } + + template + inline const VEC3 _cvec2::_yyy() const + { + return VEC3(this->y, this->y, this->y); + } + + ////////////////////////////////////////////////////////////// + // Right hand side 4 components common swizzle operators + + template + inline const VEC4 _cvec2::_xxxx() const + { + return VEC4(this->x, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec2::_yxxx() const + { + return VEC4(this->y, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec2::_xyxx() const + { + return VEC4(this->x, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec2::_yyxx() const + { + return VEC4(this->y, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec2::_xxyx() const + { + return VEC4(this->x, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec2::_yxyx() const + { + return VEC4(this->y, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec2::_xyyx() const + { + return VEC4(this->x, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec2::_yyyx() const + { + return VEC4(this->y, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec2::_xxxy() const + { + return VEC4(this->x, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec2::_yxxy() const + { + return VEC4(this->y, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec2::_xyxy() const + { + return VEC4(this->x, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec2::_yyxy() const + { + return VEC4(this->y, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec2::_xxyy() const + { + return VEC4(this->x, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec2::_yxyy() const + { + return VEC4(this->y, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec2::_xyyy() const + { + return VEC4(this->x, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec2::_yyyy() const + { + return VEC4(this->y, this->y, this->y, this->y); + } +#endif //defined(GLM_SWIZZLE) + +} //namespace detail +} //namespace glm + +#endif //__cvec2_inl__ diff --git a/wip/sse/glm/core/_cvec3.h b/wip/sse/glm/core/_cvec3.h new file mode 100644 index 00000000..d810401b --- /dev/null +++ b/wip/sse/glm/core/_cvec3.h @@ -0,0 +1,217 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-15 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_cvec3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_cvec3__ +#define __glm_core_cvec3__ + +#include "_cvecx.h" + +namespace glm{ +namespace detail{ + + template + class _cvec3 + { + public: + typedef T value_type; + typedef int size_type; + static const size_type value_size; + + // Data + /* ISO C++ version unavailable with VC7.1 ... + union{T x, r, s;}; + union{T y, g, t;}; + union{T z, b, p;}; + */ + // Solution away from ISO C++ but available with VC7.1 and GCC without -pedantic +/* + union + { + struct{T x, y, z;}; + struct{T r, g, b;}; + struct{T s, t, p;}; + }; +*/ + +#ifndef GLM_SINGLE_COMP_NAME +#ifdef GLM_COMPILER_GCC + union{T x, r, s;}; + union{T y, g, t;}; + union{T z, b, p;}; +#endif//GLM_COMPILER_GCC + +#ifdef GLM_COMPILER_VC + union + { + struct{T x, y, z;}; + struct{T r, g, b;}; + struct{T s, t, p;}; + }; +#endif//GLM_COMPILER_VC + +#else + T x, y, z; +#endif//GLM_SINGLE_COMP_NAME + + // Constructor + _cvec3(){} + _cvec3(const T x, const T y, const T z); + + // Accesses + T& operator [] (size_type i); + const T operator [] (size_type i) const; + operator T* (); + operator const T* () const; + +#if defined(GLM_SWIZZLE) + // Left hand side 2 components common swizzle operators + REF2 _yx(); + REF2 _zx(); + REF2 _xy(); + REF2 _zy(); + REF2 _xz(); + REF2 _yz(); + + // Right hand side 2 components common swizzle operators + const VEC2 _xx() const; + const VEC2 _yx() const; + const VEC2 _zx() const; + const VEC2 _xy() const; + const VEC2 _yy() const; + const VEC2 _zy() const; + const VEC2 _xz() const; + const VEC2 _yz() const; + const VEC2 _zz() const; + + // Left hand side 3 components common swizzle operators + REF3 _zyx(); + REF3 _yzx(); + REF3 _zxy(); + REF3 _xzy(); + REF3 _yxz(); + REF3 _xyz(); + + // Right hand side 3 components common swizzle operators + const VEC3 _xxx() const; + const VEC3 _yxx() const; + const VEC3 _zxx() const; + const VEC3 _xyx() const; + const VEC3 _yyx() const; + const VEC3 _zyx() const; + const VEC3 _xzx() const; + const VEC3 _yzx() const; + const VEC3 _zzx() const; + const VEC3 _xxy() const; + const VEC3 _yxy() const; + const VEC3 _zxy() const; + const VEC3 _xyy() const; + const VEC3 _yyy() const; + const VEC3 _zyy() const; + const VEC3 _xzy() const; + const VEC3 _yzy() const; + const VEC3 _zzy() const; + const VEC3 _xxz() const; + const VEC3 _yxz() const; + const VEC3 _zxz() const; + const VEC3 _xyz() const; + const VEC3 _yyz() const; + const VEC3 _zyz() const; + const VEC3 _xzz() const; + const VEC3 _yzz() const; + const VEC3 _zzz() const; + + // 4 components common swizzle operators + const VEC4 _xxxx() const; + const VEC4 _yxxx() const; + const VEC4 _zxxx() const; + const VEC4 _xyxx() const; + const VEC4 _yyxx() const; + const VEC4 _zyxx() const; + const VEC4 _xzxx() const; + const VEC4 _yzxx() const; + const VEC4 _zzxx() const; + const VEC4 _xxyx() const; + const VEC4 _yxyx() const; + const VEC4 _zxyx() const; + const VEC4 _xyyx() const; + const VEC4 _yyyx() const; + const VEC4 _zyyx() const; + const VEC4 _xzyx() const; + const VEC4 _yzyx() const; + const VEC4 _zzyx() const; + const VEC4 _xxzx() const; + const VEC4 _yxzx() const; + const VEC4 _zxzx() const; + const VEC4 _xyzx() const; + const VEC4 _yyzx() const; + const VEC4 _zyzx() const; + const VEC4 _xzzx() const; + const VEC4 _yzzx() const; + const VEC4 _zzzx() const; + const VEC4 _xxxy() const; + const VEC4 _yxxy() const; + const VEC4 _zxxy() const; + const VEC4 _xyxy() const; + const VEC4 _yyxy() const; + const VEC4 _zyxy() const; + const VEC4 _xzxy() const; + const VEC4 _yzxy() const; + const VEC4 _zzxy() const; + const VEC4 _xxyy() const; + const VEC4 _yxyy() const; + const VEC4 _zxyy() const; + const VEC4 _xyyy() const; + const VEC4 _yyyy() const; + const VEC4 _zyyy() const; + const VEC4 _xzyy() const; + const VEC4 _yzyy() const; + const VEC4 _zzyy() const; + const VEC4 _xxzy() const; + const VEC4 _yxzy() const; + const VEC4 _zxzy() const; + const VEC4 _xyzy() const; + const VEC4 _yyzy() const; + const VEC4 _zyzy() const; + const VEC4 _xzzy() const; + const VEC4 _yzzy() const; + const VEC4 _zzzy() const; + const VEC4 _xxxz() const; + const VEC4 _yxxz() const; + const VEC4 _zxxz() const; + const VEC4 _xyxz() const; + const VEC4 _yyxz() const; + const VEC4 _zyxz() const; + const VEC4 _xzxz() const; + const VEC4 _yzxz() const; + const VEC4 _zzxz() const; + const VEC4 _xxyz() const; + const VEC4 _yxyz() const; + const VEC4 _zxyz() const; + const VEC4 _xyyz() const; + const VEC4 _yyyz() const; + const VEC4 _zyyz() const; + const VEC4 _xzyz() const; + const VEC4 _yzyz() const; + const VEC4 _zzyz() const; + const VEC4 _xxzz() const; + const VEC4 _yxzz() const; + const VEC4 _zxzz() const; + const VEC4 _xyzz() const; + const VEC4 _yyzz() const; + const VEC4 _zyzz() const; + const VEC4 _xzzz() const; + const VEC4 _yzzz() const; + const VEC4 _zzzz() const; +#endif// defined(GLM_SWIZZLE) + }; + +} //namespace detail +} //namespace glm + +#endif//__cvec3_h__ diff --git a/wip/sse/glm/core/_cvec3.inl b/wip/sse/glm/core/_cvec3.inl new file mode 100644 index 00000000..c6847f0b --- /dev/null +++ b/wip/sse/glm/core/_cvec3.inl @@ -0,0 +1,849 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-15 +// Updated : 2007-01-15 +// Licence : This source is under GNU LGPL licence +// File : _cvec3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __cvec3_inl__ +#define __cvec3_inl__ + +#include "_cvec3.h" + +namespace glm{ +namespace detail{ + + template + const int _cvec3::value_size = 3; + + ////////////////////////////////////////////////////////////// + // _cvec3 constructor + + template + inline _cvec3::_cvec3(const T x, const T y, const T z) : + x(x), y(y), z(z) + {} + + ////////////////////////////////////////////////////////////// + // vec3 and ivec3 accesses + + template + inline T& _cvec3::operator [] (int i) + { + return (&x)[i]; + } + + template + inline const T _cvec3::operator [] (int i) const + { + return (&x)[i]; + } + + template + inline _cvec3::operator T* () + { + return &x; + } + + template + inline _cvec3::operator const T* () const + { + return &x; + } + +#if defined(GLM_SWIZZLE) + ////////////////////////////////////////////////////////////// + // Left hand side 2 components common swizzle operators + + template + inline REF2 _cvec3::_yx() + { + return REF2(this->y, this->x); + } + + template + inline REF2 _cvec3::_zx() + { + return REF2(this->z, this->x); + } + + template + inline REF2 _cvec3::_xy() + { + return REF2(this->x, this->y); + } + + template + inline REF2 _cvec3::_zy() + { + return REF2(this->x, this->y); + } + + template + inline REF2 _cvec3::_xz() + { + return REF2(this->x, this->z); + } + + template + inline REF2 _cvec3::_yz() + { + return REF2(this->y, this->z); + } + + ////////////////////////////////////////////////////////////// + // Right hand side 2 components swizzles operators + + template + inline const VEC2 _cvec3::_xx() const + { + return VEC2(this->x, this->x); + } + + template + inline const VEC2 _cvec3::_yx() const + { + return VEC2(this->y, this->x); + } + + template + inline const VEC2 _cvec3::_zx() const + { + return VEC2(this->z, this->x); + } + + template + inline const VEC2 _cvec3::_xy() const + { + return VEC2(this->x, this->y); + } + + template + inline const VEC2 _cvec3::_yy() const + { + return VEC2(this->y, this->y); + } + + template + inline const VEC2 _cvec3::_zy() const + { + return VEC2(this->z, this->y); + } + + template + inline const VEC2 _cvec3::_xz() const + { + return VEC2(this->x, this->z); + } + + template + inline const VEC2 _cvec3::_yz() const + { + return VEC2(this->y, this->z); + } + + template + inline const VEC2 _cvec3::_zz() const + { + return VEC2(this->z, this->z); + } + + ////////////////////////////////////////////////////////////// + // Left hand side 3 components common swizzle operator + + template + inline REF3 _cvec3::_zyx() + { + return REF3(this->z, this->y, this->x); + } + + template + inline REF3 _cvec3::_yzx() + { + return REF3(this->y, this->z, this->x); + } + + template + inline REF3 _cvec3::_zxy() + { + return REF3(this->z, this->x, this->y); + } + + template + inline REF3 _cvec3::_xzy() + { + return REF3(this->x, this->z, this->y); + } + + template + inline REF3 _cvec3::_yxz() + { + return REF3(this->y, this->x, this->z); + } + + template + inline REF3 _cvec3::_xyz() + { + return REF3(this->x, this->y, this->z); + } + + ////////////////////////////////////////////////////////////// + // Right hand side 3 components common swizzle operators + + template + inline const VEC3 _cvec3::_xxx() const + { + return _cvec3(this->x, this->x, this->x); + } + + template + inline const VEC3 _cvec3::_yxx() const + { + return _cvec3(this->y, this->x, this->x); + } + + template + inline const VEC3 _cvec3::_zxx() const + { + return _cvec3(this->z, this->x, this->x); + } + + template + inline const VEC3 _cvec3::_xyx() const + { + return _cvec3(this->x, this->y, this->x); + } + + template + inline const VEC3 _cvec3::_yyx() const + { + return _cvec3(this->y, this->y, this->x); + } + + template + inline const VEC3 _cvec3::_zyx() const + { + return _cvec3(this->z, this->y, this->x); + } + + template + inline const VEC3 _cvec3::_xzx() const + { + return _cvec3(this->x, this->z, this->x); + } + + template + inline const VEC3 _cvec3::_yzx() const + { + return _cvec3(this->y, this->z, this->x); + } + + template + inline const VEC3 _cvec3::_zzx() const + { + return _cvec3(this->z, this->z, this->x); + } + + template + inline const VEC3 _cvec3::_xxy() const + { + return _cvec3(this->x, this->x, this->y); + } + + template + inline const VEC3 _cvec3::_yxy() const + { + return _cvec3(this->y, this->x, this->y); + } + + template + inline const VEC3 _cvec3::_zxy() const + { + return _cvec3(this->z, this->x, this->y); + } + + template + inline const VEC3 _cvec3::_xyy() const + { + return _cvec3(this->x, this->y, this->y); + } + + template + inline const VEC3 _cvec3::_yyy() const + { + return _cvec3(this->y, this->y, this->y); + } + + template + inline const VEC3 _cvec3::_zyy() const + { + return _cvec3(this->z, this->y, this->y); + } + + template + inline const VEC3 _cvec3::_xzy() const + { + return _cvec3(this->x, this->z, this->y); + } + + template + inline const VEC3 _cvec3::_yzy() const + { + return _cvec3(this->y, this->z, this->y); + } + + template + inline const VEC3 _cvec3::_zzy() const + { + return _cvec3(this->z, this->z, this->y); + } + + template + inline const VEC3 _cvec3::_xxz() const + { + return _cvec3(this->x, this->x, this->z); + } + + template + inline const VEC3 _cvec3::_yxz() const + { + return _cvec3(this->y, this->x, this->z); + } + + template + inline const VEC3 _cvec3::_zxz() const + { + return _cvec3(this->z, this->x, this->z); + } + + template + inline const VEC3 _cvec3::_xyz() const + { + return _cvec3(this->x, this->y, this->z); + } + + template + inline const VEC3 _cvec3::_yyz() const + { + return _cvec3(this->y, this->y, this->z); + } + + template + inline const VEC3 _cvec3::_zyz() const + { + return _cvec3(this->z, this->y, this->z); + } + + template + inline const VEC3 _cvec3::_xzz() const + { + return _cvec3(this->x, this->z, this->z); + } + + template + inline const VEC3 _cvec3::_yzz() const + { + return _cvec3(this->y, this->z, this->z); + } + + template + inline const VEC3 _cvec3::_zzz() const + { + return _cvec3(this->z, this->z, this->z); + } + + // Right hand side4 components swizzles operators + template + inline const VEC4 _cvec3::_xxxx() const + { + return VEC4(this->x, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_yxxx() const + { + return VEC4(this->y, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_zxxx() const + { + return VEC4(this->z, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_xyxx() const + { + return VEC4(this->x, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_yyxx() const + { + return VEC4(this->y, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_zyxx() const + { + return VEC4(this->z, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_xzxx() const + { + return VEC4(this->x, this->z, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_yzxx() const + { + return VEC4(this->y, this->z, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_zzxx() const + { + return VEC4(this->z, this->z, this->x, this->x); + } + + template + inline const VEC4 _cvec3::_xxyx() const + { + return VEC4(this->x, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_yxyx() const + { + return VEC4(this->y, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_zxyx() const + { + return VEC4(this->z, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_xyyx() const + { + return VEC4(this->x, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_yyyx() const + { + return VEC4(this->y, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_zyyx() const + { + return VEC4(this->z, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_xzyx() const + { + return VEC4(this->x, this->z, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_yzyx() const + { + return VEC4(this->y, this->z, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_zzyx() const + { + return VEC4(this->z, this->z, this->y, this->x); + } + + template + inline const VEC4 _cvec3::_xxzx() const + { + return VEC4(this->x, this->x, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_yxzx() const + { + return VEC4(this->y, this->x, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_zxzx() const + { + return VEC4(this->z, this->x, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_xyzx() const + { + return VEC4(this->x, this->y, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_yyzx() const + { + return VEC4(this->y, this->y, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_zyzx() const + { + return VEC4(this->z, this->y, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_xzzx() const + { + return VEC4(this->x, this->z, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_yzzx() const + { + return VEC4(this->y, this->z, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_zzzx() const + { + return VEC4(this->z, this->z, this->z, this->x); + } + + template + inline const VEC4 _cvec3::_xxxy() const + { + return VEC4(this->x, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_yxxy() const + { + return VEC4(this->y, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_zxxy() const + { + return VEC4(this->z, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_xyxy() const + { + return VEC4(this->x, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_yyxy() const + { + return VEC4(this->y, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_zyxy() const + { + return VEC4(this->z, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_xzxy() const + { + return VEC4(this->x, this->z, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_yzxy() const + { + return VEC4(this->y, this->z, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_zzxy() const + { + return VEC4(this->z, this->z, this->x, this->y); + } + + template + inline const VEC4 _cvec3::_xxyy() const + { + return VEC4(this->x, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_yxyy() const + { + return VEC4(this->y, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_zxyy() const + { + return VEC4(this->z, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_xyyy() const + { + return VEC4(this->x, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_yyyy() const + { + return VEC4(this->y, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_zyyy() const + { + return VEC4(this->z, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_xzyy() const + { + return VEC4(this->x, this->z, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_yzyy() const + { + return VEC4(this->y, this->z, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_zzyy() const + { + return VEC4(this->z, this->z, this->y, this->y); + } + + template + inline const VEC4 _cvec3::_xxzy() const + { + return VEC4(this->x, this->x, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_yxzy() const + { + return VEC4(this->y, this->x, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_zxzy() const + { + return VEC4(this->z, this->x, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_xyzy() const + { + return VEC4(this->x, this->y, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_yyzy() const + { + return VEC4(this->y, this->y, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_zyzy() const + { + return VEC4(this->z, this->y, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_xzzy() const + { + return VEC4(this->x, this->z, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_yzzy() const + { + return VEC4(this->y, this->z, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_zzzy() const + { + return VEC4(this->z, this->z, this->z, this->y); + } + + template + inline const VEC4 _cvec3::_xxxz() const + { + return VEC4(this->x, this->x, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_yxxz() const + { + return VEC4(this->y, this->x, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_zxxz() const + { + return VEC4(this->z, this->x, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_xyxz() const + { + return VEC4(this->x, this->y, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_yyxz() const + { + return VEC4(this->y, this->y, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_zyxz() const + { + return VEC4(this->z, this->y, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_xzxz() const + { + return VEC4(this->x, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_yzxz() const + { + return VEC4(this->y, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_zzxz() const + { + return VEC4(this->z, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec3::_xxyz() const + { + return VEC4(this->x, this->x, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_yxyz() const + { + return VEC4(this->y, this->x, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_zxyz() const + { + return VEC4(this->z, this->x, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_xyyz() const + { + return VEC4(this->x, this->y, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_yyyz() const + { + return VEC4(this->y, this->y, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_zyyz() const + { + return VEC4(this->z, this->y, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_xzyz() const + { + return VEC4(this->x, this->z, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_yzyz() const + { + return VEC4(this->y, this->z, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_zzyz() const + { + return VEC4(this->z, this->z, this->y, this->z); + } + + template + inline const VEC4 _cvec3::_xxzz() const + { + return VEC4(this->x, this->x, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_yxzz() const + { + return VEC4(this->y, this->x, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_zxzz() const + { + return VEC4(this->z, this->x, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_xyzz() const + { + return VEC4(this->x, this->y, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_yyzz() const + { + return VEC4(this->y, this->y, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_zyzz() const + { + return VEC4(this->z, this->y, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_xzzz() const + { + return VEC4(this->x, this->z, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_yzzz() const + { + return VEC4(this->y, this->z, this->z, this->z); + } + + template + inline const VEC4 _cvec3::_zzzz() const + { + return VEC4(this->z, this->z, this->z, this->z); + } +#endif //defined(GLM_SWIZZLE) + +} //namespace detail +} //namespace glm + +#endif//__cvec3_inl__ + diff --git a/wip/sse/glm/core/_cvec4.h b/wip/sse/glm/core/_cvec4.h new file mode 100644 index 00000000..09a75ef3 --- /dev/null +++ b/wip/sse/glm/core/_cvec4.h @@ -0,0 +1,489 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-15 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : _cvec4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __cvec4_h__ +#define __cvec4_h__ + +#include "_cvecx.h" + +namespace glm{ +namespace detail{ + + template + class _cvec4 + { + public: + typedef T value_type; + typedef int size_type; + static const size_type value_size; + + // Data + /* ISO C++ version unavailable with VC7.1 ... + union{T x, r, s;}; + union{T y, g, t;}; + union{T z, b, p;}; + union{T w, a, q;}; + */ +/* + // Solution away from ISO C++ but available with VC7.1 and GCC without -pedantic + union + { + struct{T x, y, z, w;}; + struct{T r, g, b, a;}; + struct{T s, t, p, q;}; + //__m128 data; + }; +*/ + +#ifndef GLM_SINGLE_COMP_NAME +#ifdef GLM_COMPILER_GCC + union{T x, r, s;}; + union{T y, g, t;}; + union{T z, b, p;}; + union{T w, a, q;}; +#endif//GLM_COMPILER_GCC + +#ifdef GLM_COMPILER_VC + union + { + struct{T x, y, z, w;}; + struct{T r, g, b, a;}; + struct{T s, t, p, q;}; + }; +#endif//GLM_COMPILER_VC + +#else + T x, y, z, w; +#endif//GLM_SINGLE_COMP_NAME + + // Constructor + _cvec4(){} + _cvec4(const T x, const T y, const T z, const T w); + + // Accesses + T& operator[](size_type i); + const T operator[](size_type i) const; + operator T*(); + operator const T*() const; + +#if defined(GLM_SWIZZLE) + // Left hand side 2 components common swizzle operators + REF2 _yx(); + REF2 _zx(); + REF2 _wx(); + REF2 _xy(); + REF2 _zy(); + REF2 _wy(); + REF2 _xz(); + REF2 _yz(); + REF2 _wz(); + REF2 _xw(); + REF2 _yw(); + REF2 _zw(); + + // Right hand side 2 components common swizzle operators + const VEC2 _xx() const; + const VEC2 _yx() const; + const VEC2 _zx() const; + const VEC2 _wx() const; + const VEC2 _xy() const; + const VEC2 _yy() const; + const VEC2 _zy() const; + const VEC2 _wy() const; + const VEC2 _xz() const; + const VEC2 _yz() const; + const VEC2 _zz() const; + const VEC2 _wz() const; + const VEC2 _xw() const; + const VEC2 _yw() const; + const VEC2 _zw() const; + const VEC2 _ww() const; + + // Left hand side 3 components common swizzle operators + REF3 _zyx(); + REF3 _wyx(); + REF3 _yzx(); + REF3 _wzx(); + REF3 _ywx(); + REF3 _zwx(); + REF3 _zxy(); + REF3 _wxy(); + REF3 _xzy(); + REF3 _wzy(); + REF3 _xwy(); + REF3 _zwy(); + REF3 _yxz(); + REF3 _wxz(); + REF3 _xyz(); + REF3 _wyz(); + REF3 _xwz(); + REF3 _ywz(); + REF3 _yxw(); + REF3 _zxw(); + REF3 _xyw(); + REF3 _zyw(); + REF3 _xzw(); + REF3 _yzw(); + + // Right hand side 3 components common swizzle operators + const VEC3 _xxx() const; + const VEC3 _yxx() const; + const VEC3 _zxx() const; + const VEC3 _wxx() const; + const VEC3 _xyx() const; + const VEC3 _yyx() const; + const VEC3 _zyx() const; + const VEC3 _wyx() const; + const VEC3 _xzx() const; + const VEC3 _yzx() const; + const VEC3 _zzx() const; + const VEC3 _wzx() const; + const VEC3 _xwx() const; + const VEC3 _ywx() const; + const VEC3 _zwx() const; + const VEC3 _wwx() const; + const VEC3 _xxy() const; + const VEC3 _yxy() const; + const VEC3 _zxy() const; + const VEC3 _wxy() const; + const VEC3 _xyy() const; + const VEC3 _yyy() const; + const VEC3 _zyy() const; + const VEC3 _wyy() const; + const VEC3 _xzy() const; + const VEC3 _yzy() const; + const VEC3 _zzy() const; + const VEC3 _wzy() const; + const VEC3 _xwy() const; + const VEC3 _ywy() const; + const VEC3 _zwy() const; + const VEC3 _wwy() const; + const VEC3 _xxz() const; + const VEC3 _yxz() const; + const VEC3 _zxz() const; + const VEC3 _wxz() const; + const VEC3 _xyz() const; + const VEC3 _yyz() const; + const VEC3 _zyz() const; + const VEC3 _wyz() const; + const VEC3 _xzz() const; + const VEC3 _yzz() const; + const VEC3 _zzz() const; + const VEC3 _wzz() const; + const VEC3 _xwz() const; + const VEC3 _ywz() const; + const VEC3 _zwz() const; + const VEC3 _wwz() const; + const VEC3 _xxw() const; + const VEC3 _yxw() const; + const VEC3 _zxw() const; + const VEC3 _wxw() const; + const VEC3 _xyw() const; + const VEC3 _yyw() const; + const VEC3 _zyw() const; + const VEC3 _wyw() const; + const VEC3 _xzw() const; + const VEC3 _yzw() const; + const VEC3 _zzw() const; + const VEC3 _wzw() const; + const VEC3 _xww() const; + const VEC3 _yww() const; + const VEC3 _zww() const; + const VEC3 _www() const; + + // Left hand side 4 components common swizzle operators + REF4 _wzyx(); + REF4 _zwyx(); + REF4 _wyzx(); + REF4 _ywzx(); + REF4 _zywx(); + REF4 _yzwx(); + REF4 _wzxy(); + REF4 _zwxy(); + REF4 _wxzy(); + REF4 _xwzy(); + REF4 _zxwy(); + REF4 _xzwy(); + REF4 _wyxz(); + REF4 _ywxz(); + REF4 _wxyz(); + REF4 _xwyz(); + REF4 _yxwz(); + REF4 _xywz(); + REF4 _zyxw(); + REF4 _yzxw(); + REF4 _zxyw(); + REF4 _xzyw(); + REF4 _yxzw(); + REF4 _xyzw(); + + // Right hand side 4 components common swizzle operators + const VEC4 _xxxx() const; + const VEC4 _yxxx() const; + const VEC4 _zxxx() const; + const VEC4 _wxxx() const; + const VEC4 _xyxx() const; + const VEC4 _yyxx() const; + const VEC4 _zyxx() const; + const VEC4 _wyxx() const; + const VEC4 _xzxx() const; + const VEC4 _yzxx() const; + const VEC4 _zzxx() const; + const VEC4 _wzxx() const; + const VEC4 _xwxx() const; + const VEC4 _ywxx() const; + const VEC4 _zwxx() const; + const VEC4 _wwxx() const; + const VEC4 _xxyx() const; + const VEC4 _yxyx() const; + const VEC4 _zxyx() const; + const VEC4 _wxyx() const; + const VEC4 _xyyx() const; + const VEC4 _yyyx() const; + const VEC4 _zyyx() const; + const VEC4 _wyyx() const; + const VEC4 _xzyx() const; + const VEC4 _yzyx() const; + const VEC4 _zzyx() const; + const VEC4 _wzyx() const; + const VEC4 _xwyx() const; + const VEC4 _ywyx() const; + const VEC4 _zwyx() const; + const VEC4 _wwyx() const; + const VEC4 _xxzx() const; + const VEC4 _yxzx() const; + const VEC4 _zxzx() const; + const VEC4 _wxzx() const; + const VEC4 _xyzx() const; + const VEC4 _yyzx() const; + const VEC4 _zyzx() const; + const VEC4 _wyzx() const; + const VEC4 _xzzx() const; + const VEC4 _yzzx() const; + const VEC4 _zzzx() const; + const VEC4 _wzzx() const; + const VEC4 _xwzx() const; + const VEC4 _ywzx() const; + const VEC4 _zwzx() const; + const VEC4 _wwzx() const; + const VEC4 _xxwx() const; + const VEC4 _yxwx() const; + const VEC4 _zxwx() const; + const VEC4 _wxwx() const; + const VEC4 _xywx() const; + const VEC4 _yywx() const; + const VEC4 _zywx() const; + const VEC4 _wywx() const; + const VEC4 _xzwx() const; + const VEC4 _yzwx() const; + const VEC4 _zzwx() const; + const VEC4 _wzwx() const; + const VEC4 _xwwx() const; + const VEC4 _ywwx() const; + const VEC4 _zwwx() const; + const VEC4 _wwwx() const; + const VEC4 _xxxy() const; + const VEC4 _yxxy() const; + const VEC4 _zxxy() const; + const VEC4 _wxxy() const; + const VEC4 _xyxy() const; + const VEC4 _yyxy() const; + const VEC4 _zyxy() const; + const VEC4 _wyxy() const; + const VEC4 _xzxy() const; + const VEC4 _yzxy() const; + const VEC4 _zzxy() const; + const VEC4 _wzxy() const; + const VEC4 _xwxy() const; + const VEC4 _ywxy() const; + const VEC4 _zwxy() const; + const VEC4 _wwxy() const; + const VEC4 _xxyy() const; + const VEC4 _yxyy() const; + const VEC4 _zxyy() const; + const VEC4 _wxyy() const; + const VEC4 _xyyy() const; + const VEC4 _yyyy() const; + const VEC4 _zyyy() const; + const VEC4 _wyyy() const; + const VEC4 _xzyy() const; + const VEC4 _yzyy() const; + const VEC4 _zzyy() const; + const VEC4 _wzyy() const; + const VEC4 _xwyy() const; + const VEC4 _ywyy() const; + const VEC4 _zwyy() const; + const VEC4 _wwyy() const; + const VEC4 _xxzy() const; + const VEC4 _yxzy() const; + const VEC4 _zxzy() const; + const VEC4 _wxzy() const; + const VEC4 _xyzy() const; + const VEC4 _yyzy() const; + const VEC4 _zyzy() const; + const VEC4 _wyzy() const; + const VEC4 _xzzy() const; + const VEC4 _yzzy() const; + const VEC4 _zzzy() const; + const VEC4 _wzzy() const; + const VEC4 _xwzy() const; + const VEC4 _ywzy() const; + const VEC4 _zwzy() const; + const VEC4 _wwzy() const; + const VEC4 _xxwy() const; + const VEC4 _yxwy() const; + const VEC4 _zxwy() const; + const VEC4 _wxwy() const; + const VEC4 _xywy() const; + const VEC4 _yywy() const; + const VEC4 _zywy() const; + const VEC4 _wywy() const; + const VEC4 _xzwy() const; + const VEC4 _yzwy() const; + const VEC4 _zzwy() const; + const VEC4 _wzwy() const; + const VEC4 _xwwy() const; + const VEC4 _ywwy() const; + const VEC4 _zwwy() const; + const VEC4 _wwwy() const; + const VEC4 _xxxz() const; + const VEC4 _yxxz() const; + const VEC4 _zxxz() const; + const VEC4 _wxxz() const; + const VEC4 _xyxz() const; + const VEC4 _yyxz() const; + const VEC4 _zyxz() const; + const VEC4 _wyxz() const; + const VEC4 _xzxz() const; + const VEC4 _yzxz() const; + const VEC4 _zzxz() const; + const VEC4 _wzxz() const; + const VEC4 _xwxz() const; + const VEC4 _ywxz() const; + const VEC4 _zwxz() const; + const VEC4 _wwxz() const; + const VEC4 _xxyz() const; + const VEC4 _yxyz() const; + const VEC4 _zxyz() const; + const VEC4 _wxyz() const; + const VEC4 _xyyz() const; + const VEC4 _yyyz() const; + const VEC4 _zyyz() const; + const VEC4 _wyyz() const; + const VEC4 _xzyz() const; + const VEC4 _yzyz() const; + const VEC4 _zzyz() const; + const VEC4 _wzyz() const; + const VEC4 _xwyz() const; + const VEC4 _ywyz() const; + const VEC4 _zwyz() const; + const VEC4 _wwyz() const; + const VEC4 _xxzz() const; + const VEC4 _yxzz() const; + const VEC4 _zxzz() const; + const VEC4 _wxzz() const; + const VEC4 _xyzz() const; + const VEC4 _yyzz() const; + const VEC4 _zyzz() const; + const VEC4 _wyzz() const; + const VEC4 _xzzz() const; + const VEC4 _yzzz() const; + const VEC4 _zzzz() const; + const VEC4 _wzzz() const; + const VEC4 _xwzz() const; + const VEC4 _ywzz() const; + const VEC4 _zwzz() const; + const VEC4 _wwzz() const; + const VEC4 _xxwz() const; + const VEC4 _yxwz() const; + const VEC4 _zxwz() const; + const VEC4 _wxwz() const; + const VEC4 _xywz() const; + const VEC4 _yywz() const; + const VEC4 _zywz() const; + const VEC4 _wywz() const; + const VEC4 _xzwz() const; + const VEC4 _yzwz() const; + const VEC4 _zzwz() const; + const VEC4 _wzwz() const; + const VEC4 _xwwz() const; + const VEC4 _ywwz() const; + const VEC4 _zwwz() const; + const VEC4 _wwwz() const; + const VEC4 _xxxw() const; + const VEC4 _yxxw() const; + const VEC4 _zxxw() const; + const VEC4 _wxxw() const; + const VEC4 _xyxw() const; + const VEC4 _yyxw() const; + const VEC4 _zyxw() const; + const VEC4 _wyxw() const; + const VEC4 _xzxw() const; + const VEC4 _yzxw() const; + const VEC4 _zzxw() const; + const VEC4 _wzxw() const; + const VEC4 _xwxw() const; + const VEC4 _ywxw() const; + const VEC4 _zwxw() const; + const VEC4 _wwxw() const; + const VEC4 _xxyw() const; + const VEC4 _yxyw() const; + const VEC4 _zxyw() const; + const VEC4 _wxyw() const; + const VEC4 _xyyw() const; + const VEC4 _yyyw() const; + const VEC4 _zyyw() const; + const VEC4 _wyyw() const; + const VEC4 _xzyw() const; + const VEC4 _yzyw() const; + const VEC4 _zzyw() const; + const VEC4 _wzyw() const; + const VEC4 _xwyw() const; + const VEC4 _ywyw() const; + const VEC4 _zwyw() const; + const VEC4 _wwyw() const; + const VEC4 _xxzw() const; + const VEC4 _yxzw() const; + const VEC4 _zxzw() const; + const VEC4 _wxzw() const; + const VEC4 _xyzw() const; + const VEC4 _yyzw() const; + const VEC4 _zyzw() const; + const VEC4 _wyzw() const; + const VEC4 _xzzw() const; + const VEC4 _yzzw() const; + const VEC4 _zzzw() const; + const VEC4 _wzzw() const; + const VEC4 _xwzw() const; + const VEC4 _ywzw() const; + const VEC4 _zwzw() const; + const VEC4 _wwzw() const; + const VEC4 _xxww() const; + const VEC4 _yxww() const; + const VEC4 _zxww() const; + const VEC4 _wxww() const; + const VEC4 _xyww() const; + const VEC4 _yyww() const; + const VEC4 _zyww() const; + const VEC4 _wyww() const; + const VEC4 _xzww() const; + const VEC4 _yzww() const; + const VEC4 _zzww() const; + const VEC4 _wzww() const; + const VEC4 _xwww() const; + const VEC4 _ywww() const; + const VEC4 _zwww() const; + const VEC4 _wwww() const; +#endif// defined(GLM_SWIZZLE) + }; + +} //namespace detail +} //namespace glm + +#endif//__cvec4_h__ diff --git a/wip/sse/glm/core/_cvec4.inl b/wip/sse/glm/core/_cvec4.inl new file mode 100644 index 00000000..f19c64cf --- /dev/null +++ b/wip/sse/glm/core/_cvec4.inl @@ -0,0 +1,2450 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-15 +// Updated : 2007-01-15 +// Licence : This source is under GNU LGPL licence +// File : _cvec4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __cvec4_inl__ +#define __cvec4_inl__ + +#include "_cvec4.h" + +namespace glm{ +namespace detail{ + + template + const int _cvec4::value_size = 4; + + ////////////////////////////////////////////////////////////// + // _cvec4 constructor + + template + inline _cvec4::_cvec4(const T x, const T y, const T z, const T w) : + x(x), y(y), z(z), w(w) + {} + + ////////////////////////////////////////////////////////////// + // vec4 and ivec4 accesses + + template + inline T& _cvec4::operator[](int i) + { + return (&x)[i]; + } + + template + inline const T _cvec4::operator[](int i) const + { + return (&x)[i]; + } + + template + inline _cvec4::operator T*() + { + return &x; + } + + template + inline _cvec4::operator const T*() const + { + return &x; + } + +#if defined(GLM_SWIZZLE) + ////////////////////////////////////////////////////////////// + // Left hand side 2 components common swizzle operators + + template + inline REF2 _cvec4::_yx() + { + return REF2(this->y, this->x); + } + + template + inline REF2 _cvec4::_zx() + { + return REF2(this->z, this->x); + } + + template + inline REF2 _cvec4::_wx() + { + return REF2(this->w, this->x); + } + + template + inline REF2 _cvec4::_xy() + { + return REF2(this->x, this->y); + } + + template + inline REF2 _cvec4::_zy() + { + return REF2(this->z, this->y); + } + + template + inline REF2 _cvec4::_wy() + { + return REF2(this->w, this->y); + } + + template + inline REF2 _cvec4::_xz() + { + return REF2(this->x, this->z); + } + + template + inline REF2 _cvec4::_yz() + { + return REF2(this->y, this->z); + } + + template + inline REF2 _cvec4::_wz() + { + return REF2(this->w, this->z); + } + + template + inline REF2 _cvec4::_xw() + { + return REF2(this->x, this->w); + } + + template + inline REF2 _cvec4::_yw() + { + return REF2(this->y, this->w); + } + + template + inline REF2 _cvec4::_zw() + { + return REF2(this->z, this->w); + } + + // Right hand side 2 components swizzles operators + + template + inline const VEC2 _cvec4::_xx() const + { + return VEC2(this->x, this->x); + } + + template + inline const VEC2 _cvec4::_yx() const + { + return VEC2(this->y, this->x); + } + + template + inline const VEC2 _cvec4::_zx() const + { + return VEC2(this->z, this->x); + } + + template + inline const VEC2 _cvec4::_wx() const + { + return VEC2(this->w, this->x); + } + + template + inline const VEC2 _cvec4::_xy() const + { + return VEC2(this->x, this->y); + } + + template + inline const VEC2 _cvec4::_yy() const + { + return VEC2(this->y, this->y); + } + + template + inline const VEC2 _cvec4::_zy() const + { + return VEC2(this->z, this->y); + } + + template + inline const VEC2 _cvec4::_wy() const + { + return VEC2(this->w, this->y); + } + + template + inline const VEC2 _cvec4::_xz() const + { + return VEC2(this->x, this->z); + } + + template + inline const VEC2 _cvec4::_yz() const + { + return VEC2(this->y, this->z); + } + + template + inline const VEC2 _cvec4::_zz() const + { + return VEC2(this->z, this->z); + } + + template + inline const VEC2 _cvec4::_wz() const + { + return VEC2(this->w, this->z); + } + + template + inline const VEC2 _cvec4::_xw() const + { + return VEC2(this->x, this->w); + } + + template + inline const VEC2 _cvec4::_yw() const + { + return VEC2(this->y, this->w); + } + + template + inline const VEC2 _cvec4::_zw() const + { + return VEC2(this->z, this->w); + } + + template + inline const VEC2 _cvec4::_ww() const + { + return VEC2(this->w, this->w); + } + + ////////////////////////////////////////////////////////////// + // Left hand side 3 components swizzles operators + + template + inline REF3 _cvec4::_zyx() + { + return REF3(this->z, this->y, this->x); + } + + template + inline REF3 _cvec4::_wyx() + { + return REF3(this->w, this->y, this->x); + } + + template + inline REF3 _cvec4::_yzx() + { + return REF3(this->y, this->z, this->x); + } + + template + inline REF3 _cvec4::_wzx() + { + return REF3(this->w, this->z, this->x); + } + + template + inline REF3 _cvec4::_ywx() + { + return REF3(this->y, this->w, this->x); + } + + template + inline REF3 _cvec4::_zwx() + { + return REF3(this->z, this->w, this->x); + } + + template + inline REF3 _cvec4::_zxy() + { + return REF3(this->z, this->x, this->y); + } + + template + inline REF3 _cvec4::_wxy() + { + return REF3(this->w, this->x, this->y); + } + + template + inline REF3 _cvec4::_xzy() + { + return REF3(this->x, this->z, this->y); + } + + template + inline REF3 _cvec4::_wzy() + { + return REF3(this->w, this->z, this->y); + } + + template + inline REF3 _cvec4::_xwy() + { + return REF3(this->x, this->w, this->y); + } + + template + inline REF3 _cvec4::_zwy() + { + return REF3(this->z, this->w, this->y); + } + + template + inline REF3 _cvec4::_yxz() + { + return REF3(this->y, this->x, this->z); + } + + template + inline REF3 _cvec4::_wxz() + { + return REF3(this->w, this->x, this->z); + } + + template + inline REF3 _cvec4::_xyz() + { + return REF3(this->x, this->y, this->z); + } + + template + inline REF3 _cvec4::_wyz() + { + return REF3(this->w, this->y, this->z); + } + + template + inline REF3 _cvec4::_xwz() + { + return REF3(this->x, this->w, this->z); + } + + template + inline REF3 _cvec4::_ywz() + { + return REF3(this->y, this->w, this->z); + } + + template + inline REF3 _cvec4::_yxw() + { + return REF3(this->y, this->x, this->w); + } + + template + inline REF3 _cvec4::_zxw() + { + return REF3(this->z, this->x, this->w); + } + + template + inline REF3 _cvec4::_xyw() + { + return REF3(this->x, this->y, this->w); + } + + template + inline REF3 _cvec4::_zyw() + { + return REF3(this->z, this->y, this->w); + } + + template + inline REF3 _cvec4::_xzw() + { + return REF3(this->x, this->z, this->w); + } + + template + inline REF3 _cvec4::_yzw() + { + return REF3(this->y, this->z, this->w); + } + + ////////////////////////////////////////////////////////////// + // Right hand side 3 components swizzles operators + + template + inline const VEC3 _cvec4::_xxx() const + { + return VEC3(this->x, this->x, this->x); + } + + template + inline const VEC3 _cvec4::_yxx() const + { + return VEC3(this->y, this->x, this->x); + } + + template + inline const VEC3 _cvec4::_zxx() const + { + return VEC3(this->z, this->x, this->x); + } + + template + inline const VEC3 _cvec4::_wxx() const + { + return VEC3(this->w, this->x, this->x); + } + + template + inline const VEC3 _cvec4::_xyx() const + { + return VEC3(this->x, this->y, this->x); + } + + template + inline const VEC3 _cvec4::_yyx() const + { + return VEC3(this->y, this->y, this->x); + } + + template + inline const VEC3 _cvec4::_zyx() const + { + return VEC3(this->z, this->y, this->x); + } + + template + inline const VEC3 _cvec4::_wyx() const + { + return VEC3(this->w, this->y, this->x); + } + + template + inline const VEC3 _cvec4::_xzx() const + { + return VEC3(this->x, this->z, this->x); + } + + template + inline const VEC3 _cvec4::_yzx() const + { + return VEC3(this->y, this->z, this->x); + } + + template + inline const VEC3 _cvec4::_zzx() const + { + return VEC3(this->z, this->z, this->x); + } + + template + inline const VEC3 _cvec4::_wzx() const + { + return VEC3(this->w, this->z, this->x); + } + + template + inline const VEC3 _cvec4::_xwx() const + { + return VEC3(this->x, this->w, this->x); + } + + template + inline const VEC3 _cvec4::_ywx() const + { + return VEC3(this->y, this->w, this->x); + } + + template + inline const VEC3 _cvec4::_zwx() const + { + return VEC3(this->z, this->w, this->x); + } + + template + inline const VEC3 _cvec4::_wwx() const + { + return VEC3(this->w, this->w, this->x); + } + + template + inline const VEC3 _cvec4::_xxy() const + { + return VEC3(this->x, this->x, this->y); + } + + template + inline const VEC3 _cvec4::_yxy() const + { + return VEC3(this->y, this->x, this->y); + } + + template + inline const VEC3 _cvec4::_zxy() const + { + return VEC3(this->z, this->x, this->y); + } + + template + inline const VEC3 _cvec4::_wxy() const + { + return VEC3(this->w, this->x, this->y); + } + + template + inline const VEC3 _cvec4::_xyy() const + { + return VEC3(this->x, this->y, this->y); + } + + template + inline const VEC3 _cvec4::_yyy() const + { + return VEC3(this->y, this->y, this->y); + } + + template + inline const VEC3 _cvec4::_zyy() const + { + return VEC3(this->z, this->y, this->y); + } + + template + inline const VEC3 _cvec4::_wyy() const + { + return VEC3(this->w, this->y, this->y); + } + + template + inline const VEC3 _cvec4::_xzy() const + { + return VEC3(this->x, this->z, this->y); + } + + template + inline const VEC3 _cvec4::_yzy() const + { + return VEC3(this->y, this->z, this->y); + } + + template + inline const VEC3 _cvec4::_zzy() const + { + return VEC3(this->z, this->z, this->y); + } + + template + inline const VEC3 _cvec4::_wzy() const + { + return VEC3(this->w, this->z, this->y); + } + + template + inline const VEC3 _cvec4::_xwy() const + { + return VEC3(this->x, this->w, this->y); + } + + template + inline const VEC3 _cvec4::_ywy() const + { + return VEC3(this->y, this->w, this->y); + } + + template + inline const VEC3 _cvec4::_zwy() const + { + return VEC3(this->z, this->w, this->y); + } + + template + inline const VEC3 _cvec4::_wwy() const + { + return VEC3(this->w, this->w, this->y); + } + + template + inline const VEC3 _cvec4::_xxz() const + { + return VEC3(this->x, this->x, this->z); + } + + template + inline const VEC3 _cvec4::_yxz() const + { + return VEC3(this->y, this->x, this->z); + } + + template + inline const VEC3 _cvec4::_zxz() const + { + return VEC3(this->z, this->x, this->z); + } + + template + inline const VEC3 _cvec4::_wxz() const + { + return VEC3(this->w, this->x, this->z); + } + + template + inline const VEC3 _cvec4::_xyz() const + { + return VEC3(this->x, this->y, this->z); + } + + template + inline const VEC3 _cvec4::_yyz() const + { + return VEC3(this->y, this->y, this->z); + } + + template + inline const VEC3 _cvec4::_zyz() const + { + return VEC3(this->z, this->y, this->z); + } + + template + inline const VEC3 _cvec4::_wyz() const + { + return VEC3(this->w, this->y, this->z); + } + + template + inline const VEC3 _cvec4::_xzz() const + { + return VEC3(this->x, this->z, this->z); + } + + template + inline const VEC3 _cvec4::_yzz() const + { + return VEC3(this->y, this->z, this->z); + } + + template + inline const VEC3 _cvec4::_zzz() const + { + return VEC3(this->z, this->z, this->z); + } + + template + inline const VEC3 _cvec4::_wzz() const + { + return VEC3(this->w, this->z, this->z); + } + + template + inline const VEC3 _cvec4::_xwz() const + { + return VEC3(this->x, this->w, this->z); + } + + template + inline const VEC3 _cvec4::_ywz() const + { + return VEC3(this->y, this->w, this->z); + } + + template + inline const VEC3 _cvec4::_zwz() const + { + return VEC3(this->z, this->w, this->z); + } + + template + inline const VEC3 _cvec4::_wwz() const + { + return VEC3(this->w, this->w, this->z); + } + + template + inline const VEC3 _cvec4::_xxw() const + { + return VEC3(this->x, this->x, this->w); + } + + template + inline const VEC3 _cvec4::_yxw() const + { + return VEC3(this->y, this->x, this->w); + } + + template + inline const VEC3 _cvec4::_zxw() const + { + return VEC3(this->z, this->x, this->w); + } + + template + inline const VEC3 _cvec4::_wxw() const + { + return VEC3(this->w, this->x, this->w); + } + + template + inline const VEC3 _cvec4::_xyw() const + { + return VEC3(this->x, this->y, this->w); + } + + template + inline const VEC3 _cvec4::_yyw() const + { + return VEC3(this->y, this->y, this->w); + } + + template + inline const VEC3 _cvec4::_zyw() const + { + return VEC3(this->z, this->y, this->w); + } + + template + inline const VEC3 _cvec4::_wyw() const + { + return VEC3(this->w, this->y, this->w); + } + + template + inline const VEC3 _cvec4::_xzw() const + { + return VEC3(this->x, this->z, this->w); + } + + template + inline const VEC3 _cvec4::_yzw() const + { + return VEC3(this->y, this->z, this->w); + } + + template + inline const VEC3 _cvec4::_zzw() const + { + return VEC3(this->z, this->z, this->w); + } + + template + inline const VEC3 _cvec4::_wzw() const + { + return VEC3(this->w, this->z, this->w); + } + + template + inline const VEC3 _cvec4::_xww() const + { + return VEC3(this->x, this->w, this->w); + } + + template + inline const VEC3 _cvec4::_yww() const + { + return VEC3(this->y, this->w, this->w); + } + + template + inline const VEC3 _cvec4::_zww() const + { + return VEC3(this->z, this->w, this->w); + } + + template + inline const VEC3 _cvec4::_www() const + { + return VEC3(this->w, this->w, this->w); + } + + // Left hand side 4 components swizzles operators + template + inline REF4 _cvec4::_wzyx() + { + return REF4(this->w, this->z, this->y, this->x); + } + + template + inline REF4 _cvec4::_zwyx() + { + return REF4(this->z, this->w, this->y, this->x); + } + + template + inline REF4 _cvec4::_wyzx() + { + return REF4(this->w, this->y, this->z, this->x); + } + + template + inline REF4 _cvec4::_ywzx() + { + return REF4(this->y, this->w, this->z, this->x); + } + + template + inline REF4 _cvec4::_zywx() + { + return REF4(this->z, this->y, this->w, this->x); + } + + template + inline REF4 _cvec4::_yzwx() + { + return REF4(this->y, this->z, this->w, this->x); + } + + template + inline REF4 _cvec4::_wzxy() + { + return REF4(this->w, this->z, this->x, this->y); + } + + template + inline REF4 _cvec4::_zwxy() + { + return REF4(this->z, this->w, this->x, this->y); + } + + template + inline REF4 _cvec4::_wxzy() + { + return REF4(this->w, this->x, this->z, this->y); + } + + template + inline REF4 _cvec4::_xwzy() + { + return REF4(this->x, this->w, this->z, this->y); + } + + template + inline REF4 _cvec4::_zxwy() + { + return REF4(this->z, this->x, this->w, this->y); + } + + template + inline REF4 _cvec4::_xzwy() + { + return REF4(this->x, this->z, this->w, this->y); + } + + template + inline REF4 _cvec4::_wyxz() + { + return REF4(this->w, this->y, this->x, this->z); + } + + template + inline REF4 _cvec4::_ywxz() + { + return REF4(this->y, this->w, this->x, this->z); + } + + template + inline REF4 _cvec4::_wxyz() + { + return REF4(this->w, this->x, this->y, this->z); + } + + template + inline REF4 _cvec4::_xwyz() + { + return REF4(this->x, this->w, this->y, this->z); + } + + template + inline REF4 _cvec4::_yxwz() + { + return REF4(this->y, this->x, this->w, this->z); + } + + template + inline REF4 _cvec4::_xywz() + { + return REF4(this->x, this->y, this->w, this->z); + } + + template + inline REF4 _cvec4::_zyxw() + { + return REF4(this->z, this->y, this->x, this->w); + } + + template + inline REF4 _cvec4::_yzxw() + { + return REF4(this->y, this->z, this->x, this->w); + } + + template + inline REF4 _cvec4::_zxyw() + { + return REF4(this->z, this->x, this->y, this->w); + } + + template + inline REF4 _cvec4::_xzyw() + { + return REF4(this->x, this->z, this->y, this->w); + } + + template + inline REF4 _cvec4::_yxzw() + { + return REF4(this->y, this->x, this->z, this->w); + } + + template + inline REF4 _cvec4::_xyzw() + { + return REF4(this->x, this->y, this->z, this->w); + } + + // Right hand side 4 components swizzles operators + template + inline const VEC4 _cvec4::_xxxx() const + { + return _cvec4(this->x, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_yxxx() const + { + return _cvec4(this->y, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_zxxx() const + { + return _cvec4(this->z, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_wxxx() const + { + return _cvec4(this->w, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_xyxx() const + { + return _cvec4(this->x, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_yyxx() const + { + return _cvec4(this->y, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_zyxx() const + { + return _cvec4(this->z, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_wyxx() const + { + return _cvec4(this->w, this->y, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_xzxx() const + { + return _cvec4(this->x, this->z, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_yzxx() const + { + return _cvec4(this->y, this->z, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_zzxx() const + { + return _cvec4(this->z, this->z, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_wzxx() const + { + return _cvec4(this->w, this->z, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_xwxx() const + { + return _cvec4(this->x, this->w, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_ywxx() const + { + return _cvec4(this->y, this->w, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_zwxx() const + { + return _cvec4(this->z, this->w, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_wwxx() const + { + return _cvec4(this->w, this->w, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_xxyx() const + { + return _cvec4(this->x, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_yxyx() const + { + return _cvec4(this->y, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_zxyx() const + { + return _cvec4(this->z, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_wxyx() const + { + return _cvec4(this->w, this->x, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_xyyx() const + { + return _cvec4(this->x, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_yyyx() const + { + return _cvec4(this->y, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_zyyx() const + { + return _cvec4(this->z, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_wyyx() const + { + return _cvec4(this->w, this->y, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_xzyx() const + { + return _cvec4(this->x, this->z, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_yzyx() const + { + return _cvec4(this->y, this->z, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_zzyx() const + { + return _cvec4(this->z, this->z, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_wzyx() const + { + return _cvec4(this->w, this->z, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_xwyx() const + { + return _cvec4(this->x, this->w, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_ywyx() const + { + return _cvec4(this->y, this->w, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_zwyx() const + { + return _cvec4(this->z, this->w, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_wwyx() const + { + return _cvec4(this->w, this->w, this->y, this->x); + } + + template + inline const VEC4 _cvec4::_xxzx() const + { + return _cvec4(this->x, this->x, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_yxzx() const + { + return _cvec4(this->y, this->x, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_zxzx() const + { + return _cvec4(this->z, this->x, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_wxzx() const + { + return _cvec4(this->w, this->x, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_xyzx() const + { + return _cvec4(this->x, this->y, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_yyzx() const + { + return _cvec4(this->y, this->y, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_zyzx() const + { + return _cvec4(this->z, this->y, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_wyzx() const + { + return _cvec4(this->w, this->y, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_xzzx() const + { + return _cvec4(this->x, this->z, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_yzzx() const + { + return _cvec4(this->y, this->z, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_zzzx() const + { + return _cvec4(this->z, this->z, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_wzzx() const + { + return _cvec4(this->w, this->z, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_xwzx() const + { + return _cvec4(this->x, this->w, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_ywzx() const + { + return _cvec4(this->y, this->w, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_zwzx() const + { + return _cvec4(this->z, this->w, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_wwzx() const + { + return _cvec4(this->w, this->w, this->z, this->x); + } + + template + inline const VEC4 _cvec4::_xxwx() const + { + return _cvec4(this->x, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_yxwx() const + { + return _cvec4(this->y, this->x, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_zxwx() const + { + return _cvec4(this->z, this->x, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_wxwx() const + { + return _cvec4(this->w, this->x, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_xywx() const + { + return _cvec4(this->x, this->y, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_yywx() const + { + return _cvec4(this->y, this->y, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_zywx() const + { + return _cvec4(this->z, this->y, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_wywx() const + { + return _cvec4(this->w, this->y, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_xzwx() const + { + return _cvec4(this->x, this->z, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_yzwx() const + { + return _cvec4(this->y, this->z, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_zzwx() const + { + return _cvec4(this->z, this->z, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_wzwx() const + { + return _cvec4(this->w, this->z, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_xwwx() const + { + return _cvec4(this->x, this->w, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_ywwx() const + { + return _cvec4(this->y, this->w, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_zwwx() const + { + return _cvec4(this->z, this->w, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_wwwx() const + { + return _cvec4(this->w, this->w, this->w, this->x); + } + + template + inline const VEC4 _cvec4::_xxxy() const + { + return _cvec4(this->x, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_yxxy() const + { + return _cvec4(this->y, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_zxxy() const + { + return _cvec4(this->z, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_wxxy() const + { + return _cvec4(this->w, this->x, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_xyxy() const + { + return _cvec4(this->x, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_yyxy() const + { + return _cvec4(this->y, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_zyxy() const + { + return _cvec4(this->z, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_wyxy() const + { + return _cvec4(this->w, this->y, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_xzxy() const + { + return _cvec4(this->x, this->z, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_yzxy() const + { + return _cvec4(this->y, this->z, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_zzxy() const + { + return _cvec4(this->z, this->z, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_wzxy() const + { + return _cvec4(this->w, this->z, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_xwxy() const + { + return _cvec4(this->x, this->w, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_ywxy() const + { + return _cvec4(this->y, this->w, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_zwxy() const + { + return _cvec4(this->z, this->w, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_wwxy() const + { + return _cvec4(this->w, this->w, this->x, this->y); + } + + template + inline const VEC4 _cvec4::_xxyy() const + { + return _cvec4(this->x, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_yxyy() const + { + return _cvec4(this->y, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_zxyy() const + { + return _cvec4(this->z, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_wxyy() const + { + return _cvec4(this->w, this->x, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_xyyy() const + { + return _cvec4(this->x, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_yyyy() const + { + return _cvec4(this->y, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_zyyy() const + { + return _cvec4(this->z, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_wyyy() const + { + return _cvec4(this->w, this->y, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_xzyy() const + { + return _cvec4(this->x, this->z, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_yzyy() const + { + return _cvec4(this->y, this->z, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_zzyy() const + { + return _cvec4(this->z, this->z, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_wzyy() const + { + return _cvec4(this->w, this->z, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_xwyy() const + { + return _cvec4(this->x, this->w, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_ywyy() const + { + return _cvec4(this->y, this->w, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_zwyy() const + { + return _cvec4(this->z, this->w, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_wwyy() const + { + return _cvec4(this->w, this->w, this->y, this->y); + } + + template + inline const VEC4 _cvec4::_xxzy() const + { + return _cvec4(this->x, this->x, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_yxzy() const + { + return _cvec4(this->y, this->x, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_zxzy() const + { + return _cvec4(this->z, this->x, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_wxzy() const + { + return _cvec4(this->w, this->x, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_xyzy() const + { + return _cvec4(this->x, this->y, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_yyzy() const + { + return _cvec4(this->y, this->y, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_zyzy() const + { + return _cvec4(this->z, this->y, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_wyzy() const + { + return _cvec4(this->w, this->y, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_xzzy() const + { + return _cvec4(this->x, this->z, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_yzzy() const + { + return _cvec4(this->y, this->z, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_zzzy() const + { + return _cvec4(this->z, this->z, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_wzzy() const + { + return _cvec4(this->w, this->z, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_xwzy() const + { + return _cvec4(this->x, this->w, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_ywzy() const + { + return _cvec4(this->y, this->w, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_zwzy() const + { + return _cvec4(this->z, this->w, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_wwzy() const + { + return _cvec4(this->w, this->w, this->z, this->y); + } + + template + inline const VEC4 _cvec4::_xxwy() const + { + return _cvec4(this->x, this->x, this->x, this->x); + } + + template + inline const VEC4 _cvec4::_yxwy() const + { + return _cvec4(this->y, this->x, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_zxwy() const + { + return _cvec4(this->z, this->x, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_wxwy() const + { + return _cvec4(this->w, this->x, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_xywy() const + { + return _cvec4(this->x, this->y, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_yywy() const + { + return _cvec4(this->y, this->y, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_zywy() const + { + return _cvec4(this->z, this->y, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_wywy() const + { + return _cvec4(this->w, this->y, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_xzwy() const + { + return _cvec4(this->x, this->z, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_yzwy() const + { + return _cvec4(this->y, this->z, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_zzwy() const + { + return _cvec4(this->z, this->z, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_wzwy() const + { + return _cvec4(this->w, this->z, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_xwwy() const + { + return _cvec4(this->x, this->w, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_ywwy() const + { + return _cvec4(this->y, this->w, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_zwwy() const + { + return _cvec4(this->z, this->w, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_wwwy() const + { + return _cvec4(this->w, this->w, this->w, this->y); + } + + template + inline const VEC4 _cvec4::_xxxz() const + { + return _cvec4(this->x, this->x, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_yxxz() const + { + return _cvec4(this->y, this->x, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_zxxz() const + { + return _cvec4(this->z, this->x, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_wxxz() const + { + return _cvec4(this->w, this->x, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_xyxz() const + { + return _cvec4(this->x, this->y, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_yyxz() const + { + return _cvec4(this->y, this->y, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_zyxz() const + { + return _cvec4(this->z, this->y, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_wyxz() const + { + return _cvec4(this->w, this->y, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_xzxz() const + { + return _cvec4(this->x, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_yzxz() const + { + return _cvec4(this->y, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_zzxz() const + { + return _cvec4(this->z, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_wzxz() const + { + return _cvec4(this->w, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_xwxz() const + { + return _cvec4(this->x, this->w, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_ywxz() const + { + return _cvec4(this->y, this->w, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_zwxz() const + { + return _cvec4(this->z, this->w, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_wwxz() const + { + return _cvec4(this->w, this->w, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_xxyz() const + { + return _cvec4(this->x, this->x, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_yxyz() const + { + return _cvec4(this->y, this->x, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_zxyz() const + { + return _cvec4(this->z, this->x, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_wxyz() const + { + return _cvec4(this->w, this->x, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_xyyz() const + { + return _cvec4(this->x, this->y, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_yyyz() const + { + return _cvec4(this->y, this->y, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_zyyz() const + { + return _cvec4(this->z, this->y, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_wyyz() const + { + return _cvec4(this->w, this->y, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_xzyz() const + { + return _cvec4(this->x, this->z, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_yzyz() const + { + return _cvec4(this->y, this->z, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_zzyz() const + { + return _cvec4(this->z, this->z, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_wzyz() const + { + return _cvec4(this->w, this->z, this->x, this->z); + } + + template + inline const VEC4 _cvec4::_xwyz() const + { + return _cvec4(this->x, this->w, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_ywyz() const + { + return _cvec4(this->y, this->w, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_zwyz() const + { + return _cvec4(this->z, this->w, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_wwyz() const + { + return _cvec4(this->w, this->w, this->y, this->z); + } + + template + inline const VEC4 _cvec4::_xxzz() const + { + return _cvec4(this->x, this->x, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_yxzz() const + { + return _cvec4(this->y, this->x, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_zxzz() const + { + return _cvec4(this->z, this->x, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_wxzz() const + { + return _cvec4(this->w, this->x, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_xyzz() const + { + return _cvec4(this->x, this->y, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_yyzz() const + { + return _cvec4(this->y, this->y, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_zyzz() const + { + return _cvec4(this->z, this->y, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_wyzz() const + { + return _cvec4(this->w, this->y, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_xzzz() const + { + return _cvec4(this->x, this->z, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_yzzz() const + { + return _cvec4(this->y, this->z, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_zzzz() const + { + return _cvec4(this->z, this->z, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_wzzz() const + { + return _cvec4(this->w, this->z, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_xwzz() const + { + return _cvec4(this->x, this->w, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_ywzz() const + { + return _cvec4(this->y, this->w, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_zwzz() const + { + return _cvec4(this->z, this->w, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_wwzz() const + { + return _cvec4(this->w, this->w, this->z, this->z); + } + + template + inline const VEC4 _cvec4::_xxwz() const + { + return _cvec4(this->x, this->x, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_yxwz() const + { + return _cvec4(this->y, this->x, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_zxwz() const + { + return _cvec4(this->z, this->x, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_wxwz() const + { + return _cvec4(this->w, this->x, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_xywz() const + { + return _cvec4(this->x, this->y, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_yywz() const + { + return _cvec4(this->y, this->y, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_zywz() const + { + return _cvec4(this->z, this->y, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_wywz() const + { + return _cvec4(this->w, this->y, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_xzwz() const + { + return _cvec4(this->x, this->z, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_yzwz() const + { + return _cvec4(this->y, this->z, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_zzwz() const + { + return _cvec4(this->z, this->z, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_wzwz() const + { + return _cvec4(this->w, this->z, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_xwwz() const + { + return _cvec4(this->x, this->w, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_ywwz() const + { + return _cvec4(this->y, this->w, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_zwwz() const + { + return _cvec4(this->z, this->w, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_wwwz() const + { + return _cvec4(this->w, this->w, this->w, this->z); + } + + template + inline const VEC4 _cvec4::_xxxw() const + { + return _cvec4(this->x, this->x, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_yxxw() const + { + return _cvec4(this->y, this->x, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_zxxw() const + { + return _cvec4(this->z, this->x, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_wxxw() const + { + return _cvec4(this->w, this->x, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_xyxw() const + { + return _cvec4(this->x, this->y, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_yyxw() const + { + return _cvec4(this->y, this->y, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_zyxw() const + { + return _cvec4(this->z, this->y, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_wyxw() const + { + return _cvec4(this->w, this->y, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_xzxw() const + { + return _cvec4(this->x, this->z, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_yzxw() const + { + return _cvec4(this->y, this->z, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_zzxw() const + { + return _cvec4(this->z, this->z, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_wzxw() const + { + return _cvec4(this->w, this->z, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_xwxw() const + { + return _cvec4(this->x, this->w, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_ywxw() const + { + return _cvec4(this->y, this->w, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_zwxw() const + { + return _cvec4(this->z, this->w, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_wwxw() const + { + return _cvec4(this->w, this->w, this->x, this->w); + } + + template + inline const VEC4 _cvec4::_xxyw() const + { + return _cvec4(this->x, this->x, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_yxyw() const + { + return _cvec4(this->y, this->x, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_zxyw() const + { + return _cvec4(this->z, this->x, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_wxyw() const + { + return _cvec4(this->w, this->x, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_xyyw() const + { + return _cvec4(this->x, this->y, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_yyyw() const + { + return _cvec4(this->y, this->y, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_zyyw() const + { + return _cvec4(this->z, this->y, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_wyyw() const + { + return _cvec4(this->w, this->y, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_xzyw() const + { + return _cvec4(this->x, this->z, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_yzyw() const + { + return _cvec4(this->y, this->z, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_zzyw() const + { + return _cvec4(this->z, this->z, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_wzyw() const + { + return _cvec4(this->w, this->z, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_xwyw() const + { + return _cvec4(this->x, this->w, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_ywyw() const + { + return _cvec4(this->y, this->w, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_zwyw() const + { + return _cvec4(this->z, this->w, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_wwyw() const + { + return _cvec4(this->w, this->w, this->y, this->w); + } + + template + inline const VEC4 _cvec4::_xxzw() const + { + return _cvec4(this->x, this->x, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_yxzw() const + { + return _cvec4(this->y, this->x, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_zxzw() const + { + return _cvec4(this->z, this->x, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_wxzw() const + { + return _cvec4(this->w, this->x, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_xyzw() const + { + return _cvec4(this->x, this->y, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_yyzw() const + { + return _cvec4(this->y, this->y, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_zyzw() const + { + return _cvec4(this->z, this->y, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_wyzw() const + { + return _cvec4(this->w, this->y, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_xzzw() const + { + return _cvec4(this->x, this->z, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_yzzw() const + { + return _cvec4(this->y, this->z, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_zzzw() const + { + return _cvec4(this->z, this->z, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_wzzw() const + { + return _cvec4(this->w, this->z, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_xwzw() const + { + return _cvec4(this->x, this->w, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_ywzw() const + { + return _cvec4(this->y, this->w, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_zwzw() const + { + return _cvec4(this->z, this->w, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_wwzw() const + { + return _cvec4(this->w, this->w, this->z, this->w); + } + + template + inline const VEC4 _cvec4::_xxww() const + { + return _cvec4(this->x, this->x, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_yxww() const + { + return _cvec4(this->y, this->x, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_zxww() const + { + return _cvec4(this->z, this->x, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_wxww() const + { + return _cvec4(this->w, this->x, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_xyww() const + { + return _cvec4(this->x, this->y, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_yyww() const + { + return _cvec4(this->y, this->y, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_zyww() const + { + return _cvec4(this->z, this->y, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_wyww() const + { + return _cvec4(this->w, this->y, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_xzww() const + { + return _cvec4(this->x, this->z, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_yzww() const + { + return _cvec4(this->y, this->z, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_zzww() const + { + return _cvec4(this->z, this->z, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_wzww() const + { + return _cvec4(this->w, this->z, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_xwww() const + { + return _cvec4(this->x, this->w, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_ywww() const + { + return _cvec4(this->y, this->w, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_zwww() const + { + return _cvec4(this->z, this->w, this->w, this->w); + } + + template + inline const VEC4 _cvec4::_wwww() const + { + return _cvec4(this->w, this->w, this->w, this->w); + } +#endif //defined(GLM_SWIZZLE) + +} //namespace detail +} //namespace glm + +#endif//__cvec4_inl__ diff --git a/wip/sse/glm/core/_cvecx.h b/wip/sse/glm/core/_cvecx.h new file mode 100644 index 00000000..41c74b83 --- /dev/null +++ b/wip/sse/glm/core/_cvecx.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2007 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-15 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_cvecx.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_cvecx_h__ +#define __glm_core_cvecx_h__ + +#define CVEC2_TYPE T, VEC2, VEC3, VEC4, REF2 +#define CVEC3_TYPE T, VEC2, VEC3, VEC4, REF2, REF3 +#define CVEC4_TYPE T, VEC2, VEC3, VEC4, REF2, REF3, REF4 + +#define CVEC2_LIST typename T, typename VEC2, typename VEC3, typename VEC4, typename REF2 +#define CVEC3_LIST typename T, typename VEC2, typename VEC3, typename VEC4, typename REF2, typename REF3 +#define CVEC4_LIST typename T, typename VEC2, typename VEC3, typename VEC4, typename REF2, typename REF3, typename REF4 + +#define XVEC2_INST T, _xvec2, _xvec3, _xvec4, _xref2 +#define XVEC3_INST T, _xvec2, _xvec3, _xvec4, _xref2, _xref3 +#define XVEC4_INST T, _xvec2, _xvec3, _xvec4, _xref2, _xref3, _xref4 + +#define BVEC2_INST bool, _bvec2, _bvec3, _bvec4, _xref2 +#define BVEC3_INST bool, _bvec2, _bvec3, _bvec4, _xref2, _xref3 +#define BVEC4_INST bool, _bvec2, _bvec3, _bvec4, _xref2, _xref3, _xref4 + +#define HVEC2_INST hdata, _hvec2GTX, _hvec3GTX, _hvec4GTX, _xref2 +#define HVEC3_INST hdata, _hvec2GTX, _hvec3GTX, _hvec4GTX, _xref2, _xref3 +#define HVEC4_INST hdata, _hvec2GTX, _hvec3GTX, _hvec4GTX, _xref2, _xref3, _xref4 + +#define _xvec2_base(T) _cvec2, _xvec3, _xvec4, _xref2 > +#define _xvec3_base(T) _cvec3, _xvec3, _xvec4, _xref2, _xref3 > +#define _xvec4_base(T) _cvec4, _xvec3, _xvec4, _xref2, _xref3, _xref4 > + +namespace glm{ +namespace detail{ + + template class _xref2; //!< \dontinclude + template class _xref3; //!< \dontinclude + template class _xref4; //!< \dontinclude + + template class _xvec2; //!< \dontinclude + template class _xvec3; //!< \dontinclude + template class _xvec4; //!< \dontinclude + + class _bvec2; //!< \dontinclude + class _bvec3; //!< \dontinclude + class _bvec4; //!< \dontinclude +} //namespace detail +} //namespace glm + +#endif//__glm_core_cvecx_h__ diff --git a/wip/sse/glm/core/_func.h b/wip/sse/glm/core/_func.h new file mode 100644 index 00000000..070b189d --- /dev/null +++ b/wip/sse/glm/core/_func.h @@ -0,0 +1,359 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-12 +// Updated : 2007-01-05 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_func.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_func__ +#define __glm_func__ + +#include "./_xvec2.h" +#include "./_xvec3.h" +#include "./_xvec4.h" +#include "./_bvec2.h" +#include "./_bvec3.h" +#include "./_bvec4.h" +#include "./_xmat2.h" +#include "./_xmat3.h" +#include "./_xmat4.h" +#include "./_xmat2x3.h" +#include "./_xmat3x2.h" +#include "./_xmat2x4.h" +#include "./_xmat4x2.h" +#include "./_xmat3x4.h" +#include "./_xmat4x3.h" +/* +#ifdef WIN32 +#pragma warning (disable : 4244) +#endif //WIN32 +*/ +namespace glm +{ + //////////////////////////////////////////////////////////////////////// + // Trigonometric Functions + + template T radians(T degrees); //!< \brief Converts degrees to radians and returns the result. (From GLSL 1.10.59 specification) + template detail::_xvec2 radians(const detail::_xvec2& degrees); //!< \brief Converts degrees to radians and returns the result. (From GLSL 1.10.59 specification) + template detail::_xvec3 radians(const detail::_xvec3& degrees); //!< \brief Converts degrees to radians and returns the result. (From GLSL 1.10.59 specification) + template detail::_xvec4 radians(const detail::_xvec4& degrees); //!< \brief Converts degrees to radians and returns the result. (From GLSL 1.10.59 specification) + + template T degrees(T radians); //!< \brief Converts radians to degrees and returns the result. (From GLSL 1.10.59 specification) + template detail::_xvec2 degrees(const detail::_xvec2& radians); //!< \brief Converts radians to degrees and returns the result. (From GLSL 1.10.59 specification) + template detail::_xvec3 degrees(const detail::_xvec3& radians); //!< \brief Converts radians to degrees and returns the result. (From GLSL 1.10.59 specification) + template detail::_xvec4 degrees(const detail::_xvec4& radians); //!< \brief Converts radians to degrees and returns the result. (From GLSL 1.10.59 specification) + + template T sin(T angle); //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + template detail::_xvec2 sin(const detail::_xvec2& angle); //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + template detail::_xvec3 sin(const detail::_xvec3& angle); //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + template detail::_xvec4 sin(const detail::_xvec4& angle); //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + + template T cos(T angle); //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + template detail::_xvec2 cos(const detail::_xvec2& angle); //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + template detail::_xvec3 cos(const detail::_xvec3& angle); //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + template detail::_xvec4 cos(const detail::_xvec4& angle); //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLSL 1.10.59 specification) + + template T tan(T angle); //!< \brief The standard trigonometric tangent function. (From GLSL 1.10.59 specification) + template detail::_xvec2 tan(const detail::_xvec2& angle); //!< \brief The standard trigonometric tangent function. (From GLSL 1.10.59 specification) + template detail::_xvec3 tan(const detail::_xvec3& angle); //!< \brief The standard trigonometric tangent function. (From GLSL 1.10.59 specification) + template detail::_xvec4 tan(const detail::_xvec4& angle); //!< \brief The standard trigonometric tangent function. (From GLSL 1.10.59 specification) + + template T asin(T x); //!< \brief Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + template detail::_xvec2 asin(const detail::_xvec2& x); //!< \brief Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + template detail::_xvec3 asin(const detail::_xvec3& x); //!< \brief Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + template detail::_xvec4 asin(const detail::_xvec4& x); //!< \brief Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + + template T acos(T x); //!< \brief Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + template detail::_xvec2 acos(const detail::_xvec2& x); //!< \brief Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + template detail::_xvec3 acos(const detail::_xvec3& x); //!< \brief Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + template detail::_xvec4 acos(const detail::_xvec4& x); //!< \brief Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1. (From GLSL 1.10.59 specification) + + template T atan(T y, T x); //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLSL 1.10.59 specification) + template detail::_xvec2 atan(const detail::_xvec2& y, const detail::_xvec2& x); //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLSL 1.10.59 specification) + template detail::_xvec3 atan(const detail::_xvec3& y, const detail::_xvec3& x); //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLSL 1.10.59 specification) + template detail::_xvec4 atan(const detail::_xvec4& y, const detail::_xvec4& x); //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLSL 1.10.59 specification) + + template T atan(T y_over_x); //!< \brief Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this function is [-PI/2, PI/2]. (From GLSL 1.10.59 specification) + template detail::_xvec2 atan(const detail::_xvec2& y_over_x); //!< \brief Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this function is [-PI/2, PI/2]. (From GLSL 1.10.59 specification) + template detail::_xvec3 atan(const detail::_xvec3& y_over_x); //!< \brief Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this function is [-PI/2, PI/2]. (From GLSL 1.10.59 specification) + template detail::_xvec4 atan(const detail::_xvec4& y_over_x); //!< \brief Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this function is [-PI/2, PI/2]. (From GLSL 1.10.59 specification) + + //////////////////////////////////////////////////////////////////////// + // Exponential Functions + + template T pow(T x, T y); //!< \brief Returns x raised to the y power. (From GLSL 1.10.59 specification) + template detail::_xvec2 pow(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns x raised to the y power. (From GLSL 1.10.59 specification) + template detail::_xvec3 pow(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns x raised to the y power. (From GLSL 1.10.59 specification) + template detail::_xvec4 pow(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns x raised to the y power. (From GLSL 1.10.59 specification) + + template T exp(T x); //!< \brief Returns the natural exponentiation of x, i.e., e^x. (From GLSL 1.10.59 specification) + template detail::_xvec2 exp(const detail::_xvec2& x); //!< \brief Returns the natural exponentiation of x, i.e., e^x. (From GLSL 1.10.59 specification) + template detail::_xvec3 exp(const detail::_xvec3& x); //!< \brief Returns the natural exponentiation of x, i.e., e^x. (From GLSL 1.10.59 specification) + template detail::_xvec4 exp(const detail::_xvec4& x); //!< \brief Returns the natural exponentiation of x, i.e., e^x. (From GLSL 1.10.59 specification) + + template T log(T x); //!< \brief Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if x <= 0. (From GLSL 1.10.59 specification) + template detail::_xvec2 log(const detail::_xvec2& x); //!< \brief Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if x <= 0. (From GLSL 1.10.59 specification) + template detail::_xvec3 log(const detail::_xvec3& x); //!< \brief Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if x <= 0. (From GLSL 1.10.59 specification) + template detail::_xvec4 log(const detail::_xvec4& x); //!< \brief Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if x <= 0. (From GLSL 1.10.59 specification) + + template T exp2(T x); //!< \brief Returns 2 raised to the x power. (From GLSL 1.10.59 specification) + template detail::_xvec2 exp2(const detail::_xvec2& x); //!< \brief Returns 2 raised to the x power. (From GLSL 1.10.59 specification) + template detail::_xvec3 exp2(const detail::_xvec3& x); //!< \brief Returns 2 raised to the x power. (From GLSL 1.10.59 specification) + template detail::_xvec4 exp2(const detail::_xvec4& x); //!< \brief Returns 2 raised to the x power. (From GLSL 1.10.59 specification) + + template T log2(T x); //!< \brief Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y. (From GLSL 1.10.59 specification) + template detail::_xvec2 log2(const detail::_xvec2& x); //!< \brief Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y. (From GLSL 1.10.59 specification) + template detail::_xvec3 log2(const detail::_xvec3& x); //!< \brief Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y. (From GLSL 1.10.59 specification) + template detail::_xvec4 log2(const detail::_xvec4& x); //!< \brief Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y. (From GLSL 1.10.59 specification) + + template T sqrt(T x); //!< \brief Returns the positive square root of x. (From GLSL 1.10.59 specification) + template detail::_xvec2 sqrt(const detail::_xvec2& x); //!< \brief Returns the positive square root of x. (From GLSL 1.10.59 specification) + template detail::_xvec3 sqrt(const detail::_xvec3& x); //!< \brief Returns the positive square root of x. (From GLSL 1.10.59 specification) + template detail::_xvec4 sqrt(const detail::_xvec4& x); //!< \brief Returns the positive square root of x. (From GLSL 1.10.59 specification) + + template T inversesqrt(T x); //!< \brief Returns the reciprocal of the positive square root of x. (From GLSL 1.10.59 specification) + template detail::_xvec2 inversesqrt(const detail::_xvec2& x); //!< \brief Returns the reciprocal of the positive square root of x. (From GLSL 1.10.59 specification) + template detail::_xvec3 inversesqrt(const detail::_xvec3& x); //!< \brief Returns the reciprocal of the positive square root of x. (From GLSL 1.10.59 specification) + template detail::_xvec4 inversesqrt(const detail::_xvec4& x); //!< \brief Returns the reciprocal of the positive square root of x. (From GLSL 1.10.59 specification) + + //////////////////////////////////////////////////////////////////////// + // Common Functions + + template T abs(T x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLSL 1.10.59 specification) + template detail::_xvec2 abs(const detail::_xvec2& x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLSL 1.10.59 specification) + template detail::_xvec3 abs(const detail::_xvec3& x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLSL 1.10.59 specification) + template detail::_xvec4 abs(const detail::_xvec4& x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLSL 1.10.59 specification) + + template T sign(T x); //!< \brief Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0. (From GLSL 1.10.59 specification) + template detail::_xvec2 sign(const detail::_xvec2& x); //!< \brief Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0. (From GLSL 1.10.59 specification) + template detail::_xvec3 sign(const detail::_xvec3& x); //!< \brief Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0. (From GLSL 1.10.59 specification) + template detail::_xvec4 sign(const detail::_xvec4& x); //!< \brief Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0. (From GLSL 1.10.59 specification) + + template T floor(T x); //!< \brief Returns a value equal to the nearest integer that is less then or equal to x. (From GLSL 1.10.59 specification) + template detail::_xvec2 floor(const detail::_xvec2& x); //!< \brief Returns a value equal to the nearest integer that is less then or equal to x. (From GLSL 1.10.59 specification) + template detail::_xvec3 floor(const detail::_xvec3& x); //!< \brief Returns a value equal to the nearest integer that is less then or equal to x. (From GLSL 1.10.59 specification) + template detail::_xvec4 floor(const detail::_xvec4& x); //!< \brief Returns a value equal to the nearest integer that is less then or equal to x. (From GLSL 1.10.59 specification) + + template T ceil(T x); //!< \brief Returns a value equal to the nearest integer that is greater than or equal to x. (From GLSL 1.10.59 specification) + template detail::_xvec2 ceil(const detail::_xvec2& x); //!< \brief Returns a value equal to the nearest integer that is greater than or equal to x. (From GLSL 1.10.59 specification) + template detail::_xvec3 ceil(const detail::_xvec3& x); //!< \brief Returns a value equal to the nearest integer that is greater than or equal to x. (From GLSL 1.10.59 specification) + template detail::_xvec4 ceil(const detail::_xvec4& x); //!< \brief Returns a value equal to the nearest integer that is greater than or equal to x. (From GLSL 1.10.59 specification) + + template T fract(T x); //!< \brief Return x - floor(x). (From GLSL 1.10.59 specification) + template detail::_xvec2 fract(const detail::_xvec2& x); //!< \brief Return x - floor(x). (From GLSL 1.10.59 specification) + template detail::_xvec3 fract(const detail::_xvec3& x); //!< \brief Return x - floor(x). (From GLSL 1.10.59 specification) + template detail::_xvec4 fract(const detail::_xvec4& x); //!< \brief Return x - floor(x). (From GLSL 1.10.59 specification) + + template T mod(T x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLSL 1.10.59 specification) + template detail::_xvec2 mod(const detail::_xvec2& x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLSL 1.10.59 specification) + template detail::_xvec3 mod(const detail::_xvec3& x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLSL 1.10.59 specification) + template detail::_xvec4 mod(const detail::_xvec4& x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLSL 1.10.59 specification) + template detail::_xvec2 mod(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the corresponding component of y. (From GLSL 1.10.59 specification) + template detail::_xvec3 mod(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the corresponding component of y. (From GLSL 1.10.59 specification) + template detail::_xvec4 mod(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the corresponding component of y. (From GLSL 1.10.59 specification) + + template T min(T x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec2 min(const detail::_xvec2& x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec3 min(const detail::_xvec3& x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec4 min(const detail::_xvec4& x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec2 min(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns minimum of each component of x compared with the floating-point value y. (From GLSL 1.10.59 specification) + template detail::_xvec3 min(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns minimum of each component of x compared with the floating-point value y. (From GLSL 1.10.59 specification) + template detail::_xvec4 min(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns minimum of each component of x compared with the floating-point value y. (From GLSL 1.10.59 specification) + + template T max(T x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec2 max(const detail::_xvec2& x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec3 max(const detail::_xvec3& x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec4 max(const detail::_xvec4& x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLSL 1.10.59 specification) + template detail::_xvec2 max(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns maximum of each component of x compared with the floating-point value y. (From GLSL 1.10.59 specification) + template detail::_xvec3 max(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns maximum of each component of x compared with the floating-point value y. (From GLSL 1.10.59 specification) + template detail::_xvec4 max(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns maximum of each component of x compared with the floating-point value y. (From GLSL 1.10.59 specification) + + template T clamp(T x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLSL 1.10.59 specification) + template detail::_xvec2 clamp(const detail::_xvec2& x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLSL 1.10.59 specification) + template detail::_xvec3 clamp(const detail::_xvec3& x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLSL 1.10.59 specification) + template detail::_xvec4 clamp(const detail::_xvec4& x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLSL 1.10.59 specification) + template detail::_xvec2 clamp(const detail::_xvec2& x, const detail::_xvec2& minVal, const detail::_xvec2& maxVal); //!< \brief Returns the component-wise result of min(max(x, minVal), maxVal). (From GLSL 1.10.59 specification) + template detail::_xvec3 clamp(const detail::_xvec3& x, const detail::_xvec3& minVal, const detail::_xvec3& maxVal); //!< \brief Returns the component-wise result of min(max(x, minVal), maxVal). (From GLSL 1.10.59 specification) + template detail::_xvec4 clamp(const detail::_xvec4& x, const detail::_xvec4& minVal, const detail::_xvec4& maxVal); //!< \brief Returns the component-wise result of min(max(x, minVal), maxVal). (From GLSL 1.10.59 specification) + + template T mix(const T& x, const T& y, const U& a); // Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) +/* + template T mix(T x, T y, T a); //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) + template _xvec2 mix(const _xvec2& x, const _xvec2& y, T a); //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) + template _xvec3 mix(const _xvec3& x, const _xvec3& y, T a); //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) + template _xvec4 mix(const _xvec4& x, const _xvec4& y, T a); //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) + template _xvec2 mix(const _xvec2& x, const _xvec2& y, const _xvec2& a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) + template _xvec3 mix(const _xvec3& x, const _xvec3& y, const _xvec3& a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) + template _xvec4 mix(const _xvec4& x, const _xvec4& y, const _xvec4& a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLSL 1.10.59 specification) +*/ + template T step(T edge, T x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLSL 1.10.59 specification) + template detail::_xvec2 step(T edge, const detail::_xvec2& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLSL 1.10.59 specification) + template detail::_xvec3 step(T edge, const detail::_xvec3& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLSL 1.10.59 specification) + template detail::_xvec4 step(T edge, const detail::_xvec4& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLSL 1.10.59 specification) + template detail::_xvec2 step(const detail::_xvec2& edge, const detail::_xvec2& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLSL 1.10.59 specification) + template detail::_xvec3 step(const detail::_xvec3& edge, const detail::_xvec3& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLSL 1.10.59 specification) + template detail::_xvec4 step(const detail::_xvec4& edge, const detail::_xvec4& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLSL 1.10.59 specification) + + template T smoothstep(T edge0, T edge1, T x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLSL 1.10.59 specification) + template detail::_xvec2 smoothstep(T edge0, T edge1, const detail::_xvec2& x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLSL 1.10.59 specification) + template detail::_xvec3 smoothstep(T edge0, T edge1, const detail::_xvec3& x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLSL 1.10.59 specification) + template detail::_xvec4 smoothstep(T edge0, T edge1, const detail::_xvec4& x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLSL 1.10.59 specification) + template detail::_xvec2 smoothstep(const detail::_xvec2& edge0, const detail::_xvec2& edge1, const detail::_xvec2& x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLSL 1.10.59 specification) + template detail::_xvec3 smoothstep(const detail::_xvec3& edge0, const detail::_xvec3& edge1, const detail::_xvec3& x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLSL 1.10.59 specification) + template detail::_xvec4 smoothstep(const detail::_xvec4& edge0, const detail::_xvec4& edge1, const detail::_xvec4& x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLSL 1.10.59 specification) + + //////////////////////////////////////////////////////////////////////// + // Geometric Functions + + template T length(T x); //!< \brief Returns the length of x, i.e., sqrt(x * x). (From GLSL 1.10.59 specification) + template T length(const detail::_xvec2& x); //!< \brief Returns the length of x, i.e., sqrt(x[0] * x[0] + x[1] * x[1]). (From GLSL 1.10.59 specification) + template T length(const detail::_xvec3& x); //!< \brief Returns the length of x, i.e., sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]). (From GLSL 1.10.59 specification) + template T length(const detail::_xvec4& x); //!< \brief Returns the length of x, i.e., sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2] + x[3] * x[3]). (From GLSL 1.10.59 specification) + + template T distance(const T p0, const T p1); //!< \brief Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). (From GLSL 1.10.59 specification) + template T distance(const detail::_xvec2& p0, const detail::_xvec2& p1); //!< \brief Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). (From GLSL 1.10.59 specification) + template T distance(const detail::_xvec3& p0, const detail::_xvec3& p1); //!< \brief Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). (From GLSL 1.10.59 specification) + template T distance(const detail::_xvec4& p0, const detail::_xvec4& p1); //!< \brief Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). (From GLSL 1.10.59 specification) + //template valType distance(const genType& p0, const genType& p1); //!< \brief Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). (From GLSL 1.10.59 specification) + + template T dot(T v1, T v2); //!< \brief Returns the dot product of x and y, i.e., result = x * y. (From GLSL 1.10.59 specification) + template T dot(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns the dot product of x and y, i.e., result = x[0] * y[0] + x[1] * y[1]. (From GLSL 1.10.59 specification) + template T dot(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the dot product of x and y, i.e., result = x[0] * y[0] + x[1] * y[1] + x[2] * y[2]. (From GLSL 1.10.59 specification) + template T dot(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns the dot product of x and y, i.e., result = x[0] * y[0] + x[1] * y[1] + x[2] * y[2] + x[3] * y[3]. (From GLSL 1.10.59 specification) + + template detail::_xvec3 cross(const detail::_xvec3& x, const detail::_xvec3& y); //!< brief Returns the cross product of x and y. (From GLSL 1.10.59 specification) + + template T normalize(T x); //!< \brief Returns a vector in the same direction as x but with length of 1. (From GLSL 1.10.59 specification) + template detail::_xvec2 normalize(const detail::_xvec2& x); //!< \brief Returns a vector in the same direction as x but with length of 1. (From GLSL 1.10.59 specification) + template detail::_xvec3 normalize(const detail::_xvec3& x); //!< \brief Returns a vector in the same direction as x but with length of 1. (From GLSL 1.10.59 specification) + template detail::_xvec4 normalize(const detail::_xvec4& x); //!< \brief Returns a vector in the same direction as x but with length of 1. (From GLSL 1.10.59 specification) + + //template genType faceforward(const genType& N, const genType& I, const genType& Nref); //!< \brief If dot(Nref, I) < 0.0, return N, otherwise, return -N. (From GLSL 1.10.59 specification) + template T faceforward(T N, T I, T Nref); //!< \brief If dot(Nref, I) < 0.0, return N, otherwise, return -N. (From GLSL 1.10.59 specification) + template detail::_xvec2 faceforward(const detail::_xvec2& N, const detail::_xvec2& I, const detail::_xvec2& Nref); //!< \brief If dot(Nref, I) < 0.0, return N, otherwise, return -N. (From GLSL 1.10.59 specification) + template detail::_xvec3 faceforward(const detail::_xvec3& N, const detail::_xvec3& I, const detail::_xvec3& Nref); //!< \brief If dot(Nref, I) < 0.0, return N, otherwise, return -N. (From GLSL 1.10.59 specification) + template detail::_xvec4 faceforward(const detail::_xvec4& N, const detail::_xvec4& I, const detail::_xvec4& Nref); //!< \brief If dot(Nref, I) < 0.0, return N, otherwise, return -N. (From GLSL 1.10.59 specification) + + //template genType reflect(const genType& I, const genType& N); //!< \brief For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N. (From GLSL 1.10.59 specification) + template T reflect(T I, T N); //!< \brief For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N. (From GLSL 1.10.59 specification) + template detail::_xvec2 reflect(const detail::_xvec2& I, const detail::_xvec2& N); //!< \brief For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N. (From GLSL 1.10.59 specification) + template detail::_xvec3 reflect(const detail::_xvec3& I, const detail::_xvec3& N); //!< \brief For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N. (From GLSL 1.10.59 specification) + template detail::_xvec4 reflect(const detail::_xvec4& I, const detail::_xvec4& N); //!< \brief For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N. (From GLSL 1.10.59 specification) + + template T refract(T I, T N, T eta); //!< \brief For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector. (From GLSL 1.10.59 specification) + template detail::_xvec2 refract(const detail::_xvec2& I, const detail::_xvec2& N, T eta); //!< \brief For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector. (From GLSL 1.10.59 specification) + template detail::_xvec3 refract(const detail::_xvec3& I, const detail::_xvec3& N, T eta); //!< \brief For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector. (From GLSL 1.10.59 specification) + template detail::_xvec4 refract(const detail::_xvec4& I, const detail::_xvec4& N, T eta); //!< \brief For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector. (From GLSL 1.10.59 specification) + + //////////////////////////////////////////////////////////////////////// + // Matrix Functions + + template detail::_xmat2 matrixCompMult(const detail::_xmat2& x, const detail::_xmat2& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.10.59 specification) + template detail::_xmat3 matrixCompMult(const detail::_xmat3& x, const detail::_xmat3& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.10.59 specification) + template detail::_xmat4 matrixCompMult(const detail::_xmat4& x, const detail::_xmat4& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.10.59 specification) + template detail::_xmat2x3 matrixCompMult(const detail::_xmat2x3& x, const detail::_xmat2x3& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.20.6 specification) + template detail::_xmat3x2 matrixCompMult(const detail::_xmat3x2& x, const detail::_xmat3x2& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.20.6 specification) + template detail::_xmat2x4 matrixCompMult(const detail::_xmat2x4& x, const detail::_xmat2x4& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.20.6 specification) + template detail::_xmat4x2 matrixCompMult(const detail::_xmat4x2& x, const detail::_xmat4x2& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.20.6 specification) + template detail::_xmat3x4 matrixCompMult(const detail::_xmat3x4& x, const detail::_xmat3x4& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.20.6 specification) + template detail::_xmat4x3 matrixCompMult(const detail::_xmat4x3& x, const detail::_xmat4x3& y); //!< \brief Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (From GLSL 1.20.6 specification) + + template detail::_xmat2 outerProduct(const detail::_xvec2& c, const detail::_xvec2& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat3 outerProduct(const detail::_xvec3& c, const detail::_xvec3& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat4 outerProduct(const detail::_xvec4& c, const detail::_xvec4& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat2x3 outerProduct(const detail::_xvec3& c, const detail::_xvec2& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat3x2 outerProduct(const detail::_xvec2& c, const detail::_xvec3& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat2x4 outerProduct(const detail::_xvec2& c, const detail::_xvec4& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat4x2 outerProduct(const detail::_xvec4& c, const detail::_xvec2& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat3x4 outerProduct(const detail::_xvec4& c, const detail::_xvec3& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + template detail::_xmat4x3 outerProduct(const detail::_xvec3& c, const detail::_xvec4& r); //!< \brief Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (From GLSL 1.20.6 specification) + + template detail::_xmat2 transpose(const detail::_xmat2& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat3 transpose(const detail::_xmat3& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat4 transpose(const detail::_xmat4& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat2x3 transpose(const detail::_xmat3x2& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat3x2 transpose(const detail::_xmat2x3& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat2x4 transpose(const detail::_xmat4x2& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat4x2 transpose(const detail::_xmat2x4& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat3x4 transpose(const detail::_xmat4x3& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + template detail::_xmat4x3 transpose(const detail::_xmat3x4& x); //!< Returns the transposed matrix of x (From GLSL 1.20.6 specification) + + //////////////////////////////////////////////////////////////////////// + // Vector Relational Functions + + template detail::_bvec2 lessThan(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns the component-wise compare of x < y. (From GLSL 1.10.59 specification) + template detail::_bvec3 lessThan(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the component-wise compare of x < y. (From GLSL 1.10.59 specification) + template detail::_bvec4 lessThan(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns the component-wise compare of x < y. (From GLSL 1.10.59 specification) + + template detail::_bvec2 lessThanEqual(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns the component-wise compare of x <= y. (From GLSL 1.10.59 specification) + template detail::_bvec3 lessThanEqual(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the component-wise compare of x <= y. (From GLSL 1.10.59 specification) + template detail::_bvec4 lessThanEqual(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns the component-wise compare of x <= y. (From GLSL 1.10.59 specification) + + template detail::_bvec2 greaterThan(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns the component-wise compare of x > y. (From GLSL 1.10.59 specification) + template detail::_bvec3 greaterThan(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the component-wise compare of x > y. (From GLSL 1.10.59 specification) + template detail::_bvec4 greaterThan(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns the component-wise compare of x > y. (From GLSL 1.10.59 specification) + + template detail::_bvec2 greaterThanEqual(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns the component-wise compare of x >= y. (From GLSL 1.10.59 specification) + template detail::_bvec3 greaterThanEqual(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the component-wise compare of x >= y. (From GLSL 1.10.59 specification) + template detail::_bvec4 greaterThanEqual(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns the component-wise compare of x >= y. (From GLSL 1.10.59 specification) + + detail::_bvec2 equal(const detail::_bvec2& x, const detail::_bvec2& y); //!< \brief Returns the component-wise compare of x == y. (From GLSL 1.10.59 specification) + detail::_bvec3 equal(const detail::_bvec3& x, const detail::_bvec3& y); //!< \brief Returns the component-wise compare of x == y. (From GLSL 1.10.59 specification) + detail::_bvec4 equal(const detail::_bvec4& x, const detail::_bvec4& y); //!< \brief Returns the component-wise compare of x == y. (From GLSL 1.10.59 specification) + template detail::_bvec2 equal(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns the component-wise compare of x == y. (From GLSL 1.10.59 specification) + template detail::_bvec3 equal(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the component-wise compare of x == y. (From GLSL 1.10.59 specification) + template detail::_bvec4 equal(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns the component-wise compare of x == y. (From GLSL 1.10.59 specification) + + detail::_bvec2 notEqual(const detail::_bvec2& x, const detail::_bvec2& y); //!< \brief Returns the component-wise compare of x != y. (From GLSL 1.10.59 specification) + detail::_bvec3 notEqual(const detail::_bvec3& x, const detail::_bvec3& y); //!< \brief Returns the component-wise compare of x != y. (From GLSL 1.10.59 specification) + detail::_bvec4 notEqual(const detail::_bvec4& x, const detail::_bvec4& y); //!< \brief Returns the component-wise compare of x != y. (From GLSL 1.10.59 specification) + template detail::_bvec2 notEqual(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns the component-wise compare of x != y. (From GLSL 1.10.59 specification) + template detail::_bvec3 notEqual(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the component-wise compare of x != y. (From GLSL 1.10.59 specification) + template detail::_bvec4 notEqual(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns the component-wise compare of x != y. (From GLSL 1.10.59 specification) + + bool any(const detail::_bvec2& x); //!< \brief Returns true if any component of x is true. (From GLSL 1.10.59 specification) + bool any(const detail::_bvec3& x); //!< \brief Returns true if any component of x is true. (From GLSL 1.10.59 specification) + bool any(const detail::_bvec4& x); //!< \brief Returns true if any component of x is true. (From GLSL 1.10.59 specification) + + bool all(const detail::_bvec2& x); //!< \brief Returns true if all component of x is true. (From GLSL 1.10.59 specification) + bool all(const detail::_bvec3& x); //!< \brief Returns true if all component of x is true. (From GLSL 1.10.59 specification) + bool all(const detail::_bvec4& x); //!< \brief Returns true if all component of x is true. (From GLSL 1.10.59 specification) + +#if (defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC) // VC compiler doesn't support the C++ key word 'not' + bool not(bool x); //!< \brief Returns the component-wise logical complement of x. (From GLSL 1.10.59 specification) + detail::_bvec2 not(const detail::_bvec2& v); //!< \brief Returns the component-wise logical complement of x. (From GLSL 1.10.59 specification) + detail::_bvec3 not(const detail::_bvec3& v); //!< \brief Returns the component-wise logical complement of x. (From GLSL 1.10.59 specification) + detail::_bvec4 not(const detail::_bvec4& v); //!< \brief Returns the component-wise logical complement of x. (From GLSL 1.10.59 specification) +#elif (defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_GCC) // GCC + detail::_bvec2 operator not(const detail::_bvec2& v); //!< \brief Returns the component-wise logical complement of x. (From GLSL 1.10.59 specification) + detail::_bvec3 operator not(const detail::_bvec3& v); //!< \brief Returns the component-wise logical complement of x. (From GLSL 1.10.59 specification) + detail::_bvec4 operator not(const detail::_bvec4& v); //!< \brief Returns the component-wise logical complement of x. (From GLSL 1.10.59 specification) +#endif + + //////////////////////////////////////////////////////////////////////// + // Noise Functions + + template T noise1(T x); //!< \brief Returns a 1D noise value based on the input value x. (From GLSL 1.10.59 specification) + template T noise1(const detail::_xvec2& x); //!< \brief Returns a 1D noise value based on the input value x. (From GLSL 1.10.59 specification) + template T noise1(const detail::_xvec3& x); //!< \brief Returns a 1D noise value based on the input value x. (From GLSL 1.10.59 specification) + template T noise1(const detail::_xvec4& x); //!< \brief Returns a 1D noise value based on the input value x. (From GLSL 1.10.59 specification) + + template detail::_xvec2 noise2(T x); //!< \brief Returns a 2D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec2 noise2(const detail::_xvec2& x); //!< \brief Returns a 2D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec2 noise2(const detail::_xvec3& x); //!< \brief Returns a 2D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec2 noise2(const detail::_xvec4& x); //!< \brief Returns a 2D noise value based on the input value x. (From GLSL 1.10.59 specification) + + template detail::_xvec3 noise3(T x); //!< \brief Returns a 3D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec3 noise3(const detail::_xvec2& x); //!< \brief Returns a 3D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec3 noise3(const detail::_xvec3& x); //!< \brief Returns a 3D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec3 noise3(const detail::_xvec4& x); //!< \brief Returns a 3D noise value based on the input value x. (From GLSL 1.10.59 specification) + + template detail::_xvec4 noise4(T x); //!< \brief Returns a 4D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec4 noise4(const detail::_xvec2& x); //!< \brief Returns a 4D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec4 noise4(const detail::_xvec3& x); //!< \brief Returns a 4D noise value based on the input value x. (From GLSL 1.10.59 specification) + template detail::_xvec4 noise4(const detail::_xvec4& x); //!< \brief Returns a 4D noise value based on the input value x. (From GLSL 1.10.59 specification) +} //namespace glm + +#endif //__glm_func__ diff --git a/wip/sse/glm/core/_func.inl b/wip/sse/glm/core/_func.inl new file mode 100644 index 00000000..fcbfecf9 --- /dev/null +++ b/wip/sse/glm/core/_func.inl @@ -0,0 +1,2247 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-12 +// Updated : 2007-03-19 +// Licence : This source is under GNU LGPL licence +// File : _func.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __func_inl__ +#define __func_inl__ + +#include +#include +#include "./_func.h" + +namespace glm +{ + //////////////////////////////////////////////////////////////////////// + // Trigonometric Functions + + // radians + template + inline T radians(T degrees) + { + const T pi = T(3.1415926535897932384626433832795); + return degrees * (pi / T(180)); + } + + template + inline detail::_xvec2 radians(const detail::_xvec2& degrees) + { + return detail::_xvec2( + radians(degrees.x), + radians(degrees.y)); + } + + template + inline detail::_xvec3 radians(const detail::_xvec3& degrees) + { + return detail::_xvec3( + radians(degrees.x), + radians(degrees.y), + radians(degrees.z)); + } + + template + inline detail::_xvec4 radians(const detail::_xvec4& degrees) + { + return detail::_xvec4( + radians(degrees.x), + radians(degrees.y), + radians(degrees.z), + radians(degrees.w)); + } + + // degrees + template + inline T degrees(T radians) + { + const T pi = T(3.1415926535897932384626433832795); + return radians * (T(180) / pi); + } + + template + inline detail::_xvec2 degrees(const detail::_xvec2& radians) + { + return detail::_xvec2( + degrees(radians.x), + degrees(radians.y)); + } + + template + inline detail::_xvec3 degrees(const detail::_xvec3& radians) + { + return detail::_xvec3( + degrees(radians.x), + degrees(radians.y), + degrees(radians.z)); + } + + template + inline detail::_xvec4 degrees(const detail::_xvec4& radians) + { + return detail::_xvec4( + degrees(radians.x), + degrees(radians.y), + degrees(radians.z), + degrees(radians.w)); + } + + // sin + template + inline T sin(T angle) + { + return ::std::sin(angle); + } + + template + inline detail::_xvec2 sin(const detail::_xvec2& angle) + { + return detail::_xvec2( + sin(angle.x), + sin(angle.y)); + } + + template + inline detail::_xvec3 sin(const detail::_xvec3& angle) + { + return detail::_xvec3( + sin(angle.x), + sin(angle.y), + sin(angle.z)); + } + + template + inline detail::_xvec4 sin(const detail::_xvec4& angle) + { + return detail::_xvec4( + sin(angle.x), + sin(angle.y), + sin(angle.z), + sin(angle.w)); + } + + // cos + template + inline T cos(T angle) + { + return ::std::cos(angle); + } + + template + inline detail::_xvec2 cos(const detail::_xvec2& angle) + { + return detail::_xvec2( + cos(angle.x), + cos(angle.y)); + } + + template + inline detail::_xvec3 cos(const detail::_xvec3& angle) + { + return detail::_xvec3( + cos(angle.x), + cos(angle.y), + cos(angle.z)); + } + + template + inline detail::_xvec4 cos(const detail::_xvec4& angle) + { + return detail::_xvec4( + cos(angle.x), + cos(angle.y), + cos(angle.z), + cos(angle.w)); + } + + // tan + template + inline T tan(T angle) + { + return ::std::tan(angle); + } + + template + inline detail::_xvec2 tan(const detail::_xvec2& angle) + { + return detail::_xvec2( + tan(angle.x), + tan(angle.y)); + } + + template + inline detail::_xvec3 tan(const detail::_xvec3& angle) + { + return detail::_xvec3( + tan(angle.x), + tan(angle.y), + tan(angle.z)); + } + + template + inline detail::_xvec4 tan(const detail::_xvec4& angle) + { + return detail::_xvec4( + tan(angle.x), + tan(angle.y), + tan(angle.z), + tan(angle.w)); + } + + // asin + template + inline T asin(T x) + { + return ::std::asin(x); + } + + template + inline detail::_xvec2 asin(const detail::_xvec2& x) + { + return detail::_xvec2( + asin(x.x), + asin(x.y)); + } + + template + inline detail::_xvec3 asin(const detail::_xvec3& x) + { + return detail::_xvec3( + asin(x.x), + asin(x.y), + asin(x.z)); + } + + template + inline detail::_xvec4 asin(const detail::_xvec4& x) + { + return detail::_xvec4( + asin(x.x), + asin(x.y), + asin(x.z), + asin(x.w)); + } + + // acos + template + inline T acos(T x) + { + return ::std::acos(x); + } + + template + inline detail::_xvec2 acos(const detail::_xvec2& x) + { + return detail::_xvec2( + acos(x.x), + acos(x.y)); + } + + template + inline detail::_xvec3 acos(const detail::_xvec3& x) + { + return detail::_xvec3( + acos(x.x), + acos(x.y), + acos(x.z)); + } + + template + inline detail::_xvec4 acos(const detail::_xvec4& x) + { + return detail::_xvec4( + acos(x.x), + acos(x.y), + acos(x.z), + acos(x.w)); + } + + // atan + template + inline T atan(T y, T x) + { + return ::std::atan2(y, x); + } + + template + inline detail::_xvec2 atan(const detail::_xvec2& y, const detail::_xvec2& x) + { + return detail::_xvec2( + atan(y.x, x.x), + atan(y.y, x.y)); + } + + template + inline detail::_xvec3 atan(const detail::_xvec3& y, const detail::_xvec3& x) + { + return detail::_xvec3( + atan(y.x, x.x), + atan(y.y, x.y), + atan(y.z, x.z)); + } + + template + inline detail::_xvec4 atan(const detail::_xvec4& y, const detail::_xvec4& x) + { + return detail::_xvec4( + atan(y.x, x.x), + atan(y.y, x.y), + atan(y.z, x.z), + atan(y.w, x.w)); + } + + template + inline T atan(T x) + { + return ::std::atan(x); + } + + template + inline detail::_xvec2 atan(const detail::_xvec2& x) + { + return detail::_xvec2( + atan(x.x), + atan(x.y)); + } + + template + inline detail::_xvec3 atan(const detail::_xvec3& x) + { + return detail::_xvec3( + atan(x.x), + atan(x.y), + atan(x.z)); + } + + template + inline detail::_xvec4 atan(const detail::_xvec4& x) + { + return detail::_xvec4( + atan(x.x), + atan(x.y), + atan(x.z), + atan(x.w)); + } + + //////////////////////////////////////////////////////////////////////// + // Exponential Functions + + // pow + template + inline T pow(T x, T y) + { + return ::std::pow(x, y); + } + + template + inline detail::_xvec2 pow(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + pow(x.x, y.x), + pow(x.y, y.y)); + } + + template + inline detail::_xvec3 pow(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + pow(x.x, y.x), + pow(x.y, y.y), + pow(x.z, y.z)); + } + + template + inline detail::_xvec4 pow(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + pow(x.x, y.x), + pow(x.y, y.y), + pow(x.z, y.z), + pow(x.w, y.w)); + } + + // exp + template + inline T exp(T x) + { + return ::std::exp(x); + } + + template + inline detail::_xvec2 exp(const detail::_xvec2& x) + { + return detail::_xvec2( + exp(x.x), + exp(x.y)); + } + + template + inline detail::_xvec3 exp(const detail::_xvec3& x) + { + return detail::_xvec3( + exp(x.x), + exp(x.y), + exp(x.z)); + } + + template + inline detail::_xvec4 exp(const detail::_xvec4& x) + { + return detail::_xvec4( + exp(x.x), + exp(x.y), + exp(x.z), + exp(x.w)); + } + + // log + template + inline T log(T x) + { + return ::std::log(x); + } + + template + inline detail::_xvec2 log(const detail::_xvec2& x) + { + return detail::_xvec2( + log(x.x), + log(x.y)); + } + + template + inline detail::_xvec3 log(const detail::_xvec3& x) + { + return detail::_xvec3( + log(x.x), + log(x.y), + log(x.z)); + } + + template + inline detail::_xvec4 log(const detail::_xvec4& x) + { + return detail::_xvec4( + log(x.x), + log(x.y), + log(x.z), + log(x.w)); + } + + //exp2, ln2 = 0.69314718055994530941723212145818f + template + inline T exp2(T x) + { + return ::std::exp(T(0.69314718055994530941723212145818) * x); + } + + template + inline detail::_xvec2 exp2(const detail::_xvec2& x) + { + return detail::_xvec2( + exp2(x.x), + exp2(x.y)); + } + + template + inline detail::_xvec3 exp2(const detail::_xvec3& x) + { + return detail::_xvec3( + exp2(x.x), + exp2(x.y), + exp2(x.z)); + } + + template + inline detail::_xvec4 exp2(const detail::_xvec4& x) + { + return detail::_xvec4( + exp2(x.x), + exp2(x.y), + exp2(x.z), + exp2(x.w)); + } + + // log2, ln2 = 0.69314718055994530941723212145818f + template + inline T log2(T x) + { + return ::std::log(x) / T(0.69314718055994530941723212145818); + } + + template + inline detail::_xvec2 log2(const detail::_xvec2& x) + { + return detail::_xvec2( + log2(x.x), + log2(x.y)); + } + + template + inline detail::_xvec3 log2(const detail::_xvec3& x) + { + return detail::_xvec3( + log2(x.x), + log2(x.y), + log2(x.z)); + } + + template + inline detail::_xvec4 log2(const detail::_xvec4& x) + { + return detail::_xvec4( + log2(x.x), + log2(x.y), + log2(x.z), + log2(x.w)); + } + + // sqrt + template + inline T sqrt(T x) + { + return T(::std::sqrt(double(x))); + } + + template + inline detail::_xvec2 sqrt(const detail::_xvec2& x) + { + return detail::_xvec2( + sqrt(x.x), + sqrt(x.y)); + } + + template + inline detail::_xvec3 sqrt(const detail::_xvec3& x) + { + return detail::_xvec3( + sqrt(x.x), + sqrt(x.y), + sqrt(x.z)); + } + + template + inline detail::_xvec4 sqrt(const detail::_xvec4& x) + { + return detail::_xvec4( + sqrt(x.x), + sqrt(x.y), + sqrt(x.z), + sqrt(x.w)); + } + + template + inline T inversesqrt(T x) + { + return 1.0f / ::std::sqrt(x); + } + + template + inline detail::_xvec2 inversesqrt(const detail::_xvec2& x) + { + return detail::_xvec2( + inversesqrt(x.x), + inversesqrt(x.y)); + } + + template + inline detail::_xvec3 inversesqrt(const detail::_xvec3& x) + { + return detail::_xvec3( + inversesqrt(x.x), + inversesqrt(x.y), + inversesqrt(x.z)); + } + + template + inline detail::_xvec4 inversesqrt(const detail::_xvec4& x) + { + return detail::_xvec4( + inversesqrt(x.x), + inversesqrt(x.y), + inversesqrt(x.z), + inversesqrt(x.w)); + } + + //////////////////////////////////////////////////////////////////////// + // Common Functions + + // abs + template + inline T abs(T x) + { + return x >= T(0) ? x : -x; + } + + template + inline detail::_xvec2 abs(const detail::_xvec2& x) + { + return detail::_xvec2( + abs(x.x), + abs(x.y)); + } + + template + inline detail::_xvec3 abs(const detail::_xvec3& x) + { + return detail::_xvec3( + abs(x.x), + abs(x.y), + abs(x.z)); + } + + template + inline detail::_xvec4 abs(const detail::_xvec4& x) + { + return detail::_xvec4( + abs(x.x), + abs(x.y), + abs(x.z), + abs(x.w)); + } + + // sign +/* + Try something like based on x >> 31 to get the sign bit +*/ + template + inline T sign(T x) + { + T result; + if(x > T(0)) + result = T(1); + else if(x < T(0)) + result = T(-1); + else + result = T(0); + return result; + } + + template + inline detail::_xvec2 sign(const detail::_xvec2& x) + { + return detail::_xvec2( + sign(x.x), + sign(x.y)); + } + + template + inline detail::_xvec3 sign(const detail::_xvec3& x) + { + return detail::_xvec3( + sign(x.x), + sign(x.y), + sign(x.z)); + } + + template + inline detail::_xvec4 sign(const detail::_xvec4& x) + { + return detail::_xvec4( + sign(x.x), + sign(x.y), + sign(x.z), + sign(x.w)); + } + + // floor + template + inline T floor(T x) + { + return ::std::floor(x); + } + + template + inline detail::_xvec2 floor(const detail::_xvec2& x) + { + return detail::_xvec2( + floor(x.x), + floor(x.y)); + } + + template + inline detail::_xvec3 floor(const detail::_xvec3& x) + { + return detail::_xvec3( + floor(x.x), + floor(x.y), + floor(x.z)); + } + + template + inline detail::_xvec4 floor(const detail::_xvec4& x) + { + return detail::_xvec4( + floor(x.x), + floor(x.y), + floor(x.z), + floor(x.w)); + } + + // ceil + template + inline T ceil(T x) + { + return ::std::ceil(x); + } + + template + inline detail::_xvec2 ceil(const detail::_xvec2& x) + { + return detail::_xvec2( + ceil(x.x), + ceil(x.y)); + } + + template + inline detail::_xvec3 ceil(const detail::_xvec3& x) + { + return detail::_xvec3( + ceil(x.x), + ceil(x.y), + ceil(x.z)); + } + + template + inline detail::_xvec4 ceil(const detail::_xvec4& x) + { + return detail::_xvec4( + ceil(x.x), + ceil(x.y), + ceil(x.z), + ceil(x.w)); + } + + // fract + template + inline T fract(T x) + { + return x - ::std::floor(x); + } + + template + inline detail::_xvec2 fract(const detail::_xvec2& x) + { + return detail::_xvec2( + fract(x.x), + fract(x.y)); + } + + template + inline detail::_xvec3 fract(const detail::_xvec3& x) + { + return detail::_xvec3( + fract(x.x), + fract(x.y), + fract(x.z)); + } + + template + inline detail::_xvec4 fract(const detail::_xvec4& x) + { + return detail::_xvec4( + fract(x.x), + fract(x.y), + fract(x.z), + fract(x.w)); + } + + // mod + template + inline T mod(T x, T y) + { + return x - y * floor(x / y); + } + + template + inline detail::_xvec2 mod(const detail::_xvec2& x, T y) + { + return detail::_xvec2( + mod(x.x, y), + mod(x.y, y)); + } + + template + inline detail::_xvec3 mod(const detail::_xvec3& x, T y) + { + return detail::_xvec3( + mod(x.x, y), + mod(x.y, y), + mod(x.z, y)); + } + + template + inline detail::_xvec4 mod(const detail::_xvec4& x, T y) + { + return detail::_xvec4( + mod(x.x, y), + mod(x.y, y), + mod(x.z, y), + mod(x.w, y)); + } + + template + inline detail::_xvec2 mod(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + mod(x.x, y.x), + mod(x.y, y.y)); + } + + template + inline detail::_xvec3 mod(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + mod(x.x, y.x), + mod(x.y, y.y), + mod(x.z, y.z)); + } + + template + inline detail::_xvec4 mod(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + mod(x.x, y.x), + mod(x.y, y.y), + mod(x.z, y.z), + mod(x.w, y.w)); + } + + // min + template + inline T min(T x, T y) + { + return x < y ? x : y; + } + + template + inline detail::_xvec2 min(const detail::_xvec2& x, T y) + { + return detail::_xvec2( + min(x.x, y), + min(x.y, y)); + } + + template + inline detail::_xvec3 min(const detail::_xvec3& x, T y) + { + return detail::_xvec3( + min(x.x, y), + min(x.y, y), + min(x.z, y)); + } + + template + inline detail::_xvec4 min(const detail::_xvec4& x, T y) + { + return detail::_xvec4( + min(x.x, y), + min(x.y, y), + min(x.z, y), + min(x.w, y)); + } + + template + inline detail::_xvec2 min(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + min(x.x, y.x), + min(x.y, y.y)); + } + + template + inline detail::_xvec3 min(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + min(x.x, y.x), + min(x.y, y.y), + min(x.z, y.z)); + } + + template + inline detail::_xvec4 min(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + min(x.x, y.x), + min(x.y, y.y), + min(x.z, y.z), + min(x.w, y.w)); + } + + // max + template + inline T max(T x, T y) + { + return x > y ? x : y; + } + + template + inline detail::_xvec2 max(const detail::_xvec2& x, T y) + { + return detail::_xvec2( + max(x.x, y), + max(x.y, y)); + } + + template + inline detail::_xvec3 max(const detail::_xvec3& x, T y) + { + return detail::_xvec3( + max(x.x, y), + max(x.y, y), + max(x.z, y)); + } + + template + inline detail::_xvec4 max(const detail::_xvec4& x, T y) + { + return detail::_xvec4( + max(x.x, y), + max(x.y, y), + max(x.z, y), + max(x.w, y)); + } + + template + inline detail::_xvec2 max(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + max(x.x, y.x), + max(x.y, y.y)); + } + + template + inline detail::_xvec3 max(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + max(x.x, y.x), + max(x.y, y.y), + max(x.z, y.z)); + } + + template + inline detail::_xvec4 max(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + max(x.x, y.x), + max(x.y, y.y), + max(x.z, y.z), + max(x.w, y.w)); + } + + // clamp + template + inline T clamp(T x, T minVal, T maxVal) + { + if(x >= maxVal) return maxVal; + if(x <= minVal) return minVal; + return x; + } + + template + inline detail::_xvec2 clamp(const detail::_xvec2& x, T minVal, T maxVal) + { + return detail::_xvec2( + clamp(x.x, minVal, maxVal), + clamp(x.y, minVal, maxVal)); + } + + template + inline detail::_xvec3 clamp(const detail::_xvec3& x, T minVal, T maxVal) + { + return detail::_xvec3( + clamp(x.x, minVal, maxVal), + clamp(x.y, minVal, maxVal), + clamp(x.z, minVal, maxVal)); + } + + template + inline detail::_xvec4 clamp(const detail::_xvec4& x, T minVal, T maxVal) + { + return detail::_xvec4( + clamp(x.x, minVal, maxVal), + clamp(x.y, minVal, maxVal), + clamp(x.z, minVal, maxVal), + clamp(x.w, minVal, maxVal)); + } + + template + inline detail::_xvec2 clamp(const detail::_xvec2& x, const detail::_xvec2& minVal, const detail::_xvec2& maxVal) + { + return detail::_xvec2( + clamp(x.x, minVal.x, maxVal.x), + clamp(x.y, minVal.y, maxVal.y)); + } + + template + inline detail::_xvec3 clamp(const detail::_xvec3& x, const detail::_xvec3& minVal, const detail::_xvec3& maxVal) + { + return detail::_xvec3( + clamp(x.x, minVal.x, maxVal.x), + clamp(x.y, minVal.y, maxVal.y), + clamp(x.z, minVal.z, maxVal.z)); + } + + template + inline detail::_xvec4 clamp(const detail::_xvec4& x, const detail::_xvec4& minVal, const detail::_xvec4& maxVal) + { + return detail::_xvec4( + clamp(x.x, minVal.x, maxVal.x), + clamp(x.y, minVal.y, maxVal.y), + clamp(x.z, minVal.z, maxVal.z), + clamp(x.w, minVal.w, maxVal.w)); + } + + // mix + template + inline T mix(const T& x, const T& y, const U& a) + { + return x * (T(1) - a) + y * a; + } +/* + // mix + template + inline T mix(T x, T y, T a) + { + return x * (T(1) - a) + y * a; + } + + template + inline detail::_xvec2 mix(const detail::_xvec2& x, const detail::_xvec2& y, T a) + { + return x * (T(1) - a) + y * a; + } + + template + inline detail::_xvec3 mix(const detail::_xvec3& x, const detail::_xvec3& y, T a) + { + return x * (T(1) - a) + y * a; + } + + template + inline detail::_xvec4 mix(const detail::_xvec4& x, const detail::_xvec4& y, T a) + { + return x * (T(1) - a) + y * a; + } + + template + inline detail::_xvec2 mix(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& a) + { + return x * (T(1) - a) + y * a; + } + + template + inline detail::_xvec3 mix(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& a) + { + return x * (T(1) - a) + y * a; + } + + template + inline detail::_xvec4 mix(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& a) + { + return x * (T(1) - a) + y * a; + } +*/ + + // step + template + inline T step(T edge, T x) + { + return x <= edge ? T(0) : T(1); + } + + template + inline detail::_xvec2 step(T edge, const detail::_xvec2& x) + { + return detail::_xvec2( + x.x <= edge ? T(0) : T(1), + x.y <= edge ? T(0) : T(1)); + } + + template + inline detail::_xvec3 step(T edge, const detail::_xvec3& x) + { + return detail::_xvec3( + x.x <= edge ? T(0) : T(1), + x.y <= edge ? T(0) : T(1), + x.z <= edge ? T(0) : T(1)); + } + + template + inline detail::_xvec4 step(T edge, const detail::_xvec4& x) + { + return detail::_xvec4( + x.x <= edge ? T(0) : T(1), + x.y <= edge ? T(0) : T(1), + x.z <= edge ? T(0) : T(1), + x.w <= edge ? T(0) : T(1)); + } + + template + inline detail::_xvec2 step(const detail::_xvec2& edge, const detail::_xvec2& x) + { + return detail::_xvec2( + x.x <= edge.x ? T(0) : T(1), + x.y <= edge.y ? T(0) : T(1)); + } + + template + inline detail::_xvec3 step(const detail::_xvec3& edge, const detail::_xvec3& x) + { + return detail::_xvec3( + x.x <= edge.x ? T(0) : T(1), + x.y <= edge.y ? T(0) : T(1), + x.z <= edge.z ? T(0) : T(1)); + } + + template + inline detail::_xvec4 step(const detail::_xvec4& edge, const detail::_xvec4& x) + { + return detail::_xvec4( + x.x <= edge.x ? T(0) : T(1), + x.y <= edge.y ? T(0) : T(1), + x.z <= edge.z ? T(0) : T(1), + x.w <= edge.w ? T(0) : T(1)); + } + + // smoothstep + template + inline T smoothstep(T edge0, T edge1, T x) + { + T tmp = clamp((x - edge0) / (edge1 - edge0), T(0), T(1)); + return tmp * tmp * (T(3) - T(2) * tmp); + } + + template + inline detail::_xvec2 smoothstep(T edge0, T edge1, const detail::_xvec2& x) + { + return detail::_xvec2( + smoothstep(edge0, edge1, x.x), + smoothstep(edge0, edge1, x.y)); + } + + template + inline detail::_xvec3 smoothstep(T edge0, T edge1, const detail::_xvec3& x) + { + return detail::_xvec3( + smoothstep(edge0, edge1, x.x), + smoothstep(edge0, edge1, x.y), + smoothstep(edge0, edge1, x.z)); + } + + template + inline detail::_xvec4 smoothstep(T edge0, T edge1, const detail::_xvec4& x) + { + return detail::_xvec4( + smoothstep(edge0, edge1, x.x), + smoothstep(edge0, edge1, x.y), + smoothstep(edge0, edge1, x.z), + smoothstep(edge0, edge1, x.w)); + } + + template + inline detail::_xvec2 smoothstep(const detail::_xvec2& edge0, const detail::_xvec2& edge1, const detail::_xvec2& x) + { + return detail::_xvec2( + smoothstep(edge0.x, edge1.x, x.x), + smoothstep(edge0.y, edge1.y, x.y)); + } + + template + inline detail::_xvec3 smoothstep(const detail::_xvec3& edge0, const detail::_xvec3& edge1, const detail::_xvec3& x) + { + return detail::_xvec3( + smoothstep(edge0.x, edge1.x, x.x), + smoothstep(edge0.y, edge1.y, x.y), + smoothstep(edge0.z, edge1.z, x.z)); + } + + template + inline detail::_xvec4 smoothstep(const detail::_xvec4& edge0, const detail::_xvec4& edge1, const detail::_xvec4& x) + { + return detail::_xvec4( + smoothstep(edge0.x, edge1.x, x.x), + smoothstep(edge0.y, edge1.y, x.y), + smoothstep(edge0.z, edge1.z, x.z), + smoothstep(edge0.w, edge1.w, x.w)); + } + + //////////////////////////////////////////////////////////////////////// + // Geometric Functions + + // length + template + inline T length(T x) + { + return abs(x); + } + + template + inline T length(const detail::_xvec2& x) + { + T sqr = x.x * x.x + x.y * x.y; + return sqrt(sqr); + } + + template + inline T length(const detail::_xvec3& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z; + return sqrt(sqr); + } + + template + inline T length(const detail::_xvec4& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; + return sqrt(sqr); + } + + // distance + template + inline T distance(const T p0, const T p1) + { + return length(p1 - p0); + } + + template + inline T distance(const detail::_xvec2& p0, const detail::_xvec2& p1) + { + return length(p1 - p0); + } + + template + inline T distance(const detail::_xvec3& p0, const detail::_xvec3& p1) + { + return length(p1 - p0); + } + + template + inline T distance(const detail::_xvec4& p0, const detail::_xvec4& p1) + { + return length(p1 - p0); + } +/* + template + inline valType distance(const genType& p0, const genType& p1) + { + return length(p1 - p0); + } +*/ + // dot + template + inline T dot(T x, T y) + { + return x * y; + } + + template + inline T dot(const detail::_xvec2& x, const detail::_xvec2& y) + { + return x.x * y.x + x.y * y.y; + } + + template + inline T dot(const detail::_xvec3& x, const detail::_xvec3& y) + { + return x.x * y.x + x.y * y.y + x.z * y.z; + } +/* // SSE3 + inline float dot(const _xvec4& x, const _xvec4& y) + { + float Result; + __asm + { + mov esi, x + mov edi, y + movaps xmm0, [esi] + mulps xmm0, [edi] + haddps( _xmm0, _xmm0 ) + haddps( _xmm0, _xmm0 ) + movss Result, xmm0 + } + return Result; + } +*/ + template + inline T dot(const detail::_xvec4& x, const detail::_xvec4& y) + { + return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; + } + + // cross + template + inline detail::_xvec3 cross(const detail::_xvec3 & x, const detail::_xvec3 & y) + { + return detail::_xvec3( + x.y * y.z - y.y * x.z, + x.z * y.x - y.z * x.x, + x.x * y.y - y.x * x.y); + } + + // normalize + template + inline T normalize(T x) + { + return x < T(0) ? T(-1) : T(1); + } + + // According to issue 10, if length(x) == 0 then result is undefine and generate an error + template + inline detail::_xvec2 normalize(const detail::_xvec2& x) + { + T sqr = x.x * x.x + x.y * x.y; + return x * inversesqrt(sqr); + } + + template + inline detail::_xvec3 normalize(const detail::_xvec3& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z; + return x * inversesqrt(sqr); + } + + template + inline detail::_xvec4 normalize(const detail::_xvec4& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; + return x * inversesqrt(sqr); + } +/* + // faceforward + template + inline genType faceforward(const genType& N, const genType& I, const genType& Nref) + { + return dot(Nref, I) < T(0) ? N : -N; + } +*/ + // faceforward + template + inline T faceforward(T N, T I, T Nref) + { + return dot(Nref, I) < T(0) ? N : -N; + } + + template + inline detail::_xvec2 faceforward(const detail::_xvec2& N, const detail::_xvec2& I, const detail::_xvec2& Nref) + { + return dot(Nref, I) < T(0) ? N : -N; + } + + template + inline detail::_xvec3 faceforward(const detail::_xvec3& N, const detail::_xvec3& I, const detail::_xvec3& Nref) + { + return dot(Nref, I) < T(0) ? N : -N; + } + + template + inline detail::_xvec4 faceforward(const detail::_xvec4& N, const detail::_xvec4& I, const detail::_xvec4& Nref) + { + return dot(Nref, I) < T(0) ? N : -N; + } +/* + // reflect + template + genType reflect(const genType& I, const genType& N) + { + return I - N * dot(N, I) * T(2); + } +*/ + // reflect + template + inline T reflect(T I, T N) + { + return I - N * dot(N, I) * T(2); + } + + template + inline detail::_xvec2 reflect(const detail::_xvec2& I, const detail::_xvec2& N) + { + return I - N * dot(N, I) * T(2); + } + + template + inline detail::_xvec3 reflect(const detail::_xvec3& I, const detail::_xvec3& N) + { + return I - N * dot(N, I) * T(2); + } + + template + inline detail::_xvec4 reflect(const detail::_xvec4& I, const detail::_xvec4& N) + { + return I - N * dot(N, I) * T(2); + } + + // refract + template + inline T refract(T I, T N, T eta) + { + T dot = dot(N, I); + T k = T(1) - eta * eta * (T(1) - dot * dot); + if(k < T(0)) + return T(0); + else + return eta * I - (eta * dot + sqrt(k)) * N; + } + + template + inline detail::_xvec2 refract(const detail::_xvec2& I, const detail::_xvec2& N, T eta) + { + T dotValue = dot(N, I); + T k = T(1) - eta * eta * (T(1) - dotValue * dotValue); + if(k < T(0)) + return detail::_xvec2(T(0)); + else + return eta * I - (eta * dotValue + sqrt(k)) * N; + } + + template + inline detail::_xvec3 refract(const detail::_xvec3& I, const detail::_xvec3& N, T eta) + { + T dotValue = dot(N, I); + T k = T(1) - eta * eta * (T(1) - dotValue * dotValue); + if(k < T(0)) + return detail::_xvec3(T(0)); + else + return eta * I - (eta * dotValue + sqrt(k)) * N; + } + + template + inline detail::_xvec4 refract(const detail::_xvec4& I, const detail::_xvec4& N, T eta) + { + T dotValue = dot(N, I); + T k = T(1) - eta * eta * (T(1) - dotValue * dotValue); + if(k < T(0)) + return detail::_xvec4(T(0)); + else + return eta * I - (eta * dotValue + sqrt(k)) * N; + } + + //////////////////////////////////////////////////////////////////////// + // Matrix Functions + + // matrixCompMult + template + inline detail::_xmat2 matrixCompMult(const detail::_xmat2& x, const detail::_xmat2& y) + { + detail::_xmat2 result; + for(int j = 0; j < 2; ++j) + for(int i = 0; i < 2; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat3 matrixCompMult(const detail::_xmat3& x, const detail::_xmat3& y) + { + detail::_xmat3 result; + for(int j = 0; j < 3; ++j) + for(int i = 0; i < 3; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat4 matrixCompMult(const detail::_xmat4& x, const detail::_xmat4& y) + { + detail::_xmat4 result; + for(int j = 0; j < 4; ++j) + for(int i = 0; i < 4; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat2x3 matrixCompMult(const detail::_xmat2x3& x, const detail::_xmat2x3& y) + { + detail::_xmat2x3 result; + for(int j = 0; j < 2; ++j) + for(int i = 0; i < 3; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat3x2 matrixCompMult(const detail::_xmat3x2& x, const detail::_xmat3x2& y) + { + detail::_xmat3x2 result; + for(int j = 0; j < 3; ++j) + for(int i = 0; i < 2; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat2x4 matrixCompMult(const detail::_xmat2x4& x, const detail::_xmat2x4& y) + { + detail::_xmat2x4 result; + for(int j = 0; j < 2; ++j) + for(int i = 0; i < 4; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat4x2 matrixCompMult(const detail::_xmat4x2& x, const detail::_xmat4x2& y) + { + detail::_xmat4x2 result; + for(int j = 0; j < 4; ++j) + for(int i = 0; i < 2; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat3x4 matrixCompMult(const detail::_xmat3x4& x, const detail::_xmat3x4& y) + { + detail::_xmat3x4 result; + for(int j = 0; j < 3; ++j) + for(int i = 0; i < 4; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmat4x3 matrixCompMult(const detail::_xmat4x3& x, const detail::_xmat4x3& y) + { + detail::_xmat4x3 result; + for(int j = 0; j < 4; ++j) + for(int i = 0; i < 3; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + // outerProduct + template + inline detail::_xmat2 outerProduct(const detail::_xvec2& c, const detail::_xvec2& r) + { + detail::_xmat2 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + return m; + } + + template + inline detail::_xmat3 outerProduct(const detail::_xvec3& c, const detail::_xvec3& r) + { + detail::_xmat3 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[0][2] = c.z * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[1][2] = c.z * r.y; + m[2][0] = c.x * r.z; + m[2][1] = c.y * r.z; + m[2][2] = c.z * r.z; + return m; + } + + template + inline detail::_xmat4 outerProduct(const detail::_xvec4& c, const detail::_xvec4& r) + { + detail::_xmat4 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[0][2] = c.z * r.x; + m[0][3] = c.w * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[1][2] = c.z * r.y; + m[1][3] = c.w * r.y; + m[2][0] = c.x * r.z; + m[2][1] = c.y * r.z; + m[2][2] = c.z * r.z; + m[2][3] = c.w * r.z; + m[3][0] = c.x * r.w; + m[3][1] = c.y * r.w; + m[3][2] = c.z * r.w; + m[3][3] = c.w * r.w; + return m; + } + + template + inline detail::_xmat2x3 outerProduct(const detail::_xvec3& c, const detail::_xvec2& r) + { + detail::_xmat2x3 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[0][2] = c.z * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[1][2] = c.z * r.y; + return m; + } + + template + inline detail::_xmat3x2 outerProduct(const detail::_xvec2& c, const detail::_xvec3& r) + { + detail::_xmat3x2 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[2][0] = c.x * r.z; + m[2][1] = c.y * r.z; + return m; + } + + template + inline detail::_xmat2x4 outerProduct(const detail::_xvec2& c, const detail::_xvec4& r) + { + detail::_xmat2x4 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[0][2] = c.z * r.x; + m[0][3] = c.w * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[1][2] = c.z * r.y; + m[1][3] = c.w * r.y; + return m; + } + + template + inline detail::_xmat4x2 outerProduct(const detail::_xvec4& c, const detail::_xvec2& r) + { + detail::_xmat4x2 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[2][0] = c.x * r.z; + m[2][1] = c.y * r.z; + m[3][0] = c.x * r.w; + m[3][1] = c.y * r.w; + return m; + } + + template + inline detail::_xmat3x4 outerProduct(const detail::_xvec4& c, const detail::_xvec3& r) + { + detail::_xmat3x4 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[0][2] = c.z * r.x; + m[0][3] = c.w * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[1][2] = c.z * r.y; + m[1][3] = c.w * r.y; + m[2][0] = c.x * r.z; + m[2][1] = c.y * r.z; + m[2][2] = c.z * r.z; + m[2][3] = c.w * r.z; + return m; + } + + template + inline detail::_xmat4x3 outerProduct(const detail::_xvec3& c, const detail::_xvec4& r) + { + detail::_xmat4x3 m; + m[0][0] = c.x * r.x; + m[0][1] = c.y * r.x; + m[0][2] = c.z * r.x; + m[1][0] = c.x * r.y; + m[1][1] = c.y * r.y; + m[1][2] = c.z * r.y; + m[2][0] = c.x * r.z; + m[2][1] = c.y * r.z; + m[2][2] = c.z * r.z; + m[3][0] = c.x * r.w; + m[3][1] = c.y * r.w; + m[3][2] = c.z * r.w; + return m; + } + + template + inline detail::_xmat2 transpose(const detail::_xmat2& m) + { + detail::_xmat2 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + return result; + } + + template + inline detail::_xmat3 transpose(const detail::_xmat3 & m) + { + detail::_xmat3 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; + + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; + + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[2][2] = m[2][2]; + return result; + } + + template + inline detail::_xmat4 transpose(const detail::_xmat4 & m) + { + detail::_xmat4 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; + result[0][3] = m[3][0]; + + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; + result[1][3] = m[3][1]; + + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[2][2] = m[2][2]; + result[2][3] = m[3][2]; + + result[3][0] = m[0][3]; + result[3][1] = m[1][3]; + result[3][2] = m[2][3]; + result[3][3] = m[3][3]; + return result; + } + + template + inline detail::_xmat2x3 transpose(const detail::_xmat3x2& m) + { + detail::_xmat2x3 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; + return result; + } + + template + inline detail::_xmat3x2 transpose(const detail::_xmat2x3& m) + { + detail::_xmat3x2 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + return result; + } + + template + inline detail::_xmat2x4 transpose(const detail::_xmat4x2& m) + { + detail::_xmat2x4 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; + result[0][3] = m[3][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; + result[1][3] = m[3][1]; + return result; + } + + template + inline detail::_xmat4x2 transpose(const detail::_xmat2x4& m) + { + detail::_xmat4x2 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[3][0] = m[0][3]; + result[3][1] = m[1][3]; + return result; + } + + template + inline detail::_xmat3x4 transpose(const detail::_xmat4x3& m) + { + detail::_xmat3x4 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; + result[0][3] = m[3][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; + result[1][3] = m[3][1]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[2][2] = m[2][2]; + result[2][3] = m[3][2]; + return result; + } + + template + inline detail::_xmat4x3 transpose(const detail::_xmat3x4& m) + { + detail::_xmat4x3 result; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[2][2] = m[2][2]; + result[3][0] = m[0][3]; + result[3][1] = m[1][3]; + result[3][2] = m[2][3]; + result[4][0] = m[0][4]; + result[4][1] = m[1][4]; + result[4][2] = m[2][4]; + return result; + } + + //////////////////////////////////////////////////////////////////////// + // Vector Relational Functions + + // lessThan + template + inline detail::_bvec2 lessThan(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_bvec2(x.x < y.x, x.y < y.y); + } + + template + inline detail::_bvec3 lessThan(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_bvec3(x.x < y.x, x.y < y.y, x.z < y.z); + } + + template + inline detail::_bvec4 lessThan(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_bvec4(x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w); + } + + // lessThanEqual + template + inline detail::_bvec2 lessThanEqual(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_bvec2(x.x <= y.x, x.y <= y.y); + } + + template + inline detail::_bvec3 lessThanEqual(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_bvec3(x.x <= y.x, x.y <= y.y, x.z <= y.z); + } + + template + inline detail::_bvec4 lessThanEqual(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_bvec4(x.x <= y.x, x.y <= y.y, x.z <= y.z, x.w <= y.w); + } + + // greaterThan + template + inline detail::_bvec2 greaterThan(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_bvec2(x.x > y.x, x.y > y.y); + } + + template + inline detail::_bvec3 greaterThan(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_bvec3(x.x > y.x, x.y > y.y, x.z > y.z); + } + + template + inline detail::_bvec4 greaterThan(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_bvec4(x.x > y.x, x.y > y.y, x.z > y.z, x.w > y.w); + } + + // greaterThanEqual + template + inline detail::_bvec2 greaterThanEqual(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_bvec2(x.x >= y.x, x.y >= y.y); + } + + template + inline detail::_bvec3 greaterThanEqual(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_bvec3(x.x >= y.x, x.y >= y.y, x.z >= y.z); + } + + template + inline detail::_bvec4 greaterThanEqual(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_bvec4(x.x >= y.x, x.y >= y.y, x.z >= y.z, x.w >= y.w); + } + + // equal + inline detail::_bvec2 equal(const detail::_bvec2& x, const detail::_bvec2& y) + { + return detail::_bvec2(x.x == y.x, x.y == y.y); + } + + inline detail::_bvec3 equal(const detail::_bvec3& x, const detail::_bvec3& y) + { + return detail::_bvec3(x.x == y.x, x.y == y.y, x.z == y.z); + } + + inline detail::_bvec4 equal(const detail::_bvec4& x, const detail::_bvec4& y) + { + return detail::_bvec4(x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w); + } + + template + inline detail::_bvec2 equal(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_bvec2(x.x == y.x, x.y == y.y); + } + + template + inline detail::_bvec3 equal(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_bvec3(x.x == y.x, x.y == y.y, x.z == y.z); + } + + template + inline detail::_bvec4 equal(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_bvec4(x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w); + } + + // notEqual + inline detail::_bvec2 notEqual(const detail::_bvec2& x, const detail::_bvec2& y) + { + return detail::_bvec2(x.x != y.x, x.y != y.y); + } + + inline detail::_bvec3 notEqual(const detail::_bvec3 & x, const detail::_bvec3& y) + { + return detail::_bvec3(x.x != y.x, x.y != y.y, x.z != y.z); + } + + inline detail::_bvec4 notEqual(const detail::_bvec4 & x, const detail::_bvec4& y) + { + return detail::_bvec4(x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w); + } + + template + inline detail::_bvec2 notEqual(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_bvec2(x.x != y.x, x.y != y.y); + } + + template + inline detail::_bvec3 notEqual(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_bvec3(x.x != y.x, x.y != y.y, x.z != y.z); + } + + template + inline detail::_bvec4 notEqual(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_bvec4(x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w); + } + + // any + inline bool any(const detail::_bvec2& x) + { + return x.x || x.y; + } + + inline bool any(const detail::_bvec3& x) + { + return x.x || x.y || x.z; + } + + inline bool any(const detail::_bvec4& x) + { + return x.x || x.y || x.z || x.w; + } + + // all + inline bool all(const detail::_bvec2& x) + { + return x.x && x.y; + } + + inline bool all(const detail::_bvec3& x) + { + return x.x && x.y && x.z; + } + + inline bool all(const detail::_bvec4& x) + { + return x.x && x.y && x.z && x.w; + } + +#ifdef GLM_COMPILER_VC + inline bool not(bool x) + { + return !x; + } + + inline detail::_bvec2 not(const detail::_bvec2& v) + { + return detail::_bvec2(!v.x, !v.y); + } + + inline detail::_bvec3 not(const detail::_bvec3& v) + { + return detail::_bvec3(!v.x, !v.y, !v.z); + } + + inline detail::_bvec4 not(const detail::_bvec4& v) + { + return detail::_bvec4(!v.x, !v.y, !v.z, !v.w); + } + +#elif GLM_COMPILER_GCC + inline detail::_bvec2 operator not(const detail::_bvec2& v) + { + return detail::_bvec2(!v.x, !v.y); + } + + inline detail::_bvec3 operator not(const detail::_bvec3& v) + { + return detail::_bvec3(!v.x, !v.y, !v.z); + } + + inline detail::_bvec4 operator not(const detail::_bvec4& v) + { + return detail::_bvec4(!v.x, !v.y, !v.z, !v.w); + } +#endif + + //////////////////////////////////////////////////////////////////////// + // Noise Functions + + // noise1 + template + inline T noise1(T x) + { + int iNbr = int(x + T(3) / T(2)) * 1103515245 + 12345; + return T(int(iNbr / T(65536)) % 32768) / T(32767); + } + + template + inline T noise1(const detail::_xvec2& x) + { + T fNbr(0); + for(int i = 0; i < 2; ++i) + fNbr += x[i]; + int iNbr = int(fNbr + T(3) / T(2)) * 1103515245 + 12345; + return T(int(iNbr / T(65536)) % 32768) / T(32767); + } + + template + inline T noise1(const detail::_xvec3& x) + { + T fNbr(0); + for(int i = 0; i < 3; ++i) + fNbr += x[i]; + int iNbr = int(fNbr + T(3) / T(2)) * 1103515245 + 12345; + return T(int(iNbr / T(65536)) % 32768) / T(32767); + } + + template + inline T noise1(const detail::_xvec4& x) + { + T fNbr(0); + for(int i = 0; i < 4; i++) + fNbr += x[i]; + int iNbr = int(fNbr + T(3) / T(2)) * 1103515245 + 12345; + return T(int(iNbr / T(65536)) % 32768) / T(32767); + } + + // noise2 + template + inline detail::_xvec2 noise2(T x) + { + T f1 = x * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + return detail::_xvec2( + noise1(f1), + noise1(f2)); + } + + template + inline detail::_xvec2 noise2(const detail::_xvec2& x) + { + T f0(0); + for(int i = 0; i < 2; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + return detail::_xvec2( + noise1(f1), + noise1(f2)); + } + + template + inline detail::_xvec2 noise2(const detail::_xvec3& x) + { + T f0(0); + for(int i = 0; i < 3; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + return detail::_xvec2( + noise1(f1), + noise1(f2)); + } + + template + inline detail::_xvec2 noise2(const detail::_xvec4& x) + { + T f0(0); + for(int i = 0; i < 4; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + return detail::_xvec2( + noise1(f1), + noise1(f2)); + } + + // noise3 + template + inline detail::_xvec3 noise3(T x) + { + T f1 = x * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + return detail::_xvec3( + noise1(f1), + noise1(f2), + noise1(f3)); + } + + template + inline detail::_xvec3 noise3(const detail::_xvec2& x) + { + T f0(0); + for(int i = 0; i < 2; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + return detail::_xvec3( + noise1(f1), + noise1(f2), + noise1(f3)); + } + + template + inline detail::_xvec3 noise3(const detail::_xvec3& x) + { + T f0(0); + for(int i = 0; i < 3; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + return detail::_xvec3( + noise1(f1), + noise1(f2), + noise1(f3)); + } + + template + inline detail::_xvec3 noise3(const detail::_xvec4& x) + { + T f0(0); + for(int i = 0; i < 4; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + return detail::_xvec3( + noise1(f1), + noise1(f2), + noise1(f3)); + } + + // noise4 + template + inline detail::_xvec4 noise4(T x) + { + T f1 = x * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + T f4 = f3 * T(1103515245) + T(12345); + return detail::_xvec4( + noise1(f1), + noise1(f2), + noise1(f3), + noise1(f4)); + } + + template + inline detail::_xvec4 noise4(const detail::_xvec2& x) + { + T f0(0); + for(int i = 0; i < 2; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + T f4 = f3 * T(1103515245) + T(12345); + return detail::_xvec4( + noise1(f1), + noise1(f2), + noise1(f3), + noise1(f4)); + } + + template + inline detail::_xvec4 noise4(const detail::_xvec3& x) + { + T f0(0); + for(int i = 0; i < 3; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + T f4 = f3 * T(1103515245) + T(12345); + return detail::_xvec4( + noise1(f1), + noise1(f2), + noise1(f3), + noise1(f4)); + } + + template + inline detail::_xvec4 noise4(const detail::_xvec4& x) + { + T f0(0); + for(int i = 0; i < 4; ++i) + f0 += x[i]; + T f1 = f0 * T(1103515245) + T(12345); + T f2 = f1 * T(1103515245) + T(12345); + T f3 = f2 * T(1103515245) + T(12345); + T f4 = f3 * T(1103515245) + T(12345); + return detail::_xvec4( + noise1(f1), + noise1(f2), + noise1(f3), + noise1(f4)); + } +} //namespace glm + +#endif //__func_inl__ diff --git a/wip/sse/glm/core/_swizzle.h b/wip/sse/glm/core/_swizzle.h new file mode 100644 index 00000000..8f7e6cfc --- /dev/null +++ b/wip/sse/glm/core/_swizzle.h @@ -0,0 +1,1742 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-20 +// Updated : 2006-12-03 +// Licence : This source is under GNU LGPL licence +// File : _swizzle.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __swizzle_h__ +#define __swizzle_h__ + +namespace glm +{ + +} + +#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) + +// 2 components common swizzle operators +#define xx _xx() +#define yx _yx() +#define zx _zx() +#define wx _wx() +#define xy _xy() +#define yy _yy() +#define zy _zy() +#define wy _wy() +#define xz _xz() +#define yz _yz() +#define zz _zz() +#define wz _wz() +#define xw _xw() +#define yw _yw() +#define zw _zw() +#define ww _ww() + +// 3 components common swizzle operators +#define xxx _xxx() +#define yxx _yxx() +#define zxx _zxx() +#define wxx _wxx() +#define xyx _xyx() +#define yyx _yyx() +#define zyx _zyx() +#define wyx _wyx() +#define xzx _xzx() +#define yzx _yzx() +#define zzx _zzx() +#define wzx _wzx() +#define xwx _xwx() +#define ywx _ywx() +#define zwx _zwx() +#define wwx _wwx() +#define xxy _xxy() +#define yxy _yxy() +#define zxy _zxy() +#define wxy _wxy() +#define xyy _xyy() +#define yyy _yyy() +#define zyy _zyy() +#define wyy _wyy() +#define xzy _xzy() +#define yzy _yzy() +#define zzy _zzy() +#define wzy _wzy() +#define xwy _xwy() +#define ywy _ywy() +#define zwy _zwy() +#define wwy _wwy() +#define xxz _xxz() +#define yxz _yxz() +#define zxz _zxz() +#define wxz _wxz() +#define xyz _xyz() +#define yyz _yyz() +#define zyz _zyz() +#define wyz _wyz() +#define xzz _xzz() +#define yzz _yzz() +#define zzz _zzz() +#define wzz _wzz() +#define xwz _xwz() +#define ywz _ywz() +#define zwz _zwz() +#define wwz _wwz() +#define xxw _xxw() +#define yxw _yxw() +#define zxw _zxw() +#define wxw _wxw() +#define xyw _xyw() +#define yyw _yyw() +#define zyw _zyw() +#define wyw _wyw() +#define xzw _xzw() +#define yzw _yzw() +#define zzw _zzw() +#define wzw _wzw() +#define xww _xww() +#define yww _yww() +#define zww _zww() +#define www _www() + +// 4 components common swizzle operators +#define xxxx _xxxx() +#define yxxx _yxxx() +#define zxxx _zxxx() +#define wxxx _wxxx() +#define xyxx _xyxx() +#define yyxx _yyxx() +#define zyxx _zyxx() +#define wyxx _wyxx() +#define xzxx _xzxx() +#define yzxx _yzxx() +#define zzxx _zzxx() +#define wzxx _wzxx() +#define xwxx _xwxx() +#define ywxx _ywxx() +#define zwxx _zwxx() +#define wwxx _wwxx() +#define xxyx _xxyx() +#define yxyx _yxyx() +#define zxyx _zxyx() +#define wxyx _wxyx() +#define xyyx _xyyx() +#define yyyx _yyyx() +#define zyyx _zyyx() +#define wyyx _wyyx() +#define xzyx _xzyx() +#define yzyx _yzyx() +#define zzyx _zzyx() +#define wzyx _wzyx() +#define xwyx _xwyx() +#define ywyx _ywyx() +#define zwyx _zwyx() +#define wwyx _wwyx() +#define xxzx _xxzx() +#define yxzx _yxzx() +#define zxzx _zxzx() +#define wxzx _wxzx() +#define xyzx _xyzx() +#define yyzx _yyzx() +#define zyzx _zyzx() +#define wyzx _wyzx() +#define xzzx _xzzx() +#define yzzx _yzzx() +#define zzzx _zzzx() +#define wzzx _wzzx() +#define xwzx _xwzx() +#define ywzx _ywzx() +#define zwzx _zwzx() +#define wwzx _wwzx() +#define xxwx _xxwx() +#define yxwx _yxwx() +#define zxwx _zxwx() +#define wxwx _wxwx() +#define xywx _xywx() +#define yywx _yywx() +#define zywx _zywx() +#define wywx _wywx() +#define xzwx _xzwx() +#define yzwx _yzwx() +#define zzwx _zzwx() +#define wzwx _wzwx() +#define xwwx _xwwx() +#define ywwx _ywwx() +#define zwwx _zwwx() +#define wwwx _wwwx() +#define xxxy _xxxy() +#define yxxy _yxxy() +#define zxxy _zxxy() +#define wxxy _wxxy() +#define xyxy _xyxy() +#define yyxy _yyxy() +#define zyxy _zyxy() +#define wyxy _wyxy() +#define xzxy _xzxy() +#define yzxy _yzxy() +#define zzxy _zzxy() +#define wzxy _wzxy() +#define xwxy _xwxy() +#define ywxy _ywxy() +#define zwxy _zwxy() +#define wwxy _wwxy() +#define xxyy _xxyy() +#define yxyy _yxyy() +#define zxyy _zxyy() +#define wxyy _wxyy() +#define xyyy _xyyy() +#define yyyy _yyyy() +#define zyyy _zyyy() +#define wyyy _wyyy() +#define xzyy _xzyy() +#define yzyy _yzyy() +#define zzyy _zzyy() +#define wzyy _wzyy() +#define xwyy _xwyy() +#define ywyy _ywyy() +#define zwyy _zwyy() +#define wwyy _wwyy() +#define xxzy _xxzy() +#define yxzy _yxzy() +#define zxzy _zxzy() +#define wxzy _wxzy() +#define xyzy _xyzy() +#define yyzy _yyzy() +#define zyzy _zyzy() +#define wyzy _wyzy() +#define xzzy _xzzy() +#define yzzy _yzzy() +#define zzzy _zzzy() +#define wzzy _wzzy() +#define xwzy _xwzy() +#define ywzy _ywzy() +#define zwzy _zwzy() +#define wwzy _wwzy() +#define xxwy _xxwy() +#define yxwy _yxwy() +#define zxwy _zxwy() +#define wxwy _wxwy() +#define xywy _xywy() +#define yywy _yywy() +#define zywy _zywy() +#define wywy _wywy() +#define xzwy _xzwy() +#define yzwy _yzwy() +#define zzwy _zzwy() +#define wzwy _wzwy() +#define xwwy _xwwy() +#define ywwy _ywwy() +#define zwwy _zwwy() +#define wwwy _wwwy() +#define xxxz _xxxz() +#define yxxz _yxxz() +#define zxxz _zxxz() +#define wxxz _wxxz() +#define xyxz _xyxz() +#define yyxz _yyxz() +#define zyxz _zyxz() +#define wyxz _wyxz() +#define xzxz _xzxz() +#define yzxz _yzxz() +#define zzxz _zzxz() +#define wzxz _wzxz() +#define xwxz _xwxz() +#define ywxz _ywxz() +#define zwxz _zwxz() +#define wwxz _wwxz() +#define xxyz _xxyz() +#define yxyz _yxyz() +#define zxyz _zxyz() +#define wxyz _wxyz() +#define xyyz _xyyz() +#define yyyz _yyyz() +#define zyyz _zyyz() +#define wyyz _wyyz() +#define xzyz _xzyz() +#define yzyz _yzyz() +#define zzyz _zzyz() +#define wzyz _wzyz() +#define xwyz _xwyz() +#define ywyz _ywyz() +#define zwyz _zwyz() +#define wwyz _wwyz() +#define xxzz _xxzz() +#define yxzz _yxzz() +#define zxzz _zxzz() +#define wxzz _wxzz() +#define xyzz _xyzz() +#define yyzz _yyzz() +#define zyzz _zyzz() +#define wyzz _wyzz() +#define xzzz _xzzz() +#define yzzz _yzzz() +#define zzzz _zzzz() +#define wzzz _wzzz() +#define xwzz _xwzz() +#define ywzz _ywzz() +#define zwzz _zwzz() +#define wwzz _wwzz() +#define xxwz _xxwz() +#define yxwz _yxwz() +#define zxwz _zxwz() +#define wxwz _wxwz() +#define xywz _xywz() +#define yywz _yywz() +#define zywz _zywz() +#define wywz _wywz() +#define xzwz _xzwz() +#define yzwz _yzwz() +#define zzwz _zzwz() +#define wzwz _wzwz() +#define xwwz _xwwz() +#define ywwz _ywwz() +#define zwwz _zwwz() +#define wwwz _wwwz() +#define xxxw _xxxw() +#define yxxw _yxxw() +#define zxxw _zxxw() +#define wxxw _wxxw() +#define xyxw _xyxw() +#define yyxw _yyxw() +#define zyxw _zyxw() +#define wyxw _wyxw() +#define xzxw _xzxw() +#define yzxw _yzxw() +#define zzxw _zzxw() +#define wzxw _wzxw() +#define xwxw _xwxw() +#define ywxw _ywxw() +#define zwxw _zwxw() +#define wwxw _wwxw() +#define xxyw _xxyw() +#define yxyw _yxyw() +#define zxyw _zxyw() +#define wxyw _wxyw() +#define xyyw _xyyw() +#define yyyw _yyyw() +#define zyyw _zyyw() +#define wyyw _wyyw() +#define xzyw _xzyw() +#define yzyw _yzyw() +#define zzyw _zzyw() +#define wzyw _wzyw() +#define xwyw _xwyw() +#define ywyw _ywyw() +#define zwyw _zwyw() +#define wwyw _wwyw() +#define xxzw _xxzw() +#define yxzw _yxzw() +#define zxzw _zxzw() +#define wxzw _wxzw() +#define xyzw _xyzw() +#define yyzw _yyzw() +#define zyzw _zyzw() +#define wyzw _wyzw() +#define xzzw _xzzw() +#define yzzw _yzzw() +#define zzzw _zzzw() +#define wzzw _wzzw() +#define xwzw _xwzw() +#define ywzw _ywzw() +#define zwzw _zwzw() +#define wwzw _wwzw() +#define xxww _xxww() +#define yxww _yxww() +#define zxww _zxww() +#define wxww _wxww() +#define xyww _xyww() +#define yyww _yyww() +#define zyww _zyww() +#define wyww _wyww() +#define xzww _xzww() +#define yzww _yzww() +#define zzww _zzww() +#define wzww _wzww() +#define xwww _xwww() +#define ywww _ywww() +#define zwww _zwww() +#define wwww _wwww() + +#endif//defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) + +#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_RGBA) + +// 2 components color swizzle operators +#define rr _xx() +#define gr _yx() +#define br _zx() +#define ar _wx() +#define rg _xy() +#define gg _yy() +#define bg _zy() +#define ag _wy() +#define rb _xz() +#define gb _yz() +#define bb _zz() +#define ab _wz() +#define ra _xw() +#define ga _yw() +#define ba _zw() +#define aa _ww() + +// 3 components color swizzle operators +#define rrr _xxx() +#define grr _yxx() +#define brr _zxx() +#define arr _wxx() +#define rgr _xyx() +#define ggr _yyx() +#define bgr _zyx() +#define agr _wyx() +#define rbr _xzx() +#define gbr _yzx() +#define bbr _zzx() +#define abr _wzx() +#define rar _xwx() +#define gar _ywx() +#define bar _zwx() +#define aar _wwx() +#define rrg _xxy() +#define grg _yxy() +#define brg _zxy() +#define arg _wxy() +#define rgg _xyy() +#define ggg _yyy() +#define bgg _zyy() +#define agg _wyy() +#define rbg _xzy() +#define gbg _yzy() +#define bbg _zzy() +#define abg _wzy() +#define rag _xwy() +#define gag _ywy() +#define bag _zwy() +#define aag _wwy() +#define rrb _xxz() +#define grb _yxz() +#define brb _zxz() +#define arb _wxz() +#define rgb _xyz() +#define ggb _yyz() +#define bgb _zyz() +#define agb _wyz() +#define rbb _xzz() +#define gbb _yzz() +#define bbb _zzz() +#define abb _wzz() +#define rab _xwz() +#define gab _ywz() +#define bab _zwz() +#define aab _wwz() +#define rra _xxw() +#define gra _yxw() +#define bra _zxw() +#define ara _wxw() +#define rga _xyw() +#define gga _yyw() +#define bga _zyw() +#define aga _wyw() +#define rba _xzw() +#define gba _yzw() +#define bba _zzw() +#define aba _wzw() +#define raa _xww() +#define gaa _yww() +#define baa _zww() +#define aaa _www() + +// 4 components color swizzle operators +#define rrrr _xxxx() +#define grrr _yxxx() +#define brrr _zxxx() +#define arrr _wxxx() +#define rgrr _xyxx() +#define ggrr _yyxx() +#define bgrr _zyxx() +#define agrr _wyxx() +#define rbrr _xzxx() +#define gbrr _yzxx() +#define bbrr _zzxx() +#define abrr _wzxx() +#define rarr _xwxx() +#define garr _ywxx() +#define barr _zwxx() +#define aarr _wwxx() +#define rrgr _xxyx() +#define grgr _yxyx() +#define brgr _zxyx() +#define argr _wxyx() +#define rggr _xyyx() +#define gggr _yyyx() +#define bggr _zyyx() +#define aggr _wyyx() +#define rbgr _xzyx() +#define gbgr _yzyx() +#define bbgr _zzyx() +#define abgr _wzyx() +#define ragr _xwyx() +#define gagr _ywyx() +#define bagr _zwyx() +#define aagr _wwyx() +#define rrbr _xxzx() +#define grbr _yxzx() +#define brbr _zxzx() +#define arbr _wxzx() +#define rgbr _xyzx() +#define ggbr _yyzx() +#define bgbr _zyzx() +#define agbr _wyzx() +#define rbbr _xzzx() +#define gbbr _yzzx() +#define bbbr _zzzx() +#define abbr _wzzx() +#define rabr _xwzx() +#define gabr _ywzx() +#define babr _zwzx() +#define aabr _wwzx() +#define rrar _xxwx() +#define grar _yxwx() +#define brar _zxwx() +#define arar _wxwx() +#define rgar _xywx() +#define ggar _yywx() +#define bgar _zywx() +#define agar _wywx() +#define rbar _xzwx() +#define gbar _yzwx() +#define bbar _zzwx() +#define abar _wzwx() +#define raar _xwwx() +#define gaar _ywwx() +#define baar _zwwx() +#define aaar _wwwx() +#define rrrg _xxxy() +#define grrg _yxxy() +#define brrg _zxxy() +#define arrg _wxxy() +#define rgrg _xyxy() +#define ggrg _yyxy() +#define bgrg _zyxy() +#define agrg _wyxy() +#define rbrg _xzxy() +#define gbrg _yzxy() +#define bbrg _zzxy() +#define abrg _wzxy() +#define rarg _xwxy() +#define garg _ywxy() +#define barg _zwxy() +#define aarg _wwxy() +#define rrgg _xxyy() +#define grgg _yxyy() +#define brgg _zxyy() +#define argg _wxyy() +#define rggg _xyyy() +#define gggg _yyyy() +#define bggg _zyyy() +#define aggg _wyyy() +#define rbgg _xzyy() +#define gbgg _yzyy() +#define bbgg _zzyy() +#define abgg _wzyy() +#define ragg _xwyy() +#define gagg _ywyy() +#define bagg _zwyy() +#define aagg _wwyy() +#define rrbg _xxzy() +#define grbg _yxzy() +#define brbg _zxzy() +#define arbg _wxzy() +#define rgbg _xyzy() +#define ggbg _yyzy() +#define bgbg _zyzy() +#define agbg _wyzy() +#define rbbg _xzzy() +#define gbbg _yzzy() +#define bbbg _zzzy() +#define abbg _wzzy() +#define rabg _xwzy() +#define gabg _ywzy() +#define babg _zwzy() +#define aabg _wwzy() +#define rrag _xxwy() +#define grag _yxwy() +#define brag _zxwy() +#define arag _wxwy() +#define rgag _xywy() +#define ggag _yywy() +#define bgag _zywy() +#define agag _wywy() +#define rbag _xzwy() +#define gbag _yzwy() +#define bbag _zzwy() +#define abag _wzwy() +#define raag _xwwy() +#define gaag _ywwy() +#define baag _zwwy() +#define aaag _wwwy() +#define rrrb _xxxz() +#define grrb _yxxz() +#define brrb _zxxz() +#define arrb _wxxz() +#define rgrb _xyxz() +#define ggrb _yyxz() +#define bgrb _zyxz() +#define agrb _wyxz() +#define rbrb _xzxz() +#define gbrb _yzxz() +#define bbrb _zzxz() +#define abrb _wzxz() +#define rarb _xwxz() +#define garb _ywxz() +#define barb _zwxz() +#define aarb _wwxz() +#define rrgb _xxyz() +#define grgb _yxyz() +#define brgb _zxyz() +#define argb _wxyz() +#define rggb _xyyz() +#define gggb _yyyz() +#define bggb _zyyz() +#define aggb _wyyz() +#define rbgb _xzyz() +#define gbgb _yzyz() +#define bbgb _zzyz() +#define abgb _wzyz() +#define ragb _xwyz() +#define gagb _ywyz() +#define bagb _zwyz() +#define aagb _wwyz() +#define rrbb _xxzz() +#define grbb _yxzz() +#define brbb _zxzz() +#define arbb _wxzz() +#define rgbb _xyzz() +#define ggbb _yyzz() +#define bgbb _zyzz() +#define agbb _wyzz() +#define rbbb _xzzz() +#define gbbb _yzzz() +#define bbbb _zzzz() +#define abbb _wzzz() +#define rabb _xwzz() +#define gabb _ywzz() +#define babb _zwzz() +#define aabb _wwzz() +#define rrab _xxwz() +#define grab _yxwz() +#define brab _zxwz() +#define arab _wxwz() +#define rgab _xywz() +#define ggab _yywz() +#define bgab _zywz() +#define agab _wywz() +#define rbab _xzwz() +#define gbab _yzwz() +#define bbab _zzwz() +#define abab _wzwz() +#define raab _xwwz() +#define gaab _ywwz() +#define baab _zwwz() +#define aaab _wwwz() +#define rrra _xxxw() +#define grra _yxxw() +#define brra _zxxw() +#define arra _wxxw() +#define rgra _xyxw() +#define ggra _yyxw() +#define bgra _zyxw() +#define agra _wyxw() +#define rbra _xzxw() +#define gbra _yzxw() +#define bbra _zzxw() +#define abra _wzxw() +#define rara _xwxw() +#define gara _ywxw() +#define bara _zwxw() +#define aara _wwxw() +#define rrga _xxyw() +#define grga _yxyw() +#define brga _zxyw() +#define arga _wxyw() +#define rgga _xyyw() +#define ggga _yyyw() +#define bgga _zyyw() +#define agga _wyyw() +#define rbga _xzyw() +#define gbga _yzyw() +#define bbga _zzyw() +#define abga _wzyw() +#define raga _xwyw() +#define gaga _ywyw() +#define baga _zwyw() +#define aaga _wwyw() +#define rrba _xxzw() +#define grba _yxzw() +#define brba _zxzw() +#define arba _wxzw() +#define rgba _xyzw() +#define ggba _yyzw() +#define bgba _zyzw() +#define agba _wyzw() +#define rbba _xzzw() +#define gbba _yzzw() +#define bbba _zzzw() +#define abba _wzzw() +#define raba _xwzw() +#define gaba _ywzw() +#define baba _zwzw() +#define aaba _wwzw() +#define rraa _xxww() +#define graa _yxww() +#define braa _zxww() +#define araa _wxww() +#define rgaa _xyww() +#define ggaa _yyww() +#define bgaa _zyww() +#define agaa _wyww() +#define rbaa _xzww() +#define gbaa _yzww() +#define bbaa _zzww() +#define abaa _wzww() +#define raaa _xwww() +#define gaaa _ywww() +#define baaa _zwww() +#define aaaa _wwww() + +#endif//defined(GLM_SWIZZLE) && defined(GLM_SWIZZLE_RGBA) + +#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STQP) + +// 2 components texcoord swizzle operators +#define ss _xx() +#define ts _yx() +#define ps _zx() +#define qs _wx() +#define st _xy() +#define tt _yy() +#define pt _zy() +#define qt _qy() +#define sp _xz() +#define tp _yz() +#define pp _zz() +#define qp _qz() +#define sq _xq() +#define tq _yq() +#define pq _zq() +#define qq _qq() + +// 3 components tescoord swizzle operators +#define sss _xxx() +#define tss _yxx() +#define pss _zxx() +#define qss _qxx() +#define sts _xyx() +#define tts _yyx() +#define pts _zyx() +#define qts _qyx() +#define sps _xzx() +#define tps _yzx() +#define pps _zzx() +#define qps _qzx() +#define sqs _xqx() +#define tqs _yqx() +#define pqs _zqx() +#define qqs _qqx() +#define sst _xxy() +#define tst _yxy() +#define pst _zxy() +#define qst _qxy() +#define stt _xyy() +#define ttt _yyy() +#define ptt _zyy() +#define qtt _qyy() +#define spt _xzy() +#define tpt _yzy() +#define ppt _zzy() +#define qpt _qzy() +#define sqt _xqy() +#define tqt _yqy() +#define pqt _zqy() +#define qqt _qqy() +#define ssp _xxz() +#define tsp _yxz() +#define psp _zxz() +#define qsp _qxz() +#define stp _xyz() +#define ttp _yyz() +#define ptp _zyz() +#define qtp _qyz() +#define spp _xzz() +#define tpp _yzz() +#define ppp _zzz() +#define qpp _qzz() +#define sqp _xqz() +#define tqp _yqz() +#define pqp _zqz() +#define qqp _qqz() +#define ssq _xxq() +#define tsq _yxq() +#define psq _zxq() +#define qsq _qxq() +#define stq _xyq() +#define ttq _yyq() +#define ptq _zyq() +#define qtq _qyq() +#define spq _xzq() +#define tpq _yzq() +#define ppq _zzq() +#define qpq _qzq() +#define sqq _xqq() +#define tqq _yqq() +#define pqq _zqq() +#define qqq _qqq() + +// 4 components tescoord swizzle operators +#define ssss _xxxx() +#define tsss _yxxx() +#define psss _zxxx() +#define qsss _qxxx() +#define stss _xyxx() +#define ttss _yyxx() +#define ptss _zyxx() +#define qtss _qyxx() +#define spss _xzxx() +#define tpss _yzxx() +#define ppss _zzxx() +#define qpss _qzxx() +#define sqss _xqxx() +#define tqss _yqxx() +#define pqss _zqxx() +#define qqss _qqxx() +#define ssts _xxyx() +#define tsts _yxyx() +#define psts _zxyx() +#define qsts _qxyx() +#define stts _xyyx() +#define ttts _yyyx() +#define ptts _zyyx() +#define qtts _qyyx() +#define spts _xzyx() +#define tpts _yzyx() +#define ppts _zzyx() +#define qpts _qzyx() +#define sqts _xqyx() +#define tqts _yqyx() +#define pqts _zqyx() +#define qqts _qqyx() +#define ssps _xxzx() +#define tsps _yxzx() +#define psps _zxzx() +#define qsps _qxzx() +#define stps _xyzx() +#define ttps _yyzx() +#define ptps _zyzx() +#define qtps _qyzx() +#define spps _xzzx() +#define tpps _yzzx() +#define ppps _zzzx() +#define qpps _qzzx() +#define sqps _xqzx() +#define tqps _yqzx() +#define pqps _zqzx() +#define qqps _qqzx() +#define ssqs _xxqx() +#define tsqs _yxqx() +#define psqs _zxqx() +#define qsqs _qxqx() +#define stqs _xyqx() +#define ttqs _yyqx() +#define ptqs _zyqx() +#define qtqs _qyqx() +#define spqs _xzqx() +#define tpqs _yzqx() +#define ppqs _zzqx() +#define qpqs _qzqx() +#define sqqs _xqqx() +#define tqqs _yqqx() +#define pqqs _zqqx() +#define qqqs _qqqx() +#define ssst _xxxy() +#define tsst _yxxy() +#define psst _zxxy() +#define qsst _qxxy() +#define stst _xyxy() +#define ttst _yyxy() +#define ptst _zyxy() +#define qtst _qyxy() +#define spst _xzxy() +#define tpst _yzxy() +#define ppst _zzxy() +#define qpst _qzxy() +#define sqst _xqxy() +#define tqst _yqxy() +#define pqst _zqxy() +#define qqst _qqxy() +#define sstt _xxyy() +#define tstt _yxyy() +#define pstt _zxyy() +#define qstt _qxyy() +#define sttt _xyyy() +#define tttt _yyyy() +#define pttt _zyyy() +#define qttt _qyyy() +#define sptt _xzyy() +#define tptt _yzyy() +#define pptt _zzyy() +#define qptt _qzyy() +#define sqtt _xqyy() +#define tqtt _yqyy() +#define pqtt _zqyy() +#define qqtt _qqyy() +#define sspt _xxzy() +#define tspt _yxzy() +#define pspt _zxzy() +#define qspt _qxzy() +#define stpt _xyzy() +#define ttpt _yyzy() +#define ptpt _zyzy() +#define qtpt _qyzy() +#define sppt _xzzy() +#define tppt _yzzy() +#define pppt _zzzy() +#define qppt _qzzy() +#define sqpt _xqzy() +#define tqpt _yqzy() +#define pqpt _zqzy() +#define qqpt _qqzy() +#define ssqt _xxqy() +#define tsqt _yxqy() +#define psqt _zxqy() +#define qsqt _qxqy() +#define stqt _xyqy() +#define ttqt _yyqy() +#define ptqt _zyqy() +#define qtqt _qyqy() +#define spqt _xzqy() +#define tpqt _yzqy() +#define ppqt _zzqy() +#define qpqt _qzqy() +#define sqqt _xqqy() +#define tqqt _yqqy() +#define pqqt _zqqy() +#define qqqt _qqqy() +#define sssp _xxxz() +#define tssp _yxxz() +#define pssp _zxxz() +#define qssp _qxxz() +#define stsp _xyxz() +#define ttsp _yyxz() +#define ptsp _zyxz() +#define qtsp _qyxz() +#define spsp _xzxz() +#define tpsp _yzxz() +#define ppsp _zzxz() +#define qpsp _qzxz() +#define sqsp _xqxz() +#define tqsp _yqxz() +#define pqsp _zqxz() +#define qqsp _qqxz() +#define sstp _xxyz() +#define tstp _yxyz() +#define pstp _zxyz() +#define qstp _qxyz() +#define sttp _xyyz() +#define tttp _yyyz() +#define pttp _zyyz() +#define qttp _qyyz() +#define sptp _xzyz() +#define tptp _yzyz() +#define pptp _zzyz() +#define qptp _qzyz() +#define sqtp _xqyz() +#define tqtp _yqyz() +#define pqtp _zqyz() +#define qqtp _qqyz() +#define sspp _xxzz() +#define tspp _yxzz() +#define pspp _zxzz() +#define qspp _qxzz() +#define stpp _xyzz() +#define ttpp _yyzz() +#define ptpp _zyzz() +#define qtpp _qyzz() +#define sppp _xzzz() +#define tppp _yzzz() +#define pppp _zzzz() +#define qppp _qzzz() +#define sqpp _xqzz() +#define tqpp _yqzz() +#define pqpp _zqzz() +#define qqpp _qqzz() +#define ssqp _xxqz() +#define tsqp _yxqz() +#define psqp _zxqz() +#define qsqp _qxqz() +#define stqp _xyqz() +#define ttqp _yyqz() +#define ptqp _zyqz() +#define qtqp _qyqz() +#define spqp _xzqz() +#define tpqp _yzqz() +#define ppqp _zzqz() +#define qpqp _qzqz() +#define sqqp _xqqz() +#define tqqp _yqqz() +#define pqqp _zqqz() +#define qqqp _qqqz() +#define sssq _xxxq() +#define tssq _yxxq() +#define pssq _zxxq() +#define qssq _qxxq() +#define stsq _xyxq() +#define ttsq _yyxq() +#define ptsq _zyxq() +#define qtsq _qyxq() +#define spsq _xzxq() +#define tpsq _yzxq() +#define ppsq _zzxq() +#define qpsq _qzxq() +#define sqsq _xqxq() +#define tqsq _yqxq() +#define pqsq _zqxq() +#define qqsq _qqxq() +#define sstq _xxyq() +#define tstq _yxyq() +#define pstq _zxyq() +#define qstq _qxyq() +#define sttq _xyyq() +#define tttq _yyyq() +#define pttq _zyyq() +#define qttq _qyyq() +#define sptq _xzyq() +#define tptq _yzyq() +#define pptq _zzyq() +#define qptq _qzyq() +#define sqtq _xqyq() +#define tqtq _yqyq() +#define pqtq _zqyq() +#define qqtq _qqyq() +#define sspq _xxzq() +#define tspq _yxzq() +#define pspq _zxzq() +#define qspq _qxzq() +#define stpq _xyzq() +#define ttpq _yyzq() +#define ptpq _zyzq() +#define qtpq _qyzq() +#define sppq _xzzq() +#define tppq _yzzq() +#define pppq _zzzq() +#define qppq _qzzq() +#define sqpq _xqzq() +#define tqpq _yqzq() +#define pqpq _zqzq() +#define qqpq _qqzq() +#define ssqq _xxqq() +#define tsqq _yxqq() +#define psqq _zxqq() +#define qsqq _qxqq() +#define stqq _xyqq() +#define ttqq _yyqq() +#define ptqq _zyqq() +#define qtqq _qyqq() +#define spqq _xzqq() +#define tpqq _yzqq() +#define ppqq _zzqq() +#define qpqq _qzqq() +#define sqqq _xqqq() +#define tqqq _yqqq() +#define pqqq _zqqq() +#define qqqq _qqqq() + +#endif//defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STQP) + +/* +// 2 components color swizzle operators +#define rr _rr() +#define gr _gr() +#define br _br() +#define ar _ar() +#define rg _rg() +#define gg _gg() +#define bg _bg() +#define ag _ag() +#define rb _rb() +#define gb _gb() +#define bb _bb() +#define ab _ab() +#define ra _ra() +#define ga _ga() +#define ba _ba() +#define aa _aa() + +// 3 components color swizzle operators +#define rrr _rrr() +#define grr _grr() +#define brr _brr() +#define arr _arr() +#define rgr _rgr() +#define ggr _ggr() +#define bgr _bgr() +#define agr _agr() +#define rbr _rbr() +#define gbr _gbr() +#define bbr _bbr() +#define abr _abr() +#define rar _rar() +#define gar _gar() +#define bar _bar() +#define aar _aar() +#define rrg _rrg() +#define grg _grg() +#define brg _brg() +#define arg _arg() +#define rgg _rgg() +#define ggg _ggg() +#define bgg _bgg() +#define agg _agg() +#define rbg _rbg() +#define gbg _gbg() +#define bbg _bbg() +#define abg _abg() +#define rag _rag() +#define gag _gag() +#define bag _bag() +#define aag _aag() +#define rrb _rrb() +#define grb _grb() +#define brb _brb() +#define arb _arb() +#define rgb _rgb() +#define ggb _ggb() +#define bgb _bgb() +#define agb _agb() +#define rbb _rbb() +#define gbb _gbb() +#define bbb _bbb() +#define abb _abb() +#define rab _rab() +#define gab _gab() +#define bab _bab() +#define aab _aab() +#define rra _rra() +#define gra _gra() +#define bra _bra() +#define ara _ara() +#define rga _rga() +#define gga _gga() +#define bga _bga() +#define aga _aga() +#define rba _rba() +#define gba _gba() +#define bba _bba() +#define aba _aba() +#define raa _raa() +#define gaa _gaa() +#define baa _baa() +#define aaa _aaa() + +// 4 components color swizzle operators +#define rrrr _rrrr() +#define grrr _grrr() +#define brrr _brrr() +#define arrr _arrr() +#define rgrr _rgrr() +#define ggrr _ggrr() +#define bgrr _bgrr() +#define agrr _agrr() +#define rbrr _rbrr() +#define gbrr _gbrr() +#define bbrr _bbrr() +#define abrr _abrr() +#define rarr _rarr() +#define garr _garr() +#define barr _barr() +#define aarr _aarr() +#define rrgr _rrgr() +#define grgr _grgr() +#define brgr _brgr() +#define argr _argr() +#define rggr _rggr() +#define gggr _gggr() +#define bggr _bggr() +#define aggr _aggr() +#define rbgr _rbgr() +#define gbgr _gbgr() +#define bbgr _bbgr() +#define abgr _abgr() +#define ragr _ragr() +#define gagr _gagr() +#define bagr _bagr() +#define aagr _aagr() +#define rrbr _rrbr() +#define grbr _grbr() +#define brbr _brbr() +#define arbr _arbr() +#define rgbr _rgbr() +#define ggbr _ggbr() +#define bgbr _bgbr() +#define agbr _agbr() +#define rbbr _rbbr() +#define gbbr _gbbr() +#define bbbr _bbbr() +#define abbr _abbr() +#define rabr _rabr() +#define gabr _gabr() +#define babr _babr() +#define aabr _aabr() +#define rrar _rrar() +#define grar _grar() +#define brar _brar() +#define arar _arar() +#define rgar _rgar() +#define ggar _ggar() +#define bgar _bgar() +#define agar _agar() +#define rbar _rbar() +#define gbar _gbar() +#define bbar _bbar() +#define abar _abar() +#define raar _raar() +#define gaar _gaar() +#define baar _baar() +#define aaar _aaar() +#define rrrg _rrrg() +#define grrg _grrg() +#define brrg _brrg() +#define arrg _arrg() +#define rgrg _rgrg() +#define ggrg _ggrg() +#define bgrg _bgrg() +#define agrg _agrg() +#define rbrg _rbrg() +#define gbrg _gbrg() +#define bbrg _bbrg() +#define abrg _abrg() +#define rarg _rarg() +#define garg _garg() +#define barg _barg() +#define aarg _aarg() +#define rrgg _rrgg() +#define grgg _grgg() +#define brgg _brgg() +#define argg _argg() +#define rggg _rggg() +#define gggg _gggg() +#define bggg _bggg() +#define aggg _aggg() +#define rbgg _rbgg() +#define gbgg _gbgg() +#define bbgg _bbgg() +#define abgg _abgg() +#define ragg _ragg() +#define gagg _gagg() +#define bagg _bagg() +#define aagg _aagg() +#define rrbg _rrbg() +#define grbg _grbg() +#define brbg _brbg() +#define arbg _arbg() +#define rgbg _rgbg() +#define ggbg _ggbg() +#define bgbg _bgbg() +#define agbg _agbg() +#define rbbg _rbbg() +#define gbbg _gbbg() +#define bbbg _bbbg() +#define abbg _abbg() +#define rabg _rabg() +#define gabg _gabg() +#define babg _babg() +#define aabg _aabg() +#define rrag _rrag() +#define grag _grag() +#define brag _brag() +#define arag _arag() +#define rgag _rgag() +#define ggag _ggag() +#define bgag _bgag() +#define agag _agag() +#define rbag _rbag() +#define gbag _gbag() +#define bbag _bbag() +#define abag _abag() +#define raag _raag() +#define gaag _gaag() +#define baag _baag() +#define aaag _aaag() +#define rrrb _rrrb() +#define grrb _grrb() +#define brrb _brrb() +#define arrb _arrb() +#define rgrb _rgrb() +#define ggrb _ggrb() +#define bgrb _bgrb() +#define agrb _agrb() +#define rbrb _rbrb() +#define gbrb _gbrb() +#define bbrb _bbrb() +#define abrb _abrb() +#define rarb _rarb() +#define garb _garb() +#define barb _barb() +#define aarb _aarb() +#define rrgb _rrgb() +#define grgb _grgb() +#define brgb _brgb() +#define argb _argb() +#define rggb _rggb() +#define gggb _gggb() +#define bggb _bggb() +#define aggb _aggb() +#define rbgb _rbgb() +#define gbgb _gbgb() +#define bbgb _bbgb() +#define abgb _abgb() +#define ragb _ragb() +#define gagb _gagb() +#define bagb _bagb() +#define aagb _aagb() +#define rrbb _rrbb() +#define grbb _grbb() +#define brbb _brbb() +#define arbb _arbb() +#define rgbb _rgbb() +#define ggbb _ggbb() +#define bgbb _bgbb() +#define agbb _agbb() +#define rbbb _rbbb() +#define gbbb _gbbb() +#define bbbb _bbbb() +#define abbb _abbb() +#define rabb _rabb() +#define gabb _gabb() +#define babb _babb() +#define aabb _aabb() +#define rrab _rrab() +#define grab _grab() +#define brab _brab() +#define arab _arab() +#define rgab _rgab() +#define ggab _ggab() +#define bgab _bgab() +#define agab _agab() +#define rbab _rbab() +#define gbab _gbab() +#define bbab _bbab() +#define abab _abab() +#define raab _raab() +#define gaab _gaab() +#define baab _baab() +#define aaab _aaab() +#define rrra _rrra() +#define grra _grra() +#define brra _brra() +#define arra _arra() +#define rgra _rgra() +#define ggra _ggra() +#define bgra _bgra() +#define agra _agra() +#define rbra _rbra() +#define gbra _gbra() +#define bbra _bbra() +#define abra _abra() +#define rara _rara() +#define gara _gara() +#define bara _bara() +#define aara _aara() +#define rrga _rrga() +#define grga _grga() +#define brga _brga() +#define arga _arga() +#define rgga _rgga() +#define ggga _ggga() +#define bgga _bgga() +#define agga _agga() +#define rbga _rbga() +#define gbga _gbga() +#define bbga _bbga() +#define abga _abga() +#define raga _raga() +#define gaga _gaga() +#define baga _baga() +#define aaga _aaga() +#define rrba _rrba() +#define grba _grba() +#define brba _brba() +#define arba _arba() +#define rgba _rgba() +#define ggba _ggba() +#define bgba _bgba() +#define agba _agba() +#define rbba _rbba() +#define gbba _gbba() +#define bbba _bbba() +#define abba _abba() +#define raba _raba() +#define gaba _gaba() +#define baba _baba() +#define aaba _aaba() +#define rraa _rraa() +#define graa _graa() +#define braa _braa() +#define araa _araa() +#define rgaa _rgaa() +#define ggaa _ggaa() +#define bgaa _bgaa() +#define agaa _agaa() +#define rbaa _rbaa() +#define gbaa _gbaa() +#define bbaa _bbaa() +#define abaa _abaa() +#define raaa _raaa() +#define gaaa _gaaa() +#define baaa _baaa() +#define aaaa _aaaa() + +// 2 components texcoord swizzle operators +#define ss _ss() +#define ts _ts() +#define ps _ps() +#define qs _qs() +#define st _st() +#define tt _tt() +#define pt _pt() +#define qt _qt() +#define sp _sp() +#define tp _tp() +#define pp _pp() +#define qp _qp() +#define sq _sq() +#define tq _tq() +#define pq _pq() +#define qq _qq() + +// 3 components tescoord swizzle operators +#define sss _sss() +#define tss _tss() +#define pss _pss() +#define qss _qss() +#define sts _sts() +#define tts _tts() +#define pts _pts() +#define qts _qts() +#define sps _sps() +#define tps _tps() +#define pps _pps() +#define qps _qps() +#define sqs _sqs() +#define tqs _tqs() +#define pqs _pqs() +#define qqs _qqs() +#define sst _sst() +#define tst _tst() +#define pst _pst() +#define qst _qst() +#define stt _stt() +#define ttt _ttt() +#define ptt _ptt() +#define qtt _qtt() +#define spt _spt() +#define tpt _tpt() +#define ppt _ppt() +#define qpt _qpt() +#define sqt _sqt() +#define tqt _tqt() +#define pqt _pqt() +#define qqt _qqt() +#define ssp _ssp() +#define tsp _tsp() +#define psp _psp() +#define qsp _qsp() +#define stp _stp() +#define ttp _ttp() +#define ptp _ptp() +#define qtp _qtp() +#define spp _spp() +#define tpp _tpp() +#define ppp _ppp() +#define qpp _qpp() +#define sqp _sqp() +#define tqp _tqp() +#define pqp _pqp() +#define qqp _qqp() +#define ssq _ssq() +#define tsq _tsq() +#define psq _psq() +#define qsq _qsq() +#define stq _stq() +#define ttq _ttq() +#define ptq _ptq() +#define qtq _qtq() +#define spq _spq() +#define tpq _tpq() +#define ppq _ppq() +#define qpq _qpq() +#define sqq _sqq() +#define tqq _tqq() +#define pqq _pqq() +#define qqq _qqq() + +// 4 components tescoord swizzle operators +#define ssss _ssss() +#define tsss _tsss() +#define psss _psss() +#define qsss _qsss() +#define stss _stss() +#define ttss _ttss() +#define ptss _ptss() +#define qtss _qtss() +#define spss _spss() +#define tpss _tpss() +#define ppss _ppss() +#define qpss _qpss() +#define sqss _sqss() +#define tqss _tqss() +#define pqss _pqss() +#define qqss _qqss() +#define ssts _ssts() +#define tsts _tsts() +#define psts _psts() +#define qsts _qsts() +#define stts _stts() +#define ttts _ttts() +#define ptts _ptts() +#define qtts _qtts() +#define spts _spts() +#define tpts _tpts() +#define ppts _ppts() +#define qpts _qpts() +#define sqts _sqts() +#define tqts _tqts() +#define pqts _pqts() +#define qqts _qqts() +#define ssps _ssps() +#define tsps _tsps() +#define psps _psps() +#define qsps _qsps() +#define stps _stps() +#define ttps _ttps() +#define ptps _ptps() +#define qtps _qtps() +#define spps _spps() +#define tpps _tpps() +#define ppps _ppps() +#define qpps _qpps() +#define sqps _sqps() +#define tqps _tqps() +#define pqps _pqps() +#define qqps _qqps() +#define ssqs _ssqs() +#define tsqs _tsqs() +#define psqs _psqs() +#define qsqs _qsqs() +#define stqs _stqs() +#define ttqs _ttqs() +#define ptqs _ptqs() +#define qtqs _qtqs() +#define spqs _spqs() +#define tpqs _tpqs() +#define ppqs _ppqs() +#define qpqs _qpqs() +#define sqqs _sqqs() +#define tqqs _tqqs() +#define pqqs _pqqs() +#define qqqs _qqqs() +#define ssst _ssst() +#define tsst _tsst() +#define psst _psst() +#define qsst _qsst() +#define stst _stst() +#define ttst _ttst() +#define ptst _ptst() +#define qtst _qtst() +#define spst _spst() +#define tpst _tpst() +#define ppst _ppst() +#define qpst _qpst() +#define sqst _sqst() +#define tqst _tqst() +#define pqst _pqst() +#define qqst _qqst() +#define sstt _sstt() +#define tstt _tstt() +#define pstt _pstt() +#define qstt _qstt() +#define sttt _sttt() +#define tttt _tttt() +#define pttt _pttt() +#define qttt _qttt() +#define sptt _sptt() +#define tptt _tptt() +#define pptt _pptt() +#define qptt _qptt() +#define sqtt _sqtt() +#define tqtt _tqtt() +#define pqtt _pqtt() +#define qqtt _qqtt() +#define sspt _sspt() +#define tspt _tspt() +#define pspt _pspt() +#define qspt _qspt() +#define stpt _stpt() +#define ttpt _ttpt() +#define ptpt _ptpt() +#define qtpt _qtpt() +#define sppt _sppt() +#define tppt _tppt() +#define pppt _pppt() +#define qppt _qppt() +#define sqpt _sqpt() +#define tqpt _tqpt() +#define pqpt _pqpt() +#define qqpt _qqpt() +#define ssqt _ssqt() +#define tsqt _tsqt() +#define psqt _psqt() +#define qsqt _qsqt() +#define stqt _stqt() +#define ttqt _ttqt() +#define ptqt _ptqt() +#define qtqt _qtqt() +#define spqt _spqt() +#define tpqt _tpqt() +#define ppqt _ppqt() +#define qpqt _qpqt() +#define sqqt _sqqt() +#define tqqt _tqqt() +#define pqqt _pqqt() +#define qqqt _qqqt() +#define sssp _sssp() +#define tssp _tssp() +#define pssp _pssp() +#define qssp _qssp() +#define stsp _stsp() +#define ttsp _ttsp() +#define ptsp _ptsp() +#define qtsp _qtsp() +#define spsp _spsp() +#define tpsp _tpsp() +#define ppsp _ppsp() +#define qpsp _qpsp() +#define sqsp _sqsp() +#define tqsp _tqsp() +#define pqsp _pqsp() +#define qqsp _qqsp() +#define sstp _sstp() +#define tstp _tstp() +#define pstp _pstp() +#define qstp _qstp() +#define sttp _sttp() +#define tttp _tttp() +#define pttp _pttp() +#define qttp _qttp() +#define sptp _sptp() +#define tptp _tptp() +#define pptp _pptp() +#define qptp _qptp() +#define sqtp _sqtp() +#define tqtp _tqtp() +#define pqtp _pqtp() +#define qqtp _qqtp() +#define sspp _sspp() +#define tspp _tspp() +#define pspp _pspp() +#define qspp _qspp() +#define stpp _stpp() +#define ttpp _ttpp() +#define ptpp _ptpp() +#define qtpp _qtpp() +#define sppp _sppp() +#define tppp _tppp() +#define pppp _pppp() +#define qppp _qppp() +#define sqpp _sqpp() +#define tqpp _tqpp() +#define pqpp _pqpp() +#define qqpp _qqpp() +#define ssqp _ssqp() +#define tsqp _tsqp() +#define psqp _psqp() +#define qsqp _qsqp() +#define stqp _stqp() +#define ttqp _ttqp() +#define ptqp _ptqp() +#define qtqp _qtqp() +#define spqp _spqp() +#define tpqp _tpqp() +#define ppqp _ppqp() +#define qpqp _qpqp() +#define sqqp _sqqp() +#define tqqp _tqqp() +#define pqqp _pqqp() +#define qqqp _qqqp() +#define sssq _sssq() +#define tssq _tssq() +#define pssq _pssq() +#define qssq _qssq() +#define stsq _stsq() +#define ttsq _ttsq() +#define ptsq _ptsq() +#define qtsq _qtsq() +#define spsq _spsq() +#define tpsq _tpsq() +#define ppsq _ppsq() +#define qpsq _qpsq() +#define sqsq _sqsq() +#define tqsq _tqsq() +#define pqsq _pqsq() +#define qqsq _qqsq() +#define sstq _sstq() +#define tstq _tstq() +#define pstq _pstq() +#define qstq _qstq() +#define sttq _sttq() +#define tttq _tttq() +#define pttq _pttq() +#define qttq _qttq() +#define sptq _sptq() +#define tptq _tptq() +#define pptq _pptq() +#define qptq _qptq() +#define sqtq _sqtq() +#define tqtq _tqtq() +#define pqtq _pqtq() +#define qqtq _qqtq() +#define sspq _sspq() +#define tspq _tspq() +#define pspq _pspq() +#define qspq _qspq() +#define stpq _stpq() +#define ttpq _ttpq() +#define ptpq _ptpq() +#define qtpq _qtpq() +#define sppq _sppq() +#define tppq _tppq() +#define pppq _pppq() +#define qppq _qppq() +#define sqpq _sqpq() +#define tqpq _tqpq() +#define pqpq _pqpq() +#define qqpq _qqpq() +#define ssqq _ssqq() +#define tsqq _tsqq() +#define psqq _psqq() +#define qsqq _qsqq() +#define stqq _stqq() +#define ttqq _ttqq() +#define ptqq _ptqq() +#define qtqq _qtqq() +#define spqq _spqq() +#define tpqq _tpqq() +#define ppqq _ppqq() +#define qpqq _qpqq() +#define sqqq _sqqq() +#define tqqq _tqqq() +#define pqqq _pqqq() +#define qqqq _qqqq() +*/ + +#endif//__swizzle_h__ diff --git a/wip/sse/glm/core/_swizzle.inl b/wip/sse/glm/core/_swizzle.inl new file mode 100644 index 00000000..adbe5440 --- /dev/null +++ b/wip/sse/glm/core/_swizzle.inl @@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2006-04-27 +// Licence : This source is under GNU LGPL licence +// File : _swizzle.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __swizzle_inl__ +#define __swizzle_inl__ + +#include "./_swizzle.h" + +namespace glm +{ + +} + +#endif//__swizzle_inl__ diff --git a/wip/sse/glm/core/_xmat2.h b/wip/sse/glm/core/_xmat2.h new file mode 100644 index 00000000..b6f5580a --- /dev/null +++ b/wip/sse/glm/core/_xmat2.h @@ -0,0 +1,173 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-27 +// Updated : 2007-03-01 +// Licence : This source is under GNU LGPL licence +// File : _xmat2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat2x2_h__ +#define __mat2x2_h__ + +namespace glm{ +namespace detail{ + + template class _xvec2; + template class _xmat3; + template class _xmat4; + template class _xmat2x4; + template class _xmat2x3; + template class _xmat3x2; + template class _xmat3x4; + template class _xmat4x2; + template class _xmat4x3; + + //!< \brief Template for 2 * 2 matrix of floating-point numbers. + template + class _xmat2 + { + private: + // Data + _xvec2 value[2]; + + public: + _xmat2 _inverse() const; + + public: + typedef T value_type; + typedef _xvec2 col_type; + typedef _xvec2 row_type; + typedef int size_type; + static const size_type value_size; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat2(); + _xmat2(const _xmat2& m); + + explicit _xmat2(const T x); + explicit _xmat2(const T x1, const T y1, + const T x2, const T y2); + explicit _xmat2(const _xvec2 & v1, + const _xvec2 & v2); + + // Conversions + template + explicit _xmat2(const _xmat2& m); + + explicit _xmat2(const _xmat3& x); + explicit _xmat2(const _xmat4& x); + explicit _xmat2(const _xmat2x3& x); + explicit _xmat2(const _xmat3x2& x); + explicit _xmat2(const _xmat2x4& x); + explicit _xmat2(const _xmat4x2& x); + explicit _xmat2(const _xmat3x4& x); + explicit _xmat2(const _xmat4x3& x); + + //explicit _xmat2(const T* a); + // GL_GTX_euler_angles + //explicit _xmat2(const _xvec2 & angles); + + // Accesses + _xvec2& operator[](int i) {return value[i];} + const _xvec2 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat2& operator=(const _xmat2& m); + _xmat2& operator+=(const T s); + _xmat2& operator+=(const _xmat2& m); + _xmat2& operator-=(const T s); + _xmat2& operator-=(const _xmat2& m); + _xmat2& operator*=(const T s); + _xmat2& operator*= (const _xmat2& m); + _xmat2& operator/= (const T s); + _xmat2& operator/= (const _xmat2& m); + _xmat2& operator++ (); + _xmat2& operator-- (); + + const _xmat2 operator- () const; + const _xmat2 operator++ (int n) const; + const _xmat2 operator-- (int n) const; + }; + + // Binary operators + template + inline _xmat2 operator+ (const _xmat2& m, const T s); + + template + inline _xmat2 operator+ (const T s, const _xmat2& m); + + template + inline _xvec2 operator+ (const _xmat2& m, const _xvec2& v); + + template + inline _xvec2 operator+ (const _xvec2& v, const _xmat2& m); + + template + inline _xmat2 operator+ (const _xmat2& m1, const _xmat2& m2); + + template + inline _xmat2 operator- (const _xmat2& m, const T s); + + template + inline _xmat2 operator- (const T s, const _xmat2& m); + + template + inline _xvec2 operator- (const _xmat2& m, const _xvec2& v); + + template + inline _xvec2 operator- (const _xvec2& v, const _xmat2& m); + + template + inline _xmat2 operator- (const _xmat2& m1, const _xmat2& m2); + + template + inline _xmat2 operator* (const _xmat2& m, const T s); + + template + inline _xmat2 operator* (const T s, const _xmat2& m); + + template + inline _xvec2 operator* (const _xmat2& m, const _xvec2& v); + + template + inline _xvec2 operator* (const _xvec2& v, const _xmat2& m); + + template + inline _xmat2 operator* (const _xmat2& m1, const _xmat2& m2); + + template + inline _xmat2 operator/ (const _xmat2& m, const T s); + + template + inline _xmat2 operator/ (const T s, const _xmat2& m); + + template + inline _xvec2 operator/ (const _xmat2& m, const _xvec2& v); + + template + inline _xvec2 operator/ (const _xvec2& v, const _xmat2& m); + + template + inline _xmat2 operator/ (const _xmat2& m1, const _xmat2& m2); + + // Unary constant operators + template + inline const _xmat2 operator- (const _xmat2& m); + + template + inline const _xmat2 operator-- (const _xmat2& m, int); + + template + inline const _xmat2 operator++ (const _xmat2& m, int); + +} //namespace detail +} //namespace glm + +#endif //__mat2x2_h__ diff --git a/wip/sse/glm/core/_xmat2.inl b/wip/sse/glm/core/_xmat2.inl new file mode 100644 index 00000000..aa3a3483 --- /dev/null +++ b/wip/sse/glm/core/_xmat2.inl @@ -0,0 +1,416 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-16 +// Updated : 2007-03-01 +// Licence : This source is under GNU LGPL licence +// File : _xmat2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xmat2x2_inl__ +#define __xmat2x2_inl__ + +#include "./_xmat2.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat2::size_type _xmat2::value_size = 2; + template const typename _xmat2::size_type _xmat2::col_size = 2; + template const typename _xmat2::size_type _xmat2::row_size = 2; + + ////////////////////////////////////////////////////////////// + // mat2 constructors + + template + inline _xmat2::_xmat2() + { + this->value[0] = _xvec2(1, 0); + this->value[1] = _xvec2(0, 1); + } + + template + inline _xmat2::_xmat2(const _xmat2 & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + } + + template + inline _xmat2::_xmat2(const T f) + { + this->value[0] = _xvec2(f, 0); + this->value[1] = _xvec2(0, f); + } + + template + inline _xmat2::_xmat2(const T x0, const T y0, const T x1, const T y1) + { + this->value[0] = _xvec2(x0, y0); + this->value[1] = _xvec2(x1, y1); + } + + template + inline _xmat2::_xmat2(const _xvec2& v0, const _xvec2& v1) + { + this->value[0] = v0; + this->value[1] = v1; + } + + ////////////////////////////////////////////////////////////// + // mat2 conversions + + template + template + inline _xmat2::_xmat2(const _xmat2& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + } + + template + inline _xmat2::_xmat2(const _xmat3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + } + + template + inline _xmat2::_xmat2(const _xmat4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + } + + template + inline _xmat2::_xmat2(const _xmat2x3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + } + + template + inline _xmat2::_xmat2(const _xmat3x2& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + } + + template + inline _xmat2::_xmat2(const _xmat2x4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + } + + template + inline _xmat2::_xmat2(const _xmat4x2& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + } + + template + inline _xmat2::_xmat2(const _xmat3x4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + } + + template + inline _xmat2::_xmat2(const _xmat4x3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + } + +/* + template + inline _xmat2::_xmat2(const T* a) + { + this->value[0] = _xvec2(a[0], a[1]); + this->value[1] = _xvec2(a[2], a[3]); + } +*/ + + template + inline _xmat2 _xmat2::_inverse() const + { + T Determinant = value[0][0] * value[1][1] - value[1][0] * value[0][1]; + + _xmat2 Inverse( + + value[1][1] / Determinant, + - value[1][0] / Determinant, + - value[0][1] / Determinant, + + value[0][0] / Determinant); + return Inverse; + } + + ////////////////////////////////////////////////////////////// + // mat3 operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + template + inline _xmat2& _xmat2::operator=(const _xmat2& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + return *this; + } + + template + inline _xmat2& _xmat2::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + return *this; + } + + template + inline _xmat2& _xmat2::operator+= (const _xmat2& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + return *this; + } + + template + inline _xmat2& _xmat2::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + return *this; + } + + template + inline _xmat2& _xmat2::operator-= (const _xmat2& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + return *this; + } + + template + inline _xmat2& _xmat2::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + return *this; + } + + template + inline _xmat2& _xmat2::operator*= (const _xmat2& m) + { + return (*this = *this * m); + } + + template + inline _xmat2& _xmat2::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + return *this; + } + + template + inline _xmat2& _xmat2::operator/= (const _xmat2& m) + { + return (*this = *this / m); + } + + template + inline _xmat2& _xmat2::operator++ () + { + ++this->value[0]; + ++this->value[1]; + return *this; + } + + template + inline _xmat2& _xmat2::operator-- () + { + --this->value[0]; + --this->value[1]; + return *this; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat2 operator+ (const _xmat2& m, const T s) + { + return _xmat2( + m[0] + s, + m[1] + s); + } + + template + inline _xmat2 operator+ (const T s, const _xmat2& m) + { + return _xmat2( + m[0] + s, + m[1] + s); + } + + template + inline _xvec2 operator+ (const _xmat2& m, const _xvec2& v) + { + + } + + template + inline _xvec2 operator+ (const _xvec2& v, const _xmat2& m) + { + + } + + template + inline _xmat2 operator+ (const _xmat2& m1, const _xmat2& m2) + { + return _xmat2( + m1[0] + m2[0], + m1[1] + m2[1]); + } + + template + inline _xmat2 operator- (const _xmat2& m, const T s) + { + return _xmat2( + m[0] - s, + m[1] - s); + } + + template + inline _xmat2 operator- (const T s, const _xmat2& m) + { + return _xmat2( + s - m[0], + s - m[1]); + } + + template + inline _xmat2 operator- (const _xmat2& m, const _xvec2& v) + { + + } + + template + inline _xmat2 operator- (const _xvec2& v, const _xmat2& m) + { + + } + + template + inline _xmat2 operator- (const _xmat2& m1, const _xmat2& m2) + { + return _xmat2( + m1[0] - m2[0], + m1[1] - m2[1]); + } + + template + inline _xmat2 operator* (const _xmat2& m, const T s) + { + return _xmat2( + m[0] * s, + m[1] * s); + } + + template + inline _xmat2 operator* (const T s, const _xmat2& m) + { + return _xmat2( + m[0] * s, + m[1] * s); + } + + template + inline _xvec2 operator* (const _xmat2& m, const _xvec2& v) + { + return _xvec2( + m[0][0] * v.x + m[1][0] * v.y, + m[0][1] * v.x + m[1][1] * v.y); + } + + template + inline _xvec2 operator* (const _xvec2& v, const _xmat2& m) + { + return _xvec2( + m[0][0] * v.x + m[0][1] * v.y, + m[1][0] * v.x + m[1][1] * v.y); + } + + template + inline _xmat2 operator* (const _xmat2& m1, const _xmat2& m2) + { + return _xmat2( + m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1], + m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1], + m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1], + m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1]); + } + + template + inline _xmat2 operator/ (const _xmat2& m, const T s) + { + return _xmat2( + m[0] / s, + m[1] / s); + } + + template + inline _xmat2 operator/ (const T s, const _xmat2& m) + { + return _xmat2( + s / m[0], + s / m[1]); + } + + template + inline _xvec2 operator/ (const _xmat2& m, const _xvec2& v) + { + return m._inverse() * v; + } + + template + inline _xvec2 operator/ (const _xvec2& v, const _xmat2& m) + { + return v * m._inverse(); + } + + template + inline _xmat2 operator/ (const _xmat2& m1, const _xmat2& m2) + { + return m1 * m2._inverse(); + } + + // Unary constant operators + template + inline const _xmat2 operator- (const _xmat2& m) + { + return _xmat2( + -m.value[0], + -m.value[1]); + } + + template + inline const _xmat2 operator-- (const _xmat2& m, int) + { + return _xmat2( + m.value[0] - T(1), + m.value[1] - T(1)); + } + + template + inline const _xmat2 operator++ (const _xmat2& m, int) + { + return _xmat2( + m.value[0] + T(1), + m.value[1] + T(1)); + } + +} //namespace detail +} //namespace glm + +#endif //__xmat2x2_inl__ diff --git a/wip/sse/glm/core/_xmat2x3.h b/wip/sse/glm/core/_xmat2x3.h new file mode 100644 index 00000000..1d69f790 --- /dev/null +++ b/wip/sse/glm/core/_xmat2x3.h @@ -0,0 +1,143 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-10-01 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat2x3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat2x3_h__ +#define __mat2x3_h__ + +namespace glm{ +namespace detail{ + + template class _xvec2; + template class _xvec3; + template class _xvec4; + template class _xmat2; + template class _xmat3; + template class _xmat4; + template class _xmat2x4; + template class _xmat3x2; + template class _xmat3x4; + template class _xmat4x2; + template class _xmat4x3; + + //!< \brief Template for 2 * 3 matrix of floating-point numbers. + template + class _xmat2x3 + { + private: + // Data + _xvec3 value[2]; + + public: + typedef T value_type; + typedef _xvec3 col_type; + typedef _xvec2 row_type; + typedef int size_type; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat2x3(); + explicit _xmat2x3(const T x); + explicit _xmat2x3( + const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1); + explicit _xmat2x3( + const _xvec3& v0, + const _xvec3& v1); + + // Conversion + template + explicit _xmat2x3(const _xmat2x3& m); + + explicit _xmat2x3(const _xmat2& x); + explicit _xmat2x3(const _xmat3& x); + explicit _xmat2x3(const _xmat4& x); + explicit _xmat2x3(const _xmat2x4& x); + explicit _xmat2x3(const _xmat3x2& x); + explicit _xmat2x3(const _xmat3x4& x); + explicit _xmat2x3(const _xmat4x2& x); + explicit _xmat2x3(const _xmat4x3& x); + + // Accesses + _xvec3& operator[](int i) {return value[i];} + const _xvec3 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat2x3& operator= (const _xmat2x3& m); + _xmat2x3& operator+= (const T s); + _xmat2x3& operator+= (const _xmat2x3& m); + _xmat2x3& operator-= (const T s); + _xmat2x3& operator-= (const _xmat2x3& m); + _xmat2x3& operator*= (const T s); + _xmat2x3& operator*= (const _xmat3x2& m); + _xmat2x3& operator/= (const T s); +/* ToDo + _xmat2x3& operator/= (const _xmat3x2& m); +*/ + _xmat2x3& operator++ (); + _xmat2x3& operator-- (); + + // Unary constant operators + const _xmat2x3 operator- () const; + const _xmat2x3 operator++ (int n) const; + const _xmat2x3 operator-- (int n) const; + }; + + // Binary operators + template + _xmat2x3 operator+ (const _xmat2x3& m, const T s); + + template + _xmat2x3 operator+ (const _xmat2x3& m1, const _xmat2x3& m2); + + template + _xmat2x3 operator- (const _xmat2x3& m, const T s); + + template + _xmat2x3 operator- (const _xmat2x3& m1, const _xmat2x3& m2); + + template + _xmat2x3 operator* (const _xmat2x3& m, const T s); + + template + _xmat2x3 operator* (const T s, const _xmat2x3& m); + + template + _xvec3 operator* (const _xmat2x3& m, const _xvec2& v); + + template + _xvec3 operator* (const _xvec3& v, const _xmat2x3& m); + + template + _xmat3 operator* (const _xmat2x3& m1, const _xmat3x2& m2); + + template + _xmat3x2 operator/ (const _xmat2x3& m, const T s); + + template + _xmat3x2 operator/ (const T s, const _xmat2x3& m); +/* ToDo + template + _xvec3 operator/ (const _xmat2x3& m, const _xvec2& v); + + template + _xvec2 operator/ (const _xvec3& v, const _xmat2x3& m); + + template + _xmat3 operator/ (const _xmat3x2& m1, const _xmat2x3& m2); +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat2x3_h__ diff --git a/wip/sse/glm/core/_xmat2x3.inl b/wip/sse/glm/core/_xmat2x3.inl new file mode 100644 index 00000000..3e208a07 --- /dev/null +++ b/wip/sse/glm/core/_xmat2x3.inl @@ -0,0 +1,379 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-05 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat2x3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat2x3_inl__ +#define __mat2x3_inl__ + +#include "./_xmat2x3.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat2x3::size_type _xmat2x3::col_size = 2; + template const typename _xmat2x3::size_type _xmat2x3::row_size = 3; + + ////////////////////////////////////////////////////////////// + // Constructors + + template + inline _xmat2x3::_xmat2x3() + { + this->value[0] = _xvec3(T(1), T(0), T(0)); + this->value[1] = _xvec3(T(0), T(1), T(0)); + } + + template + inline _xmat2x3::_xmat2x3(const T f) + { + this->value[0] = _xvec3(f, T(0), T(0)); + this->value[1] = _xvec3(T(0), f, T(0)); + } + + template + inline _xmat2x3::_xmat2x3 + ( + const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1 + ) + { + this->value[0] = _xvec3(x0, y0, z0); + this->value[1] = _xvec3(x1, y1, z1); + } + + template + inline _xmat2x3::_xmat2x3 + ( + const _xvec3 & v0, + const _xvec3 & v1 + ) + { + this->value[0] = v0; + this->value[1] = v1; + } + + // Conversion + template + template + inline _xmat2x3::_xmat2x3(const _xmat2x3& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat3& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat2x4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat3x2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat3x4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat4x2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + } + + template + inline _xmat2x3::_xmat2x3(const _xmat4x3& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + } + + ////////////////////////////////////////////////////////////// + // Unary updatable operators + + template + inline _xmat2x3& _xmat2x3::operator= (const _xmat2x3& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + return *this; + } + + template + inline _xmat2x3& _xmat2x3::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + return *this; + } + + template + inline _xmat2x3& _xmat2x3::operator+= (const _xmat2x3& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + return *this; + } + + template + inline _xmat2x3& _xmat2x3::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + return *this; + } + + template + inline _xmat2x3& _xmat2x3::operator-= (const _xmat2x3& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + return *this; + } + + template + inline _xmat2x3& _xmat2x3::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + return *this; + } + + template + inline _xmat2x3& _xmat2x3::operator*= (const _xmat3x2& m) + { + return (*this = _xmat2x3(*this * m)); + } + + template + inline _xmat2x3 & _xmat2x3::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + return *this; + } +/* ToDo + template + inline _xmat2x3& _xmat2x3::operator/= (const _xmat3x2& m) + { + return (*this = _xmat2x3(*this / m)); + } +*/ + template + inline _xmat2x3& _xmat2x3::operator++ () + { + ++this->value[0]; + ++this->value[1]; + return *this; + } + + template + inline _xmat2x3& _xmat2x3::operator-- () + { + --this->value[0]; + --this->value[1]; + return *this; + } + + ////////////////////////////////////////////////////////////// + // Unary constant operators + template + inline const _xmat2x3 _xmat2x3::operator- () const + { + return _xmat2x3( + -this->value[0], + -this->value[1]); + } + + template + inline const _xmat2x3 _xmat2x3::operator-- (int n) const + { + _xmat2x3 m = *this; + --m.value[0]; + --m.value[1]; + return m; + } + + template + inline const _xmat2x3 _xmat2x3::operator++ (int n) const + { + _xmat2x3 m = *this; + ++m.value[0]; + ++m.value[1]; + return m; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat2x3 operator+ (const _xmat2x3& m, const T s) + { + return _xmat2x3( + m[0] + s, + m[1] + s); + } + + template + inline _xmat2x3 operator+ (const _xmat2x3& m1, const _xmat2x3& m2) + { + return _xmat2x3( + m1[0] + m2[0], + m1[1] + m2[1]); + } + + template + inline _xmat2x3 operator- (const _xmat2x3& m, const T s) + { + return _xmat2x3( + m[0] - s, + m[1] - s); + } + + template + inline _xmat2x3 operator- (const _xmat2x3& m1, const _xmat2x3& m2) + { + return _xmat2x3( + m1[0] - m2[0], + m1[1] - m2[1]); + } + + template + inline _xmat2x3 operator* (const _xmat2x3& m, const T s) + { + return _xmat2x3( + m[0] * s, + m[1] * s); + } + + template + inline _xmat2x3 operator* (const T s, const _xmat2x3 & m) + { + return _xmat2x3( + m[0] * s, + m[1] * s); + } + + template + inline _xvec3 operator* (const _xmat2x3& m, const _xvec2& v) + { + return _xvec3( + m[0][0] * v.x + m[1][0] * v.y, + m[0][1] * v.x + m[1][1] * v.y, + m[0][2] * v.x + m[1][2] * v.y, + m[0][3] * v.x + m[1][3] * v.y); + } + + template + inline _xvec2 operator* (const _xvec3& v, const _xmat2x3& m) + { + return _xvec2( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w); + } + + template + inline _xmat3 operator* (const _xmat2x3& m1, const _xmat3x2& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA02 = m1[0][2]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA12 = m1[1][2]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB20 = m2[2][0]; + const T SrcB21 = m2[2][1]; + + _xmat3 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01; + Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11; + Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11; + Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21; + Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21; + Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21; + return Result; + } + + template + inline _xmat2x3 operator/ (const _xmat2x3& m, const T s) + { + return _xmat2x3( + m.value[0] / s, + m.value[1] / s, + m.value[2] / s); + } + + template + inline _xmat2x3 operator/ (const T s, const _xmat2x3& m) + { + return _xmat2x3( + s / m.value[0], + s / m.value[1], + s / m.value[2]); + } +/* ToDo + template + inline _xvec3 operator/ (const _xmat2x3& m, const _xvec2& v) + { + + } + + template + inline _xvec2 operator/ (const _xvec3& v, const _xmat3x2& m) + { + + } + + template + inline _xmat3 operator/ (const _xmat2x3& m1, const _xmat3x2& m2) + { + + } +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat2x3_inl__ diff --git a/wip/sse/glm/core/_xmat2x4.h b/wip/sse/glm/core/_xmat2x4.h new file mode 100644 index 00000000..1a15ef2b --- /dev/null +++ b/wip/sse/glm/core/_xmat2x4.h @@ -0,0 +1,144 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-05 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat2x4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat2x4_h__ +#define __mat2x4_h__ + +namespace glm{ +namespace detail{ + + template class _xvec2; + template class _xvec3; + template class _xvec4; + template class _xmat2; + template class _xmat3; + template class _xmat4; + template class _xmat2x3; + template class _xmat3x2; + template class _xmat3x4; + template class _xmat4x2; + template class _xmat4x3; + + //!< \brief Template for 2 * 4 matrix of floating-point numbers. + template + class _xmat2x4 + { + private: + // Data + _xvec4 value[2]; + + public: + typedef T value_type; + typedef _xvec2 col_type; + typedef _xvec4 row_type; + typedef int size_type; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat2x4(); + explicit _xmat2x4(const T x); + explicit _xmat2x4( + const T x0, const T y0, const T z0, const T w0, + const T x1, const T y1, const T z1, const T w1); + explicit _xmat2x4( + const _xvec4& v0, + const _xvec4& v1); + + // Conversion + template + explicit _xmat2x4(const _xmat2x4& m); + + explicit _xmat2x4(const _xmat2& x); + explicit _xmat2x4(const _xmat3& x); + explicit _xmat2x4(const _xmat4& x); + explicit _xmat2x4(const _xmat2x3& x); + //explicit _xmat2x4(const _xmat2x4& x); + explicit _xmat2x4(const _xmat3x2& x); + explicit _xmat2x4(const _xmat3x4& x); + explicit _xmat2x4(const _xmat4x2& x); + explicit _xmat2x4(const _xmat4x3& x); + + // Accesses + _xvec4& operator[](int i) {return value[i];} + const _xvec4 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat2x4& operator= (const _xmat2x4& m); + _xmat2x4& operator+= (const T s); + _xmat2x4& operator+= (const _xmat2x4& m); + _xmat2x4& operator-= (const T s); + _xmat2x4& operator-= (const _xmat2x4& m); + _xmat2x4& operator*= (const T s); + _xmat2x4& operator*= (const _xmat4x2& m); + _xmat2x4& operator/= (const T s); +/* ToDo + _xmat2x4& operator/= (const _xmat4x2& m); +*/ + _xmat2x4& operator++ (); + _xmat2x4& operator-- (); + + // Unary constant operators + const _xmat2x4 operator- () const; + const _xmat2x4 operator++ (int n) const; + const _xmat2x4 operator-- (int n) const; + }; + + // Binary operators + template + _xmat2x4 operator+ (const _xmat2x4& m, const T s); + + template + _xmat2x4 operator+ (const _xmat2x4& m1, const _xmat2x4& m2); + + template + _xmat2x4 operator- (const _xmat2x4& m, const T s); + + template + _xmat2x4 operator- (const _xmat2x4& m1, const _xmat2x4& m2); + + template + _xmat2x4 operator* (const _xmat2x4& m, const T s); + + template + _xmat2x4 operator* (const T s, const _xmat2x4& m); + + template + _xvec4 operator* (const _xmat2x4& m, const _xvec2& v); + + template + _xvec3 operator* (const _xvec4& v, const _xmat2x4& m); + + template + _xmat4 operator* (const _xmat2x4& m1, const _xmat4x2& m2); + + template + _xmat4x2 operator/ (const _xmat2x4& m, const T s); + + template + _xmat4x2 operator/ (const T s, const _xmat2x4& m); +/* ToDo + template + _xvec4 operator/ (const _xmat2x4& m, const _xvec2& v); + + template + _xvec2 operator/ (const _xvec4& v, const _xmat2x4& m); + + template + _xmat4 operator/ (const _xmat4x2& m1, const _xmat2x4& m2); +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat2x4_h__ diff --git a/wip/sse/glm/core/_xmat2x4.inl b/wip/sse/glm/core/_xmat2x4.inl new file mode 100644 index 00000000..1a7490a5 --- /dev/null +++ b/wip/sse/glm/core/_xmat2x4.inl @@ -0,0 +1,392 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-05 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat2x4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat2x4_inl__ +#define __mat2x4_inl__ + +#include "./_xmat2x4.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat2x4::size_type _xmat2x4::col_size = 2; + template const typename _xmat2x4::size_type _xmat2x4::row_size = 4; + + ////////////////////////////////////////////////////////////// + // Constructors + + template + inline _xmat2x4::_xmat2x4() + { + this->value[0] = _xvec4(1, 0, 0, 0); + this->value[1] = _xvec4(0, 1, 0, 0); + } + + template + inline _xmat2x4::_xmat2x4(const T f) + { + this->value[0] = _xvec4(f, 0, 0, 0); + this->value[1] = _xvec4(0, f, 0, 0); + } + + template + inline _xmat2x4::_xmat2x4 + ( + const T x0, const T y0, const T z0, const T w0, + const T x1, const T y1, const T z1, const T w1 + ) + { + this->value[0] = _xvec4(x0, y0, z0, w0); + this->value[1] = _xvec4(x1, y1, z1, w1); + } + + template + inline _xmat2x4::_xmat2x4 + ( + const _xvec4 & v0, + const _xvec4 & v1 + ) + { + this->value[0] = v0; + this->value[1] = v1; + } + + // Conversion + template + template + inline _xmat2x4::_xmat2x4(const _xmat2x4& m) + { + this->value[0] = _xvec4(m[0]); + this->value[1] = _xvec4(m[1]); + } + + template + inline _xmat2x4::_xmat2x4(const _xmat2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + } + + template + inline _xmat2x4::_xmat2x4(const _xmat3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + } + + template + inline _xmat2x4::_xmat2x4(const _xmat4& m) + { + this->value[0] = _xvec4(m[0]); + this->value[1] = _xvec4(m[1]); + } + + template + inline _xmat2x4::_xmat2x4(const _xmat2x3& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + } + + template + inline _xmat2x4::_xmat2x4(const _xmat3x2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + } + + template + inline _xmat2x4::_xmat2x4(const _xmat3x4& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + } + + template + inline _xmat2x4::_xmat2x4(const _xmat4x2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(T(0))); + this->value[1] = _xvec4(m[1], _xvec2(T(0))); + } + + template + inline _xmat2x4::_xmat2x4(const _xmat4x3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + } + + ////////////////////////////////////////////////////////////// + // Unary updatable operators + + template + inline _xmat2x4& _xmat2x4::operator= (const _xmat2x4& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + return *this; + } + + template + inline _xmat2x4& _xmat2x4::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + return *this; + } + + template + inline _xmat2x4& _xmat2x4::operator+= (const _xmat2x4& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + return *this; + } + + template + inline _xmat2x4& _xmat2x4::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + return *this; + } + + template + inline _xmat2x4& _xmat2x4::operator-= (const _xmat2x4& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + return *this; + } + + template + inline _xmat2x4& _xmat2x4::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + return *this; + } + + template + inline _xmat2x4& _xmat2x4::operator*= (const _xmat4x2& m) + { + return (*this = _xmat2x4(*this * m)); + } + + template + inline _xmat2x4 & _xmat2x4::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + return *this; + } +/* ToDo + template + inline _xmat2x4& _xmat2x4::operator/= (const _xmat4x2& m) + { + return (*this = _xmat2x4(*this / m)); + } +*/ + template + inline _xmat2x4& _xmat2x4::operator++ () + { + ++this->value[0]; + ++this->value[1]; + return *this; + } + + template + inline _xmat2x4& _xmat2x4::operator-- () + { + --this->value[0]; + --this->value[1]; + return *this; + } + + ////////////////////////////////////////////////////////////// + // Unary constant operators + template + inline const _xmat2x4 _xmat2x4::operator- () const + { + return _xmat2x4( + -this->value[0], + -this->value[1]); + } + + template + inline const _xmat2x4 _xmat2x4::operator-- (int n) const + { + _xmat2x4 m = *this; + --m.value[0]; + --m.value[1]; + return m; + } + + template + inline const _xmat2x4 _xmat2x4::operator++ (int n) const + { + _xmat2x4 m = *this; + ++m.value[0]; + ++m.value[1]; + return m; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat2x4 operator+ (const _xmat2x4& m, const T s) + { + return _xmat2x4( + m[0] + s, + m[1] + s); + } + + template + inline _xmat2x4 operator+ (const _xmat2x4& m1, const _xmat2x4& m2) + { + return _xmat2x4( + m1[0] + m2[0], + m1[1] + m2[1]); + } + + template + inline _xmat2x4 operator- (const _xmat2x4& m, const T s) + { + return _xmat2x4( + m[0] - s, + m[1] - s); + } + + template + inline _xmat2x4 operator- (const _xmat2x4& m1, const _xmat2x4& m2) + { + return _xmat2x4( + m1[0] - m2[0], + m1[1] - m2[1]); + } + + template + inline _xmat2x4 operator* (const _xmat2x4& m, const T s) + { + return _xmat2x4( + m[0] * s, + m[1] * s); + } + + template + inline _xmat2x4 operator* (const T s, const _xmat2x4 & m) + { + return _xmat2x4( + m[0] * s, + m[1] * s); + } + + template + inline _xvec4 operator* (const _xmat2x4& m, const _xvec2& v) + { + return _xvec4( + m[0][0] * v.x + m[1][0] * v.y, + m[0][1] * v.x + m[1][1] * v.y, + m[0][2] * v.x + m[1][2] * v.y, + m[0][3] * v.x + m[1][3] * v.y); + } + + template + inline _xvec2 operator* (const _xvec4& v, const _xmat2x4& m) + { + return _xvec2( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w); + } + + template + inline _xmat4 operator* (const _xmat2x4& m1, const _xmat4x2& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA02 = m1[0][2]; + const T SrcA03 = m1[0][3]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA12 = m1[1][2]; + const T SrcA13 = m1[1][3]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB20 = m2[2][0]; + const T SrcB21 = m2[2][1]; + const T SrcB30 = m2[3][0]; + const T SrcB31 = m2[3][1]; + + _xmat4 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01; + Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01; + Result[0][3] = SrcA03 * SrcB00 + SrcA13 * SrcB01; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11; + Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11; + Result[1][3] = SrcA03 * SrcB10 + SrcA13 * SrcB11; + Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21; + Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21; + Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21; + Result[2][3] = SrcA03 * SrcB20 + SrcA13 * SrcB21; + Result[3][0] = SrcA00 * SrcB30 + SrcA10 * SrcB31; + Result[3][1] = SrcA01 * SrcB30 + SrcA11 * SrcB31; + Result[3][2] = SrcA02 * SrcB30 + SrcA12 * SrcB31; + Result[3][3] = SrcA03 * SrcB30 + SrcA13 * SrcB31; + return Result; + } + + template + inline _xmat2x4 operator/ (const _xmat2x4& m, const T s) + { + return _xmat2x4( + m.value[0] / s, + m.value[1] / s, + m.value[2] / s, + m.value[3] / s); + } + + template + inline _xmat2x4 operator/ (const T s, const _xmat2x4& m) + { + return _xmat2x4( + s / m.value[0], + s / m.value[1], + s / m.value[2], + s / m.value[3]); + } +/* ToDo + template + inline _xvec4 operator/ (const _xmat2x4& m, const _xvec2& v) + { + + } + + template + inline _xvec2 operator/ (const _xvec4& v, const _xmat4x2& m) + { + + } + + template + inline _xmat4 operator/ (const _xmat2x4& m1, const _xmat4x2& m2) + { + + } +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat2x4_inl__ diff --git a/wip/sse/glm/core/_xmat3.h b/wip/sse/glm/core/_xmat3.h new file mode 100644 index 00000000..63f84dce --- /dev/null +++ b/wip/sse/glm/core/_xmat3.h @@ -0,0 +1,176 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-27 +// Updated : 2007-03-01 +// Licence : This source is under GNU LGPL licence +// File : _xmat3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xmat3_h__ +#define __xmat3_h__ + +namespace glm{ +namespace detail{ + + template class _xvec2; + template class _xvec3; + template class _xquat; + + template class _xmat2; + template class _xmat4; + template class _xmat2x4; + template class _xmat2x3; + template class _xmat3x2; + template class _xmat3x4; + template class _xmat4x2; + template class _xmat4x3; + + //!< \brief Template for 3 * 3 matrix of floating-point numbers. + template + class _xmat3 + { + private: + // Data + _xvec3 value[3]; + + public: + _xmat3 _inverse() const; + + public: + typedef T value_type; + typedef _xvec3 col_type; + typedef _xvec3 row_type; + typedef int size_type; + static const size_type value_size; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat3(); + explicit _xmat3(const T x); + explicit _xmat3(const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1, + const T x2, const T y2, const T z2); + explicit _xmat3(const _xvec3 & v0, + const _xvec3 & v1, + const _xvec3 & v2); + + // Conversions + template + explicit _xmat3(const _xmat3& m); + + explicit _xmat3(const _xmat2& x); + explicit _xmat3(const _xmat4& x); + explicit _xmat3(const _xmat2x3& x); + explicit _xmat3(const _xmat3x2& x); + explicit _xmat3(const _xmat2x4& x); + explicit _xmat3(const _xmat4x2& x); + explicit _xmat3(const _xmat3x4& x); + explicit _xmat3(const _xmat4x3& x); + + //explicit _xmat3(const T* a); + // GL_GTX_euler_angles + //explicit _xmat3(const _xvec2 & angles); + //explicit _xmat3(const _xvec3 & angles); + + // Conversions + //explicit _xmat3(const glm::_xquat & q); + + // Accesses + _xvec3& operator[](int i) {return value[i];} + const _xvec3 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat3& operator=(const _xmat3& m); + _xmat3& operator+= (const T s); + _xmat3& operator+= (const _xmat3& m); + _xmat3& operator-= (const T s); + _xmat3& operator-= (const _xmat3& m); + _xmat3& operator*= (const T s); + _xmat3& operator*= (const _xmat3& m); + _xmat3& operator/= (const T s); + _xmat3& operator/= (const _xmat3& m); + _xmat3& operator++ (); + _xmat3& operator-- (); + }; + + // Binary operators + template + inline _xmat3 operator+ (const _xmat3& m, const T s); + + template + inline _xmat3 operator+ (const T s, const _xmat3& m); + + template + inline _xvec3 operator+ (const _xmat3& m, const _xvec3& v); + + template + inline _xvec3 operator+ (const _xvec3& v, const _xmat3& m); + + template + inline _xmat3 operator+ (const _xmat3& m1, const _xmat3& m2); + + template + inline _xmat3 operator- (const _xmat3& m, const T s); + + template + inline _xmat3 operator- (const T s, const _xmat3& m); + + template + inline _xvec3 operator- (const _xmat3& m, const _xvec3& v); + + template + inline _xvec3 operator- (const _xvec3& v, const _xmat3& m); + + template + inline _xmat3 operator- (const _xmat3& m1, const _xmat3& m2); + + template + inline _xmat3 operator* (const _xmat3& m, const T s); + + template + inline _xmat3 operator* (const T s, const _xmat3& m); + + template + inline _xvec3 operator* (const _xmat3& m, const _xvec3& v); + + template + inline _xvec3 operator* (const _xvec3& v, const _xmat3& m); + + template + inline _xmat3 operator* (const _xmat3& m1, const _xmat3& m2); + + template + inline _xmat3 operator/ (const _xmat3& m, const T s); + + template + inline _xmat3 operator/ (const T s, const _xmat3& m); + + template + inline _xvec3 operator/ (const _xmat3& m, const _xvec3& v); + + template + inline _xvec3 operator/ (const _xvec3& v, const _xmat3& m); + + template + inline _xmat3 operator/ (const _xmat3& m1, const _xmat3& m2); + + // Unary constant operators + template + inline const _xmat3 operator- (const _xmat3& m); + + template + inline const _xmat3 operator-- (const _xmat3& m, int); + + template + inline const _xmat3 operator++ (const _xmat3& m, int); + +} //namespace detail +} //namespace glm + +#endif //__xmat3_h__ diff --git a/wip/sse/glm/core/_xmat3.inl b/wip/sse/glm/core/_xmat3.inl new file mode 100644 index 00000000..ff7e99b0 --- /dev/null +++ b/wip/sse/glm/core/_xmat3.inl @@ -0,0 +1,546 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-27 +// Updated : 2007-03-01 +// Licence : This source is under GNU LGPL licence +// File : _xmat3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xmat3_inl__ +#define __xmat3_inl__ + +#include "./_xmat3.h" +#include "./_func.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat3::size_type _xmat3::value_size = 3; + template const typename _xmat3::size_type _xmat3::col_size = 3; + template const typename _xmat3::size_type _xmat3::row_size = 3; + + ////////////////////////////////////////////////////////////// + // mat3 constructors + + template + inline _xmat3::_xmat3() + { + this->value[0] = _xvec3(1, 0, 0); + this->value[1] = _xvec3(0, 1, 0); + this->value[2] = _xvec3(0, 0, 1); + } + + template + inline _xmat3::_xmat3(const T f) + { + this->value[0] = _xvec3(f, 0, 0); + this->value[1] = _xvec3(0, f, 0); + this->value[2] = _xvec3(0, 0, f); + } + + template + inline _xmat3::_xmat3 + ( + const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1, + const T x2, const T y2, const T z2 + ) + { + this->value[0] = _xvec3(x0, y0, z0); + this->value[1] = _xvec3(x1, y1, z1); + this->value[2] = _xvec3(x2, y2, z2); + } + + template + inline _xmat3::_xmat3 + ( + const _xvec3& v0, + const _xvec3& v1, + const _xvec3& v2 + ) + { + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; + } + + ////////////////////////////////////////////////////////////// + // mat3 conversions + + template + template + inline _xmat3::_xmat3(const _xmat3& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(m[2]); + } + + template + inline _xmat3::_xmat3(const _xmat2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + this->value[2] = _xvec3(_xvec2(0), T(1)); + } + + template + inline _xmat3::_xmat3(const _xmat4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(m[2]); + } + + template + inline _xmat3::_xmat3(const _xmat2x3& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = _xvec3(_xvec2(0), T(1)); + } + + template + inline _xmat3::_xmat3(const _xmat3x2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + this->value[2] = _xvec3(m[2], T(1)); + } + + template + inline _xmat3::_xmat3(const _xmat2x4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(_xvec2(0), T(1)); + } + + template + inline _xmat3::_xmat3(const _xmat4x2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + this->value[2] = _xvec3(m[2], T(1)); + } + + template + inline _xmat3::_xmat3(const _xmat3x4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(m[2]); + } + + template + inline _xmat3::_xmat3(const _xmat4x3& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + } + +/* + template + inline _xmat3::_xmat3(const T* a) + { + this->value[0] = _xvec3(a[0], a[1], a[2]); + this->value[1] = _xvec3(a[3], a[4], a[5]); + this->value[2] = _xvec3(a[6], a[7], a[8]); + } +*/ + /* + // GL_GTX_euler_angles + template + inline _xmat3::_xmat3(const _xvec3 & angles) + { + T ch = cos(angles.x); + T sh = sin(angles.x); + T cp = cos(angles.y); + T sp = sin(angles.y); + T cb = cos(angles.z); + T sb = sin(angles.z); + + value[0][0] = ch * cb + sh * sp * sb; + value[0][1] = sb * cp; + value[0][2] = -sh * cb + ch * sp * sb; + value[1][0] = -ch * sb + sh * sp * cb; + value[1][1] = cb * cp; + value[1][2] = sb * sh + ch * sp * cb; + value[2][0] = sh * cp; + value[2][1] = -sp; + value[2][2] = ch * cp; + } + */ + ////////////////////////////////////////////////////////////// + // mat3 conversions + /* + template + inline _xmat3::_xmat3(const _xquat & q) + { + this->value[0][0] = 1 - 2 * q.y * q.y - 2 * q.z * q.z; + this->value[0][1] = 2 * q.x * q.y + 2 * q.w * q.z; + this->value[0][2] = 2 * q.x * q.z - 2 * q.w * q.y; + + this->value[1][0] = 2 * q.x * q.y - 2 * q.w * q.z; + this->value[1][1] = 1 - 2 * q.x * q.x - 2 * q.z * q.z; + this->value[1][2] = 2 * q.y * q.z + 2 * q.w * q.x; + + this->value[2][0] = 2 * q.x * q.z + 2 * q.w * q.y; + this->value[2][1] = 2 * q.y * q.z - 2 * q.w * q.x; + this->value[2][2] = 1 - 2 * q.x * q.x - 2 * q.y * q.y; + } + */ + ////////////////////////////////////////////////////////////// + // mat3 operators + + template + inline _xmat3& _xmat3::operator=(const _xmat3& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + return *this; + } + + template + inline _xmat3& _xmat3::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + this->value[2] += s; + return *this; + } + + template + inline _xmat3& _xmat3::operator+= (const _xmat3& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + this->value[2] += m[2]; + return *this; + } + + template + inline _xmat3& _xmat3::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + this->value[2] -= s; + return *this; + } + + template + inline _xmat3& _xmat3::operator-= (const _xmat3& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + this->value[2] -= m[2]; + return *this; + } + + template + inline _xmat3& _xmat3::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + this->value[2] *= s; + return *this; + } + + template + inline _xmat3& _xmat3::operator*= (const _xmat3& m) + { + return (*this = *this * m); + } + + template + inline _xmat3& _xmat3::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + this->value[2] /= s; + return *this; + } + + template + inline _xmat3& _xmat3::operator/= (const _xmat3& m) + { + return (*this = *this / m); + } + + template + inline _xmat3& _xmat3::operator++ () + { + this->value[0]++; + this->value[1]++; + this->value[2]++; + return *this; + } + + template + inline _xmat3& _xmat3::operator-- () + { + this->value[0]--; + this->value[1]--; + this->value[2]--; + return *this; + } + + template + inline _xmat3 _xmat3::_inverse() const + { + T S00 = value[0][0]; + T S01 = value[0][1]; + T S02 = value[0][2]; + + T S10 = value[1][0]; + T S11 = value[1][1]; + T S12 = value[1][2]; + + T S20 = value[2][0]; + T S21 = value[2][1]; + T S22 = value[2][2]; + + _xmat3 Inverse( + + (S11 * S22 - S21 * S12), + - (S10 * S22 - S20 * S12), + + (S10 * S21 - S20 * S11), + - (S01 * S22 - S21 * S02), + + (S00 * S22 - S20 * S02), + - (S00 * S21 - S20 * S01), + + (S01 * S12 - S11 * S02), + - (S00 * S12 - S10 * S02), + + (S00 * S11 - S10 * S01)); + + T Determinant = S00 * (S11 * S22 - S21 * S12) + - S10 * (S01 * S22 - S21 * S02) + + S20 * (S01 * S12 - S11 * S02); + + Inverse /= Determinant; + return Inverse; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat3 operator+ (const _xmat3& m, const T s) + { + return _xmat3( + m[0] + s, + m[1] + s, + m[2] + s); + } + + template + inline _xmat3 operator+ (const T s, const _xmat3& m) + { + return _xmat3( + m[0] + s, + m[1] + s, + m[2] + s); + } + + template + inline _xvec3 operator+ (const _xmat3& m, const _xvec3& v) + { + + } + + template + inline _xvec3 operator+ (const _xvec3& v, const _xmat3& m) + { + + } + + template + inline _xmat3 operator+ (const _xmat3& m1, const _xmat3& m2) + { + return _xmat3( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2]); + } + + template + inline _xmat3 operator- (const _xmat3& m, const T s) + { + return _xmat3( + m[0] - s, + m[1] - s, + m[2] - s); + } + + template + inline _xmat3 operator- (const T s, const _xmat3& m) + { + return _xmat3( + s - m[0], + s - m[1], + s - m[2]); + } + + template + inline _xvec3 operator- (const _xmat3& m, const _xvec3& v) + { + + } + + template + inline _xvec3 operator- (const _xvec3& v, const _xmat3& m) + { + + } + + template + inline _xmat3 operator- (const _xmat3& m1, const _xmat3& m2) + { + return _xmat3( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2]); + } + + template + inline _xmat3 operator* (const _xmat3& m, const T s) + { + return _xmat3( + m[0] * s, + m[1] * s, + m[2] * s); + } + + template + inline _xmat3 operator* (const T s, const _xmat3& m) + { + return _xmat3( + m[0] * s, + m[1] * s, + m[2] * s); + } + + template + inline _xvec3 operator* (const _xmat3& m, const _xvec3& v) + { + return _xvec3( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z, + m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z); + } + + template + inline _xvec3 operator* (const _xvec3& v, const _xmat3& m) + { + return _xvec3( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z); + } + + template + inline _xmat3 operator* (const _xmat3& m1, const _xmat3& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA02 = m1[0][2]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA12 = m1[1][2]; + const T SrcA20 = m1[2][0]; + const T SrcA21 = m1[2][1]; + const T SrcA22 = m1[2][2]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB02 = m2[0][2]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB12 = m2[1][2]; + const T SrcB20 = m2[2][0]; + const T SrcB21 = m2[2][1]; + const T SrcB22 = m2[2][2]; + + _xmat3 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02; + Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01 + SrcA22 * SrcB02; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12; + Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11 + SrcA22 * SrcB12; + Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21 + SrcA20 * SrcB22; + Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21 + SrcA21 * SrcB22; + Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21 + SrcA22 * SrcB22; + return Result; + } + + + template + inline _xmat3 operator/ (const _xmat3& m, const T s) + { + return _xmat3( + m[0] / s, + m[1] / s, + m[2] / s); + } + + template + inline _xmat3 operator/ (const T s, const _xmat3& m) + { + return _xmat3( + s / m[0], + s / m[1], + s / m[2]); + } + + template + inline _xvec3 operator/ (const _xmat3& m, const _xvec3& v) + { + return m._inverse() * v; + } + + template + inline _xvec3 operator/ (const _xvec3& v, const _xmat3& m) + { + return v * m._inverse(); + } + + template + inline _xmat3 operator/ (const _xmat3& m1, const _xmat3& m2) + { + return m1 * m2._inverse(); + } + + // Unary constant operators + template + inline const _xmat3 operator- (const _xmat3& m) + { + return _xmat3( + -m.value[0], + -m.value[1], + -m.value[2]); + } + + template + inline const _xmat3 operator-- (const _xmat3& m, int) + { + return _xmat3( + m.value[0] - T(1), + m.value[1] - T(1), + m.value[2] - T(1)); + } + + template + inline const _xmat3 operator++ (const _xmat3& m, int) + { + return _xmat3( + m.value[0] + T(1), + m.value[1] + T(1), + m.value[2] + T(1)); + } + +} //namespace detail +} //namespace glm + +#endif //__xmat3_inl__ diff --git a/wip/sse/glm/core/_xmat3x2.h b/wip/sse/glm/core/_xmat3x2.h new file mode 100644 index 00000000..488aeef2 --- /dev/null +++ b/wip/sse/glm/core/_xmat3x2.h @@ -0,0 +1,145 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-05 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat3x2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat3x2_h__ +#define __mat3x2_h__ + +namespace glm{ +namespace detail{ + + template class _xvec2; + template class _xvec3; + template class _xvec4; + template class _xmat2; + template class _xmat3; + template class _xmat4; + template class _xmat2x3; + template class _xmat2x4; + template class _xmat3x4; + template class _xmat4x2; + template class _xmat4x3; + + //!< \brief Template for 3 * 2 matrix of floating-point numbers. + template + class _xmat3x2 + { + private: + // Data + _xvec2 value[3]; + + public: + typedef T value_type; + typedef _xvec3 col_type; + typedef _xvec2 row_type; + typedef int size_type; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat3x2(); + explicit _xmat3x2(const T x); + explicit _xmat3x2( + const T x0, const T y0, + const T x1, const T y1, + const T x2, const T y2); + explicit _xmat3x2( + const _xvec2& v0, + const _xvec2& v1, + const _xvec2& v2); + + // Conversion + template + explicit _xmat3x2(const _xmat3x2& m); + + explicit _xmat3x2(const _xmat2& x); + explicit _xmat3x2(const _xmat3& x); + explicit _xmat3x2(const _xmat4& x); + explicit _xmat3x2(const _xmat2x3& x); + explicit _xmat3x2(const _xmat2x4& x); + explicit _xmat3x2(const _xmat3x4& x); + explicit _xmat3x2(const _xmat4x2& x); + explicit _xmat3x2(const _xmat4x3& x); + + // Accesses + _xvec2& operator[](int i) {return value[i];} + const _xvec2 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat3x2& operator= (const _xmat3x2& m); + _xmat3x2& operator+= (const T s); + _xmat3x2& operator+= (const _xmat3x2& m); + _xmat3x2& operator-= (const T s); + _xmat3x2& operator-= (const _xmat3x2& m); + _xmat3x2& operator*= (const T s); + _xmat3x2& operator*= (const _xmat2x3& m); + _xmat3x2& operator/= (const T s); +/* ToDo + _xmat3x2& operator/= (const _xmat2x3& m); +*/ + _xmat3x2& operator++ (); + _xmat3x2& operator-- (); + + // Unary constant operators + const _xmat3x2 operator- () const; + const _xmat3x2 operator++ (int n) const; + const _xmat3x2 operator-- (int n) const; + }; + + // Binary operators + template + _xmat3x2 operator+ (const _xmat3x2& m, const T s); + + template + _xmat3x2 operator+ (const _xmat3x2& m1, const _xmat3x2& m2); + + template + _xmat3x2 operator- (const _xmat3x2& m, const T s); + + template + _xmat3x2 operator- (const _xmat3x2& m1, const _xmat3x2& m2); + + template + _xmat3x2 operator* (const _xmat3x2& m, const T s); + + template + _xmat3x2 operator* (const T s, const _xmat3x4& m); + + template + _xvec2 operator* (const _xmat3x2& m, const _xvec3& v); + + template + _xvec3 operator* (const _xvec2& v, const _xmat3x2& m); + + template + _xmat2 operator* (const _xmat3x2& m1, const _xmat2x3& m2); + + template + _xmat2x3 operator/ (const _xmat2x3& m, const T s); + + template + _xmat2x3 operator/ (const T s, const _xmat2x3& m); +/* ToDo + template + _xvec2 operator/ (const _xmat3x2& m, const _xvec3& v); + + template + _xvec3 operator/ (const _xvec2& v, const _xmat3x2& m); + + template + _xmat2 operator/ (const _xmat2x3& m1, const _xmat3x2& m2); +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat3x2_h__ diff --git a/wip/sse/glm/core/_xmat3x2.inl b/wip/sse/glm/core/_xmat3x2.inl new file mode 100644 index 00000000..1414c681 --- /dev/null +++ b/wip/sse/glm/core/_xmat3x2.inl @@ -0,0 +1,451 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-05 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat3x2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat3x2_inl__ +#define __mat3x2_inl__ + +#include "./_xmat3x2.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat3x2::size_type _xmat3x2::col_size = 3; + template const typename _xmat3x2::size_type _xmat3x2::row_size = 2; + + ////////////////////////////////////////////////////////////// + // Constructors + + template + inline _xmat3x2::_xmat3x2() + { + this->value[0] = _xvec2(1, 0); + this->value[1] = _xvec2(0, 1); + this->value[2] = _xvec2(0, 0); + } + + template + inline _xmat3x2::_xmat3x2(const T f) + { + this->value[0] = _xvec2(f, 0); + this->value[1] = _xvec2(0, f); + this->value[2] = _xvec2(0, 0); + } + + template + inline _xmat3x2::_xmat3x2 + ( + const T x0, const T y0, + const T x1, const T y1, + const T x2, const T y2 + ) + { + this->value[0] = _xvec2(x0, y0); + this->value[1] = _xvec2(x1, y1); + this->value[2] = _xvec2(x2, y2); + } + + template + inline _xmat3x2::_xmat3x2 + ( + const _xvec2 & v0, + const _xvec2 & v1, + const _xvec2 & v2 + ) + { + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; + } + + // Conversion + template + template + inline _xmat3x2::_xmat3x2(const _xmat3x2& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + } + + template + inline _xmat3x2::_xmat3x2(const _xmat2& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = _xvec2(T(0)); + } + + template + inline _xmat3x2::_xmat3x2(const _xmat3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + } + + template + inline _xmat3x2::_xmat3x2(const _xmat4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + } + + template + inline _xmat3x2::_xmat3x2(const _xmat2x3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(T(0)); + } + + template + inline _xmat3x2::_xmat3x2(const _xmat2x4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(T(0)); + } + + template + inline _xmat3x2::_xmat3x2(const _xmat3x4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + } + + template + inline _xmat3x2::_xmat3x2(const _xmat4x2& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + } + + template + inline _xmat3x2::_xmat3x2(const _xmat4x3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + } + + ////////////////////////////////////////////////////////////// + // Unary updatable operators + + template + inline _xmat3x2& _xmat3x2::operator= (const _xmat3x2& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + return *this; + } + + template + inline _xmat3x2& _xmat3x2::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + this->value[2] += s; + return *this; + } + + template + inline _xmat3x2& _xmat3x2::operator+= (const _xmat3x2& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + this->value[2] += m[2]; + return *this; + } + + template + inline _xmat3x2& _xmat3x2::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + this->value[2] -= s; + return *this; + } + + template + inline _xmat3x2& _xmat3x2::operator-= (const _xmat3x2& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + this->value[2] -= m[2]; + return *this; + } + + template + inline _xmat3x2& _xmat3x2::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + this->value[2] *= s; + return *this; + } + + template + inline _xmat3x2& _xmat3x2::operator*= (const _xmat2x3& m) + { + return (*this = _xmat3x2(*this * m)); + } + + template + inline _xmat3x2 & _xmat3x2::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + this->value[2] /= s; + return *this; + } +/* ToDo + template + inline _xmat3x2& _xmat3x2::operator/= (const _xmat3x2& m) + { + return (*this = _xmat3x2(*this / m)); + } +*/ + template + inline _xmat3x2& _xmat3x2::operator++ () + { + ++this->value[0]; + ++this->value[1]; + ++this->value[2]; + return *this; + } + + template + inline _xmat3x2& _xmat3x2::operator-- () + { + --this->value[0]; + --this->value[1]; + --this->value[2]; + return *this; + } +/* + template + inline _xmat3x2 _xmat3x2::_inverse() const + { + T S00 = value[0][0]; + T S01 = value[0][1]; + + T S10 = value[1][0]; + T S11 = value[1][1]; + + T S20 = value[2][0]; + T S21 = value[2][1]; + + _xmat3x2 Inverse( + + (S11 * S22 - S21 * S12), + - (S10 * S22 - S20 * S12), + + (S10 * S21 - S20 * S11), + - (S01 * S22 - S21 * S02), + + (S00 * S22 - S20 * S02), + - (S00 * S21 - S20 * S01), + + (S01 * S12 - S11 * S02), + - (S00 * S12 - S10 * S02), + + (S00 * S11 - S10 * S01)); + + T Determinant = S00 * (S11 * S22 - S21 * S12) + - S10 * (S01 * S22 - S21 * S02) + + S20 * (S01 * S12 - S11 * S02); + + Inverse /= Determinant; + return Inverse; + } + + template + inline _xmat2 _xmat2::_inverse() const + { + T Determinant = value[0][0] * value[1][1] - value[1][0] * value[0][1]; + + _xmat2 Inverse( + + value[1][1] / Determinant, + - value[1][0] / Determinant, + - value[0][1] / Determinant, + + value[0][0] / Determinant); + return Inverse; + } +*/ + ////////////////////////////////////////////////////////////// + // Unary constant operators + template + inline const _xmat3x2 _xmat3x2::operator- () const + { + return _xmat3x2( + -this->value[0], + -this->value[1], + -this->value[2]); + } + + template + inline const _xmat3x2 _xmat3x2::operator-- (int n) const + { + _xmat3x2 m = *this; + --m.value[0]; + --m.value[1]; + --m.value[2]; + return m; + } + + template + inline const _xmat3x2 _xmat3x2::operator++ (int n) const + { + _xmat3x2 m = *this; + ++m.value[0]; + ++m.value[1]; + ++m.value[2]; + return m; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat3x2 operator+ (const _xmat3x2& m, const T s) + { + return _xmat3x2( + m[0] + s, + m[1] + s, + m[2] + s); + } + + template + inline _xmat3x2 operator+ (const _xmat3x2& m1, const _xmat3x2& m2) + { + return _xmat3x2( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2]); + } + + template + inline _xmat3x2 operator- (const _xmat3x2& m, const T s) + { + return _xmat3x4( + m[0] - s, + m[1] - s, + m[2] - s); + } + + template + inline _xmat3x2 operator- (const _xmat3x2& m1, const _xmat3x2& m2) + { + return _xmat3x2( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2]); + } + + template + inline _xmat3x2 operator* (const _xmat3x2& m, const T s) + { + return _xmat3x2( + m[0] * s, + m[1] * s, + m[2] * s); + } + + template + inline _xmat3x2 operator* (const T s, const _xmat3x2 & m) + { + return _xmat3x2( + m[0] * s, + m[1] * s, + m[2] * s); + } + + template + inline _xvec2 operator* (const _xmat3x2& m, const _xvec3& v) + { + return _xvec2( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z); + } + + template + inline _xvec3 operator* (const _xvec2& v, const _xmat3x2& m) + { + return _xvec3( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w); + } + + template + inline _xmat2 operator* (const _xmat3x2& m1, const _xmat2x3& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA20 = m1[2][0]; + const T SrcA21 = m1[2][1]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB02 = m2[0][2]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB12 = m2[1][2]; + + _xmat2 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA01 * SrcB01 + SrcA20 * SrcB02; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12; + return Result; + } + + template + inline _xmat3x2 operator/ (const _xmat3x2& m, const T s) + { + return _xmat3x2( + m.value[0] / s, + m.value[1] / s, + m.value[2] / s, + m.value[3] / s); + } + + template + inline _xmat3x2 operator/ (const T s, const _xmat3x2& m) + { + return _xmat3x2( + s / m.value[0], + s / m.value[1], + s / m.value[2], + s / m.value[3]); + } +/* ToDo + template + inline _xvec3 operator/ (const _xmat3x2& m, const _xvec2& v) + { + + } + + template + inline _xvec3 operator/ (const _xvec2& v, const _xmat3x2& m) + { + + } + + template + inline _xmat2 operator/ (const _xmat3x2& m1, const _xmat3x2& m2) + { + + } +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat3x2_inl__ diff --git a/wip/sse/glm/core/_xmat3x4.h b/wip/sse/glm/core/_xmat3x4.h new file mode 100644 index 00000000..6d40abbb --- /dev/null +++ b/wip/sse/glm/core/_xmat3x4.h @@ -0,0 +1,145 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-05 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat3x4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat3x4_h__ +#define __mat3x4_h__ + +namespace glm{ +namespace detail{ + + template class _xvec2; + template class _xvec3; + template class _xvec4; + template class _xmat2; + template class _xmat3; + template class _xmat4; + template class _xmat2x3; + template class _xmat3x2; + template class _xmat2x4; + template class _xmat4x2; + template class _xmat4x3; + + //!< \brief Template for 3 * 4 matrix of floating-point numbers. + template + class _xmat3x4 + { + private: + // Data + _xvec4 value[3]; + + public: + typedef T value_type; + typedef _xvec3 col_type; + typedef _xvec4 row_type; + typedef int size_type; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat3x4(); + explicit _xmat3x4(const T x); + explicit _xmat3x4( + const T x0, const T y0, const T z0, const T w0, + const T x1, const T y1, const T z1, const T w1, + const T x2, const T y2, const T z2, const T w2); + explicit _xmat3x4( + const _xvec4& v0, + const _xvec4& v1, + const _xvec4& v2); + + // Conversion + template + explicit _xmat3x4(const _xmat3x4& m); + + explicit _xmat3x4(const _xmat2& x); + explicit _xmat3x4(const _xmat3& x); + explicit _xmat3x4(const _xmat4& x); + explicit _xmat3x4(const _xmat2x3& x); + explicit _xmat3x4(const _xmat3x2& x); + explicit _xmat3x4(const _xmat2x4& x); + explicit _xmat3x4(const _xmat4x2& x); + explicit _xmat3x4(const _xmat4x3& x); + + // Accesses + _xvec4& operator[](int i) {return value[i];} + const _xvec4 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat3x4& operator= (const _xmat3x4& m); + _xmat3x4& operator+= (const T s); + _xmat3x4& operator+= (const _xmat3x4& m); + _xmat3x4& operator-= (const T s); + _xmat3x4& operator-= (const _xmat3x4& m); + _xmat3x4& operator*= (const T s); + _xmat3x4& operator*= (const _xmat4x3& m); + _xmat3x4& operator/= (const T s); +/* ToDo + _xmat3x4& operator/= (const _xmat4x3& m); +*/ + _xmat3x4& operator++ (); + _xmat3x4& operator-- (); + + // Unary constant operators + const _xmat3x4 operator- () const; + const _xmat3x4 operator++ (int n) const; + const _xmat3x4 operator-- (int n) const; + }; + + // Binary operators + template + _xmat3x4 operator+ (const _xmat3x4& m, const T s); + + template + _xmat3x4 operator+ (const _xmat3x4& m1, const _xmat3x4& m2); + + template + _xmat3x4 operator- (const _xmat3x4& m, const T s); + + template + _xmat3x4 operator- (const _xmat3x4& m1, const _xmat3x4& m2); + + template + _xmat3x4 operator* (const _xmat3x4& m, const T s); + + template + _xmat3x4 operator* (const T s, const _xmat3x4& m); + + template + _xvec4 operator* (const _xmat3x4& m, const _xvec3& v); + + template + _xvec3 operator* (const _xvec4& v, const _xmat3x4& m); + + template + _xmat4 operator* (const _xmat3x4& m1, const _xmat4x3& m2); + + template + _xmat4x3 operator/ (const _xmat4x3& m, const T s); + + template + _xmat4x3 operator/ (const T s, const _xmat4x3& m); +/* ToDo + template + _xvec4 operator/ (const _xmat3x4& m, const _xvec3& v); + + template + _xvec3 operator/ (const _xvec4& v, const _xmat3x4& m); + + template + _xmat4 operator/ (const _xmat4x3& m1, const _xmat3x4& m2); +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat3x4_h__ diff --git a/wip/sse/glm/core/_xmat3x4.inl b/wip/sse/glm/core/_xmat3x4.inl new file mode 100644 index 00000000..e504c5ce --- /dev/null +++ b/wip/sse/glm/core/_xmat3x4.inl @@ -0,0 +1,434 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-05 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat3x4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat3x4_inl__ +#define __mat3x4_inl__ + +#include "./_xmat3x4.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat3x4::size_type _xmat3x4::col_size = 3; + template const typename _xmat3x4::size_type _xmat3x4::row_size = 4; + + ////////////////////////////////////////////////////////////// + // Constructors + + template + inline _xmat3x4::_xmat3x4() + { + this->value[0] = _xvec4(1, 0, 0, 0); + this->value[1] = _xvec4(0, 1, 0, 0); + this->value[2] = _xvec4(0, 0, 1, 0); + } + + template + inline _xmat3x4::_xmat3x4(const T f) + { + this->value[0] = _xvec4(f, 0, 0, 0); + this->value[1] = _xvec4(0, f, 0, 0); + this->value[2] = _xvec4(0, 0, f, 0); + } + + template + inline _xmat3x4::_xmat3x4 + ( + const T x0, const T y0, const T z0, const T w0, + const T x1, const T y1, const T z1, const T w1, + const T x2, const T y2, const T z2, const T w2 + ) + { + this->value[0] = _xvec4(x0, y0, z0, w0); + this->value[1] = _xvec4(x1, y1, z1, w1); + this->value[2] = _xvec4(x2, y2, z2, w2); + } + + template + inline _xmat3x4::_xmat3x4 + ( + const _xvec4 & v0, + const _xvec4 & v1, + const _xvec4 & v2 + ) + { + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; + } + + // Conversion + template + template + inline _xmat3x4::_xmat3x4(const _xmat3x4& m) + { + this->value[0] = _xvec4(m[0]); + this->value[1] = _xvec4(m[1]); + this->value[2] = _xvec4(m[2]); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + this->value[2] = _xvec4(T(0), T(0), T(1), T(0)); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + this->value[2] = _xvec4(m[2], T(0)); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat4& m) + { + this->value[0] = _xvec4(m[0]); + this->value[1] = _xvec4(m[1]); + this->value[2] = _xvec4(m[2]); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat2x3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + this->value[2] = _xvec4(T(0), T(0), T(1), T(0)); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat3x2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + this->value[2] = _xvec4(m[2], T(0), T(1)); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat2x4& m) + { + this->value[0] = _xvec4(m[0]); + this->value[1] = _xvec4(m[1]); + this->value[2] = _xvec4(T(0), T(0), T(1), T(0)); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat4x2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(T(0))); + this->value[1] = _xvec4(m[1], _xvec2(T(0))); + this->value[2] = _xvec4(m[2], _xvec2(T(1), T(0))); + } + + template + inline _xmat3x4::_xmat3x4(const _xmat4x3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + this->value[2] = _xvec4(m[2], T(0)); + } + + ////////////////////////////////////////////////////////////// + // Unary updatable operators + + template + inline _xmat3x4& _xmat3x4::operator= (const _xmat3x4& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + return *this; + } + + template + inline _xmat3x4& _xmat3x4::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + this->value[2] += s; + return *this; + } + + template + inline _xmat3x4& _xmat3x4::operator+= (const _xmat3x4& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + this->value[2] += m[2]; + return *this; + } + + template + inline _xmat3x4& _xmat3x4::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + this->value[2] -= s; + return *this; + } + + template + inline _xmat3x4& _xmat3x4::operator-= (const _xmat3x4& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + this->value[2] -= m[2]; + return *this; + } + + template + inline _xmat3x4& _xmat3x4::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + this->value[2] *= s; + return *this; + } + + template + inline _xmat3x4& _xmat3x4::operator*= (const _xmat4x3& m) + { + return (*this = _xmat3x4(*this * m)); + } + + template + inline _xmat3x4 & _xmat3x4::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + this->value[2] /= s; + return *this; + } +/* ToDo + template + inline _xmat3x4& _xmat3x4::operator/= (const _xmat4x3& m) + { + return (*this = _xmat3x4(*this / m)); + } +*/ + template + inline _xmat3x4& _xmat3x4::operator++ () + { + ++this->value[0]; + ++this->value[1]; + ++this->value[2]; + return *this; + } + + template + inline _xmat3x4& _xmat3x4::operator-- () + { + --this->value[0]; + --this->value[1]; + --this->value[2]; + return *this; + } + + ////////////////////////////////////////////////////////////// + // Unary constant operators + template + inline const _xmat3x4 _xmat3x4::operator- () const + { + return _xmat3x4( + -this->value[0], + -this->value[1], + -this->value[2]); + } + + template + inline const _xmat3x4 _xmat3x4::operator-- (int n) const + { + _xmat3x4 m = *this; + --m.value[0]; + --m.value[1]; + --m.value[2]; + return m; + } + + template + inline const _xmat3x4 _xmat3x4::operator++ (int n) const + { + _xmat3x4 m = *this; + ++m.value[0]; + ++m.value[1]; + ++m.value[2]; + return m; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat3x4 operator+ (const _xmat3x4& m, const T s) + { + return _xmat3x4( + m[0] + s, + m[1] + s, + m[2] + s); + } + + template + inline _xmat3x4 operator+ (const _xmat3x4& m1, const _xmat3x4& m2) + { + return _xmat3x4( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2]); + } + + template + inline _xmat3x4 operator- (const _xmat3x4& m, const T s) + { + return _xmat3x4( + m[0] - s, + m[1] - s, + m[2] - s); + } + + template + inline _xmat3x4 operator- (const _xmat3x4& m1, const _xmat3x4& m2) + { + return _xmat3x4( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2]); + } + + template + inline _xmat3x4 operator* (const _xmat3x4& m, const T s) + { + return _xmat3x4( + m[0] * s, + m[1] * s, + m[2] * s); + } + + template + inline _xmat3x4 operator* (const T s, const _xmat3x4 & m) + { + return _xmat3x4( + m[0] * s, + m[1] * s, + m[2] * s); + } + + template + inline _xvec4 operator* (const _xmat3x4& m, const _xvec3& v) + { + return _xvec4( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z, + m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z, + m[0][3] * v.x + m[1][3] * v.y + m[2][3] * v.z); + } + + template + inline _xvec3 operator* (const _xvec4& v, const _xmat3x4& m) + { + return _xvec3( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w, + m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w); + } + + template + inline _xmat4 operator* (const _xmat3x4& m1, const _xmat4x3& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA02 = m1[0][2]; + const T SrcA03 = m1[0][3]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA12 = m1[1][2]; + const T SrcA13 = m1[1][3]; + const T SrcA20 = m1[2][0]; + const T SrcA21 = m1[2][1]; + const T SrcA22 = m1[2][2]; + const T SrcA23 = m1[2][3]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB02 = m2[0][2]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB12 = m2[1][2]; + const T SrcB20 = m2[2][0]; + const T SrcB21 = m2[2][1]; + const T SrcB22 = m2[2][2]; + const T SrcB30 = m2[3][0]; + const T SrcB31 = m2[3][1]; + const T SrcB32 = m2[3][2]; + + _xmat4 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02; + Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01 + SrcA22 * SrcB02; + Result[0][3] = SrcA03 * SrcB00 + SrcA13 * SrcB01 + SrcA23 * SrcB02; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12; + Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11 + SrcA22 * SrcB12; + Result[1][3] = SrcA03 * SrcB10 + SrcA13 * SrcB11 + SrcA23 * SrcB12; + Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21 + SrcA20 * SrcB22; + Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21 + SrcA21 * SrcB22; + Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21 + SrcA22 * SrcB22; + Result[2][3] = SrcA03 * SrcB20 + SrcA13 * SrcB21 + SrcA23 * SrcB22; + Result[3][0] = SrcA00 * SrcB30 + SrcA10 * SrcB31 + SrcA20 * SrcB32; + Result[3][1] = SrcA01 * SrcB30 + SrcA11 * SrcB31 + SrcA21 * SrcB32; + Result[3][2] = SrcA02 * SrcB30 + SrcA12 * SrcB31 + SrcA22 * SrcB32; + Result[3][3] = SrcA03 * SrcB30 + SrcA13 * SrcB31 + SrcA23 * SrcB32; + return Result; + } + + template + inline _xmat3x4 operator/ (const _xmat3x4& m, const T s) + { + return _xmat3x4( + m.value[0] / s, + m.value[1] / s, + m.value[2] / s, + m.value[3] / s); + } + + template + inline _xmat3x4 operator/ (const T s, const _xmat3x4& m) + { + return _xmat3x4( + s / m.value[0], + s / m.value[1], + s / m.value[2], + s / m.value[3]); + } +/* ToDo + template + inline _xvec3 operator/ (const _xmat4x3& m, const _xvec4& v) + { + + } + + template + inline _xvec3 operator/ (const _xvec4& v, const _xmat4x3& m) + { + + } + + template + inline _xmat4 operator/ (const _xmat3x4& m1, const _xmat4x3& m2) + { + + } +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat3x4_inl__ diff --git a/wip/sse/glm/core/_xmat4.h b/wip/sse/glm/core/_xmat4.h new file mode 100644 index 00000000..a26e8874 --- /dev/null +++ b/wip/sse/glm/core/_xmat4.h @@ -0,0 +1,178 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-27 +// Updated : 2007-03-01 +// Licence : This source is under GNU LGPL licence +// File : _xmat4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xmat4_h__ +#define __xmat4_h__ + +namespace glm{ +namespace detail{ + + template class _xvec3; + template class _xvec4; + template class _xquat; + + template class _xmat2; + template class _xmat3; + template class _xmat2x4; + template class _xmat2x3; + template class _xmat3x2; + template class _xmat3x4; + template class _xmat4x2; + template class _xmat4x3; + + //!< \brief Template for 4 * 4 matrix of floating-point numbers. + template + class _xmat4 + { + private: + // Data + _xvec4 value[4]; + + public: + typedef T value_type; + typedef _xvec4 col_type; + typedef _xvec4 row_type; + typedef int size_type; + static const size_type value_size; + static const size_type col_size; + static const size_type row_size; + + _xmat4 _inverse() const; + + public: + // Constructors + _xmat4(); + explicit _xmat4(const T x); + explicit _xmat4( + const T x0, const T y0, const T z0, const T w0, + const T x1, const T y1, const T z1, const T w1, + const T x2, const T y2, const T z2, const T w2, + const T x3, const T y3, const T z3, const T w3); + explicit _xmat4(const _xvec4 & v0, + const _xvec4 & v1, + const _xvec4 & v2, + const _xvec4 & v3); + + // Conversions + template + explicit _xmat4(const _xmat4& m); + + explicit _xmat4(const _xmat2& x); + explicit _xmat4(const _xmat3& x); + explicit _xmat4(const _xmat2x3& x); + explicit _xmat4(const _xmat3x2& x); + explicit _xmat4(const _xmat2x4& x); + explicit _xmat4(const _xmat4x2& x); + explicit _xmat4(const _xmat3x4& x); + explicit _xmat4(const _xmat4x3& x); + + //explicit _xmat4(const T* a); + // GL_GTX_euler_angles + //explicit _xmat4(const _xvec3 & angle); + + // Conversion + //explicit _xmat4(const glm::_xquat & q); + + // Accesses + _xvec4& operator[](int i) {return value[i];} + const _xvec4 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat4& operator= (const _xmat4& m); + _xmat4& operator+= (const T s); + _xmat4& operator+= (const _xmat4& m); + _xmat4& operator-= (const T s); + _xmat4& operator-= (const _xmat4& m); + _xmat4& operator*= (const T s); + _xmat4& operator*= (const _xmat4& m); + _xmat4& operator/= (const T s); + _xmat4& operator/= (const _xmat4& m); + _xmat4& operator++ (); + _xmat4& operator-- (); + }; + + // Binary operators + template + inline _xmat4 operator+ (const _xmat4& m, const T s); + + template + inline _xmat4 operator+ (const T s, const _xmat4& m); + + template + inline _xvec4 operator+ (const _xmat4& m, const _xvec4& v); + + template + inline _xvec4 operator+ (const _xvec4& v, const _xmat4& m); + + template + inline _xmat4 operator+ (const _xmat4& m1, const _xmat4& m2); + + template + inline _xmat4 operator- (const _xmat4& m, const T s); + + template + inline _xmat4 operator- (const T s, const _xmat4& m); + + template + inline _xvec4 operator- (const _xmat4& m, const _xvec4& v); + + template + inline _xvec4 operator- (const _xvec4& v, const _xmat4& m); + + template + inline _xmat4 operator- (const _xmat4& m1, const _xmat4& m2); + + template + inline _xmat4 operator* (const _xmat4& m, const T s); + + template + inline _xmat4 operator* (const T s, const _xmat4& m); + + template + inline _xvec4 operator* (const _xmat4& m, const _xvec4& v); + + template + inline _xvec4 operator* (const _xvec4& v, const _xmat4& m); + + template + inline _xmat4 operator* (const _xmat4& m1, const _xmat4& m2); + + template + inline _xmat4 operator/ (const _xmat4& m, const T s); + + template + inline _xmat4 operator/ (const T s, const _xmat4& m); + + template + inline _xvec4 operator/ (const _xmat4& m, const _xvec4& v); + + template + inline _xvec4 operator/ (const _xvec4& v, const _xmat4& m); + + template + inline _xmat4 operator/ (const _xmat4& m1, const _xmat4& m2); + + // Unary constant operators + template + inline const _xmat4 operator- (const _xmat4& m); + + template + inline const _xmat4 operator-- (const _xmat4& m, int); + + template + inline const _xmat4 operator++ (const _xmat4& m, int); + +} //namespace detail +} //namespace glm + +#endif //__xmat4_h__ diff --git a/wip/sse/glm/core/_xmat4.inl b/wip/sse/glm/core/_xmat4.inl new file mode 100644 index 00000000..9e34945b --- /dev/null +++ b/wip/sse/glm/core/_xmat4.inl @@ -0,0 +1,633 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-27 +// Updated : 2007-03-01 +// Licence : This source is under GNU LGPL licence +// File : _xmat4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat4_inl__ +#define __mat4_inl__ + +#include "./_xmat4.h" +#include "./_func.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat4::size_type _xmat4::value_size = 4; + template const typename _xmat4::size_type _xmat4::col_size = 4; + template const typename _xmat4::size_type _xmat4::row_size = 4; + + ////////////////////////////////////////////////////////////// + // mat4 constructors + + template + inline _xmat4::_xmat4() + { + this->value[0] = _xvec4(1, 0, 0, 0); + this->value[1] = _xvec4(0, 1, 0, 0); + this->value[2] = _xvec4(0, 0, 1, 0); + this->value[3] = _xvec4(0, 0, 0, 1); + } + + template + inline _xmat4::_xmat4(const T f) + { + this->value[0] = _xvec4(f, 0, 0, 0); + this->value[1] = _xvec4(0, f, 0, 0); + this->value[2] = _xvec4(0, 0, f, 0); + this->value[3] = _xvec4(0, 0, 0, f); + } + + template + inline _xmat4::_xmat4 + ( + const T x0, const T y0, const T z0, const T w0, + const T x1, const T y1, const T z1, const T w1, + const T x2, const T y2, const T z2, const T w2, + const T x3, const T y3, const T z3, const T w3 + ) + { + this->value[0] = _xvec4(x0, y0, z0, w0); + this->value[1] = _xvec4(x1, y1, z1, w1); + this->value[2] = _xvec4(x2, y2, z2, w2); + this->value[3] = _xvec4(x3, y3, z3, w3); + } + + template + inline _xmat4::_xmat4 + ( + const _xvec4& v0, + const _xvec4& v1, + const _xvec4& v2, + const _xvec4& v3 + ) + { + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; + this->value[3] = v3; + } + + template + template + inline _xmat4::_xmat4(const _xmat4& m) + { + this->value[0] = _xvec4(m[0]); + this->value[1] = _xvec4(m[1]); + this->value[2] = _xvec4(m[2]); + this->value[3] = _xvec4(m[3]); + } + + template + inline _xmat4::_xmat4(const _xmat2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + this->value[2] = _xvec4(_xvec3(0), T(0)); + this->value[3] = _xvec4(_xvec3(0), T(1)); + } + + template + inline _xmat4::_xmat4(const _xmat3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + this->value[2] = _xvec4(m[2], T(0)); + this->value[3] = _xvec4(_xvec3(0), T(1)); + } + + template + inline _xmat4::_xmat4(const _xmat2x3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + this->value[2] = _xvec4(T(0)); + this->value[3] = _xvec4(_xvec3(0), T(1)); + } + + template + inline _xmat4::_xmat4(const _xmat3x2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + this->value[2] = _xvec4(m[2], _xvec2(0)); + this->value[3] = _xvec4(_xvec3(0), T(1)); + } + + template + inline _xmat4::_xmat4(const _xmat2x4& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = _xvec4(T(0)); + this->value[3] = _xvec4(_xvec3(0), T(1)); + } + + template + inline _xmat4::_xmat4(const _xmat4x2& m) + { + this->value[0] = _xvec4(m[0], _xvec2(0)); + this->value[1] = _xvec4(m[1], _xvec2(0)); + this->value[2] = _xvec4(T(0)); + this->value[3] = _xvec4(_xvec3(0), T(1)); + } + + template + inline _xmat4::_xmat4(const _xmat3x4& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + this->value[3] = _xvec4(_xvec3(0), T(1)); + } + + template + inline _xmat4::_xmat4(const _xmat4x3& m) + { + this->value[0] = _xvec4(m[0], T(0)); + this->value[1] = _xvec4(m[1], T(0)); + this->value[2] = _xvec4(m[2], T(0)); + this->value[3] = _xvec4(m[3], T(1)); + } + +/* + template + inline _xmat4::_xmat4(const T* a) + { + this->value[0] = _xvec4(a[0], a[1], a[2], a[3]); + this->value[1] = _xvec4(a[4], a[5], a[6], a[7]); + this->value[2] = _xvec4(a[8], a[9], a[10], a[11]); + this->value[4] = _xvec4(a[12], a[13], a[14], a[15]); + } +*/ + /* + // GL_GTX_euler_angles + template + inline _xmat4::_xmat4(const _xvec3 & angles) + { + T ch = cos(angles.x); + T sh = sin(angles.x); + T cp = cos(angles.y); + T sp = sin(angles.y); + T cb = cos(angles.z); + T sb = sin(angles.z); + + value[0][0] = ch * cb + sh * sp * sb; + value[0][1] = sb * cp; + value[0][2] = -sh * cb + ch * sp * sb; + value[0][3] = 0.0f; + value[1][0] = -ch * sb + sh * sp * cb; + value[1][1] = cb * cp; + value[1][2] = sb * sh + ch * sp * cb; + value[1][3] = 0.0f; + value[2][0] = sh * cp; + value[2][1] = -sp; + value[2][2] = ch * cp; + value[2][3] = 0.0f; + value[3][0] = 0.0f; + value[3][1] = 0.0f; + value[3][2] = 0.0f; + value[3][3] = 1.0f; + } + */ + ////////////////////////////////////////////////////////////// + // mat4 conversion + /* + template + inline _xmat4::_xmat4(const _xquat & q) + { + *this = _xmat4(1); + this->value[0][0] = 1 - 2 * q.y * q.y - 2 * q.z * q.z; + this->value[0][1] = 2 * q.x * q.y + 2 * q.w * q.z; + this->value[0][2] = 2 * q.x * q.z - 2 * q.w * q.y; + + this->value[1][0] = 2 * q.x * q.y - 2 * q.w * q.z; + this->value[1][1] = 1 - 2 * q.x * q.x - 2 * q.z * q.z; + this->value[1][2] = 2 * q.y * q.z + 2 * q.w * q.x; + + this->value[2][0] = 2 * q.x * q.z + 2 * q.w * q.y; + this->value[2][1] = 2 * q.y * q.z - 2 * q.w * q.x; + this->value[2][2] = 1 - 2 * q.x * q.x - 2 * q.y * q.y; + } + */ + ////////////////////////////////////////////////////////////// + // mat4 operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + template + inline _xmat4& _xmat4::operator= (const _xmat4& m) + { + //memcpy could be faster + //memcpy(&this->value, &m.value, 16 * sizeof(T)); + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + this->value[3] = m[3]; + return *this; + } + + template + inline _xmat4& _xmat4::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + this->value[2] += s; + this->value[3] += s; + return *this; + } + + template + inline _xmat4& _xmat4::operator+= (const _xmat4& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + this->value[2] += m[2]; + this->value[3] += m[3]; + return *this; + } + + template + inline _xmat4& _xmat4::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + this->value[2] -= s; + this->value[3] -= s; + return *this; + } + + template + inline _xmat4& _xmat4::operator-= (const _xmat4& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + this->value[2] -= m[2]; + this->value[3] -= m[3]; + return *this; + } + + template + inline _xmat4& _xmat4::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + this->value[2] *= s; + this->value[3] *= s; + return *this; + } + + template + inline _xmat4& _xmat4::operator*= (const _xmat4& m) + { + return (*this = *this * m); + } + + template + inline _xmat4 & _xmat4::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + this->value[2] /= s; + this->value[3] /= s; + return *this; + } + + template + inline _xmat4& _xmat4::operator/= (const _xmat4& m) + { + return (*this = *this / m); + } + + template + inline _xmat4& _xmat4::operator-- () + { + --this->value[0]; + --this->value[1]; + --this->value[2]; + --this->value[3]; + return *this; + } + + template + inline _xmat4& _xmat4::operator++ () + { + ++this->value[0]; + ++this->value[1]; + ++this->value[2]; + ++this->value[3]; + return *this; + } + + // Private functions + template + inline _xmat4 _xmat4::_inverse() const + { + // Calculate all mat2 determinants + T SubFactor00 = this->value[2][2] * this->value[3][3] - this->value[3][2] * this->value[2][3]; + T SubFactor01 = this->value[2][1] * this->value[3][3] - this->value[3][1] * this->value[2][3]; + T SubFactor02 = this->value[2][1] * this->value[3][2] - this->value[3][1] * this->value[2][2]; + T SubFactor03 = this->value[2][0] * this->value[3][3] - this->value[3][0] * this->value[2][3]; + T SubFactor04 = this->value[2][0] * this->value[3][2] - this->value[3][0] * this->value[2][2]; + T SubFactor05 = this->value[2][0] * this->value[3][1] - this->value[3][0] * this->value[2][1]; + T SubFactor06 = this->value[1][2] * this->value[3][3] - this->value[3][2] * this->value[1][3]; + T SubFactor07 = this->value[1][1] * this->value[3][3] - this->value[3][1] * this->value[1][3]; + T SubFactor08 = this->value[1][1] * this->value[3][2] - this->value[3][1] * this->value[1][2]; + T SubFactor09 = this->value[1][0] * this->value[3][3] - this->value[3][0] * this->value[1][3]; + T SubFactor10 = this->value[1][0] * this->value[3][2] - this->value[3][0] * this->value[1][2]; + T SubFactor11 = this->value[1][1] * this->value[3][3] - this->value[3][1] * this->value[1][3]; + T SubFactor12 = this->value[1][0] * this->value[3][1] - this->value[3][0] * this->value[1][1]; + T SubFactor13 = this->value[1][2] * this->value[2][3] - this->value[2][2] * this->value[1][3]; + T SubFactor14 = this->value[1][1] * this->value[2][3] - this->value[2][1] * this->value[1][3]; + T SubFactor15 = this->value[1][1] * this->value[2][2] - this->value[2][1] * this->value[1][2]; + T SubFactor16 = this->value[1][0] * this->value[2][3] - this->value[2][0] * this->value[1][3]; + T SubFactor17 = this->value[1][0] * this->value[2][2] - this->value[2][0] * this->value[1][2]; + T SubFactor18 = this->value[1][0] * this->value[2][1] - this->value[2][0] * this->value[1][1]; + + _xmat4 Inverse( + + (this->value[1][1] * SubFactor00 - this->value[1][2] * SubFactor01 + this->value[1][3] * SubFactor02), + - (this->value[1][0] * SubFactor00 - this->value[1][2] * SubFactor03 + this->value[1][3] * SubFactor04), + + (this->value[1][0] * SubFactor01 - this->value[1][1] * SubFactor03 + this->value[1][3] * SubFactor05), + - (this->value[1][0] * SubFactor02 - this->value[1][1] * SubFactor04 + this->value[1][2] * SubFactor05), + + - (this->value[0][1] * SubFactor00 - this->value[0][2] * SubFactor01 + this->value[0][3] * SubFactor02), + + (this->value[0][0] * SubFactor00 - this->value[0][2] * SubFactor03 + this->value[0][3] * SubFactor04), + - (this->value[0][0] * SubFactor01 - this->value[0][1] * SubFactor03 + this->value[0][3] * SubFactor05), + + (this->value[0][0] * SubFactor02 - this->value[0][1] * SubFactor04 + this->value[0][2] * SubFactor05), + + + (this->value[0][1] * SubFactor06 - this->value[0][2] * SubFactor07 + this->value[0][3] * SubFactor08), + - (this->value[0][0] * SubFactor06 - this->value[0][2] * SubFactor09 + this->value[0][3] * SubFactor10), + + (this->value[0][0] * SubFactor11 - this->value[0][1] * SubFactor09 + this->value[0][3] * SubFactor12), + - (this->value[0][0] * SubFactor08 - this->value[0][1] * SubFactor10 + this->value[0][2] * SubFactor12), + + - (this->value[0][1] * SubFactor13 - this->value[0][2] * SubFactor14 + this->value[0][3] * SubFactor15), + + (this->value[0][0] * SubFactor13 - this->value[0][2] * SubFactor16 + this->value[0][3] * SubFactor17), + - (this->value[0][0] * SubFactor14 - this->value[0][1] * SubFactor16 + this->value[0][3] * SubFactor18), + + (this->value[0][0] * SubFactor15 - this->value[0][1] * SubFactor17 + this->value[0][2] * SubFactor18)); + + T Determinant = this->value[0][0] * Inverse[0][0] + + this->value[0][1] * Inverse[1][0] + + this->value[0][2] * Inverse[2][0] + + this->value[0][3] * Inverse[3][0]; + + Inverse /= Determinant; + return Inverse; + } + + // Binary operators + template + inline _xmat4 operator+ (const _xmat4& m, const T s) + { + return _xmat4( + m[0] + s, + m[1] + s, + m[2] + s, + m[3] + s); + } + + template + inline _xmat4 operator+ (const T s, const _xmat4& m) + { + return _xmat4( + m[0] + s, + m[1] + s, + m[2] + s, + m[3] + s); + } + + template + inline _xvec4 operator+ (const _xmat4& m, const _xvec4& v) + { + + } + + template + inline _xvec4 operator+ (const _xvec4& v, const _xmat4& m) + { + + } + + template + inline _xmat4 operator+ (const _xmat4& m1, const _xmat4& m2) + { + return _xmat4( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2], + m1[3] + m2[3]); + } + + template + inline _xmat4 operator- (const _xmat4& m, const T s) + { + return _xmat4( + m[0] - s, + m[1] - s, + m[2] - s, + m[3] - s); + } + + template + inline _xmat4 operator- (const T s, const _xmat4& m) + { + return _xmat4( + s - m[0], + s - m[1], + s - m[2], + s - m[3]); + } + + template + inline _xvec4 operator- (const _xmat4& m, const _xvec4& v) + { + + } + + template + inline _xvec4 operator- (const _xvec4& v, const _xmat4& m) + { + + } + + template + inline _xmat4 operator- (const _xmat4& m1, const _xmat4& m2) + { + return _xmat4( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2], + m1[3] - m2[3]); + } + + template + inline _xmat4 operator* (const _xmat4& m, const T s) + { + return _xmat4( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xmat4 operator* (const T s, const _xmat4& m) + { + return _xmat4( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xvec4 operator* (const _xmat4& m, const _xvec4& v) + { + return _xvec4( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w, + m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w, + m[0][3] * v.x + m[1][3] * v.y + m[2][3] * v.z + m[3][3] * v.w); + } + + template + inline _xvec4 operator* (const _xvec4& v, const _xmat4& m) + { + return _xvec4( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] * v.w, + m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] * v.w); + } + + template + inline _xmat4 operator* (const _xmat4& m1, const _xmat4& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA02 = m1[0][2]; + const T SrcA03 = m1[0][3]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA12 = m1[1][2]; + const T SrcA13 = m1[1][3]; + const T SrcA20 = m1[2][0]; + const T SrcA21 = m1[2][1]; + const T SrcA22 = m1[2][2]; + const T SrcA23 = m1[2][3]; + const T SrcA30 = m1[3][0]; + const T SrcA31 = m1[3][1]; + const T SrcA32 = m1[3][2]; + const T SrcA33 = m1[3][3]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB02 = m2[0][2]; + const T SrcB03 = m2[0][3]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB12 = m2[1][2]; + const T SrcB13 = m2[1][3]; + const T SrcB20 = m2[2][0]; + const T SrcB21 = m2[2][1]; + const T SrcB22 = m2[2][2]; + const T SrcB23 = m2[2][3]; + const T SrcB30 = m2[3][0]; + const T SrcB31 = m2[3][1]; + const T SrcB32 = m2[3][2]; + const T SrcB33 = m2[3][3]; + + _xmat4 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02 + SrcA30 * SrcB03; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02 + SrcA31 * SrcB03; + Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01 + SrcA22 * SrcB02 + SrcA32 * SrcB03; + Result[0][3] = SrcA03 * SrcB00 + SrcA13 * SrcB01 + SrcA23 * SrcB02 + SrcA33 * SrcB03; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12 + SrcA30 * SrcB13; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12 + SrcA31 * SrcB13; + Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11 + SrcA22 * SrcB12 + SrcA32 * SrcB13; + Result[1][3] = SrcA03 * SrcB10 + SrcA13 * SrcB11 + SrcA23 * SrcB12 + SrcA33 * SrcB13; + Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21 + SrcA20 * SrcB22 + SrcA30 * SrcB23; + Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21 + SrcA21 * SrcB22 + SrcA31 * SrcB23; + Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21 + SrcA22 * SrcB22 + SrcA32 * SrcB23; + Result[2][3] = SrcA03 * SrcB20 + SrcA13 * SrcB21 + SrcA23 * SrcB22 + SrcA33 * SrcB23; + Result[3][0] = SrcA00 * SrcB30 + SrcA10 * SrcB31 + SrcA20 * SrcB32 + SrcA30 * SrcB33; + Result[3][1] = SrcA01 * SrcB30 + SrcA11 * SrcB31 + SrcA21 * SrcB32 + SrcA31 * SrcB33; + Result[3][2] = SrcA02 * SrcB30 + SrcA12 * SrcB31 + SrcA22 * SrcB32 + SrcA32 * SrcB33; + Result[3][3] = SrcA03 * SrcB30 + SrcA13 * SrcB31 + SrcA23 * SrcB32 + SrcA33 * SrcB33; + return Result; + } + + template + inline _xmat4 operator/ (const _xmat4& m, const T s) + { + return _xmat4( + m[0] / s, + m[1] / s, + m[2] / s, + m[3] / s); + } + + template + inline _xmat4 operator/ (const T s, const _xmat4& m) + { + return _xmat4( + s / m[0], + s / m[1], + s / m[2], + s / m[3]); + } + + template + inline _xvec4 operator/ (const _xmat4& m, const _xvec4& v) + { + return m._inverse() * v; + } + + template + inline _xvec4 operator/ (const _xvec4& v, const _xmat4& m) + { + return v * m._inverse(); + } + + template + inline _xmat4 operator/ (const _xmat4& m1, const _xmat4& m2) + { + return m1 * m2._inverse(); + } + + // Unary constant operators + template + inline const _xmat4 operator- (const _xmat4& m) + { + return _xmat4( + -m.value[0], + -m.value[1], + -m.value[2], + -m.value[3]); + } + + template + inline const _xmat4 operator++ (const _xmat4& m, int) + { + return _xmat4( + m.value[0] + 1, + m.value[1] + 1, + m.value[2] + 1, + m.value[3] + 1); + } + + template + inline const _xmat4 operator-- (const _xmat4& m, int) + { + return _xmat4( + m.value[0] - 1, + m.value[1] - 1, + m.value[2] - 1, + m.value[3] - 1); + } + +} //namespace detail +} //namespace glm + +#endif //__mat4_inl__ diff --git a/wip/sse/glm/core/_xmat4x2.h b/wip/sse/glm/core/_xmat4x2.h new file mode 100644 index 00000000..5c2fa4e0 --- /dev/null +++ b/wip/sse/glm/core/_xmat4x2.h @@ -0,0 +1,146 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-10-01 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat4x2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat4x2_h__ +#define __mat4x2_h__ + +namespace glm{ +namespace detail{ + + template class _xvec3; + template class _xvec4; + template class _xmat2; + template class _xmat3; + template class _xmat4; + template class _xmat2x3; + template class _xmat3x2; + template class _xmat2x4; + template class _xmat3x4; + template class _xmat4x3; + + //!< \brief Template for 4 * 2 matrix of floating-point numbers. + template + class _xmat4x2 + { + private: + // Data + _xvec2 value[4]; + + public: + typedef T value_type; + typedef _xvec4 col_type; + typedef _xvec2 row_type; + typedef int size_type; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat4x2(); + explicit _xmat4x2(const T x); + explicit _xmat4x2( + const T x0, const T y0, + const T x1, const T y1, + const T x2, const T y2, + const T x3, const T y3); + explicit _xmat4x2( + const _xvec2& v0, + const _xvec2& v1, + const _xvec2& v2, + const _xvec2& v3); + + // Conversions + template + explicit _xmat4x2(const _xmat4x2& m); + + explicit _xmat4x2(const _xmat2& x); + explicit _xmat4x2(const _xmat3& x); + explicit _xmat4x2(const _xmat4& x); + explicit _xmat4x2(const _xmat2x3& x); + explicit _xmat4x2(const _xmat3x2& x); + explicit _xmat4x2(const _xmat2x4& x); + explicit _xmat4x2(const _xmat4x3& x); + explicit _xmat4x2(const _xmat3x4& x); + + // Accesses + _xvec2& operator[](int i) {return value[i];} + const _xvec2 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat4x2& operator= (const _xmat4x2& m); + _xmat4x2& operator+= (const T s); + _xmat4x2& operator+= (const _xmat4x2& m); + _xmat4x2& operator-= (const T s); + _xmat4x2& operator-= (const _xmat4x2& m); + _xmat4x2& operator*= (const T s); + _xmat4x2& operator*= (const _xmat2x4& m); + _xmat4x2& operator/= (const T s); +/* ToDo + _xmat4x2& operator/= (const _xmat2x4& m); +*/ + _xmat4x2& operator++ (); + _xmat4x2& operator-- (); + + // Unary constant operators + const _xmat4x2 operator- () const; + const _xmat4x2 operator++ (int n) const; + const _xmat4x2 operator-- (int n) const; + }; + + // Binary operators + template + _xmat4x2 operator+ (const _xmat4x2& m, const T s); + + template + _xmat4x2 operator+ (const _xmat4x2& m1, const _xmat4x2& m2); + + template + _xmat4x2 operator- (const _xmat4x2& m, const T s); + + template + _xmat4x2 operator- (const _xmat4x2& m1, const _xmat4x2& m2); + + template + _xmat4x2 operator* (const _xmat4x2& m, const T s); + + template + _xmat4x2 operator* (const T s, const _xmat4x2& m); + + template + _xvec2 operator* (const _xmat4x2& m, const _xvec4& v); + + template + _xmat4 operator* (const _xvec2& v, const _xmat4x2& m); +/* ToDo + template + _xmat2 operator* (const _xmat4x2& m1, const _xmat2x4& m2); +*/ + template + _xmat4x2 operator/ (const _xmat4x2& m, const T s); + + template + _xmat4x2 operator/ (const T s, const _xmat4x2& m); +/* ToDo + template + _xvec2 operator/ (const _xmat4x2& m, const _xvec4& v); + + template + _xvec4 operator/ (const _xvec2& v, const _xmat4x2& m); + + template + _xmat2 operator/ (const _xmat4x2& m1, const _xmat2x4& m2); +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat4x2_h__ diff --git a/wip/sse/glm/core/_xmat4x2.inl b/wip/sse/glm/core/_xmat4x2.inl new file mode 100644 index 00000000..4be38820 --- /dev/null +++ b/wip/sse/glm/core/_xmat4x2.inl @@ -0,0 +1,440 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-10-01 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat4x2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat4x2_inl__ +#define __mat4x2_inl__ + +#include "./_xmat4x2.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat4x2::size_type _xmat4x2::col_size = 4; + template const typename _xmat4x2::size_type _xmat4x2::row_size = 2; + + ////////////////////////////////////////////////////////////// + // Constructors + + template + inline _xmat4x2::_xmat4x2() + { + this->value[0] = _xvec2(1, 0); + this->value[1] = _xvec2(0, 1); + this->value[2] = _xvec2(0, 0); + this->value[3] = _xvec2(0, 0); + } + + template + inline _xmat4x2::_xmat4x2(const T f) + { + this->value[0] = _xvec2(f, 0); + this->value[1] = _xvec2(0, f); + this->value[2] = _xvec2(0, 0); + this->value[3] = _xvec2(0, 0); + } + + template + inline _xmat4x2::_xmat4x2 + ( + const T x0, const T y0, + const T x1, const T y1, + const T x2, const T y2, + const T x3, const T y3 + ) + { + this->value[0] = _xvec2(x0, y0); + this->value[1] = _xvec2(x1, y1); + this->value[2] = _xvec2(x2, y2); + this->value[3] = _xvec2(x3, y3); + } + + template + inline _xmat4x2::_xmat4x2 + ( + const _xvec2 & v0, + const _xvec2 & v1, + const _xvec2 & v2, + const _xvec2 & v3 + ) + { + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; + this->value[3] = v3; + } + + // Conversion + template + template + inline _xmat4x2::_xmat4x2(const _xmat4x2& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + this->value[3] = _xvec2(m[3]); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat2& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + this->value[3] = _xvec2(T(0)); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + this->value[3] = _xvec2(T(0)); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + this->value[3] = _xvec2(m[3]); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat2x3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(T(0)); + this->value[3] = _xvec2(T(0)); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat3x2& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + this->value[3] = _xvec2(T(0)); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat2x4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(T(0)); + this->value[3] = _xvec2(T(0)); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat4x3& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + this->value[3] = _xvec2(m[3]); + } + + template + inline _xmat4x2::_xmat4x2(const _xmat3x4& m) + { + this->value[0] = _xvec2(m[0]); + this->value[1] = _xvec2(m[1]); + this->value[2] = _xvec2(m[2]); + this->value[3] = _xvec2(T(0)); + } + + ////////////////////////////////////////////////////////////// + // Unary updatable operators + + template + inline _xmat4x2& _xmat4x2::operator= (const _xmat4x2& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + this->value[3] = m[3]; + return *this; + } + + template + inline _xmat4x2& _xmat4x2::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + this->value[2] += s; + this->value[3] += s; + return *this; + } + + template + inline _xmat4x2& _xmat4x2::operator+= (const _xmat4x2& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + this->value[2] += m[2]; + this->value[3] += m[3]; + return *this; + } + + template + inline _xmat4x2& _xmat4x2::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + this->value[2] -= s; + this->value[3] -= s; + return *this; + } + + template + inline _xmat4x2& _xmat4x2::operator-= (const _xmat4x2& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + this->value[2] -= m[2]; + this->value[3] -= m[3]; + return *this; + } + + template + inline _xmat4x2& _xmat4x2::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + this->value[2] *= s; + this->value[3] *= s; + return *this; + } + + template + inline _xmat4x2& _xmat4x2::operator*= (const _xmat2x4& m) + { + return (*this = _xmat4x2(*this * m)); + } + + template + inline _xmat4x2 & _xmat4x2::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + this->value[2] /= s; + this->value[3] /= s; + return *this; + } +/* ToDo + template + inline _xmat4x2& _xmat4x2::operator/= (const _xmat2x4& m) + { + return (*this = *this / m); + } +*/ + template + inline _xmat4x2& _xmat4x2::operator++ () + { + ++this->value[0]; + ++this->value[1]; + ++this->value[2]; + ++this->value[3]; + return *this; + } + + template + inline _xmat4x2& _xmat4x2::operator-- () + { + --this->value[0]; + --this->value[1]; + --this->value[2]; + --this->value[3]; + return *this; + } + + ////////////////////////////////////////////////////////////// + // Unary constant operators + template + inline const _xmat4x2 _xmat4x2::operator- () const + { + return _xmat4x2( + -this->value[0], + -this->value[1], + -this->value[2], + -this->value[3]); + } + + template + inline const _xmat4x2 _xmat4x2::operator-- (int n) const + { + _xmat4x2 m = *this; + --m.value[0]; + --m.value[1]; + --m.value[2]; + --m.value[3]; + return m; + } + + template + inline const _xmat4x2 _xmat4x2::operator++ (int n) const + { + _xmat4x2 m = *this; + ++m.value[0]; + ++m.value[1]; + ++m.value[2]; + ++m.value[3]; + return m; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat4x2 operator+ (const _xmat4x2& m, const T s) + { + return _xmat4x2( + m[0] + s, + m[1] + s, + m[2] + s, + m[3] + s); + } + + template + inline _xmat4x2 operator+ (const _xmat4x2& m1, const _xmat4x2& m2) + { + return _xmat4x2( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2], + m1[3] + m2[3]); + } + + template + inline _xmat4x2 operator- (const _xmat4x2& m, const T s) + { + return _xmat4x2( + m[0] - s, + m[1] - s, + m[2] - s, + m[3] - s); + } + + template + inline _xmat4x2 operator- (const _xmat4x2& m1, const _xmat4x2& m2) + { + return _xmat4x2( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2], + m1[3] - m2[3]); + } + + template + inline _xmat4x2 operator* (const _xmat4x2& m, const T s) + { + return _xmat4x2( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xmat4x2 operator* (const T s, const _xmat4x2 & m) + { + return _xmat4x2( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xvec2 operator* (const _xmat4x2& m, const _xvec4& v) + { + return _xvec2( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w); + } + + template + inline _xvec4 operator* (const _xvec2& v, const _xmat4x2& m) + { + return _xvec4( + v.x * m[0][0] + v.y * m[0][1], + v.x * m[1][0] + v.y * m[1][1], + v.x * m[2][0] + v.y * m[2][1], + v.x * m[3][0] + v.y * m[3][1]); + } + + template + inline _xmat2 operator* (const _xmat4x2& m1, const _xmat2x4& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA20 = m1[2][0]; + const T SrcA21 = m1[2][1]; + const T SrcA30 = m1[3][0]; + const T SrcA31 = m1[3][1]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB02 = m2[0][2]; + const T SrcB03 = m2[0][3]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB12 = m2[1][2]; + const T SrcB13 = m2[1][3]; + + _xmat2 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA01 * SrcB01 + SrcA20 * SrcB02 + SrcA30 * SrcB03; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02 + SrcA31 * SrcB03; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12 + SrcA30 * SrcB13; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12 + SrcA31 * SrcB13; + return Result; + } + + template + inline _xmat4x2 operator/ (const _xmat4x2& m, const T s) + { + return _xmat4x2( + m.value[0] / s, + m.value[1] / s, + m.value[2] / s, + m.value[3] / s); + } + + template + inline _xmat4x2 operator/ (const T s, const _xmat4x2& m) + { + return _xmat4x2( + s / m.value[0], + s / m.value[1], + s / m.value[2], + s / m.value[3]); + } +/* ToDo + template + inline _xmat4x2 operator/ (const _xmat4x2& m1, const _xmat2x4& m2) + { + + } + + template + inline _xmat4x2 operator/ (const _xmat2x4& m1, const _xmat4x2& m2) + { + + } +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat4x2_inl__ diff --git a/wip/sse/glm/core/_xmat4x3.h b/wip/sse/glm/core/_xmat4x3.h new file mode 100644 index 00000000..96066571 --- /dev/null +++ b/wip/sse/glm/core/_xmat4x3.h @@ -0,0 +1,146 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-08-04 +// Updated : 2006-10-01 +// Licence : This source is under GNU LGPL licence +// File : _mat4x3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat4x3_h__ +#define __mat4x3_h__ + +namespace glm{ +namespace detail{ + + template class _xvec3; + template class _xvec4; + template class _xmat2; + template class _xmat3; + template class _xmat4; + template class _xmat2x3; + template class _xmat3x2; + template class _xmat2x4; + template class _xmat4x2; + template class _xmat3x4; + + //!< \brief Template for 4 * 3 matrix of floating-point numbers. + template + class _xmat4x3 + { + private: + // Data + _xvec3 value[4]; + + public: + typedef T value_type; + typedef _xvec4 col_type; + typedef _xvec3 row_type; + typedef int size_type; + static const size_type col_size; + static const size_type row_size; + + // Constructors + _xmat4x3(); + explicit _xmat4x3(const T x); + explicit _xmat4x3( + const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1, + const T x2, const T y2, const T z2, + const T x3, const T y3, const T z3); + explicit _xmat4x3( + const _xvec3& v0, + const _xvec3& v1, + const _xvec3& v2, + const _xvec3& v3); + + // Conversion + template + explicit _xmat4x3(const _xmat4x3& m); + + explicit _xmat4x3(const _xmat2& x); + explicit _xmat4x3(const _xmat3& x); + explicit _xmat4x3(const _xmat4& x); + explicit _xmat4x3(const _xmat2x3& x); + explicit _xmat4x3(const _xmat3x2& x); + explicit _xmat4x3(const _xmat2x4& x); + explicit _xmat4x3(const _xmat4x2& x); + explicit _xmat4x3(const _xmat3x4& x); + + // Accesses + _xvec3& operator[](int i) {return value[i];} + const _xvec3 & operator[](int i) const {return value[i];} + // operator T*() {return &value[0][0];} + // operator const T*() const {return &value[0][0];} + operator T*() {return (T*)this;} + operator const T*() const {return (const T*)this;} + + // Unary updatable operators + _xmat4x3& operator= (const _xmat4x3& m); + _xmat4x3& operator+= (const T s); + _xmat4x3& operator+= (const _xmat4x3& m); + _xmat4x3& operator-= (const T s); + _xmat4x3& operator-= (const _xmat4x3& m); + _xmat4x3& operator*= (const T s); + _xmat4x3& operator*= (const _xmat3x4& m); + _xmat4x3& operator/= (const T s); +/* ToDo + _xmat4x3& operator/= (const _xmat3x4& m); +*/ + _xmat4x3& operator++ (); + _xmat4x3& operator-- (); + + // Unary constant operators + const _xmat4x3 operator- () const; + const _xmat4x3 operator++ (int n) const; + const _xmat4x3 operator-- (int n) const; + }; + + // Binary operators + template + _xmat4x3 operator+ (const _xmat4x3& m, const T s); + + template + _xmat4x3 operator+ (const _xmat4x3& m1, const _xmat4x3& m2); + + template + _xmat4x3 operator- (const _xmat4x3& m, const T s); + + template + _xmat4x3 operator- (const _xmat4x3& m1, const _xmat4x3& m2); + + template + _xmat4x3 operator* (const _xmat4x3& m, const T s); + + template + _xmat4x3 operator* (const T s, const _xmat4x3& m); + + template + _xvec3 operator* (const _xmat4x3& m, const _xvec4& v); + + template + _xvec4 operator* (const _xvec3& v, const _xmat4x3& m); + + template + _xmat3 operator* (const _xmat4x3& m1, const _xmat3x4& m2); + + template + _xmat4x3 operator/ (const _xmat4x3& m, const T s); + + template + _xmat4x3 operator/ (const T s, const _xmat4x3& m); +/* ToDo + template + _xvec3 operator/ (const _xmat4x3& m, const _xvec4& v); + + template + _xvec4 operator/ (const _xvec3& v, const _xmat4x3& m); + + template + _xmat3 operator/ (const _xmat4x3& m1, const _xmat3x4& m2); +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat4x3_h__ diff --git a/wip/sse/glm/core/_xmat4x3.inl b/wip/sse/glm/core/_xmat4x3.inl new file mode 100644 index 00000000..2c12f342 --- /dev/null +++ b/wip/sse/glm/core/_xmat4x3.inl @@ -0,0 +1,460 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-17 +// Updated : 2006-04-17 +// Licence : This source is under GNU LGPL licence +// File : _mat4x3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __mat4x3_inl__ +#define __mat4x3_inl__ + +#include "./_xmat4x3.h" + +namespace glm{ +namespace detail{ + + template const typename _xmat4x3::size_type _xmat4x3::col_size = 4; + template const typename _xmat4x3::size_type _xmat4x3::row_size = 3; + + ////////////////////////////////////////////////////////////// + // Constructors + + template + inline _xmat4x3::_xmat4x3() + { + this->value[0] = _xvec3(1, 0, 0); + this->value[1] = _xvec3(0, 1, 0); + this->value[2] = _xvec3(0, 0, 1); + this->value[3] = _xvec3(0, 0, 0); + } + + template + inline _xmat4x3::_xmat4x3(const T f) + { + this->value[0] = _xvec3(f, 0, 0); + this->value[1] = _xvec3(0, f, 0); + this->value[2] = _xvec3(0, 0, f); + this->value[3] = _xvec3(0, 0, 0); + } + + template + inline _xmat4x3::_xmat4x3 + ( + const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1, + const T x2, const T y2, const T z2, + const T x3, const T y3, const T z3 + ) + { + this->value[0] = _xvec3(x0, y0, z0); + this->value[1] = _xvec3(x1, y1, z1); + this->value[2] = _xvec3(x2, y2, z2); + this->value[3] = _xvec3(x3, y3, z3); + } + + template + inline _xmat4x3::_xmat4x3 + ( + const _xvec3 & v0, + const _xvec3 & v1, + const _xvec3 & v2, + const _xvec3 & v3 + ) + { + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; + this->value[3] = v3; + } + + // Conversion + template + template + inline _xmat4x3::_xmat4x3(const _xmat4x3& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(m[2]); + this->value[3] = _xvec3(m[3]); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + this->value[2] = _xvec3(m[2], T(1)); + this->value[3] = _xvec3(T(0)); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat3& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(m[2]); + this->value[3] = _xvec3(T(0)); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(m[2]); + this->value[3] = _xvec3(m[3]); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat2x3& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(T(0), T(0), T(1)); + this->value[3] = _xvec3(T(0)); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat3x2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + this->value[2] = _xvec3(m[2], T(1)); + this->value[3] = _xvec3(T(0)); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat2x4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(T(0), T(0), T(1)); + this->value[3] = _xvec3(T(0)); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat4x2& m) + { + this->value[0] = _xvec3(m[0], T(0)); + this->value[1] = _xvec3(m[1], T(0)); + this->value[2] = _xvec3(m[2], T(1)); + this->value[3] = _xvec3(m[3], T(0)); + } + + template + inline _xmat4x3::_xmat4x3(const _xmat3x4& m) + { + this->value[0] = _xvec3(m[0]); + this->value[1] = _xvec3(m[1]); + this->value[2] = _xvec3(m[2]); + this->value[3] = _xvec3(T(0)); + } + + ////////////////////////////////////////////////////////////// + // Unary updatable operators + + template + inline _xmat4x3& _xmat4x3::operator= (const _xmat4x3& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + this->value[3] = m[3]; + return *this; + } + + template + inline _xmat4x3& _xmat4x3::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + this->value[2] += s; + this->value[3] += s; + return *this; + } + + template + inline _xmat4x3& _xmat4x3::operator+= (const _xmat4x3& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + this->value[2] += m[2]; + this->value[3] += m[3]; + return *this; + } + + template + inline _xmat4x3& _xmat4x3::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + this->value[2] -= s; + this->value[3] -= s; + return *this; + } + + template + inline _xmat4x3& _xmat4x3::operator-= (const _xmat4x3& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + this->value[2] -= m[2]; + this->value[3] -= m[3]; + return *this; + } + + template + inline _xmat4x3& _xmat4x3::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + this->value[2] *= s; + this->value[3] *= s; + return *this; + } + + template + inline _xmat4x3& _xmat4x3::operator*= (const _xmat3x4& m) + { + return (*this = _xmat4x3(*this * m)); + } + + template + inline _xmat4x3 & _xmat4x3::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + this->value[2] /= s; + this->value[3] /= s; + return *this; + } +/* ToDo + template + inline _xmat4x3& _xmat4x3::operator/= (const _xmat3x4& m) + { + return (*this = *this / m); + } +*/ + template + inline _xmat4x3& _xmat4x3::operator++ () + { + ++this->value[0]; + ++this->value[1]; + ++this->value[2]; + ++this->value[3]; + return *this; + } + + template + inline _xmat4x3& _xmat4x3::operator-- () + { + --this->value[0]; + --this->value[1]; + --this->value[2]; + --this->value[3]; + return *this; + } + + ////////////////////////////////////////////////////////////// + // Unary constant operators + template + inline const _xmat4x3 _xmat4x3::operator- () const + { + return _xmat4x3( + -this->value[0], + -this->value[1], + -this->value[2], + -this->value[3]); + } + + template + inline const _xmat4x3 _xmat4x3::operator-- (int n) const + { + _xmat4x3 m = *this; + --m.value[0]; + --m.value[1]; + --m.value[2]; + --m.value[3]; + return m; + } + + template + inline const _xmat4x3 _xmat4x3::operator++ (int n) const + { + _xmat4 m = *this; + ++m.value[0]; + ++m.value[1]; + ++m.value[2]; + ++m.value[3]; + return m; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat4x3 operator+ (const _xmat4x3& m, const T s) + { + return _xmat4x3( + m[0] + s, + m[1] + s, + m[2] + s, + m[3] + s); + } + + template + inline _xmat4x3 operator+ (const _xmat4x3& m1, const _xmat4x3& m2) + { + return _xmat4x3( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2], + m1[3] + m2[3]); + } + + template + inline _xmat4x3 operator- (const _xmat4x3& m, const T s) + { + return _xmat4x3( + m[0] - s, + m[1] - s, + m[2] - s, + m[3] - s); + } + + template + inline _xmat4x3 operator- (const _xmat4x3& m1, const _xmat4x3& m2) + { + return _xmat4x3( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2], + m1[3] - m2[3]); + } + + template + inline _xmat4x3 operator* (const _xmat4x3& m, const T s) + { + return _xmat4x3( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xmat4x3 operator* (const T s, const _xmat4x3 & m) + { + return _xmat4x3( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xvec3 operator* (const _xmat4x3& m, const _xvec4& v) + { + return _xvec3( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w, + m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w); + } + + template + inline _xvec4 operator* (const _xvec3& v, const _xmat4x3& m) + { + return _xvec4( + v.x * m[0][0] + v.y * m[0][1] + v.z * m[0][2], + v.x * m[1][0] + v.y * m[1][1] + v.z * m[1][2], + v.x * m[2][0] + v.y * m[2][1] + v.z * m[2][2], + v.x * m[3][0] + v.y * m[3][1] + v.z * m[3][2]); + } + + template + inline _xmat3 operator* (const _xmat4x3& m1, const _xmat3x4& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA02 = m1[0][2]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA12 = m1[1][2]; + const T SrcA20 = m1[2][0]; + const T SrcA21 = m1[2][1]; + const T SrcA22 = m1[2][2]; + const T SrcA30 = m1[3][0]; + const T SrcA31 = m1[3][1]; + const T SrcA32 = m1[3][2]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB02 = m2[0][2]; + const T SrcB03 = m2[0][3]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB12 = m2[1][2]; + const T SrcB13 = m2[1][3]; + const T SrcB20 = m2[2][0]; + const T SrcB21 = m2[2][1]; + const T SrcB22 = m2[2][2]; + const T SrcB23 = m2[2][3]; + + _xmat3 Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02 + SrcA30 * SrcB03; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02 + SrcA31 * SrcB03; + Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01 + SrcA22 * SrcB02 + SrcA32 * SrcB03; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12 + SrcA30 * SrcB13; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12 + SrcA31 * SrcB13; + Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11 + SrcA22 * SrcB12 + SrcA32 * SrcB13; + Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21 + SrcA20 * SrcB22 + SrcA30 * SrcB23; + Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21 + SrcA21 * SrcB22 + SrcA31 * SrcB23; + Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21 + SrcA22 * SrcB22 + SrcA32 * SrcB23; + return Result; + } + + template + inline _xmat4x3 operator/ (const _xmat4x3& m, const T s) + { + return _xmat4x3( + m.value[0] / s, + m.value[1] / s, + m.value[2] / s, + m.value[3] / s); + } + + template + inline _xmat4x3 operator/ (const T s, const _xmat4x3& m) + { + return _xmat4x3( + s / m.value[0], + s / m.value[1], + s / m.value[2], + s / m.value[3]); + } +/* ToDo + template + _xvec3 operator/ (const _xmat4x3& m, const _xvec4& v) + { + + } + + template + _xvec4 operator/ (const _xvec3& v, const _xmat4x3& m) + { + + } + + template + inline _xmat4x3 operator/ (const _xmat4x3& m1, const _xmat4x3& m2) + { + + } +*/ + +} //namespace detail +} //namespace glm + +#endif //__mat4x3_inl__ diff --git a/wip/sse/glm/core/_xref2.h b/wip/sse/glm/core/_xref2.h new file mode 100644 index 00000000..63d7eff6 --- /dev/null +++ b/wip/sse/glm/core/_xref2.h @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-05-29 +// Updated : 2008-01-04 +// Licence : This source is under GNU LGPL licence +// File : _xref2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xref2_h__ +#define __xref2_h__ + +namespace glm{ +namespace detail{ + + template + class _xref2 + { + public: + _xref2(T& x, T& y); + _xref2& operator= (const _xref2& r); + _xref2& operator+=(const _xref2& r); + _xref2& operator-=(const _xref2& r); + _xref2& operator*=(const _xref2& r); + _xref2& operator/=(const _xref2& r); + _xref2& operator= (const _xvec2& v); + _xref2& operator+=(const _xvec2& v); + _xref2& operator-=(const _xvec2& v); + _xref2& operator*=(const _xvec2& v); + _xref2& operator/=(const _xvec2& v); + T& x; + T& y; + }; + +} //namespace detail +} //namespace glm + +#endif//__xref2_h__ diff --git a/wip/sse/glm/core/_xref2.inl b/wip/sse/glm/core/_xref2.inl new file mode 100644 index 00000000..6d6e70b2 --- /dev/null +++ b/wip/sse/glm/core/_xref2.inl @@ -0,0 +1,107 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-05-29 +// Updated : 2006-05-29 +// Licence : This source is under GNU LGPL licence +// File : _xref2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xref2_inl__ +#define __xref2_inl__ + +#include "./_xref2.h" + +namespace glm{ +namespace detail{ + + template + inline _xref2::_xref2(T& x, T& y) : + x(x), + y(y) + {} + + template + inline _xref2& _xref2::operator=(const _xref2& r) + { + x = r.x; + y = r.y; + return *this; + } + + template + inline _xref2& _xref2::operator+=(const _xref2& r) + { + x += r.x; + y += r.y; + return *this; + } + + template + inline _xref2& _xref2::operator-=(const _xref2& r) + { + x -= r.x; + y -= r.y; + return *this; + } + + template + inline _xref2& _xref2::operator*=(const _xref2& r) + { + x *= r.x; + y *= r.y; + return *this; + } + + template + inline _xref2& _xref2::operator/=(const _xref2& r) + { + x /= r.x; + y /= r.y; + return *this; + } + + template + inline _xref2& _xref2::operator=(const _xvec2& v) + { + x = v.x; + y = v.y; + return *this; + } + + template + inline _xref2& _xref2::operator+=(const _xvec2& v) + { + x += v.x; + y += v.y; + return *this; + } + + template + inline _xref2& _xref2::operator-=(const _xvec2& v) + { + x -= v.x; + y -= v.y; + return *this; + } + + template + inline _xref2& _xref2::operator*=(const _xvec2& v) + { + x *= v.x; + y *= v.y; + return *this; + } + + template + inline _xref2& _xref2::operator/=(const _xvec2& v) + { + x /= v.x; + y /= v.y; + return *this; + } + +} //namespace detail +} //namespace glm + +#endif//__xref2_inl__ diff --git a/wip/sse/glm/core/_xref3.h b/wip/sse/glm/core/_xref3.h new file mode 100644 index 00000000..cea557ae --- /dev/null +++ b/wip/sse/glm/core/_xref3.h @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-05-29 +// Updated : 2006-05-29 +// Licence : This source is under GNU LGPL licence +// File : _xref3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xref3_h__ +#define __xref3_h__ + +namespace glm{ +namespace detail{ + + template + class _xref3 + { + public: + _xref3(T& x, T& y, T& z); + _xref3& operator= (const _xref3& r); + _xref3& operator+=(const _xref3& r); + _xref3& operator-=(const _xref3& r); + _xref3& operator*=(const _xref3& r); + _xref3& operator/=(const _xref3& r); + _xref3& operator= (const _xvec3& v); + _xref3& operator+=(const _xvec3& v); + _xref3& operator-=(const _xvec3& v); + _xref3& operator*=(const _xvec3& v); + _xref3& operator/=(const _xvec3& v); + T& x; + T& y; + T& z; + }; + +} //namespace detail +} //namespace glm + +#endif//__xref3_h__ diff --git a/wip/sse/glm/core/_xref3.inl b/wip/sse/glm/core/_xref3.inl new file mode 100644 index 00000000..7c226bd8 --- /dev/null +++ b/wip/sse/glm/core/_xref3.inl @@ -0,0 +1,118 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-05-29 +// Updated : 2006-05-29 +// Licence : This source is under GNU LGPL licence +// File : _xref3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xref3_inl__ +#define __xref3_inl__ + +#include "./_xref3.h" + +namespace glm{ +namespace detail{ + + template + inline _xref3::_xref3(T& x, T& y, T& z) : + x(x), + y(y), + z(z) + {} + + template + inline _xref3& _xref3::operator=(const _xref3& r) + { + x = r.x; + y = r.y; + z = r.z; + return *this; + } + + template + inline _xref3& _xref3::operator+=(const _xref3& r) + { + x += r.x; + y += r.y; + z += r.z; + return *this; + } + + template + inline _xref3& _xref3::operator-=(const _xref3& r) + { + x -= r.x; + y -= r.y; + z -= r.z; + return *this; + } + + template + inline _xref3& _xref3::operator*=(const _xref3& r) + { + x *= r.x; + y *= r.y; + z *= r.z; + return *this; + } + + template + inline _xref3& _xref3::operator/=(const _xref3& r) + { + x /= r.x; + y /= r.y; + z /= r.z; + return *this; + } + + template + inline _xref3& _xref3::operator=(const _xvec3& v) + { + x = v.x; + y = v.y; + z = v.z; + return *this; + } + + template + inline _xref3& _xref3::operator+=(const _xvec3& v) + { + x += v.x; + y += v.y; + z += v.z; + return *this; + } + + template + inline _xref3& _xref3::operator-=(const _xvec3& v) + { + x -= v.x; + y -= v.y; + z -= v.z; + return *this; + } + + template + inline _xref3& _xref3::operator*=(const _xvec3& v) + { + x *= v.x; + y *= v.y; + z *= v.z; + return *this; + } + + template + inline _xref3& _xref3::operator/=(const _xvec3& v) + { + x /= v.x; + y /= v.y; + z /= v.z; + return *this; + } + +} //namespace detail +} //namespace glm + +#endif//__xref3_inl__ diff --git a/wip/sse/glm/core/_xref4.h b/wip/sse/glm/core/_xref4.h new file mode 100644 index 00000000..45e817a4 --- /dev/null +++ b/wip/sse/glm/core/_xref4.h @@ -0,0 +1,40 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-05-29 +// Updated : 2006-05-29 +// Licence : This source is under GNU LGPL licence +// File : _xref4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xref4_h__ +#define __xref4_h__ + +namespace glm{ +namespace detail{ + + template + class _xref4 + { + public: + _xref4(T& x, T& y, T& z, T& w); + _xref4& operator= (const _xref4& r); + _xref4& operator+=(const _xref4& r); + _xref4& operator-=(const _xref4& r); + _xref4& operator*=(const _xref4& r); + _xref4& operator/=(const _xref4& r); + _xref4& operator= (const _xvec4& v); + _xref4& operator+=(const _xvec4& v); + _xref4& operator-=(const _xvec4& v); + _xref4& operator*=(const _xvec4& v); + _xref4& operator/=(const _xvec4& v); + T& x; + T& y; + T& z; + T& w; + }; + +} //namespace detail +} //namespace glm + +#endif//__xref4_h__ diff --git a/wip/sse/glm/core/_xref4.inl b/wip/sse/glm/core/_xref4.inl new file mode 100644 index 00000000..97d37793 --- /dev/null +++ b/wip/sse/glm/core/_xref4.inl @@ -0,0 +1,129 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-05-29 +// Updated : 2006-05-29 +// Licence : This source is under GNU LGPL licence +// File : _xref4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xref4_inl__ +#define __xref4_inl__ + +#include "./_xref4.h" + +namespace glm{ +namespace detail{ + + template + inline _xref4::_xref4(T& x, T& y, T& z, T& w) : + x(x), + y(y), + z(z), + w(w) + {} + + template + inline _xref4& _xref4::operator=(const _xref4& r) + { + x = r.x; + y = r.y; + z = r.z; + w = r.w; + return *this; + } + + template + inline _xref4& _xref4::operator+=(const _xref4& r) + { + x += r.x; + y += r.y; + z += r.z; + w += r.w; + return *this; + } + + template + inline _xref4& _xref4::operator-=(const _xref4& r) + { + x -= r.x; + y -= r.y; + z -= r.z; + w -= r.w; + return *this; + } + + template + inline _xref4& _xref4::operator*=(const _xref4& r) + { + x *= r.x; + y *= r.y; + z *= r.z; + w *= r.w; + return *this; + } + + template + inline _xref4& _xref4::operator/=(const _xref4& r) + { + x /= r.x; + y /= r.y; + z /= r.z; + w /= r.w; + return *this; + } + + template + _xref4& _xref4::operator=(const _xvec4& v) + { + x = v.x; + y = v.y; + z = v.z; + w = v.w; + return *this; + } + + template + inline _xref4& _xref4::operator+=(const _xvec4& v) + { + x += v.x; + y += v.y; + z += v.z; + w += v.w; + return *this; + } + + template + inline _xref4& _xref4::operator-=(const _xvec4& v) + { + x -= v.x; + y -= v.y; + z -= v.z; + w -= v.w; + return *this; + } + + template + inline _xref4& _xref4::operator*=(const _xvec4& v) + { + x *= v.x; + y *= v.y; + z *= v.z; + w *= v.w; + return *this; + } + + template + inline _xref4& _xref4::operator/=(const _xvec4& v) + { + x /= v.x; + y /= v.y; + z /= v.z; + w /= v.w; + return *this; + } + +} //namespace detail +} //namespace glm + +#endif//__xref4_inl__ diff --git a/wip/sse/glm/core/_xvec2.h b/wip/sse/glm/core/_xvec2.h new file mode 100644 index 00000000..520273fd --- /dev/null +++ b/wip/sse/glm/core/_xvec2.h @@ -0,0 +1,260 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-15 +// Licence : This source is under GNU LGPL licence +// File : _xvec2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xvec2_h__ +#define __xvec2_h__ + +#include "./_cvec2.inl" + +namespace glm{ +namespace detail{ + + template + class _xvec2 : public _xvec2_base(T) + { + public: + // Common constructors + _xvec2(); + _xvec2(const _xvec2& v); + + // Swizzle constructors + _xvec2(const _xref2& r); + _xvec2(const _xvec2_base(T)& b); + + // T constructors + explicit _xvec2(const T x); + explicit _xvec2(const T a, const T b); + explicit _xvec2(const T a, const _xvec2& b); + explicit _xvec2(const T a, const _xvec3& b); + explicit _xvec2(const T a, const _xvec4& b); + explicit _xvec2(const _xvec3& a); + explicit _xvec2(const _xvec4& a); + + // U constructors + template explicit _xvec2(const U x); + template explicit _xvec2(const U a, const U b); + template explicit _xvec2(const U a, const _xvec2& b); + template explicit _xvec2(const U a, const _xvec3& b); + template explicit _xvec2(const U a, const _xvec4& b); + template explicit _xvec2(const _xvec2& a); + template explicit _xvec2(const _xvec3& a); + template explicit _xvec2(const _xvec4& a); + + // Bool constructors + explicit _xvec2(const bool x); + explicit _xvec2(const bool a, const bool b); + explicit _xvec2(const bool a, const _bvec2& b); + explicit _xvec2(const bool a, const _bvec3& b); + explicit _xvec2(const bool a, const _bvec4& b); + explicit _xvec2(const _bvec2& a); + explicit _xvec2(const _bvec3& a); + explicit _xvec2(const _bvec4& a); + + // Unary updatable operators + _xvec2& operator= (const _xvec2& v); + _xvec2& operator+=(const T s); + _xvec2& operator+=(const _xvec2& v); + _xvec2& operator-=(const T s); + _xvec2& operator-=(const _xvec2& v); + _xvec2& operator*=(const T s); + _xvec2& operator*=(const _xvec2& v); + _xvec2& operator/=(const T s); + _xvec2& operator/=(const _xvec2& v); + _xvec2& operator++(); + _xvec2& operator--(); +/* + // Bit operators + _xvec2& operator%=(const T s); + _xvec2& operator%=(const _xvec2& v); + _xvec2& operator&=(const T s); + _xvec2& operator&=(const _xvec2& v); + _xvec2& operator|=(const T s); + _xvec2& operator|=(const _xvec2& v); + _xvec2& operator^=(const T s); + _xvec2& operator^=(const _xvec2& v); + _xvec2& operator<<=(const T s); + _xvec2& operator<<=(const _xvec2& v); + _xvec2& operator>>=(const T s); + _xvec2& operator>>=(const _xvec2& v); +*/ + }; +/* + // Bit operators + template + _xvec2 operator% (const _xvec2& v, const T s); + + template + _xvec2 operator% (const T s, const _xvec2& v); + + template + _xvec2 operator% (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator& (const _xvec2& v, const T s); + + template + _xvec2 operator& (const T s, const _xvec2& v); + + template + _xvec2 operator& (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator| (const _xvec2& v, const T s); + + template + _xvec2 operator| (const T s, const _xvec2& v); + + template + _xvec2 operator| (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator^ (const _xvec2& v, const T s); + + template + _xvec2 operator^ (const T s, const _xvec2& v); + + template + _xvec2 operator^ (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator<< (const _xvec2& v, const T s); + + template + _xvec2 operator<< (const T s, const _xvec2& v); + + template + _xvec2 operator<< (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator>> (const _xvec2& v, const T s); + + template + _xvec2 operator>> (const T s, const _xvec2& v); + + template + _xvec2 operator>> (const _xvec2& v1, const _xvec2& v2); + + template + const _xvec2 operator~ (const _xvec2& v); +*/ + // Binary operators + // operator+ + template + _xvec2 operator+ (const _xvec2& v, const T s); + + template + _xvec2 operator+ (const T s, const _xvec2& v); + + template + _xvec2 operator+ (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator+ (const _xref2& v, const T s); + + template + _xvec2 operator+ (const T s, const _xref2& v); + + template + _xvec2 operator+ (const _xref2& v1, const _xref2& v2); + + template + _xvec2 operator+ (const _xvec2& v1, const _xref2& v2); + + template + _xvec2 operator+ (const _xref2& v1, const _xvec2& v2); + + // operator- + template + _xvec2 operator- (const _xvec2& v, const T s); + + template + _xvec2 operator- (const T s, const _xvec2& v); + + template + _xvec2 operator- (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator- (const _xref2& v, const T s); + + template + _xvec2 operator- (const T s, const _xref2& v); + + template + _xvec2 operator- (const _xref2& v1, const _xref2& v2); + + template + _xvec2 operator- (const _xvec2& v1, const _xref2& v2); + + template + _xvec2 operator- (const _xref2& v1, const _xvec2& v2); + + // operator* + template + _xvec2 operator* (const _xvec2& v, const T s); + + template + _xvec2 operator* (const T s, const _xvec2& v); + + template + _xvec2 operator* (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator* (const _xref2& v, const T s); + + template + _xvec2 operator* (const T s, const _xref2& v); + + template + _xvec2 operator* (const _xref2& v1, const _xref2& v2); + + template + _xvec2 operator* (const _xvec2& v1, const _xref2& v2); + + template + _xvec2 operator* (const _xref2& v1, const _xvec2& v2); + + // operator/ + template + _xvec2 operator/ (const _xvec2& v, const T s); + + template + _xvec2 operator/ (const T s, const _xvec2& v); + + template + _xvec2 operator/ (const _xvec2& v1, const _xvec2& v2); + + template + _xvec2 operator/ (const _xref2& v, const T s); + + template + _xvec2 operator/ (const T s, const _xref2& v); + + template + _xvec2 operator/ (const _xref2& v1, const _xref2& v2); + + template + _xvec2 operator/ (const _xvec2& v1, const _xref2& v2); + + template + _xvec2 operator/ (const _xref2& v1, const _xvec2& v2); + + // Unary constant operators + template + const _xvec2 operator- (const _xvec2& v); + + template + const _xvec2 operator--(const _xvec2& v, int); + + template + const _xvec2 operator++(const _xvec2& v, int); + +} //namespace detail +} //namespace glm + +#endif //__xvec2_h__ diff --git a/wip/sse/glm/core/_xvec2.inl b/wip/sse/glm/core/_xvec2.inl new file mode 100644 index 00000000..8ad49acd --- /dev/null +++ b/wip/sse/glm/core/_xvec2.inl @@ -0,0 +1,802 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : _xvec2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __xvec2_inl__ +#define __xvec2_inl__ + +#include "./_cvec2.h" +#include "./_xvec2.h" +#include "./_bvec2.h" +#include "./_xvec3.h" +#include "./_bvec3.h" +#include "./_xvec4.h" +#include "./_bvec4.h" +#include "./_swizzle.inl" + +namespace glm{ +namespace detail{ + + // Common constructors + template + inline _xvec2::_xvec2() : + _cvec2(T(0), T(0)) + {} + + template + inline _xvec2::_xvec2(const _xvec2& v) : + _cvec2(v.x, v.y) + {} + + // Swizzle conclassor + template + inline _xvec2::_xvec2(const _xref2& r) : + _cvec2(r.x, r.y) + {} + + template + inline _xvec2::_xvec2(const _xvec2_base(T)& b) : + _cvec2(b.x, b.y) + {} + + // T constructors + template + inline _xvec2::_xvec2(const T x) : + _cvec2(x, x) + {} + + template + inline _xvec2::_xvec2(const T a, const T b) : + _cvec2(a, b) + {} + + template + inline _xvec2::_xvec2(const T a, const _xvec2& b) : + _cvec2(a, b.x) + {} + + template + inline _xvec2::_xvec2(const T a, const _xvec3& b) : + _cvec2(a, b.x) + {} + + template + inline _xvec2::_xvec2(const T a, const _xvec4& b) : + _cvec2(a, b.x) + {} + + template + inline _xvec2::_xvec2(const _xvec3& a) : + _cvec2(a.x, a.y) + {} + + template + inline _xvec2::_xvec2(const _xvec4& a) : + _cvec2(a.x, a.y) + {} + + // U constructors + template + template + inline _xvec2::_xvec2(const U x) : + _cvec2(T(x), T(x)) + {} + + template + template + inline _xvec2::_xvec2(const U a, const U b) : + _cvec2(T(a), T(b)) + {} + + template + template + inline _xvec2::_xvec2(const U a, const _xvec2& b) : + _cvec2(T(a), T(b.x)) + {} + + template + template + inline _xvec2::_xvec2(const U a, const _xvec3& b) : + _cvec2(T(a), T(b.x)) + {} + + template + template + inline _xvec2::_xvec2(const U a, const _xvec4& b) : + _cvec2(T(a), T(b.x)) + {} + + template + template + inline _xvec2::_xvec2(const _xvec2& a) : + _cvec2(T(a.x), T(a.y)) + {} + + template + template + inline _xvec2::_xvec2(const _xvec3& a) : + _cvec2(T(a.x), T(a.y)) + {} + + template + template + inline _xvec2::_xvec2(const _xvec4& a) : + _cvec2(T(a.x), T(a.y)) + {} + + // Bool constructors + template + inline _xvec2::_xvec2(const bool x) : + _cvec2(T(x), T(x)) + {} + + template + inline _xvec2::_xvec2(const bool a, const bool b) : + _cvec2(T(a), T(b)) + {} + + template + inline _xvec2::_xvec2(const bool a, const _bvec2& b) : + _cvec2(T(a), T(b.x)) + {} + + template + inline _xvec2::_xvec2(const bool a, const _bvec3& b) : + _cvec2(T(a), T(b.x)) + {} + + template + inline _xvec2::_xvec2(const bool a, const _bvec4& b) : + _cvec2(T(a), T(b.x)) + {} + + template + inline _xvec2::_xvec2(const _bvec3& a) : + _cvec2(T(a.x), T(a.y)) + {} + + template + inline _xvec2::_xvec2(const _bvec4& a) : + _cvec2(T(a.x), T(a.y)) + {} + + template + inline _xvec2::_xvec2(const _bvec2& a) : + _cvec2(T(a.x), T(a.y)) + {} + + ////////////////////////////////////////////////////////////// + // vec2 and ivec2 operators + + template + inline _xvec2& _xvec2::operator=(const _xvec2& v) + { + this->x = v.x; + this->y = v.y; + return *this; + } + + template + inline _xvec2& _xvec2::operator+= (const T s) + { + this->x += s; + this->y += s; + return *this; + } + + template + inline _xvec2& _xvec2::operator+= (const _xvec2& v) + { + this->x += v.x; + this->y += v.y; + return *this; + } + + template + inline _xvec2& _xvec2::operator-= (const T s) + { + this->x -= s; + this->y -= s; + return *this; + } + + template + inline _xvec2& _xvec2::operator-= (const _xvec2& v) + { + this->x -= v.x; + this->y -= v.y; + return *this; + } + + template + inline _xvec2& _xvec2::operator*= (const T s) + { + this->x *= s; + this->y *= s; + return *this; + } + + template + inline _xvec2& _xvec2::operator*= (const _xvec2& v) + { + this->x *= v.x; + this->y *= v.y; + return *this; + } + + template + inline _xvec2& _xvec2::operator/= (const T s) + { + this->x /= s; + this->y /= s; + return *this; + } + + template + inline _xvec2& _xvec2::operator/= (const _xvec2& v) + { + this->x /= v.x; + this->y /= v.y; + return *this; + } + + template + inline _xvec2& _xvec2::operator++ () + { + ++this->x; + ++this->y; + return *this; + } + + template + inline _xvec2& _xvec2::operator-- () + { + --this->x; + --this->y; + return *this; + } +/* + template + inline _xvec2& operator%=(const T s) + { + this->x %= s; + this->y %= s; + return *this; + } + + template + inline _xvec2& operator%=(const _xvec2& v) + { + this->x %= v.x; + this->y %= v.y; + return *this; + } + + template + inline _xvec2& operator&=(const T s) + { + this->x &= s; + this->y &= s; + return *this; + } + + template + inline _xvec2& operator&=(const _xvec2& v) + { + this->x &= v.x; + this->y &= v.y; + return *this; + } + + template + inline _xvec2& operator|=(const T s) + { + this->x |= s; + this->y |= s; + return *this; + } + + template + inline _xvec2& operator|=(const _xvec2& v) + { + this->x |= v.x; + this->y |= v.y; + return *this; + } + + template + inline _xvec2& operator^=(const T s) + { + this->x ^= s; + this->y ^= s; + return *this; + } + + template + inline _xvec2& operator^=(const _xvec2& v) + { + this->x ^= v.x; + this->y ^= v.y; + return *this; + } + + template + inline _xvec2& operator<<=(const T s) + { + this->x <<= s; + this->y <<= s; + return *this; + } + + template + inline _xvec2& operator<<=(const _xvec2& v) + { + this->x <<= v.x; + this->y <<= v.y; + return *this; + } + + template + inline _xvec2& operator>>=(const T s) + { + this->x >>= s; + this->y >>= s; + return *this; + } + + template + inline _xvec2& operator>>=(const _xvec2& v) + { + this->x >>= v.x; + this->y >>= v.y; + return *this; + } + + // Bit operators + template + inline _xvec2 operator% (const _xvec2& v, const T s) + { + return _xvec2( + v.x % s, + v.y % s); + } + + template + inline _xvec2 operator% (const T s, const _xvec2& v) + { + return _xvec2( + s % v.x, + s % v.y); + } + + template + inline _xvec2 operator% (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x % v2.x, + v1.y % v2.y); + } + + template + inline _xvec2 operator& (const _xvec2& v, const T s) + { + return _xvec2( + v.x & s, + v.y & s); + } + + template + inline _xvec2 operator& (const T s, const _xvec2& v) + { + return _xvec2( + s & v.x, + s & v.y); + } + + template + inline _xvec2 operator& (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x & v2.x, + v1.y & v2.y); + } + + template + inline _xvec2 operator| (const _xvec2& v, const T s) + { + return _xvec2( + v.x | s, + v.y | s); + } + + template + inline _xvec2 operator| (const T s, const _xvec2& v) + { + return _xvec2( + s | v.x, + s | v.y); + } + + template + inline _xvec2 operator| (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x | v2.x, + v1.y | v2.y); + } + + template + inline _xvec2 operator^ (const _xvec2& v, const T s) + { + return _xvec2( + v.x ^ s, + v.y ^ s); + } + + template + inline _xvec2 operator^ (const T s, const _xvec2& v) + { + return _xvec2( + s ^ v.x, + s ^ v.y); + } + + template + inline _xvec2 operator^ (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x ^ v2.x, + v1.y ^ v2.y); + } + + template + inline _xvec2 operator<< (const _xvec2& v, const T s) + { + return _xvec2( + v.x << s, + v.y << s); + } + + template + inline _xvec2 operator<< (const T s, const _xvec2& v) + { + return _xvec2( + s << v.x, + s << v.y); + } + + template + inline _xvec2 operator<< (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x << v2.x, + v1.y << v2.y); + } + + template + inline _xvec2 operator>> (const _xvec2& v, const T s) + { + return _xvec2( + v.x >> s, + v.y >> s); + } + + template + inline _xvec2 operator>> (const T s, const _xvec2& v) + { + return _xvec2( + s >> v.x, + s >> v.y); + } + + template + inline _xvec2 operator>> (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x >> v2.x, + v1.y >> v2.y); + } + + template + inline const _xvec2 operator~ (const _xvec2& v) + { + return _xvec2( + ~v.x, + ~v.y); + } +*/ + // Binary operators + //operator+ + template + inline _xvec2 operator+ (const _xvec2& v, const T s) + { + return _xvec2( + v.x + s, + v.y + s); + } + + template + inline _xvec2 operator+ (const T s, const _xvec2& v) + { + return _xvec2( + s + v.x, + s + v.y); + } + + template + inline _xvec2 operator+ (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x + v2.x, + v1.y + v2.y); + } + + template + inline _xvec2 operator+ (const _xref2& v, const T s) + { + return _xvec2( + v.x + s, + v.y + s); + } + + template + inline _xvec2 operator+ (const T s, const _xref2& v) + { + return _xvec2( + s + v.x, + s + v.y); + } + + template + inline _xvec2 operator+ (const _xref2& v1, const _xref2& v2) + { + return _xvec2( + v1.x + v2.x, + v1.y + v2.y); + } + + template + inline _xvec2 operator+ (const _xvec2& v1, const _xref2& v2) + { + return _xvec2( + v1.x + v2.x, + v1.y + v2.y); + } + + template + inline _xvec2 operator+ (const _xref2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x + v2.x, + v1.y + v2.y); + } + + //operator- + template + inline _xvec2 operator- (const _xvec2& v, const T s) + { + return _xvec2( + v.x - s, + v.y - s); + } + + template + inline _xvec2 operator- (const T s, const _xvec2& v) + { + return _xvec2( + s - v.x, + s - v.y); + } + + template + inline _xvec2 operator- (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x - v2.x, + v1.y - v2.y); + } + + template + inline _xvec2 operator- (const _xref2& v, const T s) + { + return _xvec2( + v.x - s, + v.y - s); + } + + template + inline _xvec2 operator- (const T s, const _xref2& v) + { + return _xvec2( + s - v.x, + s - v.y); + } + + template + inline _xvec2 operator- (const _xref2& v1, const _xref2& v2) + { + return _xvec2( + v1.x - v2.x, + v1.y - v2.y); + } + + template + inline _xvec2 operator- (const _xvec2& v1, const _xref2& v2) + { + return _xvec2( + v1.x - v2.x, + v1.y - v2.y); + } + + template + inline _xvec2 operator- (const _xref2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x - v2.x, + v1.y - v2.y); + } + + //operator* + template + inline _xvec2 operator* (const _xvec2& v, const T s) + { + return _xvec2( + v.x * s, + v.y * s); + } + + template + inline _xvec2 operator* (const T s, const _xvec2& v) + { + return _xvec2( + s * v.x, + s * v.y); + } + + template + inline _xvec2 operator* (const _xvec2& v1, const _xvec2 & v2) + { + return _xvec2( + v1.x * v2.x, + v1.y * v2.y); + } + + template + inline _xvec2 operator* (const _xref2& v, const T s) + { + return _xvec2( + v.x * s, + v.y * s); + } + + template + inline _xvec2 operator* (const T s, const _xref2& v) + { + return _xvec2( + s * v.x, + s * v.y); + } + + template + inline _xvec2 operator* (const _xref2& v1, const _xref2& v2) + { + return _xvec2( + v1.x * v2.x, + v1.y * v2.y); + } + + template + inline _xvec2 operator* (const _xvec2& v1, const _xref2& v2) + { + return _xvec2( + v1.x * v2.x, + v1.y * v2.y); + } + + template + inline _xvec2 operator* (const _xref2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x * v2.x, + v1.y * v2.y); + } + + //operator/ + template + inline _xvec2 operator/ (const _xvec2& v, const T s) + { + return _xvec2( + v.x / s, + v.y / s); + } + + template + inline _xvec2 operator/ (const T s, const _xvec2& v) + { + return _xvec2( + s / v.x, + s / v.y); + } + + template + inline _xvec2 operator/ (const _xvec2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x / v2.x, + v1.y / v2.y); + } + + template + inline _xvec2 operator/ (const _xref2& v, const T s) + { + return _xvec2( + v.x / s, + v.y / s); + } + + template + inline _xvec2 operator/ (const T s, const _xref2& v) + { + return _xvec2( + s / v.x, + s / v.y); + } + + template + inline _xvec2 operator/ (const _xref2& v1, const _xref2& v2) + { + return _xvec2( + v1.x / v2.x, + v1.y / v2.y); + } + + template + inline _xvec2 operator/ (const _xvec2& v1, const _xref2& v2) + { + return _xvec2( + v1.x / v2.x, + v1.y / v2.y); + } + + template + inline _xvec2 operator/ (const _xref2& v1, const _xvec2& v2) + { + return _xvec2( + v1.x / v2.x, + v1.y / v2.y); + } + + // Unary constant operators + template + inline const _xvec2 operator- (const _xvec2& v) + { + return _xvec2( + -v.x, + -v.y); + } + + template + inline const _xvec2 operator++ (const _xvec2& v, int) + { + return _xvec2( + v.x + T(1), + v.y + T(1)); + } + + template + inline const _xvec2 operator-- (const _xvec2& v, int) + { + return _xvec2( + v.x - T(1), + v.y - T(1)); + } + +} //namespace detail +} //namespace glm + +#endif //__xvec2_inl__ diff --git a/wip/sse/glm/core/_xvec3.h b/wip/sse/glm/core/_xvec3.h new file mode 100644 index 00000000..a9a9b676 --- /dev/null +++ b/wip/sse/glm/core/_xvec3.h @@ -0,0 +1,283 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-15 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_xvec3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Optimisation note: Don't use vec3 class instead of vec4 because you think it +// whould be faster. It whouldn't be the case especially if you use SSE +// intructions set in your compiler option and/or mat4 transformations. +// An advide: test your code speed with vec3 and vec4 to select the faster. +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_xvec3_h__ +#define __glm_core_xvec3_h__ + +#include "./_cvec3.inl" + +namespace glm{ +namespace detail{ + + template + class _xvec3 : public _xvec3_base(T) + { + public: + // Common constructors + _xvec3(); + _xvec3(const _xvec3& v); + + // Swizzle constructors + _xvec3(const _xref3& r); + _xvec3(const _xvec3_base(T)& b); + + // T constructors + explicit _xvec3(const T x); + explicit _xvec3(const T a, const T b, const T c); + explicit _xvec3(const T a, const T b, const _xvec2& c); + explicit _xvec3(const T a, const T b, const _xvec3& c); + explicit _xvec3(const T a, const T b, const _xvec4& c); + explicit _xvec3(const T a, const _xvec2& b); + explicit _xvec3(const T a, const _xvec3& b); + explicit _xvec3(const T a, const _xvec4& b); + explicit _xvec3(const _xvec2& a, T b); + explicit _xvec3(const _xvec2& a, const _xvec2& b); + explicit _xvec3(const _xvec2& a, const _xvec3& b); + explicit _xvec3(const _xvec2& a, const _xvec4& b); + explicit _xvec3(const _xvec4& a); + + // U constructors + template explicit _xvec3(const U x); + template explicit _xvec3(const U a, const U b, const U c); + template explicit _xvec3(const U a, const U b, const _xvec2& c); + template explicit _xvec3(const U a, const U b, const _xvec3& c); + template explicit _xvec3(const U a, const U b, const _xvec4& c); + template explicit _xvec3(const U a, const _xvec2& b); + template explicit _xvec3(const U a, const _xvec3& b); + template explicit _xvec3(const U a, const _xvec4& b); + template explicit _xvec3(const _xvec2& a, U b); + template explicit _xvec3(const _xvec2& a, const _xvec2& b); + template explicit _xvec3(const _xvec2& a, const _xvec3& b); + template explicit _xvec3(const _xvec2& a, const _xvec4& b); + template explicit _xvec3(const _xvec3& a); + template explicit _xvec3(const _xvec4& a); + + // Bool constructors + explicit _xvec3(const bool x); + explicit _xvec3(const bool a, const bool b, const bool c); + explicit _xvec3(const bool a, const bool b, const _bvec2& c); + explicit _xvec3(const bool a, const bool b, const _bvec3& c); + explicit _xvec3(const bool a, const bool b, const _bvec4& c); + explicit _xvec3(const bool a, const _bvec2& b); + explicit _xvec3(const bool a, const _bvec3& b); + explicit _xvec3(const bool a, const _bvec4& b); + explicit _xvec3(const _bvec2& a, bool b); + explicit _xvec3(const _bvec2& a, const _bvec2& b); + explicit _xvec3(const _bvec2& a, const _bvec3& b); + explicit _xvec3(const _bvec2& a, const _bvec4& b); + explicit _xvec3(const _bvec3& a); + explicit _xvec3(const _bvec4& a); + + // Unary updatable operators + _xvec3& operator= (const _xvec3& v); + _xvec3& operator+=(const T s); + _xvec3& operator+=(const _xvec3& v); + _xvec3& operator-=(const T s); + _xvec3& operator-=(const _xvec3& v); + _xvec3& operator*=(const T s); + _xvec3& operator*=(const _xvec3& v); + _xvec3& operator/=(const T s); + _xvec3& operator/=(const _xvec3& v); + _xvec3& operator++(); + _xvec3& operator--(); +/* + // Bit operators + _xvec3& operator%=(const T s); + _xvec3& operator%=(const _xvec3& v); + _xvec3& operator&=(const T s); + _xvec3& operator&=(const _xvec3& v); + _xvec3& operator|=(const T s); + _xvec3& operator|=(const _xvec3& v); + _xvec3& operator^=(const T s); + _xvec3& operator^=(const _xvec3& v); + _xvec3& operator<<=(const T s); + _xvec3& operator<<=(const _xvec3& v); + _xvec3& operator>>=(const T s); + _xvec3& operator>>=(const _xvec3& v); +*/ + }; +/* + // Bit operators + template + _xvec3 operator% (const _xvec3& v, const T s); + + template + _xvec3 operator% (const T s, const _xvec3& v); + + template + _xvec3 operator% (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator& (const _xvec3& v, const T s); + + template + _xvec3 operator& (const T s, const _xvec3& v); + + template + _xvec3 operator& (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator| (const _xvec3& v, const T s); + + template + _xvec3 operator| (const T s, const _xvec3& v); + + template + _xvec3 operator| (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator^ (const _xvec3& v, const T s); + + template + _xvec3 operator^ (const T s, const _xvec3& v); + + template + _xvec3 operator^ (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator<< (const _xvec3& v, const T s); + + template + _xvec3 operator<< (const T s, const _xvec3& v); + + template + _xvec3 operator<< (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator>> (const _xvec3& v, const T s); + + template + _xvec3 operator>> (const T s, const _xvec3& v); + + template + _xvec3 operator>> (const _xvec3& v1, const _xvec3& v2); + + template + const _xvec3 operator~ (const _xvec2& v); +*/ + // Binasy opesators + // operator+ + template + _xvec3 operator+ (const _xvec3& v, const T s); + + template + _xvec3 operator+ (const T s, const _xvec3& v); + + template + _xvec3 operator+ (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator+ (const _xref3& v, const T s); + + template + _xvec3 operator+ (const T s, const _xref3& v); + + template + _xvec3 operator+ (const _xref3& v1, const _xref3& v2); + + template + _xvec3 operator+ (const _xvec3& v1, const _xref3& v2); + + template + _xvec3 operator+ (const _xref3& v1, const _xvec3& v2); + + // operator- + template + _xvec3 operator- (const _xvec3& v, const T s); + + template + _xvec3 operator- (const T s, const _xvec3& v); + + template + _xvec3 operator- (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator- (const _xref3& v, const T s); + + template + _xvec3 operator- (const T s, const _xref3& v); + + template + _xvec3 operator- (const _xref3& v1, const _xref3& v2); + + template + _xvec3 operator- (const _xvec3& v1, const _xref3& v2); + + template + _xvec3 operator- (const _xref3& v1, const _xvec3& v2); + + // operator* + template + _xvec3 operator* (const _xvec3& v, const T s); + + template + _xvec3 operator* (const T s, const _xvec3& v); + + template + _xvec3 operator* (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator* (const _xref3& v, const T s); + + template + _xvec3 operator* (const T s, const _xref3& v); + + template + _xvec3 operator* (const _xref3& v1, const _xref3& v2); + + template + _xvec3 operator* (const _xvec3& v1, const _xref3& v2); + + template + _xvec3 operator* (const _xref3& v1, const _xvec3& v2); + + // operator/ + template + _xvec3 operator/ (const _xvec3& v, const T s); + + template + _xvec3 operator/ (const T s, const _xvec3& v); + + template + _xvec3 operator/ (const _xvec3& v1, const _xvec3& v2); + + template + _xvec3 operator/ (const _xref3& v, const T s); + + template + _xvec3 operator/ (const T s, const _xref3& v); + + template + _xvec3 operator/ (const _xref3& v1, const _xref3& v2); + + template + _xvec3 operator/ (const _xvec3& v1, const _xref3& v2); + + template + _xvec3 operator/ (const _xref3& v1, const _xvec3& v2); + + // Unary constant operators + template + const _xvec3 operator- (const _xvec3& v); + + template + const _xvec3 operator-- (const _xvec3& v, int); + + template + const _xvec3 operator++ (const _xvec3& v, int); + +} //namespace detail +} //namespace glm + +#endif//__glm_core_xvec3_h__ diff --git a/wip/sse/glm/core/_xvec3.inl b/wip/sse/glm/core/_xvec3.inl new file mode 100644 index 00000000..a11ce130 --- /dev/null +++ b/wip/sse/glm/core/_xvec3.inl @@ -0,0 +1,694 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_xvec3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_xvec3_inl__ +#define __glm_core_xvec3_inl__ + +#include "./_xvec2.h" +#include "./_bvec2.h" +#include "./_xvec3.h" +#include "./_bvec3.h" +#include "./_xvec4.h" +#include "./_bvec4.h" +#include "./_swizzle.inl" + +namespace glm{ +namespace detail{ + + // Common constructors + template + inline _xvec3::_xvec3() : + _cvec3(T(0), T(0), T(0)) + {} + + template + inline _xvec3::_xvec3(const _xvec3& v) : + _cvec3(v.x, v.y, v.z) + {} + + // Swizzle constructors + template + inline _xvec3::_xvec3(const _xref3& r) : + _cvec3(r.x, r.y, r.z) + {} + + template + inline _xvec3::_xvec3(const _xvec3_base(T)& b) : + _cvec3(b.x, b.y, b.z) + {} + + // T constructors + template + inline _xvec3::_xvec3(const T x) : + _cvec3(x, x, x) + {} + + template + inline _xvec3::_xvec3(const T a, const T b, const T c) : + _cvec3(a, b, c) + {} + + template + inline _xvec3::_xvec3(const T a, const T b, const _xvec2& c) : + _cvec3(a, b, c.x) + {} + + template + inline _xvec3::_xvec3(const T a, const T b, const _xvec3& c) : + _cvec3(a, b, c.x) + {} + + template + inline _xvec3::_xvec3(const T a, const T b, const _xvec4& c) : + _cvec3(a, b, c.x) + {} + + template + inline _xvec3::_xvec3(const T a, const _xvec2& b) : + _cvec3(a, b.x, b.y) + {} + + template + inline _xvec3::_xvec3(const T a, const _xvec3& b) : + _cvec3(a, b.x, b.y) + {} + + template + inline _xvec3::_xvec3(const T a, const _xvec4& b) : + _cvec3(a, b.x, b.y) + {} + + template + inline _xvec3::_xvec3(const _xvec2& a, T b) : + _cvec3(a.x, a.y, b) + {} + + template + inline _xvec3::_xvec3(const _xvec2& a, const _xvec2& b) : + _cvec3(a.x, a.y, b.x) + {} + + template + inline _xvec3::_xvec3(const _xvec2& a, const _xvec3& b) : + _cvec3(a.x, a.y, b.x) + {} + + template + inline _xvec3::_xvec3(const _xvec2& a, const _xvec4& b) : + _cvec3(a.x, a.y, b.x) + {} + + template + inline _xvec3::_xvec3(const _xvec4& a) : + _cvec3(a.x, a.y, a.z) + {} + + // U constructors + template + template + inline _xvec3::_xvec3(const U x) : + _cvec3(T(x), T(x), T(x)) + {} + + template + template + inline _xvec3::_xvec3(const U a, const U b, const U c) : + _cvec3(T(a), T(b), T(c)) + {} + + template + template + inline _xvec3::_xvec3(const U a, const U b, const _xvec2& c) : + _cvec3(T(a), T(b), T(c.x)) + {} + + template + template + inline _xvec3::_xvec3(const U a, const U b, const _xvec3& c) : + _cvec3(T(a), T(b), T(c.x)) + {} + + template + template + inline _xvec3::_xvec3(const U a, const U b, const _xvec4& c) : + _cvec3(T(a), T(b), T(c.x)) + {} + + template + template + inline _xvec3::_xvec3(const U a, const _xvec2& b) : + _cvec3(T(a), T(b.x), T(b.y)) + {} + + template + template + inline _xvec3::_xvec3(const U a, const _xvec3& b) : + _cvec3(T(a), T(b.x), T(b.y)) + {} + + template + template + inline _xvec3::_xvec3(const U a, const _xvec4& b) : + _cvec3(T(a), T(b.x), T(b.y)) + {} + + template + template + inline _xvec3::_xvec3(const _xvec2& a, U b) : + _cvec3(T(a.x), T(a.y), T(b)) + {} + + template + template + inline _xvec3::_xvec3(const _xvec2& a, const _xvec2& b) : + _cvec3(T(a.x), T(a.y), T(b.x)) + {} + + template + template + inline _xvec3::_xvec3(const _xvec2& a, const _xvec3& b) : + _cvec3(T(a.x), T(a.y), T(b.x)) + {} + + template + template + inline _xvec3::_xvec3(const _xvec2& a, const _xvec4& b) : + _cvec3(T(a.x), T(a.y), T(b.x)) + {} + + template + template + inline _xvec3::_xvec3(const _xvec3& a) : + _cvec3(T(a.x), T(a.y), T(a.z)) + {} + + template + template + inline _xvec3::_xvec3(const _xvec4& a) : + _cvec3(T(a.x), T(a.y), T(a.z)) + {} + + // Bool constructors + template + inline _xvec3::_xvec3(const bool x) : + _cvec3(T(x), T(x), T(x)) + {} + + template + inline _xvec3::_xvec3(const bool a, const bool b, const bool c) : + _cvec3(T(a), T(b), T(c)) + {} + + template + inline _xvec3::_xvec3(const bool a, const bool b, const _bvec2& c) : + _cvec3(T(a), T(b), T(c.x)) + {} + + template + inline _xvec3::_xvec3(const bool a, const bool b, const _bvec3& c) : + _cvec3(T(a), T(b), T(c.x)) + {} + + template + inline _xvec3::_xvec3(const bool a, const bool b, const _bvec4& c) : + _cvec3(T(a), T(b), T(c.x)) + {} + + template + inline _xvec3::_xvec3(const bool a, const _bvec2& b) : + _cvec3(T(a), T(b.x), T(b.y)) + {} + + template + inline _xvec3::_xvec3(const bool a, const _bvec3& b) : + _cvec3(T(a), T(b.x), T(b.y)) + {} + + template + inline _xvec3::_xvec3(const bool a, const _bvec4& b) : + _cvec3(T(a), T(b.x), T(b.y)) + {} + + template + inline _xvec3::_xvec3(const _bvec2& a, bool b) : + _cvec3(T(a.x), T(a.y), T(b)) + {} + + template + inline _xvec3::_xvec3(const _bvec2& a, const _bvec2& b) : + _cvec3(T(a.x), T(a.y), T(b.x)) + {} + + template + inline _xvec3::_xvec3(const _bvec2& a, const _bvec3& b) : + _cvec3(T(a.x), T(a.y), T(b.x)) + {} + + template + inline _xvec3::_xvec3(const _bvec2& a, const _bvec4& b) : + _cvec3(T(a.x), T(a.y), T(b.x)) + {} + + template + inline _xvec3::_xvec3(const _bvec3& a) : + _cvec3(T(a.x), T(a.y), T(a.z)) + {} + + template + inline _xvec3::_xvec3(const _bvec4& a) : + _cvec3(T(a.x), T(a.y), T(a.z)) + {} + + ////////////////////////////////////////////////////////////// + // vec3 and ivec3 operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + template + inline _xvec3& _xvec3::operator=(const _xvec3& v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + return *this; + } + + template + inline _xvec3& _xvec3::operator+= (const T s) + { + this->x += s; + this->y += s; + this->z += s; + return *this; + } + + template + inline _xvec3& _xvec3::operator+= (const _xvec3& v) + { + this->x += v.x; + this->y += v.y; + this->z += v.z; + return *this; + } + + template + inline _xvec3& _xvec3::operator-= (const T s) + { + this->x -= s; + this->y -= s; + this->z -= s; + return *this; + } + + template + inline _xvec3& _xvec3::operator-= (const _xvec3& v) + { + this->x -= v.x; + this->y -= v.y; + this->z -= v.z; + return *this; + } + + template + inline _xvec3& _xvec3::operator*= (const T s) + { + this->x *= s; + this->y *= s; + this->z *= s; + return *this; + } + + template + inline _xvec3& _xvec3::operator*= (const _xvec3& v) + { + this->x *= v.x; + this->y *= v.y; + this->z *= v.z; + return *this; + } + + template + inline _xvec3& _xvec3::operator/= (const T s) + { + this->x /= s; + this->y /= s; + this->z /= s; + return *this; + } + + template + inline _xvec3& _xvec3::operator/= (const _xvec3& v) + { + this->x /= v.x; + this->y /= v.y; + this->z /= v.z; + return *this; + } + + template + inline _xvec3& _xvec3::operator++ () + { + this->x++; + this->y++; + this->z++; + return *this; + } + + template + inline _xvec3& _xvec3::operator-- () + { + this->x--; + this->y--; + this->z--; + return *this; + } + + // Unary constant operators + template + inline const _xvec3 operator- (const _xvec3& v) + { + return _xvec3( + -v.x, + -v.y, + -v.z); + } + + template + inline const _xvec3 operator++ (const _xvec3& v, int) + { + return _xvec3( + v.x + T(1), + v.y + T(1), + v.z + T(1)); + } + + template + inline const _xvec3 operator-- (const _xvec3& v, int) + { + return _xvec3( + v.x - T(1), + v.y - T(1), + v.z - T(1)); + } + + // Binary operators + // operator+ + template + inline _xvec3 operator+ (const _xvec3& v, const T s) + { + return _xvec3( + v.x + s, + v.y + s, + v.z + s); + } + + template + inline _xvec3 operator+ (const T s, const _xvec3& v) + { + return _xvec3( + s + v.x, + s + v.y, + s + v.z); + } + + template + inline _xvec3 operator+ (const _xvec3& v1, const _xvec3& v2) + { + return _xvec3( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z); + } + + template + inline _xvec3 operator+ (const _xref3& v, const T s) + { + return _xvec3( + v.x + s, + v.y + s, + v.z + s); + } + + template + inline _xvec3 operator+ (const T s, const _xref3& v) + { + return _xvec3( + s + v.x, + s + v.y, + s + v.z); + } + + template + inline _xvec3 operator+ (const _xref3& v1, const _xref3& v2) + { + return _xvec3( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z); + } + + template + inline _xvec3 operator+ (const _xvec3& v1, const _xref3& v2) + { + return _xvec3( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z); + } + + template + inline _xvec3 operator+ (const _xref3& v1, const _xvec3& v2) + { + return _xvec3( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z); + } + + // operator- + template + inline _xvec3 operator- (const _xvec3& v, const T s) + { + return _xvec3( + v.x - s, + v.y - s, + v.z - s); + } + + template + inline _xvec3 operator- (const T s, const _xvec3& v) + { + return _xvec3( + s - v.x, + s - v.y, + s - v.z); + } + + template + inline _xvec3 operator- (const _xvec3& v1, const _xvec3& v2) + { + return _xvec3( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z); + } + + template + inline _xvec3 operator- (const _xref3& v, const T s) + { + return _xvec3( + v.x - s, + v.y - s, + v.z - s); + } + + template + inline _xvec3 operator- (const T s, const _xref3& v) + { + return _xvec3( + s - v.x, + s - v.y, + s - v.z); + } + + template + inline _xvec3 operator- (const _xref3& v1, const _xref3& v2) + { + return _xvec3( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z); + } + + template + inline _xvec3 operator- (const _xvec3& v1, const _xref3& v2) + { + return _xvec3( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z); + } + + template + inline _xvec3 operator- (const _xref3& v1, const _xvec3& v2) + { + return _xvec3( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z); + } + + // operator* + template + inline _xvec3 operator* (const _xvec3& v, const T s) + { + return _xvec3( + v.x * s, + v.y * s, + v.z * s); + } + + template + inline _xvec3 operator* (const T s, const _xvec3& v) + { + return _xvec3( + s * v.x, + s * v.y, + s * v.z); + } + + template + inline _xvec3 operator* (const _xvec3& v1, const _xvec3 & v2) + { + return _xvec3( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z); + } + + template + inline _xvec3 operator* (const _xref3& v, const T s) + { + return _xvec3( + v.x * s, + v.y * s, + v.z * s); + } + + template + inline _xvec3 operator* (const T s, const _xref3& v) + { + return _xvec3( + s * v.x, + s * v.y, + s * v.z); + } + + template + inline _xvec3 operator* (const _xref3& v1, const _xref3& v2) + { + return _xvec3( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z); + } + + template + inline _xvec3 operator* (const _xvec3& v1, const _xref3& v2) + { + return _xvec3( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z); + } + + template + inline _xvec3 operator* (const _xref3& v1, const _xvec3& v2) + { + return _xvec3( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z); + } + + // operator/ + template + inline _xvec3 operator/ (const _xvec3& v, const T s) + { + return _xvec3( + v.x / s, + v.y / s, + v.z / s); + } + + template + inline _xvec3 operator/ (const T s, const _xvec3& v) + { + return _xvec3( + s / v.x, + s / v.y, + s / v.z); + } + + template + inline _xvec3 operator/ (const _xvec3& v1, const _xvec3& v2) + { + return _xvec3( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z); + } + + template + inline _xvec3 operator/ (const _xref3& v, const T s) + { + return _xvec3( + v.x / s, + v.y / s, + v.z / s); + } + + template + inline _xvec3 operator/ (const T s, const _xref3& v) + { + return _xvec3( + s / v.x, + s / v.y, + s / v.z); + } + + template + inline _xvec3 operator/ (const _xref3& v1, const _xref3& v2) + { + return _xvec3( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z); + } + + template + inline _xvec3 operator/ (const _xvec3& v1, const _xref3& v2) + { + return _xvec3( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z); + } + + template + inline _xvec3 operator/ (const _xref3& v1, const _xvec3& v2) + { + return _xvec3( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z); + } +} //namespace detail +} //namespace glm + +#endif//__glm_core_xvec3_inl__ diff --git a/wip/sse/glm/core/_xvec4.h b/wip/sse/glm/core/_xvec4.h new file mode 100644 index 00000000..129df9b7 --- /dev/null +++ b/wip/sse/glm/core/_xvec4.h @@ -0,0 +1,241 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-15 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_xvec4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_xvec4_h__ +#define __glm_core_xvec4_h__ + +#include "./_cvec4.inl" + +namespace glm{ +namespace detail{ + + template + class _xvec4 : public _xvec4_base(T) + { + public: + // Common constructors + _xvec4(); + _xvec4(const _xvec4& v); + + // Swizzle constructors + _xvec4(const _xref4& r); + _xvec4(const _xvec4_base(T)& b); + + // T constructors + explicit _xvec4(const T x); + explicit _xvec4(const T a, const T b, const T c, const T d); + explicit _xvec4(const T a, const T b, const T c, const _xvec2& d); + explicit _xvec4(const T a, const T b, const T c, const _xvec3& d); + explicit _xvec4(const T a, const T b, const T c, const _xvec4& d); + explicit _xvec4(const T a, const T b, const _xvec2& c); + explicit _xvec4(const T a, const T b, const _xvec3& c); + explicit _xvec4(const T a, const T b, const _xvec4& c); + explicit _xvec4(const T a, const _xvec2& b, const T c); + explicit _xvec4(const T a, const _xvec2& b, const _xvec2& c); + explicit _xvec4(const T a, const _xvec2& b, const _xvec3& c); + explicit _xvec4(const T a, const _xvec2& b, const _xvec4& c); + explicit _xvec4(const T a, const _xvec3& b); + explicit _xvec4(const T a, const _xvec4& b); + explicit _xvec4(const _xvec2& a, const T b, const T c); + explicit _xvec4(const _xvec2& a, const T b, const _xvec2& c); + explicit _xvec4(const _xvec2& a, const T b, const _xvec3& c); + explicit _xvec4(const _xvec2& a, const T b, const _xvec4& c); + explicit _xvec4(const _xvec2& a, const _xvec2& b); + explicit _xvec4(const _xvec2& a, const _xvec3& b); + explicit _xvec4(const _xvec2& a, const _xvec4& b); + explicit _xvec4(const _xvec3& a, const T b); + explicit _xvec4(const _xvec3& a, const _xvec2& b); + explicit _xvec4(const _xvec3& a, const _xvec3& b); + explicit _xvec4(const _xvec3& a, const _xvec4& b); + + // U constructors + template explicit _xvec4(const U x); + template explicit _xvec4(const U a, const U b, const U c, const U d); + template explicit _xvec4(const U a, const U b, const U c, const _xvec2& d); + template explicit _xvec4(const U a, const U b, const U c, const _xvec3& d); + template explicit _xvec4(const U a, const U b, const U c, const _xvec4& d); + template explicit _xvec4(const U a, const U b, const _xvec2& c); + template explicit _xvec4(const U a, const U b, const _xvec3& c); + template explicit _xvec4(const U a, const U b, const _xvec4& c); + template explicit _xvec4(const U a, const _xvec2& b, const U c); + template explicit _xvec4(const U a, const _xvec2& b, const _xvec2& c); + template explicit _xvec4(const U a, const _xvec2& b, const _xvec3& c); + template explicit _xvec4(const U a, const _xvec2& b, const _xvec4& c); + template explicit _xvec4(const U a, const _xvec3& b); + template explicit _xvec4(const U a, const _xvec4& b); + template explicit _xvec4(const _xvec2& a, const U b, const U c); + template explicit _xvec4(const _xvec2& a, const U b, const _xvec2& c); + template explicit _xvec4(const _xvec2& a, const U b, const _xvec3& c); + template explicit _xvec4(const _xvec2& a, const U b, const _xvec4& c); + template explicit _xvec4(const _xvec2& a, const _xvec2& b); + template explicit _xvec4(const _xvec2& a, const _xvec3& b); + template explicit _xvec4(const _xvec2& a, const _xvec4& b); + template explicit _xvec4(const _xvec3& a, const U b); + template explicit _xvec4(const _xvec3& a, const _xvec2& b); + template explicit _xvec4(const _xvec3& a, const _xvec3& b); + template explicit _xvec4(const _xvec3& a, const _xvec4& b); + template explicit _xvec4(const _xvec4& a); + + // Bool constructors + explicit _xvec4(const bool x); + explicit _xvec4(const bool a, const bool b, const bool c, const bool d); + explicit _xvec4(const bool a, const bool b, const bool c, const _bvec2& d); + explicit _xvec4(const bool a, const bool b, const bool c, const _bvec3& d); + explicit _xvec4(const bool a, const bool b, const bool c, const _bvec4& d); + explicit _xvec4(const bool a, const bool b, const _bvec2& c); + explicit _xvec4(const bool a, const bool b, const _bvec3& c); + explicit _xvec4(const bool a, const bool b, const _bvec4& c); + explicit _xvec4(const bool a, const _bvec2& b, const bool c); + explicit _xvec4(const bool a, const _bvec2& b, const _bvec2& c); + explicit _xvec4(const bool a, const _bvec2& b, const _bvec3& c); + explicit _xvec4(const bool a, const _bvec2& b, const _bvec4& c); + explicit _xvec4(const bool a, const _bvec3& b); + explicit _xvec4(const bool a, const _bvec4& b); + explicit _xvec4(const _bvec2& a, const bool b, const bool c); + explicit _xvec4(const _bvec2& a, const bool b, const _bvec2& c); + explicit _xvec4(const _bvec2& a, const bool b, const _bvec3& c); + explicit _xvec4(const _bvec2& a, const bool b, const _bvec4& c); + explicit _xvec4(const _bvec2& a, const _bvec2& b); + explicit _xvec4(const _bvec2& a, const _bvec3& b); + explicit _xvec4(const _bvec2& a, const _bvec4& b); + explicit _xvec4(const _bvec3& a, const bool b); + explicit _xvec4(const _bvec3& a, const _bvec2& b); + explicit _xvec4(const _bvec3& a, const _bvec3& b); + explicit _xvec4(const _bvec3& a, const _bvec4& b); + explicit _xvec4(const _bvec4& a); + + // Unary updatable operators + _xvec4& operator= (const _xvec4& x); + _xvec4& operator+=(const T s); + _xvec4& operator+=(const _xvec4& v); + _xvec4& operator-=(const T s); + _xvec4& operator-=(const _xvec4& v); + _xvec4& operator*=(const T s); + _xvec4& operator*=(const _xvec4& v); + _xvec4& operator/=(const T s); + _xvec4& operator/=(const _xvec4& v); + _xvec4& operator++(); + _xvec4& operator--(); + }; + + // Binary operators + // operator+ + template + _xvec4 operator+ (const _xvec4& v, const T s); + + template + _xvec4 operator+ (const T s, const _xvec4& v); + + template + _xvec4 operator+ (const _xvec4& v1, const _xvec4& v2); + + template + _xvec4 operator+ (const _xref4& v, const T s); + + template + _xvec4 operator+ (const T s, const _xref4& v); + + template + _xvec4 operator+ (const _xref4& v1, const _xref4& v2); + + template + _xvec4 operator+ (const _xvec4& v1, const _xref4& v2); + + template + _xvec4 operator+ (const _xref4& v1, const _xvec4& v2); + + // operator- + template + _xvec4 operator- (const _xvec4& v, const T s); + + template + _xvec4 operator- (const T s, const _xvec4& v); + + template + _xvec4 operator- (const _xvec4& v1, const _xvec4& v2); + + template + _xvec4 operator- (const _xref4& v, const T s); + + template + _xvec4 operator- (const T s, const _xref4& v); + + template + _xvec4 operator- (const _xref4& v1, const _xref4& v2); + + template + _xvec4 operator- (const _xvec4& v1, const _xref4& v2); + + template + _xvec4 operator- (const _xref4& v1, const _xvec4& v2); + + // operator* + template + _xvec4 operator* (const _xvec4& v, const T s); + + template + _xvec4 operator* (const T s, const _xvec4& v); + + template + _xvec4 operator* (const _xvec4& v1, const _xvec4& v2); + + template + _xvec4 operator* (const _xref4& v, const T s); + + template + _xvec4 operator* (const T s, const _xref4& v); + + template + _xvec4 operator* (const _xref4& v1, const _xref4& v2); + + template + _xvec4 operator* (const _xvec4& v1, const _xref4& v2); + + template + _xvec4 operator* (const _xref4& v1, const _xvec4& v2); + + // operator/ + template + _xvec4 operator/ (const _xvec4& v, const T s); + + template + _xvec4 operator/ (const T s, const _xvec4& v); + + template + _xvec4 operator/ (const _xvec4& v1, const _xvec4& v2); + + template + _xvec4 operator/ (const _xref4& v, const T s); + + template + _xvec4 operator/ (const T s, const _xref4& v); + + template + _xvec4 operator/ (const _xref4& v1, const _xref4& v2); + + template + _xvec4 operator/ (const _xvec4& v1, const _xref4& v2); + + template + _xvec4 operator/ (const _xref4& v1, const _xvec4& v2); + + // Unary constant operators + template + const _xvec4 operator- (const _xvec4& v); + + template + const _xvec4 operator-- (const _xvec4& v, int); + + template + const _xvec4 operator++ (const _xvec4& v, int); + +} //namespace detail +} //namespace glm + +#endif//__glm_core_xvec4_h__ diff --git a/wip/sse/glm/core/_xvec4.inl b/wip/sse/glm/core/_xvec4.inl new file mode 100644 index 00000000..c73d5af5 --- /dev/null +++ b/wip/sse/glm/core/_xvec4.inl @@ -0,0 +1,1242 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-27 +// Updated : 2007-01-19 +// Licence : This source is under GNU LGPL licence +// File : glm/core/_xvec4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_core_xvec4_inl__ +#define __glm_core_xvec4_inl__ + +#include "./_xvec2.h" +#include "./_bvec2.h" +#include "./_xvec3.h" +#include "./_bvec3.h" +#include "./_xvec4.h" +#include "./_bvec4.h" +#include "./_swizzle.inl" + +namespace glm{ +namespace detail{ + + // Common constructors + template + inline _xvec4::_xvec4() : + _cvec4(T(0), T(0), T(0), T(0)) + {} + + template + inline _xvec4::_xvec4(const _xvec4& v) : + _cvec4(v.x, v.y, v.z, v.w) + {} + + // Swizzle constructors + template + inline _xvec4::_xvec4(const _xref4& r) : + _cvec4(r.x, r.y, r.z, r.w) + {} + + template + inline _xvec4::_xvec4(const _xvec4_base(T)& b) : + _cvec4(b.x, b.y, b.z, b.w) + {} + + // T constructors + template + inline _xvec4::_xvec4(const T s) : + _cvec4(s, s, s, s) + {} + + template + inline _xvec4::_xvec4(const T x, const T y, const T z, const T w) : + _cvec4(x, y, z, w) + {} + + template + inline _xvec4::_xvec4(const T s1, const T s2, const T s3, const _xvec2& v) : + _cvec4(s1, s2, s3, v.x) + {} + + template + inline _xvec4::_xvec4(const T s1, const T s2, const T s3, const _xvec3& v) : + _cvec4(s1, s2, s3, v.x) + {} + + template + inline _xvec4::_xvec4(const T s1, const T s2, const T s3, const _xvec4& v) : + _cvec4(s1, s2, s3, v.x) + {} + + template + inline _xvec4::_xvec4(const T s1, const T s2, const _xvec2& v) : + _cvec4(s1, s2, v.x, v.y) + {} + + template + inline _xvec4::_xvec4(const T s1, const T s2, const _xvec3& v) : + _cvec4(s1, s2, v.x, v.y) + {} + + template + inline _xvec4::_xvec4(const T s1, const T s2, const _xvec4& v) : + _cvec4(s1, s2, v.x, v.y) + {} + + template + inline _xvec4::_xvec4(const T s1, const _xvec2& v, const T s2) : + _cvec4(s1, v.x, v.y, s2) + {} + + template + inline _xvec4::_xvec4(const T s, const _xvec2& v1, const _xvec2& v2) : + _cvec4(s, v1.x, v1.y, v2.x) + {} + + template + inline _xvec4::_xvec4(const T s, const _xvec2& v1, const _xvec3& v2) : + _cvec4(s, v1.x, v1.y, v2.x) + {} + + template + inline _xvec4::_xvec4(const T s, const _xvec2& v1, const _xvec4& v2) : + _cvec4(s, v1.x, v1.y, v2.x) + {} + + template + inline _xvec4::_xvec4(const T s, const _xvec3& v) : + _cvec4(s, v.x, v.y, v.z) + {} + + template + inline _xvec4::_xvec4(const T s, const _xvec4& v) : + _cvec4(s, v.x, v.y, v.z) + {} + + template + inline _xvec4::_xvec4(const _xvec2& v, const T s1, const T s2) : + _cvec4(v.x, v.y, s1, s2) + {} + + template + inline _xvec4::_xvec4(const _xvec2& v1, const T s, const _xvec2& v2) : + _cvec4(v1.x, v1.y, s, v2.x) + {} + + template + inline _xvec4::_xvec4(const _xvec2& v1, const T s, const _xvec3& v2) : + _cvec4(v1.x, v1.y, s, v2.x) + {} + + template + inline _xvec4::_xvec4(const _xvec2& v1, const T s, const _xvec4& v2) : + _cvec4(v1.x, v1.y, s, v2.x) + {} + + template + inline _xvec4::_xvec4(const _xvec2& v1, const _xvec2& v2) : + _cvec4(v1.x, v1.y, v2.x, v2.y) + {} + + template + inline _xvec4::_xvec4(const _xvec2& v1, const _xvec3& v2) : + _cvec4(v1.x, v1.y, v2.x, v2.y) + {} + + template + inline _xvec4::_xvec4(const _xvec2& v1, const _xvec4& v2) : + _cvec4(v1.x, v1.y, v2.x, v2.y) + {} + + template + inline _xvec4::_xvec4(const _xvec3& v, const T s) : + _cvec4(v.x, v.y, v.z, s) + {} + + template + inline _xvec4::_xvec4(const _xvec3& v1, const _xvec2& v2) : + _cvec4(v1.x, v1.y, v1.z, v2.x) + {} + + template + inline _xvec4::_xvec4(const _xvec3& v1, const _xvec3& v2) : + _cvec4(v1.x, v1.y, v1.z, v2.x) + {} + + template + inline _xvec4::_xvec4(const _xvec3& v1, const _xvec4& v2) : + _cvec4(v1.x, v1.y, v1.z, v2.x) + {} + + // U constructors + template + template + inline _xvec4::_xvec4(const U s) : + _cvec4(T(s), T(s), T(s), T(s)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const U s2, const U s3, const U s4) : + _cvec4(T(s1), T(s2), T(s3), T(s4)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const U s2, const U s3, const _xvec2& v) : + _cvec4(T(s1), T(s2), T(s3), T(v.x)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const U s2, const U s3, const _xvec3& v) : + _cvec4(T(s1), T(s2), T(s3), T(v.x)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const U s2, const U s3, const _xvec4& v) : + _cvec4(T(s1), T(s2), T(s3), T(v.x)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const U s2, const _xvec2& v) : + _cvec4(T(s1), T(s2), T(v.x), T(v.y)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const U s2, const _xvec3& v) : + _cvec4(T(s1), T(s2), T(v.x), T(v.y)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const U s2, const _xvec4& v) : + _cvec4(T(s1), T(s2), T(v.x), T(v.y)) + {} + + template + template + inline _xvec4::_xvec4(const U s1, const _xvec2& v, const U s2) : + _cvec4(T(s1), T(v.x), T(v.y), T(s2)) + {} + + template + template + inline _xvec4::_xvec4(const U s, const _xvec2& v1, const _xvec2& v2) : + _cvec4(T(s), T(v1.x), T(v1.y), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const U s, const _xvec2& v1, const _xvec3& v2) : + _cvec4(T(s), T(v1.x), T(v1.y), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const U s, const _xvec2& v1, const _xvec4& v2) : + _cvec4(T(s), T(v1.x), T(v1.y), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const U s, const _xvec3& v) : + _cvec4(T(s), T(v.x), T(v.y), T(v.z)) + {} + + template + template + inline _xvec4::_xvec4(const U s, const _xvec4& v) : + _cvec4(T(s), T(v.x), T(v.y), T(v.z)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec2& v, const U s1, const U s2) : + _cvec4(T(v.x), T(v.y), T(s1), T(s2)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec2& v1, const U s, const _xvec2& v2) : + _cvec4(T(v1.x), T(v1.y), T(s), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec2& v1, const U s, const _xvec3& v2) : + _cvec4(T(v1.x), T(v1.y), T(s), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec2& v1, const U s, const _xvec4& v2) : + _cvec4(T(v1.x), T(v1.y), T(s), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec2& v1, const _xvec2& v2) : + _cvec4(T(v1.x), T(v1.y), T(v2.x), T(v2.y)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec2& v1, const _xvec3& v2) : + _cvec4(T(v1.x), T(v1.y), T(v2.x), T(v2.y)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec2& v1, const _xvec4& v2) : + _cvec4(T(v1.x), T(v1.y), T(v2.x), T(v2.y)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec3& v, const U s) : + _cvec4(T(v.x), T(v.y), T(v.z), T(s)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec3& v1, const _xvec2& v2) : + _cvec4(T(v1.x), T(v1.y), T(v1.z), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec3& v1, const _xvec3& v2) : + _cvec4(T(v1.x), T(v1.y), T(v1.z), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec3& v1, const _xvec4& v2) : + _cvec4(T(v1.x), T(v1.y), T(v1.z), T(v2.x)) + {} + + template + template + inline _xvec4::_xvec4(const _xvec4& v) : + _cvec4(T(v.x), T(v.y), T(v.z), T(v.w)) + {} + + // Bool constructors + template + inline _xvec4::_xvec4(const bool x) : + _cvec4(T(x), T(x), T(x), T(x)) + {} + + template + inline _xvec4::_xvec4(const bool x, const bool y, const bool z, const bool w) : + _cvec4(T(x), T(y), T(z), T(w)) + {} + + template + inline _xvec4::_xvec4(const bool s1, const bool s2, const bool s3, const _bvec2& v) : + _cvec4(T(s1), T(s2), T(s3), T(v.x)) + {} + + template + inline _xvec4::_xvec4(const bool s1, const bool s2, const bool s3, const _bvec3& v) : + _cvec4(T(s1), T(s2), T(s3), T(v.x)) + {} + + template + inline _xvec4::_xvec4(const bool s1, const bool s2, const bool s3, const _bvec4& v) : + _cvec4(T(s1), T(s2), T(s3), T(v.x)) + {} + + template + inline _xvec4::_xvec4(const bool s1, const bool s2, const _bvec2& v) : + _cvec4(T(s1), T(s2), T(v.x), T(v.y)) + {} + + template + inline _xvec4::_xvec4(const bool s1, const bool s2, const _bvec3& v) : + _cvec4(T(s1), T(s2), T(v.x), T(v.y)) + {} + + template + inline _xvec4::_xvec4(const bool s1, const bool s2, const _bvec4& v) : + _cvec4(T(s1), T(s2), T(v.x), T(v.y)) + {} + + template + inline _xvec4::_xvec4(const bool s1, const _bvec2& v, const bool s2) : + _cvec4(T(s1), T(v.x), T(v.y), T(s2)) + {} + + template + inline _xvec4::_xvec4(const bool s, const _bvec2& v1, const _bvec2& v2) : + _cvec4(T(s), T(v1.x), T(v1.y), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const bool s, const _bvec2& v1, const _bvec3& v2) : + _cvec4(T(s), T(v1.x), T(v1.y), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const bool s, const _bvec2& v1, const _bvec4& v2) : + _cvec4(T(s), T(v1.x), T(v1.y), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const bool s, const _bvec3& v) : + _cvec4(T(s), T(v.x), T(v.y), T(v.z)) + {} + + template + inline _xvec4::_xvec4(const bool s, const _bvec4& v) : + _cvec4(T(s), T(v.x), T(v.y), T(v.z)) + {} + + template + inline _xvec4::_xvec4(const _bvec2& v, const bool s1, const bool s2) : + _cvec4(T(v.x), T(v.y), T(s1), T(s2)) + {} + + template + inline _xvec4::_xvec4(const _bvec2& v1, const bool s, const _bvec2& v2) : + _cvec4(T(v1.x), T(v1.y), T(s), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const _bvec2& v1, const bool s, const _bvec3& v2) : + _cvec4(T(v1.x), T(v1.y), T(s), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const _bvec2& v1, const bool s, const _bvec4& v2) : + _cvec4(T(v1.x), T(v1.y), T(s), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const _bvec2& v1, const _bvec2& v2) : + _cvec4(T(v1.x), T(v1.y), T(v2.x), T(v2.y)) + {} + + template + inline _xvec4::_xvec4(const _bvec2& v1, const _bvec3& v2) : + _cvec4(T(v1.x), T(v1.y), T(v2.x), T(v2.y)) + {} + + template + inline _xvec4::_xvec4(const _bvec2& v1, const _bvec4& v2) : + _cvec4(T(v1.x), T(v1.y), T(v2.x), T(v2.y)) + {} + + template + inline _xvec4::_xvec4(const _bvec3& v, const bool s) : + _cvec4(T(v.x), T(v.y), T(v.z), T(s)) + {} + + template + inline _xvec4::_xvec4(const _bvec3& v1, const _bvec2& v2) : + _cvec4(T(v1.x), T(v1.y), T(v1.z), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const _bvec3& v1, const _bvec3& v2) : + _cvec4(T(v1.x), T(v1.y), T(v1.z), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const _bvec3& v1, const _bvec4& v2) : + _cvec4(T(v1.x), T(v1.y), T(v1.z), T(v2.x)) + {} + + template + inline _xvec4::_xvec4(const _bvec4& v) : + _cvec4(T(v.x), T(v.y), T(v.z), T(v.w)) + {} + + // vec4 and ivec4 operators definitions + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + template + inline _xvec4& _xvec4::operator=(const _xvec4& x) + { + this->x = x.x; + this->y = x.y; + this->z = x.z; + this->w = x.w; + return *this; + } + + template + inline _xvec4& _xvec4::operator+= (const T s) + { + this->x += s; + this->y += s; + this->z += s; + this->w += s; + return *this; + } + + template + inline _xvec4& _xvec4::operator+=(const _xvec4 & v) + { + this->x += v.x; + this->y += v.y; + this->z += v.z; + this->w += v.w; + return *this; + } + + template + inline _xvec4& _xvec4::operator-= (const T s) + { + this->x -= s; + this->y -= s; + this->z -= s; + this->w -= s; + return *this; + } + + template + inline _xvec4& _xvec4::operator-=(const _xvec4 & v) + { + this->x -= v.x; + this->y -= v.y; + this->z -= v.z; + this->w -= v.w; + return *this; + } + + template + inline _xvec4& _xvec4::operator*=(const T s) + { + this->x *= s; + this->y *= s; + this->z *= s; + this->w *= s; + return *this; + } + + template + inline _xvec4& _xvec4::operator*= (const _xvec4 & v) + { + this->x *= v.x; + this->y *= v.y; + this->z *= v.z; + this->w *= v.w; + return *this; + } + + template + inline _xvec4& _xvec4::operator/=(const T s) + { + this->x /= s; + this->y /= s; + this->z /= s; + this->w /= s; + return *this; + } + + template + inline _xvec4& _xvec4::operator/= (const _xvec4 & v) + { + this->x /= v.x; + this->y /= v.y; + this->z /= v.z; + this->w /= v.w; + return *this; + } + + template + inline _xvec4& _xvec4::operator++ () + { + ++this->x; + ++this->y; + ++this->z; + ++this->w; + return *this; + } + + template + inline _xvec4& _xvec4::operator-- () + { + --this->x; + --this->y; + --this->z; + --this->w; + return *this; + } + + // Unary constant operators + template + inline const _xvec4 operator- (const _xvec4& v) + { + return _xvec4( + -v.x, + -v.y, + -v.z, + -v.w); + } + + template + inline const _xvec4 operator++ (const _xvec4& v, int) + { + return _xvec4( + v.x + T(1), + v.y + T(1), + v.z + T(1), + v.w + T(1)); + } + + template + inline const _xvec4 operator-- (const _xvec4& v, int) + { + return _xvec4( + v.x - T(1), + v.y - T(1), + v.z - T(1), + v.w - T(1)); + } +/* + template + inline _xvec4& operator%=(const T s) + { + this->x %= s; + this->y %= s; + this->z %= s; + this->w %= s; + return *this; + } + + template + inline _xvec4& operator%=(const _xvec4& v) + { + this->x %= v.x; + this->y %= v.y; + this->z %= v.z; + this->w %= v.w; + return *this; + } + + template + inline _xvec4& operator&=(const T s) + { + this->x &= s; + this->y &= s; + this->z &= s; + this->w &= s; + return *this; + } + + template + inline _xvec4& operator&=(const _xvec4& v) + { + this->x &= v.x; + this->y &= v.y; + this->z &= v.z; + this->w &= v.w; + return *this; + } + + template + inline _xvec4& operator|=(const T s) + { + this->x |= s; + this->y |= s; + this->z |= s; + this->w |= s; + return *this; + } + + template + inline _xvec4& operator|=(const _xvec4& v) + { + this->x |= v.x; + this->y |= v.y; + this->z |= v.z; + this->w |= v.w; + return *this; + } + + template + inline _xvec4& operator^=(const T s) + { + this->x ^= s; + this->y ^= s; + this->z ^= s; + this->w ^= s; + return *this; + } + + template + inline _xvec4& operator^=(const _xvec4& v) + { + this->x ^= v.x; + this->y ^= v.y; + this->z ^= v.z; + this->w ^= v.w; + return *this; + } + + template + inline _xvec4& operator<<=(const T s) + { + this->x <<= s; + this->y <<= s; + this->z <<= s; + this->w <<= s; + return *this; + } + + template + inline _xvec4& operator<<=(const _xvec4& v) + { + this->x <<= v.x; + this->y <<= v.y; + this->z <<= v.z; + this->w <<= v.w; + return *this; + } + + template + inline _xvec4& operator>>=(const T s) + { + this->x >>= s; + this->y >>= s; + this->z >>= s; + this->w >>= s; + return *this; + } + + template + inline _xvec4& operator>>=(const _xvec4& v) + { + this->x >>= v.x; + this->y >>= v.y; + this->z >>= v.z; + this->w >>= v.w; + return *this; + } + + // Bit operators + template + inline _xvec4 operator% (const _xvec4& v, const T s) + { + return _xvec4( + v.x % s, + v.y % s, + v.z % s, + v.w % s); + } + + template + inline _xvec4 operator% (const T s, const _xvec4& v) + { + return _xvec4( + s % v.x, + s % v.y, + s % v.z, + s % v.w); + } + + template + inline _xvec4 operator% (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x % v2.x, + v1.y % v2.y, + v1.z % v2.z, + v1.w % v2.w); + } + + template + inline _xvec4 operator& (const _xvec4& v, const T s) + { + return _xvec4( + v.x & s, + v.y & s, + v.z & s, + v.w & s); + } + + template + inline _xvec4 operator& (const T s, const _xvec4& v) + { + return _xvec4( + s & v.x, + s & v.y, + s & v.z, + s & v.w); + } + + template + inline _xvec4 operator& (const _xvec4& v1, const _xvec4& v2) + { + return _xvec2( + v1.x & v2.x, + v1.y & v2.y, + v1.z & v2.z, + v1.w & v2.w); + } + + template + inline _xvec4 operator| (const _xvec4& v, const T s) + { + return _xvec4( + v.x | s, + v.y | s, + v.z | s, + v.w | s); + } + + template + inline _xvec4 operator| (const T s, const _xvec4& v) + { + return _xvec4( + s | v.x, + s | v.y, + s | v.z, + s | v.w); + } + + template + inline _xvec4 operator| (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x | v2.x, + v1.y | v2.y, + v1.z | v2.z, + v1.w | v2.w); + } + + template + inline _xvec4 operator^ (const _xvec4& v, const T s) + { + return _xvec4( + v.x ^ s, + v.y ^ s, + v.z ^ s, + v.w ^ s); + } + + template + inline _xvec4 operator^ (const T s, const _xvec4& v) + { + return _xvec4( + s ^ v.x, + s ^ v.y, + s ^ v.z, + s ^ v.w); + } + + template + inline _xvec4 operator^ (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x ^ v2.x, + v1.y ^ v2.y, + v1.z ^ v2.z, + v1.w ^ v2.w); + } + + template + inline _xvec4 operator<< (const _xvec4& v, const T s) + { + return _xvec4( + v.x << s, + v.y << s, + v.z << s, + v.w << s); + } + + template + inline _xvec4 operator<< (const T s, const _xvec4& v) + { + return _xvec4( + s << v.x, + s << v.y, + s << v.z, + s << v.w); + } + + template + inline _xvec4 operator<< (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x << v2.x, + v1.y << v2.y, + v1.z << v2.z, + v1.w << v2.w); + } + + template + inline _xvec4 operator>> (const _xvec4& v, const T s) + { + return _xvec4( + v.x >> s, + v.y >> s, + v.z >> s, + v.w >> s); + } + + template + inline _xvec4 operator>> (const T s, const _xvec4& v) + { + return _xvec4( + s >> v.x, + s >> v.y, + s >> v.z, + s >> v.w); + } + + template + inline _xvec4 operator>> (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x >> v2.x, + v1.y >> v2.y, + v1.z >> v2.z, + v1.w >> v2.w); + } + + template + inline const _xvec4 operator~ (const _xvec4& v) + { + return _xvec4( + ~v.x, + ~v.y, + ~v.z, + ~v.w); + } +*/ + // Binary operators + //operator+ + template + inline _xvec4 operator+ (const _xvec4& v, const T s) + { + return _xvec4( + v.x + s, + v.y + s, + v.z + s, + v.w + s); + } + + template + inline _xvec4 operator+ (const T s, const _xvec4& v) + { + return _xvec4( + v.x + s, + v.y + s, + v.z + s, + v.w + s); + } + + template + inline _xvec4 operator+ (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z, + v1.w + v2.w); + } + + template + inline _xvec4 operator+ (const _xref4& v, const T s) + { + return _xvec4( + v.x + s, + v.y + s, + v.z + s, + v.w + s); + } + + template + inline _xvec4 operator+ (const T s, const _xref4& v) + { + return _xvec4( + s + v.x, + s + v.y, + s + v.z, + s + v.w); + } + + template + inline _xvec4 operator+ (const _xref4& v1, const _xref4& v2) + { + return _xvec4( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z, + v1.w + v2.w); + } + + template + inline _xvec4 operator+ (const _xvec4& v1, const _xref4& v2) + { + return _xvec4( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z, + v1.w + v2.w); + } + + template + inline _xvec4 operator+ (const _xref4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x + v2.x, + v1.y + v2.y, + v1.z + v2.z, + v1.w + v2.w); + } + + //operator- + template + inline _xvec4 operator- (const _xvec4& v, const T s) + { + return _xvec4( + v.x - s, + v.y - s, + v.z - s, + v.w - s); + } + + template + inline _xvec4 operator- (const T s, const _xvec4& v) + { + return _xvec4( + s - v.x, + s - v.y, + s - v.z, + s - v.w); + } + + template + inline _xvec4 operator- (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z, + v1.w - v2.w); + } + + template + inline _xvec4 operator- (const _xref4& v, const T s) + { + return _xvec4( + v.x - s, + v.y - s, + v.z - s, + v.w - s); + } + + template + inline _xvec4 operator- (const T s, const _xref4& v) + { + return _xvec4( + s - v.x, + s - v.y, + s - v.z, + s - v.w); + } + + template + inline _xvec4 operator- (const _xref4& v1, const _xref4& v2) + { + return _xvec4( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z, + v1.w - v2.w); + } + + template + inline _xvec4 operator- (const _xvec4& v1, const _xref4& v2) + { + return _xvec4( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z, + v1.w - v2.w); + } + + template + inline _xvec4 operator- (const _xref4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x - v2.x, + v1.y - v2.y, + v1.z - v2.z, + v1.w - v2.w); + } + + //operator* + template + inline _xvec4 operator* (const _xvec4& v, const T s) + { + return _xvec4( + v.x * s, + v.y * s, + v.z * s, + v.w * s); + } + + template + inline _xvec4 operator* (const T s, const _xvec4& v) + { + return _xvec4( + s * v.x, + s * v.y, + s * v.z, + s * v.w); + } + + template + inline _xvec4 operator* (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z, + v1.w * v2.w); + } + + template + inline _xvec4 operator* (const _xref4& v, const T s) + { + return _xvec4( + v.x * s, + v.y * s, + v.z * s, + v.w * s); + } + + template + inline _xvec4 operator* (const T s, const _xref4& v) + { + return _xvec4( + s * v.x, + s * v.y, + s * v.z, + s * v.w); + } + + template + inline _xvec4 operator* (const _xref4& v1, const _xref4& v2) + { + return _xvec4( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z, + v1.w * v2.w); + } + + template + inline _xvec4 operator* (const _xvec4& v1, const _xref4& v2) + { + return _xvec4( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z, + v1.w * v2.w); + } + + template + inline _xvec4 operator* (const _xref4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x * v2.x, + v1.y * v2.y, + v1.z * v2.z, + v1.w * v2.w); + } + + // operator/ + template + inline _xvec4 operator/ (const _xvec4& v, const T s) + { + return _xvec4( + v.x / s, + v.y / s, + v.z / s, + v.w / s); + } + + template + inline _xvec4 operator/ (const T s, const _xvec4& v) + { + return _xvec4( + s / v.x, + s / v.y, + s / v.z, + s / v.w); + } + + template + inline _xvec4 operator/ (const _xvec4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z, + v1.w / v2.w); + } + + template + inline _xvec4 operator/ (const _xref4& v, const T s) + { + return _xvec4( + v.x / s, + v.y / s, + v.z / s, + v.w / s); + } + + template + inline _xvec4 operator/ (const T s, const _xref4& v) + { + return _xvec4( + s / v.x, + s / v.y, + s / v.z, + s / v.w); + } + + template + inline _xvec4 operator/ (const _xref4& v1, const _xref4& v2) + { + return _xvec4( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z, + v1.w / v2.w); + } + + template + inline _xvec4 operator/ (const _xvec4& v1, const _xref4& v2) + { + return _xvec4( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z, + v1.w / v2.w); + } + + template + inline _xvec4 operator/ (const _xref4& v1, const _xvec4& v2) + { + return _xvec4( + v1.x / v2.x, + v1.y / v2.y, + v1.z / v2.z, + v1.w / v2.w); + } +} //namespace detail +} //namespace glm + +#endif//__glm_core_xvec4_inl__ diff --git a/wip/sse/glm/ext/gtx.h b/wip/sse/glm/ext/gtx.h new file mode 100644 index 00000000..0d71dec5 --- /dev/null +++ b/wip/sse/glm/ext/gtx.h @@ -0,0 +1,81 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-04-03 +// Updated : 2007-08-03 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Note: +// GTX extensions are experimental extensions +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_glx__ +#define __glm_glx__ + +//#include "./gtx/array_range.h" +#include "./gtx/associated_min_max.h" +#include "./gtx/bit.h" +#include "./gtx/closest_point.h" +#include "./gtx/color_cast.h" +#include "./gtx/color_space.h" +#include "./gtx/compatibility.h" +#include "./gtx/component_wise.h" +//#include "./gtx/complex.h" +#include "./gtx/determinant.h" +#include "./gtx/double.h" +#include "./gtx/epsilon.h" +#include "./gtx/euler_angles.h" +#include "./gtx/extend.h" +#include "./gtx/extented_min_max.h" +#include "./gtx/fast_exponential.h" +#include "./gtx/fast_square_root.h" +#include "./gtx/fast_trigonometry.h" +#include "./gtx/flexible_mix.h" +#include "./gtx/gpu_shader4.h" +#include "./gtx/half.h" +#include "./gtx/handed_coordinate_space.h" +#include "./gtx/hyperbolic.h" +#include "./gtx/inertia.h" +#include "./gtx/integer.h" +#include "./gtx/intersect.h" +#include "./gtx/inverse.h" +#include "./gtx/inverse_transpose.h" +#include "./gtx/mat4x3.h" +//#include "./gtx/mat_mn.h" +#include "./gtx/matrix_access.h" +#include "./gtx/matrix_cross_product.h" +#include "./gtx/matrix_major_storage.h" +#include "./gtx/matrix_projection.h" +#include "./gtx/matrix_query.h" +#include "./gtx/matrix_selection.h" +#include "./gtx/matx.h" +#include "./gtx/mixed_product.h" +#include "./gtx/mul.h" +#include "./gtx/norm.h" +#include "./gtx/normal.h" +#include "./gtx/normalize_dot.h" +#include "./gtx/number_precision.h" +#include "./gtx/optimum_pow.h" +#include "./gtx/orthonormalize.h" +#include "./gtx/outer_product.h" +#include "./gtx/perpendicular.h" +#include "./gtx/polar_coordinates.h" +#include "./gtx/projection.h" +#include "./gtx/quaternion.h" +#include "./gtx/random.h" +#include "./gtx/rotate_vector.h" +#include "./gtx/round.h" +#include "./gtx/spline.h" +#include "./gtx/transform.h" +#include "./gtx/transform2.h" +#include "./gtx/transpose.h" +#include "./gtx/unsigned_int.h" +#include "./gtx/vector_access.h" +#include "./gtx/vector_angle.h" +#include "./gtx/vector_comp_mult.h" +#include "./gtx/vector_query.h" +#include "./gtx/vecx.h" +#include "./gtx/verbose_operator.h" + +#endif //__glm_glx__ diff --git a/wip/sse/glm/ext/gtx/associated_min_max.h b/wip/sse/glm/ext/gtx/associated_min_max.h new file mode 100644 index 00000000..cd7e0bb3 --- /dev/null +++ b/wip/sse/glm/ext/gtx/associated_min_max.h @@ -0,0 +1,518 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-03-10 +// Updated : 2008-03-15 +// Licence : This source is under GNU LGPL licence +// File : gtx_associated_min_max.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_extented_min_max +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_associated_min_max__ +#define __glm_gtx_associated_min_max__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + //! Min comparison between 2 variables + template + U associatedMinGTX( + T x, U a, + T y, U b); + + //! Min comparison between 2 variables + template + detail::_xvec2 associatedMinGTX( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b); + + //! Min comparison between 2 variables + template + detail::_xvec3 associatedMinGTX( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b); + + //! Min comparison between 2 variables + template + detail::_xvec4 associatedMinGTX( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b); + + //! Min comparison between 2 variables + template + detail::_xvec2 associatedMinGTX( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b); + + //! Min comparison between 2 variables + template + detail::_xvec3 associatedMinGTX( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b); + + //! Min comparison between 2 variables + template + detail::_xvec4 associatedMinGTX( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b); + + //! Min comparison between 2 variables + template + detail::_xvec2 associatedMinGTX( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b); + + //! Min comparison between 2 variables + template + detail::_xvec3 associatedMinGTX( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b); + + //! Min comparison between 2 variables + template + detail::_xvec4 associatedMinGTX( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b); + + //! Min comparison between 3 variables + template + U associatedMinGTX( + T x, U a, + T y, U b, + T z, U c); + + //! Min comparison between 3 variables + template + detail::_xvec2 associatedMinGTX( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c); + + //! Min comparison between 3 variables + template + detail::_xvec3 associatedMinGTX( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c); + + //! Min comparison between 3 variables + template + detail::_xvec4 associatedMinGTX( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c); + + //! Min comparison between 3 variables + template + detail::_xvec2 associatedMinGTX( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b, + T z, const detail::_xvec2& c); + + //! Min comparison between 3 variables + template + detail::_xvec3 associatedMinGTX( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b, + T z, const detail::_xvec3& c); + + //! Min comparison between 3 variables + template + detail::_xvec4 associatedMinGTX( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b, + T z, const detail::_xvec4& c); + + //! Min comparison between 3 variables + template + detail::_xvec2 associatedMinGTX( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b, + const detail::_xvec2& z, U c); + + //! Min comparison between 3 variables + template + detail::_xvec3 associatedMinGTX( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b, + const detail::_xvec3& z, U c); + + //! Min comparison between 3 variables + template + detail::_xvec4 associatedMinGTX( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b, + const detail::_xvec4& z, U c); + + //! Min comparison between 4 variables + template + U associatedMinGTX( + T x, U a, + T y, U b, + T z, U c, + T w, U d); + + //! Min comparison between 4 variables + template + detail::_xvec2 associatedMinGTX( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c, + const detail::_xvec2& w, const detail::_xvec2& d); + + //! Min comparison between 4 variables + template + detail::_xvec3 associatedMinGTX( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c, + const detail::_xvec3& w, const detail::_xvec3& d); + + //! Min comparison between 4 variables + template + detail::_xvec4 associatedMinGTX( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c, + const detail::_xvec4& w, const detail::_xvec4& d); + + //! Min comparison between 4 variables + template + detail::_xvec2 associatedMinGTX( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b, + T z, const detail::_xvec2& c, + T w, const detail::_xvec2& d); + + //! Min comparison between 4 variables + template + detail::_xvec3 associatedMinGTX( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b, + T z, const detail::_xvec3& c, + T w, const detail::_xvec3& d); + + //! Min comparison between 4 variables + template + detail::_xvec4 associatedMinGTX( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b, + T z, const detail::_xvec4& c, + T w, const detail::_xvec4& d); + + //! Min comparison between 4 variables + template + detail::_xvec2 associatedMinGTX( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b, + const detail::_xvec2& z, U c, + const detail::_xvec2& w, U d); + + //! Min comparison between 4 variables + template + detail::_xvec3 associatedMinGTX( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b, + const detail::_xvec3& z, U c, + const detail::_xvec3& w, U d); + + //! Min comparison between 4 variables + template + detail::_xvec4 associatedMinGTX( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b, + const detail::_xvec4& z, U c, + const detail::_xvec4& w, U d); + + //! Max comparison between 2 variables + template + U associatedMaxGTX( + T x, U a, + T y, U b); + + //! Max comparison between 2 variables + template + detail::_xvec2 associatedMaxGTX( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b); + + //! Max comparison between 2 variables + template + detail::_xvec3 associatedMaxGTX( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b); + + //! Max comparison between 2 variables + template + detail::_xvec4 associatedMaxGTX( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b); + + //! Max comparison between 2 variables + template + detail::_xvec2 associatedMaxGTX( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b); + + //! Max comparison between 2 variables + template + detail::_xvec3 associatedMaxGTX( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b); + + //! Max comparison between 2 variables + template + detail::_xvec4 associatedMaxGTX( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b); + + //! Max comparison between 2 variables + template + detail::_xvec2 associatedMaxGTX( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b); + + //! Max comparison between 2 variables + template + detail::_xvec3 associatedMaxGTX( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b); + + //! Max comparison between 2 variables + template + detail::_xvec4 associatedMaxGTX( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b); + + //! Max comparison between 3 variables + template + U associatedMaxGTX( + T x, U a, + T y, U b, + T z, U c); + + //! Max comparison between 3 variables + template + detail::_xvec2 associatedMaxGTX( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c); + + //! Max comparison between 3 variables + template + detail::_xvec3 associatedMaxGTX( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c); + + //! Max comparison between 3 variables + template + detail::_xvec4 associatedMaxGTX( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c); + + //! Max comparison between 3 variables + template + detail::_xvec2 associatedMaxGTX( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b, + T z, const detail::_xvec2& c); + + //! Max comparison between 3 variables + template + detail::_xvec3 associatedMaxGTX( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b, + T z, const detail::_xvec3& c); + + //! Max comparison between 3 variables + template + detail::_xvec4 associatedMaxGTX( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b, + T z, const detail::_xvec4& c); + + //! Max comparison between 3 variables + template + detail::_xvec2 associatedMaxGTX( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b, + const detail::_xvec2& z, U c); + + //! Max comparison between 3 variables + template + detail::_xvec3 associatedMaxGTX( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b, + const detail::_xvec3& z, U c); + + //! Max comparison between 3 variables + template + detail::_xvec4 associatedMaxGTX( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b, + const detail::_xvec4& z, U c); + + //! Max comparison between 4 variables + template + U associatedMaxGTX( + T x, U a, + T y, U b, + T z, U c, + T w, U d); + + //! Max comparison between 4 variables + template + detail::_xvec2 associatedMaxGTX( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c, + const detail::_xvec2& w, const detail::_xvec2& d); + + //! Max comparison between 4 variables + template + detail::_xvec3 associatedMaxGTX( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c, + const detail::_xvec3& w, const detail::_xvec3& d); + + //! Max comparison between 4 variables + template + detail::_xvec4 associatedMaxGTX( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c, + const detail::_xvec4& w, const detail::_xvec4& d); + + //! Max comparison between 4 variables + template + detail::_xvec2 associatedMaxGTX( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b, + T z, const detail::_xvec2& c, + T w, const detail::_xvec2& d); + + //! Max comparison between 4 variables + template + detail::_xvec3 associatedMaxGTX( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b, + T z, const detail::_xvec3& c, + T w, const detail::_xvec3& d); + + //! Max comparison between 4 variables + template + detail::_xvec4 associatedMaxGTX( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b, + T z, const detail::_xvec4& c, + T w, const detail::_xvec4& d); + + //! Max comparison between 4 variables + template + detail::_xvec2 associatedMaxGTX( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b, + const detail::_xvec2& z, U c, + const detail::_xvec2& w, U d); + + //! Max comparison between 4 variables + template + detail::_xvec3 associatedMaxGTX( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b, + const detail::_xvec3& z, U c, + const detail::_xvec3& w, U d); + + //! Max comparison between 4 variables + template + detail::_xvec4 associatedMaxGTX( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b, + const detail::_xvec4& z, U c, + const detail::_xvec4& w, U d); + + namespace gtx + { + //! GLM_GTX_associated_min_max extension: Min and max functions that return associated values not the compared onces. + namespace associated_min_max + { + //! Min comparison between 2 variables + template + inline genTypeU associatedMin( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b) + { + return associatedMinGTX(x, a, y, b); + } + + //! Min comparison between 3 variables + template + inline genTypeU associatedMin( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c) + { + return associatedMinGTX(x, a, y, b, z, c); + } + + //! Min comparison between 4 variables + template + inline genTypeU associatedMin( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c, + const genTypeT& w, const genTypeU& d) + { + return associatedMinGTX(x, a, y, b, z, c, w, d); + } + + //! Max comparison between 2 variables + template + inline genTypeU associatedMax( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b) + { + return associatedMaxGTX(x, a, y, b); + } + + //! Max comparison between 3 variables + template + inline genTypeU associatedMax( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c) + { + return associatedMaxGTX(x, a, y, b, z, c); + } + + //! Max comparison between 4 variables + template + inline genTypeU associatedMax( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c, + const genTypeT& w, const genTypeU& d) + { + return associatedMaxGTX(x, a, y, b, z, c, w, d); + } + } + } +} + +#define GLM_GTX_associated_min_max namespace gtx::associated_min_max + +#include "associated_min_max.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_associated_min_max;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_associated_min_max__ diff --git a/wip/sse/glm/ext/gtx/associated_min_max.inl b/wip/sse/glm/ext/gtx/associated_min_max.inl new file mode 100644 index 00000000..e3f6c10c --- /dev/null +++ b/wip/sse/glm/ext/gtx/associated_min_max.inl @@ -0,0 +1,911 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-03-10 +// Updated : 2008-03-15 +// Licence : This source is under GNU LGPL licence +// File : gtx_associated_min_max.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // Min comparison between 2 variables + template + inline U associatedMinGTX(T x, U a, T y, U b) + { + return x < y ? a : b; + } + + template + inline detail::_xvec2 associatedMinGTX + ( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b + ) + { + detail::_xvec2 Result; + //Result.x = x[0] < y[0] ? a[0] : b[0]; + //Result.y = x[1] < y[1] ? a[1] : b[1]; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; + } + + template + inline detail::_xvec3 associatedMinGTX + ( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; + } + + template + inline detail::_xvec4 associatedMinGTX + ( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; + } + + template + inline detail::_xvec2 associatedMinGTX + ( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; + } + + template + inline detail::_xvec3 associatedMinGTX + ( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; + } + + template + inline detail::_xvec4 associatedMinGTX + ( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; + } + + template + inline detail::_xvec2 associatedMinGTX + ( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; + } + + template + inline detail::_xvec3 associatedMinGTX + ( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; + } + + template + inline detail::_xvec4 associatedMinGTX + ( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; + } + + // Min comparison between 3 variables + template + inline U associatedMinGTX + ( + T x, U a, + T y, U b, + T z, U c + ) + { + U Result = x < y ? (x < z ? a : c) : (y < z ? b : c); + return Result; + } + + template + inline detail::_xvec2 associatedMinGTX + ( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; + } + + template + inline detail::_xvec3 associatedMinGTX + ( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; + } + + template + inline detail::_xvec4 associatedMinGTX + ( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; + } + + // Min comparison between 4 variables + template + inline U associatedMinGTX + ( + T x, U a, + T y, U b, + T z, U c, + T w, U d + ) + { + T Test1 = min(x, y); + T Test2 = min(z, w);; + U Result1 = x < y ? a : b; + U Result2 = z < w ? c : d; + U Result = Test1 < Test2 ? Result1 : Result2; + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec2 associatedMinGTX + ( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c, + const detail::_xvec2& w, const detail::_xvec2& d + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec3 associatedMinGTX + ( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c, + const detail::_xvec3& w, const detail::_xvec3& d + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec4 associatedMinGTX + ( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c, + const detail::_xvec4& w, const detail::_xvec4& d + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec2 associatedMinGTX + ( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b, + T z, const detail::_xvec2& c, + T w, const detail::_xvec2& d + ) + { + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + { + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec3 associatedMinGTX + ( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b, + T z, const detail::_xvec3& c, + T w, const detail::_xvec3& d + ) + { + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + { + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec4 associatedMinGTX + ( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b, + T z, const detail::_xvec4& c, + T w, const detail::_xvec4& d + ) + { + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + { + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec2 associatedMinGTX + ( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b, + const detail::_xvec2& z, U c, + const detail::_xvec2& w, U d + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec3 associatedMinGTX + ( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b, + const detail::_xvec3& z, U c, + const detail::_xvec3& w, U d + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Min comparison between 4 variables + template + inline detail::_xvec4 associatedMinGTX + ( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b, + const detail::_xvec4& z, U c, + const detail::_xvec4& w, U d + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 2 variables + template + inline U associatedMaxGTX(T x, U a, T y, U b) + { + return x > y ? a : b; + } + + // Max comparison between 2 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; + } + + // Max comparison between 2 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; + } + + // Max comparison between 3 variables + template + inline U associatedMaxGTX + ( + T x, U a, + T y, U b, + T z, U c + ) + { + U Result = x > y ? (x > z ? a : c) : (y > z ? b : c); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b, + T z, const detail::_xvec2& c + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b, + T z, const detail::_xvec3& c + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b, + T z, const detail::_xvec4& c + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b, + const detail::_xvec2& z, U c + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b, + const detail::_xvec3& z, U c + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; + } + + // Max comparison between 3 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b, + const detail::_xvec4& z, U c + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; + } + + // Max comparison between 4 variables + template + inline U associatedMaxGTX + ( + T x, U a, + T y, U b, + T z, U c, + T w, U d + ) + { + T Test1 = max(x, y); + T Test2 = max(z, w);; + U Result1 = x > y ? a : b; + U Result2 = z > w ? c : d; + U Result = Test1 > Test2 ? Result1 : Result2; + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + const detail::_xvec2& x, const detail::_xvec2& a, + const detail::_xvec2& y, const detail::_xvec2& b, + const detail::_xvec2& z, const detail::_xvec2& c, + const detail::_xvec2& w, const detail::_xvec2& d + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + const detail::_xvec3& x, const detail::_xvec3& a, + const detail::_xvec3& y, const detail::_xvec3& b, + const detail::_xvec3& z, const detail::_xvec3& c, + const detail::_xvec3& w, const detail::_xvec3& d + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + const detail::_xvec4& x, const detail::_xvec4& a, + const detail::_xvec4& y, const detail::_xvec4& b, + const detail::_xvec4& z, const detail::_xvec4& c, + const detail::_xvec4& w, const detail::_xvec4& d + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + T x, const detail::_xvec2& a, + T y, const detail::_xvec2& b, + T z, const detail::_xvec2& c, + T w, const detail::_xvec2& d + ) + { + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + { + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + T x, const detail::_xvec3& a, + T y, const detail::_xvec3& b, + T z, const detail::_xvec3& c, + T w, const detail::_xvec3& d + ) + { + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + { + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + T x, const detail::_xvec4& a, + T y, const detail::_xvec4& b, + T z, const detail::_xvec4& c, + T w, const detail::_xvec4& d + ) + { + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + { + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec2 associatedMaxGTX + ( + const detail::_xvec2& x, U a, + const detail::_xvec2& y, U b, + const detail::_xvec2& z, U c, + const detail::_xvec2& w, U d + ) + { + detail::_xvec2 Result; + for(detail::_xvec2::size_type i = 0; i < detail::_xvec2::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec3 associatedMaxGTX + ( + const detail::_xvec3& x, U a, + const detail::_xvec3& y, U b, + const detail::_xvec3& z, U c, + const detail::_xvec3& w, U d + ) + { + detail::_xvec3 Result; + for(detail::_xvec3::size_type i = 0; i < detail::_xvec3::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } + + // Max comparison between 4 variables + template + inline detail::_xvec4 associatedMaxGTX + ( + const detail::_xvec4& x, U a, + const detail::_xvec4& y, U b, + const detail::_xvec4& z, U c, + const detail::_xvec4& w, U d + ) + { + detail::_xvec4 Result; + for(detail::_xvec4::size_type i = 0; i < detail::_xvec4::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; + } +} diff --git a/wip/sse/glm/ext/gtx/bit.h b/wip/sse/glm/ext/gtx/bit.h new file mode 100644 index 00000000..46c41259 --- /dev/null +++ b/wip/sse/glm/ext/gtx/bit.h @@ -0,0 +1,76 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-14 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/bit.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_gpu_shader4 +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_bit__ +#define __glm_gtx_bit__ + +// Dependency: +#include "../../glm.h" +#include "../../ext/gtx/gpu_shader4.h" + +namespace glm +{ + template int highestBitGTX(const T value); //!< \brief Find the highest bit set to 1 in a integer variable. (From GLM_GTX_bit extension) + template detail::_xvec2 highestBitGTX(const detail::_xvec2& value); //!< \brief Find the highest bit set to 1 in a integer variable. (From GLM_GTX_bit extension) + template detail::_xvec3 highestBitGTX(const detail::_xvec3& value); //!< \brief Find the highest bit set to 1 in a integer variable. (From GLM_GTX_bit extension) + template detail::_xvec4 highestBitGTX(const detail::_xvec4& value); //!< \brief Find the highest bit set to 1 in a integer variable. (From GLM_GTX_bit extension) + + template T highestBitValueGTX(const T value); //!< \brief Find the highest bit set to 1 in a integer variable and return its value. (From GLM_GTX_bit extension) + template detail::_xvec2 highestBitValueGTX(const detail::_xvec2& value); //!< \brief Find the highest bit set to 1 in a integer variable and return its value. (From GLM_GTX_bit extension) + template detail::_xvec3 highestBitValueGTX(const detail::_xvec3& value); //!< \brief Find the highest bit set to 1 in a integer variable and return its value. (From GLM_GTX_bit extension) + template detail::_xvec4 highestBitValueGTX(const detail::_xvec4& value); //!< \brief Find the highest bit set to 1 in a integer variable and return its value. (From GLM_GTX_bit extension) + + template bool isPowerOfTwoGTX(const T value); //!< \brief Return true if the value is a power of two number. (From GLM_GTX_bit extension) + template detail::_bvec2 isPowerOfTwoGTX(const detail::_xvec2& value); //!< \brief Return true if the value is a power of two number. (From GLM_GTX_bit extension) + template detail::_bvec3 isPowerOfTwoGTX(const detail::_xvec3& value); //!< \brief Return true if the value is a power of two number. (From GLM_GTX_bit extension) + template detail::_bvec4 isPowerOfTwoGTX(const detail::_xvec4& value); //!< \brief Return true if the value is a power of two number. (From GLM_GTX_bit extension) + + template T powerOfTwoAboveGTX(const T value); //!< \brief Return the power of two number which value is just higher the input value. (From GLM_GTX_bit extension) + template detail::_xvec2 powerOfTwoAboveGTX(const detail::_xvec2& value); //!< \brief Return the power of two number which value is just higher the input value. (From GLM_GTX_bit extension) + template detail::_xvec3 powerOfTwoAboveGTX(const detail::_xvec3& value); //!< \brief Return the power of two number which value is just higher the input value. (From GLM_GTX_bit extension) + template detail::_xvec4 powerOfTwoAboveGTX(const detail::_xvec4& value); //!< \brief Return the power of two number which value is just higher the input value. (From GLM_GTX_bit extension) + + template T powerOfTwoBelowGTX(const T value); //!< \brief Return the power of two number which value is just lower the input value. (From GLM_GTX_bit extension) + template detail::_xvec2 powerOfTwoBelowGTX(const detail::_xvec2& value); //!< \brief Return the power of two number which value is just lower the input value. (From GLM_GTX_bit extension) + template detail::_xvec3 powerOfTwoBelowGTX(const detail::_xvec3& value); //!< \brief Return the power of two number which value is just lower the input value. (From GLM_GTX_bit extension) + template detail::_xvec4 powerOfTwoBelowGTX(const detail::_xvec4& value); //!< \brief Return the power of two number which value is just lower the input value. (From GLM_GTX_bit extension) + + template T powerOfTwoNearestGTX(const T value); //!< \brief Return the power of two number which value is the closet to the input value. (From GLM_GTX_bit extension) + template detail::_xvec2 powerOfTwoNearestGTX(const detail::_xvec2& value); //!< \brief Return the power of two number which value is the closet to the input value. (From GLM_GTX_bit extension) + template detail::_xvec3 powerOfTwoNearestGTX(const detail::_xvec3& value); //!< \brief Return the power of two number which value is the closet to the input value. (From GLM_GTX_bit extension) + template detail::_xvec4 powerOfTwoNearestGTX(const detail::_xvec4& value); //!< \brief Return the power of two number which value is the closet to the input value. (From GLM_GTX_bit extension) + + namespace gtx + { + //! GLM_GTX_bit extension: Allow to perform bit operations on integer values + namespace bit + { + template inline int highestBit(const T& value){return highestBitGTX(value);} //!< \brief Find the highest bit set to 1 in a integer variable. (From GLM_GTX_bit extension) + template inline T highestBitValue(const T& value){return highestBitValueGTX(value);} //!< \brief Find the highest bit set to 1 in a integer variable and return its value. (From GLM_GTX_bit extension) + template inline bool isPowerOfTwo(const T& value){return isPowerOfTwoGTX(value);} //!< \brief Return true if the value is a power of two number. (From GLM_GTX_bit extension) + template inline T powerOfTwoAbove(const T& value){return powerOfTwoAboveGTX(value);} //!< \brief Return the power of two number which value is just higher the input value. (From GLM_GTX_bit extension) + template inline T powerOfTwoBelow(const T& value){return powerOfTwoBelowGTX(value);} //!< \brief Return the power of two number which value is just lower the input value. (From GLM_GTX_bit extension) + template inline T powerOfTwoNearest(const T& value){return powerOfTwoNearestGTX(value);} //!< \brief Return the power of two number which value is the closet to the input value. (From GLM_GTX_bit extension) + } + } +} + +#define GLM_GTX_bit namespace gtx::bit + +#include "bit.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_bit;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_bit__ diff --git a/wip/sse/glm/ext/gtx/bit.inl b/wip/sse/glm/ext/gtx/bit.inl new file mode 100644 index 00000000..65f2d86c --- /dev/null +++ b/wip/sse/glm/ext/gtx/bit.inl @@ -0,0 +1,242 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-14 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/bit.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_bit_inl__ +#define __glm_gtx_bit_inl__ + +namespace glm +{ + // highestBitGTX + template + inline int highestBitGTX(const T value) + { + T bit = -1; + for(T tmp = value; tmp; tmp >>= 1, ++bit); + return bit; + } + + template <> + inline int highestBitGTX(const int value) + { + int bit = -1; + for(int tmp = value; tmp; tmp >>= 1, ++bit); + return bit; + } + + template + inline detail::_xvec2 highestBitGTX(const detail::_xvec2& value) + { + return detail::_xvec2( + highestBitGTX(value[0]), + highestBitGTX(value[1])); + } + + template + inline detail::_xvec3 highestBitGTX(const detail::_xvec3& value) + { + return detail::_xvec3( + highestBitGTX(value[0]), + highestBitGTX(value[1]), + highestBitGTX(value[2])); + } + + template + inline detail::_xvec4 highestBitGTX(const detail::_xvec4& value) + { + return detail::_xvec4( + highestBitGTX(value[0]), + highestBitGTX(value[1]), + highestBitGTX(value[2]), + highestBitGTX(value[3])); + } + + // highestBitValueGTX + template + inline T highestBitValueGTX(const T value) + { + T tmp = value; + T result = T(0); + while(tmp) + { + result = (tmp & (~tmp + 1)); // grab lowest bit + tmp &= ~result; // clear lowest bit + } + return result; + } + + template + inline detail::_xvec2 highestBitValueGTX(const detail::_xvec2& value) + { + return detail::_xvec2( + highestBitValueGTX(value[0]), + highestBitValueGTX(value[1])); + } + + template + inline detail::_xvec3 highestBitValueGTX(const detail::_xvec3& value) + { + return detail::_xvec3( + highestBitValueGTX(value[0]), + highestBitValueGTX(value[1]), + highestBitValueGTX(value[2])); + } + + template + inline detail::_xvec4 highestBitValueGTX(const detail::_xvec4& value) + { + return detail::_xvec4( + highestBitValueGTX(value[0]), + highestBitValueGTX(value[1]), + highestBitValueGTX(value[2]), + highestBitValueGTX(value[3])); + } + + // isPowerOfTwoGTX + template + inline bool isPowerOfTwoGTX(const T value) + { + return !(value & (value - 1)); + } + + template + inline detail::_bvec2 isPowerOfTwoGTX(const detail::_xvec2& value) + { + return detail::_bvec2( + isPowerOfTwoGTX(value[0]), + isPowerOfTwoGTX(value[1])); + } + + template + inline detail::_bvec3 isPowerOfTwoGTX(const detail::_xvec3& value) + { + return detail::_bvec3( + isPowerOfTwoGTX(value[0]), + isPowerOfTwoGTX(value[1]), + isPowerOfTwoGTX(value[2])); + } + + template + inline detail::_bvec4 isPowerOfTwoGTX(const detail::_xvec4& value) + { + return detail::_bvec4( + isPowerOfTwoGTX(value[0]), + isPowerOfTwoGTX(value[1]), + isPowerOfTwoGTX(value[2]), + isPowerOfTwoGTX(value[3])); + } + + // powerOfTwoAboveGTX + template + inline T powerOfTwoAboveGTX(const T value) + { + return isPowerOfTwoGTX(value) ? value : highestBitValueGTX(value) << 1; + } + + template + inline detail::_xvec2 powerOfTwoAboveGTX(const detail::_xvec2& value) + { + return detail::_xvec2( + powerOfTwoAboveGTX(value[0]), + powerOfTwoAboveGTX(value[1])); + } + + template + inline detail::_xvec3 powerOfTwoAboveGTX(const detail::_xvec3& value) + { + return detail::_xvec3( + powerOfTwoAboveGTX(value[0]), + powerOfTwoAboveGTX(value[1]), + powerOfTwoAboveGTX(value[2])); + } + + template + inline detail::_xvec4 powerOfTwoAboveGTX(const detail::_xvec4& value) + { + return detail::_xvec4( + powerOfTwoAboveGTX(value[0]), + powerOfTwoAboveGTX(value[1]), + powerOfTwoAboveGTX(value[2]), + powerOfTwoAboveGTX(value[3])); + } + + // powerOfTwoBelowGTX + template + inline T powerOfTwoBelowGTX(const T value) + { + return isPowerOfTwoGTX(value) ? value : highestBitValueGTX(value); + } + + template + inline detail::_xvec2 powerOfTwoBelowGTX(const detail::_xvec2& value) + { + return detail::_xvec2( + powerOfTwoBelowGTX(value[0]), + powerOfTwoBelowGTX(value[1])); + } + + template + inline detail::_xvec3 powerOfTwoBelowGTX(const detail::_xvec3& value) + { + return detail::_xvec3( + powerOfTwoBelowGTX(value[0]), + powerOfTwoBelowGTX(value[1]), + powerOfTwoBelowGTX(value[2])); + } + + template + inline detail::_xvec4 powerOfTwoBelowGTX(const detail::_xvec4& value) + { + return detail::_xvec4( + powerOfTwoBelowGTX(value[0]), + powerOfTwoBelowGTX(value[1]), + powerOfTwoBelowGTX(value[2]), + powerOfTwoBelowGTX(value[3])); + } + + // powerOfTwoNearestGTX + template + inline T powerOfTwoNearestGTX(const T value) + { + if(isPowerOfTwoGTX(value)) + return value; + + T prev = highestBitValueGTX(value); + T next = prev << 1; + return (next - value) < (value - prev) ? next : prev; + } + + template + inline detail::_xvec2 powerOfTwoNearestGTX(const detail::_xvec2& value) + { + return detail::_xvec2( + powerOfTwoNearestGTX(value[0]), + powerOfTwoNearestGTX(value[1])); + } + + template + inline detail::_xvec3 powerOfTwoNearestGTX(const detail::_xvec3& value) + { + return detail::_xvec3( + powerOfTwoNearestGTX(value[0]), + powerOfTwoNearestGTX(value[1]), + powerOfTwoNearestGTX(value[2])); + } + + template + inline detail::_xvec4 powerOfTwoNearestGTX(const detail::_xvec4& value) + { + return detail::_xvec4( + powerOfTwoNearestGTX(value[0]), + powerOfTwoNearestGTX(value[1]), + powerOfTwoNearestGTX(value[2]), + powerOfTwoNearestGTX(value[3])); + } +} + +#endif//__glm_gtx_bit_inl__ diff --git a/wip/sse/glm/ext/gtx/closest_point.h b/wip/sse/glm/ext/gtx/closest_point.h new file mode 100644 index 00000000..d6331757 --- /dev/null +++ b/wip/sse/glm/ext/gtx/closest_point.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-30 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/closest_point.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_closest_point__ +#define __glm_gtx_closest_point__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + //! Find the point on a straight line which is the closet of a point. (from GLM_GTX_closest_point extension) + template + detail::_xvec3 closestPointOnLineGTX( + const detail::_xvec3& point, + const detail::_xvec3& a, + const detail::_xvec3& b); + + namespace gtx + { + //! GLM_GTX_closest_point extension: Find the point on a straight line which is the closet of a point. + namespace closest_point + { + //! Find the point on a straight line which is the closet of a point. (from GLM_GTX_closest_point extension) + template + inline detail::_xvec3 closestPointOnLine( + const detail::_xvec3& point, + const detail::_xvec3& a, + const detail::_xvec3& b) + { + return closestPointOnLineGTX(point, a, b); + } + } + } +} + +#define GLM_GTX_closest_point namespace gtx::closest_point + +#include "closest_point.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_closest_point;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_closest_point__ diff --git a/wip/sse/glm/ext/gtx/closest_point.inl b/wip/sse/glm/ext/gtx/closest_point.inl new file mode 100644 index 00000000..ad082f3b --- /dev/null +++ b/wip/sse/glm/ext/gtx/closest_point.inl @@ -0,0 +1,31 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-30 +// Updated : 2006-01-04 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/closest_point.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_closest_point_inl__ +#define __glm_gtx_closest_point_inl__ + +namespace glm +{ + template + inline detail::_xvec3 closestPointOnLineGTX(const detail::_xvec3& point, const detail::_xvec3& a, const detail::_xvec3& b) + { + T LineLength = distance(a, b); + detail::_xvec3 Vector = point - a; + detail::_xvec3 LineDirection = (b - a) / LineLength; + + // Project Vector to LineDirection to get the distance of point from a + T Distance = dot(Vector, LineDirection); + + if(Distance <= 0) return a; + if(Distance >= LineLength) return b; + return a + LineDirection * Distance; + } +} + +#endif//__glm_gtx_closest_point_inl__ diff --git a/wip/sse/glm/ext/gtx/color_cast.h b/wip/sse/glm/ext/gtx/color_cast.h new file mode 100644 index 00000000..db645524 --- /dev/null +++ b/wip/sse/glm/ext/gtx/color_cast.h @@ -0,0 +1,165 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-06-21 +// Updated : 2007-08-03 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/color_cast.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_half +// - GLM_GTX_double +// - GLM_GTX_int +// - GLM_GTX_unsigned_int +// - GLM_GTX_number_precision +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_color_cast__ +#define __glm_gtx_color_cast__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/half.h" +#include "../gtx/double.h" +#include "../gtx/integer.h" +#include "../gtx/unsigned_int.h" +#include "../gtx/number_precision.h" + +namespace glm +{ + template __uint8GTX u8channel_castGTX(T a); //!< Conversion of a floating value into a 8bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint16GTX u16channel_castGTX(T a); //!< Conversion of a floating value into a 16bit unsigned int value. (From GLM_GTX_color_cast extension) + + template __uint32GTX u32_rgbx_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint32GTX u32_xrgb_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint32GTX u32_bgrx_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint32GTX u32_xbgr_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + + template __uint32GTX u32_rgba_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint32GTX u32_argb_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint32GTX u32_bgra_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint32GTX u32_abgr_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + + template __uint64GTX u64_rgbx_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint64GTX u64_xrgb_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint64GTX u64_bgrx_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint64GTX u64_xbgr_castGTX(const detail::_xvec3& c); //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + + template __uint64GTX u64_rgba_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint64GTX u64_argb_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint64GTX u64_bgra_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template __uint64GTX u64_abgr_castGTX(const detail::_xvec4& c); //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + + template __halfGTX f16_channel_castGTX(T a); //!< Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template detail::_xvec3<__halfGTX> f16_rgbx_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3<__halfGTX> f16_xrgb_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3<__halfGTX> f16_bgrx_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3<__halfGTX> f16_xbgr_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template detail::_xvec4<__halfGTX> f16_rgba_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4<__halfGTX> f16_argb_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4<__halfGTX> f16_bgra_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4<__halfGTX> f16_abgr_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + template float f32_channel_castGTX(T a); //!< Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template detail::_xvec3 f32_rgbx_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3 f32_xrgb_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3 f32_bgrx_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3 f32_xbgr_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template detail::_xvec4 f32_rgba_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4 f32_argb_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4 f32_bgra_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4 f32_abgr_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + template double f64_channel_castGTX(T a); //!< Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template detail::_xvec3 f64_rgbx_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3 f64_xrgb_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3 f64_bgrx_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec3 f64_xbgr_castGTX(T color); //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template detail::_xvec4 f64_rgba_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4 f64_argb_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4 f64_bgra_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template detail::_xvec4 f64_abgr_castGTX(T color); //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + namespace gtx + { + //! GLM_GTX_color_cast extension: Conversion between two color types + namespace color_cast + { + template inline __uint8GTX u8channel_cast(T a){return u8channel_castGTX(a);} //!< Conversion of a floating value into a 8bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint16GTX u16channel_cast(T a){return u16channel_castGTX(a);} //!< Conversion of a floating value into a 16bit unsigned int value. (From GLM_GTX_color_cast extension) + + template inline __uint32GTX u32_rgbx_cast(const detail::_xvec3& c){return u32_rgbx_castGTX(c);} //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint32GTX u32_xrgb_cast(const detail::_xvec3& c){return u32_xrgb_castGTX(c);} //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint32GTX u32_bgrx_cast(const detail::_xvec3& c){return u32_bgrx_castGTX(c);} //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint32GTX u32_xbgr_cast(const detail::_xvec3& c){return u32_xbgr_castGTX(c);} //!< Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + + template inline __uint32GTX u32_rgba_cast(const detail::_xvec4& c){return u32_rgba_castGTX(c);} //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint32GTX u32_argb_cast(const detail::_xvec4& c){return u32_argb_castGTX(c);} //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint32GTX u32_bgra_cast(const detail::_xvec4& c){return u32_bgra_castGTX(c);} //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint32GTX u32_abgr_cast(const detail::_xvec4& c){return u32_abgr_castGTX(c);} //!< Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + + template inline __uint64GTX u64_rgbx_cast(const detail::_xvec3& c){return u32_rgbx_castGTX(c);} //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint64GTX u64_xrgb_cast(const detail::_xvec3& c){return u32_xrgb_castGTX(c);} //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint64GTX u64_bgrx_cast(const detail::_xvec3& c){return u32_bgrx_castGTX(c);} //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint64GTX u64_xbgr_cast(const detail::_xvec3& c){return u32_xbgr_castGTX(c);} //!< Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + + template inline __uint64GTX u64_rgba_cast(const detail::_xvec4& c){return u32_rgba_castGTX(c);} //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint64GTX u64_argb_cast(const detail::_xvec4& c){return u32_argb_castGTX(c);} //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint64GTX u64_bgra_cast(const detail::_xvec4& c){return u32_bgra_castGTX(c);} //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template inline __uint64GTX u64_abgr_cast(const detail::_xvec4& c){return u32_abgr_castGTX(c);} //!< Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + + template inline __halfGTX f16_channel_cast(T a){return f16_channel_castGTX(a);} //!< Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template inline detail::_xvec3<__halfGTX> f16_rgbx_cast(T c){return f16_rgbx_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3<__halfGTX> f16_xrgb_cast(T c){return f16_xrgb_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3<__halfGTX> f16_bgrx_cast(T c){return f16_bgrx_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3<__halfGTX> f16_xbgr_cast(T c){return f16_xbgr_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template inline detail::_xvec4<__halfGTX> f16_rgba_cast(T c){return f16_rgba_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4<__halfGTX> f16_argb_cast(T c){return f16_argb_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4<__halfGTX> f16_bgra_cast(T c){return f16_bgra_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4<__halfGTX> f16_abgr_cast(T c){return f16_abgr_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + template inline float f32_channel_cast(T a){return f32_channel_castGTX(a);} //!< Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template inline detail::_xvec3 f32_rgbx_cast(T c){return f32_rgbx_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3 f32_xrgb_cast(T c){return f32_xrgb_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3 f32_bgrx_cast(T c){return f32_bgrx_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3 f32_xbgr_cast(T c){return f32_xbgr_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template inline detail::_xvec4 f32_rgba_cast(T c){return f32_rgba_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4 f32_argb_cast(T c){return f32_argb_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4 f32_bgra_cast(T c){return f32_bgra_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4 f32_abgr_cast(T c){return f32_abgr_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + template inline double f64_channel_cast(T a){return f64_channel_castGTX(a);} //!< Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template inline detail::_xvec3 f64_rgbx_cast(T c){return f64_rgbx_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3 f64_xrgb_cast(T c){return f64_xrgb_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3 f64_bgrx_cast(T c){return f64_bgrx_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec3 f64_xbgr_cast(T c){return f64_xbgr_castGTX(c);} //!< Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template inline detail::_xvec4 f64_rgba_cast(T c){return f64_rgba_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4 f64_argb_cast(T c){return f64_argb_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4 f64_bgra_cast(T c){return f64_bgra_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template inline detail::_xvec4 f64_abgr_cast(T c){return f64_abgr_castGTX(c);} //!< Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + } + } +} + +#define GLM_GTX_color_cast namespace gtx::color_cast + +#include "color_cast.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_color_cast;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_color_cast__ diff --git a/wip/sse/glm/ext/gtx/color_cast.inl b/wip/sse/glm/ext/gtx/color_cast.inl new file mode 100644 index 00000000..8ee1b972 --- /dev/null +++ b/wip/sse/glm/ext/gtx/color_cast.inl @@ -0,0 +1,737 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-06-21 +// Updated : 2007-08-03 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/color_cast.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline __uint8GTX u8channel_castGTX(T a) + { + return static_cast<__uint8GTX>(a * T(255)); + } + + template + inline __uint16GTX u16channel_castGTX(T a) + { + return static_cast<__uint16GTX>(a * T(65535)); + } + + template + inline __uint32GTX u32_rgbx_castGTX(const detail::_xvec3& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec3::value_type(255)) << 0; + result += static_cast<__uint32GTX>(c.y * detail::_xvec3::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.z * detail::_xvec3::value_type(255)) << 16; + return result; + } + + template + inline __uint32GTX u32_xrgb_castGTX(const detail::_xvec3& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec3::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.y * detail::_xvec3::value_type(255)) << 16; + result += static_cast<__uint32GTX>(c.z * detail::_xvec3::value_type(255)) << 24; + return result; + } + + template + inline __uint32GTX u32_bgrx_castGTX(const detail::_xvec3& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec3::value_type(255)) << 16; + result += static_cast<__uint32GTX>(c.y * detail::_xvec3::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.z * detail::_xvec3::value_type(255)) << 0; + return result; + } + + template + inline __uint32GTX u32_xbgr_castGTX(const detail::_xvec3& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec3::value_type(255)) << 24; + result += static_cast<__uint32GTX>(c.y * detail::_xvec3::value_type(255)) << 16; + result += static_cast<__uint32GTX>(c.z * detail::_xvec3::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.w * detail::_xvec3::value_type(255)) << 0; + return result; + } + + template + inline __uint32GTX u32_rgba_castGTX(const detail::_xvec4& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec4::value_type(255)) << 0; + result += static_cast<__uint32GTX>(c.y * detail::_xvec4::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.z * detail::_xvec4::value_type(255)) << 16; + result += static_cast<__uint32GTX>(c.w * detail::_xvec4::value_type(255)) << 24; + return result; + } + + template + inline __uint32GTX u32_argb_castGTX(const detail::_xvec4& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec4::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.y * detail::_xvec4::value_type(255)) << 16; + result += static_cast<__uint32GTX>(c.z * detail::_xvec4::value_type(255)) << 24; + result += static_cast<__uint32GTX>(c.w * detail::_xvec4::value_type(255)) << 0; + return result; + } + + template + inline __uint32GTX u32_bgra_castGTX(const detail::_xvec4& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec4::value_type(255)) << 16; + result += static_cast<__uint32GTX>(c.y * detail::_xvec4::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.z * detail::_xvec4::value_type(255)) << 0; + result += static_cast<__uint32GTX>(c.w * detail::_xvec4::value_type(255)) << 24; + return result; + } + + template + inline __uint32GTX u32_abgr_castGTX(const detail::_xvec4& c) + { + __uint32GTX result = 0; + result += static_cast<__uint32GTX>(c.x * detail::_xvec4::value_type(255)) << 24; + result += static_cast<__uint32GTX>(c.y * detail::_xvec4::value_type(255)) << 16; + result += static_cast<__uint32GTX>(c.z * detail::_xvec4::value_type(255)) << 8; + result += static_cast<__uint32GTX>(c.w * detail::_xvec4::value_type(255)) << 0; + return result; + } + + template + inline __uint64GTX u64_rgbx_castGTX(const detail::_xvec3& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec3::value_type(65535)) << 0; + result += static_cast<__uint64GTX>(c.y * detail::_xvec3::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.z * detail::_xvec3::value_type(65535)) << 32; + return result; + } + + template + inline __uint64GTX u32_xrgb_castGTX(const detail::_xvec3& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec3::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.y * detail::_xvec3::value_type(65535)) << 32; + result += static_cast<__uint64GTX>(c.z * detail::_xvec3::value_type(65535)) << 48; + return result; + } + + template + inline __uint64GTX u32_bgrx_castGTX(const detail::_xvec3& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec3::value_type(65535)) << 32; + result += static_cast<__uint64GTX>(c.y * detail::_xvec3::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.z * detail::_xvec3::value_type(65535)) << 0; + return result; + } + + template + inline __uint64GTX u32_xbgr_castGTX(const detail::_xvec3& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec3::value_type(65535)) << 48; + result += static_cast<__uint64GTX>(c.y * detail::_xvec3::value_type(65535)) << 32; + result += static_cast<__uint64GTX>(c.z * detail::_xvec3::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.w * detail::_xvec3::value_type(65535)) << 0; + return result; + } + + template + inline __uint64GTX u64_rgba_castGTX(const detail::_xvec4& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec4::value_type(65535)) << 0; + result += static_cast<__uint64GTX>(c.y * detail::_xvec4::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.z * detail::_xvec4::value_type(65535)) << 32; + result += static_cast<__uint64GTX>(c.w * detail::_xvec4::value_type(65535)) << 48; + return result; + } + + template + inline __uint64GTX u64_argb_castGTX(const detail::_xvec4& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec4::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.y * detail::_xvec4::value_type(65535)) << 32; + result += static_cast<__uint64GTX>(c.z * detail::_xvec4::value_type(65535)) << 48; + result += static_cast<__uint64GTX>(c.w * detail::_xvec4::value_type(65535)) << 0; + return result; + } + + template + inline __uint64GTX u64_bgra_castGTX(const detail::_xvec4& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec4::value_type(65535)) << 32; + result += static_cast<__uint64GTX>(c.y * detail::_xvec4::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.z * detail::_xvec4::value_type(65535)) << 0; + result += static_cast<__uint64GTX>(c.w * detail::_xvec4::value_type(65535)) << 48; + return result; + } + + template + inline __uint64GTX u64_abgr_castGTX(const detail::_xvec4& c) + { + __uint64GTX result = 0; + result += static_cast<__uint64GTX>(c.x * detail::_xvec4::value_type(65535)) << 48; + result += static_cast<__uint64GTX>(c.y * detail::_xvec4::value_type(65535)) << 32; + result += static_cast<__uint64GTX>(c.z * detail::_xvec4::value_type(65535)) << 16; + result += static_cast<__uint64GTX>(c.w * detail::_xvec4::value_type(65535)) << 0; + return result; + } + + template <> + inline __halfGTX f16_channel_castGTX<__uint32GTX>(__uint32GTX color) + { + return __halfGTX(static_cast(color >> 0) / static_cast(255)); + } + +#ifdef GLM_COMPILER_VC + template <> + inline detail::_xvec3<__halfGTX> f16_rgbx_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 0) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 8) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 16) / static_cast(255)); + return result; + } + + template <> + inline detail::_xvec3<__halfGTX> f16_xrgb_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 8) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 24) / static_cast(255)); + return result; + } + + template <> + inline detail::_xvec3<__halfGTX> f16_bgrx_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 16) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 8) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 0) / static_cast(255)); + return result; + } + + template <> + inline detail::_xvec3<__halfGTX> f16_xbgr_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 24) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 8) / static_cast(255)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_rgba_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 0) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 8) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 16) / static_cast(255)); + result.w = __halfGTX(static_cast(color >> 24) / static_cast(255)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_argb_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 8) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 24) / static_cast(255)); + result.w = __halfGTX(static_cast(color >> 0) / static_cast(255)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_bgra_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 16) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 8) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 0) / static_cast(255)); + result.w = __halfGTX(static_cast(color >> 24) / static_cast(255)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_abgr_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 24) / static_cast(255)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(255)); + result.z = __halfGTX(static_cast(color >> 8) / static_cast(255)); + result.w = __halfGTX(static_cast(color >> 0) / static_cast(255)); + return result; + } +#endif//GLM_COMPILER_VC + + template <> + inline float f32_channel_castGTX<__uint8GTX>(__uint8GTX color) + { + return static_cast(color >> 0) / static_cast(255); + } + + template <> + inline detail::_xvec3 f32_rgbx_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 0) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 16) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec3 f32_xrgb_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 8) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 24) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec3 f32_bgrx_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 16) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 0) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec3 f32_xbgr_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 24) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 8) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f32_rgba_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 0) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 16) / static_cast(255); + result.w = static_cast(color >> 24) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f32_argb_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 8) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 24) / static_cast(255); + result.w = static_cast(color >> 0) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f32_bgra_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 16) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 0) / static_cast(255); + result.w = static_cast(color >> 24) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f32_abgr_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 24) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 8) / static_cast(255); + result.w = static_cast(color >> 0) / static_cast(255); + return result; + } + + template <> + inline double f64_channel_castGTX<__uint8GTX>(__uint8GTX color) + { + return static_cast(color >> 0) / static_cast(255); + } + + template <> + inline detail::_xvec3 f64_rgbx_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 0) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 16) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec3 f64_xrgb_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 8) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 24) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec3 f64_bgrx_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 16) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 0) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec3 f64_xbgr_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 24) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 8) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f64_rgba_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 0) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 16) / static_cast(255); + result.w = static_cast(color >> 24) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f64_argb_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 8) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 24) / static_cast(255); + result.w = static_cast(color >> 0) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f64_bgra_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 16) / static_cast(255); + result.y = static_cast(color >> 8) / static_cast(255); + result.z = static_cast(color >> 0) / static_cast(255); + result.w = static_cast(color >> 24) / static_cast(255); + return result; + } + + template <> + inline detail::_xvec4 f64_abgr_castGTX<__uint32GTX>(__uint32GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 24) / static_cast(255); + result.y = static_cast(color >> 16) / static_cast(255); + result.z = static_cast(color >> 8) / static_cast(255); + result.w = static_cast(color >> 0) / static_cast(255); + return result; + } + + template <> + inline __halfGTX f16_channel_castGTX<__uint16GTX>(__uint16GTX color) + { + return __halfGTX(static_cast(color >> 0) / static_cast(65535)); + } + +#ifdef GLM_COMPILER_VC + template <> + inline detail::_xvec3<__halfGTX> f16_rgbx_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 0) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + return result; + } + + template <> + inline detail::_xvec3<__halfGTX> f16_xrgb_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 48) / static_cast(65535)); + return result; + } + + template <> + inline detail::_xvec3<__halfGTX> f16_bgrx_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 0) / static_cast(65535)); + return result; + } + + template <> + inline detail::_xvec3<__halfGTX> f16_xbgr_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 48) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_rgba_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 0) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + result.w = __halfGTX(static_cast(color >> 48) / static_cast(65535)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_argb_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 48) / static_cast(65535)); + result.w = __halfGTX(static_cast(color >> 0) / static_cast(65535)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_bgra_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 0) / static_cast(65535)); + result.w = __halfGTX(static_cast(color >> 48) / static_cast(65535)); + return result; + } + + template <> + inline detail::_xvec4<__halfGTX> f16_abgr_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4<__halfGTX> result; + result.x = __halfGTX(static_cast(color >> 48) / static_cast(65535)); + result.y = __halfGTX(static_cast(color >> 32) / static_cast(65535)); + result.z = __halfGTX(static_cast(color >> 16) / static_cast(65535)); + result.w = __halfGTX(static_cast(color >> 0) / static_cast(65535)); + return result; + } +#endif//GLM_COMPILER_VC + + template <> + inline float f32_channel_castGTX<__uint16GTX>(__uint16GTX color) + { + return static_cast(color >> 0) / static_cast(65535); + } + + template <> + inline detail::_xvec3 f32_rgbx_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 0) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 32) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec3 f32_xrgb_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 16) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 48) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec3 f32_bgrx_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 32) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 0) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec3 f32_xbgr_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 48) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 16) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f32_rgba_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 0) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 32) / static_cast(65535); + result.w = static_cast(color >> 48) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f32_argb_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 16) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 48) / static_cast(65535); + result.w = static_cast(color >> 0) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f32_bgra_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 32) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 0) / static_cast(65535); + result.w = static_cast(color >> 48) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f32_abgr_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 48) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 16) / static_cast(65535); + result.w = static_cast(color >> 0) / static_cast(65535); + return result; + } + + template <> + inline double f64_channel_castGTX<__uint16GTX>(__uint16GTX color) + { + return static_cast(color >> 0) / static_cast(65535); + } + + template <> + inline detail::_xvec3 f64_rgbx_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 0) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 32) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec3 f64_xrgb_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 16) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 48) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec3 f64_bgrx_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 32) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 0) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec3 f64_xbgr_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec3 result; + result.x = static_cast(color >> 48) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 16) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f64_rgba_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 0) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 32) / static_cast(65535); + result.w = static_cast(color >> 48) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f64_argb_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 16) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 48) / static_cast(65535); + result.w = static_cast(color >> 0) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f64_bgra_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 32) / static_cast(65535); + result.y = static_cast(color >> 16) / static_cast(65535); + result.z = static_cast(color >> 0) / static_cast(65535); + result.w = static_cast(color >> 48) / static_cast(65535); + return result; + } + + template <> + inline detail::_xvec4 f64_abgr_castGTX<__uint64GTX>(__uint64GTX color) + { + detail::_xvec4 result; + result.x = static_cast(color >> 48) / static_cast(65535); + result.y = static_cast(color >> 32) / static_cast(65535); + result.z = static_cast(color >> 16) / static_cast(65535); + result.w = static_cast(color >> 0) / static_cast(65535); + return result; + } +} diff --git a/wip/sse/glm/ext/gtx/color_space.h b/wip/sse/glm/ext/gtx/color_space.h new file mode 100644 index 00000000..979cd315 --- /dev/null +++ b/wip/sse/glm/ext/gtx/color_space.h @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-02-22 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/color_space.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_color_space__ +#define __glm_gtx_color_space__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xvec3 rgbColorGTX(const detail::_xvec3& hsvValue); //!< \brief Converts a color from HSV color space to its color in RGB color space (from GLM_GTX_color_space extension) + template detail::_xvec3 hsvColorGTX(const detail::_xvec3& rgbValue); //!< \brief Converts a color from RGB color space to its color in HSV color space (from GLM_GTX_color_space extension) + template detail::_xmat4 saturationGTX(const T s); //!< Build a saturation matrix (from GLM_GTX_color_space extension) + template detail::_xvec3 saturationGTX(const T s, const detail::_xvec3& color); //!< Modify the saturation of a color (from GLM_GTX_color_space extension) + template detail::_xvec4 saturationGTX(const T s, const detail::_xvec4& color); //!< Modify the saturation of a color (from GLM_GTX_color_space extension) + template T luminosityGTX(const detail::_xvec3& cColor); //!< Compute color luminosity associating ratios (0.33, 0.59, 0.11) to RGB canals (from GLM_GTX_color_space extension) + + namespace gtx + { + //! GLM_GTX_color_space extension: Related to RVB to HSV conversions and operations + namespace color_space + { + template inline detail::_xvec3 rgbColor(const detail::_xvec3& hsvValue){return rgbColorGTX(hsvValue);} //!< \brief Converts a color from HSV color space to its color in RGB color space (from GLM_GTX_color_space extension) + template inline detail::_xvec3 hsvColor(const detail::_xvec3& rgbValue){return hsvColorGTX(rgbValue);} //!< \brief Converts a color from RGB color space to its color in HSV color space (from GLM_GTX_color_space extension) + template inline detail::_xmat4 saturation(const T s){return saturationGTX(s);} //!< Build a saturation matrix (from GLM_GTX_color_space extension) + template inline detail::_xvec3 saturation(const T s, const detail::_xvec3& color){return saturationGTX(s, color);} //!< Modify the saturation of a color (from GLM_GTX_color_space extension) + template inline detail::_xvec4 saturation(const T s, const detail::_xvec4& color){return saturationGTX(s, color);} //!< Modify the saturation of a color (from GLM_GTX_color_space extension) + template inline T luminosity(const detail::_xvec3& color){return luminosityGTX(color);} //!< Compute color luminosity associating ratios (0.33, 0.59, 0.11) to RGB canals (from GLM_GTX_color_space extension) + } + } +} + +#define GLM_GTX_color_space namespace gtx::color_space + +#include "color_space.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_color_space;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_color_space__ diff --git a/wip/sse/glm/ext/gtx/color_space.inl b/wip/sse/glm/ext/gtx/color_space.inl new file mode 100644 index 00000000..115de1f0 --- /dev/null +++ b/wip/sse/glm/ext/gtx/color_space.inl @@ -0,0 +1,149 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-02-22 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/color_space.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xvec3 rgbColorGTX(const detail::_xvec3& color) + { + detail::_xvec3 hsv = color; + detail::_xvec3 rgb; + + if(hsv.y == T(0)) + // achromatic (grey) + rgb = detail::_xvec3(hsv.z); + else + { + T sector = floor(hsv.x / T(60)); + T frac = (hsv.x / T(60)) - sector; + // factorial part of h + T o = hsv.z * (T(1) - hsv.y); + T p = hsv.z * (T(1) - hsv.y * frac); + T q = hsv.z * (T(1) - hsv.y * (T(1) - frac)); + + switch(int(sector)) + { + default: + case 0: + rgb.r = hsv.z; + rgb.g = q; + rgb.b = o; + break; + case 1: + rgb.r = p; + rgb.g = hsv.z; + rgb.b = o; + break; + case 2: + rgb.r = o; + rgb.g = hsv.z; + rgb.b = q; + break; + case 3: + rgb.r = o; + rgb.g = p; + rgb.b = hsv.z; + break; + case 4: + rgb.r = q; + rgb.g = o; + rgb.b = hsv.z; + break; + case 5: + rgb.r = hsv.z; + rgb.g = o; + rgb.b = p; + break; + } + } + + return rgb; + } + + template + inline detail::_xvec3 hsvColorGTX(const detail::_xvec3& rgb) + { + detail::_xvec3 hsv = rgb; + float Min = min(min(rgb.r, rgb.g), rgb.b); + float Max = max(max(rgb.r, rgb.g), rgb.b); + float Delta = Max - Min; + + hsv.z = Max; + + if(Max != T(0)) + { + hsv.y = Delta / hsv.z; + T h = T(0); + + if(rgb.r == Max) + // between yellow & magenta + h = T(0) + T(60) * (rgb.g - rgb.b) / Delta; + else if(rgb.g == Max) + // between cyan & yellow + h = T(120) + T(60) * (rgb.b - rgb.r) / Delta; + else + // between magenta & cyan + h = T(240) + T(60) * (rgb.r - rgb.g) / Delta; + + if(h < T(0)) + hsv.x = h + T(360); + else + hsv.x = h; + } + else + { + // If r = g = b = 0 then s = 0, h is undefined + hsv.y = T(0); + hsv.x = T(0); + } + + return hsv; + } + + template + inline detail::_xmat4 saturationGTX(const T s) + { + detail::_xvec3 rgbw = detail::_xvec3(T(0.2126), T(0.7152), T(0.0722)); + + T col0 = (T(1) - s) * rgbw.r; + T col1 = (T(1) - s) * rgbw.g; + T col2 = (T(1) - s) * rgbw.b; + + detail::_xmat4 result(T(1)); + result[0][0] = col0 + s; + result[0][1] = col0; + result[0][2] = col0; + result[1][0] = col1; + result[1][1] = col1 + s; + result[1][2] = col1; + result[2][0] = col2; + result[2][1] = col2; + result[2][2] = col2 + s; + return result; + } + + template + inline detail::_xvec3 saturationGTX(const T s, const detail::_xvec3& color) + { + return detail::_xvec3(saturationGTX(s) * detail::_xvec4(color, T(0))); + } + + template + inline detail::_xvec4 saturationGTX(const T s, const detail::_xvec4& color) + { + return saturationGTX(s) * color; + } + + template + inline T luminosityGTX(const detail::_xvec3& color) + { + const detail::_xvec3 tmp = detail::_xvec3(0.33, 0.59, 0.11); + return dot(color, tmp); + } +} diff --git a/wip/sse/glm/ext/gtx/compatibility.h b/wip/sse/glm/ext/gtx/compatibility.h new file mode 100644 index 00000000..7beb9c7b --- /dev/null +++ b/wip/sse/glm/ext/gtx/compatibility.h @@ -0,0 +1,298 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-24 +// Updated : 2007-09-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/compatibility.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_mul +// - GLM_GTX_half +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_compatibility__ +#define __glm_gtx_compatibility__ + +// Dependency: +#include "../../glm.h" +#include "../../glmsetup.h" +#include "../gtx/mul.h" +#include "../gtx/half.h" + +#ifdef GLM_COMPILER_VC +#include +#endif +#ifdef GLM_COMPILER_GCC +#include +#endif + +namespace glm +{ + template inline T lerpGTX(T x, T y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility extension) + + template inline detail::_xvec2 lerpGTX(const detail::_xvec2& x, const detail::_xvec2& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility extension) + template inline detail::_xvec3 lerpGTX(const detail::_xvec3& x, const detail::_xvec3& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility extension) + template inline detail::_xvec4 lerpGTX(const detail::_xvec4& x, const detail::_xvec4& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility extension) + + template inline detail::_xvec2 lerpGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility extension) + template inline detail::_xvec3 lerpGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility extension) + template inline detail::_xvec4 lerpGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility extension) + + template inline T saturateGTX(T x){clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility extension) + template inline detail::_xvec2 saturateGTX(const detail::_xvec2& x){clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility extension) + template inline detail::_xvec3 saturateGTX(const detail::_xvec3& x){clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility extension) + template inline detail::_xvec4 saturateGTX(const detail::_xvec4& x){clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility extension) + + template inline T atan2GTX(T x, T y){atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility extension) + template inline detail::_xvec2 atan2GTX(const detail::_xvec2& x, const detail::_xvec2& y){atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility extension) + template inline detail::_xvec3 atan2GTX(const detail::_xvec3& x, const detail::_xvec3& y){atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility extension) + template inline detail::_xvec4 atan2GTX(const detail::_xvec4& x, const detail::_xvec4& y){atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility extension) + + template bool isfiniteGTX(T x); //!< \brief Determines whether the given floating-point value is finite. (From GLM_GTX_compatibility extension) + template detail::_bvec2 isfiniteGTX(const detail::_xvec2& x); //!< \brief Determines whether the given floating-point values is finite. (From GLM_GTX_compatibility extension) + template detail::_bvec3 isfiniteGTX(const detail::_xvec3& x); //!< \brief Determines whether the given floating-point values is finite. (From GLM_GTX_compatibility extension) + template detail::_bvec4 isfiniteGTX(const detail::_xvec4& x); //!< \brief Determines whether the given floating-point values is finite. (From GLM_GTX_compatibility extension) + + template bool isinfGTX(T x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension) + template detail::_bvec2 isinfGTX(const detail::_xvec2& x); //!< \brief Determines whether the given floating-point values is infinite. (From GLM_GTX_compatibility extension) + template detail::_bvec3 isinfGTX(const detail::_xvec3& x); //!< \brief Determines whether the given floating-point values is infinite. (From GLM_GTX_compatibility extension) + template detail::_bvec4 isinfGTX(const detail::_xvec4& x); //!< \brief Determines whether the given floating-point values is infinite. (From GLM_GTX_compatibility extension) + + template bool isnanGTX(T x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension) + template detail::_bvec2 isnanGTX(const detail::_xvec2& x); //!< \brief Checks given floating-point values for not a number (NAN) (From GLM_GTX_compatibility extension) + template detail::_bvec3 isnanGTX(const detail::_xvec3& x); //!< \brief Checks given floating-point values for not a number (NAN) (From GLM_GTX_compatibility extension) + template detail::_bvec4 isnanGTX(const detail::_xvec4& x); //!< \brief Checks given floating-point values for not a number (NAN) (From GLM_GTX_compatibility extension) + + typedef bool bool1GTX; + typedef detail::_bvec2 bool2GTX; + typedef detail::_bvec3 bool3GTX; + typedef detail::_bvec4 bool4GTX; +/* + typedef bool bool1x1GTX; + typedef detail::_xmat2 bool2x2GTX; + typedef detail::_xmat3 bool3x3GTX; + typedef detail::_xmat4 bool4x4GTX; + + typedef detail::_xmat2x3 bool2x3GTX; + typedef detail::_xmat2x4 bool2x4GTX; + typedef detail::_xmat3x2 bool3x2GTX; + typedef detail::_xmat3x4 bool3x4GTX; + typedef detail::_xmat4x2 bool4x2GTX; + typedef detail::_xmat4x3 bool4x3GTX; +*/ + typedef int __int1GTX; + typedef detail::_xvec2 __int2GTX; + typedef detail::_xvec3 __int3GTX; + typedef detail::_xvec4 __int4GTX; + + typedef int __int1x1GTX; + typedef detail::_xmat2 __int2x2GTX; + typedef detail::_xmat3 __int3x3GTX; + typedef detail::_xmat4 __int4x4GTX; + + typedef detail::_xmat2x3 __int2x3GTX; + typedef detail::_xmat2x4 __int2x4GTX; + typedef detail::_xmat3x2 __int3x2GTX; + typedef detail::_xmat3x4 __int3x4GTX; + typedef detail::_xmat4x2 __int4x2GTX; + typedef detail::_xmat4x3 __int4x3GTX; + + typedef __halfGTX __half1GTX; + typedef detail::_xvec2<__halfGTX> __half2GTX; + typedef detail::_xvec3<__halfGTX> __half3GTX; + typedef detail::_xvec4<__halfGTX> __half4GTX; + + typedef __halfGTX __half1x1GTX; + typedef detail::_xmat2<__halfGTX> __half2x2GTX; + typedef detail::_xmat3<__halfGTX> __half3x3GTX; + typedef detail::_xmat4<__halfGTX> __half4x4GTX; + + typedef detail::_xmat2x3<__halfGTX> __half2x3GTX; + typedef detail::_xmat2x4<__halfGTX> __half2x4GTX; + typedef detail::_xmat3x2<__halfGTX> __half3x2GTX; + typedef detail::_xmat3x4<__halfGTX> __half3x4GTX; + typedef detail::_xmat4x2<__halfGTX> __half4x2GTX; + typedef detail::_xmat4x3<__halfGTX> __half4x3GTX; + + typedef float __float1GTX; + typedef detail::_xvec2 __float2GTX; + typedef detail::_xvec3 __float3GTX; + typedef detail::_xvec4 __float4GTX; + + typedef float __float1x1GTX; + typedef detail::_xmat2 __float2x2GTX; + typedef detail::_xmat3 __float3x3GTX; + typedef detail::_xmat4 __float4x4GTX; + + typedef detail::_xmat2x3 __float2x3GTX; + typedef detail::_xmat2x4 __float2x4GTX; + typedef detail::_xmat3x2 __float3x2GTX; + typedef detail::_xmat3x4 __float3x4GTX; + typedef detail::_xmat4x2 __float4x2GTX; + typedef detail::_xmat4x3 __float4x3GTX; + + typedef double __double1GTX; + typedef detail::_xvec2 __double2GTX; + typedef detail::_xvec3 __double3GTX; + typedef detail::_xvec4 __double4GTX; + + typedef double __double1x1GTX; + typedef detail::_xmat2 __double2x2GTX; + typedef detail::_xmat3 __double3x3GTX; + typedef detail::_xmat4 __double4x4GTX; + + typedef detail::_xmat2x3 __double2x3GTX; + typedef detail::_xmat2x4 __double2x4GTX; + typedef detail::_xmat3x2 __double3x2GTX; + typedef detail::_xmat3x4 __double3x4GTX; + typedef detail::_xmat4x2 __double4x2GTX; + typedef detail::_xmat4x3 __double4x3GTX; + + namespace gtx + { + //! GLM_GTX_compatibility extension: Provide functions to increase the compatibility with Cg and HLSL languages + namespace compatibility + { + template inline T lerp(T x, T y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + + template inline detail::_xvec2 lerp(const detail::_xvec2& x, const detail::_xvec2& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template inline detail::_xvec3 lerp(const detail::_xvec3& x, const detail::_xvec3& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template inline detail::_xvec4 lerp(const detail::_xvec4& x, const detail::_xvec4& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + + template inline detail::_xvec2 lerp(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template inline detail::_xvec3 lerp(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template inline detail::_xvec4 lerp(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + + template inline T saturate(T x){saturateGTX(x);} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + template inline detail::_xvec2 saturate(const detail::_xvec2& x){saturateGTX(x);} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + template inline detail::_xvec3 saturate(const detail::_xvec3& x){saturateGTX(x);} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + template inline detail::_xvec4 saturate(const detail::_xvec4& x){saturateGTX(x);} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + + template inline T atan2(T x, T y){atan(x, y);} + template inline detail::_xvec2 atan2(const detail::_xvec2& x, const detail::_xvec2& y){atan(x, y);} + template inline detail::_xvec3 atan2(const detail::_xvec3& x, const detail::_xvec3& y){atan(x, y);} + template inline detail::_xvec4 atan2(const detail::_xvec4& x, const detail::_xvec4& y){atan(x, y);} + + template inline bool isfinite(T x){return isfiniteGTX(x);} + template inline detail::_bvec2 isfinite(const detail::_xvec2& x){return isfiniteGTX(x);} + template inline detail::_bvec3 isfinite(const detail::_xvec3& x){return isfiniteGTX(x);} + template inline detail::_bvec4 isfinite(const detail::_xvec4& x){return isfiniteGTX(x);} + + template inline bool isinf(T x){return isinfGTX(x);} + template inline detail::_bvec2 isinf(const detail::_xvec2& x){return isinfGTX(x);} + template inline detail::_bvec3 isinf(const detail::_xvec3& x){return isinfGTX(x);} + template inline detail::_bvec4 isinf(const detail::_xvec4& x){return isinfGTX(x);} + + template inline bool isnan(T x){return isnanGTX(x);} + template inline detail::_bvec2 isnan(const detail::_xvec2& x){return isnanGTX(x);} + template inline detail::_bvec3 isnan(const detail::_xvec3& x){return isnanGTX(x);} + template inline detail::_bvec4 isnan(const detail::_xvec4& x){return isnanGTX(x);} + + typedef bool bool1; + typedef detail::_bvec2 bool2; + typedef detail::_bvec3 bool3; + typedef detail::_bvec4 bool4; +/* + typedef bool bool1x1; + typedef detail::_xmat2 bool2x2; + typedef detail::_xmat3 bool3x3; + typedef detail::_xmat4 bool4x4; + + typedef detail::_xmat2x3 bool2x3; + typedef detail::_xmat2x4 bool2x4; + typedef detail::_xmat3x2 bool3x2; + typedef detail::_xmat3x4 bool3x4; + typedef detail::_xmat4x2 bool4x2; + typedef detail::_xmat4x3 bool4x3; +*/ + typedef int int1; + typedef detail::_xvec2 int2; + typedef detail::_xvec3 int3; + typedef detail::_xvec4 int4; + + typedef int int1x1; + typedef detail::_xmat2 int2x2; + typedef detail::_xmat3 int3x3; + typedef detail::_xmat4 int4x4; + + typedef detail::_xmat2x3 int2x3; + typedef detail::_xmat2x4 int2x4; + typedef detail::_xmat3x2 int3x2; + typedef detail::_xmat3x4 int3x4; + typedef detail::_xmat4x2 int4x2; + typedef detail::_xmat4x3 int4x3; + + typedef __halfGTX half1; + typedef detail::_xvec2<__halfGTX> half2; + typedef detail::_xvec3<__halfGTX> half3; + typedef detail::_xvec4<__halfGTX> half4; + + typedef detail::_xmat2<__halfGTX> half2x2; + typedef detail::_xmat3<__halfGTX> half3x3; + typedef detail::_xmat4<__halfGTX> half4x4; + + typedef detail::_xmat2x3<__halfGTX> half2x3; + typedef detail::_xmat2x4<__halfGTX> half2x4; + typedef detail::_xmat3x2<__halfGTX> half3x2; + typedef detail::_xmat3x4<__halfGTX> half3x4; + typedef detail::_xmat4x2<__halfGTX> half4x2; + typedef detail::_xmat4x3<__halfGTX> half4x3; + + typedef float float1; + typedef detail::_xvec2 float2; + typedef detail::_xvec3 float3; + typedef detail::_xvec4 float4; + + typedef float float1x1; + typedef detail::_xmat2 float2x2; + typedef detail::_xmat3 float3x3; + typedef detail::_xmat4 float4x4; + + typedef detail::_xmat2x3 float2x3; + typedef detail::_xmat2x4 float2x4; + typedef detail::_xmat3x2 float3x2; + typedef detail::_xmat3x4 float3x4; + typedef detail::_xmat4x2 float4x2; + typedef detail::_xmat4x3 float4x3; + + typedef double double1; + typedef detail::_xvec2 double2; + typedef detail::_xvec3 double3; + typedef detail::_xvec4 double4; + + typedef double double1x1; + typedef detail::_xmat2 double2x2; + typedef detail::_xmat3 double3x3; + typedef detail::_xmat4 double4x4; + + typedef detail::_xmat2x3 double2x3; + typedef detail::_xmat2x4 double2x4; + typedef detail::_xmat3x2 double3x2; + typedef detail::_xmat3x4 double3x4; + typedef detail::_xmat4x2 double4x2; + typedef detail::_xmat4x3 double4x3; + } + } +} + +#define GLM_GTX_compatibility namespace gtx::compatibility + +#include "compatibility.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_compatibility;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_compatibility__ + + + + + + + + + + diff --git a/wip/sse/glm/ext/gtx/compatibility.inl b/wip/sse/glm/ext/gtx/compatibility.inl new file mode 100644 index 00000000..67da2e2b --- /dev/null +++ b/wip/sse/glm/ext/gtx/compatibility.inl @@ -0,0 +1,132 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-16 +// Updated : 2007-09-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/compatibility.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // isfiniteGTX + template + inline bool isfiniteGTX(T x) + { +#ifdef GLM_COMPILER_VC + return _finite(x); +#endif + +#ifdef GLM_COMPILER_GCC + return std::isfinite(x); +#endif + } + + template + inline detail::_bvec2 isfiniteGTX(const detail::_xvec2& x) + { + return detail::_bvec2( + isfiniteGTX(x.x), + isfiniteGTX(x.y)); + } + + template + inline detail::_bvec3 isfiniteGTX(const detail::_xvec3& x) + { + return detail::_bvec3( + isfiniteGTX(x.x), + isfiniteGTX(x.y), + isfiniteGTX(x.z)); + } + + template + inline detail::_bvec4 isfiniteGTX(const detail::_xvec4& x) + { + return detail::_bvec4( + isfiniteGTX(x.x), + isfiniteGTX(x.y), + isfiniteGTX(x.z), + isfiniteGTX(x.w)); + } + + // isinfGTX + template + inline bool isinfGTX(T x) + { +#ifdef GLM_COMPILER_VC + return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; +#endif + +#ifdef GLM_COMPILER_GCC + return std::isinf(x); +#endif + } + + template + inline detail::_bvec2 isinfGTX(const detail::_xvec2& x) + { + return detail::_bvec2( + isinfGTX(x.x), + isinfGTX(x.y)); + } + + template + inline detail::_bvec3 isinfGTX(const detail::_xvec3& x) + { + return detail::_bvec3( + isinfGTX(x.x), + isinfGTX(x.y), + isinfGTX(x.z)); + } + + template + inline detail::_bvec4 isinfGTX(const detail::_xvec4& x) + { + return detail::_bvec4( + isinfGTX(x.x), + isinfGTX(x.y), + isinfGTX(x.z), + isinfGTX(x.w)); + } + + // isnanGTX + template + inline bool isnanGTX(T x) + { +#ifdef GLM_COMPILER_VC + return _isnan(x); +#endif + +#ifdef GLM_COMPILER_GCC + return std::isnan(x); +#endif + } + + template + inline detail::_bvec2 isnanGTX(const detail::_xvec2& x) + { + return detail::_bvec2( + isnanGTX(x.x), + isnanGTX(x.y)); + } + + template + inline detail::_bvec3 isnanGTX(const detail::_xvec3& x) + { + return detail::_bvec3( + isnanGTX(x.x), + isnanGTX(x.y), + isnanGTX(x.z)); + } + + template + inline detail::_bvec4 isnanGTX(const detail::_xvec4& x) + { + return detail::_bvec4( + isnanGTX(x.x), + isnanGTX(x.y), + isnanGTX(x.z), + isnanGTX(x.w)); + } +} + diff --git a/wip/sse/glm/ext/gtx/component_wise.h b/wip/sse/glm/ext/gtx/component_wise.h new file mode 100644 index 00000000..c7bd7315 --- /dev/null +++ b/wip/sse/glm/ext/gtx/component_wise.h @@ -0,0 +1,49 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-21 +// Updated : 2007-05-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/component_wise.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_component_wise__ +#define __glm_gtx_component_wise__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template GLMvalType compAddGTX(const genType& v); //!< Add all vector components together. (From GLM_GTX_component_wise extension) + template GLMvalType compMulGTX(const genType& v); //!< Multiply all vector components together. (From GLM_GTX_component_wise extension) + + template GLMvalType compMinGTX(const genType& v); //!< Find the minimum value between single vector components. (From GLM_GTX_component_wise extension) + template GLMvalType compMaxGTX(const genType& v); //!< Find the maximum value between single vector components. (From GLM_GTX_component_wise extension) + + namespace gtx + { + //! GLM_GTX_component_wise extension: Operations between components of a type + namespace component_wise + { + template inline GLMvalType compAdd(const genType& v){return compAddGTX(v);} //!< Add all vector components together. (From GLM_GTX_component_wise extension) + template inline GLMvalType compMul(const genType& v){return compMulGTX(v);} //!< Multiply all vector components together. (From GLM_GTX_component_wise extension) + + template inline GLMvalType compMin(const genType& v){return compMinGTX(v);} //!< Find the minimum value between single vector components. (From GLM_GTX_component_wise extension) + template inline GLMvalType compMax(const genType& v){return compMaxGTX(v);} //!< Find the maximum value between single vector components. (From GLM_GTX_component_wise extension) + } + } +} + +#define GLM_GTX_component_wise namespace gtx::component_wise + +#include "component_wise.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_component_wise;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_component_wise__ diff --git a/wip/sse/glm/ext/gtx/component_wise.inl b/wip/sse/glm/ext/gtx/component_wise.inl new file mode 100644 index 00000000..3d46a627 --- /dev/null +++ b/wip/sse/glm/ext/gtx/component_wise.inl @@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-21 +// Updated : 2007-05-21 +// Licence : This source is under GNU LGPL licence +// File : gtx_component_wise.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline GLMvalType compAddGTX(const genType& v) + { + typename genType::size_type result = typename genType::value_type(0); + for(typename genType::size_type i = 0; i < genType::value_size; ++i) + result += v[i]; + return result; + } +/* + template + inline valType compAddGTX(const genType& v) + { + valType result = valType(0); + for(sizeType i = 0; i < valSize; ++i) + result += v[i]; + return result; + } +*/ + template + inline GLMvalType compMulGTX(const genType& v) + { + typename genType::size_type result = typename genType::value_type(0); + for(typename genType::size_type i = 0; i < genType::value_size; ++i) + result *= v[i]; + return result; + } +/* + template + inline GLMvalType compMulGTX(const genType& v) + { + valType result = valType(0); + for(GLMsizeType i = 0; i < valSize; ++i) + result *= v[i]; + return result; + } +*/ + template + inline GLMvalType compMinGTX(const genType& v) + { + typename genType::size_type result = typename genType::value_type(0); + for(typename genType::size_type i = 0; i < genType::value_size; ++i) + result = min(result, v[i]); + return result; + } +/* + template + inline GLMvalType compMinGTX(const genType& v) + { + valType result = valType(0); + for(GLMsizeType i = 0; i < valSize; ++i) + result = min(result, v[i]); + return result; + } +*/ + template + inline GLMvalType compMaxGTX(const genType& v) + { + typename genType::size_type result = typename genType::value_type(0); + for(typename genType::size_type i = 0; i < genType::value_size; ++i) + result = max(result, v[i]); + return result; + } +/* + template + inline GLMvalType compMaxGTX(const genType& v) + { + GLMvalType result = GLMvalType(0); + for(GLMsizeType i = 0; i < GLMvalSize; ++i) + result = max(result, v[i]); + return result; + } +*/ +} + diff --git a/wip/sse/glm/ext/gtx/determinant.h b/wip/sse/glm/ext/gtx/determinant.h new file mode 100644 index 00000000..910fcf80 --- /dev/null +++ b/wip/sse/glm/ext/gtx/determinant.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/determinant.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_determinant__ +#define __glm_gtx_determinant__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template T determinantGTX(const detail::_xmat2& m); //!< \brief Returns the determinant of a 2 * 2 matrix. (From GLM_GTX_determinant extension) + template T determinantGTX(const detail::_xmat3& m); //!< \brief Returns the determinant of a 3 * 3 matrix. (From GLM_GTX_determinant extension) + template T determinantGTX(const detail::_xmat4& m); //!< \brief Returns the determinant of a 4 * 4 matrix. (From GLM_GTX_determinant extension) + + namespace gtx + { + //! GLM_GTX_determinant extension: Compute the determinant of a matrix + namespace determinant + { + template inline T determinant(const detail::_xmat2& m){return determinantGTX(m);} //!< \brief Returns the determinant of a 2 * 2 matrix. (From GLM_GTX_determinant extension) + template inline T determinant(const detail::_xmat3& m){return determinantGTX(m);} //!< \brief Returns the determinant of a 3 * 3 matrix. (From GLM_GTX_determinant extension) + template inline T determinant(const detail::_xmat4& m){return determinantGTX(m);} //!< \brief Returns the determinant of a 4 * 4 matrix. (From GLM_GTX_determinant extension) + } + } +} + +#define GLM_GTX_determinant namespace gtx::determinant + +#include "determinant.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_determinant;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_determinant__ diff --git a/wip/sse/glm/ext/gtx/determinant.inl b/wip/sse/glm/ext/gtx/determinant.inl new file mode 100644 index 00000000..db1bb7be --- /dev/null +++ b/wip/sse/glm/ext/gtx/determinant.inl @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/determinant.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline T determinantGTX(const detail::_xmat2& m) + { + return m[0][0] * m[1][1] - m[1][0] * m[0][1]; + } + + template + inline T determinantGTX(const detail::_xmat3& m) + { + return m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) + - m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2]) + + m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + } + + template + inline T determinantGTX(const detail::_xmat4& m) + { + T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + T SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + T SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + T SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + T SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + + detail::_xvec4 DetCof( + + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02), + - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04), + + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05), + - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05)); + + return m[0][0] * DetCof[0] + + m[0][1] * DetCof[1] + + m[0][2] * DetCof[2] + + m[0][3] * DetCof[3]; + } +} diff --git a/wip/sse/glm/ext/gtx/double.h b/wip/sse/glm/ext/gtx/double.h new file mode 100644 index 00000000..ee142a87 --- /dev/null +++ b/wip/sse/glm/ext/gtx/double.h @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-03-20 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/double.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_quaternion +/////////////////////////////////////////////////////////////////////////////////////////////////// +// ToDo: +// - Finish to declare extension functions +// - Nothing define +// - Study extension dependencies +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Note: +// - This implementation doesn't need to redefine all build-in functions to +// support double based type. +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_double__ +#define __glm_gtx_double__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/quaternion.h" + +namespace glm +{ + typedef detail::_xvec2 __fvec2GTX; //!< \brief Vector of 2 single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec3 __fvec3GTX; //!< \brief Vector of 3 single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec4 __fvec4GTX; //!< \brief Vector of 4 single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat2 __fmat2GTX; //!< \brief 2 * 2 matrix of single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat3 __fmat3GTX; //!< \brief 3 * 3 matrix of single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat4 __fmat4GTX; //!< \brief 4 * 4 matrix of single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xquat __fquatGTX; //!< \brief quaternion of single-precision floating-point numbers. (from GLM_GTX_double extension) + + typedef detail::_xvec2 __dvec2GTX; //!< \brief Vector of 2 double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec3 __dvec3GTX; //!< \brief Vector of 3 double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec4 __dvec4GTX; //!< \brief Vector of 4 double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat2 __dmat2GTX; //!< \brief 2 * 2 matrix of double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat3 __dmat3GTX; //!< \brief 3 * 3 matrix of double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat4 __dmat4GTX; //!< \brief 4 * 4 matrix of double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xquat __dquatGTX; //!< \brief quaternion of double-precision floating-point numbers. (from GLM_GTX_double extension) + + namespace gtx + { + //! GLM_GTX_double_float extension: Add support for double precision flotting-point types + namespace double_float + { + typedef detail::_xvec2 fvec2; //!< \brief Vector of 2 single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec3 fvec3; //!< \brief Vector of 3 single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec4 fvec4; //!< \brief Vector of 4 single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat2 fmat2; //!< \brief 2 * 2 matrix of single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat3 fmat3; //!< \brief 3 * 3 matrix of single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat4 fmat4; //!< \brief 4 * 4 matrix of single-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xquat fquat; //!< \brief quaternion of single-precision floating-point numbers. (from GLM_GTX_double extension) + + typedef detail::_xvec2 dvec2; //!< \brief Vector of 2 double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec3 dvec3; //!< \brief Vector of 3 double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xvec4 dvec4; //!< \brief Vector of 4 double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat2 dmat2; //!< \brief 2 * 2 matrix of double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat3 dmat3; //!< \brief 3 * 3 matrix of double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xmat4 dmat4; //!< \brief 4 * 4 matrix of double-precision floating-point numbers. (from GLM_GTX_double extension) + typedef detail::_xquat dquat; //!< \brief quaternion of double-precision floating-point numbers. (from GLM_GTX_double extension) + } + } +} + +#define GLM_GTX_double namespace gtx::double_float + +#include "double.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_double;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_double__ diff --git a/wip/sse/glm/ext/gtx/double.inl b/wip/sse/glm/ext/gtx/double.inl new file mode 100644 index 00000000..6856e51b --- /dev/null +++ b/wip/sse/glm/ext/gtx/double.inl @@ -0,0 +1,13 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/double.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + +} diff --git a/wip/sse/glm/ext/gtx/epsilon.h b/wip/sse/glm/ext/gtx/epsilon.h new file mode 100644 index 00000000..c4a824eb --- /dev/null +++ b/wip/sse/glm/ext/gtx/epsilon.h @@ -0,0 +1,100 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/epsilon.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_double +// - GLM_GTX_half +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_epsilon__ +#define __glm_gtx_epsilon__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/double.h" +#include "../gtx/half.h" + +namespace glm +{ + template bool equalEpsilonGTX(const T x, const T y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template bool notEqualEpsilonGTX(const T x, const T y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + + template detail::_bvec2 equalEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec3 equalEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec4 equalEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec2 notEqualEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec3 notEqualEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec4 notEqualEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const T epsilon); //!< \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + + template detail::_bvec2 equalEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& epsilon); //!< \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec3 equalEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& epsilon); //!< \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec4 equalEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& epsilon); //!< \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec2 notEqualEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& epsilon); //!< \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec3 notEqualEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& epsilon); //!< \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template detail::_bvec4 notEqualEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& epsilon); //!< \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) +/* + template + class epsilonGTX + { + public: + epsilonGTX() : value(std::EPSILON){} + epsilonGTX(const T& value) : value(value){} + + private: + T value; + }; +*/ + namespace gtx + { + //! GLM_GTX_epsilon extension: Comparaison functions for a user defined epsilon values. + namespace epsilon + { + //! \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template inline bool equalEpsilon(const T x, const T y, const T epsilon){return equalEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template inline bool notEqualEpsilon(const T x, const T y, const T epsilon){return notEqualEpsilonGTX(x, y, epsilon);} + + //! \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec2 equalEpsilon(const detail::_xvec2& x, const detail::_xvec2& y, const T epsilon){return equalEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec3 equalEpsilon(const detail::_xvec3& x, const detail::_xvec3& y, const T epsilon){return equalEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec4 equalEpsilon(const detail::_xvec4& x, const detail::_xvec4& y, const T epsilon){return equalEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec2 notEqualEpsilon(const detail::_xvec2& x, const detail::_xvec2& y, const T epsilon){return notEqualEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec3 notEqualEpsilon(const detail::_xvec3& x, const detail::_xvec3& y, const T epsilon){return notEqualEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec4 notEqualEpsilon(const detail::_xvec4& x, const detail::_xvec4& y, const T epsilon){return notEqualEpsilonGTX(x, y, epsilon);} + + //! \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec2 equalEpsilon(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& epsilon){return equalEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec3 equalEpsilon(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& epsilon){return equalEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| < epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec4 equalEpsilon(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& epsilon){return equalEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec2 notEqualEpsilon(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& epsilon){return notEqualEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec3 notEqualEpsilon(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& epsilon){return notEqualEpsilonGTX(x, y, epsilon);} + //! \brief Returns the component-wise compare of |x - y| >= epsilon (from GLM_GTX_epsilon extension) + template inline detail::_bvec4 notEqualEpsilon(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& epsilon){return notEqualEpsilonGTX(x, y, epsilon);} + } + } +} + +#define GLM_GTX_epsilon namespace gtx::epsilon + +#include "epsilon.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_epsilon;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_epsilon__ diff --git a/wip/sse/glm/ext/gtx/epsilon.inl b/wip/sse/glm/ext/gtx/epsilon.inl new file mode 100644 index 00000000..856df095 --- /dev/null +++ b/wip/sse/glm/ext/gtx/epsilon.inl @@ -0,0 +1,131 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-01-16 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/epsilon.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline bool equalEpsilonGTX(T x, T y, T epsilon) + { + return abs(x - y) < epsilon; + } + + template + inline bool notEqualEpsilonGTX(T x, T y, T epsilon) + { + return abs(x - y) >= epsilon; + } + + template + inline detail::_bvec2 equalEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const T epsilon) + { + return detail::_bvec2( + abs(x.x - y.x) < epsilon, + abs(y.y - y.y) < epsilon); + } + + template + inline detail::_bvec3 equalEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const T epsilon) + { + return detail::_bvec3( + abs(x.x - y.x) < epsilon, + abs(y.y - y.y) < epsilon, + abs(y.z - y.z) < epsilon); + } + + template + inline detail::_bvec4 equalEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const T epsilon) + { + return detail::_bvec4( + abs(x.x - y.x) < epsilon, + abs(y.y - y.y) < epsilon, + abs(y.z - y.z) < epsilon, + abs(y.w - y.w) < epsilon); + } + + template + inline detail::_bvec2 notEqualEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const T epsilon) + { + return detail::_bvec2( + abs(x.x - y.x) >= epsilon, + abs(y.y - y.y) >= epsilon); + } + + template + inline detail::_bvec3 notEqualEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const T epsilon) + { + return detail::_bvec3( + abs(x.x - y.x) >= epsilon, + abs(y.y - y.y) >= epsilon, + abs(y.z - y.z) >= epsilon); + } + + template + inline detail::_bvec4 notEqualEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const T epsilon) + { + return detail::_bvec4( + abs(x.x - y.x) >= epsilon, + abs(y.y - y.y) >= epsilon, + abs(y.z - y.z) >= epsilon, + abs(y.w - y.w) >= epsilon); + } + + template + inline detail::_bvec2 equalEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& epsilon) + { + return detail::_bvec2( + abs(x.x - y.x) < epsilon.x, + abs(y.y - y.y) < epsilon.y); + } + + template + inline detail::_bvec3 equalEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& epsilon) + { + return detail::_bvec3( + abs(x.x - y.x) < epsilon.x, + abs(y.y - y.y) < epsilon.y, + abs(y.z - y.z) < epsilon.z); + } + + template + inline detail::_bvec4 equalEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& epsilon) + { + return detail::_bvec4( + abs(x.x - y.x) < epsilon.x, + abs(y.y - y.y) < epsilon.y, + abs(y.z - y.z) < epsilon.z, + abs(y.w - y.w) < epsilon.w); + } + + template + inline detail::_bvec2 notEqualEpsilonGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& epsilon) + { + return detail::_bvec2( + abs(x.x - y.x) >= epsilon.x, + abs(y.y - y.y) >= epsilon.y); + } + + template + inline detail::_bvec3 notEqualEpsilonGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& epsilon) + { + return detail::_bvec3( + abs(x.x - y.x) >= epsilon.x, + abs(y.y - y.y) >= epsilon.y, + abs(y.z - y.z) >= epsilon.z); + } + + template + inline detail::_bvec4 notEqualEpsilonGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& epsilon) + { + return detail::_bvec4( + abs(x.x - y.x) >= epsilon.x, + abs(y.y - y.y) >= epsilon.y, + abs(y.z - y.z) >= epsilon.z, + abs(y.w - y.w) >= epsilon.w); + } +} diff --git a/wip/sse/glm/ext/gtx/euler_angles.h b/wip/sse/glm/ext/gtx/euler_angles.h new file mode 100644 index 00000000..b564b192 --- /dev/null +++ b/wip/sse/glm/ext/gtx/euler_angles.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-08-14 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/euler_angles.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_double +// - GLM_GTX_half +/////////////////////////////////////////////////////////////////////////////////////////////////// +// ToDo: +// - mat2 mat2GTX(const vec2& angles) undefined +// - mat3 mat3GTX(const vec2& angles) undefined +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_euler_angles__ +#define __glm_gtx_euler_angles__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/double.h" + +namespace glm +{ + template detail::_xmat2 orientate2GTX(const T angle); //!< \brief Creates a 2 * 2 rotation matrix from angle (from GLM_GTX_euler_angles extension) + template detail::_xmat3 orientate3GTX(const T angle); //!< \brief Creates a 3 * 3 rotation matrix from angle (from GLM_GTX_euler_angles extension) + template detail::_xmat3 orientate3GTX(const detail::_xvec3& angles); //!< \brief Creates a 3 * 3 rotation matrix from angles (from GLM_GTX_euler_angles extension) + template detail::_xmat4 orientate4GTX(const detail::_xvec3& angles); //!< \brief Creates a 4 * 4 rotation matrix from angles (from GLM_GTX_euler_angles extension) + + namespace gtx + { + //! GLM_GTX_euler_angles extension: Build matrices from euler angles. + namespace euler_angles + { + template inline detail::_xmat2 orientate2(const T angle){return orientate2GTX(angle);} //!< \brief Creates a 2 * 2 rotation matrix from angle (from GLM_GTX_euler_angles extension) + template inline detail::_xmat3 orientate3(const T angle){return orientate3GTX(angle);} //!< \brief Creates a 3 * 3 rotation matrix from angle (from GLM_GTX_euler_angles extension) + template inline detail::_xmat3 orientate3(const detail::_xvec3& angles){return orientate3GTX(angles);} //!< \brief Creates a 3 * 3 rotation matrix from angles (from GLM_GTX_euler_angles extension) + template inline detail::_xmat4 orientate4(const detail::_xvec3& angles){return orientate4GTX(angles);} //!< \brief Creates a 4 * 4 rotation matrix from angles (from GLM_GTX_euler_angles extension) + } + } +} + +#define GLM_GTX_euler_angles namespace gtx::euler_angles + +#include "euler_angles.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_euler_angles;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_euler_angles__ diff --git a/wip/sse/glm/ext/gtx/euler_angles.inl b/wip/sse/glm/ext/gtx/euler_angles.inl new file mode 100644 index 00000000..d260d765 --- /dev/null +++ b/wip/sse/glm/ext/gtx/euler_angles.inl @@ -0,0 +1,97 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-08-14 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/euler_angles.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat2 orientate2GTX(const T angle) + { + T c = cos(angle); + T s = sin(angle); + + detail::_xmat2 Result; + Result[0][0] = c; + Result[0][1] = s; + Result[1][0] = -s; + Result[1][1] = c; + return Result; + } + + template + inline detail::_xmat3 orientate3GTX(const T angle) + { + T c = cos(angle); + T s = sin(angle); + + detail::_xmat3 Result; + Result[0][0] = c; + Result[0][1] = s; + Result[0][2] = 0.0f; + Result[1][0] = -s; + Result[1][1] = c; + Result[1][2] = 0.0f; + Result[2][0] = 0.0f; + Result[2][1] = 0.0f; + Result[2][2] = 1.0f; + return Result; + } + + template + inline detail::_xmat3 orientate3GTX(const detail::_xvec3& angles) + { + T tmp_ch = cos(angles.x); + T tmp_sh = sin(angles.x); + T tmp_cp = cos(angles.y); + T tmp_sp = sin(angles.y); + T tmp_cb = cos(angles.z); + T tmp_sb = sin(angles.z); + + detail::_xmat3 Result; + Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb; + Result[0][1] = tmp_sb * tmp_cp; + Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb; + Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb; + Result[1][1] = tmp_cb * tmp_cp; + Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb; + Result[2][0] = tmp_sh * tmp_cp; + Result[2][1] = -tmp_sp; + Result[2][2] = tmp_ch * tmp_cp; + return Result; + } + + template + inline detail::_xmat4 orientate4GTX(const detail::_xvec3& angles) + { + T tmp_ch = cos(angles.x); + T tmp_sh = sin(angles.x); + T tmp_cp = cos(angles.y); + T tmp_sp = sin(angles.y); + T tmp_cb = cos(angles.z); + T tmp_sb = sin(angles.z); + + detail::_xmat4 Result; + Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb; + Result[0][1] = tmp_sb * tmp_cp; + Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb; + Result[0][3] = T(0); + Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb; + Result[1][1] = tmp_cb * tmp_cp; + Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb; + Result[1][3] = T(0); + Result[2][0] = tmp_sh * tmp_cp; + Result[2][1] = -tmp_sp; + Result[2][2] = tmp_ch * tmp_cp; + Result[2][3] = T(0); + Result[3][0] = T(0); + Result[3][1] = T(0); + Result[3][2] = T(0); + Result[3][3] = T(1); + return Result; + } +} diff --git a/wip/sse/glm/ext/gtx/extend.h b/wip/sse/glm/ext/gtx/extend.h new file mode 100644 index 00000000..0ccba557 --- /dev/null +++ b/wip/sse/glm/ext/gtx/extend.h @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-07 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/extend.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_extend__ +#define __glm_gtx_extend__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template genType extendGTX(const genType& Origin, const genType& Source, const T Length); //!< \brief Extends of Length the Origin position using the (Source - Origin) direction (from GLM_GTX_extend extension) + + namespace gtx + { + //! GLM_GTX_extend extension: Extend a position from a source to a position at a defined length. + namespace extend + { + template inline genType extend(const genType& Origin, const genType& Source, const T Length){return extendGTX(Origin, Source, Length);} //!< \brief Extends of Length the Origin position using the (Source - Origin) direction (from GLM_GTX_extend extension) + } + } +} + +#define GLM_GTX_extend namespace gtx::extend + +#include "extend.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_extend;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_extend__ diff --git a/wip/sse/glm/ext/gtx/extend.inl b/wip/sse/glm/ext/gtx/extend.inl new file mode 100644 index 00000000..f6da5d5d --- /dev/null +++ b/wip/sse/glm/ext/gtx/extend.inl @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-07 +// Updated : 2006-01-07 +// Licence : This source is under GNU LGPL licence +// File : gtx_extend.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM version 1.0 +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + T extendGTX(const T Origin, const T Source, const T Distance) + { + return Origin + (Source - Origin) * Distance; + } + + template + detail::_xvec2 extendGTX(const detail::_xvec2& Origin, const detail::_xvec2& Source, const T Distance) + { + return Origin + (Source - Origin) * Distance; + } + + template + detail::_xvec3 extendGTX(const detail::_xvec3& Origin, const detail::_xvec3& Source, const T Distance) + { + return Origin + (Source - Origin) * Distance; + } + + template + detail::_xvec4 extendGTX(const detail::_xvec4& Origin, const detail::_xvec4& Source, const T Distance) + { + return Origin + (Source - Origin) * Distance; + } +} diff --git a/wip/sse/glm/ext/gtx/extented_min_max.h b/wip/sse/glm/ext/gtx/extented_min_max.h new file mode 100644 index 00000000..14b83524 --- /dev/null +++ b/wip/sse/glm/ext/gtx/extented_min_max.h @@ -0,0 +1,105 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-14 +// Updated : 2007-08-14 +// Licence : This source is under GNU LGPL licence +// File : gtx_extented_min_max.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_half +// - GLM_GTX_double +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_extented_min_max__ +#define __glm_gtx_extented_min_max__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/half.h" +#include "../gtx/double.h" + +namespace glm +{ + template detail::_xvec2 minGTX(const detail::_xvec2& x, const T y, const T z); //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 minGTX(const detail::_xvec3& x, const T y, const T z); //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 minGTX(const detail::_xvec4& x, const T y, const T z); //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template detail::_xvec2 minGTX(const detail::_xvec2& x, const T y, const T z, const T w); //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 minGTX(const detail::_xvec3& x, const T y, const T z, const T w); //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 minGTX(const detail::_xvec4& x, const T y, const T z, const T w); //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + + template detail::_xvec2 minGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z); //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 minGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z); //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 minGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z); //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template detail::_xvec2 minGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z, const detail::_xvec2& w); //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 minGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z, const detail::_xvec3& w); //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 minGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z, const detail::_xvec4& w); //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + + template detail::_xvec2 maxGTX(const detail::_xvec2& x, const T y, const T z); //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 maxGTX(const detail::_xvec3& x, const T y, const T z); //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 maxGTX(const detail::_xvec4& x, const T y, const T z); //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template detail::_xvec2 maxGTX(const detail::_xvec2& x, const T y, const T z, const T w); //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 maxGTX(const detail::_xvec3& x, const T y, const T z, const T w); //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 maxGTX(const detail::_xvec4& x, const T y, const T z, const T w); //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + + template detail::_xvec2 maxGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z); //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 maxGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z); //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 maxGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z); //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template detail::_xvec2 maxGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z, const detail::_xvec2& w); //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec3 maxGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z, const detail::_xvec3& w); //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template detail::_xvec4 maxGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z, const detail::_xvec4& w); //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + + namespace gtx + { + //! GLM_GTX_extented_min_max extension: Min and max functions for 3 to 4 parameters. + namespace extented_min_max + { + template inline detail::_xvec2 min(const detail::_xvec2& x, const T y, const T z){return minGTX(x, y, z);} //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 min(const detail::_xvec3& x, const T y, const T z){return minGTX(x, y, z);} //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 min(const detail::_xvec4& x, const T y, const T z){return minGTX(x, y, z);} //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template inline detail::_xvec2 min(const detail::_xvec2& x, const T y, const T z, const T w){return minGTX(x, y, z, w);} //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 min(const detail::_xvec3& x, const T y, const T z, const T w){return minGTX(x, y, z, w);} //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 min(const detail::_xvec4& x, const T y, const T z, const T w){return minGTX(x, y, z, w);} //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + + template inline detail::_xvec2 min(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z){return minGTX(x, y, z);} //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 min(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z){return minGTX(x, y, z);} //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 min(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z){return minGTX(x, y, z);} //!< Return the minimum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template inline detail::_xvec2 min(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z, const detail::_xvec2& w){return minGTX(x, y, z, w);} //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 min(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z, const detail::_xvec3& w){return minGTX(x, y, z, w);} //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 min(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z, const detail::_xvec4& w){return minGTX(x, y, z, w);} //!< Return the minimum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + + template inline detail::_xvec2 max(const detail::_xvec2& x, const T y, const T z){return maxGTX(x, y, z);} //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 max(const detail::_xvec3& x, const T y, const T z){return maxGTX(x, y, z);} //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 max(const detail::_xvec4& x, const T y, const T z){return maxGTX(x, y, z);} //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template inline detail::_xvec2 max(const detail::_xvec2& x, const T y, const T z, const T w){return maxGTX(x, y, z, w);} //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 max(const detail::_xvec3& x, const T y, const T z, const T w){return maxGTX(x, y, z, w);} //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 max(const detail::_xvec4& x, const T y, const T z, const T w){return maxGTX(x, y, z, w);} //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + + template inline detail::_xvec2 max(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z){return maxGTX(x, y, z);} //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 max(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z){return maxGTX(x, y, z);} //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 max(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z){return maxGTX(x, y, z);} //!< Return the maximum component-wise values of 3 imputs (From GLM_GTX_extented_min_max extension) + + template inline detail::_xvec2 max(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z, const detail::_xvec2& w){return maxGTX(x, y, z, w);} //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec3 max(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z, const detail::_xvec3& w){return maxGTX(x, y, z, w);} //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + template inline detail::_xvec4 max(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z, const detail::_xvec4& w){return maxGTX(x, y, z, w);} //!< Return the maximum component-wise values of 4 imputs (From GLM_GTX_extented_min_max extension) + } + } +} + +#define GLM_GTX_extented_min_max namespace gtx::extented_min_max + +#include "extented_min_max.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_extented_min_max;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_extented_min_max__ diff --git a/wip/sse/glm/ext/gtx/extented_min_max.inl b/wip/sse/glm/ext/gtx/extented_min_max.inl new file mode 100644 index 00000000..14c3e2ac --- /dev/null +++ b/wip/sse/glm/ext/gtx/extented_min_max.inl @@ -0,0 +1,155 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-14 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : gtx_extented_min_max.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xvec2 minGTX(const detail::_xvec2& x, const T y, const T z) + { + return min(x, min(y, z)); + } + + template + inline detail::_xvec3 minGTX(const detail::_xvec3& x, const T y, const T z) + { + return min(x, min(y, z)); + } + + template + inline detail::_xvec4 minGTX(const detail::_xvec4& x, const T y, const T z) + { + return min(x, min(y, z)); + } + + template + inline detail::_xvec2 minGTX(const detail::_xvec2& x, const T y, const T z, const T w) + { + return min(x, min(y, min(z, w))); + } + + template + inline detail::_xvec3 minGTX(const detail::_xvec3& x, const T y, const T z, const T w) + { + return min(x, min(y, min(z, w))); + } + + template + inline detail::_xvec4 minGTX(const detail::_xvec4& x, const T y, const T z, const T w) + { + return min(x, min(y, min(z, w))); + } + + template + inline detail::_xvec2 minGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z) + { + return min(x, min(y, z)); + } + + template + inline detail::_xvec3 minGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z) + { + return min(x, min(y, z)); + } + + template + inline detail::_xvec4 minGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z) + { + return min(x, min(y, z)); + } + + template + inline detail::_xvec2 minGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z, const detail::_xvec2& w) + { + return min(min(x, y), min(z, w)); + } + + template + inline detail::_xvec3 minGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z, const detail::_xvec3& w) + { + return min(min(x, y), min(z, w)); + } + + template + inline detail::_xvec4 minGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z, const detail::_xvec4& w) + { + return min(min(x, y), min(z, w)); + } + + template + inline detail::_xvec2 maxGTX(const detail::_xvec2& x, const T y, const T z) + { + return max(x, max(y, z)); + } + + template + inline detail::_xvec3 maxGTX(const detail::_xvec3& x, const T y, const T z) + { + return max(x, max(y, z)); + } + + template + inline detail::_xvec4 maxGTX(const detail::_xvec4& x, const T y, const T z) + { + return max(x, max(y, z)); + } + + template + inline detail::_xvec2 maxGTX(const detail::_xvec2& x, const T y, const T z, const T w) + { + return max(max(x, y), max(z, w)); + } + + template + inline detail::_xvec3 maxGTX(const detail::_xvec3& x, const T y, const T z, const T w) + { + return max(max(x, y), max(z, w)); + } + + template + inline detail::_xvec4 maxGTX(const detail::_xvec4& x, const T y, const T z, const T w) + { + return max(max(x, y), max(z, w)); + } + + template + inline detail::_xvec2 maxGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z) + { + return max(max(x, y), z); + } + + template + inline detail::_xvec3 maxGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z) + { + return max(max(x, y), z); + } + + template + inline detail::_xvec4 maxGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z) + { + return max(max(x, y), z); + } + + template + inline detail::_xvec2 maxGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& z, const detail::_xvec2& w) + { + return max(max(x, y), max(z, w)); + } + + template + inline detail::_xvec3 maxGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& z, const detail::_xvec3& w) + { + return max(max(x, y), max(z, w)); + } + + template + inline detail::_xvec4 maxGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& z, const detail::_xvec4& w) + { + return max(max(x, y), max(z, w)); + } +} diff --git a/wip/sse/glm/ext/gtx/fast_exponential.h b/wip/sse/glm/ext/gtx/fast_exponential.h new file mode 100644 index 00000000..c273e137 --- /dev/null +++ b/wip/sse/glm/ext/gtx/fast_exponential.h @@ -0,0 +1,84 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-09 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/fast_exponential.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_half +// - GLM_GTX_double +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_fast_exponential__ +#define __glm_gtx_fast_exponential__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/half.h" +#include "../gtx/double.h" + +namespace glm +{ + template T fastPowGTX(const T x, const T y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec2 fastPowGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec3 fastPowGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec4 fastPowGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + + template T fastPowGTX(const T x, int y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec2 fastPowGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec3 fastPowGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec4 fastPowGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + + template T fastExpGTX(const T x); //!< Faster than the common exp function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec2 fastExpGTX(const detail::_xvec2& x); //!< Faster than the common exp function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec3 fastExpGTX(const detail::_xvec3& x); //!< Faster than the common exp function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec4 fastExpGTX(const detail::_xvec4& x); //!< Faster than the common exp function but less accurate (From GLM_GTX_fast_exponential extension) + + template T fastLogGTX(const T x); //!< Faster than the common log function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec2 fastLogGTX(const detail::_xvec2& x); //!< Faster than the common log function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec3 fastLogGTX(const detail::_xvec3& x); //!< Faster than the common log function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec4 fastLogGTX(const detail::_xvec4& x); //!< Faster than the common log function but less accurate (From GLM_GTX_fast_exponential extension) + + template T fastExp2GTX(const T x); //!< Faster than the common exp2 function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec2 fastExp2GTX(const detail::_xvec2& x); //!< Faster than the common exp2 function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec3 fastExp2GTX(const detail::_xvec3& x); //!< Faster than the common exp2 function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec4 fastExp2GTX(const detail::_xvec4& x); //!< Faster than the common exp2 function but less accurate (From GLM_GTX_fast_exponential extension) + + template T fastLog2GTX(const T x); //!< Faster than the common log2 function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec2 fastLog2GTX(const detail::_xvec2& x); //!< Faster than the common log2 function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec3 fastLog2GTX(const detail::_xvec3& x); //!< Faster than the common log2 function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec4 fastLog2GTX(const detail::_xvec4& x); //!< Faster than the common log2 function but less accurate (From GLM_GTX_fast_exponential extension) + + template T fastLnGTX(const T x); //!< Faster than the common ln function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec2 fastLnGTX(const detail::_xvec2& x); //!< Faster than the common ln function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec3 fastLnGTX(const detail::_xvec3& x); //!< Faster than the common ln function but less accurate (From GLM_GTX_fast_exponential extension) + template detail::_xvec4 fastLnGTX(const detail::_xvec4& x); //!< Faster than the common ln function but less accurate (From GLM_GTX_fast_exponential extension) + + namespace gtx + { + //! GLM_GTX_fast_exponential extension: Fast but less accurate implementations of exponential based functions. + namespace fast_exponential + { + template inline T fastPow(const T& x, const T& y){return fastPowGTX(x, y);} //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template inline T fastPow(const T& x, const U& y){return fastPowGTX(x, y);} //!< Faster than the common pow function but less accurate (From GLM_GTX_fast_exponential extension) + template inline T fastExp(const T& x){return fastExpGTX(x);} //!< Faster than the common exp function but less accurate (From GLM_GTX_fast_exponential extension) + template inline T fastLog(const T& x){return fastLogGTX(x);} //!< Faster than the common log function but less accurate (From GLM_GTX_fast_exponential extension) + template inline T fastExp2(const T& x){return fastExp2GTX(x);} //!< Faster than the common exp2 function but less accurate (From GLM_GTX_fast_exponential extension) + template inline T fastLog2(const T& x){return fastLog2GTX(x);} //!< Faster than the common log2 function but less accurate (From GLM_GTX_fast_exponential extension) + template inline T fastLn(const T& x){return fastLnGTX(x);} //!< Faster than the common ln function but less accurate (From GLM_GTX_fast_exponential extension) + } + } +} + +#define GLM_GTX_fast_exponential namespace gtx::fast_exponential + +#include "fast_exponential.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_fast_exponential;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_fast_exponential__ diff --git a/wip/sse/glm/ext/gtx/fast_exponential.inl b/wip/sse/glm/ext/gtx/fast_exponential.inl new file mode 100644 index 00000000..c13248de --- /dev/null +++ b/wip/sse/glm/ext/gtx/fast_exponential.inl @@ -0,0 +1,265 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-09 +// Updated : 2006-01-09 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/fast_exponential.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // fastPowGTX: + template + inline T fastPowGTX(const T x, const T y) + { + return exp(y * log(x)); + } + + template + inline detail::_xvec2 fastPowGTX(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + fastPowGTX(x.x, y.x), + fastPowGTX(x.y, y.y)); + } + + template + inline detail::_xvec3 fastPowGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + fastPowGTX(x.x, y.x), + fastPowGTX(x.y, y.y), + fastPowGTX(x.z, y.z)); + } + + template + inline detail::_xvec4 fastPowGTX(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + fastPowGTX(x.x, y.x), + fastPowGTX(x.y, y.y), + fastPowGTX(x.z, y.z), + fastPowGTX(x.w, y.w)); + } + + template + inline T fastPowGTX(const T x, int y) + { + T f = T(1); + for(int i = 0; i < y; ++i) + f *= x; + return f; + } + + template + inline detail::_xvec2 fastPowGTX(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + fastPowGTX(x.x, y.x), + fastPowGTX(x.y, y.y)); + } + + template + inline detail::_xvec3 fastPowGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + fastPowGTX(x.x, y.x), + fastPowGTX(x.y, y.y), + fastPowGTX(x.z, y.z)); + } + + template + inline detail::_xvec4 fastPowGTX(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + fastPowGTX(x.x, y.x), + fastPowGTX(x.y, y.y), + fastPowGTX(x.z, y.z), + fastPowGTX(x.w, y.w)); + } + + // fastExpGTX + // Note: This function provides accurate results only for value between -1 and 1, else avoid it. + template + inline T fastExpGTX(const T x) + { + // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. + // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); + T x2 = x * x; + T x3 = x2 * x; + T x4 = x3 * x; + T x5 = x4 * x; + return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333)); + } +/* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance + inline float fastExpGTX(float x) + { + const float e = 2.718281828f; + const float IntegerPart = floor(x); + const float FloatPart = x - IntegerPart; + float z = 1.f; + + for(int i = 0; i < int(IntegerPart); ++i) + z *= e; + + const float x2 = FloatPart * FloatPart; + const float x3 = x2 * FloatPart; + const float x4 = x3 * FloatPart; + const float x5 = x4 * FloatPart; + return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)); + } + + // Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers + inline float fastExpGTX(float x) + { + // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. + // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); + float x2 = x * x; + float x3 = x2 * x; + float x4 = x3 * x; + float x5 = x4 * x; + float x6 = x5 * x; + float x7 = x6 * x; + float x8 = x7 * x; + return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)+ (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f);; + } +*/ + template + inline detail::_xvec2 fastExpGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastExpGTX(x.x), + fastExpGTX(x.y)); + } + + template + inline detail::_xvec3 fastExpGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastExpGTX(x.x), + fastExpGTX(x.y), + fastExpGTX(x.z)); + } + + template + inline detail::_xvec4 fastExpGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastExpGTX(x.x), + fastExpGTX(x.y), + fastExpGTX(x.z), + fastExpGTX(x.w)); + } + + // fastLogGTX + template + inline T fastLogGTX(const T x) + { + return std::log(x); + } + + /* Slower than the VC7.1 function... + inline float fastLogGTX(float x) + { + float y1 = (x - 1.0f) / (x + 1.0f); + float y2 = y1 * y1; + return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f))); + } + */ + + template + inline detail::_xvec2 fastLogGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastLnGTX(x.x), + fastLnGTX(x.y)); + } + + template + inline detail::_xvec3 fastLogGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastLnGTX(x.x), + fastLnGTX(x.y), + fastLnGTX(x.z)); + } + + template + inline detail::_xvec4 fastLogGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastLnGTX(x.x), + fastLnGTX(x.y), + fastLnGTX(x.z), + fastLnGTX(x.w)); + } + + //fastExp2GTX, ln2 = 0.69314718055994530941723212145818f + template + inline T fastExp2GTX(const T x) + { + return fastExpGTX(0.69314718055994530941723212145818f * x); + } + + template + inline detail::_xvec2 fastExp2GTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastExp2GTX(x.x), + fastExp2GTX(x.y)); + } + + template + inline detail::_xvec3 fastExp2GTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastExp2GTX(x.x), + fastExp2GTX(x.y), + fastExp2GTX(x.z)); + } + + template + inline detail::_xvec4 fastExp2GTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastExp2GTX(x.x), + fastExp2GTX(x.y), + fastExp2GTX(x.z), + fastExp2GTX(x.w)); + } + + // fastLog2GTX, ln2 = 0.69314718055994530941723212145818f + template + inline T fastLog2GTX(const T x) + { + return fastLogGTX(x) / 0.69314718055994530941723212145818f; + } + + template + inline detail::_xvec2 fastLog2GTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastLog2GTX(x.x), + fastLog2GTX(x.y)); + } + + template + inline detail::_xvec3 fastLog2GTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastLog2GTX(x.x), + fastLog2GTX(x.y), + fastLog2GTX(x.z)); + } + + template + inline detail::_xvec4 fastLog2GTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastLog2GTX(x.x), + fastLog2GTX(x.y), + fastLog2GTX(x.z), + fastLog2GTX(x.w)); + } +} diff --git a/wip/sse/glm/ext/gtx/fast_square_root.h b/wip/sse/glm/ext/gtx/fast_square_root.h new file mode 100644 index 00000000..3f3d3cf7 --- /dev/null +++ b/wip/sse/glm/ext/gtx/fast_square_root.h @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-04 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/fast_square_root.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Note: +// - Sqrt optimisation based on Newton's method, +// www.gamedev.net/community/forums/topic.asp?topic id=139956 +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_fast_square_root__ +#define __glm_gtx_fast_square_root__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template T fastSqrtGTX(const T x); //!< Faster than the common sqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec2 fastSqrtGTX(const detail::_xvec2& x); //!< Faster than the common sqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec3 fastSqrtGTX(const detail::_xvec3& x); //!< Faster than the common sqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec4 fastSqrtGTX(const detail::_xvec4& x); //!< Faster than the common sqrt function but less accurate (From GLM_GTX_fast_square_root extension) + + template T fastInverseSqrtGTX(const T x); //!< Faster than the common inversesqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec2 fastInverseSqrtGTX(const detail::_xvec2& x); //!< Faster than the common inversesqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec3 fastInverseSqrtGTX(const detail::_xvec3& x); //!< Faster than the common inversesqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec4 fastInverseSqrtGTX(const detail::_xvec4& x); //!< Faster than the common inversesqrt function but less accurate (From GLM_GTX_fast_square_root extension) + + template T fastLengthGTX(const T x); //!< Faster than the common length function but less accurate (From GLM_GTX_fast_square_root extension) + template T fastLengthGTX(const detail::_xvec2& x); //!< Faster than the common length function but less accurate (From GLM_GTX_fast_square_root extension) + template T fastLengthGTX(const detail::_xvec3& x); //!< Faster than the common length function but less accurate (From GLM_GTX_fast_square_root extension) + template T fastLengthGTX(const detail::_xvec4& x); //!< Faster than the common length function but less accurate (From GLM_GTX_fast_square_root extension) + + template T fastDistanceGTX(const T x, const T y); //!< Faster than the common distance function but less accurate (From GLM_GTX_fast_square_root extension) + template T fastDistanceGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< Faster than the common distance function but less accurate (From GLM_GTX_fast_square_root extension) + template T fastDistanceGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< Faster than the common distance function but less accurate (From GLM_GTX_fast_square_root extension) + template T fastDistanceGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< Faster than the common distance function but less accurate (From GLM_GTX_fast_square_root extension) + + template T fastNormalizeGTX(const T x); //!< Faster than the common normalize function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec2 fastNormalizeGTX(const detail::_xvec2& x); //!< Faster than the common normalize function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec3 fastNormalizeGTX(const detail::_xvec3& x); //!< Faster than the common normalize function but less accurate (From GLM_GTX_fast_square_root extension) + template detail::_xvec4 fastNormalizeGTX(const detail::_xvec4& x); //!< Faster than the common normalize function but less accurate (From GLM_GTX_fast_square_root extension) + + namespace gtx + { + //! GLM_GTX_fast_square_root extension: Fast but less accurate implementations of square root based functions. + namespace fast_square_root + { + template inline T fastSqrt(const T& x){return fastSqrtGTX(x);} //!< Faster than the common sqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template inline T fastInverseSqrt(const T& x){return fastInverseSqrtGTX(x);} //!< Faster than the common inversesqrt function but less accurate (From GLM_GTX_fast_square_root extension) + template inline T fastLength(const T& x){return fastLengthGTX(x);} //!< Faster than the common length function but less accurate (From GLM_GTX_fast_square_root extension) + template inline T fastDistance(const T& x, const T& y){return fastDistanceGTX(x, y);} //!< Faster than the common distance function but less accurate (From GLM_GTX_fast_square_root extension) + template inline T fastNormalize(const T& x){return fastNormalizeGTX(x);} //!< Faster than the common normalize function but less accurate (From GLM_GTX_fast_square_root extension) + } + } +} + +#define GLM_GTX_fast_square_root namespace gtx::fast_square_root + +#include "fast_square_root.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_fast_square_root;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_fast_square_root__ diff --git a/wip/sse/glm/ext/gtx/fast_square_root.inl b/wip/sse/glm/ext/gtx/fast_square_root.inl new file mode 100644 index 00000000..57a0bcb0 --- /dev/null +++ b/wip/sse/glm/ext/gtx/fast_square_root.inl @@ -0,0 +1,165 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-04 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/fast_square_root.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // fastSqrtGTX + template + inline T fastSqrtGTX(const T x) + { + return 1.0f / fastInverseSqrtGTX(x); + } + + template + inline detail::_xvec2 fastSqrtGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastSqrtGTX(x.x), + fastSqrtGTX(x.y)); + } + + template + inline detail::_xvec3 fastSqrtGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastSqrtGTX(x.x), + fastSqrtGTX(x.y), + fastSqrtGTX(x.z)); + } + + template + inline detail::_xvec4 fastSqrtGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastSqrtGTX(x.x), + fastSqrtGTX(x.y), + fastSqrtGTX(x.z), + fastSqrtGTX(x.w)); + } + + // fastInversesqrtGTX + template + inline T fastInverseSqrtGTX(const T x) + { + float xhalf = 0.5f * x; + int i = *(int*)&x; + i = 0x5f375a86 - (i >> 1); + x = *(float*)&i; + x = x * (1.5f - xhalf * x * x); + return T(x); + } + + template + inline detail::_xvec2 fastInverseSqrtGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastInverseSqrtGTX(x.x), + fastInverseSqrtGTX(x.y)); + } + + template + inline detail::_xvec3 fastInverseSqrtGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastInverseSqrtGTX(x.x), + fastInverseSqrtGTX(x.y), + fastInverseSqrtGTX(x.z)); + } + + template + inline detail::_xvec4 fastInverseSqrtGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastInverseSqrtGTX(x.x), + fastInverseSqrtGTX(x.y), + fastInverseSqrtGTX(x.z), + fastInverseSqrtGTX(x.w)); + } + + // fastLengthGTX + template + inline T fastLengthGTX(const T x) + { + return abs(x); + } + + template + inline T fastLengthGTX(const detail::_xvec2& x) + { + T sqr = x.x * x.x + x.y * x.y; + return fastSqrtGTX(sqr); + } + + template + inline T fastLengthGTX(const detail::_xvec3& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z; + return fastSqrtGTX(sqr); + } + + template + inline T fastLengthGTX(const detail::_xvec4& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; + return fastSqrtGTX(sqr); + } + + // fastDistanceGTX + template + inline T fastDistanceGTX(const T x, const T y) + { + return fastLengthGTX(y - x); + } + + template + inline T fastDistanceGTX(const detail::_xvec2& x, const detail::_xvec2& y) + { + return fastLengthGTX(y - x); + } + + template + inline T fastDistanceGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return fastLengthGTX(y - x); + } + + template + inline T fastDistanceGTX(const detail::_xvec4& x, const detail::_xvec4& y) + { + return fastLengthGTX(y - x); + } + + // fastNormalizeGTX + template + inline T fastNormalizeGTX(const T x) + { + return x > 0.0f ? 1.0f : -1.0f; + } + + template + inline detail::_xvec2 fastNormalizeGTX(const detail::_xvec2& x) + { + T sqr = x.x * x.x + x.y * x.y; + return x * fastInverseSqrtGTX(sqr); + } + + template + inline detail::_xvec3 fastNormalizeGTX(const detail::_xvec3& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z; + return x * fastInverseSqrtGTX(sqr); + } + + template + inline detail::_xvec4 fastNormalizeGTX(const detail::_xvec4& x) + { + T sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; + return x * fastInverseSqrtGTX(sqr); + } +} diff --git a/wip/sse/glm/ext/gtx/fast_trigonometry.h b/wip/sse/glm/ext/gtx/fast_trigonometry.h new file mode 100644 index 00000000..a4e0cc0a --- /dev/null +++ b/wip/sse/glm/ext/gtx/fast_trigonometry.h @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-08 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/fast_trigonometry.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_fast_trigonometry__ +#define __glm_gtx_fast_trigonometry__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template T fastSinGTX(const T angle); //!< Faster than the common sin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec2 fastSinGTX(const detail::_xvec2& angle); //!< Faster than the common sin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec3 fastSinGTX(const detail::_xvec3& angle); //!< Faster than the common sin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec4 fastSinGTX(const detail::_xvec4& angle); //!< Faster than the common sin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + + template T fastCosGTX(const T angle); //!< Faster than the common cos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec2 fastCosGTX(const detail::_xvec2& angle); //!< Faster than the common cos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec3 fastCosGTX(const detail::_xvec3& angle); //!< Faster than the common cos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec4 fastCosGTX(const detail::_xvec4& angle); //!< Faster than the common cos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + + template T fastTanGTX(const T angle); //!< Faster than the common tan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec2 fastTanGTX(const detail::_xvec2& angle); //!< Faster than the common tan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec3 fastTanGTX(const detail::_xvec3& angle); //!< Faster than the common tan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec4 fastTanGTX(const detail::_xvec4& angle); //!< Faster than the common tan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + + template T fastAsinGTX(const T x); //!< Faster than the common asin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec2 fastAsinGTX(const detail::_xvec2& x); //!< Faster than the common asin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec3 fastAsinGTX(const detail::_xvec3& x); //!< Faster than the common asin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec4 fastAsinGTX(const detail::_xvec4& x); //!< Faster than the common asin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + + template T fastAcosGTX(const T x); //!< Faster than the common acos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec2 fastAcosGTX(const detail::_xvec2& x); //!< Faster than the common acos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec3 fastAcosGTX(const detail::_xvec3& x); //!< Faster than the common acos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec4 fastAcosGTX(const detail::_xvec4& x); //!< Faster than the common acos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + + template T fastAtanGTX(const T y, const T x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec2 fastAtanGTX(const detail::_xvec2& y, const detail::_xvec2& x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec3 fastAtanGTX(const detail::_xvec3& y, const detail::_xvec3& x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec4 fastAtanGTX(const detail::_xvec4& y, const detail::_xvec4& x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + + template T fastAtanGTX(const T y_over_x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec2 fastAtanGTX(const detail::_xvec2& y_over_x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec3 fastAtanGTX(const detail::_xvec3& y_over_x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template detail::_xvec4 fastAtanGTX(const detail::_xvec4& y_over_x); //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + + namespace gtx + { + //! GLM_GTX_fast_trigonometry extension: Fast but less accurate implementations of trigonometric functions. + namespace fast_trigonometry + { + template inline T fastSin(const T& angle){return fastSinGTX(angle);} //!< Faster than the common sin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template inline T fastCos(const T& angle){return fastCosGTX(angle);} //!< Faster than the common cos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template inline T fastTan(const T& angle){return fastTanGTX(angle);} //!< Faster than the common tan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template inline T fastAsin(const T& angle){return fastAsinGTX(angle);} //!< Faster than the common asin function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template inline T fastAcos(const T& angle){return fastAcosGTX(angle);} //!< Faster than the common acos function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template inline T fastAtan(const T& y, const T& x){return fastAtanGTX(y, x);} //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + template inline T fastAtan(const T& angle){return fastAtanGTX(angle);} //!< Faster than the common atan function but less accurate. Defined between -2pi and 2pi. (From GLM_GTX_fast_trigonometry extension) + } + } +} + +#define GLM_GTX_fast_trigonometry namespace gtx::fast_trigonometry + +#include "fast_trigonometry.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_fast_trigonometry;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_fast_trigonometry__ diff --git a/wip/sse/glm/ext/gtx/fast_trigonometry.inl b/wip/sse/glm/ext/gtx/fast_trigonometry.inl new file mode 100644 index 00000000..2101b667 --- /dev/null +++ b/wip/sse/glm/ext/gtx/fast_trigonometry.inl @@ -0,0 +1,243 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-08 +// Updated : 2006-01-08 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/fast_trigonometry.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // sin + template + inline T fastSinGTX(const T x) + { + return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040)); + } + + template + inline detail::_xvec2 fastSinGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastSinGTX(x.x), + fastSinGTX(x.y)); + } + + template + inline detail::_xvec3 fastSinGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastSinGTX(x.x), + fastSinGTX(x.y), + fastSinGTX(x.z)); + } + + template + inline detail::_xvec4 fastSinGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastSinGTX(x.x), + fastSinGTX(x.y), + fastSinGTX(x.z), + fastSinGTX(x.w)); + } + + // cos + template + inline T fastCosGTX(const T x) + { + return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888)); + } + + template + inline detail::_xvec2 fastCosGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastCosGTX(x.x), + fastCosGTX(x.y)); + } + + template + inline detail::_xvec3 fastCosGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastCosGTX(x.x), + fastCosGTX(x.y), + fastCosGTX(x.z)); + } + + template + inline detail::_xvec4 fastCosGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastCosGTX(x.x), + fastCosGTX(x.y), + fastCosGTX(x.z), + fastCosGTX(x.w)); + } + + // tan + template + inline T fastTanGTX(const T x) + { + return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539)); + } + + template + inline detail::_xvec2 fastTanGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastTanGTX(x.x), + fastTanGTX(x.y)); + } + + template + inline detail::_xvec3 fastTanGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastTanGTX(x.x), + fastTanGTX(x.y), + fastTanGTX(x.z)); + } + + template + inline detail::_xvec4 fastTanGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastTanGTX(x.x), + fastTanGTX(x.y), + fastTanGTX(x.z), + fastTanGTX(x.w)); + } + + // asin + template + inline T fastAsinGTX(const T x) + { + return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159)); + } + + template detail::_xvec2 fastAsinGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastAsinGTX(x.x), + fastAsinGTX(x.y)); + } + + template detail::_xvec3 fastAsinGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastAsinGTX(x.x), + fastAsinGTX(x.y), + fastAsinGTX(x.z)); + } + + template detail::_xvec4 fastAsinGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastAsinGTX(x.x), + fastAsinGTX(x.y), + fastAsinGTX(x.z), + fastAsinGTX(x.w)); + } + + // acos + template + inline T fastAcosGTX(const T x) + { + return T(1.5707963267948966192313216916398) - fastAsinGTX(x); //(PI / 2) + } + + template detail::_xvec2 fastAcosGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastAcosGTX(x.x), + fastAcosGTX(x.y)); + } + + template detail::_xvec3 fastAcosGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastAcosGTX(x.x), + fastAcosGTX(x.y), + fastAcosGTX(x.z)); + } + + template detail::_xvec4 fastAcosGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastAcosGTX(x.x), + fastAcosGTX(x.y), + fastAcosGTX(x.z), + fastAcosGTX(x.w)); + } + + // atan + template + inline T fastAtanGTX(const T y, const T x) + { + T sgn = sign(y) * sign(x); + return abs(fastAtanGTX(y / x)) * sgn; + } + + template + inline detail::_xvec2 fastAtanGTX(const detail::_xvec2& y, const detail::_xvec2& x) + { + return detail::_xvec2( + fastAtanGTX(y.x, x.x), + fastAtanGTX(y.y, x.y)); + } + + template + inline detail::_xvec3 fastAtanGTX(const detail::_xvec3& y, const detail::_xvec3& x) + { + return detail::_xvec3( + fastAtanGTX(y.x, x.x), + fastAtanGTX(y.y, x.y), + fastAtanGTX(y.z, x.z)); + } + + template + inline detail::_xvec4 fastAtanGTX(const detail::_xvec4& y, const detail::_xvec4& x) + { + return detail::_xvec4( + fastAtanGTX(y.x, x.x), + fastAtanGTX(y.y, x.y), + fastAtanGTX(y.z, x.z), + fastAtanGTX(y.w, x.w)); + } + + template + inline T fastAtanGTX(const T x) + { + return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909)); + } + + template + inline detail::_xvec2 fastAtanGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + fastAtanGTX(x.x), + fastAtanGTX(x.y)); + } + + template + inline detail::_xvec3 fastAtanGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + fastAtanGTX(x.x), + fastAtanGTX(x.y), + fastAtanGTX(x.z)); + } + + template + inline detail::_xvec4 fastAtanGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + fastAtanGTX(x.x), + fastAtanGTX(x.y), + fastAtanGTX(x.z), + fastAtanGTX(x.w)); + } +} diff --git a/wip/sse/glm/ext/gtx/flexible_mix.h b/wip/sse/glm/ext/gtx/flexible_mix.h new file mode 100644 index 00000000..687a98ad --- /dev/null +++ b/wip/sse/glm/ext/gtx/flexible_mix.h @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-09-21 +// Updated : 2007-09-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/flexible_mix.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_flexible_mix__ +#define __glm_gtx_flexible_mix__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template T mixGTX(T x, T y, U a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + template detail::_xvec2 mixGTX(const detail::_xvec2& x, const detail::_xvec2& y, U a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + template detail::_xvec3 mixGTX(const detail::_xvec3& x, const detail::_xvec3& y, U a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + template detail::_xvec4 mixGTX(const detail::_xvec4& x, const detail::_xvec4& y, U a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + template detail::_xvec2 mixGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + template detail::_xvec3 mixGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + template detail::_xvec4 mixGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& a); //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + + namespace gtx + { + //! GLM_GTX_flexible_mix extension: More flexible functions for linear interpolations + namespace flexible_mix + { + template T mix(T x, T y, U a){return mixGTX(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using a values. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_flexible_mix extension) + } + } +} + +#define GLM_GTX_flexible_mix namespace gtx::flexible_mix + +#include "flexible_mix.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_flexible_mix;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_flexible_mix__ diff --git a/wip/sse/glm/ext/gtx/flexible_mix.inl b/wip/sse/glm/ext/gtx/flexible_mix.inl new file mode 100644 index 00000000..d9af0244 --- /dev/null +++ b/wip/sse/glm/ext/gtx/flexible_mix.inl @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-09-21 +// Updated : 2007-09-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/flexible_mix.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // mix + template + inline T mixGTX(T x, T y, T a) + { + return T(x * (U(1) - a) + y * a); + } + + template + inline detail::_xvec2 mixGTX(const detail::_xvec2& x, const detail::_xvec2& y, U a) + { + return detail::_xvec2(detail::_xvec2(x) * (U(1) - a) + detail::_xvec2(y) * a); + //return x * (U(1) - a) + y * a; + } + + template + inline detail::_xvec3 mixGTX(const detail::_xvec3& x, const detail::_xvec3& y, U a) + { + return detail::_xvec3(detail::_xvec3(x) * (U(1) - a) + detail::_xvec3(y) * a); + //return x * (U(1) - a) + y * a; + //return mix(x, y, _xvec3(a)); + } + + template + inline detail::_xvec4 mixGTX(const detail::_xvec4& x, const detail::_xvec4& y, U a) + { + return detail::_xvec4(detail::_xvec4(x) * (U(1) - a) + detail::_xvec4(y) * a); + //return x * (U(1) - a) + y * a; + } + + template + inline detail::_xvec2 mixGTX(const detail::_xvec2& x, const detail::_xvec2& y, const detail::_xvec2& a) + { + return detail::_xvec2(detail::_xvec2(x) * (U(1) - a) + detail::_xvec2(y) * a); + } + + template + inline detail::_xvec3 mixGTX(const detail::_xvec3& x, const detail::_xvec3& y, const detail::_xvec3& a) + { + return detail::_xvec3(detail::_xvec3(x) * (U(1) - a) + detail::_xvec3(y) * a); + } + + template + inline detail::_xvec4 mixGTX(const detail::_xvec4& x, const detail::_xvec4& y, const detail::_xvec4& a) + { + return detail::_xvec4(detail::_xvec4(x) * (U(1) - a) + detail::_xvec4(y) * a); + } +} diff --git a/wip/sse/glm/ext/gtx/gpu_shader4.h b/wip/sse/glm/ext/gtx/gpu_shader4.h new file mode 100644 index 00000000..4c588527 --- /dev/null +++ b/wip/sse/glm/ext/gtx/gpu_shader4.h @@ -0,0 +1,169 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-11-13 +// Updated : 2007-08-20 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/gpu_shader4.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_round +// - GLM_GTX_half +// - GLM_GTX_double +// - GLM_GTX_integer +/////////////////////////////////////////////////////////////////////////////////////////////////// +// ToDo: +// - Defined all the extensions +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Comment: +// This extension is based on GL_EXT_gpu_shader4 extension +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_gpu_shader4__ +#define __glm_gtx_gpu_shader4__ + +// Dependency: +#include "../../glm.h" +#include "../../ext/gtx/round.h" +#include "../../ext/gtx/half.h" + +namespace glm +{ + __halfGTX truncateGTX(__halfGTX x); //!< \brief Computes the truncate value of x (from GLM_GTX_gpu_shader4 extension) + float truncateGTX(float x); //!< \brief Computes the truncate value of x (from GLM_GTX_gpu_shader4 extension) + double truncateGTX(double x); //!< \brief Computes the truncate value of x (from GLM_GTX_gpu_shader4 extension) + template genType truncateGTX(const genType& x); //!< \brief Computes the component-wise truncate value of x (from GLM_GTX_gpu_shader4 extension) + + unsigned int powGTX(unsigned int x, unsigned int y); //!< \brief Returns x raised to the y power. (from GLM_GTX_gpu_shader4 extension) + unsigned int sqrtGTX(unsigned int x); //!< \brief Returns the positive square root of x. (from GLM_GTX_gpu_shader4 extension) + + typedef detail::_xvec2 __uvec2GTX; //!< \brief Vector of 2 half-precision floating-point numbers. (From GLM_GTX_gpu_shader4 extension) + typedef detail::_xvec3 __uvec3GTX; //!< \brief Vector of 3 half-precision floating-point numbers. (From GLM_GTX_gpu_shader4 extension) + typedef detail::_xvec4 __uvec4GTX; //!< \brief Vector of 4 half-precision floating-point numbers. (From GLM_GTX_gpu_shader4 extension) + + namespace gtx + { + //! GLM_GTX_gpu_shader4 extension: Implementation of GL_EXT_gpu_shader4 for GLM + namespace gpu_shader4 + { + template genType truncate(const genType& x){return truncateGTX(x);} //!< \brief Computes the component-wise truncate value of x (from GLM_GTX_gpu_shader4 extension) + + typedef detail::_xvec2 uvec2; //!< \brief Vector of 2 half-precision floating-point numbers. (From GLM_GTX_gpu_shader4 extension) + typedef detail::_xvec3 uvec3; //!< \brief Vector of 3 half-precision floating-point numbers. (From GLM_GTX_gpu_shader4 extension) + typedef detail::_xvec4 uvec4; //!< \brief Vector of 4 half-precision floating-point numbers. (From GLM_GTX_gpu_shader4 extension) + + // vec2 bit operators + template detail::_xvec2& operator%=(detail::_xvec2& r, const T s); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator%=(detail::_xvec2& r, const detail::_xvec2& v); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator&=(detail::_xvec2& r, const T s); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator&=(detail::_xvec2& r, const detail::_xvec2& v); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator|=(detail::_xvec2& r, const T s); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator|=(detail::_xvec2& r, const detail::_xvec2& v); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator^=(detail::_xvec2& r, const T s); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator^=(detail::_xvec2& r, const detail::_xvec2& v); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator<<=(detail::_xvec2& r, const T s); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator<<=(detail::_xvec2& r, const detail::_xvec2& v); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator>>=(detail::_xvec2& r, const T s); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2& operator>>=(detail::_xvec2& r, const detail::_xvec2& v); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + + template detail::_xvec2 operator% (const detail::_xvec2& v, const T s); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator% (const T s, const detail::_xvec2& v); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator% (const detail::_xvec2& v1, const detail::_xvec2& v2); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator& (const detail::_xvec2& v, const T s); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator& (const T s, const detail::_xvec2& v); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator& (const detail::_xvec2& v1, const detail::_xvec2& v2); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator| (const detail::_xvec2& v, const T s); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator| (const T s, const detail::_xvec2& v); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator| (const detail::_xvec2& v1, const detail::_xvec2& v2); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator^ (const detail::_xvec2& v, const T s); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator^ (const T s, const detail::_xvec2& v); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator^ (const detail::_xvec2& v1, const detail::_xvec2& v2); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator<< (const detail::_xvec2& v, const T s); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator<< (const T s, const detail::_xvec2& v); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator<< (const detail::_xvec2& v1, const detail::_xvec2& v2); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator>> (const detail::_xvec2& v, const T s); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator>> (const T s, const detail::_xvec2& v); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec2 operator>> (const detail::_xvec2& v1, const detail::_xvec2& v2); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template const detail::_xvec2 operator~ (const detail::_xvec2& v); + + // vec3 bit operators + template detail::_xvec3& operator%=(detail::_xvec3& r, const T s); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator%=(detail::_xvec3& r, const detail::_xvec3& v); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator&=(detail::_xvec3& r, const T s); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator&=(detail::_xvec3& r, const detail::_xvec3& v); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator|=(detail::_xvec3& r, const T s); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator|=(detail::_xvec3& r, const detail::_xvec3& v); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator^=(detail::_xvec3& r, const T s); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator^=(detail::_xvec3& r, const detail::_xvec3& v); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator<<=(detail::_xvec3& r, const T s); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator<<=(detail::_xvec3& r, const detail::_xvec3& v); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator>>=(detail::_xvec3& r, const T s); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3& operator>>=(detail::_xvec3& r, const detail::_xvec3& v); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + + template detail::_xvec3 operator% (const detail::_xvec3& v, const T s); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator% (const T s, const detail::_xvec3& v); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator% (const detail::_xvec3& v1, const detail::_xvec3& v2); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator& (const detail::_xvec3& v, const T s); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator& (const T s, const detail::_xvec3& v); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator& (const detail::_xvec3& v1, const detail::_xvec3& v2); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator| (const detail::_xvec3& v, const T s); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator| (const T s, const detail::_xvec3& v); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator| (const detail::_xvec3& v1, const detail::_xvec3& v2); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator^ (const detail::_xvec3& v, const T s); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator^ (const T s, const detail::_xvec3& v); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator^ (const detail::_xvec3& v1, const detail::_xvec3& v2); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator<< (const detail::_xvec3& v, const T s); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator<< (const T s, const detail::_xvec3& v); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator<< (const detail::_xvec3& v1, const detail::_xvec3& v2); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator>> (const detail::_xvec3& v, const T s); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator>> (const T s, const detail::_xvec3& v); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec3 operator>> (const detail::_xvec3& v1, const detail::_xvec3& v2); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template const detail::_xvec3 operator~ (const detail::_xvec3& v); //!< \brief bitwise negation operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + + // vec4 bit operators + template detail::_xvec4& operator%=(detail::_xvec4& r, const T s); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator%=(detail::_xvec4& r, const detail::_xvec4& v); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator&=(detail::_xvec4& r, const T s); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator&=(detail::_xvec4& r, const detail::_xvec4& v); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator|=(detail::_xvec4& r, const T s); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator|=(detail::_xvec4& r, const detail::_xvec4& v); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator^=(detail::_xvec4& r, const T s); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator^=(detail::_xvec4& r, const detail::_xvec4& v); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator<<=(detail::_xvec4& r, const T s); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator<<=(detail::_xvec4& r, const detail::_xvec4& v); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator>>=(detail::_xvec4& r, const T s); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4& operator>>=(detail::_xvec4& r, const detail::_xvec4& v); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + + template detail::_xvec4 operator% (const detail::_xvec4& v, const T s); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator% (const T s, const detail::_xvec4& v); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator% (const detail::_xvec4& v1, const detail::_xvec4& v2); //!< \brief Modulus operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator& (const detail::_xvec4& v, const T s); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator& (const T s, const detail::_xvec4& v); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator& (const detail::_xvec4& v1, const detail::_xvec4& v2); //!< \brief bitwise AND operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator| (const detail::_xvec4& v, const T s); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator| (const T s, const detail::_xvec4& v); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator| (const detail::_xvec4& v1, const detail::_xvec4& v2); //!< \brief bitwise inclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator^ (const detail::_xvec4& v, const T s); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator^ (const T s, const detail::_xvec4& v); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator^ (const detail::_xvec4& v1, const detail::_xvec4& v2); //!< \brief bitwise exclusive OR operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator<< (const detail::_xvec4& v, const T s); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator<< (const T s, const detail::_xvec4& v); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator<< (const detail::_xvec4& v1, const detail::_xvec4& v2); //!< \brief bitwise left shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator>> (const detail::_xvec4& v, const T s); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator>> (const T s, const detail::_xvec4& v); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template detail::_xvec4 operator>> (const detail::_xvec4& v1, const detail::_xvec4& v2); //!< \brief bitwise right shift operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + template const detail::_xvec4 operator~ (const detail::_xvec4& v); //!< \brief bitwise negation operator for integer vectors. (From GLM_GTX_gpu_shader4 extension) + } + } +} + +#define GLM_GTX_gpu_shader4 namespace gtx::gpu_shader4 + +#include "gpu_shader4.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_gpu_shader4;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_gpu_shader4__ diff --git a/wip/sse/glm/ext/gtx/gpu_shader4.inl b/wip/sse/glm/ext/gtx/gpu_shader4.inl new file mode 100644 index 00000000..e3ffea03 --- /dev/null +++ b/wip/sse/glm/ext/gtx/gpu_shader4.inl @@ -0,0 +1,949 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-11-13 +// Updated : 2007-08-20 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/gpu_shader4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + inline __halfGTX truncateGTX(__halfGTX x) + { + return __halfGTX(float(int(x + __halfGTX(0.5)))); + } + + inline float truncateGTX(float x) + { + return float(int(x + float(0.5))); + } + + inline double truncateGTX(double x) + { + return double(int(x + double(0.5))); + } + + template + inline detail::_xvec2 truncateGTX(const detail::_xvec2& x) + { + detail::_xvec2 result; + result[1] = T(int(x[1] + T(0.5))); + result[2] = T(int(x[2] + T(0.5))); + return result; + } + + template + inline detail::_xvec3 truncateGTX(const detail::_xvec3& x) + { + detail::_xvec3 result; + result[0] = T(int(x[0] + T(0.5))); + result[1] = T(int(x[1] + T(0.5))); + result[2] = T(int(x[2] + T(0.5))); + return result; + } + + template + inline detail::_xvec4 truncateGTX(const detail::_xvec4& x) + { + detail::_xvec4 result; + result[0] = T(int(x[0] + T(0.5))); + result[1] = T(int(x[1] + T(0.5))); + result[2] = T(int(x[2] + T(0.5))); + result[3] = T(int(x[3] + T(0.5))); + return result; + } + + namespace gtx + { + namespace gpu_shader4 + { + // vec2 bit operators + template + inline detail::_xvec2& operator%=(detail::_xvec2& r, const T s) + { + r.x %= s; + r.y %= s; + return r; + } + + template + inline detail::_xvec2& operator%=(detail::_xvec2& r, const detail::_xvec2& v) + { + r.x %= v.x; + r.y %= v.y; + return r; + } + + template + inline detail::_xvec2& operator&=(detail::_xvec2& r, const T s) + { + r.x &= s; + r.y &= s; + return r; + } + + template + inline detail::_xvec2& operator&=(detail::_xvec2& r, const detail::_xvec2& v) + { + r.x &= v.x; + r.y &= v.y; + return r; + } + + template + inline detail::_xvec2& operator|=(detail::_xvec2& r, const T s) + { + r.x |= s; + r.y |= s; + return r; + } + + template + inline detail::_xvec2& operator|=(detail::_xvec2& r, const detail::_xvec2& v) + { + r.x |= v.x; + r.y |= v.y; + return r; + } + + template + inline detail::_xvec2& operator^=(detail::_xvec2& r, const T s) + { + r.x ^= s; + r.y ^= s; + return r; + } + + template + inline detail::_xvec2& operator^=(detail::_xvec2& r, const detail::_xvec2& v) + { + r.x ^= v.x; + r.y ^= v.y; + return r; + } + + template + inline detail::_xvec2& operator<<=(detail::_xvec2& r, const T s) + { + r.x <<= s; + r.y <<= s; + return r; + } + + template + inline detail::_xvec2& operator<<=(detail::_xvec2& r, const detail::_xvec2& v) + { + r.x <<= v.x; + r.y <<= v.y; + return r; + } + + template + inline detail::_xvec2& operator>>=(detail::_xvec2& r, const T s) + { + r.x >>= s; + r.y >>= s; + return r; + } + + template + inline detail::_xvec2& operator>>=(detail::_xvec2& r, const detail::_xvec2& v) + { + r.x >>= v.x; + r.y >>= v.y; + return r; + } + + template + inline detail::_xvec2 operator% (const detail::_xvec2& v, const T s) + { + return detail::_xvec2( + v.x % s, + v.y % s); + } + + template + inline detail::_xvec2 operator% (const T s, const detail::_xvec2& v) + { + return detail::_xvec2( + s % v.x, + s % v.y); + } + + template + inline detail::_xvec2 operator% (const detail::_xvec2& v1, const detail::_xvec2& v2) + { + return detail::_xvec2( + v1.x % v2.x, + v1.y % v2.y); + } + + template + inline detail::_xvec2 operator& (const detail::_xvec2& v, const T s) + { + return detail::_xvec2( + v.x & s, + v.y & s); + } + + template + inline detail::_xvec2 operator& (const T s, const detail::_xvec2& v) + { + return detail::_xvec2( + s & v.x, + s & v.y); + } + + template + inline detail::_xvec2 operator& (const detail::_xvec2& v1, const detail::_xvec2& v2) + { + return detail::_xvec2( + v1.x & v2.x, + v1.y & v2.y); + } + + template + inline detail::_xvec2 operator| (const detail::_xvec2& v, const T s) + { + return detail::_xvec2( + v.x | s, + v.y | s); + } + + template + inline detail::_xvec2 operator| (const T s, const detail::_xvec2& v) + { + return detail::_xvec2( + s | v.x, + s | v.y); + } + + template + inline detail::_xvec2 operator| (const detail::_xvec2& v1, const detail::_xvec2& v2) + { + return detail::_xvec2( + v1.x | v2.x, + v1.y | v2.y); + } + + template + inline detail::_xvec2 operator^ (const detail::_xvec2& v, const T s) + { + return detail::_xvec2( + v.x ^ s, + v.y ^ s); + } + + template + inline detail::_xvec2 operator^ (const T s, const detail::_xvec2& v) + { + return detail::_xvec2( + s ^ v.x, + s ^ v.y); + } + + template + inline detail::_xvec2 operator^ (const detail::_xvec2& v1, const detail::_xvec2& v2) + { + return detail::_xvec2( + v1.x ^ v2.x, + v1.y ^ v2.y); + } + + template + inline detail::_xvec2 operator<< (const detail::_xvec2& v, const T s) + { + return detail::_xvec2( + v.x << s, + v.y << s); + } + + template + inline detail::_xvec2 operator<< (const T s, const detail::_xvec2& v) + { + return detail::_xvec2( + s << v.x, + s << v.y); + } + + template + inline detail::_xvec2 operator<< (const detail::_xvec2& v1, const detail::_xvec2& v2) + { + return detail::_xvec2( + v1.x << v2.x, + v1.y << v2.y); + } + + template + inline detail::_xvec2 operator>> (const detail::_xvec2& v, const T s) + { + return detail::_xvec2( + v.x >> s, + v.y >> s); + } + + template + inline detail::_xvec2 operator>> (const T s, const detail::_xvec2& v) + { + return detail::_xvec2( + s >> v.x, + s >> v.y); + } + + template + inline detail::_xvec2 operator>> (const detail::_xvec2& v1, const detail::_xvec2& v2) + { + return detail::_xvec2( + v1.x >> v2.x, + v1.y >> v2.y); + } + + template + inline const detail::_xvec2 operator~ (const detail::_xvec2& v) + { + return detail::_xvec2( + ~v.x, + ~v.y); + } + + // vec3 bit operators + template + inline detail::_xvec3& operator%=(detail::_xvec3& r, const T s) + { + r.x &= s; + r.y &= s; + r.z &= s; + return r; + } + + template + inline detail::_xvec3& operator%=(detail::_xvec3& r, const detail::_xvec3& v) + { + r.x &= v.x; + r.y &= v.y; + r.z &= v.z; + return r; + } + + template + inline detail::_xvec3& operator&=(detail::_xvec3& r, const T s) + { + r.x &= s; + r.y &= s; + r.z &= s; + return r; + } + + template + inline detail::_xvec3& operator&=(detail::_xvec3& r, const detail::_xvec3& v) + { + r.x &= v.x; + r.y &= v.y; + r.z &= v.z; + return r; + } + + template + inline detail::_xvec3& operator|=(detail::_xvec3& r, const T s) + { + r.x |= s; + r.y |= s; + r.z |= s; + return r; + } + + template + inline detail::_xvec3& operator|=(detail::_xvec3& r, const detail::_xvec3& v) + { + r.x |= v.x; + r.y |= v.y; + r.z |= v.z; + return r; + } + + template + inline detail::_xvec3& operator^=(detail::_xvec3& r, const T s) + { + r.x ^= s; + r.y ^= s; + r.z ^= s; + return r; + } + + template + inline detail::_xvec3& operator^=(detail::_xvec3& r, const detail::_xvec3& v) + { + r.x ^= v.x; + r.y ^= v.y; + r.z ^= v.z; + return r; + } + + template + inline detail::_xvec3& operator<<=(detail::_xvec3& r, const T s) + { + r.x <<= s; + r.y <<= s; + r.z <<= s; + return r; + } + + template + inline detail::_xvec3& operator<<=(detail::_xvec3& r, const detail::_xvec3& v) + { + r.x <<= v.x; + r.y <<= v.y; + r.z <<= v.z; + return r; + } + + template + inline detail::_xvec3& operator>>=(detail::_xvec3& r, const T s) + { + r.x >>= s; + r.y >>= s; + r.z >>= s; + return r; + } + + template + inline detail::_xvec3& operator>>=(detail::_xvec3& r, const detail::_xvec3& v) + { + r.x >>= v.x; + r.y >>= v.y; + r.z >>= v.z; + return r; + } + + template + inline detail::_xvec3 operator% (const detail::_xvec3& v, const T s) + { + return detail::_xvec3( + v.x % s, + v.y % s, + v.z % s); + } + + template + inline detail::_xvec3 operator% (const T s, const detail::_xvec3& v) + { + return detail::_xvec3( + s % v.x, + s % v.y, + s % v.z); + } + + template + inline detail::_xvec3 operator% (const detail::_xvec3& v1, const detail::_xvec3& v2) + { + return detail::_xvec3( + v1.x % v2.x, + v1.y % v2.y, + v1.z % v2.z); + } + + template + inline detail::_xvec3 operator& (const detail::_xvec3& v, const T s) + { + return detail::_xvec3( + v.x & s, + v.y & s, + v.z & s); + } + + template + inline detail::_xvec3 operator& (const T s, const detail::_xvec3& v) + { + return detail::_xvec3( + s & v.x, + s & v.y, + s & v.z); + } + + template + inline detail::_xvec3 operator& (const detail::_xvec3& v1, const detail::_xvec3& v2) + { + return detail::_xvec2( + v1.x & v2.x, + v1.y & v2.y, + v1.z & v2.z); + } + + template + inline detail::_xvec3 operator| (const detail::_xvec3& v, const T s) + { + return detail::_xvec3( + v.x | s, + v.y | s, + v.z | s); + } + + template + inline detail::_xvec3 operator| (const T s, const detail::_xvec3& v) + { + return detail::_xvec3( + s | v.x, + s | v.y, + s | v.z); + } + + template + inline detail::_xvec3 operator| (const detail::_xvec3& v1, const detail::_xvec3& v2) + { + return detail::_xvec3( + v1.x | v2.x, + v1.y | v2.y, + v1.z | v2.z); + } + + template + inline detail::_xvec3 operator^ (const detail::_xvec3& v, const T s) + { + return detail::_xvec3( + v.x ^ s, + v.y ^ s, + v.z ^ s); + } + + template + inline detail::_xvec3 operator^ (const T s, const detail::_xvec3& v) + { + return detail::_xvec3( + s ^ v.x, + s ^ v.y, + s ^ v.z); + } + + template + inline detail::_xvec3 operator^ (const detail::_xvec3& v1, const detail::_xvec3& v2) + { + return detail::_xvec3( + v1.x ^ v2.x, + v1.y ^ v2.y, + v1.z ^ v2.z); + } + + template + inline detail::_xvec3 operator<< (const detail::_xvec3& v, const T s) + { + return detail::_xvec3( + v.x << s, + v.y << s, + v.z << s); + } + + template + inline detail::_xvec3 operator<< (const T s, const detail::_xvec3& v) + { + return detail::_xvec3( + s << v.x, + s << v.y, + s << v.z); + } + + template + inline detail::_xvec3 operator<< (const detail::_xvec3& v1, const detail::_xvec3& v2) + { + return detail::_xvec3( + v1.x << v2.x, + v1.y << v2.y, + v1.z << v2.z); + } + + template + inline detail::_xvec3 operator>> (const detail::_xvec3& v, const T s) + { + return detail::_xvec3( + v.x >> s, + v.y >> s, + v.z >> s); + } + + template + inline detail::_xvec3 operator>> (const T s, const detail::_xvec3& v) + { + return detail::_xvec3( + s >> v.x, + s >> v.y, + s >> v.z); + } + + template + inline detail::_xvec3 operator>> (const detail::_xvec3& v1, const detail::_xvec3& v2) + { + return detail::_xvec3( + v1.x >> v2.x, + v1.y >> v2.y, + v1.z >> v2.z); + } + + template + inline const detail::_xvec3 operator~ (const detail::_xvec3& v) + { + return detail::_xvec3( + ~v.x, + ~v.y, + ~v.z); + } + + // vec4 bit operators + template + inline detail::_xvec4& operator%=(detail::_xvec4& r, const T s) + { + r.x %= s; + r.y %= s; + r.z %= s; + r.w %= s; + return r; + } + + template + inline detail::_xvec4& operator%=(detail::_xvec4& r, const detail::_xvec4& v) + { + r.x %= v.x; + r.y %= v.y; + r.z %= v.z; + r.w %= v.w; + return r; + } + + template + inline detail::_xvec4& operator&=(detail::_xvec4& r, const T s) + { + r.x &= s; + r.y &= s; + r.z &= s; + r.w &= s; + return r; + } + + template + inline detail::_xvec4& operator&=(detail::_xvec4& r, const detail::_xvec4& v) + { + r.x &= v.x; + r.y &= v.y; + r.z &= v.z; + r.w &= v.w; + return r; + } + + template + inline detail::_xvec4& operator|=(detail::_xvec4& r, const T s) + { + r.x |= s; + r.y |= s; + r.z |= s; + r.w |= s; + return r; + } + + template + inline detail::_xvec4& operator|=(detail::_xvec4& r, const detail::_xvec4& v) + { + r.x |= v.x; + r.y |= v.y; + r.z |= v.z; + r.w |= v.w; + return r; + } + + template + inline detail::_xvec4& operator^=(detail::_xvec4& r, const T s) + { + r.x ^= s; + r.y ^= s; + r.z ^= s; + r.w ^= s; + return r; + } + + template + inline detail::_xvec4& operator^=(detail::_xvec4& r, const detail::_xvec4& v) + { + r.x ^= v.x; + r.y ^= v.y; + r.z ^= v.z; + r.w ^= v.w; + return r; + } + + template + inline detail::_xvec4& operator<<=(detail::_xvec4& r, const T s) + { + r.x <<= s; + r.y <<= s; + r.z <<= s; + r.w <<= s; + return r; + } + + template + inline detail::_xvec4& operator<<=(detail::_xvec4& r, const detail::_xvec4& v) + { + r.x <<= v.x; + r.y <<= v.y; + r.z <<= v.z; + r.w <<= v.w; + return r; + } + + template + inline detail::_xvec4& operator>>=(detail::_xvec4& r, const T s) + { + r.x >>= s; + r.y >>= s; + r.z >>= s; + r.w >>= s; + return r; + } + + template + inline detail::_xvec4& operator>>=(detail::_xvec4& r, const detail::_xvec4& v) + { + r.x >>= v.x; + r.y >>= v.y; + r.z >>= v.z; + r.w >>= v.w; + return r; + } + + template + inline detail::_xvec4 operator% (const detail::_xvec4& v, const T s) + { + return detail::_xvec4( + v.x % s, + v.y % s, + v.z % s, + v.w % s); + } + + template + inline detail::_xvec4 operator% (const T s, const detail::_xvec4& v) + { + return detail::_xvec4( + s % v.x, + s % v.y, + s % v.z, + s % v.w); + } + + template + inline detail::_xvec4 operator% (const detail::_xvec4& v1, const detail::_xvec4& v2) + { + return detail::_xvec4( + v1.x % v2.x, + v1.y % v2.y, + v1.z % v2.z, + v1.w % v2.w); + } + + template + inline detail::_xvec4 operator& (const detail::_xvec4& v, const T s) + { + return detail::_xvec4( + v.x & s, + v.y & s, + v.z & s, + v.w & s); + } + + template + inline detail::_xvec4 operator& (const T s, const detail::_xvec4& v) + { + return detail::_xvec4( + s & v.x, + s & v.y, + s & v.z, + s & v.w); + } + + template + inline detail::_xvec4 operator& (const detail::_xvec4& v1, const detail::_xvec4& v2) + { + return detail::_xvec4( + v1.x & v2.x, + v1.y & v2.y, + v1.z & v2.z, + v1.w & v2.w); + } + + template + inline detail::_xvec4 operator| (const detail::_xvec4& v, const T s) + { + return detail::_xvec4( + v.x | s, + v.y | s, + v.z | s, + v.w | s); + } + + template + inline detail::_xvec4 operator| (const T s, const detail::_xvec4& v) + { + return detail::_xvec4( + s | v.x, + s | v.y, + s | v.z, + s | v.w); + } + + template + inline detail::_xvec4 operator| (const detail::_xvec4& v1, const detail::_xvec4& v2) + { + return detail::_xvec4( + v1.x | v2.x, + v1.y | v2.y, + v1.z | v2.z, + v1.w | v2.w); + } + + template + inline detail::_xvec4 operator^ (const detail::_xvec4& v, const T s) + { + return detail::_xvec4( + v.x ^ s, + v.y ^ s, + v.z ^ s, + v.w ^ s); + } + + template + inline detail::_xvec4 operator^ (const T s, const detail::_xvec4& v) + { + return detail::_xvec4( + s ^ v.x, + s ^ v.y, + s ^ v.z, + s ^ v.w); + } + + template + inline detail::_xvec4 operator^ (const detail::_xvec4& v1, const detail::_xvec4& v2) + { + return detail::_xvec4( + v1.x ^ v2.x, + v1.y ^ v2.y, + v1.z ^ v2.z, + v1.w ^ v2.w); + } + + template + inline detail::_xvec4 operator<< (const detail::_xvec4& v, const T s) + { + return detail::_xvec4( + v.x << s, + v.y << s, + v.z << s, + v.w << s); + } + + template + inline detail::_xvec4 operator<< (const T s, const detail::_xvec4& v) + { + return detail::_xvec4( + s << v.x, + s << v.y, + s << v.z, + s << v.w); + } + + template + inline detail::_xvec4 operator<< (const detail::_xvec4& v1, const detail::_xvec4& v2) + { + return detail::_xvec4( + v1.x << v2.x, + v1.y << v2.y, + v1.z << v2.z, + v1.w << v2.w); + } + + template + inline detail::_xvec4 operator>> (const detail::_xvec4& v, const T s) + { + return detail::_xvec4( + v.x >> s, + v.y >> s, + v.z >> s, + v.w >> s); + } + + template + inline detail::_xvec4 operator>> (const T s, const detail::_xvec4& v) + { + return detail::_xvec4( + s >> v.x, + s >> v.y, + s >> v.z, + s >> v.w); + } + + template + inline detail::_xvec4 operator>> (const detail::_xvec4& v1, const detail::_xvec4& v2) + { + return detail::_xvec4( + v1.x >> v2.x, + v1.y >> v2.y, + v1.z >> v2.z, + v1.w >> v2.w); + } + + template + inline const detail::_xvec4 operator~ (const detail::_xvec4& v) + { + return detail::_xvec4( + ~v.x, + ~v.y, + ~v.z, + ~v.w); + } + } + } + +/* + inline half truncate(half x) + { + return half(float(int(x + half(0.5)))); + } + + inline float truncate(float x) + { + return float(int(x + float(0.5))); + } + + inline double truncate(double x) + { + return double(int(x + double(0.5))); + } + + template + inline detail::_xvec2 truncate(const detail::_xvec2& x) + { + detail::_xvec2 result; + result[1] = T(int(x[1] + T(0.5))); + result[2] = T(int(x[2] + T(0.5))); + return result; + } + + template + inline detail::_xvec3 truncate(const detail::_xvec3& x) + { + detail::_xvec3 result; + result[0] = T(int(x[0] + T(0.5))); + result[1] = T(int(x[1] + T(0.5))); + result[2] = T(int(x[2] + T(0.5))); + return result; + } + + template + inline detail::_xvec4 truncate(const detail::_xvec4& x) + { + detail::_xvec4 result; + result[0] = T(int(x[0] + T(0.5))); + result[1] = T(int(x[1] + T(0.5))); + result[2] = T(int(x[2] + T(0.5))); + result[3] = T(int(x[3] + T(0.5))); + return result; + } +*/ +} diff --git a/wip/sse/glm/ext/gtx/half.h b/wip/sse/glm/ext/gtx/half.h new file mode 100644 index 00000000..c63ced4f --- /dev/null +++ b/wip/sse/glm/ext/gtx/half.h @@ -0,0 +1,405 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/half.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_quaternion +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Copyright: +// This half implementation is based on OpenEXR witch is Copyright (c) 2002, +// Industrial Light & Magic, a division of Lucas Digital Ltd. LLC +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_half__ +#define __glm_gtx_half__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/quaternion.h" + +namespace glm +{ + namespace detail + { + struct hdata + { + hdata() : data(0) {} + hdata(const hdata& value); + hdata(float value); + + operator float(); + + short data; + }; + + float _toFloat32(hdata value); + hdata _toFloat16(float value); + + union uif + { + int i; + float f; + }; + + //! \brief Type for half-precision floating-point numbers. (From GLM_GTX_half extension) + class _halfGTX + { + public: + // Constructors + _halfGTX(); + _halfGTX(float s); + _halfGTX(double s); + _halfGTX(int s); + _halfGTX(bool s); + _halfGTX(detail::hdata value) : + data(value) + {} + + operator float() const; + operator double() const; + operator int() const; + operator detail::hdata() const; + + // Operators + _halfGTX& operator=(_halfGTX s); + _halfGTX& operator=(float s); + _halfGTX operator+ (_halfGTX s) const; + _halfGTX& operator+= (_halfGTX s); + _halfGTX operator+ (float s) const; + _halfGTX& operator+= (float s); + _halfGTX operator- (_halfGTX s) const; + _halfGTX& operator-= (_halfGTX s); + _halfGTX operator- (float s) const; + _halfGTX& operator-= (float s); + _halfGTX operator* (_halfGTX s) const; + _halfGTX& operator*= (_halfGTX s); + _halfGTX operator* (float s) const; + _halfGTX& operator*= (float s); + _halfGTX operator/ (_halfGTX s) const; + _halfGTX& operator/= (_halfGTX s); + _halfGTX operator/ (float s) const; + _halfGTX& operator/= (float s); + _halfGTX operator- () const; + _halfGTX operator++ (); + _halfGTX operator++ (int n) const; + _halfGTX operator-- (); + _halfGTX operator-- (int n) const; + + bool operator< (const _halfGTX& s) const; + bool operator> (const _halfGTX& s) const; + bool operator<=(const _halfGTX& s) const; + bool operator>=(const _halfGTX& s) const; + bool operator==(const _halfGTX& s) const; + bool operator!=(const _halfGTX& s) const; + + detail::hdata _data() const{return data;} + + private: + detail::hdata data; + }; + + class _hvec3GTX; + class _hvec4GTX; + + class _hvec2GTX : public _cvec2 > + { + public: + // Common constructors + _hvec2GTX(); + _hvec2GTX(const _hvec2GTX& v); + + // Swizzle constructors + _hvec2GTX(const _xref2& r); + + // T constructors + explicit _hvec2GTX(const _halfGTX x); + explicit _hvec2GTX(const _halfGTX a, const _halfGTX b); + explicit _hvec2GTX(const _halfGTX a, const _hvec2GTX& b); + explicit _hvec2GTX(const _halfGTX a, const _hvec3GTX& b); + explicit _hvec2GTX(const _halfGTX a, const _hvec4GTX& b); + explicit _hvec2GTX(const _hvec3GTX& a); + explicit _hvec2GTX(const _hvec4GTX& a); + + // U constructors + template explicit _hvec2GTX(const U x); + template explicit _hvec2GTX(const U a, const U b); + template explicit _hvec2GTX(const U a, const _xvec2& b); + template explicit _hvec2GTX(const U a, const _xvec3& b); + template explicit _hvec2GTX(const U a, const _xvec4& b); + template explicit _hvec2GTX(const _xvec2& a); + template explicit _hvec2GTX(const _xvec3& a); + template explicit _hvec2GTX(const _xvec4& a); + + // Bool constructors + explicit _hvec2GTX(const bool x); + explicit _hvec2GTX(const bool a, const bool b); + explicit _hvec2GTX(const bool a, const _bvec2& b); + explicit _hvec2GTX(const bool a, const _bvec3& b); + explicit _hvec2GTX(const bool a, const _bvec4& b); + explicit _hvec2GTX(const _bvec2& a); + explicit _hvec2GTX(const _bvec3& a); + explicit _hvec2GTX(const _bvec4& a); + + // Unary updatable operators + _hvec2GTX& operator= (const _hvec2GTX& v); + _hvec2GTX& operator+=(const _halfGTX s); + _hvec2GTX& operator+=(const _hvec2GTX& v); + _hvec2GTX& operator-=(const _halfGTX s); + _hvec2GTX& operator-=(const _hvec2GTX& v); + _hvec2GTX& operator*=(const _halfGTX s); + _hvec2GTX& operator*=(const _hvec2GTX& v); + _hvec2GTX& operator/=(const _halfGTX s); + _hvec2GTX& operator/=(const _hvec2GTX& v); + _hvec2GTX& operator++(); + _hvec2GTX& operator--(); + }; + + class _hvec3GTX : public _cvec3, _xref3 > + { + public: + // Common constructors + _hvec3GTX(); + _hvec3GTX(const _hvec3GTX& v); + + // Swizzle constructors + _hvec3GTX(const _xref3& r); + + // T constructors + explicit _hvec3GTX(const _halfGTX a); + explicit _hvec3GTX(const _halfGTX a, const _halfGTX b, const _halfGTX c); + explicit _hvec3GTX(const _halfGTX a, const _halfGTX b, const _hvec2GTX& c); + explicit _hvec3GTX(const _halfGTX a, const _halfGTX b, const _hvec3GTX& c); + explicit _hvec3GTX(const _halfGTX a, const _halfGTX b, const _hvec4GTX& c); + explicit _hvec3GTX(const _halfGTX a, const _hvec2GTX& b); + explicit _hvec3GTX(const _halfGTX a, const _hvec3GTX& b); + explicit _hvec3GTX(const _halfGTX a, const _hvec4GTX& b); + explicit _hvec3GTX(const _hvec2GTX& a, _halfGTX b); + explicit _hvec3GTX(const _hvec2GTX& a, const _hvec2GTX& b); + explicit _hvec3GTX(const _hvec2GTX& a, const _hvec3GTX& b); + explicit _hvec3GTX(const _hvec2GTX& a, const _hvec4GTX& b); + explicit _hvec3GTX(const _hvec4GTX& a); + + // U constructors + template explicit _hvec3GTX(const U x); + template explicit _hvec3GTX(const U a, const U b, const U c); + template explicit _hvec3GTX(const U a, const U b, const _xvec2& c); + template explicit _hvec3GTX(const U a, const U b, const _xvec3& c); + template explicit _hvec3GTX(const U a, const U b, const _xvec4& c); + template explicit _hvec3GTX(const U a, const _xvec2& b); + template explicit _hvec3GTX(const U a, const _xvec3& b); + template explicit _hvec3GTX(const U a, const _xvec4& b); + template explicit _hvec3GTX(const _xvec2& a, U b); + template explicit _hvec3GTX(const _xvec2& a, const _xvec2& b); + template explicit _hvec3GTX(const _xvec2& a, const _xvec3& b); + template explicit _hvec3GTX(const _xvec2& a, const _xvec4& b); + template explicit _hvec3GTX(const _xvec3& a); + template explicit _hvec3GTX(const _xvec4& a); + + // Bool constructors + explicit _hvec3GTX(const bool a); + explicit _hvec3GTX(const bool a, const bool b, const bool c); + explicit _hvec3GTX(const bool a, const bool b, const _bvec2& c); + explicit _hvec3GTX(const bool a, const bool b, const _bvec3& c); + explicit _hvec3GTX(const bool a, const bool b, const _bvec4& c); + explicit _hvec3GTX(const bool a, const _bvec2& b); + explicit _hvec3GTX(const bool a, const _bvec3& b); + explicit _hvec3GTX(const bool a, const _bvec4& b); + explicit _hvec3GTX(const _bvec2& a, bool b); + explicit _hvec3GTX(const _bvec2& a, const _bvec2& b); + explicit _hvec3GTX(const _bvec2& a, const _bvec3& b); + explicit _hvec3GTX(const _bvec2& a, const _bvec4& b); + explicit _hvec3GTX(const _bvec3& a); + explicit _hvec3GTX(const _bvec4& a); + + // Unary updatable operators + _hvec3GTX& operator= (const _hvec3GTX& v); + _hvec3GTX& operator+=(const _halfGTX s); + _hvec3GTX& operator+=(const _hvec3GTX& v); + _hvec3GTX& operator-=(const _halfGTX s); + _hvec3GTX& operator-=(const _hvec3GTX& v); + _hvec3GTX& operator*=(const _halfGTX s); + _hvec3GTX& operator*=(const _hvec3GTX& v); + _hvec3GTX& operator/=(const _halfGTX s); + _hvec3GTX& operator/=(const _hvec3GTX& v); + _hvec3GTX& operator++(); + _hvec3GTX& operator--(); + }; + + class _hvec4GTX : public _cvec4, _xref3, _xref4 > + { + public: + // Common constructors + _hvec4GTX(); + _hvec4GTX(const _hvec4GTX& v); + + // Swizzle constructors + _hvec4GTX(const _xref4& r); + + // T constructors + explicit _hvec4GTX(const _halfGTX a); + explicit _hvec4GTX(const _halfGTX a, const _halfGTX b, const _halfGTX c, const _halfGTX d); + explicit _hvec4GTX(const _halfGTX a, const _halfGTX b, const _halfGTX c, const _hvec2GTX& d); + explicit _hvec4GTX(const _halfGTX a, const _halfGTX b, const _halfGTX c, const _hvec3GTX& d); + explicit _hvec4GTX(const _halfGTX a, const _halfGTX b, const _halfGTX c, const _hvec4GTX& d); + explicit _hvec4GTX(const _halfGTX a, const _halfGTX b, const _hvec2GTX& c); + explicit _hvec4GTX(const _halfGTX a, const _halfGTX b, const _hvec3GTX& c); + explicit _hvec4GTX(const _halfGTX a, const _halfGTX b, const _hvec4GTX& c); + explicit _hvec4GTX(const _halfGTX a, const _hvec2GTX& b, const _halfGTX c); + explicit _hvec4GTX(const _halfGTX a, const _hvec2GTX& b, const _hvec2GTX& c); + explicit _hvec4GTX(const _halfGTX a, const _hvec2GTX& b, const _hvec3GTX& c); + explicit _hvec4GTX(const _halfGTX a, const _hvec2GTX& b, const _hvec4GTX& c); + explicit _hvec4GTX(const _halfGTX a, const _hvec3GTX& b); + explicit _hvec4GTX(const _halfGTX a, const _hvec4GTX& b); + explicit _hvec4GTX(const _hvec2GTX& a, const _halfGTX b, const _halfGTX c); + explicit _hvec4GTX(const _hvec2GTX& a, const _halfGTX b, const _hvec2GTX& c); + explicit _hvec4GTX(const _hvec2GTX& a, const _halfGTX b, const _hvec3GTX& c); + explicit _hvec4GTX(const _hvec2GTX& a, const _halfGTX b, const _hvec4GTX& c); + explicit _hvec4GTX(const _hvec2GTX& a, const _hvec2GTX& b); + explicit _hvec4GTX(const _hvec2GTX& a, const _hvec3GTX& b); + explicit _hvec4GTX(const _hvec2GTX& a, const _hvec4GTX& b); + explicit _hvec4GTX(const _hvec3GTX& a, const _halfGTX b); + explicit _hvec4GTX(const _hvec3GTX& a, const _hvec2GTX& b); + explicit _hvec4GTX(const _hvec3GTX& a, const _hvec3GTX& b); + explicit _hvec4GTX(const _hvec3GTX& a, const _hvec4GTX& b); + + // U constructors + template explicit _hvec4GTX(const U x); + template explicit _hvec4GTX(const U a, const U b, const U c, const U d); + template explicit _hvec4GTX(const U a, const U b, const U c, const _xvec2& d); + template explicit _hvec4GTX(const U a, const U b, const U c, const _xvec3& d); + template explicit _hvec4GTX(const U a, const U b, const U c, const _xvec4& d); + template explicit _hvec4GTX(const U a, const U b, const _xvec2& c); + template explicit _hvec4GTX(const U a, const U b, const _xvec3& c); + template explicit _hvec4GTX(const U a, const U b, const _xvec4& c); + template explicit _hvec4GTX(const U a, const _xvec2& b, const U c); + template explicit _hvec4GTX(const U a, const _xvec2& b, const _xvec2& c); + template explicit _hvec4GTX(const U a, const _xvec2& b, const _xvec3& c); + template explicit _hvec4GTX(const U a, const _xvec2& b, const _xvec4& c); + template explicit _hvec4GTX(const U a, const _xvec3& b); + template explicit _hvec4GTX(const U a, const _xvec4& b); + template explicit _hvec4GTX(const _xvec2& a, const U b, const U c); + template explicit _hvec4GTX(const _xvec2& a, const U b, const _xvec2& c); + template explicit _hvec4GTX(const _xvec2& a, const U b, const _xvec3& c); + template explicit _hvec4GTX(const _xvec2& a, const U b, const _xvec4& c); + template explicit _hvec4GTX(const _xvec2& a, const _xvec2& b); + template explicit _hvec4GTX(const _xvec2& a, const _xvec3& b); + template explicit _hvec4GTX(const _xvec2& a, const _xvec4& b); + template explicit _hvec4GTX(const _xvec3& a, const U b); + template explicit _hvec4GTX(const _xvec3& a, const _xvec2& b); + template explicit _hvec4GTX(const _xvec3& a, const _xvec3& b); + template explicit _hvec4GTX(const _xvec3& a, const _xvec4& b); + template explicit _hvec4GTX(const _xvec4& a); + + // Bool constructors + explicit _hvec4GTX(const bool x); + explicit _hvec4GTX(const bool a, const bool b, const bool c, const bool d); + explicit _hvec4GTX(const bool a, const bool b, const bool c, const _bvec2& d); + explicit _hvec4GTX(const bool a, const bool b, const bool c, const _bvec3& d); + explicit _hvec4GTX(const bool a, const bool b, const bool c, const _bvec4& d); + explicit _hvec4GTX(const bool a, const bool b, const _bvec2& c); + explicit _hvec4GTX(const bool a, const bool b, const _bvec3& c); + explicit _hvec4GTX(const bool a, const bool b, const _bvec4& c); + explicit _hvec4GTX(const bool a, const _bvec2& b, const bool c); + explicit _hvec4GTX(const bool a, const _bvec2& b, const _bvec2& c); + explicit _hvec4GTX(const bool a, const _bvec2& b, const _bvec3& c); + explicit _hvec4GTX(const bool a, const _bvec2& b, const _bvec4& c); + explicit _hvec4GTX(const bool a, const _bvec3& b); + explicit _hvec4GTX(const bool a, const _bvec4& b); + explicit _hvec4GTX(const _bvec2& a, const bool b, const bool c); + explicit _hvec4GTX(const _bvec2& a, const bool b, const _bvec2& c); + explicit _hvec4GTX(const _bvec2& a, const bool b, const _bvec3& c); + explicit _hvec4GTX(const _bvec2& a, const bool b, const _bvec4& c); + explicit _hvec4GTX(const _bvec2& a, const _bvec2& b); + explicit _hvec4GTX(const _bvec2& a, const _bvec3& b); + explicit _hvec4GTX(const _bvec2& a, const _bvec4& b); + explicit _hvec4GTX(const _bvec3& a, const bool b); + explicit _hvec4GTX(const _bvec3& a, const _bvec2& b); + explicit _hvec4GTX(const _bvec3& a, const _bvec3& b); + explicit _hvec4GTX(const _bvec3& a, const _bvec4& b); + explicit _hvec4GTX(const _bvec4& a); + + // Unary updatable operators + _hvec4GTX& operator= (const _hvec4GTX& x); + _hvec4GTX& operator+=(const _halfGTX s); + _hvec4GTX& operator+=(const _hvec4GTX& v); + _hvec4GTX& operator-=(const _halfGTX s); + _hvec4GTX& operator-=(const _hvec4GTX& v); + _hvec4GTX& operator*=(const _halfGTX s); + _hvec4GTX& operator*=(const _hvec4GTX& v); + _hvec4GTX& operator/=(const _halfGTX s); + _hvec4GTX& operator/=(const _hvec4GTX& v); + _hvec4GTX& operator++(); + _hvec4GTX& operator--(); + }; + } + + typedef detail::_halfGTX __halfGTX; //!< \brief Type for half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef detail::_xvec2 __hvec2GTX; //!< \brief Vector of 2 half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef detail::_xvec3 __hvec3GTX; //!< \brief Vector of 3 half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef detail::_xvec4 __hvec4GTX; //!< \brief Vector of 4 half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef detail::_xmat2 __hmat2GTX; //!< \brief 2 * 2 matrix of half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef detail::_xmat3 __hmat3GTX; //!< \brief 3 * 3 matrix of half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef detail::_xmat4 __hmat4GTX; //!< \brief 4 * 4 matrix of half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef detail::_xquat __hquatGTX; //!< \brief Quaternion of half-precision floating-point numbers. (from GLM_GTX_half extension) + + __halfGTX cosGTX(__halfGTX x); + __hvec2GTX cosGTX(const __hvec2GTX& x); + __hvec3GTX cosGTX(const __hvec3GTX& x); + __hvec4GTX cosGTX(const __hvec4GTX& x); + + __halfGTX sinGTX(__halfGTX x); + __hvec2GTX sinGTX(const __hvec2GTX& x); + __hvec3GTX sinGTX(const __hvec3GTX& x); + __hvec4GTX sinGTX(const __hvec4GTX& x); + + __halfGTX tanGTX(__halfGTX x); + __hvec2GTX tanGTX(const __hvec2GTX& x); + __hvec3GTX tanGTX(const __hvec3GTX& x); + __hvec4GTX tanGTX(const __hvec4GTX& x); + + namespace gtx + { + //! GLM_GTX_half extension: Add support for half precision flotting-point types + namespace half + { + typedef __halfGTX half; //!< \brief Type for half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef __hvec2GTX hvec2; //!< \brief Vector of 2 half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef __hvec3GTX hvec3; //!< \brief Vector of 3 half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef __hvec4GTX hvec4; //!< \brief Vector of 4 half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef __hmat2GTX hmat2; //!< \brief 2 * 2 matrix of half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef __hmat3GTX hmat3; //!< \brief 3 * 3 matrix of half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef __hmat4GTX hmat4; //!< \brief 4 * 4 matrix of half-precision floating-point numbers. (From GLM_GTX_half extension) + typedef __hquatGTX hquat; //!< \brief Quaternion of half-precision floating-point numbers. (From GLM_GTX_half extension) + + inline __halfGTX cos(__halfGTX x){return cosGTX(x);} //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + inline __hvec2GTX cos(const __hvec2GTX& x){return cosGTX(x);} //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + inline __hvec3GTX cos(const __hvec3GTX& x){return cosGTX(x);} //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + inline __hvec4GTX cos(const __hvec4GTX& x){return cosGTX(x);} //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + + inline __halfGTX sin(__halfGTX x){return sinGTX(x);} //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + inline __hvec2GTX sin(const __hvec2GTX& x){return sinGTX(x);} //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + inline __hvec3GTX sin(const __hvec3GTX& x){return sinGTX(x);} //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + inline __hvec4GTX sin(const __hvec4GTX& x){return sinGTX(x);} //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_half extension) + + inline __halfGTX tan(__halfGTX x){return tanGTX(x);} //!< \brief The standard trigonometric tangent function. (From GLM_GTX_half extension) + inline __hvec2GTX tan(const __hvec2GTX& x){return tanGTX(x);} //!< \brief The standard trigonometric tangent function. (From GLM_GTX_half extension) + inline __hvec3GTX tan(const __hvec3GTX& x){return tanGTX(x);} //!< \brief The standard trigonometric tangent function. (From GLM_GTX_half extension) + inline __hvec4GTX tan(const __hvec4GTX& x){return tanGTX(x);} //!< \brief The standard trigonometric tangent function. (From GLM_GTX_half extension) + } + } +} + +#define GLM_GTX_half namespace gtx::half + +#include "half.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_half;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_half__ diff --git a/wip/sse/glm/ext/gtx/half.inl b/wip/sse/glm/ext/gtx/half.inl new file mode 100644 index 00000000..d68e4b19 --- /dev/null +++ b/wip/sse/glm/ext/gtx/half.inl @@ -0,0 +1,1248 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/half.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_HALF_OP(A, B, O) _toFloat16(_toFloat32(A) O _toFloat32(B)) +#define GLM_HALF_OP_1(A, B, O) _toFloat16(_toFloat32(A) O float(B)) +#define GLM_HALF_OP_2(A, O, B) _toFloat16(_toFloat32(A) O _toFloat32(B)) + +namespace glm +{ + inline __halfGTX cosGTX(__halfGTX x) + { + return __halfGTX(cos(float(x))); + } + + inline __hvec2GTX cosGTX(const __hvec2GTX& x) + { + return __hvec2GTX( + cos(float(x.x)), + cos(float(x.y))); + } + + inline __hvec3GTX cosGTX(const __hvec3GTX& x) + { + return __hvec3GTX( + cos(float(x.x)), + cos(float(x.y)), + cos(float(x.z))); + } + + inline __hvec4GTX cosGTX(const __hvec4GTX& x) + { + return __hvec4GTX( + cos(float(x.x)), + cos(float(x.y)), + cos(float(x.z)), + cos(float(x.w))); + } + + inline __halfGTX sinGTX(__halfGTX x) + { + return __halfGTX(sin(float(x))); + } + + inline __hvec2GTX sinGTX(const __hvec2GTX& x) + { + return __hvec2GTX( + sin(float(x.x)), + sin(float(x.y))); + } + + inline __hvec3GTX sinGTX(const __hvec3GTX& x) + { + return __hvec3GTX( + sin(float(x.x)), + sin(float(x.y)), + sin(float(x.z))); + } + + inline __hvec4GTX sinGTX(const __hvec4GTX& x) + { + return __hvec4GTX( + sin(float(x.x)), + sin(float(x.y)), + sin(float(x.z)), + sin(float(x.w))); + } + + inline __halfGTX tanGTX(__halfGTX x) + { + return __halfGTX(tan(float(x))); + } + + inline __hvec2GTX tanGTX(const __hvec2GTX& x) + { + return __hvec2GTX( + __halfGTX(tan(float(x.x))), + __halfGTX(tan(float(x.y)))); + } + + inline __hvec3GTX tanGTX(const __hvec3GTX& x) + { + return __hvec3GTX( + __halfGTX(tan(float(x.x))), + __halfGTX(tan(float(x.y))), + __halfGTX(tan(float(x.z)))); + } + + inline __hvec4GTX tanGTX(const __hvec4GTX& x) + { + return __hvec4GTX( + __halfGTX(tan(float(x.x))), + __halfGTX(tan(float(x.y))), + __halfGTX(tan(float(x.z))), + __halfGTX(tan(float(x.w)))); + } + + namespace detail + { + inline hdata::hdata(const hdata& value) : + data(value.data) + {} + + inline hdata::hdata(float value) : + data(_toFloat16(value).data) + {} + + inline hdata::operator float () + { + return _toFloat32(data); + } + + inline float _overflow() + { + volatile float f = 1e10; + + for(int i = 0; i < 10; ++i) + f *= f; // this will overflow before + // the for­loop terminates + return f; + } + + inline float _toFloat32(hdata HData) + { + short value = HData.data; + + int s = (value >> 15) & 0x00000001; + int e = (value >> 10) & 0x0000001f; + int m = value & 0x000003ff; + + if(e == 0) + { + if(m == 0) + { + // + // Plus or minus zero + // + + uif result; + result.i = s << 31; + return result.f; + } + else + { + // + // Denormalized number -- renormalize it + // + + while(!(m & 0x00000400)) + { + m <<= 1; + e -= 1; + } + + e += 1; + m &= ~0x00000400; + } + } + else if(e == 31) + { + if(m == 0) + { + // + // Positive or negative infinity + // + + uif result; + result.i = (s << 31) | 0x7f800000; + return result.f; + } + else + { + // + // Nan -- preserve sign and significand bits + // + + uif result; + result.i = (s << 31) | 0x7f800000 | (m << 13); + return result.f; + } + } + + // + // Normalized number + // + + e = e + (127 - 15); + m = m << 13; + + // + // Assemble s, e and m. + // + + uif Result; + Result.i = (s << 31) | (e << 23) | m; + return Result.f; + } + + inline hdata _toFloat16(float f) + { + uif Entry; + Entry.f = f; + int i = Entry.i; + + // + // Our floating point number, f, is represented by the bit + // pattern in integer i. Disassemble that bit pattern into + // the sign, s, the exponent, e, and the significand, m. + // Shift s into the position where it will go in in the + // resulting _halfGTX number. + // Adjust e, accounting for the different exponent bias + // of float and _halfGTX (127 versus 15). + // + + register int s = (i >> 16) & 0x00008000; + register int e = ((i >> 23) & 0x000000ff) - (127 - 15); + register int m = i & 0x007fffff; + + // + // Now reassemble s, e and m into a _halfGTX: + // + + if(e <= 0) + { + if(e < -10) + { + // + // E is less than -10. The absolute value of f is + // less than __halfGTX_MIN (f may be a small normalized + // float, a denormalized float or a zero). + // + // We convert f to a _halfGTX zero. + // + + return 0; + } + + // + // E is between -10 and 0. F is a normalized float, + // whose magnitude is less than __halfGTX_NRM_MIN. + // + // We convert f to a denormalized _halfGTX. + // + + m = (m | 0x00800000) >> (1 - e); + + // + // Round to nearest, round "0.5" up. + // + // Rounding may cause the significand to overflow and make + // our number normalized. Because of the way a _halfGTX's bits + // are laid out, we don't have to treat this case separately; + // the code below will handle it correctly. + // + + if(m & 0x00001000) m += 0x00002000; + + // + // Assemble the _halfGTX from s, e (zero) and m. + // + + hdata HData; + HData.data = s | (m >> 13); + return HData; + } + else if(e == 0xff - (127 - 15)) + { + if(m == 0) + { + // + // F is an infinity; convert f to a _halfGTX + // infinity with the same sign as f. + // + + hdata HData; + HData.data = s | 0x7c00; + return HData; + } + else + { + // + // F is a NAN; we produce a _halfGTX NAN that preserves + // the sign bit and the 10 leftmost bits of the + // significand of f, with one exception: If the 10 + // leftmost bits are all zero, the NAN would turn + // into an infinity, so we have to set at least one + // bit in the significand. + // + + m >>= 13; + + hdata HData; + HData.data = s | 0x7c00 | m | (m == 0); + return HData; + } + } + else + { + // + // E is greater than zero. F is a normalized float. + // We try to convert f to a normalized _halfGTX. + // + + // + // Round to nearest, round "0.5" up + // + + if(m & 0x00001000) + { + m += 0x00002000; + + if(m & 0x00800000) + { + m = 0; // overflow in significand, + e += 1; // adjust exponent + } + } + + // + // Handle exponent overflow + // + + if (e > 30) + { + _overflow(); // Cause a hardware floating point overflow; + + hdata HData; + HData.data = s | 0x7c00; + return HData; + // if this returns, the _halfGTX becomes an + } // infinity with the same sign as f. + + // + // Assemble the _halfGTX from s, e and m. + // + + hdata HData; + HData.data = s | (e << 10) | (m >> 13); + return HData; + } + } + + inline _halfGTX::_halfGTX() + {} + + inline _halfGTX::_halfGTX(float s) + { + if(s == 0) + data = 0; + else + data = _toFloat16(s).data; + } + + inline _halfGTX::_halfGTX(double s) + { + if(s == 0) + data.data = 0; + else + data = _toFloat16(float(s)).data; + } + + inline _halfGTX::_halfGTX(int s) + { + data = _toFloat16(float(s)); + } + + inline _halfGTX::_halfGTX(bool s) + { + data = _toFloat16(float(s)); + } + + inline _halfGTX::operator float() const + { + return _toFloat32(data); + } + + inline _halfGTX::operator double() const + { + return double(_toFloat32(data)); + } + + inline _halfGTX::operator int() const + { + return int(_toFloat32(data)); + } + + inline _halfGTX::operator hdata() const + { + return data; + } + + inline _halfGTX& _halfGTX::operator=(_halfGTX h) + { + data = h.data; + return *this; + } + + inline _halfGTX& _halfGTX::operator=(float f) + { + *this = _halfGTX(f); + return *this; + } + + inline _halfGTX _halfGTX::operator+(_halfGTX h) const + { + return _halfGTX(float(*this) + float(h)); + } + + inline _halfGTX& _halfGTX::operator+=(_halfGTX h) + { + *this = _halfGTX(float(*this) + float(h)); + return *this; + } + + inline _halfGTX _halfGTX::operator+(float f) const + { + return _halfGTX(float(*this) + f); + } + + inline _halfGTX& _halfGTX::operator+=(float f) + { + *this = _halfGTX(float(*this) + f); + return *this; + } + + inline _halfGTX _halfGTX::operator-(_halfGTX h) const + { + return _halfGTX(float(*this) - float(h)); + } + + inline _halfGTX& _halfGTX::operator-=(_halfGTX h) + { + *this = _halfGTX(float(*this) - float(h)); + return *this; + } + + inline _halfGTX _halfGTX::operator-(float f) const + { + return _halfGTX(float(*this) - f); + } + + inline _halfGTX& _halfGTX::operator-=(float f) + { + *this = _halfGTX (float (*this) - f); + return *this; + } + + inline _halfGTX _halfGTX::operator*(_halfGTX h) const + { + return _halfGTX(float(*this) * float(h)); + } + + inline _halfGTX& _halfGTX::operator*=(_halfGTX h) + { + *this = _halfGTX (float (*this) * float (h)); + return *this; + } + + inline _halfGTX _halfGTX::operator*(float f) const + { + return _halfGTX(float(*this) * f); + } + + inline _halfGTX& _halfGTX::operator*=(float f) + { + *this = _halfGTX (float (*this) * f); + return *this; + } + + inline _halfGTX _halfGTX::operator/(_halfGTX h) const + { + return _halfGTX(float(*this) / float(h)); + } + + inline _halfGTX& _halfGTX::operator/=(_halfGTX h) + { + *this = _halfGTX (float (*this) / float (h)); + return *this; + } + + inline _halfGTX _halfGTX::operator/(float f) const + { + return _halfGTX(float(*this) / f); + } + + inline _halfGTX& _halfGTX::operator/=(float f) + { + *this = _halfGTX (float (*this) / f); + return *this; + } + + inline _halfGTX _halfGTX::operator-() const + { + float Result = -_toFloat32(data); + return _halfGTX(Result); + } + + inline bool _halfGTX::operator< (const _halfGTX& s) const + { + return _toFloat32(data) < _toFloat32(s.data); + } + + inline bool _halfGTX::operator> (const _halfGTX& s) const + { + return _toFloat32(data) > _toFloat32(s.data); + } + + inline bool _halfGTX::operator<=(const _halfGTX& s) const + { + return _toFloat32(data) <= _toFloat32(s.data); + } + + inline bool _halfGTX::operator>=(const _halfGTX& s) const + { + return _toFloat32(data) >= _toFloat32(s.data); + } + + inline bool _halfGTX::operator==(const _halfGTX& s) const + { + return data.data == s.data.data; + } + + inline bool _halfGTX::operator!=(const _halfGTX& s) const + { + return data.data != s.data.data; + } + + // Common constructors + inline _hvec2GTX::_hvec2GTX() : + _cvec2(0, 0) + {} + + inline _hvec2GTX::_hvec2GTX(const _hvec2GTX& v) : + _cvec2(v.x, v.y) + {} + + // Swizzle conclassor + inline _hvec2GTX::_hvec2GTX(const _xref2& r) : + _cvec2(r.x, r.y) + {} + + // T constructors + inline _hvec2GTX::_hvec2GTX(const _halfGTX x) : + _cvec2(x._data(), x._data()) + {} + + inline _hvec2GTX::_hvec2GTX(const _halfGTX a, const _halfGTX b) : + _cvec2(a._data(), b._data()) + {} + + inline _hvec2GTX::_hvec2GTX(const _halfGTX a, const _hvec2GTX& b) : + _cvec2(a._data(), b.x) + {} + + inline _hvec2GTX::_hvec2GTX(const _halfGTX a, const _hvec3GTX& b) : + _cvec2(a._data(), b.x) + {} + + inline _hvec2GTX::_hvec2GTX(const _halfGTX a, const _hvec4GTX& b) : + _cvec2(a._data(), b.x) + {} + + inline _hvec2GTX::_hvec2GTX(const _hvec3GTX& a) : + _cvec2(a.x, a.y) + {} + + inline _hvec2GTX::_hvec2GTX(const _hvec4GTX& a) : + _cvec2(a.x, a.y) + {} + + // U constructors + template + inline _hvec2GTX::_hvec2GTX(const U x) : + _cvec2(_halfGTX(x)._data(), _halfGTX(x)._data()) + {} + + template + inline _hvec2GTX::_hvec2GTX(const U a, const U b) : + _cvec2(_halfGTX(a)._data(), _halfGTX(b)._data()) + {} + + template + inline _hvec2GTX::_hvec2GTX(const U a, const _xvec2& b) : + _cvec2(T(a), T(b.x)) + {} + + template + inline _hvec2GTX::_hvec2GTX(const U a, const _xvec3& b) : + _cvec2(T(a), T(b.x)) + {} + + template + inline _hvec2GTX::_hvec2GTX(const U a, const _xvec4& b) : + _cvec2(T(a), T(b.x)) + {} + + template + inline _hvec2GTX::_hvec2GTX(const _xvec2& a) : + _cvec2(_halfGTX(a.x)._data(), _halfGTX(a.y)._data()) + {} + + template + inline _hvec2GTX::_hvec2GTX(const _xvec3& a) : + _cvec2(T(a.x), T(a.y)) + {} + + template + inline _hvec2GTX::_hvec2GTX(const _xvec4& a) : + _cvec2(T(a.x), T(a.y)) + {} + + // Bool constructors + inline _hvec2GTX::_hvec2GTX(const bool a) : + _cvec2(a, a) + {} + + inline _hvec2GTX::_hvec2GTX(const bool a, const bool b) : + _cvec2(a, b) + {} + + inline _hvec2GTX::_hvec2GTX(const bool a, const _bvec2& b) : + _cvec2(a, b.x) + {} + + inline _hvec2GTX::_hvec2GTX(const bool a, const _bvec3& b) : + _cvec2(a, b.x) + {} + + inline _hvec2GTX::_hvec2GTX(const bool a, const _bvec4& b) : + _cvec2(a, b.x) + {} + + inline _hvec2GTX::_hvec2GTX(const _bvec3& a) : + _cvec2(a.x, a.y) + {} + + inline _hvec2GTX::_hvec2GTX(const _bvec4& a) : + _cvec2(a.x, a.y) + {} + + inline _hvec2GTX::_hvec2GTX(const _bvec2& a) : + _cvec2(a.x, a.y) + {} + + ////////////////////////////////////////////////////////////// + // vec2 and ivec2 operators + + inline _hvec2GTX& _hvec2GTX::operator=(const _hvec2GTX& v) + { + this->x = v.x; + this->y = v.y; + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator+= (const _halfGTX s) + { + this->x = (_halfGTX(this->x) + s)._data(); + this->y = (_halfGTX(this->y) + s)._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator+= (const _hvec2GTX& v) + { + this->x = (_halfGTX(this->x) + _halfGTX(v.x))._data(); + this->y = (_halfGTX(this->y) + _halfGTX(v.y))._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator-= (const _halfGTX s) + { + this->x = (_halfGTX(this->x) - s)._data(); + this->y = (_halfGTX(this->y) - s)._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator-= (const _hvec2GTX& v) + { + this->x = (_halfGTX(this->x) - _halfGTX(v.x))._data(); + this->y = (_halfGTX(this->y) - _halfGTX(v.y))._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator*= (const _halfGTX s) + { + this->x = (_halfGTX(this->x) * s)._data(); + this->y = (_halfGTX(this->y) * s)._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator*= (const _hvec2GTX& v) + { + this->x = (_halfGTX(this->x) * _halfGTX(v.x))._data(); + this->y = (_halfGTX(this->y) * _halfGTX(v.y))._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator/= (const _halfGTX s) + { + this->x = (_halfGTX(this->x) / s)._data(); + this->y = (_halfGTX(this->y) / s)._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator/= (const _hvec2GTX& v) + { + this->x = (_halfGTX(this->x) / _halfGTX(v.x))._data(); + this->y = (_halfGTX(this->y) / _halfGTX(v.y))._data(); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator++ () + { + this->x = _toFloat16(_toFloat32(this->x) + 1.0f); + this->y = _toFloat16(_toFloat32(this->y) + 1.0f); + return *this; + } + + inline _hvec2GTX& _hvec2GTX::operator-- () + { + this->x = _toFloat16(_toFloat32(this->x) - 1.0f); + this->y = _toFloat16(_toFloat32(this->y) - 1.0f); + return *this; + } + + // Binary operators + inline _hvec2GTX operator+ (const _hvec2GTX& v, const _halfGTX s) + { + return _hvec2GTX( + _halfGTX(v.x) + s, + _halfGTX(v.y) + s); + } + + inline _hvec2GTX operator+ (const _halfGTX s, const _hvec2GTX& v) + { + return _hvec2GTX( + _halfGTX(v.x) + s, + _halfGTX(v.y) + s); + } + + inline _hvec2GTX operator+ (const _hvec2GTX& v1, const _hvec2GTX& v2) + { + return _hvec2GTX( + _halfGTX(v1.x) + _halfGTX(v2.x), + _halfGTX(v1.y) + _halfGTX(v2.y)); + } + + inline _hvec2GTX operator- (const _hvec2GTX& v, const _halfGTX s) + { + return _hvec2GTX( + _halfGTX(v.x) - s, + _halfGTX(v.y) - s); + } + + inline _hvec2GTX operator- (const _halfGTX s, const _hvec2GTX& v) + { + return _hvec2GTX( + _halfGTX(v.x) - s, + _halfGTX(v.y) - s); + } + + inline _hvec2GTX operator- (const _hvec2GTX& v1, const _hvec2GTX& v2) + { + return _hvec2GTX( + _halfGTX(v1.x) - _halfGTX(v2.x), + _halfGTX(v1.y) - _halfGTX(v2.y)); + } + + inline _hvec2GTX operator* (const _hvec2GTX& v, const _halfGTX s) + { + return _hvec2GTX( + _halfGTX(v.x) * s, + _halfGTX(v.y) * s); + } + + inline _hvec2GTX operator* (const _halfGTX s, const _hvec2GTX& v) + { + return _hvec2GTX( + s * _halfGTX(v.x), + s * _halfGTX(v.y)); + } + + inline _hvec2GTX operator* (const _hvec2GTX& v1, const _hvec2GTX& v2) + { + return _hvec2GTX( + _halfGTX(v1.x) * _halfGTX(v2.x), + _halfGTX(v1.y) * _halfGTX(v2.y)); + } + + inline _hvec2GTX operator/ (const _hvec2GTX& v, const _halfGTX s) + { + return _hvec2GTX( + _halfGTX(v.x) / s, + _halfGTX(v.y) / s); + } + + inline _hvec2GTX operator/ (const _halfGTX s, const _hvec2GTX& v) + { + return _hvec2GTX( + s / _halfGTX(v.x), + s / _halfGTX(v.y)); + } + + inline _hvec2GTX operator/ (const _hvec2GTX& v1, const _hvec2GTX& v2) + { + return _hvec2GTX( + _halfGTX(v1.x) / _halfGTX(v2.x), + _halfGTX(v1.y) / _halfGTX(v2.y)); + } + + // Unary constant operators + inline const _hvec2GTX operator- (const _hvec2GTX& v) + { + return _hvec2GTX( + -_halfGTX(v.x), + -_halfGTX(v.y)); + } + + inline const _hvec2GTX operator++ (const _hvec2GTX& v, int) + { + return _hvec2GTX( + _halfGTX(v.x) + _halfGTX(1), + _halfGTX(v.y) + _halfGTX(1)); + } + + inline const _hvec2GTX operator-- (const _hvec2GTX& v, int) + { + return _hvec2GTX( + _halfGTX(v.x) - _halfGTX(1), + _halfGTX(v.y) - _halfGTX(1)); + } + + //////////////////////////////////////////////////////// + // _hvec3GTX + // Common constructors + inline _hvec3GTX::_hvec3GTX() : + _cvec3(0, 0, 0) + {} + + inline _hvec3GTX::_hvec3GTX(const _hvec3GTX& v) : + _cvec3(v.x, v.y, v.z) + {} + + // Swizzle constructors + inline _hvec3GTX::_hvec3GTX(const _xref3& r) : + _cvec3(r.x, r.y, r.z) + {} + + // T constructors + inline _hvec3GTX::_hvec3GTX(const _halfGTX x) : + _cvec3(x, x, x) + {} + + inline _hvec3GTX::_hvec3GTX(const _halfGTX a, const _halfGTX b, const _halfGTX c) : + _cvec3(a, b, c) + {} + + inline _hvec3GTX::_hvec3GTX(const _halfGTX a, const _halfGTX b, const _hvec2GTX& c) : + _cvec3(a, b, c.x) + {} + + inline _hvec3GTX::_hvec3GTX(const _halfGTX a, const _halfGTX b, const _hvec3GTX& c) : + _cvec3(a, b, c.x) + {} + + inline _hvec3GTX::_hvec3GTX(const _halfGTX a, const _halfGTX b, const _hvec4GTX& c) : + _cvec3(a, b, c.x) + {} + + inline _hvec3GTX::_hvec3GTX(const _halfGTX a, const _hvec2GTX& b) : + _cvec3(a, b.x, b.y) + {} + + inline _hvec3GTX::_hvec3GTX(const _halfGTX a, const _hvec3GTX& b) : + _cvec3(a, b.x, b.y) + {} + + inline _hvec3GTX::_hvec3GTX(const _halfGTX a, const _hvec4GTX& b) : + _cvec3(a, b.x, b.y) + {} + + inline _hvec3GTX::_hvec3GTX(const _hvec2GTX& a, _halfGTX b) : + _cvec3(a.x, a.y, b) + {} + + inline _hvec3GTX::_hvec3GTX(const _hvec2GTX& a, const _hvec2GTX& b) : + _cvec3(a.x, a.y, b.x) + {} + + inline _hvec3GTX::_hvec3GTX(const _hvec2GTX& a, const _hvec3GTX& b) : + _cvec3(a.x, a.y, b.x) + {} + + inline _hvec3GTX::_hvec3GTX(const _hvec2GTX& a, const _hvec4GTX& b) : + _cvec3(a.x, a.y, b.x) + {} + + inline _hvec3GTX::_hvec3GTX(const _hvec4GTX& a) : + _cvec3(a.x, a.y, a.z) + {} + + // U constructors + template + inline _hvec3GTX::_hvec3GTX(const U x) : + _cvec3(_halfGTX(x)._data(), _halfGTX(x)._data(), _halfGTX(x)._data()) + {} + + template + inline _hvec3GTX::_hvec3GTX(const U a, const U b, const U c) : + _cvec3(_halfGTX(a)._data(), _halfGTX(b)._data(), _halfGTX(c)._data()) + {} + + template + inline _hvec3GTX::_hvec3GTX(const U a, const U b, const _xvec2& c) : + _cvec3(_halfGTX(a)._data(), _halfGTX(b)._data(), _halfGTX(c.x)._data()) + {} + + template + inline _hvec3GTX::_hvec3GTX(const U a, const U b, const _xvec3& c) : + _cvec3(_toFloat16(float(a)), _toFloat16(float(b)), _toFloat16(float(c.x))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const U a, const U b, const _xvec4& c) : + _cvec3(_toFloat16(float(a)), _toFloat16(float(b)), _toFloat16(float(c.x))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const U a, const _xvec2& b) : + _cvec3(_toFloat16(float(a)), _toFloat16(float(b.x)), _toFloat16(float(b.y))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const U a, const _xvec3& b) : + _cvec3(_toFloat16(float(a)), _toFloat16(float(b.x)), _toFloat16(float(b.y))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const U a, const _xvec4& b) : + _cvec3(_toFloat16(float(a)), _toFloat16(float(b.x)), _toFloat16(float(b.y))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const _xvec2& a, U b) : + _cvec3(_toFloat16(float(a.x)), _toFloat16(float(a.y)), _toFloat16(float(b))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const _xvec2& a, const _xvec2& b) : + _cvec3(_toFloat16(float(a.x)), _toFloat16(float(a.y)), _toFloat16(float(b.x))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const _xvec2& a, const _xvec3& b) : + _cvec3(_toFloat16(float(a.x)), _toFloat16(float(a.y)), _toFloat16(float(b.x))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const _xvec2& a, const _xvec4& b) : + _cvec3(_toFloat16(float(a.x)), _toFloat16(float(a.y)), _toFloat16(float(b.x))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const _xvec3& a) : + _cvec3(_toFloat16(float(a.x)), _toFloat16(float(a.y)), _toFloat16(float(a.z))) + {} + + template + inline _hvec3GTX::_hvec3GTX(const _xvec4& a) : + _cvec3(_toFloat16(float(a.x)), _toFloat16(float(a.y)), _toFloat16(float(a.z))) + {} + + // Bool constructors + inline _hvec3GTX::_hvec3GTX(const bool x) : + _cvec3(float(x), float(x), float(x)) + {} + + inline _hvec3GTX::_hvec3GTX(const bool a, const bool b, const bool c) : + _cvec3(float(a), float(b), float(c)) + {} + + inline _hvec3GTX::_hvec3GTX(const bool a, const bool b, const _bvec2& c) : + _cvec3(float(a), float(b), float(c.x)) + {} + + inline _hvec3GTX::_hvec3GTX(const bool a, const bool b, const _bvec3& c) : + _cvec3(float(a), float(b), float(c.x)) + {} + + inline _hvec3GTX::_hvec3GTX(const bool a, const bool b, const _bvec4& c) : + _cvec3(float(a), float(b), float(c.x)) + {} + + inline _hvec3GTX::_hvec3GTX(const bool a, const _bvec2& b) : + _cvec3(float(a), float(b.x), float(b.y)) + {} + + inline _hvec3GTX::_hvec3GTX(const bool a, const _bvec3& b) : + _cvec3(float(a), float(b.x), float(b.y)) + {} + + inline _hvec3GTX::_hvec3GTX(const bool a, const _bvec4& b) : + _cvec3(float(a), float(b.x), float(b.y)) + {} + + inline _hvec3GTX::_hvec3GTX(const _bvec2& a, bool b) : + _cvec3(float(a.x), float(a.y), float(b)) + {} + + inline _hvec3GTX::_hvec3GTX(const _bvec2& a, const _bvec2& b) : + _cvec3(float(a.x), float(a.y), float(b.x)) + {} + + inline _hvec3GTX::_hvec3GTX(const _bvec2& a, const _bvec3& b) : + _cvec3(float(a.x), float(a.y), float(b.x)) + {} + + inline _hvec3GTX::_hvec3GTX(const _bvec2& a, const _bvec4& b) : + _cvec3(float(a.x), float(a.y), float(b.x)) + {} + + inline _hvec3GTX::_hvec3GTX(const _bvec3& a) : + _cvec3(float(a.x), float(a.y), float(a.z)) + {} + + inline _hvec3GTX::_hvec3GTX(const _bvec4& a) : + _cvec3(float(a.x), float(a.y), float(a.z)) + {} + + ////////////////////////////////////////////////////////////// + // hvec3 operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + inline _hvec3GTX& _hvec3GTX::operator=(const _hvec3GTX& v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator+= (const _halfGTX s) + { + this->x = GLM_HALF_OP(this->x, s._data(), +); + this->y = GLM_HALF_OP(this->y, s._data(), +); + this->z = GLM_HALF_OP(this->z, s._data(), +); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator+= (const _hvec3GTX& v) + { + this->x = GLM_HALF_OP(this->x, v.x, +); + this->y = GLM_HALF_OP(this->y, v.y, +); + this->z = GLM_HALF_OP(this->z, v.z, +); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator-= (const _halfGTX s) + { + this->x = GLM_HALF_OP(this->x, s._data(), -); + this->y = GLM_HALF_OP(this->y, s._data(), -); + this->z = GLM_HALF_OP(this->z, s._data(), -); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator-= (const _hvec3GTX& v) + { + this->x = GLM_HALF_OP(this->x, v.x, -); + this->y = GLM_HALF_OP(this->y, v.y, -); + this->z = GLM_HALF_OP(this->z, v.z, -); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator*= (const _halfGTX s) + { + this->x = GLM_HALF_OP(this->x, s._data(), *); + this->y = GLM_HALF_OP(this->y, s._data(), *); + this->z = GLM_HALF_OP(this->z, s._data(), *); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator*= (const _hvec3GTX& v) + { + this->x = GLM_HALF_OP(this->x, v.x, *); + this->y = GLM_HALF_OP(this->y, v.y, *); + this->z = GLM_HALF_OP(this->z, v.z, *); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator/= (const _halfGTX s) + { + this->x = GLM_HALF_OP(this->x, s._data(), /); + this->y = GLM_HALF_OP(this->y, s._data(), /); + this->z = GLM_HALF_OP(this->z, s._data(), /); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator/= (const _hvec3GTX& v) + { + this->x = GLM_HALF_OP(this->x, v.x, /); + this->y = GLM_HALF_OP(this->y, v.y, /); + this->z = GLM_HALF_OP(this->z, v.z, /); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator++ () + { + this->x = GLM_HALF_OP_1(this->x, 1.0f, +); + this->y = GLM_HALF_OP_1(this->y, 1.0f, +); + this->z = GLM_HALF_OP_1(this->z, 1.0f, +); + return *this; + } + + inline _hvec3GTX& _hvec3GTX::operator-- () + { + this->x = GLM_HALF_OP_1(this->x, 1.0f, -); + this->y = GLM_HALF_OP_1(this->y, 1.0f, -); + this->z = GLM_HALF_OP_1(this->z, 1.0f, -); + return *this; + } + + // Unary constant operators + inline const _hvec3GTX operator- (const _hvec3GTX& v) + { + return _hvec3GTX( + _toFloat16(-_toFloat32(v.x)), + _toFloat16(-_toFloat32(v.y)), + _toFloat16(-_toFloat32(v.z))); + } + + inline const _hvec3GTX operator++ (const _hvec3GTX& v, int) + { + return _hvec3GTX( + GLM_HALF_OP_1(v.x, 1.0f, +), + GLM_HALF_OP_1(v.y, 1.0f, +), + GLM_HALF_OP_1(v.z, 1.0f, +)); + } + + inline const _hvec3GTX operator-- (const _hvec3GTX& v, int) + { + return _hvec3GTX( + GLM_HALF_OP_1(v.x, 1.0f, -), + GLM_HALF_OP_1(v.y, 1.0f, -), + GLM_HALF_OP_1(v.z, 1.0f, -)); + } + + // Binary operators + inline _hvec3GTX operator+ (const _hvec3GTX& v, const _halfGTX s) + { + return _hvec3GTX( + GLM_HALF_OP_2(v.x, +, s), + GLM_HALF_OP_2(v.y, +, s), + GLM_HALF_OP_2(v.z, +, s)); + } + + inline _hvec3GTX operator+ (const _halfGTX s, const _hvec3GTX& v) + { + return _hvec3GTX( + GLM_HALF_OP_2(s, +, v.x), + GLM_HALF_OP_2(s, +, v.y), + GLM_HALF_OP_2(s, +, v.z)); + } + + inline _hvec3GTX operator+ (const _hvec3GTX& v1, const _hvec3GTX& v2) + { + return _hvec3GTX( + GLM_HALF_OP_2(v1.x, +, v2.x), + GLM_HALF_OP_2(v1.y, +, v2.y), + GLM_HALF_OP_2(v1.z, +, v2.z)); + } + + inline _hvec3GTX operator- (const _hvec3GTX& v, const _halfGTX s) + { + return _hvec3GTX( + GLM_HALF_OP_2(v.x, -, s), + GLM_HALF_OP_2(v.y, -, s), + GLM_HALF_OP_2(v.z, -, s)); + } + + inline _hvec3GTX operator- (const _halfGTX s, const _hvec3GTX& v) + { + return _hvec3GTX( + GLM_HALF_OP_2(s, -, v.x), + GLM_HALF_OP_2(s, -, v.y), + GLM_HALF_OP_2(s, -, v.z)); + } + + inline _hvec3GTX operator- (const _hvec3GTX& v1, const _hvec3GTX& v2) + { + return _hvec3GTX( + GLM_HALF_OP_2(v1.x, -, v2.x), + GLM_HALF_OP_2(v1.y, -, v2.y), + GLM_HALF_OP_2(v1.z, -, v2.z)); + } + + inline _hvec3GTX operator* (const _hvec3GTX& v, const _halfGTX s) + { + return _hvec3GTX( + GLM_HALF_OP_2(v.x, *, s), + GLM_HALF_OP_2(v.y, *, s), + GLM_HALF_OP_2(v.z, *, s)); + } + + inline _hvec3GTX operator* (const _halfGTX s, const _hvec3GTX& v) + { + return _hvec3GTX( + GLM_HALF_OP_2(s, *, v.x), + GLM_HALF_OP_2(s, *, v.y), + GLM_HALF_OP_2(s, *, v.z)); + } + + inline _hvec3GTX operator* (const _hvec3GTX& v1, const _hvec3GTX & v2) + { + return _hvec3GTX( + GLM_HALF_OP_2(v1.x, *, v2.x), + GLM_HALF_OP_2(v1.y, *, v2.y), + GLM_HALF_OP_2(v1.z, *, v2.z)); + } + + inline _hvec3GTX operator/ (const _hvec3GTX& v, const _halfGTX s) + { + return _hvec3GTX( + GLM_HALF_OP_2(v.x, /, s), + GLM_HALF_OP_2(v.y, /, s), + GLM_HALF_OP_2(v.z, /, s)); + } + + inline _hvec3GTX operator/ (const _halfGTX s, const _hvec3GTX& v) + { + return _hvec3GTX( + GLM_HALF_OP_2(s, /, v.x), + GLM_HALF_OP_2(s, /, v.y), + GLM_HALF_OP_2(s, /, v.z)); + } + + inline _hvec3GTX operator/ (const _hvec3GTX& v1, const _hvec3GTX& v2) + { + return _hvec3GTX( + GLM_HALF_OP_2(v1.x, /, v2.x), + GLM_HALF_OP_2(v1.y, /, v2.y), + GLM_HALF_OP_2(v1.z, /, v2.z)); + } + } +} diff --git a/wip/sse/glm/ext/gtx/handed_coordinate_space.h b/wip/sse/glm/ext/gtx/handed_coordinate_space.h new file mode 100644 index 00000000..fbcbd7d7 --- /dev/null +++ b/wip/sse/glm/ext/gtx/handed_coordinate_space.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/handed_coordinate_space.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_handed_coordinate_space__ +#define __glm_gtx_handed_coordinate_space__ + +// Dependency: +#include "../../glm.h" + +#define GLM_GTX_handed_coordinate_space_supported + +namespace glm +{ + template bool rightHandedGTX(const detail::_xvec3& tangent, const detail::_xvec3& binormal, const detail::_xvec3& normal); //!< Return if a trihedron right handed or not (From GLM_GTX_handed_coordinate_space extension) + template bool leftHandedGTX(const detail::_xvec3& tangent, const detail::_xvec3& binormal, const detail::_xvec3& normal); //!< Return if a trihedron left handed or not (From GLM_GTX_handed_coordinate_space extension) + + namespace gtx + { + //! GLM_GTX_handed_coordinate_space extension: To know if a triedron is right or left handed + namespace handed_coordinate_space + { + template inline bool rightHanded(const detail::_xvec3& tangent, const detail::_xvec3& binormal, const detail::_xvec3& normal){return rightHandedGTX(tangent, binormal, normal);} //!< Return if a trihedron right handed or not (From GLM_GTX_handed_coordinate_space extension) + template inline bool leftHanded(const detail::_xvec3& tangent, const detail::_xvec3& binormal, const detail::_xvec3& normal){return leftHandedGTX(tangent, binormal, normal);} //!< Return if a trihedron left handed or not (From GLM_GTX_handed_coordinate_space extension) + } + } +} + +#define GLM_GTX_handed_coordinate_space namespace gtx::handed_coordinate_space + +#include "handed_coordinate_space.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_handed_coordinate_space;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_handed_coordinate_space__ diff --git a/wip/sse/glm/ext/gtx/handed_coordinate_space.inl b/wip/sse/glm/ext/gtx/handed_coordinate_space.inl new file mode 100644 index 00000000..ce5954f2 --- /dev/null +++ b/wip/sse/glm/ext/gtx/handed_coordinate_space.inl @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/handed_coordinate_space.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline bool rightHandedGTX(const detail::_xvec3& tangent, const detail::_xvec3& binormal, const detail::_xvec3& normal) + { + return dot(cross(normal, tangent), binormal) > T(0); + } + + template + inline bool leftHandedGTX(const detail::_xvec3& tangent, const detail::_xvec3& binormal, const detail::_xvec3& normal) + { + return dot(cross(normal, tangent), binormal) < T(0); + } +} diff --git a/wip/sse/glm/ext/gtx/hyperbolic.h b/wip/sse/glm/ext/gtx/hyperbolic.h new file mode 100644 index 00000000..042629d7 --- /dev/null +++ b/wip/sse/glm/ext/gtx/hyperbolic.h @@ -0,0 +1,75 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-25 +// Updated : 2007-01-26 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/hyperbolic.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_hyperbolic__ +#define __glm_gtx_hyperbolic__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template T sinhGTX(const T angle); //!< \brief The trigonometric hyperbolic sine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec2 sinhGTX(const detail::_xvec2& angle); //!< \brief The standard trigonometric hyperbolic sine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec3 sinhGTX(const detail::_xvec3& angle); //!< \brief The standard trigonometric hyperbolic sine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec4 sinhGTX(const detail::_xvec4& angle); //!< \brief The standard trigonometric hyperbolic sine function. (From GLM_GTX_hyperbolic extension) + + template T coshGTX(const T angle); //!< \brief The trigonometric hyperbolic cosine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec2 coshGTX(const detail::_xvec2& angle); //!< \brief The standard trigonometric hyperbolic cosine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec3 coshGTX(const detail::_xvec3& angle); //!< \brief The standard trigonometric hyperbolic cosine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec4 coshGTX(const detail::_xvec4& angle); //!< \brief The standard trigonometric hyperbolic cosine function. (From GLM_GTX_hyperbolic extension) + + template T tanhGTX(const T angle); //!< \brief The trigonometric hyperbolic tangent function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec2 tanhGTX(const detail::_xvec2& angle); //!< \brief The standard trigonometric hyperbolic tangent function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec3 tanhGTX(const detail::_xvec3& angle); //!< \brief The standard trigonometric hyperbolic tangent function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec4 tanhGTX(const detail::_xvec4& angle); //!< \brief The standard trigonometric hyperbolic tangent function. (From GLM_GTX_hyperbolic extension) + + template T asinhGTX(const T angle); //!< \brief The trigonometric hyperbolic asine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec2 asinhGTX(const detail::_xvec2& angle); //!< \brief The trigonometric hyperbolic asine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec3 asinhGTX(const detail::_xvec3& angle); //!< \brief The trigonometric hyperbolic asine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec4 asinhGTX(const detail::_xvec4& angle); //!< \brief The trigonometric hyperbolic asine function. (From GLM_GTX_hyperbolic extension) + + template T acoshGTX(const T angle); //!< \brief The trigonometric hyperbolic acosine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec2 acoshGTX(const detail::_xvec2& angle); //!< \brief The trigonometric hyperbolic acosine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec3 acoshGTX(const detail::_xvec3& angle); //!< \brief The trigonometric hyperbolic acosine function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec4 acoshGTX(const detail::_xvec4& angle); //!< \brief The trigonometric hyperbolic acosine function. (From GLM_GTX_hyperbolic extension) + + template T atanhGTX(const T angle); //!< \brief The trigonometric hyperbolic atangente function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec2 atanhGTX(const detail::_xvec2& angle); //!< \brief The trigonometric hyperbolic atangente function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec3 atanhGTX(const detail::_xvec3& angle); //!< \brief The trigonometric hyperbolic atangente function. (From GLM_GTX_hyperbolic extension) + template detail::_xvec4 atanhGTX(const detail::_xvec4& angle); //!< \brief The trigonometric hyperbolic atangente function. (From GLM_GTX_hyperbolic extension) + + namespace gtx + { + //! GLM_GTX_hyperbolic extension: Add hyperbolic functions + namespace hyperbolic + { + template inline T sinh(const T& angle){return sinhGTX(angle);} //!< \brief The trigonometric hyperbolic sine function. (From GLM_GTX_hyperbolic extension) + template inline T cosh(const T& angle){return coshGTX(angle);} //!< \brief The trigonometric hyperbolic cosine function. (From GLM_GTX_hyperbolic extension) + template inline T tanh(const T& angle){return tanhGTX(angle);} //!< \brief The trigonometric hyperbolic tangent function. (From GLM_GTX_hyperbolic extension) + + template inline T asinh(const T& x){return asinhGTX(x);} //!< \brief The trigonometric hyperbolic asine function. (From GLM_GTX_hyperbolic extension) + template inline T acosh(const T& x){return asinhGTX(x);} //!< \brief The trigonometric hyperbolic acosine function. (From GLM_GTX_hyperbolic extension) + template inline T atanh(const T& x){return asinhGTX(x);} //!< \brief The trigonometric hyperbolic atangente function. (From GLM_GTX_hyperbolic extension) + } + } +} + +#define GLM_GTX_hyperbolic namespace gtx::hyperbolic + +#include "hyperbolic.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_hyperbolic;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_hyperbolic__ diff --git a/wip/sse/glm/ext/gtx/hyperbolic.inl b/wip/sse/glm/ext/gtx/hyperbolic.inl new file mode 100644 index 00000000..494420d2 --- /dev/null +++ b/wip/sse/glm/ext/gtx/hyperbolic.inl @@ -0,0 +1,219 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-25 +// Updated : 2007-01-26 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/hyperbolic.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // sinh + template + inline T sinh(const T angle) + { + return std::sinh(angle); + } + + template + inline detail::_xvec2 sinh(const detail::_xvec2& angle) + { + return detail::_xvec2( + sinh(angle.x), + sinh(angle.y)); + } + + template + inline detail::_xvec3 sinh(const detail::_xvec3& angle) + { + return detail::_xvec3( + sinh(angle.x), + sinh(angle.y), + sinh(angle.z)); + } + + template + inline detail::_xvec4 sinh(const detail::_xvec4& angle) + { + return detail::_xvec4( + sinh(angle.x), + sinh(angle.y), + sinh(angle.z), + sinh(angle.w)); + } + + // cosh + template + inline T cosh(const T angle) + { + return std::cosh(angle); + } + + template + inline detail::_xvec2 cosh(const detail::_xvec2& angle) + { + return detail::_xvec2( + cosh(angle.x), + cosh(angle.y)); + } + + template + inline detail::_xvec3 cosh(const detail::_xvec3& angle) + { + return detail::_xvec3( + cosh(angle.x), + cosh(angle.y), + cosh(angle.z)); + } + + template + inline detail::_xvec4 cosh(const detail::_xvec4& angle) + { + return detail::_xvec4( + cosh(angle.x), + cosh(angle.y), + cosh(angle.z), + cosh(angle.w)); + } + + // tanh + template + inline T tanh(const T angle) + { + return std::tanh(angle); + } + + template + inline detail::_xvec2 tanh(const detail::_xvec2& angle) + { + return detail::_xvec2( + tanh(angle.x), + tanh(angle.y)); + } + + template + inline detail::_xvec3 tanh(const detail::_xvec3& angle) + { + return detail::_xvec3( + tanh(angle.x), + tanh(angle.y), + tanh(angle.z)); + } + + template + inline detail::_xvec4 tanh(const detail::_xvec4& angle) + { + return detail::_xvec4( + tanh(angle.x), + tanh(angle.y), + tanh(angle.z), + tanh(angle.w)); + } + + // asinh + template + inline T asinh(const T x) + { + return (x < T(0) ? T(-1) : (x > T(0) ? T(1) : T(0))) * log(abs(x) + sqrt(T(1) + x * x)); + } + + template + inline detail::_xvec2 asinh(const detail::_xvec2& x) + { + return detail::_xvec2( + asinh(x.x), + asinh(x.y)); + } + + template + inline detail::_xvec3 asinh(const detail::_xvec3& x) + { + return detail::_xvec3( + asinh(x.x), + asinh(x.y), + asinh(x.z)); + } + + template + inline detail::_xvec4 asinh(const detail::_xvec4& x) + { + return detail::_xvec4( + asinh(x.x), + asinh(x.y), + asinh(x.z), + asinh(x.w)); + } + + // acosh + template + inline T acosh(const T x) + { + if(x < T(1)) + return T(0); + return log(x + sqrt(x * x - T(1))); + } + + template + inline detail::_xvec2 acosh(const detail::_xvec2& x) + { + return detail::_xvec2( + acosh(x.x), + acosh(x.y)); + } + + template + inline detail::_xvec3 acosh(const detail::_xvec3& x) + { + return detail::_xvec3( + acosh(x.x), + acosh(x.y), + acosh(x.z)); + } + + template + inline detail::_xvec4 acosh(const detail::_xvec4& x) + { + return detail::_xvec4( + acosh(x.x), + acosh(x.y), + acosh(x.z), + acosh(x.w)); + } + + // atanh + template + inline T atanh(const T x) + { + if(abs(x) >= T(1)) + return 0; + return T(0.5) * log((T(1) + x) / (T(1) - x)); + } + + template + inline detail::_xvec2 atanh(const detail::_xvec2& x) + { + return detail::_xvec2( + atanh(x.x), + atanh(x.y)); + } + + template + inline detail::_xvec3 atanh(const detail::_xvec3& x) + { + return detail::_xvec3( + atanh(x.x), + atanh(x.y), + atanh(x.z)); + } + + template + inline detail::_xvec4 atanh(const detail::_xvec4& x) + { + return detail::_xvec4( + atanh(x.x), + atanh(x.y), + atanh(x.z), + atanh(x.w)); + } +} diff --git a/wip/sse/glm/ext/gtx/inertia.h b/wip/sse/glm/ext/gtx/inertia.h new file mode 100644 index 00000000..5d9965fc --- /dev/null +++ b/wip/sse/glm/ext/gtx/inertia.h @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/inertia.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_inertia__ +#define __glm_gtx_inertia__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat3 boxInertia3GTX(const T Mass, const detail::_xvec3& Scale); //!< Build an inertia matrix for a box (From GLM_GTX_inertia extension) + template detail::_xmat4 boxInertia4GTX(const T Mass, const detail::_xvec3& Scale); //!< Build an inertia matrix for a box (From GLM_GTX_inertia extension) + template detail::_xmat3 diskInertia3GTX(const T Mass, const T Radius); //!< Build an inertia matrix for a disk (From GLM_GTX_inertia extension) + template detail::_xmat4 diskInertia4GTX(const T Mass, const T Radius); //!< Build an inertia matrix for a disk (From GLM_GTX_inertia extension) + template detail::_xmat3 ballInertia3GTX(const T Mass, const T Radius); //!< Build an inertia matrix for a ball (From GLM_GTX_inertia extension) + template detail::_xmat4 ballInertia4GTX(const T Mass, const T Radius); //!< Build an inertia matrix for a ball (From GLM_GTX_inertia extension) + template detail::_xmat3 sphereInertia3GTX(const T Mass, const T Radius); //!< Build an inertia matrix for a sphere (From GLM_GTX_inertia extension) + template detail::_xmat4 sphereInertia4GTX(const T Mass, const T Radius); //!< Build an inertia matrix for a sphere (From GLM_GTX_inertia extension) + + namespace gtx + { + //! GLM_GTX_inertia extension: Create inertia matrices + namespace inertia + { + template inline detail::_xmat3 boxInertia3(const T Mass, const detail::_xvec3& Scale){return boxInertia3GTX(Mass, Scale);} //!< Build an inertia matrix for a box (From GLM_GTX_inertia extension) + template inline detail::_xmat4 boxInertia4(const T Mass, const detail::_xvec3& Scale){return boxInertia$GTX(Mass, Scale);} //!< Build an inertia matrix for a box (From GLM_GTX_inertia extension) + template inline detail::_xmat3 diskInertia3(const T Mass, const T Radius){return diskInertia3GTX(Mass, Radius);} //!< Build an inertia matrix for a disk (From GLM_GTX_inertia extension) + template inline detail::_xmat4 diskInertia4(const T Mass, const T Radius){return diskInertia4GTX(Mass, Radius);} //!< Build an inertia matrix for a disk (From GLM_GTX_inertia extension) + template inline detail::_xmat3 ballInertia3(const T Mass, const T Radius){return ballInertia3GTX(Mass, Radius);} //!< Build an inertia matrix for a ball (From GLM_GTX_inertia extension) + template inline detail::_xmat4 ballInertia4(const T Mass, const T Radius){return ballInertia4GTX(Mass, Radius);} //!< Build an inertia matrix for a ball (From GLM_GTX_inertia extension) + template inline detail::_xmat3 sphereInertia3(const T Mass, const T Radius){return sphereInertia3GTX(Mass, Radius);} //!< Build an inertia matrix for a sphere (From GLM_GTX_inertia extension) + template inline detail::_xmat4 sphereInertia4(const T Mass, const T Radius){return sphereInertia4GTX(Mass, Radius);} //!< Build an inertia matrix for a sphere (From GLM_GTX_inertia extension) + } + } +} + +#define GLM_GTX_inertia namespace gtx::inertia + +#include "inertia.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_inertia;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_inertia__ diff --git a/wip/sse/glm/ext/gtx/inertia.inl b/wip/sse/glm/ext/gtx/inertia.inl new file mode 100644 index 00000000..8a5d1184 --- /dev/null +++ b/wip/sse/glm/ext/gtx/inertia.inl @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-21 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/inertia.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat3 boxInertia3GTX(const T Mass, const detail::_xvec3& Scale) + { + detail::_xmat3 Result(T(1)); + Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); + Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); + Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); + return Result; + } + + template + inline detail::_xmat4 boxInertia4GTX(const T Mass, const detail::_xvec3& Scale) + { + detail::_xmat4 Result(T(1)); + Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); + Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); + Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); + return Result; + } + + template + inline detail::_xmat3 diskInertia3GTX(const T Mass, const T Radius) + { + T a = Mass * Radius * Radius / T(2); + detail::_xmat3 Result(a); + Result[2][2] *= T(2); + return Result; + } + + template + inline detail::_xmat4 diskInertia4GTX(const T Mass, const T Radius) + { + T a = Mass * Radius * Radius / T(2); + detail::_xmat4 Result(a); + Result[2][2] *= T(2); + Result[3][3] = T(1); + return Result; + } + + template + inline detail::_xmat3 ballInertia3GTX(const T Mass, const T Radius) + { + T a = T(2) * Mass * Radius * Radius / T(5); + return detail::_xmat3(a); + } + + template + inline detail::_xmat4 ballInertia4GTX(const T Mass, const T Radius) + { + T a = T(2) * Mass * Radius * Radius / T(5); + detail::_xmat4 Result(a); + Result[3][3] = T(1); + return Result; + } + + template + inline detail::_xmat3 sphereInertia3GTX(const T Mass, const T Radius) + { + T a = T(2) * Mass * Radius * Radius / T(3); + return detail::_xmat3(a); + } + + template + inline detail::_xmat4 sphereInertia4GTX(const T Mass, const T Radius) + { + T a = T(2) * Mass * Radius * Radius / T(3); + detail::_xmat4 Result(a); + Result[3][3] = T(1); + return Result; + } +} diff --git a/wip/sse/glm/ext/gtx/integer.h b/wip/sse/glm/ext/gtx/integer.h new file mode 100644 index 00000000..c4bfb0bb --- /dev/null +++ b/wip/sse/glm/ext/gtx/integer.h @@ -0,0 +1,104 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-24 +// Updated : 2006-11-14 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/integer.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_integer__ +#define __glm_gtx_integer__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + int absGTX(int x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_integer extension) + template T absGTX(T x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_integer extension) + template detail::_xvec2 absGTX(const detail::_xvec2& x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_integer extension) + template detail::_xvec3 absGTX(const detail::_xvec3& x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_integer extension) + template detail::_xvec4 absGTX(const detail::_xvec4& x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_integer extension) + + template genType signGTX(const genType& x); //!< \brief Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0. (From GLM_GTX_integer extension) + + template T minGTX(T x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec2 minGTX(const detail::_xvec2& x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec3 minGTX(const detail::_xvec3& x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec4 minGTX(const detail::_xvec4& x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec2 minGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec3 minGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec4 minGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_integer extension) + + template T maxGTX(T x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec2 maxGTX(const detail::_xvec2& x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec3 maxGTX(const detail::_xvec3& x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec4 maxGTX(const detail::_xvec4& x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec2 maxGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec3 maxGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_integer extension) + template detail::_xvec4 maxGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_integer extension) + + template T clampGTX(T x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_integer extension) + template detail::_xvec2 clampGTX(const detail::_xvec2& x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_integer extension) + template detail::_xvec3 clampGTX(const detail::_xvec3& x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_integer extension) + template detail::_xvec4 clampGTX(const detail::_xvec4& x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_integer extension) + template detail::_xvec2 clampGTX(const detail::_xvec2& x, const detail::_xvec2& minVal, const detail::_xvec2& maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_integer extension) + template detail::_xvec3 clampGTX(const detail::_xvec3& x, const detail::_xvec3& minVal, const detail::_xvec3& maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_integer extension) + template detail::_xvec4 clampGTX(const detail::_xvec4& x, const detail::_xvec4& minVal, const detail::_xvec4& maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_integer extension) + + int powGTX(int x, int y); //!< \brief Returns x raised to the y power. (From GLM_GTX_integer extension) + template T powGTX(T x, T y); //!< \brief Returns x raised to the y power. (From GLM_GTX_integer extension) + template detail::_xvec2 powGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Returns x raised to the y power. (From GLM_GTX_integer extension) + template detail::_xvec3 powGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns x raised to the y power. (From GLM_GTX_integer extension) + template detail::_xvec4 powGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Returns x raised to the y power. (From GLM_GTX_integer extension) + + int sqrtGTX(int x); //!< \brief Returns the positive square root of x. (From GLM_GTX_integer extension) + template T sqrtGTX(T x); //!< \brief Returns the positive square root of x. (From GLM_GTX_integer extension) + template detail::_xvec2 sqrtGTX(const detail::_xvec2& x); //!< \brief Returns the positive square root of x. (From GLM_GTX_integer extension) + template detail::_xvec3 sqrtGTX(const detail::_xvec3& x); //!< \brief Returns the positive square root of x. (From GLM_GTX_integer extension) + template detail::_xvec4 sqrtGTX(const detail::_xvec4& x); //!< \brief Returns the positive square root of x. (From GLM_GTX_integer extension) + + int modGTX(int x, int y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + //template T modGTX(T x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + template detail::_xvec2 modGTX(const detail::_xvec2& x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + template detail::_xvec3 modGTX(const detail::_xvec3& x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + template detail::_xvec4 modGTX(const detail::_xvec4& x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + template detail::_xvec2 modGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + template detail::_xvec3 modGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + template detail::_xvec4 modGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + + template T factorialGTX(T x); //!< \brief Return the factorial value of a number (!12 max, integer only) + template detail::_xvec2 factorialGTX(const detail::_xvec2& x); //!< \brief Return the factorial value of a number (!12 max, integer only) + template detail::_xvec3 factorialGTX(const detail::_xvec3& x); //!< \brief Return the factorial value of a number (!12 max, integer only) + template detail::_xvec4 factorialGTX(const detail::_xvec4& x); //!< \brief Return the factorial value of a number (!12 max, integer only) + + namespace gtx + { + //! GLM_GTX_integer extension: Add support for integer for core functions + namespace integer + { + inline int abs(int x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_integer extension) + inline int pow(int x, int y){return powGTX(x, y);} //!< \brief Returns x raised to the y power. (From GLM_GTX_integer extension) + inline int sqrt(int x){return sqrtGTX(x);} //!< \brief Returns the positive square root of x. (From GLM_GTX_integer extension) + inline int mod(int x, int y){return modGTX(x, y);} //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_integer extension) + template inline T factorial(T x){return factorialGTX(x);} //!< \brief Return the factorial value of a number (!12 max, integer only) + template inline detail::_xvec2 factorial(const detail::_xvec2& x){return factorialGTX(x);} //!< \brief Return the factorial value of a number (!12 max, integer only) + template inline detail::_xvec3 factorial(const detail::_xvec3& x){return factorialGTX(x);} //!< \brief Return the factorial value of a number (!12 max, integer only) + template inline detail::_xvec4 factorial(const detail::_xvec4& x){return factorialGTX(x);} //!< \brief Return the factorial value of a number (!12 max, integer only) + } + } +} + +#define GLM_GTX_integer namespace gtx::integer + +#include "integer.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_integer;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_integer__ diff --git a/wip/sse/glm/ext/gtx/integer.inl b/wip/sse/glm/ext/gtx/integer.inl new file mode 100644 index 00000000..2b5a8f37 --- /dev/null +++ b/wip/sse/glm/ext/gtx/integer.inl @@ -0,0 +1,284 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-24 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/integer.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // absGTX + inline int absGTX(int x) + { + return ((x >> 31) ^ x) - (x >> 31); + } + + template + inline T absGTX(T x) + { + return x >= T(0) ? x : -x; + } + + template + inline detail::_xvec2 absGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + absGTX(x.x), + absGTX(x.y)); + } + + template + inline detail::_xvec3 absGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + absGTX(x.x), + absGTX(x.y), + absGTX(x.z)); + } + + template + inline detail::_xvec4 absGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + absGTX(x.x), + absGTX(x.y), + absGTX(x.z), + absGTX(x.w)); + } + + // signGTX + template inline genType signGTX(const genType& x){return sign(x);} + + // minGTX + // test: + /* + inline int minGTX(int x, int y) + { + return (x + y - absGTX(x - y)) >> 1; + } + */ + template inline T minGTX(T x, T y) {return min(x, y);} + template inline detail::_xvec2 minGTX(const detail::_xvec2& x, T y) {return min(x, y);} + template inline detail::_xvec3 minGTX(const detail::_xvec3& x, T y) {return min(x, y);} + template inline detail::_xvec4 minGTX(const detail::_xvec4& x, T y) {return min(x, y);} + template inline detail::_xvec2 minGTX(const detail::_xvec2& x, const detail::_xvec2& y) {return min(x, y);} + template inline detail::_xvec3 minGTX(const detail::_xvec3& x, const detail::_xvec3& y) {return min(x, y);} + template inline detail::_xvec4 minGTX(const detail::_xvec4& x, const detail::_xvec4& y) {return min(x, y);} + + // maxGTX + template inline T maxGTX(T x, T y) {return max(x, y);} + template inline detail::_xvec2 maxGTX(const detail::_xvec2& x, T y) {return max(x, y);} + template inline detail::_xvec3 maxGTX(const detail::_xvec3& x, T y) {return max(x, y);} + template inline detail::_xvec4 maxGTX(const detail::_xvec4& x, T y) {return max(x, y);} + template inline detail::_xvec2 maxGTX(const detail::_xvec2& x, const detail::_xvec2& y) {return max(x, y);} + template inline detail::_xvec3 maxGTX(const detail::_xvec3& x, const detail::_xvec3& y) {return max(x, y);} + template inline detail::_xvec4 maxGTX(const detail::_xvec4& x, const detail::_xvec4& y) {return max(x, y);} + + // clampGTX + template inline T clampGTX(T x, T minVal, T maxVal) {return min(max(x, minVal), maxVal);} + template inline detail::_xvec2 clampGTX(const detail::_xvec2& x, T minVal, T maxVal) {return min(max(x, minVal), maxVal);} + template inline detail::_xvec3 clampGTX(const detail::_xvec3& x, T minVal, T maxVal) {return min(max(x, minVal), maxVal);} + template inline detail::_xvec4 clampGTX(const detail::_xvec4& x, T minVal, T maxVal) {return min(max(x, minVal), maxVal);} + template inline detail::_xvec2 clampGTX(const detail::_xvec2& x, const detail::_xvec2& minVal, const detail::_xvec2& maxVal) {return min(max(x, minVal), maxVal);} + template inline detail::_xvec3 clampGTX(const detail::_xvec3& x, const detail::_xvec3& minVal, const detail::_xvec3& maxVal) {return min(max(x, minVal), maxVal);} + template inline detail::_xvec4 clampGTX(const detail::_xvec4& x, const detail::_xvec4& minVal, const detail::_xvec4& maxVal) {return min(max(x, minVal), maxVal);} + + // powGTX + inline int powGTX(int x, int y) + { + if(y == 0) + return 1; + int result = x; + for(int i = 1; i < y; ++i) + result *= x; + return result; + } + + template + inline T powGTX(T x, T y) + { + return std::pow(x, y); + } + + template + inline detail::_xvec2 powGTX(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + powGTX(x.x, y.x), + powGTX(x.y, y.y)); + } + + template + inline detail::_xvec3 powGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + powGTX(x.x, y.x), + powGTX(x.y, y.y), + powGTX(x.z, y.z)); + } + + template + inline detail::_xvec4 powGTX(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + powGTX(x.x, y.x), + powGTX(x.y, y.y), + powGTX(x.z, y.z), + powGTX(x.w, y.w)); + } + + // sqrtGTX: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387 + inline int sqrtGTX(int x) + { + if(x <= 1) return x; + + int NextTrial = x >> 1; + int CurrentAnswer; + + do + { + CurrentAnswer = NextTrial; + NextTrial = (NextTrial + x / NextTrial) >> 1; + } while(NextTrial < CurrentAnswer); + + return CurrentAnswer; + } + + template + inline T sqrtGTX(T x) + { + return std::sqrt(x); + } + + template + inline detail::_xvec2 sqrtGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + sqrtGTX(x.x), + sqrtGTX(x.y)); + } + + template + inline detail::_xvec3 sqrtGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + sqrtGTX(x.x), + sqrtGTX(x.y), + sqrtGTX(x.z)); + } + + template + inline detail::_xvec4 sqrtGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + sqrtGTX(x.x), + sqrtGTX(x.y), + sqrtGTX(x.z), + sqrtGTX(x.w)); + } + + // modGTX + inline int modGTX(int x, int y) + { + return x - y * (x / y); + } +/* + template + inline T modGTX(T x, T y) + { + return x - y * (x / y); + } +*/ + template + inline detail::_xvec2 modGTX(const detail::_xvec2& x, T y) + { + return detail::_xvec2( + modGTX(x.x, y), + modGTX(x.y, y)); + } + + template + inline detail::_xvec3 modGTX(const detail::_xvec3& x, T y) + { + return detail::_xvec3( + modGTX(x.x, y), + modGTX(x.y, y), + modGTX(x.z, y)); + } + + template + inline detail::_xvec4 modGTX(const detail::_xvec4& x, T y) + { + return detail::_xvec4( + modGTX(x.x, y), + modGTX(x.y, y), + modGTX(x.z, y), + modGTX(x.w, y)); + } + + template + inline detail::_xvec2 modGTX(const detail::_xvec2& x, const detail::_xvec2& y) + { + return detail::_xvec2( + modGTX(x.x, y.x), + modGTX(x.y, y.y)); + } + + template + inline detail::_xvec3 modGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return detail::_xvec3( + modGTX(x.x, y.x), + modGTX(x.y, y.y), + modGTX(x.z, y.z)); + } + + template + inline detail::_xvec4 modGTX(const detail::_xvec4& x, const detail::_xvec4& y) + { + return detail::_xvec4( + modGTX(x.x, y.x), + modGTX(x.y, y.y), + modGTX(x.z, y.z), + modGTX(x.w, y.w)); + } + + // factorial (!12 max, integer only) + template + inline T factorialGTX(T x) + { + T Result; + for(Result = 1; x > 1; --x) + Result *= x; + return Result; + } + + template + inline detail::_xvec2 factorialGTX(const detail::_xvec2& x) + { + return detail::_xvec2( + factorialGTX(x.x), + factorialGTX(x.y)); + } + + template + inline detail::_xvec3 factorialGTX(const detail::_xvec3& x) + { + return detail::_xvec3( + factorialGTX(x.x), + factorialGTX(x.y), + factorialGTX(x.z)); + } + + template + inline detail::_xvec4 factorialGTX(const detail::_xvec4& x) + { + return detail::_xvec4( + factorialGTX(x.x), + factorialGTX(x.y), + factorialGTX(x.z), + factorialGTX(x.w)); + } +} diff --git a/wip/sse/glm/ext/gtx/intersect.h b/wip/sse/glm/ext/gtx/intersect.h new file mode 100644 index 00000000..f9c182a2 --- /dev/null +++ b/wip/sse/glm/ext/gtx/intersect.h @@ -0,0 +1,107 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-04-03 +// Updated : 2007-04-03 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/intersect.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_closest_point +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_intersect__ +#define __glm_gtx_intersect__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/closest_point.h" + +namespace glm +{ + //! Compute the intersection of a ray and a triangle (From GLM_GTX_intersect extension) + template + bool intersectRayTriangleGTX( + const genType& orig, const genType& dir, + const genType& vert0, const genType& vert1, const genType& vert2, + genType& position); + + //! Compute the intersection of a line and a triangle (From GLM_GTX_intersect extension) + template + bool intersectLineTriangleGTX( + const genType& orig, const genType& dir, + const genType& vert0, const genType& vert1, const genType& vert2, + genType& position); + + //! Compute the intersection of a ray and a sphere (From GLM_GTX_intersect extension) + template + bool intersectRaySphereGTX( + const genType& orig, const genType& dir, + const genType& center, GLMvalType radius, + genType& position, genType& normal); + + //! Compute the intersection of a line and a sphere (From GLM_GTX_intersect extension) + template + bool intersectLineSphereGTX( + const genType& point0, const genType& point1, + const genType& center, GLMvalType radius, + genType& position, genType& normal); + + namespace gtx + { + //! GLM_GTX_intersect extension: Add intersection functions + namespace intersect + { + //! Compute the intersection of a ray and a triangle (From GLM_GTX_intersect extension) + template + inline bool intersectRayTriangle( + const genType& orig, const genType& dir, + const genType& vert0, const genType& vert1, const genType& vert2, + genType& position) + { + return intersectRayTriangleGTX(orig, dir, vert0, vert1, vert2, position); + } + + //! Compute the intersection of a line and a triangle (From GLM_GTX_intersect extension) + template + inline bool intersectLineTriangle( + const genType& orig, const genType& dir, + const genType& vert0, const genType& vert1, const genType& vert2, + genType& position) + { + return intersectLineTriangleGTX(orig, dir, vert0, vert1, vert2, position); + } + + //! Compute the intersection of a ray and a sphere (From GLM_GTX_intersect extension) + template + inline bool intersectRaySphere( + const genType& orig, const genType& dir, + const genType& center, GLMvalType radius, + genType& position, genType& normal) + { + return intersectRaySphereGTX(orig, dir, center, radius, position, normal); + } + + //! Compute the intersection of a line and a sphere (From GLM_GTX_intersect extension) + template + inline bool intersectLineSphere( + const genType& point0, const genType& point1, + const genType& center, GLMvalType radius, + genType& position, genType& normal) + { + return intersectLineSphereGTX(point0, point1, center, radius, position, normal); + } + } + } +} + +#define GLM_GTX_intersect namespace gtx::intersect + +#include "intersect.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_intersect;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_intersect__ diff --git a/wip/sse/glm/ext/gtx/intersect.inl b/wip/sse/glm/ext/gtx/intersect.inl new file mode 100644 index 00000000..1fdbb4ca --- /dev/null +++ b/wip/sse/glm/ext/gtx/intersect.inl @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-04-03 +// Updated : 2007-04-03 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/intersect.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline bool intersectRayTriangleGTX( + const genType& orig, const genType& dir, + const genType& vert0, const genType& vert1, const genType& vert2, + genType& position) + { +// typename genType::size_type result = typename genType::value_type(0); +// typename genType::value_type pouet; + + typename genType::value_type Epsilon = std::numeric_limits::epsilon(); + + genType edge1 = vert1 - vert0; + genType edge2 = vert2 - vert0; + + genType pvec = cross(dir, edge2); + + float det = dot(edge1, pvec); + if(det < Epsilon) + return false; + + genType tvec = orig - vert0; + + position.y = dot(tvec, pvec); + if (position.y < typename genType::value_type(0) || position.y > det) + return genType::value_type(0); + + genType qvec = cross(tvec, edge1); + + position.z = dot(dir, qvec); + if (position.z < typename genType::value_type(0) || position.y + position.z > det) + return genType::value_type(0); + + position.x = dot(edge2, qvec); + position *= typename genType::value_type(1) / det; + + return typename genType::value_type(1); + } + + template + inline bool intersectLineTriangleGTX( + const genType& orig, const genType& dir, + const genType& vert0, const genType& vert1, const genType& vert2, + genType& position) + { + typename genType::value_type Epsilon = std::numeric_limits::epsilon(); + + genType edge1 = vert1 - vert0; + genType edge2 = vert2 - vert0; + + genType pvec = cross(dir, edge2); + + float det = dot(edge1, pvec); + + if (det > -Epsilon && det < Epsilon) + return false; + float inv_det = typename genType::value_type(1) / det; + + genType tvec = orig - vert0; + + position.y = dot(tvec, pvec) * inv_det; + if (position.y < typename genType::value_type(0) || position.y > typename genType::value_type(1)) + return false; + + genType qvec = cross(tvec, edge1); + + position.z = dot(dir, qvec) * inv_det; + if (position.z < typename genType::value_type(0) || position.y + position.z > typename genType::value_type(1)) + return false; + + position.x = dot(edge2, qvec) * inv_det; + + return true; + } + + template + inline bool intersectRaySphereGTX( + const genType& orig, const genType& dir, + const genType& center, GLMvalType radius, + genType& position, genType& normal) + { + typename genType::value_type Epsilon = std::numeric_limits::epsilon(); + + typename genType::value_type a = dot(position, position); + typename genType::value_type b = typename genType::value_type(2) * dot(center, dir); + typename genType::value_type c = dot(center, center) - radius * radius; + typename genType::value_type d = b * b - typename genType::value_type(4) * a * c; + typename genType::value_type e = sqrt(d); + typename genType::value_type x1 = (-b - e) / (typename genType::value_type(2) * a); + typename genType::value_type x2 = (-b - e) / (typename genType::value_type(2) * a); + + if(x1 > Epsilon) + { + position = orig + dir * radius; + normal = (position - center) / radius; + return true; + } + else if(x2 > Epsilon) + { + position = orig + dir * radius; + normal = (position - center) / radius; + return true; + } + return false; + } + + template + inline bool intersectLineSphereGTX( + const genType& point0, const genType& point1, + const genType& center, GLMvalType radius, + genType& position, genType& normal) + { + typename genType::value_type Epsilon = std::numeric_limits::epsilon(); + + genType dir = point1 - point0; + typename genType::value_type a = dot(position, position); + typename genType::value_type b = typename genType::value_type(2) * dot(center, dir); + typename genType::value_type c = dot(center, center) - radius * radius; + typename genType::value_type d = b * b - typename genType::value_type(4) * a * c; + typename genType::value_type e = sqrt(d); + typename genType::value_type x1 = (-b - e) / (typename genType::value_type(2) * a); + typename genType::value_type x2 = (-b - e) / (typename genType::value_type(2) * a); + + if(x1 > Epsilon) + { + position = center + dir * radius; + normal = (position - center) / radius; + return true; + } + else if(x2 > Epsilon) + { + position = center + dir * radius; + normal = (position - center) / radius; + return true; + } + return false; + } +} diff --git a/wip/sse/glm/ext/gtx/inverse.h b/wip/sse/glm/ext/gtx/inverse.h new file mode 100644 index 00000000..fa77665d --- /dev/null +++ b/wip/sse/glm/ext/gtx/inverse.h @@ -0,0 +1,61 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-09-09 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/inverse.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_transpose +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_inverse__ +#define __glm_gtx_inverse__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/transpose.h" + +namespace glm +{ + template detail::_xmat2 inverseGTX(const detail::_xmat2& m); //!< Compute the inverse of a generic 2x2 matrix (From GLM_GTX_inverse extension) + template detail::_xmat3 inverseGTX(const detail::_xmat3& m); //!< Compute the inverse of a generic 3x3 matrix (From GLM_GTX_inverse extension) + template detail::_xmat4 inverseGTX(const detail::_xmat4& m); //!< Compute the inverse of a generic 4x4 matrix (From GLM_GTX_inverse extension) + + template detail::_xmat3 inverseTransformGTX(const detail::_xmat3& m); //!< Compute the inverse of a transformation 4x4 matrix (From GLM_GTX_inverse extension) + template detail::_xmat4 inverseTransformGTX(const detail::_xmat4& m); //!< Compute the inverse of a transformation 4x4 matrix (From GLM_GTX_inverse extension) + +// template detail::_xmat2 affineInverseGTX(const detail::_xmat2& m); +// template detail::_xmat3 affineInverseGTX(const detail::_xmat3& m); +// template detail::_xmat4 affineInverseGTX(const detail::_xmat4& m); + + namespace gtx + { + //! GLM_GTX_inverse extension: Inverse matrix functions + namespace inverse + { + template detail::_xmat2 inverse(const detail::_xmat2& m){return inverseGTX(m);} //!< Compute the inverse of a generic 2x2 matrix (From GLM_GTX_inverse extension) + template detail::_xmat3 inverse(const detail::_xmat3& m){return inverseGTX(m);} //!< Compute the inverse of a generic 3x3 matrix (From GLM_GTX_inverse extension) + template detail::_xmat4 inverse(const detail::_xmat4& m){return inverseGTX(m);} //!< Compute the inverse of a generic 4x4 matrix (From GLM_GTX_inverse extension) + + template detail::_xmat3 inverseTransform(const detail::_xmat3& m){return inverseTransformGTX(m);} //!< Compute the inverse of a transformation 3x3 matrix (From GLM_GTX_inverse extension) + template detail::_xmat4 inverseTransform(const detail::_xmat4& m){return inverseTransformGTX(m);} //!< Compute the inverse of a transformation 4x4 matrix (From GLM_GTX_inverse extension) + +// template detail::_xmat2 affineInverse(const detail::_xmat2& m){return affineInverseGTX(m);} +// template detail::_xmat3 affineInverse(const detail::_xmat3& m){return affineInverseGTX(m);} +// template detail::_xmat4 affineInverse(const detail::_xmat4& m){return affineInverseGTX(m);} + } + } +} + +#define GLM_GTX_inverse namespace gtx::inverse + +#include "inverse.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_inverse;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_inverse__ diff --git a/wip/sse/glm/ext/gtx/inverse.inl b/wip/sse/glm/ext/gtx/inverse.inl new file mode 100644 index 00000000..53dac0fd --- /dev/null +++ b/wip/sse/glm/ext/gtx/inverse.inl @@ -0,0 +1,184 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-09-09 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/inverse.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat2 inverseGTX(const detail::_xmat2& m) + { + T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; + + detail::_xmat2 Inverse( + + m[1][1] / Determinant, + - m[1][0] / Determinant, + - m[0][1] / Determinant, + + m[0][0] / Determinant); + + return Inverse; + } + + template + inline detail::_xmat3 inverseGTX(const detail::_xmat3& m) + { + T Determinant = m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) + - m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2]) + + m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + + detail::_xmat3 Inverse; + Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]); + Inverse[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); + Inverse[2][0] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]); + Inverse[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); + Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]); + Inverse[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); + Inverse[0][2] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + Inverse[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); + Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + Inverse /= Determinant; + + return Inverse; + } + + template + inline detail::_xmat4 inverseGTX(const detail::_xmat4& m) + { + T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + T SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + T SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + T SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + T SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + T SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; + T SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + T SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; + T SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; + T SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; + T SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + T SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; + T SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; + T SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; + T SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; + T SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; + T SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; + T SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; + + detail::_xmat4 Inverse( + + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02), + - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02), + + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08), + - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15), + + - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04), + + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04), + - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10), + + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17), + + + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05), + - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05), + + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12), + - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18), + + - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05), + + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05), + - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12), + + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18)); + + T Determinant = m[0][0] * Inverse[0][0] + + m[0][1] * Inverse[1][0] + + m[0][2] * Inverse[2][0] + + m[0][3] * Inverse[3][0]; + + Inverse /= Determinant; + + return Inverse; + } + + template + inline detail::_xmat3 inverseTransformGTX(const detail::_xmat3& m) + { + detail::_xmat3 Result; + Result[2] = detail::_xvec3(0, 0, 1); + Result = transposeGTX(Result); + detail::_xvec3 Translation = Result * -m[3]; + Result[2] = Translation; + return Result; + } + + template + inline detail::_xmat4 inverseTransformGTX(const detail::_xmat4& m) + { + detail::_xmat4 Result; + Result[3] = detail::_xvec4(0, 0, 0, 1); + Result = transposeGTX(Result); + detail::_xvec4 Translation = Result * -m[3]; + Result[3] = Translation; + return Result; + } + +/* + template + inline detail::_xmat2 affineInverseGTX(const detail::_xmat2& m) + { + T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; + + detail::_xmat2 Inverse( + + m[1][1] / Determinant, + - m[1][0] / Determinant, + - m[0][1] / Determinant, + + m[0][0] / Determinant); + + return Inverse; + } + + template + inline detail::_xmat3 affineInverseGTX(const detail::_xmat3& m) + { + detail::_xmat3 Result; + return Result; + } + + template + inline detail::_xmat4 affineInverseGTX(const detail::_xmat4& m) + { + #define ACCUMULATE() \ + if(Temp >= T(0)) Positive += Temp; \ + else Negative += Temp + + float Positive = T(0), Negative = T(0); + float Temp = T(0); + + Temp = m[0][0] * m[1][1] * m[2][2]; + ACCUMULATE(); + Temp = m[1][0] * m[2][1] * m[0][2]; + ACCUMULATE(); + Temp = m[2][0] * m[0][1] * m[1][2]; + ACCUMULATE(); + Temp = m[2][0] * m[1][1] * m[2][0]; + ACCUMULATE(); + Temp = m[1][0] * m[0][1] * m[2][2]; + ACCUMULATE(); + Temp = m[0][0] * m[2][1] * m[1][2]; + ACCUMULATE(); + float Det = 1.0f / (Positive + Negative); + + //Temp = Det / (Positive - Negative); + detail::_xmat4 Result; + Result[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * Det; + Result[0][1] = (m[0][1] * m[2][2] - m[2][1] * m[0][2]) * Det; + Result[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]) * Det; + Result[1][0] = (m[1][0] * m[2][2] - m[2][0] * m[1][2]) * Det; + Result[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]) * Det; + Result[1][2] = (m[0][0] * m[1][2] - m[1][0] * m[0][2]) * Det; + Result[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]) * Det; + Result[2][1] = (m[0][0] * m[2][1] - m[2][0] * m[0][1]) * Det; + Result[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) * Det; + return Result; + } +*/ +} diff --git a/wip/sse/glm/ext/gtx/inverse_transpose.h b/wip/sse/glm/ext/gtx/inverse_transpose.h new file mode 100644 index 00000000..ab8dcd0e --- /dev/null +++ b/wip/sse/glm/ext/gtx/inverse_transpose.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-04 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/inverse_transpose.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_inverse_transpose__ +#define __glm_gtx_inverse_transpose__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat2 inverseTransposeGTX(const detail::_xmat2& m); //!< Compute the inverse transpose of a generic 2x2 matrix (From GLM_GTX_inverse extension) + template detail::_xmat3 inverseTransposeGTX(const detail::_xmat3& m); //!< Compute the inverse transpose of a generic 3x3 matrix (From GLM_GTX_inverse extension) + template detail::_xmat4 inverseTransposeGTX(const detail::_xmat4& m); //!< Compute the inverse transpose of a generic 4x4 matrix (From GLM_GTX_inverse extension) + + namespace gtx + { + //! GLM_GTX_inverse_transpose extension: Inverse transpose matrix functions + namespace inverse_transpose + { + template inline T inverseTranspose(const T& m){return inverseTransposeGTX(m);} //!< Compute the inverse transpose of a matrix (From GLM_GTX_inverse extension) + } + } +} + +#define GLM_GTX_inverse_transpose namespace gtx::inverse_transpose + +#include "inverse_transpose.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_inverse_transpose;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_inverse_transpose__ diff --git a/wip/sse/glm/ext/gtx/inverse_transpose.inl b/wip/sse/glm/ext/gtx/inverse_transpose.inl new file mode 100644 index 00000000..9136142e --- /dev/null +++ b/wip/sse/glm/ext/gtx/inverse_transpose.inl @@ -0,0 +1,101 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-04 +// Updated : 2006-01-04 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/inverse_transpose.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat2 inverseTransposeGTX(const detail::_xmat2& m) + { + T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; + + detail::_xmat2 Inverse( + + m[1][1] / Determinant, + - m[0][1] / Determinant, + - m[1][0] / Determinant, + + m[0][0] / Determinant); + + return Inverse; + } + + template + inline detail::_xmat3 inverseTransposeGTX(const detail::_xmat3& m) + { + T Determinant = m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) + - m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2]) + + m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + + detail::_xmat3 Inverse; + Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]); + Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); + Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]); + Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); + Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]); + Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); + Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); + Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + Inverse /= Determinant; + + return Inverse; + } + + template + inline detail::_xmat4 inverseTransposeGTX(const detail::_xmat4& m) + { + T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + T SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + T SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + T SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + T SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + T SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; + T SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + T SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; + T SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; + T SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; + T SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + T SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; + T SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; + T SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; + T SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; + T SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; + T SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; + T SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; + + detail::_xmat4 Inverse; + Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02); + Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04); + Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05); + Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05); + + Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02); + Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04); + Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05); + Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05); + + Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08); + Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10); + Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12); + Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12); + + Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15); + Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17); + Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18); + Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18); + + T Determinant = m[0][0] * Inverse[0][0] + + m[0][1] * Inverse[1][0] + + m[0][2] * Inverse[2][0] + + m[0][3] * Inverse[3][0]; + + Inverse /= Determinant; + + return Inverse; + } +} diff --git a/wip/sse/glm/ext/gtx/mat4x3.h b/wip/sse/glm/ext/gtx/mat4x3.h new file mode 100644 index 00000000..d25c2daa --- /dev/null +++ b/wip/sse/glm/ext/gtx/mat4x3.h @@ -0,0 +1,134 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-27 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/mat4x3.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_mat4x3__ +#define __glm_gtx_mat4x3__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template class _xvec3; + template class _xvec4; + + template class _xmat4x3GTX + { + private: + // Data + _xvec3 value[4]; + + public: + // Constructors + _xmat4x3GTX(); + explicit _xmat4x3GTX(const T x); + explicit _xmat4x3GTX( + const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1, + const T x2, const T y2, const T z2, + const T x3, const T y3, const T z3); + explicit _xmat4x3GTX( + const _xvec3& v0, + const _xvec3& v1, + const _xvec3& v2, + const _xvec3& v3); + + // Accesses + _xvec3& operator[](int i) {return value[i];} + const _xvec3 & operator[](int i) const {return value[i];} + operator T*() {return &value[0][0];} + operator const T*() const {return &value[0][0];} + + // Unary updatable operators + _xmat4x3GTX& operator= (const _xmat4x3GTX& m); + _xmat4x3GTX& operator+= (const T s); + _xmat4x3GTX& operator+= (const _xmat4x3GTX& m); + _xmat4x3GTX& operator-= (const T s); + _xmat4x3GTX& operator-= (const _xmat4x3GTX& m); + _xmat4x3GTX& operator*= (const T s); + _xmat4x3GTX& operator*= (const _xmat4x3GTX& m); + _xmat4x3GTX& operator/= (const T s); + // ToDo + //_xmat4x3GTX& operator/= (const _xmat4x3GTX& m); + _xmat4x3GTX& operator++ (); + _xmat4x3GTX& operator-- (); + + // Unary constant operators + const _xmat4x3GTX operator- () const; + const _xmat4x3GTX operator++ (int n) const; + const _xmat4x3GTX operator-- (int n) const; + }; + + // Binary operators + template + _xmat4x3GTX operator+ (const _xmat4x3GTX& m, const T s); + + template + _xmat4x3GTX operator+ (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2); + + template + _xmat4x3GTX operator- (const _xmat4x3GTX& m, const T s); + + template + _xmat4x3GTX operator- (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2); + + template + _xmat4x3GTX operator* (const _xmat4x3GTX& m, const T s); + + template + _xmat4x3GTX operator* (const T s, const _xmat4x3GTX& m); + + template + _xvec3 operator* (const _xmat4x3GTX& m, const _xvec4& v); + + template + _xvec3 operator* (const _xvec4& v, const _xmat4x3GTX& m); + + template + _xmat4x3GTX operator* (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2); + + template + _xmat4x3GTX operator/ (const _xmat4x3GTX& m, const T s); + + template + _xmat4x3GTX operator/ (const T s, const _xmat4x3GTX& m); +/* + template + _xvec3 operator/ (const _xmat4x3GTX& m, const _xvec4& v); + + template + _xvec3 operator/ (const _xvec4& v, const _xmat4x3GTX& m); +*/ + template + _xmat4x3GTX operator/ (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2); + + typedef _xmat4x3GTX __mat4x3GTX; //!< - Deprecated - 4 * 3 matrix of floating-point numbers. (From GLM_GTX_mat4x3 extension) + + namespace gtx + { + //! GLM_GTX_mat4x3 extension: Deprecated + namespace mat4x3 + { + typedef _xmat4x3GTX mat4x3; //!< - Deprecated - 4 * 3 matrix of floating-point numbers. (From GLM_GTX_mat4x3 extension) + } + } +} //namespace glm + +#define GLM_GTX_mat4x3 namespace gtx::mat4x3 + +#include "mat4x3.inl" +/* Deprecated +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_mat4x3;} +#endif//GLM_GTX_INCLUDED +*/ +#endif //__glm_gtx_mat4x3__ diff --git a/wip/sse/glm/ext/gtx/mat4x3.inl b/wip/sse/glm/ext/gtx/mat4x3.inl new file mode 100644 index 00000000..27d8c459 --- /dev/null +++ b/wip/sse/glm/ext/gtx/mat4x3.inl @@ -0,0 +1,405 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-17 +// Updated : 2006-04-17 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/mat4x3.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + ////////////////////////////////////////////////////////////// + // Constructors + + template + inline _xmat4x3GTX::_xmat4x3GTX() + { + this->value[0] = _xvec3(1, 0, 0); + this->value[1] = _xvec3(0, 1, 0); + this->value[2] = _xvec3(0, 0, 1); + this->value[3] = _xvec3(0, 0, 0); + } + + template + inline _xmat4x3GTX::_xmat4x3GTX(const T f) + { + this->value[0] = _xvec3(f, 0, 0); + this->value[1] = _xvec3(0, f, 0); + this->value[2] = _xvec3(0, 0, f); + this->value[3] = _xvec3(0, 0, 0); + } + + template + inline _xmat4x3GTX::_xmat4x3GTX + ( + const T x0, const T y0, const T z0, + const T x1, const T y1, const T z1, + const T x2, const T y2, const T z2, + const T x3, const T y3, const T z3 + ) + { + this->value[0] = _xvec3(x0, y0, z0); + this->value[1] = _xvec3(x1, y1, z1); + this->value[2] = _xvec3(x2, y2, z2); + this->value[3] = _xvec3(x3, y3, z3); + } + + template + inline _xmat4x3GTX::_xmat4x3GTX + ( + const _xvec3 & v0, + const _xvec3 & v1, + const _xvec3 & v2, + const _xvec3 & v3 + ) + { + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; + this->value[3] = v3; + } + + ////////////////////////////////////////////////////////////// + // Unary updatable operators + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator= (const _xmat4x3GTX& m) + { + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; + this->value[3] = m[3]; + return *this; + } + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator+= (const T s) + { + this->value[0] += s; + this->value[1] += s; + this->value[2] += s; + this->value[3] += s; + return *this; + } + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator+= (const _xmat4x3GTX& m) + { + this->value[0] += m[0]; + this->value[1] += m[1]; + this->value[2] += m[2]; + this->value[3] += m[3]; + return *this; + } + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator-= (const T s) + { + this->value[0] -= s; + this->value[1] -= s; + this->value[2] -= s; + this->value[3] -= s; + return *this; + } + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator-= (const _xmat4x3GTX& m) + { + this->value[0] -= m[0]; + this->value[1] -= m[1]; + this->value[2] -= m[2]; + this->value[3] -= m[3]; + return *this; + } + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator*= (const T s) + { + this->value[0] *= s; + this->value[1] *= s; + this->value[2] *= s; + this->value[3] *= s; + return *this; + } + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator*= (const _xmat4x3GTX& m) + { + return (*this = *this * m); + } + + template + inline _xmat4x3GTX & _xmat4x3GTX::operator/= (const T s) + { + this->value[0] /= s; + this->value[1] /= s; + this->value[2] /= s; + this->value[3] /= s; + return *this; + } +/* + template + inline _xmat4x3GTX& _xmat4x3GTX::operator/= (const _xmat4x3GTX& m) + { + return (*this = *this / m); + } +*/ + template + inline _xmat4x3GTX& _xmat4x3GTX::operator++ () + { + ++this->value[0]; + ++this->value[1]; + ++this->value[2]; + ++this->value[3]; + return *this; + } + + template + inline _xmat4x3GTX& _xmat4x3GTX::operator-- () + { + --this->value[0]; + --this->value[1]; + --this->value[2]; + --this->value[3]; + return *this; + } + + ////////////////////////////////////////////////////////////// + // Unary constant operators + template + inline const _xmat4x3GTX _xmat4x3GTX::operator- () const + { + return _xmat4x3GTX( + -this->value[0], + -this->value[1], + -this->value[2], + -this->value[3]); + } + + template + inline const _xmat4x3GTX _xmat4x3GTX::operator-- (int n) const + { + _xmat4x3GTX m = *this; + --m.value[0]; + --m.value[1]; + --m.value[2]; + --m.value[3]; + return m; + } + + template + inline const _xmat4x3GTX _xmat4x3GTX::operator++ (int n) const + { + detail::_xmat4 m = *this; + ++m.value[0]; + ++m.value[1]; + ++m.value[2]; + ++m.value[3]; + return m; + } + + ////////////////////////////////////////////////////////////// + // Binary operators + + template + inline _xmat4x3GTX operator+ (const _xmat4x3GTX& m, const T s) + { + return _xmat4x3GTX( + m[0] + s, + m[1] + s, + m[2] + s, + m[3] + s); + } + + template + inline _xmat4x3GTX operator+ (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2) + { + return _xmat4x3GTX( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2], + m1[3] + m2[3]); + } + + template + inline _xmat4x3GTX operator- (const _xmat4x3GTX& m, const T s) + { + return _xmat4x3GTX( + m[0] - s, + m[1] - s, + m[2] - s, + m[3] - s); + } + + template + inline _xmat4x3GTX operator- (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2) + { + return _xmat4x3GTX( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2], + m1[3] - m2[3]); + } + + template + inline _xmat4x3GTX operator* (const _xmat4x3GTX& m, const T s) + { + return _xmat4x3GTX( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xmat4x3GTX operator* (const T s, const _xmat4x3GTX & m) + { + return _xmat4x3GTX( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s); + } + + template + inline _xvec3 operator* (const _xmat4x3GTX& m, const _xvec4& v) + { + return _xvec3( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w, + m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w); + } + + template + inline _xvec3 operator* (const _xvec4& v, const _xmat4x3GTX& m) + { + return _xvec3( + m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, + m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w, + m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w); + } + + template + inline _xmat4x3GTX operator* (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2) + { + const T SrcA00 = m1[0][0]; + const T SrcA01 = m1[0][1]; + const T SrcA02 = m1[0][2]; + const T SrcA10 = m1[1][0]; + const T SrcA11 = m1[1][1]; + const T SrcA12 = m1[1][2]; + const T SrcA20 = m1[2][0]; + const T SrcA21 = m1[2][1]; + const T SrcA22 = m1[2][2]; + const T SrcA30 = m1[3][0]; + const T SrcA31 = m1[3][1]; + const T SrcA32 = m1[3][2]; + + const T SrcB00 = m2[0][0]; + const T SrcB01 = m2[0][1]; + const T SrcB02 = m2[0][2]; + const T SrcB10 = m2[1][0]; + const T SrcB11 = m2[1][1]; + const T SrcB12 = m2[1][2]; + const T SrcB20 = m2[2][0]; + const T SrcB21 = m2[2][1]; + const T SrcB22 = m2[2][2]; + const T SrcB30 = m2[3][0]; + const T SrcB31 = m2[3][1]; + const T SrcB32 = m2[3][2]; + + _xmat4x3GTX Result; + Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02; + Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02; + Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01 + SrcA22 * SrcB02; + Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12; + Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12; + Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11 + SrcA22 * SrcB12; + Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21 + SrcA20 * SrcB22; + Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21 + SrcA21 * SrcB22; + Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21 + SrcA22 * SrcB22; + Result[3][0] = SrcA00 * SrcB30 + SrcA10 * SrcB31 + SrcA20 * SrcB32 + SrcA30; + Result[3][1] = SrcA01 * SrcB30 + SrcA11 * SrcB31 + SrcA21 * SrcB32 + SrcA31; + Result[3][2] = SrcA02 * SrcB30 + SrcA12 * SrcB31 + SrcA22 * SrcB32 + SrcA32; + return Result; + } + + template + inline _xmat4x3GTX operator/ (const _xmat4x3GTX& m, const T s) + { + return _xmat4x3GTX( + m.value[0] / s, + m.value[1] / s, + m.value[2] / s, + m.value[3] / s); + } +/* + template + inline _xmat4x3GTX operator/ (const T s, const _xmat4x3GTX& m) + { + return _xmat4x3GTX( + s / m.value[0], + s / m.value[1], + s / m.value[2], + s / m.value[3]); + } + + template + _xvec3 operator/ (const _xmat4x3GTX& m, const _xvec4& v) + { + + } + + template + _xvec3 operator/ (const _xvec4& v, const _xmat4x3GTX& m) + { + + } +*/ + + template + inline _xmat4x3GTX operator/ (const _xmat4x3GTX& m1, const _xmat4x3GTX& m2) + { + T SubFactor01 = m2[2][1] * m2[3][2] - m2[3][1] * m2[2][2]; + T SubFactor02 = m2[2][0] * m2[3][2] - m2[3][0] * m2[2][2]; + T SubFactor03 = m2[2][0] * m2[3][1] - m2[3][0] * m2[2][1]; + T SubFactor04 = m2[1][1] * m2[3][2] - m2[3][1] * m2[1][2]; + T SubFactor05 = m2[1][0] * m2[3][2] - m2[3][0] * m2[1][2]; + T SubFactor06 = m2[1][0] * m2[3][1] - m2[3][0] * m2[1][1]; + T SubFactor07 = m2[1][1] * m2[2][2] - m2[2][1] * m2[1][2]; + T SubFactor08 = m2[1][0] * m2[2][2] - m2[2][0] * m2[1][2]; + T SubFactor09 = m2[1][0] * m2[2][1] - m2[2][0] * m2[1][1]; + + _xmat4x3GTX Inverse( + + m2[1][3] * SubFactor01, + - m2[1][3] * SubFactor02, + + m2[1][3] * SubFactor03, + -(m2[1][0] * SubFactor01 - m2[1][1] * SubFactor02 + m2[1][2] * SubFactor03), + + - m2[0][3] * SubFactor01, + + m2[0][3] * SubFactor02, + - m2[0][3] * SubFactor03, + +(m2[0][0] * SubFactor02 - m2[0][1] * SubFactor02 + m2[0][2] * SubFactor03), + + + m2[0][3] * SubFactor04, + - m2[0][3] * SubFactor05, + + m2[0][3] * SubFactor06, + -(m2[0][0] * SubFactor04 - m2[0][1] * SubFactor05 + m2[0][2] * SubFactor06), + + - m2[0][3] * SubFactor07, + + m2[0][3] * SubFactor08, + - m2[0][3] * SubFactor09, + +(m2[0][0] * SubFactor07 - m2[0][1] * SubFactor08 + m2[0][2] * SubFactor09)); + + T Determinant = m2[0][0] * Inverse[0][0] + + m2[0][1] * Inverse[1][0] + + m2[0][2] * Inverse[2][0] + + m2[0][3] * Inverse[3][0]; + + Inverse /= Determinant; + + return m1 * Inverse; + } + +} //namespace glm diff --git a/wip/sse/glm/ext/gtx/matrix_access.h b/wip/sse/glm/ext/gtx/matrix_access.h new file mode 100644 index 00000000..0a23797a --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_access.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-27 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_access.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_matrix_access__ +#define __glm_gtx_matrix_access__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template genType rowGTX(const genType& m, int index, const GLMrowType& x); //!< Set a specific row to a matrix (From GLM_GTX_matrix_access extension) + template genType columnGTX(const genType& m, int index, const GLMcolType& x); //!< Set a specific column to a matrix (From GLM_GTX_matrix_access extension) + + namespace gtx + { + //! GLM_GTX_matrix_access extension: Set a column or a row of a matrix + namespace matrix_access + { + template inline genType row(const genType& m, int index, const GLMrowType& x){return rowGTX(m, index, x);} //!< Set a specific row to a matrix (From GLM_GTX_matrix_access extension) + template inline genType column(const genType& m, int index, const GLMcolType& x){return columnGTX(m, index, x);} //!< Set a specific column to a matrix (From GLM_GTX_matrix_access extension) + } + } +} + +#define GLM_GTX_matrix_access namespace gtx::matrix_access + +#include "matrix_access.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_matrix_access;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_matrix_access__ diff --git a/wip/sse/glm/ext/gtx/matrix_access.inl b/wip/sse/glm/ext/gtx/matrix_access.inl new file mode 100644 index 00000000..5091e9cb --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_access.inl @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-27 +// Updated : 2005-12-27 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_access.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline genType rowGTX(const genType& m, int index, const GLMrowType& x) + { + genType Result = m; + for(typename genType::size_type i = 0; i < genType::row_size; ++i) + Result[i][index] = x[i]; + return Result; + } + + template + inline genType columnGTX(const genType& m, int index, const GLMcolType& x) + { + genType Result = m; + Result[index] = x; + return Result; + } +/* + template + inline _xmat2 rowGTX(const _xmat2& m, int index, const _xvec2& x) + { + _xmat2 Result = m; + Result[0][index] = x[0]; + Result[1][index] = x[1]; + return Result; + } + + template + inline _xmat3 rowGTX(const _xmat3& m, int index, const _xvec3& x) + { + _xmat3 Result = m; + Result[0][index] = x[0]; + Result[1][index] = x[1]; + Result[2][index] = x[2]; + return Result; + } + + template + inline _xmat4 rowGTX(const _xmat4& m, int index, const _xvec4& x) + { + _xmat4 Result = m; + Result[0][index] = x[0]; + Result[1][index] = x[1]; + Result[2][index] = x[2]; + Result[3][index] = x[3]; + return Result; + } + + template + inline _xmat2 columnGTX(const _xmat2 & m, int index, const _xvec2& x) + { + _xmat2 Result = m; + Result[index] = x; + return Result; + } + + template + inline _xmat3 columnGTX(const _xmat3 & m, int index, const _xvec3& x) + { + _xmat3 Result = m; + Result[index] = x; + return Result; + } + + template + inline _xmat4 columnGTX(const _xmat4 & m, int index, const _xvec4& x) + { + _xmat4 Result = m; + Result[index] = x; + return Result; + } +*/ +} diff --git a/wip/sse/glm/ext/gtx/matrix_cross_product.h b/wip/sse/glm/ext/gtx/matrix_cross_product.h new file mode 100644 index 00000000..dc20176c --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_cross_product.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_cross_product.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_matrix_cross_product__ +#define __glm_gtx_matrix_cross_product__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat3 matrixCross3GTX(const detail::_xvec3& x); //!< Build a cross product matrix (From GLM_GTX_matrix_cross_product extension) + template detail::_xmat4 matrixCross4GTX(const detail::_xvec3& x); //!< Build a cross product matrix (From GLM_GTX_matrix_cross_product extension) + + namespace gtx + { + //! GLM_GTX_matrix_cross_product: Build cross product matrices + namespace matrix_cross_product + { + template inline detail::_xmat3 matrixCross3(const detail::_xvec3& x){return matrixCross3GTX(x);} //!< Build a cross product matrix (From GLM_GTX_matrix_cross_product extension) + template inline detail::_xmat4 matrixCross4(const detail::_xvec3& x){return matrixCross4GTX(x);} //!< Build a cross product matrix (From GLM_GTX_matrix_cross_product extension) + } + } +} + +#define GLM_GTX_matrix_cross_product namespace gtx::matrix_cross_product + +#include "matrix_cross_product.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_matrix_cross_product;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_matrix_cross_product__ diff --git a/wip/sse/glm/ext/gtx/matrix_cross_product.inl b/wip/sse/glm/ext/gtx/matrix_cross_product.inl new file mode 100644 index 00000000..d2f7c835 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_cross_product.inl @@ -0,0 +1,37 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_cross_product.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat3 matrixCross3GTX(const detail::_xvec3& x) + { + detail::_xmat3 Result(T(0)); + Result[0][1] = x.z; + Result[1][0] = -x.z; + Result[0][2] = -x.y; + Result[2][0] = x.y; + Result[1][2] = x.x; + Result[2][1] = -x.x; + return Result; + } + + template + inline detail::_xmat4 matrixCross4GTX(const detail::_xvec3& x) + { + detail::_xmat4 Result(T(0)); + Result[0][1] = x.z; + Result[1][0] = -x.z; + Result[0][2] = -x.y; + Result[2][0] = x.y; + Result[1][2] = x.x; + Result[2][1] = -x.x; + return Result; + } +} diff --git a/wip/sse/glm/ext/gtx/matrix_major_storage.h b/wip/sse/glm/ext/gtx/matrix_major_storage.h new file mode 100644 index 00000000..6dc1fff2 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_major_storage.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-19 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_major_storage.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_matrix_major_storage__ +#define __glm_gtx_matrix_major_storage__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat2 rowMajor2GTX(const detail::_xvec2& v1, const detail::_xvec2& v2); //!< Build a row major matrix from row vectors (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat2 rowMajor2GTX(const detail::_xmat2& m); //!< Build a row major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat3 rowMajor3GTX(const detail::_xvec3& v1, const detail::_xvec3& v2, const detail::_xvec3& v3); //!< Build a row major matrix from row vectors (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat3 rowMajor3GTX(const detail::_xmat3& m); //!< Build a row major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat4 rowMajor4GTX(const detail::_xvec4& v1, const detail::_xvec4& v2, const detail::_xvec4& v3, const detail::_xvec4& v4); //!< Build a row major matrix from row vectors (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat4 rowMajor4GTX(const detail::_xmat4& m); //!< Build a row major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + + template detail::_xmat2 colMajor2GTX(const detail::_xvec2& v1, const detail::_xvec2& v2); //!< Build a column major matrix from column vectors (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat2 colMajor2GTX(const detail::_xmat2& m); //!< Build a column major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat3 colMajor3GTX(const detail::_xvec3& v1, const detail::_xvec3& v2, const detail::_xvec3& v3); //!< Build a column major matrix from column vectors (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat3 colMajor3GTX(const detail::_xmat3& m); //!< Build a column major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat4 colMajor4GTX(const detail::_xvec4& v1, const detail::_xvec4& v2, const detail::_xvec4& v3, const detail::_xvec4& v4); //!< Build a column major matrix from column vectors (From GLM_GTX_matrix_major_storage extension) + template detail::_xmat4 colMajor4GTX(const detail::_xmat4& m); //!< Build a column major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + + namespace gtx + { + //! GLM_GTX_matrix_cross_product: Build matrices with specific matrix order, row or column + namespace matrix_major_storage + { + template inline detail::_xmat2 rowMajor2(const detail::_xvec2& v1, const detail::_xvec2& v2){return rowMajor2GTX(v1, v2);} //!< Build a row major matrix from row vectors (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat2 rowMajor2(const detail::_xmat2& m){return rowMajor2GTX(m);} //!< Build a row major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat3 rowMajor3(const detail::_xvec3& v1, const detail::_xvec3& v2, const detail::_xvec3& v3){return rowMajor3GTX(v1, v2, v3);} //!< Build a row major matrix from row vectors (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat3 rowMajor3(const detail::_xmat3& m){return rowMajor3GTX(m);} //!< Build a row major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat4 rowMajor4(const detail::_xvec4& v1, const detail::_xvec4& v2, const detail::_xvec4& v3, const detail::_xvec4& v4){return rowMajor4GTX(v1, v2, v3, v4);} //!< Build a row major matrix from row vectors (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat4 rowMajor4(const detail::_xmat4& m){return rowMajor4GTX(m);} //!< Build a row major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + + template inline detail::_xmat2 colMajor2(const detail::_xvec2& v1, const detail::_xvec2& v2){return colMajor2GTX(v1, v2);} //!< Build a column major matrix from column vectors (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat2 colMajor2(const detail::_xmat2& m){return colMajor2GTX(m);} //!< Build a column major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat3 colMajor3(const detail::_xvec3& v1, const detail::_xvec3& v2, const detail::_xvec3& v3){return colMajor2GTX(v1, v2, v3);} //!< Build a column major matrix from column vectors (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat3 colMajor3(const detail::_xmat3& m){return colMajor3GTX(m);} //!< Build a column major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat4 colMajor4(const detail::_xvec4& v1, const detail::_xvec4& v2, const detail::_xvec4& v3, const detail::_xvec4& v4){return colMajor2GTX(v1, v2, v3, v4);} //!< Build a column major matrix from column vectors (From GLM_GTX_matrix_major_storage extension) + template inline detail::_xmat4 colMajor4(const detail::_xmat4& m){return colMajor4GTX(m);} //!< Build a column major matrix from other matrix (From GLM_GTX_matrix_major_storage extension) + } + } +} + +#define GLM_GTX_matrix_major_storage namespace gtx::matrix_major_storage + +#include "matrix_major_storage.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_matrix_major_storage;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_matrix_major_storage__ diff --git a/wip/sse/glm/ext/gtx/matrix_major_storage.inl b/wip/sse/glm/ext/gtx/matrix_major_storage.inl new file mode 100644 index 00000000..61a082e7 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_major_storage.inl @@ -0,0 +1,170 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-19 +// Updated : 2008-05-01 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_major_storage.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat2 rowMajor2GTX( + const detail::_xvec2& v1, + const detail::_xvec2& v2) + { + detail::_xmat2 Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + return Result; + } + + template + inline detail::_xmat2 rowMajor2GTX( + const detail::_xmat2& m) + { + detail::_xmat2 Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + return Result; + } + + template + inline detail::_xmat3 rowMajor3GTX( + const detail::_xvec3& v1, + const detail::_xvec3& v2, + const detail::_xvec3& v3) + { + detail::_xmat3 Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[2][0] = v1.z; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + Result[2][1] = v2.z; + Result[0][2] = v3.x; + Result[1][2] = v3.y; + Result[2][2] = v3.z; + return Result; + } + + template + inline detail::_xmat3 rowMajor3GTX( + const detail::_xmat3& m) + { + detail::_xmat3 Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[0][2] = m[2][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + Result[1][2] = m[2][1]; + Result[2][0] = m[0][2]; + Result[2][1] = m[1][2]; + Result[2][2] = m[2][2]; + return Result; + } + + template + inline detail::_xmat4 rowMajor4GTX( + const detail::_xvec4& v1, + const detail::_xvec4& v2, + const detail::_xvec4& v3, + const detail::_xvec4& v4) + { + detail::_xmat4 Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[2][0] = v1.z; + Result[3][0] = v1.w; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + Result[2][1] = v2.z; + Result[3][1] = v2.w; + Result[0][2] = v3.x; + Result[1][2] = v3.y; + Result[2][2] = v3.z; + Result[3][2] = v3.w; + Result[0][3] = v4.x; + Result[1][3] = v4.y; + Result[2][3] = v4.z; + Result[3][3] = v4.w; + return Result; + } + + template + inline detail::_xmat4 rowMajor4GTX( + const detail::_xmat4& m) + { + detail::_xmat4 Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[0][2] = m[2][0]; + Result[0][3] = m[3][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + Result[1][2] = m[2][1]; + Result[1][3] = m[3][1]; + Result[2][0] = m[0][2]; + Result[2][1] = m[1][2]; + Result[2][2] = m[2][2]; + Result[2][3] = m[3][2]; + Result[3][0] = m[0][3]; + Result[3][1] = m[1][3]; + Result[3][2] = m[2][3]; + Result[3][3] = m[3][3]; + return Result; + } + + template + inline detail::_xmat2 colMajor2GTX( + const detail::_xvec2& v1, + const detail::_xvec2& v2) + { + return detail::_xmat2(v1, v2); + } + + template + inline detail::_xmat2 colMajor2GTX( + const detail::_xmat2& m) + { + return detail::_xmat2(m); + } + + template + inline detail::_xmat3 colMajor3GTX( + const detail::_xvec3& v1, + const detail::_xvec3& v2, + const detail::_xvec3& v3) + { + return detail::_xmat3(v1, v2, v3); + } + + template + inline detail::_xmat3 colMajor3GTX( + const detail::_xmat3& m) + { + return detail::_xmat3(m); + } + + template + inline detail::_xmat4 colMajor4GTX( + const detail::_xvec4& v1, + const detail::_xvec4& v2, + const detail::_xvec4& v3, + const detail::_xvec4& v4) + { + return detail::_xmat4(v1, v2, v3, v4); + } + + template + inline detail::_xmat4 colMajor4GTX(const detail::_xmat4& m) + { + return detail::_xmat4(m); + } +} diff --git a/wip/sse/glm/ext/gtx/matrix_projection.h b/wip/sse/glm/ext/gtx/matrix_projection.h new file mode 100644 index 00000000..1453d915 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_projection.h @@ -0,0 +1,53 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_projection.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_matrix_projection__ +#define __glm_gtx_matrix_projection__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat4 ortho2DGTX(T left, T right, T bottom, T top); //!< \brief Creates a matrix for projecting two-dimensional coordinates onto the screen (from GLM_GTX_matrix_projection extension) + template detail::_xmat4 ortho3DGTX(T left, T right, T bottom, T top, T zNear, T zFar); //!< \brief Creates a matrix for an orthographic parallel viewing volume (from GLM_GTX_matrix_projection extension) + template detail::_xmat4 perspectiveGTX(T fovy, T aspect, T zNear, T zFar); //!< \brief Creates a matrix for a symmetric perspective-view frustum (from GLM_GTX_matrix_projection extension) + template detail::_xmat4 infinitePerspectiveGTX(T fovy, T aspect, T zNear); //!< \brief Creates a matrix for a symmetric perspective-view frustum with far plane at infinite (from GLM_GTX_matrix_projection extension) + template detail::_xmat4 tweakedInfinitePerspectiveGTX(T fovy, T aspect, T zNear); //!< \brief Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping (from GLM_GTX_matrix_projection extension) + template detail::_xvec3 projectGTX(const detail::_xvec3& obj, const detail::_xmat4& model, const detail::_xmat4& proj, const detail::_xvec4& viewport); //!< \brief Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates (from GLM_GTX_matrix_projection extension) + template detail::_xvec3 unProjectGTX(const detail::_xvec3& win, const detail::_xmat4& model, const detail::_xmat4& proj, const detail::_xvec4& viewport); //!< \brief Map the specified window coordinates (win.x, win.y, win.z) into object coordinates (from GLM_GTX_matrix_projection extension) + + namespace gtx + { + //! GLM_GTX_matrix_projection: Varius ways to build and operate on projection matrices + namespace matrix_projection + { + template inline detail::_xmat4 ortho2D(T left, T right, T bottom, T top){return ortho2DGTX(left, right, bottom, top);} //!< \brief Creates a matrix for projecting two-dimensional coordinates onto the screen (from GLM_GTX_matrix_projection extension) + template inline detail::_xmat4 ortho3D(T left, T right, T bottom, T top, T zNear, T zFar){return ortho2DGTX(left, right, bottom, top, zNear, zFar);} //!< \brief Creates a matrix for an orthographic parallel viewing volume (from GLM_GTX_matrix_projection extension) + template inline detail::_xmat4 perspective(T fovy, T aspect, T zNear, T zFar){return perspectiveGTX(fovy, aspect, zNear, zFar);} //!< \brief Creates a matrix for a symmetric perspective-view frustum (from GLM_GTX_matrix_projection extension) + template inline detail::_xmat4 infinitePerspective(T fovy, T aspect, T zNear){return infinitePerspectiveGTX(fovy, aspect, zNear);} //!< \brief Creates a matrix for a symmetric perspective-view frustum with far plane at infinite (from GLM_GTX_matrix_projection extension) + template inline detail::_xmat4 tweakedInfinitePerspective(T fovy, T aspect, T zNear){return tweakedInfinitePerspectiveGTX(fovy, aspect, zNear);} //!< \brief Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping (from GLM_GTX_matrix_projection extension) + template inline detail::_xvec3 project(const detail::_xvec3& obj, const detail::_xmat4& model, const detail::_xmat4& proj, const detail::_xvec4& viewport){return projectGTX(obj, model, proj, viewport);} //!< \brief Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates (from GLM_GTX_matrix_projection extension) + template inline detail::_xvec3 unProject(const detail::_xvec3& win, const detail::_xmat4& model, const detail::_xmat4& proj, const detail::_xvec4& viewport){return unProjectGTX(win, model, proj, viewport);} //!< \brief Map the specified window coordinates (win.x, win.y, win.z) into object coordinates (from GLM_GTX_matrix_projection extension) + } + } +} + +#define GLM_GTX_matrix_projection namespace gtx::matrix_projection + +#include "matrix_projection.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_matrix_projection;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_matrix_projection__ diff --git a/wip/sse/glm/ext/gtx/matrix_projection.inl b/wip/sse/glm/ext/gtx/matrix_projection.inl new file mode 100644 index 00000000..6d3512b8 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_projection.inl @@ -0,0 +1,135 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_projection.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat4 perspectiveGTX(T fovy, T aspect, T zNear, T zFar) + { + T range = tan(radians(fovy / 2)) * zNear; + T left = -range * aspect; + T right = range * aspect; + T bottom = -range; + T top = range; + + detail::_xmat4 Result(T(0)); + Result[0][0] = (2 * zNear) / (right - left); + Result[1][1] = (2 * zNear) / (top - bottom); + Result[2][2] = - (zFar + zNear) / (zFar - zNear); + Result[2][3] = -1; + Result[3][2] = - (2 * zFar * zNear) / (zFar - zNear); + return Result; + } + + template + inline detail::_xmat4 infinitePerspectiveGTX(T fovy, T aspect, T zNear) + { + T range = tan(radians(fovy / 2)) * zNear; + T left = -range * aspect; + T right = range * aspect; + T bottom = -range; + T top = range; + + detail::_xmat4 Result(T(0)); + Result[0][0] = (2 * zNear) / (right - left); + Result[1][1] = (2 * zNear) / (top - bottom); + Result[2][2] = -1; + Result[2][3] = -1; + Result[3][2] = - 2 * zNear; + return Result; + } + + template + inline detail::_xmat4 tweakedInfinitePerspectiveGTX(T fovy, T aspect, T zNear) + { + T range = tan(radians(fovy / 2)) * zNear; + T left = -range * aspect; + T right = range * aspect; + T bottom = -range; + T top = range; + + detail::_xmat4 Result(T(0)); + Result[0][0] = (2 * zNear) / (right - left); + Result[1][1] = (2 * zNear) / (top - bottom); + Result[2][2] = T(0.0001f) -1; + Result[2][3] = -1; + Result[3][2] = - (0.0001f - 2) * zNear; + return Result; + } + + template + inline detail::_xmat4 ortho2DGTX(T left, T right, T bottom, T top) + { + detail::_xmat4 Result(1); + Result[0][0] = 2 / (right - left); + Result[1][1] = 2 / (top - bottom); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + return Result; + } + + template + inline detail::_xmat4 ortho3DGTX(T left, T right, T bottom, T top, T zNear, T zFar) + { + detail::_xmat4 Result(1); + Result[0][0] = 2 / (right - left); + Result[1][1] = 2 / (top - bottom); + Result[2][2] = 2 / (zFar - zNear); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + Result[3][2] = - (zFar + zNear) / (zFar - zNear); + return Result; + } +/* + template + _xvec3 projectGTX(const _xvec3& obj, const _xmat4& model, const _xmat4& proj, const _xvec4& view) + { + _xvec4 v = proj * model * _xvec4(obj, 1); + return _xvec3(T(view.x) + T(view.z) * (v.x + 1) / 2, T(view.y) + T(view.w) * (v.y + 1) / 2, (v.z + 1) / 2); + } +*/ + template + inline detail::_xvec3 projectGTX(const detail::_xvec3& obj, const detail::_xmat4& model, const detail::_xmat4& proj, const detail::_xvec4& viewport) + { + detail::_xvec4 tmp = detail::_xvec4(obj, T(1.0)); + tmp = model * tmp; + tmp = proj * tmp; + + tmp /= tmp.w; + tmp = tmp * T(0.5) + T(0.5); + tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); + tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); + + return detail::_xvec3(tmp); + } +/* + template + _xvec3 unProjectGTX(const _xvec3& win, const _xmat4& model, const _xmat4& proj, const _xvec4& view) + { + _xvec4 v(2 * (win.x - T(view.x)) / view.z - 1, 2 * (win.y - T(view.y)) / view.w - 1, 2 * win.z - 1, 1); + return _xvec3(inverseGTX(proj * model) * v); + } +*/ + template + inline detail::_xvec3 unProjectGTX(const detail::_xvec3& win, const detail::_xmat4& model, const detail::_xmat4& proj, const detail::_xvec4& viewport) + { + detail::_xmat4 inverse = inverseGTX(proj * model); + + detail::_xvec4 tmp = detail::_xvec4(win, T(1)); + tmp.x = (tmp.x - viewport[0]) / viewport[2]; + tmp.y = (tmp.y - viewport[1]) / viewport[3]; + tmp = tmp * T(2) - T(1); + + detail::_xvec4 obj = inverse * tmp; + obj /= obj.w; + + return detail::_xvec3(obj); + } + +} diff --git a/wip/sse/glm/ext/gtx/matrix_query.h b/wip/sse/glm/ext/gtx/matrix_query.h new file mode 100644 index 00000000..f4149c11 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_query.h @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-05 +// Updated : 2007-03-05 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_query.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_matrix_query__ +#define __glm_gtx_matrix_query__ + +// Dependency: +#include "../../glm.h" +#include + +namespace glm +{ + template bool isNullGTX(const detail::_xmat2& m, const T epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix a null matrix (from GLM_GTX_matrix_query extension) + template bool isNullGTX(const detail::_xmat3& m, const T epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix a null matrix (from GLM_GTX_matrix_query extension) + template bool isNullGTX(const detail::_xmat4& m, const T epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix a null matrix (from GLM_GTX_matrix_query extension) + + template bool isIdentityGTX(const genType& m, const typename genType::value_type epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix an identity matrix (from GLM_GTX_matrix_query extension) + + template bool isNormalizedGTX(const detail::_xmat2& m, const T epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix a normalized matrix (from GLM_GTX_matrix_query extension) + template bool isNormalizedGTX(const detail::_xmat3& m, const T epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix a normalized matrix (from GLM_GTX_matrix_query extension) + template bool isNormalizedGTX(const detail::_xmat4& m, const T epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix a normalized matrix (from GLM_GTX_matrix_query extension) + + template bool isOrthogonalGTX(const genType& m, const typename genType::value_type epsilon = std::numeric_limits::epsilon()); //!< Return if a matrix an orthonormalized matrix (from GLM_GTX_matrix_query extension) + + namespace gtx + { + //! GLM_GTX_matrix_query: Query to evaluate matrices properties + namespace matrix_query + { + template inline bool isNull(const detail::_xmat2& m, const T epsilon = std::numeric_limits::epsilon()){return isNullGTX(m, epsilon);} //!< Return if a matrix a null matrix (from GLM_GTX_matrix_query extension) + template inline bool isNull(const detail::_xmat3& m, const T epsilon = std::numeric_limits::epsilon()){return isNullGTX(m, epsilon);} //!< Return if a matrix a null matrix (from GLM_GTX_matrix_query extension) + template inline bool isNull(const detail::_xmat4& m, const T epsilon = std::numeric_limits::epsilon()){return isNullGTX(m, epsilon);} //!< Return if a matrix a null matrix (from GLM_GTX_matrix_query extension) + + template inline bool isIdentity(const genType& m, const typename genType::value_type epsilon = std::numeric_limits::epsilon()){return isIdentityGTX(m, epsilon);} //!< Return if a matrix an identity matrix (from GLM_GTX_matrix_query extension) + + template inline bool isNormalized(const detail::_xmat2& m, const T epsilon = std::numeric_limits::epsilon()){return isNormalizedGTX(m, epsilon);} //!< Return if a matrix a normalized matrix (from GLM_GTX_matrix_query extension) + template inline bool isNormalized(const detail::_xmat3& m, const T epsilon = std::numeric_limits::epsilon()){return isNormalizedGTX(m, epsilon);} //!< Return if a matrix a normalized matrix (from GLM_GTX_matrix_query extension) + template inline bool isNormalized(const detail::_xmat4& m, const T epsilon = std::numeric_limits::epsilon()){return isNormalizedGTX(m, epsilon);} //!< Return if a matrix a normalized matrix (from GLM_GTX_matrix_query extension) + + template inline bool isOrthogonal(const genType& m, const typename genType::value_type epsilon = std::numeric_limits::epsilon()){return isOrthogonalGTX(m, epsilon);} //!< Return if a matrix an orthonormalized matrix (from GLM_GTX_matrix_query extension) + } + } +} + +#define GLM_GTX_matrix_query namespace gtx::matrix_query + +#include "matrix_query.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_matrix_query;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_matrix_query__ diff --git a/wip/sse/glm/ext/gtx/matrix_query.inl b/wip/sse/glm/ext/gtx/matrix_query.inl new file mode 100644 index 00000000..2341c5bb --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_query.inl @@ -0,0 +1,255 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-05 +// Updated : 2007-03-05 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_query.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ +/* + template + inline bool isNullGTX(const genType& m, const typename genType::value_type epsilon) + { + bool result = true; + for(genType::value_type i = genType::value_type(0); result && i < genType::col_size; ++i) + result = isNullGTX(m[i], epsilon); + return result; + } +*/ + template + inline bool isNullGTX(const detail::_xmat2& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 2 ; ++i) + result = isNull(m[i], epsilon); + return result; + } + + template + inline bool isNullGTX(const detail::_xmat3& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 3 ; ++i) + result = isNull(m[i], epsilon); + return result; + } + + template + inline bool isNullGTX(const detail::_xmat4& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 4 ; ++i) + result = isNull(m[i], epsilon); + return result; + } + + template + inline bool isIdentityGTX(const genType& m, const typename genType::value_type epsilon) + { + bool result = true; + for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size; ++i) + { + for(typename genType::value_type j = typename genType::value_type(0); result && j < i ; ++j) + result = abs(m[i][j]) <= epsilon; + if(result) + result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon; + for(typename genType::value_type j = i + typename genType::value_type(1); result && j < genType::row_size; ++j) + result = abs(m[i][j]) <= epsilon; + } + return result; + } +/* + template + inline bool isIdentityGTX(const _xmat2& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 2; ++i) + { + for(int j = 0; result && j < i ; ++j) + result = abs(m[i][j]) <= epsilon; + if(result) + result = abs(m[i][i] - T(1)) <= epsilon; + for(int j = i + 1; result && j < 2; ++j) + result = abs(m[i][j]) <= epsilon; + } + return result; + } + + template + inline bool isIdentityGTX(const _xmat3& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 3; ++i) + { + for(int j = 0; result && j < i ; ++j) + result = abs(m[i][j]) <= epsilon; + if(result) + result = abs(m[i][i] - T(1)) <= epsilon; + for(int j = i + 1; result && j < 3; ++j) + result = abs(m[i][j]) <= epsilon; + } + return result; + } + + template + inline bool isIdentityGTX(const _xmat4& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 4; ++i) + { + for(int j = 0; result && j < i ; ++j) + result = abs(m[i][j]) <= epsilon; + if(result) + result = abs(m[i][i] - T(1)) <= epsilon; + for(int j = i + 1; result && j < 4; ++j) + result = abs(m[i][j]) <= epsilon; + } + return result; + } +*/ +/* + template + inline bool isNormalizedGTX(const genType& m, const typename genType::value_type epsilon) + { + bool result = true; + for(genType::value_type i = genType::value_type(0); result && i < genType::col_size; ++i) + result = isNormalized(m[i], epsilon); + for(genType::value_type i = genType::value_type(0); result && i < genType::row_size; ++i) + { + vecType v; + for(genType::value_type j = genType::value_type(0); j < genType::col_size; ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; + } +*/ + + template + inline bool isNormalizedGTX(const detail::_xmat2& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 2; ++i) + result = isNormalized(m[i], epsilon); + for(int i = 0; result && i < 2; ++i) + { + detail::_xvec2 v; + for(int j = 0; j < 2; ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; + } + + template + inline bool isNormalizedGTX(const detail::_xmat3& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 3; ++i) + result = isNormalized(m[i], epsilon); + for(int i = 0; result && i < 3; ++i) + { + detail::_xvec3 v; + for(int j = 0; j < 3; ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; + } + + template + inline bool isNormalizedGTX(const detail::_xmat4& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 4; ++i) + result = isNormalized(m[i], epsilon); + for(int i = 0; result && i < 4; ++i) + { + detail::_xvec4 v; + for(int j = 0; j < 4; ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; + } + + template + inline bool isOrthogonalGTX(const genType& m, const typename genType::value_type epsilon) + { + bool result = true; + for(int i = 0; result && i < genType::col_size - 1; ++i) + for(int j= i + 1; result && j < genType::col_size; ++j) + result = areOrthogonal(m[i], m[j], epsilon); + + if(result) + { + genType tmp = transpose(m); + for(int i = 0; result && i < genType::col_size - 1 ; ++i) + for(int j = i + 1; result && j < genType::col_size; ++j) + result = areOrthogonal(tmp[i], tmp[j], epsilon); + } + return result; + } + +/* + template + inline bool isOrthogonalGTX(const _xmat2& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 2 - 1; ++i) + for(int j= i + 1; result && j < 2; ++j) + result = areOrthogonal(m[i], m[j], epsilon); + + if(result) + { + _xmat2 tmp = transpose(m); + for(int i = 0; result && i < 2 - 1 ; ++i) + for(int j = i + 1; result && j < 2; ++j) + result = areOrthogonal(tmp[i], tmp[j], epsilon); + } + return result; + } + + template + inline bool isOrthogonalGTX(const _xmat3& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 3 - 1; ++i) + for(int j= i + 1; result && j < 3; ++j) + result = areOrthogonal(m[i], m[j], epsilon); + + if(result) + { + _xmat3 tmp = transpose(m); + for(int i = 0; result && i < 3 - 1 ; ++i) + for(int j = i + 1; result && j < 3; ++j) + result = areOrthogonal(tmp[i], tmp[j], epsilon); + } + return result; + } + + template + inline bool isOrthogonalGTX(const _xmat4& m, const T epsilon) + { + bool result = true; + for(int i = 0; result && i < 4 - 1; ++i) + for(int j= i + 1; result && j < 4; ++j) + result = areOrthogonal(m[i], m[j], epsilon); + + if(result) + { + _xmat4 tmp = transpose(m); + for(int i = 0; result && i < 4 - 1 ; ++i) + for(int j = i + 1; result && j < 4; ++j) + result = areOrthogonal(tmp[i], tmp[j], epsilon); + } + return result; + } +*/ +} diff --git a/wip/sse/glm/ext/gtx/matrix_selection.h b/wip/sse/glm/ext/gtx/matrix_selection.h new file mode 100644 index 00000000..2760bcf5 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_selection.h @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_selection.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_matrix_selection__ +#define __glm_gtx_matrix_selection__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xvec2 rowGTX(const detail::_xmat2& m, int index); //!< \brief Returns a 2 components vector that contains the row of the matrix m witch values is the ones of the row index (from GLM_GTX_matrix_selection extension) + template detail::_xvec3 rowGTX(const detail::_xmat3& m, int index); //!< \brief Returns a 3 components vector that contains the row of the matrix m witch values is the ones of the row index (from GLM_GTX_matrix_selection extension) + template detail::_xvec4 rowGTX(const detail::_xmat4& m, int index); //!< \brief Returns a 4 components vector that contains the row of the matrix m witch values is the ones of the row index (from GLM_GTX_matrix_selection extension) + template detail::_xvec2 columnGTX(const detail::_xmat2& m, int index); //!< \brief Returns a 2 components vector that contains the row of the matrix m witch values is the ones of the column index (from GLM_GTX_matrix_selection extension) + template detail::_xvec3 columnGTX(const detail::_xmat3& m, int index); //!< \brief Returns a 3 components vector that contains the row of the matrix m witch values is the ones of the column index (from GLM_GTX_matrix_selection extension) + template detail::_xvec4 columnGTX(const detail::_xmat4& m, int index); //!< \brief Returns a 4 components vector that contains the row of the matrix m witch values is the ones of the column index (from GLM_GTX_matrix_selection extension) + + namespace gtx + { + //! GLM_GTX_matrix_selection extension: Access to matrix columns or rows. + namespace matrix_selection + { + template detail::_xvec2 row(const detail::_xmat2& m, int index){return rowGTX(m, index);} //!< \brief Returns a 2 components vector that contains the row of the matrix m witch values is the ones of the row index (from GLM_GTX_matrix_selection extension) + template detail::_xvec3 row(const detail::_xmat3& m, int index){return rowGTX(m, index);} //!< \brief Returns a 3 components vector that contains the row of the matrix m witch values is the ones of the row index (from GLM_GTX_matrix_selection extension) + template detail::_xvec4 row(const detail::_xmat4& m, int index){return rowGTX(m, index);} //!< \brief Returns a 4 components vector that contains the row of the matrix m witch values is the ones of the row index (from GLM_GTX_matrix_selection extension) + template detail::_xvec2 column(const detail::_xmat2& m, int index){return columnGTX(m, index);} //!< \brief Returns a 2 components vector that contains the row of the matrix m witch values is the ones of the column index (from GLM_GTX_matrix_selection extension) + template detail::_xvec3 column(const detail::_xmat3& m, int index){return columnGTX(m, index);} //!< \brief Returns a 3 components vector that contains the row of the matrix m witch values is the ones of the column index (from GLM_GTX_matrix_selection extension) + template detail::_xvec4 column(const detail::_xmat4& m, int index){return columnGTX(m, index);} //!< \brief Returns a 4 components vector that contains the row of the matrix m witch values is the ones of the column index (from GLM_GTX_matrix_selection extension) + } + } +} + +#define GLM_GTX_matrix_selection namespace gtx::matrix_selection + +#include "matrix_selection.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_matrix_selection;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_matrix_selection__ diff --git a/wip/sse/glm/ext/gtx/matrix_selection.inl b/wip/sse/glm/ext/gtx/matrix_selection.inl new file mode 100644 index 00000000..5d68cc01 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matrix_selection.inl @@ -0,0 +1,63 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matrix_selection.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ +/* + template + GLMrowType rowGTX(const genType& m, int index) + { + GLMrowType result; + for(typename genType::size_type i = 0; i < genType::row_size; ++i) + result[i] = m[i][index]; + return result; + } + + template + GLMcolType columnGTX(const genType& m, int index) + { + return m[index]; + } +*/ + template + inline detail::_xvec2 rowGTX(const detail::_xmat2& m, int index) + { + return detail::_xvec2(m[0][index], m[1][index]); + } + + template + inline detail::_xvec3 rowGTX(const detail::_xmat3& m, int index) + { + return detail::_xvec3(m[0][index], m[1][index], m[2][index]); + } + + template + inline detail::_xvec4 rowGTX(const detail::_xmat4& m, int index) + { + return detail::_xvec4(m[0][index], m[1][index], m[2][index], m[3][index]); + } + + template + inline detail::_xvec2 columnGTX(const detail::_xmat2& m, int index) + { + return m[index]; + } + + template + inline detail::_xvec3 columnGTX(const detail::_xmat3& m, int index) + { + return m[index]; + } + + template + inline detail::_xvec4 columnGTX(const detail::_xmat4& m, int index) + { + return m[index]; + } +} diff --git a/wip/sse/glm/ext/gtx/matx.h b/wip/sse/glm/ext/gtx/matx.h new file mode 100644 index 00000000..79b357e5 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matx.h @@ -0,0 +1,184 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-02-21 +// Updated : 2007-03-01 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matx.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_vecx +// - GLM_GTX_matrix_selection +// - GLM_GTX_matrix_access +// - GLM_GTX_mul +// - GLM_GTX_inverse_transpose +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_matx__ +#define __glm_gtx_matx__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/vecx.h" + +namespace glm{ +namespace detail{ + + template + class _xmatxGTX + { + private: + // Data + _xvecxGTX value[N]; + + public: + _xmatxGTX _inverse() const; + + public: + typedef T value_type; + typedef int size_type; + static const size_type value_size; + + // Constructors + _xmatxGTX(); + explicit _xmatxGTX(const T x); + + // Accesses + _xvecxGTX& operator[](int i) {return value[i];} + const _xvecxGTX & operator[](int i) const {return value[i];} + operator T*() {return &value[0][0];} + operator const T*() const {return &value[0][0];} + + // Unary updatable operators + _xmatxGTX& operator= (const _xmatxGTX& m); + _xmatxGTX& operator+= (const T s); + _xmatxGTX& operator+= (const _xmatxGTX& m); + _xmatxGTX& operator-= (const T s); + _xmatxGTX& operator-= (const _xmatxGTX& m); + _xmatxGTX& operator*= (const T s); + _xmatxGTX& operator*= (const _xmatxGTX& m); + _xmatxGTX& operator/= (const T s); + _xmatxGTX& operator/= (const _xmatxGTX& m); + _xmatxGTX& operator++ (); + _xmatxGTX& operator-- (); + }; + + // Binary operators + template + _xmatxGTX operator+ (const _xmatxGTX& m, const T s); + + template + _xmatxGTX operator+ (const T s, const _xmatxGTX& m); + + template + _xvecxGTX operator+ (const _xmatxGTX& m, const _xvecxGTX& v); + + template + _xvecxGTX operator+ (const _xvecxGTX& v, const _xmatxGTX& m); + + template + _xmatxGTX operator+ (const _xmatxGTX& m1, const _xmatxGTX& m2); + + template + _xmatxGTX operator- (const _xmatxGTX& m, const T s); + + template + _xmatxGTX operator- (const T s, const _xmatxGTX& m); + + template + _xvecxGTX operator- (const _xmatxGTX& m, const _xvecxGTX& v); + + template + _xvecxGTX operator- (const _xvecxGTX& v, const _xmatxGTX& m); + + template + _xmatxGTX operator- (const _xmatxGTX& m1, const _xmatxGTX& m2); + + template + _xmatxGTX operator* (const _xmatxGTX& m, const T s); + + template + _xmatxGTX operator* (const T s, const _xmatxGTX& m); + + template + _xvecxGTX operator* (const _xmatxGTX& m, const _xvecxGTX& v); + + template + _xvecxGTX operator* (const _xvecxGTX& v, const _xmatxGTX& m); + + template + _xmatxGTX operator* (const _xmatxGTX& m1, const _xmatxGTX& m2); + + template + _xmatxGTX operator/ (const _xmatxGTX& m, const T s); + + template + _xmatxGTX operator/ (const T s, const _xmatxGTX& m); + + template + _xvecxGTX operator/ (const _xmatxGTX& m, const _xvecxGTX& v); + + template + _xvecxGTX operator/ (const _xvecxGTX& v, const _xmatxGTX& m); + + template + _xmatxGTX operator/ (const _xmatxGTX& m1, const _xmatxGTX& m2); + + // Unary constant operators + template + const _xmatxGTX operator- (const _xmatxGTX& m); + + template + const _xmatxGTX operator-- (const _xmatxGTX& m, int); + + template + const _xmatxGTX operator++ (const _xmatxGTX& m, int); + +}//namespace detail + + // Extension functions + template detail::_xmatxGTX matrixCompMultGTX(const detail::_xmatxGTX& x, const detail::_xmatxGTX& y); //!< Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (from GLM_GTX_matx extension) + template detail::_xmatxGTX outerProductGTX(const detail::_xvecxGTX& c, const detail::_xvecxGTX& r); //!< Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (from GLM_GTX_matx extension) + template detail::_xmatxGTX transposeGTX(const detail::_xmatxGTX& x); //!< Returns the transposed matrix of x. (from GLM_GTX_matx extension) + + template T determinantGTX(const detail::_xmatxGTX& m); //!< Returns the determinant of a 2 * 2 matrix. (from GLM_GTX_matx extension) + template detail::_xmatxGTX inverseTransposeGTX(const detail::_xmatxGTX & m); //!< Compute the inverse of a transformation 4x4 matrix (From GLM_GTX_matx extension) + + template void columnGTX(detail::_xmatxGTX& m, int ColIndex, const detail::_xvecxGTX& v); //!< Set a specific column to a matrix (From GLM_GTX_matx extension) + template void rowGTX(detail::_xmatxGTX& m, int RowIndex, const detail::_xvecxGTX& v); //!< Set a specific row to a matrix (From GLM_GTX_matx extension) + + template detail::_xvecxGTX columnGTX(const detail::_xmatxGTX& m, int ColIndex); //!< Get a specific column to a matrix (From GLM_GTX_matx extension) + template detail::_xvecxGTX rowGTX(const detail::_xmatxGTX& m, int RowIndex); //!< Get a specific row to a matrix (From GLM_GTX_matx extension) + + namespace gtx + { + //! GLM_GTX_matx extension: - Work in progress - NxN matrix types. + namespace matx + { + // Matrix Functions + template inline detail::_xmatxGTX matrixCompMult(const detail::_xmatxGTX& x, const detail::_xmatxGTX& y){return matrixCompMult(x, y);} //!< Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j]. (from GLM_GTX_matx extension) + template inline detail::_xmatxGTX outerProduct(const detail::_xvecxGTX& c, const detail::_xvecxGTX& r){return outerProductGTX(c, r);} //!< Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r. (from GLM_GTX_matx extension) + template inline detail::_xmatxGTX transpose(const detail::_xmatxGTX& x){return transposeGTX(x);} //!< Returns the transposed matrix of x. (from GLM_GTX_matx extension) + + template inline T determinant(const detail::_xmatxGTX& m){return determinantGTX(m);} //!< Returns the determinant of a 2 * 2 matrix. (from GLM_GTX_matx extension) + template inline detail::_xmatxGTX inverseTranspose(const detail::_xmatxGTX& m){return inverseTransposeGTX(m);} //!< Compute the inverse of a transformation 4x4 matrix (From GLM_GTX_matx extension) + + template inline void column(detail::_xmatxGTX& m, int ColIndex, const detail::_xvecxGTX& v){setColumnGTX(m, v);} //!< Set a specific column to a matrix (From GLM_GTX_matx extension) + template inline void row(detail::_xmatxGTX& m, int RowIndex, const detail::_xvecxGTX& v){setRowGTX(m, v);} //!< Set a specific row to a matrix (From GLM_GTX_matx extension) + + template inline detail::_xvecxGTX column(const detail::_xmatxGTX& m, int ColIndex){return column(m, ColIndex);} //!< Get a specific column to a matrix (From GLM_GTX_matx extension) + template inline detail::_xvecxGTX row(const detail::_xmatxGTX& m, int RowIndex){return row(m, RowIndex);} //!< Get a specific row to a matrix (From GLM_GTX_matx extension) + } + } +} + +#define GLM_GTX_matx namespace gtx::matx + +#include "matx.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_matx;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_matx__ diff --git a/wip/sse/glm/ext/gtx/matx.inl b/wip/sse/glm/ext/gtx/matx.inl new file mode 100644 index 00000000..62e85720 --- /dev/null +++ b/wip/sse/glm/ext/gtx/matx.inl @@ -0,0 +1,479 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-02-21 +// Updated : 2007-02-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/matx.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +namespace glm{ +namespace detail{ + + template const typename _xmatxGTX::size_type _xmatxGTX::value_size = N; + + ////////////////////////////////////////////////////////////// + // _xmatxGTX constructors + + template + inline _xmatxGTX::_xmatxGTX() + { + for(int i = 0; i < N; ++i) + this->value[i][i] = T(0); + } + + template + inline _xmatxGTX::_xmatxGTX(const T f) + { + for(int i = 0; i < N; ++i) + this->value[i][i] = f; + } + + ////////////////////////////////////////////////////////////// + // _xmatxGTX operators + + // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared + template + inline _xmatxGTX& _xmatxGTX::operator= (const _xmatxGTX& m) + { + //memcpy could be faster + //memcpy(&this->value, &m.value, 16 * sizeof(T)); + for(int i = 0; i < N; ++i) + this->value[i] = m[i]; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator+= (const T s) + { + for(int i = 0; i < N; ++i) + this->value[i] += s; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator+= (const _xmatxGTX& m) + { + for(int i = 0; i < N; ++i) + this->value[i] += m[i]; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator-= (const T s) + { + for(int i = 0; i < N; ++i) + this->value[i] -= s; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator-= (const _xmatxGTX& m) + { + for(int i = 0; i < N; ++i) + this->value[i] -= m[i]; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator*= (const T s) + { + for(int i = 0; i < N; ++i) + this->value[i] *= s; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator*= (const _xmatxGTX& m) + { + return (*this = *this * m); + } + + template + inline _xmatxGTX& _xmatxGTX::operator/= (const T s) + { + for(int i = 0; i < N; ++i) + this->value[i] /= s; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator/= (const _xmatxGTX& m) + { + return (*this = *this / m); + } + + template + inline _xmatxGTX& _xmatxGTX::operator-- () + { + for(int i = 0; i < N; ++i) + --this->value[i]; + return *this; + } + + template + inline _xmatxGTX& _xmatxGTX::operator++ () + { + for(int i = 0; i < N; ++i) + ++this->value[i]; + return *this; + } + + // Private functions + template + inline _xmatxGTX _xmatxGTX::_inverse() const + { + _xmatxGTX Result = *this; + + int ColIndex[N]; + int RowIndex[N]; + bool Pivoted[N]; + memset(ColIndex, 0, N * sizeof(int)); + memset(RowIndex, 0, N * sizeof(int)); + memset(Pivoted, 0, N * sizeof(bool)); + + int iRow = 0, iCol = 0; + + // elimination by full pivoting + for(int i0 = 0; i0 < N; i0++) + { + // search matrix (excluding pivoted rows) for maximum absolute entry + T fMax = T(0); + for(int i1 = 0; i1 < N; i1++) + { + if(Pivoted[i1]) + continue; + + for(int i2 = 0; i2 < N; i2++) + { + if(Pivoted[i2]) + continue; + + T Abs = abs(Result[i1][i2]); + if(Abs > fMax) + { + fMax = Abs; + iRow = i1; + iCol = i2; + } + } + } + + if(fMax == T(0)) + { + return _xmatxGTX(1.0f); // Error + } + + Pivoted[iCol] = true; + + // swap rows so that A[iCol][iCol] contains the pivot entry + if(iRow != iCol) + { + _xvecxGTX Row = rowGTX(Result, iRow); + _xvecxGTX Col = rowGTX(Result, iCol); + rowGTX(Result, iRow, Col); + rowGTX(Result, iCol, Row); + } + + // keep track of the permutations of the rows + RowIndex[i0] = iRow; + ColIndex[i0] = iCol; + + // scale the row so that the pivot entry is 1 + T fInv = T(1) / Result[iCol][iCol]; + Result[iCol][iCol] = T(1); + for(int i2 = 0; i2 < N; i2++) + Result[iCol][i2] *= fInv; + + // zero out the pivot column locations in the other rows + for(int i1 = 0; i1 < N; ++i1) + { + if(i1 == iCol) + continue; + + T Tmp = Result[i1][iCol]; + Result[i1][iCol] = T(0); + for(int i2 = 0; i2 < N; i2++) + Result[i1][i2] -= Result[iCol][i2] * Tmp; + } + } + + // reorder rows so that A[][] stores the inverse of the original matrix + for(int i1 = N-1; i1 >= 0; --i1) + { + if(RowIndex[i1] == ColIndex[i1]) + continue; + for(int i2 = 0; i2 < N; ++i2) + std::swap(Result[i2][RowIndex[i1]], Result[i2][ColIndex[i1]]); + } + + return Result; + } + + // Binary operators + template + inline _xmatxGTX operator+ (const _xmatxGTX& m, const T s) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m[i] + s; + return result; + } + + template + inline _xmatxGTX operator+ (const T s, const _xmatxGTX& m) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = s + m[i]; + return result; + } +/* + template + inline _xvec4 operator+ (const _xmatxGTX& m, const _xvec4& v) + { + + } + + template + inline _xvec4 operator+ (const _xvec4& v, const _xmatxGTX& m) + { + + } +*/ + template + inline _xmatxGTX operator+ (const _xmatxGTX& m1, const _xmatxGTX& m2) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m1[i] + m2[i]; + return result; + } + + template + inline _xmatxGTX operator- (const _xmatxGTX& m, const T s) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m[i] - s; + return result; + } + + template + inline _xmatxGTX operator- (const T s, const _xmatxGTX& m) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = s - m[i]; + return result; + } +/* + template + inline _xvec4 operator- (const _xmatxGTX& m, const _xvec4& v) + { + + } + + template + inline _xvec4 operator- (const _xvec4& v, const _xmatxGTX& m) + { + + } +*/ + template + inline _xmatxGTX operator- (const _xmatxGTX& m1, const _xmatxGTX& m2) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m1[i] - m2[i]; + return result; + } + + template + inline _xmatxGTX operator* (const _xmatxGTX& m, const T s) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m[i] * s; + return result; + } + + template + inline _xmatxGTX operator* (const T s, const _xmatxGTX& m) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = s * m[i]; + return result; + } + + template + inline _xvecxGTX operator* (const _xmatxGTX& m, const _xvecxGTX& v) + { + _xvecxGTX result(T(0)); + for(int j = 0; j < N; ++j) + for(int i = 0; i < N; ++i) + result[j] += m[i][j] * v[i]; + return result; + } + + template + inline _xvecxGTX operator* (const _xvecxGTX& v, const _xmatxGTX& m) + { + _xvecxGTX result(T(0)); + for(int j = 0; j < N; ++j) + for(int i = 0; i < N; ++i) + result[j] += m[j][i] * v[i]; + return result; + } + + template + inline _xmatxGTX operator* (const _xmatxGTX& m1, const _xmatxGTX& m2) + { + _xmatxGTX Result(T(0)); + for(int k = 0; k < N; ++k) + for(int j = 0; j < N; ++j) + for(int i = 0; i < N; ++i) + Result[k][j] += m1[i][j] * m2[k][i]; + return Result; + } + + template + inline _xmatxGTX operator/ (const _xmatxGTX& m, const T s) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m[i] / s; + return result; + } + + template + inline _xmatxGTX operator/ (const T s, const _xmatxGTX& m) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = s / m[i]; + return result; + } + + template + inline _xvecxGTX operator/ (const _xmatxGTX& m, const _xvecxGTX& v) + { + return m._inverse() * v; + } + + template + inline _xvecxGTX operator/ (const _xvecxGTX& v, const _xmatxGTX& m) + { + return v * m._inverse(); + } + + template + inline _xmatxGTX operator/ (const _xmatxGTX& m1, const _xmatxGTX& m2) + { + return m1 * m2._inverse(); + } + + // Unary constant operators + template + inline const _xmatxGTX operator- (const _xmatxGTX& m) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = -m[i]; + return result; + } + + template + inline const _xmatxGTX operator++ (const _xmatxGTX& m, int) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m[i] + T(1); + return result; + } + + template + inline const _xmatxGTX operator-- (const _xmatxGTX& m, int) + { + _xmatxGTX result; + for(int i = 0; i < N; ++i) + result[i] = m[i] - T(1); + return result; + } +}//namespace detail + + // Matrix Functions + template + inline detail::_xmatxGTX matrixCompMultGTX(const detail::_xmatxGTX& x, const detail::_xmatxGTX& y) + { + detail::_xmatxGTX result; + for(int j = 0; j < N; ++j) + for(int i = 0; i < N; ++i) + result[j][i] = x[j][i] * y[j][i]; + return result; + } + + template + inline detail::_xmatxGTX outerProductGTX(const detail::_xvecxGTX& c, const detail::_xvecxGTX& r) + { + detail::_xmatxGTX result; + for(int j = 0; j < N; ++j) + for(int i = 0; i < N; ++i) + result[j][i] = c[i] * r[j]; + return result; + } + + template + inline detail::_xmatxGTX transposeGTX(const detail::_xmatxGTX& m) + { + detail::_xmatxGTX result; + for(int j = 0; j < N; ++j) + for(int i = 0; i < N; ++i) + result[j][i] = m[i][j]; + return result; + } + + template + inline T determinantGTX(const detail::_xmatxGTX& m) + { + + } + + template + inline detail::_xmatxGTX inverseTransposeGTX(const detail::_xmatxGTX& m) + { + + } + + template + inline void columnGTX(detail::_xmatxGTX& m, int ColIndex, const detail::_xvecxGTX& v) + { + m[ColIndex] = v; + } + + template + inline void rowGTX(detail::_xmatxGTX& m, int RowIndex, const detail::_xvecxGTX& v) + { + for(int i = 0; i < N; ++i) + m[i][RowIndex] = v[i]; + } + + template + inline detail::_xvecxGTX columnGTX(const detail::_xmatxGTX& m, int ColIndex) + { + return m[ColIndex]; + } + + template + inline detail::_xvecxGTX rowGTX(const detail::_xmatxGTX& m, int RowIndex) + { + detail::_xvecxGTX v; + for(int i = 0; i < N; ++i) + v[i] = m[i][RowIndex]; + return v; + } +} //namespace glm diff --git a/wip/sse/glm/ext/gtx/mixed_product.h b/wip/sse/glm/ext/gtx/mixed_product.h new file mode 100644 index 00000000..1c37cc2c --- /dev/null +++ b/wip/sse/glm/ext/gtx/mixed_product.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-04-03 +// Updated : 2007-04-03 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/mixed_product.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_mixed_product__ +#define __glm_gtx_mixed_product__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + //! Mixed product of 3 vectors (from GLM_GTX_mixed_product extension) + template + GLMvalType mixedProductGTX( + const genType& v1, + const genType& v2, + const genType& v3); + + namespace gtx + { + //! GLM_GTX_mixed_product extension: Mixed product of 3 vectors. + namespace mixed_product + { + //! Mixed product of 3 vectors (from GLM_GTX_mixed_product extension) + template + inline GLMvalType mixedProduct( + const genType& v1, + const genType& v2, + const genType& v3) + { + return mixedProductGTX(v1, v2, v3); + } + } + } +} + +#define GLM_GTX_mixed_product namespace gtx::mixed_product + +#include "mixed_product.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_mixed_product;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_mixed_product__ diff --git a/wip/sse/glm/ext/gtx/mixed_product.inl b/wip/sse/glm/ext/gtx/mixed_product.inl new file mode 100644 index 00000000..18258d40 --- /dev/null +++ b/wip/sse/glm/ext/gtx/mixed_product.inl @@ -0,0 +1,28 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-04-03 +// Updated : 2007-04-03 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/mixed_product.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline GLMvalType mixedProductGTX( + const genType& v1, + const genType& v2, + const genType& v3) + { + return dot(cross(v1, v2), v3); + } +} + + + + + + + + diff --git a/wip/sse/glm/ext/gtx/mul.h b/wip/sse/glm/ext/gtx/mul.h new file mode 100644 index 00000000..b410873f --- /dev/null +++ b/wip/sse/glm/ext/gtx/mul.h @@ -0,0 +1,48 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-20 +// Updated : 2007-04-04 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/mul.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Comment: +// - Extension for Cg compatibility +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_mul__ +#define __glm_gtx_mul__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template genType mulGTX(const genType& a, const genType& b); //!< Product of 2 matrices (From GLM_GTX_mul extension) + template GLMcolType mulGTX(const genType& m, const GLMcolType& v); //!< Product of a matrix and a vector (From GLM_GTX_mul extension) + template GLMcolType mulGTX(const GLMcolType& v, const genType& m); //!< Product of a vector and a matrix (From GLM_GTX_mul extension) + + namespace gtx + { + //! GLM_GTX_mul extension: mul function for Cg and HLSL compatibility. + namespace mul + { + template inline genType mul(const genType& a, const genType& b); //!< Product of 2 matrices (From GLM_GTX_mul extension) + template inline GLMcolType mul(const genType& m, const GLMcolType& v); //!< Product of a matrix and a vector (From GLM_GTX_mul extension) + template inline GLMcolType mul(const GLMcolType& v, const genType& m); //!< Product of a vector and a matrix (From GLM_GTX_mul extension) + } + } +} + +#define GLM_GTX_mul namespace gtx::mul + +#include "mul.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_mul;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_mul__ diff --git a/wip/sse/glm/ext/gtx/mul.inl b/wip/sse/glm/ext/gtx/mul.inl new file mode 100644 index 00000000..e58c7aa8 --- /dev/null +++ b/wip/sse/glm/ext/gtx/mul.inl @@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-20 +// Updated : 2007-04-04 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/mul.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline genType mulGTX(const genType& a, const genType& b) + { + return a * b; + } + + template + inline GLMcolType mulGTX(const genType& m, const GLMcolType& v) + { + return m * v; + } + + template + inline GLMcolType mulGTX(const GLMcolType& v, const genType& m) + { + return v * m; + } +} + +/* + template + inline _xmat2 mulGTX(const _xmat2& a, const _xmat2& b) + { + return a * b; + } + + template + inline _xmat3 mulGTX(const _xmat3& a, const _xmat3& b) + { + return a * b; + } + + template + inline _xmat4 mulGTX(const _xmat4& a, const _xmat4& b) + { + return a * b; + } + + template + inline _xvec2 mulGTX(const _xmat2& m, const _xvec2& v) + { + return m * v; + } + + template + inline _xvec3 mulGTX(const _xmat3& m, const _xvec3& v) + { + return m * v; + } + + template + inline _xvec4 mulGTX(const _xmat4& m, const _xvec4& v) + { + return m * v; + } + + template + inline _xvec2 mulGTX(const _xvec2& v, const _xmat2& m) + { + return v * m; + } + + template + inline _xvec3 mulGTX(const _xvec3& v, const _xmat3& m) + { + return v * m; + } + + template + inline _xvec4 mulGTX(const _xvec4& v, const _xmat4& m) + { + return v * m; + } +*/ diff --git a/wip/sse/glm/ext/gtx/norm.h b/wip/sse/glm/ext/gtx/norm.h new file mode 100644 index 00000000..d1b7aee6 --- /dev/null +++ b/wip/sse/glm/ext/gtx/norm.h @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/norm.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_quaternion +// - GLM_GTX_double +/////////////////////////////////////////////////////////////////////////////////////////////////// +// ToDo: +// - Study the validity of the notion of length2 to quaternion +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_norm__ +#define __glm_gtx_norm__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/double.h" +#include "../gtx/quaternion.h" + +namespace glm +{ + template T length2GTX(const T x); //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template T length2GTX(const detail::_xvec2& x); //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template T length2GTX(const detail::_xvec3& x); //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template T length2GTX(const detail::_xvec4& x); //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template T length2GTX(const detail::_xquat& q); //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template T l1NormGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Returns the L1 norm between x and y (from GLM_GTX_norm extension) + + namespace gtx + { + //! GLM_GTX_norm extension: Varius way to compute vector norms. + namespace norm + { + template inline T length2(const T x){return length2GTX(x);} //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template inline T length2(const detail::_xvec2& x){return length2GTX(x);} //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template inline T length2(const detail::_xvec3& x){return length2GTX(x);} //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template inline T length2(const detail::_xvec4& x){return length2GTX(x);} //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template inline T length2(const detail::_xquat& q){return length2GTX(q);} //!< \brief Returns the squared length of x (from GLM_GTX_norm extension) + template inline T l1Norm(const detail::_xvec3& x, const detail::_xvec3& y){return l1NormGTX(x, y);} //!< \brief Returns the L1 norm between x and y (from GLM_GTX_norm extension) + } + } +} + +#define GLM_GTX_norm namespace gtx::norm + +#include "norm.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_norm;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_norm__ diff --git a/wip/sse/glm/ext/gtx/norm.inl b/wip/sse/glm/ext/gtx/norm.inl new file mode 100644 index 00000000..07097501 --- /dev/null +++ b/wip/sse/glm/ext/gtx/norm.inl @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/norm.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline T length2GTX(const T x) + { + return x * x; + } + + template + inline T length2GTX(const detail::_xvec2& x) + { + return dot(x, x); + } + + template + inline T length2GTX(const detail::_xvec3& x) + { + return dot(x, x); + } + + template + inline T length2GTX(const detail::_xvec4& x) + { + return dot(x, x); + } + + template + inline T length2GTX(const detail::_xquat& q) + { + return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w; + } + + template + inline T l1NormGTX(const detail::_xvec3& a, const detail::_xvec3& b) + { + return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z); + } +} diff --git a/wip/sse/glm/ext/gtx/normal.h b/wip/sse/glm/ext/gtx/normal.h new file mode 100644 index 00000000..6dca85a2 --- /dev/null +++ b/wip/sse/glm/ext/gtx/normal.h @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/normal.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_normal__ +#define __glm_gtx_normal__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template _xvec3 triangleNormalGTX(const _xvec3& p1, const _xvec3& p2, const _xvec3& p3); //!< /brief Computes triangle normal from triangle points. (from GLM_GTX_normal extension) + + namespace gtx + { + //! GLM_GTX_normal extension: Compute the normal of a triangle. + namespace normal + { + template inline _xvec3 triangleNormal(const _xvec3& p1, const _xvec3& p2, const _xvec3& p3){return triangleNormalGTX(p1, p2, p3);} //!< /brief Computes triangle normal from triangle points. (from GLM_GTX_normal extension) + } + } +} + +#define GLM_GTX_normal namespace gtx::normal + +#include "normal.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_normal;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_normal__ diff --git a/wip/sse/glm/ext/gtx/normal.inl b/wip/sse/glm/ext/gtx/normal.inl new file mode 100644 index 00000000..2b50cc84 --- /dev/null +++ b/wip/sse/glm/ext/gtx/normal.inl @@ -0,0 +1,17 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/normal.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline _xvec3 triangleNormalGTX(const _xvec3& p1, const _xvec3& p2, const _xvec3& p3) + { + return normalize(cross(p1 - p2, p1 - p3)); + } +} diff --git a/wip/sse/glm/ext/gtx/normalize_dot.h b/wip/sse/glm/ext/gtx/normalize_dot.h new file mode 100644 index 00000000..a12c1042 --- /dev/null +++ b/wip/sse/glm/ext/gtx/normalize_dot.h @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-09-28 +// Updated : 2008-01-05 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/normalize_dot.h +////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_fast_square_root +////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_normalize_dot__ +#define __glm_gtx_normalize_dot__ + +// Dependency: +#include "../../glm.h" +#include "../../ext/gtx/fast_square_root.h" + +namespace glm +{ + template T normalizeDotGTX(T x, T y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + template T normalizeDotGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + template T normalizeDotGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + template T normalizeDotGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + + template T fastNormalizeDotGTX(T x, T y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + template T fastNormalizeDotGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + template T fastNormalizeDotGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + template T fastNormalizeDotGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + + namespace gtx + { + //! GLM_GTX_normalize_dot extension: Dot product of vectors that need to be normalize with a single square root. + namespace normalize_dot + { + template T normalizeDot(T x, T y){normalizeDotGTX(x, y);} //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + template T fastNormalizeDot(T x, T y){fastNormalizeDotGTX(x, y);} //!< \brief Normalize parameters and returns the dot product of x and y, faster that dot(normalize(x), normalize(y)) (From GLM_GTX_normalize_dot extension) + } + } +} + +#define GLM_GTX_normalize_dot namespace gtx::normalize_dot + +#include "normalize_dot.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_normalize_dot;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_normalize_dot__ diff --git a/wip/sse/glm/ext/gtx/normalize_dot.inl b/wip/sse/glm/ext/gtx/normalize_dot.inl new file mode 100644 index 00000000..0c8f5c74 --- /dev/null +++ b/wip/sse/glm/ext/gtx/normalize_dot.inl @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-09-28 +// Updated : 2007-09-28 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/normalize_dot.inl +////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template T normalizeDotGTX(T x, T y) + { + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); + } + + template T normalizeDotGTX(const detail::_xvec2& x, const detail::_xvec2& y) + { + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); + } + + template T normalizeDotGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); + } + + template T normalizeDotGTX(const detail::_xvec4& x, const detail::_xvec4& y) + { + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); + } + + template T fastNormalizeDotGTX(T x, T y) + { + return glm::dot(x, y) * glm::fastInverseSqrtGTX(glm::dot(x, x) * glm::dot(y, y)); + } + + template T fastNormalizeDotGTX(const detail::_xvec2& x, const detail::_xvec2& y) + { + return glm::dot(x, y) * glm::fastInverseSqrtGTX(glm::dot(x, x) * glm::dot(y, y)); + } + + template T fastNormalizeDotGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return glm::dot(x, y) * glm::fastInverseSqrtGTX(glm::dot(x, x) * glm::dot(y, y)); + } + + template T fastNormalizeDotGTX(const detail::_xvec4& x, const detail::_xvec4& y) + { + return glm::dot(x, y) * glm::fastInverseSqrtGTX(glm::dot(x, x) * glm::dot(y, y)); + } +} diff --git a/wip/sse/glm/ext/gtx/number_precision.h b/wip/sse/glm/ext/gtx/number_precision.h new file mode 100644 index 00000000..eb8cb3f5 --- /dev/null +++ b/wip/sse/glm/ext/gtx/number_precision.h @@ -0,0 +1,265 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-10 +// Updated : 2007-05-10 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/number_precision.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_half +// - GLM_GTX_double +// - GLM_GTX_integer +// - GLM_GTX_unsigned_integer +// - GLM_GTX_quaternion +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_number_precision__ +#define __glm_gtx_number_precision__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/half.h" +#include "../gtx/double.h" +#include "../gtx/integer.h" +#include "../gtx/unsigned_int.h" +#include "../gtx/quaternion.h" + +namespace glm +{ + typedef signed char __int8GTX; //!< 8bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed short __int16GTX; //!< 16bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed int __int32GTX; //!< 32bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed long long __int64GTX; //!< 64bit signed integer. (from GLM_GTX_number_precision extension) + + typedef signed char __i8GTX; //!< 8bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed short __i16GTX; //!< 16bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed int __i32GTX; //!< 32bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed long long __i64GTX; //!< 64bit signed integer. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __i8vec2GTX; //!< 8bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __i8vec3GTX; //!< 8bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __i8vec4GTX; //!< 8bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __i16vec2GTX; //!< 16bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __i16vec3GTX; //!< 16bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __i16vec4GTX; //!< 16bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __i32vec2GTX; //!< 32bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __i32vec3GTX; //!< 32bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __i32vec4GTX; //!< 32bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __i64vec2GTX; //!< 64bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __i64vec3GTX; //!< 64bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __i64vec4GTX; //!< 64bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef unsigned char __uint8GTX; //!< 8bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned short __uint16GTX; //!< 16bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned int __uint32GTX; //!< 32bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned long long __uint64GTX; //!< 64bit unsigned integer. (from GLM_GTX_number_precision extension) + + typedef unsigned char __u8GTX; //!< 8bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned short __u16GTX; //!< 16bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned int __u32GTX; //!< 32bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned long long __u64GTX; //!< 64bit unsigned integer. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __u8vec2GTX; //!< 8bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __u8vec3GTX; //!< 8bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __u8vec4GTX; //!< 8bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __u16vec2GTX; //!< 16bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __u16vec3GTX; //!< 16bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __u16vec4GTX; //!< 16bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __u32vec2GTX; //!< 32bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __u32vec3GTX; //!< 32bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __u32vec4GTX; //!< 32bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __u64vec2GTX; //!< 64bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __u64vec3GTX; //!< 64bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __u64vec4GTX; //!< 64bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef __halfGTX __float16GTX; //!< Half-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef float __float32GTX; //!< Single-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef double __float64GTX; //!< Double-precision floating-point number. (from GLM_GTX_number_precision extension) + + typedef __halfGTX __f16GTX; //!< Half-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef float __f32GTX; //!< Single-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef double __f64GTX; //!< Double-precision floating-point number. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2<__halfGTX> __f16vec2GTX; //!< Half-precision floating-point vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3<__halfGTX> __f16vec3GTX; //!< Half-precision floating-point vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4<__halfGTX> __f16vec4GTX; //!< Half-precision floating-point vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __f32vec2GTX; //!< Single-precision floating-point vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __f32vec3GTX; //!< Single-precision floating-point vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __f32vec4GTX; //!< Single-precision floating-point vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 __f64vec2GTX; //!< Double-precision floating-point vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 __f64vec3GTX; //!< Double-precision floating-point vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 __f64vec4GTX; //!< Double-precision floating-point vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2<__halfGTX> __f16mat2GTX; //!< Half-precision floating-point 2x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3<__halfGTX> __f16mat3GTX; //!< Half-precision floating-point 3x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4<__halfGTX> __f16mat4GTX; //!< Half-precision floating-point 4x4 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2x3<__halfGTX> __f16mat2x3GTX; //!< Half-precision floating-point 2x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat2x4<__halfGTX> __f16mat2x4GTX; //!< Half-precision floating-point 2x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x2<__halfGTX> __f16mat3x2GTX; //!< Half-precision floating-point 3x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x4<__halfGTX> __f16mat3x4GTX; //!< Half-precision floating-point 3x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x2<__halfGTX> __f16mat4x2GTX; //!< Half-precision floating-point 4x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x3<__halfGTX> __f16mat4x3GTX; //!< Half-precision floating-point 4x3 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2 __f32mat2GTX; //!< Single-precision floating-point 2x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3 __f32mat3GTX; //!< Single-precision floating-point 3x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4 __f32mat4GTX; //!< Single-precision floating-point 4x4 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2x3 __f32mat2x3GTX; //!< Single-precision floating-point 2x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat2x4 __f32mat2x4GTX; //!< Single-precision floating-point 2x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x2 __f32mat3x2GTX; //!< Single-precision floating-point 3x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x4 __f32mat3x4GTX; //!< Single-precision floating-point 3x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x2 __f32mat4x2GTX; //!< Single-precision floating-point 4x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x3 __f32mat4x3GTX; //!< Single-precision floating-point 4x3 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2 __f64mat2GTX; //!< Double-precision floating-point 2x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3 __f64mat3GTX; //!< Double-precision floating-point 3x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4 __f64mat4GTX; //!< Double-precision floating-point 4x4 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2x3 __f64mat2x3GTX; //!< Double-precision floating-point 2x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat2x4 __f64mat2x4GTX; //!< Double-precision floating-point 2x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x2 __f64mat3x2GTX; //!< Double-precision floating-point 3x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x4 __f64mat3x4GTX; //!< Double-precision floating-point 3x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x2 __f64mat4x2GTX; //!< Double-precision floating-point 4x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x3 __f64mat4x3GTX; //!< Double-precision floating-point 4x3 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xquat<__halfGTX> __f16quatGTX; //!< Half-precision floating-point quaternion. (from GLM_GTX_number_precision extension) + typedef detail::_xquat __f32quatGTX; //!< Single-precision floating-point quaternion. (from GLM_GTX_number_precision extension) + typedef detail::_xquat __f64quatGTX; //!< Double-precision floating-point quaternion. (from GLM_GTX_number_precision extension) + + namespace gtx + { + //! GLM_GTX_number_precision extension: Defined size types. + namespace number_precision + { + typedef signed char int8; //!< 8bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed short int16; //!< 16bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed int int32; //!< 32bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed long long int64; //!< 64bit signed integer. (from GLM_GTX_number_precision extension) + + typedef signed char i8; //!< 8bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed short i16; //!< 16bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed int i32; //!< 32bit signed integer. (from GLM_GTX_number_precision extension) + typedef signed long long i64; //!< 64bit signed integer. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 i8vec2; //!< 8bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 i8vec3; //!< 8bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 i8vec4; //!< 8bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 i16vec2; //!< 16bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 i16vec3; //!< 16bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 i16vec4; //!< 16bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 i32vec2; //!< 32bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 i32vec3; //!< 32bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 i32vec4; //!< 32bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 i64vec2; //!< 64bit signed integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 i64vec3; //!< 64bit signed integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 i64vec4; //!< 64bit signed integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef unsigned char uint8; //!< 8bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned short uint16; //!< 16bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned int uint32; //!< 32bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned long long uint64; //!< 64bit unsigned integer. (from GLM_GTX_number_precision extension) + + typedef unsigned char u8; //!< 8bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned short u16; //!< 16bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned int u32; //!< 32bit unsigned integer. (from GLM_GTX_number_precision extension) + typedef unsigned long long u64; //!< 64bit unsigned integer. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 u8vec2; //!< 8bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 u8vec3; //!< 8bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 u8vec4; //!< 8bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 u16vec2; //!< 16bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 u16vec3; //!< 16bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 u16vec4; //!< 16bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 u32vec2; //!< 32bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 u32vec3; //!< 32bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 u32vec4; //!< 32bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 u64vec2; //!< 64bit unsigned integer vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 u64vec3; //!< 64bit unsigned integer vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 u64vec4; //!< 64bit unsigned integer vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef __halfGTX float16; //!< Half-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef float float32; //!< Single-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef double float64; //!< Double-precision floating-point number. (from GLM_GTX_number_precision extension) + + typedef __halfGTX f16; //!< Half-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef float f32; //!< Single-precision floating-point number. (from GLM_GTX_number_precision extension) + typedef double f64; //!< Double-precision floating-point number. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2<__halfGTX> f16vec2; //!< Half-precision floating-point vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3<__halfGTX> f16vec3; //!< Half-precision floating-point vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4<__halfGTX> f16vec4; //!< Half-precision floating-point vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 f32vec2; //!< Single-precision floating-point vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 f32vec3; //!< Single-precision floating-point vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 f32vec4; //!< Single-precision floating-point vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xvec2 f64vec2; //!< Double-precision floating-point vector of 2 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec3 f64vec3; //!< Double-precision floating-point vector of 3 components. (from GLM_GTX_number_precision extension) + typedef detail::_xvec4 f64vec4; //!< Double-precision floating-point vector of 4 components. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2<__halfGTX> f16mat2; //!< Half-precision floating-point 2x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3<__halfGTX> f16mat3; //!< Half-precision floating-point 3x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4<__halfGTX> f16mat4; //!< Half-precision floating-point 4x4 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2x3<__halfGTX> f16mat2x3; //!< Half-precision floating-point 2x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat2x4<__halfGTX> f16mat2x4; //!< Half-precision floating-point 2x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x2<__halfGTX> f16mat3x2; //!< Half-precision floating-point 3x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x4<__halfGTX> f16mat3x4; //!< Half-precision floating-point 3x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x2<__halfGTX> f16mat4x2; //!< Half-precision floating-point 4x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x3<__halfGTX> f16mat4x3; //!< Half-precision floating-point 4x3 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2 f32mat2; //!< Single-precision floating-point 2x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3 f32mat3; //!< Single-precision floating-point 3x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4 f32mat4; //!< Single-precision floating-point 4x4 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2x3 f32mat2x3; //!< Single-precision floating-point 2x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat2x4 f32mat2x4; //!< Single-precision floating-point 2x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x2 f32mat3x2; //!< Single-precision floating-point 3x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x4 f32mat3x4; //!< Single-precision floating-point 3x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x2 f32mat4x2; //!< Single-precision floating-point 4x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x3 f32mat4x3; //!< Single-precision floating-point 4x3 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2 f64mat2; //!< Double-precision floating-point 2x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3 f64mat3; //!< Double-precision floating-point 3x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4 f64mat4; //!< Double-precision floating-point 4x4 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xmat2x3 f64mat2x3; //!< Double-precision floating-point 2x3 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat2x4 f64mat2x4; //!< Double-precision floating-point 2x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x2 f64mat3x2; //!< Double-precision floating-point 3x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat3x4 f64mat3x4; //!< Double-precision floating-point 3x4 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x2 f64mat4x2; //!< Double-precision floating-point 4x2 matrix. (from GLM_GTX_number_precision extension) + typedef detail::_xmat4x3 f64mat4x3; //!< Double-precision floating-point 4x3 matrix. (from GLM_GTX_number_precision extension) + + typedef detail::_xquat<__halfGTX> f16quat; //!< Half-precision floating-point quaternion. (from GLM_GTX_number_precision extension) + typedef detail::_xquat f32quat; //!< Single-precision floating-point quaternion. (from GLM_GTX_number_precision extension) + typedef detail::_xquat f64quat; //!< Double-precision floating-point quaternion. (from GLM_GTX_number_precision extension) + } + } +} + +#define GLM_GTX_number_precision namespace gtx::number_precision + +#include "number_precision.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_number_precision;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_number_precision__ diff --git a/wip/sse/glm/ext/gtx/number_precision.inl b/wip/sse/glm/ext/gtx/number_precision.inl new file mode 100644 index 00000000..19e9c8da --- /dev/null +++ b/wip/sse/glm/ext/gtx/number_precision.inl @@ -0,0 +1,13 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-10 +// Updated : 2007-05-10 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/number_precision.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + +} diff --git a/wip/sse/glm/ext/gtx/optimum_pow.h b/wip/sse/glm/ext/gtx/optimum_pow.h new file mode 100644 index 00000000..59b8cf48 --- /dev/null +++ b/wip/sse/glm/ext/gtx/optimum_pow.h @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/optimum_pow.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_optimum_pow__ +#define __glm_gtx_optimum_pow__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template genType pow2GTX(const genType& x); //!< \brief Returns x raised to the power of 2. (From GLM_GTX_optimum_pow extension) + template genType pow3GTX(const genType& x); //!< \brief Returns x raised to the power of 3. (From GLM_GTX_optimum_pow extension) + template genType pow4GTX(const genType& x); //!< \brief Returns x raised to the power of 4. (From GLM_GTX_optimum_pow extension) + + inline bool powOfTwoGTX(int num); //!< \brief Checks if the parameter is a power of 2 number. (From GLM_GTX_optimum_pow extension) + inline detail::_bvec2 powOfTwoGTX(const detail::_xvec2& x); //!< \brief Checks to determine if the parameter component are power of 2 numbers. (From GLM_GTX_optimum_pow extension) + inline detail::_bvec3 powOfTwoGTX(const detail::_xvec3& x); //!< \brief Checks to determine if the parameter component are power of 2 numbers. (From GLM_GTX_optimum_pow extension) + inline detail::_bvec4 powOfTwoGTX(const detail::_xvec4& x); //!< \brief Checks to determine if the parameter component are power of 2 numbers. (From GLM_GTX_optimum_pow extension) + + namespace gtx + { + //! GLM_GTX_optimum_pow extension: Integer exponenciation of power functions. + namespace optimum_pow + { + template inline genType pow2(const genType& x){return pow2GTX(x);} //!< \brief Returns x raised to the power of 2. (From GLM_GTX_optimum_pow extension) + template inline genType pow3(const genType& x){return pow3GTX(x);} //!< \brief Returns x raised to the power of 3. (From GLM_GTX_optimum_pow extension) + template inline genType pow4(const genType& x){return pow4GTX(x);} //!< \brief Returns x raised to the power of 4. (From GLM_GTX_optimum_pow extension) + + inline bool powOfTwo(int num){return powOfTwoGTX(num);} //!< \brief Checks if the parameter is a power of 2 number. (From GLM_GTX_optimum_pow extension) + inline detail::_bvec2 powOfTwo(const detail::_xvec2& x){return powOfTwoGTX(x);} //!< \brief Checks to determine if the parameter component are power of 2 numbers. (From GLM_GTX_optimum_pow extension) + inline detail::_bvec3 powOfTwo(const detail::_xvec3& x){return powOfTwoGTX(x);} //!< \brief Checks to determine if the parameter component are power of 2 numbers. (From GLM_GTX_optimum_pow extension) + inline detail::_bvec4 powOfTwo(const detail::_xvec4& x){return powOfTwoGTX(x);} //!< \brief Checks to determine if the parameter component are power of 2 numbers. (From GLM_GTX_optimum_pow extension) + } + } +} + +#define GLM_GTX_optimum_pow namespace gtx::optimum_pow + +#include "optimum_pow.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_optimum_pow;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_optimum_pow__ diff --git a/wip/sse/glm/ext/gtx/optimum_pow.inl b/wip/sse/glm/ext/gtx/optimum_pow.inl new file mode 100644 index 00000000..379f43b8 --- /dev/null +++ b/wip/sse/glm/ext/gtx/optimum_pow.inl @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-27 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/optimum_pow.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline genType pow2GTX(const genType& x) + { + return x * x; + } + + template + inline genType pow3GTX(const genType& x) + { + return x * x * x; + } + + template + inline genType pow4GTX(const genType& x) + { + return x * x * x * x; + } + + inline bool powOfTwoGTX(int x) + { + return !(x & (x - 1)); + } + + inline detail::_bvec2 powOfTwoGTX(const detail::_xvec2& x) + { + return detail::_bvec2( + powOfTwoGTX(x.x), + powOfTwoGTX(x.y)); + } + + inline detail::_bvec3 powOfTwoGTX(const detail::_xvec3& x) + { + return detail::_bvec3( + powOfTwoGTX(x.x), + powOfTwoGTX(x.y), + powOfTwoGTX(x.z)); + } + + inline detail::_bvec4 powOfTwoGTX(const detail::_xvec4& x) + { + return detail::_bvec4( + powOfTwoGTX(x.x), + powOfTwoGTX(x.y), + powOfTwoGTX(x.z), + powOfTwoGTX(x.w)); + } +} diff --git a/wip/sse/glm/ext/gtx/orthonormalize.h b/wip/sse/glm/ext/gtx/orthonormalize.h new file mode 100644 index 00000000..7238218c --- /dev/null +++ b/wip/sse/glm/ext/gtx/orthonormalize.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/orthonormalize.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_orthonormalize__ +#define __glm_gtx_orthonormalize__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat3 orthonormalizeGTX(const detail::_xmat3& m); //!< \brief Returns the orthonormalized matrix of m (from GLM_GTX_orthonormalize extension) + template detail::_xvec3 orthonormalizeGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< \brief Orthonormalizes x according y (from GLM_GTX_orthonormalize extension) + + namespace gtx + { + //! GLM_GTX_orthonormalize extension: Orthonormalize matrices. + namespace orthonormalize + { + template inline detail::_xmat3 orthonormalize(const detail::_xmat3& m){return orthonormalizeGTX(m);} //!< \brief Returns the orthonormalized matrix of m (from GLM_GTX_orthonormalize extension) + template inline detail::_xvec3 orthonormalize(const detail::_xvec3& x, const detail::_xvec3& y){return orthonormalizeGTX(x, y);} //!< \brief Orthonormalizes x according y (from GLM_GTX_orthonormalize extension) + } + } +} + +#define GLM_GTX_orthonormalize namespace gtx::orthonormalize + +#include "orthonormalize.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_orthonormalize;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_orthonormalize__ diff --git a/wip/sse/glm/ext/gtx/orthonormalize.inl b/wip/sse/glm/ext/gtx/orthonormalize.inl new file mode 100644 index 00000000..6471c86e --- /dev/null +++ b/wip/sse/glm/ext/gtx/orthonormalize.inl @@ -0,0 +1,36 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/orthonormalize.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat3 orthonormalizeGTX(const detail::_xmat3& m) + { + detail::_xmat3 r = m; + + r[0] = normalize(r[0]); + + float d0 = dot(r[0], r[1]); + r[1] -= r[0] * d0; + r[1] = normalize(r[1]); + + float d1 = dot(r[1], r[2]); + d0 = dot(r[0], r[2]); + r[2] -= r[0] * d0 + r[1] * d1; + r[2] = normalize(r[2]); + + return r; + } + + template + inline detail::_xvec3 orthonormalizeGTX(const detail::_xvec3& x, const detail::_xvec3& y) + { + return normalize(x - y * dot(y, x)); + } +} diff --git a/wip/sse/glm/ext/gtx/outer_product.h b/wip/sse/glm/ext/gtx/outer_product.h new file mode 100644 index 00000000..47b7dd32 --- /dev/null +++ b/wip/sse/glm/ext/gtx/outer_product.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2006 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-03-30 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/outer_product.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_outer_product__ +#define __glm_gtx_outer_product__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat2 outerProductGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< Product of x extended to a matrix with the y extended to a transposed matrix. (from GLM_GTX_outer_product extension) + template detail::_xmat3 outerProductGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< Product of x extended to a matrix with the y extended to a transposed matrix. (from GLM_GTX_outer_product extension) + template detail::_xmat4 outerProductGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< Product of x extended to a matrix with the y extended to a transposed matrix. (from GLM_GTX_outer_product extension) + + namespace gtx + { + //! GLM_GTX_outer_product extension: Product of x extended to a matrix with the y extended to a transposed matrix. (Deprecated: included in GLM core) + namespace outer_product + { + template inline detail::_xmat2 outerProduct(const detail::_xvec2& x, const detail::_xvec2& y){return outerProductGTX(x, y);} //!< Product of x extended to a matrix with the y extended to a transposed matrix. (from GLM_GTX_outer_product extension) + template inline detail::_xmat3 outerProduct(const detail::_xvec3& x, const detail::_xvec3& y){return outerProductGTX(x, y);} //!< Product of x extended to a matrix with the y extended to a transposed matrix. (from GLM_GTX_outer_product extension) + template inline detail::_xmat4 outerProduct(const detail::_xvec4& x, const detail::_xvec4& y){return outerProductGTX(x, y);} //!< Product of x extended to a matrix with the y extended to a transposed matrix. (from GLM_GTX_outer_product extension) + } + } +} + +#define GLM_GTX_outer_product namespace gtx::outer_product + +#include "outer_product.inl" +/* Deprecated +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_outer_product;} +#endif//GLM_GTX_INCLUDED +*/ +#endif//__glm_gtx_outer_product__ diff --git a/wip/sse/glm/ext/gtx/outer_product.inl b/wip/sse/glm/ext/gtx/outer_product.inl new file mode 100644 index 00000000..3039c63a --- /dev/null +++ b/wip/sse/glm/ext/gtx/outer_product.inl @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-03-30 +// Updated : 2006-03-30 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/outer_product.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat2 outerProductGTX( + const detail::_xvec2& a, + const detail::_xvec2& b) + { + detail::_xmat2 m; + m[0][0] = a.x * b.x; + m[0][1] = a.x * b.y; + m[1][0] = a.y * b.x; + m[1][1] = a.y * b.y; + return m; + } + + template + inline detail::_xmat3 outerProductGTX( + const detail::_xvec3& a, + const detail::_xvec3& b) + { + detail::_xmat3 m; + m[0][0] = a.x * b.x; + m[0][1] = a.x * b.y; + m[0][2] = a.x * b.z; + m[1][0] = a.y * b.x; + m[1][1] = a.y * b.y; + m[1][2] = a.y * b.z; + m[2][0] = a.z * b.x; + m[2][1] = a.z * b.y; + m[2][2] = a.z * b.z; + return m; + } + + template + inline detail::_xmat4 outerProductGTX( + const detail::_xvec4& a, + const detail::_xvec4& b) + { + detail::_xmat4 m; + m[0][0] = a.x * b.x; + m[0][1] = a.x * b.y; + m[0][2] = a.x * b.z; + m[0][3] = T(0); + m[1][0] = a.y * b.x; + m[1][1] = a.y * b.y; + m[1][2] = a.y * b.z; + m[1][3] = T(0); + m[2][0] = a.z * b.x; + m[2][1] = a.z * b.y; + m[2][2] = a.z * b.z; + m[2][3] = T(0); + m[3] = detail::_xvec4(T(0), T(0), T(0), T(1)); + return m; + } +} diff --git a/wip/sse/glm/ext/gtx/perpendicular.h b/wip/sse/glm/ext/gtx/perpendicular.h new file mode 100644 index 00000000..389f5615 --- /dev/null +++ b/wip/sse/glm/ext/gtx/perpendicular.h @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/perpendicular.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_projection +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_perpendicular__ +#define __glm_gtx_perpendicular__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/projection.h" + +namespace glm +{ + template detail::_xvec2 perpGTX(const detail::_xvec2& x, const detail::_xvec2& Normal); //!< \brief Projects x a perpendicular axis of Normal (from GLM_GTX_perpendicular extension) + template detail::_xvec3 perpGTX(const detail::_xvec3& x, const detail::_xvec3& Normal); //!< \brief Projects x a perpendicular axis of Normal (from GLM_GTX_perpendicular extension) + template detail::_xvec4 perpGTX(const detail::_xvec4& x, const detail::_xvec4& Normal); //!< \brief Projects x a perpendicular axis of Normal (from GLM_GTX_perpendicular extension) + + namespace gtx + { + //! GLM_GTX_perpendicular extension: Perpendicular of a vector from other one + namespace perpendicular + { + template inline detail::_xvec2 perp(const detail::_xvec2& x, const detail::_xvec2& Normal){return perpGTX(x, Normal);} //!< \brief Projects x a perpendicular axis of Normal (from GLM_GTX_perpendicular extension) + template inline detail::_xvec3 perp(const detail::_xvec3& x, const detail::_xvec3& Normal){return perpGTX(x, Normal);} //!< \brief Projects x a perpendicular axis of Normal (from GLM_GTX_perpendicular extension) + template inline detail::_xvec4 perp(const detail::_xvec4& x, const detail::_xvec4& Normal){return perpGTX(x, Normal);} //!< \brief Projects x a perpendicular axis of Normal (from GLM_GTX_perpendicular extension) + } + } +} + +#define GLM_GTX_perpendicular namespace gtx::perpendicular + +#include "perpendicular.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_perpendicular;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_perpendicular__ diff --git a/wip/sse/glm/ext/gtx/perpendicular.inl b/wip/sse/glm/ext/gtx/perpendicular.inl new file mode 100644 index 00000000..c32c7345 --- /dev/null +++ b/wip/sse/glm/ext/gtx/perpendicular.inl @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/perpendicular.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xvec2 perpGTX(const detail::_xvec2& x, const detail::_xvec2& Normal) + { + return x - projGTX(x, Normal); + } + + template + inline detail::_xvec3 perpGTX(const detail::_xvec3& x, const detail::_xvec3& Normal) + { + return x - projGTX(x, Normal); + } + + template + inline detail::_xvec4 perpGTX(const detail::_xvec4& x, const detail::_xvec4& Normal) + { + return x - projGTX(x, Normal); + } +} diff --git a/wip/sse/glm/ext/gtx/polar_coordinates.h b/wip/sse/glm/ext/gtx/polar_coordinates.h new file mode 100644 index 00000000..e8d9f08d --- /dev/null +++ b/wip/sse/glm/ext/gtx/polar_coordinates.h @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-06 +// Updated : 2007-03-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/polar_coordinates.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_polar_coordinates__ +#define __glm_gtx_polar_coordinates__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + //! Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude (From GLM_GTX_polar_coordinates extension) + template _xvec3 polarGTX(const _xvec3& euclidean); + //! Convert Polar to Euclidean coordinates (From GLM_GTX_polar_coordinates extension) + template _xvec3 euclideanGTX(const _xvec3& polar); + + namespace gtx + { + //! GLM_GTX_polar_coordinates extension: Conversion from Euclidean space to polar space and revert. + namespace polar_coordinates + { + //! Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude (From GLM_GTX_polar_coordinates extension) + template inline _xvec3 polar(const _xvec3& euclidean){return polarGTX(euclidean);} + //! Convert Polar to Euclidean coordinates (From GLM_GTX_polar_coordinates extension) + template inline _xvec3 euclidean(const _xvec3& polar){return euclideanGTX(polar);} + } + } +} + +#define GLM_GTX_polar_coordinates namespace gtx::polar_coordinates + +#include "polar_coordinates.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_polar_coordinates;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_polar_coordinates__ diff --git a/wip/sse/glm/ext/gtx/polar_coordinates.inl b/wip/sse/glm/ext/gtx/polar_coordinates.inl new file mode 100644 index 00000000..79e24e81 --- /dev/null +++ b/wip/sse/glm/ext/gtx/polar_coordinates.inl @@ -0,0 +1,35 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-06 +// Updated : 2007-03-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/polar_coordinates.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline _xvec3 polarGTX(const _xvec3& euclidean) + { + T length = length(euclidean); + _xvec3 tmp = euclidean / length; + T xz_dist = sqrt(tmp.x * tmp.x + tmp.z * tmp.z); + + return _xvec3( + degrees(atan(xz_dist, tmp.y)), // latitude + degrees(atan(tmp.x, tmp.z)), // longitude + xz_dist); // xz distance + } + + template + inline _xvec3 euclideanGTX(const _xvec3& polar) + { + T latitude = radians(polar.x); + T longitude = radians(polar.y); + return _xvec3( + cos(latitude) * sin(longitude), + sin(latitude), + cos(latitude) * cos(longitude)); + } +} diff --git a/wip/sse/glm/ext/gtx/projection.h b/wip/sse/glm/ext/gtx/projection.h new file mode 100644 index 00000000..7b8f6653 --- /dev/null +++ b/wip/sse/glm/ext/gtx/projection.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/projection.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_projection__ +#define __glm_gtx_projection__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xvec2 projGTX(const detail::_xvec2& x, const detail::_xvec2& Normal); //!< \brief Projects x on Normal (from GLM_GTX_projection extension) + template detail::_xvec3 projGTX(const detail::_xvec3& x, const detail::_xvec3& Normal); //!< \brief Projects x on Normal (from GLM_GTX_projection extension) + template detail::_xvec4 projGTX(const detail::_xvec4& x, const detail::_xvec4& Normal); //!< \brief Projects x on Normal (from GLM_GTX_projection extension) + + namespace gtx + { + //! GLM_GTX_projection extension: Projection of a vector to other one + namespace projection + { + template inline detail::_xvec2 proj(const detail::_xvec2& x, const detail::_xvec2& Normal){return projGTX(x, Normal);} //!< \brief Projects x on Normal (from GLM_GTX_projection extension) + template inline detail::_xvec3 proj(const detail::_xvec3& x, const detail::_xvec3& Normal){return projGTX(x, Normal);} //!< \brief Projects x on Normal (from GLM_GTX_projection extension) + template inline detail::_xvec4 proj(const detail::_xvec4& x, const detail::_xvec4& Normal){return projGTX(x, Normal);} //!< \brief Projects x on Normal (from GLM_GTX_projection extension) + } + } +} + +#define GLM_GTX_projection namespace gtx::projection + +#include "projection.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_projection;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_projection__ diff --git a/wip/sse/glm/ext/gtx/projection.inl b/wip/sse/glm/ext/gtx/projection.inl new file mode 100644 index 00000000..c44ae383 --- /dev/null +++ b/wip/sse/glm/ext/gtx/projection.inl @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/projection.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xvec2 projGTX(const detail::_xvec2& x, const detail::_xvec2& Normal) + { + return dot(x, Normal) / dot(Normal, Normal) * Normal; + } + + template + inline detail::_xvec3 projGTX(const detail::_xvec3& x, const detail::_xvec3& Normal) + { + return dot(x, Normal) / dot(Normal, Normal) * Normal; + } + + template + inline detail::_xvec4 projGTX(const detail::_xvec4& x, const detail::_xvec4& Normal) + { + return dot(x, Normal) / dot(Normal, Normal) * Normal; + } +} diff --git a/wip/sse/glm/ext/gtx/quaternion.h b/wip/sse/glm/ext/gtx/quaternion.h new file mode 100644 index 00000000..fe491323 --- /dev/null +++ b/wip/sse/glm/ext/gtx/quaternion.h @@ -0,0 +1,175 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/quaternion.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// +// ToDo: +// - Study constructors with angles and axis +// - Study constructors with vec3 that are the imaginary component of quaternion +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_quaternion__ +#define __glm_gtx_quaternion__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + namespace detail + { + //! \brief Template for quaternion. (From GLM_GTX_quaternion extension) + template class _xquat + { + public: + T x, y, z, w; + + // Constructors + _xquat(); + explicit _xquat(const T s, const _xvec3& v); + explicit _xquat(const T w, const T x, const T y, const T z); + + // Convertions + explicit _xquat(const T pitch, const T yaw, const T roll); + explicit _xquat(const _xvec3& eulerAngles); + //explicit _xquat(const _xvec4& x); + explicit _xquat(const _xmat3& m); + explicit _xquat(const _xmat4& m); + //explicit _xquat(float angle, float x, float y, float z); + //explicit _xquat(float angle, const _xvec3& v); + + // Accesses + T& operator[](int i); + T operator[](int i) const; + operator T*(); + operator const T*() const; + + // Operators + _xquat operator+ (const _xquat& q) const; + _xquat& operator+=(const _xquat& q); + _xquat operator- (const _xquat& q) const; + _xquat& operator-=(const _xquat& q); + _xquat operator* (T s) const; + _xquat& operator*=(T s); + _xquat operator* (const _xquat& q) const; + _xquat& operator*=(const _xquat& q); + _xquat operator/ (T s) const; + _xquat& operator/=(T s); + _xquat operator/ (const _xquat& q) const; + _xquat& operator/=(const _xquat& q); + _xquat operator- () const; + + // Transformations + _xvec3 operator* (const _xvec3& v) const; + _xvec4 operator* (const _xvec4& v) const; + }; + + template _xquat operator* (const T s, const _xquat & q) + { + return q * s; + } + } //namespace detail + + template T lengthGTX(const detail::_xquat& q); //!< \brief Returns the length of the quaternion x. (from GLM_GTX_quaternion extension) + template detail::_xquat normalizeGTX(const detail::_xquat& q); //!< \brief Returns the normalized quaternion of from x. (from GLM_GTX_quaternion extension) + template T dotGTX(const detail::_xquat& q1, const detail::_xquat& q2); //!< \brief Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... (from GLM_GTX_quaternion extension) + template detail::_xquat crossGTX(const detail::_xquat& q1, const detail::_xquat& q2); //!< \brief Returns the cross product of q1 and q2. (from GLM_GTX_quaternion extension) + template detail::_xquat mixGTX(const detail::_xquat& x, const detail::_xquat& y, T a); //!< \brief Returns a LERP interpolated quaternion of x and y according a. (from GLM_GTX_quaternion extension) + template detail::_xquat squadGTX(const detail::_xquat& q1, const detail::_xquat& q2, const detail::_xquat& s1, const detail::_xquat& s2, const T h); //!< \brief Compute a point on a path according squad equation. q1 and q2 are control points; s1 and s2 are intermediate control points (from GLM_GTX_transform extension) + template detail::_xquat intermediateGTX(const detail::_xquat& prev, const detail::_xquat& curr, const detail::_xquat& next); //!< \brief Returns an intermediate control point for squad interpolation (from GLM_GTX_quaternion extension) + template detail::_xquat expGTX(const detail::_xquat& q, const T exponent); //!< \brief Returns a exp of a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat logGTX(const detail::_xquat& q); //!< \brief Returns a log of a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat powGTX(const detail::_xquat& x, T y); //!< \brief Returns x raised to the y power. (from GLM_GTX_quaternion extension) + template detail::_xquat sqrtGTX(const detail::_xquat& q); + template detail::_xquat conjugateGTX(const detail::_xquat& q); //!< \brief Returns the q conjugate. (from GLM_GTX_quaternion extension) + template detail::_xquat inverseGTX(const detail::_xquat& q); //!< \brief Returns the q inverse. (from GLM_GTX_quaternion extension) + template detail::_xquat rotateGTX(const detail::_xquat& q, T angle, T x, T y, T z); //!< \brief Rotates a quaternion from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xquat rotateGTX(const detail::_xquat& q, T angle, const detail::_xvec3& v); //!< \brief Rotates a quaternion from an vector of 3 components axis and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xvec3 rotateGTX(const detail::_xquat& q, const detail::_xvec3& v); //!< \brief Rotates a 3 components vector by a quaternion. (from GLM_GTX_transform extension) + template detail::_xvec4 rotateGTX(const detail::_xquat& q, const detail::_xvec4& v); //!< \brief Rotates a 4 components vector by a quaternion. (from GLM_GTX_transform extension) + template T angleGTX(const detail::_xquat& x); //!< \brief Returns the q rotation angle. (from GLM_GTX_quaternion extension) + template detail::_xvec3 axisGTX(const detail::_xquat& x); //!< \brief Returns the q rotation axis. (from GLM_GTX_quaternion extension) + //template detail::_xmat3 mat3GTX(const detail::_xquat& x); //!< \brief Converts a quaternion to a 3 * 3 matrix. (from GLM_GTX_quaternion extension) + //template detail::_xmat4 mat4GTX(const detail::_xquat& x); //!< \brief Converts a quaternion to a 4 * 4 matrix. (from GLM_GTX_quaternion extension) + //template detail::_xquat quatGTX(const detail::_xmat3& x); //!< \brief Converts a 3 * 3 matrix to a quaternion. (from GLM_GTX_quaternion extension) + //template detail::_xquat quatGTX(const detail::_xmat4& x); //!< \brief Converts a 4 * 4 matrix to a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat angleAxisGTX(T angle, T x, T y, T z); //!< \brief Build a quaternion from an angle and an axis. (from GLM_GTX_quaternion extension) + template detail::_xquat angleAxisGTX(T angle, const detail::_xvec3& v); //!< \brief Build a quaternion from an angle and an axis. (from GLM_GTX_quaternion extension) + template T extractRealComponentGTX(const detail::_xquat& q); //!< \brief Extract the real component of a quaternion. (from GLM_GTX_quaternion extension) + template T rollGTX(const detail::_xquat& x); //!< \brief Returns roll value of euler angles. (from GLM_GTX_quaternion extension) + template T pitchGTX(const detail::_xquat& x); //!< \brief Returns pitch value of euler angles. (from GLM_GTX_quaternion extension) + template T yawGTX(const detail::_xquat& x); //!< \brief Returns yaw value of euler angles. (from GLM_GTX_quaternion extension) + template detail::_xvec3 eularAnglesGTX(const detail::_xquat& x); //!< \brief Returns euler angles, yitch as x, yaw as y, roll as z. (from GLM_GTX_quaternion extension) + template detail::_xvec3 crossGTX(const detail::_xquat& q, const detail::_xvec3& v){return rotateGTX(q, v);} //!< \brief Compute a cross product between a quaternion and a vector. (from GLM_GTX_quaternion extension) + template detail::_xvec3 crossGTX(const detail::_xvec3& v, const detail::_xquat& q){return rotateGTX(inverseGTX(q), v);} //!< \brief Compute a cross product between a vector and a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xmat3 toMat3GTX(const detail::_xquat& x); //!< \brief Converts a quaternion to a 3 * 3 matrix. (from GLM_GTX_quaternion extension) + template detail::_xmat4 toMat4GTX(const detail::_xquat& x); //!< \brief Converts a quaternion to a 4 * 4 matrix. (from GLM_GTX_quaternion extension) + template detail::_xquat toQuatGTX(const detail::_xmat3& x); //!< \brief Converts a 3 * 3 matrix to a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat toQuatGTX(const detail::_xmat4& x); //!< \brief Converts a 4 * 4 matrix to a quaternion. (from GLM_GTX_quaternion extension) + + typedef detail::_xquat __quatGTX; //!< \brief Quaternion of floating-point numbers. (from GLM_GTX_quaternion extension) + + namespace gtx + { + //! GLM_GTX_quaternion extension: Quaternion types and functions + namespace quaternion + { + template T length(const detail::_xquat& q){return lengthGTX(q);} //!< \brief Returns the length of the quaternion x. (from GLM_GTX_quaternion extension) + template detail::_xquat normalize(const detail::_xquat& q){return normalizeGTX(q);} //!< \brief Returns the normalized quaternion of from x. (from GLM_GTX_quaternion extension) + template T dot(const detail::_xquat& q1, const detail::_xquat& q2){return dotGTX(q1, q2);} //!< \brief Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... (from GLM_GTX_quaternion extension) + template detail::_xquat cross(const detail::_xquat& q1, const detail::_xquat& q2){return crossGTX(q1, q2);} //!< \brief Returns the cross product of q1 and q2. (from GLM_GTX_quaternion extension) + template detail::_xquat mix(const detail::_xquat& x, const detail::_xquat& y, T a){return mixGTX(x, y, a);} //!< \brief Returns a LERP interpolated quaternion of x and y according a. (from GLM_GTX_quaternion extension) + template detail::_xquat squad(const detail::_xquat& q1, const detail::_xquat& q2, const detail::_xquat& s1, const detail::_xquat& s2, const T h) + {return squadGTX(q1, q2, s1, s2, h);} //!< \brief Compute a point on a path according squad equation. q1 and q2 are control points; s1 and s2 are intermediate control points (from GLM_GTX_transform extension) + template detail::_xquat intermediate(const detail::_xquat& prev, const detail::_xquat& curr, const detail::_xquat& next) + {return intermediateGTX(prev, curr, next);} //!< \brief Returns an intermediate control point for squad interpolation (from GLM_GTX_quaternion extension) + template detail::_xquat exp(const detail::_xquat& q, const T exponent){return expGTX(q, exponent);} //!< \brief Returns a exp of a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat log(const detail::_xquat& q){return logGTX(q);} //!< \brief Returns a log of a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat pow(const detail::_xquat& x, T y){return powGTX(x, y);} //!< \brief Returns x raised to the y power. (from GLM_GTX_quaternion extension) + template detail::_xquat sqrt(const detail::_xquat& q){return sqrtGTX(q);} //!< \brief Returns quarternion square root (from GLM_GTX_quaternion extension) + template detail::_xquat conjugate(const detail::_xquat& q){return conjugateGTX(q);} //!< \brief Returns the q conjugate. (from GLM_GTX_quaternion extension) + template detail::_xquat inverse(const detail::_xquat& q){return inverseGTX(q);} //!< \brief Returns the q inverse. (from GLM_GTX_quaternion extension) + template detail::_xquat rotate(const detail::_xquat& q, T angle, T x, T y, T z){return rotateGTX(q, angle, x, y ,z);} //!< \brief Rotates a quaternion from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xquat rotate(const detail::_xquat& q, T angle, const detail::_xvec3& v){return rotateGTX(q, angle, v);} //!< \brief Rotates a quaternion from an vector of 3 components axis and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xvec3 rotate(const detail::_xquat& q, const detail::_xvec3& v){return rotateGTX(q, v);} //!< \brief Rotates a 3 components vector by a quaternion. (from GLM_GTX_transform extension) + template detail::_xvec4 rotate(const detail::_xquat& q, const detail::_xvec4& v){return rotateGTX(q, v);} //!< \brief Rotates a 4 components vector by a quaternion. (from GLM_GTX_transform extension) + template T angle(const detail::_xquat& x){return angleGTX(x);} //!< \brief Returns the q rotation angle. (from GLM_GTX_quaternion extension) + template detail::_xvec3 axis(const detail::_xquat& x){return axisGTX(x);} //!< \brief Returns the q rotation axis. (from GLM_GTX_quaternion extension) + //template detail::_xmat3 mat3(const detail::_xquat& x); //!< \brief Converts a quaternion to a 3 * 3 matrix. (from GLM_GTX_quaternion extension) + //template detail::_xmat4 mat4(const detail::_xquat& x); //!< \brief Converts a quaternion to a 4 * 4 matrix. (from GLM_GTX_quaternion extension) + //template detail::_xquat quat(const detail::_xmat3& x); //!< \brief Converts a 3 * 3 matrix to a quaternion. (from GLM_GTX_quaternion extension) + //template detail::_xquat quat(const detail::_xmat4& x); //!< \brief Converts a 4 * 4 matrix to a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat angleAxis(T angle, T x, T y, T z){return angleAxisGTX(angle, x, y, z);} //!< \brief Build a quaternion from an angle and an axis. (from GLM_GTX_quaternion extension) + template detail::_xquat angleAxis(T angle, const detail::_xvec3& v){return angleAxisGTX(angle, v);} //!< \brief Build a quaternion from an angle and an axis. (from GLM_GTX_quaternion extension) + template T extractRealComponent(const detail::_xquat& q){return extractRealComponentGTX(q);} //!< \brief Extract the real component of a quaternion. (from GLM_GTX_quaternion extension) + template T roll(const detail::_xquat& x){return rollGTX(x);} //!< \brief Returns roll value of euler angles. (from GLM_GTX_quaternion extension) + template T pitch(const detail::_xquat& x){return pitchGTX(x);} //!< \brief Returns pitch value of euler angles. (from GLM_GTX_quaternion extension) + template T yaw(const detail::_xquat& x){return yawGTX(x);} //!< \brief Returns yaw value of euler angles. (from GLM_GTX_quaternion extension) + template detail::_xvec3 eularAngles(const detail::_xquat& x){return eularAnglesGTX(x);} //!< \brief Returns euler angles, yitch as x, yaw as y, roll as z. (from GLM_GTX_quaternion extension) + template detail::_xvec3 cross(const detail::_xquat& q, const detail::_xvec3& v){return rotateGTX(q, v);} //!< \brief Compute a cross product between a quaternion and a vector. (from GLM_GTX_quaternion extension) + template detail::_xvec3 cross(const detail::_xvec3& v, const detail::_xquat& q){return rotateGTX(inverseGTX(q), v);} //!< \brief Compute a cross product between a vector and a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xmat3 toMat3(const detail::_xquat& x){return toMat3GTX(x);} //!< \brief Converts a quaternion to a 3 * 3 matrix. (from GLM_GTX_quaternion extension) + template detail::_xmat4 toMat4(const detail::_xquat& x){return toMat4GTX(x);} //!< \brief Converts a quaternion to a 4 * 4 matrix. (from GLM_GTX_quaternion extension) + template detail::_xquat toQuat(const detail::_xmat3& x){return toQuatGTX(x);} //!< \brief Converts a 3 * 3 matrix to a quaternion. (from GLM_GTX_quaternion extension) + template detail::_xquat toQuat(const detail::_xmat4& x){return toQuatGTX(x);} //!< \brief Converts a 4 * 4 matrix to a quaternion. (from GLM_GTX_quaternion extension) + + typedef detail::_xquat quat; //!< \brief Quaternion of floating-point numbers. (from GLM_GTX_quaternion extension) + } + } +} //namespace glm + +#define GLM_GTX_quaternion namespace gtx::quaternion + +#include "quaternion.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_quaternion;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_quaternion__ diff --git a/wip/sse/glm/ext/gtx/quaternion.inl b/wip/sse/glm/ext/gtx/quaternion.inl new file mode 100644 index 00000000..0fd08cc5 --- /dev/null +++ b/wip/sse/glm/ext/gtx/quaternion.inl @@ -0,0 +1,847 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Created : 2005-12-21 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/quaternion.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm{ +namespace detail{ + + template + inline _xquat::_xquat() : + x(0), + y(0), + z(0), + w(1) + {} + + template + inline _xquat::_xquat(const T s, const _xvec3& v) : + x(v.x), + y(v.y), + z(v.z), + w(s) + {} + + template + inline _xquat::_xquat(const T w, const T x, const T y, const T z) : + x(x), + y(y), + z(z), + w(w) + {} + + ////////////////////////////////////////////////////////////// + // _xquat conversions + + template + inline _xquat::_xquat(const T pitch, const T yaw, const T roll) + { + _xvec3 eulerAngle(pitch * T(0.5), yaw * T(0.5), roll * T(0.5)); + _xvec3 c = cos(eulerAngle * T(0.5)); + _xvec3 s = sin(eulerAngle * T(0.5)); + + this->w = c.x * c.y * c.z + s.x * s.y * s.z; + this->x = s.x * c.y * c.z - c.x * s.y * s.z; + this->y = c.x * s.y * c.z + s.x * c.y * s.z; + this->z = c.x * c.y * s.z - s.x * s.y * c.z; + } + + template + inline _xquat::_xquat(const _xvec3& eulerAngle) + { + _xvec3 c = cos(eulerAngle * T(0.5)); + _xvec3 s = sin(eulerAngle * T(0.5)); + + this->w = c.x * c.y * c.z + s.x * s.y * s.z; + this->x = s.x * c.y * c.z - c.x * s.y * s.z; + this->y = c.x * s.y * c.z + s.x * c.y * s.z; + this->z = c.x * c.y * s.z - s.x * s.y * c.z; + } + + /* + template + inline _xquat::_xquat(const _xvec4& x) : + w(x.w), + x(x.x), + y(x.y), + z(x.z) + {} + */ + + template + inline _xquat::_xquat(const _xmat3& m) + { + T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2]; + T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2]; + T fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1]; + T fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2]; + + int biggestIndex = 0; + T fourBiggestSquaredMinus1 = fourWSquaredMinus1; + if(fourXSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourXSquaredMinus1; + biggestIndex = 1; + } + if(fourYSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourYSquaredMinus1; + biggestIndex = 2; + } + if(fourZSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourZSquaredMinus1; + biggestIndex = 3; + } + + T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5); + T mult = T(0.25) / biggestVal; + + switch(biggestIndex) + { + case 0: + this->x = (m[1][2] - m[2][1]) * mult; + this->y = (m[2][0] - m[0][2]) * mult; + this->z = (m[0][1] - m[1][0]) * mult; + this->w = biggestVal; + break; + case 1: + this->x = biggestVal; + this->y = (m[0][1] + m[1][0]) * mult; + this->z = (m[2][1] + m[1][2]) * mult; + this->w = (m[1][2] - m[2][1]) * mult; + break; + case 2: + this->x = (m[0][1] + m[1][0]) * mult; + this->y = biggestVal; + this->z = (m[1][2] + m[2][1]) * mult; + this->w = (m[2][0] - m[0][2]) * mult; + break; + case 3: + this->x = (m[2][0] + m[0][2]) * mult; + this->y = (m[1][2] + m[2][1]) * mult; + this->z = biggestVal; + this->w = (m[0][1] - m[1][0]) * mult; + break; + } + } + + template + inline _xquat::_xquat(const _xmat4& m) + { + T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2]; + T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2]; + T fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1]; + T fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2]; + + int biggestIndex = 0; + T fourBiggestSquaredMinus1 = fourWSquaredMinus1; + if(fourXSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourXSquaredMinus1; + biggestIndex = 1; + } + if(fourYSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourYSquaredMinus1; + biggestIndex = 2; + } + if(fourZSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourZSquaredMinus1; + biggestIndex = 3; + } + + T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0); + T mult = T(0.25) / biggestVal; + + switch(biggestIndex) + { + case 0: + this->x = (m[1][2] - m[2][1]) * mult; + this->y = (m[2][0] - m[0][2]) * mult; + this->z = (m[0][1] - m[1][0]) * mult; + this->w = biggestVal; + break; + case 1: + this->x = biggestVal; + this->y = (m[0][1] + m[1][0]) * mult; + this->z = (m[2][1] + m[1][2]) * mult; + this->w = (m[1][2] - m[2][1]) * mult; + break; + case 2: + this->x = (m[0][1] + m[1][0]) * mult; + this->y = biggestVal; + this->z = (m[1][2] + m[2][1]) * mult; + this->w = (m[2][0] - m[0][2]) * mult; + break; + case 3: + this->x = (m[2][0] + m[0][2]) * mult; + this->y = (m[1][2] + m[2][1]) * mult; + this->z = biggestVal; + this->w = (m[0][1] - m[1][0]) * mult; + break; + } + } + /* + template + inline _xquat::_xquat(float angle, float x, float y, float z) + { + // Axis of rotation must be normalised + float len = length(_xvec3(x, y, z)); + if(abs(len - 1.0f) > 0.001f) + { + float oneOverLen = 1 / len; + x *= oneOverLen; + y *= oneOverLen; + z *= oneOverLen; + } + + angle = radians(angle); + float fSin = sin(angle * 0.5f); + + this->x = x * fSin; + this->y = y * fSin; + this->z = z * fSin; + this->w = cos(angle * 0.5f)); + } + + template + inline _xquat::_xquat(float angle, const _xvec3& v) + { + _xvec3 v_normalized = normalize(v); + + angle = radians(angle); + float fSin = sin(angle * 0.5f); + + this->x = v.x * fSin; + this->y = v.y * fSin; + this->z = v.z * fSin; + this->w = cos(angle * 0.5f)); + } + */ + ////////////////////////////////////////////////////////////// + // __quatGT accesses + + template + inline T& _xquat::operator [] (int i) + { + return (&x)[i]; + } + + template + inline T _xquat::operator [] (int i) const + { + return (&x)[i]; + } + + template + inline _xquat::operator T* () + { + return &x; + } + + template + inline _xquat::operator const T* () const + { + return &x; + } + + ////////////////////////////////////////////////////////////// + // __quatGT Operators + + template + inline _xquat _xquat::operator +(const _xquat& q) const + { + return _xquat( + this->w + q.w, + this->x + q.x, + this->y + q.y, + this->z + q.z); + } + + template + inline _xquat& _xquat::operator +=(const _xquat& q) + { + return *this = *this + q; + } + + template + inline _xquat _xquat::operator -(const _xquat& q) const + { + return _xquat( + this->w - q.w, + this->x - q.x, + this->y - q.y, + this->z - q.z); + } + + template + inline _xquat& _xquat::operator -=(const _xquat& q) + { + return *this = *this - q; + } + + template + inline _xquat _xquat::operator *(T s) const + { + return _xquat( + this->w * s, + this->x * s, + this->y * s, + this->z * s); + } + + template + inline _xquat& _xquat::operator *=(T s) + { + this->w *= s; + this->x *= s; + this->y *= s; + this->z *= s; + return *this; + } + + template + inline _xquat _xquat::operator* (const _xquat& q) const + { + return _xquat(this->w * q.w, this->x * q.x, this->y * q.y, this->z * q.z); + } + + template + inline _xquat& _xquat::operator *=(const _xquat& q) + { + return *this = *this * q; + } + + template + inline _xquat _xquat::operator /(T s) const + { + return _xquat( + this->w / s, + this->x / s, + this->y / s, + this->z / s); + } + + template + inline _xquat& _xquat::operator /=(T s) + { + this->w /= s; + this->x /= s; + this->y /= s; + this->z /= s; + return *this; + } + + template + inline _xquat _xquat::operator /(const _xquat& q) const + { + return *this * inverseGTX(q); + } + + template + inline _xquat& _xquat::operator /=(const _xquat& q) + { + return *this = *this * inverseGTX(q); + } + + template + inline _xquat _xquat::operator- () const + { + return _xquat(-this->w, -this->x, -this->y, -this->z); + } + + // Transformation + template + inline _xvec3 _xquat::operator* (const _xvec3& v) const + { + _xvec3 uv, uuv; + _xvec3 QuatVector(x, y, z); + uv = cross(QuatVector, v); + uuv = cross(QuatVector, uv); + uv *= (T(2) * w); + uuv *= T(2); + + return v + uv + uuv; + } + + template + inline _xvec4 _xquat::operator* (const _xvec4& v) const + { + return _xvec4(*this * _xvec3(v), v.w); + } +}//namespace detail + + //////////////////////////////////////////////////////// + template + inline T lengthGTX(const detail::_xquat & q) + { + return static_cast(sqrt( + q.x * q.x + + q.y * q.y + + q.z * q.z + + q.w * q.w)); + } + + template + inline detail::_xquat normalizeGTX(const detail::_xquat& q) + { + T len = static_cast(length(q)); + if(len <= 0) // Problem + return detail::_xquat(1, 0, 0, 0); + T oneOverLen = 1 / len; + return detail::_xquat(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen); + } + + template + inline T dotGTX(const detail::_xquat& q1, const detail::_xquat& q2) + { + return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; + } + + template + inline detail::_xquat crossGTX(const detail::_xquat& q1, const detail::_xquat& q2) + { + return detail::_xquat( + q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, + q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, + q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z, + q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x); + } + /* + template + inline detail::_xquat crossGTX(const detail::_xquat & q, const detail::_xvec3 & v) + { + return detail::_xquat( + (q.w * v.x) + (q.y * v.z) - (q.z * v.y), + (q.w * v.y) + (q.z * v.x) - (q.x * v.z), + (q.w * v.z) + (q.x * v.y) - (q.y * v.x), + -(q.x * v.x) - (q.y * v.y) - (q.z * v.z)); + } + */ + /* + template + inline detail::_xquat crossGTX(const detail::_xvec3 & v, const detail::_xquat & q) + { + + } + */ + template + inline detail::_xquat mixGTX(const detail::_xquat& x, const detail::_xquat& y, T a) + { + if(a <= T(0)) return x; + if(a >= T(1)) return y; + + float fCos = dot(x, y); + detail::_xquat y2(y); //BUG!!! _xquat y2; + if(fCos < T(0)) + { + y2 = -y; + fCos = -fCos; + } + + //if(fCos > 1.0f) // problem + float k0, k1; + if(fCos > T(0.9999)) + { + k0 = T(1) - a; + k1 = T(0) + a; //BUG!!! 1.0f + a; + } + else + { + T fSin = sqrt(T(1) - fCos * fCos); + T fAngle = atan(fSin, fCos); + T fOneOverSin = T(1) / fSin; + k0 = sin((T(1) - a) * fAngle) * fOneOverSin; + k1 = sin((T(0) + a) * fAngle) * fOneOverSin; + } + + return detail::_xquat( + k0 * x.w + k1 * y2.w, + k0 * x.x + k1 * y2.x, + k0 * x.y + k1 * y2.y, + k0 * x.z + k1 * y2.z); + } + + template + inline detail::_xquat squadGTX(const detail::_xquat& q1, const detail::_xquat& q2, const detail::_xquat& s1, const detail::_xquat& s2, const T h) + { + return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * h (T(1) - h)); + } + + template + inline detail::_xquat intermediateGTX(const detail::_xquat& prev, const detail::_xquat& curr, const detail::_xquat& next) + { + detail::_xquat invQuat = inverseGTX(curr); + return extGTX((logGTX(next + invQuat) + logGTX(prev + invQuat)) / T(-4)) * curr; + } + + template + inline detail::_xquat expGTX(const detail::_xquat& q, const T exponent) + { + detail::_xvec3 u(q.x, q.y, q.z); + float a = length(u); + detail::_xvec3 v(u / a); + return detail::_xquat(cos(a), sin(a) * v); + } + + template + inline detail::_xquat logGTX(const detail::_xquat& q) + { + if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0))) + { + if(q.w > T(0)) + return detail::_xquat(log(q.w), T(0), T(0), T(0)); + else if(q.w < T(0)) + return detail::_xquat(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0)); + else + return detail::_xquat(std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()); + } + else + { + T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z); + T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w); + T t = atan(Vec3Len, T(q.w)) / Vec3Len; + return detail::_xquat(t * q.x, t * q.y, t * q.z, log(QuatLen)); + } + } +/* + template + inline detail::_xquat powGTX(const _xquat& q, const T exponent) + { + detail::_xquat Result; + + T alpha = acos(w); + T expAlpha = alpha * exponent; + + Result.w = cos(expAlpha); + + T mult = sin(expAlpha) / sin(alpha); + Result.x = q.x * mult; + Result.y = q.y * mult; + Result.z = q.z * mult; + + return Result; + } +*/ + template + inline detail::_xquat powGTX(const detail::_xquat& x, const T y) + { + if(abs(x.w) > T(0.9999)) + return x; + float Angle = acos(y); + float NewAngle = Angle * y; + float Div = sin(NewAngle) / sin(Angle); + return detail::_xquat( + cos(NewAngle), + x.x * Div, + x.y * Div, + x.z * Div); + } + + template + inline detail::_xquat sqrtGTX(const detail::_xquat& q) + { + T q0 = T(1) - dotGTX(q, q); + return T(2) * (T(1) + q0) * q; + } + + template + inline detail::_xquat conjugateGTX(const detail::_xquat& q) + { + return detail::_xquat(q.w, -q.x, -q.y, -q.z); + } + + template + inline detail::_xquat inverseGTX(const detail::_xquat& q) + { + return conjugateGTX(q) / lengthGTX(q); + } + + template + inline detail::_xquat rotateGTX(const detail::_xquat& q, T angle, T x, T y, T z) + { + // Axis of rotation must be normalised + T len = length(detail::_xvec3(x, y, z)); + if(abs(len - T(1)) > T(0.001)) + { + T oneOverLen = T(1) / len; + x *= oneOverLen; + y *= oneOverLen; + z *= oneOverLen; + } + + angle = radians(angle); + T fSin = sin(angle * T(0.5)); + + return detail::_xquat(cos(angle * T(0.5)), x * fSin, y * fSin, z * fSin); + } + + template + inline detail::_xvec3 rotateGTX(const detail::_xquat& q, const detail::_xvec3& v) + { + detail::_xquat Result = q * v * inverseGTX(q); + return detail::_xvec3(Result.x, Result.y, Result.z); + } + + template + inline detail::_xvec4 rotateGTX(const detail::_xquat& q, const detail::_xvec4& v) + { + detail::_xquat Result = q * v * inverseGTX(q); + return detail::_xvec4(v.w, Result.x, Result.y, Result.z); + } + + template + inline T angleGTX(const detail::_xquat& x) + { + return cos(x.w) * T(2); + } + + template + inline detail::_xvec3 axisGTX(const detail::_xquat& x) + { + T tmp1 = T(1) - x.w * x.w; + if(tmp1 <= T(0)) + return detail::_xvec3(0, 0, 1); + T tmp2 = T(1) / sqrt(tmp1); + return detail::_xvec3(x.x * tmp2, x.y * tmp2, x.z * tmp2); + } + + template + inline detail::_xmat3 toMat3GTX(const detail::_xquat& q) + { + detail::_xmat3 Result(1); + Result[0][0] = 1 - 2 * q.y * q.y - 2 * q.z * q.z; + Result[0][1] = 2 * q.x * q.y + 2 * q.w * q.z; + Result[0][2] = 2 * q.x * q.z - 2 * q.w * q.y; + + Result[1][0] = 2 * q.x * q.y - 2 * q.w * q.z; + Result[1][1] = 1 - 2 * q.x * q.x - 2 * q.z * q.z; + Result[1][2] = 2 * q.y * q.z + 2 * q.w * q.x; + + Result[2][0] = 2 * q.x * q.z + 2 * q.w * q.y; + Result[2][1] = 2 * q.y * q.z - 2 * q.w * q.x; + Result[2][2] = 1 - 2 * q.x * q.x - 2 * q.y * q.y; + return Result; + } + + template + inline detail::_xmat4 toMat4GTX(const detail::_xquat& q) + { + detail::_xmat4 Result = detail::_xmat4(1); + Result[0][0] = 1 - 2 * q.y * q.y - 2 * q.z * q.z; + Result[0][1] = 2 * q.x * q.y + 2 * q.w * q.z; + Result[0][2] = 2 * q.x * q.z - 2 * q.w * q.y; + + Result[1][0] = 2 * q.x * q.y - 2 * q.w * q.z; + Result[1][1] = 1 - 2 * q.x * q.x - 2 * q.z * q.z; + Result[1][2] = 2 * q.y * q.z + 2 * q.w * q.x; + + Result[2][0] = 2 * q.x * q.z + 2 * q.w * q.y; + Result[2][1] = 2 * q.y * q.z - 2 * q.w * q.x; + Result[2][2] = 1 - 2 * q.x * q.x - 2 * q.y * q.y; + return Result; + } + + template + inline detail::_xquat toQuatGTX(const detail::_xmat3& m) + { + T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2]; + T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2]; + T fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1]; + T fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2]; + + int biggestIndex = 0; + T fourBiggestSquaredMinus1 = fourWSquaredMinus1; + if(fourXSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourXSquaredMinus1; + biggestIndex = 1; + } + if(fourYSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourYSquaredMinus1; + biggestIndex = 2; + } + if(fourZSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourZSquaredMinus1; + biggestIndex = 3; + } + + T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5); + T mult = T(0.25) / biggestVal; + + detail::_xquat Result; + switch(biggestIndex) + { + case 0: + Result.w = biggestVal; + Result.x = (m[1][2] - m[2][1]) * mult; + Result.y = (m[2][0] - m[0][2]) * mult; + Result.z = (m[0][1] - m[1][0]) * mult; + break; + case 1: + Result.w = (m[1][2] - m[2][1]) * mult; + Result.x = biggestVal; + Result.y = (m[0][1] + m[1][0]) * mult; + Result.z = (m[2][1] + m[1][2]) * mult; + break; + case 2: + Result.w = (m[2][0] - m[0][2]) * mult; + Result.x = (m[0][1] + m[1][0]) * mult; + Result.y = biggestVal; + Result.z = (m[1][2] + m[2][1]) * mult; + break; + case 3: + Result.w = (m[0][1] - m[1][0]) * mult; + Result.x = (m[2][0] + m[0][2]) * mult; + Result.y = (m[1][2] + m[2][1]) * mult; + Result.z = biggestVal; + break; + } + return Result; + } + + template + inline detail::_xquat toQuatGTX(const detail::_xmat4& m) + { + T fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2]; + T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2]; + T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2]; + T fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1]; + + int biggestIndex = 0; + T fourBiggestSquaredMinus1 = fourWSquaredMinus1; + if(fourXSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourXSquaredMinus1; + biggestIndex = 1; + } + if(fourYSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourYSquaredMinus1; + biggestIndex = 2; + } + if(fourZSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourZSquaredMinus1; + biggestIndex = 3; + } + + T biggestVal = sqrt(fourBiggestSquaredMinus1 + 1) * T(0.5); + T mult = T(0.25) / biggestVal; + + detail::_xquat Result; + switch(biggestIndex) + { + case 0: + Result.w = biggestVal; + Result.x = (m[1][2] - m[2][1]) * mult; + Result.y = (m[2][0] - m[0][2]) * mult; + Result.z = (m[0][1] - m[1][0]) * mult; + break; + case 1: + Result.w = (m[1][2] - m[2][1]) * mult; + Result.x = biggestVal; + Result.y = (m[0][1] + m[1][0]) * mult; + Result.z = (m[2][1] + m[1][2]) * mult; + break; + case 2: + Result.w = (m[2][0] - m[0][2]) * mult; + Result.x = (m[0][1] + m[1][0]) * mult; + Result.y = biggestVal; + Result.z = (m[1][2] + m[2][1]) * mult; + break; + case 3: + Result.w = (m[0][1] - m[1][0]) * mult; + Result.x = (m[2][0] + m[0][2]) * mult; + Result.y = (m[1][2] + m[2][1]) * mult; + Result.z = biggestVal; + break; + } + return Result; + } + + template + inline detail::_xquat angleAxisGTX(T angle, T x, T y, T z) + { + detail::_xquat result; + // Axis of rotation must be normalised + float len = length(detail::_xvec3(x, y, z)); + if(abs(len - T(1)) > T(0.001)) + { + T oneOverLen = T(1) / len; + x *= oneOverLen; + y *= oneOverLen; + z *= oneOverLen; + } + + angle = radians(angle); + T fSin = sin(angle * T(0.5)); + + result.w = cos(angle * T(0.5)); + result.x = x * fSin; + result.y = y * fSin; + result.z = z * fSin; + return result; + } + + template + inline detail::_xquat angleAxisGTX(T angle, const detail::_xvec3& v) + { + detail::_xquat result; + detail::_xvec3 v_normalized = normalize(v); + + angle = radians(angle); + T fSin = sin(angle * T(0.5)); + + result.w = cos(angle * T(0.5)); + result.x = v.x * fSin; + result.y = v.y * fSin; + result.z = v.z * fSin; + return result; + } + + template + inline T extractRealComponentGTX(const detail::_xquat& q) + { + T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z; + if(w < T(0)) + return T(0); + else + return -sqrt(w); + } + + template + inline T rollGTX(const detail::_xquat& q) + { + return tan2(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z); + } + + template + inline T pitchGTX(const detail::_xquat& q) + { + return atan2(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z); + } + + template + inline T yawGTX(const detail::_xquat& q) + { + return asin(T(-2) * (q.x * q.z - q.w * q.y)); + } + + template + inline detail::_xvec3 eularAnglesGTX(const detail::_xquat& x) + { + return detail::_xvec3(pitchGTX(x), yawGTX(x), rollGTX(x)); + } +} diff --git a/wip/sse/glm/ext/gtx/random.h b/wip/sse/glm/ext/gtx/random.h new file mode 100644 index 00000000..207a83a7 --- /dev/null +++ b/wip/sse/glm/ext/gtx/random.h @@ -0,0 +1,157 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-16 +// Updated : 2007-08-30 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/random.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_vecx +// - GLM_GTX_half +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_random__ +#define __glm_gtx_random__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/half.h" +#include "../gtx/vecx.h" + +namespace glm +{ + template T signedRand1GTX(); //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template <> __halfGTX signedRand1GTX(); //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template <> float signedRand1GTX(); //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template <> double signedRand1GTX(); //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec2 signedRand2GTX(); //!< Generate 2 random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec3 signedRand3GTX(); //!< Generate 3 random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec4 signedRand4GTX(); //!< Generate 4 random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvecxGTX signedRandGTX(); //!< Generate N random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + + template detail::_xvec2 normalizedRand2GTX(); //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + //template <> _xvec2<__halfGTX> normalizedRand2GTX(); //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + //template <> _xvec2 normalizedRand2GTX(); //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + //template <> _xvec2 normalizedRand2GTX(); //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + template detail::_xvec2 normalizedRand2GTX(T Min, T Max); //!< Generate a scaled and normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + + template detail::_xvec3 normalizedRand3GTX(); //!< Generate a normalized 3D vector regulary distribute on a sphere (From GLM_GTX_random extension) + //template <> _xvec3<__halfGTX> normalizedRand3GTX(); //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + //template <> _xvec3 normalizedRand3GTX(); //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + //template <> _xvec3 normalizedRand3GTX(); //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + template detail::_xvec3 normalizedRand3GTX(T Min, T Max); //!< Generate a scaled and normalized 3D vector regulary distribute on a sphere (From GLM_GTX_random extension) + + template T compRand1GTX(); //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template <> __halfGTX compRand1GTX(); //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template <> float compRand1GTX(); //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template <> double compRand1GTX(); //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template T compRand1GTX(T Min, T Max); //!< Generate a random number in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec2 compRand2GTX(T Min, T Max); //!< Generate 2 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec3 compRand3GTX(T Min, T Max); //!< Generate 3 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec4 compRand4GTX(T Min, T Max); //!< Generate 4 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvecxGTX compRandGTX(T Min, T Max); //!< Generate N random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec2 compRand2GTX(const detail::_xvec2& Min, const detail::_xvec2& Max); //!< Generate 2 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec3 compRand3GTX(const detail::_xvec3& Min, const detail::_xvec3& Max); //!< Generate 3 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvec3 compRand4GTX(const detail::_xvec4& Min, const detail::_xvec4& Max); //!< Generate 4 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template detail::_xvecxGTX compRandGTX(const detail::_xvecxGTX& Min, const detail::_xvecxGTX& Max); //!< Generate N random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + + template detail::_xvec2 vecRand2GTX(); //!< Generate a random normalized 2 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template <> detail::_xvec2<__halfGTX> vecRand2GTX(); //!< Generate a random normalized 2 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template <> detail::_xvec2 vecRand2GTX(); //!< Generate a random normalized 2 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template <> detail::_xvec2 vecRand2GTX(); //!< Generate a random normalized 2 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template detail::_xvec2 vecRand2GTX(T MinRadius, T MaxRadius); //!< Generate a random normalized 2 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + + template detail::_xvec3 vecRand3GTX(); //!< Generate a random normalized 3 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + //template <> detail::_xvec3<__halfGTX> vecRand3GTX(); //!< Generate a random normalized 3 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + //template <> detail::_xvec3 vecRand3GTX(); //!< Generate a random normalized 3 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + //template <> detail::_xvec3 vecRand3GTX(); //!< Generate a random normalized 3 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template detail::_xvec3 vecRand3GTX(T MinRadius, T MaxRadius); //!< Generate a random normalized 3 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + + template detail::_xvec4 vecRand4GTX(); //!< Generate a random normalized 4 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template <> detail::_xvec4<__halfGTX> vecRand4GTX(); //!< Generate a random normalized 4 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template <> detail::_xvec4 vecRand4GTX(); //!< Generate a random normalized 4 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template <> detail::_xvec4 vecRand4GTX(); //!< Generate a random normalized 4 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template detail::_xvec4 vecRand4GTX(T MinRadius, T MaxRadius); //!< Generate a random normalized 4 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + + template T gaussRand1GTX(T mean, T std_deviation); //!< Gererate a random floating number according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec2 gaussRand2GTX(T mean, T std_deviation); //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec3 gaussRand3GTX(T mean, T std_deviation); //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec4 gaussRand4GTX(T mean, T std_deviation); //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec2 gaussRand2GTX(const detail::_xvec2& mean, T std_deviation); //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec3 gaussRand3GTX(const detail::_xvec3& mean, T std_deviation); //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec4 gaussRand4GTX(const detail::_xvec4& mean, T std_deviation); //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec2 gaussRand2GTX(T mean, const detail::_xvec2& std_deviation); //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec3 gaussRand3GTX(T mean, const detail::_xvec3& std_deviation); //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec4 gaussRand4GTX(T mean, const detail::_xvec4& std_deviation); //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec2 gaussRand2GTX(const detail::_xvec2& mean, const detail::_xvec2& std_deviation); //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec3 gaussRand3GTX(const detail::_xvec3& mean, const detail::_xvec3& std_deviation); //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template detail::_xvec4 gaussRand4GTX(const detail::_xvec4& mean, const detail::_xvec4& std_deviation); //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + + namespace gtx + { + //! GLM_GTX_random extension: Generate random number from varius distribution methods + namespace random + { + template inline T signedRand1(){return signedRand1GTX();} //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template <> inline __halfGTX signedRand1(){return signedRand1GTX<__halfGTX>();} //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template <> inline float signedRand1(){return signedRand1GTX();} //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template <> inline double signedRand1(){return signedRand1GTX();} //!< Generate a random number in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec2 signedRand2(){return signedRand2GTX();} //!< Generate 2 random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec3 signedRand3(){return signedRand3GTX();} //!< Generate 3 random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec4 signedRand4(){return signedRand4GTX();} //!< Generate 4 random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvecxGTX signedRand(){return signedRandGTX();} //!< Generate N random numbers in the interval [-1, 1], according a linear distribution (From GLM_GTX_random extension) + + template detail::_xvec2 normalizedRand2(){return normalizedRand2GTX();} //!< Generate a normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + template detail::_xvec2 normalizedRand2(T Min, T Max){return normalizedRand2GTX(Min, Max);} //!< Generate a scaled and normalized 2D vector regulary distribute on a circle (From GLM_GTX_random extension) + template detail::_xvec3 normalizedRand3(){return normalizedRand3GTX();} //!< Generate a normalized 3D vector regulary distribute on a sphere (From GLM_GTX_random extension) + template detail::_xvec3 normalizedRand3(T Min, T Max){return normalizedRand3GTX(Min, Max);} //!< Generate a scaled and normalized 3D vector regulary distribute on a sphere (From GLM_GTX_random extension) + + template inline T compRand1(){return compRand1GTX();} //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template <> inline __halfGTX compRand1(){return compRand1GTX<__halfGTX>();} //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template <> inline float compRand1(){return compRand1GTX();} //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template <> inline double compRand1(){return compRand1GTX();} //!< Generate a random number in the interval [0, 1], according a linear distribution (From GLM_GTX_random extension) + template inline T compRand1(T Min, T Max){return compRand1GTX(Min, Max);} //!< Generate a random number in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec2 compRand2(T Min, T Max){return compRand2GTX(Min, Max);} //!< Generate 2 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec3 compRand3(T Min, T Max){return compRand3GTX(Min, Max);} //!< Generate 3 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec4 compRand4(T Min, T Max){return compRand4GTX(Min, Max);} //!< Generate 4 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvecxGTX compRand(T Min, T Max){return compRand(Min, Max);} //!< Generate N random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec2 compRand2(const detail::_xvec2& Min, const detail::_xvec2& Max){return compRand2GTX(Min, Max);} //!< Generate 2 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec3 compRand3(const detail::_xvec3& Min, const detail::_xvec3& Max){return compRand3GTX(Min, Max);} //!< Generate 3 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvec3 compRand4(const detail::_xvec4& Min, const detail::_xvec4& Max){return compRand4GTX(Min, Max);} //!< Generate 4 random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + template inline detail::_xvecxGTX compRand(const detail::_xvecxGTX& Min, const detail::_xvecxGTX& Max){return compRandGTX(Min, Max);} //!< Generate N random numbers in the interval [Min, Max], according a linear distribution (From GLM_GTX_random extension) + + template inline detail::_xvec2 vecRand2(){return vecRand2GTX();} //!< Generate a random normalized 2 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template inline detail::_xvec2 vecRand2(T MinRadius, T MaxRadius){return vecRand2GTX(MinRadius, MaxRadius);} //!< Generate a random normalized 2 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template inline detail::_xvec3 vecRand3(){return vecRand3GTX();} //!< Generate a random normalized 3 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template inline detail::_xvec3 vecRand3(T MinRadius, T MaxRadius){return vecRand3GTX(MinRadius, MaxRadius);} //!< Generate a random normalized 3 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template inline detail::_xvec4 vecRand4(){return vecRand4GTX();} //!< Generate a random normalized 4 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + template inline detail::_xvec4 vecRand4(T MinRadius, T MaxRadius){return vecRand4GTX(MinRadius, MaxRadius);} //!< Generate a random normalized 4 component vector. It's a spherical uniform distribution. (From GLM_GTX_random extension) + + template inline T gaussRand1(T mean, T std_deviation){return gaussRand1GTX(mean, std_deviation);} //!< Gererate a random floating number according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec2 gaussRand2(T mean, T std_deviation){return gaussRand2GTX(mean, std_deviation);} //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec3 gaussRand3(T mean, T std_deviation){return gaussRand3GTX(mean, std_deviation);} //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec4 gaussRand4(T mean, T std_deviation){return gaussRand4GTX(mean, std_deviation);} //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec2 gaussRand2(const detail::_xvec2& mean, T std_deviation){return gaussRand2GTX(mean, std_deviation);} //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec3 gaussRand3(const detail::_xvec3& mean, T std_deviation){return gaussRand3GTX(mean, std_deviation);} //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec4 gaussRand4(const detail::_xvec4& mean, T std_deviation){return gaussRand4GTX(mean, std_deviation);} //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec2 gaussRand2(T mean, const detail::_xvec2& std_deviation){return gaussRand2GTX(mean, std_deviation);} //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec3 gaussRand3(T mean, const detail::_xvec3& std_deviation){return gaussRand3GTX(mean, std_deviation);} //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec4 gaussRand4(T mean, const detail::_xvec4& std_deviation){return gaussRand4GTX(mean, std_deviation);} //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec2 gaussRand2(const detail::_xvec2& mean, const detail::_xvec2& std_deviation){return gaussRand2GTX(mean, std_deviation);} //!< Gererate 2 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec3 gaussRand3(const detail::_xvec3& mean, const detail::_xvec3& std_deviation){return gaussRand3GTX(mean, std_deviation);} //!< Gererate 3 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + template inline detail::_xvec4 gaussRand4(const detail::_xvec4& mean, const detail::_xvec4& std_deviation){return gaussRand4GTX(mean, std_deviation);} //!< Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) + } + } +} + +#define GLM_GTX_random namespace gtx::random + +#include "random.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_random;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_random__ diff --git a/wip/sse/glm/ext/gtx/random.inl b/wip/sse/glm/ext/gtx/random.inl new file mode 100644 index 00000000..e1dc2a09 --- /dev/null +++ b/wip/sse/glm/ext/gtx/random.inl @@ -0,0 +1,627 @@ +////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-16 +// Updated : 2006-01-16 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/random.inl +////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm +{ + template <> + inline __halfGTX signedRand1GTX() + { + return __halfGTX(signedRand1GTX()); + } + + template <> + inline float signedRand1GTX() + { + #define GLM_COMPILER GLM_COMPILER_VC80 + #if(GLM_COMPILER == GLM_COMPILER_VC80) + #define RAND_SHIFT_NUM 5 + #else + #define RAND_SHIFT_NUM 0 + #endif + return float((std::rand() - (RAND_MAX >> 1) - 1) << 1) / float(RAND_MAX - RAND_SHIFT_NUM); + } + + template <> + inline double signedRand1GTX() + { + return double(signedRand1GTX()); + } + + template + inline detail::_xvec2 signedRand2GTX() + { + return detail::_xvec2( + signedRand1GTX(), + signedRand1GTX()); + } + + template + inline detail::_xvec3 signedRand3GTX() + { + return detail::_xvec3( + signedRand1GTX(), + signedRand1GTX(), + signedRand1GTX()); + } + + template + inline detail::_xvec4 signedRand4GTX() + { + return detail::_xvec4( + signedRand1GTX(), + signedRand1GTX(), + signedRand1GTX(), + signedRand1GTX()); + } + + template + inline detail::_xvecxGTX signedRandGTX() + { + detail::_xvecxGTX Result; + for(int i = 0; i < N; ++i) + Result[i] = signedRand1GTX(T()); + } + + template + inline detail::_xvec2 normalizedRand2GTX() + { + T a = compRand1GTX(T(0), T(6.283185307179586476925286766559f)); + return detail::_xvec2(cos(a), sin(a)); + } +/* +#ifdef GLM_COMPILER_VC + template <> + inline detail::_xvec2<__halfGTX> normalizedRand2GTX() + { + return detail::_xvec2<__halfGTX>(normalizedRand2GTX()); + } +#endif//GLM_COMPILER_VC + + template <> + inline detail::_xvec2 normalizedRand2GTX() + { + float a = compRand1GTX(float(0), float(6.283185307179586476925286766559f)); + return detail::_xvec2(cos(a), sin(a)); + } + + template <> + inline detail::_xvec2 normalizedRand2GTX() + { + double a = compRand1GTX(double(0), double(6.283185307179586476925286766559)); + return detail::_xvec2(cos(a), sin(a)); + } + + template + inline detail::_xvec2 normalizedRand2GTX(T Min, T Max) + { + return normalizedRand2GTX() * compRand1GTX(Min, Max); + } +*/ + template + inline detail::_xvec3 normalizedRand3GTX() + { + T z = compRand1GTX(T(-1), T(1)); + T a = compRand1GTX(T(0), T(6.283185307179586476925286766559f)); + + T r = sqrt(T(1) - z * z); + + T x = r * cos(a); + T y = r * sin(a); + + return detail::_xvec3(x, y, z); + } + + template + inline detail::_xvec3 normalizedRand3GTX(T Min, T Max) + { + return normalizedRand3GTX() * compRand1GTX(Min, Max); + } + + template <> + inline __halfGTX compRand1GTX() + { + return __halfGTX(float(std::rand()) / float(RAND_MAX)); + } + + template <> + inline float compRand1GTX() + { + return float(std::rand()) / float(RAND_MAX); + } + + template <> + inline double compRand1GTX() + { + return double(std::rand()) / double(RAND_MAX); + } + + template + inline T compRand1GTX(T Min, T Max) + { + return compRand1GTX() * (Max - Min) + Min; + } + + template + inline detail::_xvec2 compRand2GTX(T Min, T Max) + { + return detail::_xvec2( + compRand1GTX(Min, Max), + compRand1GTX(Min, Max)); + } + + template + inline detail::_xvec3 compRand3GTX(T Min, T Max) + { + return detail::_xvec3( + compRand1GTX(Min, Max), + compRand1GTX(Min, Max), + compRand1GTX(Min, Max)); + } + + template + inline detail::_xvec4 compRand4GTX(T Min, T Max) + { + return detail::_xvec4( + compRand1GTX(Min, Max), + compRand1GTX(Min, Max), + compRand1GTX(Min, Max), + compRand1GTX(Min, Max)); + } + + template + inline detail::_xvecxGTX compRandGTX(T Min, T Max) + { + detail::_xvecxGTX result; + for(int i = 0; i < N; ++i) + result[i] = compRand1GTX(Min, Max); + return result; + } + + template + inline detail::_xvec2 compRand2GTX(T Min, const detail::_xvec2& Max) + { + return detail::_xvec2( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y)); + } + + template + inline detail::_xvec3 compRand3GTX(T Min, const detail::_xvec3& Max) + { + return detail::_xvec3( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y), + compRand1GTX(Min.z, Max.z)); + } + + template + inline detail::_xvec4 compRand4GTX(T Min, const detail::_xvec4& Max) + { + return detail::_xvec4( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y), + compRand1GTX(Min.z, Max.z), + compRand1GTX(Min.w, Max.w)); + } + + template + inline detail::_xvecxGTX compRandGTX(T Min, const detail::_xvecxGTX& Max) + { + detail::_xvecxGTX result; + for(int i = 0; i < N; ++i) + result[i] = compRand1GTX(Min[i], Max[i]); + return result; + } + + template + inline detail::_xvec2 compRand2GTX(const detail::_xvec2& Min, T Max) + { + return detail::_xvec2( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y)); + } + + template + inline detail::_xvec3 compRand3GTX(const detail::_xvec3& Min, T Max) + { + return detail::_xvec3( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y), + compRand1GTX(Min.z, Max.z)); + } + + template + inline detail::_xvec4 compRand4GTX(const detail::_xvec4& Min, T Max) + { + return detail::_xvec4( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y), + compRand1GTX(Min.z, Max.z), + compRand1GTX(Min.w, Max.w)); + } + + template + inline detail::_xvecxGTX compRandGTX(const detail::_xvecxGTX& Min, T Max) + { + detail::_xvecxGTX result; + for(int i = 0; i < N; ++i) + result[i] = compRand1GTX(Min[i], Max[i]); + return result; + } + + template + inline detail::_xvec2 compRand2GTX(const detail::_xvec2& Min, const detail::_xvec2& Max) + { + return detail::_xvec2( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y)); + } + + template + inline detail::_xvec3 compRand3GTX(const detail::_xvec3& Min, const detail::_xvec3& Max) + { + return detail::_xvec3( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y), + compRand1GTX(Min.z, Max.z)); + } + + template + inline detail::_xvec4 compRand4GTX(const detail::_xvec4& Min, const detail::_xvec4& Max) + { + return detail::_xvec4( + compRand1GTX(Min.x, Max.x), + compRand1GTX(Min.y, Max.y), + compRand1GTX(Min.z, Max.z), + compRand1GTX(Min.w, Max.w)); + } + + template + inline detail::_xvecxGTX compRandGTX(const detail::_xvecxGTX& Min, const detail::_xvecxGTX& Max) + { + detail::_xvecxGTX result; + for(int i = 0; i < N; ++i) + result[i] = compRand1GTX(Min[i], Max[i]); + return result; + } +/* + template + inline detail::_xvec2 vecRand2GTX() + { + detail::_xvec2 result(0); + do + { + result = compRand2GTX(T(-1), T(1)); + } while (length(result) > T(1)); + + return result; + } +*/ + +#ifdef GLM_COMPILER_VC + template <> + inline detail::_xvec2<__halfGTX> vecRand2GTX() + { + detail::_xvec2 result(float(0)); + do + { + result = compRand2GTX(float(-1), float(1)); + } while (length(result) > float(1)); + + return detail::_xvec2<__halfGTX>(result); + } +#endif//GLM_COMPILER_VC + + template + inline detail::_xvec2 vecRand2GTX() + { + detail::_xvec2 result(float(0)); + do + { + result = compRand2GTX(float(-1), float(1)); + } while (length(result) > float(1)); + + return result; + } + + template + inline detail::_xvec2 vecRand2GTX() + { + detail::_xvec2 result(double(0)); + do + { + result = compRand2GTX(double(-1), double(1)); + } while (length(result) > double(1)); + + return result; + } + + template + inline detail::_xvec2 vecRand2GTX(T MinRadius, T MaxRadius) + { + assert(MinRadius < MaxRadius); + + detail::_xvec2 Result(T(0)); + T LenRadius(0); + + do + { + Result = compRand2GTX(-MaxRadius, MaxRadius); + LenRadius = length(Result); + } + while(LenRadius > MaxRadius || LenRadius < MinRadius); + + return Result; + } + + template + inline detail::_xvec3 vecRand3GTX() + { + detail::_xvec3 Result(T(0)); + do + { + Result = compRand3GTX(T(-1), T(1)); + } + while(length(Result) > T(1)); + + return Result; + } + +/* +#ifdef GLM_COMPILER_VC + template <> + inline detail::_xvec3<__halfGTX> vecRand3GTX<__halfGTX>() + { + detail::_xvec3 result(float(0)); + do + { + result = compRand3GTX(float(-1), float(1)); + } while (length(result) > float(1)); + + return detail::_xvec3<__halfGTX>(result); + } +#endif//GLM_COMPILER_VC + + template + inline detail::_xvec3 vecRand3GTX() + { + detail::_xvec3 result(float(0)); + do + { + result = compRand3GTX(float(-1), float(1)); + } while (length(result) > float(1)); + + return result; + } + + template + inline detail::_xvec3 vecRand3GTX() + { + detail::_xvec3 result(double(0)); + do + { + result = compRand3GTX(double(-1), double(1)); + } while (length(result) > double(1)); + + return result; + } +*/ + template + inline detail::_xvec3 vecRand3GTX(T MinRadius, T MaxRadius) + { + assert(MinRadius < MaxRadius); + + detail::_xvec3 Result(0); + T LenRadius(0); + + do + { + Result = compRand3GTX(-MaxRadius, MaxRadius); + LenRadius = length(Result); + } + while(LenRadius > MaxRadius || LenRadius < MinRadius); + + return Result; + } +/* + template + inline detail::_xvec4 vecRand4GTX() + { + detail::_xvec4 Result(T(0)); + do + { + Result = compRand4GTX(T(-1), T(1)); + } + while(length(Result) > T(1)); + + return Result; + } +*/ +#ifdef GLM_COMPILER_VC + template <> + inline detail::_xvec4<__halfGTX> vecRand4GTX() + { + detail::_xvec4 result(float(0)); + do + { + result = compRand4GTX(float(-1), float(1)); + } while (length(result) > float(1)); + + return detail::_xvec4<__halfGTX>(result); + } +#endif//GLM_COMPILER_VC + + template + inline detail::_xvec4 vecRand4GTX() + { + detail::_xvec4 result(float(0)); + do + { + result = compRand4GTX(float(-1), float(1)); + } while (length(result) > float(1)); + + return result; + } + + template + inline detail::_xvec4 vecRand4GTX() + { + detail::_xvec4 result(double(0)); + do + { + result = compRand4GTX(double(-1), double(1)); + } while (length(result) > double(1)); + + return result; + } + + template + inline detail::_xvec4 vecRand4GTX(T MinRadius, T MaxRadius) + { + assert(MinRadius < MaxRadius); + + detail::_xvec4 Result(T(0)); + T LenRadius(T(0)); + + do + { + Result = compRand4GTX(-MaxRadius, MaxRadius); + LenRadius = length(Result); + } + while(LenRadius > MaxRadius || LenRadius < MinRadius); + + return Result; + } + + template + inline T gaussRand1GTX(T mean, T std_deviation) + { + T w, x1, x2; + + do + { + x1 = rand1GTX(T(-1), T(1)); + x2 = rand1GTX(T(-1), T(1)); + + w = x1 * x1 + x2 * x2; + } while(w > T(1)); + + return x2 * std_deviation * std_deviation * sqrt((T(-2) * ln(w)) / w) + mean; + } + + template + inline detail::_xvec2 gaussRand2GTX(T mean, T std_deviation) + { + return detail::_xvec2( + gaussRand1GTX(mean, std_deviation), + gaussRand1GTX(mean, std_deviation)); + } + + template + inline detail::_xvec3 gaussRand3GTX(T mean, T std_deviation) + { + return detail::_xvec3( + gaussRand1GTX(mean, std_deviation), + gaussRand1GTX(mean, std_deviation), + gaussRand1GTX(mean, std_deviation)); + } + + template + inline detail::_xvec4 gaussRand4GTX(T mean, T std_deviation) + { + return detail::_xvec4( + gaussRand1GTX(mean, std_deviation), + gaussRand1GTX(mean, std_deviation), + gaussRand1GTX(mean, std_deviation), + gaussRand1GTX(mean, std_deviation)); + } + + template + inline detail::_xvec2 gaussRand2GTX(T mean, const detail::_xvec2& std_deviation) + { + return detail::_xvec2( + gaussRand1GTX(mean, std_deviation.x), + gaussRand1GTX(mean, std_deviation.y)); + } + + template + inline detail::_xvec3 gaussRand3GTX(T mean, const detail::_xvec3& std_deviation) + { + return detail::_xvec3( + gaussRand1GTX(mean, std_deviation.x), + gaussRand1GTX(mean, std_deviation.y), + gaussRand1GTX(mean, std_deviation.z)); + } + + template + inline detail::_xvec4 gaussRand4GTX(T mean, const detail::_xvec4& std_deviation) + { + return detail::_xvec4( + gaussRand1GTX(mean, std_deviation.x), + gaussRand1GTX(mean, std_deviation.y), + gaussRand1GTX(mean, std_deviation.z), + gaussRand1GTX(mean, std_deviation.w)); + } + + template + inline detail::_xvec2 gaussRand2GTX(const detail::_xvec2& mean, T std_deviation) + { + return detail::_xvec2( + gaussRand1GTX(mean.x, std_deviation), + gaussRand1GTX(mean.y, std_deviation)); + } + + template + inline detail::_xvec3 gaussRand3GTX(const detail::_xvec3& mean, T std_deviation) + { + return detail::_xvec3( + gaussRand1GTX(mean.x, std_deviation), + gaussRand1GTX(mean.y, std_deviation), + gaussRand1GTX(mean.z, std_deviation)); + } + + template + inline detail::_xvec4 gaussRand4GTX(const detail::_xvec4& mean, T std_deviation) + { + return detail::_xvec4( + gaussRand1GTX(mean.x, std_deviation), + gaussRand1GTX(mean.y, std_deviation), + gaussRand1GTX(mean.z, std_deviation), + gaussRand1GTX(mean.w, std_deviation)); + } + + template + inline detail::_xvec2 gaussRand2GTX(const detail::_xvec2& mean, const detail::_xvec2& std_deviation) + { + return detail::_xvec2( + gaussRand1GTX(mean.x, std_deviation.x), + gaussRand1GTX(mean.y, std_deviation.y)); + } + + template + inline detail::_xvec3 gaussRand3GTX(const detail::_xvec3& mean, const detail::_xvec3& std_deviation) + { + return detail::_xvec3( + gaussRand1GTX(mean.x, std_deviation.x), + gaussRand1GTX(mean.y, std_deviation.y), + gaussRand1GTX(mean.z, std_deviation.z)); + } + + template + inline detail::_xvec4 gaussRand4GTX(const detail::_xvec4& mean, const detail::_xvec4& std_deviation) + { + return detail::_xvec4( + gaussRand1GTX(mean.x, std_deviation.x), + gaussRand1GTX(mean.y, std_deviation.y), + gaussRand1GTX(mean.z, std_deviation.z), + gaussRand1GTX(mean.w, std_deviation.w)); + } +} diff --git a/wip/sse/glm/ext/gtx/rotate_vector.h b/wip/sse/glm/ext/gtx/rotate_vector.h new file mode 100644 index 00000000..19009b77 --- /dev/null +++ b/wip/sse/glm/ext/gtx/rotate_vector.h @@ -0,0 +1,60 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-11-02 +// Updated : 2006-12-15 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/rotate_vector.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_rotate_vector__ +#define __glm_gtx_rotate_vector__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/transform.h" + +namespace glm +{ + template detail::_xvec2 rotateGTX(const detail::_xvec2& v, T angle); //!< \brief Rotate a two dimentionnals vector (from GLM_GTX_rotate_vector extension) + template detail::_xvec3 rotateGTX(const detail::_xvec3& v, T angle, const detail::_xvec3& normal); //!< \brief Rotate a three dimentionnals vector around an axis (from GLM_GTX_rotate_vector extension) + template detail::_xvec4 rotateGTX(const detail::_xvec4& v, T angle, const detail::_xvec3& normal); //!< \brief Rotate a four dimentionnals vector around an axis (from GLM_GTX_rotate_vector extension) + template detail::_xvec3 rotateXGTX(const detail::_xvec3& v, T angle); //!< \brief Rotate a three dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template detail::_xvec3 rotateYGTX(const detail::_xvec3& v, T angle); //!< \brief Rotate a three dimentionnals vector around the Y axis (from GLM_GTX_rotate_vector extension) + template detail::_xvec3 rotateZGTX(const detail::_xvec3& v, T angle); //!< \brief Rotate a three dimentionnals vector around the Z axis (from GLM_GTX_rotate_vector extension) + template detail::_xvec4 rotateXGTX(const detail::_xvec4& v, T angle); //!< \brief Rotate a four dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template detail::_xvec4 rotateYGTX(const detail::_xvec4& v, T angle); //!< \brief Rotate a four dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template detail::_xvec4 rotateZGTX(const detail::_xvec4& v, T angle); //!< \brief Rotate a four dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template detail::_xmat4 orientationGTX(const detail::_xvec3& Normal, const detail::_xvec3& Up); //!< \brief Build a rotation matrix from a normal and a up vector (from GLM_GTX_rotate_vector extension) + + namespace gtx + { + //! GLM_GTX_rotate_vector extension: Function to directly rotate a vector + namespace rotate_vector + { + template inline detail::_xvec2 rotate(const detail::_xvec2& v, T angle){return rotateGTX(v, angle);} //!< \brief Rotate a two dimentionnals vector (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec3 rotate(const detail::_xvec3& v, T angle, const detail::_xvec3& normal){return rotateGTX(v, angle, normal);} //!< \brief Rotate a three dimentionnals vector around an axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec4 rotate(const detail::_xvec4& v, T angle, const detail::_xvec3& normal){return rotateGTX(v, angle, normal);} //!< \brief Rotate a four dimentionnals vector around an axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec3 rotateX(const detail::_xvec3& v, T angle){return rotateXGTX(v, angle);} //!< \brief Rotate a three dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec3 rotateY(const detail::_xvec3& v, T angle){return rotateYGTX(v, angle);} //!< \brief Rotate a three dimentionnals vector around the Y axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec3 rotateZ(const detail::_xvec3& v, T angle){return rotateZGTX(v, angle);} //!< \brief Rotate a three dimentionnals vector around the Z axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec4 rotateX(const detail::_xvec4& v, T angle){return rotateXGTX(v, angle);} //!< \brief Rotate a four dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec4 rotateY(const detail::_xvec4& v, T angle){return rotateYGTX(v, angle);} //!< \brief Rotate a four dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xvec4 rotateZ(const detail::_xvec4& v, T angle){return rotateZGTX(v, angle);} //!< \brief Rotate a four dimentionnals vector around the X axis (from GLM_GTX_rotate_vector extension) + template inline detail::_xmat4 orientation(const detail::_xvec3& Normal, const detail::_xvec3& Up){return orientationGTX(Normal, Up);} //!< \brief Build a rotation matrix from a normal and a up vector (from GLM_GTX_rotate_vector extension) + } + } +} + +#define GLM_GTX_rotate_vector namespace gtx::rotate_vector + +#include "rotate_vector.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_rotate_vector;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_rotate_vector__ diff --git a/wip/sse/glm/ext/gtx/rotate_vector.inl b/wip/sse/glm/ext/gtx/rotate_vector.inl new file mode 100644 index 00000000..e788f91a --- /dev/null +++ b/wip/sse/glm/ext/gtx/rotate_vector.inl @@ -0,0 +1,119 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-11-02 +// Updated : 2006-11-02 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/rotate_vector.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xvec2 rotateGTX(const detail::_xvec2& v, T angle) + { + detail::_xvec2 Result; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; + }; + + template + inline detail::_xvec3 rotateGTX(const detail::_xvec3& v, T angle, const detail::_xvec3& normal) + { + return rotateGTX(angle, normal) * v; + } +/* + template + inline detail::_xvec3 rotateGTX(const detail::_xvec3& x, T angle, const detail::_xvec3& normal) + { + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin; + } +*/ + template + inline detail::_xvec4 rotateGTX(const detail::_xvec4& v, T angle, const detail::_xvec3& normal) + { + return rotateGTX(angle, normal) * v; + } + + template + inline detail::_xvec3 rotateXGTX(const detail::_xvec3& v, T angle) + { + detail::_xvec3 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.y = v.y * Cos - v.z * Sin; + Result.z = v.y * Sin + v.z * Cos; + return Result; + } + + template + inline detail::_xvec3 rotateYGTX(const detail::_xvec3& v, T angle) + { + detail::_xvec3 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos + v.z * Sin; + Result.z = -v.x * Sin + v.z * Cos; + return Result; + } + + template + inline detail::_xvec3 rotateZGTX(const detail::_xvec3& v, T angle) + { + detail::_xvec3 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; + }; + + template + inline detail::_xvec4 rotateXGTX(const detail::_xvec4& v, T angle) + { + detail::_xvec4 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.y = v.y * Cos - v.z * Sin; + Result.z = v.y * Sin + v.z * Cos; + return Result; + } + + template + inline detail::_xvec4 rotateYGTX(const detail::_xvec4& v, T angle) + { + detail::_xvec4 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos + v.z * Sin; + Result.z = -v.x * Sin + v.z * Cos; + return Result; + } + + template + inline detail::_xvec4 rotateZGTX(const detail::_xvec4& v, T angle) + { + detail::_xvec4 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; + }; + + template + inline detail::_xmat4 orientationGTX(const detail::_xvec3& Normal, const detail::_xvec3& Up) + { + if(all(equal(Normal, Up))) + return detail::_xmat4(T(1)); + + detail::_xvec3 RotationAxis = cross(Up, Normal); + T Angle = degrees(acos(dot(Normal, Up))); + return rotateGTX(Angle, RotationAxis); + } +} diff --git a/wip/sse/glm/ext/gtx/round.h b/wip/sse/glm/ext/gtx/round.h new file mode 100644 index 00000000..cf4a47c3 --- /dev/null +++ b/wip/sse/glm/ext/gtx/round.h @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/round.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_half +// - GLM_GTX_double +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_round__ +#define __glm_gtx_round__ + +// Dependency: +#include "../../glm.h" +#include "../../ext/gtx/half.h" +#include "../../ext/gtx/double.h" + +namespace glm +{ + template genType roundGTX(const genType& x); //!< \brief Computes the component-wise round value of x (from GLM_GTX_round extension) + __halfGTX roundGTX(__halfGTX x); //!< \brief Computes the round value of x (from GLM_GTX_round extension) + float roundGTX(float x); //!< \brief Computes the round value of x (from GLM_GTX_round extension) + double roundGTX(double x); //!< \brief Computes the round value of x (from GLM_GTX_round extension) + + namespace gtx + { + //! GLM_GTX_round extension: Computes the round value + namespace round + { + template inline genType round(const genType& x){return roundGTX(x);} //!< \brief Computes the component-wise round value of x (from GLM_GTX_round extension) + inline __halfGTX round(__halfGTX x){return roundGTX(x);} //!< \brief Computes the round value of x (from GLM_GTX_round extension) + inline float round(float x){return roundGTX(x);} //!< \brief Computes the round value of x (from GLM_GTX_round extension) + inline double round(double x){return roundGTX(x);} //!< \brief Computes the round value of x (from GLM_GTX_round extension) + } + } +} + +#define GLM_GTX_round namespace gtx::round + +#include "round.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_round;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_round__ diff --git a/wip/sse/glm/ext/gtx/round.inl b/wip/sse/glm/ext/gtx/round.inl new file mode 100644 index 00000000..2d6b9384 --- /dev/null +++ b/wip/sse/glm/ext/gtx/round.inl @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/round.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GL_GTX_double +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline genType roundGTX(const genType& x) + { + genType result; + int i = x._size(); + while(i--) + result[i] = float(int(x[i] + 0.5f)); + return result; + } + + inline __halfGTX roundGTX(__halfGTX x) + { + return __halfGTX(roundGTX(float(x))); + } + + inline float roundGTX(float x) + { + return float(int(x + 0.5f)); + } + + inline double roundGTX(double x) + { + return double(int(x + 0.5)); + } +} diff --git a/wip/sse/glm/ext/gtx/spline.h b/wip/sse/glm/ext/gtx/spline.h new file mode 100644 index 00000000..4b27ce23 --- /dev/null +++ b/wip/sse/glm/ext/gtx/spline.h @@ -0,0 +1,46 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-25 +// Updated : 2007-03-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/spline.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_spline__ +#define __glm_gtx_spline__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template genType catmullRomGTX(const genType& v1, const genType& v2, const genType& v3, const genType& v4, const GLMvalType& s); //!< Return a point from a catmull rom curve (from GLM_GTX_spline extension) + template genType hermiteGTX(const genType& v1, const genType& t1, const genType& v2, const genType& t2, const GLMvalType& s); //!< Return a point from a hermite curve (from GLM_GTX_spline extension) + template genType cubicGTX(const genType& v1, const genType& v2, const genType& v3, const genType& v4, const GLMvalType& s); //!< Return a point from a cubic curve (from GLM_GTX_spline extension) + + namespace gtx + { + //! GLM_GTX_spline extension: Spline functions + namespace spline + { + template inline genType catmullRom(const genType& v1, const genType& v2, const genType& v3, const genType& v4, const GLMvalType& s){return catmullRomGTX(v1, v2, v3, v4, s);} //!< Return a point from a catmull rom curve (from GLM_GTX_spline extension) + template inline genType hermite(const genType& v1, const genType& t1, const genType& v2, const genType& t2, const GLMvalType& s){return hermiteGTX(v1, t1, v2, t2, s);} //!< Return a point from a hermite curve (from GLM_GTX_spline extension) + template inline genType cubic(const genType& v1, const genType& v2, const genType& v3, const genType& v4, const GLMvalType& s){return cubicGTX(v1, v2, v3, v4, s);} //!< Return a point from a cubic curve (from GLM_GTX_spline extension) + } + } +} + +#define GLM_GTX_spline namespace gtx::spline + +#include "spline.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_spline;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_spline__ + diff --git a/wip/sse/glm/ext/gtx/spline.inl b/wip/sse/glm/ext/gtx/spline.inl new file mode 100644 index 00000000..d75858aa --- /dev/null +++ b/wip/sse/glm/ext/gtx/spline.inl @@ -0,0 +1,48 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-25 +// Updated : 2007-03-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/spline.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline genType catmullRomGTX(const genType& v1, const genType& v2, const genType& v3, const genType& v4, const GLMvalType& s) + { + GLMvalType s1 = s; + GLMvalType s2 = pow2GTX(s); + GLMvalType s3 = pow3GTX(s); + + GLMvalType f1 = -s3 + GLMvalType(2) * s2 - s; + GLMvalType f2 = GLMvalType(3) * s3 - GLMvalType(5) * s2 + GLMvalType(2); + GLMvalType f3 = GLMvalType(-3) * s3 + GLMvalType(4) * s2 + s; + GLMvalType f4 = s3 - s2; + + return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / GLMvalType(2); + + } + + template + inline genType hermiteGTX(const genType& v1, const genType& t1, const genType& v2, const genType& t2, const GLMvalType& s) + { + GLMvalType s1 = s; + GLMvalType s2 = pow2GTX(s); + GLMvalType s3 = pow3GTX(s); + + GLMvalType f1 = GLMvalType(2) * s3 - GLMvalType(3) * s2 + GLMvalType(1); + GLMvalType f2 = GLMvalType(-2) * s3 + GLMvalType(3) * s2; + GLMvalType f3 = s3 - GLMvalType(2) * s2 + s; + GLMvalType f4 = s3 - s2; + + return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; + } + + template + inline genType cubicGTX(const genType& v1, const genType& v2, const genType& v3, const genType& v4, const GLMvalType& s) + { + return ((v1 * s + v2) * s + v3) * s + v4; + } +} diff --git a/wip/sse/glm/ext/gtx/statistics_operation.h b/wip/sse/glm/ext/gtx/statistics_operation.h new file mode 100644 index 00000000..fa4e8225 --- /dev/null +++ b/wip/sse/glm/ext/gtx/statistics_operation.h @@ -0,0 +1,71 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-11-21 +// Updated : 2007-11-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/statistics_operation.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_statistics_operation__ +#define __glm_gtx_statistics_operation__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template T distanceGTX(const _xvec2& v1, const _xvec2& v2); + template T distanceGTX(const _xvec3& v1, const _xvec3& v2); + template T distanceGTX(const _xvec4& v1, const _xvec4& v2); + + template T distanceGTX(const _xmat2& m1, const _xmat2& m2); + template T distanceGTX(const _xmat3& m1, const _xmat3& m2); + template T distanceGTX(const _xmat4& m1, const _xmat4& m2); + + template T expectedValueGTX(const _xvec2& v1, const _xvec2& v2); + template T expectedValueGTX(const _xvec3& v1, const _xvec3& v2); + template T expectedValueGTX(const _xvec4& v1, const _xvec4& v2); + + template T expectedValueGTX(const _xmat2& m1, const _xmat2& m2); + template T expectedValueGTX(const _xmat3& m1, const _xmat3& m2); + template T expectedValueGTX(const _xmat4& m1, const _xmat4& m2); + + template T varianceGTX(const _xvec2& v1, const _xvec2& v2); + template T varianceGTX(const _xvec3& v1, const _xvec3& v2); + template T varianceGTX(const _xvec4& v1, const _xvec4& v2); + + template T varianceGTX(const _xmat2& m1, const _xmat2& m2); + template T varianceGTX(const _xmat3& m1, const _xmat3& m2); + template T varianceGTX(const _xmat4& m1, const _xmat4& m2); + + template T standardDevitionGTX(const _xvec2& v1, const _xvec2& v2); + template T standardDevitionGTX(const _xvec3& v1, const _xvec3& v2); + template T standardDevitionGTX(const _xvec4& v1, const _xvec4& v2); + + template T standardDevitionGTX(const _xmat2& m1, const _xmat2& m2); + template T standardDevitionGTX(const _xmat3& m1, const _xmat3& m2); + template T standardDevitionGTX(const _xmat4& m1, const _xmat4& m2); + + namespace gtx + { + //! GLM_GTX_statistics_operation extension: - Work in progress - Statistics functions + namespace statistics_operation + { + + } + } +} + +#define GLM_GTX_statistics_operation namespace gtx::statistics_operation + +#include "statistics_operation.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_statistics_operation;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_statistics_operation__ diff --git a/wip/sse/glm/ext/gtx/statistics_operation.inl b/wip/sse/glm/ext/gtx/statistics_operation.inl new file mode 100644 index 00000000..97644a9b --- /dev/null +++ b/wip/sse/glm/ext/gtx/statistics_operation.inl @@ -0,0 +1,81 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-11-21 +// Updated : 2007-11-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/statistics_operator.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm +{ + //! Compute the sum of square of differences between each matrices paremeters + template + inline T distanceGTX(const _xmat2& m1, const _xmat2& m2) + { + T result = T(0); + for(int j = 0; j < 2; ++j) + for(int i = 0; i < 2; ++i) + { + T diff = m1[j][i] - m2[j][i]; + result += diff * diff; + } + return result; + } + + template + inline T distanceGTX(const _xmat3& m1, const _xmat3& m2) + { + T result = T(0); + for(int j = 0; j < 3; ++j) + for(int i = 0; i < 3; ++i) + { + T diff = m1[j][i] - m2[j][i]; + result += diff * diff; + } + return result; + } + + template + inline T distanceGTX(const _xmat4& m1, const _xmat4& m2) + { + T result = T(0); + for(int j = 0; j < 4; ++j) + for(int i = 0; i < 4; ++i) + { + T diff = m1[j][i] - m2[j][i]; + result += diff * diff; + } + return result; + } + + template + T expectedValueGTX(const _xmat4& m) + { + T result = T(0); + for(int j = 0; j < 4; ++j) + for(int i = 0; i < 4; ++i) + result += m[j][i]; + result *= T(0,0625); + return result; + } + + template + T varianceGTX(const _xmat4& m) + { + T ExpectedValue = expectedValueGTX(m); + T ExpectedValueOfSquaredMatrix = expectedValueGTX(matrixCompMult(m)); + return ExpectedValueOfSquaredMatrix - ExpectedValue * ExpectedValue; + } + + template + T standardDevitionGTX(const _xmat4& m) + { + return sqrt(varianceGTX(m)); + } +} diff --git a/wip/sse/glm/ext/gtx/transform.h b/wip/sse/glm/ext/gtx/transform.h new file mode 100644 index 00000000..b7004dde --- /dev/null +++ b/wip/sse/glm/ext/gtx/transform.h @@ -0,0 +1,107 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/transform.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_transform__ +#define __glm_gtx_transform__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat4 translateGTX(T x, T y, T z); //!< /brief Builds a translation 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template detail::_xmat4 translateGTX(const detail::_xvec3 & v); //!< /brief Builds a translation 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template detail::_xmat4 translateGTX(const detail::_xmat4 & m, T x, T y, T z); //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template detail::_xmat4 translateGTX(const detail::_xmat4 & m, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template detail::_xmat4 rotateGTX(T angle, T x, T y, T z); //!< /brief Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat4 rotateGTX(T angle, const detail::_xvec3 & v); //!< /brief Builds a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat4 rotateGTX(const detail::_xmat4 & m, T angle, T x, T y, T z); //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat4 rotateGTX(const detail::_xmat4 & m, T angle, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat4 scaleGTX(T x, T y, T z); //!< /brief Builds a scale 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template detail::_xmat4 scaleGTX(const detail::_xvec3 & v); //!< /brief Builds a scale 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template detail::_xmat4 scaleGTX(const detail::_xmat4 & m, T x, T y, T z); //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template detail::_xmat4 scaleGTX(const detail::_xmat4 & m, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + + // 3D + template detail::_xmat4 translate3DGTX(const detail::_xmat4 & m, T x, T y, T z); //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template detail::_xmat4 translate3DGTX(const detail::_xmat4 & m, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template detail::_xmat4 rotate3DGTX(const detail::_xmat4 & m, T angle, T x, T y, T z); //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat4 rotate3DGTX(const detail::_xmat4 & m, T angle, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat3 rotate3DGTX(const detail::_xmat3 & m, T angle, T x, T y, T z); //!< /brief Transforms a matrix with a rotation 3 * 3 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat3 rotate3DGTX(const detail::_xmat3 & m, T angle, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a rotation 3 * 3 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat4 scale3DGTX(const detail::_xmat4 & m, T x, T y, T z); //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template detail::_xmat4 scale3DGTX(const detail::_xmat4 & m, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template detail::_xmat3 scale3DGTX(const detail::_xmat3 & m, T x, T y, T z); //!< /brief Transforms a matrix with a scale 3 * 3 matrix created from 3 scalars (from GLM_GTX_transform extension) + template detail::_xmat3 scale3DGTX(const detail::_xmat3 & m, const detail::_xvec3 & v); //!< /brief Transforms a matrix with a scale 3 * 3 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + + // 2D + template detail::_xmat3 translate2DGTX(const detail::_xmat3 & m, T x, T y); //!< /brief Translates a 3 * 3 matrix from 2 scalars (from GLM_GTX_transform extension) + template detail::_xmat3 translate2DGTX(const detail::_xmat3 & m, const detail::_xvec2 & v); //!< /brief Translates a 3 * 3 matrix from a vector of 2 components (from GLM_GTX_transform extension) + template detail::_xmat3 rotate2DGTX(const detail::_xmat3 & m, T angle); //!< /brief Rotates a 3 * 3 matrix from an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat2 rotate2DGTX(const detail::_xmat2 & m, T angle); //!< /brief Rotates a 2 * 2 matrix from an angle expressed in degrees (from GLM_GTX_transform extension) + template detail::_xmat3 scale2DGTX(const detail::_xmat3 & m, T x, T y); //!< /brief Scales a 3 * 3 matrix using 2 scalars (from GLM_GTX_transform extension) + template detail::_xmat3 scale2DGTX(const detail::_xmat3 & m, const detail::_xvec2 & v); //!< /brief Scales a 3 * 3 matrix using a vector of 2 components (from GLM_GTX_transform extension) + template detail::_xmat2 scale2DGTX(const detail::_xmat2 & m, T x, T y); //!< /brief Scales a 2 * 2 matrix using 2 scalars (from GLM_GTX_transform extension) + template detail::_xmat2 scale2DGTX(const detail::_xmat2 & m, const detail::_xvec2 & v); //!< /brief Scales a 2 * 2 matrix using a vector of 2 components (from GLM_GTX_transform extension) + + namespace gtx + { + //! GLM_GTX_transform extension: Add transformation matrices + namespace transform + { + template inline detail::_xmat4 translate(T x, T y, T z){return translateGTX(x, y, z);} //!< /brief Builds a translation 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat4 translate(const detail::_xvec3 & v){return translateGTX(v);} //!< /brief Builds a translation 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template inline detail::_xmat4 translate(const detail::_xmat4 & m, T x, T y, T z){return translateGTX(m, x, y, z);} //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat4 translate(const detail::_xmat4 & m, const detail::_xvec3 & v){return translateGTX(m, v);} //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template inline detail::_xmat4 rotate(T angle, T x, T y, T z){return rotateGTX(angle, x, y, z);} //!< /brief Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat4 rotate(T angle, const detail::_xvec3 & v){return rotateGTX(angle, v);} //!< /brief Builds a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat4 rotate(const detail::_xmat4 & m, T angle, T x, T y, T z){return rotateGTX(m, angle, x, y, z);} //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat4 rotate(const detail::_xmat4 & m, T angle, const detail::_xvec3 & v){return rotateGTX(m, angle, v);} //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat4 scale(T x, T y, T z){return scaleGTX(x, y, z);} //!< /brief Builds a scale 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat4 scale(const detail::_xvec3 & v){return scaleGTX(v);} //!< /brief Builds a scale 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template inline detail::_xmat4 scale(const detail::_xmat4 & m, T x, T y, T z){return scaleGTX(m, x, y, z);} //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat4 scale(const detail::_xmat4 & m, const detail::_xvec3 & v){return scaleGTX(m, v);} //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + + // 3D + template inline detail::_xmat4 translate3D(const detail::_xmat4 & m, T x, T y, T z){return translate3DGTX(m, x, y, z);} //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat4 translate3D(const detail::_xmat4 & m, const detail::_xvec3 & v){return translate3DGTX(m, v);} //!< /brief Transforms a matrix with a translation 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template inline detail::_xmat4 rotate3D(const detail::_xmat4 & m, T angle, T x, T y, T z){return rotate3DGTX(m, angle, x, y, z);} //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat4 rotate3D(const detail::_xmat4 & m, T angle, const detail::_xvec3 & v){return rotate3DGTX(m, angle, v);} //!< /brief Transforms a matrix with a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat3 rotate3D(const detail::_xmat3 & m, T angle, T x, T y, T z){return rotate3DGTX(m, angle, x, y, z);} //!< /brief Transforms a matrix with a rotation 3 * 3 matrix created from an axis of 3 scalars and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat3 rotate3D(const detail::_xmat3 & m, T angle, const detail::_xvec3 & v){return rotate3DGTX(m, angle, v);} //!< /brief Transforms a matrix with a rotation 3 * 3 matrix created from an axis vector and an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat4 scale3D(const detail::_xmat4 & m, T x, T y, T z){return scale3DGTX(m, x, y, z);} //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from 3 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat4 scale3D(const detail::_xmat4 & m, const detail::_xvec3 & v){return scale3DGTX(m, v);} //!< /brief Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + template inline detail::_xmat3 scale3D(const detail::_xmat3 & m, T x, T y, T z){return scale3DGTX(m, x, y, z);} //!< /brief Transforms a matrix with a scale 3 * 3 matrix created from 3 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat3 scale3D(const detail::_xmat3 & m, const detail::_xvec3 & v){return scale3DGTX(m, v);} //!< /brief Transforms a matrix with a scale 3 * 3 matrix created from a vector of 3 components (from GLM_GTX_transform extension) + + // 2D + template inline detail::_xmat3 translate2D(const detail::_xmat3 & m, T x, T y){return translate2DGTX(m, x, y);} //!< /brief Translates a 3 * 3 matrix from 2 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat3 translate2D(const detail::_xmat3 & m, const detail::_xvec2 & v){return translate2DGTX(m, v);} //!< /brief Translates a 3 * 3 matrix from a vector of 2 components (from GLM_GTX_transform extension) + template inline detail::_xmat3 rotate2D(const detail::_xmat3 & m, T angle){return rotate2DGTX(m, angle);} //!< /brief Rotates a 3 * 3 matrix from an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat2 rotate2D(const detail::_xmat2 & m, T angle){return rotate2DGTX(m, angle);} //!< /brief Rotates a 2 * 2 matrix from an angle expressed in degrees (from GLM_GTX_transform extension) + template inline detail::_xmat3 scale2D(const detail::_xmat3 & m, T x, T y){return scale2DGTX(m, x, y);} //!< /brief Scales a 3 * 3 matrix using 2 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat3 scale2D(const detail::_xmat3 & m, const detail::_xvec2 & v){return scale2DGTX(m, v);} //!< /brief Scales a 3 * 3 matrix using a vector of 2 components (from GLM_GTX_transform extension) + template inline detail::_xmat2 scale2D(const detail::_xmat2 & m, T x, T y){return scale2DGTX(m, x, y);} //!< /brief Scales a 2 * 2 matrix using 2 scalars (from GLM_GTX_transform extension) + template inline detail::_xmat2 scale2D(const detail::_xmat2 & m, const detail::_xvec2 & v){return scale2DGTX(m, v);} //!< /brief Scales a 2 * 2 matrix using a vector of 2 components (from GLM_GTX_transform extension) + } + } +} + +#define GLM_GTX_transform namespace gtx::transform + +#include "transform.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_transform;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_transform__ diff --git a/wip/sse/glm/ext/gtx/transform.inl b/wip/sse/glm/ext/gtx/transform.inl new file mode 100644 index 00000000..84c5b183 --- /dev/null +++ b/wip/sse/glm/ext/gtx/transform.inl @@ -0,0 +1,334 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/transform.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat4 translateGTX(T x, T y, T z) + { + return translateGTX(detail::_xvec3(x, y , z)); + } + + template + inline detail::_xmat4 translateGTX(const detail::_xvec3& v) + { + detail::_xmat4 result(T(1)); + result[3] = detail::_xvec4(v, T(1)); + return result; + } + + template + inline detail::_xmat4 translateGTX(const detail::_xmat4& m, T x, T y, T z) + { + detail::_xmat4 r; + r[0] = m[0]; + r[1] = m[1]; + r[2] = m[2]; + r[3][0] = m[0][0] * x + m[1][0] * y + m[2][0] * z + m[3][0]; + r[3][1] = m[0][1] * x + m[1][1] * y + m[2][1] * z + m[3][1]; + r[3][2] = m[0][2] * x + m[1][2] * y + m[2][2] * z + m[3][2]; + r[3][3] = m[0][3] * x + m[1][3] * y + m[2][3] * z + m[3][3]; + return r; + } + + template + inline detail::_xmat4 translateGTX(const detail::_xmat4& m, const detail::_xvec3& v) + { + return translateGTX(m, v.x, v.y, v.z); + } + + template + inline detail::_xmat4 rotateGTX(T angle, T x, T y, T z) + { + float a = radians(angle); + float c = cos(a); + float s = sin(a); + detail::_xmat4 Result; + + detail::_xvec3 axis = normalize(detail::_xvec3(x, y, z)); + + Result[0][0] = c + (1 - c) * axis.x * axis.x; + Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; + Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y; + Result[0][3] = 0; + + Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; + Result[1][1] = c + (1 - c) * axis.y * axis.y; + Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; + Result[1][3] = 0; + + Result[2][0] = (1 - c) * axis.x * axis.z + s * axis.y; + Result[2][1] = (1 - c) * axis.y * axis.z - s * axis.x; + Result[2][2] = c + (1 - c) * axis.z * axis.z; + Result[2][3] = 0; + + Result[3] = detail::_xvec4(0, 0, 0, 1); + return Result; + } + + template + inline detail::_xmat4 rotateGTX(T angle, const detail::_xvec3& v) + { + return rotateGTX(angle, v.x, v.y, v.z); + } + + template + inline detail::_xmat4 rotateGTX(const detail::_xmat4& m, T angle, T x, T y, T z) + { + return m * rotateGTX(angle, x, y, z); + } + + template + inline detail::_xmat4 rotateGTX(const detail::_xmat4& m, T angle, const detail::_xvec3& v) + { + return m * rotateGTX(angle, v.x, v.y, v.z); + } + + template + inline detail::_xmat4 scaleGTX(T x, T y, T z) + { + detail::_xmat4 Result(T(1)); + Result[0][0] = x; + Result[1][1] = y; + Result[2][2] = z; + return Result; + } + + template + inline detail::_xmat4 scaleGTX(const detail::_xvec3& v) + { + return scaleGTX(v.x, v.y, v.z); + } + + template + inline detail::_xmat4 scaleGTX(const detail::_xmat4& m, T x, T y, T z) + { + detail::_xmat4 Result; + Result[0] = m[0] * x; + Result[1] = m[1] * y; + Result[2] = m[2] * z; + Result[3] = m[3]; + return Result; + } + + template + inline detail::_xmat4 scaleGTX(const detail::_xmat4& m, const detail::_xvec3& v) + { + return scaleGTX(m, v.x, v.y, v.z); + } + + ///////////////////////////////////////////////// + template + inline detail::_xmat4 translate3DGTX(const detail::_xmat4& m, T x, T y, T z) + { + detail::_xmat4 r; + r[0] = m[0]; + r[1] = m[1]; + r[2] = m[2]; + r[3][0] = m[0][0] * x + m[1][0] * y + m[2][0] * z + m[3][0]; + r[3][1] = m[0][1] * x + m[1][1] * y + m[2][1] * z + m[3][1]; + r[3][2] = m[0][2] * x + m[1][2] * y + m[2][2] * z + m[3][2]; + r[3][3] = m[0][3] * x + m[1][3] * y + m[2][3] * z + m[3][3]; + return r; + } + + template + inline detail::_xmat4 translate3DGTX(const detail::_xmat4& m, const detail::_xvec3& v) + { + return translate3DGTX(m, v.x, v.y, v.z); + } + + template + inline detail::_xmat4 rotate3DGTX(const detail::_xmat4& m, T angle, T x, T y, T z) + { + T a = radians(angle); + T c = cos(a); + T s = sin(a); + detail::_xmat4 Result; + + detail::_xvec3 axis = normalize(detail::_xvec3(x, y, z)); + + Result[0][0] = c + (1 - c) * axis.x * axis.x; + Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; + Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y; + Result[0][3] = 0; + + Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; + Result[1][1] = c + (1 - c) * axis.y * axis.y; + Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; + Result[1][3] = 0; + + Result[2][0] = (1 - c) * axis.x * axis.z + s * axis.y; + Result[2][1] = (1 - c) * axis.y * axis.z - s * axis.x; + Result[2][2] = c + (1 - c) * axis.z * axis.z; + Result[2][3] = 0; + + Result[3] = detail::_xvec4(0, 0, 0, 1); + + return m * Result; + } + + template + inline detail::_xmat4 rotate3DGTX(const detail::_xmat4& m, T angle, const detail::_xvec3& v) + { + return rotate3DGTX(m, angle, v.x, v.y, v.z); + } + + template + inline detail::_xmat3 rotate3DGTX(const detail::_xmat3& m, T angle, T x, T y, T z) + { + T a = radians(angle); + T c = cos(a); + T s = sin(a); + detail::_xmat3 Result; + + detail::_xvec3 axis = normalize(detail::_xvec3(x, y, z)); + + Result[0][0] = c + (1 - c) * axis.x * axis.x; + Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; + Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y; + + Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; + Result[1][1] = c + (1 - c) * axis.y * axis.y; + Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; + + Result[2][0] = (1 - c) * axis.x * axis.z + s * axis.y; + Result[2][1] = (1 - c) * axis.y * axis.z - s * axis.x; + Result[2][2] = c + (1 - c) * axis.z * axis.z; + + return m * Result; + } + + template + inline detail::_xmat3 rotate3DGTX(const detail::_xmat3& m, T angle, const detail::_xvec3& v) + { + return rotate3DGTX(m, angle, v.x, v.y, v.z); + } + + template + inline detail::_xmat4 scale3DGTX(const detail::_xmat4& m, T x, T y, T z) + { + detail::_xmat4 r; + r[0] = m[0] * x; + r[1] = m[1] * y; + r[2] = m[2] * z; + r[3] = m[3]; + return r; + } + + template + inline detail::_xmat4 scale3DGTX(const detail::_xmat4& m, const detail::_xvec3& v) + { + return scale3DGTX(m, v.x, v.y, v.z); + } + + template + inline detail::_xmat3 scale3DGTX(const detail::_xmat3& m, T x, T y, T z) + { + detail::_xmat3 r; + r[0] = m[0] * x; + r[1] = m[1] * y; + r[2] = m[2] * z; + return r; + } + + template + inline detail::_xmat3 scale3DGTX(const detail::_xmat3& m, const detail::_xvec3& v) + { + return scale3DGTX(m, v.x, v.y, v.z); + } + + template + inline detail::_xmat3 translate2DGTX(const detail::_xmat3& m, T x, T y) + { + detail::_xmat3 r; + r[0] = m[0]; + r[1] = m[1]; + r[2] = m[2]; + r[2][0] = m[0][0] * x + m[1][0] * y + m[2][0]; + r[2][1] = m[0][1] * x + m[1][1] * y + m[2][1]; + r[2][2] = m[0][2] * x + m[1][2] * y + m[2][2]; + return r; + } + + template + inline detail::_xmat3 translate2DGTX(const detail::_xmat3& m, const detail::_xvec2& v) + { + return translate2DGTX(m, v.x, v.y); + } + + template + inline detail::_xmat3 rotate2DGTX(const detail::_xmat3& m, T angle) + { + T a = radians(angle); + T c = cos(a); + T s = sin(a); + detail::_xmat3 Result; + + Result[0][0] = c; + Result[0][1] = -s; + Result[0][2] = 0; + + Result[1][0] = s; + Result[1][1] = c; + Result[1][2] = 0; + + Result[2] = detail::_xvec3(0, 0, 1); + + return m * Result; + } + + template + inline detail::_xmat2 rotate2DGTX(const detail::_xmat2& m, T angle) + { + T a = radians(angle); + T c = cos(a); + T s = sin(a); + detail::_xmat2 Result; + + Result[0][0] = c; + Result[0][1] = -s; + + Result[1][0] = s; + Result[1][1] = c; + + return m * Result; + } + + template + inline detail::_xmat3 scale2DGTX(const detail::_xmat3& m, T x, T y) + { + detail::_xmat3 r; + r[0] = m[0] * x; + r[1] = m[1] * y; + r[2] = m[2]; + return r; + } + + template + inline detail::_xmat3 scale2DGTX(const detail::_xmat3& m, const detail::_xvec2& v) + { + return scale2DGTX(m, v.x, v.y); + } + + template + inline detail::_xmat2 scale2DGTX(const detail::_xmat2& m, T x, T y) + { + detail::_xmat2 r; + r[0] = m[0] * x; + r[1] = m[1] * y; + return r; + } + + template + inline detail::_xmat2 scale2DGTX(const detail::_xmat2& m, const detail::_xvec2& v) + { + return scale2DGTX(m, v.x, v.y); + } +} diff --git a/wip/sse/glm/ext/gtx/transform2.h b/wip/sse/glm/ext/gtx/transform2.h new file mode 100644 index 00000000..05973f4e --- /dev/null +++ b/wip/sse/glm/ext/gtx/transform2.h @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/transform2.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_transform2__ +#define __glm_gtx_transform2__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat3 shearX2DGTX(const detail::_xmat3 & m, T y); //!< /brief Transforms a matrix with a shearing on X axis (from GLM_GTX_transform2 extension) + template detail::_xmat3 shearY2DGTX(const detail::_xmat3 & m, T x); //!< /brief Transforms a matrix with a shearing on Y axis (from GLM_GTX_transform2 extension) + template detail::_xmat4 shearX3DGTX(const detail::_xmat4 & m, T y, T z); //!< /brief Transforms a matrix with a shearing on X axis (from GLM_GTX_transform2 extension) + template detail::_xmat4 shearY3DGTX(const detail::_xmat4 & m, T x, T z); //!< /brief Transforms a matrix with a shearing on Y axis (from GLM_GTX_transform2 extension) + template detail::_xmat4 shearZ3DGTX(const detail::_xmat4 & m, T x, T y); //!< /brief Transforms a matrix with a shearing on Z axis (from GLM_GTX_transform2 extension) + //template detail::_xmat4 shearGTX(const detail::_xmat4 & m, shearPlane, planePoint, angle) + // Identity + tan(angle) * cross(Normal, OnPlaneVector) 0 + // - dot(PointOnPlane, normal) * OnPlaneVector 1 + + // Reflect functions seem to don't work + template detail::_xmat3 reflect2DGTX(const detail::_xmat3 & m, const detail::_xvec3& normal); + template detail::_xmat4 reflect3DGTX(const detail::_xmat4 & m, const detail::_xvec3& normal); + template detail::_xmat3 proj2DGTX(const detail::_xmat3 & m, const detail::_xvec3& normal); //!< /brief Build planar projection matrix along normal axis (from GLM_GTX_transform2 extension) + template detail::_xmat4 proj3DGTX(const detail::_xmat4 & m, const detail::_xvec3& normal); //!< /brief Build planar projection matrix along normal axis (from GLM_GTX_transform2 extension) + template detail::_xmat4 lookAtGTX(const detail::_xvec3& eye, const detail::_xvec3& center, const detail::_xvec3& up); //!< /brief Build a look at view matrix (from GLM_GTX_transform2 extension) + + namespace gtx + { + //! GLM_GTX_transform2 extension: Add extra transformation matrices + namespace transform2 + { + template inline detail::_xmat3 shearX2D(const detail::_xmat3 & m, T y){return shearX2DGTX(m, y);} //!< /brief Transforms a matrix with a shearing on X axis (from GLM_GTX_transform2 extension) + template inline detail::_xmat3 shearY2D(const detail::_xmat3 & m, T x){return shearY2DGTX(m, x);} //!< /brief Transforms a matrix with a shearing on Y axis (from GLM_GTX_transform2 extension) + template inline detail::_xmat4 shearX3D(const detail::_xmat4 & m, T y, T z){return shearX3DGTX(m, y, z);} //!< /brief Transforms a matrix with a shearing on X axis (from GLM_GTX_transform2 extension) + template inline detail::_xmat4 shearY3D(const detail::_xmat4 & m, T x, T z){return shearY3DGTX(m, x, z);} //!< /brief Transforms a matrix with a shearing on Y axis (from GLM_GTX_transform2 extension) + template inline detail::_xmat4 shearZ3D(const detail::_xmat4 & m, T x, T y){return shearZ3DGTX(m, x, y);} //!< /brief Transforms a matrix with a shearing on Z axis (from GLM_GTX_transform2 extension) + //template inline detail::_xmat4 shear(const detail::_xmat4 & m, shearPlane, planePoint, angle) + // Identity + tan(angle) * cross(Normal, OnPlaneVector) 0 + // - dot(PointOnPlane, normal) * OnPlaneVector 1 + + // Reflect functions seem to don't work + template inline detail::_xmat3 reflect2D(const detail::_xmat3 & m, const detail::_xvec3& normal){return reflect2DGTX(m, normal);} + template inline detail::_xmat4 reflect3D(const detail::_xmat4 & m, const detail::_xvec3& normal){return reflect3DGTX(m, normal);} + template inline detail::_xmat3 proj2D(const detail::_xmat3 & m, const detail::_xvec3& normal){return proj2DGTX(m, normal);} //!< /brief Build planar projection matrix along normal axis (from GLM_GTX_transform2 extension) + template inline detail::_xmat4 proj3D(const detail::_xmat4 & m, const detail::_xvec3& normal){return proj3DGTX(m, normal);} //!< /brief Build planar projection matrix along normal axis (from GLM_GTX_transform2 extension) + template inline detail::_xmat4 lookAt(const detail::_xvec3& eye, const detail::_xvec3& center, const detail::_xvec3& up){return lookAtGTX(eye, center, up);} //!< /brief Build a look at view matrix (from GLM_GTX_transform2 extension) + } + } +} + +#define GLM_GTX_transform2 namespace gtx::transform2 + +#include "transform2.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_transform2;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_transform2__ diff --git a/wip/sse/glm/ext/gtx/transform2.inl b/wip/sse/glm/ext/gtx/transform2.inl new file mode 100644 index 00000000..06ee280c --- /dev/null +++ b/wip/sse/glm/ext/gtx/transform2.inl @@ -0,0 +1,136 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-02-28 +// Updated : 2005-04-23 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/transform2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat3 shearX2DGTX(const detail::_xmat3& m, T s) + { + detail::_xmat3 r(1); + r[0][1] = s; + return m * r; + } + + template + inline detail::_xmat3 shearY2DGTX(const detail::_xmat3& m, T s) + { + detail::_xmat3 r(1); + r[1][0] = s; + return m * r; + } + + template + inline detail::_xmat4 shearX3DGTX(const detail::_xmat4& m, T s, T t) + { + detail::_xmat4 r(1); + r[1][0] = s; + r[2][0] = t; + return m * r; + } + + template + inline detail::_xmat4 shearY3DGTX(const detail::_xmat4& m, T s, T t) + { + detail::_xmat4 r(1); + r[0][1] = s; + r[2][1] = t; + return m * r; + } + + template + inline detail::_xmat4 shearZ3DGTX(const detail::_xmat4& m, T s, T t) + { + detail::_xmat4 r(1); + r[0][2] = s; + r[1][2] = t; + return m * r; + } + + template + inline detail::_xmat3 reflect2DGTX(const detail::_xmat3& m, const detail::_xvec3& normal) + { + detail::_xmat3 r(1); + r[0][0] = 1 - 2 * normal.x * normal.x; + r[0][1] = -2 * normal.x * normal.y; + r[1][0] = -2 * normal.x * normal.y; + r[1][1] = 1 - 2 * normal.y * normal.y; + return m * r; + } + + template + inline detail::_xmat4 reflect3DGTX(const detail::_xmat4& m, const detail::_xvec3& normal) + { + detail::_xmat4 r(1); + r[0][0] = 1 - 2 * normal.x * normal.x; + r[0][1] = -2 * normal.x * normal.y; + r[0][2] = -2 * normal.x * normal.z; + + r[1][0] = -2 * normal.x * normal.y; + r[1][1] = 1 - 2 * normal.y * normal.y; + r[1][2] = -2 * normal.y * normal.z; + + r[2][0] = -2 * normal.x * normal.z; + r[2][1] = -2 * normal.y * normal.z; + r[2][2] = 1 - 2 * normal.z * normal.z; + return m * r; + } + + template + inline detail::_xmat3 proj2DGTX(const detail::_xmat3& m, const detail::_xvec3& normal) + { + detail::_xmat3 r(1); + r[0][0] = 1 - normal.x * normal.x; + r[0][1] = - normal.x * normal.y; + r[1][0] = - normal.x * normal.y; + r[1][1] = 1 - normal.y * normal.y; + return m * r; + } + + template + inline detail::_xmat4 proj3DGTX(const detail::_xmat4& m, const detail::_xvec3& normal) + { + detail::_xmat4 r(1); + r[0][0] = 1 - normal.x * normal.x; + r[0][1] = - normal.x * normal.y; + r[0][2] = - normal.x * normal.z; + r[1][0] = - normal.x * normal.y; + r[1][1] = 1 - normal.y * normal.y; + r[1][2] = - normal.y * normal.z; + r[2][0] = - normal.x * normal.z; + r[2][1] = - normal.y * normal.z; + r[2][2] = 1 - normal.z * normal.z; + return m * r; + } + + template + inline detail::_xmat4 lookAtGTX(const detail::_xvec3& eye, const detail::_xvec3& center, const detail::_xvec3& up) + { + detail::_xvec3 f = normalize(center - eye); + detail::_xvec3 u = normalize(up); + detail::_xvec3 s = normalize(cross(f, u)); + u = cross(s, f); + + detail::_xmat4 Result(1); + Result[0][0] = s.x; + Result[1][0] = s.y; + Result[2][0] = s.z; + Result[0][1] = u.x; + Result[1][1] = u.y; + Result[2][1] = u.z; + Result[0][2] =-f.x; + Result[1][2] =-f.y; + Result[2][2] =-f.z; + /* Test this instead of translate3DGTX + Result[3][0] =-dot(s, eye); + Result[3][1] =-dot(y, eye); + Result[3][2] = dot(f, eye); + */ + return translate3DGTX(Result, -eye); + } +} diff --git a/wip/sse/glm/ext/gtx/transpose.h b/wip/sse/glm/ext/gtx/transpose.h new file mode 100644 index 00000000..a00aab10 --- /dev/null +++ b/wip/sse/glm/ext/gtx/transpose.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/transpose.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_transpose__ +#define __glm_gtx_transpose__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xmat2 transposeGTX(const detail::_xmat2& x); //!< - Deprecated - Returns the transposed 2 * 2 matrix of x (From GLM_GTX_transpose extension) + template detail::_xmat3 transposeGTX(const detail::_xmat3& x); //!< - Deprecated - Returns the transposed 3 * 3 matrix of x (From GLM_GTX_transpose extension) + template detail::_xmat4 transposeGTX(const detail::_xmat4& x); //!< - Deprecated - Returns the transposed 4 * 4 matrix of x (From GLM_GTX_transpose extension) + + namespace gtx + { + //! GLM_GTX_transpose extension: - Deprecated - Use GLM core function instead + namespace transpose + { + template inline detail::_xmat2 transpose(const detail::_xmat2& x){return transposeGTX(x);} //!< - Deprecated - Returns the transposed 2 * 2 matrix of x (From GLM_GTX_transpose extension) + template inline detail::_xmat3 transpose(const detail::_xmat3& x){return transposeGTX(x);} //!< - Deprecated - Returns the transposed 3 * 3 matrix of x (From GLM_GTX_transpose extension) + template inline detail::_xmat4 transpose(const detail::_xmat4& x){return transposeGTX(x);} //!< - Deprecated - Returns the transposed 4 * 4 matrix of x (From GLM_GTX_transpose extension) + } + } +} + +#define GLM_GTX_transpose namespace gtx::transpose + +#include "transpose.inl" +/* Deprecated +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_transpose;} +#endif//GLM_GTX_INCLUDED +*/ +#endif//__glm_gtx_transpose__ diff --git a/wip/sse/glm/ext/gtx/transpose.inl b/wip/sse/glm/ext/gtx/transpose.inl new file mode 100644 index 00000000..b7df22a0 --- /dev/null +++ b/wip/sse/glm/ext/gtx/transpose.inl @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/transpose.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xmat2 transposeGTX(const detail::_xmat2& m) + { + detail::_xmat2 Transpose; + Transpose[0][0] = m[0][0]; + Transpose[0][1] = m[1][0]; + Transpose[1][0] = m[0][1]; + Transpose[1][1] = m[1][1]; + return Transpose; + } + + template + inline detail::_xmat3 transposeGTX(const detail::_xmat3& m) + { + detail::_xmat3 Transpose; + Transpose[0][0] = m[0][0]; + Transpose[0][1] = m[1][0]; + Transpose[0][2] = m[2][0]; + + Transpose[1][0] = m[0][1]; + Transpose[1][1] = m[1][1]; + Transpose[1][2] = m[2][1]; + + Transpose[2][0] = m[0][2]; + Transpose[2][1] = m[1][2]; + Transpose[2][2] = m[2][2]; + return Transpose; + } + + template + inline detail::_xmat4 transposeGTX(const detail::_xmat4& m) + { + detail::_xmat4 Transpose; + Transpose[0][0] = m[0][0]; + Transpose[0][1] = m[1][0]; + Transpose[0][2] = m[2][0]; + Transpose[0][3] = m[3][0]; + + Transpose[1][0] = m[0][1]; + Transpose[1][1] = m[1][1]; + Transpose[1][2] = m[2][1]; + Transpose[1][3] = m[3][1]; + + Transpose[2][0] = m[0][2]; + Transpose[2][1] = m[1][2]; + Transpose[2][2] = m[2][2]; + Transpose[2][3] = m[3][2]; + + Transpose[3][0] = m[0][3]; + Transpose[3][1] = m[1][3]; + Transpose[3][2] = m[2][3]; + Transpose[3][3] = m[3][3]; + return Transpose; + } +} diff --git a/wip/sse/glm/ext/gtx/unsigned_int.h b/wip/sse/glm/ext/gtx/unsigned_int.h new file mode 100644 index 00000000..ae21d450 --- /dev/null +++ b/wip/sse/glm/ext/gtx/unsigned_int.h @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-24 +// Updated : 2006-11-14 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/unsigned_int.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_unsigned_int +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_unsigned_int__ +#define __glm_gtx_unsigned_int__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/integer.h" + +namespace glm +{ + unsigned int powGTX(unsigned int x, unsigned int y); //!< \brief Returns x raised to the y power. (From GLM_GTX_unsigned_int extensions) + unsigned int sqrtGTX(unsigned int x); //!< \brief Returns the positive square root of x. (From GLM_GTX_unsigned_int extensions) + unsigned int modGTX(unsigned int x, unsigned int y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_unsigned_int extensions) + + namespace gtx + { + //! GLM_GTX_unsigned_int extension: Add support for unsigned integer for core functions + namespace unsigned_int + { + inline unsigned int pow(unsigned int x, unsigned int y){return powGTX(x, y);} //!< \brief Returns x raised to the y power. (From GLM_GTX_unsigned_int extensions) + inline unsigned int sqrt(unsigned int x){return sqrtGTX(x);} //!< \brief Returns the positive square root of x. (From GLM_GTX_unsigned_int extensions) + inline unsigned int mod(unsigned int x, unsigned int y){return modGTX(x, y);} //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_unsigned_int extensions) + } + } +} + +#define GLM_GTX_unsigned_int namespace gtx::unsigned_int; using namespace gtx::integer + +#include "unsigned_int.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_unsigned_int;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_unsigned_int__ diff --git a/wip/sse/glm/ext/gtx/unsigned_int.inl b/wip/sse/glm/ext/gtx/unsigned_int.inl new file mode 100644 index 00000000..ae0d8121 --- /dev/null +++ b/wip/sse/glm/ext/gtx/unsigned_int.inl @@ -0,0 +1,40 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-24 +// Updated : 2006-12-06 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/unsigned_int.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + inline unsigned int powGTX(unsigned int x, unsigned int y) + { + unsigned int result = x; + for(unsigned int i = 1; i < y; ++i) + result *= x; + return result; + } + + inline unsigned int sqrtGTX(unsigned int x) + { + if(x <= 1) return x; + + unsigned int NextTrial = x >> 1; + unsigned int CurrentAnswer; + + do + { + CurrentAnswer = NextTrial; + NextTrial = (NextTrial + x / NextTrial) >> 1; + } while(NextTrial < CurrentAnswer); + + return CurrentAnswer; + } + + inline unsigned int modGTX(unsigned int x, unsigned int y) + { + return x - y * (x / y); + } +} diff --git a/wip/sse/glm/ext/gtx/vector_access.h b/wip/sse/glm/ext/gtx/vector_access.h new file mode 100644 index 00000000..e30cb2a4 --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_access.h @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-16 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_access.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_double +// - GLM_GTX_half +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_vector_access__ +#define __glm_gtx_vector_access__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/half.h" +#include "../gtx/double.h" + +namespace glm +{ +/* + void setGTX(float& v, float x); + void setGTX(int& v, int x); + void setGTX(bool& v, bool x); + void setGTX(double& v, double x); + void setGTX(__halfGTX& v, __halfGTX x); +*/ + template void setGTX(detail::_xvec2& v, T x, T y); //!< \brief Sets values to a 2 components vector of floating-point numbers or integers (from GLM_GTX_vector_access extension) + template void setGTX(detail::_xvec3& v, T x, T y, T z); //!< \brief Sets values to a 3 components vector of floating-point numbers or integers (from GLM_GTX_vector_access extension) + template void setGTX(detail::_xvec4& v, T x, T y, T z, T w); //!< \brief Sets values to a 4 components vector of floating-point numbers or integers (from GLM_GTX_vector_access extension) + + void setGTX(detail::_bvec2& v, bool x, bool y); //!< \brief Sets values to a 2 components vector of booleans (from GLM_GTX_vector_access extension) + void setGTX(detail::_bvec3& v, bool x, bool y, bool z); //!< \brief Sets values to a 3 components vector of booleans (from GLM_GTX_vector_access extension) + void setGTX(detail::_bvec4& v, bool x, bool y, bool z, bool w); //!< \brief Sets values to a 4 components vector of booleans (from GLM_GTX_vector_access extension) + + namespace gtx + { + //! GLM_GTX_vector_access extension: Function to set values to vectors + namespace vector_access + { + template void set(detail::_xvec2& v, T x, T y){setGTX(v, x, y);} //!< \brief Sets values to a 2 components vector of floating-point numbers or integers (from GLM_GTX_vector_access extension) + template void set(detail::_xvec3& v, T x, T y, T z){setGTX(v, x, y, z);} //!< \brief Sets values to a 3 components vector of floating-point numbers or integers (from GLM_GTX_vector_access extension) + template void set(detail::_xvec4& v, T x, T y, T z, T w){setGTX(v, x, y, z, w);} //!< \brief Sets values to a 4 components vector of floating-point numbers or integers (from GLM_GTX_vector_access extension) + + inline void set(detail::_bvec2& v, bool x, bool y){setGTX(v, x, y);} //!< \brief Sets values to a 2 components vector of booleans (from GLM_GTX_vector_access extension) + inline void set(detail::_bvec3& v, bool x, bool y, bool z){setGTX(v, x, y, z);} //!< \brief Sets values to a 3 components vector of booleans (from GLM_GTX_vector_access extension) + inline void set(detail::_bvec4& v, bool x, bool y, bool z, bool w){setGTX(v, x, y, z, w);} //!< \brief Sets values to a 4 components vector of booleans (from GLM_GTX_vector_access extension) + } + } +} + +#define GLM_GTX_vector_access namespace gtx::vector_access + +#include "vector_access.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_vector_access;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_vector_access__ diff --git a/wip/sse/glm/ext/gtx/vector_access.inl b/wip/sse/glm/ext/gtx/vector_access.inl new file mode 100644 index 00000000..a2ad8ede --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_access.inl @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-16 +// Updated : 2006-01-16 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_access.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ +/* + inline void setGTX(float& v, float x) + { + v = x; + } + + inline void setGTX(int& v, int x) + { + v = x; + } + + inline void setGTX(bool& v, bool x) + { + v = x; + } + + inline void setGTX(double& v, double x) + { + v = x; + } + + inline void setGTX(__halfGTX& v, __halfGTX x) + { + v = x; + } +*/ + template + inline void setGTX(detail::_xvec2& v, T x, T y) + { + v.x = x; + v.y = y; + } + + template + inline void setGTX(detail::_xvec3& v, T x, T y, T z) + { + v.x = x; + v.y = y; + v.z = z; + } + + template + inline void setGTX(detail::_xvec4& v, T x, T y, T z, T w) + { + v.x = x; + v.y = y; + v.z = z; + v.w = w; + } + + inline void setGTX(detail::_bvec2& v, bool x, bool y) + { + v.x = x; + v.y = y; + } + + inline void setGTX(detail::_bvec3& v, bool x, bool y, bool z) + { + v.x = x; + v.y = y; + v.z = z; + } + + inline void setGTX(detail::_bvec4& v, bool x, bool y, bool z, bool w) + { + v.x = x; + v.y = y; + v.z = z; + v.w = w; + } +} diff --git a/wip/sse/glm/ext/gtx/vector_angle.h b/wip/sse/glm/ext/gtx/vector_angle.h new file mode 100644 index 00000000..b4c03df5 --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_angle.h @@ -0,0 +1,56 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-30 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_angle.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +// - GLM_GTX_quaternion +// - GLM_GTX_epsilon +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_vector_angle__ +#define __glm_gtx_vector_angle__ + +// Dependency: +#include "../../glm.h" +#include "../gtx/quaternion.h" +#include "../gtx/epsilon.h" + +namespace glm +{ + template T angleGTX(const T x, const T y); //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + template T angleGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + template T angleGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + template T angleGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + template T orientedAngleGTX(const detail::_xvec2& x, const detail::_xvec2& y); //!< Returns the oriented angle between x and y (From GLM_GTX_vector_angle extension) + template T orientedAngleGTX(const detail::_xvec3& x, const detail::_xvec3& y); //!< Returns the oriented angle between x and y (From GLM_GTX_vector_angle extension) + template T orientedAngleGTX(const detail::_xvec4& x, const detail::_xvec4& y); //!< Returns the oriented angle between x and y (From GLM_GTX_vector_angle extension) + + namespace gtx + { + //! GLM_GTX_vector_angle extension: Compute angle between vectors + namespace vector_angle + { + template inline T angle(const T x, const T y){return angleGTX(x, y);} //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + template inline T angle(const detail::_xvec2& x, const detail::_xvec2& y){return angleGTX(x, y);} //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + template inline T angle(const detail::_xvec3& x, const detail::_xvec3& y){return angleGTX(x, y);} //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + template inline T angle(const detail::_xvec4& x, const detail::_xvec4& y){return angleGTX(x, y);} //!< Returns the absolute angle between x and y (From GLM_GTX_vector_angle extension) + + template inline GLMvalType orientedAngle(const genType& x, const genType& y){return orientedAngleGTX(x, y);} //!< Returns the oriented angle between x and y (From GLM_GTX_vector_angle extension) + } + } +} + +#define GLM_GTX_vector_angle namespace gtx::vector_angle + +#include "vector_angle.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_vector_angle;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_vector_angle__ diff --git a/wip/sse/glm/ext/gtx/vector_angle.inl b/wip/sse/glm/ext/gtx/vector_angle.inl new file mode 100644 index 00000000..297977a6 --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_angle.inl @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-30 +// Updated : 2005-12-30 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_angle.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline T angleGTX(const T x, const T y) + { + return degrees(acos(dot(x, y))); + } + + template + inline T angleGTX( + const detail::_xvec2& x, + const detail::_xvec2& y) + { + return degrees(acos(dot(x, y))); + } + + template + inline T angleGTX( + const detail::_xvec3& x, + const detail::_xvec3& y) + { + return degrees(acos(dot(x, y))); + } + + template + inline T angleGTX( + const detail::_xvec4& x, + const detail::_xvec4& y) + { + return degrees(acos(dot(x, y))); + } + + template + inline T orientedAngleGTX( + const detail::_xvec2& x, + const detail::_xvec2& y) + { + T Angle = acos(dot(x, y)); + T c = cos(Angle); + T s = sin(Angle); + detail::_xvec2 TransformedVector = detail::_xvec2(c * y.x - s * y.y, s * y.x + c * y.y); + if(all(equalEpsilonGTX(x, TransformedVector, T(0.01)))) + return -degrees(Angle); + else + return degrees(Angle); + } + + template + inline T orientedAngleGTX( + const detail::_xvec3& x, + const detail::_xvec3& y) + { + T Angle = degrees(acos(dot(x, y))); + detail::_xvec3 TransformedVector = rotateGTX(__quatGTX(), Angle, cross(x, y)) * y; + if(all(equalEpsilonGTX(x, TransformedVector, T(0.01)))) + return -degrees(Angle); + else + return degrees(Angle); + } + + template + inline T orientedAngleGTX( + const detail::_xvec4& x, + const detail::_xvec4& y) + { + T Angle = degrees(acos(dot(x, y))); + detail::_xvec4 TransformedVector = rotateGTX(__quatGTX(), Angle, cross(x, y)) * y; + if(all(equalEpsilonGTX(x, TransformedVector, T(0.01)))) + return -degrees(Angle); + else + return degrees(Angle); + } +} diff --git a/wip/sse/glm/ext/gtx/vector_comp_mult.h b/wip/sse/glm/ext/gtx/vector_comp_mult.h new file mode 100644 index 00000000..47303286 --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_comp_mult.h @@ -0,0 +1,56 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2006-11-13 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_comp_mult.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Note: +// mat4 m; +// vec4 v; +// ... +// vec4 Result = transposeGTX(m) * v; +// Same result as the following, but it's faster by avoiding the matrix transpose: +// vec4 Result = vectorCompMultGTX(m, v); +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Note: +// - This extension is deprecated, use the operator vec* * mat* instead. +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_vector_comp_mult__ +#define __glm_gtx_vector_comp_mult__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template detail::_xvec2 vectorCompMultGTX(const detail::_xmat2& x, const detail::_xvec2& y); //!< - Deprecated - Returns the result of the product between the transposed 2 * 2 matrix of x and the 2 component vector y. Deprecated, prefer vec2 * mat2 operator (From GLM_GTX_vector_comp_mult extension) + template detail::_xvec3 vectorCompMultGTX(const detail::_xmat3& x, const detail::_xvec3& y); //!< - Deprecated - Returns the result of the product between the transposed 3 * 3 matrix of x and the 3 component vector y. Deprecated, prefer vec3 * mat3 operator (From GLM_GTX_vector_comp_mult extension) + template detail::_xvec4 vectorCompMultGTX(const detail::_xmat4& x, const detail::_xvec4& y); //!< - Deprecated - Returns the result of the product between the transposed 4 * 4 matrix of x and the 4 component vector y. Deprecated, prefer vec4 * mat4 operator (From GLM_GTX_vector_comp_mult extension) + + namespace gtx + { + //! GLM_GTX_vector_comp_mult extension: - Deprecated - Revert matrix and vector product instead with core operators + namespace vector_comp_mult + { + template inline detail::_xvec2 vectorCompMult(const detail::_xmat2& x, const detail::_xvec2& y){return vectorCompMultGTX(x, y);} //!< - Deprecated - Returns the result of the product between the transposed 2 * 2 matrix of x and the 2 component vector y. Deprecated, prefer vec2 * mat2 operator (From GLM_GTX_vector_comp_mult extension) + template inline detail::_xvec3 vectorCompMult(const detail::_xmat3& x, const detail::_xvec3& y){return vectorCompMultGTX(x, y);} //!< - Deprecated - Returns the result of the product between the transposed 3 * 3 matrix of x and the 3 component vector y. Deprecated, prefer vec3 * mat3 operator (From GLM_GTX_vector_comp_mult extension) + template inline detail::_xvec4 vectorCompMult(const detail::_xmat4& x, const detail::_xvec4& y){return vectorCompMultGTX(x, y);} //!< - Deprecated - Returns the result of the product between the transposed 4 * 4 matrix of x and the 4 component vector y. Deprecated, prefer vec4 * mat4 operator (From GLM_GTX_vector_comp_mult extension) + } + } +} + +#define GLM_GTX_vector_comp_mult namespace gtx::vector_comp_mult + +#include "vector_comp_mult.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_vector_comp_mult;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_vector_comp_mult__ diff --git a/wip/sse/glm/ext/gtx/vector_comp_mult.inl b/wip/sse/glm/ext/gtx/vector_comp_mult.inl new file mode 100644 index 00000000..7a5acc57 --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_comp_mult.inl @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_comp_mult.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline detail::_xvec2 vectorCompMultGTX(const detail::_xmat2& m, const detail::_xvec2& v) + { + return detail::_xvec2( + m[0][0] * v.x + m[0][1] * v.y, + m[1][0] * v.x + m[1][1] * v.y); + } + + template + inline detail::_xvec3 vectorCompMultGTX(const detail::_xmat3& m, const detail::_xvec3& v) + { + return detail::_xvec3( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z); + } + + template + inline detail::_xvec4 vectorCompMultGTX(const detail::_xmat4& m, const detail::_xvec4& v) + { + return detail::_xvec4( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] * v.w, + m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] * v.w); + } +} diff --git a/wip/sse/glm/ext/gtx/vector_query.h b/wip/sse/glm/ext/gtx/vector_query.h new file mode 100644 index 00000000..ec4b5bb6 --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_query.h @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-05 +// Updated : 2007-03-05 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_query.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_vector_query__ +#define __glm_gtx_vector_query__ + +// Dependency: +#include "../../glm.h" +#include + +namespace glm +{ + template bool areCollinearGTX(const detail::_xvec2& v0, const detail::_xvec2& v1, const T epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are collinears (From GLM_GTX_vector_query extensions) + template bool areCollinearGTX(const detail::_xvec3& v0, const detail::_xvec3& v1, const T epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are collinears (From GLM_GTX_vector_query extensions) + template bool areCollinearGTX(const detail::_xvec4& v0, const detail::_xvec4& v1, const T epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are collinears (From GLM_GTX_vector_query extensions) + + template bool areOppositeGTX(const detail::_xvec2& v0, const detail::_xvec2& v1, const T epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are opposite (From GLM_GTX_vector_query extensions) + template bool areOppositeGTX(const detail::_xvec3& v0, const detail::_xvec3& v1, const T epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are opposite (From GLM_GTX_vector_query extensions) + template bool areOppositeGTX(const detail::_xvec4& v0, const detail::_xvec4& v1, const T epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are opposite (From GLM_GTX_vector_query extensions) + + template bool areOrthogonalGTX(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are orthogonal (From GLM_GTX_vector_query extensions) + + template bool isNormalizedGTX(const genType& v, const GLMvalType epsilon = std::numeric_limits::epsilon()); //!< Check if a vector is normalized (From GLM_GTX_vector_query extensions) + + template bool isNullGTX(const genType& v, const GLMvalType epsilon = std::numeric_limits::epsilon()); //!< Check if a vector is null (From GLM_GTX_vector_query extensions) + + template bool isCompNullGTX(const float s, const T epsilon = std::numeric_limits::epsilon()); //!< Check if each vector component is null (From GLM_GTX_vector_query extensions) + template bvec2 isCompNullGTX(const detail::_xvec2& v, const T epsilon = std::numeric_limits::epsilon()); //!< Check if each vector component is null (From GLM_GTX_vector_query extensions) + template bvec3 isCompNullGTX(const detail::_xvec3& v, const T epsilon = std::numeric_limits::epsilon()); //!< Check if each vector component is null (From GLM_GTX_vector_query extensions) + template bvec4 isCompNullGTX(const detail::_xvec4& v, const T epsilon = std::numeric_limits::epsilon()); //!< Check if each vector component is null (From GLM_GTX_vector_query extensions) + + template bool areOrthonormalGTX(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are orthonormal (From GLM_GTX_vector_query extensions) + + template bool areSimilarGTX(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()); //!< Check if two vectors are similar (From GLM_GTX_vector_query extensions) + + namespace gtx + { + //! GLM_GTX_vector_query extension: Query informations of vector types + namespace vector_query + { + template inline bool areCollinear(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()){return areCollinearGTX(v0, v1, epsilon);} //!< Check if two vectors are collinears (From GLM_GTX_vector_query extensions) + template inline bool areOpposite(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()){return areOppositeGTX(v0, v1, epsilon);} //!< Check if two vectors are opposites (From GLM_GTX_vector_query extensions) + template inline bool areOrthogonal(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()){return areOrthogonalGTX(v0, v1, epsilon);} //!< Check if two vectors are orthogonals (From GLM_GTX_vector_query extensions) + template inline bool isNormalized(const genType& v, const GLMvalType epsilon = std::numeric_limits::epsilon()){return isNormalizedGTX(v, epsilon);} //!< Check if a vector is normalized (From GLM_GTX_vector_query extensions) + template inline bool isNull(const genType& v, const GLMvalType epsilon = std::numeric_limits::epsilon()){return isNullGTX(v, epsilon);} //!< Check if a vector is null (From GLM_GTX_vector_query extensions) + template inline bool areOrthonormal(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()){return areOrthonormalGTX(v0, v1, epsilon);} //!< Check if two vectors are orthonormal (From GLM_GTX_vector_query extensions) + template inline bool areSimilar(const genType& v0, const genType& v1, const GLMvalType epsilon = std::numeric_limits::epsilon()){return areSimilarGTX(v0, v1, epsilon);} //!< Check if two vectors are similar (From GLM_GTX_vector_query extensions) + } + } +} + +#define GLM_GTX_vector_query namespace gtx::vector_query + +#include "vector_query.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_vector_query;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_vector_query__ diff --git a/wip/sse/glm/ext/gtx/vector_query.inl b/wip/sse/glm/ext/gtx/vector_query.inl new file mode 100644 index 00000000..4a54e77c --- /dev/null +++ b/wip/sse/glm/ext/gtx/vector_query.inl @@ -0,0 +1,233 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-05 +// Updated : 2007-03-05 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vector_query.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm +{ + template + inline bool areCollinearGTX(const detail::_xvec2& v0, const detail::_xvec2& v1, const T epsilon) + { + return length(cross(detail::_xvec3(v0, T(0)), detail::_xvec3(v1, T(0)))) < epsilon; + } + + template + inline bool areCollinearGTX(const detail::_xvec3& v0, const detail::_xvec3& v1, const T epsilon) + { + return length(cross(v0, v1)) < epsilon; + } + + template + inline bool areCollinearGTX(const detail::_xvec4& v0, const detail::_xvec4& v1, const T epsilon) + { + return length(cross(detail::_xvec3(v0), detail::_xvec3(v1))) < epsilon; + } + + template + inline bool areOppositeGTX(const genType& v0, const genType& v1, const GLMvalType epsilon) + { + assert(isNormalized(v0) && isNormalized(v1)); + return((genType::value_type(1) + dot(v0, v1)) <= epsilon); + } +/* + template + inline bool areOppositeGTX(const _xvec2& v0, const _xvec2& v1, const T epsilon) + { + assert(isNormalized(v0) && isNormalized(v1)); + return((T(1) + dot(v0, v1)) <= epsilon); + } + + template + inline bool areOppositeGTX(const _xvec3& v0, const _xvec3& v1, const T epsilon) + { + assert(isNormalized(v0) && isNormalized(v1)); + return((T(1) + dot(v0, v1)) <= epsilon); + } + + template + inline bool areOppositeGTX(const _xvec4& v0, const _xvec4& v1, const T epsilon) + { + assert(isNormalized(v0) && isNormalized(v1)); + return((T(1) + dot(v0, v1)) <= epsilon); + } +*/ + template + inline bool areOrthogonalGTX(const genType& v0, const genType& v1, const GLMvalType epsilon) + { + return abs(dot(v0, v1)) <= max(GLMvalType(1), length(v0)) * max(GLMvalType(1), length(v1)) * epsilon; + } +/* + template + inline bool areOrthogonalGTX(const _xvec2& v0, const _xvec2& v1, const T epsilon) + { + return abs(dot(v0, v1)) <= max(T(1), length(v0)) * max(T(1), length(v1)) * epsilon; + } + + template + inline bool areOrthogonalGTX(const _xvec3& v0, const _xvec3& v1, const T epsilon) + { + return abs(dot(v0, v1)) <= max(T(1), length(v0)) * max(T(1), length(v1)) * epsilon; + } + + template + inline bool areOrthogonalGTX(const _xvec4& v0, const _xvec4& v1, const T epsilon) + { + return abs(dot(v0, v1)) <= max(T(1), length(v0)) * max(T(1), length(v1)) * epsilon; + } +*/ + + template + inline bool isNormalizedGTX(const genType& v, const GLMvalType epsilon) + { + return abs(length(v) - GLMvalType(1)) <= GLMvalType(2) * epsilon; + } +/* + template + inline bool isNormalizedGTX(const _xvec2& v, const T epsilon) + { + return abs(length(v) - T(1)) <= T(2) * epsilon; + } + + template + inline bool isNormalizedGTX(const _xvec3& v, const T epsilon) + { + return abs(length(v) - T(1)) <= T(2) * epsilon; + } + + template + inline bool isNormalizedGTX(const _xvec4& v, const T epsilon) + { + return abs(length(v) - T(1)) <= T(2) * epsilon; + } +*/ + template + inline bool isNullGTX(const genType& v, const GLMvalType epsilon) + { + return length(v) <= epsilon; + } +/* + template + inline bool isNullGTX(const _xvec2& v, const T epsilon) + { + return length(v) <= epsilon; + } + + template + inline bool isNullGTX(const _xvec3& v, const T epsilon) + { + return length(v) <= epsilon; + } + + template + inline bool isNullGTX(const _xvec4& v, const T epsilon) + { + return length(v) <= epsilon; + } +*/ + + template + inline bool isCompNullGTX(const T s, const T epsilon) + { + return abs(s) < epsilon; + } + + template + inline bvec2 isCompNullGTX(const detail::_xvec2& v, const T epsilon) + { + return bvec2( + (abs(v.x) < epsilon), + (abs(v.y) < epsilon)); + } + + template + inline bvec3 isCompNullGTX(const detail::_xvec3& v, const T epsilon) + { + return bvec3( + abs(v.x) < epsilon, + abs(v.y) < epsilon, + abs(v.z) < epsilon); + } + + template + inline bvec4 isCompNullGTX(const detail::_xvec4& v, const T epsilon) + { + return bvec4( + abs(v.x) < epsilon, + abs(v.y) < epsilon, + abs(v.z) < epsilon, + abs(v.w) < epsilon); + } + + template + inline bool areOrthonormalGTX(const genType& v0, const genType& v1, const GLMvalType epsilon) + { + return isNormalizedGTX(v0) && isNormalizedGTX(v1) && (abs(dot(v0, v1)) <= epsilon); + } + +/* + template + inline bool areOrthonormalGTX(const _xvec2& v0, const _xvec2& v1, const T epsilon) + { + return isNormalizedGTX(v0) && isNormalizedGTX(v1) && (abs(dot(v0, v1)) <= epsilon); + } + + template + inline bool areOrthonormalGTX(const _xvec3& v0, const _xvec3& v1, const T epsilon) + { + return isNormalizedGTX(v0) && isNormalizedGTX(v1) && (abs(dot(v0, v1)) <= epsilon); + } + + template + inline bool areOrthonormalGTX(const _xvec4& v0, const _xvec4& v1, const T epsilon) + { + return isNormalizedGTX(v0) && isNormalizedGTX(v1) && (abs(dot(v0, v1)) <= epsilon); + } +*/ + + template + inline bool areSimilarGTX(const genType& v0, const genType& v1, const GLMvalType epsilon) + { + bool similar = true; + for(typename genType::size_type i = 0; similar && i < genType::value_size; i++) + similar = (abs(v0[i] - v1[i]) <= epsilon); + return similar; + } + +/* + template + inline bool areSimilar(const _xvec2& v0, const _xvec2& v1, const T epsilon) + { + bool similar = true; + for(int i = 0; similar && i < 2; i++) + similar = (abs(v0[i] - v1[i]) <= epsilon); + return similar; + } + + template + inline bool areSimilar(const _xvec3& v0, const _xvec3& v1, const T epsilon) + { + bool similar = true; + for(int i = 0; similar && i < 3; i++) + similar = (abs(v0[i] - v1[i]) <= epsilon); + return similar; + } + + template + inline bool areSimilar(const _xvec4& v0, const _xvec4& v1, const T epsilon) + { + bool similar = true; + for(int i = 0; similar && i < 4; i++) + similar = (abs(v0[i] - v1[i]) <= epsilon); + return similar; + } +*/ +} diff --git a/wip/sse/glm/ext/gtx/vecx.h b/wip/sse/glm/ext/gtx/vecx.h new file mode 100644 index 00000000..ec93f08d --- /dev/null +++ b/wip/sse/glm/ext/gtx/vecx.h @@ -0,0 +1,221 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-02-21 +// Updated : 2007-02-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vecx.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_vecx__ +#define __glm_gtx_vecx__ + +namespace glm{ +namespace detail{ + + template + class _bvecxGTX + { + private: + bool data[N]; + + public: + typedef bool value_type; + typedef int size_type; + static const size_type value_size; + static const size_type col_size; + static const size_type row_size; + + // Common constructors + _bvecxGTX(); + _bvecxGTX(const _bvecxGTX& v); + + // Accesses + bool& operator[](int i); + const bool operator[](int i) const; + operator bool*(); + operator const bool*() const; + + // Bool constructors + explicit _bvecxGTX(const bool a); + + // Operators + _bvecxGTX& operator=(const _bvecxGTX& v); + _bvecxGTX operator! () const; + }; + + template + class _xvecxGTX + { + private: + T data[N]; + + public: + typedef T value_type; + typedef int size_type; + static const size_type value_size; + + // Common constructors + _xvecxGTX(); + _xvecxGTX(const _xvecxGTX& v); + + // Accesses + T& operator[](int i); + const T operator[](int i) const; + operator T*(); + operator const T*() const; + + // T constructors + explicit _xvecxGTX(const T x); + + // Unary updatable operators + _xvecxGTX& operator= (const _xvecxGTX& v); + _xvecxGTX& operator+=(const T s); + _xvecxGTX& operator+=(const _xvecxGTX& v); + _xvecxGTX& operator-=(const T s); + _xvecxGTX& operator-=(const _xvecxGTX& v); + _xvecxGTX& operator*=(const T s); + _xvecxGTX& operator*=(const _xvecxGTX& v); + _xvecxGTX& operator/=(const T s); + _xvecxGTX& operator/=(const _xvecxGTX& v); + _xvecxGTX& operator++(); + _xvecxGTX& operator--(); + }; + +}//namespace detail + + // Binary operators + template + detail::_xvecxGTX operator+ (const detail::_xvecxGTX& v, const T s); + + template + detail::_xvecxGTX operator+ (const T s, const detail::_xvecxGTX& v); + + template + detail::_xvecxGTX operator+ (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2); + + template + detail::_xvecxGTX operator- (const detail::_xvecxGTX& v, const T s); + + template + detail::_xvecxGTX operator- (const T s, const detail::_xvecxGTX& v); + + template + detail::_xvecxGTX operator- (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2); + + template + detail::_xvecxGTX operator* (const detail::_xvecxGTX& v, const T s); + + template + detail::_xvecxGTX operator* (const T s, const detail::_xvecxGTX& v); + + template + detail::_xvecxGTX operator* (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2); + + template + detail::_xvecxGTX operator/ (const detail::_xvecxGTX& v, const T s); + + template + detail::_xvecxGTX operator/ (const T s, const detail::_xvecxGTX& v); + + template + detail::_xvecxGTX operator/ (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2); + + // Unary constant operators + template + const detail::_xvecxGTX operator- (const detail::_xvecxGTX& v); + + template + const detail::_xvecxGTX operator-- (const detail::_xvecxGTX& v, int); + + template + const detail::_xvecxGTX operator++ (const detail::_xvecxGTX& v, int); + + // Trigonometric Functions + template const detail::_xvecxGTX radians(const detail::_xvecxGTX& degrees); //!< \brief Converts degrees to radians and returns the result. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX degrees(const detail::_xvecxGTX& radians); //!< \brief Converts radians to degrees and returns the result. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX sin(const detail::_xvecxGTX& angle); //!< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX cos(const detail::_xvecxGTX& angle); //!< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX tan(const detail::_xvecxGTX& angle); //!< \brief The standard trigonometric tangent function. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX asin(const detail::_xvecxGTX& x); //!< \brief Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX acos(const detail::_xvecxGTX& x); //!< \brief Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX atan(const detail::_xvecxGTX& y, const detail::_xvecxGTX& x); //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX atan(const detail::_xvecxGTX& y_over_x); //!< \brief Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this function is [-PI/2, PI/2]. (From GLM_GTX_vecx extension) + + // Exponential Functions + template const detail::_xvecxGTX pow(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns x raised to the y power. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX exp(const detail::_xvecxGTX& x); //!< \brief Returns the natural exponentiation of x, i.e., e^x. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX log(const detail::_xvecxGTX& x); //!< \brief Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if x <= 0. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX exp2(const detail::_xvecxGTX& x); //!< \brief Returns 2 raised to the x power. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX log2(const detail::_xvecxGTX& x); //!< \brief Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX sqrt(const detail::_xvecxGTX& x); //!< \brief Returns the positive square root of x. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX inversesqrt(const detail::_xvecxGTX& x); //!< \brief Returns the reciprocal of the positive square root of x. (From GLM_GTX_vecx extension) + + // Common Functions + template const detail::_xvecxGTX abs(const detail::_xvecxGTX& x); //!< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX sign(const detail::_xvecxGTX& x); //!< \brief Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX floor(const detail::_xvecxGTX& x); //!< \brief Returns a value equal to the nearest integer that is less then or equal to x. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX ceil(const detail::_xvecxGTX& x); //!< \brief Returns a value equal to the nearest integer that is greater than or equal to x. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX fract(const detail::_xvecxGTX& x); //!< \brief Return x - floor(x). (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX mod(const detail::_xvecxGTX& x, T y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX mod(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the corresponding component of y. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX min(const detail::_xvecxGTX& x, T y); //!< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX min(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns minimum of each component of x compared with the floating-point value y. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX max(const detail::_xvecxGTX& x, T y); //!< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX max(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns maximum of each component of x compared with the floating-point value y. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX clamp(const detail::_xvecxGTX& x, T minVal, T maxVal); //!< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX clamp(const detail::_xvecxGTX& x, const detail::_xvecxGTX& minVal, const detail::_xvecxGTX& maxVal); //!< \brief Returns the component-wise result of min(max(x, minVal), maxVal). (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX step(T edge, const detail::_xvecxGTX& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX step(const detail::_xvecxGTX& edge, const detail::_xvecxGTX& x); //!< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX smoothstep(T edge0, T edge1, const detail::_xvecxGTX& x); //!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX smoothstep(const detail::_xvecxGTX& edge0, const detail::_xvecxGTX& edge1, const detail::_xvecxGTX& x);//!< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLM_GTX_vecx extension) + + // Geometric Functions + template const T length(const detail::_xvecxGTX& x); //!< \brief Returns the length of x, i.e., sqrt(x * x). (From GLM_GTX_vecx extension) + template const T distance(const detail::_xvecxGTX& p0, const detail::_xvecxGTX& p1); //!< \brief Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). (From GLM_GTX_vecx extension) + template const T dot(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns the dot product of x and y, i.e., result = x[0] * y[0] + x[1] * y[1]. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX normalize(const detail::_xvecxGTX& x); //!< \brief Returns a vector in the same direction as x but with length of 1. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX faceforward(const detail::_xvecxGTX& Norm, const detail::_xvecxGTX& I, const detail::_xvecxGTX& Nref); //!< \brief If dot(Nref, I) < 0.0, return N, otherwise, return -N. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX reflect(const detail::_xvecxGTX& I, const detail::_xvecxGTX& N); //!< \brief For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N. (From GLM_GTX_vecx extension) + template const detail::_xvecxGTX refract(const detail::_xvecxGTX& I, const detail::_xvecxGTX& N, T eta); //!< \brief For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector. (From GLM_GTX_vecx extension) + + // Vector Relational Functions + template const detail::_bvecxGTX lessThan(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns the component-wise compare of x < y. (From GLM_GTX_vecx extension) + template const detail::_bvecxGTX lessThanEqual(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns the component-wise compare of x <= y. (From GLM_GTX_vecx extension) + template const detail::_bvecxGTX greaterThan(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns the component-wise compare of x > y. (From GLM_GTX_vecx extension) + template const detail::_bvecxGTX greaterThanEqual(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns the component-wise compare of x >= y. (From GLM_GTX_vecx extension) + template const detail::_bvecxGTX equal(const detail::_bvecxGTX& x, const detail::_bvecxGTX& y); //!< \brief Returns the component-wise compare of x == y. (From GLM_GTX_vecx extension) + template const detail::_bvecxGTX equal(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns the component-wise compare of x == y. (From GLM_GTX_vecx extension) + template const detail::_bvecxGTX notEqual(const detail::_bvecxGTX& x, const detail::_bvecxGTX& y); //!< \brief Returns the component-wise compare of x != y. (From GLM_GTX_vecx extension) + template const detail::_bvecxGTX notEqual(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y); //!< \brief Returns the component-wise compare of x != y. (From GLM_GTX_vecx extension) + template const bool any(const detail::_bvecxGTX& x); //!< \brief Returns true if any component of x is true. (From GLM_GTX_vecx extension) + template const bool all(const detail::_bvecxGTX& x); //!< \brief Returns true if all component of x is true. (From GLM_GTX_vecx extension) +#ifdef _MSC_VER // VC compiler doesn't support the C++ key word 'not' + template const detail::_bvecxGTX not(const detail::_bvecxGTX& v); //!< \brief Returns the component-wise logical complement of x. (From GLM_GTX_vecx extension) +#endif +#ifdef __GNUC__ // GCC + template const detail::_bvecxGTX operator not(const detail::_bvecxGTX& v); //!< \brief Returns the component-wise logical complement of x. (From GLM_GTX_vecx extension) +#endif + + namespace gtx + { + //! GLM_GTX_vecx extension: - Work in progress - Add custom size vectors + namespace vecx + { + + } + } +} + +#define GLM_GTX_vecx namespace gtx::vecx + +#include "vecx.inl" + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_vecx;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_vecx__ diff --git a/wip/sse/glm/ext/gtx/vecx.inl b/wip/sse/glm/ext/gtx/vecx.inl new file mode 100644 index 00000000..6f8620c1 --- /dev/null +++ b/wip/sse/glm/ext/gtx/vecx.inl @@ -0,0 +1,866 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-02-21 +// Updated : 2007-02-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/vecx.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm +{ +namespace detail{ + + template const typename _bvecxGTX::size_type _bvecxGTX::value_size = N; + + // Bool constructors + template + inline _bvecxGTX::_bvecxGTX() + { + for(int i = 0; i < N; ++i) + this->data[i] = false; + } + + template + inline _bvecxGTX::_bvecxGTX(const _bvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] = v[i]; + } + + template + inline _bvecxGTX::_bvecxGTX(const bool s) + { + for(int i = 0; i < N; ++i) + this->data[i] = s; + } + + // Accesses + template + inline bool& _bvecxGTX::operator[](int i) + { + assert(i >= 0 && i < N); + return this->data[i]; + } + + template + inline const bool _bvecxGTX::operator[](int i) const + { + assert(i >= 0 && i < N); + return this->data[i]; + } + + template + inline _bvecxGTX::operator bool*() + { + return data; + } + + template + inline _bvecxGTX::operator const bool*() const + { + return data; + } + + // Operators + template + inline _bvecxGTX& _bvecxGTX::operator=(const _bvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] = v[i]; + return *this; + } + + template + inline _bvecxGTX _bvecxGTX::operator! () const + { + _bvecxGTX result; + for(int i = 0; i < N; ++i) + result[i] = !this->data[i]; + return result; + } + + template const typename _xvecxGTX::size_type _xvecxGTX::value_size = N; + + // Common constructors + template + inline _xvecxGTX::_xvecxGTX() + { + for(int i = 0; i < N; ++i) + this->data[i] = T(0); + } + + template + inline _xvecxGTX::_xvecxGTX(const _xvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] = v[i]; + } + + // T constructors + template + inline _xvecxGTX::_xvecxGTX(const T s) + { + for(int i = 0; i < N; ++i) + this->data[i] = s; + } + + // Accesses + template + inline T& _xvecxGTX::operator[](int i) + { + assert(i >= 0 && i < N); + return this->data[i]; + } + + template + inline const T _xvecxGTX::operator[](int i) const + { + assert(i >= 0 && i < N); + return this->data[i]; + } + + template + inline _xvecxGTX::operator T*() + { + return data; + } + + template + inline _xvecxGTX::operator const T*() const + { + return data; + } + + template + inline _xvecxGTX& _xvecxGTX::operator=(const _xvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] = v[i]; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator+= (const T s) + { + for(int i = 0; i < N; ++i) + this->data[i] += s; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator+=(const _xvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] += v[i]; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator-= (const T s) + { + for(int i = 0; i < N; ++i) + this->data[i] -= s; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator-=(const _xvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] -= v[i]; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator*=(const T s) + { + for(int i = 0; i < N; ++i) + this->data[i] *= s; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator*= (const _xvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] *= v[i]; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator/=(const T s) + { + for(int i = 0; i < N; ++i) + this->data[i] /= s; + return *this; + } + + template + inline _xvecxGTX& _xvecxGTX::operator/= (const _xvecxGTX& v) + { + for(int i = 0; i < N; ++i) + this->data[i] /= v[i]; + return *this; + } +}//namespace detail + + // Unary constant operators + template + inline const detail::_xvecxGTX operator- (const detail::_xvecxGTX& v) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = -v[i]; + return result; + } + + template + inline const detail::_xvecxGTX operator++ (const detail::_xvecxGTX& v, int) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v[i] + T(1); + return result; + } + + template + inline const detail::_xvecxGTX operator-- (const detail::_xvecxGTX& v, int) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v[i] - T(1); + return result; + } + + // Binary operators + template + inline detail::_xvecxGTX operator+ (const detail::_xvecxGTX& v, const T s) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v[i] + s; + return result; + } + + template + inline detail::_xvecxGTX operator+ (const T s, const detail::_xvecxGTX& v) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v[i] + s; + return result; + } + + template + inline detail::_xvecxGTX operator+ (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v1[i] + v2[i]; + return result; + } + + template + inline detail::_xvecxGTX operator- (const detail::_xvecxGTX& v, const T s) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v[i] - s; + return result; + } + + template + inline detail::_xvecxGTX operator- (const T s, const detail::_xvecxGTX& v) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = s - v[i]; + return result; + } + + template + inline detail::_xvecxGTX operator- (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v1[i] - v2[i]; + return result; + } + + template + inline detail::_xvecxGTX operator* (const detail::_xvecxGTX& v, const T s) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v[i] * s; + return result; + } + + template + inline detail::_xvecxGTX operator* (const T s, const detail::_xvecxGTX& v) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = s * v[i]; + return result; + } + + template + inline detail::_xvecxGTX operator* (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v1[i] * v2[i]; + return result; + } + + template + inline detail::_xvecxGTX operator/ (const detail::_xvecxGTX& v, const T s) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v[i] / s; + return result; + } + + template + inline detail::_xvecxGTX operator/ (const T s, const detail::_xvecxGTX& v) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = s / v[i]; + return result; + } + + template + inline detail::_xvecxGTX operator/ (const detail::_xvecxGTX& v1, const detail::_xvecxGTX& v2) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = v1[i] / v2[i]; + return result; + } + + // Trigonometric Functions + template + const detail::_xvecxGTX radians(const detail::_xvecxGTX& degrees) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = radians(degrees[i]); + return result; + } + + template + const detail::_xvecxGTX degrees(const detail::_xvecxGTX& radians) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = degrees(radians[i]); + return result; + } + + template + const detail::_xvecxGTX sin(const detail::_xvecxGTX& angle) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = sin(angle[i]); + return result; + } + + template + const detail::_xvecxGTX cos(const detail::_xvecxGTX& angle) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = cos(angle[i]); + return result; + } + + template + const detail::_xvecxGTX tan(const detail::_xvecxGTX& angle) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = tan(angle[i]); + return result; + } + + template + const detail::_xvecxGTX asin(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = asin(x[i]); + return result; + } + + template + const detail::_xvecxGTX acos(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = acos(x[i]); + return result; + } + + template + const detail::_xvecxGTX atan(const detail::_xvecxGTX& y, const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = atan(y[i], x[i]); + return result; + } + + template + const detail::_xvecxGTX atan(const detail::_xvecxGTX& y_over_x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = atan(y_over_x[i]); + return result; + } + + // Exponential Functions + template + const detail::_xvecxGTX pow(const detail::_xvecxGTX& x, const detail::_xvecxGTX& y) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = pow(x[i], y[i]); + return result; + } + + template + const detail::_xvecxGTX exp(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = exp(x[i]); + return result; + } + + template + const detail::_xvecxGTX log(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = log(x[i]); + return result; + } + + template + const detail::_xvecxGTX exp2(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = exp2(x[i]); + return result; + } + + template + const detail::_xvecxGTX log2(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = log2(x[i]); + return result; + } + + template + const detail::_xvecxGTX sqrt(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = sqrt(x[i]); + return result; + } + + template + const detail::_xvecxGTX inversesqrt(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = inversesqrt(x[i]); + return result; + } + + // Common Functions + template + const detail::_xvecxGTX abs(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = abs(x[i]); + return result; + } + + template + const detail::_xvecxGTX sign(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = sign(x[i]); + return result; + } + + template + const detail::_xvecxGTX floor(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = floor(x[i]); + return result; + } + + template + const detail::_xvecxGTX ceil(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = ceil(x[i]); + return result; + } + + template + const detail::_xvecxGTX fract(const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = fract(x[i]); + return result; + } + + template + const detail::_xvecxGTX mod(const detail::_xvecxGTX& x, T y) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = mod(x[i], y); + return result; + } + + template + const detail::_xvecxGTX mod( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = mod(x[i], y[i]); + return result; + } + + template + const detail::_xvecxGTX min( + const detail::_xvecxGTX& x, + T y) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = min(x[i], y); + return result; + } + + template + const detail::_xvecxGTX min( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = min(x[i], y[i]); + return result; + } + + template + const detail::_xvecxGTX max( + const detail::_xvecxGTX& x, + T y) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = max(x[i], y); + return result; + } + + template + const detail::_xvecxGTX max( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = max(x[i], y[i]); + return result; + } + + template + const detail::_xvecxGTX clamp( + const detail::_xvecxGTX& x, + T minVal, + T maxVal) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = clamp(x[i], minVal, maxVal); + return result; + } + + template + const detail::_xvecxGTX clamp( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& minVal, + const detail::_xvecxGTX& maxVal) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = clamp(x[i], minVal[i], maxVal[i]); + return result; + } + + template + const detail::_xvecxGTX step( + T edge, + const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = step(edge, x[i]); + return result; + } + + template + const detail::_xvecxGTX step( + const detail::_xvecxGTX& edge, + const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = step(edge[i], x[i]); + return result; + } + + template + const detail::_xvecxGTX smoothstep( + T edge0, + T edge1, + const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = step(edge0, edge1, x[i]); + return result; + } + + template + const detail::_xvecxGTX smoothstep( + const detail::_xvecxGTX& edge0, + const detail::_xvecxGTX& edge1, + const detail::_xvecxGTX& x) + { + detail::_xvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = step(edge0[i], edge1[i], x[i]); + return result; + } + + // Geometric Functions + template + const T length( + const detail::_xvecxGTX& x) + { + T sqr = dot(x, x); + return sqrt(sqr); + } + + template + const T distance( + const detail::_xvecxGTX& p0, + const detail::_xvecxGTX& p1) + { + return length(p1 - p0); + } + + template + const T dot( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + T result = T(0); + for(int i = 0; i < N; ++i) + result += x[i] * y[i]; + return result; + } + + template + const detail::_xvecxGTX normalize( + const detail::_xvecxGTX& x) + { + T sqr = dot(x, x); + return x * inversesqrt(sqr); + } + + template + const detail::_xvecxGTX faceforward( + const detail::_xvecxGTX& Normal, + const detail::_xvecxGTX& I, + const detail::_xvecxGTX& Nref) + { + return dot(Nref, I) < T(0) ? Normal : -Normal; + } + + template + const detail::_xvecxGTX reflect( + const detail::_xvecxGTX& I, + const detail::_xvecxGTX& Normal) + { + return I - Normal * dot(Normal, I) * T(2); + } + + template + const detail::_xvecxGTX refract( + const detail::_xvecxGTX& I, + const detail::_xvecxGTX& Normal, + T eta) + { + T dot = dot(Normal, I); + T k = T(1) - eta * eta * (T(1) - dot * dot); + if(k < T(0)) + return detail::_xvecxGTX(T(0)); + else + return eta * I - (eta * dot + sqrt(k)) * Normal; + } + + // Vector Relational Functions + template + const detail::_bvecxGTX lessThan( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = lessThan(x[i], y[i]); + return result; + } + + template + const detail::_bvecxGTX lessThanEqual( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = lessThanEqual(x[i], y[i]); + return result; + } + + template + const detail::_bvecxGTX greaterThan( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = greaterThan(x[i], y[i]); + return result; + } + + template + const detail::_bvecxGTX greaterThanEqual( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = greaterThanEqual(x[i], y[i]); + return result; + } + + template + const detail::_bvecxGTX equal( + const detail::_bvecxGTX& x, + const detail::_bvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = equal(x[i], y[i]); + return result; + } + + template + const detail::_bvecxGTX equal( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = equal(x[i], y[i]); + return result; + } + + template + const detail::_bvecxGTX notEqual( + const detail::_bvecxGTX& x, + const detail::_bvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = equal(x[i], y[i]); + return result; + } + + template + const detail::_bvecxGTX notEqual( + const detail::_xvecxGTX& x, + const detail::_xvecxGTX& y) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = notEqual(x[i], y[i]); + return result; + } + + template + const bool any(const detail::_bvecxGTX& x) + { + for(int i = 0; i< N; ++i) + if(x[i]) return true; + return false; + } + + template + const bool all(const detail::_bvecxGTX& x) + { + for(int i = 0; i< N; ++i) + if(!x[i]) return false; + return true; + } + +#if (defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC) // VC compiler doesn't support the C++ key word 'not' + template + detail::_bvecxGTX not( + const detail::_bvecxGTX& v) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = !v[i]; + return result; + } +#elif (defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_GCC) // GCC + template + detail::_bvecxGTX operator not( + const detail::_bvecxGTX& v) + { + detail::_bvecxGTX result; + for(int i = 0; i< N; ++i) + result[i] = !v[i]; + return result; + } +#endif +} //namespace glm diff --git a/wip/sse/glm/ext/gtx/verbose_operator.h b/wip/sse/glm/ext/gtx/verbose_operator.h new file mode 100644 index 00000000..0b2ad4dd --- /dev/null +++ b/wip/sse/glm/ext/gtx/verbose_operator.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-21 +// Updated : 2007-05-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/verbose_operator.h +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_gtx_verbose_operator__ +#define __glm_gtx_verbose_operator__ + +// Dependency: +#include "../../glm.h" + +namespace glm +{ + template genType addGTX(const genType& a, const genType& b); // Addition of two numbers, two vectors or two matrices (from GLM_GTX_verbose_operator extension) + template genType subGTX(const genType& a, const genType& b); // Substration of two numbers, two vectors or two matrices (from GLM_GTX_verbose_operator extension) + template genType divGTX(const genType& a, const genType& b); // Division of two numbers, two vectors or two matrices (from GLM_GTX_verbose_operator extension) + + namespace gtx + { + //! GLM_GTX_verbose_operator extension: Use words to replace operators + namespace verbose_operator + { + template inline genType add(const genType& a, const genType& b){return addGTX(a, b);} // Addition of two numbers, two vectors or two matrices (from GLM_GTX_verbose_operator extension) + template inline genType sub(const genType& a, const genType& b){return subGTX(a, b);} // Substration of two numbers, two vectors or two matrices (from GLM_GTX_verbose_operator extension) + template inline genType div(const genType& a, const genType& b){return divGTX(a, b);} // Division of two numbers, two vectors or two matrices (from GLM_GTX_verbose_operator extension) + } + } +} + +#include "verbose_operator.inl" + +#define GLM_GTX_verbose_operator namespace gtx::verbose_operator + +#ifdef GLM_GTX_INCLUDED +namespace glm{using GLM_GTX_verbose_operator;} +#endif//GLM_GTX_INCLUDED + +#endif//__glm_gtx_verbose_operator__ diff --git a/wip/sse/glm/ext/gtx/verbose_operator.inl b/wip/sse/glm/ext/gtx/verbose_operator.inl new file mode 100644 index 00000000..65983b66 --- /dev/null +++ b/wip/sse/glm/ext/gtx/verbose_operator.inl @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-21 +// Updated : 2007-05-21 +// Licence : This source is under GNU LGPL licence +// File : glm/gtx/verbose_operator.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + inline genType addGTX(const genType& a, const genType& b) + { + return a + b; + } + + template + inline genType subGTX(const genType& a, const genType& b) + { + return a - b; + } + + template + inline genType divGTX(const genType& a, const genType& b) + { + return a / b; + } +} diff --git a/wip/sse/glm/glm.h b/wip/sse/glm/glm.h new file mode 100644 index 00000000..d5d40b14 --- /dev/null +++ b/wip/sse/glm/glm.h @@ -0,0 +1,180 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-14 +// Updated : 2008-03-22 +// Licence : This source is under GNU LGPL licence +// File : glm/glm.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \mainpage OpenGL Mathematics + * + * \section introduction 1. Introduction + * + * OpenGL Mathematics (GLM) is a mathematics library for 3D applications based on OpenGL Shading Language(GLSL). The project's goal is to provide to 3D programmer the same tools when he develops under GPU and CPU. This project wasn't limited by GLSL tools, an extension system based on GLSL extensions development conventions allows to extend GLSL capabilities. GLM is release under MIT license and available for all version of GCC from version 3.4 and Visual Studio from version 7.1 (2003). + * + * Any feedback are welcome, please send then to g.truc.creation[NO_SPAM_THANKS]gmail.com. + * + * \section using_glm_installation 2. Installation + * + * \subsection using_glm_installation_compiler 2.1. Compiler setup + * It's not required to build GLM, it's a header library. You use have to indicate where is the "glm" directory to your compiler. The only files present in this directory that matter for your own projects are header files. You can whether copy this directory in your "include" project directory or add this directory to your compiler header directories list (-I with GCC). + * + * \subsection using_glm_installation_core 2.2. Core features + * When you have setup your compiler or project, all core features of GLM (basically, GLSL features) will be available to your project if you include "glm.h": #include + * + * \subsection using_glm_installation_swizzle 2.3. Setup of swizzle operators + * Swizzle operators are disabled by default. It's possible to enable each component types by defining GLM_SWIZZLE to GLM_SWIZZLE_XYZW, GLM_SWIZZLE_RGBA or GLM_SWIZZLE_STQP. To enable all swizzle names, use GLM_SWIZZLE_FULL. + * This setup is done using defines included in "glmsetup.h". You can directly edit this file but you take the risk to replace "glmsetup.h" and lose your settings when you will update GLM. Other way is to include "glmsetup.h" in a third-party file and then add your settings before including "glm.h". GLM will use default settings if "glmsetup.h" isn't included before "glm.h". + * + * \subsection using_glm_installation_ext 2.4. Using extensions features + * To take advantages of all extra features of GLM, you have to use the extensions which are included in "glmext.h": #include . Go to section 3 for more information about extensions + * + * \section extensions 3. GLM Extensions + * + * \subsection extensions_setup 3.1. Setup + * To take advantages of all extra features of GLM, you have to use the extensions which are included in "glmext.h": #include + * + * \subsection extensions_about 3.2. About GLSL extension convensions + * GLSL working group have defined some rules to define GLSL extensions. However, it seams that graphics card companies choose to adapt this rules according there own wishes which actually have some advantages thanks to the possibility to enable or disable GLSL extensions. + * + * \subsection extensions_arb 3.3. ARB convensions + * By default, all extensions are available using the working group rules. To use an extension, you just have to include the according header file. To include the quaternion extension (GLM_GTX_quaternion), just include "glm/gtx/quaternion.h" You can also ask to use every extension by including glmext.h. + * + * \subsection extensions_ihv 3.4. IHV convensions + * To use the vendor way of using extensions, it's still required include header files but you also have to explicitly ask for it. Example to use GLM_GTX_quaternion with IHV convensions: + * + * namespace glm + * { + * using GLM_GTX_quaternion; + * } + * + * It's also possible to automatically setup every extensions defining GLM_GTX_INCLUDED before including "glm.h". + * + * + * \section known_issue 4. Known issues + * + * \subsection known_issue_swizzle 4.1. Swizzle operators + * Enabling swizzle operator can result to name collision with the Win32 API. + * + * \subsection known_issue_not 4.2. "not" function + * The GLSL keyword "not" isn’t well supported under Visual Studio because of Microsoft implementation of the "not" C++ Keyword… it's a #define. + * + * \subsection known_issue_half 4.3. "half" based types + * Half based types can't be used with GCC because of multiple component names implementation based on union. To use half based types, define GLM_SINGLE_COMP_NAME before including GLM headers. This disables color and texcoord component names. + * + */ + +#ifndef __glm_glm__ +#define __glm_glm__ + +#undef max +#undef min + +#ifdef __GNUC__ +#define GLM_SINGLE_COMP_NAME +#endif + +#define GLMvalType typename genType::value_type +#define GLMcolType typename genType::col_type +#define GLMrowType typename genType::row_type + +#define GLMsizeType typename genType::size_type +#define GLMrowSize typename genType::row_size +#define GLMcolSize typename genType::col_size + +#define GLMvalSize typename genType::value_size + +#include "./glmsetup.h" + +#include "./core/_bvec2.inl" +#include "./core/_bvec3.inl" +#include "./core/_bvec4.inl" +#include "./core/_xvec2.inl" +#include "./core/_xvec3.inl" +#include "./core/_xvec4.inl" +#include "./core/_xmat2.inl" +#include "./core/_xmat3.inl" +#include "./core/_xmat4.inl" +#include "./core/_xmat2x3.inl" +#include "./core/_xmat2x4.inl" +#include "./core/_xmat3x2.inl" +#include "./core/_xmat3x4.inl" +#include "./core/_xmat4x2.inl" +#include "./core/_xmat4x3.inl" +#include "./core/_func.inl" +#include "./core/_swizzle.h" +#include "./core/_xref2.inl" +#include "./core/_xref3.inl" +#include "./core/_xref4.inl" + +//! \brief OpenGL Mathematics namespace +namespace glm +{ + //! GLM experimental extensions. The interface could change between releases. + namespace gtx{} + + //! GLM stable extensions. Nothing yet. + namespace gtc{} + + typedef detail::_xvec2 vec2; //!< \brief Vector of 2 floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xvec2 ivec2; //!< \brief Vector of 2 integers. (From GLSL 1.20.6 specification) + typedef detail::_bvec2 bvec2; //!< \brief Vector of 2 booleans. (From GLSL 1.20.6 specification) + typedef detail::_xvec3 vec3; //!< \brief Vector of 3 floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xvec3 ivec3; //!< \brief Vector of 3 integers. (From GLSL 1.20.6 specification) + typedef detail::_bvec3 bvec3; //!< \brief Vector of 3 booleans. (From GLSL 1.20.6 specification) + typedef detail::_xvec4 vec4; //!< \brief Vector of 4 floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xvec4 ivec4; //!< \brief Vector of 4 integers. (From GLSL 1.20.6 specification) + typedef detail::_bvec4 bvec4; //!< \brief Vector of 4 booleans. (From GLSL 1.20.6 specification) + typedef detail::_xmat2 mat2; //!< \brief 2 * 2 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat3 mat3; //!< \brief 3 * 3 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat4 mat4; //!< \brief 4 * 4 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat2 mat2x2; //!< \brief 2 * 2 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat3 mat3x3; //!< \brief 3 * 3 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat4 mat4x4; //!< \brief 4 * 4 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat2x3 mat2x3; //!< \brief 2 * 3 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat3x2 mat3x2; //!< \brief 3 * 2 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat2x4 mat2x4; //!< \brief 2 * 4 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat4x2 mat4x2; //!< \brief 4 * 2 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat3x4 mat3x4; //!< \brief 3 * 4 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + typedef detail::_xmat4x3 mat4x3; //!< \brief 4 * 3 matrix of floating-point numbers. (From GLSL 1.20.6 specification) + + typedef const vec2& param_vec2; + typedef const vec3& param_vec3; + typedef const vec4& param_vec4; + typedef const ivec2& param_ivec2; + typedef const ivec3& param_ivec3; + typedef const ivec4& param_ivec4; + typedef const bvec2& param_bvec2; + typedef const bvec3& param_bvec3; + typedef const bvec4& param_bvec4; + typedef const mat2& param_mat2; + typedef const mat3& param_mat3; + typedef const mat4& param_mat4; + typedef const mat2x3& param_mat2x3; + typedef const mat3x2& param_mat3x2; + typedef const mat2x4& param_mat2x4; + typedef const mat4x2& param_mat4x2; + typedef const mat3x4& param_mat3x4; + typedef const mat4x3& param_mat4x3; +} //namespace glm + +#ifdef GLM_COMPILER_VC +#define GLM_DEPRECATED __declspec(deprecated) +#else +#define GLM_DEPRECATED +#endif//GLM_COMPILER_VC + +#ifdef GLM_COMPILER_VC +#define GLM_RESTRICT __restrict +#else +#define GLM_RESTRICT +#endif//GLM_COMPILER_VC + +#ifdef GLM_COMPILER_VC +#define GLM_ALIGN(x) __declspec(align(x)) +#else +#define GLM_ALIGN(x) +#endif//GLM_COMPILER_VC + +#endif //__glm_glm__ diff --git a/wip/sse/glm/glmext.h b/wip/sse/glm/glmext.h new file mode 100644 index 00000000..fa05e945 --- /dev/null +++ b/wip/sse/glm/glmext.h @@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-14 +// Updated : 2007-08-03 +// Licence : This source is under GNU LGPL licence +// File : glm/glmext.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_glmext__ +#define __glm_glmext__ + +#include "./glm.h" +//#include "./ext/gtc.h" +#include "./ext/gtx.h" + +//const float goldenRatio = 1.618033988749894848f; +//const float pi = 3.141592653589793238f; + +#endif //__glm_glmext__ diff --git a/wip/sse/glm/glmsetup.h b/wip/sse/glm/glmsetup.h new file mode 100644 index 00000000..e85317e8 --- /dev/null +++ b/wip/sse/glm/glmsetup.h @@ -0,0 +1,128 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2008 G-Truc Creation (www.g-truc.net) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-11-13 +// Updated : 2007-03-14 +// Licence : This source is under GNU LGPL licence +// File : glm/glmsetup.h +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef __glm_glmsetup__ +#define __glm_glmsetup__ + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Version + +#define GLM_VERSION 70 +#define GLM_REVISION 111 + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Cast + +#define GLM_CAST_NONE 0x00000000 +#define GLM_CAST_DIRECTX_9 0x00000001 +#define GLM_CAST_DIRECTX_10 0x00000002 +#define GLM_CAST_NVSG 0x00000004 +#define GLM_CAST_WILD_MAGIC_3 0x00000008 +#define GLM_CAST_WILD_MAGIC_4 0x00000010 +#define GLM_CAST_PHYSX 0x00000020 +#define GLM_CAST_ODE 0x00000040 + +//! By default: +// #define GLM_CAST GLM_CAST_NONE +// #define GLM_CAST_EXT GLM_CAST_NONE + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Swizzle operators + +#define GLM_SWIZZLE_NONE 0x00000000 +#define GLM_SWIZZLE_XYZW 0x00000001 +#define GLM_SWIZZLE_RGBA 0x00000002 +#define GLM_SWIZZLE_STQP 0x00000004 +#define GLM_SWIZZLE_FULL (GLM_SWIZZLE_XYZW | GLM_SWIZZLE_RGBA | GLM_SWIZZLE_STQP) + +//! By default: +// #define GLM_SWIZZLE GLM_SWIZZLE_NONE + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Compiler + +#ifdef _MSC_VER +#define GLM_COMPILER_VC 0x01001000 + +#if _MSC_VER == 1000 +#define GLM_COMPILER_VC40 0x01000100 +#endif + +#if _MSC_VER == 1100 +#define GLM_COMPILER_VC50 0x01000200 +#endif + +#if _MSC_VER == 1200 +#define GLM_COMPILER_VC60 0x01000400 +#endif + +#if _MSC_VER == 1300 +#define GLM_COMPILER_VC70 0x01000800 +#endif + +#if _MSC_VER == 1310 +#define GLM_COMPILER_VC71 0x01001000 +#endif + +#if _MSC_VER == 1400 +#define GLM_COMPILER_VC80 0x01002000 +#endif + +#endif + +#ifdef __GNUC__ +#define GLM_COMPILER_GCC 0x02000000 + +#if (__GNUC__ == 2) && (__GNUC_MINOR__ == 8) //!< GCC 2.8x isn't supported +#define GLM_COMPILER_GCC29 0x02000400 +#endif + +#if (__GNUC__ == 2) && (__GNUC_MINOR__ == 9) //!< GCC 2.9x isn't supported +#define GLM_COMPILER_GCC29 0x02000400 +#endif + +#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 0) //!< GCC 3.0 isn't supported yet +#define GLM_COMPILER_GCC30 0x02000800 +#endif + +#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 1) //!< GCC 3.1 isn't supported yet +#define GLM_COMPILER_GCC31 0x02001000 +#endif + +#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2) +#define GLM_COMPILER_GCC32 0x02002000 +#endif + +#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 3) +#define GLM_COMPILER_GCC33 0x02004000 +#endif + +#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 4) +#define GLM_COMPILER_GCC34 0x02008000 +#endif + +#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 5) +#define GLM_COMPILER_GCC35 0x02010000 +#endif + +#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 0) +#define GLM_COMPILER_GCC40 0x02020000 +#endif + +#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 1) +#define GLM_COMPILER_GCC41 0x02040000 +#endif + +#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) +#define GLM_COMPILER_GCC42 0x02080000 +#endif + +#endif + +#endif//__glm_glmsetup__ diff --git a/wip/sse/main.cpp b/wip/sse/main.cpp new file mode 100644 index 00000000..df35be1d --- /dev/null +++ b/wip/sse/main.cpp @@ -0,0 +1,137 @@ +#include "precompiled.h" +#include "sse_vec4.h" +#include "sse_vec4array.h" +#include "sse_mat4.h" +#include "sse_mat4array.h" + +#include + +#define CPUID __asm __emit 0fh __asm __emit 0a2h +#define RDTSC __asm __emit 0fh __asm __emit 031h + +unsigned test_sse() +{ + //test_sse_vec4(); + //test_sse_mat4(); + + glm::sse::vec4 v0 = glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::sse::mat4 m0 = glm::sse::mat4(v0, v0, v0, v0); + glm::sse::mat4 m1 = glm::sse::mat4(v0, v0, v0, v0); + + unsigned cycles; + + __asm + { + pushad + + CPUID + RDTSC + mov cycles, eax + + popad + } + + //glm::sse::transpose(m0); + //m0.transpose(); + m0 * m0; + + __asm + { + pushad + + CPUID + RDTSC + sub eax, cycles + mov cycles, eax + + popad + } + + return cycles; +} + +int main() +{ + test_sse_vec4(); + test_sse_mat4(); + + unsigned int base, base1, base2, base3, base4, base5; + unsigned int clock; + + // Warm up cpuid & rdtsc + + __asm + { + pushad; + + cpuid; + rdtsc; + mov clock, eax; + cpuid; + rdtsc; + sub eax, clock; + mov base1, eax; + + cpuid; + rdtsc; + mov clock, eax; + cpuid; + rdtsc; + sub eax, clock; + mov base2, eax; + + cpuid; + rdtsc; + mov clock, eax; + cpuid; + rdtsc; + sub eax, clock; + mov base3, eax; + + cpuid; + rdtsc; + mov clock, eax; + cpuid; + rdtsc; + sub eax, clock; + mov base4, eax; + + cpuid; + rdtsc; + mov clock, eax; + cpuid; + rdtsc; + sub eax, clock; + mov base5, eax; + + popad; + } + + base = base1; + if (base > base2) + base = base2; + if (base > base3) + base = base3; + if (base > base4) + base = base4; + if (base > base5) + base = base5; + + { + const unsigned size = 16; + unsigned cycles[size]; + for(unsigned i = 0; i < size; ++i) + cycles[i] = test_sse(); + + // By the second or third run, both data and instruction + // cache effects should have been eliminated, and results + // will be consistent. + + printf("SSE\nBase : %d\n", base); + printf("Cycle counts:\n"); + for(unsigned i = 0; i < size; ++i) + printf("%d\n", cycles[i] - base); + } + + system("pause"); +} diff --git a/wip/sse/precompiled.cpp b/wip/sse/precompiled.cpp new file mode 100644 index 00000000..c08ca1f1 --- /dev/null +++ b/wip/sse/precompiled.cpp @@ -0,0 +1 @@ +#include "precompiled.h" \ No newline at end of file diff --git a/wip/sse/precompiled.h b/wip/sse/precompiled.h new file mode 100644 index 00000000..cfd780ea --- /dev/null +++ b/wip/sse/precompiled.h @@ -0,0 +1,7 @@ +#ifndef SSE_PRECOMPILED_H +#define SSE_PRECOMPILED_H + +#include "glm/glm.h" +#include "glm/glmext.h" + +#endif//SSE_PRECOMPILED_H diff --git a/wip/sse/rdtsc.cpp b/wip/sse/rdtsc.cpp new file mode 100644 index 00000000..5f656a45 --- /dev/null +++ b/wip/sse/rdtsc.cpp @@ -0,0 +1 @@ +#include "precompiled.h" diff --git a/wip/sse/rdtsc.h b/wip/sse/rdtsc.h new file mode 100644 index 00000000..e69de29b diff --git a/wip/sse/sse.cpp b/wip/sse/sse.cpp new file mode 100644 index 00000000..f68aaa32 --- /dev/null +++ b/wip/sse/sse.cpp @@ -0,0 +1,1378 @@ +#include "precompiled.h" +#include "sse.h" + +//namespace sse +//{ +// // some defines first +// union ieee754_QNAN +// { +// const float f; +// struct +// { +// const unsigned int mantissa:23, exp:8, sign:1; +// }; +// +// ieee754_QNAN() : f(0.0), mantissa(0x7FFFFF), exp(0xFF), sign(0x0) {} +// }; +// +// namespace detail +// { +// union ieee754 +// { +// ieee754() : +// f(0.0f) +// {} +// +// ieee754(float f) : +// f(f) +// {} +// +// ieee754(unsigned int mantissa, unsigned int exp, unsigned int sign) : +// mantissa(mantissa), exp(exp), sign(sign) +// {} +// +// float f; +// struct +// { +// unsigned int mantissa:23, exp:8, sign:1; +// }; +// }; +// +// _MM_ALIGN16 const ieee754 qnan(0x7FFFFF, 0xFF, 0x0); +// } +// +// float load(unsigned int mantissa, unsigned int exp, unsigned int sign) +// { +// sse::detail::ieee754 value(mantissa, exp, sign); +// return value.f; +// } +// +// _MM_ALIGN16 const sse::detail::ieee754 qnan(0x7FFFFF, 0xFF, 0x0); +// +// _MM_ALIGN16 const ieee754_QNAN absMask; +// //static const __m128 abs4Mask = _mm_load1_ps( &absMask.f); +// static const __m128 abs4Mask = _mm_set_ps1(absMask.f); +// +// __m128 _mm_neg_ps(__m128 v) +// { +// return _mm_sub_ps(_mm_setzero_ps(), v); +// } +// +// __m128 fast_pow(__m128 base, __m128 exponent) +// { +// __m128 denom = _mm_mul_ps( exponent, base); +// denom = _mm_sub_ps( exponent, denom); +// denom = _mm_add_ps( base, denom); +// return _mm_mul_ps( base, _mm_rcp_ps(denom)); +// } +// +// static const __m128 zero = _mm_setzero_ps(); +// static const __m128 one = _mm_set_ps1(1.0f); +// static const __m128 two = _mm_set_ps1(2.0f); +// static const __m128 pi = _mm_set_ps1(3.1415926535897932384626433832795f); +// static const __m128 hundred_eighty = _mm_set_ps1(180.f); +// static const __m128 pi_over_hundred_eighty = _mm_set_ps1(0.017453292519943295769236907684886f); +// static const __m128 hundred_eighty_over_pi = _mm_set_ps1(57.295779513082320876798154814105f); +// +// //vec4 radians(vec4 degrees) +// //{ +// // const float pi = float(3.1415926535897932384626433832795); +// // return degrees * (pi / 180.f); +// //} +// __m128 radians(__m128 degrees) +// { +// return _mm_mul_ps(degrees, pi_over_hundred_eighty); +// } +// +// __m128 _mm_rad_ss(__m128 degrees) +// { +// return _mm_mul_ss(degrees, pi_over_hundred_eighty); +// } +// +// __m128 _mm_rad_ps(__m128 degrees) +// { +// return _mm_mul_ps(degrees, pi_over_hundred_eighty); +// } +// +// //vec4 degrees(vec4 radians) +// //{ +// // const float pi = float(3.1415926535897932384626433832795); +// // return radians * (180.f / pi); +// //} +// __m128 degrees(__m128 radians) +// { +// return _mm_mul_ps(radians, hundred_eighty_over_pi); +// } +// +// __m128 _mm_deg_ss(__m128 radians) +// { +// return _mm_mul_ss(radians, hundred_eighty_over_pi); +// } +// +// __m128 _mm_deg_ps(__m128 radians) +// { +// return _mm_mul_ps(radians, hundred_eighty_over_pi); +// } +// +// //vec4 sqrt(vec4 v) +// //{ +// // return vec4(sqrt(v.x), sqrt(v.y), sqrt(v.z), sqrt(v.w)); +// //} +// __m128 sqrt(__m128 v) +// { +// return _mm_sqrt_ps(v); +// } +// +// //vec4 inversesqrt(vec4 x) +// //{ +// // return vec4(1.0f) / sqrt(x); +// //} +// __m128 inversesqrt(__m128 v) +// { +// return _mm_rsqrt_ps(v); +// } +// +// //vec4 abs(vec4 x) +// //{ +// // return x >= T(0) ? x : -x; +// //} +// __m128 abs(__m128 x) +// { +// return _mm_and_ps(abs4Mask, x); +// } +// +// //__m128 _mm_abs_ss(__m128 x) +// //{ +// // return _mm_and_ss(abs4Mask, x); +// //} +// +// __m128 _mm_abs_ps(__m128 x) +// { +// return _mm_and_ps(abs4Mask, x); +// } +// +// //vec4 sign(vec4 x) +// //{ +// // vec4 result; +// // if(x > vec4(0)) +// // result = vec4(1); +// // else if(x < T(0)) +// // result = vec4(-1); +// // else +// // result = vec4(0); +// // return result; +// //} +// __m128 sign(__m128 x) +// { +// __m128 result; +// __m128 cmp0 = _mm_cmpeq_ps(x, zero); +// if(_mm_movemask_ps(cmp0) == 0) +// result = zero; +// else +// { +// __m128 cmp1 = _mm_cmpge_ps(x, zero); +// //__m128 cmp2 = _mm_cmple_ps(x, zero); +// if(_mm_movemask_ps(cmp1) > 0) +// result = one; +// else //if(_mm_movemask_ps(cmp2) > 0) +// result = minus_one; +// } +// return result; +// } +// +// __m128 _mm_sgn_ss(__m128 x) +// { +// __m128 result; +// __m128 cmp0 = _mm_cmpeq_ss(x, zero); +// if(_mm_movemask_ss(cmp0) == 0) +// result = zero; +// else +// { +// __m128 cmp1 = _mm_cmpge_ss(x, zero); +// //__m128 cmp2 = _mm_cmple_ss(x, zero); +// if(_mm_movemask_ss(cmp1) > 0) +// result = one; +// else //if(_mm_movemask_ss(cmp2) > 0) +// result = minus_one; +// } +// return result; +// } +// +// __m128 _mm_sgn_ps(__m128 x) +// { +// __m128 cmp0 = _mm_cmpeq_ps(x, zero); +// __m128 cmp1 = _mm_cmple_ps(x, zero); +// __m128 cmp2 = _mm_cmpge_ps(x, zero) +// +// __m128 result; +// __m128 cmp0 = _mm_cmpeq_ps(x, zero); +// if(_mm_movemask_ps(cmp0) == 0) +// result = zero; +// else +// { +// __m128 cmp1 = _mm_cmpge_ps(x, zero); +// //__m128 cmp2 = _mm_cmple_ps(x, zero); +// if(_mm_movemask_ps(cmp1) > 0) +// result = one; +// else //if(_mm_movemask_ps(cmp2) > 0) +// result = minus_one; +// } +// return result; +// } +// +// //vec4 floor(vec4 x) +// //{ +// // return ::std::floor(x); +// //} +// +// __m128 floor(__m128 v) +// { +// +// } +// +// __m128 _mm_flr_ss(__m128 v) +// { +// +// } +// +// __m128 _mm_flr_ps(__m128 v) +// { +// +// } +// +// //vec4 ceil(vec4 x) +// //{ +// // return ::std::ceil(vec4); +// //} +// +// +// +// //vec4 fract(vec4 x) +// //{ +// // return x - floor(x); +// //} +// __m128 fract(__m128 x) +// { +// __m128 flr0 = floor(x); +// __m128 sub0 = _mm_sub_ps(x, flr0); +// return sub0; +// } +// +// __m128 _mm_frc_ss(__m128 x) +// { +// __m128 flr0 = _mm_flr_ss(x); +// __m128 sub0 = _mm_sub_ss(x, flr0); +// return sub0; +// } +// +// __m128 _mm_frc_ps(__m128 x) +// { +// __m128 flr0 = _mm_flr_ps(x); +// __m128 sub0 = _mm_sub_ps(x, flr0); +// return sub0; +// } +// +// //vec4 mod(vec4 x, vec4 y) +// //{ +// // return x - y * floor(x / y); +// //} +// __m128 mod(__m128 x, __m128 y) +// { +// __m128 div0 = _mm_div_ps(x, y); +// __m128 flr0 = _mm_flr_ps(div0); +// __m128 mul0 = _mm_mul_ps(y, flr0); +// __m128 sub0 = _mm_sub_ps(x, mul0); +// return sub0; +// } +// +// __m128 _mm_mod_ss(__m128 x, __m128 y) +// { +// __m128 div0 = _mm_div_ss(x, y); +// __m128 flr0 = _mm_flr_ss(div0); +// __m128 mul0 = _mm_mul_ss(y, flr0); +// __m128 sub0 = _mm_sub_ss(x, mul0); +// return sub0; +// } +// +// __m128 _mm_mod_ps(__m128 x, __m128 y) +// { +// __m128 div0 = _mm_div_ps(x, y); +// __m128 flr0 = _mm_flr_ps(div0); +// __m128 mul0 = _mm_mul_ps(y, flr0); +// __m128 sub0 = _mm_sub_ps(x, mul0); +// return sub0; +// } +// +// //vec4 min(vec4 x, vec4 y) +// //{ +// // return x < y ? x : y; +// //} +// __m128 min(__m128 v1, __m128 v2) +// { +// return _mm_min_ps(v1, v2); +// } +// +// //vec4 max(vec4 x, vec4 y) +// //{ +// // return x > y ? x : y; +// //} +// __m128 max(__m128 v1, __m128 v2) +// { +// return _mm_max_ps(v1, v2); +// } +// +// //vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal) +// //{ +// // return max(min(v, maxVal), minVal); +// //} +// __m128 clamp(__m128 v, __m128 minVal, __m128 maxVal) +// { +// return _mm_max_ps(_mm_min_ps(v, maxVal), minVal); +// } +// +// __m128 _mm_clp_ss(__m128 v, __m128 minVal, __m128 maxVal) +// { +// __m128 min0 = _mm_min_ss(v, maxVal); +// __m128 max0 = _mm_max_ss(min0, minVal); +// return max0; +// } +// +// __m128 _mm_clp_ps(__m128 v, __m128 minVal, __m128 maxVal) +// { +// __m128 min0 = _mm_min_ps(v, maxVal); +// __m128 max0 = _mm_max_ps(min0, minVal); +// return max0; +// } +// +// //vec4 mix(vec4 x, vec4 y, vec4 a) +// //{ +// // return x * (vec4(1) - a) + y * a; +// //} +// __m128 mix(__m128 v1, __m128 v2, __m128 a) +// { +// __m128 sub0 = _mm_sub_ps(one, a); +// __m128 mul0 = _mm_mul_ps(v1, sub0); +// __m128 mul1 = _mm_mul_ps(v2, a); +// __m128 add0 = _mm_add_ps(mul0, mul1); +// return add0; +// } +// +// __m128 _mm_lerp_ss(__m128 v1, __m128 v2, __m128 a) +// { +// __m128 sub0 = _mm_sub_ss(one, a); +// __m128 mul0 = _mm_mul_ss(v1, sub0); +// __m128 mul1 = _mm_mul_ss(v2, a); +// __m128 add0 = _mm_add_ss(mul0, mul1); +// return add0; +// } +// +// __m128 _mm_lerp_ps(__m128 v1, __m128 v2, __m128 a) +// { +// __m128 sub0 = _mm_sub_ps(one, a); +// __m128 mul0 = _mm_mul_ps(v1, sub0); +// __m128 mul1 = _mm_mul_ps(v2, a); +// __m128 add0 = _mm_add_ps(mul0, mul1); +// return add0; +// } +// +// //vec4 step(vec4 edge, vec4 x) +// //{ +// // return x <= edge ? vec4(0) : vec4(1); +// //} +// __m128 step(__m128 edge, __m128 x) +// { +// __m128 cmp = _mm_cmple_ps(x, edge); +// if(_mm_movemask_ps(cmp) == 0) +// return one; +// else +// return zero; +// } +// +// __m128 _mm_step_ss(__m128 edge, __m128 x) +// { +// __m128 cmp = _mm_cmple_ss(x, edge); +// if(_mm_movemask_ss(cmp) == 0) +// return one; +// else +// return zero; +// } +// +// __m128 _mm_step_ps(__m128 edge, __m128 x) +// { +// __m128 cmp = _mm_cmple_ps(x, edge); +// if(_mm_movemask_ps(cmp) == 0) +// return one; +// else +// return zero; +// } +// +// //vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x) +// //{ +// // vec4 tmp = clamp((x - edge0) / (edge1 - edge0), vec4(0), vec4(1)); +// // return tmp * tmp * (vec4(3) - vec4(2) * tmp); +// //} +// __m128 smoothstep(__m128 edge0, __m128 edge1, __m128 x) +// { +// __m128 sub0 = _mm_sub_ps(x, edge0); +// __m128 sub1 = _mm_sub_ps(edge1, edge0); +// __m128 div0 = _mm_sub_ps(sub0, sub1); +// __m128 clp0 = _mm_clp_ps(div0, zero, one); +// __m128 mul0 = _mm_mul_ps(two, clp0); +// __m128 sub2 = _mm_sub_ps(three, mul0); +// __m128 mul1 = _mm_mul_ps(clp0, clp0); +// __m128 mul2 = _mm_mul_ps(mul1, sub2); +// return mul2; +// } +// +// __m128 _mm_ssp_ss(__m128 edge0, __m128 edge1, __m128 x) +// { +// __m128 sub0 = _mm_sub_ss(x, edge0); +// __m128 sub1 = _mm_sub_ss(edge1, edge0); +// __m128 div0 = _mm_sub_ss(sub0, sub1); +// __m128 clp0 = _mm_clp_ss(div0, zero, one); +// __m128 mul0 = _mm_mul_ss(two, clp0); +// __m128 sub2 = _mm_sub_ss(three, mul0); +// __m128 mul1 = _mm_mul_ss(clp0, clp0); +// __m128 mul2 = _mm_mul_ss(mul1, sub2); +// return mul2; +// } +// +// __m128 _mm_ssp_ps(__m128 edge0, __m128 edge1, __m128 x) +// { +// __m128 sub0 = _mm_sub_ps(x, edge0); +// __m128 sub1 = _mm_sub_ps(edge1, edge0); +// __m128 div0 = _mm_sub_ps(sub0, sub1); +// __m128 clp0 = _mm_clp_ps(div0, zero, one); +// __m128 mul0 = _mm_mul_ps(two, clp0); +// __m128 sub2 = _mm_sub_ps(three, mul0); +// __m128 mul1 = _mm_mul_ps(clp0, clp0); +// __m128 mul2 = _mm_mul_ps(mul1, sub2); +// return mul2; +// } +// +// //float length(vec4 x) +// //{ +// // float sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; +// // return sqrt(sqr); +// //} +// __m128 length(__m128 x) +// { +// __m128 dot0 = dot(x, x); +// __m128 sqt0 = _mm_sqrt_ps(dot0); +// return sqt0; +// } +// +// __m128 _mm_len_ss(__m128 x) +// { +// __m128 dot0 = _mm_dot_ss(x, x); +// __m128 sqt0 = _mm_sqrt_ss(dot0); +// return sqt0; +// } +// +// __m128 _mm_len_ps(__m128 x) +// { +// __m128 dot0 = _mm_dot_ps(x, x); +// __m128 sqt0 = _mm_sqrt_ps(dot0); +// return sqt0; +// } +// +// //float distance(vec4 p0, vec4 p1) +// //{ +// // return length(p1 - p0); +// //} +// __m128 distance(__m128 p0, __m128 p1) +// { +// __m128 sub0 = _mm_sub_ps(p0, p1); +// __m128 len0 = _mm_len_ps(sub0); +// return len0; +// } +// +// __m128 _mm_dst_ss(__m128 p0, __m128 p1) +// { +// __m128 sub0 = _mm_sub_ps(p0, p1); +// __m128 len0 = _mm_len_ps(sub0); +// return len0; +// } +// +// __m128 _mm_dst_ps(__m128 p0, __m128 p1) +// { +// __m128 sub0 = _mm_sub_ps(p0, p1); +// __m128 len0 = _mm_len_ps(sub0); +// return len0; +// } +// +// //vec4 dot(vec4 x, vec4 y) +// //{ +// // return vec4(x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w); +// //} +// __m128 dot(__m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v1, v2); +// __m128 swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1)); +// __m128 add0 = _mm_add_ps(mul0, swp0); +// __m128 swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3)); +// __m128 add1 = _mm_add_ps(add0, swp1); +// return add1; +// } +// +// __m128 _mm_dot_ss(__m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v1, v2); +// __m128 swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1)); +// __m128 add0 = _mm_add_ps(mul0, swp0); +// __m128 swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3)); +// __m128 add1 = _mm_add_ps(add0, swp1); +// return add1; +// } +// +// __m128 _mm_dot_ps(__m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v1, v2); +// __m128 swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1)); +// __m128 add0 = _mm_add_ps(mul0, swp0); +// __m128 swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3)); +// __m128 add1 = _mm_add_ps(add0, swp1); +// return add1; +// } +// +// //vec3 cross(vec3 x, vec3 y) +// //{ +// // return vec3( +// // x.y * y.z - y.y * x.z, +// // x.z * y.x - y.z * x.x, +// // x.x * y.y - y.x * x.y); +// //} +// __m128 cross(__m128 v1, __m128 v2) +// { +// __m128 swp0 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp1 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 swp2 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp3 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 mul0 = _mm_mul_ps(swp0, swp3); +// __m128 mul1 = _mm_mul_ps(swp1, swp2); +// __m128 sub0 = _mm_sub_ps(mul0, mul1); +// return sub0; +// } +// +// __m128 _mm_xpd_ps(__m128 v1, __m128 v2) +// { +// __m128 swp0 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp1 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 swp2 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 0, 2, 1)); +// __m128 swp3 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 1, 0, 2)); +// __m128 mul0 = _mm_mul_ps(swp0, swp3); +// __m128 mul1 = _mm_mul_ps(swp1, swp2); +// __m128 sub0 = _mm_sub_ps(mul0, mul1); +// return sub0; +// } +// +// //vec4 normalize(vec4 x) +// //{ +// // float sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; +// // return x * inversesqrt(sqr); +// //} +// __m128 normalize(__m128 v) +// { +// __m128 dot0 = dot(v, v); +// __m128 isr0 = _mm_rsqrt_ps(dot0); +// __m128 mul0 = _mm_mul_ps(v, isr0); +// return mul0; +// } +// +// __m128 _mm_nrm_ps(__m128 v) +// { +// __m128 dot0 = dot(v, v); +// __m128 isr0 = _mm_rsqrt_ps(dot0); +// __m128 mul0 = _mm_mul_ps(v, isr0); +// return mul0; +// } +// +// __m128 rcp(__m128 v) +// { +// return _mm_rcp_ps(v); +// } +// +// //vec4 mad(vec4 v0, vec4 v1, vec4 v2) +// //{ +// // return v0 * v1 + v2; +// //} +// __m128 mad(__m128 v0, __m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v0, v1); +// __m128 add0 = _mm_add_ps(mul0, v2); +// return add0; +// } +// +// __m128 _mm_mad_ss(__m128 v0, __m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ss(v0, v1); +// __m128 add0 = _mm_add_ss(mul0, v2); +// return add0; +// } +// +// __m128 _mm_mad_ps(__m128 v0, __m128 v1, __m128 v2) +// { +// __m128 mul0 = _mm_mul_ps(v0, v1); +// __m128 add0 = _mm_add_ps(mul0, v2); +// return add0; +// } +// +// //vec4 reflect(vec4 I, vec4 N) +// //{ +// // return I - N * dot(N, I) * 2.0f; +// //} +// __m128 reflect(__m128 I, __m128 N) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(N, I); +// __m128 mul1 = _mm_mul_ps(mul0, two); +// __m128 sub0 = _mm_sub_ps(I, mul1); +// return sub0; +// } +// +// __m128 _mm_rfe_ps(__m128 I, __m128 N) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(N, I); +// __m128 mul1 = _mm_mul_ps(mul0, two); +// __m128 sub0 = _mm_sub_ps(I, mul1); +// return sub0; +// } +// +// //vec4 refract(vec4 I, vec4 N, T eta) +// //{ +// // float dotValue = dot(N, I); +// // float k = 1.0f - eta * eta * (1.0f - dotValue * dotValue); +// // if(k < 0.0f) +// // return vec4(0.0f); +// // return eta * I - (eta * dotValue + sqrt(k)) * N; +// //} +// __m128 refract(__m128 I, __m128 N, __m128 eta) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(eta, eta); +// __m128 mul1 = _mm_mul_ps(dot0, dot0); +// __m128 sub0 = _mm_sub_ps(one, mul0); +// __m128 sub1 = _mm_sub_ps(one, mul1); +// __m128 mul2 = _mm_mul_ps(sub0, sub1); +// +// if(_mm_movemask_ps(_mm_cmplt_ss(mul2, zero)) == 0) +// return zero; +// +// __m128 sqt0 = _mm_sqrt_ps(mul2); +// __m128 mul3 = _mm_mul_ps(eta, dot0); +// __m128 add0 = _mm_add_ps(mul3, sqt0); +// __m128 mul4 = _mm_mul_ps(add0, N); +// __m128 mul5 = _mm_mul_ps(eta, I); +// __m128 sub2 = _mm_sub_ps(mul5, mul4); +// +// return sub2; +// } +// +// __m128 _mm_rfa_ps(__m128 I, __m128 N, __m128 eta) +// { +// __m128 dot0 = dot(N, I); +// __m128 mul0 = _mm_mul_ps(eta, eta); +// __m128 mul1 = _mm_mul_ps(dot0, dot0); +// __m128 sub0 = _mm_sub_ps(one, mul0); +// __m128 sub1 = _mm_sub_ps(one, mul1); +// __m128 mul2 = _mm_mul_ps(sub0, sub1); +// +// if(_mm_movemask_ps(_mm_cmplt_ss(mul2, zero)) == 0) +// return zero; +// +// __m128 sqt0 = _mm_sqrt_ps(mul2); +// __m128 mul3 = _mm_mul_ps(eta, dot0); +// __m128 add0 = _mm_add_ps(mul3, sqt0); +// __m128 mul4 = _mm_mul_ps(add0, N); +// __m128 mul5 = _mm_mul_ps(eta, I); +// __m128 sub2 = _mm_sub_ps(mul5, mul4); +// +// return sub2; +// } +// +// +// struct vec4; +// typedef const vec4& vec4_param; +// +// template +// class comp +// { +// public: +// comp(int i) : +// index(i) +// { +// assert(i < N && i >= 0); +// } +// +// operator const int() const{return index;} +// +// private: +// int index; +// }; +// +// typedef comp<4> comp4_t; +// +// struct vec4 +// { +// vec4(); +// vec4(float s); +// vec4(float x, float y, float z, float w); +// vec4(float v[4]); +// +// explicit vec4(__m128 data); +// +// vec4& operator= (vec4_param v); +// vec4& operator+=(float s); +// vec4& operator+=(vec4_param v); +// vec4& operator-=(float s); +// vec4& operator-=(vec4_param v); +// vec4& operator*=(float s); +// vec4& operator*=(vec4_param v); +// vec4& operator/=(float s); +// vec4& operator/=(vec4_param v); +// vec4& operator++(); +// vec4& operator--(); +// +// union +// { +// __m128 data; +// struct{float x, y, z, w;}; +// float array[4]; +// }; +// }; +// +// vec4::vec4() : +// data(_mm_setzero_ps()) +// {} +// +// vec4::vec4(float s) : +// data(_mm_load_ps1(&s)) +//// data(_mm_set_ps1(s)) +// {} +// +// vec4::vec4(float v[4]) : +// data(_mm_load_ps(v)) +// {} +// +// vec4::vec4(float x, float y, float z, float w) : +//// data(_mm_setr_ps(x, y, z, w)) +// data(_mm_set_ps(w, z, y, x)) +// {} +// +// vec4::vec4(__m128 data) : +// data(data) +// {} +// +// vec4& vec4::operator= (vec4_param v) +// { +// this->data = v.data; +// return *this; +// } +// +// vec4& vec4::operator+=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_add_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator+=(vec4_param v) +// { +// this->data = _mm_add_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator-=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_sub_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator-=(vec4_param v) +// { +// this->data = _mm_sub_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator*=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_mul_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator*=(vec4_param v) +// { +// this->data = _mm_mul_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator/=(float s) +// { +// vec4 tmp(s); +// this->data = _mm_div_ps(this->data , tmp.data); +// return *this; +// } +// +// vec4& vec4::operator/=(vec4_param v) +// { +// this->data = _mm_div_ps(this->data , v.data); +// return *this; +// } +// +// vec4& vec4::operator++() +// { +// static __m128 inc = _mm_set_ps1(1.0f); +// this->data = _mm_add_ps(this->data , inc); +// return *this; +// } +// +// vec4& vec4::operator--() +// { +// static __m128 inc = _mm_set_ps1(1.0f); +// this->data = _mm_sub_ps(this->data , inc); +// return *this; +// } +// +// vec4 operator+ (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_add_ps(v1.data , v2.data)); +// } +// +// vec4 operator+ (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_add_ps(v1.data , v2.data)); +// } +// +// vec4 operator+ (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_add_ps(v1.data , v2.data)); +// } +// +// vec4 operator- (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_sub_ps(v1.data , v2.data)); +// } +// +// vec4 operator- (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_sub_ps(v1.data , v2.data)); +// } +// +// vec4 operator- (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_sub_ps(v1.data , v2.data)); +// } +// +// vec4 operator* (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_mul_ps(v1.data , v2.data)); +// } +// +// vec4 operator* (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_mul_ps(v1.data , v2.data)); +// } +// +// vec4 operator* (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_mul_ps(v1.data , v2.data)); +// } +// +// vec4 operator/ (const vec4& v1, const vec4& v2) +// { +// return vec4(_mm_div_ps(v1.data , v2.data)); +// } +// +// vec4 operator/ (const vec4& v1, const float s) +// { +// vec4 v2(s); +// return vec4(_mm_div_ps(v1.data , v2.data)); +// } +// +// vec4 operator/ (const float s, const vec4& v2) +// { +// vec4 v1(s); +// return vec4(_mm_div_ps(v1.data , v2.data)); +// } +// +// vec4 load(const vec4& v, const comp4_t component) +// { +// switch(component) +// { +// default: +// case 3: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(0, 0, 0, 0))); +// case 2: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(1, 1, 1, 1))); +// case 1: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(2, 2, 2, 2))); +// case 0: +// return vec4(_mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(3, 3, 3, 3))); +// } +// } +// +// vec4 rcp(vec4_param v) +// { +// return vec4(_mm_rcp_ps(v.data)); +// } +// +// vec4 sqrt(vec4_param v) +// { +// return vec4(_mm_sqrt_ps(v.data)); +// } +// +// vec4 inversesqrt(vec4_param v) +// { +// return vec4(_mm_rsqrt_ps(v.data)); +// } +// +// vec4 min(vec4_param v1, vec4_param v2) +// { +// return vec4(_mm_min_ps(v1.data, v2.data)); +// } +// +// vec4 max(vec4_param v1, vec4_param v2) +// { +// return vec4(_mm_max_ps(v1.data, v2.data)); +// } +// +// vec4 clamp(vec4_param v, float minVal, float maxVal) +// { +// vec4 v1(minVal); +// vec4 v2(maxVal); +// return vec4(_mm_min_ps(_mm_max_ps(v.data, v2.data), v1.data)); +// } +// +// vec4 clamp(vec4_param v, vec4_param minVal, vec4_param maxVal) +// { +// return vec4(_mm_min_ps(_mm_max_ps(v.data, maxVal.data), minVal.data)); +// } +// +// vec4 mix(vec4_param x, vec4_param y, vec4_param a) +// { +// __m128 one = _mm_set_ps1(1.0f); +// __m128 b = _mm_sub_ps(one, a.data); +// __m128 mul1 = _mm_mul_ps(x.data, b); +// __m128 mul2 = _mm_mul_ps(y.data, a.data); +// __m128 addFinal = _mm_add_ps(mul1, mul2); +// return vec4(addFinal); +// +// +//// __m128 b = _mm_sub_ps(_mm_set_ps1(1.0f), a.data); +//// return vec4(_mm_add_ps(_mm_mul_ps(x.data, b), _mm_mul_ps(y.data, a.data))); +// } +// +// float dot(vec4_param x, vec4_param y) +// { +// float result = 0.0f; +// _mm_store_ss(&result, dot(x.data, y.data)); +// return result; +// } +// +// vec4 reflect(vec4_param I, vec4_param N) +// { +// __m128 Normal = N.data; +// __m128 Inc = I.data; +// __m128 Two = _mm_set_ps1(2.0f); +// __m128 Mul = _mm_mul_ps(Normal, dot(Normal, Inc)); +// return vec4(_mm_sub_ps(Inc, _mm_mul_ps(Mul, Two))); +// } +// +// vec4 refract(vec4_param I, vec4_param N, float eta) +// { +// __m128 zero = _mm_set_ps1(0.0f); +// __m128 eta1 = _mm_set_ps1(eta); +// __m128 eta2 = _mm_mul_ps(eta1, eta1); +// __m128 one = _mm_set_ps1(1.0f); +// __m128 dotValue = dot(I.data, N.data); +// __m128 dotValue2 = _mm_mul_ps(dotValue, dotValue); +// __m128 k = _mm_sub_ps(one, _mm_mul_ps(eta2, _mm_sub_ps(one, dotValue2))); +// __m128 isnull = _mm_cmplt_ss(k, zero); +// if(_mm_movemask_ps(isnull) == 0) +// return vec4(zero); +// else +// { +// __m128 temp0 = _mm_add_ps(_mm_mul_ps(eta1, dotValue), sqrt(k)); +// __m128 temp1 = _mm_shuffle_ps(temp0, temp0, _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 temp2 = _mm_mul_ps(temp1, N.data); +// __m128 temp3 = _mm_mul_ps(eta1, I.data); +// return vec4(_mm_sub_ps(temp3, temp2)); +// } +// } +// +// +//}; +// +//namespace glm +//{ +// glm::vec4 rcp(const glm::vec4& v) +// { +// return 1.0f / v; +// } +//} +// +//namespace cpu +//{ +// void sincos(float a, float &s, float &c) +// { +// _asm +// { +// fld a +// fsincos +// mov ecx, c +// mov edx, s +// fstp dword ptr [ecx] +// fstp dword ptr [edx] +// } +// } +// +// void sincos(double a, double& s, double& c) +// { +// _asm +// { +// fld a +// fsincos +// mov ecx, c +// mov edx, s +// fstp qword ptr [ecx] +// fstp qword ptr [edx] +// } +// } +// +// float sin(float s) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s +// fsin +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// +// //float result = 0.0f; +// //_asm +// //{ +// // fld s +// // fsin +// // mov ecx, result +// // fstp dword ptr [ecx] +// //} +// //return result; +// } +// +// float abs(float s) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s +// fabs +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// +// //float result = 0.0f; +// //_asm +// //{ +// // fld s +// // fsin +// // mov ecx, result +// // fstp dword ptr [ecx] +// //} +// //return result; +// } +// +// float add(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fadd +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +// +// float sub(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fsub +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +// +// float mul(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fmul +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +// +// float div(float s1, float s2) +// { +// float result = 0.0f; +// float* p = &result; +// _asm +// { +// fld s1 +// fld s2 +// fdiv +// mov ecx, p +// fstp dword ptr [ecx] +// } +// return result; +// } +//} +// +//void test_asm() +//{ +// float sin0 = cpu::sin(1.0f); +// float sin1 = glm::sin(1.0f); +// float add0 = cpu::add(1.0f, 2.0f); +// float sub0 = cpu::sub(1.0f, 2.0f); +// +// +// float end = 1.0f; +//} +// +//void test_clamp() +//{ +// sse::vec4 v(0.5f, 0.5f, 9.5f, 9.5f); +// sse::vec4 minVal(1.0f, 2.0f, 3.0f, 4.0f); +// sse::vec4 maxVal(5.0f, 6.0f, 7.0f, 8.0f); +// +// __m128 clamp0 = sse::clamp( +// v.data, +// minVal.data, +// maxVal.data); +// +// glm::vec4 clamp1 = glm::clamp( +// glm::vec4(0.5f, 0.5f, 9.5f, 9.5f), +// glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), +// glm::vec4(5.0f, 6.0f, 7.0f, 8.0f)); +// +// __m128 end = _mm_setzero_ps(); +//} +// +//#define DECLARE_EPI32_CONST(name) \ +// extern const _MM_ALIGN16 int _epi32_##name[4]; +//#define IMPLEMENT_EPI32_CONST(name,x) \ +// const _MM_ALIGN16 int _epi32_##name[4]={x,x,x,x}; +//#define IMPLEMENT_EPI32_CONST4(name,x,y,z,w) \ +// const _MM_ALIGN16 int _epi32_##name[4]={w,z,y,x}; +// +//#define DECLARE_PS_CONST(name) \ +// extern const _MM_ALIGN16 float _ps_##name[4]; +//#define IMPLEMENT_PS_CONST(name,x) \ +// const _MM_ALIGN16 float _ps_##name[4]={x,x,x,x}; +//#define IMPLEMENT_PS_CONST4(name,x,y,z,w) \ +// const _MM_ALIGN16 float _ps_##name[4]={w,z,y,x}; +// +////IMPLEMENT_PS_CONST(sincos_p0, 0.15707963267948963959e1f) +////IMPLEMENT_PS_CONST(sincos_p1, -0.64596409750621907082e0f) +////IMPLEMENT_PS_CONST(sincos_p2, 0.7969262624561800806e-1f) +////IMPLEMENT_PS_CONST(sincos_p3, -0.468175413106023168e-2f) +// +//IMPLEMENT_EPI32_CONST(sign_mask,0x80000000) +//IMPLEMENT_EPI32_CONST(inv_sign_mask,0x7FFFFFFF) +//IMPLEMENT_EPI32_CONST(mant_mask,0x7F800000) +//IMPLEMENT_EPI32_CONST(inv_mant_mask,0x807FFFFF) +//IMPLEMENT_EPI32_CONST(min_norm_pos,0x00800000) +//IMPLEMENT_EPI32_CONST(1,1) +//IMPLEMENT_EPI32_CONST(2,2) +//IMPLEMENT_EPI32_CONST(7,7) +//IMPLEMENT_EPI32_CONST(127,127) +//IMPLEMENT_EPI32_CONST(ninf,0xFF800000) +//IMPLEMENT_EPI32_CONST(pinf,0x7F800000) +// +//IMPLEMENT_PS_CONST(1_3,0.33333333333333333333333333333333f) +//IMPLEMENT_PS_CONST(0p5,0.5f) +//IMPLEMENT_PS_CONST(1,1.0f) +//IMPLEMENT_PS_CONST(m1,-1.0f) +//IMPLEMENT_PS_CONST(2,2.0f) +//IMPLEMENT_PS_CONST(3,3.0f) +//IMPLEMENT_PS_CONST(127,127.0f) +//IMPLEMENT_PS_CONST(255,255.0f) +//IMPLEMENT_PS_CONST(2pow23,8388608.0f) +// +//IMPLEMENT_PS_CONST4(1_0_0_0,1.0f,0.0f,0.0f,0.0f) +//IMPLEMENT_PS_CONST4(0_1_0_0,0.0f,1.0f,0.0f,0.0f) +//IMPLEMENT_PS_CONST4(0_0_1_0,0.0f,0.0f,1.0f,0.0f) +//IMPLEMENT_PS_CONST4(0_0_0_1,0.0f,0.0f,0.0f,1.0f) +// +//IMPLEMENT_PS_CONST(pi, 3.1415926535897932384626433832795f) +//IMPLEMENT_PS_CONST(pi2, 6.283185307179586476925286766560f) +//IMPLEMENT_PS_CONST(2_pi, 0.63661977236758134307553505349006f) +//IMPLEMENT_PS_CONST(pi_2, 1.5707963267948966192313216916398f) +//IMPLEMENT_PS_CONST(4_pi, 1.2732395447351626861510701069801f) +//IMPLEMENT_PS_CONST(pi_4, 0.78539816339744830961566084581988f) +// +//IMPLEMENT_PS_CONST(sincos_p0, 0.15707963267948963959e1f) +//IMPLEMENT_PS_CONST(sincos_p1, -0.64596409750621907082e0f) +//IMPLEMENT_PS_CONST(sincos_p2, 0.7969262624561800806e-1f) +//IMPLEMENT_PS_CONST(sincos_p3, -0.468175413106023168e-2f) +//IMPLEMENT_PS_CONST(tan_p0, -1.79565251976484877988e7f) +//IMPLEMENT_PS_CONST(tan_p1, 1.15351664838587416140e6f) +//IMPLEMENT_PS_CONST(tan_p2, -1.30936939181383777646e4f) +//IMPLEMENT_PS_CONST(tan_q0, -5.38695755929454629881e7f) +//IMPLEMENT_PS_CONST(tan_q1, 2.50083801823357915839e7f) +//IMPLEMENT_PS_CONST(tan_q2, -1.32089234440210967447e6f) +//IMPLEMENT_PS_CONST(tan_q3, 1.36812963470692954678e4f) +//IMPLEMENT_PS_CONST(tan_poleval,3.68935e19f) +//IMPLEMENT_PS_CONST(atan_t0, -0.91646118527267623468e-1f) +//IMPLEMENT_PS_CONST(atan_t1, -0.13956945682312098640e1f) +//IMPLEMENT_PS_CONST(atan_t2, -0.94393926122725531747e2f) +//IMPLEMENT_PS_CONST(atan_t3, 0.12888383034157279340e2f) +//IMPLEMENT_PS_CONST(atan_s0, 0.12797564625607904396e1f) +//IMPLEMENT_PS_CONST(atan_s1, 0.21972168858277355914e1f) +//IMPLEMENT_PS_CONST(atan_s2, 0.68193064729268275701e1f) +//IMPLEMENT_PS_CONST(atan_s3, 0.28205206687035841409e2f) +// +//IMPLEMENT_PS_CONST(exp_hi, 88.3762626647949f) +//IMPLEMENT_PS_CONST(exp_lo, -88.3762626647949f) +//IMPLEMENT_PS_CONST(exp_rln2, 1.4426950408889634073599f) +//IMPLEMENT_PS_CONST(exp_p0, 1.26177193074810590878e-4f) +//IMPLEMENT_PS_CONST(exp_p1, 3.02994407707441961300e-2f) +//IMPLEMENT_PS_CONST(exp_q0, 3.00198505138664455042e-6f) +//IMPLEMENT_PS_CONST(exp_q1, 2.52448340349684104192e-3f) +//IMPLEMENT_PS_CONST(exp_q2, 2.27265548208155028766e-1f) +//IMPLEMENT_PS_CONST(exp_q3, 2.00000000000000000009e0f) +//IMPLEMENT_PS_CONST(exp_c1, 6.93145751953125e-1f) +//IMPLEMENT_PS_CONST(exp_c2, 1.42860682030941723212e-6f) +//IMPLEMENT_PS_CONST(exp2_hi, 127.4999961853f) +//IMPLEMENT_PS_CONST(exp2_lo, -127.4999961853f) +//IMPLEMENT_PS_CONST(exp2_p0, 2.30933477057345225087e-2f) +//IMPLEMENT_PS_CONST(exp2_p1, 2.02020656693165307700e1f) +//IMPLEMENT_PS_CONST(exp2_p2, 1.51390680115615096133e3f) +//IMPLEMENT_PS_CONST(exp2_q0, 2.33184211722314911771e2f) +//IMPLEMENT_PS_CONST(exp2_q1, 4.36821166879210612817e3f) +//IMPLEMENT_PS_CONST(log_p0, -7.89580278884799154124e-1f) +//IMPLEMENT_PS_CONST(log_p1, 1.63866645699558079767e1f) +//IMPLEMENT_PS_CONST(log_p2, -6.41409952958715622951e1f) +//IMPLEMENT_PS_CONST(log_q0, -3.56722798256324312549e1f) +//IMPLEMENT_PS_CONST(log_q1, 3.12093766372244180303e2f) +//IMPLEMENT_PS_CONST(log_q2, -7.69691943550460008604e2f) +//IMPLEMENT_PS_CONST(log_c0, 0.693147180559945f) +//IMPLEMENT_PS_CONST(log2_c0, 1.44269504088896340735992f) +// +//#define GLM_NAKED __declspec(naked) __cdecl +// +//__m128 GLM_NAKED _mm_cos_ps(__m128 x) +//{ +// __asm +// { +// andps xmm0, _epi32_inv_sign_mask +// addps xmm0, _ps_pi_2 +// mulps xmm0, _ps_2_pi +// pxor xmm3, xmm3 +// movdqa xmm5, _epi32_1 +// movaps xmm4, _ps_1 +// cvttps2dq xmm2, xmm0 +// pand xmm5, xmm2 +// pcmpeqd xmm5, xmm3 +// cvtdq2ps xmm6, xmm2 +// pand xmm2, _epi32_2 +// pslld xmm2, 30 +// subps xmm0, xmm6 +// minps xmm0, xmm4 +// subps xmm4, xmm0 +// andps xmm0, xmm5 +// andnps xmm5, xmm4 +// orps xmm0, xmm5 +// movaps xmm1, xmm0 +// mulps xmm0, xmm0 +// orps xmm1, xmm2 +// movaps xmm7, xmm0 +// mulps xmm0, _ps_sincos_p3 +// addps xmm0, _ps_sincos_p2 +// mulps xmm0, xmm7 +// addps xmm0, _ps_sincos_p1 +// mulps xmm0, xmm7 +// addps xmm0, _ps_sincos_p0 +// mulps xmm0, xmm1 +// ret +// } +//} +// +//void test_sse() +//{ +// sse::vec4 v1(1.0f, 2.0f, 3.0f, 4.0f); +// sse::vec4 v2(5.0f, 6.0f, 7.0f, 8.0f); +// sse::vec4 v3(9.0f); +// sse::vec4 v4(0.5f, 0.5f, 0.5f, 0.5f); +// __m128 v5 = sse::mix(v1.data, v2.data, v4.data); +// __m128 dot0 = sse::dot(v1.data, v2.data); +// float dot1 = sse::dot(v1, v2); +// __m128 rcp0 = sse::rcp(v1.data); +// glm::vec4 rcp1 = rcp(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); +// +// // cross +// { +// sse::vec4 v1(4.0f, 2.0f, 2.0f, 0.0f); +// sse::vec4 v2(1.0f, 2.0f, 3.0f, 0.0f); +// __m128 crs0 = sse::cross(v1.data, v2.data); +// +// glm::vec3 v3(4.0f, 2.0f, 2.0f); +// glm::vec3 v4(1.0f, 2.0f, 3.0f); +// glm::vec3 crs1 = glm::cross(v3, v4); +// +// __m128 end = _mm_set_ps1(1.0f); +// } +// +// // ieee754 +// { +// sse::detail::ieee754 one(1.f); +// float f = sse::load(one.mantissa, one.exp, one.sign); +// +// __m128 end = _mm_set_ps1(1.0f); +// } +// +// test_clamp(); +// test_asm(); +// +// __m128 cos0 = _mm_cos_ps(_mm_set_ps1(1.0f)); +// glm::vec4 cos1 = glm::cos(glm::vec4(1.0f)); +// +// float f = glm::dot(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f)); +// sse::vec4 end(9.0f); +// +// //sse::vec4 vComp = sse::load(sse::vec4(1.0f, 2.0f, 3.0f, 4.0f), 1); +// //vComp += sse::vec4(1.0f); +// //--vComp; +// //sse::vec4 vMixed = sse::mix(vComp, sse::vec4(-0.5f), sse::vec4(0.5f)); +// //float sDot = sse::dot(sse::vec4(1.0f), sse::vec4(2.0f)); +// //float cDot = glm::dot(glm::vec4(1.0f), glm::vec4(2.0f)); +//} diff --git a/wip/sse/sse.h b/wip/sse/sse.h new file mode 100644 index 00000000..3ba5a7a0 --- /dev/null +++ b/wip/sse/sse.h @@ -0,0 +1,13 @@ +#ifndef __GLM_SSE_H__ +#define __GLM_SSE_H__ + +#ifdef _WIN32 +#include +#endif + +#include "glm/glm.h" +#include "glm/glmext.h" + +void test_sse(); + +#endif//__GLM_SSE_H__ diff --git a/wip/sse/sse.sln b/wip/sse/sse.sln new file mode 100644 index 00000000..7f54daaa --- /dev/null +++ b/wip/sse/sse.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sse", "sse.vcproj", "{55569881-CA84-46D7-A385-C192D498163F}" +EndProject +Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {55569881-CA84-46D7-A385-C192D498163F}.Debug|Win32.ActiveCfg = Debug|Win32 + {55569881-CA84-46D7-A385-C192D498163F}.Debug|Win32.Build.0 = Debug|Win32 + {55569881-CA84-46D7-A385-C192D498163F}.Release|Win32.ActiveCfg = Release|Win32 + {55569881-CA84-46D7-A385-C192D498163F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/wip/sse/sse.vcproj b/wip/sse/sse.vcproj new file mode 100644 index 00000000..a968a81a --- /dev/null +++ b/wip/sse/sse.vcproj @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wip/sse/sse_mat4.cpp b/wip/sse/sse_mat4.cpp new file mode 100644 index 00000000..34a0c5ad --- /dev/null +++ b/wip/sse/sse_mat4.cpp @@ -0,0 +1,60 @@ +#include "precompiled.h" +#include "sse_mat4.h" + +void test_sse_mat4() +{ + { + glm::sse::mat4 m( + glm::sse::vec4(0, 1, 2, 3), + glm::sse::vec4(4, 5, 6, 7), + glm::sse::vec4(8, 9, 10, 11), + glm::sse::vec4(12, 13, 14, 15)); + glm::sse::mat4 n = glm::sse::transpose(m); + m.transpose(); + glm::sse::mat4 m_end; + } + + { + glm::sse::mat4 m0; + glm::sse::mat4 m1(3.f); + glm::sse::mat4 m2( + glm::sse::vec4(1), + glm::sse::vec4(2), + glm::sse::vec4(3), + glm::sse::vec4(4)); + glm::sse::mat4 m3 = m1 + 1.0f; + glm::sse::mat4 m4 = 1.0f + m1; + glm::sse::mat4 m5 = m2 * m2; + + glm::sse::vec4 v0 = glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::sse::vec4 v1 = glm::sse::vec4(5.0f, 6.0f, 7.0f, 8.0f); + glm::sse::vec4 v2 = glm::sse::mat4(v0, v1, v0, v1) * glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::sse::vec4 v3 = glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f) * glm::sse::mat4(v0, v1, v0, v1); + glm::sse::vec4 v_end; + } + + { + glm::mat4 m0; + glm::mat4 m1(3.f); + glm::mat4 m2( + glm::vec4(1), + glm::vec4(2), + glm::vec4(3), + glm::vec4(4)); + glm::mat4 m3 = m1 + 1.0f; + glm::mat4 m4 = 1.0f + m1; + glm::mat4 m5 = m2 * m2; + + glm::vec4 v0 = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::vec4 v1 = glm::vec4(5.0f, 6.0f, 7.0f, 8.0f); + glm::vec4 v2 = glm::mat4(v0, v1, v0, v1) * glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); + glm::vec4 v3 = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) * glm::mat4(v0, v1, v0, v1); + glm::vec4 v_end; + } + + { + int a[][4] = {{0, 0, 1, 2}, {0, 0, 1, 2}}; + } + + glm::sse::mat4 m_end; +} diff --git a/wip/sse/sse_mat4.h b/wip/sse/sse_mat4.h new file mode 100644 index 00000000..31257107 --- /dev/null +++ b/wip/sse/sse_mat4.h @@ -0,0 +1,1280 @@ +#ifndef GLM_SSE_MAT4_H +#define GLM_SSE_MAT4_H + +#include +#include +#include "sse_vec4.h" + +namespace glm{ +namespace sse{ + +const __m128i maskX = _mm_set_epi32(0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF); +const __m128i maskY = _mm_set_epi32(0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000); +const __m128i maskZ = _mm_set_epi32(0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000); +const __m128i maskW = _mm_set_epi32(0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000); + +GLM_ALIGN(16) struct mat4 +{ + enum ENoInit + { + NO_INIT + }; + + union + { + __m128 data[4]; + }; + + mat4(); + mat4(ENoInit NoInit); + mat4(float s); + mat4(const vec4& x, const vec4& y, const vec4& z, const vec4& w); + + mat4& operator+=(const float s); + + mat4& operator+=(const mat4& m); + mat4& operator*=(const mat4& m); + + void mat4::transpose(); +}; + +__forceinline mat4::mat4() +{ + void* address = this; + + __asm + { + mov esi, address + xorps xmm0, xmm0 + movaps [esi+0x00], xmm0 + movaps [esi+0x10], xmm0 + movaps [esi+0x20], xmm0 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4::mat4(ENoInit NoInit) +{} + +__forceinline mat4::mat4(float s) +{ + void* address = this; + + __asm + { + mov esi, address + movss xmm0, s + shufps xmm0, xmm0, 0 + xorps xmm1, xmm1 + movaps [esi+0x00], xmm1 + movaps [esi+0x10], xmm1 + movaps [esi+0x20], xmm1 + movaps [esi+0x30], xmm1 + movss [esi+0x00], xmm0 + movss [esi+0x14], xmm0 + movss [esi+0x28], xmm0 + movss [esi+0x3C], xmm0 + } +} + +__forceinline mat4::mat4(const vec4& x, const vec4& y, const vec4& z, const vec4& w) +{ + void* address = this; + + __asm + { + mov esi, address + + mov edi, x + movaps xmm0, [edi] + movaps [esi+0x00], xmm0 + + mov edi, y + movaps xmm0, [edi] + movaps [esi+0x10], xmm0 + + mov edi, z + movaps xmm0, [edi] + movaps [esi+0x20], xmm0 + + mov edi, w + movaps xmm0, [edi] + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator+(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + addps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + addps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + addps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + addps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator+(float s, const mat4& m) +{ + return m + s; +} + +__forceinline mat4 operator-(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + subps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + subps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + subps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + subps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator-(float s, const mat4& m) +{ + __asm + { + movss xmm2, s + shufps xmm2, xmm2, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x00], xmm1 + + movaps xmm0, [esi+0x10] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x10], xmm1 + + movaps xmm0, [esi+0x20] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x20], xmm1 + + movaps xmm0, [esi+0x30] + movaps xmm1, xmm2 + subps xmm1, xmm0 + movaps [esi+0x30], xmm1 + } +} + +__forceinline mat4 operator*(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + mulps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + mulps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + mulps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + mulps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator*(float s, const mat4& m) +{ + return m * s; +} + +__forceinline mat4 operator/(const mat4& m, float s) +{ + __asm + { + movss xmm1, s + shufps xmm1, xmm1, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + divps xmm0, xmm1 + movaps [esi+0x00], xmm0 + + movaps xmm0, [esi+0x10] + divps xmm0, xmm1 + movaps [esi+0x10], xmm0 + + movaps xmm0, [esi+0x20] + divps xmm0, xmm1 + movaps [esi+0x20], xmm0 + + movaps xmm0, [esi+0x30] + divps xmm0, xmm1 + movaps [esi+0x30], xmm0 + } +} + +__forceinline mat4 operator/(float s, const mat4& m) +{ + __asm + { + movss xmm2, s + shufps xmm2, xmm2, 0 + mov esi, [m] + + movaps xmm0, [esi+0x00] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x00], xmm1 + + movaps xmm0, [esi+0x10] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x10], xmm1 + + movaps xmm0, [esi+0x20] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x20], xmm1 + + movaps xmm0, [esi+0x30] + movaps xmm1, xmm2 + divps xmm1, xmm0 + movaps [esi+0x30], xmm1 + } +} + +__forceinline vec4 operator*(const mat4& m, const vec4& v) +{ + vec4 result(vec4::NO_INIT); + + // SSE2 + __asm + { + mov esi, [m] + mov edi, [v] + movaps xmm4, [edi] + + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result, xmm0 + } + + return result; +} + +__forceinline vec4 operator*(const vec4& v, const mat4& m) +{ + vec4 result(vec4::NO_INIT); + + // SSE1 + __asm + { + mov esi, [m] + mov edi, [v] + movaps xmm4, [edi] // xmm4: v[3], v[2], v[1], v[0] + + movaps xmm0, [esi+0x00] // xmm0: m[0][3], m[0][2], m[0][1], m[0][0] + movaps xmm1, [esi+0x10] // xmm1: m[1][3], m[1][2], m[1][1], m[1][0] + movaps xmm2, [esi+0x20] // xmm2: m[2][3], m[2][2], m[2][1], m[2][0] + movaps xmm3, [esi+0x30] // xmm3: m[3][3], m[3][2], m[3][1], m[3][0] + + mulps xmm0, xmm4 // xmm0: m[0][3]*v[3], m[0][2]*v[2], m[0][1]*v[1], m[0][0]*v[0] + mulps xmm1, xmm4 // xmm1: m[1][3]*v[3], m[1][2]*v[2], m[1][1]*v[1], m[1][0]*v[0] + mulps xmm2, xmm4 // xmm2: m[2][3]*v[3], m[2][2]*v[2], m[2][1]*v[1], m[2][0]*v[0] + mulps xmm3, xmm4 // xmm2: m[3][3]*v[3], m[3][2]*v[2], m[3][1]*v[1], m[3][0]*v[0] + + movaps xmm4, xmm0 // xmm4: m[0][3]*v[3], m[0][2]*v[2], m[0][1]*v[1], m[0][0]*v[0] + movhlps xmm0, xmm1 // xmm0: m[0][3]*v[3], m[0][2]*v[2], m[1][3]*v[3], m[1][2]*v[2] + movlhps xmm1, xmm4 // xmm1: m[0][1]*v[1], m[0][0]*v[0], m[1][1]*v[1], m[1][0]*v[0] + addps xmm0, xmm1 + + movaps xmm5, xmm2 + movhlps xmm2, xmm3 + movlhps xmm3, xmm5 + addps xmm2, xmm3 + + movaps xmm1, xmm0 + shufps xmm0, xmm2, _MM_SHUFFLE(0, 2, 0, 2) //_MM_SHUFFLE(2, 0, 2, 0) + shufps xmm1, xmm2, _MM_SHUFFLE(1, 3, 1, 3) //_MM_SHUFFLE(3, 1, 3, 1) + addps xmm0, xmm1 + + movaps result, xmm0 + } + + return result; +} + +// 289000 +/* +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + next: + movaps xmm7, [edi] + + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm4 + + pshufd xmm4, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm4 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm4 + + pshufd xmm4, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm4 + + addps xmm2, xmm3 + addps xmm0, xmm1 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +// 288000 +/* +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + next: + movaps xmm7, [edi] + + movaps xmm0, [esi+0x00] + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm5 + + movaps xmm1, [esi+0x10] + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + + movaps xmm2, [esi+0x20] + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm5 + + movaps xmm3, [esi+0x30] + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ +/* +// 290000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm4 + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm4 + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 295000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm4 + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm4 + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 290000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm0, xmm4 + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm2, xmm4 + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 288000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov ecx, 0x10 + mov edx, 0x04 + + movaps xmm7, [edi] + + next: + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm4, xmm7, _MM_SHUFFLE(0, 0, 0, 0) + pshufd xmm5, xmm7, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm0, xmm4 + mulps xmm1, xmm5 + addps xmm0, xmm1 + + pshufd xmm4, xmm7, _MM_SHUFFLE(2, 2, 2, 2) + pshufd xmm5, xmm7, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm2, xmm4 + mulps xmm3, xmm5 + addps xmm2, xmm3 + + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, ecx + add eax, ecx + dec edx + jnz next + } + + return result; +} +*/ + +/* +// 298000 +inline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result; + void* adresse = &result; + + const int int0x10 = 0x10; + + // SSE2 + __asm + { + mov esi, m + mov edi, n + mov eax, adresse + mov edx, int0x10 + + // First column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, edx + add eax, edx + + // Second column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, edx + add eax, edx + + // Third column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + + add edi, edx + add eax, edx + + // Forth column + movaps xmm4, [edi] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps [eax], xmm0 + } + + return result; +} +*/ + +// 294000 +__forceinline mat4 operator*(const mat4& m, const mat4& n) +{ + mat4 result(mat4::NO_INIT); + + // SSE2 + __asm + { + mov esi, m + mov edi, n + + // First column + movaps xmm4, [edi+0x00] + + movaps xmm0, [esi+0x00] + movaps xmm1, [esi+0x10] + movaps xmm2, [esi+0x20] + movaps xmm3, [esi+0x30] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + mulps xmm0, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + mulps xmm1, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + mulps xmm2, xmm5 + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x00], xmm0 + + // Second column + movaps xmm4, [edi+0x10] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x10], xmm0 + + // Third column + movaps xmm4, [edi+0x20] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x20], xmm0 + + // Forth column + movaps xmm4, [edi+0x30] + + pshufd xmm5, xmm4, _MM_SHUFFLE(0, 0, 0, 0) + movaps xmm0, [esi+0x00] + mulps xmm0, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(1, 1, 1, 1) + movaps xmm1, [esi+0x10] + mulps xmm1, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(2, 2, 2, 2) + movaps xmm2, [esi+0x20] + mulps xmm2, xmm5 + + pshufd xmm5, xmm4, _MM_SHUFFLE(3, 3, 3, 3) + movaps xmm3, [esi+0x30] + mulps xmm3, xmm5 + + addps xmm0, xmm1 + addps xmm2, xmm3 + addps xmm0, xmm2 + + movaps result[0x30], xmm0 + } + + return result; +} + +const __m128 sign1010 = _mm_set_ps( 1.0f,-1.0f, 1.0f,-1.0f); +const __m128 sign0101 = _mm_set_ps(-1.0f, 1.0f,-1.0f, 1.0f); +const __m128i mask1010 = _mm_set_epi32(0x00000000, 0x80000000, 0x00000000, 0x80000000); +const __m128i mask0101 = _mm_set_epi32(0x80000000, 0x00000000, 0x80000000, 0x00000000); + +__forceinline mat4 inverse(const mat4& m) +{ + mat4 result(mat4::NO_INIT); + + vec4 m0a; + vec4 m0b; + vec4 m0c; + + vec4 m1a; + vec4 m1b; + vec4 m1c; + + vec4 m2a; + vec4 m2b; + vec4 m2c; + + vec4 m3a; + vec4 m3b; + vec4 m3c; + + __asm + { + mov esi, m + + ////////////////////////////////////////////////////////////////////////////////////////////// + //R00 = +1 * m11*(m22*m33 - m32*m23) -1 * m12*(m23*m31 - m33*m21) +1 * m13*(m21*m32 - m31*m22) + //R01 = -1 * m12*(m23*m30 - m33*m20) +1 * m13*(m20*m32 - m30*m22) -1 * m10*(m22*m33 - m32*m23) + //R02 = +1 * m13*(m20*m31 - m30*m21) -1 * m10*(m21*m33 - m31*m23) +1 * m11*(m23*m30 - m33*m20) + //R03 = -1 * m10*(m21*m32 - m31*m22) +1 * m11*(m22*m30 - m32*m20) -1 * m12*(m20*m31 - m30*m21) + + movaps xmm6, [esi+20] // xmm6: m23, m22, m21, m20 + movaps xmm7, [esi+30] // xmm7: m33, m32, m31, m30 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm0: m21, m20, m23, m22 (movhlps optimization possible) + pshufd xmm1, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm1: m30, m33, m32, m31 + pshufd xmm2, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm2: m20, m23, m22, m21 + pshufd xmm3, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm3: m31, m30, m33, m32 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m21*m30, m20*m33, m23*m32, m22*m31 + mulps xmm3, xmm2 // xmm2: m20*m31, m23*m30, m22*m33, m21*m32 + subps xmm3, xmm0 // xmm2: m20*m31-m21*m30, m23*m30-m20*m33, m22*m33-m23*m32, m21*m32-m22*m31 + movaps xmm4, xmm3 // xmm4: m20*m31-m21*m30, m23*m30-m20*m33, m22*m33-m23*m32, m21*m32-m22*m31 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm0: m22, m21, m20, m23 + // Reuse xmm1: pshufd xmm1, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm1: m30, m33, m32, m31 + // Reuse xmm2: pshufd xmm2, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm2: m20, m23, m22, m21 + pshufd xmm3, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm3: m32, m31, m30, m33 + + mulps xmm1, xmm0 // xmm1: m30*m22, m33*m21, m32*m20, m31*m23 + mulps xmm2, xmm3 // xmm2: m20*m32, m23*m31, m22*m30, m21*m33 + subps xmm1, xmm2 // xmm1: m30*m22-m20*m32, m33*m21-m23*m31, m32*m20-m22*m30, m31*m23-m21*m33 + movaps xmm5, xmm2 // xmm5: m30*m22-m20*m32, m33*m21-m23*m31, m32*m20-m22*m30, m31*m23-m21*m33 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + // Reuse xmm0: pshufd xmm0, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm0: m22, m21, m20, m23 + pshufd xmm1, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm1: m31, m30, m33, m32 (movhlps optimization possible) + pshufd xmm2, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm2: m21, m20, m23, m22 (movhlps optimization possible) + // Reuse xmm3: pshufd xmm3, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm3: m32, m31, m30, m33 + + mulps xmm0, xmm1 // xmm1: m22*m31, m21*m30, m20*m33, m23*m32 + mulps xmm2, xmm3 // xmm2: m21*m32, m20*m31, m23*m30, m22*m33 + subps xmm2, xmm0 // xmm2: m23*m32-m22*m33, m20*m33-m23*m30, m21*m30-m20*m31, m22*m31-m21*m32 + movaps xmm6, xmm0 // xmm6: m23*m32-m22*m33, m20*m33-m23*m30, m21*m30-m20*m31, m22*m31-m21*m32 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + movaps xmm0, [esi+10] // m13, m12, m11, m10 + + pshufd xmm1, xmm0, _MM_SHUFFLE(2, 1, 0, 3) + xorps xmm1, mask1010 //-m12, m11,-m10, m13 + mulaps xmm4, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(1, 0, 3, 2) // (movhlps optimization possible) + xorps xmm1, mask0101 // m11,-m10, m13,-m12 + mulaps xmm5, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(0, 3, 2, 1) + xorps xmm1, mask1010 //-m10, m13,-m12, m10 + mulaps xmm6, xmm1 + + mulaps xmm6, xmm5 + mulaps xmm6, xmm4 + movaps result[0x00], xmm6 + + ////////////////////////////////////////////////////////////////////////////////////////////// + //R10 = -1 * m21*(m32*m03 – m02*m33) +1 * m22*(m33*m01 – m03*m31) –1 * m23*(m31*m02 – m01*m32) + //R11 = +1 * m22*(m33*m00 – m03*m30) –1 * m23*(m30*m02 – m00*m32) +1 * m20*(m32*m03 – m02*m33) + //R12 = -1 * m23*(m30*m01 – m00*m31) +1 * m20*(m31*m03 – m01*m33) -1 * m21*(m33*m00 – m03*m30) + //R13 = +1 * m20*(m31*m02 – m01*m32) -1 * m21*(m32*m00 – m02*m30) +1 * m22*(m30*m01 – m00*m31) + + movaps xmm6, [esi+00] // xmm6: m03, m02, m01, m00 + // Reuse xmm7 movaps xmm7, [esi+30] // xmm7: m33, m32, m31, m30 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm0: m00, m03, m02, m01 + pshufd xmm1, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm1: m31, m30, m33, m32 (movhlps optimization possible) + pshufd xmm2, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm2: m01, m00, m03, m02 (movhlps optimization possible) + pshufd xmm3, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm3: m30, m33, m32, m31 + + mulps xmm0, xmm1 // xmm0: m31*m00, m30*m03, m33*m02, m32*m01 + mulps xmm3, xmm2 // xmm3: m30*m01, m33*m00, m32*m03, m31*m02 + subps xmm3, xmm0 // xmm3: m30*m01-m31*m00, m33*m00-m30*m03, m32*m03-m33*m02, m31*m02-m32*m01 + movaps xmm4, xmm3 // xmm4: m30*m01-m31*m00, m33*m00-m30*m03, m32*m03-m33*m02, m31*m02-m32*m01 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + // Reuse xmm0 pshufd xmm0, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm0: m00, m03, m02, m01 + pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + // Reuse xmm3 pshufd xmm3, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm3: m30, m33, m32, m31 + + mulps xmm0, xmm1 // xmm0: m00*m32, m03*m31, m02*m30, m01*m33 + mulps xmm3, xmm2 // xmm3: m30*m02, m33*m01, m32*m00, m31*m03 + subps xmm0, xmm3 // xmm3: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + movaps xmm5, xmm0 // xmm4: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(3, 0, 3, 2) // xmm0: m01, m00, m03, m02 (movhlps optimization possible) + // Reuse xmm1: pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + // Reuse xmm2: pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + pshufd xmm3, xmm7, _MM_SHUFFLE(3, 0, 3, 2) // xmm3: m31, m30, m33, m32 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m01*m32, m00*m31, m03*m30, m02*m33 + mulps xmm3, xmm2 // xmm3: m02*m31, m01*m30, m00*m33, m03*m32 + subps xmm3, xmm0 // xmm3: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + movaps xmm6, xmm3 // xmm6: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + movaps xmm0, [esi+20] // m23, m22, m21, m20 + + pshufd xmm1, xmm0, _MM_SHUFFLE(2, 1, 0, 3) + xorps xmm1, mask0101 //-m22, m21,-m20, m23 + mulaps xmm4, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(1, 0, 3, 2) // (movhlps optimization possible) + xorps xmm1, mask1010 // m21,-m20, m23,-m22 + mulaps xmm5, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(0, 3, 2, 1) + xorps xmm1, mask0101 //-m20, m23,-m22, m21 + mulaps xmm6, xmm1 + + mulaps xmm6, xmm5 + mulaps xmm6, xmm4 + movaps result[0x10], xmm6 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + //R20 = +1 * m31*(m02*m13 - m12*m03) -1 * m32*(m03*m11 – m13*m01) +1 * m33*(m01*m12 - m11*m02) + //R21 = -1 * m32*(m03*m10 - m13*m00) +1 * m33*(m00*m12 – m10*m02) -1 * m30*(m02*m13 - m12*m03) + //R22 = +1 * m33*(m00*m11 - m10*m01) -1 * m30*(m01*m13 – m11*m03) +1 * m31*(m03*m10 - m13*m00) + //R23 = -1 * m30*(m01*m12 - m11*m02) +1 * m31*(m02*m10 – m12*m00) -1 * m32*(m00*m11 - m10*m01) + + //Reuse xmm6: movaps xmm6, [esi+00] // xmm6: m03, m02, m01, m00 + movaps xmm7, [esi+10] // xmm7: m13, m12, m11, m10 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(1, 0, 3, 2) // xmm0: m11, m10, m13, m12 (movhlps optimization possible) + pshufd xmm1, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm1: m00, m03, m02, m01 + pshufd xmm2, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm2: m10, m13, m12, m11 + pshufd xmm3, xmm7, _MM_SHUFFLE(1, 0, 3, 2) // xmm3: m01, m00, m03, m02 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m11*m00, m10*m03, m13*m02, m12*m01 + mulps xmm3, xmm2 // xmm3: m01*m10, m00*m13, m03*m12, m02*m11 + subps xmm3, xmm0 // xmm3: m11*m00-m01*m10, m10*m03-m00*m13, m13*m02-m03*m12, m12*m01-m02*m11 + movaps xmm4, xmm3 // xmm4: m11*m00-m01*m10, m10*m03-m00*m13, m13*m02-m03*m12, m12*m01-m02*m11 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + + + + + + + // Reuse xmm0 pshufd xmm0, xmm6, _MM_SHUFFLE(0, 3, 2, 1) // xmm0: m00, m03, m02, m01 + pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + // Reuse xmm3 pshufd xmm3, xmm7, _MM_SHUFFLE(0, 3, 2, 1) // xmm3: m30, m33, m32, m31 + + mulps xmm0, xmm1 // xmm0: m00*m32, m03*m31, m02*m30, m01*m33 + mulps xmm3, xmm2 // xmm3: m30*m02, m33*m01, m32*m00, m31*m03 + subps xmm0, xmm3 // xmm3: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + movaps xmm5, xmm0 // xmm4: m00*m32-m30*m02, m03*m31-m33*m01, m02*m30-m32*m00, m01*m33-m31*m03 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + pshufd xmm0, xmm6, _MM_SHUFFLE(3, 0, 3, 2) // xmm0: m01, m00, m03, m02 (movhlps optimization possible) + // Reuse xmm1: pshufd xmm1, xmm7, _MM_SHUFFLE(2, 1, 0, 3) // xmm1: m32, m31, m30, m33 + // Reuse xmm2: pshufd xmm2, xmm6, _MM_SHUFFLE(2, 1, 0, 3) // xmm2: m02, m01, m00, m03 + pshufd xmm3, xmm7, _MM_SHUFFLE(3, 0, 3, 2) // xmm3: m31, m30, m33, m32 (movhlps optimization possible) + + mulps xmm0, xmm1 // xmm0: m01*m32, m00*m31, m03*m30, m02*m33 + mulps xmm3, xmm2 // xmm3: m02*m31, m01*m30, m00*m33, m03*m32 + subps xmm3, xmm0 // xmm3: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + movaps xmm6, xmm3 // xmm6: m02*m31-m01*m32, m01*m30-m00*m31, m00*m33-m03*m30, m03*m32-m02*m33 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + movaps xmm0, [esi+20] // m23, m22, m21, m20 + + pshufd xmm1, xmm0, _MM_SHUFFLE(2, 1, 0, 3) + xorps xmm1, mask0101 //-m22, m21,-m20, m23 + mulaps xmm4, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(1, 0, 3, 2) // (movhlps optimization possible) + xorps xmm1, mask1010 // m21,-m20, m23,-m22 + mulaps xmm5, xmm1 + + pshufd xmm1, xmm0, _MM_SHUFFLE(0, 3, 2, 1) + xorps xmm1, mask0101 //-m20, m23,-m22, m21 + mulaps xmm6, xmm1 + + mulaps xmm6, xmm5 + mulaps xmm6, xmm4 + movaps result[0x10], xmm6 + + ////////////////////////////////////////////////////////////////////////////////////////////// + + + } + + return result; +} + +__forceinline mat4 transpose(const mat4& m) +{ + mat4 result(mat4::NO_INIT); + + __asm + { + mov esi, m + + movaps xmm4, [esi+0x00] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x10] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movaps xmm0, xmm5 + movhlps xmm1, xmm5 + + movaps xmm2, xmm4 + movhlps xmm3, xmm4 + + movaps xmm4, [esi+0x20] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x30] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movlhps xmm0, xmm5 + movlhps xmm2, xmm4 + + movhlps xmm7, xmm5 + movhlps xmm6, xmm4 + + movlhps xmm1, xmm7 + movlhps xmm3, xmm6 + + movaps result[0x00], xmm0 + movaps result[0x10], xmm1 + movaps result[0x20], xmm2 + movaps result[0x30], xmm3 + } + + return result; +} + +__forceinline void mat4::transpose() +{ + void* address = this; + + __asm + { + mov esi, address + + movaps xmm4, [esi+0x00] + movaps xmm6, [esi+0x10] + movaps xmm5, xmm4 + + unpcklps xmm5, xmm6 + movaps xmm0, xmm5 + movhlps xmm1, xmm5 + + unpckhps xmm4, xmm6 + movaps xmm2, xmm4 + movhlps xmm3, xmm4 + + movaps xmm4, [esi+0x20] + movaps xmm6, [esi+0x30] + movaps xmm5, xmm4 + + unpcklps xmm5, xmm6 + movlhps xmm0, xmm5 + movhlps xmm2, xmm5 + movlhps xmm1, xmm5 + + unpckhps xmm4, xmm6 + movlhps xmm2, xmm4 + movhlps xmm4, xmm4 + movlhps xmm3, xmm4 + + movaps [esi+0x00], xmm0 + movaps [esi+0x10], xmm1 + movaps [esi+0x20], xmm2 + movaps [esi+0x30], xmm3 + } +} + + +/* +inline mat4 transpose(const mat4& m) +{ + mat4 result; + + __asm + { + mov esi, m + + movaps xmm4, [esi+0x00] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x10] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movaps xmm0, xmm5 + movhlps xmm1, xmm5 + + movaps xmm2, xmm4 + movhlps xmm3, xmm4 + + movaps xmm4, [esi+0x20] + movaps xmm5, xmm4 + movaps xmm6, [esi+0x30] + + unpcklps xmm5, xmm6 + unpckhps xmm4, xmm6 + + movlhps xmm0, xmm5 + movhlps xmm7, xmm5 + movlhps xmm1, xmm7 + + movlhps xmm2, xmm4 + movhlps xmm6, xmm4 + movlhps xmm3, xmm6 + + movaps result[0x00], xmm0 + movaps result[0x10], xmm1 + movaps result[0x20], xmm2 + movaps result[0x30], xmm3 + } + + return result; +} +*/ +}//namespace sse +}//namespace glm + +void test_sse_mat4(); + +#endif//GLM_SSE_MAT4_H diff --git a/wip/sse/sse_mat4array.cpp b/wip/sse/sse_mat4array.cpp new file mode 100644 index 00000000..c08ca1f1 --- /dev/null +++ b/wip/sse/sse_mat4array.cpp @@ -0,0 +1 @@ +#include "precompiled.h" \ No newline at end of file diff --git a/wip/sse/sse_mat4array.h b/wip/sse/sse_mat4array.h new file mode 100644 index 00000000..e69de29b diff --git a/wip/sse/sse_vec4.cpp b/wip/sse/sse_vec4.cpp new file mode 100644 index 00000000..93158f23 --- /dev/null +++ b/wip/sse/sse_vec4.cpp @@ -0,0 +1,52 @@ +#include "precompiled.h" +#include "sse_vec4.h" + +void test_shufps(const glm::sse::vec4& v1, const glm::sse::vec4& v2) +{ + glm::sse::vec4 Result0; + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm0, [esi] + movaps xmm1, [edi] + shufps xmm0, xmm1, _MM_SHUFFLE(3, 2, 1, 0) + movaps Result0, xmm0 + } + + glm::sse::vec4 Result1; + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm2, [esi] + movaps xmm3, [edi] + pshufd xmm2, xmm3, _MM_SHUFFLE(3, 2, 1, 0) + movaps Result1, xmm2 + } + + glm::sse::vec4 end; +} + +void test_sse_vec4() +{ + test_shufps( + glm::sse::vec4(1.0f, 2.0f, 3.0f, 4.0f), + glm::sse::vec4(5.0f, 6.0f, 7.0f, 8.0f)); + + glm::sse::vec4 v0; + glm::sse::vec4 v1(76.f); + glm::sse::vec4 v2(5.f, 1.f, 2.f, 3.f); + v2 += v1; + glm::sse::vec4 v3 = v2; + glm::sse::vec4 v4(1.0f); + float dot = glm::sse::dot(v4, v1); + ++v4; + glm::sse::vec4 v5 = -v4; + glm::sse::vec4 v6(2.f); + glm::sse::vec4 v7 = glm::sse::cross(v2, v6); + glm::vec3 v8 = glm::cross(glm::vec3(5.f, 1.f, 2.f), glm::vec3(2.f)); + printf("vec4(%f, %f, %f, %f)\n", v4.x, v4.y, v4.z, v4.w); + glm::sse::vec4 v9 = glm::sse::normalize(glm::sse::vec4(1.0f, 1.0f, 1.0f, 0.0f)); + glm::sse::vec4 vx; +} diff --git a/wip/sse/sse_vec4.h b/wip/sse/sse_vec4.h new file mode 100644 index 00000000..a1ac53de --- /dev/null +++ b/wip/sse/sse_vec4.h @@ -0,0 +1,290 @@ +#ifndef GLM_SSE_VEC4_H +#define GLM_SSE_VEC4_H + +#include +#include + +namespace glm{ +namespace sse{ + +#define GLM_SHUFFLE(fp3,fp2,fp1,fp0) (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | ((fp0))) + +const __m128 zero = _mm_setzero_ps(); +const __m128 one = _mm_set_ps1(1.0f); +const __m128 two = _mm_set_ps1(2.0f); +const __m128 three = _mm_set_ps1(3.0f); +const __m128 pouet = _mm_set_ps(2.0f, 4.0f, 6.0f, 8.0f); + +#define GLM_ALIGN(x) __declspec(align(x)) + +GLM_ALIGN(16) struct vec4 +{ + enum ENoInit + { + NO_INIT + }; + + union + { + __m128 data; + struct{float x, y, z, w;}; + float array[4]; + }; + + vec4(); + vec4(ENoInit NoInit); + vec4(float s); + vec4(float x, float y, float z, float w); + vec4(float v[4]); + + vec4& operator+=(const float s); + + vec4& operator+=(const vec4& v); + vec4& operator*=(const vec4& v); + + vec4& operator++(); +}; + +__forceinline vec4::vec4() +{ + void* address = this; + + __asm + { + mov eax, [address] + xorps xmm0, xmm0 + movaps [eax], xmm0 + } +} + +__forceinline vec4::vec4(ENoInit NoInit) +{} + +__forceinline vec4::vec4(float s) +{ + void* address = this; + + __asm + { + mov esi, [address] + movss xmm0, s + shufps xmm0, xmm0, 0 + movaps [esi], xmm0 + } +} + +__forceinline vec4::vec4(float x, float y, float z, float w) +{ + void* address = this; + + __asm + { + mov esi, address + movss xmm0, x + movss xmm1, y + movss xmm2, z + movss xmm3, w + unpcklps xmm0, xmm1 + unpcklps xmm2, xmm3 + movlhps xmm0, xmm2 + movaps [esi], xmm0 + } +} + +__forceinline vec4::vec4(float v[4]) +{ + void* address = this; + + __asm + { + mov eax, [address] + mov ebx, [v] + movups xmm0, [ebx] + movaps [eax], xmm0 + } +} + +__forceinline vec4& vec4::operator+=(const float s) +{ + void* address = this; + + __asm + { + mov eax, [address] + movss xmm1, s + shufps xmm1, xmm1, 0 + movaps xmm0, [eax] + addps xmm0, xmm1 + movaps [eax], xmm0 + } + + return *this; +} + +__forceinline vec4& vec4::operator+=(const vec4& v) +{ + void* address = this; + + __asm + { + mov eax, [address] + mov ebx, [v] + movaps xmm0, [eax] + addps xmm0, [ebx] + movaps [eax], xmm0 + } + + return *this; +} + +__forceinline vec4& vec4::operator*=(const vec4& v) +{ + void* address = this; + + __asm + { + mov esi, address + mov edi, v + movaps xmm0, esi + mulps xmm0, edi + movaps [esi], xmm0 + } + + return *this; +} + +__forceinline vec4& vec4::operator++() +{ + void* address = this; + + __asm + { + mov eax, [address] + movaps xmm0, [eax] + addps xmm0, one + movaps [eax], xmm0 + } + + return *this; +} + +__forceinline const vec4 operator- (const vec4& v) +{ + vec4 result(vec4::NO_INIT); + + __asm + { + mov esi, v + xorps xmm0, xmm0 + subps xmm0, [esi] + movaps result, xmm0 + } + + result; +} + +__forceinline vec4 cross(const vec4& v1, const vec4& v2) +{ + vec4 result(vec4::NO_INIT); + + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm0, [esi] + movaps xmm1, [edi] + shufps xmm0, xmm0, _MM_SHUFFLE(3, 0, 2, 1) + movaps xmm2, xmm0 + shufps xmm0, xmm0, _MM_SHUFFLE(3, 1, 0, 2) + shufps xmm1, xmm1, _MM_SHUFFLE(3, 0, 2, 1) + movaps xmm3, xmm1 + shufps xmm1, xmm1, _MM_SHUFFLE(3, 1, 0, 2) + mulps xmm0, xmm3 + mulps xmm1, xmm2 + subps xmm0, xmm1 + movaps result, xmm0 + } + + return result; +} + +__forceinline float dot(const vec4& v1, const vec4& v2) +{ + float result; + + // All component processed + //__asm + //{ + // mov esi, v1 + // mov edi, v2 + // movaps xmm0, [esi] + // movaps xmm1, [edi] + // mulps xmm0, xmm1 + // movaps xmm1, xmm0 + // shufps xmm0, xmm0, _MM_SHUFFLE(2, 3, 0, 1) + // addps xmm0, xmm1 + // movaps xmm1, xmm0 + // shufps xmm0, xmm0, _MM_SHUFFLE(0, 1, 2, 3) + // addps xmm0, xmm1 + // movss result, xmm0 + //} + + // SSE + __asm + { + mov esi, v1 + mov edi, v2 + movaps xmm0, [esi] // w1, z1, y1, x1 + mulps xmm0, [edi] // w1 * w2, z1 * z2, y1 * y2, x1 * x2 + movhlps xmm1, xmm0 // XX, XX, w1 * w2, z1 * z2 + addps xmm0, xmm1 // XX, XX, y1 * y2 + w1 * w2, x1 * x2 + z1 * z2 + pshufd xmm1, xmm0, 1 // XX, XX, XX, y1 * y2 + w1 * w2 + addss xmm0, xmm1 // y1 * y2 + w1 * w2 + x1 * x2 + z1 * z2 + movss result, xmm0 + } + + // SSE 3 + + // SSE 4.1 + //__asm + //{ + // mov esi, v1 + // mov edi, v2 + // movaps xmm0, [esi] + // dpps xmm0, [edi] + // movss result, xmm0 + //} + + return result; +} + +__forceinline vec4 normalize(const vec4& v) +{ + vec4 result(vec4::NO_INIT); + + __asm + { + mov esi, v + movaps xmm2, [esi] + movaps xmm0, xmm2 + mulps xmm0, xmm0 + movaps xmm1, xmm0 + shufps xmm0, xmm0, _MM_SHUFFLE(2, 3, 0, 1) + addps xmm0, xmm1 + movaps xmm1, xmm0 + shufps xmm0, xmm0, _MM_SHUFFLE(0, 1, 2, 3) + addps xmm0, xmm1 + rsqrtps xmm0, xmm0 + mulps xmm2, xmm0 + movaps result, xmm2 + } + + return result; +} + +}//namespace sse +}//namespace glm + +void test_sse_vec4(); + +#endif//GLM_SSE_VEC4_H diff --git a/wip/sse/sse_vec4array.cpp b/wip/sse/sse_vec4array.cpp new file mode 100644 index 00000000..c08ca1f1 --- /dev/null +++ b/wip/sse/sse_vec4array.cpp @@ -0,0 +1 @@ +#include "precompiled.h" \ No newline at end of file diff --git a/wip/sse/sse_vec4array.h b/wip/sse/sse_vec4array.h new file mode 100644 index 00000000..e69de29b