Skip to content

Commit 29d45f4

Browse files
committed
Do not use raw literals, use virtual initialize
1 parent 723fd44 commit 29d45f4

File tree

6 files changed

+34
-44
lines changed

6 files changed

+34
-44
lines changed

src/nbl/asset/IAssetManager.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,4 @@ void IAssetManager::insertBuiltinAssets()
418418
for(auto &path : paths)
419419
addBuiltInToCaches(pipelineLayout, path);
420420
}
421-
422-
/*
423-
Pipelines
424-
*/
425-
426-
//! Okay, an explaination is needed
427-
{
428-
429-
}
430421
}

src/nbl/asset/interchange/CPLYMeshFileLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace asset
2525
CPLYMeshFileLoader::CPLYMeshFileLoader(IAssetManager* _am)
2626
: IRenderpassIndependentPipelineLoader(_am)
2727
{
28-
initialize();
28+
2929
}
3030

3131
CPLYMeshFileLoader::~CPLYMeshFileLoader() {}

src/nbl/asset/interchange/CPLYMeshFileLoader.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,34 @@ class CPLYMeshFileLoader : public IAssetLoader, public IRenderpassIndependentPip
5252

5353
//! creates/loads an animated mesh from the file.
5454
virtual SAssetBundle loadAsset(io::IReadFile* _file, const IAssetLoader::SAssetLoadParams& _params, IAssetLoader::IAssetLoaderOverride* _override = nullptr, uint32_t _hierarchyLevel = 0u) override;
55+
5556
private:
5657

57-
enum E_TYPE { ET_POS = 0, ET_UV = 2, ET_NORM = 3, ET_COL = 1 };
58+
virtual void initialize() override;
5859

59-
void initialize();
60+
enum E_TYPE { ET_POS = 0, ET_UV = 2, ET_NORM = 3, ET_COL = 1 };
6061

