Fix operations dependent on hand orientation
MODIFY
source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp
source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp
@@ -162,7 +162,10 @@ void CSceneNodeAnimatorCameraMaya::animateNode(IDummyTransformationSceneNode *no
core::vector3df_SIMD pos,tvectX;
pos.getAsVector3df() = camera->getPosition();
tvectX = pos - target;
+ if (camera->getLeftHanded())
tvectX = normalize(cross(tvectX,upVector));
+ else
+ tvectX = normalize(cross(upVector, tvectX));
const SViewFrustum* const va = camera->getViewFrustum();
core::vector3df_SIMD tvectY = (va->getFarLeftDown() - va->getFarRightDown());
@@ -191,6 +194,14 @@ void CSceneNodeAnimatorCameraMaya::animateNode(IDummyTransformationSceneNode *no
// Rotation ------------------------------------
+ auto getValueDependentOnHandOrientation = [&](const float& expression)
+ {
+ if (camera->getLeftHanded())
+ return expression;
+ else
+ return -expression;
+ };
+
if (isMouseKeyDown(0) && !Zooming)
{
if (!Rotating)
@@ -202,14 +213,14 @@ void CSceneNodeAnimatorCameraMaya::animateNode(IDummyTransformationSceneNode *no
}
else
{
- nRotX += (MousePos.X - RotateStart.X) * RotateSpeed;
- nRotY += (MousePos.Y - RotateStart.Y) * RotateSpeed;
+ nRotX += getValueDependentOnHandOrientation((RotateStart.X - MousePos.X) * RotateSpeed);
+ nRotY += getValueDependentOnHandOrientation((RotateStart.Y - MousePos.Y) * RotateSpeed);
}
}
else if (Rotating)
{
- RotX += (MousePos.X - RotateStart.X) * RotateSpeed;
- RotY += (MousePos.Y - RotateStart.Y) * RotateSpeed;
+ RotX += getValueDependentOnHandOrientation((RotateStart.X - MousePos.X) * RotateSpeed);
+ RotY += getValueDependentOnHandOrientation((RotateStart.Y - MousePos.Y) * RotateSpeed);
nRotX = RotX;
nRotY = RotY;
Rotating = false;

MODIFY
source/Irrlicht/CSceneNodeAnimatorCameraModifiedMaya.cpp
source/Irrlicht/CSceneNodeAnimatorCameraModifiedMaya.cpp
@@ -184,7 +184,10 @@ namespace irr
tvectX -= camera->getTarget();
core::vectorSIMDf other = tvectX;
+ if(camera->getLeftHanded())
tvectX = core::normalize(core::cross(tvectX,camera->getUpVector()));
+ else
+ tvectX = core::normalize(core::cross(camera->getUpVector(), tvectX));
core::vectorSIMDf tvectY = va->getFarLeftDown() - va->getFarRightDown();
if (camera->getUpVector().Y<0.f)
@@ -238,6 +241,15 @@ namespace irr
}
// Rotation ------------------------------------
+
+ auto getValueDependentOnHandOrientation = [&](const float& expression)
+ {
+ if (camera->getLeftHanded())
+ return expression;
+ else
+ return -expression;
+ };
+
if (isMouseKeyDown(0) && !(StepZooming || Zooming))
{
if (!Rotating)
@@ -247,20 +259,19 @@ namespace irr
Rotating = true;
nRotX = RotX;
nRotY = RotY;
-
}
else
{
- nRotX += (MousePos.X - RotateStart.X) * RotateSpeed;
- nRotY += (MousePos.Y - RotateStart.Y) * RotateSpeed;
+ nRotX += getValueDependentOnHandOrientation((RotateStart.X - MousePos.X) * RotateSpeed);
+ nRotY += getValueDependentOnHandOrientation((RotateStart.Y - MousePos.Y) * RotateSpeed);
}
}
else
{
if (Rotating)
{
- RotX += (MousePos.X - RotateStart.X) * RotateSpeed;
- RotY += (MousePos.Y - RotateStart.Y) * RotateSpeed;
+ RotX += getValueDependentOnHandOrientation((RotateStart.X - MousePos.X) * RotateSpeed);
+ RotY += getValueDependentOnHandOrientation((RotateStart.Y - MousePos.Y) * RotateSpeed);
nRotX = RotX;
nRotY = RotY;

Fix operations dependent on hand orientation