[Bf-blender-cvs] [e4fbcce] fracture_modifier: dynamic fracture: now multiple dynamic objects can exist, need to test interaction with prefractured, though
Martin Felke
noreply at git.blender.org
Mon Jun 1 21:29:28 CEST 2015
Commit: e4fbcce5375591ee604cf95c608d4265f1e5db16
Author: Martin Felke
Date: Thu May 21 18:28:18 2015 +0200
Branches: fracture_modifier
https://developer.blender.org/rBe4fbcce5375591ee604cf95c608d4265f1e5db16
dynamic fracture: now multiple dynamic objects can exist, need to test interaction with prefractured, though
===================================================================
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index f2ba8d5..78f4fcc 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -90,7 +90,7 @@ static void activateRigidbody(RigidBodyOb* rbo, RigidBodyWorld *UNUSED(rbw), Mes
}
static bool isModifierActive(FractureModifierData *rmd) {
- return ((rmd != NULL) && (rmd->modifier.mode & (eModifierMode_Realtime | eModifierMode_Render)) && (rmd->refresh == false));
+ return ((rmd != NULL) && (rmd->modifier.mode & (eModifierMode_Realtime | eModifierMode_Render)) && (rmd->refresh == false || rmd->fracture_mode == MOD_FRACTURE_DYNAMIC));
}
static void calc_dist_angle(RigidBodyShardCon *con, float *dist, float *angle)
@@ -1958,7 +1958,8 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
fid1->shardID = rbw->cache_index_map[linear_index1]->meshisland_index;
BLI_addtail(&fmd1->fracture_ids, fid1);
//fmd1->refresh = true;
- rbw->refresh_modifiers = true;
+ //rbw->refresh_modifiers = true;
+ fmd1->update_dynamic = true;
update_movement(fmd1, linear_index1, force, cp->contact_pos_world_onA, cp->contact_pos_world_onB);
}
}
@@ -1983,7 +1984,8 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
fid2->shardID = id;
BLI_addtail(&fmd2->fracture_ids, fid2);
//fmd2->refresh = true;
- rbw->refresh_modifiers = true;
+ //rbw->refresh_modifiers = true;
+ fmd2->update_dynamic = true;
update_movement(fmd2, id, force, cp->contact_pos_world_onB, cp->contact_pos_world_onA);
}
}
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index e6ecb5b..65bb98b 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1588,12 +1588,13 @@ typedef struct FractureModifierData {
int use_experimental;
int explo_shared;
int refresh_images;
+ int update_dynamic;
/* internal values */
float max_vol;
int last_frame;
- char pad[4];
+ //char pad[4];
} FractureModifierData;
typedef struct DataTransferModifierData {
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 6925a5b..9e7afe5 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -206,6 +206,7 @@ static void initData(ModifierData *md)
fmd->fracture_mode = MOD_FRACTURE_PREFRACTURED;
fmd->last_frame = FLT_MIN;
fmd->dynamic_force = 10.0f;
+ fmd->update_dynamic = false;
}
static void freeMeshIsland(FractureModifierData *rmd, MeshIsland *mi, bool remove_rigidbody)
@@ -1413,6 +1414,7 @@ static void copyData(ModifierData *md, ModifierData *target)
trmd->fracture_mode = rmd->fracture_mode;
trmd->last_frame = rmd->last_frame;
trmd->dynamic_force = rmd->dynamic_force;
+ trmd->update_dynamic = false;
}
/* mi->bb, its for volume fraction calculation.... */
@@ -3586,6 +3588,7 @@ static void do_modifier(FractureModifierData *fmd, Object *ob, DerivedMesh *dm)
{
if (fmd->refresh)
{
+ printf("ADD NEW 1: %s \n", ob->id.name);
if (fmd->last_frame == INT_MAX)
{
//data purge hack
@@ -3694,6 +3697,10 @@ static void do_modifier(FractureModifierData *fmd, Object *ob, DerivedMesh *dm)
* should not have a visible effect in general */
int count = 0;
+
+ //if (!fmd->dm && fmd->frac_mesh)
+ // BKE_fracture_create_dm(fmd, true);
+
while(fmd->fracture_ids.first){
FractureID* fid = (FractureID*)fmd->fracture_ids.first;
do_fracture(fmd, fid->shardID, ob, dm);
@@ -3704,14 +3711,16 @@ static void do_modifier(FractureModifierData *fmd, Object *ob, DerivedMesh *dm)
if (count > 0)
{
+ printf("REFRESH: %s \n", ob->id.name);
fmd->modifier.scene->rigidbody_world->object_changed = true;
fmd->refresh = true;
fmd->current_shard_entry->is_new = false;
}
- if (fmd->modifier.scene->rigidbody_world->refresh_modifiers)
+ if (fmd->update_dynamic)
{
- fmd->modifier.scene->rigidbody_world->refresh_modifiers = false;
+ printf("ADD NEW 2: %s \n", ob->id.name);
+ fmd->update_dynamic = false;
add_new_entries(fmd, dm, ob);
}
}
More information about the Bf-blender-cvs
mailing list