Commit: 7faf3f47363058ba4a2dfb15f180deffe706573e
Author: Martin Felke
Date:   Sat Mar 2 10:43:27 2019 +0100
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rB7faf3f47363058ba4a2dfb15f180deffe706573e

Merge remote-tracking branch 'origin/master' into fracture_modifier-2.8

# Conflicts:
#       intern/cycles/blender/blender_mesh.cpp
#       intern/rigidbody/RBI_api.h
#       intern/rigidbody/rb_bullet_api.cpp
#       source/blender/blenkernel/BKE_rigidbody.h
#       source/blender/blenkernel/intern/rigidbody.c
#       source/blender/depsgraph/intern/builder/deg_builder_relations.cc
#       source/blender/draw/intern/draw_manager.c
#       source/blender/editors/physics/rigidbody_object.c
#       source/blender/makesdna/DNA_modifier_types.h
#       source/blender/makesdna/DNA_rigidbody_types.h
#       source/blender/makesrna/intern/rna_modifier.c
#       source/blender/makesrna/intern/rna_rigidbody.c
#       source/blender/modifiers/intern/MOD_boolean.c
#       source/blender/modifiers/intern/MOD_multires.c
#       source/blender/modifiers/intern/MOD_remesh.c

===================================================================



===================================================================

diff --cc intern/cycles/blender/blender_mesh.cpp
index 836bdc91bfd,8e81e3ac121..1174fafa692
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@@ -975,87 -971,6 +971,67 @@@ static void sync_mesh_fluid_motion(BL::
        }
  }
  
 +static bool sync_mesh_precalculated_motion(BL::Mesh& b_mesh, BL::Object& 
b_ob, BL::Scene& b_scene, Scene *scene, Mesh *mesh)
 +{
 +      if(scene->need_motion() == Scene::MOTION_NONE)
 +              return false;
 +
 +      /* can have both modifiers, if we have a remesher, we take its data 
first (TODO, pass data from FM
 +       * to remesher in the future, too) */
 +
 +      BL::RemeshModifier b_remesher = object_metaball_remesher_find(b_ob);
 +      BL::FractureModifier b_fracture = object_fracture_modifier_find(b_ob);
 +
 +      if (!(b_remesher || b_fracture))
 +              return false;
 +
 +      /* Find or add attribute */
 +      float3 *P = &mesh->verts[0];
 +      Attribute *attr_mP = 
mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
 +
 +      if(!attr_mP) {
 +              attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
 +      }
 +
 +      /* Only export previous and next frame, we don't have any in between 
data. */
 +      float motion_times[2] = {-1.0f, 1.0f};
 +      for(int step = 0; step < 2; step++) {
 +              /* those are TIMES, but treated like Frames ? makes too high 
values, so take fps into account*/
 +              float relative_time = motion_times[step] * 
scene->motion_shutter_time() * 0.5f / b_scene.render().fps();
 +              float3 *mP = attr_mP->data_float3() + step*mesh->verts.size();
 +
 +              int i = 0;
 +
 +              {
 +                      BL::MeshVertexFloatPropertyLayer vlX = 
b_mesh.vertex_layers_float[std::string("velX")];
 +                      BL::MeshVertexFloatPropertyLayer vlY = 
b_mesh.vertex_layers_float[std::string("velY")];
 +                      BL::MeshVertexFloatPropertyLayer vlZ = 
b_mesh.vertex_layers_float[std::string("velZ")];
 +
 +                      BL::Pointer ptrX = (BL::Pointer)vlX;
 +                      BL::Pointer ptrY = (BL::Pointer)vlY;
 +                      BL::Pointer ptrZ = (BL::Pointer)vlZ;
 +
 +                      if (!ptrX || !ptrY || !ptrZ || vlX.data.length() != 
mesh->verts.size())
 +                      {
 +                              return false;
 +                      }
 +
 +                      for(i = 0; i < mesh->verts.size(); i++)
 +                      {
 +                              float x = vlX.data[i].value();
 +                              float y = vlY.data[i].value();
 +                              float z = vlZ.data[i].value();
 +
 +                              //printf("Vel %f %f %f\n", (double)x, 
(double)y, (double)z);
 +                              mP[i] = P[i] + make_float3(x, y, z) * 
relative_time;
 +                      }
 +              }
- #if 0
-               else if (b_fracture)
-               {
-                       /*directly access rigidbody data here, take lin+angvel 
*/
-                       //iterate over shard's verts, each vert moves "same" as 
shard does, well we need to calculate
-                       BL::FractureModifierShared::shards_iterator si;
-                       int j = 0;
- 
-                       for(b_fracture.shared().shards.begin(si); si != 
b_fracture.shared().shards.end(); ++si, ++i)
-                       {
-                               BL::Mesh::vertices_iterator vi;
-                               for(si->mesh().vertices.begin(vi); vi != 
si->mesh().vertices.end(); ++vi, ++j) {
-                                       BL::RigidBodyObject rbo = 
si->rigidbody();
- 
-                                       if (j < mesh->verts.size())
-                                               mP[j] = P[j] + 
(get_float3(rbo.linear_velocity()) + get_float3(rbo.angular_velocity())) * 
relative_time;
-                               }
-                       }
-               }
- #endif
 +      }
 +
 +      return true;
 +}
 +
 +
  Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
                               BL::Object& b_ob,
                               BL::Object& b_ob_instance,
