[Graphics][Bugfix] "Nearest Isometric" respects turntable navigation

Prior to this commit, the "Nearest Isometric" GUI command searched all
24 possible isometric views.  When using turntable navigation, this
could result in the z-axis no longer being oriented vertically.  This
commit restricts the views being searched while in turntable
navigation mode to those that follow this restriction.
pull/1310/head
Eldritch Cheese 2022-11-03 15:36:58 -05:00 committed by Paul Kahler
parent d50e2b2a43
commit 4fc0141a5e
1 changed files with 13 additions and 6 deletions

View File

@ -6,6 +6,8 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "solvespace.h" #include "solvespace.h"
#include <iostream>
typedef void MenuHandler(Command id); typedef void MenuHandler(Command id);
using MenuKind = Platform::MenuItem::Indicator; using MenuKind = Platform::MenuItem::Indicator;
struct MenuEntry { struct MenuEntry {
@ -817,13 +819,18 @@ void GraphicsWindow::MenuView(Command id) {
Quaternion quatf = quat0; Quaternion quatf = quat0;
double dmin = 1e10; double dmin = 1e10;
// There are 24 possible views; 3*2*2*2 // There are 24 possible views (3*2*2*2), if all are
int i, j, negi, negj; // allowed. If the user is in turn-table mode, the
for(i = 0; i < 3; i++) { // isometric view must have the z-axis facing up, leaving
for(j = 0; j < 3; j++) { // 8 possible views (2*1*2*2).
bool require_turntable = (id==Command::NEAREST_ISO && SS.turntableNav);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
if(i == j) continue; if(i == j) continue;
for(negi = 0; negi < 2; negi++) { if(require_turntable && (j!=2)) continue;
for(negj = 0; negj < 2; negj++) { for(int negi = 0; negi < 2; negi++) {
for(int negj = 0; negj < 2; negj++) {
Vector ou = ortho[i], ov = ortho[j]; Vector ou = ortho[i], ov = ortho[j];
if(negi) ou = ou.ScaledBy(-1); if(negi) ou = ou.ScaledBy(-1);
if(negj) ov = ov.ScaledBy(-1); if(negj) ov = ov.ScaledBy(-1);