Project

General

Profile

« Previous | Next » 

Revision db758bd0

Added by Leszek Koltunski about 2 years ago

On OpenGL ES 3.0, some drivers are veeeery slow linking a program which includes transform feedback - and such program is needed to apply vertex effects to meshes - which is needed to round corners of puzzle cubits.

Thus on 3.0 we switch off rounding corners of the meshes in the Creator mode, otherwise we'd need to wait about 24 seconds for the screen to appear!

View differences:

src/main/java/org/distorted/objectlib/helpers/FactoryBandaged3x3Cubit.java
914 914

  
915 915
///////////////////////////////////////////////////////////////////////////////////////////////////
916 916

  
917
  private int[] generateCornerIndices(float[][] vertices, int[][] indices)
917
  private int[] generateCornerIndices(float[][] vertices, boolean roundCorners)
918 918
    {
919 919
    int len = vertices.length;
920
    int val = roundCorners ? 0 : -1;
920 921
    int[] cornerIndices = new int[len];
921
    for(int i=0; i<len; i++) cornerIndices[i] = 0;
922
    for(int i=0; i<len; i++) cornerIndices[i] = val;
922 923
    return cornerIndices;
923 924
    }
924 925

  
......
1155 1156

  
1156 1157
///////////////////////////////////////////////////////////////////////////////////////////////////
1157 1158

  
1158
  public ObjectFaceShape createIrregularFaceShape(int variant, boolean iconMode)
1159
  public ObjectFaceShape createIrregularFaceShape(int variant, boolean iconMode, boolean roundCorners)
1159 1160
    {
1160 1161
    float height   = iconMode ? 0.001f : 0.05f;
1161 1162
    int angle      = 60;
......
1172 1173
                            {height/3,angle,R,S,numVertices,extraV,extraI} };
1173 1174

  
1174 1175
    int[] bandIndices   = generateBandIndices(mVertices[variant], mIndices[variant], mMove[variant]);
1175
    int[] cornerIndices = generateCornerIndices(mVertices[variant], mIndices[variant]);
1176
    int[] cornerIndices = generateCornerIndices(mVertices[variant], roundCorners);
1176 1177
    float[][] vertexVec = generateVectors(mVertices[variant], mIndices[variant], bandIndices);
1177 1178
    float[][] centers   = generateCenters(mVertices[variant], vertexVec);
1178 1179
    int[] centerIndices = generateCenterIndices(vertexVec);
......
1182 1183

  
1183 1184
///////////////////////////////////////////////////////////////////////////////////////////////////
1184 1185

  
1185
  public MeshBase createMesh(float[] pos, boolean iconMode)
1186
  public MeshBase createMesh(float[] pos, boolean iconMode, boolean roundCorners)
1186 1187
    {
1187 1188
    prepare(1);
1188 1189
    ObjectShape shape    = createIrregularShape(0,pos);
1189
    ObjectFaceShape face = createIrregularFaceShape(0,iconMode);
1190
    ObjectFaceShape face = createIrregularFaceShape(0,iconMode,roundCorners);
1190 1191
    int[][] indices      = shape.getVertIndices();
1191 1192
    int numComponents    = indices.length;
1192 1193

  
src/main/java/org/distorted/objectlib/objects/TwistyBandagedAbstract.java
24 24

  
25 25
import java.io.InputStream;
26 26

  
27
import org.distorted.library.main.DistortedLibrary;
27 28
import org.distorted.library.type.Static3D;
28 29
import org.distorted.library.type.Static4D;
29 30

  
......
344 345

  
345 346
  public ObjectFaceShape getObjectFaceShape(int variant)
346 347
    {
348
    int driver = DistortedLibrary.getGLSL();
349
    boolean roundCorners = (driver>300);
347 350
    int type,numTypes = mDims.length;
348 351
    for(type=0; type<numTypes; type++) if( mTypeVariantMap[type]==variant ) break;
349 352

  
350 353
    if( type<numTypes )
351 354
      {
355
      int val = roundCorners ? 0 : -1;
352 356
      int X = mDims[type][0];
353 357
      int Y = mDims[type][1];
354 358
      int Z = mDims[type][2];
......
356 360
      float height        = isInIconMode() ? 0.001f : 0.048f;
357 361
      int[] bandIndices   = { 0,0,1,1,2,2 };
358 362
      float[][] corners   = { {0.04f,0.15f} };
359
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
363
      int[] cornerIndices = { val,val,val,val,val,val,val,val };
360 364
      int[] centerIndices = { 0,1,2,3,4,5,6,7 };
361 365

  
362 366
      int maxXY = Math.max(X,Y);
......
386 390
      }
387 391

  
388 392
    FactoryBandaged3x3Cubit factory = FactoryBandaged3x3Cubit.getInstance();
389
    return factory.createIrregularFaceShape(variant, isInIconMode() );
393
    return factory.createIrregularFaceShape(variant, isInIconMode(), roundCorners );
390 394
    }
391 395

  
392 396
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff