Merge branch 'milek-dev' into gfx-work

This commit is contained in:
milek7
2019-01-12 02:23:32 +01:00
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 = (
@@ -1248,7 +1248,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 );

View File

@@ -407,8 +407,7 @@ shape_node::merge( shape_node &Shape ) {
m_data.vertices.insert(
std::end( m_data.vertices ),
std::begin( Shape.m_data.vertices ), std::end( Shape.m_data.vertices ) );
// NOTE: we could recalculate radius with something other than brute force, but it'll do
compute_radius();
invalidate_radius();
return true;
}
@@ -442,7 +441,16 @@ shape_node::compute_radius() {
m_data.area.radius = static_cast<float>( std::sqrt( squaredradius ) );
}
void shape_node::invalidate_radius() {
m_data.area.radius = -1.0f;
}
float shape_node::radius() {
if (m_data.area.radius == -1.0f)
compute_radius();
return m_data.area.radius;
}
// sends content of the struct to provided stream
void

View File

@@ -127,7 +127,10 @@ public:
create_geometry( gfx::geometrybank_handle const &Bank );
// calculates shape's bounding radius
void
compute_radius();
compute_radius();
// invalidates shape's bounding radius
void
invalidate_radius();
// set visibility
void
visible( bool State );
@@ -137,6 +140,8 @@ public:
// data access
shapenode_data const &
data() const;
// get bounding radius
float radius();
private:
// members