Skip to content

Commit

Permalink
[space] BitSet constructor allows both enum and integers
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Feb 18, 2025
1 parent f7bd940 commit 9fb6fbc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
11 changes: 7 additions & 4 deletions vclib/core/include/vclib/space/core/bit_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ class BitSet
template<NonBoolIntegralOrEnum I>
BitSet(std::initializer_list<I> l)
{
for (const auto& i : l)
at(i) = true;
for (const auto& i : l) {
if constexpr (std::is_enum_v<I>)
at(toUnderlying(i)) = true;
else
at(i) = true;
}
}

/**
Expand All @@ -98,8 +102,7 @@ class BitSet
"BitSet: list size is greater than the number of bits of the "
"BitSet");

uint i = 0;
for (const auto& b : l)
for (uint i = 0; const auto& b : l)
at(i++) = b;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ class LaplacianSmoothingFilter : public FilterMeshAction
{
std::pair<MeshParameter, BitSet<short>> par;
par.first = MeshParameter("input_output", "Input/Output Mesh", "");
par.second = BitSet<short>(
{toUnderlying(MeshIType::TRI_MESH),
toUnderlying(MeshIType::POLY_MESH)});
par.second = BitSet<short>({MeshIType::TRI_MESH, MeshIType::POLY_MESH});

return {par};
}
Expand Down
5 changes: 1 addition & 4 deletions vclib/render/src/vclib/bgfx/drawable/drawable_axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ void DrawableAxis::createAxis()
using MRI = MeshRenderInfo;
using enum MRI::Buffers;

MRI::BuffersBitSet btf = {
toUnderlying(VERTICES),
toUnderlying(VERT_NORMALS),
toUnderlying(TRIANGLES)};
MRI::BuffersBitSet btf = {VERTICES, VERT_NORMALS, TRIANGLES};

mArrowBuffers[0] = MeshRenderBuffers<vcl::TriMesh>(AXIS_MESHES.first, btf);

Expand Down

0 comments on commit 9fb6fbc

Please sign in to comment.