Project

General

Profile

« Previous | Next » 

Revision 1fad573e

Added by Leszek Koltunski over 4 years ago

DeferredJobs app/lib works now

View differences:

src/main/java/org/distorted/library/effectqueue/EffectQueue.java
398 398
    return mNumEffects;
399 399
    }
400 400

  
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

  
403
  public int getNumEffectsToBe()
404
    {
405
    return mNumEffectsToBe;
406
    }
407

  
401 408
///////////////////////////////////////////////////////////////////////////////////////////////////
402 409

  
403 410
  public Effect getEffect(int position)
src/main/java/org/distorted/library/mesh/DeferredJobs.java
22 22
import org.distorted.library.effect.VertexEffect;
23 23
import org.distorted.library.effectqueue.EffectQueueVertex;
24 24
import org.distorted.library.main.DistortedLibrary;
25
import org.distorted.library.type.Static4D;
25 26

  
26 27
import java.util.ArrayList;
27 28

  
29
import android.util.Log;
30

  
28 31
///////////////////////////////////////////////////////////////////////////////////////////////////
29 32
/**
30 33
 * Not part of public API, do not document (public only because has to be cleaned from the main package)
......
37 40
  private static final int JOB_TYPE_MERGE  = 1;
38 41
  private static final int JOB_TYPE_JOIN   = 2;
39 42
  private static final int JOB_TYPE_COPY   = 3;
43
  private static final int JOB_TYPE_TEXTURE= 4;
40 44

  
41 45
  private static ArrayList<JobNode> mJobs = new ArrayList<>();
42 46

  
......
45 49
  private static class Job
46 50
    {
47 51
    private int mType;
48
    private int mArg;
49 52
    private MeshBase mTarget;
50 53
    private MeshBase[] mSource;
51 54
    private EffectQueueVertex mEffects;
55
    private Static4D[] mMaps;
52 56

  
53
    Job(int type, MeshBase target, MeshBase[] source, VertexEffect effect, int arg)
57
    Job(int type, MeshBase target, MeshBase[] source, VertexEffect effect, Static4D[] maps)
54 58
      {
55 59
      mType   = type;
56 60
      mTarget = target;
57 61
      mSource = source;
58
      mArg    = arg;
62
      mMaps   = maps;
59 63

  
60 64
      if( effect!=null )
61 65
        {
......
73 77
      {
74 78
      switch(mType)
75 79
        {
76
        case JOB_TYPE_VERTEX: DistortedLibrary.adjustVertices(mTarget, mEffects);
77
                              break;
78
        case JOB_TYPE_MERGE : mTarget.merge();
79
                              break;
80
        case JOB_TYPE_JOIN  : mTarget.joinAttrib1(mSource,mArg);
81
                              break;
82
        case JOB_TYPE_COPY  : mTarget.deepCopyAttribs1(mSource[0]);
83
                              break;
80
        case JOB_TYPE_VERTEX : DistortedLibrary.adjustVertices(mTarget, mEffects);
81
                               //Log.e("jobs", "executing vertex job");
82
                               //mTarget.print();
83
                               break;
84
        case JOB_TYPE_MERGE  : mTarget.merge();
85
                               //Log.e("jobs", "executing merge job");
86
                               //mTarget.print();
87
                               break;
88
        case JOB_TYPE_JOIN   : mTarget.joinAttribs(mSource);
89
                               //Log.e("jobs", "executing join job");
90
                               //mTarget.print();
91
                               break;
92
        case JOB_TYPE_COPY   : mTarget.copy(mSource[0]);
93
                               //Log.e("jobs", "executing copy job");
94
                               //mTarget.print();
95
                               break;
96
        case JOB_TYPE_TEXTURE: mTarget.textureMap(mMaps);
97
                               //Log.e("jobs", "executing textureMap job");
98
                               //mTarget.print();
99
                               break;
84 100
        }
85 101
      }
86 102

  
......
88 104
      {
89 105
      if( mEffects!=null ) mEffects.removeAll(false);
90 106
      }
107

  
108
    String print()
109
      {
110
      switch(mType)
111
        {
112
        case JOB_TYPE_VERTEX : return "VERTEX (eff: "+mEffects.getNumEffects()+" effToBe: "+mEffects.getNumEffectsToBe()+")";
113
        case JOB_TYPE_MERGE  : return "MERGE";
114
        case JOB_TYPE_JOIN   : return "JOIN: "+mSource.length;
115
        case JOB_TYPE_COPY   : return "COPY";
116
        case JOB_TYPE_TEXTURE: return "TEXTURE";
117
        }
118

  
119
      return null;
120
      }
91 121
    }
92 122

  
93 123
  //////////////////////////////////////////////////////////////////////////
......
112 142

  
113 143
      for(int i=0; i<numPrev; i++)
114 144
        {
115
        node = mPrevJobs.get(i);
145
        node = mPrevJobs.get(0);  // removeNode() rips the executed job out, thus the 0
116 146
        node.execute();
117 147
        }
118 148

  
......
130 160
      mJob.clear();
131 161
      mJob = null;
132 162
      }
163

  
164
    void print(int level)
165
      {
166
      int numPrev = mPrevJobs.size();
167
      int numNext = mNextJobs.size();
168

  
169
      String str = "";
170
      for(int i=0; i<level; i++) str+=" ";
171

  
172
      str += mJob.print();
173

  
174
      str += (" next: "+numNext+" prev: "+numPrev);
175

  
176
      Log.e("job", str);
177

  
178
      for(int i=0; i<numPrev; i++)
179
        {
180
        JobNode node = mPrevJobs.get(i);
181
        node.print(level+1);
182
        }
183
      }
133 184
    }
134 185

  
135 186
///////////////////////////////////////////////////////////////////////////////////////////////////
......
166 217

  
167 218
    if( jn==null )
168 219
      {
169
      Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,0);
220
      Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,null);
170 221
      JobNode node = new JobNode(job);
171 222
      mJobs.add(node);
172 223
      return node;
......
180 231
        }
181 232
      else
182 233
        {
183
        Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,0);
234
        Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,null);
184 235
        JobNode node = new JobNode(job);
185 236
        node.mPrevJobs.add(jn);
186 237
        jn.mNextJobs.add(node);
......
195 246
  static JobNode merge(MeshBase target)
196 247
    {
197 248
    JobNode jn = target.mJobNode[0];
198
    Job job = new Job(JOB_TYPE_MERGE,target,null,null,0);
249
    Job job = new Job(JOB_TYPE_MERGE,target,null,null,null);
199 250
    JobNode node = new JobNode(job);
200 251
    node.mPrevJobs.add(jn);
201 252
    jn.mNextJobs.add(node);
......
205 256

  
206 257
///////////////////////////////////////////////////////////////////////////////////////////////////
207 258

  
208
  static JobNode join(MeshBase target, MeshBase[] meshes, int origVertices)
259
  static JobNode join(MeshBase target, MeshBase[] meshes)
209 260
    {
210 261
    JobNode jn;
211 262

  
212
    Job job = new Job(JOB_TYPE_JOIN,target,meshes,null,origVertices);
263
    Job job = new Job(JOB_TYPE_JOIN,target,meshes,null,null);
213 264
    JobNode node = new JobNode(job);
214 265

  
215 266
    for (MeshBase mesh : meshes)
216 267
      {
217 268
      jn = mesh.mJobNode[0];
218
      node.mPrevJobs.add(jn);
219
      jn.mNextJobs.add(node);
269

  
270
      if( jn!=null )
271
        {
272
        node.mPrevJobs.add(jn);
273
        jn.mNextJobs.add(node);
274
        }
220 275
      }
221 276

  
222 277
    mJobs.add(node);
......
230 285
    JobNode jn = mesh.mJobNode[0];
231 286
    MeshBase[] meshes = new MeshBase[1];
232 287
    meshes[0] = mesh;
233
    Job job = new Job(JOB_TYPE_COPY,target,meshes,null,0);
288
    Job job = new Job(JOB_TYPE_COPY,target,meshes,null,null);
289
    JobNode node = new JobNode(job);
290
    node.mPrevJobs.add(jn);
291
    jn.mNextJobs.add(node);
292
    mJobs.add(node);
293
    return node;
294
    }
295

  
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

  
298
  static JobNode textureMap(MeshBase target, Static4D[] maps)
299
    {
300
    JobNode jn = target.mJobNode[0];
301
    Job job = new Job(JOB_TYPE_TEXTURE,target,null,null,maps);
234 302
    JobNode node = new JobNode(job);
235 303
    node.mPrevJobs.add(jn);
236 304
    jn.mNextJobs.add(node);
src/main/java/org/distorted/library/mesh/MeshBase.java
138 138

  
139 139
   MeshBase(MeshBase original, boolean deep)
140 140
     {
141
     mShowNormals     = original.mShowNormals;
142
     mInflate         = original.mInflate;
143
     mNumVertices     = original.mNumVertices;
144

  
145
     int size = original.mComponent.size();
146
     mComponent = new ArrayList<>();
147

  
148
     for(int i=0; i<size; i++)
149
       {
150
       Component comp = new Component(original.mComponent.get(i));
151
       mComponent.add(comp);
152
       }
141
     mShowNormals= original.mShowNormals;
142
     mInflate    = original.mInflate;
143
     mNumVertices= original.mNumVertices;
153 144

  
154 145
     mAssociation= new int[MAX_COMPONENTS];
155 146
     System.arraycopy(original.mAssociation, 0, mAssociation, 0, MAX_COMPONENTS);
156 147

  
157 148
     if( deep )
158 149
       {
159
       mVBO1= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
160
       mVertAttribs1= new float[mNumVertices*VERT1_ATTRIBS];
161

  
162 150
       mJobNode = new DeferredJobs.JobNode[1];
163

  
164
       if( original.mJobNode[0]!=null )
165
         {
166
         mJobNode[0] = DeferredJobs.copy(this,original);
167
         }
168
       else
169
         {
170
         deepCopyAttribs1(original);
171
         }
151
       if( original.mJobNode[0]==null ) copy(original);
152
       else mJobNode[0] = DeferredJobs.copy(this,original);
172 153
       }
173 154
     else
174 155
       {
175 156
       mJobNode      = original.mJobNode;
176 157
       mVBO1         = original.mVBO1;
177 158
       mVertAttribs1 = original.mVertAttribs1;
159
       shallowCopy(original);
178 160
       }
179 161

  
180
     mVBO2= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
181
     mVertAttribs2= new float[mNumVertices*VERT2_ATTRIBS];
182
     System.arraycopy(original.mVertAttribs2,0,mVertAttribs2,0,mNumVertices*VERT2_ATTRIBS);
183
     mVBO2.invalidate();
184

  
185 162
     mTFO = new InternalBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, GLES30.GL_STATIC_READ);
186 163
     mTFO.invalidate();
187 164
     }
188 165

  
189 166
///////////////////////////////////////////////////////////////////////////////////////////////////
190 167

  
191
   public static int getMaxComponents()
168
   void copy(MeshBase original)
192 169
     {
193
     return MAX_COMPONENTS;
170
     shallowCopy(original);
171

  
172
     mVBO1= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
173
     mVertAttribs1= new float[mNumVertices*VERT1_ATTRIBS];
174
     System.arraycopy(original.mVertAttribs1,0,mVertAttribs1,0,mNumVertices*VERT1_ATTRIBS);
175
     mVBO1.invalidate();
194 176
     }
195 177

  
196 178
///////////////////////////////////////////////////////////////////////////////////////////////////
197 179

  
198
   public static void getUniforms(int mProgramH, int variant)
180
   private void shallowCopy(MeshBase original)
199 181
     {
200
     mComponentAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComponAssoc");
201
     }
182
     int size = original.mComponent.size();
183
     mComponent = new ArrayList<>();
202 184

  
203
///////////////////////////////////////////////////////////////////////////////////////////////////
185
     for(int i=0; i<size; i++)
186
       {
187
       Component comp = new Component(original.mComponent.get(i));
188
       mComponent.add(comp);
189
       }
204 190

  
205
   void deepCopyAttribs1(MeshBase original)
206
     {
207
     System.arraycopy(original.mVertAttribs1,0,mVertAttribs1,0,mNumVertices*VERT1_ATTRIBS);
208
     mVBO1.invalidate();
191
     mVBO2= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
192
     mVertAttribs2= new float[mNumVertices*VERT2_ATTRIBS];
193
     System.arraycopy(original.mVertAttribs2,0,mVertAttribs2,0,mNumVertices*VERT2_ATTRIBS);
194
     mVBO2.invalidate();
209 195
     }
210 196

  
211 197
///////////////////////////////////////////////////////////////////////////////////////////////////
......
252 238

  
253 239
///////////////////////////////////////////////////////////////////////////////////////////////////
254 240

  
255
   void joinAttrib1(MeshBase[] meshes, int origVertices)
241
   void joinAttribs(MeshBase[] meshes)
256 242
     {
257 243
     MeshBase mesh;
244
     Component comp;
258 245
     int numMeshes = meshes.length;
259
     int numVertices = origVertices;
260

  
261
     float[] newAttribs1 = new float[VERT1_ATTRIBS*mNumVertices];
246
     int origVertices = mNumVertices;
247
     int origComponents=0,numComponents,numVertices;
262 248

  
263 249
     if( origVertices>0 )
264 250
       {
265
       System.arraycopy(mVertAttribs1,                              0, newAttribs1,                         0, VERT1_ATTRIBS*numVertices);
266
       System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS    );
267
       origVertices++;
268

  
269
       if( numVertices%2==1 )
270
         {
271
         System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
272
         origVertices++;
273
         }
251
       origComponents = mComponent.size();
252
       mNumVertices+= ( mNumVertices%2==1 ? 2:1 );
253
       mComponent.get(origComponents-1).mEndIndex = mNumVertices-1;
274 254
       }
275 255

  
276 256
     for(int i=0; i<numMeshes; i++)
277 257
       {
278 258
       mesh = meshes[i];
259
       numComponents = mesh.mComponent.size();
279 260
       numVertices = mesh.mNumVertices;
280 261

  
281
       if( origVertices>0 )
282
         {
283
         System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS    );
284
         origVertices++;
285
         }
286
       System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS*numVertices);
287
       origVertices+=numVertices;
262
       int extraVerticesBefore = mNumVertices==0 ? 0:1;
263
       int extraVerticesAfter  = (i==numMeshes-1) ? 0 : (numVertices%2==1 ? 2:1);
288 264

  
289
       if( i<numMeshes-1 )
265
       for(int j=0; j<numComponents; j++)
290 266
         {
291
         System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
292
         origVertices++;
267
         comp = new Component(mesh.mComponent.get(j));
268
         comp.mEndIndex += (extraVerticesBefore+mNumVertices+extraVerticesAfter);
269
         mComponent.add(comp);
293 270

  
294
         if( numVertices%2==1 )
271
         if( origComponents<MAX_COMPONENTS )
295 272
           {
296
           System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
297
           origVertices++;
273
           mAssociation[origComponents] = mesh.mAssociation[j];
274
           origComponents++;
298 275
           }
299 276
         }
300
       }
301

  
302
     mVertAttribs1 = newAttribs1;
303
     mVBO1.invalidate();
304
     }
305 277

  
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

  
308
   private void joinAttrib2(MeshBase[] meshes, int origVertices)
309
     {
310
     MeshBase mesh;
311
     int numMeshes = meshes.length;
312
     int numVertices = origVertices;
278
       mNumVertices += (extraVerticesBefore+numVertices+extraVerticesAfter);
279
       }
313 280

  
281
     float[] newAttribs1 = new float[VERT1_ATTRIBS*mNumVertices];
314 282
     float[] newAttribs2 = new float[VERT2_ATTRIBS*mNumVertices];
283
     numVertices = origVertices;
315 284

  
316 285
     if( origVertices>0 )
317 286
       {
287
       System.arraycopy(mVertAttribs1,                              0, newAttribs1,                         0, VERT1_ATTRIBS*numVertices);
288
       System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS    );
318 289
       System.arraycopy(mVertAttribs2,                              0, newAttribs2,                         0, VERT2_ATTRIBS*numVertices);
319 290
       System.arraycopy(mVertAttribs2, VERT2_ATTRIBS*(origVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS    );
320 291
       origVertices++;
321 292

  
322 293
       if( numVertices%2==1 )
323 294
         {
295
         System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
324 296
         System.arraycopy(mVertAttribs2, VERT2_ATTRIBS*(origVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
325 297
         origVertices++;
326 298
         }
......
333 305

  
334 306
       if( origVertices>0 )
335 307
         {
308
         System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS    );
336 309
         System.arraycopy(mesh.mVertAttribs2, 0, newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS    );
337 310
         origVertices++;
338 311
         }
312
       System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS*numVertices);
339 313
       System.arraycopy(mesh.mVertAttribs2, 0, newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS*numVertices);
340 314
       origVertices+=numVertices;
341 315

  
342 316
       if( i<numMeshes-1 )
343 317
         {
318
         System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
344 319
         System.arraycopy(mesh.mVertAttribs2, VERT2_ATTRIBS*(numVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
345 320
         origVertices++;
346 321

  
347 322
         if( numVertices%2==1 )
348 323
           {
324
           System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
349 325
           System.arraycopy(mesh.mVertAttribs2, VERT2_ATTRIBS*(numVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
350 326
           origVertices++;
351 327
           }
......
366 342
       for( ; index<=endIndex; index++) newAttribs2[VERT2_ATTRIBS*index+COM_ATTRIB] = component;
367 343
       }
368 344

  
345
     mVertAttribs1 = newAttribs1;
369 346
     mVertAttribs2 = newAttribs2;
347
     mVBO1.invalidate();
370 348
     mVBO2.invalidate();
371 349
     }
372 350

  
......
375 353

  
376 354
   void join(MeshBase[] meshes)
377 355
     {
378
     MeshBase mesh;
379
     Component comp;
380
     int origComponents=0, numComponents, numVertices, numMeshes = meshes.length;
381
     int origVertices = mNumVertices;
356
     boolean immediateJoin = true;
382 357

  
383
     if( origVertices>0 )
358
     for (MeshBase mesh : meshes)
384 359
       {
385
       origComponents = mComponent.size();
386
       mNumVertices+= ( mNumVertices%2==1 ? 2:1 );
387
       mComponent.get(origComponents-1).mEndIndex = mNumVertices-1;
360
       if (mesh.mJobNode[0] != null)
361
         {
362
         immediateJoin = false;
363
         break;
364
         }
388 365
       }
389 366

  
390
     for(int i=0; i<numMeshes; i++)
391
       {
392
       mesh = meshes[i];
393
       numComponents = mesh.mComponent.size();
367
     if( immediateJoin ) joinAttribs(meshes);
368
     else                mJobNode[0] = DeferredJobs.join(this,meshes);
369
     }
394 370

  
395
       numVertices = mesh.mNumVertices;
371
///////////////////////////////////////////////////////////////////////////////////////////////////
396 372

  
397
       int extraVerticesBefore = mNumVertices==0 ? 0:1;
398
       int extraVerticesAfter  = (i==numMeshes-1) ? 0 : (numVertices%2==1 ? 2:1);
373
   void textureMap(Static4D[] maps)
374
     {
375
     int num_comp = mComponent.size();
376
     int num_maps = maps.length;
377
     int min = Math.min(num_comp, num_maps);
378
     int vertex = 0;
379
     Static4D newMap, oldMap;
380
     Component comp;
381
     float newW, newH, ratW, ratH, movX, movY;
399 382

  
400
       for(int j=0; j<numComponents; j++)
383
     for(int i=0; i<min; i++)
384
       {
385
       newMap = maps[i];
386
       comp = mComponent.get(i);
387

  
388
       if( newMap!=null )
401 389
         {
402
         comp = new Component(mesh.mComponent.get(j));
403
         comp.mEndIndex += (extraVerticesBefore+mNumVertices+extraVerticesAfter);
404
         mComponent.add(comp);
390
         newW = newMap.get2();
391
         newH = newMap.get3();
405 392

  
406
         if( origComponents<MAX_COMPONENTS )
393
         if( newW!=0.0f && newH!=0.0f )
407 394
           {
408
           mAssociation[origComponents] = mesh.mAssociation[j];
409
           origComponents++;
395
           oldMap = comp.mTextureMap;
396
           ratW = newW/oldMap.get2();
397
           ratH = newH/oldMap.get3();
398
           movX = newMap.get0() - ratW*oldMap.get0();
399
           movY = newMap.get1() - ratH*oldMap.get1();
400

  
401
           for( int index=vertex*VERT2_ATTRIBS+TEX_ATTRIB ; vertex<=comp.mEndIndex; vertex++, index+=VERT2_ATTRIBS)
402
             {
403
             mVertAttribs2[index  ] = ratW*mVertAttribs2[index  ] + movX;
404
             mVertAttribs2[index+1] = ratH*mVertAttribs2[index+1] + movY;
405
             }
406
           comp.setMap(newMap);
410 407
           }
411 408
         }
412 409

  
413
       mNumVertices += (extraVerticesBefore+numVertices+extraVerticesAfter);
410
       vertex= comp.mEndIndex+1;
414 411
       }
415 412

  
416
     if( mJobNode[0]!=null )
417
       {
418
       mJobNode[0] = DeferredJobs.join(this,meshes,origVertices);
419
       }
420
     else
421
       {
422
       joinAttrib1(meshes,origVertices);
423
       }
413
     mVBO2.invalidate();
414
     }
415

  
416
///////////////////////////////////////////////////////////////////////////////////////////////////
424 417

  
425
     joinAttrib2(meshes,origVertices);
418
   public static int getMaxComponents()
419
     {
420
     return MAX_COMPONENTS;
421
     }
422

  
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424

  
425
   public static void getUniforms(int mProgramH, int variant)
426
     {
427
     mComponentAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComponAssoc");
426 428
     }
427 429

  
428 430
///////////////////////////////////////////////////////////////////////////////////////////////////
......
450 452
     GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK);
451 453
     }
452 454

  
455
///////////////////////////////////////////////////////////////////////////////////////////////////
456
/**
457
 * Not part of public API, do not document (public only because has to be used from the main package)
458
 *
459
 * @y.exclude
460
 */
