43#define USE_ACCUM_NORMAL
45#define MBALL_ARRAY_LEN_INIT 4096
168 uint i = start, j = end - 1;
172 while (i < j && div > (mainb[i]->bb->vec[6][s] + mainb[i]->
bb->
vec[0][s])) {
175 while (j > i && div < (mainb[j]->bb->vec[6][s] + mainb[j]->
bb->
vec[0][s])) {
183 std::swap(mainb[i], mainb[j]);
207 dim[0] = allbox->
max[0] - allbox->
min[0];
208 dim[1] = allbox->
max[1] - allbox->
min[1];
209 dim[2] = allbox->
max[2] - allbox->
min[2];
212 if (dim[1] > dim[0] && dim[1] > dim[2]) {
215 else if (dim[2] > dim[1] && dim[2] > dim[0]) {
219 div = allbox->
min[s] + (dim[s] / 2.0f);
224 node->
child[0] =
nullptr;
226 if (part > start + 1) {
227 for (j = start; j < part; j++) {
236 node->
child[1] =
nullptr;
240 if (part < end - 1) {
241 for (j = part; j < end; j++) {
292#define HASHSIZE size_t(1 << (3 * HASHBIT))
294#define HASH(i, j, k) ((((((i) & 31) << 5) | ((j) & 31)) << 5) | ((k) & 31))
296#define MB_BIT(i, bit) (((i) >> (bit)) & 1)
312 float dvec[3] = {
x,
y,
z};
316 switch (ball->
type) {
321 if (dvec[2] > ball->
expz) {
322 dvec[2] -= ball->
expz;
324 else if (dvec[2] < -ball->
expz) {
325 dvec[2] += ball->
expz;
332 if (dvec[1] > ball->
expy) {
333 dvec[1] -= ball->
expy;
335 else if (dvec[1] < -ball->
expy) {
336 dvec[1] += ball->
expy;
343 if (dvec[0] > ball->
expx) {
344 dvec[0] -= ball->
expx;
346 else if (dvec[0] < -ball->
expx) {
347 dvec[0] += ball->
expx;
354 dvec[0] /= ball->
expx;
355 dvec[1] /= ball->
expy;
356 dvec[2] /= ball->
expz;
361 if (dvec[0] > ball->
len) {
362 dvec[0] -= ball->
len;
364 else if (dvec[0] < -ball->
len) {
365 dvec[0] += ball->
len;
372 if (dvec[1] > ball->
len) {
373 dvec[1] -= ball->
len;
375 else if (dvec[1] < -ball->
len) {
376 dvec[1] += ball->
len;
383 if (dvec[2] > ball->
len) {
384 dvec[2] -= ball->
len;
386 else if (dvec[2] < -ball->
len) {
387 dvec[2] += ball->
len;
400 return (dist2 < 0.0f) ? 0.0f : (ball->
s * dist2 * dist2 * dist2);
410 uint front = 0, back = 0;
415 while (front != back) {
416 node =
process->bvh_queue[back++];
418 for (
int i = 0; i < 2; i++) {
419 if ((node->
bb[i].
min[0] <=
x) && (node->
bb[i].
max[0] >=
x) && (node->
bb[i].
min[1] <=
y) &&
422 if (node->
child[i]) {
440#ifdef USE_ACCUM_NORMAL
446 process->indices =
static_cast<int(*)[4]
>(
458#ifdef USE_ACCUM_NORMAL
596 int i, index = 0,
count, indexar[8];
599 for (i = 0; i < 8; i++) {
631 for (edges = polys->
list; edges; edges = edges->
next) {
677 index =
HASH(i, j, k);
680 for (; c !=
nullptr; c = c->
next) {
681 if (c->
i == i && c->
j == j && c->
k == k) {
710 return (face ==
L) ?
LF :
BN;
712 return (face ==
L) ?
LN :
TF;
714 return (face ==
L) ?
LB :
TN;
716 return (face ==
L) ?
LT :
BF;
718 return (face ==
R) ?
RN :
BF;
720 return (face ==
R) ?
RF :
TN;
722 return (face ==
R) ?
RT :
BN;
724 return (face ==
R) ?
RB :
TF;
726 return (face ==
B) ?
RB :
LN;
728 return (face ==
B) ?
LB :
RF;
730 return (face ==
T) ?
LT :
RN;
732 return (face ==
T) ?
RT :
LF;
743 return face == other ?
rightface[edge] : other;
751 static bool is_done =
false;
752 int i,
e, c, done[12],
pos[8];
759 for (i = 0; i < 256; i++) {
760 for (
e = 0;
e < 12;
e++) {
763 for (c = 0; c < 8; c++) {
766 for (
e = 0;
e < 12;
e++) {
770 int start =
e, edge =
e;
798 for (i = 0; i < 256; i++) {
804 for (edges = polys->
list; edges; edges = edges->
next) {
830 for (
int i = 0; i < 256; i++) {
859 index =
HASH(i, j, k);
862 for (
l = q;
l !=
nullptr;
l =
l->next) {
863 if (
l->i == i &&
l->j == j &&
l->k == k) {
886 if (i1 > i2 || (i1 == i2 && (j1 > j2 || (j1 == j2 && k1 > k2)))) {
897 index =
HASH(i1, j1, k1) +
HASH(i2, j2, k2);
918 if (i1 > i2 || (i1 == i2 && (j1 > j2 || (j1 == j2 && k1 > k2)))) {
929 q = table[
HASH(i1, j1, k1) +
HASH(i2, j2, k2)];
930 for (; q !=
nullptr; q = q->
next) {
931 if (q->
i1 == i1 && q->
j1 == j1 && q->
k1 == k1 && q->
i2 == i2 && q->
j2 == j2 && q->
k2 == k2) {
947#ifndef USE_ACCUM_NORMAL
955 const float delta =
process->delta;
980#ifdef USE_ACCUM_NORMAL
999 float c1_value, c1_co[3];
1000 float c2_value, c2_co[3];
1003 c1_value = c2->
value;
1005 c2_value = c1->
value;
1009 c1_value = c1->
value;
1011 c2_value = c2->
value;
1015 for (
uint i = 0; i <
process->converge_res; i++) {
1029 float tmp = -c1_value / (c2_value - c1_value);
1053 for (n = 0; n < 8; n++) {
1096 for (dir[0] = -1; dir[0] <= 1; dir[0]++) {
1097 for (dir[1] = -1; dir[1] <= 1; dir[1]++) {
1098 for (dir[2] = -1; dir[2] <= 1; dir[2]++) {
1099 if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0) {
1114 add[0] = it[0] - dir[0];
1115 add[1] = it[1] - dir[1];
1116 add[2] = it[2] - dir[2];
1121 }
while ((it[0] > lbn[0]) && (it[1] > lbn[1]) && (it[2] > lbn[2]) && (it[0] < rtf[0]) &&
1122 (it[1] < rtf[1]) && (it[2] < rtf[2]));
1153 while (
process->cubes !=
nullptr) {
1181 Scene *sce_iter = scene;
1191 float obinv[4][4], obmat[4][4];
1192 copy_m4_m4(obmat, ob->object_to_world().ptr());
1220 if (!
STREQ(obname, name)) {
1237 float pos[4][4],
rot[4][4];
1238 float expx, expy, expz;
1247 new_ml->
mat =
static_cast<float *
>(
1249 new_ml->
imat =
static_cast<float *
>(
1254 if (ml->s > 10.0f) {
1263 new_ml->
s = -new_ml->
s;
1288 new_ml->
rad2 = 1 / (ml->rad * ml->rad);
1327 for (
uint i = 0; i < 8; i++) {
1333 for (
uint i = 0; i < 8; i++) {
1370 if (
process.thresh < 0.001f) {
1373 else if (
process.thresh < 0.01f) {
1376 else if (
process.thresh < 0.1f) {
1434 int corners_num = 0;
1438 corners_num +=
count;
1442 mesh->vert_positions_for_write().copy_from(
process.co);
1446 int loop_offset = 0;
1447 for (
int i = 0; i < mesh->
faces_num; i++) {
1451 face_offsets[i] = loop_offset;
1453 corner_verts[loop_offset] =
indices[0];
1454 corner_verts[loop_offset + 1] =
indices[1];
1455 corner_verts[loop_offset + 2] =
indices[2];
1457 corner_verts[loop_offset + 3] =
indices[3];
1460 loop_offset +=
count;
1464 for (
int i = 0; i < mesh->
verts_num; i++) {
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
General operations, lookup, etc. for blender objects.
int BKE_object_visibility(const Object *ob, int dag_eval_mode)
int BKE_scene_base_iter_next(Depsgraph *depsgraph, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
void accumulate_vertex_normals_v3(float n1[3], float n2[3], float n3[3], float n4[3], const float f_no[3], const float co1[3], const float co2[3], const float co3[3], const float co4[3])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
void unit_m4(float m[4][4])
bool has_zero_axis_m4(const float matrix[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
#define mul_m4_series(...)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void quat_to_mat4(float m[4][4], const float q[4])
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_v3_int(int r[3], const int a[3])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void zero_v3(float r[3])
MINLINE float normalize_v3(float n[3])
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
#define BLI_MEMARENA_STD_BUFSIZE
size_t BLI_string_split_name_number(const char *name, char delim, char *r_name_left, int *r_number) ATTR_NONNULL(1
#define INIT_MINMAX(min, max)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void process(btMatrix3x3 &B, btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V)
Helper function of 3X3 SVD for processing 2X2 SVD.
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float3 ceil(const float3 a)
static void addtovertices(PROCESS *process, const float v[3], const float no[3])
static void makecubetable()
static void closest_latice(int r[3], const float pos[3], const float size)
static void find_first_points(PROCESS *process, const uint em)
#define MBALL_ARRAY_LEN_INIT
static INTLISTS * cubetable[256]
static void polygonize(PROCESS *process)
void BKE_mball_cubeTable_free()
static void make_box_from_metaelem(Box *r, const MetaElem *ml)
static bool object_has_zero_axis_matrix(const Object *bob)
static void docube(PROCESS *process, CUBE *cube)
static int getedge(EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2)
static void next_lattice(int r[3], const float pos[3], const float size)
Mesh * BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob)
static void freepolygonize(PROCESS *process)
static int nextcwedge(int edge, int face)
static CORNER * setcorner(PROCESS *process, int i, int j, int k)
static float metaball(PROCESS *process, float x, float y, float z)
static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Object *ob)
static int vertid(PROCESS *process, const CORNER *c1, const CORNER *c2)
static uint partition_mainb(MetaElem **mainb, uint start, uint end, uint s, float div)
static int otherface(int edge, int face)
static void prev_lattice(int r[3], const float pos[3], const float size)
static void make_box_union(const BoundBox *a, const Box *b, Box *r_out)
static void add_cube(PROCESS *process, int i, int j, int k)
static void build_bvh_spatial(PROCESS *process, MetaballBVHNode *node, uint start, uint end, const Box *allbox)
static void make_face(PROCESS *process, int i1, int i2, int i3, int i4)
static void setedge(PROCESS *process, int i1, int j1, int k1, int i2, int j2, int k2, int vid)
static int setcenter(PROCESS *process, CENTERLIST *table[], const int i, const int j, const int k)
static float densfunc(const MetaElem *ball, float x, float y, float z)
static void converge(PROCESS *process, const CORNER *c1, const CORNER *c2, float r_p[3])
static void add(blender::Map< std::string, std::string > &messages, Message &msg)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
void mesh_vert_normals_assign(Mesh &mesh, Span< float3 > vert_normals)
T min(const T &a, const T &b)
void min_max(const T &value, T &min, T &max)
VecBase< int32_t, 3 > int3
VecBase< float, 3 > float3
blender::Vector< blender::float3 > co
MetaballBVHNode metaball_bvh
blender::Vector< blender::float3 > no
MetaballBVHNode ** bvh_queue