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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user