39 #define BARYCENTRIC_INTERP
41 #ifdef BARYCENTRIC_INTERP
66 const float co_a_next[3],
67 const float co_b_next[3],
69 const float co_a_prev[3],
70 const float co_b_prev[3],
109 if (
e->l->v == v_a) {
111 l_pair[1] =
e->l->next;
114 l_pair[0] =
e->l->next;
132 if (l_pair_a[0] && l_pair_b[0] ==
NULL) {
133 l_pair_b[0] = l_pair_a[1];
134 l_pair_b[1] = l_pair_a[0];
136 else if (l_pair_b[0] && l_pair_a[0] ==
NULL) {
137 l_pair_a[0] = l_pair_b[1];
138 l_pair_a[1] = l_pair_b[0];
152 const void *l_cdata[4] = {
165 const float w[2] = {1.0f -
t,
t};
177 float (*weight_table)[4])
179 float x_step = 1.0f / (
float)(xtot - 1);
180 float y_step = 1.0f / (
float)(ytot - 1);
185 for (
y = 0;
y < ytot;
y++) {
186 xy_fl[1] = y_step * (
float)
y;
187 for (
x = 0;
x < xtot;
x++) {
188 xy_fl[0] = x_step * (
float)
x;
190 const float cos[4][2] = {
191 {xy_fl[0], 0.0f}, {0.0f, xy_fl[1]}, {xy_fl[0], 1.0f}, {1.0f, xy_fl[1]}};
208 const bool use_smooth,
210 const bool use_interp_simple)
217 BMLoop *((*larr_x_a)[2]), *((*larr_x_b)[2]), *((*larr_y_a)[2]), *((*larr_y_b)[2]);
219 float(*weight_table)[4];
221 #define XY(_x, _y) ((_x) + ((_y) * (xtot)))
223 #ifdef BARYCENTRIC_INTERP
229 v_grid[
XY(0, 0)]->co,
230 v_grid[
XY(xtot - 1, 0)]->co,
231 v_grid[
XY(0, 1)]->co,
232 v_grid[
XY(xtot - 1, 1)]->co,
238 v_grid[
XY(0, (ytot - 1))]->co,
239 v_grid[
XY(xtot - 1, (ytot - 1))]->co,
240 v_grid[
XY(0, (ytot - 2))]->co,
241 v_grid[
XY(xtot - 1, (ytot - 2))]->co,
247 if (use_interp_simple || use_vert_interp || use_loop_interp) {
248 weight_table =
MEM_mallocN(
sizeof(*weight_table) * (
size_t)(xtot * ytot), __func__);
256 if (use_loop_interp) {
258 larr_x_a =
MEM_mallocN(
sizeof(*larr_x_a) * (xtot - 1), __func__);
259 larr_x_b =
MEM_mallocN(
sizeof(*larr_x_b) * (xtot - 1), __func__);
261 larr_y_a =
MEM_mallocN(
sizeof(*larr_y_a) * (ytot - 1), __func__);
262 larr_y_b =
MEM_mallocN(
sizeof(*larr_y_b) * (ytot - 1), __func__);
265 for (
x = 0;
x < xtot - 1;
x++) {
271 for (
y = 0;
y < ytot - 1;
y++) {
279 for (
y = 1;
y < ytot - 1;
y++) {
280 #ifdef BARYCENTRIC_INTERP
282 v_grid[
XY(0,
y + 0)]->co,
283 v_grid[
XY(xtot - 1,
y + 0)]->co,
284 v_grid[
XY(0,
y + 1)]->co,
285 v_grid[
XY(xtot - 1,
y + 1)]->co,
286 v_grid[
XY(0,
y - 1)]->co,
287 v_grid[
XY(xtot - 1,
y - 1)]->co,
290 for (
x = 1;
x < xtot - 1;
x++) {
297 #ifdef BARYCENTRIC_INTERP
298 if (use_interp_simple ==
false) {
299 float co_a[3], co_b[3];
302 co_a, v_grid[
x]->co, tri_t[0], tri_t[1], tri_t[2], tri_a[0], tri_a[1], tri_a[2]);
304 v_grid[(xtot * ytot) + (
x - xtot)]->co,
317 const float *
w = weight_table[
XY(
x,
y)];
327 v_grid[(
y * xtot) +
x] =
v;
331 if (use_vert_interp) {
332 const float *
w = weight_table[
XY(
x,
y)];
334 const void *v_cdata[4] = {
347 for (
x = 0;
x < xtot - 1;
x++) {
348 for (
y = 0;
y < ytot - 1;
y++) {
353 v_grid[
XY(
x,
y + 0)],
354 v_grid[
XY(
x,
y + 1)],
355 v_grid[
XY(
x + 1,
y + 1)],
356 v_grid[
XY(
x + 1,
y + 0)],
362 v_grid[
XY(
x + 1,
y + 0)],
363 v_grid[
XY(
x + 1,
y + 1)],
364 v_grid[
XY(
x,
y + 1)],
365 v_grid[
XY(
x,
y + 0)],
370 if (use_loop_interp && (larr_x_a[
x][0] || larr_y_a[
y][0])) {
375 uint x_side, y_side, i;
378 if (larr_x_a[
x][0] && larr_y_a[
y][0]) {
380 l_tmp = larr_x_a[
x][0];
382 else if (larr_x_a[
x][0]) {
384 l_tmp = larr_x_a[
x][0];
388 l_tmp = larr_y_a[
y][0];
418 for (x_side = 0; x_side < 2; x_side++) {
419 for (y_side = 0; y_side < 2; y_side++) {
420 if (interp_from ==
'B') {
421 const float *
w = weight_table[
XY(
x + x_side,
y + y_side)];
422 l_bound[0] = larr_x_a[
x][x_side];
423 l_bound[1] = larr_y_a[
y][y_side];
424 l_bound[2] = larr_x_b[
x][x_side];
425 l_bound[3] = larr_y_b[
y][y_side];
429 else if (interp_from ==
'X') {
430 const float t = (
float)(
y + y_side) / (
float)(ytot - 1);
431 l_bound[0] = larr_x_a[
x][x_side];
432 l_bound[1] = larr_x_b[
x][x_side];
436 else if (interp_from ==
'Y') {
437 const float t = (
float)(
x + x_side) / (
float)(xtot - 1);
438 l_bound[0] = larr_y_a[
y][y_side];
439 l_bound[1] = larr_y_b[
y][y_side];
459 if (use_loop_interp) {
479 const bool use_smooth,
480 const bool use_interp_simple)
482 #define USE_FLIP_DETECT
492 bool use_flip =
false;
523 for (el = lb_a->
first, i = 0; el; el = el->
next, i++) {
524 v_grid[i] = el->
data;
526 for (el = lb_b->
first, i = 0; el; el = el->
next, i++) {
527 v_grid[(ytot * xtot) + (i - xtot)] = el->
data;
529 for (el = lb_rail_a->
first, i = 0; el; el = el->
next, i++) {
530 v_grid[xtot * i] = el->
data;
532 for (el = lb_rail_b->
first, i = 0; el; el = el->
next, i++) {
533 v_grid[(xtot * i) + (xtot - 1)] = el->
data;
536 for (
x = 1;
x < xtot - 1;
x++) {
537 for (
y = 1;
y < ytot - 1;
y++) {
543 #ifdef USE_FLIP_DETECT
545 ListBase *lb_iter[4] = {lb_a, lb_b, lb_rail_a, lb_rail_b};
546 const int lb_iter_dir[4] = {-1, 1, 1, -1};
547 int winding_votes = 0;
549 for (i = 0; i < 4; i++) {
551 for (el = lb_iter[i]->first; el && (el_next = el->
next); el = el->
next) {
554 winding_votes += (
e->l->v == el->data) ? lb_iter_dir[i] : -lb_iter_dir[i];
558 use_flip = (winding_votes < 0);
565 #undef USE_FLIP_DETECT
603 BMVert *v_a_first, *v_a_last;
604 BMVert *v_b_first, *v_b_last;
611 bool changed =
false;
623 "Select two edge loops "
624 "or a single closed edge loop from which two edge loops can be calculated");
628 estore_a = eloops.
first;
629 estore_b = eloops.
last;
652 estore_rail_a = eloops_rail.
first;
653 estore_rail_b = eloops_rail.
last;
662 estore_rail_a = eloops_rail.
first;
663 estore_rail_b = eloops_rail.
last;
691 {estore_a, estore_b},
692 {estore_rail_a, estore_rail_b},
696 for (i = 0; i < 2; i++) {
699 if (len_a != len_b) {
700 if (split_edges ==
NULL) {
716 bm, estore_a, estore_b, estore_rail_a, estore_rail_b, mat_nr, use_smooth, use_interp_simple);
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
bool CustomData_has_interp(const struct CustomData *data)
void CustomData_bmesh_interp(struct CustomData *data, const void **src_blocks, const float *weights, const float *sub_weights, int count, void *dst_block)
GSet * BLI_gset_ptr_new(const char *info)
#define GSET_ITER(gs_iter_, gset_)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
BLI_INLINE void * BLI_gsetIterator_getKey(GSetIterator *gsi)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void transform_point_by_tri_v3(float pt_tar[3], float const pt_src[3], const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3])
void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const float v3[2], const float v4[2], const float co[2], float w[4])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src, void *ele_dst)
BMFace * BM_face_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, const BMFace *f_example, const eBMCreateFlag create_flag)
Make Quad/Triangle.
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
void BM_edgeloop_expand(BMesh *bm, BMEdgeLoopStore *el_store, int el_store_len, bool split, GSet *split_edges)
void BM_mesh_edgeloops_free(ListBase *eloops)
int BM_mesh_edgeloops_find(BMesh *bm, ListBase *r_eloops, bool(*test_fn)(BMEdge *, void *user_data), void *user_data)
bool BM_mesh_edgeloops_find_path(BMesh *bm, ListBase *r_eloops, bool(*test_fn)(BMEdge *, void *user_data), void *user_data, BMVert *v_src, BMVert *v_dst)
int BM_edgeloop_length_get(BMEdgeLoopStore *el_store)
bool BM_edgeloop_is_closed(BMEdgeLoopStore *el_store)
ListBase * BM_edgeloop_verts_get(BMEdgeLoopStore *el_store)
bool BM_edgeloop_overlap_check(struct BMEdgeLoopStore *el_store_a, struct BMEdgeLoopStore *el_store_b)
void BM_edgeloop_flip(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store)
@ BMERR_INVALID_SELECTION
void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg)
#define BM_elem_flag_set(ele, hflag, val)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
ATTR_WARN_UNUSED_RESULT BMesh * bm
BMVert * BM_edge_collapse(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool do_del, const bool kill_degenerate_faces)
void BMO_slot_buffer_flag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag)
BMO_FLAG_BUFFER.
#define BMO_edge_flag_test_bool(bm, e, oflag)
#define BMO_face_flag_enable(bm, e, oflag)
int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag)
bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void BM_face_as_array_loop_quad(BMFace *f, BMLoop *r_loops[4])
BMEdge * BM_edge_exists(BMVert *v_a, BMVert *v_b)
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
static void bm_loop_interp_from_grid_boundary_2(BMesh *bm, BMLoop *l, BMLoop *l_bound[2], const float t)
static void bm_loop_interp_from_grid_boundary_4(BMesh *bm, BMLoop *l, BMLoop *l_bound[4], const float w[4])
static void barycentric_weights_v2_grid_cache(const uint xtot, const uint ytot, float(*weight_table)[4])
static void bm_grid_fill_array(BMesh *bm, BMVert **v_grid, const uint xtot, const uint ytot, const short mat_nr, const bool use_smooth, const bool use_flip, const bool use_interp_simple)
static void bm_loop_pair_from_verts(BMVert *v_a, BMVert *v_b, BMLoop *l_pair[2])
static void quad_verts_to_barycentric_tri(float tri[3][3], const float co_a[3], const float co_b[3], const float co_a_next[3], const float co_b_next[3], const float co_a_prev[3], const float co_b_prev[3], const bool is_flip)
static void bm_loop_pair_test_copy(BMLoop *l_pair_a[2], BMLoop *l_pair_b[2])
static bool bm_edge_test_cb(BMEdge *e, void *bm_v)
void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
static bool bm_edge_test_rail_cb(BMEdge *e, void *UNUSED(bm_v))
static void bm_grid_fill(BMesh *bm, struct BMEdgeLoopStore *estore_a, struct BMEdgeLoopStore *estore_b, struct BMEdgeLoopStore *estore_rail_a, struct BMEdgeLoopStore *estore_rail_b, const short mat_nr, const bool use_smooth, const bool use_interp_simple)
static void bm_edgeloop_flag_set(struct BMEdgeLoopStore *estore, char hflag, bool set)
static void quad_edges_to_normal(float no[3], const float co_a1[3], const float co_a2[3], const float co_b1[3], const float co_b2[3])
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]