[core] JoinType ⇢ LineJoinType
This commit is contained in:
@@ -70,7 +70,7 @@ MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, {
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class JoinType : uint8_t {
|
||||
enum class LineJoinType : uint8_t {
|
||||
Miter,
|
||||
Bevel,
|
||||
Round,
|
||||
@@ -79,12 +79,12 @@ enum class JoinType : uint8_t {
|
||||
FlipBevel
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(JoinTypeClass, JoinType, {
|
||||
{ JoinType::Miter, "miter" },
|
||||
{ JoinType::Bevel, "bevel" },
|
||||
{ JoinType::Round, "round" },
|
||||
{ JoinType::FakeRound, "fakeround" },
|
||||
{ JoinType::FlipBevel, "flipbevel" },
|
||||
MBGL_DEFINE_ENUM_CLASS(LineJoinTypeClass, LineJoinType, {
|
||||
{ LineJoinType::Miter, "miter" },
|
||||
{ LineJoinType::Bevel, "bevel" },
|
||||
{ LineJoinType::Round, "round" },
|
||||
{ LineJoinType::FakeRound, "fakeround" },
|
||||
{ LineJoinType::FlipBevel, "flipbevel" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -31,7 +31,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) {
|
||||
type = geojsonvt::ProjectedFeatureType::LineString;
|
||||
|
||||
std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>();
|
||||
layer->layout.join = JoinType::Round;
|
||||
layer->layout.join = LineJoinType::Round;
|
||||
|
||||
const LineAnnotationProperties& properties = shape.properties.get<LineAnnotationProperties>();
|
||||
layer->paint.opacity = properties.opacity;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mbgl {
|
||||
class LineLayoutProperties {
|
||||
public:
|
||||
LayoutProperty<LineCapType> cap { LineCapType::Butt };
|
||||
LayoutProperty<JoinType> join { JoinType::Miter };
|
||||
LayoutProperty<LineJoinType> join { LineJoinType::Miter };
|
||||
LayoutProperty<float> miterLimit { 2.0f };
|
||||
LayoutProperty<float> roundLimit { 1.0f };
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
|
||||
return;
|
||||
}
|
||||
|
||||
const float miterLimit = layout.join == JoinType::Bevel ? 1.05f : float(layout.miterLimit);
|
||||
const float miterLimit = layout.join == LineJoinType::Bevel ? 1.05f : float(layout.miterLimit);
|
||||
|
||||
const double sharpCornerOffset = SHARP_CORNER_OFFSET * (float(util::EXTENT) / (util::tileSize * overscaling));
|
||||
|
||||
@@ -172,33 +172,33 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
|
||||
|
||||
// The join if a middle vertex, otherwise the cap
|
||||
const bool middleVertex = prevVertex && nextVertex;
|
||||
JoinType currentJoin = layout.join;
|
||||
LineJoinType currentJoin = layout.join;
|
||||
const LineCapType currentCap = nextVertex ? beginCap : endCap;
|
||||
|
||||
if (middleVertex) {
|
||||
if (currentJoin == JoinType::Round) {
|
||||
if (currentJoin == LineJoinType::Round) {
|
||||
if (miterLength < layout.roundLimit) {
|
||||
currentJoin = JoinType::Miter;
|
||||
currentJoin = LineJoinType::Miter;
|
||||
} else if (miterLength <= 2) {
|
||||
currentJoin = JoinType::FakeRound;
|
||||
currentJoin = LineJoinType::FakeRound;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentJoin == JoinType::Miter && miterLength > miterLimit) {
|
||||
currentJoin = JoinType::Bevel;
|
||||
if (currentJoin == LineJoinType::Miter && miterLength > miterLimit) {
|
||||
currentJoin = LineJoinType::Bevel;
|
||||
}
|
||||
|
||||
if (currentJoin == JoinType::Bevel) {
|
||||
if (currentJoin == LineJoinType::Bevel) {
|
||||
// The maximum extrude length is 128 / 63 = 2 times the width of the line
|
||||
// so if miterLength >= 2 we need to draw a different type of bevel where.
|
||||
if (miterLength > 2) {
|
||||
currentJoin = JoinType::FlipBevel;
|
||||
currentJoin = LineJoinType::FlipBevel;
|
||||
}
|
||||
|
||||
// If the miterLength is really small and the line bevel wouldn't be visible,
|
||||
// just draw a miter join to save a triangle.
|
||||
if (miterLength < miterLimit) {
|
||||
currentJoin = JoinType::Miter;
|
||||
currentJoin = LineJoinType::Miter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,12 +207,12 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
|
||||
if (prevVertex)
|
||||
distance += util::dist<double>(currentVertex, prevVertex);
|
||||
|
||||
if (middleVertex && currentJoin == JoinType::Miter) {
|
||||
if (middleVertex && currentJoin == LineJoinType::Miter) {
|
||||
joinNormal = joinNormal * miterLength;
|
||||
addCurrentVertex(currentVertex, distance, joinNormal, 0, 0, false, startVertex,
|
||||
triangleStore);
|
||||
|
||||
} else if (middleVertex && currentJoin == JoinType::FlipBevel) {
|
||||
} else if (middleVertex && currentJoin == LineJoinType::FlipBevel) {
|
||||
// miter is too big, flip the direction to make a beveled join
|
||||
|
||||
if (miterLength > 100) {
|
||||
@@ -230,7 +230,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
|
||||
|
||||
addCurrentVertex(currentVertex, distance, joinNormal * -1.0, 0, 0, false, startVertex,
|
||||
triangleStore);
|
||||
} else if (middleVertex && (currentJoin == JoinType::Bevel || currentJoin == JoinType::FakeRound)) {
|
||||
} else if (middleVertex && (currentJoin == LineJoinType::Bevel || currentJoin == LineJoinType::FakeRound)) {
|
||||
const bool lineTurnsLeft = (prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x) > 0;
|
||||
const float offset = -std::sqrt(miterLength * miterLength - 1);
|
||||
float offsetA;
|
||||
@@ -250,7 +250,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
|
||||
startVertex, triangleStore);
|
||||
}
|
||||
|
||||
if (currentJoin == JoinType::FakeRound) {
|
||||
if (currentJoin == LineJoinType::FakeRound) {
|
||||
// The join angle is sharp enough that a round join would be visible.
|
||||
// Bevel joins fill the gap between segments with a single pie slice triangle.
|
||||
// Create a round join by adding multiple pie slices. The join isn't actually round, but
|
||||
@@ -308,7 +308,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
|
||||
startVertex, triangleStore);
|
||||
}
|
||||
|
||||
} else if (middleVertex ? currentJoin == JoinType::Round : currentCap == LineCapType::Round) {
|
||||
} else if (middleVertex ? currentJoin == LineJoinType::Round : currentCap == LineCapType::Round) {
|
||||
if (!startOfLine) {
|
||||
// Close previous segment with a butt
|
||||
addCurrentVertex(currentVertex, distance, prevNormal, 0, 0, false,
|
||||
|
||||
@@ -20,7 +20,7 @@ template <> inline std:: string defaultStopsValue() { return {}; }
|
||||
template <> inline TranslateAnchorType defaultStopsValue() { return {}; };
|
||||
template <> inline RotateAnchorType defaultStopsValue() { return {}; };
|
||||
template <> inline LineCapType defaultStopsValue() { return {}; };
|
||||
template <> inline JoinType defaultStopsValue() { return {}; };
|
||||
template <> inline LineJoinType defaultStopsValue() { return {}; };
|
||||
template <> inline PlacementType defaultStopsValue() { return {}; };
|
||||
template <> inline TextAnchorType defaultStopsValue() { return {}; };
|
||||
template <> inline TextJustifyType defaultStopsValue() { return {}; };
|
||||
@@ -85,7 +85,7 @@ template class Function<std::string>;
|
||||
template class Function<TranslateAnchorType>;
|
||||
template class Function<RotateAnchorType>;
|
||||
template class Function<LineCapType>;
|
||||
template class Function<JoinType>;
|
||||
template class Function<LineJoinType>;
|
||||
template class Function<PlacementType>;
|
||||
template class Function<TextAnchorType>;
|
||||
template class Function<TextJustifyType>;
|
||||
|
||||
@@ -111,13 +111,13 @@ optional<LineCapType> parseProperty<LineCapType>(const char* name, const JSValue
|
||||
}
|
||||
|
||||
template <>
|
||||
optional<JoinType> parseProperty<JoinType>(const char* name, const JSValue& value) {
|
||||
optional<LineJoinType> parseProperty<LineJoinType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
|
||||
return {};
|
||||
}
|
||||
|
||||
return { JoinTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
return { LineJoinTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -326,8 +326,8 @@ template <> optional<Function<LineCapType>> parseProperty(const char* name, cons
|
||||
return parseFunction<LineCapType>(name, value);
|
||||
}
|
||||
|
||||
template <> optional<Function<JoinType>> parseProperty(const char* name, const JSValue& value) {
|
||||
return parseFunction<JoinType>(name, value);
|
||||
template <> optional<Function<LineJoinType>> parseProperty(const char* name, const JSValue& value) {
|
||||
return parseFunction<LineJoinType>(name, value);
|
||||
}
|
||||
|
||||
template <> optional<Function<PlacementType>> parseProperty(const char* name, const JSValue& value) {
|
||||
|
||||
@@ -39,7 +39,7 @@ template<> inline std::string interpolate(const std::string a, const std::string
|
||||
template<> inline TranslateAnchorType interpolate(const TranslateAnchorType a, const TranslateAnchorType, const double) { return a; }
|
||||
template<> inline RotateAnchorType interpolate(const RotateAnchorType a, const RotateAnchorType, const double) { return a; }
|
||||
template<> inline LineCapType interpolate(const LineCapType a, const LineCapType, const double) { return a; }
|
||||
template<> inline JoinType interpolate(const JoinType a, const JoinType, const double) { return a; }
|
||||
template<> inline LineJoinType interpolate(const LineJoinType a, const LineJoinType, const double) { return a; }
|
||||
template<> inline PlacementType interpolate(const PlacementType a, const PlacementType, const double) { return a; }
|
||||
template<> inline TextAnchorType interpolate(const TextAnchorType a, const TextAnchorType, const double) { return a; }
|
||||
template<> inline TextJustifyType interpolate(const TextJustifyType a, const TextJustifyType, const double) { return a; }
|
||||
|
||||
Reference in New Issue
Block a user