Skip to content

Commit c227b70

Browse files
committed
get colors working?
1 parent d4e6745 commit c227b70

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/nbl/asset/interchange/CSTLMeshFileLoader.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct SContext
135135

136136
core::vector<hlsl::float32_t3> vertices;
137137
core::vector<hlsl::float32_t3> normals;
138+
core::vector<uint32_t> colors;
138139
core::vector<uint32_t> indices;
139140
};
140141

@@ -243,7 +244,7 @@ SAssetBundle CSTLMeshFileLoader::loadAsset(system::IFile* _file, const IAssetLoa
243244
uint32_t newIdx = static_cast<uint32_t>(context.vertices.size());
244245
vertexMap[p] = newIdx;
245246
context.indices.push_back(newIdx);
246-
context.vertices.push_back(p);
247+
context.vertices.emplace_back(std::move(p));
247248
}
248249
else
249250
{
@@ -271,7 +272,7 @@ SAssetBundle CSTLMeshFileLoader::loadAsset(system::IFile* _file, const IAssetLoa
271272
const void* srcColor[1]{ &attrib };
272273
uint32_t color{};
273274
convertColor<EF_A1R5G5B5_UNORM_PACK16, EF_B8G8R8A8_UNORM>(srcColor, &color, 0u, 0u);
274-
colors.push_back(color);
275+
context.colors.push_back(color);
275276
}
276277
else
277278
{
@@ -290,7 +291,12 @@ SAssetBundle CSTLMeshFileLoader::loadAsset(system::IFile* _file, const IAssetLoa
290291
geometry->setPositionView(createView(E_FORMAT::EF_R32G32B32_SFLOAT, context.vertices.size(), context.vertices.data()));
291292
geometry->setNormalView(createView(E_FORMAT::EF_R32G32B32_SFLOAT, context.normals.size(), context.normals.data()));
292293

293-
// TODO: Vertex colors
294+
if (!context.colors.empty())
295+
{
296+
// I'm still not sure if this works, probably not
297+
auto colorsView = createView(EF_A1R5G5B5_UNORM_PACK16, context.colors.size(), context.colors.data());
298+
geometry->getAuxAttributeViews()->push_back(colorsView);
299+
}
294300

295301
CPolygonGeometryManipulator::recomputeContentHashes(geometry.get());
296302
CPolygonGeometryManipulator::recomputeRanges(geometry.get());

0 commit comments

Comments
 (0)