mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Hunk rotation
This commit is contained in:
parent
294a5e39a6
commit
1b96bce44f
@ -25,9 +25,12 @@ import com.volmit.iris.core.command.studio.CommandIrisStudio;
|
|||||||
import com.volmit.iris.core.command.what.CommandIrisWhat;
|
import com.volmit.iris.core.command.what.CommandIrisWhat;
|
||||||
import com.volmit.iris.core.command.world.*;
|
import com.volmit.iris.core.command.world.*;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.plugin.Command;
|
import com.volmit.iris.util.plugin.Command;
|
||||||
import com.volmit.iris.util.plugin.MortarCommand;
|
import com.volmit.iris.util.plugin.MortarCommand;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class CommandIris extends MortarCommand {
|
public class CommandIris extends MortarCommand {
|
||||||
@Command
|
@Command
|
||||||
@ -84,6 +87,7 @@ public class CommandIris extends MortarCommand {
|
|||||||
public boolean handle(VolmitSender sender, String[] args) {
|
public boolean handle(VolmitSender sender, String[] args) {
|
||||||
sender.sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
|
sender.sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
|
||||||
printHelp(sender);
|
printHelp(sender);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ import com.volmit.iris.util.interpolation.InterpolationMethod;
|
|||||||
import com.volmit.iris.util.interpolation.InterpolationMethod3D;
|
import com.volmit.iris.util.interpolation.InterpolationMethod3D;
|
||||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||||
import com.volmit.iris.util.math.BlockPosition;
|
import com.volmit.iris.util.math.BlockPosition;
|
||||||
|
import com.volmit.iris.util.math.M;
|
||||||
|
import com.volmit.iris.util.math.MathHelper;
|
||||||
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
@ -37,6 +39,7 @@ import org.bukkit.block.Biome;
|
|||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -990,15 +993,15 @@ public interface Hunk<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default int getCenterX() {
|
default int getCenterX() {
|
||||||
return Math.round(getWidth() / 2);
|
return (int) Math.floor(getWidth() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int getCenterY() {
|
default int getCenterY() {
|
||||||
return Math.round(getHeight() / 2);
|
return (int) Math.floor(getHeight() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int getCenterZ() {
|
default int getCenterZ() {
|
||||||
return Math.round(getDepth() / 2);
|
return (int) Math.floor(getDepth() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void fill(T t) {
|
default void fill(T t) {
|
||||||
@ -1280,4 +1283,125 @@ public interface Hunk<T> {
|
|||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Hunk<T> rotate(double x, double y, double z)
|
||||||
|
{
|
||||||
|
int w = getWidth();
|
||||||
|
int h = getHeight();
|
||||||
|
int d = getDepth();
|
||||||
|
int i,j,k;
|
||||||
|
int[] c = {w/2,h/2,d/2};
|
||||||
|
int[] b = {0,0,0};
|
||||||
|
int[] iii = {0,0,0};
|
||||||
|
int[] aaa = {w,h,d};
|
||||||
|
int[] aai = {w,h,0};
|
||||||
|
int[] iaa = {0,h,d};
|
||||||
|
int[] aia = {w,0,d};
|
||||||
|
int[] iai = {0,h,0};
|
||||||
|
int[] iia = {0,0,d};
|
||||||
|
int[] aii = {w,0,0};
|
||||||
|
rotate(x,y,z,iii);
|
||||||
|
rotate(x,y,z,aaa);
|
||||||
|
rotate(x,y,z,aai);
|
||||||
|
rotate(x,y,z,iaa);
|
||||||
|
rotate(x,y,z,aia);
|
||||||
|
rotate(x,y,z,iai);
|
||||||
|
rotate(x,y,z,iia);
|
||||||
|
rotate(x,y,z,aii);
|
||||||
|
int maxX = max(iii[0], aaa[0], aai[0], iaa[0], aia[0], iai[0], iia[0], aii[0]);
|
||||||
|
int minX = min(iii[0], aaa[0], aai[0], iaa[0], aia[0], iai[0], iia[0], aii[0]);
|
||||||
|
int maxY = max(iii[1], aaa[1], aai[1], iaa[1], aia[1], iai[1], iia[1], aii[1]);
|
||||||
|
int minY = min(iii[1], aaa[1], aai[1], iaa[1], aia[1], iai[1], iia[1], aii[1]);
|
||||||
|
int maxZ = max(iii[2], aaa[2], aai[2], iaa[2], aia[2], iai[2], iia[2], aii[2]);
|
||||||
|
int minZ = min(iii[2], aaa[2], aai[2], iaa[2], aia[2], iai[2], iia[2], aii[2]);
|
||||||
|
Hunk<T> r = Hunk.newArrayHunk(maxX - minX, maxY - minY, maxZ - minZ);
|
||||||
|
int[] cr = {(maxX - minX)/2,(maxY - minY)/2,(maxZ - minZ)/2};
|
||||||
|
|
||||||
|
for(i = 0; i < w; i++)
|
||||||
|
{
|
||||||
|
for(j = 0; j < h; j++)
|
||||||
|
{
|
||||||
|
for(k = 0; k < d; k++)
|
||||||
|
{
|
||||||
|
b[0] = i - c[0];
|
||||||
|
b[1] = j - c[1];
|
||||||
|
b[2] = k - c[2];
|
||||||
|
rotate(x, y, z, b);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
r.set(b[0] + cr[0], b[1] + cr[1], b[2] + cr[2], get(i, j, k));
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int max(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
|
||||||
|
{
|
||||||
|
return Math.max(Math.max(Math.max(a5, a6), Math.max(a7, a8)), Math.max(Math.max(a1, a2), Math.max(a3, a4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int min(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
|
||||||
|
{
|
||||||
|
return Math.min(Math.min(Math.min(a5, a6), Math.min(a7, a8)), Math.min(Math.min(a1, a2), Math.min(a3, a4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rotate(double x, double y, double z, int[] c)
|
||||||
|
{
|
||||||
|
if(x % 360 != 0)
|
||||||
|
{
|
||||||
|
rotateAroundX(Math.toRadians(x), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(y % 360 != 0)
|
||||||
|
{
|
||||||
|
rotateAroundY(Math.toRadians(y), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z % 360 != 0)
|
||||||
|
{
|
||||||
|
rotateAroundZ(Math.toRadians(z), c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rotateAroundX(double a, int[] c) {
|
||||||
|
rotateAroundX(Math.cos(a), Math.sin(a), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rotateAroundX(double cos, double sin, int[] c) {
|
||||||
|
int y = (int) Math.floor(cos * (double)(c[1]+0.5) - sin * (double)(c[2]+0.5));
|
||||||
|
int z = (int) Math.floor(sin * (double)(c[1]+0.5) + cos * (double)(c[2]+0.5));
|
||||||
|
c[1] = y;
|
||||||
|
c[2] = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rotateAroundY(double a, int[] c) {
|
||||||
|
rotateAroundY(Math.cos(a), Math.sin(a), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rotateAroundY(double cos, double sin, int[] c) {
|
||||||
|
int x = (int) Math.floor(cos * (double)(c[0]+0.5) + sin * (double)(c[2]+0.5));
|
||||||
|
int z = (int) Math.floor(-sin * (double)(c[0]+0.5) + cos * (double)(c[2]+0.5));
|
||||||
|
c[0] = x;
|
||||||
|
c[2] = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rotateAroundZ(double a, int[] c) {
|
||||||
|
rotateAroundZ(Math.cos(a), Math.sin(a), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rotateAroundZ(double cos, double sin, int[] c) {
|
||||||
|
int x = (int) Math.floor(cos * (double)(c[0]+0.5) - sin * (double)(c[1]+0.5));
|
||||||
|
int y = (int) Math.floor(sin * (double)(c[0]+0.5) + cos * (double)(c[1]+0.5));
|
||||||
|
c[0] = x;
|
||||||
|
c[1] = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.matter;
|
package com.volmit.iris.util.matter;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.util.data.Varint;
|
import com.volmit.iris.util.data.Varint;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user