[Bf-blender-cvs] [0f093de7f3c] temp-fracture-modifier-2.8: re-added metaball remesher and deform motionblur in cycles for it and FM
Martin Felke
noreply at git.blender.org
Wed Dec 12 21:39:21 CET 2018
Commit: 0f093de7f3c8216ddda7ba17a4841ec542226bde
Author: Martin Felke
Date: Wed Dec 12 21:38:23 2018 +0100
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rB0f093de7f3c8216ddda7ba17a4841ec542226bde
re-added metaball remesher and deform motionblur in cycles for it and FM
===================================================================
M intern/cycles/blender/blender_mesh.cpp
M intern/cycles/blender/blender_util.h
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/blenkernel/BKE_fracture.h
M source/blender/blenkernel/BKE_mball_tessellate.h
M source/blender/blenkernel/intern/fracture.c
M source/blender/blenkernel/intern/mball_tessellate.c
M source/blender/blenkernel/intern/pointcache.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/makesrna/intern/rna_rigidbody.c
M source/blender/modifiers/intern/MOD_remesh.c
===================================================================
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index b27de775c54..836bdc91bfd 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -975,6 +975,87 @@ static void sync_mesh_fluid_motion(BL::Object& b_ob, Scene *scene, Mesh *mesh)
}
}
+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,
@@ -1099,6 +1180,8 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
if(view_layer.use_hair && mesh->subdivision_type == Mesh::SUBDIVISION_NONE)
sync_curves(mesh, b_mesh, b_ob, false);
+ sync_mesh_precalculated_motion(b_mesh, b_ob, b_scene, scene, mesh);
+
/* free derived mesh */
b_data.meshes.remove(b_mesh, false, true, false);
}
@@ -1160,6 +1243,12 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph& b_depsgraph,
if(b_fluid_domain)
return;
+ /* other precalculated motion (remesher / FM for now only) */
+ 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;
+
if(ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) {
/* get derived mesh */
b_mesh = object_to_mesh(b_data,
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index 53800cab90d..a626a225a3e 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -589,6 +589,36 @@ static inline BL::DomainFluidSettings object_fluid_domain_find(BL::Object b_ob)
return BL::DomainFluidSettings(PointerRNA_NULL);
}
+static inline BL::RemeshModifier object_metaball_remesher_find(BL::Object b_ob)
+{
+ BL::Object::modifiers_iterator b_mod;
+
+ for(b_ob.modifiers.begin(b_mod); b_mod != b_ob.modifiers.end(); ++b_mod) {
+ if(b_mod->is_a(&RNA_RemeshModifier)) {
+ BL::RemeshModifier b_fmd(*b_mod);
+
+ if(b_fmd.mode() == BL::RemeshModifier::mode_METABALL)
+ return b_fmd;
+ }
+ }
+
+ return BL::RemeshModifier(PointerRNA_NULL);
+}
+
+static inline BL::FractureModifier object_fracture_modifier_find(BL::Object b_ob)
+{
+ BL::Object::modifiers_iterator b_mod;
+
+ for(b_ob.modifiers.begin(b_mod); b_mod != b_ob.modifiers.end(); ++b_mod) {
+ if(b_mod->is_a(&RNA_FractureModifier)) {
+ BL::FractureModifier b_fmd(*b_mod);
+ return b_fmd;
+ }
+ }
+
+ return BL::FractureModifier(PointerRNA_NULL);
+}
+
static inline Mesh::SubdivisionType object_subdivision_type(BL::Object& b_ob, bool preview, bool experimental)
{
PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles");
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 3091421aa2b..2781c7934fe 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1212,7 +1212,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col = row.column(align=True)
col.prop(md, "mball_size")
col = row.column(align=True)
- col.label("Display Parameters:")
+ col.label(text="Display Parameters:")
col.prop(md, "mball_threshold")
col.prop(md, "mball_resolution")
col.prop(md, "mball_render_resolution")
diff --git a/source/blender/blenkernel/BKE_fracture.h b/source/blender/blenkernel/BKE_fracture.h
index f6ebc0a4540..b28b25f54f2 100644
--- a/source/blender/blenkernel/BKE_fracture.h
+++ b/source/blender/blenkernel/BKE_fracture.h
@@ -150,7 +150,6 @@ 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);
-void BKE_update_velocity_layer(struct FractureModifierData *fmd, struct Mesh *dm);
bool BKE_rigidbody_remove_modifier(struct RigidBodyWorld* rbw, struct ModifierData *md, struct Object *ob);
void BKE_fracture_external_constraints_setup(struct FractureModifierData *fmd, struct Scene *scene, struct Object *ob, int frame);
@@ -190,4 +189,6 @@ bool BKE_fracture_handle_initial_shards(struct FractureModifierData* fmd, struct
void BKE_fracture_meshislands_connect(struct Scene* scene, struct FractureModifierData* fmd,
struct Shard* mi, struct Shard* mi2, short con_type, float thresh);
+void BKE_fracture_shard_velocity_ensure(struct Shard* mi);
+
#endif /* BKE_FRACTURE_H */
diff --git a/source/blender/blenkernel/BKE_mball_tessellate.h b/source/blender/blenkernel/BKE_mball_tessellate.h
index 363bfe09c75..8709f7d02c5 100644
--- a/source/blender/blenkernel/BKE_mball_tessellate.h
+++ b/source/blender/blenkernel/BKE_mball_tessellate.h
@@ -27,6 +27,7 @@ struct Depsgraph;
struct Main;
struct Object;
struct Scene;
+struct Mesh;
void BKE_mball_polygonize(
struct Depsgraph *depsgraph, struct Scene *scene,
@@ -34,4 +35,7 @@ void BKE_mball_polygonize(
void BKE_mball_cubeTable_free(void);
+struct Mesh* BKE_repolygonize_dm(struct Mesh *dm, float thresh, float basesize[3], float wiresize, float rendersize,
+ bool render, bool override_size, int defgrp_size);
+
#endif /* __BKE_MBALL_TESSELLATE_H__ */
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 2e808268441..f597f9268ad 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -1252,10 +1252,9 @@ static void do_marking(FractureModifierData *fmd, Mesh *result)
}
}
-void BKE_fracture_copy_customdata(CustomData* src, CustomData* dst,CustomDataMask mask, int src_ofs, int dst_ofs,
- int copyelem, int totelem)
+void BKE_fracture_copy_customdata(CustomData* src, CustomData* dst,CustomDataMask mask,
+ int src_ofs, int dst_ofs, int copyelem, int totelem)
{
-
CustomDataLayer *layer;
int i;
for (i = 0; i < src->totlayer; i++)
@@ -1263,12 +1262,14 @@ void BKE_fracture_copy_customdata(CustomData* src, CustomData* dst,CustomDataMas
layer = src->layers + i;
if (mask & CD_TYPE_AS_MASK(layer->type))
{
- if (!CustomData_has_layer(dst, layer->type))
+ if (!CustomData_get_layer_named(dst, layer->type, layer->name))
{
- CustomData_add_layer(dst, layer->type, CD_CALLOC, NULL, totelem);
+ CustomData_add_layer_named(dst, layer->type, CD_CALLOC, NULL, totelem, layer->name);
}
- CustomData_copy_data_layer(src, dst, i, CustomData_get_layer_index(dst, layer->type), src_ofs, dst_ofs, copyelem);
+ CustomData_copy_data_layer(src, dst, i,
+ CustomData_get_named_layer_index(dst, layer->type, layer->name),
+ src_ofs, dst_ofs, copyelem);
}
}
}
@@ -1522,53 +1523,6 @@ void BKE_bm_mesh_hflag_flush_vert(BMesh *bm, const char hflag)
}
}
-void BKE_update_velocity_layer(FractureModifierData *fmd, Mesh *dm)
-{
- float *velX=NULL, *velY=NULL, *velZ = NULL;
- RigidBodyOb *rbo = NULL;
- int i = 0;
- Shard *mi;
- int totvert;
-
- if (!dm)
- return;
-
- if (dm->totvert == 0) {
- return;
- }
-
- totvert = dm->totvert;
-
- velX = CustomData_get_layer_named(&dm->vdata, CD_PROP_FLT, "velX");
- velY = CustomData_get_layer_named(&dm->vdata, CD_PROP_FLT, "velY");
- velZ = CustomData_get_layer_named(&dm->vdata, C
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list