Skip to content

Commit 97bf5cc

Browse files
MeshAlgo::distributePoints : Consistent handling of points at density thresh
1 parent 2922055 commit 97bf5cc

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/IECoreScene/MeshAlgoDistributePoints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void distributePointsInTriangle(
294294
if( densityView )
295295
{
296296
float d = triangleInterpolatedPrimVarValue( densityInterpolation, densityView, vertexIds, faceIdx, bary );
297-
if( d < densityThreshold )
297+
if( d <= densityThreshold )
298298
{
299299
return;
300300
}

test/IECoreScene/MeshAlgoDistributePointsTest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ def testDensityMaskPrimVar( self ) :
135135
p = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = 1000 )
136136
self.assertEqual( p.numPoints, 0 )
137137

138+
def testDensityMatches( self ):
139+
# Make sure that for exactly representable densities, setting the density using a primvar
140+
# yields the same result as setting it with an argument ( this checks for a previous situation
141+
# where PointDistribution used an exclusive threshold, but distributePoints used an inclusive
142+
# threshold when comparing to a primvar )
143+
m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ), imath.V2i( 1 ) )
144+
p1 = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = 128 )
145+
146+
m['density'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.FloatVectorData( [ 0.25 ] ) )
147+
p2 = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = 512 )
148+
149+
self.assertEqual( p1, p2 )
150+
138151
def testOffsetParameter( self ) :
139152

140153
m = IECore.Reader.create( os.path.join( "test", "IECore", "data", "cobFiles", "pCubeShape1.cob" ) ).read()

0 commit comments

Comments
 (0)