@@@ -1177,13 -1091,12 +1152,15 @@@
                                create_mesh_volume_attributes(scene, b_ob, 
mesh, b_scene.frame_current());
                        }
  
-                       if(view_layer.use_hair && mesh->subdivision_type == 
Mesh::SUBDIVISION_NONE)
+                       /* Sync hair curves. */
+                       if(view_layer.use_hair && show_particles && 
mesh->subdivision_type == Mesh::SUBDIVISION_NONE) {
                                sync_curves(mesh, b_mesh, b_ob, false);
+                       }
  
++                      /* Sync precalculated motion vectors, aka Metaball 
remesh and Fracture Modifier */
 +                      sync_mesh_precalculated_motion(b_mesh, b_ob, b_scene, 
scene, mesh);
 +
-                       /* free derived mesh */
-                       b_data.meshes.remove(b_mesh, false, true, false);
+                       free_object_to_mesh(b_data, b_ob, b_mesh);
                }
        }
        mesh->geometry_flags = requested_geometry_flags;
diff --cc source/blender/blenkernel/BKE_library.h
index 7e260b34e36,9409c8710d6..657876012ba
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@@ -119,16 -145,18 +145,19 @@@ enum 
  
        LIB_ID_FREE_NO_DEG_TAG         = 1 << 8,  /* Do not tag freed ID for 
update in depsgraph. */
        LIB_ID_FREE_NO_UI_USER         = 1 << 9,  /* Do not attempt to remove 
freed ID from UI data/notifiers/... */
 +      LIB_ID_FREE_COPY_ON_WRITE      = 1 << 10, /* Mark this free operation 
as being triggered by CoW*/
  };
  
+ void BKE_libblock_free_datablock(struct ID *id, const int flag) 
ATTR_NONNULL();
+ void BKE_libblock_free_data(struct ID *id, const bool do_id_user) 
ATTR_NONNULL();
+ 
  void BKE_id_free_ex(struct Main *bmain, void *idv, int flag, const bool 
use_flag_from_idtag);
  void BKE_id_free(struct Main *bmain, void *idv);
- /* Those three naming are bad actually, should be BKE_id_free... (since it 
goes beyond mere datablock). */
- /* "Deprecated" old API */
- void  BKE_libblock_free_ex(struct Main *bmain, void *idv, const bool 
do_id_user, const bool do_ui_user) ATTR_NONNULL();
- void  BKE_libblock_free(struct Main *bmain, void *idv) ATTR_NONNULL();
- void  BKE_libblock_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
+ 
+ void BKE_id_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
+ 
+ void BKE_id_delete(struct Main *bmain, void *idv) ATTR_NONNULL();
+ void BKE_id_multi_tagged_delete(struct Main *bmain) ATTR_NONNULL();
  
  void BKE_libblock_management_main_add(struct Main *bmain, void *idv);
  void BKE_libblock_management_main_remove(struct Main *bmain, void *idv);
diff --cc source/blender/blenkernel/BKE_rigidbody.h
index 1f940fa178c,4c644ee43fc..4652f401185
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@@ -17,17 -15,11 +17,17 @@@
   *
   * The Original Code is Copyright (C) 2013 Blender Foundation
   * All rights reserved.
 + *
 + * The Original Code is: all of this file.
 + *
