Make ClumpPlacer determine the correct fraction of failed attempts to place points
Comments by: @smiley, @elexis Patch by: @Inari Fixes #5092 Differential Revision: https://code.wildfiregames.com/D1414 This was SVN commit r26503.
This commit is contained in:
parent
1ff3b45a1e
commit
a04ad0beb2
@ -75,12 +75,14 @@ ClumpPlacer.prototype.place = function(constraint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
let failed = 0;
|
let failed = 0;
|
||||||
|
let count = 0;
|
||||||
for (let stepAngle = 0; stepAngle < intPerim; ++stepAngle)
|
for (let stepAngle = 0; stepAngle < intPerim; ++stepAngle)
|
||||||
{
|
{
|
||||||
let position = this.centerPosition.clone();
|
let position = this.centerPosition.clone();
|
||||||
let radiusUnitVector = new Vector2D(0, 1).rotate(-2 * Math.PI * stepAngle / perim);
|
let radiusUnitVector = new Vector2D(0, 1).rotate(-2 * Math.PI * stepAngle / perim);
|
||||||
let maxRadiusSteps = Math.ceil(radius * (1 + (1 - this.coherence) * noise[stepAngle]));
|
let maxRadiusSteps = Math.ceil(radius * (1 + (1 - this.coherence) * noise[stepAngle]));
|
||||||
|
|
||||||
|
count += maxRadiusSteps;
|
||||||
for (let stepRadius = 0; stepRadius < maxRadiusSteps; ++stepRadius)
|
for (let stepRadius = 0; stepRadius < maxRadiusSteps; ++stepRadius)
|
||||||
{
|
{
|
||||||
let tilePos = position.clone().floor();
|
let tilePos = position.clone().floor();
|
||||||
@ -100,5 +102,5 @@ ClumpPlacer.prototype.place = function(constraint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return failed > this.size * this.failFraction ? undefined : points;
|
return failed > count * this.failFraction ? undefined : points;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user