55 params->shape_info.tmpkey = skey;
92 #define EDGE_PERCENT 2
96 #define FACE_CUSTOMFILL 4
101 #define FLT_FACE_SPLIT_EPSILON 0.00005f
142 return l_new ? l_new->
e :
NULL;
156 const float no_dir[3],
168 float no_mid[3], no_ortho[3];
183 bool center_ok =
false;
186 float plane_a[4], plane_b[4], plane_c[4];
187 float v_a_no_ortho[3], v_b_no_ortho[3];
204 if (center_ok ==
false) {
211 float ofs_a[3], ofs_b[3], ofs_slerp[3];
212 float dist_a, dist_b;
245 else if (
params->use_smooth) {
248 #define USE_SPHERE_DUAL_BLEND
250 const float eps_unit_vec = 1e-5f;
254 #ifdef USE_SPHERE_DUAL_BLEND
255 float no_reflect[3], co_a[3], co_b[3];
261 #ifndef USE_SPHERE_DUAL_BLEND
300 if (
params->use_smooth_even) {
311 #undef USE_SPHERE_DUAL_BLEND
314 if (
params->use_fractal) {
315 float normal[3], co2[3], base1[3], base2[3], tvec[3];
343 if (
params->shape_info.totlayer > 1) {
349 i =
params->shape_info.totlayer - 1;
365 const float factor_edge_split,
366 const float factor_subd,
383 if (edge->v1->f2 & edge->v2->f2 & 1) {
386 if (edge->v1->f2 & edge->v2->f2 & 2) {
389 if (edge->v1->f2 & edge->v2->f2 & 4) {
412 float factor_edge_split, factor_subd;
415 factor_edge_split = BMO_slot_map_float_get(
params->slot_edge_percents, edge);
419 factor_edge_split = 1.0f / (
float)(totpoint + 1 - curpoint);
420 factor_subd = (
float)(curpoint + 1) / (
float)(totpoint + 1);
424 bm, edge, e_orig,
params, factor_edge_split, factor_subd, v_a, v_b, r_edge);
431 BMEdge *eed = edge, *e_new, e_tmp = *edge;
432 BMVert *
v, v1_tmp = *edge->v1, v2_tmp = *edge->v2, *
v1 = edge->v1, *
v2 = edge->v2;
433 int i, numcuts =
params->numcuts;
438 for (i = 0; i < numcuts; i++) {
449 if (
v->
e &&
v->
e->
l) {
481 if ((numcuts % 2) == 0) {
483 for (i = 0; i < numcuts; i++) {
484 if (i == numcuts / 2) {
492 for (i = 0; i < numcuts; i++) {
494 if (i == numcuts / 2) {
524 int i, numcuts =
params->numcuts;
526 for (i = 0; i < numcuts; i++) {
556 int i, numcuts =
params->numcuts;
558 v_last =
verts[numcuts];
560 for (i = numcuts - 1; i >= 0; i--) {
566 if (i != numcuts - 1) {
601 int i, numcuts =
params->numcuts;
603 for (i = 0; i < numcuts; i++) {
633 int i,
add = 0, numcuts =
params->numcuts;
635 for (i = 0; i < numcuts; i++) {
636 if (i == numcuts / 2) {
637 if (numcuts % 2 != 0) {
640 add = numcuts * 2 + 2;
645 for (i = 0; i < numcuts / 2 + 1; i++) {
677 int numcuts =
params->numcuts;
678 int i, j,
a,
b, s = numcuts + 2 ;
680 lines =
MEM_callocN(
sizeof(
BMVert *) * (numcuts + 2) * (numcuts + 2),
"q_4edge_split");
686 for (i = 0; i < numcuts + 2; i++) {
687 lines[i] =
verts[numcuts * 3 + 2 + (numcuts - i + 1)];
691 for (i = 0; i < numcuts + 2; i++) {
692 lines[(s - 1) * s + i] =
verts[numcuts + i];
696 for (i = 0; i < numcuts; i++) {
698 b = numcuts + 1 + numcuts + 1 + (numcuts - i - 1);
709 v2 = lines[(i + 1) * s + s - 1] =
verts[
b];
712 for (
a = 0;
a < numcuts;
a++) {
718 lines[(i + 1) * s +
a + 1] =
v;
722 for (i = 1; i < numcuts + 2; i++) {
723 for (j = 1; j <= numcuts; j++) {
757 int i, numcuts =
params->numcuts;
759 for (i = 0; i < numcuts; i++) {
789 BMVert ***lines, *
v, v1_tmp, v2_tmp;
791 int i, j,
a,
b, numcuts =
params->numcuts;
794 lines =
MEM_callocN(
sizeof(
void *) * (numcuts + 2),
"triangle vert table");
796 lines[0] = (
BMVert **)stackarr;
797 lines[0][0] =
verts[numcuts * 2 + 1];
799 lines[numcuts + 1] =
MEM_callocN(
sizeof(
void *) * (numcuts + 2),
"triangle vert table 2");
800 for (i = 0; i < numcuts; i++) {
801 lines[numcuts + 1][i + 1] =
verts[i];
803 lines[numcuts + 1][0] =
verts[numcuts * 3 + 2];
804 lines[numcuts + 1][numcuts + 1] =
verts[numcuts];
806 for (i = 0; i < numcuts; i++) {
807 lines[i + 1] =
MEM_callocN(
sizeof(
void *) * (2 + i),
"triangle vert table row");
808 a = numcuts * 2 + 2 + i;
809 b = numcuts + numcuts - i;
818 lines[i + 1][0] =
verts[
a];
819 lines[i + 1][i + 1] =
verts[
b];
826 for (j = 0; j < i; j++) {
828 lines[i + 1][j + 1] =
v;
846 for (i = 1; i <= numcuts; i++) {
847 for (j = 0; j < i; j++) {
861 for (i = 1; i < numcuts + 2; i++) {
891 #define PATTERNS_TOT ARRAY_SIZE(patterns)
906 BMIter viter, fiter, liter;
918 float smooth, fractal, along_normal;
919 bool use_sphere, use_single_edge, use_grid_fill, use_only_quads;
920 int cornertype,
seed, i, j,
a,
b, numcuts, totesel, smooth_falloff;
939 switch (cornertype) {
951 if (use_single_edge) {
987 params.smooth_falloff = smooth_falloff;
990 params.along_normal = along_normal;
993 params.use_fractal = (fractal != 0.0f);
994 params.use_sphere = use_sphere;
1014 float vec1[3], vec2[3];
1015 bool matched =
false;
1018 if (use_only_quads && face->
len != 4) {
1032 edges[i] = l_new->
e;
1060 pat = *BMO_slot_map_data_get(
params.slot_custom_patterns, face);
1061 for (i = 0; i < pat->
len; i++) {
1063 for (j = 0; j < pat->
len; j++) {
1064 a = (j + i) % pat->
len;
1093 if (pat->
len == face->
len) {
1094 for (
a = 0;
a < pat->
len;
a++) {
1096 for (
b = 0;
b < pat->
len;
b++) {
1097 j = (
b +
a) % pat->
len;
1122 if (!matched && totesel) {
1139 for (i = 0; i < einput->
len; i++) {
1176 for (
a = 0;
a < vlen;
a++) {
1186 b = (
a + numcuts + 1) % vlen;
1190 for (j = 0; j < vlen; j++) {
1191 b = (j +
a + numcuts + 1) % vlen;
1202 for (j = 0; j < numcuts; j++) {
1220 if (other_loop->
f != face) {
1234 loops_split[j][0] = loops[
a];
1235 loops_split[j][1] = loops[
b];
1238 loops_split[j][0] =
NULL;
1239 loops_split[j][1] =
NULL;
1254 if (loops_split[j][0]) {
1258 bm, face, loops_split[j][0], loops_split[j][1], &l_new,
NULL,
false);
1273 if (l_new->
v == fd->
start) {
1282 b = (j -
a + face->
len) % face->
len;
1319 const char edge_hflag,
1321 const short smooth_falloff,
1322 const bool use_smooth_even,
1323 const float fractal,
1324 const float along_normal,
1327 const int cornertype,
1328 const short use_single_edge,
1329 const short use_grid_fill,
1330 const short use_only_quads,
1339 "subdivide_edges edges=%he "
1340 "smooth=%f smooth_falloff=%i use_smooth_even=%b "
1341 "fractal=%f along_normal=%f "
1343 "quad_corner_type=%i "
1344 "use_single_edge=%b use_grid_fill=%b "
1345 "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
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])
bool interp_v3_v3v3_slerp(float target[3], const float a[3], const float b[3], float t) ATTR_WARN_UNUSED_RESULT
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
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 cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3_length(float r[3], float unit_scale)
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 void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
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_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_hflag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag, bool do_flush)
BMO_FLAG_BUFFER.
#define BMO_edge_flag_test(bm, e, oflag)
void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short 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.
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)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
#define BMO_vert_flag_test(bm, e, oflag)
bool BMO_op_initf(BMesh *bm, BMOperator *op, int flag, const char *fmt,...)
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)
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
SyclQueue void void size_t num_bytes void
IconTextureDrawCall normal
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
bool add(void *owner, const AttributeIDRef &attribute_id, eAttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
smooth(Type::FLOAT, "mask_weight")
union BMOpSlot::@145 data
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
BMOpSlot * slot_custom_patterns
struct SubDParams::@166 shape_info
int cd_vert_shape_offset_tmp
BMOpSlot * slot_edge_percents
subd_pattern_fill_fp connectexec