Commit: c2231bc4c96f16d8ce9a9c8054616ad05f8fe54e Author: Martin Felke Date: Thu Aug 23 12:42:45 2018 +0200 Branches: temp-fracture-modifier-2.8 https://developer.blender.org/rBc2231bc4c96f16d8ce9a9c8054616ad05f8fe54e
fixes and polishing recently implemented features =================================================================== M source/blender/blenkernel/BKE_fracture.h M source/blender/blenkernel/BKE_fracture_util.h M source/blender/blenkernel/intern/fracture.c M source/blender/blenkernel/intern/fracture_automerge.c M source/blender/blenkernel/intern/fracture_external.c M source/blender/blenkernel/intern/fracture_prefractured.c M source/blender/blenkernel/intern/fracture_util.c M source/blender/blenkernel/intern/pointcache.c M source/blender/makesrna/intern/rna_rigidbody.c =================================================================== diff --git a/source/blender/blenkernel/BKE_fracture.h b/source/blender/blenkernel/BKE_fracture.h index 74e8bc04506..eec805c63c0 100644 --- a/source/blender/blenkernel/BKE_fracture.h +++ b/source/blender/blenkernel/BKE_fracture.h @@ -34,6 +34,7 @@ #include "BLI_sys_types.h" #include "BKE_scene.h" +#include "BKE_customdata.h" struct Mesh; @@ -71,6 +72,15 @@ typedef struct FracPointCloud { } FracPointCloud; +static const CustomDataMask CD_MASK_ISLAND = + CD_MASK_MDEFORMVERT | + CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS | + CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | + CD_MASK_RECAST | CD_MASK_PAINT_MASK | + CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE | + CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP; + + void BKE_fracture_autohide_refresh(struct FractureModifierData* fmd, struct Object *ob, struct Mesh *me_assembled); void BKE_fracture_automerge_refresh(struct FractureModifierData* fmd, struct Mesh *me_assembled); @@ -109,8 +119,6 @@ void BKE_fracture_mesh_island_remove_all(struct FractureModifierData *fmd, struc void BKE_fracture_mesh_constraint_remove(struct FractureModifierData *fmd, struct RigidBodyShardCon* con, struct Scene *scene); void BKE_fracture_constraints_free(struct FractureModifierData *fmd, struct Scene *scene); -int BKE_fracture_update_visual_mesh(struct FractureModifierData *fmd, struct Object *ob, bool do_custom_data); - struct RigidBodyShardCon *BKE_fracture_mesh_constraint_create(struct Scene *scene, struct FractureModifierData *fmd, struct MeshIsland *mi1, struct MeshIsland *mi2, short con_type); @@ -135,10 +143,6 @@ void BKE_fracture_mesh_island_free(struct MeshIsland *mi, struct Scene* scene); short BKE_fracture_collect_materials(struct Main* bmain, struct Object* o, struct Object* ob, int matstart, struct GHash** mat_index_map); -struct Mesh *BKE_fracture_prefractured_do(struct FractureModifierData *fmd, struct Object *ob, struct Mesh *dm, - struct Mesh *orig_dm, char names [][66], int count, struct Scene* scene, - struct Depsgraph *depsgraph); - struct Mesh* BKE_fracture_mesh_copy(struct Mesh* source, struct Object* ob); struct BMesh* BKE_fracture_mesh_to_bmesh(struct Mesh* me); struct Mesh* BKE_fracture_bmesh_to_mesh(struct BMesh* bm); @@ -165,5 +169,9 @@ void BKE_fracture_meshislands_pack(struct FractureModifierData *fmd, struct Obje void BKE_fracture_postprocess_meshisland(struct FractureModifierData *fmd, struct Object* ob, struct MeshIsland*mi, struct Mesh** temp_meshs, int count, struct Main* bmain, struct Scene* scene, int frame); +void BKE_fracture_meshisland_normals_fix(struct FractureModifierData *fmd, struct MeshIsland* mi, struct Mesh* orig_me); + +void BKE_fracture_copy_customdata(struct CustomData* src, struct CustomData* dst, CustomDataMask mask, int src_ofs, int dst_ofs, + int copyelem, int totelem); #endif /* BKE_FRACTURE_H */ diff --git a/source/blender/blenkernel/BKE_fracture_util.h b/source/blender/blenkernel/BKE_fracture_util.h index 123f7834651..672af68da86 100644 --- a/source/blender/blenkernel/BKE_fracture_util.h +++ b/source/blender/blenkernel/BKE_fracture_util.h @@ -40,6 +40,7 @@ typedef struct BisectContext { bool clear_outer; bool use_fill; bool do_fast_bisect; + bool use_smooth_inner; char uv_layer[64]; float normal[3]; diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c index a444f32e023..b67adaf9fe4 100644 --- a/source/blender/blenkernel/intern/fracture.c +++ b/source/blender/blenkernel/intern/fracture.c @@ -96,7 +96,7 @@ static void parse_cell_polys(cell c, MPoly *mpoly, int totpoly); static void parse_cell_loops(cell c, MLoop *mloop, MPoly *mpoly, int totpoly); static void parse_cell_neighbors(cell c, int *neighbors, int totpoly); static void do_island_index_map(FractureModifierData *fmd, Object *obj); -static void fracture_meshisland_custom(FractureModifierData *fmd, Object *obj, MeshIsland* mii, Main* bmain, Scene* scene, int frame); +static void fracture_meshisland_custom(FractureModifierData *fmd, Object *obj, MeshIsland* mii, Main* bmain, Scene* scene, int frame, Depsgraph *depsgraph); void BKE_fracture_postprocess_meshisland(FractureModifierData *fmd, Object* ob, MeshIsland*mi, Mesh** temp_meshs, int count, Main* bmain, Scene* scene, int frame); @@ -420,6 +420,7 @@ static void prepare_bisect(FractureModifierData *fmd, Object* ob, BisectContext* ctx->do_fast_bisect = false; ctx->geometry_limitation_tree = fmd->shared->last_island_tree; ctx->inner_material_index = BKE_object_material_slot_find_index(ob, fmd->inner_material) - 1; + ctx->use_smooth_inner = fmd->use_smooth; /*if no inner material has been found, just pick the first one */ if (ctx->inner_material_index < 0) @@ -568,86 +569,6 @@ static void process_cells(FractureModifierData* fmd, MeshIsland* mi, Main* bmain } BKE_fracture_postprocess_meshisland(fmd, ob, mi, temp_meshs, count, bmain, scene, frame); -#if 0 - if (fmd->split_islands) - { - int diff = 1; - for (i = 0; i < count+1; i++) - { - if (temp_meshs[i]) { - BKE_fracture_split_islands(fmd, ob, temp_meshs[i], &temp_meshs, &count_new ); - BKE_fracture_mesh_free(temp_meshs[i]); - temp_meshs[i] = NULL; - } - - diff = count_new - (count+1); - - if (diff > 1) { - if (temp_meshs[i+diff-1]) { - BKE_fracture_split_islands(fmd, ob, temp_meshs[i+diff-1], &temp_meshs, &count_new ); - BKE_fracture_mesh_free(temp_meshs[i+diff-1]); - temp_meshs[i+diff-1] = NULL; - } - } - } - } - - mat4_to_size(size, ob->obmat); - - for (i = 0; i < count_new; i++) - { - if (temp_meshs[i]) - { - if (temp_meshs[i]->totvert > 0) - { /* skip invalid cells, e.g. those which are eliminated by bisect */ - float loc[3], rot[4], qrot[4], centr[3]; - MeshIsland *result = BKE_fracture_mesh_island_create(temp_meshs[i], bmain, scene, ob, frame); - fracture_meshisland_add(fmd, result); - result->id = mi->id + j; - - /* process vertexgroups, if any */ - BKE_fracture_meshisland_vertexgroups_do(fmd, ob, result); - if (result->passive_weight > 0.01f) { - /*dont make passive, but kinematic / triggered */ - /*so triggers can affect it */ - result->rigidbody->flag |= RBO_FLAG_KINEMATIC; - result->rigidbody->flag |= RBO_FLAG_IS_TRIGGERED; - } - - /*match transform and speed of rigidbody, for dynamic*/ - copy_v3_v3(loc, mi->rigidbody->pos); - copy_qt_qt(rot, mi->rigidbody->orn); - - //handle initial rot ? - invert_qt_qt(qrot, result->rot); - mul_qt_qtqt(qrot, rot, qrot); - - copy_v3_v3(centr, result->centroid); - sub_v3_v3(centr, mi->centroid); - mul_qt_v3(qrot, centr); - add_v3_v3(centr, loc); - - //init rigidbody properly ? - copy_v3_v3(result->rigidbody->pos, centr); - copy_qt_qt(result->rigidbody->orn, qrot); - - copy_v3_v3(result->rigidbody->lin_vel, mi->rigidbody->lin_vel); - copy_v3_v3(result->rigidbody->ang_vel, mi->rigidbody->ang_vel); - - //validate already here at once... dynamic somehow doesnt get updated else - BKE_rigidbody_shard_validate(scene->rigidbody_world, result, ob, fmd, true, - true, size, frame); - - result->constraint_index = result->id; - - j++; - } - else { - BKE_fracture_mesh_free(temp_meshs[i]); - } - } - } -#endif BLI_kdtree_balance(tree); @@ -961,16 +882,20 @@ void intersect_mesh_by_mesh(FractureModifierData* fmd, Object* ob, Mesh* meA, Me if (ELEM(fmd->keep_cutter_shards, MOD_FRACTURE_KEEP_BOTH, MOD_FRACTURE_KEEP_DIFFERENCE)) { boctx.operation = 2; - outB = BKE_fracture_mesh_boolean(meA, meB, ob, &boctx); + outB = BKE_fracture_mesh_boolean(meB, meA, ob, &boctx); } if (outA && (outA != meA)) { (*temp_meshs)[i] = outA; i++; } + else { + (*temp_meshs)[i] = NULL; + i++; + } - if (outB && (outB != meB)) { - (*temp_meshs)[i] = outA; + if (outB /*&& (outB != meB)*/) { + (*temp_meshs)[i] = outB; i++; } } @@ -1025,6 +950,7 @@ void BKE_fracture_postprocess_meshisland(FractureModifierData *fmd, Object* ob, /*so triggers can affect it */ result->rigidbody->flag |= RBO_FLAG_KINEMATIC; result->rigidbody->flag |= RBO_FLAG_IS_TRIGGERED; + //result->rigidbody->type = RBO_TYPE_PASSIVE; } /*match transform and speed of rigidbody, for dynamic*/ @@ -1053,6 +979,10 @@ void BKE_fracture_postprocess_meshisland(FractureModifierData *fmd, Object* ob, result->constraint_index = result->id; + if (fmd->fix_normals) { + BKE_fracture_meshisland_normals_fix(fmd, result, mi->mesh); + } + j++; } else { @@ -1062,13 +992,52 @@ void BKE_fracture_postprocess_meshisland(FractureModifierData *fmd, Object* ob, } } -static void fracture_meshisland_custom(FractureModifierData *fmd, Object *obj, MeshIsland* mii, Main* bmain, Scene* scene, int frame) +static MeshIsland* fracture_cutter_process(FractureModifierData* fmd, Object *obA, Mesh* meA, Object* obB, + MeshIsland *miB, Main* bmain, Scene* scene, int frame) { - if (fmd->cutter_group != NULL && obj->type == OB_MESH) + MVert* mv = NULL; + Mesh **temp_meshs = MEM_callocN(sizeof(Mesh*) * 2, "temp_meshs"); + Mesh* meB = miB->mesh; + int v = 0; + float imatA[4][4], imatB[4][4]; + + invert_m4_m4(imatA, obA->obmat); + invert_m4_m4(imatB, obB->obmat); + + //Transforms... + for (mv = meA->mvert, v = 0; v < meA->totvert; v++, mv++) { - //float imat[4][4]; - //invert_m4_m4(imat, obj->obmat); + mul_m4_v3(obA->obmat, mv->co); + mul_m4_v3(imatB, mv->co); + } + + intersect_mesh_by_mesh(fmd, obB, meA, meB, &temp_meshs); + + if (temp_meshs[0] && !temp_meshs[1]) { + /* only intersects, throw away whole object */ + //miB->endframe = frame; + } + //exchange difference against original mesh + if (temp_meshs[1]) { + BLI_remlink(&fmd->shared->mesh_islands, miB); + BKE_fracture_mesh_island_free(miB, scene); + miB = BKE_fracture_mesh_island_create(temp_meshs[1], bmain, scene, obB, frame); @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs