Blender V4.3
mesh.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <pxr/base/vt/array.h>
8#include <pxr/imaging/hd/sceneDelegate.h>
9
10#include "BLI_set.hh"
11
12#include "BKE_duplilist.hh"
13
14#include "material.hh"
15#include "object.hh"
16
17namespace blender::io::hydra {
18
19class MeshData : public ObjectData {
20 public:
21 struct SubMesh {
22 pxr::VtVec3fArray vertices;
23 pxr::VtIntArray face_vertex_counts;
24 pxr::VtIntArray face_vertex_indices;
25 pxr::VtVec3fArray normals;
26 pxr::VtVec2fArray uvs;
27 int mat_index = 0;
29 };
30
31 private:
32 Vector<SubMesh> submeshes_;
33 int submeshes_count_ = 0;
34
35 public:
36 MeshData(HydraSceneDelegate *scene_delegate, const Object *object, pxr::SdfPath const &prim_id);
37
38 void init() override;
39 void insert() override;
40 void remove() override;
41 void update() override;
42
43 pxr::VtValue get_data(pxr::TfToken const &key) const override;
44 pxr::VtValue get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const override;
45 pxr::SdfPath material_id(pxr::SdfPath const &id) const override;
46 void available_materials(Set<pxr::SdfPath> &paths) const override;
47
48 pxr::HdMeshTopology topology(pxr::SdfPath const &id) const;
49 pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
50 pxr::HdCullStyle cull_style(pxr::SdfPath const &id) const;
51 bool double_sided(pxr::SdfPath const &id) const;
52 void update_double_sided(MaterialData *mat_data);
53 pxr::SdfPathVector submesh_paths() const;
54
55 protected:
56 void write_materials() override;
57
58 private:
59 pxr::SdfPath submesh_prim_id(int index) const;
60 const SubMesh &submesh(pxr::SdfPath const &id) const;
61 void write_submeshes(const Mesh *mesh);
62 void update_prims();
63};
64
65} // namespace blender::io::hydra
pxr::SdfPath prim_id
Definition id.hh:36
pxr::HdMeshTopology topology(pxr::SdfPath const &id) const
pxr::VtValue get_data(pxr::TfToken const &key) const override
pxr::SdfPathVector submesh_paths() const
pxr::HdCullStyle cull_style(pxr::SdfPath const &id) const
void update_double_sided(MaterialData *mat_data)
void available_materials(Set< pxr::SdfPath > &paths) const override
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const
bool double_sided(pxr::SdfPath const &id) const
MeshData(HydraSceneDelegate *scene_delegate, const Object *object, pxr::SdfPath const &prim_id)
virtual pxr::SdfPath material_id() const
pxr::VtIntArray face_vertex_counts
Definition mesh.hh:23
pxr::VtIntArray face_vertex_indices
Definition mesh.hh:24