Project

General

Profile

« Previous | Next » 

Revision ef4a9bab

Added by Leszek Koltunski over 1 year ago

Fixes for MeshMultigon. Perfect!

View differences:

src/main/java/org/distorted/library/mesh/MeshBandedTriangle.java
332 332
    mTopY    = vT[1];
333 333

  
334 334
    mMode = mode;
335
    mNormL= normL;
336
    mNormR= normR;
335
    mNormL= new float[] { normL[0],normL[1] };
336
    mNormR= new float[] { normR[0],normR[1] };
337 337

  
338 338
    mBands        = bands;
339 339
    mNumBands     = mBands.length/2 -1;
src/main/java/org/distorted/library/mesh/MeshMultigon.java
291 291

  
292 292
      if( eupp<0 )
293 293
        {
294
        normL[0]=vT[0]-vL[0];
295
        normL[1]=vT[1]-vL[1];
294
        normL[0]=vL[0]-vT[0];
295
        normL[1]=vL[1]-vT[1];
296 296
        }
297 297
      else
298 298
        {
299
        normL[0]= v[2*prev  ] - v[2*curr  ];
300
        normL[1]= v[2*prev+1] - v[2*curr+1];
299
        normL[0]= v[2*curr  ] - v[2*prev  ];
300
        normL[1]= v[2*curr+1] - v[2*prev+1];
301 301
        }
302 302

  
303 303
      if( eupn<0 )
304 304
        {
305
        normR[0]=vT[0]-vR[0];
306
        normR[1]=vT[1]-vR[1];
305
        normR[0]=vR[0]-vT[0];
306
        normR[1]=vR[1]-vT[1];
307 307
        }
308 308
      else
309 309
        {
310 310
        int nnxt= next==len-1 ? 0 : next+1;
311
        normL[0]= v[2*nnxt  ] - v[2*next  ];
312
        normL[1]= v[2*nnxt+1] - v[2*next+1];
311
        normR[0]= v[2*next  ] - v[2*nnxt  ];
312
        normR[1]= v[2*next+1] - v[2*nnxt+1];
313 313
        }
314 314

  
315 315
      return MeshBandedTriangle.MODE_NORMAL;
......
331 331
        }
332 332
      else
333 333
        {
334
        float dx=v[2*curr]-v[2*next];
335
        float dy=v[2*curr+1]-v[2*next+1];
334
        float dx=v[2*next  ]-v[2*curr  ];
335
        float dy=v[2*next+1]-v[2*curr+1];
336 336

  
337 337
        normL[0]=dx;
338 338
        normL[1]=dy;
......
383 383

  
384 384
      for(int j=0; j<num; j++)
385 385
        {
386
        int mode=computeMode(vL, vR, vT, normL, normL, edgesUp, vertsUp,vertices,centers, i,j);
386
        int mode=computeMode(vL, vR, vT, normL, normR, edgesUp, vertsUp,vertices,centers, i,j);
387 387
        triangles[index++] = new MeshBandedTriangle(vL, vR, vT, band, normL, normR, mode, exBands, exVertices);
388 388
        }
389 389
      }

Also available in: Unified diff