Immutable view of GridAlignedBB
This commit is contained in:
parent
e826b31a99
commit
d13bf42c22
7 changed files with 25 additions and 24 deletions
|
@ -27,6 +27,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.IFlywheelWorld;
|
import com.jozufozu.flywheel.backend.IFlywheelWorld;
|
||||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||||
|
import com.jozufozu.flywheel.light.ReadOnlyBox;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllMovementBehaviours;
|
import com.simibubi.create.AllMovementBehaviours;
|
||||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||||
|
@ -1142,16 +1143,16 @@ public abstract class Contraption {
|
||||||
|
|
||||||
GridAlignedBB betterBounds = GridAlignedBB.ofRadius(radius);
|
GridAlignedBB betterBounds = GridAlignedBB.ofRadius(radius);
|
||||||
|
|
||||||
GridAlignedBB contraptionBounds = GridAlignedBB.from(bounds);
|
ReadOnlyBox contraptionBounds = GridAlignedBB.from(bounds);
|
||||||
if (axis == Direction.Axis.X) {
|
if (axis == Direction.Axis.X) {
|
||||||
betterBounds.maxX = contraptionBounds.maxX;
|
betterBounds.setMaxX(contraptionBounds.getMaxX());
|
||||||
betterBounds.minX = contraptionBounds.minX;
|
betterBounds.setMinX(contraptionBounds.getMinX());
|
||||||
} else if (axis == Direction.Axis.Y) {
|
} else if (axis == Direction.Axis.Y) {
|
||||||
betterBounds.maxY = contraptionBounds.maxY;
|
betterBounds.setMaxY(contraptionBounds.getMaxY());
|
||||||
betterBounds.minY = contraptionBounds.minY;
|
betterBounds.setMinY(contraptionBounds.getMinY());
|
||||||
} else if (axis == Direction.Axis.Z) {
|
} else if (axis == Direction.Axis.Z) {
|
||||||
betterBounds.maxZ = contraptionBounds.maxZ;
|
betterBounds.setMaxZ(contraptionBounds.getMaxZ());
|
||||||
betterBounds.minZ = contraptionBounds.minZ;
|
betterBounds.setMinZ(contraptionBounds.getMinZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds = betterBounds.toAABB();
|
bounds = betterBounds.toAABB();
|
||||||
|
|
|
@ -19,7 +19,7 @@ public abstract class ContraptionLighter<C extends Contraption> implements ILigh
|
||||||
|
|
||||||
bounds = getContraptionBounds();
|
bounds = getContraptionBounds();
|
||||||
|
|
||||||
lightVolume = new LightVolume(contraptionBoundsToVolume(bounds.copy()));
|
lightVolume = new LightVolume(contraptionBoundsToVolume(bounds));
|
||||||
|
|
||||||
lightVolume.initialize(contraption.entity.level);
|
lightVolume.initialize(contraption.entity.level);
|
||||||
scheduleRebuild = true;
|
scheduleRebuild = true;
|
||||||
|
@ -37,7 +37,7 @@ public abstract class ContraptionLighter<C extends Contraption> implements ILigh
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightUpdate(LightProvider world, LightType type, GridAlignedBB changed) {
|
public void onLightUpdate(LightProvider world, LightType type, ReadOnlyBox changed) {
|
||||||
lightVolume.notifyLightUpdate(world, type, changed);
|
lightVolume.notifyLightUpdate(world, type, changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,16 +46,17 @@ public abstract class ContraptionLighter<C extends Contraption> implements ILigh
|
||||||
lightVolume.notifyLightPacket(world, chunkX, chunkZ);
|
lightVolume.notifyLightPacket(world, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GridAlignedBB contraptionBoundsToVolume(GridAlignedBB bounds) {
|
protected GridAlignedBB contraptionBoundsToVolume(ReadOnlyBox box) {
|
||||||
|
GridAlignedBB bounds = box.copy();
|
||||||
bounds.grow(2); // so we have at least enough data on the edges to avoid artifacts and have smooth lighting
|
bounds.grow(2); // so we have at least enough data on the edges to avoid artifacts and have smooth lighting
|
||||||
bounds.minY = Math.max(bounds.minY, 0);
|
bounds.setMinY(Math.max(bounds.getMinY(), 0));
|
||||||
bounds.maxY = Math.min(bounds.maxY, 255);
|
bounds.setMaxY(Math.min(bounds.getMaxY(), 255));
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GridAlignedBB getVolume() {
|
public ReadOnlyBox getVolume() {
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||||
import com.jozufozu.flywheel.light.IMovingListener;
|
import com.jozufozu.flywheel.light.IMovingListener;
|
||||||
import com.jozufozu.flywheel.light.LightProvider;
|
import com.jozufozu.flywheel.light.LightProvider;
|
||||||
import com.jozufozu.flywheel.light.LightUpdater;
|
import com.jozufozu.flywheel.light.ReadOnlyBox;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
|
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
|
|
||||||
public class NonStationaryLighter<C extends Contraption> extends ContraptionLighter<C> implements IMovingListener {
|
public class NonStationaryLighter<C extends Contraption> extends ContraptionLighter<C> implements IMovingListener {
|
||||||
|
@ -17,7 +16,7 @@ public class NonStationaryLighter<C extends Contraption> extends ContraptionLigh
|
||||||
if (getVolume().volume() > AllConfigs.CLIENT.maxContraptionLightVolume.get())
|
if (getVolume().volume() > AllConfigs.CLIENT.maxContraptionLightVolume.get())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GridAlignedBB contraptionBounds = getContraptionBounds();
|
ReadOnlyBox contraptionBounds = getContraptionBounds();
|
||||||
|
|
||||||
if (bounds.sameAs(contraptionBounds)) {
|
if (bounds.sameAs(contraptionBounds)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||||
import com.jozufozu.flywheel.light.IMovingListener;
|
import com.jozufozu.flywheel.light.IMovingListener;
|
||||||
import com.jozufozu.flywheel.light.LightProvider;
|
import com.jozufozu.flywheel.light.LightProvider;
|
||||||
import com.jozufozu.flywheel.light.ListenerStatus;
|
import com.jozufozu.flywheel.light.ListenerStatus;
|
||||||
|
import com.jozufozu.flywheel.light.ReadOnlyBox;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||||
|
|
||||||
|
@ -180,13 +181,11 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
||||||
boolean needsUpdate;
|
boolean needsUpdate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightUpdate(LightProvider world, LightType type, GridAlignedBB changed) {
|
public void onLightUpdate(LightProvider world, LightType type, ReadOnlyBox changed) {
|
||||||
changed.intersectAssign(volume);
|
initLight(world, changed.intersect(volume));
|
||||||
|
|
||||||
initLight(world, changed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initLight(LightProvider world, GridAlignedBB changed) {
|
private void initLight(LightProvider world, ReadOnlyBox changed) {
|
||||||
int top = this.pos.getY();
|
int top = this.pos.getY();
|
||||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||||
changed.forEachContained((x, y, z) -> {
|
changed.forEachContained((x, y, z) -> {
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class PulleyLighter extends ContraptionLighter<PulleyContraption> {
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds.translate(pos);
|
bounds.translate(pos);
|
||||||
bounds.minY = 1; // the super constructor will take care of making this 0
|
bounds.setMinY(1); // the super constructor will take care of making this 0
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
||||||
|
|
||||||
Vector3d cameraPos = event.getCameraPos();
|
Vector3d cameraPos = event.getCameraPos();
|
||||||
|
|
||||||
lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume())
|
lightBox = lighter.lightVolume.getTextureVolume().toAABB()
|
||||||
.move(-cameraPos.x, -cameraPos.y, -cameraPos.z);
|
.move(-cameraPos.x, -cameraPos.y, -cameraPos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import com.jozufozu.flywheel.light.ILightUpdateListener;
|
||||||
import com.jozufozu.flywheel.light.LightProvider;
|
import com.jozufozu.flywheel.light.LightProvider;
|
||||||
import com.jozufozu.flywheel.light.LightUpdater;
|
import com.jozufozu.flywheel.light.LightUpdater;
|
||||||
import com.jozufozu.flywheel.light.ListenerStatus;
|
import com.jozufozu.flywheel.light.ListenerStatus;
|
||||||
|
import com.jozufozu.flywheel.light.ReadOnlyBox;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
|
@ -552,7 +553,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightUpdate(LightProvider world, LightType type, GridAlignedBB changed) {
|
public void onLightUpdate(LightProvider world, LightType type, ReadOnlyBox changed) {
|
||||||
GridAlignedBB beltVolume = getVolume();
|
GridAlignedBB beltVolume = getVolume();
|
||||||
|
|
||||||
if (beltVolume.intersects(changed)) {
|
if (beltVolume.intersects(changed)) {
|
||||||
|
|
Loading…
Reference in a new issue