2023-08-15 16:20:26 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2013-11-30 11:55:50 +01:00
|
|
|
|
2018-02-18 11:27:33 +01:00
|
|
|
#pragma once
|
2013-11-30 11:55:50 +01:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bli
|
2018-08-29 17:56:08 +02:00
|
|
|
*/
|
|
|
|
|
2020-03-02 15:04:53 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-01-30 13:32:23 +01:00
|
|
|
struct MemArena;
|
|
|
|
|
2021-12-09 10:01:44 +01:00
|
|
|
/**
|
|
|
|
* A version of #BLI_polyfill_calc that uses a memory arena to avoid re-allocations.
|
|
|
|
*/
|
2013-11-30 11:55:50 +01:00
|
|
|
void BLI_polyfill_calc_arena(const float (*coords)[2],
|
2022-03-30 08:26:42 +02:00
|
|
|
unsigned int coords_num,
|
2022-01-07 01:38:08 +01:00
|
|
|
int coords_sign,
|
2013-11-30 11:55:50 +01:00
|
|
|
unsigned int (*r_tris)[3],
|
|
|
|
|
|
|
|
struct MemArena *arena);
|
|
|
|
|
2021-12-09 10:01:44 +01:00
|
|
|
/**
|
|
|
|
* Triangulates the given (convex or concave) simple polygon to a list of triangle vertices.
|
|
|
|
*
|
|
|
|
* \param coords: 2D coordinates describing vertices of the polygon,
|
|
|
|
* in either clockwise or counterclockwise order.
|
2022-03-30 08:26:42 +02:00
|
|
|
* \param coords_num: Total points in the array.
|
2021-12-09 10:01:44 +01:00
|
|
|
* \param coords_sign: Pass this when we know the sign in advance to avoid extra calculations.
|
|
|
|
*
|
|
|
|
* \param r_tris: This array is filled in with triangle indices in clockwise order.
|
2022-03-30 08:26:42 +02:00
|
|
|
* The length of the array must be `coords_num - 2`.
|
2021-12-09 10:01:44 +01:00
|
|
|
* Indices are guaranteed to be assigned to unique triangles, with valid indices,
|
|
|
|
* even in the case of degenerate input (self intersecting polygons, zero area ears... etc).
|
|
|
|
*/
|
2013-11-30 11:55:50 +01:00
|
|
|
void BLI_polyfill_calc(const float (*coords)[2],
|
2022-03-30 08:26:42 +02:00
|
|
|
unsigned int coords_num,
|
2022-01-07 01:38:08 +01:00
|
|
|
int coords_sign,
|
2013-11-30 11:55:50 +01:00
|
|
|
unsigned int (*r_tris)[3]);
|
|
|
|
|
2014-12-09 12:19:26 +01:00
|
|
|
/* default size of polyfill arena */
|
|
|
|
#define BLI_POLYFILL_ARENA_SIZE MEM_SIZE_OPTIMAL(1 << 14)
|
|
|
|
|
2020-03-02 15:04:53 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|