cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.31k stars 939 forks source link

Camera bug in setViewDirection #2248

Open Ahbee opened 3 years ago

Ahbee commented 3 years ago

running this code after the line cp.setOrientation(cp.getOrientation()); the view Direction of the camera flips to {0,-1,0}. This looks like setViewDirection is not setting the orientation correctly

    cinder::CameraPersp` cp;
    cp.setViewDirection({0,1,0});
    std::cout << cp.getViewDirection() << std::endl;
    cp.setOrientation(cp.getOrientation());
    std::cout << cp.getViewDirection() << std::endl;
Ahbee commented 3 years ago

changing it to what lookAt does seems fix it

void Camera::setViewDirection(const glm::dvec3& viewDirection)
{
  mViewDirection   = normalize(viewDirection);
  mOrientation     = glm::toQuat(alignZAxisWithTarget(-mViewDirection, mWorldUp));
  mModelViewCached = false;
}