From b754dcd27c39430d8f844503b339d55e6af1d316 Mon Sep 17 00:00:00 2001 From: matrefeytontias Date: Fri, 5 Apr 2019 20:45:26 +0200 Subject: [PATCH] Better camera orientation clamping ; correctly count rendered tetrahedra --- include/Camera4.hpp | 2 +- src/main.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/Camera4.hpp b/include/Camera4.hpp index 756218b..a9d83d5 100644 --- a/include/Camera4.hpp +++ b/include/Camera4.hpp @@ -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)); diff --git a/src/main.cpp b/src/main.cpp index 2b8b1ef..4ddb8f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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);