Project

General

Profile

« Previous | Next » 

Revision 835b197e

Added by Leszek Koltunski over 3 years ago

Move the information when was a EffectQueue last time evaluated from the EffectQueues all the way up to the Node which contains them.
The point: we need to reset this time back to 0 every time we attach the Node (and thus start evaluating the Queues inside)

View differences:

src/main/java/org/distorted/library/effect/MatrixEffectScale.java
30 30
 */
31 31
public class MatrixEffectScale extends MatrixEffect
32 32
  {
33
  private Data3D mScale;
33
  private final Data3D mScale;
34 34

  
35 35
///////////////////////////////////////////////////////////////////////////////////////////////////
36 36
/**
src/main/java/org/distorted/library/effect/VertexEffectRotate.java
31 31
  {
32 32
  private static final EffectName NAME = EffectName.VERTEX_ROTATE;
33 33

  
34
  private Data1D mAngle;
35
  private Data3D mAxis, mCenter;
34
  private final Data1D mAngle;
35
  private final Data3D mAxis, mCenter;
36 36

  
37 37
///////////////////////////////////////////////////////////////////////////////////////////////////
38 38
/**
src/main/java/org/distorted/library/effectqueue/EffectQueue.java
49 49
  private static final int DETACH = 2;
50 50
  private static final int DETALL = 3;
51 51

  
52
  long mTime;
53 52
  int mNumEffects;              // 'ToBe' will be more than mNumEffects if doWork() hasn't
54 53
  private int mNumEffectsToBe;  // added them yet (or less if it hasn't removed some yet)
55 54
  Effect[] mEffects;
......
85 84
  EffectQueue(int numFloatUniforms, int numIntUniforms, boolean useUBO, int index)
86 85
    {
87 86
    mCreated        = false;
88
    mTime           = 0;
89 87
    mID             = 0;
90 88
    mNumEffects     = 0;
91 89
    mNumEffectsToBe = 0;
......
105 103
    if( !source.mCreated )
106 104
      {
107 105
      mCreated        = false;
108
      mTime           = 0;
109 106
      mID             = 0;
110 107
      mNumEffects     = 0;
111 108
      mNumEffectsToBe = 0;
......
126 123
    else
127 124
      {
128 125
      mCreated        = true;
129
      mTime           = source.mTime;
130 126
      mID             = source.mID;
131 127
      mNumEffects     = source.mNumEffects;
132 128
      mNumEffectsToBe = source.mNumEffectsToBe;
......
162 158

  
163 159
///////////////////////////////////////////////////////////////////////////////////////////////////
164 160

  
165
  public static void compute(EffectQueue[] queues, long currTime)
161
  public static void compute(EffectQueue[] queues, long currTime, long step)
166 162
    {
167
    ((EffectQueueMatrix     )queues[0]).compute(currTime);
168
    ((EffectQueueVertex     )queues[1]).compute(currTime);
169
    ((EffectQueueFragment   )queues[2]).compute(currTime);
170
    ((EffectQueuePostprocess)queues[3]).compute(currTime);
163
    ((EffectQueueMatrix     )queues[0]).compute(currTime,step);
164
    ((EffectQueueVertex     )queues[1]).compute(currTime,step);
165
    ((EffectQueueFragment   )queues[2]).compute(currTime,step);
166
    ((EffectQueuePostprocess)queues[3]).compute(currTime,step);
171 167
    }
172 168

  
173 169
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effectqueue/EffectQueueFragment.java
63 63

  
64 64
///////////////////////////////////////////////////////////////////////////////////////////////////
65 65
  
66
  void compute(long currTime)
67
    { 
68
    if( currTime==mTime ) return;
69
    if( mTime==0 ) mTime = currTime;
70

  
66
  void compute(long currTime, long step)
67
    {
71 68
    if( mNumEffects>0 )
72 69
      {
73
      long step = (currTime-mTime);
74 70
      float[] array = mUBF.getBackingArray();
75 71

  
76 72
      for(int i=0; i<mNumEffects; i++)
......
81 77
          }
82 78
        }
83 79
      }
84

  
85
    mTime = currTime;  
86 80
    }
87 81

  
88 82
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java
68 68

  
69 69
///////////////////////////////////////////////////////////////////////////////////////////////////
70 70

  
71
  void compute(long currTime)
71
  void compute(long currTime, long step)
72 72
    {
73
    if( currTime==mTime ) return;
74
    if( mTime==0 ) mTime = currTime;
75
    long step = (currTime-mTime);
76
    float[] array = mUBF.getBackingArray();
77

  
78
    for(int i=0; i<mNumEffects; i++)
73
    if( mNumEffects>0 )
79 74
      {
80
      if( mEffects[i].compute(array, NUM_FLOAT_UNIFORMS*i, currTime, step) )
75
      float[] array = mUBF.getBackingArray();
76

  
77
      for(int i=0; i<mNumEffects; i++)
81 78
        {
82
        EffectMessageSender.newMessage(mEffects[i]);
79
        if( mEffects[i].compute(array, NUM_FLOAT_UNIFORMS*i, currTime, step) )
80
          {
81
          EffectMessageSender.newMessage(mEffects[i]);
82
          }
83 83
        }
84 84
      }
85
     
86
    mTime = currTime;  
87 85
    }  
88 86

  
89 87
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
76 76

  
77 77
///////////////////////////////////////////////////////////////////////////////////////////////////
78 78

  
79
  void compute(long currTime)
79
  void compute(long currTime, long step)
80 80
    {
81
    if( currTime==mTime ) return;
82
    if( mTime==0 ) mTime = currTime;
83
    long step = (currTime-mTime);
84

  
85 81
    mR = mG = mB = mA = 0.0f;
86 82
    mHalo = 0;
87 83
    int halo;
......
111 107
      mB = array[4];
112 108
      mA = array[5];
113 109
      }
114

  
115
    mTime = currTime;
116 110
    }
117 111

  
118 112
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java
74 74
 *
75 75
 * @y.exclude
76 76
 */
77
  public void compute(long currTime)
77
  public void compute(long currTime, long step)
78 78
    {
79
    if( currTime==mTime ) return;
80
    if( mTime==0 ) mTime = currTime;
81

  
82 79
    if( mNumEffects>0 )
83 80
      {
84
      long step = (currTime-mTime);
85 81
      float[] array = mUBF.getBackingArray();
86 82

  
87 83
      for(int i=0; i<mNumEffects; i++)
......
94 90

  
95 91
      mUBF.invalidate();
96 92
      }
97

  
98
    mTime = currTime;
99 93
    }
100 94

  
101 95
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/main/DistortedLibrary.java
557 557

  
558 558
    mFullProgram.useProgram();
559 559
    mesh.bindVertexAttribs(mFullProgram);
560
    queue.compute(1);
560
    queue.compute(1,0);
561 561
    queue.send(0.0f,mFullProgramH,3);
562 562
    mesh.send(mFullProgramH,3);
563 563

  
......
573 573

  
574 574
///////////////////////////////////////////////////////////////////////////////////////////////////
575 575

  
576
  static void drawPrivOIT(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime)
576
  static void drawPrivOIT(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime, long step)
577 577
    {
578 578
    if( mMainOITProgram!=null )
579 579
      {
580 580
      EffectQueue[] queues = effects.getQueues();
581 581

  
582
      EffectQueue.compute(queues, currTime);
582
      EffectQueue.compute(queues, currTime, step);
583 583
      GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
584 584

  
585 585
      mMainOITProgram.useProgram();
......
609 609

  
610 610
///////////////////////////////////////////////////////////////////////////////////////////////////
611 611

  
612
  static void drawPriv(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime)
612
  static void drawPriv(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime, long step)
613 613
    {
614 614
    if( mMainProgram!=null )
615 615
      {
616 616
      EffectQueue[] queues = effects.getQueues();
617 617

  
618
      EffectQueue.compute(queues, currTime);
618
      EffectQueue.compute(queues, currTime, step);
619 619
      GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
620 620

  
621 621
      mMainProgram.useProgram();
src/main/java/org/distorted/library/main/DistortedNode.java
52 52
  private int mFboW, mFboH, mFboDepthStencil;
53 53
  private boolean mRenderWayOIT;
54 54
  private float mFOV, mNear;
55
  private long mLastTime;
55 56

  
56 57
///////////////////////////////////////////////////////////////////////////////////////////////////
57 58

  
......
160 161
      {
161 162
      mState.apply();
162 163
      GLES30.glDisable(GLES30.GL_BLEND);
163
      DistortedLibrary.drawPriv(mEffects, mMesh, surface, currTime);
164
      if( mLastTime==0 ) mLastTime=currTime;
165
      DistortedLibrary.drawPriv(mEffects, mMesh, surface, currTime, (currTime-mLastTime));
166
      mLastTime = currTime;
164 167
      GLES30.glEnable(GLES30.GL_BLEND);
165 168
      return 1;
166 169
      }
......
178 181
    if( input.setAsInput() )
179 182
      {
180 183
      mState.apply();
181
      DistortedLibrary.drawPrivOIT(mEffects, mMesh, surface, currTime);
184
      if( mLastTime==0 ) mLastTime=currTime;
185
      DistortedLibrary.drawPrivOIT(mEffects, mMesh, surface, currTime, (currTime-mLastTime));
186
      mLastTime = currTime;
182 187
      return 1;
183 188
      }
184 189

  
......
195 200
    if( input.setAsInput() )
196 201
      {
197 202
      mState.apply();
198
      DistortedLibrary.drawPriv(mEffects, mMesh, surface, currTime);
203
      if( mLastTime==0 ) mLastTime=currTime;
204
      DistortedLibrary.drawPriv(mEffects, mMesh, surface, currTime, (currTime-mLastTime));
205
      mLastTime = currTime;
199 206
      return 1;
200 207
      }
201 208

  
......
294 301
 */
295 302
  public DistortedNode(InternalSurface surface, DistortedEffects effects, MeshBase mesh)
296 303
    {
304
    mLastTime      = 0;
297 305
    mSurface       = surface;
298 306
    mEffects       = effects;
299 307
    mMesh          = mesh;
......
324 332
 */
325 333
  public DistortedNode(DistortedNode node, int flags)
326 334
    {
335
    mLastTime     = 0;
327 336
    mEffects      = new DistortedEffects(node.mEffects,flags);
328 337
    mMesh         = node.mMesh;
329 338
    mState        = new InternalRenderState();
src/main/java/org/distorted/library/main/DistortedScreen.java
174 174

  
175 175
    if( mDebugMode!=DEBUG_MODE_NONE && debugTexture.setAsInput())
176 176
      {
177
      DistortedLibrary.drawPriv(debugEffects, debugMesh, this, time);
177
      DistortedLibrary.drawPriv(debugEffects, debugMesh, this, time,0);
178 178
      }
179 179

  
180 180
    if( mQueueSize<=0 )
src/main/java/org/distorted/library/type/Dynamic3D.java
29 29

  
30 30
public class Dynamic3D extends Dynamic implements Data3D
31 31
  {
32
  private Vector<Static3D> vv;
32
  private final Vector<Static3D> vv;
33 33
  private Static3D prev, curr, next;
34 34

  
35 35
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/uniformblock/UniformBlockAssociation.java
74 74

  
75 75
///////////////////////////////////////////////////////////////////////////////////////////////////
76 76
// stride can be 0, if we just tried compiling a vertex shader which has NUM_VERTEX=0.
77
// stride==1 we also don't like because then we have an exception ( stride*mMax-1 < stride*(mMax-1)+1 )
77 78

  
78 79
  public void correctStride(int stride)
79 80
    {
80
    if( mStride != stride && stride!=0 )
81
    if( mStride != stride && stride>1 )
81 82
      {
82 83
      int[] tmp = new int[stride*mMax];
83 84

  

Also available in: Unified diff