Improved memory usage in traffic renderer

This commit is contained in:
r.kuznetsov 2016-11-24 18:18:14 +03:00
parent 1e2abf5883
commit 32adcf92e3
4 changed files with 14 additions and 7 deletions

View file

@ -345,7 +345,9 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
case Message::FlushTrafficGeometry:
{
ref_ptr<FlushTrafficGeometryMessage> msg = message;
m_trafficGenerator->FlushSegmentsGeometry(msg->GetKey(), msg->GetSegments(), m_texMng);
auto const & tileKey = msg->GetKey();
if (m_requestedTiles->CheckTileKey(tileKey) && m_readManager->CheckTileKey(tileKey))
m_trafficGenerator->FlushSegmentsGeometry(tileKey, msg->GetSegments(), m_texMng);
break;
}

View file

@ -192,6 +192,7 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg
state.SetMaskTexture(textures->GetTrafficArrowTexture());
static vector<RoadClass> roadClasses = {RoadClass::Class0, RoadClass::Class1, RoadClass::Class2};
static const int kGenerateCapsZoomLevel[] = {13, 14, 16};
for (auto geomIt = geom.begin(); geomIt != geom.end(); ++geomIt)
{
@ -208,6 +209,10 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg
auto segmentColoringIt = coloring.find(sid);
if (segmentColoringIt != coloring.end())
{
// We do not generate geometry for unknown segments.
if (segmentColoringIt->second == traffic::SpeedGroup::Unknown)
continue;
TrafficSegmentGeometry const & g = geomIt->second[i].second;
ref_ptr<dp::Batcher> batcher = m_batchersPool->GetBatcher(TrafficBatcherKey(geomIt->first, tileKey, g.m_roadClass));
@ -216,7 +221,7 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg
vector<TrafficStaticVertex> staticGeometry;
vector<TrafficDynamicVertex> dynamicGeometry;
bool const generateCaps = (tileKey.m_zoomLevel > kOutlineMinZoomLevel);
bool const generateCaps = (tileKey.m_zoomLevel > kGenerateCapsZoomLevel[static_cast<uint32_t>(g.m_roadClass)]);
GenerateSegment(colorRegion, g.m_polyline, tileKey.GetGlobalRect().Center(), generateCaps, staticGeometry, dynamicGeometry);
ASSERT_EQUAL(staticGeometry.size(), dynamicGeometry.size(), ());

View file

@ -35,8 +35,7 @@ enum class RoadClass : uint8_t
int constexpr kRoadClass0ZoomLevel = 10;
int constexpr kRoadClass1ZoomLevel = 12;
int constexpr kRoadClass2ZoomLevel = 14;
int constexpr kOutlineMinZoomLevel = 13;
int constexpr kRoadClass2ZoomLevel = 15;
struct TrafficSegmentID
{

View file

@ -19,8 +19,9 @@ namespace df
namespace
{
int const kMinVisibleArrowZoomLevel = 16;
int const kRoadClass2MinVisibleArrowZoomLevel = 17;
int constexpr kMinVisibleArrowZoomLevel = 16;
int constexpr kRoadClass2MinVisibleArrowZoomLevel = 17;
int constexpr kOutlineMinZoomLevel = 13;
float const kTrafficArrowAspect = 24.0f / 8.0f;
@ -53,7 +54,7 @@ float const kRoadClass2WidthScalar[] =
// 1 2 3 4 5 6 7 8 9 10
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
//11 12 13 14 15 16 17 18 19 20
0.0f, 0.0f, 0.0f, 0.2f, 0.3f, 0.5f, 0.7f, 0.8f, 0.9f, 1.0f
0.0f, 0.0f, 0.0f, 0.0f, 0.3f, 0.5f, 0.7f, 0.8f, 0.9f, 1.0f
};
float CalculateHalfWidth(ScreenBase const & screen, RoadClass const & roadClass, bool left)