Project

General

Profile

« Previous | Next » 

Revision e8925fcd

Added by Leszek Koltunski almost 4 years ago

Big change to MeshBase:
1) split the list of Components into two: 'texture map' components and 'effect' components.
Reason: imagine the Rubik Cube with a Solver. When setting up a initial position in the Solver, we need to be able to set texture maps of each individual face of each cubit.
Thus previously (when there was only one Component which kept info both about Effect associations and Texture Maps) a 5x5x5 Rubik Cube would have to have 98*6 = almost 600 components.
This alone would mean 1200 uniforms in the Vertex Shader --> more than the guaranteed 1024.
Splitting the Component into two parts lets us merge the 6 'Effect' components of each Rubik Cubit into one (thus leaving only 98 Effect Components in the Verteex Shader --> 196 uniforms) while still allowing for change of the texture map of each individual face.
2) (re-) add the 'apply a matrix effect' (this time with associations)

View differences:

src/main/java/org/distorted/library/mesh/DeferredJobs.java
19 19

  
20 20
package org.distorted.library.mesh;
21 21

  
22
import org.distorted.library.effect.MatrixEffect;
22 23
import org.distorted.library.effect.VertexEffect;
23 24
import org.distorted.library.effectqueue.EffectQueueVertex;
24 25
import org.distorted.library.main.DistortedLibrary;
......
36 37
 */
37 38
public class DeferredJobs
38 39
  {
39
  private static final int JOB_TYPE_VERTEX = 0;
40
  private static final int JOB_TYPE_MERGE  = 1;
41
  private static final int JOB_TYPE_JOIN   = 2;
42
  private static final int JOB_TYPE_COPY   = 3;
43
  private static final int JOB_TYPE_TEXTURE= 4;
40
  private static final int JOB_TYPE_VERTEX   = 0;
41
  private static final int JOB_TYPE_MATRIX   = 1;
42
  private static final int JOB_TYPE_MERGE_TEX= 2;
43
  private static final int JOB_TYPE_MERGE_EFF= 3;
44
  private static final int JOB_TYPE_JOIN     = 4;
45
  private static final int JOB_TYPE_COPY     = 5;
46
  private static final int JOB_TYPE_TEXTURE  = 6;
44 47

  
45 48
  private static ArrayList<JobNode> mJobs = new ArrayList<>();
46 49

  
......
51 54
    private int mType;
52 55
    private MeshBase mTarget;
53 56
    private MeshBase[] mSource;
54
    private EffectQueueVertex mEffects;
57
    private EffectQueueVertex mVertexEffects;
58
    private MatrixEffect mMatrixEffect;
55 59
    private Static4D[] mMaps;
60
    private int mAndAssoc, mEcuAssoc;
56 61

  
57
    Job(int type, MeshBase target, MeshBase[] source, VertexEffect effect, Static4D[] maps)
62
    Job(int type, MeshBase target, MeshBase[] source, VertexEffect vEff, MatrixEffect mEff, Static4D[] maps, int and, int ecu)
58 63
      {
59
      mType   = type;
60
      mTarget = target;
61
      mSource = source;
62
      mMaps   = maps;
63

  
64
      if( effect!=null )
64
      mType     = type;
65
      mTarget   = target;
66
      mSource   = source;
67
      mMaps     = maps;
68
      mAndAssoc = and;
69
      mEcuAssoc = ecu;
70

  
71
      if( vEff!=null )
65 72
        {
66
        mEffects= new EffectQueueVertex();
67
        mEffects.add(effect);
73
        mVertexEffects= new EffectQueueVertex();
74
        mVertexEffects.add(vEff);
68 75
        }
76

  
77
      mMatrixEffect = mEff;
69 78
      }
70 79

  
71 80
    void addEffect(VertexEffect effect)
72 81
      {
73
      mEffects.add(effect);
82
      mVertexEffects.add(effect);
74 83
      }
75 84

  
76 85
    void execute()
77 86
      {
78 87
      switch(mType)
79 88
        {
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;
89
        case JOB_TYPE_VERTEX   : DistortedLibrary.adjustVertices(mTarget, mVertexEffects);
90
                                 break;
91
        case JOB_TYPE_MATRIX   : mTarget.applyMatrix(mMatrixEffect,mAndAssoc,mEcuAssoc);
92
                                 break;
93
        case JOB_TYPE_MERGE_TEX: mTarget.mergeTexComponentsNow();
94
                                 break;
95
        case JOB_TYPE_MERGE_EFF: mTarget.mergeEffComponentsNow();
96
                                 break;
97
        case JOB_TYPE_JOIN     : mTarget.joinAttribs(mSource);
98
                                 break;
99
        case JOB_TYPE_COPY     : mTarget.copy(mSource[0]);
100
                                 break;
101
        case JOB_TYPE_TEXTURE  : mTarget.textureMap(mMaps);
102
                                 break;
100 103
        }
104
/*
105
      Log.e("jobs", "executing "+print()+" job");
106
      mTarget.print();
107
*/
101 108
      }
102 109

  
103 110
    void clear()
104 111
      {
105
      if( mEffects!=null ) mEffects.removeAll(false);
112
      if( mVertexEffects!=null ) mVertexEffects.removeAll(false);
106 113
      }
107 114

  
108 115
    String print()
109 116
      {
110 117
      switch(mType)
111 118
        {
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";
119
        case JOB_TYPE_VERTEX   : return "VERTEX";
120
        case JOB_TYPE_MATRIX   : return "MATRIX";
121
        case JOB_TYPE_MERGE_TEX: return "MERGE_TEX";
122
        case JOB_TYPE_MERGE_EFF: return "MERGE_EFF";
123
        case JOB_TYPE_JOIN     : return "JOIN";
124
        case JOB_TYPE_COPY     : return "COPY";
125
        case JOB_TYPE_TEXTURE  : return "TEXTURE";
117 126
        }
118 127

  
119 128
      return null;
......
217 226

  
218 227
    if( jn==null )
219 228
      {
220
      Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,null);
229
      Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,null,null,0,0);
221 230
      JobNode node = new JobNode(job);
222 231
      mJobs.add(node);
223 232
      return node;
......
231 240
        }
