Skip to content

Commit

Permalink
compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanMOlson committed Nov 12, 2024
1 parent 14c4404 commit f737b2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/mbgl/map/transform_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,14 @@ bool TransformState::setCameraOrientation(const Quaternion& orientation_) {
return false;
}

Quaternion updatedOrientation = util::Camera::orientationFromFrame(forward, up);
std::optional<Quaternion> updatedOrientation = util::Camera::orientationFromFrame(forward, up);

camera.setOrientation(updatedOrientation);
return true;
if (updatedOrientation) {
camera.setOrientation(*updatedOrientation);
return true;
}

return false;
}

void TransformState::setFreeCameraOptions(const FreeCameraOptions& options) {
Expand Down
10 changes: 5 additions & 5 deletions src/mbgl/util/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace std::numbers;
namespace mbgl {

namespace {
double vec2Len(const vec2& v) noexcept {
/*double vec2Len(const vec2& v) noexcept {
return std::sqrt(v[0] * v[0] + v[1] * v[1]);
};
Expand All @@ -25,8 +25,8 @@ double vec2Dot(const vec2& a, const vec2& b) noexcept {
vec2 vec2Scale(const vec2& v, double s) noexcept {
return vec2{{v[0] * s, v[1] * s}};
};
} // namespace*/
};*/
} // namespace

namespace util {

Expand Down Expand Up @@ -191,7 +191,7 @@ void Camera::setPosition(const vec3& position) noexcept {
updateTransform(transform, position);
}

Quaternion Camera::orientationFromFrame(const vec3& forward, const vec3& up) noexcept {
std::optional<Quaternion> Camera::orientationFromFrame(const vec3& forward, const vec3& up) noexcept {
const vec3 right = vec3Cross(up, forward);

const double bearing = std::atan2(-right[1], right[0]);
Expand Down Expand Up @@ -238,7 +238,7 @@ void FreeCameraOptions::lookAtPoint(const LatLng& location, const std::optional<
// Flip z-component of the up vector if it's pointing downwards
up[2] = std::abs(up[2]);

orientation = util::Camera::orientationFromFrame(forward, up).m;
orientation = util::Camera::orientationFromFrame(forward, up)->m;
}

void FreeCameraOptions::setPitchBearing(double pitch, double bearing, double twist) noexcept {
Expand Down

0 comments on commit f737b2f

Please sign in to comment.