Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Nov 23, 2023
1 parent 2ed8add commit 2dda82e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/vclib/io/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

namespace vcl {

std::shared_ptr<unsigned char> loadImageData(
inline std::shared_ptr<unsigned char> loadImageData(
const std::string& filename,
int& w,
int& h)
Expand Down
26 changes: 15 additions & 11 deletions include/vclib/render/mesh_render_buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ namespace vcl {
template<MeshConcept MeshType>
class MeshRenderBuffers
{
uint nv = 0;
uint nt = 0;

std::vector<float> verts;
std::vector<uint32_t> tris;
std::vector<float> vNormals;
Expand All @@ -66,9 +63,9 @@ class MeshRenderBuffers
fillMeshAttribs(m);
}

uint vertexNumber() const { return nv; }
uint vertexNumber() const { return verts.size() / 3; }

uint triangleNumber() const { return nt; }
uint triangleNumber() const { return tris.size() / 3; }

uint textureNumber() const { return textures.size(); }

Expand All @@ -88,13 +85,23 @@ class MeshRenderBuffers
return verts.data();
}

const uint vertexBufferSize() const
{
return verts.size();
}

const uint32_t* triangleBufferData() const
{
if (tris.empty())
return nullptr;
return tris.data();
}

const uint triangleBufferSize() const
{
return tris.size();
}

const float* vertexNormalBufferData() const
{
if (vNormals.empty())
Expand Down Expand Up @@ -181,8 +188,7 @@ class MeshRenderBuffers
std::numeric_limits<double>::lowest());
}

nv = m.vertexNumber();
verts.resize(nv * 3);
verts.resize(m.vertexNumber() * 3);

if constexpr (vcl::HasPerVertexNormal<MeshType>) {
if (vcl::isPerVertexNormalAvailable(m)) {
Expand Down Expand Up @@ -249,9 +255,7 @@ class MeshRenderBuffers
std::vector<std::vector<uint>> vinds; // necessary for wedge attribs

if constexpr (vcl::HasTriangles<MeshType>) {
nt = m.faceNumber();

tris.resize(nt * 3);
tris.resize(m.faceNumber() * 3);

uint i = 0;
for (const auto& f : m.faces()) {
Expand All @@ -266,7 +270,7 @@ class MeshRenderBuffers
triPolyMap.reserve(m.faceNumber(), m.faceNumber());
tris.reserve(m.faceNumber());

nt = 0;
uint nt = 0;
for (const auto& f : m.faces()) {
if (f.vertexNumber() == 3) {
triPolyMap.insert(nt, m.faceIndexIfCompact(m.index(f)));
Expand Down

0 comments on commit 2dda82e

Please sign in to comment.