@Override public Vector3 localGetSupportingVertexWithoutMargin(Vector3 vec0, Vector3 out) { Stack stack = Stack.enter(); Vector3 supVec = out; supVec.set(0f, 0f, 0f); float maxDot = -1e30f; Vector3 vec = stack.alloc(vec0); float lenSqr = vec.len2(); if (lenSqr < 0.0001f) { vec.set(1f, 0f, 0f); } else { float rlen = 1f / (float) Math.sqrt(lenSqr); vec.scl(rlen); } Vector3 vtx = stack.allocVector3(); float newDot; float radius = getRadius(); Vector3 tmp1 = stack.allocVector3(); Vector3 tmp2 = stack.allocVector3(); Vector3 pos = stack.allocVector3(); { pos.set(0f, 0f, 0f); VectorUtil.setCoord(pos, getUpAxis(), getHalfHeight()); VectorUtil.mul(tmp1, vec, localScaling); tmp1.scl(radius); tmp2.set(vec).scl(getMargin()); vtx.set(pos).add(tmp1); vtx.sub(tmp2); newDot = vec.dot(vtx); if (newDot > maxDot) { maxDot = newDot; supVec.set(vtx); } } { pos.set(0f, 0f, 0f); VectorUtil.setCoord(pos, getUpAxis(), -getHalfHeight()); VectorUtil.mul(tmp1, vec, localScaling); tmp1.scl(radius); tmp2.set(vec).scl(getMargin()); vtx.set(pos).add(tmp1); vtx.sub(tmp2); newDot = vec.dot(vtx); if (newDot > maxDot) { maxDot = newDot; supVec.set(vtx); } } stack.leave(); return out; }
@Override public void circle( float width, float height, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, int divisions, float angleFrom, float angleTo) { tempV1.set(normalX, normalY, normalZ).crs(0, 0, 1); tempV2.set(normalX, normalY, normalZ).crs(0, 1, 0); if (tempV2.len2() > tempV1.len2()) tempV1.set(tempV2); tempV2.set(tempV1.nor()).crs(normalX, normalY, normalZ).nor(); circle( width, height, centerX, centerY, centerZ, normalX, normalY, normalZ, tempV1.x, tempV1.y, tempV1.z, tempV2.x, tempV2.y, tempV2.z, divisions, angleFrom, angleTo); }