232 241
      else
233 242
        {
234
        Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,null);
243
        Job job = new Job(JOB_TYPE_VERTEX,target,null,effect,null,null,0,0);
235 244
        JobNode node = new JobNode(job);
236 245
        node.mPrevJobs.add(jn);
237 246
        jn.mNextJobs.add(node);
......
243 252

  
244 253
///////////////////////////////////////////////////////////////////////////////////////////////////
245 254

  
246
  static JobNode merge(MeshBase target)
255
  static JobNode matrix(MeshBase target, MatrixEffect effect, int andAssoc, int ecuAssoc)
256
    {
257
    JobNode jn = target.mJobNode[0];
258
    Job job = new Job(JOB_TYPE_MATRIX,target,null,null,effect,null,andAssoc,ecuAssoc);
259
    JobNode node = new JobNode(job);
260
    node.mPrevJobs.add(jn);
261
    jn.mNextJobs.add(node);
262
    mJobs.add(node);
263
    return node;
264
    }
265

  
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

  
268
  static JobNode mergeTex(MeshBase target)
269
    {
270
    JobNode jn = target.mJobNode[0];
271
    Job job = new Job(JOB_TYPE_MERGE_TEX,target,null,null,null,null,0,0);
272
    JobNode node = new JobNode(job);
273
    node.mPrevJobs.add(jn);
274
    jn.mNextJobs.add(node);
275
    mJobs.add(node);
276
    return node;
277
    }
278

  
279
///////////////////////////////////////////////////////////////////////////////////////////////////
280

  
281
  static JobNode mergeEff(MeshBase target)
247 282
    {
248 283
    JobNode jn = target.mJobNode[0];
249
    Job job = new Job(JOB_TYPE_MERGE,target,null,null,null);
284
    Job job = new Job(JOB_TYPE_MERGE_EFF,target,null,null,null,null,0,0);
250 285
    JobNode node = new JobNode(job);
251 286
    node.mPrevJobs.add(jn);
252 287
    jn.mNextJobs.add(node);
......
260 295
    {
261 296
    JobNode jn;
262 297

  
263
    Job job = new Job(JOB_TYPE_JOIN,target,meshes,null,null);
298
    Job job = new Job(JOB_TYPE_JOIN,target,meshes,null,null,null,0,0);
264 299
    JobNode node = new JobNode(job);
265 300

  
266 301
    for (MeshBase mesh : meshes)
......
285 320
    JobNode jn = mesh.mJobNode[0];
286 321
    MeshBase[] meshes = new MeshBase[1];
287 322
    meshes[0] = mesh;
288
    Job job = new Job(JOB_TYPE_COPY,target,meshes,null,null);
323
    Job job = new Job(JOB_TYPE_COPY,target,meshes,null,null,null,0,0);
289 324
    JobNode node = new JobNode(job);
290 325
    node.mPrevJobs.add(jn);
291 326
    jn.mNextJobs.add(node);
......
298 333
  static JobNode textureMap(MeshBase target, Static4D[] maps)
299 334
    {
300 335
    JobNode jn = target.mJobNode[0];
301
    Job job = new Job(JOB_TYPE_TEXTURE,target,null,null,maps);
336
    Job job = new Job(JOB_TYPE_TEXTURE,target,null,null,null,maps,0,0);
302 337
    JobNode node = new JobNode(job);
303 338
    node.mPrevJobs.add(jn);
304 339
    jn.mNextJobs.add(node);

Also available in: Unified diff