mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 18:24:35 +00:00
Fixed merge
This commit is contained in:
commit
b5c8d9e812
@ -12,6 +12,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
#add_definitions(-S)
|
||||
#add_definitions(-s)
|
||||
add_definitions(-msse2)
|
||||
add_definitions(-std=c++0x )
|
||||
#add_definitions(-m32)
|
||||
#add_definitions(-mfpmath=387)
|
||||
#add_definitions(-ffast-math)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -132,6 +132,7 @@ namespace glm
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'dot' only accept floating-point inputs");
|
||||
|
@ -114,6 +114,12 @@ namespace detail
|
||||
|
||||
tvec2(tref2<T> const & r);
|
||||
|
||||
template <int E0, int E1>
|
||||
GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2<T>,E0,E1,-1,-2>& that)
|
||||
{
|
||||
*this = that();
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion constructors
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace detail
|
||||
|
||||
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
|
||||
value_type x, y, z;
|
||||
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
|
||||
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT || GLM_LANG == GLM_LANG_CXX0X)
|
||||
union
|
||||
{
|
||||
_GLM_SWIZZLE3_2_MEMBERS(value_type,glm::detail::tvec2<value_type>,x,y,z)
|
||||
@ -80,7 +80,7 @@ namespace detail
|
||||
struct{value_type r, g, b;};
|
||||
struct{value_type s, t, p;};
|
||||
struct{value_type x, y, z;};
|
||||
};
|
||||
};
|
||||
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
|
||||
union {value_type x, r, s;};
|
||||
union {value_type y, g, t;};
|
||||
@ -152,6 +152,12 @@ namespace detail
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec3(A const & s, tref2<B> const & v);
|
||||
|
||||
template <int E0, int E1, int E2>
|
||||
GLM_FUNC_DECL tvec3(glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & that)
|
||||
{
|
||||
*this = that();
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
|
@ -153,6 +153,12 @@ namespace detail
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL explicit tvec4(tvec4<U> const & v);
|
||||
|
||||
template <int E0, int E1, int E2, int E3>
|
||||
GLM_FUNC_DECL tvec4(glm::detail::swizzle<4, T, tvec4<T>, E0, E1, E2, E3> const & that)
|
||||
{
|
||||
*this = that();
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
|
@ -247,30 +247,20 @@ int test_vec3_swizzle3_3()
|
||||
glm::vec3 v(1, 2, 3);
|
||||
glm::vec3 u;
|
||||
|
||||
u.xyz = v.xyz;
|
||||
Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
|
||||
u = v.xyz;
|
||||
Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.zyx;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.zyx = v;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
|
||||
u = v.rgb;
|
||||
Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.bgr;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.bgr = v;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
|
||||
u = v.stp;
|
||||
Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.pts;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.pts = v;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
|
||||
u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
@ -284,34 +274,111 @@ int test_vec3_swizzle_half()
|
||||
glm::hvec3 v(a1, b1, c1);
|
||||
glm::hvec3 u;
|
||||
|
||||
float c = v.x;
|
||||
float d = v.y;
|
||||
u = v;
|
||||
|
||||
float a = u.x;
|
||||
float b = u.y;
|
||||
Error += (u.x == glm::half(1.0f) && u.y == glm::half(2.0f) && u.z == glm::half(3.0f)) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1;
|
||||
|
||||
/*u = v.xyz;
|
||||
Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.xyz;
|
||||
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1;
|
||||
u = v.zyx;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
|
||||
u.zyx = v;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
|
||||
|
||||
u = v.rgb;
|
||||
Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1;
|
||||
u = v.bgr;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
|
||||
u.bgr = v;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
|
||||
|
||||
u = v.stp;
|
||||
Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1;
|
||||
u = v.pts;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
|
||||
u.pts = v;
|
||||
Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;*/
|
||||
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 q, u, v;
|
||||
|
||||
u = glm::vec3(1, 2, 3);
|
||||
v = glm::vec3(10, 20, 30);
|
||||
|
||||
// Swizzle, swizzle binary operators
|
||||
q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1;
|
||||
q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1;
|
||||
q = (u.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1;
|
||||
q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1;
|
||||
|
||||
// vec, swizzle binary operators
|
||||
q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1;
|
||||
q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1;
|
||||
q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1;
|
||||
q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1;
|
||||
|
||||
// swizzle,vec binary operators
|
||||
q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1;
|
||||
q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1;
|
||||
q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1;
|
||||
q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1;
|
||||
|
||||
// Compile errors
|
||||
//q = (u.yz * v.xyz);
|
||||
//q = (u * v.xy);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_functions()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
//
|
||||
// NOTE: template functions cannot pick up the implicit conversion from
|
||||
// a swizzle to the unswizzled type, therefore the operator() must be
|
||||
// used. E.g.:
|
||||
//
|
||||
// glm::dot(u.xy, v.xy); <--- Compile error
|
||||
// glm::dot(u.xy(), v.xy()); <--- Compiles correctly
|
||||
//
|
||||
|
||||
float r;
|
||||
|
||||
// vec2
|
||||
glm::vec2 a(1, 2);
|
||||
glm::vec2 b(10, 20);
|
||||
r = glm::dot(a, b); Error += (int(r) == 50) ? 0 : 1;
|
||||
r = glm::dot(a.xy(), b.xy()); Error += (int(r) == 50) ? 0 : 1;
|
||||
r = glm::dot(a.xy(), b.yy()); Error += (int(r) == 60) ? 0 : 1;
|
||||
|
||||
// vec3
|
||||
glm::vec3 q, u, v;
|
||||
u = glm::vec3(1, 2, 3);
|
||||
v = glm::vec3(10, 20, 30);
|
||||
r = glm::dot(u, v); Error += (int(r) == 140) ? 0 : 1;
|
||||
r = glm::dot(u.xyz(), v.zyz()); Error += (int(r) == 160) ? 0 : 1;
|
||||
r = glm::dot(u, v.zyx()); Error += (int(r) == 100) ? 0 : 1;
|
||||
r = glm::dot(u.xyz(), v); Error += (int(r) == 140) ? 0 : 1;
|
||||
r = glm::dot(u.xy(), v.xy()); Error += (int(r) == 50) ? 0 : 1;
|
||||
|
||||
// vec4
|
||||
glm::vec4 s, t;
|
||||
s = glm::vec4(1, 2, 3, 4);
|
||||
t = glm::vec4(10, 20, 30, 40);
|
||||
r = glm::dot(s, t); Error += (int(r) == 300) ? 0 : 1;
|
||||
r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
|
||||
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -354,6 +421,8 @@ int main()
|
||||
Error += test_vec3_swizzle3_3();
|
||||
Error += test_vec3_swizzle_half();
|
||||
Error += test_vec3_swizzle_partial();
|
||||
Error += test_vec3_swizzle_operators();
|
||||
Error += test_vec3_swizzle_functions();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
10
test/glm.cppcheck
Normal file
10
test/glm.cppcheck
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="1">
|
||||
<root name="glm"/>
|
||||
<includedir>
|
||||
<dir name=".."/>
|
||||
</includedir>
|
||||
<paths>
|
||||
<dir name=".."/>
|
||||
</paths>
|
||||
</project>
|
Loading…
Reference in New Issue
Block a user