Skip to content

Commit d64d4a4

Browse files
PointDistribution : Allow r-value references for functors, for lambdas
1 parent 00fbb69 commit d64d4a4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

include/IECore/PointDistribution.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class IECORE_API PointDistribution : public boost::noncopyable
8484
///
8585
/// pointEmitter is called for each point generated and must have the signature void( const Imath::V2f &pos ).
8686
template<typename DensityFunction, typename PointFunction>
87-
void operator () ( const Imath::Box2f &bounds, float density, DensityFunction &densitySampler, PointFunction &pointEmitter ) const;
87+
void operator () ( const Imath::Box2f &bounds, float density, DensityFunction &&densitySampler, PointFunction &&pointEmitter ) const;
8888
/// Variation on the function above for times when the density function isn't available to be evaluated on a point
8989
/// by point basis - perhaps because it is best evaluated in SIMD (as the IECoreRI::SXRenderer would do).
9090
///
@@ -94,7 +94,7 @@ class IECORE_API PointDistribution : public boost::noncopyable
9494
/// densityThreshold allows for deferred rejection of the points using a density function evaluated later - if the density evaluated
9595
/// is less than densityThreshold then that point should be rejected.
9696
template<typename PointFunction>
97-
void operator () ( const Imath::Box2f &bounds, float density, PointFunction &pointEmitter ) const;
97+
void operator () ( const Imath::Box2f &bounds, float density, PointFunction &&pointEmitter ) const;
9898

9999
/// Returns a reference to a static PointDistribution which can be shared by anyone who needs one. This
100100
/// distribution uses the tile set pointed to by the CORTEX_POINTDISTRIBUTION_TILESET environment variable.
@@ -108,10 +108,10 @@ class IECORE_API PointDistribution : public boost::noncopyable
108108
struct DensityThresholdedEmitter;
109109

110110
template<typename PointFunction>
111-
void processTile( const Tile &tile, const Imath::V2f &bottomLeft, const Imath::Box2f &bounds, float density, PointFunction &pointEmitter ) const;
111+
void processTile( const Tile &tile, const Imath::V2f &bottomLeft, const Imath::Box2f &bounds, float density, PointFunction &&pointEmitter ) const;
112112

113113
template<typename PointFunction>
114-
void recurseTile( const Tile &tile, const Imath::V2f &bottomLeft, unsigned level, const Imath::Box2f &bounds, float density, PointFunction &pointEmitter ) const;
114+
void recurseTile( const Tile &tile, const Imath::V2f &bottomLeft, unsigned level, const Imath::Box2f &bounds, float density, PointFunction &&pointEmitter ) const;
115115

116116
typedef std::vector<Tile> TileVector;
117117
TileVector m_tiles;

include/IECore/PointDistribution.inl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct PointDistribution::Tile
5656
template<typename DensityFunction, typename PointFunction>
5757
struct PointDistribution::DensityThresholdedEmitter
5858
{
59-
DensityThresholdedEmitter( DensityFunction &densitySampler, PointFunction &pointEmitter )
59+
DensityThresholdedEmitter( DensityFunction &&densitySampler, PointFunction &&pointEmitter )
6060
: m_densitySampler( densitySampler ), m_pointEmitter( pointEmitter )
6161
{
6262
}
@@ -77,14 +77,14 @@ struct PointDistribution::DensityThresholdedEmitter
7777
};
7878

7979
template<typename DensityFunction, typename PointFunction>
80-
void PointDistribution::operator () ( const Imath::Box2f &bounds, float density, DensityFunction &densitySampler, PointFunction &pointEmitter ) const
80+
void PointDistribution::operator () ( const Imath::Box2f &bounds, float density, DensityFunction &&densitySampler, PointFunction &&pointEmitter ) const
8181
{
8282
DensityThresholdedEmitter<DensityFunction, PointFunction> thresholdedEmitter( densitySampler, pointEmitter );
8383
(*this)( bounds, density, thresholdedEmitter );
8484
}
8585

8686
template<typename PointFunction>
87-
void PointDistribution::operator () ( const Imath::Box2f &bounds, float density, PointFunction &pointEmitter ) const
87+
void PointDistribution::operator () ( const Imath::Box2f &bounds, float density, PointFunction &&pointEmitter ) const
8888
{
8989
Imath::Box2i bi;
9090
bi.min.x = fastFloatFloor( bounds.min.x );
@@ -117,7 +117,7 @@ void PointDistribution::operator () ( const Imath::Box2f &bounds, float density,
117117
}
118118

119119
template<typename PointFunction>
120-
void PointDistribution::processTile( const Tile &tile, const Imath::V2f &bottomLeft, const Imath::Box2f &bounds, float density, PointFunction &pointEmitter ) const
120+
void PointDistribution::processTile( const Tile &tile, const Imath::V2f &bottomLeft, const Imath::Box2f &bounds, float density, PointFunction &&pointEmitter ) const
121121
{
122122
unsigned potentialPoints = std::min( tile.points.size(), (size_t)density );
123123
float factor = 1.0f / density;
@@ -136,7 +136,7 @@ void PointDistribution::processTile( const Tile &tile, const Imath::V2f &bottomL
136136
}
137137

138138
template<typename PointFunction>
139-
void PointDistribution::recurseTile( const Tile &tile, const Imath::V2f &bottomLeft, unsigned level, const Imath::Box2f &bounds, float density, PointFunction &pointEmitter ) const
139+
void PointDistribution::recurseTile( const Tile &tile, const Imath::V2f &bottomLeft, unsigned level, const Imath::Box2f &bounds, float density, PointFunction &&pointEmitter ) const
140140
{
141141
float tileSize = 1.0f / powf( (float)m_numSubTiles, (float)level );
142142

0 commit comments

Comments
 (0)