[Bf-blender-cvs] [95e8a1b] alembic_basic_io: Merge branch 'master' into alembic_basic_io

Kévin Dietrich noreply at git.blender.org
Tue Jul 19 15:47:56 CEST 2016


Commit: 95e8a1b6511bbe3507349f8b754567387aa15cd3
Author: Kévin Dietrich
Date:   Tue Jul 19 13:52:55 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB95e8a1b6511bbe3507349f8b754567387aa15cd3

Merge branch 'master' into alembic_basic_io

Conflicts:
	intern/cycles/blender/blender_mesh.cpp
	intern/cycles/blender/blender_sync.h
	intern/cycles/render/scene.cpp

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



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

diff --cc intern/cycles/blender/blender_mesh.cpp
index 17a9b60,ec11a89..b9afb33
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@@ -680,65 -680,43 +680,102 @@@ static void create_subd_mesh(Scene *sce
  
  /* Sync */
  
 +static inline BL::MeshSequenceCacheModifier object_mesh_cache_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_MeshSequenceCacheModifier)) {
 +			continue;
 +		}
 +
 +		BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(*b_mod);
 +
 +		if (MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) {
 +			return mesh_cache;
 +		}
 +	}
 +
 +	return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
 +}
 +
 +static void sync_mesh_cached_velocities(BL::Object& b_ob, Scene *scene, Mesh *mesh)
 +{
 +	if(scene->need_motion() == Scene::MOTION_NONE)
 +		return;
 +
 +	BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(b_ob);
 +
 +	if(!mesh_cache)
 +		return;
 +
 +	/* TODO: check that the number of vertices still matches. */
 +
 +	/* 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);
 +	}
 +
 +	const size_t numverts = mesh->verts.size();
 +
 +	float3 *buffer = new float3[numverts];
 +
 +	MeshSequenceCacheModifier_velocity_cache_get(&mesh_cache.ptr, &buffer[0].x);
 +
 +	/* 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++) {
 +		const float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f;
 +		float3 *mP = attr_mP->data_float3() + step*numverts;
 +
 +		for (int i = 0; i < numverts; ++i) {
 +			mP[i] = P[i] + buffer[i]*relative_time;
 +		}
 +	}
 +
 +	delete [] buffer;
 +}
 +
+ static void sync_mesh_fluid_motion(BL::Object& b_ob, Scene *scene, Mesh *mesh)
+ {
+ 	if(scene->need_motion() == Scene::MOTION_NONE)
+ 		return;
+ 
+ 	BL::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob);
+ 
+ 	if(!b_fluid_domain)
+ 		return;
+ 
+ 	/* If the mesh has modifiers following the fluid domain we can't export motion. */
+ 	if(b_fluid_domain.fluid_mesh_vertices.length() != mesh->verts.size())
+ 		return;
+ 
+ 	/* 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++) {
+ 		float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f;
+ 		float3 *mP = attr_mP->data_float3() + step*mesh->verts.size();
+ 
+ 		BL::DomainFluidSettings::fluid_mesh_vertices_iterator fvi;
+ 		int i = 0;
+ 
+ 		for(b_fluid_domain.fluid_mesh_vertices.begin(fvi); fvi != b_fluid_domain.fluid_mesh_vertices.end(); ++fvi, ++i) {
+ 			mP[i] = P[i] + get_float3(fvi->velocity()) * relative_time;
+ 		}
+ 	}
+ }
+ 
  Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
                               bool object_updated,
                               bool hide_tris)
@@@ -880,9 -858,9 +917,12 @@@
  			mesh->displacement_method = Mesh::DISPLACE_BOTH;
  	}
  
 +	/* cached velocities (e.g. from alembic archive) */
 +	sync_mesh_cached_velocities(b_ob, scene, mesh);
 +
+ 	/* fluid motion */
+ 	sync_mesh_fluid_motion(b_ob, scene, mesh);
+ 
  	/* tag update */
  	bool rebuild = false;
  
@@@ -972,11 -950,11 +1012,16 @@@ void BlenderSync::sync_mesh_motion(BL::
  	 * would need a more extensive check to see which objects are animated */
  	BL::Mesh b_mesh(PointerRNA_NULL);
  
 +	/* cached motion is exported immediate with mesh, skip here */
 +	BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(b_ob);
 +	if (mesh_cache)
 +		return;
 +
+ 	/* fluid motion is exported immediate with mesh, skip here */
+ 	BL::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob);
+ 	if (b_fluid_domain)
+ 		return;
+ 
  	if(ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) {
  		/* get derived mesh */
  		b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, false);




More information about the Bf-blender-cvs mailing list