[Bf-blender-cvs] [6091d9a] alembic: Use the extended archive writer variant to set the correct start frame for slices.

Lukas Tönne noreply at git.blender.org
Mon May 18 20:36:04 CEST 2015


Commit: 6091d9afa05ebc7cf84d796ce4326635b764d407
Author: Lukas Tönne
Date:   Mon May 18 20:34:34 2015 +0200
Branches: alembic
https://developer.blender.org/rB6091d9afa05ebc7cf84d796ce4326635b764d407

Use the extended archive writer variant to set the correct start frame
for slices.

Also the time sampling for slice output properties must be passed down
from the output archive, since the input properties use the original
start frame and cycle times.

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

M	source/blender/editors/io/io_cache_library.c
M	source/blender/pointcache/alembic/abc_split.cpp
M	source/blender/pointcache/alembic/alembic.cpp
M	source/blender/pointcache/alembic/alembic.h

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

diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 0ed76fc..9c6292a 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -628,7 +628,7 @@ static int cache_library_archive_slice_exec(bContext *C, wmOperator *op)
 		return OPERATOR_CANCELLED;
 	}
 	
-	output_archive = PTC_open_writer_archive(scene, output_filename);
+	output_archive = PTC_open_writer_archive_ex(FPS, start_frame, output_filename);
 	if (!output_archive) {
 		BKE_reportf(op->reports, RPT_ERROR, "Cannot write to cache file at '%s'", output_filepath);
 		return OPERATOR_CANCELLED;
diff --git a/source/blender/pointcache/alembic/abc_split.cpp b/source/blender/pointcache/alembic/abc_split.cpp
index b769c5e..bbca286 100644
--- a/source/blender/pointcache/alembic/abc_split.cpp
+++ b/source/blender/pointcache/alembic/abc_split.cpp
@@ -73,11 +73,10 @@ using namespace ::Alembic::AbcGeom;
 
 namespace PTC {
 
-static void slice_properties(ICompoundProperty iParent, OCompoundProperty out_parent, chrono_t start, chrono_t end);
+static void slice_properties(ICompoundProperty iParent, OCompoundProperty out_parent, TimeSamplingPtr time_sampling, chrono_t start, chrono_t end);
 
-static void slice_array_property(IArrayProperty iProp, OCompoundProperty out_parent, chrono_t start, chrono_t end)
+static void slice_array_property(IArrayProperty iProp, OCompoundProperty out_parent, TimeSamplingPtr time_sampling, chrono_t start, chrono_t end)
 {
-	TimeSamplingPtr time_sampling = iProp.getTimeSampling();
 	OArrayProperty out(out_parent, iProp.getName(), iProp.getDataType(), iProp.getMetaData(), time_sampling);
 	
 	ArrayPropertyReaderPtr reader = iProp.getPtr();
@@ -115,9 +114,8 @@ static void slice_array_property(IArrayProperty iProp, OCompoundProperty out_par
 		delete[] buf;
 }
 
-static void slice_scalar_property(IScalarProperty iProp, OCompoundProperty out_parent, chrono_t start, chrono_t end)
+static void slice_scalar_property(IScalarProperty iProp, OCompoundProperty out_parent, TimeSamplingPtr time_sampling, chrono_t start, chrono_t end)
 {
-	TimeSamplingPtr time_sampling = iProp.getTimeSampling();
 	OScalarProperty out(out_parent, iProp.getName(), iProp.getDataType(), iProp.getMetaData(), time_sampling);
 	
 	ScalarPropertyReaderPtr reader = iProp.getPtr();
@@ -154,27 +152,27 @@ static void slice_scalar_property(IScalarProperty iProp, OCompoundProperty out_p
 	delete[] buf;
 }
 
-static void slice_compound_property(ICompoundProperty iProp, OCompoundProperty out_parent, chrono_t start, chrono_t end)
+static void slice_compound_property(ICompoundProperty iProp, OCompoundProperty out_parent, TimeSamplingPtr time_sampling, chrono_t start, chrono_t end)
 {
 	OCompoundProperty out(out_parent, iProp.getName(), iProp.getMetaData());
 	
-	slice_properties(iProp, out, start, end);
+	slice_properties(iProp, out, time_sampling, start, end);
 }
 
-static void slice_properties(ICompoundProperty iParent, OCompoundProperty out_parent, chrono_t start, chrono_t end)
+static void slice_properties(ICompoundProperty iParent, OCompoundProperty out_parent, TimeSamplingPtr time_sampling, chrono_t start, chrono_t end)
 {
 	for (size_t i = 0 ; i < iParent.getNumProperties() ; i++) {
 		PropertyHeader header = iParent.getPropertyHeader(i);
 		
 		if (header.isCompound()) {
-			slice_compound_property(ICompoundProperty(iParent, header.getName()), out_parent, start, end);
+			slice_compound_property(ICompoundProperty(iParent, header.getName()), out_parent, time_sampling, start, end);
 		}
 		else if (header.isScalar()) {
-			slice_scalar_property(IScalarProperty(iParent, header.getName()), out_parent, start, end);
+			slice_scalar_property(IScalarProperty(iParent, header.getName()), out_parent, time_sampling, start, end);
 		}
 		else {
 			BLI_assert(header.isArray());
-			slice_array_property(IArrayProperty(iParent, header.getName()), out_parent, start, end);
+			slice_array_property(IArrayProperty(iParent, header.getName()), out_parent, time_sampling, start, end);
 		}
 	}
 }
@@ -182,10 +180,10 @@ static void slice_properties(ICompoundProperty iParent, OCompoundProperty out_pa
 typedef std::map<ObjectReaderPtr, ObjectWriterPtr> ObjectMap;
 typedef std::pair<ObjectReaderPtr, ObjectWriterPtr> ObjectPair;
 
-static void slice_object(IObject iObj, OObject out, chrono_t start, chrono_t end, ObjectMap &object_map)
+static void slice_object(IObject iObj, OObject out, TimeSamplingPtr time_sampling, chrono_t start, chrono_t end, ObjectMap &object_map)
 {
 	// Get the properties.
-	slice_properties(iObj.getProperties(), out.getProperties(), start, end);
+	slice_properties(iObj.getProperties(), out.getProperties(), time_sampling, start, end);
 	
 	// now the child objects
 	for (size_t i = 0 ; i < iObj.getNumChildren() ; i++) {
@@ -204,7 +202,7 @@ static void slice_object(IObject iObj, OObject out, chrono_t start, chrono_t end
 				out_child = OObject(out, child_header.getName(), child_header.getMetaData());
 			object_map[child.getPtr()] = out_child.getPtr();
 			
-			slice_object(child, out_child, start, end, object_map);
+			slice_object(child, out_child, time_sampling, start, end, object_map);
 		}
 	}
 }
@@ -230,11 +228,11 @@ static void slice_object_instances(IObject iObj, OObject out, const ObjectMap &o
 	}
 }
 
-void abc_archive_slice(IArchive in, OArchive out, chrono_t start, chrono_t end)
+void abc_archive_slice(IArchive in, OArchive out, TimeSamplingPtr time_sampling, chrono_t start, chrono_t end)
 {
 	ObjectMap object_map;
 	
-	slice_object(in.getTop(), out.getTop(), start, end, object_map);
+	slice_object(in.getTop(), out.getTop(), time_sampling, start, end, object_map);
 	slice_object_instances(in.getTop(), out.getTop(), object_map);
 }
 
diff --git a/source/blender/pointcache/alembic/alembic.cpp b/source/blender/pointcache/alembic/alembic.cpp
index 284a960..c42a814 100644
--- a/source/blender/pointcache/alembic/alembic.cpp
+++ b/source/blender/pointcache/alembic/alembic.cpp
@@ -56,7 +56,7 @@ class AbcFactory : public Factory {
 		AbcReaderArchive *abc_in = static_cast<AbcReaderArchive*>(in);
 		AbcWriterArchive *abc_out = static_cast<AbcWriterArchive*>(out);
 		
-		abc_archive_slice(abc_in->abc_archive(), abc_out->abc_archive(), abc_in->frame_to_time(start_frame), abc_in->frame_to_time(end_frame));
+		abc_archive_slice(abc_in->abc_archive(), abc_out->abc_archive(), abc_out->frame_sampling(), abc_in->frame_to_time(start_frame), abc_in->frame_to_time(end_frame));
 	}
 	
 	Writer *create_writer_object(const std::string &name, Scene *scene, Object *ob)
diff --git a/source/blender/pointcache/alembic/alembic.h b/source/blender/pointcache/alembic/alembic.h
index 5074aeb..ad700a5 100644
--- a/source/blender/pointcache/alembic/alembic.h
+++ b/source/blender/pointcache/alembic/alembic.h
@@ -30,7 +30,7 @@ namespace PTC {
 void abc_archive_info_stream(Alembic::Abc::IArchive &archive, void (*stream)(void *, const char *), void *userdata);
 void abc_archive_info_nodes(Alembic::Abc::IArchive &archive, CacheArchiveInfo *info, bool calc_bytes_size);
 
-void abc_archive_slice(Alembic::Abc::IArchive in, Alembic::Abc::OArchive out, Alembic::Abc::chrono_t start, Alembic::Abc::chrono_t end);
+void abc_archive_slice(Alembic::Abc::IArchive in, Alembic::Abc::OArchive out, Alembic::Abc::TimeSamplingPtr time_sampling, Alembic::Abc::chrono_t start, Alembic::Abc::chrono_t end);
 
 } /* namespace PTC */




More information about the Bf-blender-cvs mailing list