Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this isn't supposed to be fast... yet
- default void forEachScaled(Vec3i startUnscaled, Vec3i endUnscaled, Vec3i scale, NoiseConsumer consumer) {
- int xScale = scale.getX();
- int yScale = scale.getY();
- int zScale = scale.getZ();
- double stepX = 1.0/xScale;
- double stepY = 1.0/yScale;
- double stepZ = 1.0/zScale;
- int minX = startUnscaled.getX();
- int minY = startUnscaled.getY();
- int minZ = startUnscaled.getZ();
- int maxX = endUnscaled.getX();
- int maxY = endUnscaled.getY();
- int maxZ = endUnscaled.getZ();
- for (int sectionX = minX; sectionX < maxX; ++sectionX) {
- int x = sectionX*xScale;
- for (int sectionZ = minZ; sectionZ < maxZ; ++sectionZ) {
- int z = sectionZ*zScale;
- for (int sectionY = minY; sectionY < maxY; ++sectionY) {
- int y = sectionY*yScale;
- NoiseValue v0y0 = this.get(x, y, z);
- NoiseValue v0y1 = this.get(x, y, z + zScale);
- NoiseValue v1y0 = this.get(x + xScale, y, z);
- NoiseValue v1y1 = this.get(x + xScale, y, z + zScale);
- NoiseValue d0y0 = this.get(x, y + yScale, z).sub(v0y0).mul(stepY);
- NoiseValue d0y1 = this.get(x, y + yScale, z + zScale).sub(v0y1).mul(stepY);
- NoiseValue d1y0 = this.get(x + xScale, y + yScale, z).sub(v1y0).mul(stepY);
- NoiseValue d1y1 = this.get(x + xScale, y + yScale, z + zScale).sub(v1y1).mul(stepY);
- for (int yRel = 0; yRel < yScale; ++yRel) {
- NoiseValue vxy0 = v0y0;
- NoiseValue vxy1 = v0y1;
- NoiseValue dxy0 = v1y0.sub(v0y0).mul(stepZ);
- NoiseValue dxy1 = v1y1.sub(v0y1).mul(stepZ);
- for (int xRel = 0; xRel < xScale; ++xRel) {
- NoiseValue dxyz = vxy1.sub(vxy0).mul(stepX);
- NoiseValue vxyz = vxy0.sub(dxyz);
- for (int zRel = 0; zRel < zScale; ++zRel) {
- vxyz = vxyz.add(dxyz);
- consumer.consume(x + xRel, y + yRel, z + zRel, vxyz);
- }
- vxy0 = vxy0.add(dxy0);
- vxy1 = vxy1.add(dxy1);
- }
- v0y0 = v0y0.add(d0y0);
- v0y1 = v0y1.add(d0y1);
- v1y0 = v1y0.add(d1y0);
- v1y1 = v1y1.add(d1y1);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement