Revision ffc7ccd5
Added by Leszek Koltunski 12 months ago
src/main/java/org/distorted/objectlib/helpers/FactoryBandaged.java | ||
---|---|---|
459 | 459 |
|
460 | 460 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
461 | 461 |
|
462 |
private void buildSection(int ax, boolean left, boolean[] walls, ArrayList<float[][]> list, boolean debug)
|
|
462 |
private void buildAllSections(int ax, boolean left, boolean[] walls, ArrayList<float[][]> list)
|
|
463 | 463 |
{ |
464 | 464 |
int numElements = 0; |
465 | 465 |
for(int i=0; i<mNumElements; i++) |
466 | 466 |
if( walls[i] ) numElements++; |
467 | 467 |
|
468 |
boolean showDebug = ( ax==2 && !left && debug ); |
|
469 |
|
|
470 |
if( showDebug ) |
|
471 |
{ |
|
472 |
for(int i=0; i<mNumElements; i++) |
|
473 |
android.util.Log.e("D", "element "+i+" walls: "+walls[i]); |
|
474 |
} |
|
475 |
|
|
476 | 468 |
int[] tmp = new int[numElements]; |
477 | 469 |
|
478 | 470 |
while( numElements>0 ) |
... | ... | |
487 | 479 |
break; |
488 | 480 |
} |
489 | 481 |
|
490 |
int found = computeConnectedSection(element,ax,walls,tmp,1);
|
|
482 |
int elementsInSection = computeConnectedSection(element,ax,walls,tmp,1);
|
|
491 | 483 |
|
492 |
float[][] newSection = new float[found][];
|
|
484 |
float[][] newSection = new float[elementsInSection][];
|
|
493 | 485 |
|
494 |
for(int i=0; i<found; i++)
|
|
486 |
for(int i=0; i<elementsInSection; i++)
|
|
495 | 487 |
newSection[i] = elementVertices(ax,left,tmp[i]); |
496 | 488 |
|
497 |
if( showDebug ) |
|
498 |
{ |
|
499 |
android.util.Log.e("D", "numFound="+found); |
|
500 |
|
|
501 |
for(int i=0; i<found; i++) |
|
502 |
{ |
|
503 |
float[] s = newSection[i]; |
|
504 |
android.util.Log.e("D", "found: "+i+" first vertex: "+s[0]+" "+s[1]+" "+s[2]); |
|
505 |
} |
|
506 |
} |
|
507 |
|
|
508 | 489 |
list.add(newSection); |
509 | 490 |
|
510 |
numElements -= found;
|
|
491 |
numElements -= elementsInSection;
|
|
511 | 492 |
} |
512 | 493 |
} |
513 | 494 |
|
514 | 495 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
515 | 496 |
|
516 |
private void fillUpVertexArray(int length)
|
|
497 |
private void fillUpVertexArray() |
|
517 | 498 |
{ |
518 | 499 |
boolean[][][] walls = new boolean[mNumAxis][2][mNumElements]; |
519 | 500 |
|
520 | 501 |
int[] tmp = new int[mNumAxis]; |
521 | 502 |
|
522 |
if( length>3 ) |
|
523 |
for(int e=0; e<mNumElements; e++) |
|
524 |
{ |
|
525 |
float[] p = mElements[e].getPos(); |
|
526 |
android.util.Log.e("D", "element "+e+" : "+p[0]+" "+p[1]+" "+p[2]); |
|
527 |
} |
|
528 |
|
|
529 | 503 |
for(int e=0; e<mNumElements; e++) |
530 | 504 |
{ |
531 | 505 |
int[] row = mElements[e].getRotRow(); |
... | ... | |
543 | 517 |
|
544 | 518 |
for(int a=0; a<mNumAxis; a++) |
545 | 519 |
{ |
546 |
buildSection(a, true, walls[a][0], mVertexArray, length>3 );
|
|
547 |
buildSection(a, false, walls[a][1], mVertexArray, length>3 );
|
|
520 |
buildAllSections(a, true, walls[a][0], mVertexArray );
|
|
521 |
buildAllSections(a, false, walls[a][1], mVertexArray );
|
|
548 | 522 |
} |
549 | 523 |
} |
550 | 524 |
|
... | ... | |
644 | 618 |
mElements = new BandagedElement[mNumElements]; |
645 | 619 |
for(int i=0; i<mNumElements; i++) mElements[i] = new BandagedElement(pos, 3*i, mRotAxis, mCuts); |
646 | 620 |
|
647 |
fillUpVertexArray(pos.length);
|
|
621 |
fillUpVertexArray(); |
|
648 | 622 |
|
649 | 623 |
computeMove(pos,variant); |
650 | 624 |
float[][] verts = getVertices(mVertexArray,variant); |
Also available in: Unified diff
Minor.