Project

General

Profile

« Previous | Next » 

Revision 20156af7

Added by Leszek Koltunski about 6 years ago

Important bugfix in MeshCubes for the Inflate vectors.

View differences:

src/main/java/org/distorted/library/main/EffectQueueMatrix.java
107 107
    // Here we need a bit more because we are marking not only the halo, but a little bit around
108 108
    // it as well so that the (blur for example) will be smooth on the edges. Thus the 2.0f.
109 109
    //
110
    // mMipmap ( 1.0 , 0.5, 0.25, 0.125 ) - we need to make the size of the halo independent
110
    // mMipmap ( 1.0, 0.5, 0.25, 0.125 ) - we need to make the size of the halo independent
111 111
    // of postprocessing effect quality.
112 112

  
113 113
    return projection.mMipmap*2.0f*marginInPixels/( xLenInPixels>yLenInPixels ? yLenInPixels:xLenInPixels );
src/main/java/org/distorted/library/mesh/MeshCubes.java
194 194
       mInflateX = new byte[mRows+1][mCols+1];
195 195
       mInflateY = new byte[mRows+1][mCols+1];
196 196

  
197
       for(int j=0; j<mCols; j++)
198
         for(int i=0; i<mRows; i++)
199
           mCubes[i][j] = (desc.charAt(i * mCols + j) == '1' ? 1 : 0);
197
       for(int col=0; col<mCols; col++)
198
         for(int row=0; row<mRows; row++)
199
           mCubes[row][col] = (desc.charAt(row * mCols + col) == '1' ? 1 : 0);
200 200

  
201
       for(int j=0; j<mCols+1; j++)
202
         for(int i=0; i<mRows+1; i++)
201
       for(int col=0; col<mCols+1; col++)
202
         for(int row=0; row<mRows+1; row++)
203 203
           {
204
           fillInflate(j,i);
204
           fillInflate(row,col);
205 205
           }
206 206

  
207 207
       markRegions();
......
226 226
       mInflateX = new byte[mRows+1][mCols+1];
227 227
       mInflateY = new byte[mRows+1][mCols+1];
228 228

  
229
       for(int j=0; j<mCols; j++)
230
         for(int i=0; i<mRows; i++)
231
           mCubes[i][j] = 1;
229
       for(int col=0; col<mCols; col++)
230
         for(int row=0; row<mRows; row++)
231
           mCubes[row][col] = 1;
232 232

  
233
       for(int j=0; j<mCols+1; j++)
234
         for(int i=0; i<mRows+1; i++)
233
       for(int col=0; col<mCols+1; col++)
234
         for(int row=0; row<mRows+1; row++)
235 235
           {
236
           fillInflate(j,i);
236
           fillInflate(row,col);
237 237
           }
238 238

  
239 239
       markRegions();
......
586 586

  
587 587
///////////////////////////////////////////////////////////////////////////////////////////////////
588 588

  
589
  private void fillInflate(int col, int row)
589
  private void fillInflate(int row, int col)
590 590
    {
591 591
    int diff;
592 592

  
593
         if( col==0     ) mInflateX[col][row] = -1;
594
    else if( col==mCols ) mInflateX[col][row] = +1;
593
         if( col==0     ) mInflateX[row][col] = -1;
594
    else if( col==mCols ) mInflateX[row][col] = +1;
595 595
    else
596 596
      {
597 597
      if( row==0 )
......
611 611
        if( diff== 2 ) diff= 1;
612 612
        }
613 613

  
614
      mInflateX[col][row] = (byte)diff;
614
      mInflateX[row][col] = (byte)diff;
615 615
      }
616 616

  
617
         if( row==0    ) mInflateY[col][row] = +1;
618
    else if(row==mRows ) mInflateY[col][row] = -1;
617
         if( row==0     ) mInflateY[row][col] = +1;
618
    else if( row==mRows ) mInflateY[row][col] = -1;
619 619
    else
620 620
      {
621 621
      if( col==0 )
......
635 635
        if( diff== 2 ) diff= 1;
636 636
        }
637 637

  
638
      mInflateY[col][row] = (byte)diff;
638
      mInflateY[row][col] = (byte)diff;
639 639
      }
640 640

  
641 641
    //android.util.Log.e("mesh","col="+col+" row="+row+" inflateX="+mInflateX[col][row]+" InflateY="+mInflateY[col][row]);
......
656 656
     attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = mNormalY[index];
657 657
     attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = mNormalZ[index];
658 658

  
659
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[col][row]/2.0f;
660
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[col][row]/2.0f;
659
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
660
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
661 661
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = vectZ;
662 662

  
663 663
     attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB  ] = x;
......
690 690
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = 1.0f;
691 691
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
692 692

  
693
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[col][row]/2.0f;
694
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[col][row]/2.0f;
693
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
694
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
695 695
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
696 696

  
697 697
                   attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB  ] = x;
......
711 711
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] =-1.0f;
712 712
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
713 713

  
714
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[col][row]/2.0f;
715
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[col][row]/2.0f;
714
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
715
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
716 716
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
717 717

  
718 718
                   attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB  ] = x;
......
732 732
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = side==WEST ? 0.0f : (side==NORTH?-R:R);
733 733
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
734 734

  
735
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[col][row]/2.0f;
736
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[col][row]/2.0f;
735
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
736
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
737 737
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
738 738

  
739 739
                   attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB  ] = (float)(col-slice)/mCols;
......
753 753
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = side==EAST ? 0.0f : (side==SOUTH?-R:R);
754 754
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
755 755

  
756
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[col][row]/2.0f;
757
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[col][row]/2.0f;
756
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
757
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
758 758
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
759 759

  
760 760
                   attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB  ] = (float)(col+slice)/mCols;

Also available in: Unified diff