diff options
Diffstat (limited to 'source/blender/io')
79 files changed, 395 insertions, 407 deletions
diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt index cbcdfaf4b77..6de7d327d4e 100644 --- a/source/blender/io/alembic/CMakeLists.txt +++ b/source/blender/io/alembic/CMakeLists.txt @@ -41,6 +41,7 @@ set(INC_SYS ) set(SRC + intern/abc_axis_conversion.cc intern/abc_customdata.cc intern/abc_exporter.cc intern/abc_reader_archive.cc @@ -65,6 +66,7 @@ set(SRC intern/alembic_capi.cc ABC_alembic.h + intern/abc_axis_conversion.h intern/abc_customdata.h intern/abc_exporter.h intern/abc_reader_archive.h diff --git a/source/blender/io/alembic/intern/abc_axis_conversion.cc b/source/blender/io/alembic/intern/abc_axis_conversion.cc new file mode 100644 index 00000000000..17db5e9c99f --- /dev/null +++ b/source/blender/io/alembic/intern/abc_axis_conversion.cc @@ -0,0 +1,166 @@ +/* + * 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. + */ + +/** \file + * \ingroup Alembic + */ + +#include "abc_axis_conversion.h" + +extern "C" { +#include "BLI_assert.h" +#include "DNA_object_types.h" + +#include "BLI_math_geom.h" +} + +void create_swapped_rotation_matrix(float rot_x_mat[3][3], + float rot_y_mat[3][3], + float rot_z_mat[3][3], + const float euler[3], + AbcAxisSwapMode mode) +{ + const float rx = euler[0]; + float ry; + float rz; + + /* Apply transformation */ + switch (mode) { + case ABC_ZUP_FROM_YUP: + ry = -euler[2]; + rz = euler[1]; + break; + case ABC_YUP_FROM_ZUP: + ry = euler[2]; + rz = -euler[1]; + break; + default: + ry = 0.0f; + rz = 0.0f; + BLI_assert(false); + break; + } + + unit_m3(rot_x_mat); + unit_m3(rot_y_mat); + unit_m3(rot_z_mat); + + rot_x_mat[1][1] = cos(rx); + rot_x_mat[2][1] = -sin(rx); + rot_x_mat[1][2] = sin(rx); + rot_x_mat[2][2] = cos(rx); + + rot_y_mat[2][2] = cos(ry); + rot_y_mat[0][2] = -sin(ry); + rot_y_mat[2][0] = sin(ry); + rot_y_mat[0][0] = cos(ry); + + rot_z_mat[0][0] = cos(rz); + rot_z_mat[1][0] = -sin(rz); + rot_z_mat[0][1] = sin(rz); + rot_z_mat[1][1] = cos(rz); +} + +/* Convert matrix from Z=up to Y=up or vice versa. + * Use yup_mat = zup_mat for in-place conversion. */ +void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode) +{ + float dst_rot[3][3], src_rot[3][3], dst_scale_mat[4][4]; + float rot_x_mat[3][3], rot_y_mat[3][3], rot_z_mat[3][3]; + float src_trans[3], dst_scale[3], src_scale[3], euler[3]; + + zero_v3(src_trans); + zero_v3(dst_scale); + zero_v3(src_scale); + zero_v3(euler); + unit_m3(src_rot); + unit_m3(dst_rot); + unit_m4(dst_scale_mat); + + /* TODO(Sybren): This code assumes there is no sheer component and no + * homogeneous scaling component, which is not always true when writing + * non-hierarchical (e.g. flat) objects (e.g. when parent has non-uniform + * scale and the child rotates). This is currently not taken into account + * when axis-swapping. */ + + /* Extract translation, rotation, and scale form matrix. */ + mat4_to_loc_rot_size(src_trans, src_rot, src_scale, src_mat); + + /* Get euler angles from rotation matrix. */ + mat3_to_eulO(euler, ROT_MODE_XZY, src_rot); + + /* Create X, Y, Z rotation matrices from euler angles. */ + create_swapped_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler, mode); + + /* Concatenate rotation matrices. */ + mul_m3_m3m3(dst_rot, dst_rot, rot_z_mat); + mul_m3_m3m3(dst_rot, dst_rot, rot_y_mat); + mul_m3_m3m3(dst_rot, dst_rot, rot_x_mat); + + mat3_to_eulO(euler, ROT_MODE_XZY, dst_rot); + + /* Start construction of dst_mat from rotation matrix */ + unit_m4(dst_mat); + copy_m4_m3(dst_mat, dst_rot); + + /* Apply translation */ + switch (mode) { + case ABC_ZUP_FROM_YUP: + copy_zup_from_yup(dst_mat[3], src_trans); + break; + case ABC_YUP_FROM_ZUP: + copy_yup_from_zup(dst_mat[3], src_trans); + break; + default: + BLI_assert(false); + } + + /* Apply scale matrix. Swaps y and z, but does not + * negate like translation does. */ + dst_scale[0] = src_scale[0]; + dst_scale[1] = src_scale[2]; + dst_scale[2] = src_scale[1]; + + size_to_mat4(dst_scale_mat, dst_scale); + mul_m4_m4m4(dst_mat, dst_mat, dst_scale_mat); +} + +/* Recompute transform matrix of object in new coordinate system + * (from Z-Up to Y-Up). */ +void create_transform_matrix(Object *obj, + float r_yup_mat[4][4], + AbcMatrixMode mode, + Object *proxy_from) +{ + float zup_mat[4][4]; + + /* get local or world matrix. */ + if (mode == ABC_MATRIX_LOCAL && obj->parent) { + /* Note that this produces another matrix than the local matrix, due to + * constraints and modifiers as well as the obj->parentinv matrix. */ + invert_m4_m4(obj->parent->imat, obj->parent->obmat); + mul_m4_m4m4(zup_mat, obj->parent->imat, obj->obmat); + } + else { + copy_m4_m4(zup_mat, obj->obmat); + } + + if (proxy_from) { + mul_m4_m4m4(zup_mat, proxy_from->obmat, zup_mat); + } + + copy_m44_axis_swap(r_yup_mat, zup_mat, ABC_YUP_FROM_ZUP); +} diff --git a/source/blender/io/alembic/intern/abc_axis_conversion.h b/source/blender/io/alembic/intern/abc_axis_conversion.h new file mode 100644 index 00000000000..7fde0e92ea4 --- /dev/null +++ b/source/blender/io/alembic/intern/abc_axis_conversion.h @@ -0,0 +1,99 @@ +/* + * 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) 2016 Kévin Dietrich & Blender Foundation. + * All rights reserved. + */ +#pragma once + +/** \file + * \ingroup Alembic + */ + +struct Object; + +#ifdef _MSC_VER +# define ABC_INLINE static __forceinline +#else +# define ABC_INLINE static inline +#endif + +/* TODO(kevin): for now keeping these transformations hardcoded to make sure + * everything works properly, and also because Alembic is almost exclusively + * used in Y-up software, but eventually they'll be set by the user in the UI + * like other importers/exporters do, to support other axis. */ + +/* Copy from Y-up to Z-up. */ + +ABC_INLINE void copy_zup_from_yup(float zup[3], const float yup[3]) +{ + const float old_yup1 = yup[1]; /* in case zup == yup */ + zup[0] = yup[0]; + zup[1] = -yup[2]; + zup[2] = old_yup1; +} + +ABC_INLINE void copy_zup_from_yup(short zup[3], const short yup[3]) +{ + const short old_yup1 = yup[1]; /* in case zup == yup */ + zup[0] = yup[0]; + zup[1] = -yup[2]; + zup[2] = old_yup1; +} + +/* Copy from Z-up to Y-up. */ + +ABC_INLINE void copy_yup_from_zup(float yup[3], const float zup[3]) +{ + const float old_zup1 = zup[1]; /* in case yup == zup */ + yup[0] = zup[0]; + yup[1] = zup[2]; + yup[2] = -old_zup1; +} + +ABC_INLINE void copy_yup_from_zup(short yup[3], const short zup[3]) +{ + const short old_zup1 = zup[1]; /* in case yup == zup */ + yup[0] = zup[0]; + yup[1] = zup[2]; + yup[2] = -old_zup1; +} + +/* Names are given in (dst, src) order, just like + * the parameters of copy_m44_axis_swap() */ +typedef enum { + ABC_ZUP_FROM_YUP = 1, + ABC_YUP_FROM_ZUP = 2, +} AbcAxisSwapMode; + +/* Create a rotation matrix for each axis from euler angles. + * Euler angles are swapped to change coordinate system. */ +void create_swapped_rotation_matrix(float rot_x_mat[3][3], + float rot_y_mat[3][3], + float rot_z_mat[3][3], + const float euler[3], + AbcAxisSwapMode mode); + +void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode); + +typedef enum { + ABC_MATRIX_WORLD = 1, + ABC_MATRIX_LOCAL = 2, +} AbcMatrixMode; + +void create_transform_matrix(Object *obj, + float r_transform_mat[4][4], + AbcMatrixMode mode, + Object *proxy_from); diff --git a/source/blender/io/alembic/intern/abc_customdata.cc b/source/blender/io/alembic/intern/abc_customdata.cc index c5f60ac3e29..40a057f9a20 100644 --- a/source/blender/io/alembic/intern/abc_customdata.cc +++ b/source/blender/io/alembic/intern/abc_customdata.cc @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. @@ -27,7 +27,6 @@ #include <algorithm> #include <unordered_map> -extern "C" { #include "DNA_customdata_types.h" #include "DNA_meshdata_types.h" @@ -35,7 +34,6 @@ extern "C" { #include "BLI_utildefines.h" #include "BKE_customdata.h" -} /* NOTE: for now only UVs and Vertex Colors are supported for streaming. * Although Alembic only allows for a single UV layer per {I|O}Schema, and does diff --git a/source/blender/io/alembic/intern/abc_customdata.h b/source/blender/io/alembic/intern/abc_customdata.h index 11b005eb66a..04572c736af 100644 --- a/source/blender/io/alembic/intern/abc_customdata.h +++ b/source/blender/io/alembic/intern/abc_customdata.h @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. diff --git a/source/blender/io/alembic/intern/abc_exporter.cc b/source/blender/io/alembic/intern/abc_exporter.cc index e3e095463b4..dbf24452b78 100644 --- a/source/blender/io/alembic/intern/abc_exporter.cc +++ b/source/blender/io/alembic/intern/abc_exporter.cc @@ -33,7 +33,6 @@ #include "abc_writer_points.h" #include "abc_writer_transform.h" -extern "C" { #include "DNA_camera_types.h" #include "DNA_curve_types.h" #include "DNA_fluid_types.h" @@ -62,7 +61,6 @@ extern "C" { #include "BKE_scene.h" #include "DEG_depsgraph_query.h" -} using Alembic::Abc::OBox3dProperty; using Alembic::Abc::TimeSamplingPtr; @@ -105,7 +103,7 @@ ExportSettings::ExportSettings() static bool object_is_smoke_sim(Object *ob) { - ModifierData *md = modifiers_findByType(ob, eModifierType_Fluid); + ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Fluid); if (md) { FluidModifierData *smd = reinterpret_cast<FluidModifierData *>(md); diff --git a/source/blender/io/alembic/intern/abc_reader_archive.cc b/source/blender/io/alembic/intern/abc_reader_archive.cc index 6ad44553701..563466d81bc 100644 --- a/source/blender/io/alembic/intern/abc_reader_archive.cc +++ b/source/blender/io/alembic/intern/abc_reader_archive.cc @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. @@ -23,12 +23,10 @@ #include "abc_reader_archive.h" -extern "C" { #include "BKE_main.h" #include "BLI_path_util.h" #include "BLI_string.h" -} #ifdef WIN32 # include "utfconv.h" diff --git a/source/blender/io/alembic/intern/abc_reader_archive.h b/source/blender/io/alembic/intern/abc_reader_archive.h index bdb53bd0b8c..35273e10108 100644 --- a/source/blender/io/alembic/intern/abc_reader_archive.h +++ b/source/blender/io/alembic/intern/abc_reader_archive.h @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. diff --git a/source/blender/io/alembic/intern/abc_reader_camera.cc b/source/blender/io/alembic/intern/abc_reader_camera.cc index ab506f32cbe..0752534f8c2 100644 --- a/source/blender/io/alembic/intern/abc_reader_camera.cc +++ b/source/blender/io/alembic/intern/abc_reader_camera.cc @@ -22,7 +22,6 @@ #include "abc_reader_transform.h" #include "abc_util.h" -extern "C" { #include "DNA_camera_types.h" #include "DNA_object_types.h" @@ -30,7 +29,6 @@ extern "C" { #include "BKE_object.h" #include "BLI_math.h" -} using Alembic::AbcGeom::CameraSample; using Alembic::AbcGeom::ICamera; diff --git a/source/blender/io/alembic/intern/abc_reader_curves.cc b/source/blender/io/alembic/intern/abc_reader_curves.cc index 1be164c7c94..d5e0b694294 100644 --- a/source/blender/io/alembic/intern/abc_reader_curves.cc +++ b/source/blender/io/alembic/intern/abc_reader_curves.cc @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. @@ -22,6 +22,7 @@ */ #include "abc_reader_curves.h" +#include "abc_axis_conversion.h" #include "abc_reader_transform.h" #include "abc_util.h" @@ -29,7 +30,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "DNA_curve_types.h" #include "DNA_object_types.h" @@ -38,7 +38,6 @@ extern "C" { #include "BKE_curve.h" #include "BKE_mesh.h" #include "BKE_object.h" -} using Alembic::Abc::FloatArraySamplePtr; using Alembic::Abc::Int32ArraySamplePtr; diff --git a/source/blender/io/alembic/intern/abc_reader_curves.h b/source/blender/io/alembic/intern/abc_reader_curves.h index 763a83f586f..eb0538308f8 100644 --- a/source/blender/io/alembic/intern/abc_reader_curves.h +++ b/source/blender/io/alembic/intern/abc_reader_curves.h @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index b69a5301d76..8b79a3a0aa0 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -19,6 +19,7 @@ */ #include "abc_reader_mesh.h" +#include "abc_axis_conversion.h" #include "abc_reader_transform.h" #include "abc_util.h" @@ -26,7 +27,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -39,7 +39,6 @@ extern "C" { #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" -} using Alembic::Abc::Int32ArraySamplePtr; using Alembic::Abc::P3fArraySamplePtr; diff --git a/source/blender/io/alembic/intern/abc_reader_nurbs.cc b/source/blender/io/alembic/intern/abc_reader_nurbs.cc index 0ada10baba5..10d9a35a8e1 100644 --- a/source/blender/io/alembic/intern/abc_reader_nurbs.cc +++ b/source/blender/io/alembic/intern/abc_reader_nurbs.cc @@ -19,12 +19,12 @@ */ #include "abc_reader_nurbs.h" +#include "abc_axis_conversion.h" #include "abc_reader_transform.h" #include "abc_util.h" #include "MEM_guardedalloc.h" -extern "C" { #include "DNA_curve_types.h" #include "DNA_object_types.h" @@ -33,7 +33,6 @@ extern "C" { #include "BKE_curve.h" #include "BKE_object.h" -} using Alembic::AbcGeom::FloatArraySamplePtr; using Alembic::AbcGeom::kWrapExisting; diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc index 9b0c3237c45..e5bd0771a42 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.cc +++ b/source/blender/io/alembic/intern/abc_reader_object.cc @@ -19,9 +19,9 @@ */ #include "abc_reader_object.h" +#include "abc_axis_conversion.h" #include "abc_util.h" -extern "C" { #include "DNA_cachefile_types.h" #include "DNA_constraint_types.h" #include "DNA_modifier_types.h" @@ -36,7 +36,6 @@ extern "C" { #include "BLI_math_geom.h" #include "BLI_string.h" #include "BLI_utildefines.h" -} using Alembic::AbcGeom::IObject; using Alembic::AbcGeom::IXform; @@ -295,7 +294,7 @@ void AbcObjectReader::read_matrix(float r_mat[4][4] /* local matrix */, void AbcObjectReader::addCacheModifier() { - ModifierData *md = modifier_new(eModifierType_MeshSequenceCache); + ModifierData *md = BKE_modifier_new(eModifierType_MeshSequenceCache); BLI_addtail(&m_object->modifiers, md); MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md); diff --git a/source/blender/io/alembic/intern/abc_reader_object.h b/source/blender/io/alembic/intern/abc_reader_object.h index 94923df2df9..dcc2697e0b5 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.h +++ b/source/blender/io/alembic/intern/abc_reader_object.h @@ -24,9 +24,7 @@ #include <Alembic/Abc/All.h> #include <Alembic/AbcGeom/All.h> -extern "C" { #include "DNA_ID.h" -} struct CacheFile; struct Main; diff --git a/source/blender/io/alembic/intern/abc_reader_points.cc b/source/blender/io/alembic/intern/abc_reader_points.cc index e4dc345f868..c5d08693176 100644 --- a/source/blender/io/alembic/intern/abc_reader_points.cc +++ b/source/blender/io/alembic/intern/abc_reader_points.cc @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. @@ -26,14 +26,12 @@ #include "abc_reader_transform.h" #include "abc_util.h" -extern "C" { #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "BKE_customdata.h" #include "BKE_mesh.h" #include "BKE_object.h" -} using Alembic::AbcGeom::kWrapExisting; using Alembic::AbcGeom::N3fArraySamplePtr; diff --git a/source/blender/io/alembic/intern/abc_reader_points.h b/source/blender/io/alembic/intern/abc_reader_points.h index bb33afb466f..99881e091f9 100644 --- a/source/blender/io/alembic/intern/abc_reader_points.h +++ b/source/blender/io/alembic/intern/abc_reader_points.h @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. diff --git a/source/blender/io/alembic/intern/abc_reader_transform.cc b/source/blender/io/alembic/intern/abc_reader_transform.cc index ce569a9ccb5..3df391f8432 100644 --- a/source/blender/io/alembic/intern/abc_reader_transform.cc +++ b/source/blender/io/alembic/intern/abc_reader_transform.cc @@ -21,13 +21,11 @@ #include "abc_reader_transform.h" #include "abc_util.h" -extern "C" { #include "DNA_object_types.h" #include "BLI_utildefines.h" #include "BKE_object.h" -} using Alembic::Abc::ISampleSelector; diff --git a/source/blender/io/alembic/intern/abc_util.cc b/source/blender/io/alembic/intern/abc_util.cc index b26ef8b3b76..1f3bd2a1aaa 100644 --- a/source/blender/io/alembic/intern/abc_util.cc +++ b/source/blender/io/alembic/intern/abc_util.cc @@ -20,6 +20,7 @@ #include "abc_util.h" +#include "abc_axis_conversion.h" #include "abc_reader_camera.h" #include "abc_reader_curves.h" #include "abc_reader_mesh.h" @@ -31,13 +32,11 @@ #include <algorithm> -extern "C" { #include "DNA_object_types.h" #include "BLI_math_geom.h" #include "PIL_time.h" -} std::string get_id_name(const Object *const ob) { @@ -121,144 +120,6 @@ void split(const std::string &s, const char delim, std::vector<std::string> &tok } } -void create_swapped_rotation_matrix(float rot_x_mat[3][3], - float rot_y_mat[3][3], - float rot_z_mat[3][3], - const float euler[3], - AbcAxisSwapMode mode) -{ - const float rx = euler[0]; - float ry; - float rz; - - /* Apply transformation */ - switch (mode) { - case ABC_ZUP_FROM_YUP: - ry = -euler[2]; - rz = euler[1]; - break; - case ABC_YUP_FROM_ZUP: - ry = euler[2]; - rz = -euler[1]; - break; - default: - ry = 0.0f; - rz = 0.0f; - BLI_assert(false); - break; - } - - unit_m3(rot_x_mat); - unit_m3(rot_y_mat); - unit_m3(rot_z_mat); - - rot_x_mat[1][1] = cos(rx); - rot_x_mat[2][1] = -sin(rx); - rot_x_mat[1][2] = sin(rx); - rot_x_mat[2][2] = cos(rx); - - rot_y_mat[2][2] = cos(ry); - rot_y_mat[0][2] = -sin(ry); - rot_y_mat[2][0] = sin(ry); - rot_y_mat[0][0] = cos(ry); - - rot_z_mat[0][0] = cos(rz); - rot_z_mat[1][0] = -sin(rz); - rot_z_mat[0][1] = sin(rz); - rot_z_mat[1][1] = cos(rz); -} - -/* Convert matrix from Z=up to Y=up or vice versa. - * Use yup_mat = zup_mat for in-place conversion. */ -void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode) -{ - float dst_rot[3][3], src_rot[3][3], dst_scale_mat[4][4]; - float rot_x_mat[3][3], rot_y_mat[3][3], rot_z_mat[3][3]; - float src_trans[3], dst_scale[3], src_scale[3], euler[3]; - - zero_v3(src_trans); - zero_v3(dst_scale); - zero_v3(src_scale); - zero_v3(euler); - unit_m3(src_rot); - unit_m3(dst_rot); - unit_m4(dst_scale_mat); - - /* TODO(Sybren): This code assumes there is no sheer component and no - * homogeneous scaling component, which is not always true when writing - * non-hierarchical (e.g. flat) objects (e.g. when parent has non-uniform - * scale and the child rotates). This is currently not taken into account - * when axis-swapping. */ - - /* Extract translation, rotation, and scale form matrix. */ - mat4_to_loc_rot_size(src_trans, src_rot, src_scale, src_mat); - - /* Get euler angles from rotation matrix. */ - mat3_to_eulO(euler, ROT_MODE_XZY, src_rot); - - /* Create X, Y, Z rotation matrices from euler angles. */ - create_swapped_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler, mode); - - /* Concatenate rotation matrices. */ - mul_m3_m3m3(dst_rot, dst_rot, rot_z_mat); - mul_m3_m3m3(dst_rot, dst_rot, rot_y_mat); - mul_m3_m3m3(dst_rot, dst_rot, rot_x_mat); - - mat3_to_eulO(euler, ROT_MODE_XZY, dst_rot); - - /* Start construction of dst_mat from rotation matrix */ - unit_m4(dst_mat); - copy_m4_m3(dst_mat, dst_rot); - - /* Apply translation */ - switch (mode) { - case ABC_ZUP_FROM_YUP: - copy_zup_from_yup(dst_mat[3], src_trans); - break; - case ABC_YUP_FROM_ZUP: - copy_yup_from_zup(dst_mat[3], src_trans); - break; - default: - BLI_assert(false); - } - - /* Apply scale matrix. Swaps y and z, but does not - * negate like translation does. */ - dst_scale[0] = src_scale[0]; - dst_scale[1] = src_scale[2]; - dst_scale[2] = src_scale[1]; - - size_to_mat4(dst_scale_mat, dst_scale); - mul_m4_m4m4(dst_mat, dst_mat, dst_scale_mat); -} - -/* Recompute transform matrix of object in new coordinate system - * (from Z-Up to Y-Up). */ -void create_transform_matrix(Object *obj, - float r_yup_mat[4][4], - AbcMatrixMode mode, - Object *proxy_from) -{ - float zup_mat[4][4]; - - /* get local or world matrix. */ - if (mode == ABC_MATRIX_LOCAL && obj->parent) { - /* Note that this produces another matrix than the local matrix, due to - * constraints and modifiers as well as the obj->parentinv matrix. */ - invert_m4_m4(obj->parent->imat, obj->parent->obmat); - mul_m4_m4m4(zup_mat, obj->parent->imat, obj->obmat); - } - else { - copy_m4_m4(zup_mat, obj->obmat); - } - - if (proxy_from) { - mul_m4_m4m4(zup_mat, proxy_from->obmat, zup_mat); - } - - copy_m44_axis_swap(r_yup_mat, zup_mat, ABC_YUP_FROM_ZUP); -} - bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name) { if (!prop.valid()) { diff --git a/source/blender/io/alembic/intern/abc_util.h b/source/blender/io/alembic/intern/abc_util.h index 0b3462c2132..57b4d9800a5 100644 --- a/source/blender/io/alembic/intern/abc_util.h +++ b/source/blender/io/alembic/intern/abc_util.h @@ -56,15 +56,6 @@ Imath::M44d convert_matrix_datatype(float mat[4][4]); /* Convert from Alembic to float matrix representations. Does NOT convert from Y-up to Z-up. */ void convert_matrix_datatype(const Imath::M44d &xform, float r_mat[4][4]); -typedef enum { - ABC_MATRIX_WORLD = 1, - ABC_MATRIX_LOCAL = 2, -} AbcMatrixMode; -void create_transform_matrix(Object *obj, - float r_transform_mat[4][4], - AbcMatrixMode mode, - Object *proxy_from); - void split(const std::string &s, const char delim, std::vector<std::string> &tokens); template<class TContainer> bool begins_with(const TContainer &input, const TContainer &match) @@ -115,66 +106,6 @@ float get_weight_and_index(float time, AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSettings &settings); -/* ************************** */ - -/* TODO(kevin): for now keeping these transformations hardcoded to make sure - * everything works properly, and also because Alembic is almost exclusively - * used in Y-up software, but eventually they'll be set by the user in the UI - * like other importers/exporters do, to support other axis. */ - -/* Copy from Y-up to Z-up. */ - -ABC_INLINE void copy_zup_from_yup(float zup[3], const float yup[3]) -{ - const float old_yup1 = yup[1]; /* in case zup == yup */ - zup[0] = yup[0]; - zup[1] = -yup[2]; - zup[2] = old_yup1; -} - -ABC_INLINE void copy_zup_from_yup(short zup[3], const short yup[3]) -{ - const short old_yup1 = yup[1]; /* in case zup == yup */ - zup[0] = yup[0]; - zup[1] = -yup[2]; - zup[2] = old_yup1; -} - -/* Copy from Z-up to Y-up. */ - -ABC_INLINE void copy_yup_from_zup(float yup[3], const float zup[3]) -{ - const float old_zup1 = zup[1]; /* in case yup == zup */ - yup[0] = zup[0]; - yup[1] = zup[2]; - yup[2] = -old_zup1; -} - -ABC_INLINE void copy_yup_from_zup(short yup[3], const short zup[3]) -{ - const short old_zup1 = zup[1]; /* in case yup == zup */ - yup[0] = zup[0]; - yup[1] = zup[2]; - yup[2] = -old_zup1; -} - -/* Names are given in (dst, src) order, just like - * the parameters of copy_m44_axis_swap() */ -typedef enum { - ABC_ZUP_FROM_YUP = 1, - ABC_YUP_FROM_ZUP = 2, -} AbcAxisSwapMode; - -/* Create a rotation matrix for each axis from euler angles. - * Euler angles are swapped to change coordinate system. */ -void create_swapped_rotation_matrix(float rot_x_mat[3][3], - float rot_y_mat[3][3], - float rot_z_mat[3][3], - const float euler[3], - AbcAxisSwapMode mode); - -void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode); - /* *************************** */ #undef ABC_DEBUG_TIME diff --git a/source/blender/io/alembic/intern/abc_writer_archive.cc b/source/blender/io/alembic/intern/abc_writer_archive.cc index af18d480a18..5aae1f05f4b 100644 --- a/source/blender/io/alembic/intern/abc_writer_archive.cc +++ b/source/blender/io/alembic/intern/abc_writer_archive.cc @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. @@ -22,14 +22,13 @@ */ #include "abc_writer_archive.h" -extern "C" { + #include "BKE_blender_version.h" #include "BLI_path_util.h" #include "BLI_string.h" #include "DNA_scene_types.h" -} #ifdef WIN32 # include "utfconv.h" diff --git a/source/blender/io/alembic/intern/abc_writer_archive.h b/source/blender/io/alembic/intern/abc_writer_archive.h index e261e60990a..82b0e98b376 100644 --- a/source/blender/io/alembic/intern/abc_writer_archive.h +++ b/source/blender/io/alembic/intern/abc_writer_archive.h @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. diff --git a/source/blender/io/alembic/intern/abc_writer_camera.cc b/source/blender/io/alembic/intern/abc_writer_camera.cc index e705e5ba911..07ae81e584f 100644 --- a/source/blender/io/alembic/intern/abc_writer_camera.cc +++ b/source/blender/io/alembic/intern/abc_writer_camera.cc @@ -21,10 +21,8 @@ #include "abc_writer_camera.h" #include "abc_writer_transform.h" -extern "C" { #include "DNA_camera_types.h" #include "DNA_object_types.h" -} using Alembic::AbcGeom::OCamera; using Alembic::AbcGeom::OFloatProperty; diff --git a/source/blender/io/alembic/intern/abc_writer_curves.cc b/source/blender/io/alembic/intern/abc_writer_curves.cc index 3ab9b365a72..db93ac1920e 100644 --- a/source/blender/io/alembic/intern/abc_writer_curves.cc +++ b/source/blender/io/alembic/intern/abc_writer_curves.cc @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. @@ -22,17 +22,16 @@ */ #include "abc_writer_curves.h" +#include "abc_axis_conversion.h" #include "abc_reader_curves.h" #include "abc_writer_transform.h" -extern "C" { #include "DNA_curve_types.h" #include "DNA_object_types.h" #include "BKE_curve.h" #include "BKE_mesh.h" #include "BKE_object.h" -} using Alembic::AbcGeom::OCompoundProperty; using Alembic::AbcGeom::OCurves; diff --git a/source/blender/io/alembic/intern/abc_writer_curves.h b/source/blender/io/alembic/intern/abc_writer_curves.h index e57978ada2a..83f0289dd2d 100644 --- a/source/blender/io/alembic/intern/abc_writer_curves.h +++ b/source/blender/io/alembic/intern/abc_writer_curves.h @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. diff --git a/source/blender/io/alembic/intern/abc_writer_hair.cc b/source/blender/io/alembic/intern/abc_writer_hair.cc index f29d195f2ff..ed62889b03d 100644 --- a/source/blender/io/alembic/intern/abc_writer_hair.cc +++ b/source/blender/io/alembic/intern/abc_writer_hair.cc @@ -19,12 +19,11 @@ */ #include "abc_writer_hair.h" -#include "abc_util.h" +#include "abc_axis_conversion.h" #include "abc_writer_transform.h" #include <cstdio> -extern "C" { #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" @@ -35,7 +34,6 @@ extern "C" { #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" #include "BKE_particle.h" -} using Alembic::Abc::P3fArraySamplePtr; diff --git a/source/blender/io/alembic/intern/abc_writer_mball.cc b/source/blender/io/alembic/intern/abc_writer_mball.cc index 151848674f9..3593acf18b0 100644 --- a/source/blender/io/alembic/intern/abc_writer_mball.cc +++ b/source/blender/io/alembic/intern/abc_writer_mball.cc @@ -21,7 +21,6 @@ #include "abc_writer_mball.h" #include "abc_writer_mesh.h" -extern "C" { #include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_object_types.h" @@ -33,7 +32,6 @@ extern "C" { #include "BKE_object.h" #include "BLI_utildefines.h" -} AbcMBallWriter::AbcMBallWriter(Main *bmain, Object *ob, diff --git a/source/blender/io/alembic/intern/abc_writer_mesh.cc b/source/blender/io/alembic/intern/abc_writer_mesh.cc index f7b575e7b23..89c37dab468 100644 --- a/source/blender/io/alembic/intern/abc_writer_mesh.cc +++ b/source/blender/io/alembic/intern/abc_writer_mesh.cc @@ -19,10 +19,9 @@ */ #include "abc_writer_mesh.h" -#include "abc_util.h" +#include "abc_axis_conversion.h" #include "abc_writer_transform.h" -extern "C" { #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -40,7 +39,6 @@ extern "C" { #include "bmesh_tools.h" #include "DEG_depsgraph_query.h" -} using Alembic::Abc::FloatArraySample; using Alembic::Abc::Int32ArraySample; @@ -169,7 +167,7 @@ static ModifierData *get_subsurf_modifier(Scene *scene, Object *ob) ModifierData *md = static_cast<ModifierData *>(ob->modifiers.last); for (; md; md = md->prev) { - if (!modifier_isEnabled(scene, md, eModifierMode_Render)) { + if (!BKE_modifier_is_enabled(scene, md, eModifierMode_Render)) { continue; } @@ -192,9 +190,9 @@ static ModifierData *get_subsurf_modifier(Scene *scene, Object *ob) static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob) { - ModifierData *md = modifiers_findByType(ob, eModifierType_Fluidsim); + ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Fluidsim); - if (md && (modifier_isEnabled(scene, md, eModifierMode_Render))) { + if (md && (BKE_modifier_is_enabled(scene, md, eModifierMode_Render))) { FluidsimModifierData *fsmd = reinterpret_cast<FluidsimModifierData *>(md); if (fsmd->fss && fsmd->fss->type == OB_FLUIDSIM_DOMAIN) { diff --git a/source/blender/io/alembic/intern/abc_writer_nurbs.cc b/source/blender/io/alembic/intern/abc_writer_nurbs.cc index d643f5482c0..8b4a1050d33 100644 --- a/source/blender/io/alembic/intern/abc_writer_nurbs.cc +++ b/source/blender/io/alembic/intern/abc_writer_nurbs.cc @@ -19,17 +19,15 @@ */ #include "abc_writer_nurbs.h" -#include "abc_util.h" +#include "abc_axis_conversion.h" #include "abc_writer_transform.h" -extern "C" { #include "DNA_curve_types.h" #include "DNA_object_types.h" #include "BLI_listbase.h" #include "BKE_curve.h" -} using Alembic::AbcGeom::FloatArraySample; using Alembic::AbcGeom::OBoolProperty; diff --git a/source/blender/io/alembic/intern/abc_writer_object.cc b/source/blender/io/alembic/intern/abc_writer_object.cc index 75dc93bd08e..f4a3587f54d 100644 --- a/source/blender/io/alembic/intern/abc_writer_object.cc +++ b/source/blender/io/alembic/intern/abc_writer_object.cc @@ -20,11 +20,9 @@ #include "abc_writer_object.h" -extern "C" { #include "DNA_object_types.h" #include "BKE_object.h" -} AbcObjectWriter::AbcObjectWriter(Object *ob, uint32_t time_sampling, diff --git a/source/blender/io/alembic/intern/abc_writer_object.h b/source/blender/io/alembic/intern/abc_writer_object.h index c3511566372..830c4aee903 100644 --- a/source/blender/io/alembic/intern/abc_writer_object.h +++ b/source/blender/io/alembic/intern/abc_writer_object.h @@ -26,9 +26,7 @@ #include "abc_exporter.h" -extern "C" { #include "DNA_ID.h" -} class AbcTransformWriter; diff --git a/source/blender/io/alembic/intern/abc_writer_points.cc b/source/blender/io/alembic/intern/abc_writer_points.cc index 70a1ead239a..d45af2eed4c 100644 --- a/source/blender/io/alembic/intern/abc_writer_points.cc +++ b/source/blender/io/alembic/intern/abc_writer_points.cc @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. @@ -26,7 +26,6 @@ #include "abc_writer_mesh.h" #include "abc_writer_transform.h" -extern "C" { #include "DNA_object_types.h" #include "DNA_particle_types.h" @@ -36,7 +35,6 @@ extern "C" { #include "BLI_math.h" #include "DEG_depsgraph_query.h" -} using Alembic::AbcGeom::kVertexScope; using Alembic::AbcGeom::OPoints; diff --git a/source/blender/io/alembic/intern/abc_writer_points.h b/source/blender/io/alembic/intern/abc_writer_points.h index c171cddd10e..184a363ae6b 100644 --- a/source/blender/io/alembic/intern/abc_writer_points.h +++ b/source/blender/io/alembic/intern/abc_writer_points.h @@ -10,7 +10,7 @@ * 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, + * 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) 2016 Kévin Dietrich. diff --git a/source/blender/io/alembic/intern/abc_writer_transform.cc b/source/blender/io/alembic/intern/abc_writer_transform.cc index d7bcc46d96f..1ec7db0a1c6 100644 --- a/source/blender/io/alembic/intern/abc_writer_transform.cc +++ b/source/blender/io/alembic/intern/abc_writer_transform.cc @@ -19,17 +19,15 @@ */ #include "abc_writer_transform.h" -#include "abc_util.h" +#include "abc_axis_conversion.h" #include <OpenEXR/ImathBoxAlgo.h> -extern "C" { #include "DNA_object_types.h" #include "BLI_math.h" #include "DEG_depsgraph_query.h" -} using Alembic::AbcGeom::OObject; using Alembic::AbcGeom::OXform; diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index ced5791e0e8..987a3cacb3b 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -40,7 +40,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "DNA_cachefile_types.h" #include "DNA_curve_types.h" #include "DNA_modifier_types.h" @@ -74,7 +73,6 @@ extern "C" { #include "WM_api.h" #include "WM_types.h" -} using Alembic::Abc::Int32ArraySamplePtr; using Alembic::Abc::ObjectHeader; diff --git a/source/blender/io/collada/AnimationExporter.h b/source/blender/io/collada/AnimationExporter.h index 3e40a485ddf..b4564eb7b2d 100644 --- a/source/blender/io/collada/AnimationExporter.h +++ b/source/blender/io/collada/AnimationExporter.h @@ -23,7 +23,6 @@ #include "BCAnimationCurve.h" -extern "C" { #include "DNA_action_types.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -48,7 +47,6 @@ extern "C" { #include "BKE_object.h" #include "BKE_scene.h" #include "ED_object.h" -} #include "MEM_guardedalloc.h" diff --git a/source/blender/io/collada/AnimationImporter.h b/source/blender/io/collada/AnimationImporter.h index 263a130d1eb..51041c6ee3e 100644 --- a/source/blender/io/collada/AnimationImporter.h +++ b/source/blender/io/collada/AnimationImporter.h @@ -35,14 +35,14 @@ #include "COLLADAFWNode.h" #include "COLLADAFWUniqueId.h" -extern "C" { #include "BKE_context.h" + #include "DNA_anim_types.h" + #include "DNA_camera_types.h" #include "DNA_light_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -} //#include "ArmatureImporter.h" #include "TransformReader.h" diff --git a/source/blender/io/collada/ArmatureExporter.cpp b/source/blender/io/collada/ArmatureExporter.cpp index 660917c2aa1..fc697e1617b 100644 --- a/source/blender/io/collada/ArmatureExporter.cpp +++ b/source/blender/io/collada/ArmatureExporter.cpp @@ -29,11 +29,8 @@ #include "BKE_action.h" #include "BKE_armature.h" - -extern "C" { #include "BKE_global.h" #include "BKE_mesh.h" -} #include "ED_armature.h" diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index 4e9f31182f1..a69500432e8 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -25,14 +25,12 @@ #include "COLLADAFWUniqueId.h" -extern "C" { #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_object.h" #include "BLI_listbase.h" #include "BLI_string.h" #include "ED_armature.h" -} #include "DEG_depsgraph.h" @@ -335,7 +333,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone /* * It is possible that the child's head is located on the parents head. * When this happens, then moving the parent's tail to the child's head - * would result in a zero sized bone and Blender would silently remove the bone. + * would result in a zero sized bone and Blender would silently remove the bone. * So we move the tail only when the resulting bone has a minimum length: */ diff --git a/source/blender/io/collada/ArmatureImporter.h b/source/blender/io/collada/ArmatureImporter.h index bafa10ca804..7393b882f4b 100644 --- a/source/blender/io/collada/ArmatureImporter.h +++ b/source/blender/io/collada/ArmatureImporter.h @@ -25,7 +25,6 @@ #include "COLLADAFWNode.h" #include "COLLADAFWUniqueId.h" -extern "C" { #include "BKE_context.h" #include "BKE_key.h" @@ -35,7 +34,6 @@ extern "C" { #include "DNA_scene_types.h" #include "ED_armature.h" -} #include "AnimationImporter.h" #include "ExtraTags.h" diff --git a/source/blender/io/collada/BCAnimationCurve.h b/source/blender/io/collada/BCAnimationCurve.h index 71640ff3013..e0216ee6849 100644 --- a/source/blender/io/collada/BCAnimationCurve.h +++ b/source/blender/io/collada/BCAnimationCurve.h @@ -25,14 +25,13 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "BKE_armature.h" #include "BKE_fcurve.h" #include "BKE_material.h" + #include "ED_anim_api.h" #include "ED_keyframes_edit.h" #include "ED_keyframing.h" -} typedef float(TangentPoint)[2]; diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp index 0c19ce9a4c7..fc23a58ccbc 100644 --- a/source/blender/io/collada/BCAnimationSampler.cpp +++ b/source/blender/io/collada/BCAnimationSampler.cpp @@ -27,20 +27,21 @@ #include "ExportSettings.h" #include "collada_utils.h" -extern "C" { #include "BKE_action.h" #include "BKE_constraint.h" #include "BKE_key.h" #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_material.h" + #include "BLI_listbase.h" + #include "DNA_anim_types.h" #include "DNA_constraint_types.h" #include "DNA_key_types.h" #include "DNA_scene_types.h" + #include "ED_object.h" -} static std::string EMPTY_STRING; static BCAnimationCurveMap BCEmptyAnimationCurves; diff --git a/source/blender/io/collada/BCAnimationSampler.h b/source/blender/io/collada/BCAnimationSampler.h index 96138d0cbca..3273ac8e0a0 100644 --- a/source/blender/io/collada/BCAnimationSampler.h +++ b/source/blender/io/collada/BCAnimationSampler.h @@ -21,12 +21,12 @@ #include "BCSampleData.h" #include "collada_utils.h" -extern "C" { #include "BKE_action.h" #include "BKE_lib_id.h" + #include "BLI_math_rotation.h" + #include "DNA_action_types.h" -} /* Collection of animation curves */ class BCAnimation { diff --git a/source/blender/io/collada/BCMath.h b/source/blender/io/collada/BCMath.h index 9ecea85b08c..38158751740 100644 --- a/source/blender/io/collada/BCMath.h +++ b/source/blender/io/collada/BCMath.h @@ -23,10 +23,9 @@ #include "BlenderTypes.h" -extern "C" { #include "BKE_object.h" + #include "BLI_math.h" -} class BCQuat { private: diff --git a/source/blender/io/collada/BCSampleData.h b/source/blender/io/collada/BCSampleData.h index 877fb49981a..6f3ca9135b3 100644 --- a/source/blender/io/collada/BCSampleData.h +++ b/source/blender/io/collada/BCSampleData.h @@ -28,15 +28,15 @@ #include "BCSampleData.h" #include "ExportSettings.h" -extern "C" { #include "BKE_object.h" + #include "BLI_math_rotation.h" + #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" -} typedef std::map<Bone *, BCMatrix *> BCBoneMatrixMap; diff --git a/source/blender/io/collada/BlenderContext.h b/source/blender/io/collada/BlenderContext.h index 15ebd671b1a..bf6fde134fa 100644 --- a/source/blender/io/collada/BlenderContext.h +++ b/source/blender/io/collada/BlenderContext.h @@ -21,11 +21,6 @@ #ifndef __BLENDERCONTEXT_H__ #define __BLENDERCONTEXT_H__ -#ifdef __cplusplus - -extern "C" { -#endif - #include "BKE_context.h" #include "BKE_main.h" #include "BLI_linklist.h" @@ -35,6 +30,10 @@ extern "C" { #include "DNA_layer_types.h" #include "DNA_object_types.h" +#ifdef __cplusplus +extern "C" { +#endif + static const BC_global_forward_axis BC_DEFAULT_FORWARD = BC_GLOBAL_FORWARD_Y; static const BC_global_up_axis BC_DEFAULT_UP = BC_GLOBAL_UP_Z; diff --git a/source/blender/io/collada/CameraExporter.cpp b/source/blender/io/collada/CameraExporter.cpp index 74862c44270..246a454eb66 100644 --- a/source/blender/io/collada/CameraExporter.cpp +++ b/source/blender/io/collada/CameraExporter.cpp @@ -22,9 +22,8 @@ #include "COLLADASWCamera.h" -extern "C" { #include "DNA_camera_types.h" -} + #include "CameraExporter.h" #include "collada_internal.h" diff --git a/source/blender/io/collada/CameraExporter.h b/source/blender/io/collada/CameraExporter.h index e4df994354c..0dda6392d03 100644 --- a/source/blender/io/collada/CameraExporter.h +++ b/source/blender/io/collada/CameraExporter.h @@ -24,10 +24,8 @@ #include "COLLADASWLibraryCameras.h" #include "COLLADASWStreamWriter.h" -extern "C" { #include "DNA_object_types.h" #include "DNA_scene_types.h" -} #include "DNA_camera_types.h" #include "ExportSettings.h" diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp index c26647d4747..1b8c859f443 100644 --- a/source/blender/io/collada/ControllerExporter.cpp +++ b/source/blender/io/collada/ControllerExporter.cpp @@ -29,13 +29,10 @@ #include "BKE_action.h" #include "BKE_armature.h" - -extern "C" { #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.h" #include "BKE_mesh.h" -} #include "ED_armature.h" diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index 7565aa881fd..b890d4cf018 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -58,7 +58,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "DNA_action_types.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -96,13 +95,12 @@ extern "C" { #include "ED_keyframing.h" #ifdef WITH_BUILDINFO -extern char build_commit_date[]; -extern char build_commit_time[]; -extern char build_hash[]; +extern "C" char build_commit_date[]; +extern "C" char build_commit_time[]; +extern "C" char build_hash[]; #endif #include "RNA_access.h" -} #include "DocumentExporter.h" #include "collada_internal.h" diff --git a/source/blender/io/collada/DocumentExporter.h b/source/blender/io/collada/DocumentExporter.h index f024befbd17..1fe52420534 100644 --- a/source/blender/io/collada/DocumentExporter.h +++ b/source/blender/io/collada/DocumentExporter.h @@ -25,9 +25,7 @@ #include "collada.h" #include "collada_utils.h" -extern "C" { #include "DNA_customdata_types.h" -} class DocumentExporter { public: diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index 281786bb45f..2305072a6eb 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -45,7 +45,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_math.h" @@ -72,7 +71,6 @@ extern "C" { #include "WM_api.h" #include "WM_types.h" -} #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/io/collada/EffectExporter.cpp b/source/blender/io/collada/EffectExporter.cpp index f21ea57c91c..7f6d3cbdc6f 100644 --- a/source/blender/io/collada/EffectExporter.cpp +++ b/source/blender/io/collada/EffectExporter.cpp @@ -31,7 +31,6 @@ #include "collada_internal.h" #include "collada_utils.h" -extern "C" { #include "DNA_mesh_types.h" #include "DNA_world_types.h" @@ -39,7 +38,6 @@ extern "C" { #include "BKE_customdata.h" #include "BKE_material.h" #include "BKE_mesh.h" -} static std::string getActiveUVLayerName(Object *ob) { diff --git a/source/blender/io/collada/ExportSettings.h b/source/blender/io/collada/ExportSettings.h index 69e260a1e91..477f0b8b678 100644 --- a/source/blender/io/collada/ExportSettings.h +++ b/source/blender/io/collada/ExportSettings.h @@ -21,6 +21,9 @@ #ifndef __EXPORTSETTINGS_H__ #define __EXPORTSETTINGS_H__ +#include "BLI_linklist.h" +#include "BlenderContext.h" + #ifdef __cplusplus # include "BCMath.h" # include <vector> @@ -28,9 +31,6 @@ extern "C" { #endif -#include "BLI_linklist.h" -#include "BlenderContext.h" - typedef enum BC_export_mesh_type { BC_MESH_TYPE_VIEW, BC_MESH_TYPE_RENDER, diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 469d8601a8b..c7fcc51d42f 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -29,7 +29,6 @@ #include "DNA_meshdata_types.h" -extern "C" { #include "BLI_utildefines.h" #include "BKE_customdata.h" @@ -37,7 +36,6 @@ extern "C" { #include "BKE_lib_id.h" #include "BKE_material.h" #include "BKE_mesh.h" -} #include "collada_internal.h" #include "collada_utils.h" diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp index 1cd3301b8a8..1c897e37a4a 100644 --- a/source/blender/io/collada/ImageExporter.cpp +++ b/source/blender/io/collada/ImageExporter.cpp @@ -21,7 +21,6 @@ #include "COLLADABUURI.h" #include "COLLADASWImage.h" -extern "C" { #include "DNA_image_types.h" #include "DNA_meshdata_types.h" #include "DNA_texture_types.h" @@ -37,7 +36,6 @@ extern "C" { #include "BLI_string.h" #include "IMB_imbuf_types.h" -} #include "ImageExporter.h" #include "MaterialExporter.h" diff --git a/source/blender/io/collada/InstanceWriter.cpp b/source/blender/io/collada/InstanceWriter.cpp index a0bea16adfb..6c197823ec2 100644 --- a/source/blender/io/collada/InstanceWriter.cpp +++ b/source/blender/io/collada/InstanceWriter.cpp @@ -23,11 +23,10 @@ #include "COLLADASWInstanceMaterial.h" -extern "C" { #include "BKE_customdata.h" #include "BKE_material.h" + #include "DNA_mesh_types.h" -} #include "InstanceWriter.h" #include "collada_internal.h" diff --git a/source/blender/io/collada/MaterialExporter.h b/source/blender/io/collada/MaterialExporter.h index 8b3d1130fe9..babb113567f 100644 --- a/source/blender/io/collada/MaterialExporter.h +++ b/source/blender/io/collada/MaterialExporter.h @@ -27,12 +27,11 @@ #include "COLLADASWLibraryMaterials.h" #include "COLLADASWStreamWriter.h" -extern "C" { #include "BKE_material.h" + #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -} #include "ExportSettings.h" #include "GeometryExporter.h" diff --git a/source/blender/io/collada/Materials.h b/source/blender/io/collada/Materials.h index 86fc4c00073..e1d12246a2b 100644 --- a/source/blender/io/collada/Materials.h +++ b/source/blender/io/collada/Materials.h @@ -20,13 +20,11 @@ #include <map> #include <string> -extern "C" { #include "BKE_context.h" #include "BKE_node.h" #include "BLI_listbase.h" #include "DNA_material_types.h" #include "DNA_node_types.h" -} #include "COLLADAFWEffectCommon.h" #include "collada_utils.h" diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 6ac87d3d394..6683f07bf65 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -30,7 +30,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "BKE_customdata.h" #include "BKE_displist.h" #include "BKE_global.h" @@ -43,7 +42,6 @@ extern "C" { #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" -} #include "ArmatureImporter.h" #include "MeshImporter.h" diff --git a/source/blender/io/collada/MeshImporter.h b/source/blender/io/collada/MeshImporter.h index 5ad2fb17fce..2f2a18ff11a 100644 --- a/source/blender/io/collada/MeshImporter.h +++ b/source/blender/io/collada/MeshImporter.h @@ -38,14 +38,13 @@ #include "ArmatureImporter.h" #include "collada_utils.h" -extern "C" { #include "BLI_edgehash.h" + #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -} /* only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid */ class MeshImporterBase { diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp index 2f70bc1c26b..1b3bc1b66ea 100644 --- a/source/blender/io/collada/SceneExporter.cpp +++ b/source/blender/io/collada/SceneExporter.cpp @@ -18,13 +18,11 @@ * \ingroup collada */ -extern "C" { #include "BKE_collection.h" #include "BKE_lib_id.h" #include "BKE_object.h" #include "BLI_listbase.h" #include "BLI_utildefines.h" -} #include "BCSampleData.h" #include "SceneExporter.h" diff --git a/source/blender/io/collada/SceneExporter.h b/source/blender/io/collada/SceneExporter.h index 6effb54fd48..3ea6a9fac8e 100644 --- a/source/blender/io/collada/SceneExporter.h +++ b/source/blender/io/collada/SceneExporter.h @@ -25,7 +25,6 @@ #include <stdio.h> #include <stdlib.h> -extern "C" { #include "DNA_action_types.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -47,7 +46,6 @@ extern "C" { #include "BLI_fileops.h" #include "BLI_path_util.h" #include "ED_keyframing.h" -} #include "COLLADASWAsset.h" #include "COLLADASWBaseInputElement.h" diff --git a/source/blender/io/collada/collada.cpp b/source/blender/io/collada/collada.cpp index 683e64b2647..bf1ebbfa669 100644 --- a/source/blender/io/collada/collada.cpp +++ b/source/blender/io/collada/collada.cpp @@ -27,7 +27,6 @@ #include "ImportSettings.h" #include "collada.h" -extern "C" { #include "BKE_context.h" #include "BKE_scene.h" #include "DEG_depsgraph.h" @@ -37,6 +36,8 @@ extern "C" { #include "BLI_fileops.h" #include "BLI_linklist.h" +extern "C" { + static void print_import_header(ImportSettings &import_settings) { fprintf(stderr, "+-- Collada Import parameters------\n"); diff --git a/source/blender/io/collada/collada.h b/source/blender/io/collada/collada.h index deadbcffcaf..d8e498ef4b2 100644 --- a/source/blender/io/collada/collada.h +++ b/source/blender/io/collada/collada.h @@ -26,14 +26,14 @@ #include "ExportSettings.h" #include "ImportSettings.h" -#ifdef __cplusplus -extern "C" { -#endif - #include "BLI_linklist.h" #include "BLI_path_util.h" #include "RNA_types.h" +#ifdef __cplusplus +extern "C" { +#endif + struct bContext; /* diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index 1df82ed3038..d2e05c7ae5b 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -30,7 +30,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_customdata_types.h" @@ -75,7 +74,6 @@ extern "C" { #if 0 # include "NOD_common.h" #endif -} #include "BlenderContext.h" #include "ExportSettings.h" diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h index 54ba8073679..b1ec2c8b81a 100644 --- a/source/blender/io/collada/collada_utils.h +++ b/source/blender/io/collada/collada_utils.h @@ -33,7 +33,6 @@ #include <set> #include <vector> -extern "C" { #include "DNA_anim_types.h" #include "DNA_camera_types.h" #include "DNA_constraint_types.h" @@ -57,7 +56,6 @@ extern "C" { #include "BKE_node.h" #include "BKE_object.h" #include "BKE_scene.h" -} #include "DEG_depsgraph_query.h" diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc index d837d3d8dd3..e382fa6bb1d 100644 --- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc @@ -24,7 +24,6 @@ #include <stdio.h> #include <string> -extern "C" { #include "BKE_anim_data.h" #include "BKE_duplilist.h" #include "BKE_key.h" @@ -41,7 +40,6 @@ extern "C" { #include "DNA_particle_types.h" #include "DEG_depsgraph_query.h" -} namespace USD { @@ -345,8 +343,11 @@ void AbstractHierarchyIterator::visit_object(Object *object, context->original_export_path = ""; copy_m4_m4(context->matrix_world, object->obmat); + ExportGraph::key_type graph_index = determine_graph_index_object(context); + context_update_for_graph_index(context, graph_index); + // Store this HierarchyContext as child of the export parent. - export_graph_[std::make_pair(export_parent, nullptr)].insert(context); + export_graph_[graph_index].insert(context); // Create an empty entry for this object to indicate it is part of the export. This will be used // by connect_loose_objects(). Having such an "indicator" will make it possible to do an O(log n) @@ -359,38 +360,25 @@ void AbstractHierarchyIterator::visit_object(Object *object, } } +AbstractHierarchyIterator::ExportGraph::key_type AbstractHierarchyIterator:: + determine_graph_index_object(const HierarchyContext *context) +{ + return std::make_pair(context->export_parent, nullptr); +} + void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object, Object *duplicator, const std::set<Object *> &dupli_set) { - ExportGraph::key_type graph_index; - bool animation_check_include_parent = false; - HierarchyContext *context = new HierarchyContext(); context->object = dupli_object->ob; context->duplicator = duplicator; context->weak_export = false; context->export_path = ""; context->original_export_path = ""; + context->export_path = ""; + context->animation_check_include_parent = false; - /* If the dupli-object's parent is also instanced by this object, use that as the - * export parent. Otherwise use the dupli-parent as export parent. */ - Object *parent = dupli_object->ob->parent; - if (parent != nullptr && dupli_set.find(parent) != dupli_set.end()) { - // The parent object is part of the duplicated collection. - context->export_parent = parent; - graph_index = std::make_pair(parent, duplicator); - } - else { - /* The parent object is NOT part of the duplicated collection. This means that the world - * transform of this dupli-object can be influenced by objects that are not part of its - * export graph. */ - animation_check_include_parent = true; - context->export_parent = duplicator; - graph_index = std::make_pair(duplicator, nullptr); - } - - context->animation_check_include_parent = animation_check_include_parent; copy_m4_m4(context->matrix_world, dupli_object->mat); // Construct export name for the dupli-instance. @@ -401,9 +389,39 @@ void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object, } context->export_name = make_valid_name(get_object_name(context->object) + suffix_stream.str()); + ExportGraph::key_type graph_index = determine_graph_index_dupli(context, dupli_set); + context_update_for_graph_index(context, graph_index); export_graph_[graph_index].insert(context); } +AbstractHierarchyIterator::ExportGraph::key_type AbstractHierarchyIterator:: + determine_graph_index_dupli(const HierarchyContext *context, + const std::set<Object *> &dupli_set) +{ + /* If the dupli-object's parent is also instanced by this object, use that as the + * export parent. Otherwise use the dupli-parent as export parent. */ + + Object *parent = context->object->parent; + if (parent != nullptr && dupli_set.find(parent) != dupli_set.end()) { + // The parent object is part of the duplicated collection. + return std::make_pair(parent, context->duplicator); + } + return std::make_pair(context->duplicator, nullptr); +} + +void AbstractHierarchyIterator::context_update_for_graph_index( + HierarchyContext *context, const ExportGraph::key_type &graph_index) const +{ + // Update the HierarchyContext so that it is consistent with the graph index. + context->export_parent = graph_index.first; + if (context->export_parent != context->object->parent) { + /* The parent object in Blender is NOT used as the export parent. This means + * that the world transform of this object can be influenced by objects that + * are not part of its export graph. */ + context->animation_check_include_parent = true; + } +} + AbstractHierarchyIterator::ExportChildren &AbstractHierarchyIterator::graph_children( const HierarchyContext *context) { @@ -428,8 +446,7 @@ void AbstractHierarchyIterator::determine_export_paths(const HierarchyContext *p duplisource_export_path_[source_ob] = context->export_path; if (context->object->data != nullptr) { - ID *object_data = static_cast<ID *>(context->object->data); - ID *source_data = object_data; + ID *source_data = static_cast<ID *>(context->object->data); duplisource_export_path_[source_data] = get_object_data_path(context); } } @@ -488,6 +505,7 @@ void AbstractHierarchyIterator::make_writers(const HierarchyContext *parent_cont } for (HierarchyContext *context : graph_children(parent_context)) { + // Update the context so that it is correct for this parent-child relation. copy_m4_m4(context->parent_matrix_inv_world, parent_matrix_inv_world); // Get or create the transform writer. @@ -556,7 +574,7 @@ void AbstractHierarchyIterator::make_writers_particle_systems( HierarchyContext hair_context = *transform_context; hair_context.export_path = path_concatenate(transform_context->export_path, - get_id_name(&psys->part->id)); + make_valid_name(psys->name)); hair_context.particle_system = psys; AbstractHierarchyWriter *writer = nullptr; @@ -586,9 +604,10 @@ std::string AbstractHierarchyIterator::get_object_data_name(const Object *object return get_id_name(object_data); } -AbstractHierarchyWriter *AbstractHierarchyIterator::get_writer(const std::string &export_path) +AbstractHierarchyWriter *AbstractHierarchyIterator::get_writer( + const std::string &export_path) const { - WriterMap::iterator it = writers_.find(export_path); + WriterMap::const_iterator it = writers_.find(export_path); if (it == writers_.end()) { return nullptr; diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.h b/source/blender/io/usd/intern/abstract_hierarchy_iterator.h index 08b50e2560d..e31d5c91252 100644 --- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.h +++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.h @@ -56,7 +56,7 @@ class AbstractHierarchyWriter; * struct contains everything necessary to export a single object to a file. */ struct HierarchyContext { /*********** Determined during hierarchy iteration: ***************/ - Object *object; + Object *object; /* Evaluated object. */ Object *export_parent; Object *duplicator; float matrix_world[4][4]; @@ -188,11 +188,14 @@ class AbstractHierarchyIterator { const std::set<Object *> &dupli_set); ExportChildren &graph_children(const HierarchyContext *parent_context); + void context_update_for_graph_index(HierarchyContext *context, + const ExportGraph::key_type &graph_index) const; void determine_export_paths(const HierarchyContext *parent_context); void determine_duplication_references(const HierarchyContext *parent_context, std::string indent); + /* These three functions create writers and call their write() method. */ void make_writers(const HierarchyContext *parent_context); void make_writer_object_data(const HierarchyContext *context); void make_writers_particle_systems(const HierarchyContext *context); @@ -201,7 +204,7 @@ class AbstractHierarchyIterator { std::string get_object_name(const Object *object) const; std::string get_object_data_name(const Object *object) const; - AbstractHierarchyWriter *get_writer(const std::string &export_path); + AbstractHierarchyWriter *get_writer(const std::string &export_path) const; typedef AbstractHierarchyWriter *(AbstractHierarchyIterator::*create_writer_func)( const HierarchyContext *); @@ -233,12 +236,19 @@ class AbstractHierarchyIterator { virtual bool should_visit_dupli_object(const DupliObject *dupli_object) const; + virtual ExportGraph::key_type determine_graph_index_object(const HierarchyContext *context); + virtual ExportGraph::key_type determine_graph_index_dupli(const HierarchyContext *context, + const std::set<Object *> &dupli_set); + /* These functions should create an AbstractHierarchyWriter subclass instance, or return * nullptr if the object or its data should not be exported. Returning a nullptr for * data/hair/particle will NOT prevent the transform to be written. * * The returned writer is owned by the AbstractHierarchyWriter, and should be freed in - * delete_object_writer(). */ + * delete_object_writer(). + * + * The created AbstractHierarchyWriter instances should NOT keep a copy of the context pointer. + * The context can be stack-allocated and go out of scope. */ virtual AbstractHierarchyWriter *create_transform_writer(const HierarchyContext *context) = 0; virtual AbstractHierarchyWriter *create_data_writer(const HierarchyContext *context) = 0; virtual AbstractHierarchyWriter *create_hair_writer(const HierarchyContext *context) = 0; diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc index 60ab3676847..f8e0a03abfa 100644 --- a/source/blender/io/usd/intern/usd_capi.cc +++ b/source/blender/io/usd/intern/usd_capi.cc @@ -26,7 +26,6 @@ #include "MEM_guardedalloc.h" -extern "C" { #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" @@ -44,7 +43,6 @@ extern "C" { #include "WM_api.h" #include "WM_types.h" -} namespace USD { diff --git a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc index 47f09af7442..56e367dd877 100644 --- a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc +++ b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc @@ -31,7 +31,6 @@ #include <pxr/base/tf/stringUtils.h> -extern "C" { #include "BKE_duplilist.h" #include "BLI_assert.h" @@ -41,7 +40,6 @@ extern "C" { #include "DNA_ID.h" #include "DNA_layer_types.h" #include "DNA_object_types.h" -} namespace USD { diff --git a/source/blender/io/usd/intern/usd_writer_abstract.h b/source/blender/io/usd/intern/usd_writer_abstract.h index cf0f7e9d437..01b53f4c916 100644 --- a/source/blender/io/usd/intern/usd_writer_abstract.h +++ b/source/blender/io/usd/intern/usd_writer_abstract.h @@ -29,10 +29,9 @@ #include <vector> -extern "C" { #include "DEG_depsgraph_query.h" + #include "DNA_material_types.h" -} struct Material; struct Object; diff --git a/source/blender/io/usd/intern/usd_writer_camera.cc b/source/blender/io/usd/intern/usd_writer_camera.cc index 9b85d69559c..ea551a43c9f 100644 --- a/source/blender/io/usd/intern/usd_writer_camera.cc +++ b/source/blender/io/usd/intern/usd_writer_camera.cc @@ -22,13 +22,11 @@ #include <pxr/usd/usdGeom/camera.h> #include <pxr/usd/usdGeom/tokens.h> -extern "C" { #include "BKE_camera.h" #include "BLI_assert.h" #include "DNA_camera_types.h" #include "DNA_scene_types.h" -} namespace USD { diff --git a/source/blender/io/usd/intern/usd_writer_hair.cc b/source/blender/io/usd/intern/usd_writer_hair.cc index 9251425c0b8..d38c1032969 100644 --- a/source/blender/io/usd/intern/usd_writer_hair.cc +++ b/source/blender/io/usd/intern/usd_writer_hair.cc @@ -22,11 +22,9 @@ #include <pxr/usd/usdGeom/basisCurves.h> #include <pxr/usd/usdGeom/tokens.h> -extern "C" { #include "BKE_particle.h" #include "DNA_particle_types.h" -} namespace USD { diff --git a/source/blender/io/usd/intern/usd_writer_light.cc b/source/blender/io/usd/intern/usd_writer_light.cc index e13e2c58a79..0ce3ee5f8ce 100644 --- a/source/blender/io/usd/intern/usd_writer_light.cc +++ b/source/blender/io/usd/intern/usd_writer_light.cc @@ -24,13 +24,11 @@ #include <pxr/usd/usdLux/rectLight.h> #include <pxr/usd/usdLux/sphereLight.h> -extern "C" { #include "BLI_assert.h" #include "BLI_utildefines.h" #include "DNA_light_types.h" #include "DNA_object_types.h" -} namespace USD { diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 2e6696e12ca..909869d2af1 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -23,7 +23,6 @@ #include <pxr/usd/usdShade/material.h> #include <pxr/usd/usdShade/materialBindingAPI.h> -extern "C" { #include "BLI_assert.h" #include "BLI_math_vector.h" @@ -42,7 +41,6 @@ extern "C" { #include "DNA_modifier_types.h" #include "DNA_object_fluidsim_types.h" #include "DNA_particle_types.h" -} namespace USD { @@ -441,7 +439,7 @@ void USDGenericMeshWriter::write_surface_velocity(Object *object, /* Only velocities from the fluid simulation are exported. This is the most important case, * though, as the baked mesh changes topology all the time, and thus computing the velocities * at import time in a post-processing step is hard. */ - ModifierData *md = modifiers_findByType(object, eModifierType_Fluidsim); + ModifierData *md = BKE_modifiers_findby_type(object, eModifierType_Fluidsim); if (md == nullptr) { return; } @@ -450,7 +448,7 @@ void USDGenericMeshWriter::write_surface_velocity(Object *object, const bool use_render = (DEG_get_mode(usd_export_context_.depsgraph) == DAG_EVAL_RENDER); const ModifierMode required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime; const Scene *scene = DEG_get_evaluated_scene(usd_export_context_.depsgraph); - if (!modifier_isEnabled(scene, md, required_mode)) { + if (!BKE_modifier_is_enabled(scene, md, required_mode)) { return; } FluidsimModifierData *fsmd = reinterpret_cast<FluidsimModifierData *>(md); diff --git a/source/blender/io/usd/intern/usd_writer_metaball.cc b/source/blender/io/usd/intern/usd_writer_metaball.cc index 25b216d20f3..96bf854d327 100644 --- a/source/blender/io/usd/intern/usd_writer_metaball.cc +++ b/source/blender/io/usd/intern/usd_writer_metaball.cc @@ -23,7 +23,6 @@ #include <pxr/usd/usdShade/material.h> #include <pxr/usd/usdShade/materialBindingAPI.h> -extern "C" { #include "BLI_assert.h" #include "BKE_displist.h" @@ -34,7 +33,6 @@ extern "C" { #include "DNA_mesh_types.h" #include "DNA_meta_types.h" -} namespace USD { diff --git a/source/blender/io/usd/intern/usd_writer_transform.cc b/source/blender/io/usd/intern/usd_writer_transform.cc index 321b516221a..038f2b17b1a 100644 --- a/source/blender/io/usd/intern/usd_writer_transform.cc +++ b/source/blender/io/usd/intern/usd_writer_transform.cc @@ -22,13 +22,11 @@ #include <pxr/base/gf/matrix4f.h> #include <pxr/usd/usdGeom/xform.h> -extern "C" { #include "BKE_object.h" #include "BLI_math_matrix.h" #include "DNA_layer_types.h" -} namespace USD { diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h index 8a5575d53cf..eee98521289 100644 --- a/source/blender/io/usd/usd.h +++ b/source/blender/io/usd/usd.h @@ -20,12 +20,12 @@ #ifndef __USD_H__ #define __USD_H__ +#include "DEG_depsgraph.h" + #ifdef __cplusplus extern "C" { #endif -#include "DEG_depsgraph.h" - struct Scene; struct bContext; |