[Bf-blender-cvs] [4d72c167b4f] temp-fracture-modifier-2.8: Merge remote-tracking branch 'origin/master' into fracture_modifier-2.8
Martin Felke
noreply at git.blender.org
Fri Dec 21 17:04:55 CET 2018
Commit: 4d72c167b4fd3552eee656b4b26eff49cdccda66
Author: Martin Felke
Date: Fri Dec 21 16:33:28 2018 +0100
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rB4d72c167b4fd3552eee656b4b26eff49cdccda66
Merge remote-tracking branch 'origin/master' into fracture_modifier-2.8
# Conflicts:
# release/scripts/addons
# release/scripts/addons_contrib
# source/blender/blenkernel/BKE_rigidbody.h
# source/blender/blenkernel/intern/rigidbody.c
# source/blender/depsgraph/intern/builder/deg_builder_relations.cc
# source/blender/editors/physics/rigidbody_constraint.c
# source/blender/makesrna/intern/rna_rigidbody.c
===================================================================
===================================================================
diff --cc release/scripts/addons
index e05c81e0ad0,0457976a872..1f36b19604c
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit e05c81e0ad0ba49642a9b8bd4b49a5f6049758d8
-Subproject commit 0457976a872000993202763abe7503c76b461122
++Subproject commit 1f36b19604c4b62ac6acf47f93ad5863af2032de
diff --cc source/blender/blenkernel/BKE_rigidbody.h
index 8c053456004,9a5f3c31264..1f940fa178c
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@@ -36,18 -36,12 +36,18 @@@
struct RigidBodyWorld;
struct RigidBodyOb;
+struct RigidBodyShardCon;
+ struct Collection;
struct Depsgraph;
- struct Scene;
+ struct Main;
struct Object;
-struct Scene;
+struct Group;
+struct Shard;
+struct FractureModifierData;
- struct Main;
+struct rbCollisionShape;
+struct rbContactPoint;
+struct ModifierData;
/* -------------- */
/* Memory Management */
@@@ -71,12 -65,16 +71,19 @@@ void BKE_rigidbody_world_id_loop(struc
/* create Blender-side settings data - physics objects not initialized yet */
struct RigidBodyWorld *BKE_rigidbody_create_world(struct Scene *scene);
-struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type);
-struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type);
+struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type, struct Shard *mi);
+struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type, struct RigidBodyShardCon *con);
+struct RigidBodyOb *BKE_rigidbody_create_shard(struct Object *ob, struct Object *target, struct Shard *mi,
+ struct Scene *scene);
+struct RigidBodyShardCon *BKE_rigidbody_create_shard_constraint(struct Scene *scene, short type, bool reset);
+ /* Ensure newly set collections' objects all have required data. */
+ void BKE_rigidbody_objects_collection_validate(struct Scene *scene, struct RigidBodyWorld *rbw);
+ void BKE_rigidbody_constraints_collection_validate(struct Scene *scene, struct RigidBodyWorld *rbw);
+
+ /* Ensure object added to collection gets RB data if that collection is a RB one. */
+ void BKE_rigidbody_main_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *object);
+
/* copy */
struct RigidBodyWorld *BKE_rigidbody_world_copy(struct RigidBodyWorld *rbw, const int flag);
void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw);
diff --cc source/blender/blenkernel/intern/fracture_automerge.c
index ce0b3ae8d1b,00000000000..acda6695c70
mode 100644,000000..100644
--- a/source/blender/blenkernel/intern/fracture_automerge.c
+++ b/source/blender/blenkernel/intern/fracture_automerge.c
@@@ -1,862 -1,0 +1,862 @@@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright (C) 2018 by Martin Felke.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_fracture.h"
+#include "BKE_customdata.h"
+#include "BKE_mesh.h"
+#include "BKE_pointcache.h"
+#include "BKE_material.h"
+
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_fracture_types.h"
+#include "DNA_collection_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_rigidbody_types.h"
+
+#include "BLI_math.h"
+#include "BLI_kdtree.h"
+#include "BLI_ghash.h"
+#include "BLI_listbase.h"
+
+#include "bmesh.h"
+
+static void do_match_normals(MPoly *mp, MPoly *other_mp, MVert *mvert, MLoop *mloop)
+{
+ MLoop ml, ml2;
+ MVert *v, *v2;
+ short sno[3];
+ float fno[3], fno2[3];
+ int j;
+
+ if (mp->totloop == other_mp->totloop) //mpoly+index
+ {
+ for (j = 0; j < mp->totloop; j++)
+ {
+ ml = mloop[mp->loopstart + j];
+ ml2 = mloop[other_mp->loopstart + j];
+ v = mvert + ml.v;
+ v2 = mvert + ml2.v;
+
+ normal_short_to_float_v3(fno, v->no);
+ normal_short_to_float_v3(fno2, v2->no);
+ add_v3_v3(fno, fno2);
+ mul_v3_fl(fno, 0.5f);
+ normal_float_to_short_v3(sno, fno);
+ copy_v3_v3_short(v->no, sno);
+ copy_v3_v3_short(v2->no, sno);
+ }
+ }
+}
+
+void BKE_fracture_face_pairs(FractureModifierData *fmd, Mesh *dm, Object *ob)
+{
+ /* make kdtree of all faces of dm, then find closest face for each face*/
+ MPoly *mp = NULL;
+ MPoly *mpoly = dm->mpoly;
+ MLoop* mloop = dm->mloop;
+ MVert* mvert = dm->mvert;
+ int totpoly = dm->totpoly;
+ KDTree *tree = BLI_kdtree_new(totpoly);
+ int i = 0;
+
+ //TODO, work with poly customdata int layer maybe to store "Innerness" ?
+ int inner_index = BKE_object_material_slot_find_index(ob, fmd->inner_material) - 1;
+
+ //printf("Make Face Pairs\n");
+ int faces = 0, pairs = 0;
+
+ for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
+ float co[3];
+ BKE_fracture_face_calc_center_mean(dm, mp, co);
+ if (mp->mat_nr == inner_index)
+ {
+ BLI_kdtree_insert(tree, i, co);
+ faces++;
+ }
+ }
+
+ BLI_kdtree_balance(tree);
+
+ /*now find pairs of close faces*/
+
+ for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
+ if (mp->mat_nr == inner_index) { /* treat only inner faces ( with inner material) */
+ int index = -1, j = 0, r = 0, val = -1;
+ KDTreeNearest *n;
+ float co[3], dist = fmd->autohide_dist;
+
+ BKE_fracture_face_calc_center_mean(dm, mp, co);
+ if (fmd->frac_algorithm == MOD_FRACTURE_BOOLEAN_FRACTAL)
+ {
+ /*just as precaution, rather search a wider radius*/
+ dist = fmd->autohide_dist * 10;
+ }
+
+ r = BLI_kdtree_range_search(tree, co, &n, dist);
+ //r = BLI_kdtree_find_nearest_n(tree, co, &n, 2);
+ /*2nd nearest means not ourselves...*/
+ if (r == 0)
+ continue;
+
+ index = n[0].index;
+ while (j < r) {
+ int v1, v2;
+ Shard *mi1, *mi2;
+ index = n[j].index;
+ //printf("I, INDEX %d %d %f\n", i, index, n[j].dist);
+ v1 = mloop[mp->loopstart].v;
+ v2 = mloop[(mpoly+index)->loopstart].v;
+ mi1 = BLI_ghash_lookup(fmd->shared->vertex_island_map, POINTER_FROM_INT(v1));
+ mi2 = BLI_ghash_lookup(fmd->shared->vertex_island_map, POINTER_FROM_INT(v2));
+
+ if (mi1 != mi2) {
+ /*dont delete faces on own meshisland if they are closer than faces on adjacent island
+ like with boolean fractal*/
+ break;
+ }
+
+ j++;
+ }
+
+ val = POINTER_AS_INT(BLI_ghash_lookup(fmd->shared->adjacent_face_pairs, POINTER_FROM_INT(index)));
+ if (val != i && index != i) {
+ BLI_ghash_insert(fmd->shared->adjacent_face_pairs, POINTER_FROM_INT(i), POINTER_FROM_INT(index));
+ pairs++;
+ /*match normals...*/
+ if (fmd->flag & MOD_FRACTURE_USE_FIX_NORMALS) {
+ do_match_normals(mp, mpoly+index, mvert, mloop);
+ }
+ }
+
+ if (n != NULL) {
+ MEM_freeN(n);
+ }
+ }
+ }
+
+ if (faces == 0 || pairs == 0) {
+ BLI_ghash_free(fmd->shared->adjacent_face_pairs, NULL, NULL);
+ fmd->shared->adjacent_face_pairs = NULL;
+ }
+
+ printf("faces, pairs: %d %d\n", faces, pairs);
+ BLI_kdtree_free(tree);
+}
+
+static void find_other_face(FractureModifierData *fmd, int i, BMesh* bm, Object* ob, BMFace ***faces, int *del_faces)
+{
+ float f_centr[3], f_centr_other[3];
+ BMFace *f1, *f2;
+ int other = POINTER_AS_INT(BLI_ghash_lookup(fmd->shared->adjacent_face_pairs, POINTER_FROM_INT(i)));
+ int inner_index = BKE_object_material_slot_find_index(ob, fmd->inner_material) - 1;
+
+ if ((other == i))
+ {
+ //printf("other == i %d \n", i);
+ f1 = BM_face_at_index(bm, i);
+
+ if (f1->mat_nr == inner_index)
+ {
+ /*is this a remainder face ? */
+ *faces = MEM_reallocN(*faces, sizeof(BMFace *) * ((*del_faces) + 1));
+ (*faces)[*del_faces] = f1;
+ (*del_faces) += 1;
+ }
+
+ return;
+ }
+
+ if (other >= bm->totface) {
+ return;
+ }
+
+ f1 = BM_face_at_index(bm, i);
+ f2 = BM_face_at_index(bm, other);
+
+ if ((f1 == NULL) || (f2 == NULL)) {
+ return;
+ }
+
+
- BM_face_calc_center_mean(f1, f_centr);
- BM_face_calc_center_mean(f2, f_centr_other);
++ BM_face_calc_center_median(f1, f_centr);
++ BM_face_calc_center_median(f2, f_centr_other);
+
+
+ if ((len_squared_v3v3(f_centr, f_centr_other) < (fmd->autohide_dist)) && (f1 != f2) &&
+ (f1->mat_nr == inner_index) && (f2->mat_nr == inner_index))
+ {
+ bool in_filter = false;
+
+ /*filter out face pairs, if we have an autohide filter group */
+ if (fmd->autohide_filter_group)
+ {
+ CollectionObject *go;
+ for (go = fmd->autohide_filter_group->gobject.first; go; go = go->next)
+ {
+ /*check location and scale (maximum size if nonuniform) for now */
+ /*if not in any filter range, delete... else keep */
+ Object* obj = go->ob;
+ float f1_loc[3], f2_loc[3];
+ float radius = 0.1f; //autohide_filter_dist
+ //MAX3(obj->size[0], obj->size[1], obj->size[2]);
+
+ /* TODO XXX watch out if go->ob is parented to ob (Transformation error ?) */
+ mul_v3_m4v3(f1_loc, ob->obmat, f_centr);
+ mul_v3_m4v3(f2_loc, ob->obmat, f_centr_other);
+ radius = radius * radius;
+
+ if (obj->type == OB_MESH)
+ {
+ /* use geometry of meshes */
+ MVert* mvert = NULL, *mv = NULL;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list