Fix threading issues.
This commit is contained in:
parent
6b64e29689
commit
9642d25c34
@ -33,8 +33,8 @@ public class Panel extends JPanel implements Runnable {
|
||||
private MemoryImageSource mImageProducer;
|
||||
private ColorModel cm;
|
||||
private Thread thread;
|
||||
Thread[] workerThread = new Thread[8];
|
||||
String[][] keySets = new String[8][];
|
||||
Thread[] workerThread = new Thread[9];
|
||||
String[][] keySets = new String[9][];
|
||||
ConcurrentLinkedQueue<Triangle> newTris = new ConcurrentLinkedQueue<>();
|
||||
List<Triangle> accumulatedTris = new ArrayList<Triangle>();
|
||||
public static ConcurrentLinkedQueue<Triangle> accumulatedTris1 = new ConcurrentLinkedQueue<>();
|
||||
@ -134,15 +134,7 @@ public class Panel extends JPanel implements Runnable {
|
||||
int currentSet=0;
|
||||
for (String key : SigRenderer.blockGrid.keySet()) {
|
||||
if (currentPiece==0) {
|
||||
if (currentSet==7) {
|
||||
if (SigRenderer.blockGrid.size()%8==0) {
|
||||
keySets[currentSet] = new String[pieces];
|
||||
} else {
|
||||
keySets[currentSet] = new String[SigRenderer.blockGrid.size()%8];
|
||||
}
|
||||
} else {
|
||||
keySets[currentSet] = new String[pieces];
|
||||
}
|
||||
}
|
||||
keySets[currentSet][currentPiece]=key;
|
||||
currentPiece++;
|
||||
@ -167,18 +159,24 @@ public class Panel extends JPanel implements Runnable {
|
||||
accumulatedTris1.clear();
|
||||
}
|
||||
final Matrix matWorld2 = matWorld;
|
||||
for (int i=0;i<8;i++) {
|
||||
for (int i=0;i<9;i++) {
|
||||
final int id=i;
|
||||
workerThread[i] = new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
ConcurrentLinkedQueue<Triangle> newTris = new ConcurrentLinkedQueue<>();
|
||||
if (keySets[id]!=null) {
|
||||
for (String key : keySets[id]) {
|
||||
if (key!=null) {
|
||||
Block b = SigRenderer.blockGrid.get(key);
|
||||
if (b!=null) {
|
||||
for (Triangle t : b.block.prepareRender(b)) {
|
||||
prepareTriForRender(matWorld2, matView, t, newTris);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (renderFirst) {
|
||||
accumulatedTris2.addAll(newTris);
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ public class SigRenderer implements WindowFocusListener,KeyListener,MouseListene
|
||||
|
||||
public static boolean windowActive=true;
|
||||
public static boolean WIREFRAME = false;
|
||||
public static boolean PROFILING = true;
|
||||
public static boolean PROFILING = false;
|
||||
public static boolean FLYING_MODE = false;
|
||||
public static int SCREEN_WIDTH=1280;
|
||||
public static int SCREEN_HEIGHT=720;
|
||||
@ -402,8 +402,6 @@ public class SigRenderer implements WindowFocusListener,KeyListener,MouseListene
|
||||
for (int x=0;x<64;x++) {
|
||||
for (int z=0;z<64;z++) {
|
||||
addBlock(new Vector(x,0,z),Cube.class,BlockType.SOIL_WET,FacingDirection.SOUTH);
|
||||
addBlock(new Vector(x,1,z),Plant.class,BlockType.valueOf("WHEAT_"+(r.nextInt(7))),FacingDirection.SOUTH);
|
||||
|
||||
//addBlock(new Vector(x,1,z),Staircase.class,BlockType.JUNGLE_PLANK,FacingDirection.SOUTH);
|
||||
//addBlock(new Vector(x,2,z),Staircase.class,BlockType.SPRUCE_PLANK,FacingDirection.SOUTH);
|
||||
/*for (int y=1;y<r.nextInt(5);y++) {
|
||||
@ -430,6 +428,7 @@ public class SigRenderer implements WindowFocusListener,KeyListener,MouseListene
|
||||
}*/
|
||||
}
|
||||
}
|
||||
addBlock(new Vector(31,1,31),Plant.class,BlockType.valueOf("WHEAT_"+(r.nextInt(7))),FacingDirection.SOUTH);
|
||||
/*addBlock(new Vector(31,2,32),Staircase.class,BlockType.PLANKS,FacingDirection.EAST);
|
||||
addBlock(new Vector(31,3,33),Staircase.class,BlockType.PLANKS,FacingDirection.WEST);
|
||||
addBlock(new Vector(31,4,34),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
|
||||
|
Loading…
x
Reference in New Issue
Block a user