Blender V4.3
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
13namespace blender::io::usd {
14
19using XformResult = std::tuple<pxr::GfMatrix4f, bool>;
20
22 private:
23 bool use_parent_xform_;
24
25 /* Indicates if the created object is the root of a
26 * transform hierarchy. */
27 bool is_root_xform_;
28
29 public:
30 USDXformReader(const pxr::UsdPrim &prim,
31 const USDImportParams &import_params,
32 const ImportSettings &settings)
33 : USDPrimReader(prim, import_params, settings),
34 use_parent_xform_(false),
35 is_root_xform_(is_root_xform_prim())
36 {
37 }
38
39 void create_object(Main *bmain, double motionSampleTime) override;
40 void read_object_data(Main *bmain, double motionSampleTime) override;
41
42 void read_matrix(float r_mat[4][4], float time, float scale, bool *r_is_constant) const;
43
44 bool use_parent_xform() const
45 {
46 return use_parent_xform_;
47 }
49 {
50 use_parent_xform_ = flag;
51 is_root_xform_ = is_root_xform_prim();
52 }
53
54 bool prim_has_xform_ops() const;
55
56 protected:
57 /* Returns true if the contained USD prim is the root of a transform hierarchy. */
58 bool is_root_xform_prim() const;
59
70 virtual std::optional<XformResult> get_local_usd_xform(float time) const;
71};
72
73} // namespace blender::io::usd
const pxr::UsdPrim & prim() const
void create_object(Main *bmain, double motionSampleTime) 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
std::tuple< pxr::GfMatrix4f, bool > XformResult
uint8_t flag
Definition wm_window.cc:138