+ fixes #0000957: Sketch view problem when go to edit

This commit is contained in:
wmayer 2014-12-27 17:50:37 +01:00
parent b172e069a1
commit 7149cce90f
2 changed files with 22 additions and 0 deletions

View File

@ -440,6 +440,7 @@ void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToC
// due to possible round-off errors make sure that the // due to possible round-off errors make sure that the
// exact orientation is set // exact orientation is set
cam->orientation.setValue(rot); cam->orientation.setValue(rot);
cam->position = PRIVATE(this)->focal2 - cam->focalDistance.getValue() * direction;
} }
} }
else { else {

View File

@ -4339,6 +4339,27 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo
Base::Rotation tmp(plm.getRotation()); Base::Rotation tmp(plm.getRotation());
SbRotation rot((float)tmp[0],(float)tmp[1],(float)tmp[2],(float)tmp[3]); 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->setCameraOrientation(rot);
viewer->setEditing(TRUE); viewer->setEditing(TRUE);