Skip to content

Commit

Permalink
inline getLODMeshIndices to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Jul 30, 2016
1 parent 706546f commit 317e983
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
11 changes: 0 additions & 11 deletions src/renderer/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,6 @@ RayCastModelHit Model::castRay(const Vec3& origin,
}


LODMeshIndices Model::getLODMeshIndices(float squared_distance) const
{
int i = 0;
while (squared_distance >= m_lods[i].distance)
{
++i;
}
return{ m_lods[i].from_mesh, m_lods[i].to_mesh };
}


void Model::getPose(Pose& pose)
{
ASSERT(pose.count == getBoneCount());
Expand Down
10 changes: 8 additions & 2 deletions src/renderer/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ class LUMIX_RENDERER_API Model : public Resource
const void* attributes_data,
int attributes_size);

LODMeshIndices getLODMeshIndices(float squared_distance) const;
LODMeshIndices getLODMeshIndices(float squared_distance) const
{
int i = 0;
while (squared_distance >= m_lods[i].distance) ++i;
return {m_lods[i].from_mesh, m_lods[i].to_mesh};
}

Mesh& getMesh(int index) { return m_meshes[index]; }
bgfx::VertexBufferHandle getVerticesHandle() const { return m_vertices_handle; }
bgfx::IndexBufferHandle getIndicesHandle() const { return m_indices_handle; }
Expand Down Expand Up @@ -197,4 +203,4 @@ class LUMIX_RENDERER_API Model : public Resource
};


} // ~namespace Lumix
} // namespace Lumix

0 comments on commit 317e983

Please sign in to comment.