Removed sorting when triangulating
Properly determine the insertion edge when triangulation to avoid having to sort each vertex later Synchronize the plane viewer to prevent incorrect index saving when switching planes too quickly Use the shape instead of collision shape for summoned physics objects
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
@@ -83,6 +84,8 @@ public class MeshingTest2 extends JPanel {
|
||||
private JLabel statusBar;
|
||||
private JComboBox< String > selectionBox;
|
||||
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
public static void main( String[] args ) {
|
||||
if ( CHUNK_DIR.exists() && CHUNK_DIR.isDirectory() ) {
|
||||
System.out.println( "Found " + CHUNK_DIR.list().length + " files" );
|
||||
@@ -129,7 +132,7 @@ public class MeshingTest2 extends JPanel {
|
||||
// break;
|
||||
// }
|
||||
|
||||
List< Plane > masterPlanes = new ArrayList< Plane >();
|
||||
final List< Plane > masterPlanes = new ArrayList< Plane >();
|
||||
System.out.println( "Chunk files: " + CHUNK_DIR.listFiles().length );
|
||||
int limit = 1;
|
||||
for ( File file : CHUNK_DIR.listFiles() ) {
|
||||
@@ -140,8 +143,9 @@ public class MeshingTest2 extends JPanel {
|
||||
System.out.println( "Remaining: " + limit );
|
||||
}
|
||||
}
|
||||
// final List< Plane > planes = mesh( new File( CHUNK_DIR, "world,-4,-6" ) );
|
||||
// masterPlanes.add( planes.get( 177 ) );
|
||||
|
||||
// final List< Plane > planes = mesh( new File( CHUNK_DIR, "world,-1,-1" ) );
|
||||
// masterPlanes.add( planes.get( 20 ) );
|
||||
// masterPlanes.addAll( planes );
|
||||
|
||||
// masterPlanes.add( getTestPlane() );
|
||||
@@ -679,23 +683,24 @@ public class MeshingTest2 extends JPanel {
|
||||
}
|
||||
|
||||
private MeshingTest2 setIndex( final int index ) {
|
||||
// TODO Synchronize this
|
||||
final int planeCount = planes.size();
|
||||
final int newIndex = ( ( ( index % planeCount ) + planeCount ) % planeCount );
|
||||
lock.lock();
|
||||
if ( this.index != newIndex ) {
|
||||
this.index = newIndex;
|
||||
|
||||
new Thread( () -> { getData( this::repaint ); } ).start();
|
||||
|
||||
if ( selectionBox != null ) {
|
||||
selectionBox.setSelectedIndex( newIndex );
|
||||
}
|
||||
|
||||
new Thread( () -> { getData( this.index, this::repaint ); } ).start();
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private PlaneData getData( final Runnable callback ) {
|
||||
private PlaneData getData( final int index, final Runnable callback ) {
|
||||
if ( data[ index ] != null ) {
|
||||
callback.run();
|
||||
return data[ index ];
|
||||
|
||||
Reference in New Issue
Block a user