///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 – 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the “Software”), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file glm/detail/func_integer.inl
/// @date 2010-03-17 / 2011-06-15
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include “type_vec2.hpp” namespace glm{ template template <> template template <> template return glm::bitCount(~Value & (Value – static_cast # if GLM_HAS_BITSCAN_WINDOWS # if !((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_MODEL == GLM_MODEL_32)) template template template # if GLM_HAS_BITSCAN_WINDOWS template # if !((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_MODEL == GLM_MODEL_32)) template // uaddCarry template // usubBorrow Borrow = x >= y ? static_cast template // umulExtended uint64 Value64 = static_cast template vecType // imulExtended int64 Value64 = static_cast template vecType // bitfieldExtract template return (Value >> static_cast // bitfieldInsert template T const Mask = static_cast template // bitCount template // findLSB return detail::compute_findLSB template return detail::functor1 // findMSB return findMSB(tvec1 template return detail::compute_findMSB_vec
#include “type_vec3.hpp”
#include “type_vec4.hpp”
#include “type_int.hpp”
#include “_vectorize.hpp”
#if(GLM_ARCH != GLM_ARCH_PURE)
#if(GLM_COMPILER & GLM_COMPILER_VC)
# include
# pragma intrinsic(_BitScanReverse)
#endif//(GLM_COMPILER & GLM_COMPILER_VC)
#endif//(GLM_ARCH != GLM_ARCH_PURE)
#include
namespace detail
{
template
GLM_FUNC_QUALIFIER T mask(T Bits)
{
return Bits >= sizeof(T) * 8 ? ~static_cast
}
struct compute_bitfieldReverseStep
{
template
GLM_FUNC_QUALIFIER static vecType
{
return v;
}
};
struct compute_bitfieldReverseStep
template
GLM_FUNC_QUALIFIER static vecType
{
return (v & Mask) << Shift | (v & (~Mask)) >> Shift;
}
};
struct compute_bitfieldBitCountStep
{
template
GLM_FUNC_QUALIFIER static vecType
{
return v;
}
};
struct compute_bitfieldBitCountStep
template
GLM_FUNC_QUALIFIER static vecType
{
return (v & Mask) + ((v >> Shift) & Mask);
}
};
struct compute_findLSB
{
GLM_FUNC_QUALIFIER static int call(genIUType Value)
{
if(Value == 0)
return -1;
}
};
template
struct compute_findLSB
{
GLM_FUNC_QUALIFIER static int call(genIUType Value)
{
unsigned long Result(0);
unsigned char IsNotNull = _BitScanForward(&Result, *reinterpret_cast
return IsNotNull ? int(Result) : -1;
}
};
template
struct compute_findLSB
{
GLM_FUNC_QUALIFIER static int call(genIUType Value)
{
unsigned long Result(0);
unsigned char IsNotNull = _BitScanForward64(&Result, *reinterpret_cast
return IsNotNull ? int(Result) : -1;
}
};
# endif
# endif//GLM_HAS_BITSCAN_WINDOWS
struct compute_findMSB_step_vec
{
GLM_FUNC_QUALIFIER static vecType
{
return x | (x >> Shift);
}
};
struct compute_findMSB_step_vec
{
GLM_FUNC_QUALIFIER static vecType
{
return x;
}
};
struct compute_findMSB_vec
{
GLM_FUNC_QUALIFIER static vecType
{
vecType
x = compute_findMSB_step_vec
x = compute_findMSB_step_vec
x = compute_findMSB_step_vec
x = compute_findMSB_step_vec
x = compute_findMSB_step_vec
x = compute_findMSB_step_vec
return vecType
}
};
template
GLM_FUNC_QUALIFIER int compute_findMSB_32(genIUType Value)
{
unsigned long Result(0);
unsigned char IsNotNull = _BitScanReverse(&Result, *reinterpret_cast
return IsNotNull ? int(Result) : -1;
}
struct compute_findMSB_vec
{
GLM_FUNC_QUALIFIER static vecType
{
return detail::functor1
}
};
template
GLM_FUNC_QUALIFIER int compute_findMSB_64(genIUType Value)
{
unsigned long Result(0);
unsigned char IsNotNull = _BitScanReverse64(&Result, *reinterpret_cast
return IsNotNull ? int(Result) : -1;
}
struct compute_findMSB_vec
{
GLM_FUNC_QUALIFIER static vecType
{
return detail::functor1
}
};
# endif
# endif//GLM_HAS_BITSCAN_WINDOWS
}//namespace detail
GLM_FUNC_QUALIFIER uint uaddCarry(uint const & x, uint const & y, uint & Carry)
{
uint64 const Value64(static_cast
uint64 const Max32((static_cast
Carry = Value64 > Max32 ? 1 : 0;
return static_cast
}
GLM_FUNC_QUALIFIER vecType
{
vecType
vecType
Carry = mix(vecType
return vecType
}
GLM_FUNC_QUALIFIER uint usubBorrow(uint const & x, uint const & y, uint & Borrow)
{
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), “uint and uint32 size mismatch”);
if(y >= x)
return y – x;
else
return static_cast
}
GLM_FUNC_QUALIFIER vecType
{
Borrow = mix(vecType
vecType
vecType
return mix(XgeY, YgeX, greaterThanEqual(y, x));
}
GLM_FUNC_QUALIFIER void umulExtended(uint const & x, uint const & y, uint & msb, uint & lsb)
{
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), “uint and uint32 size mismatch”);
uint32* PointerMSB = (reinterpret_cast
msb = *PointerMSB;
uint32* PointerLSB = (reinterpret_cast
lsb = *PointerLSB;
}
GLM_FUNC_QUALIFIER void umulExtended(vecType
{
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), “uint and uint32 size mismatch”);
msb = vecType
lsb = vecType
}
GLM_FUNC_QUALIFIER void imulExtended(int x, int y, int & msb, int & lsb)
{
GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), “int and int32 size mismatch”);
int32* PointerMSB = (reinterpret_cast
msb = *PointerMSB;
int32* PointerLSB = (reinterpret_cast
lsb = *PointerLSB;
}
GLM_FUNC_QUALIFIER void imulExtended(vecType
{
GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), “int and int32 size mismatch”);
lsb = vecType
msb = vecType
}
template
GLM_FUNC_QUALIFIER genIUType bitfieldExtract(genIUType Value, int Offset, int Bits)
{
return bitfieldExtract(tvec1
}
GLM_FUNC_QUALIFIER vecType
{
GLM_STATIC_ASSERT(std::numeric_limits
}
template
GLM_FUNC_QUALIFIER genIUType bitfieldInsert(genIUType const & Base, genIUType const & Insert, int Offset, int Bits)
{
return bitfieldInsert(tvec1
}
GLM_FUNC_QUALIFIER vecType
{
GLM_STATIC_ASSERT(std::numeric_limits
GLM_FUNC_QUALIFIER genType bitfieldReverse(genType x)
{
return bitfieldReverse(glm::tvec1
}
GLM_FUNC_QUALIFIER vecType
{
vecType
x = detail::compute_bitfieldReverseStep
x = detail::compute_bitfieldReverseStep
x = detail::compute_bitfieldReverseStep
x = detail::compute_bitfieldReverseStep
x = detail::compute_bitfieldReverseStep
x = detail::compute_bitfieldReverseStep
return x;
}
template
GLM_FUNC_QUALIFIER int bitCount(genType x)
{
return bitCount(glm::tvec1
}
GLM_FUNC_QUALIFIER vecType
{
vecType
x = detail::compute_bitfieldBitCountStep
x = detail::compute_bitfieldBitCountStep
x = detail::compute_bitfieldBitCountStep
x = detail::compute_bitfieldBitCountStep
x = detail::compute_bitfieldBitCountStep
x = detail::compute_bitfieldBitCountStep
return vecType
}
template
GLM_FUNC_QUALIFIER int findLSB(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits
}
GLM_FUNC_QUALIFIER vecType
{
GLM_STATIC_ASSERT(std::numeric_limits
}
template
GLM_FUNC_QUALIFIER int findMSB(genIUType x)
{
GLM_STATIC_ASSERT(std::numeric_limits
}
GLM_FUNC_QUALIFIER vecType
{
GLM_STATIC_ASSERT(std::numeric_limits
}
}//namespace glm