diff --git a/bin/render.cpp b/bin/render.cpp index 47a25af0394..21b1e78882a 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) { args::ValueFlag fovValue(argumentParser, "degrees", "FOV", {'f', "fov"}); args::ValueFlag bearingValue(argumentParser, "degrees", "Bearing", {'b', "bearing"}); args::ValueFlag pitchValue(argumentParser, "degrees", "Pitch", {'p', "pitch"}); - args::ValueFlag twistValue(argumentParser, "degrees", "Twist", {'T', "twist"}); + args::ValueFlag rollValue(argumentParser, "degrees", "Roll", {'T', "roll"}); args::ValueFlag widthValue(argumentParser, "pixels", "Image width", {'w', "width"}); args::ValueFlag heightValue(argumentParser, "pixels", "Image height", {'h', "height"}); @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) { const double fov = fovValue ? args::get(fovValue) : 37; const double bearing = bearingValue ? args::get(bearingValue) : 0; const double pitch = pitchValue ? args::get(pitchValue) : 0; - const double twist = twistValue ? args::get(twistValue) : 0; + const double roll = rollValue ? args::get(rollValue) : 0; const double pixelRatio = pixelRatioValue ? args::get(pixelRatioValue) : 1; const uint32_t width = widthValue ? args::get(widthValue) : 512; @@ -103,7 +103,7 @@ int main(int argc, char* argv[]) { } map.getStyle().loadURL(style); - map.jumpTo(CameraOptions().withCenter(LatLng{lat, lon}).withAlt(alt).withZoom(zoom).withBearing(bearing).withPitch(pitch).withTwist(twist).withFov(fov)); + map.jumpTo(CameraOptions().withCenter(LatLng{lat, lon}).withAlt(alt).withZoom(zoom).withBearing(bearing).withPitch(pitch).withRoll(roll).withFov(fov)); if (debug) { map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus diff --git a/include/mbgl/map/camera.hpp b/include/mbgl/map/camera.hpp index 22352197f05..3cdb136a6fa 100644 --- a/include/mbgl/map/camera.hpp +++ b/include/mbgl/map/camera.hpp @@ -45,8 +45,8 @@ struct CameraOptions { pitch = o; return *this; } - CameraOptions& withTwist(const std::optional& o) { - twist = o; + CameraOptions& withRoll(const std::optional& o) { + roll = o; return *this; } CameraOptions& withFov(const std::optional& o) { @@ -78,13 +78,13 @@ struct CameraOptions { two-dimensional map. */ std::optional pitch; - std::optional twist; + std::optional roll; std::optional fov; }; constexpr bool operator==(const CameraOptions& a, const CameraOptions& b) { return a.center == b.center && a.padding == b.padding && a.anchor == b.anchor && a.zoom == b.zoom && - a.bearing == b.bearing && a.pitch == b.pitch && a.twist == b.twist && a.fov == b.fov && a.altM == b.altM; + a.bearing == b.bearing && a.pitch == b.pitch && a.roll == b.roll && a.fov == b.fov && a.altM == b.altM; } constexpr bool operator!=(const CameraOptions& a, const CameraOptions& b) { @@ -170,7 +170,7 @@ struct FreeCameraOptions { /** Helper function for setting the orientation of the camera as a pitch and a bearing. Both values are in degrees */ - void setPitchBearing(double pitch, double bearing, double twist) noexcept; + void setPitchBearing(double pitch, double bearing, double roll) noexcept; }; } // namespace mbgl diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 7c2df9bde41..256d06c7e66 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -102,7 +102,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim double pitch = camera.pitch ? util::deg2rad(*camera.pitch) : getPitch(); double fov = camera.fov ? util::deg2rad(*camera.fov) : getFieldOfView(); double alt_m = camera.altM.value_or(100000); - double twist = camera.twist ? util::deg2rad(*camera.twist) : getTwist(); + double roll = camera.roll ? util::deg2rad(*camera.roll) : getRoll(); if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch)) { if (animation.transitionFinishFn) { @@ -169,7 +169,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim } state.setFieldOfView(fov); state.setAltM(alt_m); - state.setTwist(twist); + state.setRoll(roll); }, duration); } @@ -436,8 +436,8 @@ double Transform::getPitch() const { return state.getPitch(); } -double Transform::getTwist() const { - return state.getTwist(); +double Transform::getRoll() const { + return state.getRoll(); } double Transform::getFieldOfView() const { diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index 592b404191b..a8b6acd2835 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -77,7 +77,7 @@ class Transform : private util::noncopyable { // Pitch double getPitch() const; - double getTwist() const; + double getRoll() const; double getFieldOfView() const; // North Orientation diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 2eaf0e6f3b4..d8d7daf4d75 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -62,8 +62,8 @@ void TransformState::setProperties(const TransformStateProperties& properties) { if (properties.pitch) { setPitch(*properties.pitch); } - if (properties.twist) { - setTwist(*properties.twist); + if (properties.roll) { + setRoll(*properties.roll); } if (properties.xSkew) { setXSkew(*properties.xSkew); @@ -214,7 +214,7 @@ void TransformState::updateCameraState() const { const double dy = 0.5 * worldSize - y; // Set camera orientation and move it to a proper distance from the map - camera.setOrientation(pitch, getBearing(), getTwist()); + camera.setOrientation(pitch, getBearing(), getRoll()); vec3 cameraPosition = {{dx, dy, z}}; @@ -237,8 +237,8 @@ void TransformState::updateStateFromCamera() { // Compute bearing and pitch double newBearing; double newPitch; - double newTwist; - camera.getOrientation(newPitch, newBearing, newTwist); + double newRoll; + camera.getOrientation(newPitch, newBearing, newRoll); newPitch = util::clamp(newPitch, minPitch, maxPitch); // Compute zoom level from the camera altitude @@ -253,7 +253,7 @@ void TransformState::updateStateFromCamera() { setLatLngZoom(latLngFromMercator(mercatorPoint), scaleZoom(newScale)); setBearing(newBearing); setPitch(newPitch); - setTwist(newTwist); + setRoll(newRoll); } FreeCameraOptions TransformState::getFreeCameraOptions() const { @@ -437,7 +437,7 @@ CameraOptions TransformState::getCameraOptions(const std::optional& .withZoom(getZoom()) .withBearing(util::rad2deg(-bearing)) .withPitch(util::rad2deg(pitch)) - .withTwist(util::rad2deg(twist)) + .withRoll(util::rad2deg(roll)) .withFov(util::rad2deg(fov)); } @@ -621,13 +621,13 @@ void TransformState::setFieldOfView(double val) { } } -double TransformState::getTwist() const { - return twist; +double TransformState::getRoll() const { + return roll; } -void TransformState::setTwist(double val) { - if (twist != val) { - twist = val; +void TransformState::setRoll(double val) { + if (roll != val) { + roll = val; requestMatricesUpdate = true; } } diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index c602a08e09b..4e4ac583379 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -49,8 +49,8 @@ struct TransformStateProperties { pitch = val; return *this; } - TransformStateProperties& withTwist(const std::optional& val) { - twist = val; + TransformStateProperties& withRoll(const std::optional& val) { + roll = val; return *this; } TransformStateProperties& withXSkew(const std::optional& val) { @@ -105,7 +105,7 @@ struct TransformStateProperties { std::optional scale; std::optional bearing; std::optional pitch; - std::optional twist; + std::optional roll; std::optional xSkew; std::optional ySkew; std::optional axonometric; @@ -195,8 +195,8 @@ class TransformState { float getCameraToCenterDistance() const; double getPitch() const; void setPitch(double); - double getTwist() const; - void setTwist(double); + double getRoll() const; + void setRoll(double); double getXSkew() const; void setXSkew(double); @@ -302,7 +302,7 @@ class TransformState { // with: `fov = 2 * arctan((height / 2) / (height * 1.5))` double fov = 0.6435011087932844; double pitch = 0.0; - double twist = 0.0; + double roll = 0.0; double xSkew = 0.0; double ySkew = 1.0; bool axonometric = false; diff --git a/src/mbgl/util/camera.cpp b/src/mbgl/util/camera.cpp index ea808bffdac..90846ff55c5 100644 --- a/src/mbgl/util/camera.cpp +++ b/src/mbgl/util/camera.cpp @@ -65,13 +65,13 @@ static vec3 toMercator(const LatLng& location, double altitudeMeters) noexcept { altitudeMeters * pixelsPerMeter / worldSize}}; } -static Quaternion orientationFromPitchBearing(double pitch, double bearing, double twist) noexcept { +static Quaternion orientationFromPitchBearing(double pitch, double bearing, double roll) noexcept { // Both angles have to be negated to achieve CW rotation around the axis of rotation Quaternion rotBearing = Quaternion::fromAxisAngle({{0.0, 0.0, 1.0}}, -bearing); Quaternion rotPitch = Quaternion::fromAxisAngle({{1.0, 0.0, 0.0}}, -pitch); - Quaternion rotTwist = Quaternion::fromAxisAngle({{0.0, 0.0, 1.0}}, -twist); + Quaternion rotRoll = Quaternion::fromAxisAngle({{0.0, 0.0, 1.0}}, -roll); - return rotBearing.multiply(rotPitch).multiply(rotTwist); + return rotBearing.multiply(rotPitch).multiply(rotRoll); } static void updateTransform(mat4& transform, const Quaternion& orientation) noexcept { @@ -168,17 +168,17 @@ vec3 Camera::up() const noexcept { return {{-column[0], -column[1], -column[2]}}; } -void Camera::getOrientation(double& pitch, double& bearing, double& twist) const noexcept { +void Camera::getOrientation(double& pitch, double& bearing, double& roll) const noexcept { const vec3 f = forward(); const vec3 r = right(); bearing = std::atan2(-r[1], r[0]); pitch = std::atan2(std::sqrt(f[0] * f[0] + f[1] * f[1]), -f[2]); - twist = 0; //TODO + roll = 0; //TODO } -void Camera::setOrientation(double pitch, double bearing, double twist) noexcept { - orientation = orientationFromPitchBearing(pitch, bearing, twist); +void Camera::setOrientation(double pitch, double bearing, double roll) noexcept { + orientation = orientationFromPitchBearing(pitch, bearing, roll); updateTransform(transform, orientation); } @@ -196,9 +196,9 @@ std::optional Camera::orientationFromFrame(const vec3& forward, cons const double bearing = std::atan2(-right[1], right[0]); const double pitch = std::atan2(std::sqrt(forward[0] * forward[0] + forward[1] * forward[1]), -forward[2]); - const double twist = 0; //TODO + const double roll = 0; //TODO - return util::orientationFromPitchBearing(pitch, bearing, twist); + return util::orientationFromPitchBearing(pitch, bearing, roll); } } // namespace util @@ -241,9 +241,9 @@ void FreeCameraOptions::lookAtPoint(const LatLng& location, const std::optional< orientation = util::Camera::orientationFromFrame(forward, up)->m; } -void FreeCameraOptions::setPitchBearing(double pitch, double bearing, double twist) noexcept { +void FreeCameraOptions::setPitchBearing(double pitch, double bearing, double roll) noexcept { orientation = - util::orientationFromPitchBearing(util::deg2rad(pitch), util::deg2rad(bearing), util::deg2rad(twist)).m; + util::orientationFromPitchBearing(util::deg2rad(pitch), util::deg2rad(bearing), util::deg2rad(roll)).m; } } // namespace mbgl diff --git a/src/mbgl/util/camera.hpp b/src/mbgl/util/camera.hpp index ede6dbc9a56..b4b6d3f7617 100644 --- a/src/mbgl/util/camera.hpp +++ b/src/mbgl/util/camera.hpp @@ -25,8 +25,8 @@ class Camera { vec3 up() const noexcept; const Quaternion& getOrientation() const noexcept { return orientation; } - void getOrientation(double& pitch, double& bearing, double& twist) const noexcept; - void setOrientation(double pitch, double bearing, double twist) noexcept; + void getOrientation(double& pitch, double& bearing, double& roll) const noexcept; + void setOrientation(double pitch, double bearing, double roll) noexcept; void setOrientation(const Quaternion& orientation_) noexcept; void setPosition(const vec3& position) noexcept;