fixing is_colliding and centering translation.
This commit is contained in:
parent
05032d9760
commit
f129a92405
@ -375,10 +375,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool is_colliding(const Item& item) {
|
bool is_colliding(const Item& item) {
|
||||||
|
if(m_rtree.empty()) return false;
|
||||||
std::vector<SpatElement> result;
|
std::vector<SpatElement> result;
|
||||||
m_rtree.query(bgi::intersects(item.boundingBox()),
|
m_rtree.query(bgi::intersects(item.boundingBox()),
|
||||||
std::back_inserter(result));
|
std::back_inserter(result));
|
||||||
return result.empty();
|
return !result.empty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -870,7 +871,7 @@ void find_new_position(const Model &model,
|
|||||||
// Try to place items to the center
|
// Try to place items to the center
|
||||||
Item& itm = *shit;
|
Item& itm = *shit;
|
||||||
auto ibb = itm.boundingBox();
|
auto ibb = itm.boundingBox();
|
||||||
auto d = ibb.center() - binbb.center();
|
auto d = binbb.center() - ibb.center();
|
||||||
itm.translate(d);
|
itm.translate(d);
|
||||||
if(!arrange.is_colliding(itm)) {
|
if(!arrange.is_colliding(itm)) {
|
||||||
arrange.preload({{itm}});
|
arrange.preload({{itm}});
|
||||||
|
Loading…
Reference in New Issue
Block a user