61-
static const std::string getPipelineCacheKey(E_TYPE type, bool indexBufferBindingAvailable)
62+
static const std::string getPipelineCacheKey(E_TYPE type, bool indexBufferBindingAvailable)
6263
{
6364
auto getTypeHash = [&]() -> std::string
6465
{
6566
bool status = true;
6667

6768
switch (type)
6869
{
69-
case ET_POS:
70-
return "nbl/builtin/pipeline/loader/PLY/only_position_attribute/";
71-
case ET_COL:
72-
return "nbl/builtin/pipeline/loader/PLY/color_attribute/";
73-
case ET_UV:
74-
return "nbl/builtin/pipeline/loader/PLY/uv_attribute/";
75-
case ET_NORM:
76-
return "nbl/builtin/pipeline/loader/PLY/normal_attribute/";
77-
default:
78-
{
79-
status = false;
80-
assert(status);
81-
}
70+
case ET_POS:
71+
return "nbl/builtin/pipeline/loader/PLY/only_position_attribute/";
72+
case ET_COL:
73+
return "nbl/builtin/pipeline/loader/PLY/color_attribute/";
74+
case ET_UV:
75+
return "nbl/builtin/pipeline/loader/PLY/uv_attribute/";
76+
case ET_NORM:
77+
return "nbl/builtin/pipeline/loader/PLY/normal_attribute/";
78+
default:
79+
{
80+
status = false;
81+
assert(status);
82+
}
8283
}
8384
};
8485

src/nbl/asset/interchange/CPLYMeshWriter.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,14 @@ bool CPLYMeshWriter::writeAsset(io::IWriteFile* _file, const SAssetWriteParams&
8484
if (meshbuffers.size() > 1)
8585
{
8686
#ifdef _NBL_DEBUG
87-
os::Printer::log("PLY WRITER ERROR (" + std::to_string(__LINE__) + " line): Only one meshbuffer input is allowed for writing!", ELL_ERROR);
87+
os::Printer::log("PLY WRITER WARNING (" + std::to_string(__LINE__) + " line): Only one meshbuffer input is allowed for writing! Saving first one", ELL_WARNING);
8888
#endif // _NBL_DEBUG
89-
return false;
9089
}
9190

9291
os::Printer::log("Writing mesh", file->getFileName().c_str());
9392

9493
const asset::E_WRITER_FLAGS flags = _override->getAssetWritingFlags(ctx, mesh, 0u);
9594

96-
97-
9895
auto getConvertedCpuMeshBufferWithIndexBuffer = [&]() -> core::smart_refctd_ptr<asset::ICPUMeshBuffer>
9996
{
10097
auto inputMeshBuffer = *meshbuffers.begin();
@@ -140,19 +137,24 @@ bool CPLYMeshWriter::writeAsset(io::IWriteFile* _file, const SAssetWriteParams&
140137

141138
bool vaidToWrite[4]{ 0, 0, 0, 0 };
142139

143-
if (rawCopyMeshBuffer->getAttribBoundBuffer(0).buffer)
140+
const uint32_t POSITION_ATTRIBUTE = rawCopyMeshBuffer->getPositionAttributeIx();
141+
constexpr uint32_t COLOR_ATTRIBUTE = 1;
142+
constexpr uint32_t UV_ATTRIBUTE = 2;
143+
const uint32_t NORMAL_ATTRIBUTE = rawCopyMeshBuffer->getNormalAttributeIx();
144+
145+
if (rawCopyMeshBuffer->getAttribBoundBuffer(POSITION_ATTRIBUTE).buffer)
144146
{
145-
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(0);
147+
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(POSITION_ATTRIBUTE);
146148
std::string typeStr = getTypeString(t);
147149
vaidToWrite[0] = true;
148150
header +=
149151
"property " + typeStr + " x\n" +
150152
"property " + typeStr + " y\n" +
151153
"property " + typeStr + " z\n";
152154
}
153-
if (rawCopyMeshBuffer->getAttribBoundBuffer(1).buffer)
155+
if (rawCopyMeshBuffer->getAttribBoundBuffer(COLOR_ATTRIBUTE).buffer)
154156
{
155-
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(1);
157+
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(COLOR_ATTRIBUTE);
156158
std::string typeStr = getTypeString(t);
157159
vaidToWrite[1] = true;
158160
header +=
@@ -164,18 +166,18 @@ bool CPLYMeshWriter::writeAsset(io::IWriteFile* _file, const SAssetWriteParams&
164166
header += "property " + typeStr + " alpha\n";
165167
}
166168
}
167-
if (rawCopyMeshBuffer->getAttribBoundBuffer(2).buffer)
169+
if (rawCopyMeshBuffer->getAttribBoundBuffer(UV_ATTRIBUTE).buffer)
168170
{
169-
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(2);
171+
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(UV_ATTRIBUTE);
170172
std::string typeStr = getTypeString(t);
171173
vaidToWrite[2] = true;
172174
header +=
173175
"property " + typeStr + " u\n" +
174176
"property " + typeStr + " v\n";
175177
}
176-
if (rawCopyMeshBuffer->getAttribBoundBuffer(3).buffer)
178+
if (rawCopyMeshBuffer->getAttribBoundBuffer(NORMAL_ATTRIBUTE).buffer)
177179
{
178-
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(3);
180+
const asset::E_FORMAT t = rawCopyMeshBuffer->getAttribFormat(NORMAL_ATTRIBUTE);
179181
std::string typeStr = getTypeString(t);
180182
vaidToWrite[3] = true;
181183
header +=

src/nbl/asset/interchange/CSTLMeshFileLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ constexpr auto NORMAL_ATTRIBUTE = 3;
2727
CSTLMeshFileLoader::CSTLMeshFileLoader(asset::IAssetManager* _m_assetMgr)
2828
: IRenderpassIndependentPipelineLoader(_m_assetMgr), m_assetMgr(_m_assetMgr)
2929
{
30-
initialize();
30+
3131
}
3232

3333
void CSTLMeshFileLoader::initialize()

src/nbl/asset/interchange/CSTLMeshFileLoader.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ class CSTLMeshFileLoader final : public IAssetLoader, public IRenderpassIndepend
3535

3636
private:
3737

38-
/*
39-
Precompute STL pipeline
40-
*/
41-
42-
void initialize();
38+
virtual void initialize() override;
4339

4440
const std::string_view getPipelineCacheKey(bool withColorAttribute) { return withColorAttribute ? "nbl/builtin/pipeline/loader/STL/color_attribute" : "nbl/builtin/pipeline/loader/STL/no_color_attribute"; }
4541

0 commit comments

Comments
 (0)