461
   public void debug()
462
     {
463
     if( mJobNode[0]!=null )
464
       {
465
       mJobNode[0].print(0);
466
       }
467
     else
468
       {
469
       android.util.Log.e("mesh", "JobNode null");
470
       }
471
     }
472

  
473
///////////////////////////////////////////////////////////////////////////////////////////////////
474
/**
475
 * Not part of public API, do not document (public only because has to be used from the main package)
476
 *
477
 * @y.exclude
478
 */
479
   public void print()
480
     {
481
     StringBuffer sb = new StringBuffer();
482

  
483
     for(int i=0; i<mNumVertices; i++)
484
       {
485
       sb.append('(');
486
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB  ]);
487
       sb.append(',');
488
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+1]);
489
       sb.append(',');
490
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+2]);
491
       sb.append(") ");
492
       }
493

  
494
     StringBuffer sb2 = new StringBuffer();
495

  
496
     for(int i=0; i<mNumVertices; i++)
497
       {
498
       sb2.append(mVertAttribs2[VERT2_ATTRIBS*i+COM_ATTRIB]);
499
       sb2.append(' ');
500
       }
501

  
502
     Log.d("mesh", sb.toString()+"\n"+sb2.toString());
503
     }
504

  
453 505
///////////////////////////////////////////////////////////////////////////////////////////////////
454 506
/**
455 507
 * Not part of public API, do not document (public only because has to be used from the main package)
......
578 630
 */
