Vectorize and reformat

This commit is contained in:
Christophe Riccio 2011-10-14 13:15:11 +01:00
parent bc15b98730
commit 86be6440e3
13 changed files with 2195 additions and 3279 deletions

View File

@ -8,9 +8,10 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#include "../core/_detail.hpp" #include "../core/_detail.hpp"
#include "../core/_vectorize.hpp"
namespace glm{ namespace glm
{
template <typename genIType> template <typename genIType>
GLM_FUNC_QUALIFIER genIType mask GLM_FUNC_QUALIFIER genIType mask
( (
@ -20,41 +21,7 @@ GLM_FUNC_QUALIFIER genIType mask
return ((genIType(1) << (count)) - genIType(1)); return ((genIType(1) << (count)) - genIType(1));
} }
template <typename valIType> VECTORIZE_VEC(mask)
GLM_FUNC_QUALIFIER detail::tvec2<valIType> mask
(
detail::tvec2<valIType> const & count
)
{
return detail::tvec2<valIType>(
mask(count[0]),
mask(count[1]));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec3<valIType> mask
(
detail::tvec3<valIType> const & count
)
{
return detail::tvec3<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec4<valIType> mask
(
detail::tvec4<valIType> const & count
)
{
return detail::tvec4<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]),
mask(count[3]));
}
// extractField // extractField
template <typename genIType> template <typename genIType>
@ -458,41 +425,7 @@ GLM_FUNC_QUALIFIER genType powerOfTwoAbove(genType const & value)
return isPowerOfTwo(value) ? value : highestBitValue(value) << 1; return isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
} }
template <typename valType> VECTORIZE_VEC(powerOfTwoAbove)
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoAbove
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoAbove
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoAbove
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]),
powerOfTwoAbove(value[3]));
}
// powerOfTwoBelow // powerOfTwoBelow
template <typename genType> template <typename genType>
@ -504,41 +437,7 @@ GLM_FUNC_QUALIFIER genType powerOfTwoBelow
return isPowerOfTwo(value) ? value : highestBitValue(value); return isPowerOfTwo(value) ? value : highestBitValue(value);
} }
template <typename valType> VECTORIZE_VEC(powerOfTwoBelow)
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoBelow
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoBelow
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoBelow
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]),
powerOfTwoBelow(value[3]));
}
// powerOfTwoNearest // powerOfTwoNearest
template <typename genType> template <typename genType>
@ -555,41 +454,7 @@ GLM_FUNC_QUALIFIER genType powerOfTwoNearest
return (next - value) < (value - prev) ? next : prev; return (next - value) < (value - prev) ? next : prev;
} }
template <typename valType> VECTORIZE_VEC(powerOfTwoNearest)
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoNearest
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoNearest
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoNearest
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]),
powerOfTwoNearest(value[3]));
}
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType bitRevert(genType const & In) GLM_FUNC_QUALIFIER genType bitRevert(genType const & In)
@ -604,41 +469,7 @@ GLM_FUNC_QUALIFIER genType bitRevert(genType const & In)
return Out; return Out;
} }
template <typename valType> VECTORIZE_VEC(bitRevert)
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRevert
(
detail::tvec2<valType> const & Value
)
{
return detail::tvec2<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRevert
(
detail::tvec3<valType> const & Value
)
{
return detail::tvec3<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRevert
(
detail::tvec4<valType> const & Value
)
{
return detail::tvec4<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]),
bitRevert(Value[3]));
}
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType bitRotateRight(genType const & In, std::size_t Shift) GLM_FUNC_QUALIFIER genType bitRotateRight(genType const & In, std::size_t Shift)
@ -769,5 +600,4 @@ GLM_FUNC_QUALIFIER genIUType fillBitfieldWithZero
Result &= ~(1 << i); Result &= ~(1 << i);
return Result; return Result;
} }
}//namespace glm }//namespace glm

View File

@ -10,8 +10,8 @@
#ifndef glm_gtx_closest_point #ifndef glm_gtx_closest_point
#define glm_gtx_closest_point #define glm_gtx_closest_point
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
( (
@ -31,7 +31,6 @@ GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
if(Distance >= LineLength) return b; if(Distance >= LineLength) return b;
return a + LineDirection * Distance; return a + LineDirection * Distance;
} }
}//namespace glm }//namespace glm
#endif//glm_gtx_closest_point #endif//glm_gtx_closest_point

View File

