Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera Roll #3011

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0afd99b
pitch working up to but not including 90 deg
NathanMOlson Feb 12, 2024
aa02572
use max furthestDistance if pitched above the horizon
NathanMOlson Feb 12, 2024
0cb061d
variable FOV seems to work
NathanMOlson Feb 12, 2024
ac8fbc2
set camera position, not map center postion. Pitches above 90 work, b…
NathanMOlson Feb 12, 2024
c5f18db
fixes for pitch = 90
NathanMOlson Feb 14, 2024
b50ee05
fix trig issue affecting near nadir
NathanMOlson Feb 14, 2024
414b0e8
add settable camera altitude
NathanMOlson Feb 14, 2024
d17706a
twist working, but there's wreckage in camera.cpp
NathanMOlson Feb 14, 2024
92a4b4d
toward full twist support
NathanMOlson Feb 14, 2024
14c4404
Merge branch 'main' into roll (probably doesn't compile)
NathanMOlson Nov 12, 2024
f737b2f
compiles
NathanMOlson Nov 12, 2024
bf5745a
rename twist -> roll
NathanMOlson Nov 12, 2024
a3b7478
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
eb06001
fix command line abbreviations
NathanMOlson Nov 12, 2024
d32dc72
clarify altitude
NathanMOlson Nov 12, 2024
ef274ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
1c4a24e
fix compile
NathanMOlson Nov 12, 2024
b98ea0a
fix altitude interpretation
NathanMOlson Nov 12, 2024
1c195c8
Add comments
NathanMOlson Nov 12, 2024
f641468
better naming
NathanMOlson Nov 12, 2024
e39788d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
fd9fa00
fov handling improvements
NathanMOlson Nov 12, 2024
9421f10
Merge branch 'roll' of github.com:NathanMOlson/maplibre-native into roll
NathanMOlson Nov 12, 2024
92b6017
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
c001e50
formatting
NathanMOlson Nov 12, 2024
ee93d55
cleanup
NathanMOlson Nov 12, 2024
9b5370f
Merge branch 'main' into roll
NathanMOlson Nov 12, 2024
fb7ffe7
cleanup
NathanMOlson Nov 13, 2024
c150fd6
restore bounds limits, and interpolate center altitude in easeTo() an…
NathanMOlson Nov 13, 2024
8d06c07
interpolate fov in easeTo and flyTo, and limit FOV
NathanMOlson Nov 13, 2024
8b8b63c
interpolate roll
NathanMOlson Nov 13, 2024
0e2f441
Merge branch 'main' into roll
louwers Nov 13, 2024
4b6c340
Merge branch 'main' into roll
NathanMOlson Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
variable FOV seems to work
NathanMOlson committed Feb 12, 2024
commit 0cb061d39fda620c52979fdfbb385906630ab402
4 changes: 3 additions & 1 deletion bin/render.cpp
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ int main(int argc, char* argv[]) {

args::ValueFlag<double> lonValue(argumentParser, "degrees", "Longitude", {'x', "lon"});
args::ValueFlag<double> latValue(argumentParser, "degrees", "Latitude", {'y', "lat"});
args::ValueFlag<double> fovValue(argumentParser, "degrees", "FOV", {'f', "fov"});
args::ValueFlag<double> bearingValue(argumentParser, "degrees", "Bearing", {'b', "bearing"});
args::ValueFlag<double> pitchValue(argumentParser, "degrees", "Pitch", {'p', "pitch"});
args::ValueFlag<uint32_t> widthValue(argumentParser, "pixels", "Image width", {'w', "width"});
@@ -56,6 +57,7 @@ int main(int argc, char* argv[]) {
const double lat = latValue ? args::get(latValue) : 0;
const double lon = lonValue ? args::get(lonValue) : 0;
const double zoom = zoomValue ? args::get(zoomValue) : 0;
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 pixelRatio = pixelRatioValue ? args::get(pixelRatioValue) : 1;
@@ -97,7 +99,7 @@ int main(int argc, char* argv[]) {
}

map.getStyle().loadURL(style);
map.jumpTo(CameraOptions().withCenter(LatLng{lat, lon}).withZoom(zoom).withBearing(bearing).withPitch(pitch));
map.jumpTo(CameraOptions().withCenter(LatLng{lat, lon}).withZoom(zoom).withBearing(bearing).withPitch(pitch).withFov(fov));

if (debug) {
map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus
8 changes: 7 additions & 1 deletion include/mbgl/map/camera.hpp
Original file line number Diff line number Diff line change
@@ -41,6 +41,10 @@ struct CameraOptions {
pitch = o;
return *this;
}
CameraOptions& withFov(const std::optional<double>& o) {
fov = o;
return *this;
}

/** Coordinate at the center of the map. */
std::optional<LatLng> center;
@@ -63,11 +67,13 @@ struct CameraOptions {
/** Pitch toward the horizon measured in degrees , with 0 deg resulting in a
two-dimensional map. */
std::optional<double> pitch;

std::optional<double> 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.bearing == b.bearing && a.pitch == b.pitch && a.fov == b.fov;
}

constexpr bool operator!=(const CameraOptions& a, const CameraOptions& b) {
2 changes: 2 additions & 0 deletions src/mbgl/map/transform.cpp
Original file line number Diff line number Diff line change
@@ -97,6 +97,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
double zoom = camera.zoom.value_or(getZoom());
double bearing = camera.bearing ? util::deg2rad(-*camera.bearing) : getBearing();
double pitch = camera.pitch ? util::deg2rad(*camera.pitch) : getPitch();
double fov = camera.fov ? util::deg2rad(*camera.fov) : getFieldOfView();

if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch)) {
if (animation.transitionFinishFn) {
@@ -161,6 +162,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
if (pitch != startPitch) {
state.setPitch(util::interpolate(startPitch, pitch, t));
}
state.setFieldOfView(fov);
},
duration);
}
13 changes: 12 additions & 1 deletion src/mbgl/map/transform_state.cpp
Original file line number Diff line number Diff line change
@@ -48,6 +48,9 @@ void TransformState::setProperties(const TransformStateProperties& properties) {
if (properties.bearing) {
setBearing(*properties.bearing);
}
if (properties.fov) {
setFieldOfView(*properties.fov);
}
if (properties.pitch) {
setPitch(*properties.pitch);
}
@@ -429,7 +432,8 @@ CameraOptions TransformState::getCameraOptions(const std::optional<EdgeInsets>&
.withPadding(padding ? padding : edgeInsets)
.withZoom(getZoom())
.withBearing(util::rad2deg(-bearing))
.withPitch(util::rad2deg(pitch));
.withPitch(util::rad2deg(pitch))
.withFov(util::rad2deg(fov));
}

// MARK: - EdgeInsets
@@ -590,6 +594,13 @@ float TransformState::getFieldOfView() const {
return static_cast<float>(fov);
}

void TransformState::setFieldOfView(double val) {
if (fov != val) {
fov = val;
requestMatricesUpdate = true;
}
}

float TransformState::getCameraToCenterDistance() const {
return static_cast<float>(0.5 * size.height / std::tan(fov / 2.0));
}
6 changes: 6 additions & 0 deletions src/mbgl/map/transform_state.hpp
Original file line number Diff line number Diff line change
@@ -33,6 +33,10 @@ struct TransformStateProperties {
scale = val;
return *this;
}
TransformStateProperties& withFov(const std::optional<double>& val) {
fov = val;
return *this;
}
TransformStateProperties& withBearing(const std::optional<double>& val) {
bearing = val;
return *this;
@@ -88,6 +92,7 @@ struct TransformStateProperties {

std::optional<double> x;
std::optional<double> y;
std::optional<double> fov;
std::optional<double> bearing;
std::optional<double> scale;
std::optional<double> pitch;
@@ -173,6 +178,7 @@ class TransformState {
double getBearing() const;
void setBearing(double);
float getFieldOfView() const;
void setFieldOfView(double);
float getCameraToCenterDistance() const;
double getPitch() const;
void setPitch(double);