25 #define BARYCENTRIC_INTERP
27 #ifdef BARYCENTRIC_INTERP
52 const float co_a_next[3],
53 const float co_b_next[3],
55 const float co_a_prev[3],
56 const float co_b_prev[3],
97 l_pair[1] =
e->l->next;
100 l_pair[0] =
e->l->next;
118 if (l_pair_a[0] && l_pair_b[0] ==
NULL) {
119 l_pair_b[0] = l_pair_a[1];
120 l_pair_b[1] = l_pair_a[0];
122 else if (l_pair_b[0] && l_pair_a[0] ==
NULL) {
123 l_pair_a[0] = l_pair_b[1];
124 l_pair_a[1] = l_pair_b[0];
138 const void *l_cdata[4] = {
151 const float w[2] = {1.0f -
t,
t};
163 float (*weight_table)[4])
165 float x_step = 1.0f / (
float)(xtot - 1);
166 float y_step = 1.0f / (
float)(ytot - 1);
171 for (
y = 0;
y < ytot;
y++) {
172 xy_fl[1] = y_step * (
float)
y;
173 for (
x = 0;
x < xtot;
x++) {
174 xy_fl[0] = x_step * (
float)
x;
176 const float cos[4][2] = {
177 {xy_fl[0], 0.0f}, {0.0f, xy_fl[1]}, {xy_fl[0], 1.0f}, {1.0f, xy_fl[1]}};
194 const bool use_smooth,
196 const bool use_interp_simple)
203 BMLoop *((*larr_x_a)[2]), *((*larr_x_b)[2]), *((*larr_y_a)[2]), *((*larr_y_b)[2]);
205 float(*weight_table)[4];
207 #define XY(_x, _y) ((_x) + ((_y) * (xtot)))
209 #ifdef BARYCENTRIC_INTERP
215 v_grid[
XY(0, 0)]->co,
216 v_grid[
XY(xtot - 1, 0)]->co,
217 v_grid[
XY(0, 1)]->co,
218 v_grid[
XY(xtot - 1, 1)]->co,
224 v_grid[
XY(0, (ytot - 1))]->co,
225 v_grid[
XY(xtot - 1, (ytot - 1))]->co,
226 v_grid[
XY(0, (ytot - 2))]->co,
227 v_grid[
XY(xtot - 1, (ytot - 2))]->co,
233 if (use_interp_simple || use_vert_interp || use_loop_interp) {
234 weight_table =
MEM_mallocN(
sizeof(*weight_table) * (
size_t)(xtot * ytot), __func__);
242 if (use_loop_interp) {
244 larr_x_a =
MEM_mallocN(
sizeof(*larr_x_a) * (xtot - 1), __func__);
245 larr_x_b =
MEM_mallocN(
sizeof(*larr_x_b) * (xtot - 1), __func__);
247 larr_y_a =
MEM_mallocN(
sizeof(*larr_y_a) * (ytot - 1), __func__);
248 larr_y_b =
MEM_mallocN(
sizeof(*larr_y_b) * (ytot - 1), __func__);
251 for (
x = 0;
x < xtot - 1;
x++) {
257 for (
y = 0;
y < ytot - 1;
y++) {
265 for (
y = 1;
y < ytot - 1;
y++) {
266 #ifdef BARYCENTRIC_INTERP
268 v_grid[
XY(0,
y + 0)]->co,
269 v_grid[
XY(xtot - 1,
y + 0)]->co,
270 v_grid[
XY(0,
y + 1)]->co,
271 v_grid[
XY(xtot - 1,
y + 1)]->co,
272 v_grid[
XY(0,
y - 1)]->co,
273 v_grid[
XY(xtot - 1,
y - 1)]->co,
276 for (
x = 1;
x < xtot - 1;
x++) {
283 #ifdef BARYCENTRIC_INTERP
284 if (use_interp_simple ==
false) {
285 float co_a[3], co_b[3];
288 co_a, v_grid[
x]->co, tri_t[0], tri_t[1], tri_t[2], tri_a[0], tri_a[1], tri_a[2]);
290 v_grid[(xtot * ytot) + (
x - xtot)]->co,
303 const float *
w = weight_table[
XY(
x,
y)];
313 v_grid[(
y * xtot) +
x] =
v;
317 if (use_vert_interp) {
318 const float *
w = weight_table[
XY(
x,
y)];
320 const void *v_cdata[4] = {
333 for (
x = 0;
x < xtot - 1;
x++) {
334 for (
y = 0;
y < ytot - 1;
y++) {
339 v_grid[
XY(
x,
y + 0)],
340 v_grid[
XY(
x,
y + 1)],
341 v_grid[
XY(
x + 1,
y + 1)],
342 v_grid[
XY(
x + 1,
y + 0)],
348 v_grid[
XY(
x + 1,
y + 0)],
349 v_grid[
XY(
x + 1,
y + 1)],
350 v_grid[
XY(
x,
y + 1)],
351 v_grid[
XY(
x,
y + 0)],
356 if (use_loop_interp && (larr_x_a[
x][0] || larr_y_a[
y][0])) {
361 uint x_side, y_side, i;
364 if (larr_x_a[
x][0] && larr_y_a[
y][0]) {
366 l_tmp = larr_x_a[
x][0];
368 else if (larr_x_a[
x][0]) {
370 l_tmp = larr_x_a[
x][0];
374 l_tmp = larr_y_a[
y][0];
404 for (x_side = 0; x_side < 2; x_side++) {
405 for (y_side = 0; y_side < 2; y_side++) {
406 if (interp_from ==
'B') {
407 const float *
w = weight_table[
XY(
x + x_side,
y + y_side)];
408 l_bound[0] = larr_x_a[
x][x_side];
409 l_bound[1] = larr_y_a[
y][y_side];
410 l_bound[2] = larr_x_b[
x][x_side];
411 l_bound[3] = larr_y_b[
y][y_side];
415 else if (interp_from ==
'X') {
416 const float t = (
float)(
y + y_side) / (
float)(ytot - 1);
417 l_bound[0] = larr_x_a[
x][x_side];
418 l_bound[1] = larr_x_b[
x][x_side];
422 else if (interp_from ==
'Y') {
423 const float t = (
float)(
x + x_side) / (
float)(xtot - 1);
424 l_bound[0] = larr_y_a[
y][y_side];
425 l_bound[1] = larr_y_b[
y][y_side];
445 if (use_loop_interp) {
465 const bool use_smooth,
466 const bool use_interp_simple)
468 #define USE_FLIP_DETECT
478 bool use_flip =
false;
509 for (el = lb_a->
first, i = 0; el; el = el->
next, i++) {
510 v_grid[i] = el->
data;
512 for (el = lb_b->
first, i = 0; el; el = el->
next, i++) {
513 v_grid[(ytot * xtot) + (i - xtot)] = el->
data;
515 for (el = lb_rail_a->
first, i = 0; el; el = el->
next, i++) {
516 v_grid[xtot * i] = el->
data;
518 for (el = lb_rail_b->
first, i = 0; el; el = el->
next, i++) {
519 v_grid[(xtot * i) + (xtot - 1)] = el->
data;
522 for (
x = 1;
x < xtot - 1;
x++) {
523 for (
y = 1;
y < ytot - 1;
y++) {
529 #ifdef USE_FLIP_DETECT
531 ListBase *lb_iter[4] = {lb_a, lb_b, lb_rail_a, lb_rail_b};
532 const int lb_iter_dir[4] = {-1, 1, 1, -1};
533 int winding_votes = 0;
535 for (i = 0; i < 4; i++) {
537 for (el = lb_iter[i]->first; el && (el_next = el->
next); el = el->
next) {
540 winding_votes += (
e->l->v == el->data) ? lb_iter_dir[i] : -lb_iter_dir[i];
544 use_flip = (winding_votes < 0);
551 #undef USE_FLIP_DETECT
589 BMVert *v_a_first, *v_a_last;
590 BMVert *v_b_first, *v_b_last;
597 bool changed =
false;
609 "Select two edge loops "
610 "or a single closed edge loop from which two edge loops can be calculated");
614 estore_a = eloops.
first;
615 estore_b = eloops.
last;
638 estore_rail_a = eloops_rail.
first;
639 estore_rail_b = eloops_rail.
last;
648 estore_rail_a = eloops_rail.
first;
649 estore_rail_b = eloops_rail.
last;
676 {estore_a, estore_b},
677 {estore_rail_a, estore_rail_b},
681 for (i = 0; i < 2; i++) {
684 if (len_a != len_b) {
685 if (split_edges ==
NULL) {
701 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])
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])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
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)
void BMO_error_raise(BMesh *bm, BMOperator *owner, eBMOpErrorLevel level, const char *msg) ATTR_NONNULL(1
#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)
#define BMO_edge_flag_test_bool(bm, e, oflag)
void BMO_slot_buffer_flag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short oflag)
BMO_FLAG_BUFFER.
void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short 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)
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]