Skip to content

Commit

Permalink
replace ptr with ref in objmeshgroup::flushmesh
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Nov 24, 2024
1 parent 6bb8e70 commit b344c6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/engine/model/obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bool obj::objmeshgroup::load(const char *filename, float smooth)
copystring(meshname, name, std::min(namelen+1, sizeof(meshname)));
if(curmesh)
{
flushmesh(curmesh, verts, tcverts, tris, attrib[2], smooth);
flushmesh(*curmesh, verts, tcverts, tris, attrib[2], smooth);
}
curmesh = nullptr;
break;
Expand Down Expand Up @@ -233,7 +233,7 @@ bool obj::objmeshgroup::load(const char *filename, float smooth)
}
if(curmesh)
{
flushmesh(curmesh, verts, tcverts, tris, attrib[2], smooth);
flushmesh(*curmesh, verts, tcverts, tris, attrib[2], smooth);
}
delete file;
return true;
Expand Down Expand Up @@ -261,39 +261,39 @@ void obj::objmeshgroup::parsevert(char *s, std::vector<vec> &out)
}
}

void obj::objmeshgroup::flushmesh(vertmesh *curmesh,
void obj::objmeshgroup::flushmesh(vertmesh &curmesh,
const std::vector<vert> &verts,
const std::vector<tcvert> &tcverts,
const std::vector<tri> &tris,
const std::vector<vec> &attrib,
float smooth)
{
curmesh->numverts = verts.size();
curmesh.numverts = verts.size();
if(verts.size())
{
curmesh->verts = new vert[verts.size()];
std::memcpy(curmesh->verts, verts.data(), verts.size()*sizeof(vert));
curmesh->tcverts = new tcvert[verts.size()];
std::memcpy(curmesh->tcverts, tcverts.data(), tcverts.size()*sizeof(tcvert));
curmesh.verts = new vert[verts.size()];
std::memcpy(curmesh.verts, verts.data(), verts.size()*sizeof(vert));
curmesh.tcverts = new tcvert[verts.size()];
std::memcpy(curmesh.tcverts, tcverts.data(), tcverts.size()*sizeof(tcvert));
}
curmesh->numtris = tris.size();
curmesh.numtris = tris.size();
if(tris.size())
{
curmesh->tris = new tri[tris.size()];
std::memcpy(curmesh->tris, tris.data(), tris.size()*sizeof(tri));
curmesh.tris = new tri[tris.size()];
std::memcpy(curmesh.tris, tris.data(), tris.size()*sizeof(tri));
}
if(attrib.empty())
{
if(smooth <= 1)
{
curmesh->smoothnorms(smooth);
curmesh.smoothnorms(smooth);
}
else
{
curmesh->buildnorms();
curmesh.buildnorms();
}
}
curmesh->calctangents();
curmesh.calctangents();
}

bool obj::loaddefaultparts()
Expand Down
2 changes: 1 addition & 1 deletion src/engine/model/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct obj final : vertloader<obj>

private:
void parsevert(char *s, std::vector<vec> &out);
void flushmesh(vertmesh *curmesh,
void flushmesh(vertmesh &curmesh,
const std::vector<vert> &verts,
const std::vector<tcvert> &tcverts,
const std::vector<tri> &tris,
Expand Down

0 comments on commit b344c6c

Please sign in to comment.