[Bf-blender-cvs] [16533ad6100] temp-alembic-exporter-T73363-ms2: Merge remote-tracking branch 'origin/master' into temp-alembic-exporter-T73363-ms2

Sybren A. Stüvel noreply at git.blender.org
Fri Apr 10 15:39:37 CEST 2020


Commit: 16533ad6100c33dbd8da362ec32d052870a2219c
Author: Sybren A. Stüvel
Date:   Fri Apr 10 14:18:16 2020 +0200
Branches: temp-alembic-exporter-T73363-ms2
https://developer.blender.org/rB16533ad6100c33dbd8da362ec32d052870a2219c

Merge remote-tracking branch 'origin/master' into temp-alembic-exporter-T73363-ms2

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



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

diff --cc source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc
index df4d023be39,00000000000..818924d8f0b
mode 100644,000000..100644
--- a/source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc
+++ b/source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc
@@@ -1,154 -1,0 +1,153 @@@
 +/*
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) 2020 Blender Foundation.
 + * All rights reserved.
 + */
 +
 +#include "abc_hierarchy_iterator.h"
 +#include "abc_writer_abstract.h"
 +// #include "abc_writer_camera.h"
 +// #include "abc_writer_hair.h"
 +// #include "abc_writer_light.h"
 +#include "abc_writer_mesh.h"
 +// #include "abc_writer_metaball.h"
 +#include "abc_writer_transform.h"
 +
 +#include <string>
 +
 +extern "C" {
- #include "BKE_anim.h"
 +
 +#include "BLI_assert.h"
 +
 +#include "DEG_depsgraph_query.h"
 +
 +#include "DNA_ID.h"
 +#include "DNA_layer_types.h"
 +#include "DNA_object_types.h"
 +}
 +
 +namespace ABC {
 +
 +ABCHierarchyIterator::ABCHierarchyIterator(Depsgraph *depsgraph,
 +                                           ABCArchive *abc_archive,
 +                                           const AlembicExportParams &params)
 +    : AbstractHierarchyIterator(depsgraph), abc_archive_(abc_archive), params_(params)
 +{
 +}
 +
 +bool ABCHierarchyIterator::mark_as_weak_export(const Object *object) const
 +{
 +  if (params_.selected_only && (object->base_flag & BASE_SELECTED) == 0) {
 +    return true;
 +  }
 +  /* TODO(Sybren): handle other flags too? */
 +  return false;
 +}
 +
 +void ABCHierarchyIterator::delete_object_writer(AbstractHierarchyWriter *writer)
 +{
 +  delete static_cast<ABCAbstractWriter *>(writer);
 +}
 +
 +std::string ABCHierarchyIterator::make_valid_name(const std::string &name) const
 +{
 +  std::string abc_name(name);
 +  std::replace(abc_name.begin(), abc_name.end(), ' ', '_');
 +  std::replace(abc_name.begin(), abc_name.end(), '.', '_');
 +  std::replace(abc_name.begin(), abc_name.end(), ':', '_');
 +  return abc_name;
 +}
 +
 +ABCWriterConstructorArgs ABCHierarchyIterator::writer_constructor_args(
 +    const HierarchyContext *context)
 +{
 +  if (DEG_is_original_object(context->object)) {
 +    printf("writer_constructor_args: object is \033[93moriginal\033[0m\n");
 +  }
 +  else {
 +    printf("writer_constructor_args: object is \033[96mCOPY\033[0m\n");
 +  }
 +  return ABCWriterConstructorArgs{
 +      context->object, depsgraph_, abc_archive_, context->export_path, this, params_};
 +}
 +
 +AbstractHierarchyWriter *ABCHierarchyIterator::create_transform_writer(
 +    const HierarchyContext *context)
 +{
 +  return new ABCTransformWriter(writer_constructor_args(context));
 +}
 +
 +AbstractHierarchyWriter *ABCHierarchyIterator::create_data_writer(const HierarchyContext *context)
 +{
 +  ABCWriterConstructorArgs writer_args = writer_constructor_args(context);
 +  ABCAbstractWriter *data_writer = nullptr;
 +
 +  switch (context->object->type) {
 +    case OB_MESH:
 +      data_writer = new ABCMeshWriter(writer_args);
 +      break;
 +    case OB_CAMERA:
 +      // data_writer = new USDCameraWriter(writer_args);
 +      return nullptr;
 +      break;
 +    case OB_LAMP:
 +      // data_writer = new USDLightWriter(writer_args);
 +      return nullptr;
 +      break;
 +    case OB_MBALL:
 +      // data_writer = new USDMetaballWriter(writer_args);
 +      return nullptr;
 +      break;
 +
 +    case OB_EMPTY:
 +    case OB_CURVE:
 +    case OB_SURF:
 +    case OB_FONT:
 +    case OB_SPEAKER:
 +    case OB_LIGHTPROBE:
 +    case OB_LATTICE:
 +    case OB_ARMATURE:
 +    case OB_GPENCIL:
 +      return nullptr;
 +    case OB_TYPE_MAX:
 +      BLI_assert(!"OB_TYPE_MAX should not be used");
 +      return nullptr;
 +  }
 +
 +  if (!data_writer->is_supported(context)) {
 +    delete data_writer;
 +    return nullptr;
 +  }
 +
 +  return data_writer;
 +}
 +
 +AbstractHierarchyWriter *ABCHierarchyIterator::create_hair_writer(
 +    const HierarchyContext * /*context*/)
 +{
 +  if (!params_.export_hair) {
 +    return nullptr;
 +  }
 +  // return new USDHairWriter(writer_constructor_args(context));
 +  return nullptr;
 +}
 +
 +AbstractHierarchyWriter *ABCHierarchyIterator::create_particle_writer(const HierarchyContext *)
 +{
 +  return nullptr;
 +}
 +
 +}  // namespace ABC
