mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
MPC Modifier support
This commit is contained in:
parent
48f581525e
commit
d1c6f5f98e
@ -49,53 +49,67 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> a) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> a, boolean multicore) {
|
||||
if (!getDimension().isCaves()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
BurstExecutor e = getEngine().burst().burst(a.getWidth());
|
||||
for (int i = 0; i < a.getWidth(); i++) {
|
||||
int finalI = i;
|
||||
e.queue(() -> {
|
||||
for (int j = 0; j < a.getDepth(); j++) {
|
||||
KList<CaveResult> caves = genCaves(x + finalI, z + j, finalI, j, a);
|
||||
int he = (int) Math.round(getComplex().getHeightStream().get(x + finalI, z + j));
|
||||
if (caves != null && caves.isNotEmpty()) {
|
||||
IrisBiome cave = getComplex().getCaveBiomeStream().get(x + finalI, z + j);
|
||||
if(multicore)
|
||||
{
|
||||
BurstExecutor e = getEngine().burst().burst(a.getWidth());
|
||||
for (int i = 0; i < a.getWidth(); i++) {
|
||||
int finalI = i;
|
||||
e.queue(() -> modifySliver(x, z, finalI, a));
|
||||
}
|
||||
|
||||
if (cave == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CaveResult cl : caves) {
|
||||
if (cl.getFloor() < 0 || cl.getFloor() > getEngine().getHeight() || cl.getCeiling() > getEngine().getHeight() || cl.getCeiling() < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KList<BlockData> floor = cave.generateLayers(x + finalI, z + j, rng, cl.getFloor(), cl.getFloor(), getData(), getComplex());
|
||||
KList<BlockData> ceiling = cave.generateLayers(x + finalI + 656, z + j - 656, rng,
|
||||
he - cl.getCeiling(),
|
||||
he - cl.getCeiling(), getData(), getComplex());
|
||||
|
||||
for (int g = 0; g < floor.size(); g++) {
|
||||
a.set(finalI, cl.getFloor() - g, j, floor.get(g));
|
||||
}
|
||||
|
||||
for (int g = ceiling.size() - 1; g > 0; g--) {
|
||||
a.set(finalI, cl.getCeiling() + g, j, ceiling.get(g));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
e.complete();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < a.getWidth(); i++) {
|
||||
modifySliver(x, z, i, a);
|
||||
}
|
||||
}
|
||||
|
||||
e.complete();
|
||||
getEngine().getMetrics().getCave().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
public void modifySliver(int x, int z, int finalI, Hunk<BlockData> a)
|
||||
{
|
||||
for (int j = 0; j < a.getDepth(); j++) {
|
||||
KList<CaveResult> caves = genCaves(x + finalI, z + j, finalI, j, a);
|
||||
int he = (int) Math.round(getComplex().getHeightStream().get(x + finalI, z + j));
|
||||
if (caves != null && caves.isNotEmpty()) {
|
||||
IrisBiome cave = getComplex().getCaveBiomeStream().get(x + finalI, z + j);
|
||||
|
||||
if (cave == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CaveResult cl : caves) {
|
||||
if (cl.getFloor() < 0 || cl.getFloor() > getEngine().getHeight() || cl.getCeiling() > getEngine().getHeight() || cl.getCeiling() < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KList<BlockData> floor = cave.generateLayers(x + finalI, z + j, rng, cl.getFloor(), cl.getFloor(), getData(), getComplex());
|
||||
KList<BlockData> ceiling = cave.generateLayers(x + finalI + 656, z + j - 656, rng,
|
||||
he - cl.getCeiling(),
|
||||
he - cl.getCeiling(), getData(), getComplex());
|
||||
|
||||
for (int g = 0; g < floor.size(); g++) {
|
||||
a.set(finalI, cl.getFloor() - g, j, floor.get(g));
|
||||
}
|
||||
|
||||
for (int g = ceiling.size() - 1; g > 0; g--) {
|
||||
a.set(finalI, cl.getCeiling() + g, j, ceiling.get(g));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data) {
|
||||
if (!getDimension().isCaves()) {
|
||||
return EMPTY;
|
||||
|
@ -40,7 +40,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
generateDeposits(rng, output, Math.floorDiv(x, 16), Math.floorDiv(z, 16));
|
||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||
|
@ -47,20 +47,33 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
BurstExecutor e = getEngine().burst().burst(output.getWidth());
|
||||
int i;
|
||||
AtomicInteger j = new AtomicInteger();
|
||||
for (i = 0; i < output.getWidth(); i++) {
|
||||
int finalI = i;
|
||||
e.queue(() -> {
|
||||
for (j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) {
|
||||
post(finalI, j.get(), output, finalI + x, j.get() + z);
|
||||
}
|
||||
});
|
||||
if(multicore)
|
||||
{
|
||||
BurstExecutor e = getEngine().burst().burst(output.getWidth());
|
||||
for (i = 0; i < output.getWidth(); i++) {
|
||||
int finalI = i;
|
||||
e.queue(() -> {
|
||||
for (j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) {
|
||||
post(finalI, j.get(), output, finalI + x, j.get() + z);
|
||||
}
|
||||
});
|
||||
}
|
||||
e.complete();
|
||||
}
|
||||
e.complete();
|
||||
|
||||
else
|
||||
{
|
||||
for (i = 0; i < output.getWidth(); i++) {
|
||||
for (j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) {
|
||||
post(i, j.get(), output, i + x, j.get() + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getEngine().getMetrics().getPost().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
if (!getDimension().isRavines()) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user