Blender  V3.3
usd_writer_transform.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. All rights reserved. */
3 #include "usd_writer_transform.h"
5 
6 #include <pxr/base/gf/matrix4f.h>
7 #include <pxr/usd/usdGeom/xform.h>
8 
9 #include "BKE_object.h"
10 
11 #include "BLI_math_matrix.h"
12 
13 #include "DNA_layer_types.h"
14 
15 namespace blender::io::usd {
16 
18 {
19 }
20 
22 {
23  float parent_relative_matrix[4][4]; /* The object matrix relative to the parent. */
24  mul_m4_m4m4(parent_relative_matrix, context.parent_matrix_inv_world, context.matrix_world);
25 
26  /* Write the transform relative to the parent. */
27  pxr::UsdGeomXform xform = pxr::UsdGeomXform::Define(usd_export_context_.stage,
29  if (!xformOp_) {
30  xformOp_ = xform.AddTransformOp();
31  }
32  xformOp_.Set(pxr::GfMatrix4d(parent_relative_matrix), get_export_time_code());
33 }
34 
36 {
37  if (context.duplicator != nullptr) {
38  /* This object is being duplicated, so could be emitted by a particle system and thus
39  * influenced by forces. TODO(Sybren): Make this more strict. Probably better to get from the
40  * depsgraph whether this object instance has a time source. */
41  return true;
42  }
44  return true;
45  }
46  return BKE_object_moves_in_time(context.object, context.animation_check_include_parent);
47 }
48 
49 } // namespace blender::io::usd
General operations, lookup, etc. for blender objects.
bool BKE_object_moves_in_time(const struct Object *object, bool recurse_parent)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
static bool check_has_physics(const HierarchyContext &context)
pxr::UsdTimeCode get_export_time_code() const
const USDExporterContext usd_export_context_
USDTransformWriter(const USDExporterContext &ctx)
bool check_is_animated(const HierarchyContext &context) const override
void do_write(HierarchyContext &context) override