Skip to content

Commit

Permalink
std::unordered map in skelmodel blendoffsets for #257
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Oct 17, 2023
1 parent 8bb0cce commit 3510830
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/engine/model/skelmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,13 +911,14 @@ const skelmodel::skelcacheentry &skelmodel::skeleton::checkskelcache(const part

int skelmodel::skeleton::getblendoffset(const UniformLoc &u)
{
int &offset = blendoffsets.access(Shader::lastshader->program, -1);
if(offset < 0)
auto itr = blendoffsets.find(Shader::lastshader->program);
if(itr == blendoffsets.end())
{
itr = blendoffsets.insert( { Shader::lastshader->program, -1 } ).first;
DEF_FORMAT_STRING(offsetname, "%s[%d]", u.name, 2*numgpubones);
offset = glGetUniformLocation(Shader::lastshader->program, offsetname);
(*itr).second = glGetUniformLocation(Shader::lastshader->program, offsetname);
}
return offset;
return (*itr).second;
}

void skelmodel::skeleton::setglslbones(UniformLoc &u, const skelcacheentry &sc, const skelcacheentry &bc, int count)
Expand Down
4 changes: 2 additions & 2 deletions src/engine/model/skelmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ struct skelmodel : animmodel

bool usegpuskel;
std::vector<skelcacheentry> skelcache;
hashtable<GLuint, int> blendoffsets;
std::unordered_map<GLuint, int> blendoffsets;

skeleton() : name(""), shared(0), bones(nullptr), numbones(0), numinterpbones(0), numgpubones(0), numframes(0), framebones(nullptr), ragdoll(nullptr), usegpuskel(false), blendoffsets(32)
skeleton() : name(""), shared(0), bones(nullptr), numbones(0), numinterpbones(0), numgpubones(0), numframes(0), framebones(nullptr), ragdoll(nullptr), usegpuskel(false)
{
}

Expand Down

0 comments on commit 3510830

Please sign in to comment.