diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 7 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 7 |
4 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 50345237a9f..6810067b35b 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -55,6 +55,7 @@ float area_quad_v3(const float a[3], const float b[3], const float c[3], const f float area_poly_v3(int nr, float verts[][3], const float normal[3]); int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]); +int is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]); /********************************* Distance **********************************/ diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index f761f2edcba..536236c07ac 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -232,6 +232,10 @@ #define SET_INT_IN_POINTER(i) ((void *)(intptr_t)(i)) #define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i)) +#define SET_UINT_IN_POINTER(i) ((void *)(uintptr_t)(i)) +#define GET_UINT_FROM_POINTER(i) ((unsigned int)(uintptr_t)(i)) + + /* Macro to convert a value to string in the preprocessor * STRINGIFY_ARG: gives the argument as a string * STRINGIFY_APPEND: appends any argument 'b' onto the string argument 'a', diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index f9acb6ae1dd..097b14754be 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -3278,3 +3278,10 @@ int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], c /* linetests, the 2 diagonals have to instersect to be convex */ return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0) ? TRUE : FALSE; } + +int is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]) +{ + /* linetests, the 2 diagonals have to instersect to be convex */ + return (isect_line_line_v2(v1, v3, v2, v4) > 0) ? TRUE : FALSE; +} + diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index c1ef3e27291..bdca1bb51bd 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -41,6 +41,13 @@ #include "DNA_vec_types.h" #include "BLI_rect.h" +/** + * Determine if a rect is empty. An empty + * rect is one with a zero (or negative) + * width or height. + * + * \return True if \a rect is empty. + */ int BLI_rcti_is_empty(const rcti *rect) { return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); |