Skip to content

Commit ccaa744

Browse files
author
devsh
committed
remove even more dead code
1 parent e81b36b commit ccaa744

File tree

1 file changed

+49
-55
lines changed

1 file changed

+49
-55
lines changed

src/nbl/asset/utils/CSmoothNormalGenerator.cpp

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,6 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::weldVertices
383383
for (auto neighbourVertex_it = bounds.begin; neighbourVertex_it != bounds.end; neighbourVertex_it++)
384384
{
385385
const auto neighbourGroupIndex = groupIndexes[neighbourVertex_it->index];
386-
387-
hlsl::float32_t3 normal1, normal2;
388-
polygon->getNormalView().decodeElement(processedVertex->index, normal1);
389-
polygon->getNormalView().decodeElement(neighbourVertex_it->index, normal2);
390-
391-
hlsl::float32_t3 position1, position2;
392-
polygon->getPositionView().decodeElement(processedVertex->index, position1);
393-
polygon->getPositionView().decodeElement(neighbourVertex_it->index, position2);
394386

395387
// find the first group that this vertex can join
396388
if (processedVertex != neighbourVertex_it && neighbourGroupIndex && canJoinVertices(processedVertex->index, neighbourVertex_it->index))
@@ -409,29 +401,30 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::weldVertices
409401
}
410402
}
411403

412-
auto outPolygon = core::move_and_static_cast<ICPUPolygonGeometry>(polygon->clone(0u));
404+
auto outPolygon = core::move_and_static_cast<ICPUPolygonGeometry>(polygon->clone(0u));
413405
outPolygon->setIndexing(IPolygonGeometryBase::TriangleList());
414406

415407
const uint32_t indexSize = (groups.size() < std::numeric_limits<uint16_t>::max()) ? sizeof(uint16_t) : sizeof(uint32_t);
416-
auto indexBuffer = ICPUBuffer::create({indexSize * groupIndexes.size(), IBuffer::EUF_INDEX_BUFFER_BIT});
417-
auto indexBufferPtr = reinterpret_cast<std::byte*>(indexBuffer->getPointer());
418-
auto indexView = ICPUPolygonGeometry::SDataView{
419-
.composed = {
420-
.stride = indexSize,
421-
},
422-
.src = {
423-
.offset = 0,
424-
.size = indexBuffer->getSize(),
425-
.buffer = std::move(indexBuffer)
426-
}
427-
};
408+
auto indexBuffer = ICPUBuffer::create({ indexSize * groupIndexes.size(), IBuffer::EUF_INDEX_BUFFER_BIT });
409+
auto indexBufferPtr = reinterpret_cast<std::byte*>(indexBuffer->getPointer());
410+
auto indexView = ICPUPolygonGeometry::SDataView{
411+
.composed = {
412+
.stride = indexSize,
413+
},
414+
.src = {
415+
.offset = 0,
416+
.size = indexBuffer->getSize(),
417+
.buffer = std::move(indexBuffer)
418+
}
419+
};
428420
if (indexSize == 2)
429421
{
430422
indexView.composed.encodedDataRange.u16.minVx[0] = 0;
431423
indexView.composed.encodedDataRange.u16.maxVx[0] = groups.size() - 1;
432424
indexView.composed.format = EF_R16_UINT;
433425
indexView.composed.rangeFormat = IGeometryBase::EAABBFormat::U16;
434-
} else if (indexSize == 4)
426+
}
427+
else if (indexSize == 4)
435428
{
436429
indexView.composed.encodedDataRange.u32.minVx[0] = 0;
437430
indexView.composed.encodedDataRange.u32.maxVx[0] = groups.size() - 1;
@@ -445,7 +438,8 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::weldVertices
445438
{
446439
uint16_t index = *groupIndexes[index_i];
447440
memcpy(indexBufferPtr + indexSize * index_i, &index, sizeof(index));
448-
} else if (indexSize == 4)
441+
}
442+
else if (indexSize == 4)
449443
{
450444
uint32_t index = *groupIndexes[index_i];
451445
memcpy(indexBufferPtr + indexSize * index_i, &index, sizeof(index));
@@ -462,7 +456,7 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::weldVertices
462456
outPolygon->setPositionView({
463457
.composed = polygon->getPositionView().composed,
464458
.src = {.offset = 0, .size = positionBuffer->getSize(), .buffer = std::move(positionBuffer)}
465-
});
459+
});
466460

467461
using normal_t = hlsl::float32_t3;
468462
constexpr auto NormalAttrSize = sizeof(normal_t);
@@ -472,16 +466,16 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::weldVertices
472466
outPolygon->setNormalView({
473467
.composed = polygon->getNormalView().composed,
474468
.src = {.offset = 0, .size = normalBuffer->getSize(), .buffer = std::move(normalBuffer)}
475-
});
469+
});
476470

