Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-06-19 17:36:10 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-06-30 12:38:46 +0300
commit2917df21adc8a1ce0423349909db61d22a38d451 (patch)
tree35b8ccdf0078fda4f186821b016701f46cb42c86 /source/blender/io/alembic/exporter/abc_writer_points.cc
parenta2b7c84ae8eadf5983ee42091ce4e33315ca83ce (diff)
Alembic: new exporter based on the USD exporter structure
The Alembic exporter has been restructured by leverages the `AbstractHierarchyIterator` introduced by the USD exporter. The produced Alembic files have not changed much (details below), as the Alembic writing code has simply been moved from the old exporter to the new. How the export hierarchy is handled changed a lot, though, and also the way in which transforms are computed. As a result, T71395 is fixed. Differences between the old and new exporter, in terms of the produced Alembic file: - Duplicated objects now have a unique numerical suffix. - Matrices are computed differently, namely by simply computing the evaluated transform of the object relative to the evaluated transform of its export-parent. This fixes {T71395}, but otherwise should produce the same result as before (but with simpler code). Compared to the old Alembic exporter, Subdivision modifiers are now disabled in a cleaner, more efficient way (they are disabled when exporting with the "Apply Subdivisions" option is unchecked). Previously the exporter would move to a new frame, disable the modifier, evaluate the object, and enable the modifier again. This is now done before exporting starts, and modifiers are only restored when exporting ends. Some issues with the old Alembic exporter that have NOT been fixed in this patch: - Exporting NURBS patches and curves (see T49114 for example). - Exporting flattened hierarchy in combination with dupli-objects. This seems to be broken in the old Alembic exporter as well, but nobody reported this yet. Differential Revision: https://developer.blender.org/D7664 Reviewed By: Sergey
Diffstat (limited to 'source/blender/io/alembic/exporter/abc_writer_points.cc')
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_points.cc100
1 files changed, 59 insertions, 41 deletions
diff --git a/source/blender/io/alembic/exporter/abc_writer_points.cc b/source/blender/io/alembic/exporter/abc_writer_points.cc
index 4d7f5d11c36..19870e39a90 100644
--- a/source/blender/io/alembic/exporter/abc_writer_points.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_points.cc
@@ -22,9 +22,6 @@
*/
#include "abc_writer_points.h"
-#include "abc_writer_mesh.h"
-#include "abc_writer_transform.h"
-#include "intern/abc_util.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
@@ -36,81 +33,102 @@
#include "DEG_depsgraph_query.h"
+#include "CLG_log.h"
+static CLG_LogRef LOG = {"io.alembic"};
+
+namespace blender {
+namespace io {
+namespace alembic {
+
using Alembic::AbcGeom::kVertexScope;
using Alembic::AbcGeom::OPoints;
using Alembic::AbcGeom::OPointsSchema;
-/* ************************************************************************** */
+ABCPointsWriter::ABCPointsWriter(const ABCWriterConstructorArgs &args) : ABCAbstractWriter(args)
+{
+}
-namespace blender {
-namespace io {
-namespace alembic {
+void ABCPointsWriter::create_alembic_objects(const HierarchyContext * /*context*/)
+{
+ CLOG_INFO(&LOG, 2, "exporting OPoints %s", args_.abc_path.c_str());
+ abc_points_ = OPoints(args_.abc_parent, args_.abc_name, timesample_index_);
+ abc_points_schema_ = abc_points_.getSchema();
+}
-AbcPointsWriter::AbcPointsWriter(Object *ob,
- AbcTransformWriter *parent,
- uint32_t time_sampling,
- ExportSettings &settings,
- ParticleSystem *psys)
- : AbcObjectWriter(ob, time_sampling, settings, parent)
+const Alembic::Abc::OObject ABCPointsWriter::get_alembic_object() const
{
- m_psys = psys;
+ return abc_points_;
+}
- std::string psys_name = get_valid_abc_name(psys->name);
- OPoints points(parent->alembicXform(), psys_name, m_time_sampling);
- m_schema = points.getSchema();
+bool ABCPointsWriter::is_supported(const HierarchyContext *context) const
+{
+ return ELEM(context->particle_system->part->type,
+ PART_EMITTER,
+ PART_FLUID_FLIP,
+ PART_FLUID_SPRAY,
+ PART_FLUID_BUBBLE,
+ PART_FLUID_FOAM,
+ PART_FLUID_TRACER,
+ PART_FLUID_SPRAYFOAM,
+ PART_FLUID_SPRAYBUBBLE,
+ PART_FLUID_FOAMBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE);
}
-void AbcPointsWriter::do_write()
+bool ABCPointsWriter::check_is_animated(const HierarchyContext & /*context*/) const
{
- if (!m_psys) {
- return;
- }
+ /* We assume that particles are always animated. */
+ return true;
+}
+
+void ABCPointsWriter::do_write(HierarchyContext &context)
+{
+ BLI_assert(context.particle_system != nullptr);
std::vector<Imath::V3f> points;
std::vector<Imath::V3f> velocities;
std::vector<float> widths;
std::vector<uint64_t> ids;
+ ParticleSystem *psys = context.particle_system;
ParticleKey state;
-
ParticleSimulationData sim;
- sim.depsgraph = m_settings.depsgraph;
- sim.scene = m_settings.scene;
- sim.ob = m_object;
- sim.psys = m_psys;
+ sim.depsgraph = args_.depsgraph;
+ sim.scene = DEG_get_evaluated_scene(args_.depsgraph);
+ sim.ob = context.object;
+ sim.psys = psys;
- m_psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
+ psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
uint64_t index = 0;
- for (int p = 0; p < m_psys->totpart; p++) {
+ for (int p = 0; p < psys->totpart; p++) {
float pos[3], vel[3];
- if (m_psys->particles[p].flag & (PARS_NO_DISP | PARS_UNEXIST)) {
+ if (psys->particles[p].flag & (PARS_NO_DISP | PARS_UNEXIST)) {
continue;
}
- state.time = DEG_get_ctime(m_settings.depsgraph);
-
+ state.time = DEG_get_ctime(args_.depsgraph);
if (psys_get_particle_state(&sim, p, &state, 0) == 0) {
continue;
}
/* location */
- mul_v3_m4v3(pos, m_object->imat, state.co);
+ mul_v3_m4v3(pos, context.object->imat, state.co);
/* velocity */
- sub_v3_v3v3(vel, state.co, m_psys->particles[p].prev_state.co);
+ sub_v3_v3v3(vel, state.co, psys->particles[p].prev_state.co);
/* Convert Z-up to Y-up. */
points.push_back(Imath::V3f(pos[0], pos[2], -pos[1]));
velocities.push_back(Imath::V3f(vel[0], vel[2], -vel[1]));
- widths.push_back(m_psys->particles[p].size);
+ widths.push_back(psys->particles[p].size);
ids.push_back(index++);
}
- if (m_psys->lattice_deform_data) {
- BKE_lattice_deform_data_destroy(m_psys->lattice_deform_data);
- m_psys->lattice_deform_data = NULL;
+ if (psys->lattice_deform_data) {
+ BKE_lattice_deform_data_destroy(psys->lattice_deform_data);
+ psys->lattice_deform_data = NULL;
}
Alembic::Abc::P3fArraySample psample(points);
@@ -119,10 +137,10 @@ void AbcPointsWriter::do_write()
Alembic::Abc::FloatArraySample wsample_array(widths);
Alembic::AbcGeom::OFloatGeomParam::Sample wsample(wsample_array, kVertexScope);
- m_sample = OPointsSchema::Sample(psample, idsample, vsample, wsample);
- m_sample.setSelfBounds(bounds());
-
- m_schema.set(m_sample);
+ OPointsSchema::Sample sample(psample, idsample, vsample, wsample);
+ update_bounding_box(context.object);
+ sample.setSelfBounds(bounding_box_);
+ abc_points_schema_.set(sample);
}
} // namespace alembic