2014-12-08 16:57:39 +01:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2018-02-23 12:59:02 +11:00
|
|
|
#pragma once
|
2014-12-08 16:57:39 +01:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bli
|
2018-08-30 01:56:08 +10:00
|
|
|
*/
|
|
|
|
|
2020-03-02 15:04:53 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-12-08 16:57:39 +01:00
|
|
|
struct Heap;
|
|
|
|
struct MemArena;
|
|
|
|
|
2021-12-09 20:01:44 +11:00
|
|
|
/**
|
|
|
|
* The intention is that this calculates the output of #BLI_polyfill_calc
|
|
|
|
* \note assumes the \a coords form a boundary,
|
|
|
|
* so any edges running along contiguous (wrapped) indices,
|
|
|
|
* are ignored since the edges won't share 2 faces.
|
|
|
|
*/
|
2014-12-08 16:57:39 +01:00
|
|
|
void BLI_polyfill_beautify(const float (*coords)[2],
|
2022-01-07 11:38:08 +11:00
|
|
|
unsigned int coords_tot,
|
2014-12-08 16:57:39 +01:00
|
|
|
unsigned int (*tris)[3],
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-12-08 16:57:39 +01:00
|
|
|
/* structs for reuse */
|
2017-10-23 01:15:26 +11:00
|
|
|
struct MemArena *arena,
|
|
|
|
struct Heap *eheap);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-09 20:01:44 +11:00
|
|
|
/**
|
|
|
|
* Assuming we have 2 triangles sharing an edge (2 - 4),
|
|
|
|
* check if the edge running from (1 - 3) gives better results.
|
|
|
|
*
|
|
|
|
* \param lock_degenerate: Use to avoid rotating out of a degenerate state:
|
|
|
|
* - When true, an existing zero area face on either side of the (2 - 4
|
|
|
|
* split will return a positive value.
|
|
|
|
* - When false, the check must be non-biased towards either split direction.
|
|
|
|
* \param r_area: Return the area of the quad,
|
|
|
|
* This can be useful when comparing the return value with near zero epsilons.
|
|
|
|
* In this case the epsilon can be scaled by the area to avoid the return value
|
|
|
|
* of very large faces not having a reliable way to detect near-zero output.
|
|
|
|
*
|
|
|
|
* \return (negative number means the edge can be rotated, lager == better).
|
|
|
|
*/
|
2017-09-15 18:14:17 +10:00
|
|
|
float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2],
|
|
|
|
const float v2[2],
|
|
|
|
const float v3[2],
|
|
|
|
const float v4[2],
|
2022-01-07 11:38:08 +11:00
|
|
|
bool lock_degenerate,
|
2019-08-29 22:59:21 +10:00
|
|
|
float *r_area);
|
2017-09-15 18:14:17 +10:00
|
|
|
#define BLI_polyfill_beautify_quad_rotate_calc(v1, v2, v3, v4) \
|
2019-08-29 22:59:21 +10:00
|
|
|
BLI_polyfill_beautify_quad_rotate_calc_ex(v1, v2, v3, v4, false, NULL)
|
2014-12-27 16:47:42 +11:00
|
|
|
|
2014-12-08 16:57:39 +01:00
|
|
|
/* avoid realloc's when creating new structures for polyfill ngons */
|
|
|
|
#define BLI_POLYFILL_ALLOC_NGON_RESERVE 64
|
|
|
|
|
2020-03-02 15:04:53 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|