Skip to content

Commit

Permalink
[render] move Buffers enum in MeshRenderInfo class
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Feb 18, 2025
1 parent bc23dd0 commit eab579c
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 123 deletions.
4 changes: 2 additions & 2 deletions vclib/render/include/vclib/bgfx/drawable/drawable_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class DrawableMeshBGFX : public AbstractDrawableMesh, public MeshType
if (mMRS.isWireframe(MRI::Wireframe::VISIBLE)) {
if (bgfx::isValid(mProgramWireframe)) {
mMRB.bindVertexBuffers(mMRS);
mMRB.bindIndexBuffers(MeshBufferId::WIREFRAME);
mMRB.bindIndexBuffers(MRI::Buffers::WIREFRAME);
bindUniforms();

bgfx::setState(state | BGFX_STATE_PT_LINES);
Expand All @@ -193,7 +193,7 @@ class DrawableMeshBGFX : public AbstractDrawableMesh, public MeshType
if (mMRS.isEdges(MRI::Edges::VISIBLE)) {
if (bgfx::isValid(mProgramEdges)) {
mMRB.bindVertexBuffers(mMRS);
mMRB.bindIndexBuffers(MeshBufferId::EDGES);
mMRB.bindIndexBuffers(MRI::Buffers::EDGES);
bindUniforms();

bgfx::setState(state | BGFX_STATE_PT_LINES);
Expand Down
43 changes: 23 additions & 20 deletions vclib/render/include/vclib/bgfx/drawable/mesh/mesh_render_buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <vclib/bgfx/buffers.h>
#include <vclib/bgfx/drawable/uniforms/drawable_mesh_uniforms.h>
#include <vclib/bgfx/texture_unit.h>
#include <vclib/render/drawable/mesh/mesh_buffer_id.h>
#include <vclib/render/drawable/mesh/mesh_render_settings.h>
#include <vclib/space/core/image.h>

Expand All @@ -42,7 +41,9 @@ namespace vcl {
template<MeshConcept MeshType>
class MeshRenderBuffers
{
BuffersToFill mBuffersToFill = BUFFERS_TO_FILL_ALL;
using MRI = MeshRenderInfo;

MRI::BuffersBitSet mBuffersToFill = MRI::BUFFERS_ALL;

VertexBuffer mVertexCoordsBuffer;
VertexBuffer mVertexNormalsBuffer;
Expand Down Expand Up @@ -72,8 +73,8 @@ class MeshRenderBuffers
MeshRenderBuffers() = default;

MeshRenderBuffers(
const MeshType& mesh,
BuffersToFill buffersToFill = BUFFERS_TO_FILL_ALL) :
const MeshType& mesh,
MRI::BuffersBitSet buffersToFill = MRI::BUFFERS_ALL) :
mBuffersToFill(buffersToFill)
{
createBGFXBuffers(mesh);
Expand Down Expand Up @@ -139,9 +140,11 @@ class MeshRenderBuffers
}

void bindIndexBuffers(
MeshBufferId indexBufferToBind = MeshBufferId::TRIANGLES) const
MRI::Buffers indexBufferToBind = MRI::Buffers::TRIANGLES) const
{
if (indexBufferToBind == MeshBufferId::TRIANGLES) {
using enum MRI::Buffers;

if (indexBufferToBind == TRIANGLES) {
mTriangleIndexBuffer.bind();

mTriangleNormalBuffer.bind(VCL_MRB_PRIMITIVE_NORMAL_BUFFER);
Expand All @@ -151,14 +154,14 @@ class MeshRenderBuffers
mTriangleTextureIndexBuffer.bind(
VCL_MRB_TRIANGLE_TEXTURE_ID_BUFFER);
}
else if (indexBufferToBind == MeshBufferId::EDGES) {
else if (indexBufferToBind == EDGES) {
mEdgeIndexBuffer.bind();

mEdgeNormalBuffer.bind(VCL_MRB_PRIMITIVE_NORMAL_BUFFER);

mEdgeColorBuffer.bind(VCL_MRB_PRIMITIVE_COLOR_BUFFER);
}
else if (indexBufferToBind == MeshBufferId::WIREFRAME) {
else if (indexBufferToBind == WIREFRAME) {
mWireframeIndexBuffer.bind();
}
}
Expand All @@ -177,7 +180,7 @@ class MeshRenderBuffers
private:
void createBGFXBuffers(const MeshType& mesh)
{
using enum MeshBufferId;
using enum MRI::Buffers;

std::vector<std::pair<uint, uint>> vwm;
std::list<uint> vtd;
Expand Down Expand Up @@ -277,7 +280,7 @@ class MeshRenderBuffers
const auto& vtd,
const auto& ftr)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerVertexNormal<MeshType>) {
if (mBuffersToFill[toUnderlying(VERT_NORMALS)]) {
Expand Down Expand Up @@ -309,7 +312,7 @@ class MeshRenderBuffers
const auto& vtd,
const auto& ftr)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerVertexColor<MeshType>) {
if (mBuffersToFill[toUnderlying(VERT_COLORS)]) {
Expand Down Expand Up @@ -342,7 +345,7 @@ class MeshRenderBuffers
const auto& vtd,
const auto& ftr)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerVertexTexCoord<MeshType>) {
if (mBuffersToFill[toUnderlying(VERT_TEXCOORDS)]) {
Expand Down Expand Up @@ -374,7 +377,7 @@ class MeshRenderBuffers
const auto& vtd,
const auto& ftr)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerFaceWedgeTexCoords<MeshType>) {
if (mBuffersToFill[toUnderlying(WEDGE_TEXCOORDS)]) {
Expand Down Expand Up @@ -407,7 +410,7 @@ class MeshRenderBuffers
const auto& ftr,
TriPolyIndexBiMap& indexMap)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasFaces<MeshType>) {
const uint NUM_TRIS = vcl::countTriangulatedTriangles(mesh);
Expand All @@ -428,7 +431,7 @@ class MeshRenderBuffers
const MeshType& mesh,
const TriPolyIndexBiMap& indexMap)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerFaceNormal<MeshType>) {
if (mBuffersToFill[toUnderlying(TRI_NORMALS)]) {
Expand Down Expand Up @@ -456,7 +459,7 @@ class MeshRenderBuffers
const MeshType& mesh,
const TriPolyIndexBiMap& indexMap)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerFaceColor<MeshType>) {
if (mBuffersToFill[toUnderlying(TRI_COLORS)]) {
Expand Down Expand Up @@ -484,7 +487,7 @@ class MeshRenderBuffers
const MeshType& mesh,
const TriPolyIndexBiMap& indexMap)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerFaceWedgeTexCoords<MeshType>) {
if (mBuffersToFill[toUnderlying(WEDGE_TEXCOORDS)]) {
Expand Down Expand Up @@ -522,7 +525,7 @@ class MeshRenderBuffers

void createEdgeNormalsBuffer(const MeshType& mesh)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerEdgeNormal<MeshType>) {
if (mBuffersToFill[toUnderlying(EDGE_NORMALS)]) {
Expand All @@ -546,7 +549,7 @@ class MeshRenderBuffers

void createEdgeColorsBuffer(const MeshType& mesh)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasPerEdgeColor<MeshType>) {
if (mBuffersToFill[toUnderlying(EDGE_COLORS)]) {
Expand All @@ -569,7 +572,7 @@ class MeshRenderBuffers

void createWireframeIndicesBuffer(const MeshType& mesh)
{
using enum MeshBufferId;
using enum MRI::Buffers;

if constexpr (vcl::HasFaces<MeshType>) {
const uint NUM_EDGES = vcl::countPerFaceVertexReferences(mesh);
Expand Down
80 changes: 0 additions & 80 deletions vclib/render/include/vclib/render/drawable/mesh/mesh_buffer_id.h

This file was deleted.

Loading

0 comments on commit eab579c

Please sign in to comment.