Rotate around center of selection.

This commit is contained in:
Aesylwinn 2016-08-12 17:12:10 -04:00
parent 571969cd65
commit 101c3cc90d

View file

@ -323,14 +323,15 @@ void CSVRender::InstanceMode::drag (const QPoint& pos, int diffX, int diffY, dou
osg::Vec3f camBack = eye - centre; osg::Vec3f camBack = eye - centre;
// Convert coordinate system // Convert coordinate system
int widgetWidth = getWorldspaceWidget().width(); osg::Vec3f screenCenter = getScreenCoords(getSelectionCenter(selection));
int widgetHeight = getWorldspaceWidget().height(); int widgetHeight = getWorldspaceWidget().height();
int newX = pos.x() - widgetWidth / 2; float newX = pos.x() - screenCenter.x();
int newY = -pos.y() + widgetHeight / 2; float newY = (widgetHeight - pos.y()) - screenCenter.y();
int oldX = newX - diffX; float oldX = newX - diffX;
int oldY = newY - diffY; // diffY appears to already be flipped float oldY = newY - diffY; // diffY appears to already be flipped
osg::Vec3f oldVec = osg::Vec3f(oldX, oldY, 0); osg::Vec3f oldVec = osg::Vec3f(oldX, oldY, 0);
oldVec.normalize(); oldVec.normalize();