Skip to content

Commit

Permalink
Better camera orientation clamping ; correctly count rendered tetrahedra
Browse files Browse the repository at this point in the history
  • Loading branch information
matrefeytontias committed Apr 5, 2019
1 parent 3f8f6fd commit b754dcd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/Camera4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct Camera4 : private Transform4
_xz += (mouseX - _prevMouseX) / rotationDivisorX;
_yz += (mouseY - _prevMouseY) / rotationDivisorY;
// Cap _yz rotation at head and feet
_yz = clamp(_yz, -(float)M_PI / 2, (float)M_PI / 2);
_yz = clamp(_yz, -(float)M_PI / 2 + 0.01f, (float)M_PI / 2 - 0.01f);

Vector4f dir = Vector4f(-sin(_xz) * cos(_yz), sin(_yz), cos(_xz) * cos(_yz), 0);
lookAt(dir, Vector4f(0, 1, 0, 0), Vector4f(0, 0, 0, 1));
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ int _main(int, char *argv[])
{
const Model4RenderContext *rc = obj.getRenderContext();
if(rc)
tetrahedra += rc->geometry.cells.size() / 4;
{
tetrahedra += rc->geometry.isIndexed() ? rc->geometry.cells.size() / 4
: rc->geometry.vertices.size() / 4;
}
});

perspective(p, 90, (float)display_w / display_h, 0.01, 40);
Expand Down

0 comments on commit b754dcd

Please sign in to comment.