-  * Contributor(s): Joshua Leung, Sergej Reich
++ * Contributor(s): Joshua Leung, Sergej Reich, Martin Felke
 + *
 + * ***** END GPL LICENSE BLOCK *****
   */
  
 -/** \file
 - * \ingroup blenkernel
 - * \brief API for Blender-side Rigid Body stuff
 +/** \file BKE_rigidbody.h
 + *  \ingroup blenkernel
 + *  \brief API for Blender-side Rigid Body stuff
   */
  
  
@@@ -134,44 -97,13 +134,44 @@@ void BKE_rigidbody_update_ob_array(stru
  /* -------------- */
  /* Simulation */
  
 -void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float 
rot[3], float quat[4], float rotAxis[3], float rotAngle);
 -void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object 
*ob, float ctime);
 +void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float 
rot[3],
 +                                     float quat[4], float rotAxis[3], float 
rotAngle);
- void BKE_rigidbody_sync_transforms(struct Scene* scene, struct Object *ob, 
float ctime);
++void BKE_rigidbody_sync_transforms(struct Scene* scene, struct Object *ob, 
struct Depsgraph *depsgraph);
  bool BKE_rigidbody_check_sim_running(struct RigidBodyWorld *rbw, float ctime);
 -void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw);
 +void BKE_rigidbody_cache_reset(struct Scene *scene);
  void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, struct Scene 
*scene, float ctime);
  void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, struct Scene 
*scene, float ctime);
  
 +
 +// other misc stuff (implemented in rigidbody.c or fracture_rigidbody.c
 +struct rbCollisionShape *BKE_rigidbody_get_shape_trimesh_from_mesh(struct 
Object *ob, struct Mesh* me);
 +struct rbCollisionShape *BKE_rigidbody_get_shape_convexhull_from_mesh(struct 
Mesh *dm, float margin, bool *can_embed);
 +void BKE_rigidbody_update_sim_ob(struct Scene *scene, struct RigidBodyWorld 
*rbw, struct Object *ob,
 +                                   struct RigidBodyOb *rbo, float 
centroid[3], struct Shard *mi, float size[3],
 +                                   struct FractureModifierData *fmd, struct 
Depsgraph *depsgraph);
 +
 +struct Shard* BKE_rigidbody_closest_meshisland_to_point(struct 
FractureModifierData* fmd, struct Object *ob,
 +                                                             struct Object 
*ob2, struct Scene* scene);
 +
 +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* sc);
 +void BKE_rigidbody_id_callback(void* island, int* objectId, int* islandId);
 +
 +bool BKE_rigidbody_modifier_active(struct FractureModifierData *rmd);
 +void BKE_rigidbody_shard_validate(struct RigidBodyWorld *rbw, struct Shard 
*mi, struct Object *ob,
 +                                  struct FractureModifierData *fmd, int 
rebuild, int transfer_speed, float size[3], float frame);
 +
 +void BKE_rigidbody_activate(struct RigidBodyOb* rbo, struct RigidBodyWorld 
*rbw, struct Shard *mi, struct Object *ob);
 +bool BKE_rigidbody_modifier_update(struct Scene* scene, struct Object* ob, 
struct RigidBodyWorld *rbw,  bool rebuild,
 +                                   struct Depsgraph *depsgraph);
 +
- bool BKE_rigidbody_modifier_sync(struct ModifierData *md, struct Object *ob, 
struct Scene *scene, float ctime);
++bool BKE_rigidbody_modifier_sync(struct ModifierData *md, struct Object *ob, 
struct Scene *scene, struct Depsgraph *depsgraph);
 +void BKE_rigidbody_passive_hook(struct FractureModifierData *fmd, struct 
Shard *mi, struct Object* ob,
 +                                struct Scene* scene, struct Depsgraph 
*depsgraph);
 +
 +void BKE_rigidbody_passive_fake_parenting(struct FractureModifierData *fmd, 
struct Object *ob, struct RigidBodyOb *rbo,
 +                                          float imat[4][4]);
 +
  /* -------------------- */
  /* Depsgraph evaluation */
  
@@@ -185,11 -117,4 +185,10 @@@ void BKE_rigidbody_object_sync_transfor
                                            struct Scene *scene,
                                            struct Object *ob);
  
 +bool BKE_restoreKinematic(struct RigidBodyWorld *rbw, bool overri

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to