Skip to content

Commit

Permalink
move part skinlist generation to meshgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Jan 21, 2024
1 parent e59ad03 commit a6f6935
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/engine/model/animmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,20 @@ std::vector<std::vector<animmodel::Mesh *>::iterator> animmodel::meshgroup::getm
return meshlist;
}

std::vector<size_t> animmodel::meshgroup::getskins(std::string_view meshname)
{
std::vector<size_t> skinlist;
for(uint i = 0; i < meshes.size(); i++)
{
auto &m = *(meshes[i]);
if(!std::strcmp(meshname.data(), "*") || (m.name && !std::strcmp(m.name, meshname.data())))
{
skinlist.push_back(i);
}
}
return skinlist;
}

void animmodel::meshgroup::calcbb(vec &bbmin, vec &bbmax, const matrix4x3 &t) const
{
auto rendermeshes = getrendermeshes();
Expand Down
20 changes: 13 additions & 7 deletions src/engine/model/animmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,17 @@ class animmodel : public model
virtual void render(const AnimState *as, float pitch, const vec &axis, const vec &forward, dynent *d, part *p) = 0;
virtual void preload() = 0;

/**
* Returns a list of Mesh iterators corresponding to a given name
* The iterators may be invalidated by other method calls.
*/
std::vector<std::vector<animmodel::Mesh *>::iterator> getmeshes(std::string_view meshname);
/**
* Returns a list of indices corresponding to locations in animmodel::part::skins.
* These indices are invalidated if animmodel::skins is modified after calling.
*/
std::vector<size_t> getskins(std::string_view meshname);

void calcbb(vec &bbmin, vec &bbmax, const matrix4x3 &t) const;
void genBIH(const std::vector<skin> &skins, std::vector<BIH::mesh> &bih, const matrix4x3 &t);
void genshadowmesh(std::vector<triangle> &tris, const matrix4x3 &t) const;
Expand Down Expand Up @@ -963,14 +973,10 @@ struct modelcommands
{
return skinlist;
}
for(uint i = 0; i < mdl.meshes->meshes.size(); i++)
std::vector<size_t> skinindices = mdl.meshes->getskins(meshname);
for(size_t i : skinindices)
{
auto &m = *(mdl.meshes->meshes[i]);
if(!std::strcmp(meshname.data(), "*") || (m.name && !std::strcmp(m.name, meshname.data())))
{
std::vector<animmodel::skin>::iterator itr = mdl.skins.begin() + i;
skinlist.push_back(itr);
}
skinlist.push_back(mdl.skins.begin() + i);
}
return skinlist;
}
Expand Down

0 comments on commit a6f6935

Please sign in to comment.