@ -7,8 +7,8 @@
// File : glm/gtx/color_cast.inl // File : glm/gtx/color_cast.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER uint8 u8channel_cast(T a) GLM_FUNC_QUALIFIER uint8 u8channel_cast(T a)
{ {
@ -730,5 +730,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<double> f64_abgr_cast<uint64>(uint64 color)
result.w = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535); result.w = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535);
return result; return result;
} }
}//namespace glm }//namespace glm

View File

@ -7,8 +7,8 @@
// File : glm/gtx/color_space.inl // File : glm/gtx/color_space.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor) GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
{ {
@ -146,5 +146,4 @@ GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color)
const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11); const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11);
return dot(color, tmp); return dot(color, tmp);
} }
}//namespace glm }//namespace glm

View File

@ -7,8 +7,8 @@
// File : glm/gtx/color_space_YCoCg.inl // File : glm/gtx/color_space_YCoCg.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
( (
@ -61,5 +61,4 @@ GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCgR2rgb
result.r = result.b + YCoCgRColor.y; result.r = result.b + YCoCgRColor.y;
return result; return result;
} }
}//namespace glm }//namespace glm

View File

@ -7,8 +7,8 @@
// File : glm/gtx/compatibility.inl // File : glm/gtx/compatibility.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
// isfinite // isfinite
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool isfinite( GLM_FUNC_QUALIFIER bool isfinite(
@ -133,5 +133,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<bool> isnan(
isnan(x.z), isnan(x.z),
isnan(x.w)); isnan(x.w));
} }
}//namespace glm }//namespace glm

View File

@ -7,8 +7,8 @@
// File : gtx_component_wise.inl // File : gtx_component_wise.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v) GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
{ {
@ -44,5 +44,4 @@ GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v)
result = max(result, v[i]); result = max(result, v[i]);
return result; return result;
} }
}//namespace glm }//namespace glm

View File

