예제 #1
0
 public void set(Entity e, FloatVal value) {
   FloatVal r = e.get(RIGHT);
   FloatVal l = e.get(LEFT);
   float halfwidth = (r.v - l.v) * 0.5f;
   r.v = value.v + halfwidth;
   l.v = value.v - halfwidth;
 }
예제 #2
0
  @Test
  public void testGet() {
    Entity e = new Entity(EXTENT);

    FloatVal left = e.get(LEFT);
    FloatVal right = e.get(RIGHT);

    left.v = 3.0f;
    right.v = 5.5f;

    assertSame(left, e.get(LEFT));
    assertSame(right, e.get(RIGHT));
    assertEquals(3.0f, e.get(LEFT).v, EPSILON);
    assertEquals(5.5f, e.get(RIGHT).v, EPSILON);

    e.delete();
  }
예제 #3
0
 public FloatVal take(Entity e, FloatVal target) {
   FloatVal r = e.get(RIGHT);
   FloatVal l = e.get(LEFT);
   target.v = (l.v + r.v) * 0.5f;
   return target;
 }