Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Render fill-extrusion layers #8431

Merged
merged 87 commits into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5c62307
[core] Generalize std::array<float, N> converter
jfirebaugh Apr 7, 2017
d6a5137
initial WIP commit
Feb 1, 2017
272ad93
wip commit 2
Feb 2, 2017
e83c01c
[wip] rendering extrusions in glfw: still improperly depth testing + …
Feb 3, 2017
9bc5110
Change rendering from per-tile to per-tile vector (allowing layers to…
Feb 14, 2017
84983de
wip extrusion texture commit before rebase
Feb 15, 2017
21bfc15
rebase success: wip; have extrusion texture preliminarily working; ne…
Feb 16, 2017
cb2befd
wip: rendering to external texture/renderbuffers, but why are there s…
Feb 17, 2017
24effee
REVERT LATER: glfw settings
Feb 17, 2017
afd5e63
Light (initial implementation, needs work)
Feb 21, 2017
5139e61
Further light implementation details
Feb 22, 2017
4685e7b
cleanup transform_state light placeholders
Feb 22, 2017
ff52797
delete comment
Feb 22, 2017
52cf6e1
cmake changes: light
Feb 22, 2017
a3ad58b
fill_extrusion_bucket fixes
Feb 28, 2017
eb2b725
[stash]
Mar 3, 2017
962bf82
abhorrently non-atomic commit in which most things work
Mar 7, 2017
3d10230
[ci skip] Update renderbuffer storage type, start cleanups, use evalu…
Mar 7, 2017
f2cf9e7
* Add light defaults
Mar 15, 2017
5011ff3
Rebased shaders
Apr 4, 2017
ea92809
Implement transitions for light properties.
Mar 27, 2017
43dfd55
Add fill-extrusion properties to darwin overrides files
Mar 27, 2017
ab29fcc
Reconcile changes from rebase
Mar 27, 2017
de9fcdf
Use GL_DEPTH_COMPONENT rather than GL_DEPTH_COMPONENT16 to allow for …
Mar 28, 2017
3524e4f
Update darwin overrides + generated code
Mar 28, 2017
1f21d53
Render fill-extrusion-pattern
Mar 29, 2017
9fedd0a
unit test: StyleConversion.Light
Mar 30, 2017
b04bd2c
unit test: Position.Calculations
Mar 30, 2017
907ddc2
Rearrange mat3 translation so no include/ files depend on src/ header…
Mar 31, 2017
63cbf82
Cleanups (TODOs, unused includes, formatting
Mar 31, 2017
de9625d
Mark tiles as used, necessary for properly generating clipping masks
Apr 5, 2017
20828e4
Define DepthComponent as GL/GLES-dependent
Apr 5, 2017
3d46bbf
undo changes in glfw/main
Apr 6, 2017
9c45768
fix latitude in transform_state after rebase
Apr 6, 2017
286af03
Only add RenderTiles to order if they have data available
Apr 6, 2017
0dd79a3
Ran android-style-code make target
Apr 7, 2017
fb6547c
Amend position test error message based on generalized array converte…
Apr 7, 2017
7e6a310
Per review:
Apr 8, 2017
0813008
Per review:
Apr 8, 2017
9a8e5e1
Per review:
Apr 8, 2017
715ee12
Per review:
Apr 8, 2017
7423217
Fix broken Position tests from constructor change
Apr 8, 2017
97a7472
[android] wire up the fill extrusion layer
ivovandongen Apr 11, 2017
61815c7
[android] add test activity for fill extrusion layer
ivovandongen Apr 11, 2017
99fec2f
Update ios targets
Apr 11, 2017
4b8fd3a
Revert glfw formatting
Apr 11, 2017
d196d1d
Per review:
Apr 12, 2017
2b28ff5
Per review:
Apr 12, 2017
42fa99f
Per review:
Apr 12, 2017
606924c
Per review:
Apr 12, 2017
ac03d8c
Per review:
Apr 12, 2017
8c2d7c1
[ios, macos] Added MGLFillExtrusionStyleLayer to projects
1ec5 Apr 13, 2017
bf9158c
[ios, macos] Fixed fill extrusion imports
1ec5 Apr 13, 2017
a4ff7ed
[ios, macos] Added MGLFillExtrusionStyleLayer example
1ec5 Apr 13, 2017
4db2f48
[ios, macos] Updated changelogs
1ec5 Apr 13, 2017
681878f
Per review:
Apr 13, 2017
14a6327
Return early from rings with 0 vertices
Apr 13, 2017
ab202aa
Per review:
Apr 14, 2017
bad6036
Split light.hpp into public and private implementation
jfirebaugh Apr 14, 2017
c99d816
Review followups
Apr 18, 2017
4088d0c
Review followups
Apr 18, 2017
76d661e
Rebase resolutions:
Apr 19, 2017
e7b962c
Rebase follow-ups:
Apr 19, 2017
01fb6bc
:thinking_face: don't think these cmake changes are intended
Apr 19, 2017
b4829a8
Try offsetting camera options for better-defined tile cover
Apr 19, 2017
4355ba9
/s/FillExtrusion/Fill extrusion/ in darwin docs
Apr 20, 2017
2f03838
Manage light as unique_ptr of style
Apr 20, 2017
d7f03b9
Remove debug styles accidentally added
Apr 20, 2017
d487445
Return regular ptr from Map#getLight
Apr 20, 2017
806734f
Use spherical coordinates for interpolation
Apr 20, 2017
f62e820
Apply changes from 7ddca3b6116903bae9ecde1d49d29a8f1fedcec3 (rebased)…
Apr 21, 2017
f7fb7e5
Add DepthComponent24 if supported in GLES extension
Apr 24, 2017
c0fa720
Use existing getMetersPerPixelAtLatitude projection method
Apr 24, 2017
82cb69f
Formatting: indentation
Apr 24, 2017
0bb28cf
Per review: rather than thread Style references throughout render pip…
Apr 24, 2017
1b9dee7
Uncomment GLES2 Depth24 preprocessor directive
Apr 25, 2017
b52aa9d
Fall back to using DepthStencil for extrusion texture on GL ES device…
Apr 25, 2017
5a8ef68
Limit near Z fragments to 100 to preserve depth precision in the rest…
Apr 26, 2017
72278bf
Fix for previous commit: calculate a projection matrix just for the f…
Apr 26, 2017
086fa8d
Simplify OffscreenTexture: use DepthComponent (as defined by preproce…
Apr 26, 2017
764576f
Rebase conflict resolution
Apr 27, 2017
4a749c0
? redundant style.hpp in cmake
Apr 27, 2017
b22e8aa
Store both normal tile matrix + near-clipped matrix in RenderTiles to…
Apr 27, 2017
695da93
[android] - add accessor support for source layer
tobrun Apr 27, 2017
bf52d28
Update SHA after merging https://github.com/mapbox/mapbox-gl-js/pull/…
Apr 27, 2017
30df15b
Update gl-js SHA
Apr 27, 2017
b450c4c
Update gl-js SHA
jfirebaugh Apr 27, 2017
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
25 changes: 21 additions & 4 deletions cmake/core-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ set(MBGL_CORE_FILES
src/mbgl/programs/collision_box_program.cpp
src/mbgl/programs/collision_box_program.hpp
src/mbgl/programs/debug_program.hpp
src/mbgl/programs/extrusion_texture_program.cpp
src/mbgl/programs/extrusion_texture_program.hpp
src/mbgl/programs/fill_extrusion_program.cpp
src/mbgl/programs/fill_extrusion_program.hpp
src/mbgl/programs/fill_program.cpp
src/mbgl/programs/fill_program.hpp
src/mbgl/programs/line_program.cpp
Expand All @@ -162,6 +166,8 @@ set(MBGL_CORE_FILES
src/mbgl/renderer/debug_bucket.hpp
src/mbgl/renderer/fill_bucket.cpp
src/mbgl/renderer/fill_bucket.hpp
src/mbgl/renderer/fill_extrusion_bucket.cpp
src/mbgl/renderer/fill_extrusion_bucket.hpp
src/mbgl/renderer/frame_history.cpp
src/mbgl/renderer/frame_history.hpp
src/mbgl/renderer/group_by_layout.cpp
Expand All @@ -176,6 +182,7 @@ set(MBGL_CORE_FILES
src/mbgl/renderer/painter_clipping.cpp
src/mbgl/renderer/painter_debug.cpp
src/mbgl/renderer/painter_fill.cpp
src/mbgl/renderer/painter_fill_extrusion.cpp
src/mbgl/renderer/painter_line.cpp
src/mbgl/renderer/painter_raster.cpp
src/mbgl/renderer/painter_symbol.cpp
Expand Down Expand Up @@ -213,8 +220,14 @@ set(MBGL_CORE_FILES
src/mbgl/shaders/collision_box.hpp
src/mbgl/shaders/debug.cpp
src/mbgl/shaders/debug.hpp
src/mbgl/shaders/extrusion_texture.cpp
src/mbgl/shaders/extrusion_texture.hpp
src/mbgl/shaders/fill.cpp
src/mbgl/shaders/fill.hpp
src/mbgl/shaders/fill_extrusion.cpp
src/mbgl/shaders/fill_extrusion.hpp
src/mbgl/shaders/fill_extrusion_pattern.cpp
src/mbgl/shaders/fill_extrusion_pattern.hpp
src/mbgl/shaders/fill_outline.cpp
src/mbgl/shaders/fill_outline.hpp
src/mbgl/shaders/fill_outline_pattern.cpp
Expand Down Expand Up @@ -270,6 +283,8 @@ set(MBGL_CORE_FILES
include/mbgl/style/image.hpp
include/mbgl/style/layer.hpp
include/mbgl/style/layer_type.hpp
include/mbgl/style/light.hpp
include/mbgl/style/position.hpp
include/mbgl/style/property_value.hpp
include/mbgl/style/query.hpp
include/mbgl/style/source.hpp
Expand All @@ -288,6 +303,7 @@ set(MBGL_CORE_FILES
src/mbgl/style/layer_impl.hpp
src/mbgl/style/layer_observer.hpp
src/mbgl/style/layout_property.hpp
src/mbgl/style/light_impl.hpp
src/mbgl/style/observer.hpp
src/mbgl/style/paint_property.hpp
src/mbgl/style/paint_property_binder.hpp
Expand All @@ -304,10 +320,9 @@ set(MBGL_CORE_FILES
src/mbgl/style/source_observer.hpp
src/mbgl/style/style.cpp
src/mbgl/style/style.hpp
src/mbgl/style/style.hpp
src/mbgl/style/style.hpp
src/mbgl/style/tile_source_impl.cpp
src/mbgl/style/tile_source_impl.hpp
src/mbgl/style/transitioning_property.hpp
src/mbgl/style/types.cpp
src/mbgl/style/update_batch.hpp
src/mbgl/style/update_parameters.hpp
Expand All @@ -320,7 +335,9 @@ set(MBGL_CORE_FILES
include/mbgl/style/conversion/geojson.hpp
include/mbgl/style/conversion/geojson_options.hpp
include/mbgl/style/conversion/layer.hpp
include/mbgl/style/conversion/light.hpp
include/mbgl/style/conversion/make_property_setters.hpp
include/mbgl/style/conversion/position.hpp
include/mbgl/style/conversion/property_setter.hpp
include/mbgl/style/conversion/property_value.hpp
include/mbgl/style/conversion/source.hpp
Expand Down Expand Up @@ -474,6 +491,7 @@ set(MBGL_CORE_FILES
include/mbgl/util/geometry.hpp
include/mbgl/util/ignore.hpp
include/mbgl/util/image.hpp
include/mbgl/util/indexed_tuple.hpp
include/mbgl/util/interpolate.hpp
include/mbgl/util/logging.hpp
include/mbgl/util/noncopyable.hpp
Expand All @@ -487,6 +505,7 @@ set(MBGL_CORE_FILES
include/mbgl/util/tileset.hpp
include/mbgl/util/timer.hpp
include/mbgl/util/traits.hpp
include/mbgl/util/type_list.hpp
include/mbgl/util/unitbezier.hpp
include/mbgl/util/util.hpp
include/mbgl/util/variant.hpp
Expand Down Expand Up @@ -514,7 +533,6 @@ set(MBGL_CORE_FILES
src/mbgl/util/http_timeout.hpp
src/mbgl/util/i18n.cpp
src/mbgl/util/i18n.hpp
src/mbgl/util/indexed_tuple.hpp
src/mbgl/util/interpolate.cpp
src/mbgl/util/intersection_tests.cpp
src/mbgl/util/intersection_tests.hpp
Expand Down Expand Up @@ -548,7 +566,6 @@ set(MBGL_CORE_FILES
src/mbgl/util/tile_cover.cpp
src/mbgl/util/tile_cover.hpp
src/mbgl/util/token.hpp
src/mbgl/util/type_list.hpp
src/mbgl/util/url.cpp
src/mbgl/util/url.hpp
src/mbgl/util/utf.hpp
Expand Down
2 changes: 2 additions & 0 deletions cmake/test-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ set(MBGL_TEST_FILES
test/style/conversion/function.test.cpp
test/style/conversion/geojson_options.test.cpp
test/style/conversion/layer.test.cpp
test/style/conversion/light.test.cpp
test/style/conversion/stringify.test.cpp

# style
Expand Down Expand Up @@ -125,6 +126,7 @@ set(MBGL_TEST_FILES
test/util/merge_lines.test.cpp
test/util/number_conversions.test.cpp
test/util/offscreen_texture.test.cpp
test/util/position.test.cpp
test/util/projection.test.cpp
test/util/run_loop.test.cpp
test/util/text_conversions.test.cpp
Expand Down
5 changes: 5 additions & 0 deletions include/mbgl/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace style {
class Image;
class Source;
class Layer;
class Light;
} // namespace style

class Map : private util::noncopyable {
Expand Down Expand Up @@ -179,6 +180,10 @@ class Map : private util::noncopyable {
void removeImage(const std::string&);
const style::Image* getImage(const std::string&);

// Light
void setLight(std::unique_ptr<style::Light>);
style::Light* getLight();

// Defaults
std::string getStyleName() const;
LatLng getDefaultLatLng() const;
Expand Down
49 changes: 15 additions & 34 deletions include/mbgl/style/conversion/constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <mbgl/util/optional.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/enum.hpp>
#include <mbgl/util/string.hpp>

#include <array>
#include <string>
Expand Down Expand Up @@ -92,45 +93,25 @@ struct Converter<Color> {
}
};

template <>
struct Converter<std::array<float, 2>> {
template <size_t N>
struct Converter<std::array<float, N>> {
template <class V>
optional<std::array<float, 2>> operator()(const V& value, Error& error) const {
if (!isArray(value) || arrayLength(value) != 2) {
error = { "value must be an array of two numbers" };
optional<std::array<float, N>> operator()(const V& value, Error& error) const {
if (!isArray(value) || arrayLength(value) != N) {
error = { "value must be an array of " + util::toString(N) + " numbers" };
return {};
}

optional<float> first = toNumber(arrayMember(value, 0));
optional<float> second = toNumber(arrayMember(value, 1));
if (!first || !second) {
error = { "value must be an array of two numbers" };
return {};
}

return std::array<float, 2> {{ *first, *second }};
}
};

template <>
struct Converter<std::array<float, 4>> {
template <class V>
optional<std::array<float, 4>> operator()(const V& value, Error& error) const {
if (!isArray(value) || arrayLength(value) != 4) {
error = { "value must be an array of four numbers" };
return {};
}

optional<float> first = toNumber(arrayMember(value, 0));
optional<float> second = toNumber(arrayMember(value, 1));
optional<float> third = toNumber(arrayMember(value, 2));
optional<float> fourth = toNumber(arrayMember(value, 3));
if (!first || !second) {
error = { "value must be an array of four numbers" };
return {};
std::array<float, N> result;
for (size_t i = 0; i < N; i++) {
optional<float> n = toNumber(arrayMember(value, i));
if (!n) {
error = { "value must be an array of " + util::toString(N) + " numbers" };
return {};
}
result[i] = *n;
}

return std::array<float, 4> {{ *first, *second, *third, *fourth }};
return result;
}
};

Expand Down
3 changes: 3 additions & 0 deletions include/mbgl/style/conversion/layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
Expand Down Expand Up @@ -92,6 +93,8 @@ struct Converter<std::unique_ptr<Layer>> {

if (*type == "fill") {
converted = convertVectorLayer<FillLayer>(*id, value, error);
} else if (*type == "fill-extrusion") {
converted = convertVectorLayer<FillExtrusionLayer>(*id, value, error);
} else if (*type == "line") {
converted = convertVectorLayer<LineLayer>(*id, value, error);
} else if (*type == "circle") {
Expand Down
122 changes: 122 additions & 0 deletions include/mbgl/style/conversion/light.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#pragma once

#include <mbgl/style/light.hpp>
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/conversion/position.hpp>
#include <mbgl/style/conversion/property_value.hpp>
#include <mbgl/style/conversion/transition_options.hpp>

namespace mbgl {
namespace style {
namespace conversion {

template <>
struct Converter<Light> {
public:
template <class V>
optional<Light> operator()(const V& value, Error& error) const {
if (!isObject(value)) {
error = { "light must be an object" };
return {};
}

Light light;

const auto anchor = objectMember(value, "anchor");
if (anchor) {
optional<PropertyValue<LightAnchorType>> convertedAnchor =
convert<PropertyValue<LightAnchorType>>(*anchor, error);

if (convertedAnchor) {
light.get<LightAnchor>().value = *convertedAnchor;
} else {
return {};
}
}

const auto anchorTransition = objectMember(value, "anchor-transition");
if (anchorTransition) {
optional<TransitionOptions> transition =
convert<TransitionOptions>(*anchorTransition, error);
if (transition) {
light.get<LightAnchor>().transition = *transition;
} else {
return {};
}
}

const auto color = objectMember(value, "color");
if (color) {
optional<PropertyValue<Color>> convertedColor =
convert<PropertyValue<Color>>(*color, error);

if (convertedColor) {
light.get<LightColor>().value = *convertedColor;
} else {
return {};
}
}

const auto colorTransition = objectMember(value, "color-transition");
if (colorTransition) {
optional<TransitionOptions> transition =
convert<TransitionOptions>(*colorTransition, error);
if (transition) {
light.get<LightColor>().transition = *transition;
} else {
return {};
}
}

const auto position = objectMember(value, "position");
if (position) {
optional<PropertyValue<Position>> convertedPosition =
convert<PropertyValue<Position>>(*position, error);

if (convertedPosition) {
light.get<LightPosition>().value = *convertedPosition;
} else {
return {};
}
}

const auto positionTransition = objectMember(value, "position-transition");
if (positionTransition) {
optional<TransitionOptions> transition =
convert<TransitionOptions>(*positionTransition, error);
if (transition) {
light.get<LightPosition>().transition = *transition;
} else {
return {};
}
}

const auto intensity = objectMember(value, "intensity");
if (intensity) {
optional<PropertyValue<float>> convertedIntensity =
convert<PropertyValue<float>>(*intensity, error);

if (convertedIntensity) {
light.get<LightIntensity>().value = *convertedIntensity;
} else {
return {};
}
}

const auto intensityTransition = objectMember(value, "intensity-transition");
if (intensityTransition) {
optional<TransitionOptions> transition =
convert<TransitionOptions>(*intensityTransition, error);
if (transition) {
light.get<LightIntensity>().transition = *transition;
} else {
return {};
}
}
return { light };
};
};

} // namespace conversion
} // namespace style
} // namespace mbgl
29 changes: 29 additions & 0 deletions include/mbgl/style/conversion/position.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <mbgl/style/conversion.hpp>
#include <mbgl/style/position.hpp>
#include <mbgl/util/optional.hpp>

#include <array>

namespace mbgl {
namespace style {
namespace conversion {

template <>
struct Converter<Position> {
template <class V>
optional<Position> operator()(const V& value, Error& error) const {
optional<std::array<float, 3>> spherical = convert<std::array<float, 3>>(value, error);

if (!spherical) {
return {};
}

return Position(*spherical);
}
};

} // namespace conversion
} // namespace style
} // namespace mbgl
2 changes: 1 addition & 1 deletion include/mbgl/style/layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Layer : public mbgl::util::noncopyable {

// Convenience method for dynamic dispatch on the concrete layer type. Using
// method overloading, this allows consolidation of logic common to vector-based
// layers (Fill, Line, Circle, or Symbol). For example:
// layers (Fill, FillExtrusion, Line, Circle, or Symbol). For example:
//
// struct Visitor {
// void operator()(CustomLayer&) { ... }
Expand Down
Loading