Scatter brush fixes

This commit is contained in:
Jesse Boyd 2017-04-20 03:44:28 +10:00
parent 89a0a44d14
commit 92fef6f5da
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.object.PseudoRandom;
import com.boydti.fawe.object.collection.BlockVectorSet; import com.boydti.fawe.object.collection.BlockVectorSet;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
@ -46,6 +47,11 @@ public class ScatterBrush implements Brush {
this.mask = Masks.alwaysTrue(); this.mask = Masks.alwaysTrue();
} }
this.adjacent = new AdjacentAnyMask(editSession, Arrays.asList(new BaseBlock(0))); this.adjacent = new AdjacentAnyMask(editSession, Arrays.asList(new BaseBlock(0)));
for (int id = 0; id < 256; id++) {
if (FaweCache.canPassThrough(id, 0)) {
adjacent.add(new BaseBlock(id, -1));
}
}
final SolidBlockMask solid = new SolidBlockMask(editSession); final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size); final RadiusMask radius = new RadiusMask(0, (int) size);
@ -57,6 +63,10 @@ public class ScatterBrush implements Brush {
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
BlockVectorSet visited = visitor.getVisited(); BlockVectorSet visited = visitor.getVisited();
int length = visited.size(); int length = visited.size();
if (size == 0) {
length = 1;
visited.add(position);
}
LocalBlockVectorSet placed = new LocalBlockVectorSet(); LocalBlockVectorSet placed = new LocalBlockVectorSet();
int maxFails = 1000; int maxFails = 1000;

View File

@ -52,7 +52,7 @@ public class BlockVectorSet extends AbstractCollection<Vector> implements Set<Ve
return pos; return pos;
} }
} }
count = newSize; count += newSize;
} }
return null; return null;
} }

View File

@ -106,7 +106,7 @@ public class LocalBlockVectorSet implements Set<Vector> {
return null; return null;
} }
int index = -1; int index = -1;
for (int i = 0; i < getIndex; i++) { for (int i = 0; i <= getIndex; i++) {
index = set.nextSetBit(index + 1); index = set.nextSetBit(index + 1);
} }
if (index != -1) { if (index != -1) {