69 params->shape_info.tmpkey = skey;
106 #define EDGE_PERCENT 2
110 #define FACE_CUSTOMFILL 4
115 #define FLT_FACE_SPLIT_EPSILON 0.00005f
156 return l_new ? l_new->
e :
NULL;
170 const float no_dir[3],
182 float no_mid[3], no_ortho[3];
197 bool center_ok =
false;
200 float plane_a[4], plane_b[4], plane_c[4];
201 float v_a_no_ortho[3], v_b_no_ortho[3];
218 if (center_ok ==
false) {
225 float ofs_a[3], ofs_b[3], ofs_slerp[3];
226 float dist_a, dist_b;
259 else if (
params->use_smooth) {
262 #define USE_SPHERE_DUAL_BLEND
264 const float eps_unit_vec = 1e-5f;
268 #ifdef USE_SPHERE_DUAL_BLEND
269 float no_reflect[3], co_a[3], co_b[3];
275 #ifndef USE_SPHERE_DUAL_BLEND
310 smooth =
fabsf(1.0f - 2.0f *
fabsf(0.5f - perc));
314 if (
params->use_smooth_even) {
319 if (smooth != 1.0f) {
325 #undef USE_SPHERE_DUAL_BLEND
328 if (
params->use_fractal) {
329 float normal[3], co2[3], base1[3], base2[3], tvec[3];
357 if (
params->shape_info.totlayer > 1) {
363 i =
params->shape_info.totlayer - 1;
379 const float factor_edge_split,
380 const float factor_subd,
397 if (edge->
v1->f2 & edge->
v2->f2 & 1) {
400 if (edge->
v1->f2 & edge->
v2->f2 & 2) {
403 if (edge->
v1->f2 & edge->
v2->f2 & 4) {
426 float factor_edge_split, factor_subd;
429 factor_edge_split = BMO_slot_map_float_get(
params->slot_edge_percents, edge);
433 factor_edge_split = 1.0f / (
float)(totpoint + 1 - curpoint);
434 factor_subd = (
float)(curpoint + 1) / (
float)(totpoint + 1);
438 bm, edge, e_orig,
params, factor_edge_split, factor_subd, v_a, v_b, r_edge);
445 BMEdge *eed = edge, *e_new, e_tmp = *edge;
447 int i, numcuts =
params->numcuts;
452 for (i = 0; i < numcuts; i++) {
463 if (
v->
e &&
v->
e->
l) {
495 if ((numcuts % 2) == 0) {
497 for (i = 0; i < numcuts; i++) {
498 if (i == numcuts / 2) {
506 for (i = 0; i < numcuts; i++) {
508 if (i == numcuts / 2) {
538 int i, numcuts =
params->numcuts;
540 for (i = 0; i < numcuts; i++) {
570 int i, numcuts =
params->numcuts;
572 v_last =
verts[numcuts];
574 for (i = numcuts - 1; i >= 0; i--) {
580 if (i != numcuts - 1) {
615 int i, numcuts =
params->numcuts;
617 for (i = 0; i < numcuts; i++) {
647 int i,
add = 0, numcuts =
params->numcuts;
649 for (i = 0; i < numcuts; i++) {
650 if (i == numcuts / 2) {
651 if (numcuts % 2 != 0) {
654 add = numcuts * 2 + 2;
659 for (i = 0; i < numcuts / 2 + 1; i++) {
691 int numcuts =
params->numcuts;
692 int i, j,
a, b, s = numcuts + 2 ;
694 lines =
MEM_callocN(
sizeof(
BMVert *) * (numcuts + 2) * (numcuts + 2),
"q_4edge_split");
700 for (i = 0; i < numcuts + 2; i++) {
701 lines[i] =
verts[numcuts * 3 + 2 + (numcuts - i + 1)];
705 for (i = 0; i < numcuts + 2; i++) {
706 lines[(s - 1) * s + i] =
verts[numcuts + i];
710 for (i = 0; i < numcuts; i++) {
712 b = numcuts + 1 + numcuts + 1 + (numcuts - i - 1);
723 v2 = lines[(i + 1) * s + s - 1] =
verts[b];
726 for (
a = 0;
a < numcuts;
a++) {
732 lines[(i + 1) * s +
a + 1] =
v;
736 for (i = 1; i < numcuts + 2; i++) {
737 for (j = 1; j <= numcuts; j++) {
771 int i, numcuts =
params->numcuts;
773 for (i = 0; i < numcuts; i++) {
803 BMVert ***lines, *
v, v1_tmp, v2_tmp;
805 int i, j,
a, b, numcuts =
params->numcuts;
808 lines =
MEM_callocN(
sizeof(
void *) * (numcuts + 2),
"triangle vert table");
810 lines[0] = (
BMVert **)stackarr;
811 lines[0][0] =
verts[numcuts * 2 + 1];
813 lines[numcuts + 1] =
MEM_callocN(
sizeof(
void *) * (numcuts + 2),
"triangle vert table 2");
814 for (i = 0; i < numcuts; i++) {
815 lines[numcuts + 1][i + 1] =
verts[i];
817 lines[numcuts + 1][0] =
verts[numcuts * 3 + 2];
818 lines[numcuts + 1][numcuts + 1] =
verts[numcuts];
820 for (i = 0; i < numcuts; i++) {
821 lines[i + 1] =
MEM_callocN(
sizeof(
void *) * (2 + i),
"triangle vert table row");
822 a = numcuts * 2 + 2 + i;
823 b = numcuts + numcuts - i;
832 lines[i + 1][0] =
verts[
a];
833 lines[i + 1][i + 1] =
verts[b];
840 for (j = 0; j < i; j++) {
842 lines[i + 1][j + 1] =
v;
860 for (i = 1; i <= numcuts; i++) {
861 for (j = 0; j < i; j++) {
875 for (i = 1; i < numcuts + 2; i++) {
905 #define PATTERNS_TOT ARRAY_SIZE(patterns)
920 BMIter viter, fiter, liter;
932 float smooth, fractal, along_normal;
933 bool use_sphere, use_single_edge, use_grid_fill, use_only_quads;
934 int cornertype,
seed, i, j,
a, b, numcuts, totesel, smooth_falloff;
953 switch (cornertype) {
965 if (use_single_edge) {
1001 params.smooth_falloff = smooth_falloff;
1003 params.fractal = fractal;
1004 params.along_normal = along_normal;
1005 params.use_smooth = (smooth != 0.0f);
1007 params.use_fractal = (fractal != 0.0f);
1008 params.use_sphere = use_sphere;
1010 if (
params.use_fractal) {
1028 float vec1[3], vec2[3];
1029 bool matched =
false;
1032 if (use_only_quads && face->
len != 4) {
1046 edges[i] = l_new->
e;
1074 pat = *BMO_slot_map_data_get(
params.slot_custom_patterns, face);
1075 for (i = 0; i < pat->
len; i++) {
1077 for (j = 0; j < pat->
len; j++) {
1078 a = (j + i) % pat->
len;
1107 if (pat->
len == face->
len) {
1108 for (
a = 0;
a < pat->
len;
a++) {
1110 for (b = 0; b < pat->
len; b++) {
1111 j = (b +
a) % pat->
len;
1136 if (!matched && totesel) {
1153 for (i = 0; i < einput->
len; i++) {
1190 for (
a = 0;
a < vlen;
a++) {
1200 b = (
a + numcuts + 1) % vlen;
1204 for (j = 0; j < vlen; j++) {
1205 b = (j +
a + numcuts + 1) % vlen;
1216 for (j = 0; j < numcuts; j++) {
1234 if (other_loop->
f != face) {
1248 loops_split[j][0] = loops[
a];
1249 loops_split[j][1] = loops[b];
1252 loops_split[j][0] =
NULL;
1253 loops_split[j][1] =
NULL;
1268 if (loops_split[j][0]) {
1272 bm, face, loops_split[j][0], loops_split[j][1], &l_new,
NULL,
false);
1287 if (l_new->
v == fd->
start) {
1296 b = (j -
a + face->
len) % face->
len;
1333 const char edge_hflag,
1335 const short smooth_falloff,
1336 const bool use_smooth_even,
1337 const float fractal,
1338 const float along_normal,
1341 const int cornertype,
1342 const short use_single_edge,
1343 const short use_grid_fill,
1344 const short use_only_quads,
1353 "subdivide_edges edges=%he "
1354 "smooth=%f smooth_falloff=%i use_smooth_even=%b "
1355 "fractal=%f along_normal=%f "
1357 "quad_corner_type=%i "
1358 "use_single_edge=%b use_grid_fill=%b "
1359 "use_only_quads=%b "
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
int CustomData_number_of_layers(const struct CustomData *data, int type)
int CustomData_get_n_offset(const struct CustomData *data, int type, int n)
int CustomData_get_offset(const struct CustomData *data, int type)
A (mainly) macro array library.
#define BLI_array_grow_items(arr, num)
#define BLI_array_declare(arr)
#define BLI_array_len(arr)
#define BLI_array_clear(arr)
#define BLI_array_free(arr)
MINLINE float interpf(float a, float b, float t)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3])
bool isect_plane_plane_plane_v3(const float plane_a[4], const float plane_b[4], const float plane_c[4], float r_isect_co[3]) ATTR_WARN_UNUSED_RESULT
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)
void reflect_v3_v3v3(float out[3], const float vec[3], const float normal[3])
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void project_v3_plane(float out[3], const float plane_no[3], const float plane_co[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
MINLINE float normalize_v3_length(float r[3], const float unit_scale)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
bool interp_v3_v3v3_slerp(float target[3], const float a[3], const float b[3], const float t) ATTR_WARN_UNUSED_RESULT
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
struct RNG * BLI_rng_new_srandom(unsigned int seed)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_stack_push_r(BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void * BLI_stack_peek(BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_stack_free(BLI_Stack *stack) ATTR_NONNULL()
void BLI_stack_discard(BLI_Stack *stack) ATTR_NONNULL()
#define BLI_stack_new(esize, descr)
NSNotificationCenter * center
_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 v1
Read Guarded memory(de)allocation.
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n)
void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_select_flush(BMesh *bm)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
BMVert * BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float fac)
Edge Split.
BMFace * BM_face_split(BMesh *bm, BMFace *f, BMLoop *l_a, BMLoop *l_b, BMLoop **r_l, BMEdge *example, const bool no_double)
Face Split.
void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const bool do_flush)
BMO_FLAG_BUFFER.
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.
void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag)
#define BMO_edge_flag_test(bm, e, oflag)
#define BMO_edge_flag_enable(bm, e, oflag)
float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
#define BMO_vert_flag_enable(bm, e, oflag)
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
bool BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt,...)
#define BMO_face_flag_enable(bm, e, oflag)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
#define BMO_vert_flag_test(bm, e, oflag)
int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void BMO_op_finish(BMesh *bm, BMOperator *op)
BMESH OPSTACK FINISH OP.
BMOpSlot * BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK GET SLOT.
#define BMO_FLAG_DEFAULTS
#define BMO_face_flag_test(bm, e, oflag)
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)
#define BM_CHECK_ELEMENT(el)
BMEdge * BM_edge_exists(BMVert *v_a, BMVert *v_b)
float bmesh_subd_falloff_calc(const int falloff, float val)
bool BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2)
bool BM_vert_in_face(BMVert *v, BMFace *f)
BMFace * BM_vert_pair_share_face_by_len(BMVert *v_a, BMVert *v_b, BMLoop **r_l_a, BMLoop **r_l_b, const bool allow_adjacent)
BLI_INLINE bool BM_loop_is_adjacent(const BMLoop *l_a, const BMLoop *l_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, const float smooth, const short smooth_falloff, const bool use_smooth_even, const float fractal, const float along_normal, const int numcuts, const int seltype, const int cornertype, const short use_single_edge, const short use_grid_fill, const short use_only_quads, const int seed)
static BMEdge * connect_smallest_face(BMesh *bm, BMVert *v_a, BMVert *v_b, BMFace **r_f_new)
static BMVert * subdivide_edge_num(BMesh *bm, BMEdge *edge, BMEdge *e_orig, int curpoint, int totpoint, const SubDParams *params, BMVert *v_a, BMVert *v_b, BMEdge **r_edge)
static void interp_slerp_co_no_v3(const float co_a[3], const float no_a[3], const float co_b[3], const float no_b[3], const float no_dir[3], float fac, float r_co[3])
static const SubDPattern quad_1edge
struct SubDParams SubDParams
static const SubDPattern * patterns[]
#define FLT_FACE_SPLIT_EPSILON
void(* subd_pattern_fill_fp)(BMesh *bm, BMFace *face, BMVert **verts, const SubDParams *params)
struct SubDPattern SubDPattern
static const SubDPattern quad_2edge_fan
static const SubDPattern quad_4edge
static void tri_1edge_split(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static const SubDPattern quad_3edge
static void alter_co(BMVert *v, BMEdge *UNUSED(e_orig), const SubDParams *params, const float perc, const BMVert *v_a, const BMVert *v_b)
struct SubDFaceData SubDFaceData
static const SubDPattern quad_2edge_path
void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
static BMVert * bm_subdivide_edge_addvert(BMesh *bm, BMEdge *edge, BMEdge *e_orig, const SubDParams *params, const float factor_edge_split, const float factor_subd, BMVert *v_a, BMVert *v_b, BMEdge **r_edge)
void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op)
static void quad_3edge_split(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static void quad_2edge_split_innervert(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static void quad_1edge_split(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static void quad_2edge_split_fan(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static const SubDPattern tri_1edge
static void bmo_subd_init_shape_info(BMesh *bm, SubDParams *params)
static const SubDPattern tri_3edge
static const SubDPattern quad_2edge_innervert
static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, const SubDParams *params, BMVert *v_a, BMVert *v_b)
static void quad_2edge_split_path(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const SubDParams *params)
static unsigned long seed
IconTextureDrawCall normal
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static void add(GHash *messages, MemArena *memarena, const Message *msg)
union BMOpSlot::@139 data
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
BMOpSlot * slot_custom_patterns
int cd_vert_shape_offset_tmp
struct SubDParams::@160 shape_info
BMOpSlot * slot_edge_percents
subd_pattern_fill_fp connectexec