Blender V4.5
usd_reader_xform.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Tangent Animation. All rights reserved.
2 * SPDX-FileCopyrightText: 2023 Blender Authors
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 *
6 * Adapted from the Blender Alembic importer implementation. */
7
8#pragma once
9
10#include "usd.hh"
11#include "usd_reader_prim.hh"
12
13/* For #UsdGeomXformable. */
14#include <pxr/usd/usdGeom/xformable.h>
15
16struct Main;
17
18namespace blender::io::usd {
19
24using XformResult = std::tuple<pxr::GfMatrix4f, bool>;
25
27 private:
28 bool use_parent_xform_ = false;
29
30 /* Indicates if the created object is the root of a
31 * transform hierarchy. */
32 bool is_root_xform_;
33
34 public:
35 USDXformReader(const pxr::UsdPrim &prim,
36 const USDImportParams &import_params,
37 const ImportSettings &settings)
38 : USDPrimReader(prim, import_params, settings), is_root_xform_(is_root_xform_prim())
39 {
40 }
41
42 void create_object(Main *bmain) override;
43 void read_object_data(Main *bmain, double motionSampleTime) override;
44
45 pxr::SdfPath object_prim_path() const override;
46
47 void read_matrix(float r_mat[4][4], float time, float scale, bool *r_is_constant) const;
48
49 bool use_parent_xform() const
50 {
51 return use_parent_xform_;
52 }
54 {
55 use_parent_xform_ = flag;
56 is_root_xform_ = is_root_xform_prim();
57 }
58
59 bool prim_has_xform_ops() const;
60
61 protected:
62 /* Returns true if the contained USD prim is the root of a transform hierarchy. */
63 bool is_root_xform_prim() const;
64
75 virtual std::optional<XformResult> get_local_usd_xform(float time) const;
76
77 private:
78 pxr::UsdGeomXformable get_xformable() const;
79};
80
81} // namespace blender::io::usd
USDPrimReader(const pxr::UsdPrim &prim, const USDImportParams &import_params, const ImportSettings &settings)
const pxr::UsdPrim & prim() const
void create_object(Main *bmain) override
USDXformReader(const pxr::UsdPrim &prim, const USDImportParams &import_params, const ImportSettings &settings)
void read_object_data(Main *bmain, double motionSampleTime) override
virtual std::optional< XformResult > get_local_usd_xform(float time) const
void read_matrix(float r_mat[4][4], float time, float scale, bool *r_is_constant) const
pxr::SdfPath object_prim_path() const override
std::tuple< pxr::GfMatrix4f, bool > XformResult
uint8_t flag
Definition wm_window.cc:139