579 631
   public void mergeComponents()
580 632
     {
581
     if( mJobNode==null )
633
     if( mJobNode[0]==null )
582 634
       {
583 635
       merge();
584 636
       }
......
643 695
 */
644 696
   public void setTextureMap(Static4D[] maps)
645 697
     {
646
     int num_comp = mComponent.size();
647
     int num_maps = maps.length;
648
     int min = Math.min(num_comp, num_maps);
649
     int vertex = 0;
650
     Static4D newMap, oldMap;
651
     Component comp;
652
     float newW, newH, ratW, ratH, movX, movY;
653

  
654
     for(int i=0; i<min; i++)
698
     if( mJobNode[0]==null )
655 699
       {
656
       newMap = maps[i];
657
       comp = mComponent.get(i);
658

  
659
       if( newMap!=null )
660
         {
661
         newW = newMap.get2();
662
         newH = newMap.get3();
663

  
664
         if( newW!=0.0f && newH!=0.0f )
665
           {
666
           oldMap = comp.mTextureMap;
667
           ratW = newW/oldMap.get2();
668
           ratH = newH/oldMap.get3();
669
           movX = newMap.get0() - ratW*oldMap.get0();
670
           movY = newMap.get1() - ratH*oldMap.get1();
671

  
672
           for( int index=vertex*VERT2_ATTRIBS+TEX_ATTRIB ; vertex<=comp.mEndIndex; vertex++, index+=VERT2_ATTRIBS)
673
             {
674
             mVertAttribs2[index  ] = ratW*mVertAttribs2[index  ] + movX;
675
             mVertAttribs2[index+1] = ratH*mVertAttribs2[index+1] + movY;
676
             }
677
           comp.setMap(newMap);
678
           }
679
         }
680

  
681
       vertex= comp.mEndIndex+1;
700
       textureMap(maps);
701
       }
702
     else
703
       {
704
       mJobNode[0] = DeferredJobs.textureMap(this,maps);
682 705
       }
683

  
684
     mVBO2.invalidate();
685 706
     }
686 707

  
687 708
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff