diff options
author | Lauren Budorick <lauren@mapbox.com> | 2017-03-30 18:24:23 -0700 |
---|---|---|
committer | Lauren Budorick <lauren@mapbox.com> | 2017-04-24 17:09:08 -0700 |
commit | 81784367f77bf9f538b552a85f0467032d43cd25 (patch) | |
tree | 66ea6fabcd2f526c00ae62a51f9d11b160905850 | |
parent | 611ab36fa53eb7d18e9742c232003b8fc90f097d (diff) | |
download | qtlocation-mapboxgl-81784367f77bf9f538b552a85f0467032d43cd25.tar.gz |
Rearrange mat3 translation so no include/ files depend on src/ headers after rebase
-rw-r--r-- | include/mbgl/style/light.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/util/position.hpp | 13 | ||||
m--------- | mapbox-gl-js | 0 | ||||
-rw-r--r-- | platform/darwin/src/MGLFillExtrusionStyleLayer.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.h.ejs | 2 | ||||
-rw-r--r-- | src/mbgl/programs/extrusion_texture_program.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/renderer/painter_fill_extrusion.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/shaders/fill_extrusion.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/shaders/fill_extrusion_pattern.cpp | 3 | ||||
-rw-r--r-- | test/util/position.test.cpp | 13 |
10 files changed, 29 insertions, 27 deletions
diff --git a/include/mbgl/style/light.hpp b/include/mbgl/style/light.hpp index 0506c3c4ee..1fc5e7ac67 100644 --- a/include/mbgl/style/light.hpp +++ b/include/mbgl/style/light.hpp @@ -7,7 +7,6 @@ #include <mbgl/style/transition_options.hpp> #include <mbgl/style/cascade_parameters.hpp> #include <mbgl/util/constants.hpp> -#include <mbgl/util/mat3.hpp> #include <mbgl/util/color.hpp> #include <mbgl/util/constants.hpp> #include <mbgl/util/interpolate.hpp> diff --git a/include/mbgl/util/position.hpp b/include/mbgl/util/position.hpp index 6fc6be2794..55daf10ade 100644 --- a/include/mbgl/util/position.hpp +++ b/include/mbgl/util/position.hpp @@ -3,7 +3,6 @@ #include <mbgl/style/types.hpp> #include <mbgl/util/optional.hpp> #include <mbgl/util/constants.hpp> -#include <mbgl/util/mat3.hpp> #include <array> @@ -29,16 +28,8 @@ public: return !(lhs == rhs); } - const std::array<float, 3> get(LightAnchorType anchor, float angle) const { - vec3f lightvec{ { x, y, z } }; - mat3 lightmat; - matrix::identity(lightmat); - if (anchor == LightAnchorType::Viewport) { - matrix::rotate(lightmat, lightmat, -angle); - } - matrix::transformMat3f(lightvec, lightvec, lightmat); - - return lightvec; + const std::array<float, 3> get() const { + return { { x, y, z } }; }; const std::array<float, 3> getSpherical() const { diff --git a/mapbox-gl-js b/mapbox-gl-js -Subproject d7945c30a07b5e733ded00036136fd7bf543497 +Subproject d36c4d2ac86e43176916e621eb0f4b94c97dc3f diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.h b/platform/darwin/src/MGLFillExtrusionStyleLayer.h index 599d8df676..732c9a3b84 100644 --- a/platform/darwin/src/MGLFillExtrusionStyleLayer.h +++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.h @@ -338,7 +338,7 @@ MGL_EXPORT */ @interface NSValue (MGLFillExtrusionStyleLayerAdditions) -#pragma mark Working with FillExtrusion Style Layer Attribute Values +#pragma mark Working with Fill extrusion Style Layer Attribute Values /** Creates a new value object containing the given `MGLFillExtrusionTranslationAnchor` enumeration. diff --git a/platform/darwin/src/MGLStyleLayer.h.ejs b/platform/darwin/src/MGLStyleLayer.h.ejs index eed4f911be..8111da684a 100644 --- a/platform/darwin/src/MGLStyleLayer.h.ejs +++ b/platform/darwin/src/MGLStyleLayer.h.ejs @@ -161,7 +161,7 @@ which it is added. */ @interface NSValue (MGL<%- camelize(type) %>StyleLayerAdditions) -#pragma mark Working with <%- camelize(type) %> Style Layer Attribute Values +#pragma mark Working with <%- camelize(unhyphenate(type)) %> Style Layer Attribute Values <% for (let property of enumProperties) { -%> /** diff --git a/src/mbgl/programs/extrusion_texture_program.hpp b/src/mbgl/programs/extrusion_texture_program.hpp index 621e9b5922..eefa4c81d1 100644 --- a/src/mbgl/programs/extrusion_texture_program.hpp +++ b/src/mbgl/programs/extrusion_texture_program.hpp @@ -5,6 +5,7 @@ #include <mbgl/programs/uniforms.hpp> #include <mbgl/shaders/extrusion_texture.hpp> #include <mbgl/style/layers/fill_extrusion_layer_properties.hpp> +#include <mbgl/util/geometry.hpp> #include <string> diff --git a/src/mbgl/renderer/painter_fill_extrusion.cpp b/src/mbgl/renderer/painter_fill_extrusion.cpp index 818aa94e45..5ea2ba6203 100644 --- a/src/mbgl/renderer/painter_fill_extrusion.cpp +++ b/src/mbgl/renderer/painter_fill_extrusion.cpp @@ -29,8 +29,16 @@ void Painter::renderFillExtrusion(PaintParameters& parameters, const auto light = style.light.evaluated; const auto lightColor = light.get<LightColor>(); std::array<float, 3> color3f = { { lightColor.r, lightColor.g, lightColor.b } }; - const auto lightPos = - light.get<LightPosition>().get(light.get<LightAnchor>(), state.getAngle()); + const auto lightAnchor = light.get<LightAnchor>(); + + auto lightPos = light.get<LightPosition>().get(); + mat3 lightmat; + matrix::identity(lightmat); + if (lightAnchor == LightAnchorType::Viewport) { + matrix::rotate(lightmat, lightmat, -state.getAngle()); + } + matrix::transformMat3f(lightPos, lightPos, lightmat); + const auto lightIntensity = light.get<LightIntensity>(); if (!properties.get<FillExtrusionPattern>().from.empty()) { diff --git a/src/mbgl/shaders/fill_extrusion.cpp b/src/mbgl/shaders/fill_extrusion.cpp index ecb694d782..ea1c80545e 100644 --- a/src/mbgl/shaders/fill_extrusion.cpp +++ b/src/mbgl/shaders/fill_extrusion.cpp @@ -26,14 +26,17 @@ attribute lowp vec2 a_height; varying lowp float height; uniform lowp float a_color_t; -attribute lowp vec4 a_color; -varying lowp vec4 color; +attribute highp vec4 a_color; +varying highp vec4 color; void main() { base = unpack_mix_vec2(a_base, a_base_t); height = unpack_mix_vec2(a_height, a_height_t); color = unpack_mix_vec4(a_color, a_color_t); + base = max(0.0, base); + height = max(0.0, height); + float ed = a_edgedistance; // use each attrib in order to not trip a VAO assert float t = mod(a_normal.x, 2.0); @@ -75,7 +78,7 @@ const char* fill_extrusion::fragmentSource = R"MBGL_SHADER( varying vec4 v_color; varying lowp float base; varying lowp float height; -varying lowp vec4 color; +varying highp vec4 color; void main() { diff --git a/src/mbgl/shaders/fill_extrusion_pattern.cpp b/src/mbgl/shaders/fill_extrusion_pattern.cpp index 1d7137e9bc..e2de5c20b2 100644 --- a/src/mbgl/shaders/fill_extrusion_pattern.cpp +++ b/src/mbgl/shaders/fill_extrusion_pattern.cpp @@ -41,6 +41,9 @@ void main() { base = unpack_mix_vec2(a_base, a_base_t); height = unpack_mix_vec2(a_height, a_height_t); + base = max(0.0, base); + height = max(0.0, height); + float t = mod(a_normal.x, 2.0); float z = t > 0.0 ? height : base; diff --git a/test/util/position.test.cpp b/test/util/position.test.cpp index 8ab5d61f7c..d22bc921a0 100644 --- a/test/util/position.test.cpp +++ b/test/util/position.test.cpp @@ -28,20 +28,17 @@ TEST(Position, Calculations) { Position position(spherical); - ARR_NE(position.get(LightAnchorType::Map, 0), spherical); + ARR_NE(position.get(), spherical); ARR_EQ(position.getSpherical(), spherical); - ARR_EQ(position.get(LightAnchorType::Map, 0), {{ 0.34729638695716858, -1.9696154594421387, 2.384976127700611e-08 }}); - - ARR_NE(position.get(LightAnchorType::Map, 90), position.get(LightAnchorType::Viewport, 90)); - ARR_EQ(position.get(LightAnchorType::Map, 180), position.get(LightAnchorType::Map, 270)); + ARR_EQ(position.get(), {{ 0.34729638695716858, -1.9696154594421387, 2.384976127700611e-08 }}); ARR_NE(Position{{{ 2, 30, 10 }}}.getSpherical(), Position{{{ 2, 30, 370 }}}.getSpherical()); - ARR_EQ(Position{{{ 2, 30, 10 }}}.get(LightAnchorType::Map, 0), Position{{{ 2, 30, 370 }}}.get(LightAnchorType::Map, 0)); + ARR_EQ(Position{{{ 2, 30, 10 }}}.get(), Position{{{ 2, 30, 370 }}}.get()); position.set({{ 1, 80, 270 }}); ARR_NE(position.getSpherical(), spherical); - ARR_NE(position.get(LightAnchorType::Map, 0), {{ 0.34729638695716858, -1.9696154594421387, 2.384976127700611e-08 }}); - ARR_EQ(position.get(LightAnchorType::Map, 0), {{ 0.98480772972106934, -0.17364829778671265, 1.1924880638503055e-08 }}); + ARR_NE(position.get(), {{ 0.34729638695716858, -1.9696154594421387, 2.384976127700611e-08 }}); + ARR_EQ(position.get(), {{ 0.98480772972106934, -0.17364829778671265, 1.1924880638503055e-08 }}); } |