Project

General

Profile

« Previous | Next » 

Revision 3b8f5220

Added by Leszek Koltunski over 2 years ago

Improve two things in the BandagedCreator:

- when one minimizes the app and re-maximizes it, now the app remembers the state of the bandaged cube being created
- when one minimizes the app while one of th cubits is marked, it no longer gets marked the second time on re-maximizaton (which was the reason why some cubits sometimes couldn't be unmarked).

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java
279 279
   @Override
280 280
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
281 281
      {
282
      mWidth = width;
283
      mHeight= height;
284
      rescaleObject();
285

  
286
      mScreen.detachAll();
287
      int touched = mView.getTouched();
288

  
289
      for(int i=0; i<mNumCubits; i++)
290
        if( mCubits[i].isAttached() )
291
          {
292
          mCubits[i].scaleMove(mScaleValue);
293
          if( touched==i ) mCubits[i].setMarked();
294
          else             mCubits[i].setUnmarked();
295
          DistortedNode node = mCubits[i].getNode();
296
          mScreen.attach(node);
297
          }
298

  
299
      mView.setScreenSize(width,height);
300
      mScreen.resize(width,height);
282
      if( width!=mWidth || height!=mHeight )
283
        {
284
        mWidth = width;
285
        mHeight= height;
286
        rescaleObject();
287

  
288
        mScreen.detachAll();
289
        int touched = mView.getTouched();
290

  
291
        for(int i=0; i<mNumCubits; i++)
292
          if( mCubits[i].isAttached() )
293
            {
294
            mCubits[i].scaleMove(mScaleValue);
295
            if( touched==i ) mCubits[i].setMarked();
296
            else             mCubits[i].setUnmarked();
297
            DistortedNode node = mCubits[i].getNode();
298
            mScreen.attach(node);
299
            }
300

  
301
        mView.setScreenSize(width,height);
302
        mScreen.resize(width,height);
303
        }
301 304
      }
302 305

  
303 306
///////////////////////////////////////////////////////////////////////////////////////////////////
......
313 316
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
314 317
      DistortedLibrary.setCull(true);
315 318

  
316
      createCubits();
319
      if( mCubits==null )
320
        {
321
        createCubits();
322
        }
323
      else
324
        {
325
        for(int i=0; i<mNumCubits; i++) mCubits[i].recreateBitmap();
326
        }
327

  
317 328
      mCubitsCreated = true;
329
      mWidth = 0;
330
      mHeight= 0;
318 331
      }
319 332

  
320 333
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/bandaged/BandagedCreatorView.java
269 269
      if( mTouchedIndex2>=0 )
270 270
        {
271 271
        mRenderer.untouchCubit(mTouchedIndex1);
272
        mRenderer.untouchCubit(mTouchedIndex2);
273
        mRenderer.setConnecting(mTouchedIndex1,mTouchedIndex2);
272

  
273
        if( mTouchedIndex2!=mTouchedIndex1 )
274
          {
275
          mRenderer.untouchCubit(mTouchedIndex2);
276
          mRenderer.setConnecting(mTouchedIndex1,mTouchedIndex2);
277
          }
278

  
274 279
        mTouchedIndex1 = -1;
275 280
        mTouchedIndex2 = -1;
276 281
        }
src/main/java/org/distorted/bandaged/BandagedCubit.java
57 57

  
58 58
    private final DistortedNode mNode;
59 59
    private final DistortedEffects mEffects;
60
    private final DistortedTexture mTexture;
60 61
    private final Static3D mMove;
61 62
    private final boolean mRoundCorners;
62 63
    private final int mX, mY, mZ;
......
181 182
      FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance();
182 183
      MeshBase mesh = factory.createMesh(mPosition,mX,mY,mZ,false,mRoundCorners);
183 184

  
184
      DistortedTexture texture = new DistortedTexture();
185
      mTexture = new DistortedTexture();
185 186
      if( mBitmap==null ) createBitmap();
186
      texture.setTextureAlreadyInverted(mBitmap);
187
      mTexture.setTextureAlreadyInverted(mBitmap);
187 188

  
188 189
      resetTextureMaps(mesh);
189 190

  
......
198 199
      mEffects.apply(quat2Effect);
199 200
      mEffects.apply(quat1Effect);
200 201

  
201
      mNode = new DistortedNode(texture,mEffects,mesh);
202
      mNode = new DistortedNode(mTexture,mEffects,mesh);
202 203
      }
203 204

  
204 205
///////////////////////////////////////////////////////////////////////////////////////////////////
......
245 246
      mMove.set( scale*mUnscaledX, scale*mUnscaledY, scale*mUnscaledZ);
246 247
      }
247 248

  
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

  
251
    public void recreateBitmap()
252
      {
253
      if( mBitmap==null ) createBitmap();
254
      mTexture.setTextureAlreadyInverted(mBitmap);
255
      }
256

  
248 257
///////////////////////////////////////////////////////////////////////////////////////////////////
249 258

  
250 259
    public void scaleMove(float scale)
......
256 265

  
257 266
    public void setMarked()
258 267
      {
259
      FragmentEffectBrightness effect = new FragmentEffectBrightness(mAlpha);
260
      mMarkedEffectID = effect.getID();
261
      mEffects.apply(effect);
268
      if( mMarkedEffectID<0 )
269
        {
270
        FragmentEffectBrightness effect = new FragmentEffectBrightness(mAlpha);
271
        mMarkedEffectID = effect.getID();
272
        mEffects.apply(effect);
273
        }
262 274
      }
263 275

  
264 276
///////////////////////////////////////////////////////////////////////////////////////////////////
265 277

  
266 278
    public void setUnmarked()
267 279
      {
268
      if( mMarkedEffectID>=0 ) mEffects.abortById(mMarkedEffectID);
280
      if( mMarkedEffectID>=0 )
281
        {
282
        mEffects.abortById(mMarkedEffectID);
283
        mMarkedEffectID = -1;
284
        }
269 285
      }
270 286

  
271 287
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff