/** * Determine if the image is NPOT. * * @return if the image is a non-power-of-2 image, e.g. having dimensions * that are not powers of 2. */ public boolean isNPOT() { return width != 0 && height != 0 && (!FastMath.isPowerOfTwo(width) || !FastMath.isPowerOfTwo(height)); }
protected TerrainQuad(String name, int patchSize, int quadSize, Vector3f scale, float[] heightMap, int totalSize, Vector2f offset, float offsetAmount) { super(name); if (heightMap == null) heightMap = generateDefaultHeightMap(quadSize); if (!FastMath.isPowerOfTwo(quadSize - 1)) { throw new RuntimeException("size given: " + quadSize + " Terrain quad sizes may only be (2^N + 1)"); } if (FastMath.sqrt(heightMap.length) > quadSize) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Heightmap size is larger than the terrain size. Make sure your heightmap image is the same size as the terrain!"); } this.offset = offset; this.offsetAmount = offsetAmount; this.totalSize = totalSize; this.size = quadSize; this.patchSize = patchSize; this.stepScale = scale; split(patchSize, heightMap); }
if (size < 0 || !FastMath.isPowerOfTwo(size - 1)) { throw new IllegalArgumentException("The size is negative or not of the form 2^N +1" + " (a power of two plus one)");
@Test public void testNearestPowerOfTwo() { for (int i = -100; i < 1; i++) { assert FastMath.nearestPowerOfTwo(i) == 1; } for (int i = 1; i < 10000; i++) { int nextPowerOf2 = FastMath.nearestPowerOfTwo(i); assert i <= nextPowerOf2; assert FastMath.isPowerOfTwo(nextPowerOf2); assert nextPowerOf2 == nearestPowerOfTwoSlow(i); } }
/** * Determine if the image is NPOT. * * @return if the image is a non-power-of-2 image, e.g. having dimensions * that are not powers of 2. */ public boolean isNPOT() { return width != 0 && height != 0 && (!FastMath.isPowerOfTwo(width) || !FastMath.isPowerOfTwo(height)); }
protected TerrainQuad(String name, int patchSize, int quadSize, Vector3f scale, float[] heightMap, int totalSize, Vector2f offset, float offsetAmount) { super(name); if (heightMap == null) heightMap = generateDefaultHeightMap(quadSize); if (!FastMath.isPowerOfTwo(quadSize - 1)) { throw new RuntimeException("size given: " + quadSize + " Terrain quad sizes may only be (2^N + 1)"); } if (FastMath.sqrt(heightMap.length) > quadSize) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Heightmap size is larger than the terrain size. Make sure your heightmap image is the same size as the terrain!"); } this.offset = offset; this.offsetAmount = offsetAmount; this.totalSize = totalSize; this.size = quadSize; this.patchSize = patchSize; this.stepScale = scale; split(patchSize, heightMap); }
if (size < 0 || !FastMath.isPowerOfTwo(size - 1)) { throw new JMException("The size is negative or not of the form 2^N +1" + " (a power of two plus one)");