fixes #0003169: Mesh Design WB tools does not work on translated object

This commit is contained in:
wmayer
2017-10-16 20:13:43 +02:00
parent 8318cf54cb
commit eb5e791835
4 changed files with 42 additions and 31 deletions

View File

@@ -39,12 +39,18 @@ using namespace Gui;
ViewVolumeProjection::ViewVolumeProjection (const SbViewVolume &vv)
: viewVolume(vv)
, hasTransform(false)
{
}
Base::Vector3f ViewVolumeProjection::operator()(const Base::Vector3f &pt) const
{
SbVec3f pt3d(pt.x,pt.y,pt.z);
if (hasTransform) {
Base::Vector3f ptt = transform * pt;
pt3d.setValue(ptt.x, ptt.y, ptt.z);
}
viewVolume.projectToScreen(pt3d,pt3d);
return Base::Vector3f(pt3d[0],pt3d[1],pt3d[2]);
}
@@ -79,6 +85,17 @@ Base::Vector3d ViewVolumeProjection::inverse (const Base::Vector3d &pt) const
return Base::convertTo<Base::Vector3d>(ptf);
}
/*!
* \brief This method applies an additional transformation to the input points
* passed with the () operator.
* \param mat
*/
void ViewVolumeProjection::setTransform(const Base::Matrix4D& mat)
{
transform = mat;
hasTransform = (mat != Base::Matrix4D());
}
Base::Matrix4D ViewVolumeProjection::getProjectionMatrix () const
{
// Inventor stores the transposed matrix