Blender V5.0
usd_writer_pointinstancer.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
9#include "BLI_map.hh"
10#include "BLI_span.hh"
11#include "BLI_vector.hh"
12
13#include <pxr/usd/usdGeom/pointInstancer.h>
14
15struct USDExporterContext;
16
17namespace blender::io::usd {
18
20 private:
21 std::unique_ptr<USDAbstractWriter> base_writer_;
23
24 public:
26 const blender::Set<std::pair<pxr::SdfPath, Object *>> &prototype_paths,
27 std::unique_ptr<USDAbstractWriter> base_writer);
28 ~USDPointInstancerWriter() override = default;
29
30 protected:
31 void do_write(HierarchyContext &context) override;
32
33 private:
34 void write_attribute_data(const bke::AttributeIter &attr,
35 const pxr::UsdGeomPointInstancer &usd_instancer,
36 const pxr::UsdTimeCode time);
37
38 void process_instance_reference(
39 const bke::InstanceReference &reference,
40 int instance_index,
41 blender::Map<std::string, int> &proto_index_map,
42 blender::Map<std::string, int> &final_proto_index_map,
44 pxr::UsdStageRefPtr stage,
45 pxr::VtArray<int> &proto_indices,
46 blender::Vector<std::pair<int, int>> &collection_instance_object_count_map);
47
48 void compact_prototypes(const pxr::UsdGeomPointInstancer &usd_instancer,
49 const pxr::UsdTimeCode time,
50 const pxr::SdfPathVector &proto_paths) const;
51
52 void override_transform(pxr::UsdStageRefPtr stage,
53 const pxr::SdfPath &proto_path,
54 const float4x4 &transform) const;
55
56 void handle_collection_prototypes(
57 const pxr::UsdGeomPointInstancer &usd_instancer,
58 const pxr::UsdTimeCode time,
59 int instance_num,
60 const blender::Span<std::pair<int, int>> collection_instance_object_count_map) const;
61};
62
63} // namespace blender::io::usd
#define final(a, b, c)
Definition BLI_hash.h:19
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
USDAbstractWriter(const USDExporterContext &usd_export_context)
USDPointInstancerWriter(const USDExporterContext &ctx, const blender::Set< std::pair< pxr::SdfPath, Object * > > &prototype_paths, std::unique_ptr< USDAbstractWriter > base_writer)
void do_write(HierarchyContext &context) override
MatBase< float, 4, 4 > float4x4