{
qDebug() << __PRETTY_FUNCTION__;
- QRect rect = sceneBoundingRect().toRect();
-
- // returned rect size is size of original image and not scaled to size of currently presented
- // image because of using ItemIgnoresTransformations flag. Thus the rect must be scaled
+ // picture side length used for collision detection
+ const int IMAGE_SIDE = 58;
int multiplier = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
+ int side = multiplier * IMAGE_SIDE;
- int heightDelta = (rect.height() * multiplier - rect.height()) / 2;
- int widthDelta = (rect.width() * multiplier - rect.width()) / 2;
+ QPoint center = pos().toPoint();
+ QPoint topLeft(center.x() - side / 2, center.y() - side / 2);
- return rect.adjusted(-widthDelta, -heightDelta, widthDelta, heightDelta);
+ return QRect(topLeft, QSize(side, side));
}
******************************************************************************/
public:
/**
- * @brief Return item sceneBoundingRect transformed to given zoom level
+ * @brief Return item rect transformed to given zoom level
*
* Because of using ItemIgnoresTransformations, and not scaling the item, the default
- * sceneBoundingRect does always return the lowest map tile level scene bounding rect which
- * is scaled to current zoom level.
+ * sceneBoundingRect can't be used because it always returns the lowest map tile level scene
+ * bounding rect. This method does return rect scaled to given zoom level.
*
* @param zoomLevel Zoom level for which the sceneBoundingRect should be transformed
* @return sceneBoundingRect transformed to given zoom level
m_zoomLevel = zoomLevel;
- mergeCollidingGroups();
- dropOutOfGroupFriends();
- checkAllGroupsForCollidingFriends();
- checkAllFriendsForCollidingFriends();
+ for (int repeat = 2; repeat > 0; repeat--) {
+ mergeCollidingGroups();
+ dropOutOfGroupFriends();
+ checkAllGroupsForCollidingFriends();
+ checkAllFriendsForCollidingFriends();
+ }
}
void FriendItemsHandler::updateFriendItem(FriendLocationItem *friendItem, User *friendData)