Skip to content

Commit

Permalink
+ fixes #957: Sketch view problem when go to edit
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 27, 2014
1 parent b172e06 commit 7149cce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Gui/NavigationStyle.cpp
Expand Up @@ -440,6 +440,7 @@ void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToC
// due to possible round-off errors make sure that the
// exact orientation is set
cam->orientation.setValue(rot);
cam->position = PRIVATE(this)->focal2 - cam->focalDistance.getValue() * direction;
}
}
else {
Expand Down
21 changes: 21 additions & 0 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -4339,6 +4339,27 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo
Base::Rotation tmp(plm.getRotation());

SbRotation rot((float)tmp[0],(float)tmp[1],(float)tmp[2],(float)tmp[3]);

// Will the sketch be visible from the new position (#0000957)?
//
SoCamera* camera = viewer->getSoRenderManager()->getCamera();
SbVec3f curdir; // current view direction
camera->orientation.getValue().multVec(SbVec3f(0, 0, -1), curdir);
SbVec3f focal = camera->position.getValue() +
camera->focalDistance.getValue() * curdir;

SbVec3f newdir; // future view direction
rot.multVec(SbVec3f(0, 0, -1), newdir);
SbVec3f newpos = focal - camera->focalDistance.getValue() * newdir;

SbVec3f plnpos = Base::convertTo<SbVec3f>(plm.getPosition());
double dist = (plnpos - newpos).dot(newdir);
if (dist < 0) {
float focalLength = camera->focalDistance.getValue() - dist + 5;
camera->position = focal - focalLength * curdir;
camera->focalDistance.setValue(focalLength);
}

viewer->setCameraOrientation(rot);

viewer->setEditing(TRUE);
Expand Down

0 comments on commit 7149cce

Please sign in to comment.