Commit bfad7296 authored by Philip Trettner's avatar Philip Trettner

Updated glm

parent 5c1f035e
......@@ -33,50 +33,158 @@
#define GLM_MESSAGES
#include "../glm.hpp"
#include <limits>
/*
#if(GLM_ARCH & GLM_ARCH_SSE2)
struct float4
{
union
{
struct {float r, g, b, a;};
struct {float s, t, p, q;};
struct {float x, y, z, w;};
__m128 data;
};
};
int test_simd()
struct material
{
float4 f;
glm::vec4 emission; // Ecm
glm::vec4 ambient; // Acm
glm::vec4 diffuse; // Dcm
glm::vec4 specular; // Scm
float shininess; // Srm
};
struct light
{
glm::vec4 ambient; // Acli
glm::vec4 diffuse; // Dcli
glm::vec4 specular; // Scli
glm::vec4 position; // Ppli
glm::vec4 halfVector; // Derived: Hi
glm::vec3 spotDirection; // Sdli
float spotExponent; // Srli
float spotCutoff; // Crli
// (range: [0.0,90.0], 180.0)
float spotCosCutoff; // Derived: cos(Crli)
// (range: [1.0,0.0],-1.0)
float constantAttenuation; // K0
float linearAttenuation; // K1
float quadraticAttenuation;// K2
};
// Sample 1
#include <glm/vec3.hpp>// glm::vec3
#include <glm/geometric.hpp>// glm::cross, glm::normalize
return 0;
glm::vec3 computeNormal
(
glm::vec3 const & a,
glm::vec3 const & b,
glm::vec3 const & c
)
{
return glm::normalize(glm::cross(c - a, b - a));
}
#endif//GLM_ARCH
*/
typedef unsigned int GLuint;
#define GL_FALSE 0
void glUniformMatrix4fv(GLuint, int, int, float*){}
template <class T = int>
class C;
// Sample 2
#include <glm/vec3.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4, glm::ivec4
#include <glm/mat4x4.hpp> // glm::mat4
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
#include <glm/gtc/type_ptr.hpp> // glm::value_ptr
void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate)
{
glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);
glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
glm::mat4 MVP = Projection * View * Model;
glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP));
}
template <class T>
class C
// Sample 3
#include <glm/vec2.hpp>// glm::vec2
#include <glm/packing.hpp>// glm::packUnorm2x16
#include <glm/integer.hpp>// glm::uint
#include <glm/gtc/type_precision.hpp>// glm::i8vec2, glm::i32vec2
std::size_t const VertexCount = 4;
// Float quad geometry
std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2);
glm::vec2 const PositionDataF32[VertexCount] =
{
glm::vec2(-1.0f,-1.0f),
glm::vec2( 1.0f,-1.0f),
glm::vec2( 1.0f, 1.0f),
glm::vec2(-1.0f, 1.0f)
};
// Half-float quad geometry
std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint);
glm::uint const PositionDataF16[VertexCount] =
{
public:
T value;
glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))),
glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))),
glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))),
glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f)))
};
// 8 bits signed integer quad geometry
std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2);
glm::i8vec2 const PositionDataI8[VertexCount] =
{
glm::i8vec2(-1,-1),
glm::i8vec2( 1,-1),
glm::i8vec2( 1, 1),
glm::i8vec2(-1, 1)
};
// 32 bits signed integer quad geometry
std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2);
glm::i32vec2 const PositionDataI32[VertexCount] =
{
glm::i32vec2 (-1,-1),
glm::i32vec2 ( 1,-1),
glm::i32vec2 ( 1, 1),
glm::i32vec2 (-1, 1)
};
int main()
struct intersection
{
/*
# if(GLM_ARCH & GLM_ARCH_SSE2)
test_simd();
# endif
*/
glm::vec4 position;
glm::vec3 normal;
};
C<> c;
/*
// Sample 4
#include <glm/vec3.hpp>// glm::vec3
#include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect
#include <glm/exponential.hpp>// glm::pow
#include <glm/gtc/random.hpp>// glm::vecRand3
glm::vec3 lighting
(
intersection const & Intersection,
material const & Material,
light const & Light,
glm::vec3 const & View
)
{
glm::vec3 Color(0.0f);
glm::vec3 LightVertor(glm::normalize(
Light.position - Intersection.position +
glm::vecRand3(0.0f, Light.inaccuracy));
if(!shadow(Intersection.position, Light.position, LightVertor))
{
float Diffuse = glm::dot(Intersection.normal, LightVector);
if(Diffuse <= 0.0f)
return Color;
if(Material.isDiffuse())
Color += Light.color() * Material.diffuse * Diffuse;
if(Material.isSpecular())
{
glm::vec3 Reflect(glm::reflect(
glm::normalize(-LightVector),
glm::normalize(Intersection.normal)));
float Dot = glm::dot(Reflect, View);
float Base = Dot > 0.0f ? Dot : 0.0f;
float Specular = glm::pow(Base, Material.exponent);
Color += Material.specular * Specular;
}
}
return Color;
}
*/
int main()
{
return 0;
}
......
......@@ -45,7 +45,7 @@ namespace detail
struct compute_log2<true>
{
template <typename T>
T operator() (T const & Value) const
GLM_FUNC_QUALIFIER T operator() (T const & Value) const
{
return static_cast<T>(::std::log(Value)) * static_cast<T>(1.4426950408889634073599246810019);
}
......@@ -54,7 +54,7 @@ namespace detail
template <template <class, precision> class vecType, typename T, precision P>
struct compute_inversesqrt
{
static vecType<T, P> call(vecType<T, P> const & x)
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
{
return static_cast<T>(1) / sqrt(x);
}
......@@ -63,7 +63,7 @@ namespace detail
template <template <class, precision> class vecType>
struct compute_inversesqrt<vecType, float, lowp>
{
static vecType<float, lowp> call(vecType<float, lowp> const & x)
GLM_FUNC_QUALIFIER static vecType<float, lowp> call(vecType<float, lowp> const & x)
{
vecType<float, lowp> tmp(x);
vecType<float, lowp> xhalf(tmp * 0.5f);
......@@ -160,7 +160,7 @@ namespace detail
template <typename T, precision P>
struct compute_sqrt<detail::tvec1, T, P>
{
static detail::tvec1<T, P> call(detail::tvec1<T, P> const & x)
GLM_FUNC_QUALIFIER static detail::tvec1<T, P> call(detail::tvec1<T, P> const & x)
{
return detail::tvec1<T, P>(std::sqrt(x.x));
}
......@@ -169,7 +169,7 @@ namespace detail
template <typename T, precision P>
struct compute_sqrt<detail::tvec2, T, P>
{
static detail::tvec2<T, P> call(detail::tvec2<T, P> const & x)
GLM_FUNC_QUALIFIER static detail::tvec2<T, P> call(detail::tvec2<T, P> const & x)
{
return detail::tvec2<T, P>(std::sqrt(x.x), std::sqrt(x.y));
}
......@@ -178,7 +178,7 @@ namespace detail
template <typename T, precision P>
struct compute_sqrt<detail::tvec3, T, P>
{
static detail::tvec3<T, P> call(detail::tvec3<T, P> const & x)
GLM_FUNC_QUALIFIER static detail::tvec3<T, P> call(detail::tvec3<T, P> const & x)
{
return detail::tvec3<T, P>(std::sqrt(x.x), std::sqrt(x.y), std::sqrt(x.z));
}
......@@ -187,7 +187,7 @@ namespace detail
template <typename T, precision P>
struct compute_sqrt<detail::tvec4, T, P>
{
static detail::tvec4<T, P> call(detail::tvec4<T, P> const & x)
GLM_FUNC_QUALIFIER static detail::tvec4<T, P> call(detail::tvec4<T, P> const & x)
{
return detail::tvec4<T, P>(std::sqrt(x.x), std::sqrt(x.y), std::sqrt(x.z), std::sqrt(x.w));
}
......@@ -197,12 +197,22 @@ namespace detail
// sqrt
GLM_FUNC_QUALIFIER float sqrt(float x)
{
return detail::compute_sqrt<detail::tvec1, float, highp>::call(x).x;
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
detail::tvec1<float, highp> tmp(detail::compute_sqrt<detail::tvec1, float, highp>::call(x));
return tmp.x;
# else
return detail::compute_sqrt<detail::tvec1, float, highp>::call(x).x;
# endif
}
GLM_FUNC_QUALIFIER double sqrt(double x)
{
return detail::compute_sqrt<detail::tvec1, double, highp>::call(x).x;
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
detail::tvec1<double, highp> tmp(detail::compute_sqrt<detail::tvec1, double, highp>::call(x));
return tmp.x;
# else
return detail::compute_sqrt<detail::tvec1, double, highp>::call(x).x;
# endif
}
template <typename T, precision P, template <typename, precision> class vecType>
......
......@@ -41,16 +41,21 @@ namespace detail
template <typename T, precision P>
struct compute_dot<detail::tvec1, T, P>
{
static T call(detail::tvec1<T, P> const & x, detail::tvec1<T, P> const & y)
GLM_FUNC_QUALIFIER static T call(detail::tvec1<T, P> const & x, detail::tvec1<T, P> const & y)
{
return detail::tvec1<T, P>(x * y).x;
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
detail::tvec1<T, P> tmp(x * y);
return tmp.x;
# else
return detail::tvec1<T, P>(x * y).x;
# endif
}
};
template <typename T, precision P>
struct compute_dot<detail::tvec2, T, P>
{
static T call(detail::tvec2<T, P> const & x, detail::tvec2<T, P> const & y)
GLM_FUNC_QUALIFIER static T call(detail::tvec2<T, P> const & x, detail::tvec2<T, P> const & y)
{
detail::tvec2<T, P> tmp(x * y);
return tmp.x + tmp.y;
......@@ -60,7 +65,7 @@ namespace detail
template <typename T, precision P>
struct compute_dot<detail::tvec3, T, P>
{
static T call(detail::tvec3<T, P> const & x, detail::tvec3<T, P> const & y)
GLM_FUNC_QUALIFIER static T call(detail::tvec3<T, P> const & x, detail::tvec3<T, P> const & y)
{
detail::tvec3<T, P> tmp(x * y);
return tmp.x + tmp.y + tmp.z;
......@@ -70,7 +75,7 @@ namespace detail
template <typename T, precision P>
struct compute_dot<detail::tvec4, T, P>
{
static T call(detail::tvec4<T, P> const & x, detail::tvec4<T, P> const & y)
GLM_FUNC_QUALIFIER static T call(detail::tvec4<T, P> const & x, detail::tvec4<T, P> const & y)
{
detail::tvec4<T, P> tmp(x * y);
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
......
......@@ -110,10 +110,10 @@ namespace glm
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
Borrow = x >= y ? static_cast<uint32>(0) : static_cast<uint32>(1);
if(x > y)
return static_cast<uint32>(static_cast<int64>(x) -static_cast<int64>(y));
if(y >= x)
return y - x;
else
return static_cast<uint32>((static_cast<int64>(1) << static_cast<int64>(32)) + static_cast<int64>(x) - static_cast<int64>(y));
return static_cast<uint32>((static_cast<int64>(1) << static_cast<int64>(32)) + (static_cast<int64>(y) - static_cast<int64>(x)));
}
template <>
......@@ -171,8 +171,10 @@ namespace glm
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
uint64 Value64 = static_cast<uint64>(x) * static_cast<uint64>(y);
msb = *(reinterpret_cast<uint32*>(&Value64) + 1);
lsb = reinterpret_cast<uint32&>(Value64);
uint32* PointerMSB = (reinterpret_cast<uint32*>(&Value64) + 1);
msb = *PointerMSB;
uint32* PointerLSB = (reinterpret_cast<uint32*>(&Value64) + 0);
lsb = *PointerLSB;
}
template <>
......@@ -230,8 +232,10 @@ namespace glm
GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch");
int64 Value64 = static_cast<int64>(x) * static_cast<int64>(y);
msb = *(reinterpret_cast<int32*>(&Value64) + 1);
lsb = reinterpret_cast<int32&>(Value64);
int32* PointerMSB = (reinterpret_cast<int32*>(&Value64) + 1);
msb = *PointerMSB;
int32* PointerLSB = (reinterpret_cast<int32*>(&Value64));
lsb = *PointerLSB;
}
template <>
......
......@@ -48,7 +48,7 @@ GLM_FUNC_QUALIFIER __m128 sse_dst_ps(__m128 p0, __m128 p1)
//dot
GLM_FUNC_QUALIFIER __m128 sse_dot_ps(__m128 v1, __m128 v2)
{
# if((GLM_ARCH & GLM_ARCH_SSE4) == GLM_ARCH_SSE4)
# if((GLM_ARCH & GLM_ARCH_AVX) == GLM_ARCH_AVX)
return _mm_dp_ps(v1, v2, 0xff);
# else
__m128 mul0 = _mm_mul_ps(v1, v2);
......
......@@ -38,7 +38,7 @@
#define GLM_VERSION_MAJOR 0
#define GLM_VERSION_MINOR 9
#define GLM_VERSION_PATCH 5
#define GLM_VERSION_REVISION 2
#define GLM_VERSION_REVISION 3
///////////////////////////////////////////////////////////////////////////////////////////////////
// Platform
......@@ -211,6 +211,9 @@
// CUDA
#elif defined(__CUDACC__)
# if !defined(CUDA_VERSION) && !defined(GLM_FORCE_CUDA)
# include <cuda.h> // make sure version is defined since nvcc does not define it itself!
# endif
# if CUDA_VERSION < 3000
# error "GLM requires CUDA 3.0 or higher"
# else
......@@ -550,9 +553,8 @@
#define GLM_ARCH_PURE 0x0000
#define GLM_ARCH_SSE2 0x0001
#define GLM_ARCH_SSE3 0x0002// | GLM_ARCH_SSE2
#define GLM_ARCH_SSE4 0x0004// | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
#define GLM_ARCH_AVX 0x0008// | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
#define GLM_ARCH_AVX2 0x0010// | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
#define GLM_ARCH_AVX 0x0008// | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
#define GLM_ARCH_AVX2 0x0010// | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
#if(defined(GLM_FORCE_PURE))
# define GLM_ARCH GLM_ARCH_PURE
......@@ -560,51 +562,32 @@
# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
#elif(defined(GLM_FORCE_AVX))
# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
#elif(defined(GLM_FORCE_SSE4))
# define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
#elif(defined(GLM_FORCE_SSE3))
# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
#elif(defined(GLM_FORCE_SSE2))
# define GLM_ARCH (GLM_ARCH_SSE2)
#elif((GLM_COMPILER & GLM_COMPILER_VC) && (defined(_M_IX86) || defined(_M_X64)))
# if(GLM_PLATFORM == GLM_PLATFORM_WINCE)
# define GLM_ARCH GLM_ARCH_PURE
# elif(defined(_M_CEE_PURE))
# define GLM_ARCH GLM_ARCH_PURE
/* TODO: Explore auto detection of instruction set support
# elif(defined(_M_IX86_FP))
# if(_M_IX86_FP >= 3)
# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
# elif(_M_IX86_FP >= 2)
# define GLM_ARCH (GLM_ARCH_SSE2)
# else
# define GLM_ARCH GLM_ARCH_PURE
# endif
*/
# elif(GLM_COMPILER >= GLM_COMPILER_VC11)
#elif(GLM_COMPILER & GLM_COMPILER_VC)
# if _M_IX86_FP == 2 && defined(__AVX__)
# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
# elif(GLM_COMPILER >= GLM_COMPILER_VC10)
# if(_MSC_FULL_VER >= 160031118) //160031118: VC2010 SP1 beta full version
# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)//GLM_ARCH_AVX (Require SP1)
# else
# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
# endif
# elif(GLM_COMPILER >= GLM_COMPILER_VC9)
# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
# elif(GLM_COMPILER >= GLM_COMPILER_VC8)
# define GLM_ARCH GLM_ARCH_SSE2
# elif _M_IX86_FP == 2
# define GLM_ARCH (GLM_ARCH_SSE2)
# else
# define GLM_ARCH GLM_ARCH_PURE
# define GLM_ARCH (GLM_ARCH_PURE)
# endif
#elif((GLM_PLATFORM & GLM_PLATFORM_APPLE) && (GLM_COMPILER & GLM_COMPILER_GCC))
# define GLM_ARCH GLM_ARCH_PURE
#elif(((GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__))) || (GLM_COMPILER & GLM_COMPILER_LLVM_GCC))
# define GLM_ARCH (GLM_ARCH_PURE \
| (defined(__AVX2__) ? GLM_ARCH_AVX2 : 0) \
| (defined(__AVX__) ? GLM_ARCH_AVX : 0) \
| (defined(__SSE4__) ? GLM_ARCH_SSE4 : 0) \
| (defined(__SSE3__) ? GLM_ARCH_SSE3 : 0) \
| (defined(__SSE2__) ? GLM_ARCH_SSE2 : 0))
# if defined(__AVX2__)
# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
# elif defined(__AVX__)
# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
# elif defined(__SSE3__)
# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
# elif defined(__SSE2__)
# define GLM_ARCH (GLM_ARCH_SSE2)
# else
# define GLM_ARCH (GLM_ARCH_PURE)
# endif
#else
# define GLM_ARCH GLM_ARCH_PURE
#endif
......
......@@ -137,7 +137,7 @@ namespace detail
T const & s);
template <typename T, precision P>
tmat2x3<T, P> operator+ (
GLM_FUNC_DECL tmat2x3<T, P> operator+ (
tmat2x3<T, P> const & m1,
tmat2x3<T, P> const & m2);
......
......@@ -120,7 +120,9 @@
#include "./gtx/rotate_vector.hpp"
#include "./gtx/spline.hpp"
#include "./gtx/std_based_type.hpp"
#include "./gtx/string_cast.hpp"
#if(!(GLM_COMPILER & GLM_COMPILER_CUDA))
# include "./gtx/string_cast.hpp"
#endif
#include "./gtx/transform.hpp"
#include "./gtx/transform2.hpp"
#include "./gtx/vec1.hpp"
......
......@@ -52,14 +52,14 @@ namespace glm
/// Get a specific row of a matrix.
/// @see gtc_matrix_access
template <typename genType>
typename genType::row_type row(
GLM_FUNC_DECL typename genType::row_type row(
genType const & m,
length_t const & index);
/// Set a specific row to a matrix.
/// @see gtc_matrix_access
template <typename genType>
genType row(
GLM_FUNC_DECL genType row(
genType const & m,
length_t const & index,
typename genType::row_type const & x);
......@@ -67,14 +67,14 @@ namespace glm
/// Get a specific column of a matrix.
/// @see gtc_matrix_access
template <typename genType>
typename genType::col_type column(
GLM_FUNC_DECL typename genType::col_type column(
genType const & m,
length_t const & index);
/// Set a specific column to a matrix.
/// @see gtc_matrix_access
template <typename genType>
genType column(
GLM_FUNC_DECL genType column(
genType const & m,
length_t const & index,
typename genType::col_type const & x);
......
......@@ -55,7 +55,7 @@ namespace glm
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate.
/// @see gtc_matrix_inverse
template <typename genType>
GLM_FUNC_QUALIFIER genType affineInverse(genType const & m);
GLM_FUNC_DECL genType affineInverse(genType const & m);
/// Compute the inverse transpose of a matrix.
///
......@@ -63,7 +63,7 @@ namespace glm
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate.
/// @see gtc_matrix_inverse
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type inverseTranspose(
GLM_FUNC_DECL typename genType::value_type inverseTranspose(
genType const & m);
/// @}
......
......@@ -44,27 +44,6 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> translate_slow
(
detail::tmat4x4<T, P> const & m,
detail::tvec3<T, P> const & v
)
{
detail::tmat4x4<T, P> Result(T(1));
Result[3] = detail::tvec4<T, P>(v, T(1));
return m * Result;
//detail::tmat4x4<valType> Result(m);
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
//Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0];
//Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1];
//Result[3][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2];
//Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3];
//return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> rotate
(
......
......@@ -57,20 +57,20 @@ namespace glm
/// Classic perlin noise.
/// @see gtc_noise
template <typename T, precision P, template<typename, precision> class vecType>
T perlin(
GLM_FUNC_DECL T perlin(
vecType<T, P> const & p);
/// Periodic perlin noise.
/// @see gtc_noise
template <typename T, precision P, template<typename, precision> class vecType>
T perlin(
GLM_FUNC_DECL T perlin(
vecType<T, P> const & p,
vecType<T, P> const & rep);
/// Simplex noise.
/// @see gtc_noise
template <typename T, precision P, template<typename, precision> class vecType>
T simplex(
GLM_FUNC_DECL T simplex(
vecType<T, P> const & p);
/// @}
......
......@@ -141,7 +141,7 @@ namespace detail
if(x == 0.0f)
return 0;
else if(glm::isnan(x))
return ~0u;
return ~0;
else if(glm::isinf(x))
return 0x1f << 6;
......@@ -153,9 +153,9 @@ namespace detail
if(x == 0)
return 0.0f;
else if(x == ((1 << 11) - 1))
return ~0u;//NaN
return ~0;//NaN
else if(x == (0x1f << 6))
return ~0u;//Inf
return ~0;//Inf
uint result = packed11ToFloat(x);
return reinterpret_cast<float&>(result);
......@@ -164,11 +164,11 @@ namespace detail
GLM_FUNC_QUALIFIER glm::uint floatTo10bit(float x)
{
if(x == 0.0f)
return 0u;
return 0;
else if(glm::isnan(x))
return ~0u;
return ~0;
else if(glm::isinf(x))
return 0x1fu << 5;
return 0x1f << 5;
return float2packed10(reinterpret_cast<uint&>(x));
}
......
......@@ -194,24 +194,30 @@ namespace detail
# pragma warning(pop)
#endif
#if((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
# define GLM_NEXT_AFTER_FLT(x, toward) glm::detail::nextafterf((x), (toward))
# define GLM_NEXT_AFTER_DBL(x, toward) _nextafter((x), (toward))
#else
# define GLM_NEXT_AFTER_FLT(x, toward) nextafterf((x), (toward))
# define GLM_NEXT_AFTER_DBL(x, toward) nextafter((x), (toward))
#endif
namespace glm
{
template <>
GLM_FUNC_QUALIFIER float next_float(float const & x)
{
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::max());
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
return std::nextafter(x, std::numeric_limits<float>::max());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MAX);
# else
return nextafterf(x, FLT_MAX);
# endif
}
template <>
GLM_FUNC_QUALIFIER double next_float(double const & x)
{
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::max());
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
return std::nextafter(x, std::numeric_limits<double>::max());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafter(x, std::numeric_limits<double>::max());
# else
return nextafter(x, DBL_MAX);
# endif
}
template<typename T, precision P, template<typename, precision> class vecType>
......@@ -225,12 +231,24 @@ namespace glm
GLM_FUNC_QUALIFIER float prev_float(float const & x)
{
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::min());
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
return std::nextafter(x, std::numeric_limits<float>::min());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MIN);
# else
return nextafterf(x, FLT_MIN);
# endif