Project

General

Profile

« Previous | Next » 

Revision 550db260

Added by Leszek Koltunski over 2 years ago

Progress with BandagedCreator: joining cubits together. Still at least one (probably two) bugs here remain:

1) sometimes some of the walls of the newly creaed joined cubit are incorrectly rotated
2) there is an unpleasant flash when joining

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorView.java
37 37
{
38 38
    private final static int DIRECTION_SENSITIVITY=  12;
39 39
    private int mX, mY;
40
    private int mTouchedIndex;
40
    private int mTouchedIndex1, mTouchedIndex2;
41 41
    private BandagedCreatorRenderer mRenderer;
42 42
    private BandagedTouchControl mTouchControl;
43 43
    private int mScreenWidth, mScreenHeight;
......
54 54
      mX = -1;
55 55
      mY = -1;
56 56

  
57
      mTouchedIndex1 = -1;
58
      mTouchedIndex2 = -1;
59

  
57 60
      if(!isInEditMode())
58 61
        {
59 62
        BandagedCreatorActivity act = (BandagedCreatorActivity)context;
......
136 139
         case MotionEvent.ACTION_DOWN: float x1 = (x -  mScreenWidth*0.5f)/mRenderer.mScreenMin;
137 140
                                       float y1 = (mScreenHeight*0.5f - y)/mRenderer.mScreenMin;
138 141

  
139
                                       mTouchedIndex = mTouchControl.cubitTouched(x1,y1,mRenderer.mQuat2);
142
                                       int index = mTouchControl.cubitTouched(x1,y1,mRenderer.mQuat2);
140 143

  
141
                                       if( mTouchedIndex<0 )
144
                                       if( index<0 )
142 145
                                         {
143 146
                                         mX = x;
144 147
                                         mY = y;
......
148 151
                                         mX = -1;
149 152
                                         mY = -1;
150 153

  
151
                                         mTouchControl.markCubit(mTouchedIndex, BandagedCreatorRenderer.COLOR_MARKED);
154
                                         if( mTouchedIndex1<0 )
155
                                           {
156
                                           mTouchedIndex1 = index;
157
                                           mTouchControl.markCubit(mTouchedIndex1, BandagedCreatorRenderer.COLOR_MARKED);
158
                                           }
159
                                         else if( mTouchedIndex1 != index )
160
                                           {
161
                                           mTouchedIndex2 = index;
162
                                           mTouchControl.markCubit(mTouchedIndex2, BandagedCreatorRenderer.COLOR_MARKED);
163
                                           }
152 164
                                         }
153 165

  
154 166
                                       break;
......
180 192
                                         }
181 193
                                       break;
182 194

  
183
         case MotionEvent.ACTION_UP  : mX = -1;
184
                                       mY = -1;
185

  
186
                                       if( mTouchedIndex>=0 )
195
         case MotionEvent.ACTION_UP  : if( mTouchedIndex2>=0 )
187 196
                                         {
188
                                         mTouchControl.markCubit(mTouchedIndex, BandagedCreatorRenderer.COLOR_DEFAULT);
189
                                         mTouchedIndex = -1;
197
                                         mTouchControl.markCubit(mTouchedIndex1, BandagedCreatorRenderer.COLOR_DEFAULT);
198
                                         mTouchControl.markCubit(mTouchedIndex2, BandagedCreatorRenderer.COLOR_DEFAULT);
199

  
200
                                         mRenderer.tryConnectingCubits(mTouchedIndex1,mTouchedIndex2);
201

  
202
                                         mTouchedIndex1 = -1;
203
                                         mTouchedIndex2 = -1;
190 204
                                         }
191 205

  
206
                                       mX = -1;
207
                                       mY = -1;
208

  
192 209
        	                             resetQuats();
193 210
                                       break;
194 211
         }

Also available in: Unified diff