Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/alembic/exporter/abc_writer_abstract.cc
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | bool ABCAbstractWriter::is_supported(const HierarchyContext * /*context*/) const | ||||
| return true; | return true; | ||||
| } | } | ||||
| void ABCAbstractWriter::write(HierarchyContext &context) | void ABCAbstractWriter::write(HierarchyContext &context) | ||||
| { | { | ||||
| if (!frame_has_been_written_) { | if (!frame_has_been_written_) { | ||||
| is_animated_ = (args_.export_params->frame_start != args_.export_params->frame_end) && | is_animated_ = (args_.export_params->frame_start != args_.export_params->frame_end) && | ||||
| check_is_animated(context); | check_is_animated(context); | ||||
| ensure_custom_properties_exporter(context); | |||||
| } | } | ||||
| else if (!is_animated_) { | else if (!is_animated_) { | ||||
| /* A frame has already been written, and without animation one frame is enough. */ | /* A frame has already been written, and without animation one frame is enough. */ | ||||
| return; | return; | ||||
| } | } | ||||
| do_write(context); | do_write(context); | ||||
| if (custom_props_) { | |||||
| custom_props_->write_all(get_id_properties(context)); | |||||
| } | |||||
| frame_has_been_written_ = true; | frame_has_been_written_ = true; | ||||
| } | } | ||||
| void ABCAbstractWriter::ensure_custom_properties_exporter(const HierarchyContext &context) | |||||
| { | |||||
| if (!args_.export_params->export_custom_properties) { | |||||
| return; | |||||
| } | |||||
| if (custom_props_) { | |||||
| /* Custom properties exporter already created. */ | |||||
| return; | |||||
| } | |||||
| /* Avoid creating a custom properties exporter if there are no custom properties to export. */ | |||||
| const IDProperty *id_properties = get_id_properties(context); | |||||
| if (id_properties == nullptr || id_properties->len == 0) { | |||||
| return; | |||||
| } | |||||
| custom_props_ = std::make_unique<CustomPropertiesExporter>(this); | |||||
| } | |||||
| const IDProperty *ABCAbstractWriter::get_id_properties(const HierarchyContext &context) const | |||||
| { | |||||
| Object *object = context.object; | |||||
| if (object->data == nullptr) { | |||||
| return nullptr; | |||||
| } | |||||
| /* Most subclasses write object data, so default to the object data's ID properties. */ | |||||
| return static_cast<ID *>(object->data)->properties; | |||||
| } | |||||
| uint32_t ABCAbstractWriter::timesample_index() const | |||||
| { | |||||
| return timesample_index_; | |||||
| } | |||||
| const Imath::Box3d &ABCAbstractWriter::bounding_box() const | const Imath::Box3d &ABCAbstractWriter::bounding_box() const | ||||
| { | { | ||||
| return bounding_box_; | return bounding_box_; | ||||
| } | } | ||||
| void ABCAbstractWriter::update_bounding_box(Object *object) | void ABCAbstractWriter::update_bounding_box(Object *object) | ||||
| { | { | ||||
| BoundBox *bb = BKE_object_boundbox_get(object); | BoundBox *bb = BKE_object_boundbox_get(object); | ||||
| Show All 33 Lines | |||||