477471
auto createOutView = [&](const ICPUPolygonGeometry::SDataView& view)
478-
{
479-
auto buffer = ICPUBuffer::create({ view.composed.stride * groups.size(), view.src.buffer->getUsageFlags() });
480-
return ICPUPolygonGeometry::SDataView{
481-
.composed = view.composed,
482-
.src = {.offset = 0, .size = buffer->getSize(), .buffer = std::move(buffer)}
472+
{
473+
auto buffer = ICPUBuffer::create({ view.composed.stride * groups.size(), view.src.buffer->getUsageFlags() });
474+
return ICPUPolygonGeometry::SDataView{
475+
.composed = view.composed,
476+
.src = {.offset = 0, .size = buffer->getSize(), .buffer = std::move(buffer)}
477+
};
483478
};
484-
};
485479

486480
const auto& inJointWeightViews = polygon->getJointWeightViews();
487481
auto* outJointWeightViews = outPolygon->getJointWeightViews();
@@ -508,31 +502,31 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::weldVertices
508502
outPositions[group_i] = inPositions[srcIndex];
509503
outNormals[group_i] = inPositions[srcIndex];
510504

511-
for (uint64_t jointView_i = 0u; jointView_i < polygon->getJointWeightViews().size(); jointView_i++)
512-
{
513-
auto& inView = polygon->getJointWeightViews()[jointView_i];
514-
auto& outView = outPolygon->getJointWeightViews()->operator[](jointView_i);
515-
516-
const std::byte* const inJointIndices = reinterpret_cast<const std::byte*>(inView.indices.getPointer());
517-
const auto jointIndexSize = inView.indices.composed.stride;
518-
std::byte* const outJointIndices = reinterpret_cast<std::byte*>(outView.indices.getPointer());
519-
memcpy(outJointIndices + group_i * jointIndexSize, inJointIndices + srcIndex * jointIndexSize, jointIndexSize);
520-
521-
const std::byte* const inWeights = reinterpret_cast<const std::byte*>(inView.weights.getPointer());
522-
const auto jointWeightSize = inView.weights.composed.stride;
523-
std::byte* const outWeights = reinterpret_cast<std::byte*>(outView.weights.getPointer());
524-
memcpy(outWeights + group_i * jointWeightSize, inWeights + srcIndex * jointWeightSize, jointWeightSize);
525-
}
505+
for (uint64_t jointView_i = 0u; jointView_i < polygon->getJointWeightViews().size(); jointView_i++)
506+
{
507+
auto& inView = polygon->getJointWeightViews()[jointView_i];
508+
auto& outView = outPolygon->getJointWeightViews()->operator[](jointView_i);
509+
510+
const std::byte* const inJointIndices = reinterpret_cast<const std::byte*>(inView.indices.getPointer());
511+
const auto jointIndexSize = inView.indices.composed.stride;
512+
std::byte* const outJointIndices = reinterpret_cast<std::byte*>(outView.indices.getPointer());
513+
memcpy(outJointIndices + group_i * jointIndexSize, inJointIndices + srcIndex * jointIndexSize, jointIndexSize);
514+
515+
const std::byte* const inWeights = reinterpret_cast<const std::byte*>(inView.weights.getPointer());
516+
const auto jointWeightSize = inView.weights.composed.stride;
517+
std::byte* const outWeights = reinterpret_cast<std::byte*>(outView.weights.getPointer());
518+
memcpy(outWeights + group_i * jointWeightSize, inWeights + srcIndex * jointWeightSize, jointWeightSize);
519+
}
526520

527-
for (auto auxView_i = 0u; auxView_i < polygon->getAuxAttributeViews().size(); auxView_i++)
528-
{
529-
auto& inView = polygon->getAuxAttributeViews()[auxView_i];
530-
auto& outView = outPolygon->getAuxAttributeViews()->operator[](auxView_i);
531-
const auto attrSize = inView.composed.stride;
532-
const std::byte* const inAuxs = reinterpret_cast<const std::byte*>(inView.getPointer());
533-
std::byte* const outAuxs = reinterpret_cast<std::byte*>(outView.getPointer());
534-
memcpy(outAuxs + group_i * attrSize, inAuxs + srcIndex * attrSize, attrSize);
535-
}
521+
for (auto auxView_i = 0u; auxView_i < polygon->getAuxAttributeViews().size(); auxView_i++)
522+
{
523+
auto& inView = polygon->getAuxAttributeViews()[auxView_i];
524+
auto& outView = outPolygon->getAuxAttributeViews()->operator[](auxView_i);
525+
const auto attrSize = inView.composed.stride;
526+
const std::byte* const inAuxs = reinterpret_cast<const std::byte*>(inView.getPointer());
527+
std::byte* const outAuxs = reinterpret_cast<std::byte*>(outView.getPointer());
528+
memcpy(outAuxs + group_i * attrSize, inAuxs + srcIndex * attrSize, attrSize);
529+
}
536530
}
537531

538532
CPolygonGeometryManipulator::recomputeContentHashes(outPolygon.get());

0 commit comments

Comments
 (0)