Project

General

Profile

« Previous | Next » 

Revision f046b159

Added by Leszek Koltunski almost 4 years ago

First attempt at the MeshBase.apply(VertexEffect) API.

View differences:

src/main/java/org/distorted/library/effectqueue/EffectQueue.java
37 37
 */
38 38
public abstract class EffectQueue implements InternalMaster.Slave
39 39
  {
40
  static final int MAIN_VARIANTS = 3; // Number of Main program variants (ATM 3: MAIN, MAIN OIT, PREPROCESS)
40
  static final int MAIN_VARIANTS = 4; // Number of Main program variants (ATM 4: MAIN, MAIN OIT, PREPROCESS, FULL)
41 41

  
42 42
  private static final int CREATE = 0;
43 43
  private static final int ATTACH = 1;
......
47 47
  int mNumEffects;              // 'ToBe' will be more than mNumEffects if doWork() hasn't
48 48
  private int mNumEffectsToBe;  // added them yet (or less if it hasn't removed some yet)
49 49
  float[] mUniforms;
50
  private int mNumUniforms;
50 51
  long[] mCurrentDuration;
51 52
  Effect[] mEffects;
52 53
  int[] mName;
53
  long mTime=0;
54
  long mTime;
54 55

  
55 56
  private static int[] mMax = new int[EffectType.LENGTH];
56 57
  private static long mNextID;
......
60 61
  private int mIndex;
61 62
  private boolean mCreated;
62 63

  
63
  private class Job
64
  private static class Job
64 65
    {
65 66
    int type;
66 67
    int num;
......
88 89
  EffectQueue(int numUniforms, int index)
89 90
    {
90 91
    mCreated            = false;
92
    mTime               = 0;
91 93
    mID                 = 0;
92 94
    mNumEffects         = 0;
93 95
    mNumEffectsToBe     = 0;
94 96
    mIndex              = index;
97
    mNumUniforms        = numUniforms;
95 98

  
96
    mJobs.add(new Job(CREATE,numUniforms,false,null));  // create the stuff that depends on max number
99
    mJobs.add(new Job(CREATE,numUniforms,false,null)); // create the stuff that depends on max number
97 100
    InternalMaster.newSlave(this);                     // of uniforms later, on first render.
98 101
    }
99 102

  
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

  
105
  EffectQueue(EffectQueue source)
106
    {
107
    if( !source.mCreated )
108
      {
109
      mCreated            = false;
110
      mTime               = 0;
111
      mID                 = 0;
112
      mNumEffects         = 0;
113
      mNumEffectsToBe     = 0;
114
      mIndex              = source.mIndex;
115
      mNumUniforms        = source.mNumUniforms;
116

  
117
      int numJobs = source.mJobs.size();
118

  
119
      for(int i=0; i<numJobs; i++)
120
        {
121
        Job job = source.mJobs.get(i);
122
        mJobs.add(job);
123
        }
124

  
125
      InternalMaster.newSlave(this);
126
      }
127
    else
128
      {
129
      mCreated            = true;
130
      mTime               = source.mTime;
131
      mID                 = source.mID;
132
      mNumEffects         = source.mNumEffects;
133
      mNumEffectsToBe     = source.mNumEffectsToBe;
134
      mIndex              = source.mIndex;
135
      mNumUniforms        = source.mNumUniforms;
136

  
137
      int max = mMax[mIndex];
138
      if( max>0 )
139
        {
140
        mUniforms        = new float[max*source.mNumUniforms];
141
        mCurrentDuration = new long[max];
142
        mEffects         = new Effect[max];
143
        mName            = new int[max];
144
        }
145

  
146
      for(int i=0; i<mNumEffects; i++ )
147
        {
148
        mEffects[i]         = source.mEffects[i];
149
        mCurrentDuration[i] = source.mCurrentDuration[i];
150
        mName[i]            = source.mName[i];
151
        }
152
      }
153
    }
154

  
100 155
///////////////////////////////////////////////////////////////////////////////////////////////////
101 156

  
102 157
  public static void allocateQueues(EffectQueue[] queues, EffectQueue[] from, int flags)
......
135 190
    }
136 191

  
137 192
///////////////////////////////////////////////////////////////////////////////////////////////////
193
// variant: 0 --> MAIN  1 --> OIT  2 --> prePOST  3 --> FULL
138 194

  
139 195
  public static void getUniforms(int programH, int variant)
140 196
    {

Also available in: Unified diff