diff --cc source/blender/io/alembic/intern/export/abc_writer_mesh.cc
index 85217be8bf1,00000000000..66c822d0d07
mode 100644,000000..100644
--- a/source/blender/io/alembic/intern/export/abc_writer_mesh.cc
+++ b/source/blender/io/alembic/intern/export/abc_writer_mesh.cc
@@@ -1,590 -1,0 +1,589 @@@
 +/*
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) 2020 Blender Foundation.
 + * All rights reserved.
 + */
 +#include "abc_writer_mesh.h"
 +#include "abc_hierarchy_iterator.h"
 +#include "intern/abc_axis_conversion.h"
 +
 +extern "C" {
 +#include "BLI_assert.h"
 +#include "BLI_math_vector.h"
 +
- #include "BKE_anim.h"
 +#include "BKE_customdata.h"
 +#include "BKE_lib_id.h"
 +#include "BKE_material.h"
 +#include "BKE_mesh.h"
 +#include "BKE_modifier.h"
 +#include "BKE_object.h"
 +
 +#include "bmesh.h"
 +#include "bmesh_tools.h"
 +
 +#include "DEG_depsgraph.h"
 +
 +#include "DNA_layer_types.h"
 +#include "DNA_mesh_types.h"
 +#include "DNA_meshdata_types.h"
 +#include "DNA_modifier_types.h"
 +#include "DNA_object_fluidsim_types.h"
 +#include "DNA_particle_types.h"
 +}
 +
 +using Alembic::Abc::FloatArraySample;
 +using Alembic::Abc::Int32ArraySample;
 +using Alembic::Abc::OObject;
 +using Alembic::Abc::V2fArraySample;
 +using Alembic::Abc::V3fArraySample;
 +
 +using Alembic::AbcGeom::kFacevaryingScope;
 +using Alembic::AbcGeom::OBoolProperty;
 +using Alembic::AbcGeom::OCompoundProperty;
 +using Alembic::AbcGeom::OFaceSet;
 +using Alembic::AbcGeom::OFaceSetSchema;
 +using Alembic::AbcGeom::ON3fGeomParam;
 +using Alembic::AbcGeom::OPolyMesh;
 +using Alembic::AbcGeom::OPolyMeshSchema;
 +using Alembic::AbcGeom::OSubD;
 +using Alembic::AbcGeom::OSubDSchema;
 +using Alembic::AbcGeom::OV2fGeomParam;
 +using Alembic::AbcGeom::UInt32ArraySample;
 +
 +namespace ABC {
 +
 +/* NOTE: Alembic's polygon winding order is clockwise, to match with Renderman. */
 +
 +static void get_vertices(struct Mesh *mesh, std::vector<Imath::V3f> &points);
 +static void get_topology(struct Mesh *mesh,
 +                         std::vector<int32_t> &poly_verts,
 +                         std::vector<int32_t> &loop_counts,
 +                         bool &r_has_flat_shaded_poly);
 +static void get_creases(struct Mesh *mesh,
 +                        std::vector<int32_t> &indices,
 +                        std::vector<int32_t> &lengths,
 +                        std::vector<float> &sharpnesses);
 +static void get_loop_normals(struct Mesh *mesh,
 +                             std::vector<Imath::V3f> &normals,
 +                             bool has_flat_shaded_poly);
 +
 +ABCGenericMeshWriter::ABCGenericMeshWriter(const ABCWriterConstructorArgs &args)
 +    : ABCAbstractWriter(args), is_subd_(false)
 +{
 +  /* If the object is static, use the default static time sampling. */
 +  timesample_index_ = is_animated_ ? timesample_index_geometry_ : 0;
 +
 +  Object *object_orig = DEG_get_original_object(args_.object);
 +  Scene *scene_orig = DEG_get_input_scene(args_.depsgraph);
 +
 +  // Do some initialisation for the first time we see this object.
 +  // TODO(Sybren): avoid keeping ModifierData pointers around?
 +  if (!args_.export_params.apply_subdiv) {
 +    subsurf_modifier_ = get_subsurf_modifier(scene_orig, object_orig);
 +    if (subsurf_modifier_ != nullptr) {
 +      subsurf_modifier_->flag |= eModifierMode_DisableTemporary;
 +      is_subd_ = args_.export_params.use_subdiv_schema;
 +    }
 +  }
 +  // TODO(Sybren): does this have to use the original, or the evaluated?
 +  liquid_sim_modifier_ = get_liquid_sim_modifier(scene_orig, object_orig);
 +}
 +
 +ABCGenericMeshWriter::~ABCGenericMeshWriter()
 +{
 +  if (subsurf_modifier_ != nullptr) {
 +    subsurf_modifier_->flag &= ~eModifierMode_DisableTemporary;
 +  }
 +}
 +
 +const Alembic::Abc::OObject ABCGenericMeshWriter::get_alembic_object() const
 +{
 +  if (is_subd_) {
 +    return abc_subdiv_;
 +  }
 +  return abc_poly_mesh_;
 +}
 +
 +/* Check whether the mesh is a subsurf, ignoring disabled modifiers and displace if it's after
 + * subsurf. */
 +ModifierData *ABCGenericMeshWriter::get_subsurf_modifier(Scene *scene_eval, Object *ob_eval)
 +{
 +  ModifierData *md = static_cast<ModifierData *>(ob_eval->modifiers.last);
 +
 +  for (; md; md = md->prev) {
 +    if (!modifier_isEnabled(scene_eval, md, eModifierMode_Render)) {
 +      continue;
 +    }
 +
 +    if (md->type == eModifierType_Subsurf) {
 +      SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData *>(

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list