Revision c7c83fb7
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/main/RubikSurfaceView.java | ||
---|---|---|
234 | 234 |
Static4D rotatedTouchPoint= QuatHelper.rotateVectorByInvertedQuat(touchPoint, mQuat); |
235 | 235 |
Static4D rotatedCamera= QuatHelper.rotateVectorByInvertedQuat(CAMERA_POINT, mQuat); |
236 | 236 |
|
237 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera) ) |
|
237 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera,object.getObjectRatio() ) )
|
|
238 | 238 |
{ |
239 | 239 |
mDragging = false; |
240 | 240 |
mContinuingRotation = false; |
... | ... | |
394 | 394 |
|
395 | 395 |
Static4D touchPoint2 = new Static4D(x, y, 0, 0); |
396 | 396 |
Static4D rotatedTouchPoint2= QuatHelper.rotateVectorByInvertedQuat(touchPoint2, mQuat); |
397 |
Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2); |
|
397 |
Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2,object.getObjectRatio());
|
|
398 | 398 |
|
399 | 399 |
mCurrentAxis = (int)res.get0(); |
400 | 400 |
mCurrentRow = (int)res.get1(); |
src/main/java/org/distorted/objects/Movement.java | ||
---|---|---|
250 | 250 |
// PUBLIC API |
251 | 251 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
252 | 252 |
|
253 |
public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera) |
|
253 |
public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera, float objectRatio)
|
|
254 | 254 |
{ |
255 |
float objectRatio = TwistyObject.getObjectRatio(); |
|
256 |
|
|
257 | 255 |
mPoint[0] = rotatedTouchPoint.get0()/objectRatio; |
258 | 256 |
mPoint[1] = rotatedTouchPoint.get1()/objectRatio; |
259 | 257 |
mPoint[2] = rotatedTouchPoint.get2()/objectRatio; |
... | ... | |
277 | 275 |
|
278 | 276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
279 | 277 |
|
280 |
public Static2D newRotation(int numLayers, Static4D rotatedTouchPoint) |
|
278 |
public Static2D newRotation(int numLayers, Static4D rotatedTouchPoint, float objectRatio)
|
|
281 | 279 |
{ |
282 |
float objectRatio = TwistyObject.getObjectRatio(); |
|
283 |
|
|
284 | 280 |
mPoint[0] = rotatedTouchPoint.get0()/objectRatio; |
285 | 281 |
mPoint[1] = rotatedTouchPoint.get1()/objectRatio; |
286 | 282 |
mPoint[2] = rotatedTouchPoint.get2()/objectRatio; |
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
91 | 91 |
final int NUM_CUBITS; |
92 | 92 |
final int NUM_AXIS; |
93 | 93 |
|
94 |
private static float mInitScreenRatio; |
|
95 |
private static float mObjectScreenRatio = 1.0f; |
|
96 | 94 |
private static final float[] mTmp1 = new float[4]; |
97 | 95 |
private static final float[] mTmp2 = new float[4]; |
98 | 96 |
|
... | ... | |
115 | 113 |
private final float mCameraDist; |
116 | 114 |
private final Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal; |
117 | 115 |
private final DistortedTexture mTexture; |
116 |
private final float mInitScreenRatio; |
|
117 |
private float mObjectScreenRatio; |
|
118 | 118 |
private int mNumTexRows, mNumTexCols; |
119 | 119 |
private int mRotRowBitmap; |
120 | 120 |
private int mRotAxis; |
... | ... | |
137 | 137 |
mOrigPos = getCubitPositions(mNumLayers); |
138 | 138 |
mAxis = getRotationAxis(); |
139 | 139 |
mInitScreenRatio = getScreenRatio(); |
140 |
mObjectScreenRatio = 1.0f; |
|
140 | 141 |
mNumCubitFaces = getNumCubitFaces(); |
141 | 142 |
|
142 | 143 |
mCuts = getCuts(mNumLayers); |
... | ... | |
298 | 299 |
|
299 | 300 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
300 | 301 |
|
301 |
static float getObjectRatio()
|
|
302 |
public float getObjectRatio()
|
|
302 | 303 |
{ |
303 | 304 |
return mObjectScreenRatio*mInitScreenRatio; |
304 | 305 |
} |
src/main/java/org/distorted/tutorials/TutorialSurfaceView.java | ||
---|---|---|
206 | 206 |
Static4D rotatedTouchPoint= QuatHelper.rotateVectorByInvertedQuat(touchPoint, mQuat); |
207 | 207 |
Static4D rotatedCamera= QuatHelper.rotateVectorByInvertedQuat(CAMERA_POINT, mQuat); |
208 | 208 |
|
209 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera) ) |
|
209 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera,object.getObjectRatio()) )
|
|
210 | 210 |
{ |
211 | 211 |
mDragging = false; |
212 | 212 |
mContinuingRotation = false; |
... | ... | |
339 | 339 |
|
340 | 340 |
Static4D touchPoint2 = new Static4D(x, y, 0, 0); |
341 | 341 |
Static4D rotatedTouchPoint2= QuatHelper.rotateVectorByInvertedQuat(touchPoint2, mQuat); |
342 |
Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2); |
|
342 |
Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2,object.getObjectRatio());
|
|
343 | 343 |
|
344 | 344 |
mCurrentAxis = (int)res.get0(); |
345 | 345 |
mCurrentRow = (int)res.get1(); |
Also available in: Unified diff
TwistyObject's ObejctScreenRatio and InitScreenRatio shouldn't be static. Make them non-static.
Otherwise, if the current object is, say, a cube (initSR=0.5), we fire up tutorials and start a tutorial for something with vastly different ObjectScreenRatio (Jing- initSR=1.64), then come back to the Main Activity - so there's a cube on the screen again - the ratios stay at their Jing values, which screws up detection of rotations.