start porting CollisionTile and CollisionFeature

This commit is contained in:
Ansis Brammanis
2015-03-31 18:53:49 -07:00
parent 128ed1f26f
commit 8fd42f371f
6 changed files with 193 additions and 6 deletions

View File

@@ -0,0 +1,31 @@
#include <mbgl/text/collision_tile.hpp>
#include <cmath>
namespace mbgl {
void CollisionTile::reset(const float _angle, const float pitch) {
tree.clear();
angle = _angle;
// Compute the transformation matrix.
float angle_sin = std::sin(_angle);
float angle_cos = std::cos(_angle);
matrix = {{angle_cos, -angle_sin, angle_sin, angle_cos}};
// Stretch boxes in y direction to account for the map tilt.
const float _yStretch = 1.0f / std::cos(pitch / 180 * M_PI);
// The amount the map is squished depends on the y position.
// Sort of account for this by making all boxes a bit bigger.
yStretch = std::pow(_yStretch, 1.3);
}
void CollisionTile::placeFeature(CollisionFeature &) {
//void CollisionTile::placeFeature(CollisionFeature &feature) {
}
void CollisionTile::insertFeature(CollisionFeature &, const float ) {
//void CollisionTile::insertFeature(CollisionFeature &feature, const float minPlacementScale) {
}
}