@ -20,773 +20,8 @@
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE. /// THE SOFTWARE.
/// ///
/// @ref gtc_half_float /// @ref gtx_constants
/// @file glm/gtc/half_float.inl /// @file glm/gtx/constants.inl
/// @date 2009-04-29 / 2011-06-05 /// @date 2011-10-14 / 2011-10-14
/// @author Christophe Riccio /// @author Christophe Riccio
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "../core/_detail.hpp"
namespace glm{
template <typename genIType>
GLM_FUNC_QUALIFIER genIType mask
(
genIType const & count
)
{
return ((genIType(1) << (count)) - genIType(1));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec2<valIType> mask
(
detail::tvec2<valIType> const & count
)
{
return detail::tvec2<valIType>(
mask(count[0]),
mask(count[1]));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec3<valIType> mask
(
detail::tvec3<valIType> const & count
)
{
return detail::tvec3<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec4<valIType> mask
(
detail::tvec4<valIType> const & count
)
{
return detail::tvec4<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]),
mask(count[3]));
}
// extractField
template <typename genIType>
GLM_FUNC_QUALIFIER genIType extractField
(
half const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(half));
return (value._data() << first) >> ((sizeof(half) << 3) - count);
}
template <typename genIType>
GLM_FUNC_QUALIFIER genIType extractField
(
float const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(float));
return (detail::uif32(value).i << first) >> ((sizeof(float) << 3) - count);
}
template <typename genIType>
GLM_FUNC_QUALIFIER genIType extractField
(
double const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(double));
return (detail::uif64(value).i << first) >> ((sizeof(double) << genIType(3)) - count);
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER genIUType extractField
(
genIUType const & Value,
sizeType const & First,
sizeType const & Count
)
{
sizeType GenSize = sizeof(genIUType) << 3;
assert(First + Count <= GenSize);
genIUType ShiftLeft = Count ? Value << (GenSize - (Count + First)) : 0;
genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Count);
return ShiftBack;
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
(
detail::tvec2<genIUType> const & value,
sizeType const & first,
sizeType const & count
)
{
return detail::tvec2<genIUType>(
extractField(value[0], first, count),
extractField(value[1], first, count));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
(
detail::tvec3<genIUType> const & value,
sizeType const & first,
sizeType const & count
)
{
return detail::tvec3<genIUType>(
extractField(value[0], first, count),
extractField(value[1], first, count),
extractField(value[2], first, count));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
(
detail::tvec4<genIUType> const & value,
sizeType const & first,
sizeType const & count
)
{
return detail::tvec4<genIUType>(
extractField(value[0], first, count),
extractField(value[1], first, count),
extractField(value[2], first, count),
extractField(value[3], first, count));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
(
detail::tvec2<genIUType> const & value,
detail::tvec2<sizeType> const & first,
detail::tvec2<sizeType> const & count
)
{
return detail::tvec2<genIUType>(
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
(
detail::tvec3<genIUType> const & value,
detail::tvec3<sizeType> const & first,
detail::tvec3<sizeType> const & count
)
{
return detail::tvec3<genIUType>(
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]),
extractField(value[2], first[2], count[2]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
(
detail::tvec4<genIUType> const & value,
detail::tvec4<sizeType> const & first,
detail::tvec4<sizeType> const & count
)
{
return detail::tvec4<genIUType>(
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]),
extractField(value[2], first[2], count[2]),
extractField(value[3], first[3], count[3]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
(
genIUType const & value,
detail::tvec2<sizeType> const & first,
detail::tvec2<sizeType> const & count
)
{
return detail::tvec2<genIUType>(
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
(
genIUType const & value,
detail::tvec3<sizeType> const & first,
detail::tvec3<sizeType> const & count
)
{
return detail::tvec3<genIUType>(
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]),
extractField(value, first[2], count[2]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
(
genIUType const & value,
detail::tvec4<sizeType> const & first,
detail::tvec4<sizeType> const & count
)
{
return detail::tvec4<genIUType>(
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]),
extractField(value, first[2], count[2]),
extractField(value, first[3], count[3]));
}
// lowestBit
template <typename genType>
GLM_FUNC_QUALIFIER int lowestBit
(
genType const & Value
)
{
assert(Value != genType(0)); // not valid call
genType Bit;
for(Bit = genType(0); !(Value & (1 << Bit)); ++Bit){}
return Bit;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<int> lowestBit
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
lowestBit(value[0]),
lowestBit(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<int> lowestBit
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
lowestBit(value[0]),
lowestBit(value[1]),
lowestBit(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<int> lowestBit
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
lowestBit(value[0]),
lowestBit(value[1]),
lowestBit(value[2]),
lowestBit(value[3]));
}
// highestBit
template <typename genType>
GLM_FUNC_QUALIFIER int highestBit
(
genType const & value
)
{
assert(value != genType(0)); // not valid call
genType bit = genType(-1);
for(genType tmp = value; tmp; tmp >>= 1, ++bit){}
return bit;
}
//template <>
//GLM_FUNC_QUALIFIER int highestBit<int>
//(
// int value
//)
//{
// int bit = -1;
// for(int tmp = value; tmp; tmp >>= 1, ++bit);
// return bit;
//}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBit
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
highestBit(value[0]),
highestBit(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBit
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
highestBit(value[0]),
highestBit(value[1]),
highestBit(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBit
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
highestBit(value[0]),
highestBit(value[1]),
highestBit(value[2]),
highestBit(value[3]));
}
// highestBitValue
template <typename genType>
GLM_FUNC_QUALIFIER genType highestBitValue
(
genType const & value
)
{
genType tmp = value;
genType result = genType(0);
while(tmp)
{
result = (tmp & (~tmp + 1)); // grab lowest bit
tmp &= ~result; // clear lowest bit
}
return result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBitValue
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
highestBitValue(value[0]),
highestBitValue(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBitValue
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
highestBitValue(value[0]),
highestBitValue(value[1]),
highestBitValue(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBitValue
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
highestBitValue(value[0]),
highestBitValue(value[1]),
highestBitValue(value[2]),
highestBitValue(value[3]));
}
// isPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType const & Value)
{
//detail::If<std::numeric_limits<genType>::is_signed>::apply(abs, Value);
//return !(Value & (Value - 1));
// For old complier?
genType Result = Value;
if(std::numeric_limits<genType>::is_signed)
Result = abs(Result);
return !(Result & (Result - 1));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isPowerOfTwo
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isPowerOfTwo
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]),
isPowerOfTwo(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isPowerOfTwo
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]),
isPowerOfTwo(value[2]),
isPowerOfTwo(value[3]));
}
// powerOfTwoAbove
template <typename genType>
GLM_FUNC_QUALIFIER genType powerOfTwoAbove(genType const & value)
{
return isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoAbove
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoAbove
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoAbove
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]),
powerOfTwoAbove(value[3]));
}
// powerOfTwoBelow
template <typename genType>
GLM_FUNC_QUALIFIER genType powerOfTwoBelow
(
genType const & value
)
{
return isPowerOfTwo(value) ? value : highestBitValue(value);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoBelow
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoBelow
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoBelow
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]),
powerOfTwoBelow(value[3]));
}
// powerOfTwoNearest
template <typename genType>
GLM_FUNC_QUALIFIER genType powerOfTwoNearest
(
genType const & value
)
{
if(isPowerOfTwo(value))
return value;
genType prev = highestBitValue(value);
genType next = prev << 1;
return (next - value) < (value - prev) ? next : prev;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoNearest
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoNearest
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoNearest
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]),
powerOfTwoNearest(value[3]));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType bitRevert(genType const & In)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRevert' only accept integer values");
genType Out = 0;
std::size_t BitSize = sizeof(genType) * 8;
for(std::size_t i = 0; i < BitSize; ++i)
if(In & (genType(1) << i))
Out |= genType(1) << (BitSize - 1 - i);
return Out;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRevert
(
detail::tvec2<valType> const & Value
)
{
return detail::tvec2<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRevert
(
detail::tvec3<valType> const & Value
)
{
return detail::tvec3<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRevert
(
detail::tvec4<valType> const & Value
)
{
return detail::tvec4<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]),
bitRevert(Value[3]));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType bitRotateRight(genType const & In, std::size_t Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateRight' only accept integer values");
std::size_t BitSize = sizeof(genType) * 8;
return (In << Shift) | (In >> (BitSize - Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateRight
(
detail::tvec2<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec2<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateRight
(
detail::tvec3<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec3<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift),
bitRotateRight(Value[2], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateRight
(
detail::tvec4<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec4<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift),
bitRotateRight(Value[2], Shift),
bitRotateRight(Value[3], Shift));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType bitRotateLeft(genType const & In, std::size_t Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateLeft' only accept integer values");
std::size_t BitSize = sizeof(genType) * 8;
return (In >> Shift) | (In << (BitSize - Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateLeft
(
detail::tvec2<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec2<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateLeft
(
detail::tvec3<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec3<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift),
bitRotateLeft(Value[2], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateLeft
(
detail::tvec4<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec4<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift),
bitRotateLeft(Value[2], Shift),
bitRotateLeft(Value[3], Shift));
}
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType fillBitfieldWithOne
(
genIUType const & Value,
int const & FromBit,
int const & ToBit
)
{
assert(FromBit <= ToBit);
assert(ToBit <= sizeof(genIUType) * std::size_t(8));
genIUType Result = Value;
for(std::size_t i = 0; i <= ToBit; ++i)
Result |= (1 << i);
return Result;
}
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType fillBitfieldWithZero
(
genIUType const & Value,
int const & FromBit,
int const & ToBit
)
{
assert(FromBit <= ToBit);
assert(ToBit <= sizeof(genIUType) * std::size_t(8));
genIUType Result = Value;
for(std::size_t i = 0; i <= ToBit; ++i)
Result &= ~(1 << i);
return Result;
}
}//namespace glm

View File

@ -7,8 +7,8 @@
// File : glm/gtx/epsilon.inl // File : glm/gtx/epsilon.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool equalEpsilon GLM_FUNC_QUALIFIER bool equalEpsilon
( (
@ -226,5 +226,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
abs(x.z - y.z) >= epsilon.z, abs(x.z - y.z) >= epsilon.z,
abs(x.w - y.w) >= epsilon.w); abs(x.w - y.w) >= epsilon.w);
} }
}//namespace glm }//namespace glm

View File

@ -7,8 +7,8 @@
// File : glm/gtx/euler_angles.inl // File : glm/gtx/euler_angles.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
( (
@ -241,5 +241,4 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4
{ {
return yawPitchRoll(angles.z, angles.x, angles.y); return yawPitchRoll(angles.z, angles.x, angles.y);
} }
}//namespace glm }//namespace glm

View File

@ -7,8 +7,8 @@
// File : glm/gtx/extend.inl // File : glm/gtx/extend.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
genType extend genType extend
( (
@ -52,5 +52,4 @@ detail::tvec4<valType> extend
{ {
return Origin + (Source - Origin) * Distance; return Origin + (Source - Origin) * Distance;
} }
}//namespace glm }//namespace glm

View File

@ -54,17 +54,17 @@ namespace glm
//! Faster than the common pow function but less accurate. //! Faster than the common pow function but less accurate.
//! From GLM_GTX_fast_exponential extension. //! From GLM_GTX_fast_exponential extension.
template <typename valType> template <typename genType>
valType fastPow( genType fastPow(
valType const & x, genType const & x,
valType const & y); genType const & y);
//! Faster than the common pow function but less accurate. //! Faster than the common pow function but less accurate.
//! From GLM_GTX_fast_exponential extension. //! From GLM_GTX_fast_exponential extension.
template <typename T, typename U> template <typename genTypeT, typename genTypeU>
T fastPow( genType fastPow(
const T& x, genTypeT const & x,
const U& y); genTypeU const & y);
//! Faster than the common exp function but less accurate. //! Faster than the common exp function but less accurate.
//! From GLM_GTX_fast_exponential extension. //! From GLM_GTX_fast_exponential extension.

View File

@ -7,47 +7,18 @@
// File : glm/gtx/fast_exponential.inl // File : glm/gtx/fast_exponential.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ #include "../core/_vectorize.hpp"
namespace glm
{
// fastPow: // fastPow:
template <typename T> template <typename genType>
GLM_FUNC_QUALIFIER T fastPow(const T x, const T y) GLM_FUNC_QUALIFIER genType fastPow(genType const & x, genType const & y)
{ {
return exp(y * log(x)); return exp(y * log(x));
} }
template <typename T> VECTORIZE_VEC_VEC(fastPow)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
const detail::tvec2<T>& x,
const detail::tvec2<T>& y)
{
return detail::tvec2<T>(
fastPow(x.x, y.x),
fastPow(x.y, y.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
const detail::tvec3<T>& x,
const detail::tvec3<T>& y)
{
return detail::tvec3<T>(
fastPow(x.x, y.x),
fastPow(x.y, y.y),
fastPow(x.z, y.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
const detail::tvec4<T>& x,
const detail::tvec4<T>& y)
{
return detail::tvec4<T>(
fastPow(x.x, y.x),
fastPow(x.y, y.y),
fastPow(x.z, y.z),
fastPow(x.w, y.w));
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastPow(const T x, int y) GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
@ -137,39 +108,12 @@ GLM_FUNC_QUALIFIER float fastExp(float 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);; 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 <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastExp(x.x),
fastExp(x.y));
}
template <typename T> VECTORIZE_VEC(fastExp)
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp(
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastExp(x.x),
fastExp(x.y),
fastExp(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastExp(x.x),
fastExp(x.y),
fastExp(x.z),
fastExp(x.w));
}
// fastLog // fastLog
template <typename T> template <typename genType>
GLM_FUNC_QUALIFIER T fastLog(const T x) GLM_FUNC_QUALIFIER genType fastLog(genType const & x)
{ {
return std::log(x); return std::log(x);
} }
@ -183,108 +127,24 @@ GLM_FUNC_QUALIFIER float fastLog(float x)
} }
*/ */
template <typename T> VECTORIZE_VEC(fastLog)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastLog(x.x),
fastLog(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog(
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastLog(x.x),
fastLog(x.y),
fastLog(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastLog(x.x),
fastLog(x.y),
fastLog(x.z),
fastLog(x.w));
}
//fastExp2, ln2 = 0.69314718055994530941723212145818f //fastExp2, ln2 = 0.69314718055994530941723212145818f
template <typename T> template <typename genType>
GLM_FUNC_QUALIFIER T fastExp2(const T x) GLM_FUNC_QUALIFIER genType fastExp2(genType const & x)
{ {
return fastExp(0.69314718055994530941723212145818f * x); return fastExp(0.69314718055994530941723212145818f * x);
} }
template <typename T> VECTORIZE_VEC(fastExp2)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp2(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastExp2(x.x),
fastExp2(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp2(
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastExp2(x.x),
fastExp2(x.y),
fastExp2(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp2(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastExp2(x.x),
fastExp2(x.y),
fastExp2(x.z),
fastExp2(x.w));
}
// fastLog2, ln2 = 0.69314718055994530941723212145818f // fastLog2, ln2 = 0.69314718055994530941723212145818f
template <typename T> template <typename genType>
GLM_FUNC_QUALIFIER T fastLog2(const T x) GLM_FUNC_QUALIFIER genType fastLog2(genType const & x)
{ {
return fastLog(x) / 0.69314718055994530941723212145818f; return fastLog(x) / 0.69314718055994530941723212145818f;
} }
template <typename T> VECTORIZE_VEC(fastLog2)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog2(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastLog2(x.x),
fastLog2(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog2(
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastLog2(x.x),
fastLog2(x.y),
fastLog2(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog2(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastLog2(x.x),
fastLog2(x.y),
fastLog2(x.z),
fastLog2(x.w));
}
}//namespace glm }//namespace glm