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:
Diffstat (limited to 'source/blender/io/usd/intern')
-rw-r--r--source/blender/io/usd/intern/abstract_hierarchy_iterator.cc79
-rw-r--r--source/blender/io/usd/intern/abstract_hierarchy_iterator.h16
-rw-r--r--source/blender/io/usd/intern/usd_capi.cc4
-rw-r--r--source/blender/io/usd/intern/usd_hierarchy_iterator.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_abstract.h3
-rw-r--r--source/blender/io/usd/intern/usd_writer_camera.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_hair.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_light.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.cc10
-rw-r--r--source/blender/io/usd/intern/usd_writer_metaball.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_transform.cc4
11 files changed, 69 insertions, 57 deletions
diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc
index d837d3d8dd3..ab83ea2c3c4 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 {
@@ -55,7 +53,7 @@ bool HierarchyContext::operator<(const HierarchyContext &other) const
if (object != other.object) {
return object < other.object;
}
- if (duplicator != NULL && duplicator == other.duplicator) {
+ if (duplicator != nullptr && duplicator == other.duplicator) {
// Only resort to string comparisons when both objects are created by the same duplicator.
return export_name < other.export_name;
}
@@ -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 1b3bbc29ed6..cf962446d04 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 {
@@ -188,7 +186,7 @@ bool USD_export(bContext *C,
/* setup job */
WM_jobs_customdata_set(wm_job, job, MEM_freeN);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_FRAME, NC_SCENE | ND_FRAME);
- WM_jobs_callbacks(wm_job, USD::export_startjob, NULL, NULL, USD::export_endjob);
+ WM_jobs_callbacks(wm_job, USD::export_startjob, nullptr, nullptr, USD::export_endjob);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
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..841501bcf42 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 {
@@ -81,7 +79,7 @@ void USDGenericMeshWriter::do_write(HierarchyContext &context)
bool needsfree = false;
Mesh *mesh = get_export_mesh(object_eval, needsfree);
- if (mesh == NULL) {
+ if (mesh == nullptr) {
return;
}
@@ -102,7 +100,7 @@ void USDGenericMeshWriter::do_write(HierarchyContext &context)
void USDGenericMeshWriter::free_export_mesh(Mesh *mesh)
{
- BKE_id_free(NULL, mesh);
+ BKE_id_free(nullptr, mesh);
}
struct USDMeshData {
@@ -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..0694d873002 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 {
@@ -52,7 +50,7 @@ void USDTransformWriter::do_write(HierarchyContext &context)
bool USDTransformWriter::check_is_animated(const HierarchyContext &context) const
{
- if (context.duplicator != NULL) {
+ if (context.duplicator != nullptr) {
/* This object is being duplicated, so could be emitted by a particle system and thus
* influenced by forces. TODO(Sybren): Make this more strict. Probably better to get from the
* depsgraph whether this object instance has a time source. */