Project

General

Profile

« Previous | Next » 

Revision aaeef328

Added by Leszek Koltunski about 1 year ago

Support split type 'EDGE_COIN' in case of every shape.

View differences:

src/main/java/org/distorted/objectlib/touchcontrol/TouchControlHexahedron.java
36 36
    super(object,D3D,FACE_AXIS);
37 37
    }
38 38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41
  private int partEdge(float[] point, int face)
42
    {
43
    boolean e0 = point[0] > 0;
44
    boolean e1 = point[1] > 0;
45
    return e0 ? (e1 ? 0:1) : (e1 ? 3:2);
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

  
50
  private int partCorner(float[] point, int face)
51
    {
52
    boolean c0 = point[1] >= point[0];
53
    boolean c1 = point[1] >=-point[0];
54
    return c0 ? (c1 ? 0:3) : (c1 ? 1:2);
55
    }
56

  
39 57
///////////////////////////////////////////////////////////////////////////////////////////////////
40 58
//  corner    edge
41 59
//  \ 0 /     3 | 0
......
43 61
//   / \        |
44 62
//  / 2 \     2 | 1
45 63

  
46
  int returnPart(int type, int face, float[] touchPoint)
64
  int returnPart(int type, int face, float[] point)
47 65
    {
48 66
    switch(type)
49 67
      {
50
      case TYPE_NOT_SPLIT     : return 0;
51
      case TYPE_SPLIT_EDGE    : boolean e0 = touchPoint[0] > 0;
52
                                boolean e1 = touchPoint[1] > 0;
53
                                return e0 ? (e1 ? 0:1) : (e1 ? 3:2);
54
      case TYPE_SPLIT_CORNER  : boolean c0 = touchPoint[1] >= touchPoint[0];
55
                                boolean c1 = touchPoint[1] >=-touchPoint[0];
56
                                return c0 ? (c1 ? 0:3) : (c1 ? 1:2);
57
      case TYPE_SPLIT_EDGE_COIN: // not supported
68
      case TYPE_NOT_SPLIT      : return 0;
69
      case TYPE_SPLIT_EDGE     : return partEdge(point,face);
70
      case TYPE_SPLIT_CORNER   : return partCorner(point,face);
71
      case TYPE_SPLIT_EDGE_COIN: float y = point[1];
72
                                 float x = point[0];
73
                                 return partEdge(point,face) + (x*x+y*y < DIST2D*DIST2D ? 0:4 );
58 74
      }
59 75

  
60 76
    return 0;

Also available in: Unified diff