@Override public ReadOnlyVector3 get(final int index) { switch (index) { case 0: return getA(); case 1: return getB(); case 2: return getC(); } throw new IllegalArgumentException("invalid index: " + index); }
@Override public ReadOnlyVector3 get(final int index) { switch (index) { case 0: return getA(); case 1: return getB(); case 2: return getC(); } throw new IllegalArgumentException("invalid index: " + index); }
if (!_workRay.intersectsTriangle(_gridTriA.getA(), _gridTriA.getB(), _gridTriA.getC(), store)) { final boolean intersects = _workRay.intersectsTriangle(_gridTriB.getA(), _gridTriB.getB(), _gridTriB.getC(), store); if (intersects && normalStore != null) { final Vector3 edge1 = Vector3.fetchTempInstance().set(_gridTriB.getB()).subtractLocal(_gridTriB.getA()); final Vector3 edge2 = Vector3.fetchTempInstance().set(_gridTriB.getC()).subtractLocal(_gridTriB.getA()); normalStore.set(edge1).crossLocal(edge2).normalizeLocal(); } else { if (normalStore != null) { final Vector3 edge1 = Vector3.fetchTempInstance().set(_gridTriA.getB()).subtractLocal(_gridTriA.getA()); final Vector3 edge2 = Vector3.fetchTempInstance().set(_gridTriA.getC()).subtractLocal(_gridTriA.getA()); normalStore.set(edge1).crossLocal(edge2).normalizeLocal();
if (!_workRay.intersectsTriangle(_gridTriA.getA(), _gridTriA.getB(), _gridTriA.getC(), store)) { final boolean intersects = _workRay.intersectsTriangle(_gridTriB.getA(), _gridTriB.getB(), _gridTriB.getC(), store); if (intersects && normalStore != null) { final Vector3 edge1 = Vector3.fetchTempInstance().set(_gridTriB.getB()).subtractLocal(_gridTriB.getA()); final Vector3 edge2 = Vector3.fetchTempInstance().set(_gridTriB.getC()).subtractLocal(_gridTriB.getA()); normalStore.set(edge1).crossLocal(edge2).normalizeLocal(); } else { if (normalStore != null) { final Vector3 edge1 = Vector3.fetchTempInstance().set(_gridTriA.getB()).subtractLocal(_gridTriA.getA()); final Vector3 edge2 = Vector3.fetchTempInstance().set(_gridTriA.getC()).subtractLocal(_gridTriA.getA()); normalStore.set(edge1).crossLocal(edge2).normalizeLocal();
@Test public void testGetSet() { final Triangle tri1 = new Triangle(); assertEquals(Vector3.ZERO, tri1.getA()); assertEquals(Vector3.ZERO, tri1.getB()); assertEquals(Vector3.ZERO, tri1.getC()); tri1.setC(Vector3.UNIT_Z); tri1.setIndex(1); assertEquals(Vector3.NEG_ONE, tri1.getA()); assertEquals(Vector3.UNIT_X, tri1.getB()); assertEquals(Vector3.UNIT_Z, tri1.getC()); assertEquals(Vector3.NEG_ONE, tri2.getA()); assertEquals(Vector3.UNIT_X, tri2.getB()); assertEquals(Vector3.UNIT_Z, tri2.getC()); assertEquals(Vector3.ONE, tri3.getA()); assertEquals(Vector3.UNIT_Y, tri3.getB()); assertEquals(Vector3.NEG_ONE, tri3.getC()); assertEquals(Vector3.ONE, tri4.getA()); assertEquals(Vector3.UNIT_Y, tri4.getB()); assertEquals(Vector3.NEG_ONE, tri4.getC());