16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 07:49:19 +02:00

lazy bounding radius computing for shape_node (avoids O(n^2) deserialization)

This commit is contained in:
milek7
2019-01-12 01:40:22 +01:00
parent 7167771ee6
commit b6e280f14d
3 changed files with 18 additions and 5 deletions

View File

@@ -259,7 +259,7 @@ basic_cell::insert( shape_node Shape ) {
// re-calculate cell radius, in case shape geometry extends outside the cell's boundaries
m_area.radius = std::max<float>(
m_area.radius,
glm::length( m_area.center - Shape.data().area.center ) + Shape.data().area.radius );
glm::length( m_area.center - Shape.data().area.center ) + Shape.radius() );
auto const &shapedata { Shape.data() };
auto &shapes = (
@@ -1230,7 +1230,7 @@ basic_region::insert( shape_node Shape, scratch_data &Scratchpad, bool const Tra
// move the data into appropriate section(s)
for( auto &shape : shapes ) {
// with the potential splitting done we can calculate each chunk's bounding radius
shape.compute_radius();
shape.invalidate_radius();
if( point_inside( shape.m_data.area.center ) ) {
// NOTE: nodes placed outside of region boundaries are discarded
section( shape.m_data.area.center ).insert( shape );