Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to v1.1.3 #50

Merged
merged 3 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PyGLM test/
PyGLM build/
pyvers/
tests/
glm_old/
.pypirc
build.bat
build 32.bat
Expand Down
43 changes: 32 additions & 11 deletions PyGLM.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define PyGLM_VERSION "1.1.2"
#define PyGLM_VERSION "1.1.3"

#define PyGLM_NO_FUNCTIONS 1
#define PyGLM_NO_ITER_TYPECHECKING 2
Expand Down Expand Up @@ -21117,13 +21117,13 @@ NAME##_(PyObject*, PyObject* args) {\
return NULL;\
}

#define PyGLM_MAKE_GLM_FUNC_NNN_VVV_VNN__tf(NAME)\
#define PyGLM_MAKE_GLM_FUNC_NNN_VVV_VNN__tfF(NAME)\
static PyObject*\
NAME##_(PyObject*, PyObject* args) {\
PyObject *arg1, *arg2, *arg3;\
PyGLM_Arg_Unpack_3O(args, #NAME, arg1, arg2, arg3);\
if (PyGLM_Number_Check(arg1) && PyGLM_Number_Check(arg2) && PyGLM_Number_Check(arg3)) {\
return pack(glm::NAME(PyGLM_Number_FromPyObject<float>(arg1), PyGLM_Number_FromPyObject<float>(arg2), PyGLM_Number_FromPyObject<float>(arg3)));\
return pack(glm::NAME(PyGLM_Number_FromPyObject<double>(arg1), PyGLM_Number_FromPyObject<double>(arg2), PyGLM_Number_FromPyObject<double>(arg3)));\
}\
if (PyGLM_Vec_Check(1, float, arg1) && PyGLM_Vec_Check(1, float, arg2) && PyGLM_Vec_Check(1, float, arg3)) {\
return pack(glm::NAME(unpack_vec<1, float>(arg1), unpack_vec<1, float>(arg2), unpack_vec<1, float>(arg3)));\
Expand All @@ -21149,6 +21149,30 @@ NAME##_(PyObject*, PyObject* args) {\
if (PyGLM_Vec_Check(4, float, arg1) && PyGLM_Number_Check(arg2) && PyGLM_Number_Check(arg3)) {\
return pack(glm::NAME(unpack_vec<4, float>(arg1), PyGLM_Number_FromPyObject<float>(arg2), PyGLM_Number_FromPyObject<float>(arg3)));\
}\
if (PyGLM_Vec_Check(1, double, arg1) && PyGLM_Vec_Check(1, double, arg2) && PyGLM_Vec_Check(1, double, arg3)) {\
return pack(glm::NAME(unpack_vec<1, double>(arg1), unpack_vec<1, double>(arg2), unpack_vec<1, double>(arg3)));\
}\
if (PyGLM_Vec_Check(2, double, arg1) && PyGLM_Vec_Check(2, double, arg2) && PyGLM_Vec_Check(2, double, arg3)) {\
return pack(glm::NAME(unpack_vec<2, double>(arg1), unpack_vec<2, double>(arg2), unpack_vec<2, double>(arg3)));\
}\
if (PyGLM_Vec_Check(3, double, arg1) && PyGLM_Vec_Check(3, double, arg2) && PyGLM_Vec_Check(3, double, arg3)) {\
return pack(glm::NAME(unpack_vec<3, double>(arg1), unpack_vec<3, double>(arg2), unpack_vec<3, double>(arg3)));\
}\
if (PyGLM_Vec_Check(4, double, arg1) && PyGLM_Vec_Check(4, double, arg2) && PyGLM_Vec_Check(4, double, arg3)) {\
return pack(glm::NAME(unpack_vec<4, double>(arg1), unpack_vec<4, double>(arg2), unpack_vec<4, double>(arg3)));\
}\
if (PyGLM_Vec_Check(1, double, arg1) && PyGLM_Number_Check(arg2) && PyGLM_Number_Check(arg3)) {\
return pack(glm::NAME(unpack_vec<1, double>(arg1), PyGLM_Number_FromPyObject<double>(arg2), PyGLM_Number_FromPyObject<double>(arg3)));\
}\
if (PyGLM_Vec_Check(2, double, arg1) && PyGLM_Number_Check(arg2) && PyGLM_Number_Check(arg3)) {\
return pack(glm::NAME(unpack_vec<2, double>(arg1), PyGLM_Number_FromPyObject<double>(arg2), PyGLM_Number_FromPyObject<double>(arg3)));\
}\
if (PyGLM_Vec_Check(3, double, arg1) && PyGLM_Number_Check(arg2) && PyGLM_Number_Check(arg3)) {\
return pack(glm::NAME(unpack_vec<3, double>(arg1), PyGLM_Number_FromPyObject<double>(arg2), PyGLM_Number_FromPyObject<double>(arg3)));\
}\
if (PyGLM_Vec_Check(4, double, arg1) && PyGLM_Number_Check(arg2) && PyGLM_Number_Check(arg3)) {\
return pack(glm::NAME(unpack_vec<4, double>(arg1), PyGLM_Number_FromPyObject<double>(arg2), PyGLM_Number_FromPyObject<double>(arg3)));\
}\
PyErr_SetString(PyExc_TypeError, "invalid argument type(s) for " #NAME "()");\
return NULL;\
}
Expand Down Expand Up @@ -27484,7 +27508,7 @@ fmax_(PyObject*, PyObject* args) {
return NULL;
}

PyGLM_MAKE_GLM_FUNC_NNN_VVV_VNN__tf(clamp)
PyGLM_MAKE_GLM_FUNC_NNN_VVV_VNN__tfF(clamp)

static PyObject*
mix_(PyObject*, PyObject* args) {
Expand Down Expand Up @@ -34689,7 +34713,7 @@ ballRand_(PyObject*, PyObject* arg) {
return NULL;
}

//PyGLM_MAKE_GLM_FUNC_N_V__tiqsu(isPowerOfTwo);
PyGLM_MAKE_GLM_FUNC_N_V__tiqsu(isPowerOfTwo);
PyGLM_MAKE_GLM_FUNC_N_V__tiqsu(ceilPowerOfTwo);
PyGLM_MAKE_GLM_FUNC_N_V__tiqsu(floorPowerOfTwo);
PyGLM_MAKE_GLM_FUNC_N_V__tiqsu(roundPowerOfTwo);
Expand Down Expand Up @@ -35682,13 +35706,10 @@ silence(PyObject*, PyObject* arg) {

//static PyObject*
//test(PyObject* self, PyObject* arg) {
// if (PyGLM_Vec_Check(3, double, arg)) {
// Py_RETURN_TRUE;
// }
// Py_RETURN_FALSE;
// return PyFloat_FromDouble(glm::clamp(0.1, 0.0, 0.2));
//}
//#define HAS_TEST
//#define TEST_FUNC_TYPE METH_O
//#define TEST_FUNC_TYPE METH_NOARGS

static PyMethodDef glmmethods[] = {
// DETAIL
Expand Down Expand Up @@ -36004,7 +36025,7 @@ static PyMethodDef glmmethods[] = {
{ "ballRand", (PyCFunction)ballRand_, METH_O, "ballRand(Radius) -> vec3\nGenerate a random 3D vector which coordinates are regulary distributed within the area of a ball of a given radius" },

// round
//{ "isPowerOfTwo", (PyCFunction)isPowerOfTwo_, METH_O, "isPowerOfTwo(v) -> bool or bvecn\nReturn true if the value is a power of two number." },
{ "isPowerOfTwo", (PyCFunction)isPowerOfTwo_, METH_O, "isPowerOfTwo(v) -> bool or bvecn\nReturn true if the value is a power of two number." },
{ "ceilPowerOfTwo", (PyCFunction)ceilPowerOfTwo_, METH_O, "ceilPowerOfTwo(v) -> float or vecn\nReturn the power of two number which value is just higher the input value,\nround up to a power of two." },
{ "floorPowerOfTwo", (PyCFunction)floorPowerOfTwo_, METH_O, "floorPowerOfTwo(v) -> float or vecn\nReturn the power of two number which value is just lower the input value,\nround down to a power of two." },
{ "roundPowerOfTwo", (PyCFunction)roundPowerOfTwo_, METH_O, "roundPowerOfTwo(v) -> float or vecn\nReturn the power of two number which value is the closet to the input value." },
Expand Down
5 changes: 3 additions & 2 deletions PyGLM_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def fassert(func, args):
fassert(glm.fmin, args)
fassert(glm.fmax, args)

for args in gen_args("NNN_VVV_VNN__f"):
for args in gen_args("NNN_VVV_VNN__fF"):
fassert(glm.clamp, args)

for args in list(gen_args("NNNB_NNN_QQN__fF")) + list(gen_args("VVN_VVVf_VVVF_VVVB")): # need to add support for _MMN_MMMf_MMMF
Expand Down Expand Up @@ -945,6 +945,7 @@ def fassert(func, args):
# round #
for args in gen_args("N_V__iqsu"):
# need to add support for isPowerOfTwo
fassert(glm.isPowerOfTwo, args)
fassert(glm.ceilPowerOfTwo, args)
fassert(glm.floorPowerOfTwo, args)
fassert(glm.roundPowerOfTwo, args)
Expand Down Expand Up @@ -1010,4 +1011,4 @@ def fassert(func, args):
#/ulp #
##/EXTENSIONS ##

print("Finished tests in {:.3g}s".format(time.time()-start_time))
print("Finished tests in {:.3g}s".format(time.time()-start_time))
66 changes: 66 additions & 0 deletions glm/glm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
file(GLOB ROOT_SOURCE *.cpp)
file(GLOB ROOT_INLINE *.inl)
file(GLOB ROOT_HEADER *.hpp)
file(GLOB ROOT_TEXT ../*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB ROOT_NAT ../util/glm.natvis)

file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp)
file(GLOB_RECURSE CORE_INLINE ./detail/*.inl)
file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp)

file(GLOB_RECURSE EXT_SOURCE ./ext/*.cpp)
file(GLOB_RECURSE EXT_INLINE ./ext/*.inl)
file(GLOB_RECURSE EXT_HEADER ./ext/*.hpp)

file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp)
file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl)
file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp)

file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)

file(GLOB_RECURSE SIMD_SOURCE ./simd/*.cpp)
file(GLOB_RECURSE SIMD_INLINE ./simd/*.inl)
file(GLOB_RECURSE SIMD_HEADER ./simd/*.h)

source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
source_group("EXT Files" FILES ${EXT_SOURCE})
source_group("EXT Files" FILES ${EXT_INLINE})
source_group("EXT Files" FILES ${EXT_HEADER})
source_group("GTC Files" FILES ${GTC_SOURCE})
source_group("GTC Files" FILES ${GTC_INLINE})
source_group("GTC Files" FILES ${GTC_HEADER})
source_group("GTX Files" FILES ${GTX_SOURCE})
source_group("GTX Files" FILES ${GTX_INLINE})
source_group("GTX Files" FILES ${GTX_HEADER})
source_group("SIMD Files" FILES ${SIMD_SOURCE})
source_group("SIMD Files" FILES ${SIMD_INLINE})
source_group("SIMD Files" FILES ${SIMD_HEADER})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)

if(BUILD_STATIC_LIBS)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif()

if(BUILD_SHARED_LIBS)
add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif()

39 changes: 39 additions & 0 deletions glm/glm/detail/_vectorize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,44 @@ namespace detail
return vec<4, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b));
}
};

template<length_t L, typename T, qualifier Q>
struct functor2_vec_int {};

template<typename T, qualifier Q>
struct functor2_vec_int<1, T, Q>
{
GLM_FUNC_QUALIFIER static vec<1, int, Q> call(int (*Func) (T x, int y), vec<1, T, Q> const& a, vec<1, int, Q> const& b)
{
return vec<1, int, Q>(Func(a.x, b.x));
}
};

template<typename T, qualifier Q>
struct functor2_vec_int<2, T, Q>
{
GLM_FUNC_QUALIFIER static vec<2, int, Q> call(int (*Func) (T x, int y), vec<2, T, Q> const& a, vec<2, int, Q> const& b)
{
return vec<2, int, Q>(Func(a.x, b.x), Func(a.y, b.y));
}
};

template<typename T, qualifier Q>
struct functor2_vec_int<3, T, Q>
{
GLM_FUNC_QUALIFIER static vec<3, int, Q> call(int (*Func) (T x, int y), vec<3, T, Q> const& a, vec<3, int, Q> const& b)
{
return vec<3, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
}
};

template<typename T, qualifier Q>
struct functor2_vec_int<4, T, Q>
{
GLM_FUNC_QUALIFIER static vec<4, int, Q> call(int (*Func) (T x, int y), vec<4, T, Q> const& a, vec<4, int, Q> const& b)
{
return vec<4, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
}
};
}//namespace detail
}//namespace glm
2 changes: 1 addition & 1 deletion glm/glm/detail/func_common.inl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace detail
{
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& edge0, vec<L, T, Q> const& edge1, vec<L, T, Q> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'step' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'smoothstep' only accept floating-point inputs");
vec<L, T, Q> const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast<T>(0), static_cast<T>(1)));
return tmp * tmp * (static_cast<T>(3) - static_cast<T>(2) * tmp);
}
Expand Down
29 changes: 16 additions & 13 deletions glm/glm/detail/func_integer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ namespace detail
template<typename genIUType>
GLM_FUNC_QUALIFIER genIUType bitfieldInsert(genIUType const& Base, genIUType const& Insert, int Offset, int Bits)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldInsert' only accept integer values");

return bitfieldInsert(vec<1, genIUType>(Base), vec<1, genIUType>(Insert), Offset, Bits).x;
}

Expand All @@ -273,42 +275,43 @@ namespace detail
}

// bitfieldReverse
template<typename genType>
GLM_FUNC_QUALIFIER genType bitfieldReverse(genType x)
template<typename genIUType>
GLM_FUNC_QUALIFIER genIUType bitfieldReverse(genIUType x)
{
return bitfieldReverse(glm::vec<1, genType, glm::defaultp>(x)).x;
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldReverse' only accept integer values");

return bitfieldReverse(glm::vec<1, genIUType, glm::defaultp>(x)).x;
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> bitfieldReverse(vec<L, T, Q> const& v)
{
#if GLM_COMPILER & GLM_COMPILER_VC
#pragma warning(push)
#pragma warning(disable : 4309)
#endif
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldReverse' only accept integer values");

vec<L, T, Q> x(v);
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 2>::call(x, static_cast<T>(0x5555555555555555ull), static_cast<T>( 1));
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 4>::call(x, static_cast<T>(0x3333333333333333ull), static_cast<T>( 2));
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 8>::call(x, static_cast<T>(0x0F0F0F0F0F0F0F0Full), static_cast<T>( 4));
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 16>::call(x, static_cast<T>(0x00FF00FF00FF00FFull), static_cast<T>( 8));
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 32>::call(x, static_cast<T>(0x0000FFFF0000FFFFull), static_cast<T>(16));
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 64>::call(x, static_cast<T>(0x00000000FFFFFFFFull), static_cast<T>(32));
#if GLM_COMPILER & GLM_COMPILER_VC
#pragma warning(pop)
#endif
return x;
}

// bitCount
template<typename genType>
GLM_FUNC_QUALIFIER int bitCount(genType x)
template<typename genIUType>
GLM_FUNC_QUALIFIER int bitCount(genIUType x)
{
return bitCount(glm::vec<1, genType, glm::defaultp>(x)).x;
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitCount' only accept integer values");

return bitCount(glm::vec<1, genIUType, glm::defaultp>(x)).x;
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, int, Q> bitCount(vec<L, T, Q> const& v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitCount' only accept integer values");

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4310) //cast truncates constant value
Expand Down
20 changes: 20 additions & 0 deletions glm/glm/detail/qualifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,26 @@ namespace detail
};
# endif

# if GLM_ARCH & GLM_ARCH_NEON_BIT
template<>
struct storage<4, float, true>
{
typedef glm_f32vec4 type;
};

template<>
struct storage<4, int, true>
{
typedef glm_i32vec4 type;
};

template<>
struct storage<4, unsigned int, true>
{
typedef glm_u32vec4 type;
};
# endif

enum genTypeEnum
{
GENTYPE_VEC,
Expand Down
Loading