[Bf-blender-cvs] [797b15e6842] temp-fracture-modifier-2.8: simulation jumps and interrupts itself still, regular rigidbodies crash...
Martin Felke
noreply at git.blender.org
Fri Aug 10 14:00:52 CEST 2018
Commit: 797b15e6842577324af4bbf367b48ed22bf5e6e3
Author: Martin Felke
Date: Thu Aug 9 17:47:35 2018 +0200
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rB797b15e6842577324af4bbf367b48ed22bf5e6e3
simulation jumps and interrupts itself still, regular rigidbodies crash...
===================================================================
M intern/rigidbody/rb_bullet_api.cpp
M source/blender/blenkernel/BKE_rigidbody.h
M source/blender/blenkernel/intern/fracture.c
M source/blender/blenkernel/intern/fracture_rigidbody.c
M source/blender/blenkernel/intern/pointcache.c
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/editors/object/object_modifier.c
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index 8d150ea22fb..844b69d870e 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -326,7 +326,7 @@ static void tickCallback(btDynamicsWorld *world, btScalar timeStep)
rbContactPoint* cp = tworld->make_contact_point(pt, obA, obB);
broken = weakenCompound(obA, cp->contact_force, pt.getPositionWorldOnA(), fworld);
broken = broken || weakenCompound(obB, cp->contact_force, pt.getPositionWorldOnB(), fworld);
- tworld->m_contactCallback(cp, tworld->m_bworld);
+ tworld->m_contactCallback(cp, tworld->m_bscene);
delete cp;
}
@@ -739,7 +739,7 @@ struct rbFilterCallback : public btOverlapFilterCallback
collides = collides && (rb0->col_groups & rb1->col_groups);
if (this->callback != NULL && collides) {
- int result = this->callback(rb0->world->blenderWorld, rb0->meshIsland, rb1->meshIsland,
+ int result = this->callback(rb0->world->blenderScene, rb0->meshIsland, rb1->meshIsland,
rb0->blenderOb, rb1->blenderOb, activate);
collides = collides && (bool)result;
@@ -898,7 +898,7 @@ public:
rbRigidBody *rb0 = (rbRigidBody*)colObj0->getUserPointer();
rbRigidBody *rb1 = (rbRigidBody*)colObj1->getUserPointer();
- do_collide = ((rbFilterCallback*)(rb0->world->filterCallback))->callback(rb0->world->blenderWorld,
+ do_collide = ((rbFilterCallback*)(rb0->world->filterCallback))->callback(rb0->world->blenderScene,
rb0->meshIsland, rb1->meshIsland,
rb0->blenderOb, rb1->blenderOb, false);
return !do_collide;
@@ -972,7 +972,7 @@ static void nearCallback(btBroadphasePair &collisionPair, btCollisionDispatcher
//handle_activation(manifold, rb0, rb1);
//handle_activation(manifold, rb1, rb0);
- ((rbFilterCallback*)(rb0->world->filterCallback))->callback(rb0->world->blenderWorld, rb0->meshIsland, rb1->meshIsland,
+ ((rbFilterCallback*)(rb0->world->filterCallback))->callback(rb0->world->blenderScene, rb0->meshIsland, rb1->meshIsland,
rb0->blenderOb, rb1->blenderOb, true);
}
}
@@ -1005,7 +1005,7 @@ rbDynamicsWorld *RB_dworld_new(const float gravity[3], void* blenderWorld, void*
TickDiscreteDynamicsWorld *tworld = new TickDiscreteDynamicsWorld(world->dispatcher,
world->pairCache,
- world->constraintSolver,
+ world->constraintSolver,
world->collisionConfiguration,
contactCallback, blenderWorld, blenderScene, idCallback, tickCallback);
@@ -1013,6 +1013,7 @@ rbDynamicsWorld *RB_dworld_new(const float gravity[3], void* blenderWorld, void*
world->dynamicsWorld = tworld;
world->blenderWorld = blenderWorld;
world->idOutCallback = idCallbackOut;
+ world->blenderScene = blenderScene;
RB_dworld_set_gravity(world, gravity);
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index f4d3416e972..aff826c7196 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -146,7 +146,7 @@ void BKE_rigidbody_update_sim_ob(struct Scene *scene, struct RigidBodyWorld *rbw
struct MeshIsland* BKE_rigidbody_closest_meshisland_to_point(struct FractureModifierData* fmd, struct Object *ob,
struct Object *ob2, struct Scene* scene, struct RigidBodyCon *con);
-int BKE_rigidbody_filter_callback(void* world, void* island1, void* island2, void *blenderOb1, void* blenderOb2, bool activate);
+int BKE_rigidbody_filter_callback(void* scene, void* island1, void* island2, void *blenderOb1, void* blenderOb2, bool activate);
void BKE_rigidbody_contact_callback(struct rbContactPoint* cp, void* world);
void BKE_rigidbody_id_callback(void *world, void* island, int* objectId, int* islandId);
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 23096a4fd78..9d332147558 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -5524,7 +5524,9 @@ static void do_post_island_creation(FractureModifierData *fmd, Object *ob, Mesh
if (fmd->shared->refresh)
{
fmd->shared->refresh = false;
- BKE_rigidbody_update_ob_array(scene->rigidbody_world, false);
+ BKE_rigidbody_update_ob_array(scene->rigidbody_world, true);
+
+ DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
fmd->shared->refresh_constraints = true;
diff --git a/source/blender/blenkernel/intern/fracture_rigidbody.c b/source/blender/blenkernel/intern/fracture_rigidbody.c
index a29588bed22..dd5d0b3df6a 100644
--- a/source/blender/blenkernel/intern/fracture_rigidbody.c
+++ b/source/blender/blenkernel/intern/fracture_rigidbody.c
@@ -16,7 +16,7 @@
#include "DNA_ID.h"
#include "DNA_fracture_types.h"
-#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#ifdef WITH_BULLET
#include "RBI_api.h"
@@ -701,8 +701,8 @@ void BKE_rigidbody_validate_sim_shard(RigidBodyWorld *rbw, MeshIsland *mi, Objec
BKE_rigidbody_validate_sim_shard_shape(mi, ob, true);
if (rbo->shared->physics_object) {
- if (rebuild == false /*|| mi->rigidbody->flag & RBO_FLAG_KINEMATIC_REBUILD*/)
- RB_dworld_remove_body(rbw->shared->physics_world, rbo->shared->physics_object);
+ //if (rebuild == false /*|| mi->rigidbody->flag & RBO_FLAG_KINEMATIC_REBUILD*/)
+ RB_dworld_remove_body(rbw->shared->physics_world, rbo->shared->physics_object);
}
if (!rbo->shared->physics_object || rebuild /*|| (fmd->use_animated_mesh && fmd->anim_mesh_ob)*/) {
@@ -1328,19 +1328,30 @@ static bool check_constraint_island(FractureModifierData* fmd, MeshIsland *mi1,
}
/* this allows partial object activation, only some shards will be activated, called from bullet(!) */
-int BKE_rigidbody_filter_callback(void* world, void* island1, void* island2, void *blenderOb1, void* blenderOb2, bool activate)
+int BKE_rigidbody_filter_callback(void* scene, void* island1, void* island2, void *blenderOb1, void* blenderOb2, bool activate)
{
+ //pass scene here, in order to hopefully get the original one from DEG
MeshIsland* mi1, *mi2;
- RigidBodyWorld *rbw = (RigidBodyWorld*)world;
+ Scene *sc = (Scene*)scene, *sc_orig;
+
+ RigidBodyWorld *rbw;
Object* ob1, *ob2;
int ob_index1 = -1, ob_index2 = -1;
bool validOb = true, check_activate = false;
+ // oh man... the pleasures of CoW...
+ sc_orig = DEG_get_original_id(sc);
+ rbw = sc_orig->rigidbody_world;
+
mi1 = (MeshIsland*)island1;
mi2 = (MeshIsland*)island2;
- FractureModifierData *fmd1 = (FractureModifierData*)modifiers_findByType((Object*)blenderOb1, eModifierType_Fracture);
- FractureModifierData *fmd2 = (FractureModifierData*)modifiers_findByType((Object*)blenderOb2, eModifierType_Fracture);
+ //MOOOOO
+ ob1 = DEG_get_original_object((Object*)blenderOb1);
+ ob2 = DEG_get_original_object((Object*)blenderOb2);
+
+ FractureModifierData *fmd1 = (FractureModifierData*)modifiers_findByType(ob1, eModifierType_Fracture);
+ FractureModifierData *fmd2 = (FractureModifierData*)modifiers_findByType(ob2, eModifierType_Fracture);
#if 0
if ((fmd1 && fmd1->fracture_mode == MOD_FRACTURE_EXTERNAL) ||
@@ -1723,7 +1734,8 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw, Object *obA,
void BKE_rigidbody_contact_callback(rbContactPoint* cp, void* world)
{
- RigidBodyWorld *rbw = (RigidBodyWorld*)world;
+ Scene* scene = DEG_get_original_id(world);
+ RigidBodyWorld *rbw = scene->rigidbody_world;
check_fracture(cp, rbw, NULL, NULL);
}
@@ -2274,16 +2286,9 @@ bool BKE_rigidbody_modifier_update(Scene* scene, Object* ob, RigidBodyWorld *rbw
short laststeps = rbw->steps_per_second;
float lastscale = rbw->time_scale;
int i = 0;
- ModifierData *md;
- FractureModifierData *fmd;
+ FractureModifierData *fmd = NULL;
- /* check for fractured objects which want to participate first, then handle other normal objects*/
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Fracture) {
- fmd = (FractureModifierData *)md;
- break;
- }
- }
+ fmd = (FractureModifierData*) modifiers_findByType(DEG_get_original_object(ob), eModifierType_Fracture);
if (BKE_rigidbody_modifier_active(fmd)) {
float max_con_mass = 0;
@@ -2310,7 +2315,7 @@ bool BKE_rigidbody_modifier_update(Scene* scene, Object* ob, RigidBodyWorld *rbw
int fr = (int)BKE_scene_frame_get(scene);
if (BKE_fracture_dynamic_lookup_mesh_state(fmd, fr, true, scene))
{
- BKE_rigidbody_update_ob_array(rbw, false);
+ BKE_rigidbody_update_ob_array(rbw, true);
}
}
//else
@@ -2609,7 +2614,7 @@ bool BKE_rigidbody_modifier_sync(ModifierData *md, Object *ob, Scene *scene, flo
if (BKE_fracture_dynamic_lookup_mesh_state(fmd, frame, true, scene))
{
- BKE_rigidbody_update_ob_array(rbw, false);
+ BKE_rigidbody_update_ob_array(rbw, true);
}
}
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 84d8a9c39d3..e0632e3ccc4 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1299,7 +1299,7 @@ static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int cfra
return 1;
}
- if (rbo && rbo->shared->physics_object)
+ if (rbo && rbo->shared && rbo->shared->physics_object)
{
#ifdef WITH_BULLET
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index e419886a12c..096dc6ef489 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1044,7 +1044,7 @@ void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool re
if (rebuild || rbw->shared->physics_world == NULL) {
if (rbw->shared->physics_world)
RB_dworld_delete(rbw->shared->physics_world);
- rbw->shared->physics_world = RB_d
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list