mirror of
https://github.com/g-truc/glm.git
synced 2024-11-25 09:54:35 +00:00
Use value_ptr in packing.inl
This commit is contained in:
parent
0df8dcb454
commit
05c93eeae0
@ -7,6 +7,7 @@
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../detail/type_half.hpp"
|
||||
#include "type_ptr.hpp"
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
@ -295,14 +296,14 @@ namespace detail
|
||||
{
|
||||
int16 const Unpack(detail::toFloat16(v.x));
|
||||
u16vec1 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
memcpy(value_ptr(Packed), &Unpack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<1, float, Q> unpack(vec<1, uint16, Q> const& v)
|
||||
{
|
||||
i16vec1 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), value_ptr(v), sizeof(Unpack));
|
||||
return vec<1, float, Q>(detail::toFloat32(v.x));
|
||||
}
|
||||
};
|
||||
@ -314,14 +315,14 @@ namespace detail
|
||||
{
|
||||
vec<2, int16, Q> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y));
|
||||
u16vec2 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
memcpy(value_ptr(Packed), value_ptr(Unpack), sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<2, float, Q> unpack(vec<2, uint16, Q> const& v)
|
||||
{
|
||||
i16vec2 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), value_ptr(v), sizeof(Unpack));
|
||||
return vec<2, float, Q>(detail::toFloat32(v.x), detail::toFloat32(v.y));
|
||||
}
|
||||
};
|
||||
@ -333,14 +334,14 @@ namespace detail
|
||||
{
|
||||
vec<3, int16, Q> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z));
|
||||
u16vec3 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
memcpy(value_ptr(Packed), value_ptr(Unpack), sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<3, float, Q> unpack(vec<3, uint16, Q> const& v)
|
||||
{
|
||||
i16vec3 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &v, sizeof(Unpack));
|
||||
return vec<3, float, Q>(detail::toFloat32(v.x), detail::toFloat32(v.y), detail::toFloat32(v.z));
|
||||
}
|
||||
};
|
||||
@ -352,14 +353,14 @@ namespace detail
|
||||
{
|
||||
vec<4, int16, Q> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z), detail::toFloat16(v.w));
|
||||
u16vec4 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
memcpy(value_ptr(Packed), value_ptr(Unpack), sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<4, float, Q> unpack(vec<4, uint16, Q> const& v)
|
||||
{
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &v, sizeof(Unpack));
|
||||
return vec<4, float, Q>(detail::toFloat32(Unpack.x), detail::toFloat32(Unpack.y), detail::toFloat32(Unpack.z), detail::toFloat32(Unpack.w));
|
||||
}
|
||||
};
|
||||
@ -388,7 +389,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 p)
|
||||
{
|
||||
u8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return vec2(Unpack) * float(0.0039215686274509803921568627451); // 1 / 255
|
||||
}
|
||||
|
||||
@ -413,14 +414,14 @@ namespace detail
|
||||
{
|
||||
i8vec2 const Topack(round(clamp(v, -1.0f, 1.0f) * 127.0f));
|
||||
uint16 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
memcpy(&Packed, value_ptr(Topack), sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 p)
|
||||
{
|
||||
i8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return clamp(
|
||||
vec2(Unpack) * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
|
||||
-1.0f, 1.0f);
|
||||
@ -448,7 +449,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 p)
|
||||
{
|
||||
u16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return vec4(Unpack) * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||
}
|
||||
|
||||
@ -473,14 +474,14 @@ namespace detail
|
||||
{
|
||||
i16vec4 const Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
|
||||
uint64 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
memcpy(&Packed, value_ptr(Topack), sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 p)
|
||||
{
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return clamp(
|
||||
vec4(Unpack) * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
|
||||
-1.0f, 1.0f);
|
||||
@ -509,14 +510,14 @@ namespace detail
|
||||
detail::toFloat16(v.z),
|
||||
detail::toFloat16(v.w));
|
||||
uint64 Packed = 0;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
memcpy(&Packed, value_ptr(Unpack), sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 v)
|
||||
{
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &v, sizeof(Unpack));
|
||||
return vec4(
|
||||
detail::toFloat32(Unpack.x),
|
||||
detail::toFloat32(Unpack.y),
|
||||
@ -818,7 +819,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER i8vec2 unpackInt2x8(int16 p)
|
||||
{
|
||||
i8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -832,7 +833,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER u8vec2 unpackUint2x8(uint16 p)
|
||||
{
|
||||
u8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -846,7 +847,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER i8vec4 unpackInt4x8(int32 p)
|
||||
{
|
||||
i8vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -860,7 +861,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER u8vec4 unpackUint4x8(uint32 p)
|
||||
{
|
||||
u8vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -874,7 +875,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER i16vec2 unpackInt2x16(int p)
|
||||
{
|
||||
i16vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -888,7 +889,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER i16vec4 unpackInt4x16(int64 p)
|
||||
{
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -902,7 +903,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER u16vec2 unpackUint2x16(uint p)
|
||||
{
|
||||
u16vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -916,7 +917,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER u16vec4 unpackUint4x16(uint64 p)
|
||||
{
|
||||
u16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -930,7 +931,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER i32vec2 unpackInt2x32(int64 p)
|
||||
{
|
||||
i32vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
@ -944,7 +945,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER u32vec2 unpackUint2x32(uint64 p)
|
||||
{
|
||||
u32vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
memcpy(value_ptr(Unpack), &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
}//namespace glm
|
||||
|
Loading…
Reference in New Issue
Block a user