52 {
54 switch (
mesh.indices()->type()) {
55 case fb::IndexType::k16Bit:
57 break;
58 case fb::IndexType::k32Bit:
60 break;
61 }
62
63 const uint8_t* vertices_start;
64 size_t vertices_bytes;
65 bool is_skinned;
66
67 switch (
mesh.vertices_type()) {
68 case fb::VertexBuffer::UnskinnedVertexBuffer: {
69 const auto* vertices =
70 mesh.vertices_as_UnskinnedVertexBuffer()->vertices();
71 vertices_start = reinterpret_cast<const uint8_t*>(vertices->Get(0));
72 vertices_bytes = vertices->size() *
sizeof(
fb::Vertex);
73 is_skinned = false;
74 break;
75 }
76 case fb::VertexBuffer::SkinnedVertexBuffer: {
77 const auto* vertices =
mesh.vertices_as_SkinnedVertexBuffer()->vertices();
78 vertices_start = reinterpret_cast<const uint8_t*>(vertices->Get(0));
79 vertices_bytes = vertices->size() * sizeof(fb::SkinnedVertex);
80 is_skinned = true;
81 break;
82 }
83 case fb::VertexBuffer::NONE:
85 return nullptr;
86 }
87
88 const uint8_t* indices_start =
89 reinterpret_cast<const uint8_t*
>(
mesh.indices()->data()->Data());
90
91 const size_t indices_bytes =
mesh.indices()->data()->size();
92 if (vertices_bytes == 0 || indices_bytes == 0) {
93 return nullptr;
94 }
95
96 DeviceBufferDescriptor buffer_desc;
97 buffer_desc.size = vertices_bytes + indices_bytes;
99
100 auto buffer = allocator.CreateBuffer(buffer_desc);
101 buffer->SetLabel(
"Mesh vertices+indices");
102
103 if (!
buffer->CopyHostBuffer(vertices_start, Range(0, vertices_bytes))) {
104 return nullptr;
105 }
106 if (!
buffer->CopyHostBuffer(indices_start, Range(0, indices_bytes),
107 vertices_bytes)) {
108 return nullptr;
109 }
110
112 .vertex_buffer = {.buffer =
buffer, .range = Range(0, vertices_bytes)},
113 .index_buffer = {.buffer =
buffer,
114 .range = Range(vertices_bytes, indices_bytes)},
115 .vertex_count =
mesh.indices()->count(),
116 .index_type = index_type,
117 };
119}
GrTriangulator::Vertex Vertex
static std::shared_ptr< Geometry > MakeVertexBuffer(VertexBuffer vertex_buffer, bool is_skinned)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer