Project

General

Profile

« Previous | Next » 

Revision 9a7e8b98

Added by Leszek Koltunski about 1 year ago

new SPLIT type: type EDGE_COIN (will be used in Coin Tetrahedron).
Only supported in Tetrahedrons for now.

View differences:

src/main/java/org/distorted/objectlib/touchcontrol/TouchControlTetrahedron.java
24 24

  
25 25
  public static final Static3D[] FACE_AXIS = new Static3D[]
26 26
         {
27
           new Static3D(     0,+SQ3/3,+SQ6/3),
28
           new Static3D(     0,+SQ3/3,-SQ6/3),
27
           new Static3D(     0, SQ3/3, SQ6/3),
28
           new Static3D(     0, SQ3/3,-SQ6/3),
29 29
           new Static3D(-SQ6/3,-SQ3/3,     0),
30
           new Static3D(+SQ6/3,-SQ3/3,     0),
30
           new Static3D( SQ6/3,-SQ3/3,     0),
31 31
         };
32 32

  
33 33
///////////////////////////////////////////////////////////////////////////////////////////////////
......
43 43
// 2 | 0      \ /
44 44
//  / \      2 | 1
45 45
// / 1 \       |
46
//
47
// COIN: pieces inside the coin just like in EDGE; outside +=3.
46 48

  
47 49
  int returnPart(int type, int face, float[] touchPoint)
48 50
    {
49 51
    switch(type)
50 52
      {
51
      case TYPE_NOT_SPLIT   : return 0;
53
      case TYPE_NOT_SPLIT      : return 0;
52 54

  
53
      case TYPE_SPLIT_EDGE  : float y1 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
54
                              float x1 = touchPoint[0];
55
      case TYPE_SPLIT_EDGE     : float y1 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
56
                                 float x1 = touchPoint[0];
55 57

  
56
                              boolean e0 = x1>0;
57
                              boolean e1 = y1>(+SQ3/3)*x1;
58
                              boolean e2 = y1>(-SQ3/3)*x1;
58
                                 boolean e0 = x1>0;
59
                                 boolean e1 = y1>( SQ3/3)*x1;
60
                                 boolean e2 = y1>(-SQ3/3)*x1;
59 61

  
60
                              if(  e1 && e2 ) return 0;
61
                              if( !e1 && e0 ) return 1;
62
                              if( !e0 &&!e2 ) return 2;
62
                                 if(  e1 && e2 ) return 0;
63
                                 if( !e1 && e0 ) return 1;
64
                                 if( !e0 &&!e2 ) return 2;
65
                                 return 0;
63 66

  
64
      case TYPE_SPLIT_CORNER: float y2 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
65
                              float x2 = touchPoint[0];
67
      case TYPE_SPLIT_CORNER:    float y2 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
68
                                 float x2 = touchPoint[0];
66 69

  
67
                              boolean c0 = x2>0;
68
                              boolean c1 = y2>(+SQ3/3)*x2;
69
                              boolean c2 = y2>(-SQ3/3)*x2;
70
                                 boolean c0 = x2>0;
71
                                 boolean c1 = y2>( SQ3/3)*x2;
72
                                 boolean c2 = y2>(-SQ3/3)*x2;
70 73

  
71
                              if(  c0 && c2 ) return 0;
72
                              if( !c1 &&!c2 ) return 1;
73
                              if( !c0 && c1 ) return 2;
74
                                 if(  c0 && c2 ) return 0;
75
                                 if( !c1 &&!c2 ) return 1;
76
                                 if( !c0 && c1 ) return 2;
77
                                 return 0;
78
      case TYPE_SPLIT_EDGE_COIN: float y3 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
79
                                 float x3 = touchPoint[0];
80

  
81
                                 boolean s0 = x3>0;
82
                                 boolean s1 = y3>( SQ3/3)*x3;
83
                                 boolean s2 = y3>(-SQ3/3)*x3;
84

  
85
                                 int add = (x3*x3+y3*y3<DIST2D*DIST2D ? 0:3 );
86

  
87
                                 if(  s1 && s2 ) return add;
88
                                 if( !s1 && s0 ) return add+1;
89
                                 if( !s0 &&!s2 ) return add+2;
90
                                 return 0;
74 91
      }
75 92

  
76 93
    return 0;

Also available in: Unified diff