Skip to content

Commit bae6838

Browse files
committed
ovis: use frustum extents instead of setFrustumOffset
the latter assumes centered FOV, which is not the case
1 parent 2888fea commit bae6838

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

modules/ovis/src/ovis.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,19 @@ static void _setCameraIntrinsics(Camera* cam, InputArray _K, const Size& imsize)
102102

103103
Matx33f K = _K.getMat();
104104

105+
float near = cam->getNearClipDistance();
106+
float top = near * K(1, 2) / K(1, 1);
107+
float left = -near * K(0, 2) / K(0, 0);
108+
float right = near * (imsize.width - K(0, 2)) / K(0, 0);
109+
float bottom = -near * (imsize.height - K(1, 2)) / K(1, 1);
110+
111+
// use frustum extents instead of setFrustumOffset as the latter
112+
// assumes centered FOV, which is not the case
113+
cam->setFrustumExtents(left, right, top, bottom);
114+
115+
// top and bottom parts of the FOV
105116
float fovy = atan2(K(1, 2), K(1, 1)) + atan2(imsize.height - K(1, 2), K(1, 1));
106117
cam->setFOVy(Radian(fovy));
107-
108-
Vec2f pp_offset = Vec2f(0.5, 0.5) - Vec2f(K(0, 2) / imsize.width, K(1, 2) / imsize.height);
109-
cam->setFrustumOffset(toOGRE_SS * Vector2(pp_offset.val));
110118
}
111119

112120
static SceneNode& _getSceneNode(SceneManager* sceneMgr, const String& name)

0 commit comments

Comments
 (0)