Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Felke <martin.felke@googlemail.com>2019-04-04 22:30:41 +0300
committerMartin Felke <martin.felke@googlemail.com>2019-04-04 22:30:41 +0300
commitd0527bfd48ea01314c6659d05024828907331c82 (patch)
tree638281ed99e5797fd4d194786d4aa00f4c7846dd
parentf0bf1f57f68023ba6a73ce10ad8afc066a8b4cb1 (diff)
fix for inner uv and fractal / bmeshtemp-fracture-modifier-2.8
-rw-r--r--source/blender/blenkernel/intern/boolean.c42
-rw-r--r--source/blender/blenkernel/intern/fracture.c20
-rw-r--r--source/blender/blenkernel/intern/fracture_util.c4
3 files changed, 57 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/boolean.c b/source/blender/blenkernel/intern/boolean.c
index d30c294ecc0..4c195def1ae 100644
--- a/source/blender/blenkernel/intern/boolean.c
+++ b/source/blender/blenkernel/intern/boolean.c
@@ -128,6 +128,32 @@ static Mesh *get_quick_mesh(
return result;
}
+
+static void check_add_layer(CustomData *src, CustomData *dst, BMesh *bm, const char htype)
+{
+ int i = 0, index = -1;
+ CustomDataLayer *layer;
+
+ for (i = 0; i < src->totlayer; i++) {
+ layer = src->layers + i;
+ index = CustomData_get_named_layer(dst, layer->type, layer->name);
+ if (index == -1)
+ {
+ CustomData_bmesh_merge(src, dst, CD_MASK_BMESH, CD_DUPLICATE, bm, htype);
+ break;
+ }
+ }
+}
+
+/* satisfy customdata_copy_data layout, by adding required layers from src to dst */
+static void add_missing_layers(BMesh *bm, Mesh* me)
+{
+ check_add_layer(&me->vdata, &bm->vdata, bm, BM_VERT);
+ check_add_layer(&me->edata, &bm->edata, bm, BM_EDGE);
+ check_add_layer(&me->ldata, &bm->ldata, bm, BM_LOOP);
+ check_add_layer(&me->pdata, &bm->pdata, bm, BM_FACE);
+}
+
Mesh *BKE_boolean_operation(Mesh *mesh, struct Object *ob,
Mesh *mesh_other, struct Object *ob_other, int op_type, int solver,
float double_threshold, struct BooleanModifierData *bmd)
@@ -188,6 +214,7 @@ Mesh *BKE_boolean_operation(Mesh *mesh, struct Object *ob,
&allocsize,
&((struct BMeshCreateParams){.use_toolflags = false,}));
+ add_missing_layers(bm, mesh);
BM_mesh_bm_from_me(bm, mesh_other, &((struct BMeshFromMeshParams){.calc_face_normal = true,}));
if (UNLIKELY(is_flip)) {
@@ -402,9 +429,14 @@ static void DM_loop_interp_from_poly(DerivedMesh *source_dm,
{
float (*cos_3d)[3] = BLI_array_alloca(cos_3d, source_poly->totloop);
int *source_indices = BLI_array_alloca(source_indices, source_poly->totloop);
+ int *source_vert_indices = BLI_array_alloca(source_vert_indices, source_poly->totloop);
+ int *source_edge_indices = BLI_array_alloca(source_edge_indices, source_poly->totloop);
float *weights = BLI_array_alloca(weights, source_poly->totloop);
int i;
int target_vert_index = target_mloop[target_loop_index].v;
+ int target_edge_index = target_mloop[target_loop_index].e;
+ EdgeVertWeight *vweights = BLI_array_alloca(vweights, source_poly->totloop);
+
float coord[3];
for (i = 0; i < source_poly->totloop; ++i) {
@@ -422,8 +454,18 @@ static void DM_loop_interp_from_poly(DerivedMesh *source_dm,
interp_weights_poly_v3(weights, cos_3d, source_poly->totloop, coord);
+
DM_interp_loop_data(source_dm, target_dm, source_indices, weights,
source_poly->totloop, target_loop_index);
+
+ /* interpolate vertex data as well, for painted weights interpolation on fracture modifier */
+ DM_interp_vert_data(source_dm, target_dm, source_vert_indices ,weights,
+ source_poly->totloop, target_vert_index);
+
+ /*interpolate edge data as well, to keep creases and bweights hopefully */
+ DM_interp_edge_data(source_dm, target_dm, source_edge_indices, weights, vweights, source_poly->totloop, target_edge_index);
+
+ /*interpolate poly data ? */
}
typedef struct DMArrays {
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index dfbd2e83b80..38a5a54cca9 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -920,6 +920,19 @@ void BKE_fracture_postprocess_meshisland(FractureModifierData *fmd, Object* ob,
mat4_to_size(size, ob->obmat);
int last_id = 0;
+ if (fmd->uvlayer_name[0])
+ {
+ for (i = 0; i < count+1; i++)
+ {
+ /* inner UV handling... */
+ if ((*temp_meshs)[i])
+ {
+ BKE_fracture_copy_inner_uv((*temp_meshs)[i], fmd->uvlayer_name,
+ BKE_object_material_slot_find_index(ob, fmd->inner_material) - 1);
+ }
+ }
+ }
+
if (fmd->flag & MOD_FRACTURE_USE_SPLIT_TO_ISLANDS)
{
for (i = 0; i < count+1; i++)
@@ -965,13 +978,6 @@ void BKE_fracture_postprocess_meshisland(FractureModifierData *fmd, Object* ob,
result->id = last_id + j;
result->rigidbody->flag = mi->rigidbody->flag;
- /* inner UV handling... */
- if (fmd->uvlayer_name[0])
- {
- BKE_fracture_copy_inner_uv(result->mesh, fmd->uvlayer_name,
- BKE_object_material_slot_find_index(ob, fmd->inner_material) - 1);
- }
-
/* dont forget copying over the neighborhood info, we expose this to python so it might be useful */
if ((i < count) && shards && shards[i]) {
result->neighbor_count = shards[i]->neighbor_count;
diff --git a/source/blender/blenkernel/intern/fracture_util.c b/source/blender/blenkernel/intern/fracture_util.c
index 1f94367a83d..05ef8fb2377 100644
--- a/source/blender/blenkernel/intern/fracture_util.c
+++ b/source/blender/blenkernel/intern/fracture_util.c
@@ -337,7 +337,7 @@ static Mesh* do_fractal(BooleanContext *ctx)
CustomData_bmesh_init_pool(&bm->ldata, bm->totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm->pdata, bm->totface, BM_FACE);
- BM_data_layer_add(bm, &bm->ldata, CD_MLOOPUV);
+ BM_data_layer_add_named(bm, &bm->ldata, CD_MLOOPUV, "UVMap");
/* should be 4 loops, since its just a quad / plane */
mluv[0].uv[0] = 0.0f;
@@ -354,7 +354,7 @@ static Mesh* do_fractal(BooleanContext *ctx)
BM_ITER_MESH (efa, &fiter, bm, BM_FACES_OF_MESH) {
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
- MLoopUV *uv = CustomData_bmesh_get(&bm->ldata, ((BMHeader *)l)->data, CD_MLOOPUV);
+ MLoopUV *uv = CustomData_bmesh_get_named(&bm->ldata, ((BMHeader *)l)->data, CD_MLOOPUV, "UVMap");
if (uv) *uv = mluv[i];
}
}