From a50c8429f2548a885fd81e3845cbbc6bd39af080 Mon Sep 17 00:00:00 2001 From: Peregrine05 <92183530+Peregrine05@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:54:45 +0100 Subject: [PATCH 01/65] Initial testing Current bugs: - Water is invisible - Entities are visible through blocks (probably due to intersection order and not testing against distance to previous intersection test) - Sky / sunlight is visible through blocks --- .../chunky/block/AbstractModelBlock.java | 6 +- .../src/java/se/llbit/chunky/block/Block.java | 23 +- .../se/llbit/chunky/block/ModelBlock.java | 6 +- .../block/legacy/LegacyBlocksFinalizer.java | 3 +- .../block/legacy/UnfinalizedLegacyBlock.java | 6 +- .../block/legacy/blocks/LegacyBanner.java | 7 +- .../block/legacy/blocks/LegacySkull.java | 7 +- .../block/legacy/blocks/LegacyWallBanner.java | 7 +- .../llbit/chunky/block/minecraft/Banner.java | 7 +- .../llbit/chunky/block/minecraft/Beacon.java | 3 +- .../block/minecraft/CakeWithCandle.java | 3 +- .../minecraft/CalibratedSculkSensor.java | 3 +- .../chunky/block/minecraft/Campfire.java | 7 +- .../llbit/chunky/block/minecraft/Candle.java | 3 +- .../chunky/block/minecraft/Cauldron.java | 6 +- .../chunky/block/minecraft/CoralFan.java | 7 +- .../chunky/block/minecraft/DecoratedPot.java | 3 +- .../block/minecraft/EnchantingTable.java | 5 +- .../chunky/block/minecraft/HangingSign.java | 7 +- .../se/llbit/chunky/block/minecraft/Head.java | 9 +- .../llbit/chunky/block/minecraft/Honey.java | 6 +- .../se/llbit/chunky/block/minecraft/Lava.java | 143 +++-- .../chunky/block/minecraft/LavaCauldron.java | 6 +- .../llbit/chunky/block/minecraft/Lectern.java | 7 +- .../chunky/block/minecraft/LightBlock.java | 12 +- .../llbit/chunky/block/minecraft/LilyPad.java | 7 +- .../block/minecraft/PowderSnowCauldron.java | 6 +- .../se/llbit/chunky/block/minecraft/Sign.java | 7 +- .../llbit/chunky/block/minecraft/Slime.java | 6 +- .../chunky/block/minecraft/SporeBlossom.java | 7 +- .../chunky/block/minecraft/UnknownBlock.java | 6 +- .../chunky/block/minecraft/WallBanner.java | 7 +- .../chunky/block/minecraft/WallCoralFan.java | 7 +- .../block/minecraft/WallHangingSign.java | 7 +- .../chunky/block/minecraft/WallHead.java | 9 +- .../chunky/block/minecraft/WallSign.java | 7 +- .../llbit/chunky/block/minecraft/Water.java | 103 ++-- .../se/llbit/chunky/entity/ArmorStand.java | 5 +- .../se/llbit/chunky/entity/BeaconBeam.java | 10 +- .../src/java/se/llbit/chunky/entity/Book.java | 10 +- .../entity/CalibratedSculkSensorAmethyst.java | 4 +- .../java/se/llbit/chunky/entity/Campfire.java | 4 +- .../llbit/chunky/entity/CoralFanEntity.java | 5 +- .../java/se/llbit/chunky/entity/Entity.java | 14 +- .../llbit/chunky/entity/FlameParticles.java | 14 +- .../chunky/entity/HangingSignEntity.java | 7 +- .../se/llbit/chunky/entity/HeadEntity.java | 5 +- .../java/se/llbit/chunky/entity/Lectern.java | 9 +- .../se/llbit/chunky/entity/LilyPadEntity.java | 7 +- .../llbit/chunky/entity/PaintingEntity.java | 5 +- .../se/llbit/chunky/entity/PlayerEntity.java | 14 +- .../java/se/llbit/chunky/entity/Poseable.java | 10 +- .../se/llbit/chunky/entity/SignEntity.java | 6 +- .../se/llbit/chunky/entity/SkullEntity.java | 4 +- .../se/llbit/chunky/entity/SporeBlossom.java | 7 +- .../llbit/chunky/entity/StandingBanner.java | 7 +- .../se/llbit/chunky/entity/WallBanner.java | 7 +- .../chunky/entity/WallCoralFanEntity.java | 5 +- .../chunky/entity/WallHangingSignEntity.java | 7 +- .../llbit/chunky/entity/WallSignEntity.java | 7 +- .../src/java/se/llbit/chunky/map/MapView.java | 3 +- .../java/se/llbit/chunky/model/AABBModel.java | 65 ++- .../llbit/chunky/model/AnimatedQuadModel.java | 45 +- .../se/llbit/chunky/model/BlockModel.java | 4 +- .../java/se/llbit/chunky/model/QuadModel.java | 44 +- .../chunky/model/TexturedBlockModel.java | 38 +- .../src/java/se/llbit/chunky/model/Tint.java | 14 +- .../chunky/model/minecraft/CauldronModel.java | 98 ++-- .../model/minecraft/DecoratedPotModel.java | 5 +- .../model/minecraft/HoneyBlockModel.java | 37 +- .../model/minecraft/LightBlockModel.java | 10 +- .../model/minecraft/SlimeBlockModel.java | 37 +- .../chunky/model/minecraft/SpriteModel.java | 58 +- .../chunky/model/minecraft/WaterModel.java | 146 +++-- .../chunky/renderer/PathTracingRenderer.java | 8 +- .../chunky/renderer/PreviewRenderer.java | 43 +- .../chunky/renderer/TileBasedRenderer.java | 5 +- .../se/llbit/chunky/renderer/WorkerState.java | 5 +- .../projection/ApertureProjector.java | 10 +- .../renderer/projection/FisheyeProjector.java | 5 +- .../ForwardDisplacementProjector.java | 9 +- .../projection/PanoramicProjector.java | 5 +- .../projection/PanoramicSlotProjector.java | 5 +- .../projection/ParallelProjector.java | 19 +- .../renderer/projection/PinholeProjector.java | 5 +- .../chunky/renderer/projection/Projector.java | 5 +- .../renderer/projection/ShiftProjector.java | 6 +- .../SphericalApertureProjector.java | 6 +- .../projection/StereographicProjector.java | 5 +- .../stereo/ODSSinglePerspectiveProjector.java | 3 +- .../stereo/ODSVerticalStackedProjector.java | 3 +- .../OmniDirectionalStereoProjector.java | 11 +- .../chunky/renderer/scene/AlphaBuffer.java | 4 +- .../llbit/chunky/renderer/scene/Camera.java | 55 +- .../se/llbit/chunky/renderer/scene/Fog.java | 9 +- .../renderer/scene/LegacyWaterShader.java | 6 +- .../renderer/scene/OctreeFinalizer.java | 7 +- .../chunky/renderer/scene/PathTracer.java | 541 +----------------- .../chunky/renderer/scene/PreethamSky.java | 3 +- .../renderer/scene/PreviewRayTracer.java | 180 +++--- .../se/llbit/chunky/renderer/scene/Scene.java | 141 +++-- .../chunky/renderer/scene/SceneEntities.java | 26 +- .../renderer/scene/SimplexWaterShader.java | 6 +- .../se/llbit/chunky/renderer/scene/Sky.java | 226 ++------ .../llbit/chunky/renderer/scene/SkyCache.java | 3 +- .../renderer/scene/StillWaterShader.java | 4 +- .../se/llbit/chunky/renderer/scene/Sun.java | 58 +- .../chunky/renderer/scene/WaterShader.java | 4 +- .../chunky/resources/AnimatedTexture.java | 5 +- .../llbit/chunky/resources/SignTexture.java | 5 +- .../se/llbit/chunky/resources/Texture.java | 11 +- .../src/java/se/llbit/chunky/ui/ChunkMap.java | 12 +- .../ui/controller/ChunkyFxController.java | 7 +- .../se/llbit/chunky/ui/dialogs/Poser.java | 352 ++++++------ .../chunky/ui/render/tabs/CameraTab.java | 5 +- .../chunky/ui/render/tabs/EntitiesTab.java | 23 +- .../chunky/ui/render/tabs/LightingTab.java | 34 +- .../java/se/llbit/chunky/world/Dimension.java | 5 +- .../java/se/llbit/chunky/world/Material.java | 110 +++- .../se/llbit/chunky/world/SkymapTexture.java | 8 +- .../world/material/BeaconBeamMaterial.java | 17 +- .../world/material/LilyPadMaterial.java | 16 +- .../llbit/chunky/world/model/CubeModel.java | 13 +- chunky/src/java/se/llbit/math/AABB.java | 77 +-- chunky/src/java/se/llbit/math/ColorUtil.java | 4 +- chunky/src/java/se/llbit/math/Constants.java | 4 + .../src/java/se/llbit/math/Intersectable.java | 2 +- .../se/llbit/math/IntersectionRecord.java | 26 + chunky/src/java/se/llbit/math/Matrix3.java | 10 +- chunky/src/java/se/llbit/math/Octree.java | 185 +++--- chunky/src/java/se/llbit/math/Point3.java | 99 ++++ chunky/src/java/se/llbit/math/Point3i.java | 88 +++ chunky/src/java/se/llbit/math/Quad.java | 18 +- chunky/src/java/se/llbit/math/Ray.java | 45 +- chunky/src/java/se/llbit/math/Ray2.java | 30 + chunky/src/java/se/llbit/math/Triangle.java | 18 +- chunky/src/java/se/llbit/math/Tuple3.java | 7 + chunky/src/java/se/llbit/math/Vector3.java | 8 +- chunky/src/java/se/llbit/math/bvh/BVH.java | 7 +- .../src/java/se/llbit/math/bvh/BinaryBVH.java | 16 +- .../src/java/se/llbit/math/primitive/Box.java | 5 +- .../se/llbit/math/primitive/MutableAABB.java | 14 +- .../se/llbit/math/primitive/Primitive.java | 5 +- .../math/primitive/TexturedTriangle.java | 21 +- chunky/src/java/se/llbit/util/JsonUtil.java | 25 + chunky/src/java/se/llbit/util/VectorUtil.java | 12 + .../chunky/ui/render/tabs/LightingTab.fxml | 4 +- .../llbit/chunky/entity/MarshallingTest.java | 5 +- 148 files changed, 2019 insertions(+), 2028 deletions(-) create mode 100644 chunky/src/java/se/llbit/math/IntersectionRecord.java create mode 100644 chunky/src/java/se/llbit/math/Point3.java create mode 100644 chunky/src/java/se/llbit/math/Point3i.java create mode 100644 chunky/src/java/se/llbit/math/Ray2.java create mode 100644 chunky/src/java/se/llbit/math/Tuple3.java create mode 100644 chunky/src/java/se/llbit/util/VectorUtil.java diff --git a/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java b/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java index 62b38ede33..328ac02367 100644 --- a/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java +++ b/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java @@ -4,7 +4,9 @@ import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import java.util.Random; @@ -42,7 +44,7 @@ public BlockModel getModel() { } @Override - public boolean intersect(Ray ray, Scene scene) { - return model.intersect(ray, scene); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + return model.intersect(ray, intersectionRecord, scene); } } diff --git a/chunky/src/java/se/llbit/chunky/block/Block.java b/chunky/src/java/se/llbit/chunky/block/Block.java index c8eb19c23d..f8739be65a 100644 --- a/chunky/src/java/se/llbit/chunky/block/Block.java +++ b/chunky/src/java/se/llbit/chunky/block/Block.java @@ -8,7 +8,11 @@ import se.llbit.json.JsonString; import se.llbit.json.JsonValue; import se.llbit.math.AABB; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.nbt.Tag; @@ -69,14 +73,13 @@ public double surfaceArea(int face) { * @param scene Scene * @return True if the ray hit this block, false if not */ - public boolean intersect(Ray ray, Scene scene) { - ray.t = Double.POSITIVE_INFINITY; - if (block.intersect(ray)) { - float[] color = texture.getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.distance += ray.tNext; - ray.o.scaleAdd(ray.tNext, ray.d); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + if (block.intersect(ray, intersectionRecord)) { + float[] color = texture.getColor(intersectionRecord.uv.x, intersectionRecord.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); + /*ray.distance += ray.tNext; + ray.o.scaleAdd(ray.tNext, ray.d);*/ return true; } } @@ -101,7 +104,7 @@ public boolean isBlockEntity() { return false; } - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { throw new Error("This block type can not be converted to a block entity: " + getClass().getSimpleName()); } @@ -119,7 +122,7 @@ public boolean isBlockWithEntity() { return false; } - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { throw new Error("This block type can not be converted to an entity: " + getClass().getSimpleName()); } diff --git a/chunky/src/java/se/llbit/chunky/block/ModelBlock.java b/chunky/src/java/se/llbit/chunky/block/ModelBlock.java index 5f9b88ae97..b7ddae95cd 100644 --- a/chunky/src/java/se/llbit/chunky/block/ModelBlock.java +++ b/chunky/src/java/se/llbit/chunky/block/ModelBlock.java @@ -3,7 +3,9 @@ import se.llbit.chunky.model.BlockModel; import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; @PluginApi public interface ModelBlock { @@ -11,7 +13,7 @@ public interface ModelBlock { @PluginApi BlockModel getModel(); - default boolean intersect(Ray ray, Scene scene) { - return getModel().intersect(ray, scene); + default boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + return getModel().intersect(ray, intersectionRecord, scene); } } diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java index 99927e478c..88a81693eb 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java @@ -6,6 +6,7 @@ import se.llbit.chunky.world.ChunkPosition; import se.llbit.chunky.world.Material; import se.llbit.math.Octree; +import se.llbit.math.Point3i; import se.llbit.math.Vector3i; /** @@ -24,7 +25,7 @@ public class LegacyBlocksFinalizer { * @param yMax Max y level to finalize (exclusive) */ public static void finalizeChunk(Octree worldTree, Octree waterTree, BlockPalette palette, - Vector3i origin, ChunkPosition cp, int yMin, int yMax) { + Point3i origin, ChunkPosition cp, int yMin, int yMax) { OctreeFinalizationState finalizerState = new OctreeFinalizationState(worldTree, waterTree, palette, yMin, yMax); for (int cy = yMin; cy < yMax; ++cy) { diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/UnfinalizedLegacyBlock.java b/chunky/src/java/se/llbit/chunky/block/legacy/UnfinalizedLegacyBlock.java index 49ebe10cac..5934d96efc 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/UnfinalizedLegacyBlock.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/UnfinalizedLegacyBlock.java @@ -5,7 +5,9 @@ import se.llbit.chunky.block.FinalizationState; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.log.Log; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.nbt.CompoundTag; /** @@ -53,10 +55,10 @@ private UnfinalizedLegacyBlock(String name, Block block, CompoundTag tag) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { Log.info("Intersecting a UnfinalizedLegacyBlock (" + block.name + "), which is supposed to be replaced"); - return block.intersect(ray, scene); + return block.intersect(ray, intersectionRecord, scene); } /** diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java index 8d6e6036a0..318a2badd6 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java @@ -8,7 +8,10 @@ import se.llbit.chunky.world.BlockData; import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.nbt.ListTag; @@ -56,12 +59,12 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new StandingBanner(position, rotation, parseDesign(entityTag)); } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java index c3bbbcf492..4c9d871e66 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java @@ -9,7 +9,10 @@ import se.llbit.chunky.entity.SkullEntity.Kind; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -36,7 +39,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { Kind kind = getSkullKind(entityTag.get("SkullType").byteValue(0)); int rotation = entityTag.get("Rot").byteValue(0); if (kind == Kind.PLAYER) { @@ -49,7 +52,7 @@ public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java index ff46332ae8..cc99004167 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java @@ -5,7 +5,10 @@ import se.llbit.chunky.entity.WallBanner; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -32,12 +35,12 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new WallBanner(position, facing, LegacyBanner.parseDesign(entityTag)); } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java index 7f0fe77d04..88a535dfaf 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java @@ -25,7 +25,10 @@ import se.llbit.chunky.resources.Texture; import se.llbit.json.Json; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -44,7 +47,7 @@ public Banner(String name, Texture texture, int rotation, int color) { this.color = color; } - @Override public boolean intersect(Ray ray, Scene scene) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -52,7 +55,7 @@ public Banner(String name, Texture texture, int rotation, int color) { return true; } - @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { JsonObject design = StandingBanner.parseDesign(entityTag); design.set("base", Json.of(color)); // Base color is not included in the entity tag in Minecraft 1.13+. return new StandingBanner(position, rotation, design); diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java index 3f6949024b..5e464e3a48 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java @@ -23,6 +23,7 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.model.minecraft.BeaconModel; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -46,7 +47,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { if (entityTag.get("Levels").intValue(0) > 0) { return new BeaconBeam(position); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java index c6cdb2f976..05d50c5b2f 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java @@ -23,6 +23,7 @@ import se.llbit.chunky.entity.FlameParticles; import se.llbit.chunky.model.minecraft.CakeWithCandleModel; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import java.util.Random; @@ -61,7 +62,7 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { return new FlameParticles(position, entity); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java index bb4e503651..65e884579e 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java @@ -23,6 +23,7 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.model.minecraft.CalibratedSculkSensorModel; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Point3; import se.llbit.math.Vector3; public class CalibratedSculkSensor extends AbstractModelBlock { @@ -56,7 +57,7 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { return new CalibratedSculkSensorAmethyst(position, this.facing, isActive(), this); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java index 42c4d59499..7b10ffd40b 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java @@ -22,7 +22,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -44,7 +47,7 @@ public Campfire(String name, se.llbit.chunky.entity.Campfire.Kind kind, String f } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -54,7 +57,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new se.llbit.chunky.entity.Campfire(this.kind, position, this.facing, this.isLit, this); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java index 6c41351fcb..d7b1a90db9 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java @@ -25,6 +25,7 @@ import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; import se.llbit.chunky.world.material.TextureMaterial; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import java.util.Random; @@ -89,7 +90,7 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { if (entity != null) { return new FlameParticles(position, entity); } else { diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Cauldron.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Cauldron.java index 6643e6db37..313f6ff395 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Cauldron.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Cauldron.java @@ -22,7 +22,9 @@ import se.llbit.chunky.model.minecraft.CauldronModel; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class Cauldron extends MinecraftBlockTranslucent { @@ -39,8 +41,8 @@ public int getLevel() { } @Override - public boolean intersect(Ray ray, Scene scene) { - return CauldronModel.intersectWithWater(ray, scene, level); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + return CauldronModel.intersectWithWater(ray, intersectionRecord, scene, level); } @Override diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java index d68a3111c7..b602bddbb3 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java @@ -23,7 +23,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; public class CoralFan extends MinecraftBlockTranslucent { @@ -64,7 +67,7 @@ public static Texture coralTexture(String coralType) { } } - @Override public boolean intersect(Ray ray, Scene scene) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -72,7 +75,7 @@ public static Texture coralTexture(String coralType) { return true; } - @Override public Entity toEntity(Vector3 position) { + @Override public Entity toEntity(Point3 position) { return new CoralFanEntity(position, coralType); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java b/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java index 2d223fdb8c..c1ac753a4b 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java @@ -22,6 +22,7 @@ import se.llbit.chunky.model.minecraft.DecoratedPotModel; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.entity.Entity; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.nbt.StringTag; @@ -64,7 +65,7 @@ public boolean isModifiedByBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new DecoratedPotModel.DecoratedPotSpoutEntity(position, facing); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java b/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java index 7b4a2bf513..cffbd14485 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java @@ -23,6 +23,7 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.model.minecraft.EnchantmentTableModel; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Point3; import se.llbit.math.Vector3; public class EnchantingTable extends AbstractModelBlock { @@ -45,8 +46,8 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Vector3 position) { - Vector3 newPosition = new Vector3(position); + public Entity toEntity(Point3 position) { + Point3 newPosition = new Point3(position); newPosition.add(0, 0.35, 0); Book book = new Book( newPosition, diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java index f669c87a78..7102a496cc 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java @@ -22,7 +22,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.entity.HangingSignEntity; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -42,7 +45,7 @@ public HangingSign(String name, String material, int rotation, boolean attached) } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -52,7 +55,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new HangingSignEntity(position, entityTag, rotation, attached, material); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java index 6c23977ae4..6deb7f3b54 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java @@ -24,7 +24,10 @@ import se.llbit.chunky.entity.SkullEntity.Kind; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.nbt.Tag; @@ -46,7 +49,7 @@ public Head(String name, Texture texture, SkullEntity.Kind type, int rotation) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -61,7 +64,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { return new SkullEntity(position, type, rotation, 1); } @@ -71,7 +74,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { if (type == Kind.PLAYER) { String textureUrl = getTextureUrl(entityTag); return textureUrl != null ? new HeadEntity(position, textureUrl, rotation, 1) diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java index 5fcbfc15bc..fbfcad91b2 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java @@ -22,7 +22,9 @@ import se.llbit.chunky.model.minecraft.HoneyBlockModel; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class Honey extends MinecraftBlockTranslucent { public Honey() { @@ -35,7 +37,7 @@ public Honey() { } @Override - public boolean intersect(Ray ray, Scene scene) { - return HoneyBlockModel.intersect(ray); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + return HoneyBlockModel.intersect(ray, intersectionRecord); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java index 62e5099c36..1f40d2c8e6 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java @@ -22,6 +22,7 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.*; +import se.llbit.util.VectorUtil; import static se.llbit.chunky.block.minecraft.Water.CORNER_0; import static se.llbit.chunky.block.minecraft.Water.CORNER_1; @@ -56,23 +57,19 @@ public boolean isFullBlock() { return (this.data & (1 << FULL_BLOCK)) != 0; } - @Override public boolean intersect(Ray ray, Scene scene) { - ray.t = Double.POSITIVE_INFINITY; - + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { if (isFullBlock()) { - if (fullBlock.intersect(ray)) { - texture.getColor(ray); - ray.distance += ray.tNext; - ray.o.scaleAdd(ray.tNext, ray.d); + if (fullBlock.intersect(ray, intersectionRecord)) { + texture.getColor(intersectionRecord); return true; } return false; } boolean hit = false; - if (bottom.intersect(ray)) { - ray.orientNormal(bottom.n); - ray.t = ray.tNext; + IntersectionRecord intersectionTest = new IntersectionRecord(); + if (bottom.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, bottom.n)); hit = true; } @@ -81,120 +78,110 @@ public boolean isFullBlock() { int c2 = (0xF & (data >> CORNER_2)) % 8; int c3 = (0xF & (data >> CORNER_3)) % 8; Triangle triangle = Water.t012[c0][c1][c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = Water.t230[c2][c3][c0]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = Water.westt[c0][c3]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double y = ray.t * ray.d.y + ray.o.y; - double z = ray.t * ray.d.z + ray.o.z; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double y = intersectionTest.distance * ray.d.y + ray.o.y; + double z = intersectionTest.distance * ray.d.z + ray.o.z; y -= QuickMath.floor(y); z -= QuickMath.floor(z); - ray.u = z; - ray.v = y; + intersectionTest.uv.x = z; + intersectionTest.uv.y = y; hit = true; } triangle = Water.westb[c0]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double y = ray.t * ray.d.y + ray.o.y; - double z = ray.t * ray.d.z + ray.o.z; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double y = intersectionTest.distance * ray.d.y + ray.o.y; + double z = intersectionTest.distance * ray.d.z + ray.o.z; y -= QuickMath.floor(y); z -= QuickMath.floor(z); - ray.u = z; - ray.v = y; + intersectionTest.uv.x = z; + intersectionTest.uv.y = y; hit = true; } triangle = Water.eastt[c1][c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double y = ray.t * ray.d.y + ray.o.y; - double z = ray.t * ray.d.z + ray.o.z; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double y = intersectionTest.distance * ray.d.y + ray.o.y; + double z = intersectionTest.distance * ray.d.z + ray.o.z; y -= QuickMath.floor(y); z -= QuickMath.floor(z); - ray.u = z; - ray.v = y; + intersectionTest.uv.x = z; + intersectionTest.uv.y = y; hit = true; } triangle = Water.eastb[c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double y = ray.t * ray.d.y + ray.o.y; - double z = ray.t * ray.d.z + ray.o.z; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double y = intersectionTest.distance * ray.d.y + ray.o.y; + double z = intersectionTest.distance * ray.d.z + ray.o.z; y -= QuickMath.floor(y); z -= QuickMath.floor(z); - ray.u = z; - ray.v = y; + intersectionTest.uv.x = z; + intersectionTest.uv.y = y; hit = true; } triangle = Water.southt[c0][c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double x = ray.t * ray.d.x + ray.o.x; - double y = ray.t * ray.d.y + ray.o.y; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double x = intersectionTest.distance * ray.d.x + ray.o.x; + double y = intersectionTest.distance * ray.d.y + ray.o.y; x -= QuickMath.floor(x); y -= QuickMath.floor(y); - ray.u = x; - ray.v = y; + intersectionTest.uv.x = x; + intersectionTest.uv.y = y; hit = true; } triangle = Water.southb[c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double x = ray.t * ray.d.x + ray.o.x; - double y = ray.t * ray.d.y + ray.o.y; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double x = intersectionTest.distance * ray.d.x + ray.o.x; + double y = intersectionTest.distance * ray.d.y + ray.o.y; x -= QuickMath.floor(x); y -= QuickMath.floor(y); - ray.u = x; - ray.v = y; + intersectionTest.uv.x = x; + intersectionTest.uv.y = y; hit = true; } triangle = Water.northt[c2][c3]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double x = ray.t * ray.d.x + ray.o.x; - double y = ray.t * ray.d.y + ray.o.y; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double x = intersectionTest.distance * ray.d.x + ray.o.x; + double y = intersectionTest.distance * ray.d.y + ray.o.y; x -= QuickMath.floor(x); y -= QuickMath.floor(y); - ray.u = 1 - x; - ray.v = y; + intersectionTest.uv.x = 1 - x; + intersectionTest.uv.y = y; hit = true; } triangle = Water.northb[c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - double x = ray.t * ray.d.x + ray.o.x; - double y = ray.t * ray.d.y + ray.o.y; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + double x = intersectionTest.distance * ray.d.x + ray.o.x; + double y = intersectionTest.distance * ray.d.y + ray.o.y; x -= QuickMath.floor(x); y -= QuickMath.floor(y); - ray.u = 1 - x; - ray.v = y; + intersectionTest.uv.x = 1 - x; + intersectionTest.uv.y = y; hit = true; } if (hit) { - texture.getColor(ray); - ray.color.w = 1; - ray.distance += ray.tNext; - ray.o.scaleAdd(ray.tNext, ray.d); + texture.getColor(intersectionTest); + intersectionRecord.color.set(intersectionTest.color); + intersectionRecord.color.w = 1; + intersectionRecord.distance += intersectionTest.distance; return true; } return false; diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LavaCauldron.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LavaCauldron.java index e2c96f39f4..ab75cad0f5 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/LavaCauldron.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/LavaCauldron.java @@ -20,7 +20,9 @@ import se.llbit.chunky.model.minecraft.CauldronModel; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class LavaCauldron extends Cauldron { @@ -30,8 +32,8 @@ public LavaCauldron() { } @Override - public boolean intersect(Ray ray, Scene scene) { - return CauldronModel.intersectWithLava(ray); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + return CauldronModel.intersectWithLava(ray, intersectionRecord); } @Override diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java index ee8071214c..ae4afbc16b 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java @@ -22,7 +22,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; public class Lectern extends MinecraftBlockTranslucent { @@ -39,7 +42,7 @@ public Lectern(String facing, boolean hasBook) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -49,7 +52,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { return new se.llbit.chunky.entity.Lectern(position, this.facing, this.hasBook); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LightBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LightBlock.java index acdaa126b3..c20fddabda 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/LightBlock.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/LightBlock.java @@ -24,7 +24,10 @@ import se.llbit.chunky.renderer.RenderMode; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector4; public class LightBlock extends AbstractModelBlock { @@ -51,16 +54,15 @@ public int getLevel() { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { if (scene.getMode() == RenderMode.PREVIEW) { - return previewBlockModel.intersect(ray, scene); + return previewBlockModel.intersect(ray, intersectionRecord, scene); } if (scene.getMode() != RenderMode.PREVIEW && - (!scene.getEmittersEnabled() || emittance < Ray.EPSILON - || ray.depth >= scene.getRayDepth() - 1 || ray.specular)) { + (!scene.getEmittersEnabled() || emittance < Constants.EPSILON)) { return false; } - return this.model.intersect(ray, scene); + return this.model.intersect(ray, intersectionRecord, scene); } @Override diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java index 96d89236cd..1abd5ce550 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java @@ -23,7 +23,10 @@ import se.llbit.chunky.entity.LilyPadEntity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; public class LilyPad extends MinecraftBlockTranslucent { @@ -34,7 +37,7 @@ public LilyPad() { localIntersect = true; } - @Override public boolean intersect(Ray ray, Scene scene) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -42,7 +45,7 @@ public LilyPad() { return true; } - @Override public Entity toEntity(Vector3 position) { + @Override public Entity toEntity(Point3 position) { return new LilyPadEntity(position); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PowderSnowCauldron.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PowderSnowCauldron.java index cc658fd386..b45f772744 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/PowderSnowCauldron.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/PowderSnowCauldron.java @@ -21,7 +21,9 @@ import se.llbit.chunky.model.minecraft.CauldronModel; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class PowderSnowCauldron extends Cauldron { @@ -30,7 +32,7 @@ public PowderSnowCauldron(int level) { } @Override - public boolean intersect(Ray ray, Scene scene) { - return CauldronModel.intersect(ray, getLevel(), Texture.powderSnow); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + return CauldronModel.intersect(ray, intersectionRecord, getLevel(), Texture.powderSnow); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java index fd5ab16226..09d631ec1d 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java @@ -22,7 +22,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.entity.SignEntity; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -39,7 +42,7 @@ public Sign(String name, String material, int rotation) { this.material = material; } - @Override public boolean intersect(Ray ray, Scene scene) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -47,7 +50,7 @@ public Sign(String name, String material, int rotation) { return true; } - @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new SignEntity(position, entityTag, rotation, material); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java index 61301cf887..cd062672f0 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java @@ -22,7 +22,9 @@ import se.llbit.chunky.model.minecraft.SlimeBlockModel; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class Slime extends MinecraftBlockTranslucent { public Slime() { @@ -35,7 +37,7 @@ public Slime() { } @Override - public boolean intersect(Ray ray, Scene scene) { - return SlimeBlockModel.intersect(ray); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + return SlimeBlockModel.intersect(ray, intersectionRecord); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java index c9a8ea0e0d..e5da1231be 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java @@ -22,7 +22,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; public class SporeBlossom extends Block { @@ -35,7 +38,7 @@ public SporeBlossom() { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -45,7 +48,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { return new se.llbit.chunky.entity.SporeBlossom(position); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/UnknownBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/UnknownBlock.java index e0434cf392..dc88044b7f 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/UnknownBlock.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/UnknownBlock.java @@ -20,7 +20,9 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class UnknownBlock extends SpriteBlock { public static final UnknownBlock UNKNOWN = new UnknownBlock("?"); @@ -30,10 +32,10 @@ public UnknownBlock(String name) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { if (scene.getHideUnknownBlocks()) { return false; } - return super.intersect(ray, scene); + return super.intersect(ray, intersectionRecord, scene); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java index 47024654a2..785b2d0d97 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java @@ -25,7 +25,10 @@ import se.llbit.chunky.resources.Texture; import se.llbit.json.Json; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -55,7 +58,7 @@ public WallBanner(String name, Texture texture, String facing, int color) { this.color = color; } - @Override public boolean intersect(Ray ray, Scene scene) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -63,7 +66,7 @@ public WallBanner(String name, Texture texture, String facing, int color) { return true; } - @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { JsonObject design = StandingBanner.parseDesign(entityTag); design.set("base", Json.of(color)); // Base color is not included in the entity tag in Minecraft 1.13+. return new se.llbit.chunky.entity.WallBanner(position, facing, design); diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java index c1c1f1f600..4550c8678b 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java @@ -22,7 +22,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.entity.WallCoralFanEntity; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; public class WallCoralFan extends MinecraftBlockTranslucent { @@ -39,7 +42,7 @@ public WallCoralFan(String name, String coralType, String facing) { invisible = true; } - @Override public boolean intersect(Ray ray, Scene scene) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -47,7 +50,7 @@ public WallCoralFan(String name, String coralType, String facing) { return true; } - @Override public Entity toEntity(Vector3 position) { + @Override public Entity toEntity(Point3 position) { return new WallCoralFanEntity(position, coralType, facing); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java index 1afccff9fc..6c45f6e8ef 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java @@ -23,7 +23,10 @@ import se.llbit.chunky.entity.HangingSignEntity; import se.llbit.chunky.entity.WallHangingSignEntity; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -41,7 +44,7 @@ public WallHangingSign(String name, String material, String facing) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -51,7 +54,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new WallHangingSignEntity(position, entityTag, facing, material); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java index eb882a1535..143100ba9e 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java @@ -25,7 +25,10 @@ import se.llbit.chunky.entity.SkullEntity.Kind; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -59,7 +62,7 @@ public WallHead(String name, Texture texture, SkullEntity.Kind type, String faci } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -74,7 +77,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Vector3 position) { + public Entity toEntity(Point3 position) { return new SkullEntity(position, type, 0, facing); } @@ -84,7 +87,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { if (type == Kind.PLAYER) { String textureUrl = Head.getTextureUrl(entityTag); return textureUrl != null ? new HeadEntity(position, textureUrl, 0, facing) diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java index dd833d102e..5b4cc139b2 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java @@ -23,7 +23,10 @@ import se.llbit.chunky.entity.SignEntity; import se.llbit.chunky.entity.WallSignEntity; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -54,7 +57,7 @@ public WallSign(String name, String material, String facing) { } } - @Override public boolean intersect(Ray ray, Scene scene) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return false; } @@ -62,7 +65,7 @@ public WallSign(String name, String material, String facing) { return true; } - @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { return new WallSignEntity(position, entityTag, facing, material); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java index 1f819f50ff..af92eee9dd 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java @@ -20,13 +20,17 @@ import se.llbit.chunky.block.MinecraftBlockTranslucent; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.chunky.renderer.scene.StillWaterShader; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Quad; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Triangle; import se.llbit.math.Vector3; import se.llbit.math.Vector4; +import se.llbit.util.VectorUtil; public class Water extends MinecraftBlockTranslucent { @@ -189,33 +193,30 @@ public boolean isFullBlock() { } } - @Override public boolean intersect(Ray ray, Scene scene) { - ray.t = Double.POSITIVE_INFINITY; + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + IntersectionRecord intersectionTest = new IntersectionRecord(); - int data = ray.getCurrentData(); + int data = intersectionRecord.material instanceof Water ? ((Water) intersectionRecord.material).data : 0; int isFull = (data >> FULL_BLOCK) & 1; if (isFull != 0) { boolean hit = false; for (Quad quad : fullBlock) { - if (quad.intersect(ray)) { - texture.getAvgColorLinear(ray.color); - ray.t = ray.tNext; - ray.orientNormal(quad.n); + if (quad.intersect(ray, intersectionTest)) { + texture.getAvgColorLinear(intersectionRecord.color); + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); hit = true; } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.distance += intersectionTest.distance; } return hit; } boolean hit = false; - if (bottom.intersect(ray)) { - ray.orientNormal(bottom.n); - ray.t = ray.tNext; + if (bottom.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, bottom.n)); hit = true; } @@ -224,79 +225,71 @@ public boolean isFullBlock() { int c2 = (0xF & (data >> CORNER_2)) % 8; int c3 = (0xF & (data >> CORNER_3)) % 8; Triangle triangle = t012[c0][c1][c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = t230[c2][c3][c0]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = westt[c0][c3]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = westb[c0]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = eastt[c1][c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = eastb[c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = southt[c0][c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = southb[c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = northt[c2][c3]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = northb[c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } if (hit) { - texture.getAvgColorLinear(ray.color); - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + if (!(scene.getCurrentWaterShader() instanceof StillWaterShader) && intersectionRecord.shadeN.y != 0) { + scene.getCurrentWaterShader().doWaterShading(ray, intersectionRecord, scene.getAnimationTime()); + } + texture.getAvgColorLinear(intersectionRecord.color); + intersectionRecord.distance += intersectionTest.distance; } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java b/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java index a4d8c76c55..afc33317c4 100644 --- a/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java +++ b/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java @@ -23,6 +23,7 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.QuickMath; import se.llbit.math.Transform; @@ -377,7 +378,7 @@ public class ArmorStand extends Entity implements Poseable, Geared { private final boolean noBasePlate; public ArmorStand(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); this.scale = json.get("scale").asDouble(1.0); this.headScale = json.get("headScale").asDouble(1.0); this.showArms = json.get("showArms").asBoolean(false); @@ -387,7 +388,7 @@ public ArmorStand(JsonObject json) { this.noBasePlate = json.get("noBasePlate").asBoolean(false); } - public ArmorStand(Vector3 position, Tag tag) { + public ArmorStand(Point3 position, Tag tag) { super(position); gear = new JsonObject(); Tag handItems = tag.get("HandItems"); diff --git a/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java b/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java index 9df60b648d..e6c1d99cb1 100644 --- a/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java +++ b/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java @@ -12,6 +12,8 @@ import se.llbit.log.Log; import se.llbit.math.ColorUtil; import se.llbit.math.Octree; +import se.llbit.math.Point3; +import se.llbit.math.Point3i; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -60,14 +62,14 @@ public class BeaconBeam extends Entity implements Poseable { private int height = 256; private final Int2ObjectOpenHashMap materials = new Int2ObjectOpenHashMap<>(); - public BeaconBeam(Vector3 position) { + public BeaconBeam(Point3 position) { super(position); this.pose = new JsonObject(); pose.add("all", JsonUtil.vec3ToJson(new Vector3(0, 0, 0))); } public BeaconBeam(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); this.scale = json.get("scale").asDouble(1); this.height = json.get("height").asInt(256); this.pose = json.get("pose").object(); @@ -81,14 +83,14 @@ public BeaconBeam(JsonObject json) { } @Override - public void loadDataFromOctree(Octree octree, BlockPalette palette, Vector3i origin) { + public void loadDataFromOctree(Octree octree, BlockPalette palette, Point3i origin) { int firstColor = BeaconBeamMaterial.DEFAULT_COLOR; boolean foundFirst = false; this.materials.put(0, new BeaconBeamMaterial(BeaconBeamMaterial.DEFAULT_COLOR)); //Start i at 1 so the first beacon block is not checked. This would cause the base beam color to always be white. //Stop iterating if the we get outside octree. - for (int i = 1; i < height && octree.isInside(new Vector3((position.x - origin.x), (position.y + i - origin.y), (position.z - origin.z))); i++) { + for (int i = 1; i < height && octree.isInside(new Point3((position.x - origin.x), (position.y + i - origin.y), (position.z - origin.z))); i++) { Material blockMaterial = octree.getMaterial((int)(position.x - origin.x), (int)(position.y + i - origin.y), (int)(position.z - origin.z), palette); int color = getColorFromBlock((Block)blockMaterial); if(color != -1) { diff --git a/chunky/src/java/se/llbit/chunky/entity/Book.java b/chunky/src/java/se/llbit/chunky/entity/Book.java index 5179d9f797..4aeb85b62b 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Book.java +++ b/chunky/src/java/se/llbit/chunky/entity/Book.java @@ -10,6 +10,8 @@ import se.llbit.json.Json; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Constants; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Ray; import se.llbit.math.Transform; @@ -183,7 +185,7 @@ public class Book extends Entity implements Poseable { private final JsonObject pose; private double scale = 1; - public Book(Vector3 position, double openAngle, double pageAngleA, double pageAngleB) { + public Book(Point3 position, double openAngle, double pageAngleA, double pageAngleB) { super(position); this.openAngle = openAngle; this.pageAngleA = Math.max(openAngle, pageAngleA); @@ -193,7 +195,7 @@ public Book(Vector3 position, double openAngle, double pageAngleA, double pageAn } public Book(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); this.openAngle = json.get("openAngle").doubleValue(0); this.pageAngleA = json.get("pageAngleA").doubleValue(0); this.pageAngleB = json.get("pageAngleB").doubleValue(0); @@ -234,7 +236,7 @@ public Collection primitives(Transform transform) { double pagesDistance = (1 - Math.sin(Math.PI / 2 - pageAngle)) / 16.0; for (int i = 0; i < leftPages.length; i++) { - if (i == 5 && openAngle < Ray.EPSILON) { + if (i == 5 && openAngle < Constants.EPSILON) { continue; // the cover would overlay the pages if the book is closed } if (i == 4 && (pageAngleA >= (Math.PI + openAngle) / 2 @@ -247,7 +249,7 @@ public Collection primitives(Transform transform) { } for (int i = 0; i < rightPages.length; i++) { - if (i == 5 && openAngle < Ray.EPSILON) { + if (i == 5 && openAngle < Constants.EPSILON) { continue; // the cover would overlay the pages if the book is closed } if (i == 4 && (pageAngleA <= (Math.PI - openAngle) / 2 diff --git a/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java b/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java index b6fe4591e8..1aae627fd0 100644 --- a/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java +++ b/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java @@ -63,7 +63,7 @@ public class CalibratedSculkSensorAmethyst extends Entity { public static final Material activeMaterial = new TextureMaterial(Texture.calibratedSculkSensorAmethyst); public static final Material inactiveMaterial = new TextureMaterial(Texture.calibratedSculkSensorAmethyst); - public CalibratedSculkSensorAmethyst(Vector3 position, String facing, boolean active, CalibratedSculkSensor block) { + public CalibratedSculkSensorAmethyst(Point3 position, String facing, boolean active, CalibratedSculkSensor block) { super(position); this.facing = facing; this.active = active; @@ -71,7 +71,7 @@ public CalibratedSculkSensorAmethyst(Vector3 position, String facing, boolean ac } public CalibratedSculkSensorAmethyst(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); this.facing = json.get("facing").stringValue("north"); this.active = json.get("active").boolValue(true); this.block = null; diff --git a/chunky/src/java/se/llbit/chunky/entity/Campfire.java b/chunky/src/java/se/llbit/chunky/entity/Campfire.java index 36c8436860..efadc26680 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Campfire.java +++ b/chunky/src/java/se/llbit/chunky/entity/Campfire.java @@ -281,7 +281,7 @@ public static double surfaceArea(int face) { private final boolean isLit; private final Block block; - public Campfire(Campfire.Kind kind, Vector3 position, String facing, boolean lit, Block block) { + public Campfire(Campfire.Kind kind, Point3 position, String facing, boolean lit, Block block) { super(position); this.kind = kind; this.facing = facing; @@ -290,7 +290,7 @@ public Campfire(Campfire.Kind kind, Vector3 position, String facing, boolean lit } public Campfire(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); this.kind = Campfire.Kind.valueOf(json.get("campfireKind").stringValue("CAMPFIRE")); this.facing = json.get("facing").stringValue("north"); this.isLit = json.get("lit").boolValue(true); diff --git a/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java b/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java index 5b39a00c16..92be967a20 100644 --- a/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java @@ -23,6 +23,7 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -79,7 +80,7 @@ public class CoralFanEntity extends Entity { }; private final String coralType; - public CoralFanEntity(Vector3 position, String coralType) { + public CoralFanEntity(Point3 position, String coralType) { super(position); this.coralType = coralType; } @@ -107,7 +108,7 @@ public CoralFanEntity(Vector3 position, String coralType) { } public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); return new CoralFanEntity(position, json.get("coral_type").stringValue("tube")); } diff --git a/chunky/src/java/se/llbit/chunky/entity/Entity.java b/chunky/src/java/se/llbit/chunky/entity/Entity.java index 11d6bd361a..0507af14fb 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Entity.java +++ b/chunky/src/java/se/llbit/chunky/entity/Entity.java @@ -25,6 +25,8 @@ import se.llbit.json.JsonValue; import se.llbit.math.Grid; import se.llbit.math.Octree; +import se.llbit.math.Point3; +import se.llbit.math.Point3i; import se.llbit.math.Vector3; import se.llbit.math.Vector3i; import se.llbit.math.primitive.Primitive; @@ -38,10 +40,10 @@ */ abstract public class Entity { - public final Vector3 position; + public final Point3 position; - protected Entity(Vector3 position) { - this.position = new Vector3(position); + protected Entity(Point3 position) { + this.position = new Point3(position); } abstract public Collection primitives(Vector3 offset); @@ -57,7 +59,7 @@ public Grid.EmitterPosition[] getEmitterPosition() { * @param palette The scene's block palate * @param origin The Octree's origin */ - public void loadDataFromOctree(Octree octree, BlockPalette palette, Vector3i origin) { + public void loadDataFromOctree(Octree octree, BlockPalette palette, Point3i origin) { } /** @@ -124,11 +126,11 @@ public static Entity fromJson(JsonObject json) { return null; } - public Vector3 getPosition() { + public Point3 getPosition() { return position; } - public void setPosition(Vector3 position) { + public void setPosition(Point3 position) { this.position.set(position); } } diff --git a/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java b/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java index 1f0945d200..5f44efd2f9 100644 --- a/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java +++ b/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java @@ -53,27 +53,27 @@ public class FlameParticles extends Entity { private final double scale; private final Block block; - public FlameParticles(Vector3 position, double scale, Block block, Vector3[] flames) { + public FlameParticles(Point3 position, double scale, Block block, Vector3[] flames) { super(position); this.flames = flames; this.scale = scale; this.block = block; } - public FlameParticles(Vector3 position, Block block, Vector3[] flames) { + public FlameParticles(Point3 position, Block block, Vector3[] flames) { this(position, 1, block, flames); } public FlameParticles(Block block, Vector3[] flames) { - this(new Vector3(0, 0, 0), 1, block, flames); + this(new Point3(0, 0, 0), 1, block, flames); } - public FlameParticles(Vector3 position, FlameParticles other) { + public FlameParticles(Point3 position, FlameParticles other) { this(position, other.scale, other.block, other.flames); } public FlameParticles(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); this.block = null; this.scale = json.get("scale").asDouble(1.0); if (json.get("particles").isArray()) { @@ -81,7 +81,7 @@ public FlameParticles(JsonObject json) { .map(JsonUtil::vec3FromJsonObject) .toArray(Vector3[]::new); } else { - this.flames = new Vector3[]{position}; + this.flames = new Vector3[]{position.asVector()}; } } @@ -97,7 +97,7 @@ public Collection primitives(Vector3 offset) { .translate(0.5, 1 / 16.0, 0.5) .translate(flameOffset) .translate(offset) - .translate(position)); + .translate(position.asVector())); } } return faces; diff --git a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java index 4863ce9bb7..551d9d10e5 100644 --- a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java @@ -7,6 +7,7 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -260,11 +261,11 @@ public class HangingSignEntity extends Entity { private final Texture texture; private final String material; - public HangingSignEntity(Vector3 position, CompoundTag entityTag, int rotation, boolean attached, String material) { + public HangingSignEntity(Point3 position, CompoundTag entityTag, int rotation, boolean attached, String material) { this(position, SignEntity.getFrontTextLines(entityTag), SignEntity.getFrontDyeColor(entityTag), SignEntity.getFrontGlowing(entityTag), SignEntity.getBackTextLines(entityTag), SignEntity.getBackDyeColor(entityTag), SignEntity.getBackGlowing(entityTag), rotation, attached, material); } - public HangingSignEntity(Vector3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, int rotation, boolean attached, String material) { + public HangingSignEntity(Point3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, int rotation, boolean attached, String material) { super(position); Texture signTexture = HangingSignEntity.textureFromMaterial(material); this.frontText = frontText; @@ -330,7 +331,7 @@ public JsonValue toJson() { * Unmarshalls a sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); JsonArray[] frontText = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java b/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java index deec5532b3..847e83d58c 100644 --- a/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java @@ -33,6 +33,7 @@ import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; import se.llbit.log.Log; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -65,7 +66,7 @@ public class HeadEntity extends Entity { */ private final String skin; - public HeadEntity(Vector3 position, String skin, int rotation, int placement) { + public HeadEntity(Point3 position, String skin, int rotation, int placement) { super(position); this.skin = skin; this.rotation = rotation; @@ -194,7 +195,7 @@ public JsonValue toJson() { } public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); //int type = json.get("type").intValue(0); int rotation = json.get("rotation").intValue(0); diff --git a/chunky/src/java/se/llbit/chunky/entity/Lectern.java b/chunky/src/java/se/llbit/chunky/entity/Lectern.java index c2ab652e58..37b8b5b70b 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Lectern.java +++ b/chunky/src/java/se/llbit/chunky/entity/Lectern.java @@ -7,6 +7,7 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -147,7 +148,7 @@ public class Lectern extends Entity implements Poseable { private final String facing; private final Book book; - public Lectern(Vector3 position, String facing, boolean hasBook) { + public Lectern(Point3 position, String facing, boolean hasBook) { super(position); this.facing = facing; if (hasBook) { @@ -158,7 +159,7 @@ public Lectern(Vector3 position, String facing, boolean hasBook) { } public Lectern(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); this.facing = json.get("facing").stringValue("north"); if (json.get("book").isObject()) { this.book = Book.fromJson(json.get("book").object()); @@ -245,8 +246,8 @@ private static double getBookYaw(String facing) { } } - private static Book createBookEntity(Vector3 position, String facing) { - Vector3 bookPosition = new Vector3(position); + private static Book createBookEntity(Point3 position, String facing) { + Point3 bookPosition = new Point3(position); bookPosition.add(0, 8.5 / 16.0, 0); switch (facing) { diff --git a/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java b/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java index 1c934094b9..c012fddcfd 100644 --- a/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java @@ -20,6 +20,7 @@ import se.llbit.chunky.world.material.LilyPadMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Vector2; import se.llbit.math.Vector3; import se.llbit.math.primitive.Primitive; @@ -33,12 +34,12 @@ public class LilyPadEntity extends Entity { private static final Material lilyMaterial = new LilyPadMaterial(); private final int rotation; - public LilyPadEntity(Vector3 position) { + public LilyPadEntity(Point3 position) { this(position, 3 & (int) (MinecraftPRNG.rand( (long) position.x, (long) position.y, (long) position.z) >> 16)); } - public LilyPadEntity(Vector3 position, int rotation) { + public LilyPadEntity(Point3 position, int rotation) { super(position); this.rotation = rotation; } @@ -90,7 +91,7 @@ public LilyPadEntity(Vector3 position, int rotation) { * Unmarshall a lily pad entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); int rotation = json.get("rotation").intValue(0); return new LilyPadEntity(position, rotation); diff --git a/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java b/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java index 3dd6cd83df..385d962230 100644 --- a/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java @@ -28,6 +28,7 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.QuickMath; import se.llbit.math.Transform; @@ -142,7 +143,7 @@ public Painting(Texture painting, int w, int h) { private final double angle; private final String art; - public PaintingEntity(Vector3 position, String art, double angle) { + public PaintingEntity(Point3 position, String art, double angle) { super(position); this.art = art; this.angle = angle; @@ -183,7 +184,7 @@ public JsonValue toJson() { * @return deserialized entity, or {@code null} if it was not a valid entity */ public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); String art = json.get("art").stringValue(""); double angle = json.get("angle").doubleValue(0.0); diff --git a/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java b/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java index 97d6920750..7b6feca425 100644 --- a/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java @@ -68,16 +68,16 @@ public class PlayerEntity extends Entity implements Poseable, Geared { public String skin = ""; public boolean showOuterLayer = true; - public PlayerEntity(String uuid, Vector3 position) { + public PlayerEntity(String uuid, Point3 position) { this(uuid, position, 0, 0, new JsonObject()); } public PlayerEntity(PlayerEntityData data) { - this(data.uuid, new Vector3(data.x, data.y, data.z), data.rotation, data.pitch, + this(data.uuid, new Point3(data.x, data.y, data.z), data.rotation, data.pitch, buildGear(data)); } - protected PlayerEntity(String uuid, Vector3 position, double rotationDegrees, double pitchDegrees, + protected PlayerEntity(String uuid, Point3 position, double rotationDegrees, double pitchDegrees, JsonObject gear) { super(position); this.uuid = uuid; @@ -96,7 +96,7 @@ protected PlayerEntity(String uuid, Vector3 position, double rotationDegrees, do public PlayerEntity(JsonObject settings) { - super(JsonUtil.vec3FromJsonObject(settings.get("position"))); + super(JsonUtil.point3FromJsonObject(settings.get("position"))); this.model = PlayerModel.get(settings.get("model").stringValue("STEVE")); this.uuid = settings.get("uuid").stringValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); this.skin = settings.get("skin").stringValue(""); @@ -460,7 +460,7 @@ public static void addArmor(Collection faces, .chain(worldTransform); String headItemId = headItem.get("id").asString(""); if (headItemId.equals("minecraft:dragon_head")) { - SkullEntity skull = new SkullEntity(new Vector3(), Kind.DRAGON, 0, 1); + SkullEntity skull = new SkullEntity(new Point3(), Kind.DRAGON, 0, 1); faces.addAll(skull.dragonHeadPrimitives(Transform.NONE.translate(0.5, 0.5, 0.5).scale(1.2).chain(transform))); } else if (headItemId.equals("minecraft:carved_pumpkin")) { Box hat = new Box(-4.25 / 16., 4.25 / 16., -4.25 / 16., 4.25 / 16., -4.25 / 16., 4.25 / 16.); @@ -480,10 +480,10 @@ public static void addArmor(Collection faces, hat.addTopFaces(faces, Texture.pumpkinTop, new Vector4(1, 0, 1, 0)); hat.addBottomFaces(faces, Texture.pumpkinTop, new Vector4(0, 1, 0, 1)); } else if (headItemId.equals("minecraft:player_head")) { - HeadEntity head = new HeadEntity(new Vector3(), headItem.get("skin").asString(""), 0, 1); + HeadEntity head = new HeadEntity(new Point3(), headItem.get("skin").asString(""), 0, 1); faces.addAll(head.primitives(Transform.NONE.scale(1.2).translate(0.5, 0.5, 0.5).chain(transform))); } else if (headItemId.equals("minecraft:piglin_head")) { - SkullEntity skull = new SkullEntity(new Vector3(), Kind.PIGLIN, 0, 1); + SkullEntity skull = new SkullEntity(new Point3(), Kind.PIGLIN, 0, 1); faces.addAll(skull.piglinHeadPrimitives(Transform.NONE.scale(1.2).translate(0.5, 0.5, 0.5).chain(transform))); } else { addModel(faces, getHelmModel(headItem), transform); diff --git a/chunky/src/java/se/llbit/chunky/entity/Poseable.java b/chunky/src/java/se/llbit/chunky/entity/Poseable.java index 090bbbe52c..4febacea28 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Poseable.java +++ b/chunky/src/java/se/llbit/chunky/entity/Poseable.java @@ -20,6 +20,7 @@ import org.apache.commons.math3.util.FastMath; import se.llbit.json.Json; import se.llbit.json.JsonObject; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.util.JsonUtil; @@ -41,13 +42,12 @@ public interface Poseable { default double getHeadScale() { return 1; } default void setHeadScale(double value) {}; - Vector3 getPosition(); + Point3 getPosition(); - default void lookAt(Vector3 target) { - Vector3 dir = new Vector3(target); - Vector3 face = new Vector3(getPosition()); + default void lookAt(Point3 target) { + Point3 face = new Point3(getPosition()); face.add(0, 28 / 16., 0); - dir.sub(face); + Vector3 dir = target.vSub(face); dir.normalize(); double headYaw = getPose("head").y; getPose().set("rotation", Json.of(FastMath.atan2(dir.x, dir.z) + Math.PI - headYaw)); diff --git a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java index e8524edf81..4652869e71 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java @@ -322,11 +322,11 @@ public Color getGlowingOutlineColor() { private final Texture texture; private final String material; - public SignEntity(Vector3 position, CompoundTag entityTag, int blockData, String material) { + public SignEntity(Point3 position, CompoundTag entityTag, int blockData, String material) { this(position, getFrontTextLines(entityTag), getFrontDyeColor(entityTag), getFrontGlowing(entityTag), getBackTextLines(entityTag), getBackDyeColor(entityTag), getBackGlowing(entityTag), blockData & 0xF, material); } - public SignEntity(Vector3 position, JsonArray[] frontText, Color frontDye, boolean frontGlowing, JsonArray[] backText, Color backDye, boolean backGlowing, int direction, String material) { + public SignEntity(Point3 position, JsonArray[] frontText, Color frontDye, boolean frontGlowing, JsonArray[] backText, Color backDye, boolean backGlowing, int direction, String material) { super(position); Texture signTexture = SignEntity.textureFromMaterial(material); this.frontText = frontText; @@ -571,7 +571,7 @@ public JsonValue toJson() { * Unmarshalls a sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); JsonArray[] frontText = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java b/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java index 32eebab625..21250568dd 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java @@ -501,7 +501,7 @@ public enum Kind { */ private final int placement; - public SkullEntity(Vector3 position, Kind type, int rotation, int placement) { + public SkullEntity(Point3 position, Kind type, int rotation, int placement) { super(position); this.type = type; this.rotation = rotation; @@ -628,7 +628,7 @@ public JsonValue toJson() { } public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); Kind type = Kind.values()[json.get("type").intValue(0)]; int rotation = json.get("rotation").intValue(0); diff --git a/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java b/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java index 84646b8dc6..2ed235a19b 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java +++ b/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java @@ -4,6 +4,7 @@ import se.llbit.chunky.model.minecraft.SporeBlossomModel; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Transform; import se.llbit.math.Vector3; import se.llbit.math.primitive.Primitive; @@ -11,17 +12,17 @@ public class SporeBlossom extends Entity { - public SporeBlossom(Vector3 position) { + public SporeBlossom(Point3 position) { super(position); } public SporeBlossom(JsonObject json) { - super(JsonUtil.vec3FromJsonObject(json.get("position"))); + super(JsonUtil.point3FromJsonObject(json.get("position"))); } @Override public Collection primitives(Vector3 offset) { - return SporeBlossomModel.primitives(Transform.NONE.translate(position).translate(offset)); + return SporeBlossomModel.primitives(Transform.NONE.translate(position.asVector()).translate(offset)); } @Override diff --git a/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java b/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java index d2d301cfbb..56035ea343 100644 --- a/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java +++ b/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java @@ -29,6 +29,7 @@ import se.llbit.json.JsonValue; import se.llbit.log.Log; import se.llbit.math.ColorUtil; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -152,13 +153,13 @@ public class StandingBanner extends Entity { private final int rotation; private final JsonObject design; - public StandingBanner(Vector3 position, int rotation, JsonObject design) { + public StandingBanner(Point3 position, int rotation, JsonObject design) { super(position); this.rotation = rotation; this.design = design; } - public StandingBanner(Vector3 position, int rotation, CompoundTag entityTag) { + public StandingBanner(Point3 position, int rotation, CompoundTag entityTag) { this(position, rotation, parseDesign(entityTag)); } @@ -343,7 +344,7 @@ protected static BitmapImage getPatternBitmap(String pattern) { } public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); int rotation = json.get("rotation").intValue(0); return new StandingBanner(position, rotation, json.get("design").object()); diff --git a/chunky/src/java/se/llbit/chunky/entity/WallBanner.java b/chunky/src/java/se/llbit/chunky/entity/WallBanner.java index d432ccd19f..29e37d1a1b 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallBanner.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallBanner.java @@ -21,6 +21,7 @@ import se.llbit.chunky.world.Material; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -113,13 +114,13 @@ public class WallBanner extends Entity { private final int rotation; private final JsonObject design; - public WallBanner(Vector3 position, int rotation, JsonObject design) { + public WallBanner(Point3 position, int rotation, JsonObject design) { super(position); this.rotation = rotation; this.design = design; } - public WallBanner(Vector3 position, int rotation, CompoundTag entityTag) { + public WallBanner(Point3 position, int rotation, CompoundTag entityTag) { this(position, rotation, StandingBanner.parseDesign(entityTag)); } @@ -144,7 +145,7 @@ public WallBanner(Vector3 position, int rotation, CompoundTag entityTag) { } public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); int rotation = json.get("rotation").intValue(0); return new WallBanner(position, rotation, json.get("design").object()); diff --git a/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java index c779bf8022..d450d7147e 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java @@ -23,6 +23,7 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.QuickMath; import se.llbit.math.Transform; @@ -63,7 +64,7 @@ public class WallCoralFanEntity extends Entity { private final String coralType; private final String facing; - public WallCoralFanEntity(Vector3 position, String coralType, String facing) { + public WallCoralFanEntity(Point3 position, String coralType, String facing) { super(position); this.coralType = coralType; this.facing = facing; @@ -105,7 +106,7 @@ public WallCoralFanEntity(Vector3 position, String coralType, String facing) { } public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); String coralType = json.get("coral_type").stringValue("tube"); String facing = json.get("facing").stringValue("north"); diff --git a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java index ab2b75f2a3..da67704fd7 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java @@ -8,6 +8,7 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -240,11 +241,11 @@ public class WallHangingSignEntity extends Entity { private final Texture texture; private final String material; - public WallHangingSignEntity(Vector3 position, CompoundTag entityTag, WallHangingSign.Facing direction, String material) { + public WallHangingSignEntity(Point3 position, CompoundTag entityTag, WallHangingSign.Facing direction, String material) { this(position, SignEntity.getFrontTextLines(entityTag), SignEntity.getFrontDyeColor(entityTag), SignEntity.getFrontGlowing(entityTag), SignEntity.getBackTextLines(entityTag), SignEntity.getBackDyeColor(entityTag), SignEntity.getBackGlowing(entityTag), direction, material); } - public WallHangingSignEntity(Vector3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, WallHangingSign.Facing direction, String material) { + public WallHangingSignEntity(Point3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, WallHangingSign.Facing direction, String material) { super(position); Texture signTexture = HangingSignEntity.textureFromMaterial(material); this.frontText = frontText; @@ -308,7 +309,7 @@ public JsonValue toJson() { * Unmarshalls a sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); JsonArray[] frontText = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java index 336b94965c..7b4fcf7d70 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java @@ -24,6 +24,7 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -100,11 +101,11 @@ public class WallSignEntity extends Entity { private final Texture texture; private final String material; - public WallSignEntity(Vector3 position, CompoundTag entityTag, int blockData, String material) { + public WallSignEntity(Point3 position, CompoundTag entityTag, int blockData, String material) { this(position, SignEntity.getFrontTextLines(entityTag), SignEntity.getFrontDyeColor(entityTag), SignEntity.getFrontGlowing(entityTag), blockData % 6, material); } - public WallSignEntity(Vector3 position, JsonArray[] text, SignEntity.Color dye, boolean isGlowing, int direction, String material) { + public WallSignEntity(Point3 position, JsonArray[] text, SignEntity.Color dye, boolean isGlowing, int direction, String material) { super(position); Texture signTexture = SignEntity.textureFromMaterial(material); this.orientation = direction; @@ -155,7 +156,7 @@ public JsonValue toJson() { * Unmarshalls a wall sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Vector3 position = new Vector3(); + Point3 position = new Point3(); position.fromJson(json.get("position").object()); JsonArray[] text = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/map/MapView.java b/chunky/src/java/se/llbit/chunky/map/MapView.java index a1ad9e9202..c27cc005d6 100644 --- a/chunky/src/java/se/llbit/chunky/map/MapView.java +++ b/chunky/src/java/se/llbit/chunky/map/MapView.java @@ -20,6 +20,7 @@ import javafx.beans.property.SimpleObjectProperty; import se.llbit.chunky.renderer.ChunkViewListener; import se.llbit.chunky.world.ChunkView; +import se.llbit.math.Point3; import se.llbit.math.Vector2; import se.llbit.math.Vector3; @@ -65,7 +66,7 @@ public synchronized void moveView(double dx, double dz) { } /** Set the map view by block coordinates. */ - public void panTo(Vector3 pos) { + public void panTo(Point3 pos) { // Convert from block coordinates to chunk coordinates. panTo(pos.x / 16, pos.z / 16); } diff --git a/chunky/src/java/se/llbit/chunky/model/AABBModel.java b/chunky/src/java/se/llbit/chunky/model/AABBModel.java index a78da34c31..e680ffd4ed 100644 --- a/chunky/src/java/se/llbit/chunky/model/AABBModel.java +++ b/chunky/src/java/se/llbit/chunky/model/AABBModel.java @@ -4,7 +4,10 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.AABB; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import java.util.Arrays; @@ -69,7 +72,7 @@ public double faceSurfaceArea(int face) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { AABB[] boxes = getBoxes(); Texture[][] textures = getTextures(); UVMapping[][] mapping = getUVMapping(); @@ -77,70 +80,66 @@ public boolean intersect(Ray ray, Scene scene) { boolean hit = false; Tint tint = Tint.NONE; - ray.t = Double.POSITIVE_INFINITY; for (int i = 0; i < boxes.length; ++i) { - if (boxes[i].intersect(ray)) { + if (boxes[i].intersect(ray, intersectionRecord)) { Tint[] tintedFacesBox = tintedFaces != null ? tintedFaces[i] : null; - Vector3 n = ray.getNormal(); + Vector3 n = intersectionRecord.n; if (n.y > 0) { // top - ray.v = 1 - ray.v; - if (intersectFace(ray, scene, textures[i][4], + intersectionRecord.uv.x = 1 - intersectionRecord.uv.x; + if (intersectFace(intersectionRecord, scene, textures[i][4], mapping != null ? mapping[i][4] : null )) { tint = tintedFacesBox != null ? tintedFacesBox[4] : Tint.NONE; hit = true; } } else if (n.y < 0) { // bottom - if (intersectFace(ray, scene, textures[i][5], + if (intersectFace(intersectionRecord, scene, textures[i][5], mapping != null ? mapping[i][5] : null)) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[5] : Tint.NONE; } } else if (n.z < 0) { // north - if (intersectFace(ray, scene, textures[i][0], + if (intersectFace(intersectionRecord, scene, textures[i][0], mapping != null ? mapping[i][0] : null )) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[0] : Tint.NONE; } } else if (n.z > 0) { // south - if (intersectFace(ray, scene, textures[i][2], + if (intersectFace(intersectionRecord, scene, textures[i][2], mapping != null ? mapping[i][2] : null )) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[2] : Tint.NONE; } } else if (n.x < 0) { // west - if (intersectFace(ray, scene, textures[i][3], + if (intersectFace(intersectionRecord, scene, textures[i][3], mapping != null ? mapping[i][3] : null)) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[3] : Tint.NONE; } } else if (n.x > 0) { // east - if (intersectFace(ray, scene, textures[i][1], + if (intersectFace(intersectionRecord, scene, textures[i][1], mapping != null ? mapping[i][1] : null)) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[1] : Tint.NONE; } } - if (hit) { - ray.t = ray.tNext; - } } } if (hit) { - if (ray.getCurrentMaterial().opaque) { - ray.color.w = 1; + if (intersectionRecord.material.opaque) { + intersectionRecord.color.w = 1; } - tint.tint(ray.color, ray, scene); - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + tint.tint(intersectionRecord.color, ray, scene); + /*ray.distance += ray.t; + ray.o.scaleAdd(ray.t, ray.d);*/ } return hit; } - private boolean intersectFace(Ray ray, Scene scene, Texture texture, UVMapping mapping) { + private boolean intersectFace(IntersectionRecord intersectionRecord, Scene scene, Texture texture, UVMapping mapping) { // This is the method that handles intersecting faces of all AABB-based models. // Do normal mapping, parallax occlusion mapping, specular maps and all the good stuff here! @@ -152,31 +151,31 @@ private boolean intersectFace(Ray ray, Scene scene, Texture texture, UVMapping m if (mapping != null) { switch (mapping) { case ROTATE_90: - tmp = ray.u; - ray.u = 1 - ray.v; - ray.v = tmp; + tmp = intersectionRecord.uv.x; + intersectionRecord.uv.x = 1 - intersectionRecord.uv.y; + intersectionRecord.uv.y = tmp; break; case ROTATE_180: - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + intersectionRecord.uv.x = 1 - intersectionRecord.uv.x; + intersectionRecord.uv.y = 1 - intersectionRecord.uv.y; break; case ROTATE_270: - tmp = ray.v; - ray.v = 1 - ray.u; - ray.u = tmp; + tmp = intersectionRecord.uv.y; + intersectionRecord.uv.y = 1 - intersectionRecord.uv.x; + intersectionRecord.uv.x = tmp; break; case FLIP_U: - ray.u = 1 - ray.u; + intersectionRecord.uv.x = 1 - intersectionRecord.uv.x; break; case FLIP_V: - ray.v = 1 - ray.v; + intersectionRecord.uv.y = 1 - intersectionRecord.uv.y; break; } } - float[] color = texture.getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); + float[] color = texture.getColor(intersectionRecord.uv.x, intersectionRecord.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); return true; } return false; diff --git a/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java b/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java index 48946e75cf..eebe120591 100644 --- a/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java +++ b/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java @@ -3,10 +3,15 @@ import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.AnimatedTexture; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.util.MinecraftPRNG; +import se.llbit.util.VectorUtil; public abstract class AnimatedQuadModel extends QuadModel { public final static class AnimationMode { @@ -35,9 +40,9 @@ public AnimationMode getAnimationMode() { public abstract AnimatedTexture[] getTextures(); @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { boolean hit = false; - ray.t = Double.POSITIVE_INFINITY; + IntersectionRecord intersectionTest = new IntersectionRecord(); Quad[] quads = getQuads(); AnimatedTexture[] textures = getTextures(); @@ -46,8 +51,8 @@ public boolean intersect(Ray ray, Scene scene) { // The animation frame to use int j = (int) (scene.getAnimationTime() * animationMode.framerate); if (animationMode.positional) { - Vector3 position = new Vector3(ray.o); - position.scaleAdd(Ray.OFFSET, ray.d); + Point3 position = new Point3(ray.o); + position.add(ray.d.x * Constants.OFFSET, ray.d.y * Constants.OFFSET, ray.d.z * Constants.OFFSET); j += (int) MinecraftPRNG.rand((long) position.x, (long) position.y, (long) position.z); } @@ -56,34 +61,36 @@ public boolean intersect(Ray ray, Scene scene) { Tint tint = Tint.NONE; for (int i = 0; i < quads.length; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] c = textures[i].getColor(ray.u, ray.v, j); - if (c[3] > Ray.EPSILON) { + if (quad.intersect(ray, intersectionTest)) { + float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y, j); + if (c[3] > Constants.EPSILON) { tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; color = c; - ray.t = ray.tNext; - if (quad.doubleSided) - ray.orientNormal(quad.n); - else - ray.setNormal(quad.n); + if (quad.doubleSided) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + } else { + intersectionRecord.setNormal(quad.n); + } hit = true; } } } if (hit) { - double px = ray.o.x - Math.floor(ray.o.x + ray.d.x * Ray.OFFSET) + ray.d.x * ray.tNext; - double py = ray.o.y - Math.floor(ray.o.y + ray.d.y * Ray.OFFSET) + ray.d.y * ray.tNext; - double pz = ray.o.z - Math.floor(ray.o.z + ray.d.z * Ray.OFFSET) + ray.d.z * ray.tNext; + double px = ray.o.x - Math.floor(ray.o.x + ray.d.x * Constants.OFFSET) + ray.d.x * intersectionTest.distance; + double py = ray.o.y - Math.floor(ray.o.y + ray.d.y * Constants.OFFSET) + ray.d.y * intersectionTest.distance; + double pz = ray.o.z - Math.floor(ray.o.z + ray.d.z * Constants.OFFSET) + ray.d.z * intersectionTest.distance; if (px < E0 || px > E1 || py < E0 || py > E1 || pz < E0 || pz > E1) { // TODO this check is only really needed for wall torches return false; } - ray.color.set(color); - tint.tint(ray.color, ray, scene); - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.color.set(color); + tint.tint(intersectionRecord.color, ray, scene); + intersectionRecord.distance += intersectionTest.distance; + /*ray.o.scaleAdd(ray.t, ray.d); + int x; + */ } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/model/BlockModel.java b/chunky/src/java/se/llbit/chunky/model/BlockModel.java index 95c54075b7..38ee66e0ca 100644 --- a/chunky/src/java/se/llbit/chunky/model/BlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/BlockModel.java @@ -2,7 +2,9 @@ import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import java.util.List; @@ -11,7 +13,7 @@ @PluginApi public interface BlockModel { - boolean intersect(Ray ray, Scene scene); + boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene); int faceCount(); diff --git a/chunky/src/java/se/llbit/chunky/model/QuadModel.java b/chunky/src/java/se/llbit/chunky/model/QuadModel.java index 31b070b142..deedf4f945 100644 --- a/chunky/src/java/se/llbit/chunky/model/QuadModel.java +++ b/chunky/src/java/se/llbit/chunky/model/QuadModel.java @@ -23,10 +23,14 @@ import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Quad; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.math.Vector4; +import se.llbit.util.VectorUtil; import java.util.Random; @@ -75,8 +79,8 @@ public abstract class QuadModel implements BlockModel { }; // Epsilons to clip ray intersections to the current block. - protected static final double E0 = -Ray.EPSILON; - protected static final double E1 = 1 + Ray.EPSILON; + protected static final double E0 = -Constants.EPSILON; + protected static final double E1 = 1 + Constants.EPSILON; @PluginApi public abstract Quad[] getQuads(); @@ -105,9 +109,9 @@ public double faceSurfaceArea(int face) { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { boolean hit = false; - ray.t = Double.POSITIVE_INFINITY; + IntersectionRecord intersectionTest = new IntersectionRecord(); Quad[] quads = getQuads(); Texture[] textures = getTextures(); @@ -117,34 +121,36 @@ public boolean intersect(Ray ray, Scene scene) { Tint tint = Tint.NONE; for (int i = 0; i < quads.length; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] c = textures[i].getColor(ray.u, ray.v); - if (c[3] > Ray.EPSILON) { + if (quad.intersect(ray, intersectionTest)) { + float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (c[3] > Constants.EPSILON) { tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; color = c; - ray.t = ray.tNext; - if (quad.doubleSided) - ray.orientNormal(quad.n); - else - ray.setNormal(quad.n); + if (quad.doubleSided) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + } else { + intersectionRecord.setNormal(quad.n); + } hit = true; } } } if (hit) { - double px = ray.o.x - Math.floor(ray.o.x + ray.d.x * Ray.OFFSET) + ray.d.x * ray.tNext; - double py = ray.o.y - Math.floor(ray.o.y + ray.d.y * Ray.OFFSET) + ray.d.y * ray.tNext; - double pz = ray.o.z - Math.floor(ray.o.z + ray.d.z * Ray.OFFSET) + ray.d.z * ray.tNext; + double px = ray.o.x - Math.floor(ray.o.x + ray.d.x * Constants.OFFSET) + ray.d.x * intersectionTest.distance; + double py = ray.o.y - Math.floor(ray.o.y + ray.d.y * Constants.OFFSET) + ray.d.y * intersectionTest.distance; + double pz = ray.o.z - Math.floor(ray.o.z + ray.d.z * Constants.OFFSET) + ray.d.z * intersectionTest.distance; if (px < E0 || px > E1 || py < E0 || py > E1 || pz < E0 || pz > E1) { // TODO this check is only really needed for wall torches return false; } - ray.color.set(color); - tint.tint(ray.color, ray, scene); - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.color.set(color); + tint.tint(intersectionRecord.color, ray, scene); + intersectionRecord.distance += intersectionTest.distance; + /*ray.o.scaleAdd(ray.t, ray.d); + int x; + */ } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java b/chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java index fdb3568dff..daf5dfc090 100644 --- a/chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java @@ -19,8 +19,10 @@ import se.llbit.chunky.block.minecraft.Air; import se.llbit.chunky.resources.Texture; import se.llbit.math.AABB; +import se.llbit.math.IntersectionRecord; import se.llbit.math.QuickMath; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; /** @@ -54,16 +56,16 @@ public Texture[][] getTextures() { * * @param ray ray to test */ - public static void getIntersectionColor(Ray ray) { - if (ray.getCurrentMaterial() == Air.INSTANCE) { - ray.color.x = 1; - ray.color.y = 1; - ray.color.z = 1; - ray.color.w = 0; + public static void getIntersectionColor(Ray2 ray, IntersectionRecord intersectionRecord) { + if (intersectionRecord.material == Air.INSTANCE) { + intersectionRecord.color.x = 1; + intersectionRecord.color.y = 1; + intersectionRecord.color.z = 1; + intersectionRecord.color.w = 0; return; } - getTextureCoordinates(ray); - ray.getCurrentMaterial().getColor(ray); + getTextureCoordinates(ray, intersectionRecord); + intersectionRecord.material.getColor(intersectionRecord); } /** @@ -71,26 +73,26 @@ public static void getIntersectionColor(Ray ray) { * * @param ray ray to test */ - private static void getTextureCoordinates(Ray ray) { + private static void getTextureCoordinates(Ray2 ray, IntersectionRecord intersectionRecord) { int bx = (int) QuickMath.floor(ray.o.x); int by = (int) QuickMath.floor(ray.o.y); int bz = (int) QuickMath.floor(ray.o.z); - Vector3 n = ray.getNormal(); + Vector3 n = intersectionRecord.n; if (n.y != 0) { - ray.u = ray.o.x - bx; - ray.v = ray.o.z - bz; + intersectionRecord.uv.x = ray.o.x - bx; + intersectionRecord.uv.y = ray.o.z - bz; } else if (n.x != 0) { - ray.u = ray.o.z - bz; - ray.v = ray.o.y - by; + intersectionRecord.uv.x = ray.o.z - bz; + intersectionRecord.uv.y = ray.o.y - by; } else { - ray.u = ray.o.x - bx; - ray.v = ray.o.y - by; + intersectionRecord.uv.x = ray.o.x - bx; + intersectionRecord.uv.y = ray.o.y - by; } if (n.x > 0 || n.z < 0) { - ray.u = 1 - ray.u; + intersectionRecord.uv.x = 1 - intersectionRecord.uv.x; } if (n.y > 0) { - ray.v = 1 - ray.v; + intersectionRecord.uv.y = 1 - intersectionRecord.uv.y; } } } diff --git a/chunky/src/java/se/llbit/chunky/model/Tint.java b/chunky/src/java/se/llbit/chunky/model/Tint.java index 604ddf41c8..dbeb5ed3fe 100644 --- a/chunky/src/java/se/llbit/chunky/model/Tint.java +++ b/chunky/src/java/se/llbit/chunky/model/Tint.java @@ -3,7 +3,9 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.log.Log; import se.llbit.math.ColorUtil; +import se.llbit.math.Constants; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector4; public class Tint { @@ -57,18 +59,18 @@ public Tint(float[] tint) { System.arraycopy(tint, 0, this.tint, 0, 3); } - private float[] getTintColor(Ray ray, Scene scene) { + private float[] getTintColor(Ray2 ray, Scene scene) { switch (type) { case NONE: return null; case CONSTANT: return this.tint; case BIOME_FOLIAGE: - return ray.getBiomeFoliageColor(scene); + return scene.getFoliageColor((int) (ray.o.x + ray.d.x * Constants.OFFSET), (int) (ray.o.y + ray.d.y * Constants.OFFSET), (int) (ray.o.z + ray.d.z * Constants.OFFSET)); case BIOME_GRASS: - return ray.getBiomeGrassColor(scene); + return scene.getGrassColor((int) (ray.o.x + ray.d.x * Constants.OFFSET), (int) (ray.o.y + ray.d.y * Constants.OFFSET), (int) (ray.o.z + ray.d.z * Constants.OFFSET)); case BIOME_WATER: - return ray.getBiomeWaterColor(scene); + return scene.getWaterColor((int) (ray.o.x + ray.d.x * Constants.OFFSET), (int) (ray.o.y + ray.d.y * Constants.OFFSET), (int) (ray.o.z + ray.d.z * Constants.OFFSET)); default: Log.warn("Unsupported tint type " + type); return null; @@ -78,7 +80,7 @@ private float[] getTintColor(Ray ray, Scene scene) { /** * Tint a color array with the tint option of this Tint object. */ - public void tint(float[] color, Ray ray, Scene scene) { + public void tint(float[] color, Ray2 ray, Scene scene) { float[] tintColor = this.getTintColor(ray, scene); if (tintColor != null) { color[0] *= tintColor[0]; @@ -90,7 +92,7 @@ public void tint(float[] color, Ray ray, Scene scene) { /** * Tint a color vector with the tint option of this Tint object. */ - public void tint(Vector4 color, Ray ray, Scene scene) { + public void tint(Vector4 color, Ray2 ray, Scene scene) { float[] tintColor = this.getTintColor(ray, scene); if (tintColor != null) { color.x *= tintColor[0]; diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java index 485e42fe2f..53d5c764cd 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java @@ -22,8 +22,11 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.renderer.scene.StillWaterShader; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Quad; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.math.Vector4; @@ -361,51 +364,47 @@ public class CauldronModel { side, side }; - public static boolean intersect(Ray ray, int level, Texture contentTexture) { + public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, int level, Texture contentTexture) { boolean hit = false; - ray.t = Double.POSITIVE_INFINITY; + IntersectionRecord intersectionTest = new IntersectionRecord(); for (int i = 0; i < quads.length; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] color = tex[i].getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.t = ray.tNext; - ray.setNormal(quad.n); + if (quad.intersect(ray, intersectionTest)) { + float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); + intersectionRecord.setNormal(quad.n); hit = true; } } } Quad water = waterLevels[level]; - if (water != null && water.intersect(ray)) { - float[] color = contentTexture.getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.t = ray.tNext; - ray.setNormal(water.n); + if (water != null && water.intersect(ray, intersectionTest)) { + float[] color = contentTexture.getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); + intersectionRecord.setNormal(water.n); hit = true; } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.distance += intersectionTest.distance; } return hit; } - public static boolean intersectWithWater(Ray ray, Scene scene, int level) { + public static boolean intersectWithWater(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene, int level) { boolean hit = false; - ray.t = Double.POSITIVE_INFINITY; + IntersectionRecord intersectionTest = new IntersectionRecord(); for (int i = 0; i < quads.length; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] color = tex[i].getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.t = ray.tNext; - ray.setNormal(quad.n); + if (quad.intersect(ray, intersectionTest)) { + float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); + intersectionRecord.setNormal(quad.n); hit = true; } } @@ -413,58 +412,57 @@ public static boolean intersectWithWater(Ray ray, Scene scene, int level) { // TODO since this water is the same block, refraction is not taken into account – still better than no water Quad water = waterLevels[level]; - if (water != null && water.intersect(ray)) { + if (water != null && water.intersect(ray, intersectionTest)) { if (!(scene.getCurrentWaterShader() instanceof StillWaterShader)) { - scene.getCurrentWaterShader().doWaterShading(ray, scene.getAnimationTime()); + scene.getCurrentWaterShader().doWaterShading(ray, intersectionRecord, scene.getAnimationTime()); } else { - ray.setNormal(water.n); + intersectionRecord.setNormal(water.n); } - ray.setPrevMaterial(ray.getCurrentMaterial(), ray.getCurrentData()); - ray.setCurrentMaterial(Water.INSTANCE); - ray.t = ray.tNext; + intersectionRecord.material = Water.INSTANCE; } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.distance += intersectionRecord.distance; + /*ray.o.scaleAdd(ray.t, ray.d); + int x; + */ } return hit; } - public static boolean intersectWithLava(Ray ray) { + public static boolean intersectWithLava(Ray2 ray, IntersectionRecord intersectionRecord) { boolean hit = false; - ray.t = Double.POSITIVE_INFINITY; + IntersectionRecord intersectionTest = new IntersectionRecord(); for (int i = 0; i < quads.length; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] color = tex[i].getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.t = ray.tNext; - ray.setNormal(quad.n); + if (quad.intersect(ray, intersectionTest)) { + float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); + intersectionRecord.setNormal(quad.n); hit = true; } } } Quad lava = waterLevels[3]; - if (lava.intersect(ray)) { - float[] color = Texture.lava.getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.t = ray.tNext; - ray.setNormal(lava.n); + if (lava.intersect(ray, intersectionTest)) { + float[] color = Texture.lava.getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); + intersectionRecord.setNormal(lava.n); hit = true; // set the current material to lava so that only the lava is emissive and not the cauldron - ray.setPrevMaterial(ray.getCurrentMaterial(), ray.getCurrentData()); - ray.setCurrentMaterial(new Lava(7)); + intersectionRecord.material = new Lava(7); } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.distance += intersectionTest.distance; + /*ray.o.scaleAdd(ray.t, ray.d); + int x; + */ } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java index 29a72bcd1b..b3b37e6908 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java @@ -21,6 +21,7 @@ import se.llbit.chunky.model.TopBottomOrientedTexturedBlockModel; import se.llbit.chunky.resources.Texture; import se.llbit.log.Log; +import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Vector3; import se.llbit.math.Vector4; @@ -140,7 +141,7 @@ public static class DecoratedPotSpoutEntity extends Entity { private final Material material = new TextureMaterial(Texture.decoratedPotBase); private final String facing; - public DecoratedPotSpoutEntity(Vector3 position, String facing) { + public DecoratedPotSpoutEntity(Point3 position, String facing) { super(position); this.facing = facing; } @@ -158,7 +159,7 @@ public Collection primitives(Vector3 offset) { public static Entity fromJson(JsonObject json) { return new DecoratedPotSpoutEntity( - JsonUtil.vec3FromJsonObject(json.get("position")), + JsonUtil.point3FromJsonObject(json.get("position")), json.get("facing").stringValue("north") ); } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java index a3b647d1c6..66650b78d9 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java @@ -105,45 +105,42 @@ public class HoneyBlockModel { Texture.honeyBlockSide, Texture.honeyBlockSide, Texture.honeyBlockSide }; - public static boolean intersect(Ray ray) { - ray.t = Double.POSITIVE_INFINITY; + public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { + IntersectionRecord intersectionTest = new IntersectionRecord(); boolean hit = false; - Vector4 oldColor = new Vector4(ray.color); + Vector4 oldColor = new Vector4(intersectionRecord.color); for (int i = 6; i < quads.length; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] color = tex[i].getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ColorUtil.overlayColor(ray.color, color); - ray.setNormal(quad.n); - ray.t = ray.tNext; + if (quad.intersect(ray, intersectionTest)) { + float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + ColorUtil.overlayColor(intersectionRecord.color, color); + intersectionRecord.setNormal(quad.n); hit = true; } } } boolean innerHit = hit; - Vector4 innerColor = hit ? new Vector4(ray.color) : null; + Vector4 innerColor = hit ? new Vector4(intersectionRecord.color) : null; - ray.color.set(oldColor); + intersectionRecord.color.set(oldColor); hit = false; for (int i = 0; i < 6; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] color = tex[i].getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ColorUtil.overlayColor(ray.color, color); - ray.setNormal(quad.n); - ray.t = ray.tNext; + if (quad.intersect(ray, intersectionTest)) { + float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + ColorUtil.overlayColor(intersectionRecord.color, color); + intersectionRecord.setNormal(quad.n); hit = true; } } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.distance += intersectionTest.distance; if (innerHit) { - ColorUtil.overlayColor(ray.color, innerColor); + ColorUtil.overlayColor(intersectionRecord.color, innerColor); } } return hit; diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LightBlockModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LightBlockModel.java index 4fbfad8d9b..554b471b29 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/LightBlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/LightBlockModel.java @@ -22,7 +22,9 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.AABB; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector4; public class LightBlockModel extends AABBModel { @@ -47,14 +49,12 @@ public AABB[] getBoxes() { } @Override - public boolean intersect(Ray ray, Scene scene) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { boolean hit = false; AABB[] boxes = getBoxes(); - ray.t = Double.POSITIVE_INFINITY; - if (boxes[0].intersect(ray)) { - ray.color.set(color); + if (boxes[0].intersect(ray, intersectionRecord)) { + intersectionRecord.color.set(color); hit = true; - ray.t = ray.tNext; } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java index d7873dd7c0..1f0a857572 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java @@ -103,45 +103,42 @@ public class SlimeBlockModel { Texture.slime, Texture.slime, Texture.slime, Texture.slime, Texture.slime, Texture.slime }; - public static boolean intersect(Ray ray) { - ray.t = Double.POSITIVE_INFINITY; + public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { + IntersectionRecord intersectionTest = new IntersectionRecord(); boolean hit = false; - Vector4 oldColor = new Vector4(ray.color); + Vector4 oldColor = new Vector4(intersectionRecord.color); for (int i = 0; i < 6; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] color = tex[i].getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ColorUtil.overlayColor(ray.color, color); - ray.setNormal(quad.n); - ray.t = ray.tNext; + if (quad.intersect(ray, intersectionTest)) { + float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + ColorUtil.overlayColor(intersectionRecord.color, color); + intersectionRecord.setNormal(quad.n); hit = true; } } } boolean innerHit = hit; - Vector4 innerColor = hit ? new Vector4(ray.color) : null; + Vector4 innerColor = hit ? new Vector4(intersectionRecord.color) : null; - ray.color.set(oldColor); + intersectionRecord.color.set(oldColor); hit = false; for (int i = 6; i < quads.length; ++i) { Quad quad = quads[i]; - if (quad.intersect(ray)) { - float[] color = tex[i].getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ColorUtil.overlayColor(ray.color, color); - ray.setNormal(quad.n); - ray.t = ray.tNext; + if (quad.intersect(ray, intersectionTest)) { + float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (color[3] > Constants.EPSILON) { + ColorUtil.overlayColor(intersectionRecord.color, color); + intersectionRecord.setNormal(quad.n); hit = true; } } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.distance += intersectionTest.distance; if (innerHit) { - ColorUtil.overlayColor(ray.color, innerColor); + ColorUtil.overlayColor(intersectionRecord.color, innerColor); } } return hit; diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java index 0ad41c0903..31dbd32231 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java @@ -20,10 +20,14 @@ import se.llbit.chunky.model.Model; import se.llbit.chunky.model.QuadModel; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Quad; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.math.Vector4; +import se.llbit.util.VectorUtil; public class SpriteModel extends QuadModel { @@ -75,50 +79,52 @@ public Texture[] getTextures() { return textures; } - public static boolean intersect(Ray ray, Texture material) { + public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Texture material) { boolean hit = false; - ray.t = Double.POSITIVE_INFINITY; + IntersectionRecord intersectionTest = new IntersectionRecord(); + float[] color = null; for (Quad quad : quads) { - if (quad.intersect(ray)) { - float[] color = material.getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.t = ray.tNext; - if (quad.doubleSided) - ray.orientNormal(quad.n); - else - ray.setNormal(quad.n); + if (quad.intersect(ray, intersectionTest)) { + float[] c = material.getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (c[3] > Constants.EPSILON) { + color = c; + if (quad.doubleSided) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + } else { + intersectionRecord.setNormal(quad.n); + } hit = true; } } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.color.set(color); + intersectionRecord.distance += intersectionTest.distance; } return hit; } - public static boolean intersect(Ray ray, Texture material, String facing) { + public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Texture material, String facing) { boolean hit = false; - ray.t = Double.POSITIVE_INFINITY; + IntersectionRecord intersectionTest = new IntersectionRecord(); + float[] color = null; for (Quad quad : orientedQuads[getOrientationIndex(facing)]) { - if (quad.intersect(ray)) { - float[] color = material.getColor(ray.u, ray.v); - if (color[3] > Ray.EPSILON) { - ray.color.set(color); - ray.t = ray.tNext; - if (quad.doubleSided) - ray.orientNormal(quad.n); - else - ray.setNormal(quad.n); + if (quad.intersect(ray, intersectionTest)) { + float[] c = material.getColor(intersectionTest.uv.x, intersectionTest.uv.y); + color = c; + if (c[3] > Constants.EPSILON) { + if (quad.doubleSided) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + } else { + intersectionRecord.setNormal(quad.n); + } hit = true; } } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.color.set(color); + intersectionRecord.distance += intersectionTest.distance; } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java index 3d96c8edfd..9f4847340f 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java @@ -17,13 +17,19 @@ */ package se.llbit.chunky.model.minecraft; +import se.llbit.chunky.block.minecraft.Water; +import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.chunky.renderer.scene.StillWaterShader; import se.llbit.chunky.resources.Texture; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Quad; import se.llbit.math.QuickMath; -import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Triangle; import se.llbit.math.Vector3; import se.llbit.math.Vector4; +import se.llbit.util.VectorUtil; /** * A water block. The height of the top water block is slightly @@ -53,7 +59,7 @@ public class WaterModel { new Quad(new Vector3(0, 1, 1), new Vector3(1, 1, 1), new Vector3(0, 0, 1), new Vector4(0, 1, 0, 1), true),}; - static final Quad bot = + static final Quad bottom = new Quad(new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector4(0, 1, 0, 1), true); static final Triangle[][][] t012 = new Triangle[8][8][8]; @@ -173,34 +179,31 @@ public class WaterModel { } } - public static boolean intersect(Ray ray) { - ray.t = Double.POSITIVE_INFINITY; + public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + IntersectionRecord intersectionTest = new IntersectionRecord(); - int data = ray.getCurrentData(); + int data = intersectionRecord.material instanceof Water ? ((Water) intersectionRecord.material).data : 0; int isFull = (data >> FULL_BLOCK) & 1; //int level = data >> 8; if (isFull != 0) { boolean hit = false; for (Quad quad : fullBlock) { - if (quad.intersect(ray)) { - Texture.water.getAvgColorLinear(ray.color); - ray.t = ray.tNext; - ray.orientNormal(quad.n); + if (quad.intersect(ray, intersectionTest)) { + Texture.water.getAvgColorLinear(intersectionRecord.color); + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); hit = true; } } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + intersectionRecord.distance += intersectionTest.distance; } return hit; } boolean hit = false; - if (bot.intersect(ray)) { - ray.orientNormal(bot.n); - ray.t = ray.tNext; + if (bottom.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, bottom.n)); hit = true; } @@ -209,87 +212,79 @@ public static boolean intersect(Ray ray) { int c2 = (0xF & (data >> 24)) % 8; int c3 = (0xF & (data >> 28)) % 8; Triangle triangle = t012[c0][c1][c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = t230[c2][c3][c0]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = westt[c0][c3]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = westb[c0]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = eastt[c1][c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = eastb[c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = southt[c0][c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = southb[c1]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } triangle = northt[c2][c3]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = northb[c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } if (hit) { - Texture.water.getAvgColorLinear(ray.color); - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + if (!(scene.getCurrentWaterShader() instanceof StillWaterShader) && intersectionRecord.shadeN.y != 0) { + scene.getCurrentWaterShader().doWaterShading(ray, intersectionRecord, scene.getAnimationTime()); + } + Texture.water.getAvgColorLinear(intersectionRecord.color); + intersectionRecord.distance += intersectionTest.distance; } return hit; } - public static boolean intersectTop(Ray ray) { - ray.t = Double.POSITIVE_INFINITY; + public static boolean intersectTop(Ray2 ray, IntersectionRecord intersectionRecord) { + IntersectionRecord intersectionTest = new IntersectionRecord(); - int data = ray.getCurrentData(); + int data = intersectionRecord.material instanceof Water ? ((Water) intersectionRecord.material).data : 0; boolean hit = false; int c0 = (0xF & (data >> 16)) % 8; @@ -297,23 +292,20 @@ public static boolean intersectTop(Ray ray) { int c2 = (0xF & (data >> 24)) % 8; int c3 = (0xF & (data >> 28)) % 8; Triangle triangle = t012[c0][c1][c2]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); hit = true; } triangle = t230[c2][c3][c0]; - if (triangle.intersect(ray)) { - ray.orientNormal(triangle.n); - ray.t = ray.tNext; - ray.u = 1 - ray.u; - ray.v = 1 - ray.v; + if (triangle.intersect(ray, intersectionTest)) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, triangle.n)); + intersectionTest.uv.x = 1 - intersectionTest.uv.x; + intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } if (hit) { - Texture.water.getAvgColorLinear(ray.color); - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); + Texture.water.getAvgColorLinear(intersectionRecord.color); + intersectionRecord.distance += intersectionTest.distance; } return hit; } @@ -321,21 +313,21 @@ public static boolean intersectTop(Ray ray) { /** * Displace the normal using the water displacement map. */ - public static void doWaterDisplacement(Ray ray) { + public static void doWaterDisplacement(Ray2 ray, IntersectionRecord intersectionRecord) { int w = (1 << 4); double x = ray.o.x / w - QuickMath.floor(ray.o.x / w); double z = ray.o.z / w - QuickMath.floor(ray.o.z / w); - int u = (int) (x * normalMapW - Ray.EPSILON); - int v = (int) ((1 - z) * normalMapW - Ray.EPSILON); + int u = (int) (x * normalMapW - Constants.EPSILON); + int v = (int) ((1 - z) * normalMapW - Constants.EPSILON); Vector3 n = new Vector3(normalMap[(u*normalMapW + v) * 2], .15f, normalMap[(u*normalMapW + v) * 2 + 1]); w = (1 << 1); x = ray.o.x / w - QuickMath.floor(ray.o.x / w); z = ray.o.z / w - QuickMath.floor(ray.o.z / w); - u = (int) (x * normalMapW - Ray.EPSILON); - v = (int) ((1 - z) * normalMapW - Ray.EPSILON); + u = (int) (x * normalMapW - Constants.EPSILON); + v = (int) ((1 - z) * normalMapW - Constants.EPSILON); n.x += normalMap[(u*normalMapW + v) * 2] / 2; n.z += normalMap[(u*normalMapW + v) * 2 + 1] / 2; n.normalize(); - ray.setShadingNormal(n.x, n.y, n.z); + intersectionRecord.shadeN.set(n.x, n.y, n.z); } } diff --git a/chunky/src/java/se/llbit/chunky/renderer/PathTracingRenderer.java b/chunky/src/java/se/llbit/chunky/renderer/PathTracingRenderer.java index c397f16e97..4b1c88024a 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/PathTracingRenderer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/PathTracingRenderer.java @@ -91,13 +91,13 @@ public void render(DefaultRenderManager manager) throws InterruptedException { -0.5 + (y + oy + cropY) * invHeight); scene.rayTrace(tracer, state); - sr += state.ray.color.x * branchCount; - sg += state.ray.color.y * branchCount; - sb += state.ray.color.z * branchCount; + sr += state.color.x * branchCount; + sg += state.color.y * branchCount; + sb += state.color.z * branchCount; } int offset = 3 * (y*width + x); - sampleBuffer[offset + 0] = (sampleBuffer[offset + 0] * spp + sr) * sinv; + sampleBuffer[offset] = (sampleBuffer[offset] * spp + sr) * sinv; sampleBuffer[offset + 1] = (sampleBuffer[offset + 1] * spp + sg) * sinv; sampleBuffer[offset + 2] = (sampleBuffer[offset + 2] * spp + sb) * sinv; }); diff --git a/chunky/src/java/se/llbit/chunky/renderer/PreviewRenderer.java b/chunky/src/java/se/llbit/chunky/renderer/PreviewRenderer.java index 9822090996..55f5cc791b 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/PreviewRenderer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/PreviewRenderer.java @@ -20,7 +20,9 @@ import se.llbit.chunky.renderer.scene.Camera; import se.llbit.chunky.renderer.scene.RayTracer; import se.llbit.chunky.renderer.scene.Scene; -import se.llbit.math.Ray; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Ray2; import se.llbit.util.TaskTracker; public class PreviewRenderer extends TileBasedRenderer { @@ -70,11 +72,12 @@ public void render(DefaultRenderManager manager) throws InterruptedException { double halfWidth = fullWidth / (2.0 * fullHeight); double invHeight = 1.0 / fullHeight; - Ray target = new Ray(); - boolean hit = scene.traceTarget(target); - int tx = (int) Math.floor(target.o.x + target.d.x * Ray.OFFSET); - int ty = (int) Math.floor(target.o.y + target.d.y * Ray.OFFSET); - int tz = (int) Math.floor(target.o.z + target.d.z * Ray.OFFSET); + Ray2 target = new Ray2(); + IntersectionRecord intersectionRecord = new IntersectionRecord(); + boolean hit = scene.traceTarget(target, intersectionRecord); + int tx = (int) Math.floor(target.o.x + target.d.x * Constants.OFFSET); + int ty = (int) Math.floor(target.o.y + target.d.y * Constants.OFFSET); + int tz = (int) Math.floor(target.o.z + target.d.z * Constants.OFFSET); double[] sampleBuffer = scene.getSampleBuffer(); @@ -95,7 +98,7 @@ public void render(DefaultRenderManager manager) throws InterruptedException { // Draw crosshairs if (x == fullWidth / 2 && (y >= fullHeight / 2 - 5 && y <= fullHeight / 2 + 5) || y == fullHeight / 2 && ( x >= fullWidth / 2 - 5 && x <= fullWidth / 2 + 5)) { - sampleBuffer[offset + 0] = 0xFF; + sampleBuffer[offset] = 0xFF; sampleBuffer[offset + 1] = 0xFF; sampleBuffer[offset + 2] = 0xFF; return; @@ -107,24 +110,24 @@ public void render(DefaultRenderManager manager) throws InterruptedException { scene.rayTrace(tracer, state); // Target highlighting. - int rx = (int) Math.floor(state.ray.o.x + state.ray.d.x * Ray.OFFSET); - int ry = (int) Math.floor(state.ray.o.y + state.ray.d.y * Ray.OFFSET); - int rz = (int) Math.floor(state.ray.o.z + state.ray.d.z * Ray.OFFSET); + int rx = (int) Math.floor(state.ray.o.x + state.ray.d.x * Constants.OFFSET); + int ry = (int) Math.floor(state.ray.o.y + state.ray.d.y * Constants.OFFSET); + int rz = (int) Math.floor(state.ray.o.z + state.ray.d.z * Constants.OFFSET); if (hit && tx == rx && ty == ry && tz == rz) { - state.ray.color.x = 1 - state.ray.color.x; - state.ray.color.y = 1 - state.ray.color.y; - state.ray.color.z = 1 - state.ray.color.z; - state.ray.color.w = 1; + state.color.x = 1 - state.color.x; + state.color.y = 1 - state.color.y; + state.color.z = 1 - state.color.z; + state.color.w = 1; } - sampleBuffer[offset + 0] = state.ray.color.x; - sampleBuffer[offset + 1] = state.ray.color.y; - sampleBuffer[offset + 2] = state.ray.color.z; + sampleBuffer[offset + 0] = state.color.x; + sampleBuffer[offset + 1] = state.color.y; + sampleBuffer[offset + 2] = state.color.z; if (sampleNum == 0 && x < (width - 1)) { - sampleBuffer[offset + 3] = state.ray.color.x; - sampleBuffer[offset + 4] = state.ray.color.y; - sampleBuffer[offset + 5] = state.ray.color.z; + sampleBuffer[offset + 3] = state.color.x; + sampleBuffer[offset + 4] = state.color.y; + sampleBuffer[offset + 5] = state.color.z; } }); diff --git a/chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java b/chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java index 3750118cc7..122e86e201 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java @@ -21,6 +21,8 @@ import org.apache.commons.math3.util.FastMath; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.math.Ray; +import se.llbit.math.Ray2; +import se.llbit.math.Vector4; import java.util.ArrayList; import java.util.function.BiConsumer; @@ -70,14 +72,13 @@ protected void submitTiles(DefaultRenderManager manager, BiConsumer manager.pool.submit(worker -> { WorkerState state = new WorkerState(); - state.ray = new Ray(); - state.ray.setNormal(0, 0, -1); state.random = worker.random; IntIntMutablePair pair = new IntIntMutablePair(0, 0); for (int i = tile.x0; i < tile.x1; i++) { for (int j = tile.y0; j < tile.y1; j++) { + state.color.set(0, 0, 0, 0); pair.left(i).right(j); perPixel.accept(state, pair); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/WorkerState.java b/chunky/src/java/se/llbit/chunky/renderer/WorkerState.java index 380ffa28af..944f8343cc 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/WorkerState.java +++ b/chunky/src/java/se/llbit/chunky/renderer/WorkerState.java @@ -16,7 +16,7 @@ */ package se.llbit.chunky.renderer; -import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector4; import java.util.Random; @@ -25,7 +25,8 @@ * State for a render worker. */ public class WorkerState { - public Ray ray; + public Ray2 ray = new Ray2(); + public Vector4 color = new Vector4(); public Vector4 attenuation = new Vector4(); public Random random; } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java index 26c1123202..128bd788d0 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java @@ -23,6 +23,8 @@ import se.llbit.chunky.renderer.ApertureShape; import se.llbit.chunky.resources.BitmapImage; import se.llbit.log.Log; +import se.llbit.math.Constants; +import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Vector3; import se.llbit.resources.ImageLoader; @@ -43,8 +45,8 @@ public class ApertureProjector implements Projector { public ApertureProjector(Projector wrapped, double apertureSize, double subjectDistance) { this.wrapped = wrapped; - this.aperture = Math.max(apertureSize, Ray.EPSILON); - this.subjectDistance = Math.max(subjectDistance, Ray.EPSILON); + this.aperture = Math.max(apertureSize, Constants.EPSILON); + this.subjectDistance = Math.max(subjectDistance, Constants.EPSILON); this.apertureMask = null; } @@ -93,7 +95,7 @@ static private BitmapImage loadApertureMask(ApertureShape apertureShape) { return null; } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { wrapped.apply(x, y, random, o, d); d.scale(subjectDistance / d.z); @@ -144,7 +146,7 @@ static private BitmapImage loadApertureMask(ApertureShape apertureShape) { o.add(rx, ry, 0); } - @Override public void apply(double x, double y, Vector3 pos, Vector3 direction) { + @Override public void apply(double x, double y, Point3 pos, Vector3 direction) { wrapped.apply(x, y, pos, direction); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java index a3786f0129..72b1c0aab1 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java @@ -20,6 +20,7 @@ import org.apache.commons.math3.util.FastMath; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -30,11 +31,11 @@ public FisheyeProjector(double fov) { this.fov = fov; } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Point3 o, Vector3 d) { double ay = QuickMath.degToRad(y * fov); double ax = QuickMath.degToRad(x * fov); double avSquared = ay * ay + ax * ax; diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java index 9c7114af7d..51b90273d8 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java @@ -18,6 +18,7 @@ import java.util.Random; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -36,20 +37,20 @@ public ForwardDisplacementProjector(Projector wrapped, double displacement) { this.displacementSign = QuickMath.signum(displacement); } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { wrapped.apply(x, y, random, o, d); d.normalize(); d.scale(displacementValue); - o.scaleAdd(displacementSign, d); + o.add(d.x * displacementSign, d.y * displacementSign, d.z * displacementSign); } - @Override public void apply(double x, double y, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Point3 o, Vector3 d) { wrapped.apply(x, y, o, d); d.normalize(); d.scale(displacementValue); - o.scaleAdd(displacementSign, d); + o.add(d.x * displacementSign, d.y * displacementSign, d.z * displacementSign); } @Override public double getMinRecommendedFoV() { diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java index 7eb825d7dc..b2845c4172 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java @@ -20,6 +20,7 @@ import org.apache.commons.math3.util.FastMath; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -34,11 +35,11 @@ public PanoramicProjector(double fov) { this.fov = fov; } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Point3 o, Vector3 d) { double ay = QuickMath.degToRad(y * fov); double ax = QuickMath.degToRad(x * fov); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java index b5c7de1436..ad6dccb132 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java @@ -21,6 +21,7 @@ import org.apache.commons.math3.util.FastMath; import se.llbit.chunky.renderer.scene.Camera; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -37,11 +38,11 @@ public PanoramicSlotProjector(double fov) { this.fovTan = Camera.clampedFovTan(fov); } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Point3 o, Vector3 d) { double ax = QuickMath.degToRad(x * fov); double dz = FastMath.cos(ax); double dx = FastMath.sin(ax); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java index 95f0200da8..6f863f7c63 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java @@ -19,7 +19,10 @@ import java.util.Random; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.math.Constants; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; /** @@ -34,11 +37,11 @@ public ParallelProjector(double worldDiagonalSize, double fov) { this.fov = fov; } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Point3 o, Vector3 d) { o.set(fov * x, fov * y, 0); d.set(0, 0, 1); } @@ -55,23 +58,23 @@ public ParallelProjector(double worldDiagonalSize, double fov) { return worldDiagonalSize / 2; } - public static void fixRay(Ray ray, Scene scene) { + public static void fixRay(Ray2 ray, Scene scene) { // When in parallel projection, push the ray origin back so the // ray start outside the octree to prevent ray spawning inside some blocks int limit = (1 << scene.getWorldOctree().getDepth()); - Vector3 o = ray.o; + Point3 o = ray.o; Vector3 d = ray.d; double t = 0; // simplified intersection test with the 6 planes that form the bounding box of the octree - if(Math.abs(d.x) > Ray.EPSILON) { + if(Math.abs(d.x) > Constants.EPSILON) { t = Math.min(t, -o.x / d.x); t = Math.min(t, (limit - o.x) / d.x); } - if(Math.abs(d.y) > Ray.EPSILON) { + if(Math.abs(d.y) > Constants.EPSILON) { t = Math.min(t, -o.y / d.y); t = Math.min(t, (limit - o.y) / d.y); } - if(Math.abs(d.z) > Ray.EPSILON) { + if(Math.abs(d.z) > Constants.EPSILON) { t = Math.min(t, -o.z / d.z); t = Math.min(t, (limit - o.z) / d.z); } @@ -79,6 +82,6 @@ public static void fixRay(Ray ray, Scene scene) { // In theory, we only would need to set it to the closest intersection point behind // but this doesn't matter because the Octree.enterOctree function // will do the same amount of math for the same result no matter what the exact point is - ray.o.scaleAdd(t, d); + ray.o.add(d.x * t, d.y * t, d.z * t); } } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java index a67b2890b6..cf009f6c40 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java @@ -19,6 +19,7 @@ import java.util.Random; import se.llbit.chunky.renderer.scene.Camera; +import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -35,11 +36,11 @@ public PinholeProjector(double fov) { this.fovTan = Camera.clampedFovTan(fov); } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Point3 o, Vector3 d) { o.set(0, 0, 0); d.set(fovTan * x, fovTan * y, 1); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java index 273e16afe5..3a1530c7bf 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java @@ -18,6 +18,7 @@ import java.util.Random; +import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -32,7 +33,7 @@ public interface Projector { * @param direction will be populated with camera-relative ray direction * (not necessarily normalized) */ - void apply(double x, double y, Random random, Vector3 pos, Vector3 direction); + void apply(double x, double y, Random random, Point3 pos, Vector3 direction); /** * @param x pixel X coordinate, where 0 = center and +-0.5 = edges @@ -41,7 +42,7 @@ public interface Projector { * @param direction will be populated with camera-relative ray direction * (not necessarily normalized) */ - void apply(double x, double y, Vector3 pos, Vector3 direction); + void apply(double x, double y, Point3 pos, Vector3 direction); double getMinRecommendedFoV(); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java index 9cfc841786..9f9f2eeb4a 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java @@ -1,6 +1,8 @@ package se.llbit.chunky.renderer.projection; import java.util.Random; + +import se.llbit.math.Point3; import se.llbit.math.Vector3; public class ShiftProjector implements Projector { @@ -15,12 +17,12 @@ public ShiftProjector(Projector wrapped, double shiftX, double shiftY) { } @Override - public void apply(double x, double y, Random random, Vector3 pos, Vector3 direction) { + public void apply(double x, double y, Random random, Point3 pos, Vector3 direction) { wrapped.apply(x + shiftX, y - shiftY, random, pos, direction); } @Override - public void apply(double x, double y, Vector3 pos, Vector3 direction) { + public void apply(double x, double y, Point3 pos, Vector3 direction) { wrapped.apply(x + shiftX, y - shiftY, pos, direction); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java index 7de91fe23b..3e83bed56f 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java @@ -18,6 +18,8 @@ import java.util.Random; +import se.llbit.math.Constants; +import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Vector3; @@ -30,7 +32,7 @@ public SphericalApertureProjector(Projector wrapped, double apertureSize, super(wrapped, apertureSize, subjectDistance); } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { wrapped.apply(x, y, random, o, d); d.scale(subjectDistance); @@ -41,7 +43,7 @@ public SphericalApertureProjector(Projector wrapped, double apertureSize, rx = 2 * random.nextDouble() - 1; ry = 2 * random.nextDouble() - 1; double s = rx * rx + ry * ry; - if (s > Ray.EPSILON && s <= 1) { + if (s > Constants.EPSILON && s <= 1) { rx *= aperture; ry *= aperture; break; diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java index f77a8838c2..c8d3e6f0f4 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java @@ -19,6 +19,7 @@ import java.util.Random; import se.llbit.chunky.renderer.scene.Camera; +import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -34,11 +35,11 @@ public StereographicProjector(double fov) { scale = Camera.clampedFovTan(fov); } - @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Vector3 o, Vector3 d) { + @Override public void apply(double x, double y, Point3 o, Vector3 d) { y *= scale; x *= scale; double xx_yy = x * x + y * y; diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java index 7bd004a1b0..b0a20a0b6d 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java @@ -16,6 +16,7 @@ */ package se.llbit.chunky.renderer.projection.stereo; +import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -31,7 +32,7 @@ public ODSSinglePerspectiveProjector(Eye eye) { } @Override - public void apply(double x, double y, Vector3 pos, Vector3 direction) { + public void apply(double x, double y, Point3 pos, Vector3 direction) { switch (eye) { case LEFT: applyLeftEye(x + 0.5, y + 0.5, pos, direction); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java index e21793feba..6aa408d0a5 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java @@ -16,6 +16,7 @@ */ package se.llbit.chunky.renderer.projection.stereo; +import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -26,7 +27,7 @@ */ public class ODSVerticalStackedProjector extends OmniDirectionalStereoProjector { @Override - public void apply(double x, double y, Vector3 pos, Vector3 direction) { + public void apply(double x, double y, Point3 pos, Vector3 direction) { if(y < 0) { // -0.5 - 0.0 applyLeftEye(x*2 + 1, y*2 + 1, pos, direction); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java index d9397f4cd7..506cda0538 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java @@ -20,6 +20,7 @@ import se.llbit.chunky.renderer.projection.PanoramicProjector; import se.llbit.chunky.renderer.projection.Projector; import se.llbit.math.Constants; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import java.util.Random; @@ -44,18 +45,18 @@ public abstract class OmniDirectionalStereoProjector implements Projector { private static final double INTERPUPILLARY_DISTANCE = 0.069; @Override - public void apply(double x, double y, Random random, Vector3 pos, Vector3 direction) { + public void apply(double x, double y, Random random, Point3 pos, Vector3 direction) { apply(x, y, pos, direction); } @Override - public abstract void apply(double x, double y, Vector3 pos, Vector3 direction); + public abstract void apply(double x, double y, Point3 pos, Vector3 direction); /** * @param x 0-1 * @param y 0-1 */ - protected void applyLeftEye(double x, double y, Vector3 pos, Vector3 direction) { + protected void applyLeftEye(double x, double y, Point3 pos, Vector3 direction) { apply(x, y, -INTERPUPILLARY_DISTANCE / 2, pos, direction); } @@ -63,7 +64,7 @@ protected void applyLeftEye(double x, double y, Vector3 pos, Vector3 direction) * @param x 0-1 * @param y 0-1 */ - protected void applyRightEye(double x, double y, Vector3 pos, Vector3 direction) { + protected void applyRightEye(double x, double y, Point3 pos, Vector3 direction) { apply(x, y, INTERPUPILLARY_DISTANCE / 2, pos, direction); } @@ -71,7 +72,7 @@ protected void applyRightEye(double x, double y, Vector3 pos, Vector3 direction) * @param x 0-1 * @param y 0-1 */ - private void apply(double x, double y, double scale, Vector3 pos, Vector3 direction) { + private void apply(double x, double y, double scale, Point3 pos, Vector3 direction) { double theta = x * Math.PI - Constants.HALF_PI; double phi = Constants.HALF_PI - y * Math.PI; diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/AlphaBuffer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/AlphaBuffer.java index d4d689a092..015a62f546 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/AlphaBuffer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/AlphaBuffer.java @@ -6,6 +6,7 @@ import se.llbit.chunky.renderer.projection.ProjectionMode; import se.llbit.log.Log; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.util.TaskTracker; import java.nio.ByteBuffer; @@ -78,7 +79,6 @@ void computeAlpha(Scene scene, Type type, TaskTracker taskTracker) { Chunky.getCommonThreads().submit(() -> { IntStream.range(0, scene.width).parallel().forEach(x -> { WorkerState state = new WorkerState(); - state.ray = new Ray(); for (int y = 0; y < scene.height; y++) { computeAlpha(scene, x, y, state); @@ -96,7 +96,7 @@ void computeAlpha(Scene scene, Type type, TaskTracker taskTracker) { * Compute the alpha channel based on sky visibility. */ public void computeAlpha(Scene scene, int x, int y, WorkerState state) { - Ray ray = state.ray; + Ray2 ray = state.ray; double halfWidth = scene.width / (2.0 * scene.height); double invHeight = 1.0 / scene.height; diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java index 2d21ca07a2..298121cbdc 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java @@ -38,15 +38,19 @@ import se.llbit.chunky.world.Chunk; import se.llbit.json.JsonObject; import se.llbit.log.Log; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Matrix3; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector2; import se.llbit.math.Vector3; import se.llbit.util.JsonSerializable; import se.llbit.util.annotation.Nullable; import java.util.Random; +import java.util.function.BiPredicate; import java.util.function.Function; /** @@ -96,7 +100,7 @@ public static double clampedFovTan(double fov) { private boolean lockCamera = false; - Vector3 pos = new Vector3(0, 0, 0); + Point3 pos = new Point3(0, 0, 0); /** * Scratch vector used for temporary storage. @@ -265,8 +269,8 @@ private void initProjector() { /** * Set the camera position. */ - public void setPosition(Vector3 v) { - pos.set(v); + public void setPosition(Point3 p) { + pos.set(p); onViewChange(); positionListener.run(); } @@ -368,7 +372,8 @@ public synchronized void moveForward(double v) { u.set(0, -1, 0); } transform.transform(u); - pos.scaleAdd(v, u); + u.scale(v); + pos.add(u); onViewChange(); positionListener.run(); } @@ -383,7 +388,8 @@ public synchronized void moveBackward(double v) { u.set(0, -1, 0); } transform.transform(u); - pos.scaleAdd(-v, u); + u.scale(-v); + pos.add(u); onViewChange(); positionListener.run(); } @@ -393,7 +399,8 @@ public synchronized void moveBackward(double v) { */ public synchronized void moveUp(double v) { u.set(0, 1, 0); - pos.scaleAdd(v, u); + u.scale(v); + pos.add(u); onViewChange(); positionListener.run(); } @@ -403,7 +410,8 @@ public synchronized void moveUp(double v) { */ public synchronized void moveDown(double v) { u.set(0, 1, 0); - pos.scaleAdd(-v, u); + u.scale(-v); + pos.add(u); onViewChange(); positionListener.run(); } @@ -414,7 +422,8 @@ public synchronized void moveDown(double v) { public synchronized void strafeLeft(double v) { u.set(1, 0, 0); transform.transform(u); - pos.scaleAdd(-v, u); + u.scale(-v); + pos.add(u); onViewChange(); positionListener.run(); } @@ -425,7 +434,8 @@ public synchronized void strafeLeft(double v) { public synchronized void strafeRight(double v) { u.set(1, 0, 0); transform.transform(u); - pos.scaleAdd(v, u); + u.scale(v); + pos.add(u); onViewChange(); positionListener.run(); } @@ -507,10 +517,7 @@ synchronized void updateTransform() { * @param x normalized image coordinate [-0.5, 0.5] * @param y normalized image coordinate [-0.5, 0.5] */ - public void calcViewRay(Ray ray, Random random, double x, double y) { - // Reset the ray properties - current material etc. - ray.setDefault(); - + public void calcViewRay(Ray2 ray, Random random, double x, double y) { projector.apply(x, y, random, ray.o, ray.d); ray.d.normalize(); @@ -529,10 +536,7 @@ public void calcViewRay(Ray ray, Random random, double x, double y) { * @param x normalized image coordinate [-0.5, 0.5] * @param y normalized image coordinate [-0.5, 0.5] */ - public void calcViewRay(Ray ray, double x, double y) { - // Reset the ray properties - current material etc. - ray.setDefault(); - + public void calcViewRay(Ray2 ray, double x, double y) { projector.apply(x, y, ray.o, ray.d); ray.d.normalize(); @@ -556,7 +560,7 @@ public void transform(Vector3 d) { /** * @return Current position */ - public Vector3 getPosition() { + public Point3 getPosition() { return pos; } @@ -703,16 +707,17 @@ public void moveToPlayer(Entity player) { onViewChange(); } - public void autoFocus(Function traceInScene) { - Ray ray = new Ray(); - if (!traceInScene.apply(ray)) { + public void autoFocus(BiPredicate traceInScene) { + Ray2 ray = new Ray2(); + IntersectionRecord intersectionRecord = new IntersectionRecord(); + if (!traceInScene.test(ray, intersectionRecord)) { setDof(Double.POSITIVE_INFINITY); } else { if(projectionMode == ProjectionMode.PARALLEL) { - ray.distance -= worldDiagonalSize; + intersectionRecord.distance -= worldDiagonalSize; } - setSubjectDistance(ray.distance); - setDof(ray.distance * ray.distance); + setSubjectDistance(intersectionRecord.distance); + setDof(intersectionRecord.distance * intersectionRecord.distance); } } @@ -731,7 +736,7 @@ public void setProjectionListener(Runnable projectionListener) { /** * Update the argument ray to point toward the current target. */ - public void getTargetDirection(Ray ray) { + public void getTargetDirection(Ray2 ray) { calcViewRay(ray, target.x, target.y); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java index 76f16794e3..bc21002d94 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java @@ -8,6 +8,7 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Constants; import se.llbit.math.QuickMath; import se.llbit.math.Ray; import se.llbit.math.Vector3; @@ -126,7 +127,7 @@ public void addGroundFog(Ray ray, Vector3 ox, double airDistance, Vector4 scatte double fogDensity = uniformDensity * EXTINCTION_FACTOR; double extinction = Math.exp(-airDistance * fogDensity); color.scale(extinction); - if (scatterLight.w > Ray.EPSILON) { + if (scatterLight.w > Constants.EPSILON) { double inscatter = scatterLight.w; if (fastFog) { inscatter *= (1 - extinction); @@ -151,7 +152,7 @@ public void addLayeredFog(Vector4 color, double dy, double y1, double y2, Vector } double extinction = Math.exp(total / clampDy(dy)); color.scale(extinction); - if (scatterLight.w > Ray.EPSILON) { + if (scatterLight.w > Constants.EPSILON) { double inscatter = (1 - extinction) * scatterLight.w; color.x += inscatter * scatterLight.x * fogColor.x; color.y += inscatter * scatterLight.y * fogColor.y; @@ -162,7 +163,7 @@ public void addLayeredFog(Vector4 color, double dy, double y1, double y2, Vector public double sampleGroundScatterOffset(Ray ray, Vector3 ox, Random random) { double airDistance = ray.distance; if (mode == FogMode.UNIFORM) { - return QuickMath.clamp(airDistance * random.nextFloat(), Ray.EPSILON, airDistance - Ray.EPSILON); + return QuickMath.clamp(airDistance * random.nextFloat(), Constants.EPSILON, airDistance - Constants.EPSILON); } else if (mode == FogMode.LAYERED) { double dy = ray.d.y; double y1 = ox.y; @@ -186,7 +187,7 @@ public double sampleSkyScatterOffset(Scene scene, Ray ray, Random random) { private double sampleLayeredScatterOffset(Random random, double y1, double y2, double dy) { if (layers.size() == 0) { - return Ray.EPSILON; + return Constants.EPSILON; } // This works only for one fog layer yet. FogLayer layer = layers.get(0); diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/LegacyWaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/LegacyWaterShader.java index deff6a0ff5..4c98a96765 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/LegacyWaterShader.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/LegacyWaterShader.java @@ -18,12 +18,14 @@ import se.llbit.chunky.model.minecraft.WaterModel; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class LegacyWaterShader implements WaterShader { @Override - public void doWaterShading(Ray ray, double animationTime) { - WaterModel.doWaterDisplacement(ray); + public void doWaterShading(Ray2 ray, IntersectionRecord intersectionRecord, double animationTime) { + WaterModel.doWaterDisplacement(ray, intersectionRecord); } @Override diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java index a910cd0366..db9add2533 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java @@ -22,6 +22,7 @@ import se.llbit.chunky.world.ChunkPosition; import se.llbit.chunky.world.Material; import se.llbit.math.Octree; +import se.llbit.math.Point3i; import se.llbit.math.Vector3i; /** @@ -41,7 +42,7 @@ public class OctreeFinalizer { * @param cp Position of the chunk to finalize */ public static void finalizeChunk(Octree worldTree, Octree waterTree, BlockPalette palette, - Vector3i origin, ChunkPosition cp, int yMin, int yMax) { + Point3i origin, ChunkPosition cp, int yMin, int yMax) { for (int cy = yMin; cy < yMax; ++cy) { for (int cz = 0; cz < 16; ++cz) { int z = cz + cp.z * 16 - origin.z; @@ -58,7 +59,7 @@ public static void finalizeChunk(Octree worldTree, Octree waterTree, BlockPalett } private static void hideBlocks(Octree worldTree, BlockPalette palette, int x, - int cy, int z, int yMin, int yMax, Vector3i origin) { + int cy, int z, int yMin, int yMax, Point3i origin) { // Set non-visible blocks to be any block, in order to merge large patches. int y = cy - origin.y; if (cy > yMin && cy < yMax - 1) { @@ -76,7 +77,7 @@ private static void hideBlocks(Octree worldTree, BlockPalette palette, int x, } private static void processBlock(Octree worldTree, Octree waterTree, BlockPalette palette, int x, - int cy, int z, Vector3i origin) { + int cy, int z, Point3i origin) { int y = cy - origin.y; Material mat = worldTree.getMaterial(x, y, z, palette); Material wmat = waterTree.getMaterial(x, y, z, palette); diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java index 277f8ec3f0..1fc9e19138 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java @@ -17,15 +17,11 @@ */ package se.llbit.chunky.renderer.scene; -import org.apache.commons.math3.util.FastMath; import se.llbit.chunky.block.minecraft.Air; import se.llbit.chunky.block.minecraft.Water; -import se.llbit.chunky.renderer.EmitterSamplingStrategy; import se.llbit.chunky.renderer.WorkerState; -import se.llbit.chunky.world.Material; import se.llbit.math.*; -import java.util.List; import java.util.Random; /** @@ -39,12 +35,8 @@ public class PathTracer implements RayTracer { * Path trace the ray. */ @Override public void trace(Scene scene, WorkerState state) { - Ray ray = state.ray; - if (scene.isInWater(ray)) { - ray.setCurrentMaterial(Water.INSTANCE); - } else { - ray.setCurrentMaterial(Air.INSTANCE); - } + Ray2 ray = state.ray; + ray.setCurrentMedium(scene.getWorldMaterial(ray.o)); pathTrace(scene, ray, state, true); } @@ -54,528 +46,51 @@ public class PathTracer implements RayTracer { * @param firstReflection {@code true} if the ray has not yet hit the first * diffuse or specular reflection */ - public static boolean pathTrace(Scene scene, Ray ray, WorkerState state, + public static void pathTrace(Scene scene, Ray2 ray, WorkerState state, boolean firstReflection) { - - boolean hit = false; Random random = state.random; - Vector3 ox = new Vector3(ray.o); - Vector3 od = new Vector3(ray.d); - double airDistance = 0; +// Vector3 ox = new Vector3(ray.o); +// Vector3 od = new Vector3(ray.d); - while (true) { - - if (!PreviewRayTracer.nextIntersection(scene, ray)) { - if (ray.getPrevMaterial().isWater()) { - ray.color.set(0, 0, 0, 1); - hit = true; - } else if (ray.depth == 0) { - // Direct sky hit. - if (!scene.transparentSky()) { - scene.sky.getSkyColorInterpolated(ray); - addSkyFog(scene, ray, state, ox, od); - hit = true; - } - } else if (ray.specular) { - // Indirect sky hit - specular color. - scene.sky.getSkyColor(ray, true); - addSkyFog(scene, ray, state, ox, od); - hit = true; - } else { - // Indirect sky hit - diffuse color. - scene.sky.getSkyColorDiffuseSun(ray, scene.getSunSamplingStrategy().isDiffuseSun()); - // Skip sky fog - likely not noticeable in diffuse reflection. - hit = true; - } - break; - } + Vector4 cumulativeColor = state.color; + Vector3 throughput = new Vector3(1, 1, 1); - Material currentMat = ray.getCurrentMaterial(); - Material prevMat = ray.getPrevMaterial(); + int rayDepth = 0; + while (rayDepth < scene.rayDepth) { - if (!(scene.getCurrentWaterShader() instanceof StillWaterShader) && ray.getNormal().y != 0 && - ((currentMat.isWater() && prevMat == Air.INSTANCE) - || (currentMat == Air.INSTANCE && prevMat.isWater()))) { - scene.getCurrentWaterShader().doWaterShading(ray, scene.getAnimationTime()); - if (currentMat == Air.INSTANCE) { - ray.invertNormal(); - } - } + IntersectionRecord intersectionRecord = new IntersectionRecord(); - float pSpecular = currentMat.specular; + if (scene.intersect(ray, intersectionRecord)) { - double pDiffuse = scene.fancierTranslucency ? 1 - Math.sqrt(1 - ray.color.w) : ray.color.w; - - float n1 = prevMat.ior; - float n2 = currentMat.ior; - - if (prevMat == Air.INSTANCE || prevMat.isWater()) { - airDistance = ray.distance; - } - - if (pDiffuse + pSpecular < Ray.EPSILON && n1 == n2) { - // Transmission without refraction. - // This can happen when the ray passes through a transparent - // material into another. It can also happen for example - // when passing through a transparent part of an otherwise solid - // object. - // TODO: material color may change here. - continue; - } - if(ray.depth + 1 >= scene.rayDepth) { - break; - } - Vector4 cumulativeColor = new Vector4(0, 0, 0, 0); - Ray next = new Ray(); - float pMetal = currentMat.metalness; - // Reusing first rays - a simplified form of "branched path tracing" (what Blender used to call it before they implemented something fancier) - // The initial rays cast into the scene are very similar between each sample, since they are almost entirely a function of the pixel coordinates - // Because of that, casting those initial rays on every sample is redundant and can be skipped - // If the ray depth is high, this doesn't help much (just a few percent), but in some outdoor/low depth scenes, this can improve performance by >40% - // The main caveat is that antialiasing is achieved by varying the starting rays at the subpixel level (see PathTracingRenderer.java) - // Therefore, it's still necessary to have a decent amount (20 is ok, 50 is better) of distinct starting rays for each pixel - // scene.branchCount is the number of times we use the same first ray before casting a new one - int count = firstReflection ? scene.getCurrentBranchCount() : 1; - for (int i = 0; i < count; i++) { - boolean doMetal = pMetal > Ray.EPSILON && random.nextFloat() < pMetal; - if (doMetal || (pSpecular > Ray.EPSILON && random.nextFloat() < pSpecular)) { - hit |= doSpecularReflection(ray, next, cumulativeColor, doMetal, random, state, scene); - } else if(random.nextFloat() < pDiffuse) { - hit |= doDiffuseReflection(ray, next, currentMat, cumulativeColor, random, state, scene); - } else if (n1 != n2) { - hit |= doRefraction(ray, next, currentMat, prevMat, cumulativeColor, n1, n2, pDiffuse, random, state, scene); - } else { - hit |= doTransmission(ray, next, cumulativeColor, pDiffuse, state, scene); + if (intersectionRecord.material.setOutboundDir(ray, intersectionRecord, random)) { + rayDepth--; } - } - ray.color.set(cumulativeColor); - ray.color.scale(1d/count); - - if (hit && prevMat.isWater()) { - // Render water fog effect. - if(scene.waterVisibility == 0) { - ray.color.scale(0.); - } else { - double a = ray.distance / scene.waterVisibility; - double attenuation = Math.exp(-a); - ray.color.scale(attenuation); - } - } - - break; - } - if (!hit) { - ray.color.set(0, 0, 0, 1); - if (firstReflection) { - airDistance = ray.distance; - } - } - - // This is a simplistic fog model which gives greater artistic freedom but - // less realism. The user can select fog color and density; in a more - // realistic model color would depend on viewing angle and sun color/position. - if (airDistance > 0 && scene.fog.fogEnabled()) { - - // Pick point between ray origin and intersected object. - // The chosen point is used to test if the sun is lighting the - // fog between the camera and the first diffuse ray target. - // The sun contribution will be proportional to the amount of - // sunlit fog areas in the ray path, thus giving an approximation - // of the sun inscatter leading to effects like god rays. - // The way the sun contribution point is chosen is not - // entirely correct because the original ray may have - // travelled through glass or other materials between air gaps. - // However, the results are probably close enough to not be distracting, - // so this seems like a reasonable approximation. - Ray atmos = new Ray(); - double offset = scene.fog.sampleGroundScatterOffset(ray, ox, random); - atmos.o.scaleAdd(offset, od, ox); - scene.sun.getRandomSunDirection(atmos, random); - atmos.setCurrentMaterial(Air.INSTANCE); - - // Check sun visibility at random point to determine inscatter brightness. - getDirectLightAttenuation(scene, atmos, state); - scene.fog.addGroundFog(ray, ox, airDistance, state.attenuation, offset); - } - - return hit; - } - - private static boolean doSpecularReflection(Ray ray, Ray next, Vector4 cumulativeColor, boolean doMetal, Random random, WorkerState state, Scene scene) { - boolean hit = false; - next.specularReflection(ray, random); - if (pathTrace(scene, next, state, false)) { - - if (doMetal) { - // use the albedo color as specular color - cumulativeColor.x += ray.color.x * next.color.x; - cumulativeColor.y += ray.color.y * next.color.y; - cumulativeColor.z += ray.color.z * next.color.z; - } else { - cumulativeColor.x += next.color.x; - cumulativeColor.y += next.color.y; - cumulativeColor.z += next.color.z; - } - hit = true; - } - return hit; - } - - private static boolean doDiffuseReflection(Ray ray, Ray next, Material currentMat, Vector4 cumulativeColor, Random random, WorkerState state, Scene scene) { - boolean hit = false; - Vector3 emittance = new Vector3(); - Vector4 indirectEmitterColor = new Vector4(0, 0, 0, 0); - - if (scene.emittersEnabled && (!scene.isPreventNormalEmitterWithSampling() || scene.getEmitterSamplingStrategy() == EmitterSamplingStrategy.NONE || ray.depth == 0) && currentMat.emittance > Ray.EPSILON) { - - // Quadratic emittance mapping, so a pixel that's 50% darker will emit only 25% as much light - // This is arbitrary but gives pretty good results in most cases. - emittance = new Vector3(ray.color.x * ray.color.x, ray.color.y * ray.color.y, ray.color.z * ray.color.z); - emittance.scale(currentMat.emittance * scene.emitterIntensity); - - hit = true; - } else if (scene.emittersEnabled && scene.emitterSamplingStrategy != EmitterSamplingStrategy.NONE && scene.getEmitterGrid() != null) { - // Sample emitter - switch (scene.emitterSamplingStrategy) { - case ONE: - case ONE_BLOCK: { - Grid.EmitterPosition pos = scene.getEmitterGrid().sampleEmitterPosition((int) ray.o.x, (int) ray.o.y, (int) ray.o.z, random); - if (pos != null) { - indirectEmitterColor.scaleAdd(Math.PI, sampleEmitter(scene, ray, pos, random)); - } - break; - } - case ALL: { - List positions = scene.getEmitterGrid().getEmitterPositions((int) ray.o.x, (int) ray.o.y, (int) ray.o.z); - double sampleScaler = Math.PI / positions.size(); - for (Grid.EmitterPosition pos : positions) { - indirectEmitterColor.scaleAdd(sampleScaler, sampleEmitter(scene, ray, pos, random)); - } - break; - } - } - } - - if (scene.getSunSamplingStrategy().doSunSampling()) { - next.set(ray); - scene.sun.getRandomSunDirection(next, random); - - double directLightR = 0; - double directLightG = 0; - double directLightB = 0; - - boolean frontLight = next.d.dot(ray.getNormal()) > 0; - - if (frontLight || (currentMat.subSurfaceScattering - && random.nextFloat() < Scene.fSubSurface)) { - - if (!frontLight) { - next.o.scaleAdd(-Ray.OFFSET, ray.getNormal()); - } - - next.setCurrentMaterial(next.getPrevMaterial(), next.getPrevData()); - - getDirectLightAttenuation(scene, next, state); - - Vector4 attenuation = state.attenuation; - if (attenuation.w > 0) { - double mult = QuickMath.abs(next.d.dot(ray.getNormal())) * (scene.getSunSamplingStrategy().isSunLuminosity() ? scene.sun().getLuminosityPdf() : 1); - directLightR = attenuation.x * attenuation.w * mult; - directLightG = attenuation.y * attenuation.w * mult; - directLightB = attenuation.z * attenuation.w * mult; - hit = true; - } - } - - next.diffuseReflection(ray, random); - hit = pathTrace(scene, next, state, false) || hit; - if (hit) { - cumulativeColor.x += emittance.x + ray.color.x * (directLightR * scene.sun.emittance.x + next.color.x + indirectEmitterColor.x); - cumulativeColor.y += emittance.y + ray.color.y * (directLightG * scene.sun.emittance.y + next.color.y + indirectEmitterColor.y); - cumulativeColor.z += emittance.z + ray.color.z * (directLightB * scene.sun.emittance.z + next.color.z + indirectEmitterColor.z); - } else if (indirectEmitterColor.x > Ray.EPSILON || indirectEmitterColor.y > Ray.EPSILON || indirectEmitterColor.z > Ray.EPSILON) { - hit = true; - cumulativeColor.x += ray.color.x * indirectEmitterColor.x; - cumulativeColor.y += ray.color.y * indirectEmitterColor.y; - cumulativeColor.z += ray.color.z * indirectEmitterColor.z; - } - - } else { - next.diffuseReflection(ray, random); - hit = pathTrace(scene, next, state, false) || hit; - if (hit) { - cumulativeColor.x += emittance.x + ray.color.x * (next.color.x + indirectEmitterColor.x); - cumulativeColor.y += emittance.y + ray.color.y * (next.color.y + indirectEmitterColor.y); - cumulativeColor.z += emittance.z + ray.color.z * (next.color.z + indirectEmitterColor.z); - } else if (indirectEmitterColor.x > Ray.EPSILON || indirectEmitterColor.y > Ray.EPSILON || indirectEmitterColor.z > Ray.EPSILON) { - hit = true; - cumulativeColor.x += ray.color.x * indirectEmitterColor.x; - cumulativeColor.y += ray.color.y * indirectEmitterColor.y; - cumulativeColor.z += ray.color.z * indirectEmitterColor.z; - } - } - return hit; - } - - private static boolean doRefraction(Ray ray, Ray next, Material currentMat, Material prevMat, Vector4 cumulativeColor, float n1, float n2, double pDiffuse, Random random, WorkerState state, Scene scene) { - boolean hit = false; - // TODO: make this decision dependent on the material properties: - boolean doRefraction = currentMat.refractive || prevMat.refractive; + ray.o.add(ray.d.x * (intersectionRecord.distance - Constants.OFFSET), ray.d.y * (intersectionRecord.distance - Constants.OFFSET), ray.d.z * (intersectionRecord.distance - Constants.OFFSET)); - float n1n2 = n1 / n2; - double cosTheta = -ray.getNormal().dot(ray.d); - double radicand = 1 - n1n2 * n1n2 * (1 - cosTheta * cosTheta); - if (doRefraction && radicand < Ray.EPSILON) { - // Total internal reflection. - next.specularReflection(ray, random); - if (pathTrace(scene, next, state, false)) { + throughput.x *= intersectionRecord.color.x; + throughput.y *= intersectionRecord.color.y; + throughput.z *= intersectionRecord.color.z; - cumulativeColor.x += next.color.x; - cumulativeColor.y += next.color.y; - cumulativeColor.z += next.color.z; - hit = true; - } - } else { - next.set(ray); - - // Calculate angle-dependent reflectance using - // Fresnel equation approximation: - // R(cosineAngle) = R0 + (1 - R0) * (1 - cos(cosineAngle))^5 - float a = (n1n2 - 1); - float b = (n1n2 + 1); - double R0 = a * a / (b * b); - double c = 1 - cosTheta; - double Rtheta = R0 + (1 - R0) * c * c * c * c * c; + cumulativeColor.x += intersectionRecord.color.x * intersectionRecord.material.emittance * scene.emitterIntensity * throughput.x; + cumulativeColor.y += intersectionRecord.color.y * intersectionRecord.material.emittance * scene.emitterIntensity * throughput.y; + cumulativeColor.z += intersectionRecord.color.z * intersectionRecord.material.emittance * scene.emitterIntensity * throughput.z; - if (random.nextFloat() < Rtheta) { - next.specularReflection(ray, random); - if (pathTrace(scene, next, state, false)) { - - cumulativeColor.x += next.color.x; - cumulativeColor.y += next.color.y; - cumulativeColor.z += next.color.z; - hit = true; - } } else { - if (doRefraction) { + scene.sky.getSkyColor(ray, intersectionRecord); - double t2 = FastMath.sqrt(radicand); - Vector3 n = ray.getNormal(); - if (cosTheta > 0) { - next.d.x = n1n2 * ray.d.x + (n1n2 * cosTheta - t2) * n.x; - next.d.y = n1n2 * ray.d.y + (n1n2 * cosTheta - t2) * n.y; - next.d.z = n1n2 * ray.d.z + (n1n2 * cosTheta - t2) * n.z; - } else { - next.d.x = n1n2 * ray.d.x - (-n1n2 * cosTheta - t2) * n.x; - next.d.y = n1n2 * ray.d.y - (-n1n2 * cosTheta - t2) * n.y; - next.d.z = n1n2 * ray.d.z - (-n1n2 * cosTheta - t2) * n.z; - } + throughput.x *= intersectionRecord.color.x; + throughput.y *= intersectionRecord.color.y; + throughput.z *= intersectionRecord.color.z; - next.d.normalize(); + cumulativeColor.x += throughput.x; + cumulativeColor.y += throughput.y; + cumulativeColor.z += throughput.z; - // See Ray.specularReflection for information on why this is needed - // This is the same thing but for refraction instead of reflection - // so this time we want the signs of the dot product to be the same - if (QuickMath.signum(next.getGeometryNormal().dot(next.d)) != QuickMath.signum(next.getGeometryNormal().dot(ray.d))) { - double factor = QuickMath.signum(next.getGeometryNormal().dot(ray.d)) * -Ray.EPSILON - next.d.dot(next.getGeometryNormal()); - next.d.scaleAdd(factor, next.getGeometryNormal()); - next.d.normalize(); - } - - next.o.scaleAdd(Ray.OFFSET, next.d); - } - - if (pathTrace(scene, next, state, false)) { - // Calculate the color and emittance of the refracted ray - translucentRayColor(scene, ray, next, cumulativeColor, pDiffuse); - hit = true; - } - } - } - return hit; - } - - private static boolean doTransmission(Ray ray, Ray next, Vector4 cumulativeColor, double pDiffuse, WorkerState state, Scene scene) { - boolean hit = false; - next.set(ray); - next.o.scaleAdd(Ray.OFFSET, next.d); - - if (pathTrace(scene, next, state, false)) { - // Calculate the color and emittance of the refracted ray - translucentRayColor(scene, ray, next, cumulativeColor, pDiffuse); - hit = true; - } - return hit; - } - - private static void translucentRayColor(Scene scene, Ray ray, Ray next, Vector4 cumulativeColor, double opacity) { - Vector3 rgbTrans; - if(scene.fancierTranslucency) { - // Color-based transmission value - double colorTrans = (ray.color.x + ray.color.y + ray.color.z) / 3; - // Total amount of light we want to transmit (overall transparency of texture) - double shouldTrans = 1 - opacity; - // Amount of each color to transmit - default to overall transparency if RGB values add to 0 (e.g. regular glass) - rgbTrans = new Vector3(shouldTrans, shouldTrans, shouldTrans); - if (colorTrans > 0) { - // Amount to transmit of each color is scaled so the total transmitted amount matches the texture's transparency - rgbTrans.set(ray.color.toVec3()); - rgbTrans.scale(shouldTrans / colorTrans); - } - double transmissivityCap = scene.transmissivityCap; - // Determine the color with the highest transmissivity - double maxTrans = Math.max(rgbTrans.x, Math.max(rgbTrans.y, rgbTrans.z)); - if (maxTrans > transmissivityCap) { - if (maxTrans == rgbTrans.x) { - // Give excess transmission from red to green and blue - double gTransNew = reassignTransmissivity(rgbTrans.x, rgbTrans.y, rgbTrans.z, shouldTrans, transmissivityCap); - rgbTrans.z = reassignTransmissivity(rgbTrans.x, rgbTrans.z, rgbTrans.y, shouldTrans, transmissivityCap); - rgbTrans.y = gTransNew; - rgbTrans.x = transmissivityCap; - } else if (maxTrans == rgbTrans.y) { - // Give excess transmission from green to red and blue - double rTransNew = reassignTransmissivity(rgbTrans.y, rgbTrans.x, rgbTrans.z, shouldTrans, transmissivityCap); - rgbTrans.z = reassignTransmissivity(rgbTrans.y, rgbTrans.z, rgbTrans.x, shouldTrans, transmissivityCap); - rgbTrans.x = rTransNew; - rgbTrans.y = transmissivityCap; - } else if (maxTrans == rgbTrans.z) { - // Give excess transmission from blue to green and red - double gTransNew = reassignTransmissivity(rgbTrans.z, rgbTrans.y, rgbTrans.x, shouldTrans, transmissivityCap); - rgbTrans.x = reassignTransmissivity(rgbTrans.z, rgbTrans.x, rgbTrans.y, shouldTrans, transmissivityCap); - rgbTrans.y = gTransNew; - rgbTrans.z = transmissivityCap; - } - } - // Don't need to check for energy gain if transmissivity cap is 1 - if (transmissivityCap > 1) { - double currentEnergy = rgbTrans.x * next.color.x + rgbTrans.y * next.color.y + rgbTrans.z * next.color.z; - double nextEnergy = next.color.x + next.color.y + next.color.z; - double energyRatio = nextEnergy / currentEnergy; - // Normalize if there is net energy gain across all channels (more likely for higher transmissivityCap combined with high-saturation light source) - if (energyRatio < 1) { - rgbTrans.scale(energyRatio); - } - } - } else { - // Old method (see https://github.com/chunky-dev/chunky/pull/1513) - rgbTrans = new Vector3(1 - opacity, 1 - opacity, 1 - opacity); - rgbTrans.scaleAdd(opacity, ray.color.toVec3()); - } - // Scale color based on next ray - Vector4 outputColor = new Vector4(0, 0, 0, 0); - outputColor.multiplyEntrywise(new Vector4(rgbTrans, 1), next.color); - cumulativeColor.add(outputColor); - } - - private static double reassignTransmissivity(double from, double to, double other, double trans, double cap) { - // Formula here derived algebraically from this system: - // (cap - to_new)/(cap - other_new) = (from - to)/(from - other), (cap + to_new + other_new)/3 = trans - return (cap*(other - 2*to + from) + (3*trans)*(to - from))/(other + to - 2*from); - } - - private static void addSkyFog(Scene scene, Ray ray, WorkerState state, Vector3 ox, Vector3 od) { - if (scene.fog.mode == FogMode.UNIFORM) { - scene.fog.addSkyFog(ray, null); - } else if (scene.fog.mode == FogMode.LAYERED) { - Ray atmos = new Ray(); - double offset = scene.fog.sampleSkyScatterOffset(scene, ray, state.random); - atmos.o.scaleAdd(offset, od, ox); - scene.sun.getRandomSunDirection(atmos, state.random); - atmos.setCurrentMaterial(Air.INSTANCE); - getDirectLightAttenuation(scene, atmos, state); - scene.fog.addSkyFog(ray, state.attenuation); - } - } - - private static void sampleEmitterFace(Scene scene, Ray ray, Grid.EmitterPosition pos, int face, Vector4 result, double scaler, Random random) { - Ray emitterRay = new Ray(ray); - - pos.sampleFace(face, emitterRay.d, random); - emitterRay.d.sub(emitterRay.o); - - if (emitterRay.d.dot(ray.getNormal()) > 0) { - double distance = emitterRay.d.length(); - emitterRay.d.scale(1 / distance); - - emitterRay.o.scaleAdd(Ray.OFFSET, emitterRay.d); - emitterRay.distance += Ray.OFFSET; - PreviewRayTracer.nextIntersection(scene, emitterRay); - if (Math.abs(emitterRay.distance - distance) < Ray.OFFSET) { - double e = Math.abs(emitterRay.d.dot(emitterRay.getNormal())); - e /= Math.max(distance * distance, 1); - e *= pos.block.surfaceArea(face); - e *= emitterRay.getCurrentMaterial().emittance; - e *= scene.emitterIntensity; - e *= scaler; - - result.scaleAdd(e, emitterRay.color); - } - } - } - - /** - * Cast a shadow ray from the intersection point (given by ray) to the emitter - * at position pos. Returns the contribution of this emitter (0 if the emitter is occluded) - * @param scene The scene being rendered - * @param ray The ray that generated the intersection - * @param pos The position of the emitter to sample - * @param random RNG - * @return The contribution of the emitter - */ - private static Vector4 sampleEmitter(Scene scene, Ray ray, Grid.EmitterPosition pos, Random random) { - Vector4 result = new Vector4(); - result.set(0, 0, 0, 1); - - switch (scene.getEmitterSamplingStrategy()) { - default: - case ONE: - sampleEmitterFace(scene, ray, pos, random.nextInt(pos.block.faceCount()), result, 1, random); - break; - case ONE_BLOCK: - case ALL: - double scaler = 1.0 / pos.block.faceCount(); - for (int i = 0; i < pos.block.faceCount(); i++) { - sampleEmitterFace(scene, ray, pos, i, result, scaler, random); - } break; - } - - return result; - } - - /** - * Calculate direct lighting attenuation. - */ - public static void getDirectLightAttenuation(Scene scene, Ray ray, WorkerState state) { - Vector4 attenuation = state.attenuation; - attenuation.x = 1; - attenuation.y = 1; - attenuation.z = 1; - attenuation.w = 1; - while (attenuation.w > 0) { - ray.o.scaleAdd(Ray.OFFSET, ray.d); - if (!PreviewRayTracer.nextIntersection(scene, ray)) { - break; - } - double mult = 1 - ray.color.w; - attenuation.x *= ray.color.x * ray.color.w + mult; - attenuation.y *= ray.color.y * ray.color.w + mult; - attenuation.z *= ray.color.z * ray.color.w + mult; - attenuation.w *= mult; - if (ray.getPrevMaterial().isWater()) { - if(scene.waterVisibility == 0) { - attenuation.w = 0; - } else { - double a = ray.distance / scene.waterVisibility; - attenuation.w *= Math.exp(-a); - } - } - if (scene.getSunSamplingStrategy().isStrictDirectLight() && ray.getPrevMaterial().ior != ray.getCurrentMaterial().ior) { - attenuation.w = 0; } + rayDepth++; } } - } diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PreethamSky.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PreethamSky.java index 5f71ded379..1a4018198c 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/PreethamSky.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/PreethamSky.java @@ -17,6 +17,7 @@ package se.llbit.chunky.renderer.scene; import org.apache.commons.math3.util.FastMath; +import se.llbit.math.Constants; import se.llbit.math.QuickMath; import se.llbit.math.Ray; import se.llbit.math.Vector3; @@ -136,7 +137,7 @@ public Vector3 calcIncidentLight(Ray ray) { double x = zenith_x * perezF(cosTheta, gamma, cos2Gamma, A.x, B.x, C.x, D.x, E.x) * f0_x; double y = zenith_y * perezF(cosTheta, gamma, cos2Gamma, A.y, B.y, C.y, D.y, E.y) * f0_y; double z = zenith_Y * perezF(cosTheta, gamma, cos2Gamma, A.z, B.z, C.z, D.z, E.z) * f0_Y; - if (y <= Ray.EPSILON) { + if (y <= Constants.EPSILON) { return new Vector3(0, 0, 0); } else { double f = (z / y); diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java index b6ef946f26..66d100fe26 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java @@ -21,7 +21,11 @@ import se.llbit.chunky.block.MinecraftBlock; import se.llbit.chunky.block.minecraft.Water; import se.llbit.chunky.renderer.WorkerState; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.math.Vector4; @@ -34,30 +38,30 @@ public class PreviewRayTracer implements RayTracer { * Do a quick preview ray tracing for the current ray. */ @Override public void trace(Scene scene, WorkerState state) { - Ray ray = state.ray; - if (scene.isInWater(ray)) { - ray.setCurrentMaterial(Water.INSTANCE); - } else { - ray.setCurrentMaterial(Air.INSTANCE); - } + Ray2 ray = state.ray; + IntersectionRecord intersectionRecord; + ray.setCurrentMedium(scene.getWorldMaterial(ray.o)); while (true) { - if (!nextIntersection(scene, ray)) { - if (mapIntersection(scene, ray)) { + intersectionRecord = new IntersectionRecord(); + if (!scene.intersect(ray, intersectionRecord)) { + if (mapIntersection(scene, ray, intersectionRecord)) { break; } break; - } else if (ray.getCurrentMaterial() != Air.INSTANCE && ray.color.w > 0) { + } else if (intersectionRecord.material != Air.INSTANCE && intersectionRecord.color.w > 0) { + ray.o.scaleAdd((intersectionRecord.distance), ray.d); break; } else { - ray.o.scaleAdd(Ray.OFFSET, ray.d); + ray.o.scaleAdd((intersectionRecord.distance + Constants.OFFSET), ray.d); } } - if (ray.getCurrentMaterial() == Air.INSTANCE) { - scene.sky.getApparentSkyColor(ray, true); + if (intersectionRecord.material == Air.INSTANCE) { + scene.sky.getSkyColor(ray, intersectionRecord); } else { - scene.sun.flatShading(ray); + scene.sun.flatShading(intersectionRecord); } + state.color.set(intersectionRecord.color); } /** @@ -65,79 +69,81 @@ public class PreviewRayTracer implements RayTracer { * @return occlusion value (1 = occluded, 0 = transparent) */ public static double skyOcclusion(Scene scene, WorkerState state) { - Ray ray = state.ray; + Ray2 ray = state.ray; + IntersectionRecord intersectionRecord; double occlusion = 1.0; while (true) { - if (!nextIntersection(scene, ray)) { + intersectionRecord = new IntersectionRecord(); + if (!scene.intersect(ray, intersectionRecord)) { break; } else { - occlusion *= (1 - ray.color.w); + occlusion *= (1 - intersectionRecord.color.w); if (occlusion == 0) { return 1; // occlusion can't become > 0 anymore } - ray.o.scaleAdd(Ray.OFFSET, ray.d); + ray.o.scaleAdd((intersectionRecord.distance + Constants.OFFSET), ray.d); } } return 1 - occlusion; } - /** - * Find next ray intersection. - * @return true if intersected, false if no intersection has been found - */ - public static boolean nextIntersection(Scene scene, Ray ray) { - ray.setPrevMaterial(ray.getCurrentMaterial(), ray.getCurrentData()); - ray.t = Double.POSITIVE_INFINITY; - boolean hit = false; - if (scene.sky().cloudsEnabled()) { - hit = scene.sky().cloudIntersection(scene, ray); - } - if (scene.isWaterPlaneEnabled()) { - hit = waterPlaneIntersection(scene, ray) || hit; - } - if (scene.intersect(ray)) { - // Octree tracer handles updating distance. - return true; - } - if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); - scene.updateOpacity(ray); - return true; - } else { - ray.setCurrentMaterial(Air.INSTANCE); - return false; - } - } +// /** +// * Find next ray intersection. +// * @return true if intersected, false if no intersection has been found +// */ +// public static boolean nextIntersection(Scene scene, Ray ray) { +// ray.setPrevMaterial(ray.getCurrentMaterial(), ray.getCurrentData()); +// ray.t = Double.POSITIVE_INFINITY; +// boolean hit = false; +// if (scene.sky().cloudsEnabled()) { +// hit = scene.sky().cloudIntersection(scene, ray); +// } +// if (scene.isWaterPlaneEnabled()) { +// hit = waterPlaneIntersection(scene, ray) || hit; +// } +// if (scene.intersect(ray)) { +// // Octree tracer handles updating distance. +// return true; +// } +// if (hit) { +// ray.distance += ray.t; +// ray.o.scaleAdd(ray.t, ray.d); +// scene.updateOpacity(ray); +// return true; +// } else { +// ray.setCurrentMaterial(Air.INSTANCE); +// return false; +// } +// } - private static boolean waterPlaneIntersection(Scene scene, Ray ray) { - double t = (scene.getEffectiveWaterPlaneHeight() - ray.o.y - scene.origin.y) / ray.d.y; - if (scene.getWaterPlaneChunkClip()) { - Vector3 pos = new Vector3(ray.o); - pos.scaleAdd(t, ray.d); - if (scene.isChunkLoaded((int)Math.floor(pos.x), (int)Math.floor(pos.y), (int)Math.floor(pos.z))) - return false; - } - if (ray.d.y < 0) { - if (t > 0 && t < ray.t) { - ray.t = t; - Water.INSTANCE.getColor(ray); - ray.setNormal(0, 1, 0); - ray.setCurrentMaterial(scene.getPalette().water); - return true; - } - } - if (ray.d.y > 0) { - if (t > 0 && t < ray.t) { - ray.t = t; - Water.INSTANCE.getColor(ray); - ray.setNormal(0, -1, 0); - ray.setCurrentMaterial(Air.INSTANCE); - return true; - } - } - return false; - } +// private static boolean waterPlaneIntersection(Scene scene, Ray ray) { +// double t = (scene.getEffectiveWaterPlaneHeight() - ray.o.y - scene.origin.y) / ray.d.y; +// if (scene.getWaterPlaneChunkClip()) { +// Vector3 pos = new Vector3(ray.o); +// pos.scaleAdd(t, ray.d); +// if (scene.isChunkLoaded((int)Math.floor(pos.x), (int)Math.floor(pos.y), (int)Math.floor(pos.z))) +// return false; +// } +// if (ray.d.y < 0) { +// if (t > 0 && t < ray.t) { +// ray.t = t; +// Water.INSTANCE.getColor(ray); +// ray.setNormal(0, 1, 0); +// ray.setCurrentMaterial(scene.getPalette().water); +// return true; +// } +// } +// if (ray.d.y > 0) { +// if (t > 0 && t < ray.t) { +// ray.t = t; +// Water.INSTANCE.getColor(ray); +// ray.setNormal(0, -1, 0); +// ray.setCurrentMaterial(Air.INSTANCE); +// return true; +// } +// } +// return false; +// } // Chunk pattern config private static final double chunkPatternLineWidth = 0.5; // in blocks @@ -157,17 +163,17 @@ private static boolean waterPlaneIntersection(Scene scene, Ray ray) { * Changes colors for chunks inside the octree and submerged scenes. * Use only in preview mode - the ray should hit the sky in a real render. */ - private static boolean mapIntersection(Scene scene, Ray ray) { + private static boolean mapIntersection(Scene scene, Ray2 ray, IntersectionRecord intersectionRecord) { if (ray.d.y < 0) { // ray going below horizon double t = (scene.yMin - ray.o.y - scene.origin.y) / ray.d.y; - if (t > 0 && t < ray.t) { - Vector3 vec = new Vector3(); - vec.scaleAdd(t + Ray.OFFSET, ray.d, ray.o); + if (t > 0 && t < intersectionRecord.distance) { + Point3 point = new Point3(ray.o); + point.scaleAdd(t + Constants.OFFSET, ray.d); // must be submerged if water plane is enabled otherwise ray already had collided with water boolean isSubmerged = scene.isWaterPlaneEnabled(); - boolean insideOctree = scene.isInsideOctree(vec); - ray.t = t; - ray.o.set(vec); + boolean insideOctree = scene.isInsideOctree(point); + intersectionRecord.distance = t; + ray.o.set(point); double xm = ((ray.o.x) % 16.0 + 8.0) % 16.0; double zm = ((ray.o.z) % 16.0 + 8.0) % 16.0; if ( @@ -175,23 +181,23 @@ private static boolean mapIntersection(Scene scene, Ray ray) { (zm < chunkPatternLinePosition || zm > chunkPatternLinePosition + chunkPatternLineWidth) ) { // chunk fill if (isSubmerged) { - ray.color.set(chunkPatternFillColorSubmerged); + intersectionRecord.color.set(chunkPatternFillColorSubmerged); } else { - ray.color.set(chunkPatternFillColor); + intersectionRecord.color.set(chunkPatternFillColor); } } else { // chunk border if (isSubmerged) { - ray.color.set(chunkPatternLineColorSubmerged); + intersectionRecord.color.set(chunkPatternLineColorSubmerged); } else { - ray.color.set(chunkPatternLineColor); + intersectionRecord.color.set(chunkPatternLineColor); } } if(insideOctree) { - ray.color.scale(chunkPatternInsideOctreeColorFactor); + intersectionRecord.color.scale(chunkPatternInsideOctreeColorFactor); } // handle like a solid horizontal plane - ray.setCurrentMaterial(MinecraftBlock.STONE); - ray.setNormal(0, 1, 0); + intersectionRecord.material = MinecraftBlock.STONE; + intersectionRecord.setNormal(0, 1, 0); return true; } } diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java index fb4f8adcf4..bc5fef242f 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java @@ -253,7 +253,7 @@ public class Scene implements JsonSerializable, Refreshable { /** * Octree origin. */ - protected Vector3i origin = new Vector3i(); + protected Point3i origin = new Point3i(); /** * Actual upper y bound (might be lower than yClipMax). @@ -678,7 +678,7 @@ public void rayTrace(RayTracer rayTracer, WorkerState state) { * @param ray ray to test against scene * @return true if an intersection was found */ - public boolean intersect(Ray ray) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { boolean hit = false; if (Double.isNaN(ray.d.x) || Double.isNaN(ray.d.y) || Double.isNaN(ray.d.z) || @@ -693,28 +693,61 @@ public boolean intersect(Ray ray) { ray.d.set(0, 1, 0); } - if (entities.intersect(ray)) { + if (worldIntersection(ray, intersectionRecord)) { hit = true; } - if (worldIntersection(ray)) { + if (entities.intersect(ray, intersectionRecord)) { hit = true; } if (hit) { - ray.distance += ray.t; - ray.o.scaleAdd(ray.t, ray.d); - updateOpacity(ray); + /*ray.distance += ray.t; + ray.o.scaleAdd(ray.t, ray.d);*/ + updateOpacity(ray, intersectionRecord); return true; } return false; } + private boolean worldIntersection(Ray2 ray, IntersectionRecord intersectionRecord) { + boolean hit = false; + IntersectionRecord intersectionTest = new IntersectionRecord(); + if (worldOctree.enterBlock(this, ray, intersectionTest, palette) + && intersectionTest.distance < intersectionRecord.distance - Constants.EPSILON) { + intersectionRecord.distance = intersectionTest.distance; + intersectionRecord.setNormal(intersectionTest.shadeN); + intersectionRecord.color.set(intersectionTest.color); + intersectionRecord.material = intersectionTest.material; + hit = true; + } + intersectionTest = new IntersectionRecord(); + if (ray.getCurrentMedium().isWater()) { + if (waterOctree.exitWater(this, ray, intersectionTest, palette)) { + intersectionRecord.distance = intersectionTest.distance; + intersectionRecord.setNormal(intersectionTest.shadeN); + intersectionRecord.color.set(intersectionTest.color); + intersectionRecord.material = intersectionTest.material; + hit = true; + } + } else { + if (waterOctree.enterBlock(this, ray, intersectionTest, palette) + && intersectionTest.distance < intersectionRecord.distance - Constants.EPSILON) { + intersectionRecord.distance = intersectionTest.distance; + intersectionRecord.setNormal(intersectionTest.shadeN); + intersectionRecord.color.set(intersectionTest.color); + intersectionRecord.material = intersectionTest.material; + hit = true; + } + } + return hit; + } + /** * Test whether the ray intersects any voxel before exiting the Octree. * * @param ray the ray * @return {@code true} if the ray intersects a voxel */ - private boolean worldIntersection(Ray ray) { + /*private boolean worldIntersection(Ray ray) { Ray start = new Ray(ray); start.setCurrentMaterial(ray.getPrevMaterial(), ray.getPrevData()); boolean hit = false; @@ -754,22 +787,22 @@ private boolean worldIntersection(Ray ray) { } } return hit; - } + }*/ - public void updateOpacity(Ray ray) { - if (ray.getCurrentMaterial().isWater() || (ray.getCurrentMaterial() == Air.INSTANCE - && ray.getPrevMaterial().isWater())) { + public void updateOpacity(Ray2 ray, IntersectionRecord intersectionRecord) { + if (intersectionRecord.material.isWater() || (!intersectionRecord.material.isWater() + && ray.getCurrentMedium().isWater())) { if (useCustomWaterColor) { - ray.color.x = waterColor.x; - ray.color.y = waterColor.y; - ray.color.z = waterColor.z; + intersectionRecord.color.x *= waterColor.x; + intersectionRecord.color.y *= waterColor.y; + intersectionRecord.color.z *= waterColor.z; } else { - float[] waterColor = ray.getBiomeWaterColor(this); - ray.color.x *= waterColor[0]; - ray.color.y *= waterColor[1]; - ray.color.z *= waterColor[2]; + float[] waterColor = getWaterColor((int) (ray.o.x + ray.d.x * Constants.OFFSET), (int) (ray.o.y + ray.d.y * Constants.OFFSET), (int) (ray.o.z + ray.d.z * Constants.OFFSET)); + intersectionRecord.color.x *= waterColor[0]; + intersectionRecord.color.y *= waterColor[1]; + intersectionRecord.color.z *= waterColor[2]; } - ray.color.w = waterOpacity; + intersectionRecord.color.w = waterOpacity; } } @@ -984,7 +1017,7 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec Block block = palette.get(currentBlock); if(block.isEntity()) { - Vector3 position = new Vector3(cx + cp.x * 16, y, cz + cp.z * 16); + Point3 position = new Point3(cx + cp.x * 16, y, cz + cp.z * 16); Entity entity = block.toEntity(position); if (entities.shouldLoad(entity)) { @@ -1159,7 +1192,7 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec } Block block = palette.get(chunkData.getBlockAt(x, y, z)); // Metadata is the old block data (to be replaced in future Minecraft versions?). - Vector3 position = new Vector3(x + wx0, y, z + wz0); + Point3 position = new Point3(x + wx0, y, z + wz0); if (block.isModifiedByBlockEntity()) { Tag newTag = block.getNewTagWithBlockEntity(palette.getBlockSpec(chunkData.getBlockAt(x, y, z)).getTag(), entityTag); if (newTag != null) { @@ -1336,15 +1369,11 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec int wx = cp.x * Chunk.X_MAX + x; for (int z = 0; z < 16; ++z) { int wz = cp.z * Chunk.Z_MAX + z; - int nsum = 0; Integer id = biomePaletteIdxStructure.get(wx, wy, wz); if (id == null) { continue; } - if(id != 0) { - int asd = 0; - } Biome biome = biomePalette.get(id); grassTexture.set(cp.x * 16 + x - origin.x, sectionY * 16 + y - origin.y, cp.z * 16 + z - origin.z, biome.grassColorLinear); @@ -1485,9 +1514,9 @@ public synchronized boolean haveLoadedChunks() { * * @return The calculated camera position */ - public Vector3 calcCenterCamera() { + public Point3 calcCenterCamera() { if (chunks.isEmpty()) { - return new Vector3(0, 128, 0); + return new Point3(0, 128, 0); } int xmin = Integer.MAX_VALUE; @@ -1521,10 +1550,10 @@ public Vector3 calcCenterCamera() { Material block = worldOctree.getMaterial(xcenter - origin.x, y - origin.y, zcenter - origin.z, palette); if (!(block instanceof Air)) { - return new Vector3(xcenter, y + 5, zcenter); + return new Point3(xcenter, y + 5, zcenter); } } - return new Vector3(xcenter, 128, zcenter); + return new Point3(xcenter, 128, zcenter); } /** @@ -1657,22 +1686,25 @@ synchronized public void clearResetFlags() { * * @return {@code true} if the ray hit something */ - public boolean traceTarget(Ray ray) { + public boolean traceTarget(Ray2 ray, IntersectionRecord intersectionRecord) { WorkerState state = new WorkerState(); state.ray = ray; if (isInWater(ray)) { - ray.setCurrentMaterial(Water.INSTANCE); + ray.setCurrentMedium(Water.INSTANCE); } else { - ray.setCurrentMaterial(Air.INSTANCE); + ray.setCurrentMedium(Air.INSTANCE); } camera.getTargetDirection(ray); ray.o.x -= origin.x; ray.o.y -= origin.y; ray.o.z -= origin.z; - while (PreviewRayTracer.nextIntersection(this, ray)) { - if (ray.getCurrentMaterial() != Air.INSTANCE) { + while (intersect(ray, intersectionRecord)) { + if (intersectionRecord.material != Air.INSTANCE) { return true; } + ray.o.add(ray.d.x * (intersectionRecord.distance + Constants.OFFSET), + ray.d.x * (intersectionRecord.distance + Constants.OFFSET), + ray.d.x * (intersectionRecord.distance + Constants.OFFSET)); } return false; } @@ -1689,12 +1721,13 @@ public void autoFocus() { * * @return {@code null} if the camera is not aiming at some intersectable object */ - public Vector3 getTargetPosition() { - Ray ray = new Ray(); - if (!traceTarget(ray)) { + public Point3 getTargetPosition() { + Ray2 ray = new Ray2(); + IntersectionRecord intersectionRecord = new IntersectionRecord(); + if (!traceTarget(ray, intersectionRecord)) { return null; } else { - Vector3 target = new Vector3(ray.o); + Point3 target = new Point3(ray.o); target.add(origin.x, origin.y, origin.z); return target; } @@ -1703,7 +1736,7 @@ public Vector3 getTargetPosition() { /** * @return World origin in the Octree */ - public Vector3i getOrigin() { + public Point3i getOrigin() { return origin; } @@ -2305,10 +2338,11 @@ public synchronized String sceneStatus() { return "No chunks loaded!"; } else { StringBuilder buf = new StringBuilder(); - Ray ray = new Ray(); - if (traceTarget(ray) && ray.getCurrentMaterial() instanceof Block) { - Block block = (Block) ray.getCurrentMaterial(); - buf.append(String.format("target: %.2f m\n", ray.distance)); + Ray2 ray = new Ray2(); + IntersectionRecord intersectionRecord = new IntersectionRecord(); + if (traceTarget(ray, intersectionRecord) && intersectionRecord.material instanceof Block) { + Block block = (Block) intersectionRecord.material; + buf.append(String.format("target: %.2f m\n", intersectionRecord.distance)); buf.append(block.name); String description = block.description(); if (!description.isEmpty()) { @@ -2316,7 +2350,7 @@ public synchronized String sceneStatus() { } buf.append("\n"); } - Vector3 pos = camera.getPosition(); + Point3 pos = camera.getPosition(); buf.append(String.format("pos: (%.1f, %.1f, %.1f)\n", pos.x, pos.y, pos.z)); buf.append("facing: "); @@ -2485,7 +2519,18 @@ public boolean shouldSaveSnapshots() { return saveSnapshots; } - public boolean isInWater(Ray ray) { + public Material getWorldMaterial(Point3 point) { + int x = (int) QuickMath.floor(point.x); + int y = (int) QuickMath.floor(point.y); + int z = (int) QuickMath.floor(point.z); + Material material = waterOctree.getMaterial(x, y, z, palette); + if (!material.isWater()) { + material = worldOctree.getMaterial(x, y, z, palette); + } + return material; + } + + public boolean isInWater(Ray2 ray) { if (isWaterPlaneEnabled() && ray.o.y + origin.y < getEffectiveWaterPlaneHeight()) { if (getWaterPlaneChunkClip()) { if (!isChunkLoaded((int)Math.floor(ray.o.x), (int)Math.floor(ray.o.y), (int)Math.floor(ray.o.z))) { @@ -2506,8 +2551,8 @@ public boolean isInWater(Ray ray) { return false; } - public boolean isInsideOctree(Vector3 vec) { - return worldOctree.isInside(vec); + public boolean isInsideOctree(Point3 point) { + return worldOctree.isInside(point); } public double getWaterOpacity() { diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java index 9921302b83..14fd1f6718 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java @@ -12,8 +12,13 @@ import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; import se.llbit.log.Log; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Octree; +import se.llbit.math.Point3; +import se.llbit.math.Point3i; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.math.Vector3i; import se.llbit.math.bvh.BVH; @@ -84,14 +89,14 @@ public void copyState(SceneEntities other) { bvhImplementation = other.bvhImplementation; } - public boolean intersect(Ray ray) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { boolean hit = false; - if (bvh.closestIntersection(ray)) { + if (bvh.closestIntersection(ray, intersectionRecord)) { hit = true; } if (renderActors) { - if (actorBvh.closestIntersection(ray)) { + if (actorBvh.closestIntersection(ray, intersectionRecord)) { hit = true; } } @@ -153,13 +158,13 @@ public void loadEntitiesInChunk(Scene scene, ChunkData chunkData) { Tag paintingVariant = NbtUtil.getTagFromNames(tag, "Motive", "variant"); addEntity(new PaintingEntity( - new Vector3(x, y, z), + new Point3(x, y, z), paintingVariant.stringValue(), yaw )); } else if (id.equals("minecraft:armor_stand") && entityLoadingPreferences.shouldLoadClass(ArmorStand.class)) { addActor(new ArmorStand( - new Vector3(x, y, z), + new Point3(x, y, z), tag )); } @@ -180,9 +185,8 @@ public void addActor(Entity entity) { // don't add the actor again if it was already loaded from json if(actors.stream().noneMatch(actor -> { if(actor.getClass().equals(entity.getClass())) { - Vector3 distance = new Vector3(actor.position); - distance.sub(entity.position); - return distance.lengthSquared() < Ray.EPSILON; + double distance = actor.position.vSub(entity.position).lengthSquared(); + return distance < Constants.EPSILON; } return false; })) { @@ -234,7 +238,7 @@ public void setBvhImplementation(String bvhImplementation) { public void loadDataFromOctree( Octree worldOctree, BlockPalette palette, - Vector3i origin + Point3i origin ) { for (Entity entity : actors) { entity.loadDataFromOctree(worldOctree, palette, origin); @@ -244,12 +248,12 @@ public void loadDataFromOctree( } } - public void buildBvh(TaskTracker.Task task, Vector3i origin) { + public void buildBvh(TaskTracker.Task task, Point3i origin) { Vector3 worldOffset = new Vector3(-origin.x, -origin.y, -origin.z); bvh = BVH.Factory.create(bvhImplementation, entities, worldOffset, task); } - public void buildActorBvh(TaskTracker.Task task, Vector3i origin) { + public void buildActorBvh(TaskTracker.Task task, Point3i origin) { Vector3 worldOffset = new Vector3(-origin.x, -origin.y, -origin.z); actorBvh = BVH.Factory.create(bvhImplementation, actors, worldOffset, task); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SimplexWaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SimplexWaterShader.java index 682a231900..42db6aa21e 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/SimplexWaterShader.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/SimplexWaterShader.java @@ -17,7 +17,9 @@ package se.llbit.chunky.renderer.scene; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.SimplexNoise; import se.llbit.math.Vector3; @@ -39,7 +41,7 @@ public class SimplexWaterShader implements WaterShader { @Override - public void doWaterShading(Ray ray, double animationTime) { + public void doWaterShading(Ray2 ray, IntersectionRecord intersectionRecord, double animationTime) { double frequency = baseFrequency; double amplitude = baseAmplitude; @@ -64,7 +66,7 @@ public void doWaterShading(Ray ray, double animationTime) { Vector3 normal = new Vector3(); normal.cross(zslope, xslope); normal.normalize(); - ray.setShadingNormal(normal.x, normal.y, normal.z); + intersectionRecord.shadeN.set(normal.x, normal.y, normal.z); } @Override diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Sky.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Sky.java index fce0a6abda..085755d645 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Sky.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Sky.java @@ -54,7 +54,7 @@ public class Sky implements JsonSerializable { /** * Default sky light intensity */ - public static final double DEFAULT_INTENSITY = 1; + public static final double DEFAULT_EMITTANCE = 1; /** * Default cloud y-position @@ -158,19 +158,19 @@ public static SkyMode get(String name) { private double cloudSize = DEFAULT_CLOUD_SIZE; private final Vector3 cloudOffset = new Vector3(0, DEFAULT_CLOUD_HEIGHT, 0); - private double skyExposure = DEFAULT_INTENSITY; - private double skyLightModifier = DEFAULT_INTENSITY; - private double apparentSkyLightModifier = DEFAULT_INTENSITY; + private double skyEmittance = DEFAULT_EMITTANCE; /** Color gradient used for the GRADIENT sky mode. */ private List gradient = new LinkedList<>(); /** Color used for the SOLID_COLOR sky mode. */ - private Vector3 color = new Vector3(0, 0, 0); + private final Vector3 color = new Vector3(0, 0, 0); /** Current sky rendering mode. */ private SkyMode mode = SkyMode.DEFAULT; + private boolean textureInterpolation = true; + /** Simulated skies. */ public final static List skies = new ArrayList<>(); @@ -237,9 +237,7 @@ public void set(Sky other) { roll = other.roll; rotation.set(other.rotation); mirrored = other.mirrored; - skyExposure = other.skyExposure; - skyLightModifier = other.skyLightModifier; - apparentSkyLightModifier = other.apparentSkyLightModifier; + skyEmittance = other.skyEmittance; gradient = new ArrayList<>(other.gradient); color.set(other.color); mode = other.mode; @@ -255,15 +253,16 @@ public void set(Sky other) { if (simulatedSkyMode.updateSun(scene.sun, horizonOffset)) { skyCache.precalculateSky(); } + textureInterpolation = other.textureInterpolation; } /** * Calculate sky color for the ray, based on sky mode. */ - public void getSkyDiffuseColorInner(Ray ray) { + public void getSkyColorInner(Ray2 ray, IntersectionRecord intersectionRecord) { switch (mode) { case SOLID_COLOR: { - ray.color.set(color.x, color.y, color.z, 1); + intersectionRecord.color.set(color.x, color.y, color.z, 1); break; } case GRADIENT: { @@ -283,13 +282,13 @@ public void getSkyDiffuseColorInner(Ray ray) { xx = 0.5 * (Math.sin(Math.PI * xx - Constants.HALF_PI) + 1); double a = 1 - xx; double b = xx; - ray.color.set(a * c0.x + b * c1.x, a * c0.y + b * c1.y, a * c0.z + b * c1.z, 1); + intersectionRecord.color.set(a * c0.x + b * c1.x, a * c0.y + b * c1.y, a * c0.z + b * c1.z, 1); } break; } case SIMULATED: { Vector3 color = skyCache.calcIncidentLight(ray); - ray.color.set(color.x, color.y, color.z, 1); + intersectionRecord.color.set(color.x, color.y, color.z, 1); break; } case SKYMAP_EQUIRECTANGULAR: { @@ -303,12 +302,12 @@ public void getSkyDiffuseColorInner(Ray ray) { theta = (theta % 1 + 1) % 1; } double phi = Math.abs(Math.asin(y)) / Constants.HALF_PI; - skymap.getColor(theta, phi, ray.color); + skymap.getColor(theta, phi, intersectionRecord.color); } else { double theta = FastMath.atan2(z, x) / Constants.TAU; theta = (theta % 1 + 1) % 1; double phi = (Math.asin(y) + Constants.HALF_PI) / Math.PI; - skymap.getColor(theta, phi, ray.color); + getSkymapColor(skymap, theta, phi, intersectionRecord.color); } break; } @@ -317,10 +316,10 @@ public void getSkyDiffuseColorInner(Ray ray) { double y = rotation.transformY(ray.d); double z = rotation.transformZ(ray.d); double len = Math.sqrt(x * x + y * y); - double theta = (len < Ray.EPSILON) ? 0 : Math.acos(-z) / (Constants.TAU * len); + double theta = (len < Constants.EPSILON) ? 0 : Math.acos(-z) / (Constants.TAU * len); double u = theta * x + .5; double v = .5 + theta * y; - skymap.getColor(u, v, ray.color); + getSkymapColor(skymap, u, v, intersectionRecord.color); break; } case SKYBOX: { @@ -332,167 +331,66 @@ public void getSkyDiffuseColorInner(Ray ray) { double zabs = QuickMath.abs(z); if (y > xabs && y > zabs) { double alpha = 1 / yabs; - skybox[SKYBOX_UP].getColor((1 + x * alpha) / 2.0, (1 + z * alpha) / 2.0, ray.color); + getSkymapColor(skybox[SKYBOX_UP], (1 + x * alpha) / 2.0, (1 + z * alpha) / 2.0, intersectionRecord.color); } else if (-z > xabs && -z > yabs) { double alpha = 1 / zabs; - skybox[SKYBOX_FRONT].getColor((1 + x * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); + getSkymapColor(skybox[SKYBOX_FRONT], (1 + x * alpha) / 2.0, (1 + y * alpha) / 2.0, intersectionRecord.color); } else if (z > xabs && z > yabs) { double alpha = 1 / zabs; - skybox[SKYBOX_BACK].getColor((1 - x * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); + getSkymapColor(skybox[SKYBOX_BACK], (1 - x * alpha) / 2.0, (1 + y * alpha) / 2.0, intersectionRecord.color); } else if (-x > zabs && -x > yabs) { double alpha = 1 / xabs; - skybox[SKYBOX_LEFT].getColor((1 - z * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); + getSkymapColor(skybox[SKYBOX_LEFT], (1 - z * alpha) / 2.0, (1 + y * alpha) / 2.0, intersectionRecord.color); } else if (x > zabs && x > yabs) { double alpha = 1 / xabs; - skybox[SKYBOX_RIGHT].getColor((1 + z * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); + getSkymapColor(skybox[SKYBOX_RIGHT], (1 + z * alpha) / 2.0, (1 + y * alpha) / 2.0, intersectionRecord.color); } else if (-y > xabs && -y > zabs) { double alpha = 1 / yabs; - skybox[SKYBOX_DOWN].getColor((1 + x * alpha) / 2.0, (1 - z * alpha) / 2.0, ray.color); + getSkymapColor(skybox[SKYBOX_DOWN], (1 + x * alpha) / 2.0, (1 - z * alpha) / 2.0, intersectionRecord.color); } break; } case BLACK: { - ray.color.set(0, 0, 0, 1); + intersectionRecord.color.set(0, 0, 0, 1); break; } } } - /** - * Panoramic skymap color. - */ - public void getSkyColor(Ray ray, boolean drawSun) { - getSkyDiffuseColorInner(ray); - ray.color.scale(skyExposure); - ray.color.scale(skyLightModifier); - if (drawSun) addSunColor(ray); - ray.color.w = 1; + private void getSkymapColor(Texture texture, double u, double v, Vector4 color) { + if (textureInterpolation) { + texture.getColorInterpolated(u, v, color); + } else { + texture.getColor(u, v, color); + } } - public void getApparentSkyColor(Ray ray, boolean drawSun) { - getSkyDiffuseColorInner(ray); - ray.color.scale(skyExposure); - ray.color.scale(apparentSkyLightModifier); - if (drawSun) addSunColor(ray); - ray.color.w = 1; + public Vector3 getSolidColor() { + return color; } /** - * Bilinear interpolated panoramic skymap color. + * Panoramic skymap color. */ - public void getSkyColorInterpolated(Ray ray) { - switch (mode) { - case SKYMAP_EQUIRECTANGULAR: { - double x = rotation.transformX(ray.d); - double y = rotation.transformY(ray.d); - double z = rotation.transformZ(ray.d); - if (mirrored) { - double theta = FastMath.atan2(z, x) / Constants.TAU; - theta = (theta % 1 + 1) % 1; - double phi = Math.abs(Math.asin(y)) / Constants.HALF_PI; - skymap.getColorInterpolated(theta, phi, ray.color); - } else { - double theta = FastMath.atan2(z, x) / Constants.TAU; - if (theta > 1 || theta < 0) { - theta = (theta % 1 + 1) % 1; - } - double phi = (Math.asin(y) + Constants.HALF_PI) / Math.PI; - skymap.getColorInterpolated(theta, phi, ray.color); - } - break; - } - case SKYMAP_ANGULAR: { - double x = rotation.transformX(ray.d); - double y = rotation.transformY(ray.d); - double z = rotation.transformZ(ray.d); - double len = Math.sqrt(x * x + y * y); - double theta = (len < Ray.EPSILON) ? 0 : Math.acos(-z) / (Constants.TAU * len); - double u = theta * x + .5; - double v = .5 + theta * y; - skymap.getColorInterpolated(u, v, ray.color); - break; - } - case SKYBOX: { - double x = rotation.transformX(ray.d); - double y = rotation.transformY(ray.d); - double z = rotation.transformZ(ray.d); - double xabs = QuickMath.abs(x); - double yabs = QuickMath.abs(y); - double zabs = QuickMath.abs(z); - if (y > xabs && y > zabs) { - double alpha = 1 / yabs; - skybox[SKYBOX_UP] - .getColorInterpolated((1 + x * alpha) / 2.0, (1 + z * alpha) / 2.0, ray.color); - } else if (-z > xabs && -z > yabs) { - double alpha = 1 / zabs; - skybox[SKYBOX_FRONT] - .getColorInterpolated((1 + x * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); - } else if (z > xabs && z > yabs) { - double alpha = 1 / zabs; - skybox[SKYBOX_BACK] - .getColorInterpolated((1 - x * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); - } else if (-x > zabs && -x > yabs) { - double alpha = 1 / xabs; - skybox[SKYBOX_LEFT] - .getColorInterpolated((1 - z * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); - } else if (x > zabs && x > yabs) { - double alpha = 1 / xabs; - skybox[SKYBOX_RIGHT] - .getColorInterpolated((1 + z * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); - } else if (-y > xabs && -y > zabs) { - double alpha = 1 / yabs; - skybox[SKYBOX_DOWN] - .getColorInterpolated((1 + x * alpha) / 2.0, (1 - z * alpha) / 2.0, ray.color); - } - break; - } - default: { - getSkyDiffuseColorInner(ray); - } - } - ray.color.scale(skyExposure); - ray.color.scale(apparentSkyLightModifier); - addSunColor(ray); - ray.color.w = 1; + public void getSkyColor(Ray2 ray, IntersectionRecord intersectionRecord) { + getSkyColorInner(ray, intersectionRecord); + intersectionRecord.color.scale(skyEmittance); + addSunColor(ray, intersectionRecord); + intersectionRecord.color.w = 1; } /** * Add sun color contribution. This does not alpha blend the sun color * because the Minecraft sun texture has no alpha channel. */ - private void addSunColor(Ray ray) { - double r = ray.color.x; - double g = ray.color.y; - double b = ray.color.z; - if (scene.sun().intersect(ray)) { + private void addSunColor(Ray2 ray, IntersectionRecord intersectionRecord) { + Vector4 skyColor = new Vector4(intersectionRecord.color); + if (scene.sun().intersect(ray, intersectionRecord)) { + double mult = scene.sun.getLuminosity(); // Blend sun color with current color. - ray.color.x = ray.color.x + r; - ray.color.y = ray.color.y + g; - ray.color.z = ray.color.z + b; - } - } - - public void getSkyColorDiffuseSun(Ray ray, boolean diffuseSun) { - getSkyDiffuseColorInner(ray); - ray.color.scale(skyExposure); - ray.color.scale(skyLightModifier); - if (diffuseSun) addSunColorDiffuseSun(ray); - ray.color.w = 1; - } - - public void addSunColorDiffuseSun(Ray ray) { - double r = ray.color.x; - double g = ray.color.y; - double b = ray.color.z; - - if (scene.sun().intersectDiffuse(ray)) { - double mult = scene.sun().getLuminosity(); - - // Blend sun color with current color. - ray.color.x = ray.color.x * mult + r; - ray.color.y = ray.color.y * mult + g; - ray.color.z = ray.color.z * mult + b; + intersectionRecord.color.scale(mult); + intersectionRecord.color.add(skyColor); } } @@ -627,9 +525,7 @@ public void setSkyCacheResolution(int resolution) { sky.add("skyPitch", pitch); sky.add("skyRoll", roll); sky.add("skyMirrored", mirrored); - sky.add("skyExposure", skyExposure); - sky.add("skyLight", skyLightModifier); - sky.add("apparentSkyLight", apparentSkyLightModifier); + sky.add("skyEmittance", skyEmittance); sky.add("mode", mode.name()); sky.add("horizonOffset", horizonOffset); sky.add("cloudsEnabled", cloudsEnabled); @@ -683,9 +579,7 @@ public void importFromJson(JsonObject json) { roll = json.get("skyRoll").doubleValue(roll); updateTransform(); mirrored = json.get("skyMirrored").boolValue(mirrored); - skyExposure = json.get("skyExposure").doubleValue(skyExposure); - skyLightModifier = json.get("skyLight").doubleValue(skyLightModifier); - apparentSkyLightModifier = json.get("apparentSkyLight").doubleValue(apparentSkyLightModifier); + skyEmittance = json.get("skyExposure").doubleValue(skyEmittance); if (!(json.get("mode").stringValue(mode.name()).equals("SKYMAP_PANORAMIC") || json.get("mode").stringValue(mode.name()).equals("SKYMAP_SPHERICAL"))) { mode = SkyMode.get(json.get("mode").stringValue(mode.name())); } else if (json.get("mode").stringValue(mode.name()).equals("SKYMAP_PANORAMIC")) { @@ -756,37 +650,13 @@ private void updateTransform() { rotation.rotate(-pitch, -yaw, -roll); } - public void setSkyExposure(double newValue) { - skyExposure = newValue; - scene.refresh(); - } - - /** - * Set the sky light modifier. - */ - public void setSkyLight(double newValue) { - skyLightModifier = newValue; - scene.refresh(); - } - - public void setApparentSkyLight(double newValue) { - apparentSkyLightModifier = newValue; + public void setSkyEmittance(double newValue) { + skyEmittance = newValue; scene.refresh(); } - public double getSkyExposure() { - return skyExposure; - } - - /** - * @return Current sky light modifier - */ - public double getSkyLight() { - return skyLightModifier; - } - - public double getApparentSkyLight() { - return apparentSkyLightModifier; + public double getSkyEmittance() { + return skyEmittance; } public void setGradient(List newGradient) { diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SkyCache.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SkyCache.java index 4402aebfec..a15ff65566 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/SkyCache.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/SkyCache.java @@ -26,6 +26,7 @@ import se.llbit.math.ColorUtil; import se.llbit.math.QuickMath; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; /** @@ -128,7 +129,7 @@ public void setSimulatedSkyMode(SimulatedSky skyMode) { * @param ray Ray to calculate the incident light for * @return Incident light color (RGB) */ - public Vector3 calcIncidentLight(Ray ray) { + public Vector3 calcIncidentLight(Ray2 ray) { double theta = FastMath.atan2(ray.d.z, ray.d.x); theta /= PI * 2; theta = ((theta % 1) + 1) % 1; diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/StillWaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/StillWaterShader.java index 1e3347d6ba..7b4682e3fc 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/StillWaterShader.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/StillWaterShader.java @@ -18,11 +18,13 @@ import se.llbit.chunky.model.minecraft.WaterModel; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class StillWaterShader implements WaterShader { @Override - public void doWaterShading(Ray ray, double animationTime) { + public void doWaterShading(Ray2 ray, IntersectionRecord intersectionRecord, double animationTime) { } @Override diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java index a368620aa4..db30d37104 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java @@ -24,8 +24,10 @@ import se.llbit.chunky.renderer.Refreshable; import se.llbit.chunky.resources.Texture; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; import se.llbit.math.QuickMath; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.util.JsonSerializable; @@ -151,9 +153,11 @@ public class Sun implements JsonSerializable { protected final Vector3 emittance = new Vector3(1, 1, 1); - private static final double pE = FastMath.pow(DEFAULT_INTENSITY, Scene.DEFAULT_GAMMA); - - protected static final Vector3 previewEmittance = new Vector3(pE, pE, pE); + protected static final Vector3 previewEmittance = new Vector3( + DEFAULT_INTENSITY, + DEFAULT_INTENSITY, + DEFAULT_INTENSITY + ); // final to ensure that we don't do a lot of redundant re-allocation private final Vector3 color = new Vector3(1, 1, 1); @@ -226,7 +230,7 @@ private void initSun() { su.cross(sv, sw); emittance.set(color); - emittance.scale(FastMath.pow(intensity, Scene.DEFAULT_GAMMA)); + emittance.scale(intensity); if (enableTextureModification) { apparentTextureBrightness.set(apparentColor); @@ -280,34 +284,8 @@ public double getAzimuth() { * * @return true if the ray intersects the sun model */ - public boolean intersect(Ray ray) { - if (!drawTexture || ray.d.dot(sw) < .5) { - return false; - } - - double width = radius * 4; - double width2 = width * 2; - double a; - a = Math.PI / 2 - FastMath.acos(ray.d.dot(su)) + width; - if (a >= 0 && a < width2) { - double b = Math.PI / 2 - FastMath.acos(ray.d.dot(sv)) + width; - if (b >= 0 && b < width2) { - texture.getColor(a / width2, b / width2, ray.color); - ray.color.x *= apparentTextureBrightness.x * 10; - ray.color.y *= apparentTextureBrightness.y * 10; - ray.color.z *= apparentTextureBrightness.z * 10; - return true; - } - } - - return false; - } - - /** - * Used with SSS: OFF and SSS: HIGH_QUALITY. - */ - public boolean intersectDiffuse(Ray ray) { - if (ray.d.dot(sw) < .5) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { + if (!drawTexture || ray.d.dot(sw) < radiusCos) { return false; } @@ -318,10 +296,8 @@ public boolean intersectDiffuse(Ray ray) { if (a >= 0 && a < width2) { double b = Math.PI / 2 - FastMath.acos(ray.d.dot(sv)) + width; if (b >= 0 && b < width2) { - texture.getColor(a / width2, b / width2, ray.color); - ray.color.x *= color.x * 10; - ray.color.y *= color.y * 10; - ray.color.z *= color.z * 10; + texture.getColor(a / width2, b / width2, intersectionRecord.color); + intersectionRecord.color.set(color.x, color.y, color.z, 1); return true; } } @@ -332,13 +308,13 @@ public boolean intersectDiffuse(Ray ray) { /** * Calculate flat shading for ray. */ - public void flatShading(Ray ray) { - Vector3 n = ray.getNormal(); + public void flatShading(IntersectionRecord intersectionRecord) { + Vector3 n = intersectionRecord.shadeN; double shading = n.x * sw.x + n.y * sw.y + n.z * sw.z; shading = QuickMath.max(AMBIENT, shading); - ray.color.x *= previewEmittance.x * shading; - ray.color.y *= previewEmittance.y * shading; - ray.color.z *= previewEmittance.z * shading; + intersectionRecord.color.x *= previewEmittance.x * shading; + intersectionRecord.color.y *= previewEmittance.y * shading; + intersectionRecord.color.z *= previewEmittance.z * shading; } public void setColor(Vector3 newColor) { diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/WaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/WaterShader.java index c2edbb2244..393e4fa081 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/WaterShader.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/WaterShader.java @@ -17,10 +17,12 @@ package se.llbit.chunky.renderer.scene; import se.llbit.json.JsonObject; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public interface WaterShader { - void doWaterShading(Ray ray, double animationTime); + void doWaterShading(Ray2 ray, IntersectionRecord intersectionRecord, double animationTime); WaterShader clone(); void save(JsonObject json); diff --git a/chunky/src/java/se/llbit/chunky/resources/AnimatedTexture.java b/chunky/src/java/se/llbit/chunky/resources/AnimatedTexture.java index 2c98c8d4f3..587df6b386 100644 --- a/chunky/src/java/se/llbit/chunky/resources/AnimatedTexture.java +++ b/chunky/src/java/se/llbit/chunky/resources/AnimatedTexture.java @@ -16,6 +16,7 @@ */ package se.llbit.chunky.resources; +import se.llbit.math.Constants; import se.llbit.math.Ray; /** @@ -47,8 +48,8 @@ public float[] getColor(double u, double v) { */ public float[] getColor(double u, double v, int frame) { int i = Math.floorMod(frame, numFrames); - return getColor((int) (u * width - Ray.EPSILON), - (int) ((1 - v) * frameHeight - Ray.EPSILON + i * frameHeight)); + return getColor((int) (u * width - Constants.EPSILON), + (int) ((1 - v) * frameHeight - Constants.EPSILON + i * frameHeight)); } @Override public void setTexture(BitmapImage newImage) { diff --git a/chunky/src/java/se/llbit/chunky/resources/SignTexture.java b/chunky/src/java/se/llbit/chunky/resources/SignTexture.java index 7a33e4bb18..44374d84a7 100644 --- a/chunky/src/java/se/llbit/chunky/resources/SignTexture.java +++ b/chunky/src/java/se/llbit/chunky/resources/SignTexture.java @@ -20,6 +20,7 @@ import se.llbit.chunky.resources.texturepack.FontTexture.Glyph; import se.llbit.json.JsonArray; import se.llbit.json.JsonValue; +import se.llbit.math.Constants; import se.llbit.math.Ray; import se.llbit.util.annotation.Nullable; @@ -151,8 +152,8 @@ public SignTexture(JsonArray[] text, Color dyeColor, boolean isGlowing, Texture @Override public float[] getColor(double u, double v) { if (textColor != null) { - int x = (int) (u * textColor.width - Ray.EPSILON); - int y = (int) ((1 - v) * textColor.height - Ray.EPSILON); + int x = (int) (u * textColor.width - Constants.EPSILON); + int y = (int) ((1 - v) * textColor.height - Constants.EPSILON); if (textMask != null && textMask.getPixel(x, y)) { Color characterColor = Color.get(textColor.getPixel(x, y)); return characterColor.linearColor; diff --git a/chunky/src/java/se/llbit/chunky/resources/Texture.java b/chunky/src/java/se/llbit/chunky/resources/Texture.java index 5bda12f467..d02baf9cfc 100644 --- a/chunky/src/java/se/llbit/chunky/resources/Texture.java +++ b/chunky/src/java/se/llbit/chunky/resources/Texture.java @@ -24,8 +24,11 @@ import se.llbit.chunky.resources.texturepack.TexturePath; import se.llbit.fxutil.FxImageUtil; import se.llbit.math.ColorUtil; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.QuickMath; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector4; import se.llbit.resources.ImageLoader; import se.llbit.util.annotation.NotNull; @@ -1538,10 +1541,10 @@ public void getColor(double u, double v, Vector4 c) { /** * Get linear color values. * - * @param ray ray to store color value in. + * @param intersectionRecord IntersectionRecord to store color value in. */ - public void getColor(Ray ray) { - getColor(ray.u, ray.v, ray.color); + public void getColor(IntersectionRecord intersectionRecord) { + getColor(intersectionRecord.uv.x, intersectionRecord.uv.y, intersectionRecord.color); } /** @@ -1550,7 +1553,7 @@ public void getColor(Ray ray) { * @return color */ public float[] getColor(double u, double v) { - return getColor((int) (u * width - Ray.EPSILON), (int) ((1 - v) * height - Ray.EPSILON)); + return getColor((int) (u * width - Constants.EPSILON), (int) ((1 - v) * height - Constants.EPSILON)); } /** diff --git a/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java b/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java index fe3f537e04..96948180b6 100644 --- a/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java +++ b/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java @@ -652,9 +652,9 @@ public void selectVisibleChunks(ChunkView cv, se.llbit.chunky.renderer.scene.Sce double halfWidth = width / (2.0 * height); - Vector3 o = new Vector3(camera.getPosition()); + Point3 o = new Point3(camera.getPosition()); - Ray ray = new Ray(); + Ray2 ray = new Ray2(); Vector3[] corners = new Vector3[4]; camera.calcViewRay(ray, -halfWidth, -0.5); @@ -685,7 +685,7 @@ public void selectVisibleChunks(ChunkView cv, se.llbit.chunky.renderer.scene.Sce for (int z = cv.pz0; z <= cv.pz1; ++z) { // Chunk top center position: Vector3 pos = new Vector3((x + 0.5) * 16, 63, (z + 0.5) * 16); - pos.sub(o); + pos.sub(o.asVector()); if (norm[0].dot(pos) > CHUNK_SELECT_RADIUS && norm[1].dot(pos) > CHUNK_SELECT_RADIUS && norm[2].dot(pos) > CHUNK_SELECT_RADIUS && norm[3].dot(pos) > CHUNK_SELECT_RADIUS) { chunkSelection.selectChunk(currentDimension, x, z); @@ -705,7 +705,7 @@ public static void drawViewBounds(GraphicsContext gc, ChunkView cv, double halfWidth = width / (2.0 * height); - Ray ray = new Ray(); + Ray2 ray = new Ray2(); Vector3[] direction = new Vector3[4]; Vector2[] bounds = new Vector2[4]; @@ -779,7 +779,7 @@ public static void drawViewBounds(GraphicsContext gc, ChunkView cv, // Draw the camera facing direction indicator. camera.calcViewRay(ray, 0, 0); - Vector3 o = new Vector3(ray.o); + Point3 o = new Point3(ray.o); o.x /= 16; o.z /= 16; o.scaleAdd(1, ray.d); @@ -796,7 +796,7 @@ public static void drawViewBounds(GraphicsContext gc, ChunkView cv, * *

The result is given in chunk coordinates. */ - private static Vector2 findMapPos(Ray ray, ChunkView cv) { + private static Vector2 findMapPos(Ray2 ray, ChunkView cv) { if (ray.d.y < 0 && ray.o.y > 63 || ray.d.y > 0 && ray.o.y < 63) { // Ray intersects ground. double d = (63 - ray.o.y) / ray.d.y; diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java b/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java index 183795726f..2b66111853 100644 --- a/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java +++ b/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java @@ -84,6 +84,7 @@ import se.llbit.fxutil.GroupedChangeListener; import se.llbit.log.Level; import se.llbit.log.Log; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.util.ProgressListener; import se.llbit.util.TaskTracker; @@ -456,13 +457,13 @@ public File getSceneFile(String fileName) { chunkSelection.clearSelection(); } world.currentDimension().addChunkDeletionListener(chunkSelection); - Optional playerPos = world.currentDimension().getPlayerPos(); + Optional playerPos = world.currentDimension().getPlayerPos(); world.currentDimension().addChunkUpdateListener(map); Platform.runLater( () -> { if (!reloaded || trackPlayer.getValue()) { - mapView.panTo(playerPos.orElse(new Vector3(0, 0, 0))); + mapView.panTo(playerPos.orElse(new Point3(0, 0, 0))); } if (!reloaded) { ignoreYUpdate.set(true); @@ -856,7 +857,7 @@ public void panToCamera() { public void moveCameraTo(double x, double z) { chunky.getRenderController().getSceneProvider().withEditSceneProtected(scene -> { Camera camera = scene.camera(); - Vector3 pos = new Vector3(x, camera.getPosition().y, z); + Point3 pos = new Point3(x, camera.getPosition().y, z); camera.setPosition(pos); }); } diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/Poser.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/Poser.java index 9e7f7a9e8a..fb3cfc4a6a 100644 --- a/chunky/src/java/se/llbit/chunky/ui/dialogs/Poser.java +++ b/chunky/src/java/se/llbit/chunky/ui/dialogs/Poser.java @@ -53,180 +53,180 @@ /** * A tool for posing entities. */ -public class Poser extends Stage implements Initializable { - private static final WritablePixelFormat PIXEL_FORMAT = - PixelFormat.getIntArgbInstance(); - private final EntitiesTab.EntityData player; - private BVH bvh = BVH.EMPTY; - private int[] pixels; - private int width = 300; - private int height = 300; - private Matrix3 transform = new Matrix3(); - private Vector3 camPos = new Vector3(); - private WritableImage image; - - @FXML private Canvas preview; - @FXML private ChoiceBox playerModel; - @FXML private TextField skin; - @FXML private Button selectSkin; - @FXML private DoubleAdjuster direction; - @FXML private DoubleAdjuster headYaw; - @FXML private DoubleAdjuster headPitch; - @FXML private DoubleAdjuster leftArmPose; - @FXML private DoubleAdjuster rightArmPose; - @FXML private DoubleAdjuster leftLegPose; - @FXML private DoubleAdjuster rightLegPose; - private double lastX; - private double lastY; - - public Poser(EntitiesTab.EntityData data) throws IOException { - this.player = data; - FXMLLoader loader = new FXMLLoader(getClass().getResource("Poser.fxml")); - loader.setController(this); - Parent root = loader.load(); - setScene(new javafx.scene.Scene(root)); - setTitle("Pose Preview"); - } - - @Override public void initialize(URL location, ResourceBundle resources) { - selectSkin.setOnAction(e -> { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("Load Skin"); - fileChooser - .getExtensionFilters().add(new FileChooser.ExtensionFilter("Minecraft skin", "*.png")); - File skinFile = fileChooser.showOpenDialog(getScene().getWindow()); - if (skinFile != null) { - // TODO - //player.entity.setTexture(skinFile.getAbsolutePath()); - skin.setText(skinFile.getAbsolutePath()); - redraw(); - } - }); - preview.setOnMousePressed(e -> { - lastX = e.getX(); - lastY = e.getY(); - }); - preview.setOnMouseDragged(e -> { - double dx = e.getX() - lastX; - double dy = e.getY() - lastY; - lastX = e.getX(); - lastY = e.getY(); - direction.setAndUpdate(direction.get() + dx / 20); - headPitch.setAndUpdate(headPitch.get() - dy / 60); - }); - // TODO - // skin.setText(player.entity.skin); - pixels = new int[width * height]; - transform.setIdentity(); - image = new WritableImage(width, height); - playerModel.getItems().addAll(PlayerModel.values()); - // TODO - //playerModel.getSelectionModel().select(player.entity.model); - playerModel.getSelectionModel().selectedItemProperty() - .addListener((observable, oldValue, newValue) -> { - // TODO - //player.entity.model = newValue; - redraw(); - }); - direction.setName("Direction"); - direction.setRange(-Math.PI, Math.PI); - direction.onValueChange(value -> { - // TODO - //player.entity.pose.set("rotation", Json.of(value)); - redraw(); - }); - headYaw.setName("Head yaw"); - headYaw.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); - headYaw.onValueChange(value -> { - // TODO - //player.entity.headYaw = value; - redraw(); - }); - headPitch.setName("Head pitch"); - headPitch.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); - headPitch.onValueChange(value -> { - // TODO - //player.entity.pitch = value; - redraw(); - }); - leftArmPose.setName("Left arm pose"); - leftArmPose.setRange(-Math.PI, Math.PI); - leftArmPose.onValueChange(value -> { - // TODO - //player.entity.leftArmPose = value; - redraw(); - }); - rightArmPose.setName("Right arm pose"); - rightArmPose.setRange(-Math.PI, Math.PI); - rightArmPose.onValueChange(value -> { - // TODO - //player.entity.rightArmPose = value; - redraw(); - }); - leftLegPose.setName("Left leg pose"); - leftLegPose.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); - leftLegPose.onValueChange(value -> { - // TODO - //player.entity.leftLegPose = value; - redraw(); - }); - rightLegPose.setName("Right leg pose"); - rightLegPose.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); - rightLegPose.onValueChange(value -> { - // TODO - //player.entity.rightLegPose = value; - redraw(); - }); - redraw(); - } - - private void buildBvh() { - Vector3 offset = new Vector3(); // Offset to place player in focus. - // TODO - //offset.sub(player.entity.position); - //bvh = new BVH(new LinkedList<>(player.entity.primitives(offset))); - } - - private void redraw() { - buildBvh(); - GraphicsContext gc = preview.getGraphicsContext2D(); - Ray ray = new Ray(); - double aspect = width / (double) height; - double fovTan = Camera.clampedFovTan(70); - camPos.set(0, 1, -2); - for (int y = 0; y < height; ++y) { - double rayy = fovTan * (.5 - ((double) y) / height); - for (int x = 0; x < width; ++x) { - double rayx = fovTan * aspect * (.5 - ((double) x) / width); - ray.setDefault(); - ray.t = Double.MAX_VALUE; - ray.d.set(rayx, rayy, 1); - ray.d.normalize(); - - ray.o.set(camPos); - while (true) { - if (bvh.closestIntersection(ray)) { - if (ray.color.w > 0.9) { - break; - } - ray.o.scaleAdd(ray.t, ray.d); - } else { - if (x % 20 == 0 || y % 20 == 0) { - ray.color.set(0.7, 0.7, 0.7, 1); - } else { - ray.color.set(1, 1, 1, 1); - } - break; - } - } - - ray.color.x = QuickMath.min(1, FastMath.sqrt(ray.color.x)); - ray.color.y = QuickMath.min(1, FastMath.sqrt(ray.color.y)); - ray.color.z = QuickMath.min(1, FastMath.sqrt(ray.color.z)); - pixels[y * width + x] = ColorUtil.getRGB(ray.color); - } - } - image.getPixelWriter().setPixels(0, 0, width, height, PIXEL_FORMAT, pixels, 0, width); - gc.drawImage(image, 0, 0); - } +public class Poser{ // extends Stage implements Initializable { +// private static final WritablePixelFormat PIXEL_FORMAT = +// PixelFormat.getIntArgbInstance(); +// private final EntitiesTab.EntityData player; +// private BVH bvh = BVH.EMPTY; +// private int[] pixels; +// private int width = 300; +// private int height = 300; +// private Matrix3 transform = new Matrix3(); +// private Vector3 camPos = new Vector3(); +// private WritableImage image; +// +// @FXML private Canvas preview; +// @FXML private ChoiceBox playerModel; +// @FXML private TextField skin; +// @FXML private Button selectSkin; +// @FXML private DoubleAdjuster direction; +// @FXML private DoubleAdjuster headYaw; +// @FXML private DoubleAdjuster headPitch; +// @FXML private DoubleAdjuster leftArmPose; +// @FXML private DoubleAdjuster rightArmPose; +// @FXML private DoubleAdjuster leftLegPose; +// @FXML private DoubleAdjuster rightLegPose; +// private double lastX; +// private double lastY; +// +// public Poser(EntitiesTab.EntityData data) throws IOException { +// this.player = data; +// FXMLLoader loader = new FXMLLoader(getClass().getResource("Poser.fxml")); +// loader.setController(this); +// Parent root = loader.load(); +// setScene(new javafx.scene.Scene(root)); +// setTitle("Pose Preview"); +// } +// +// @Override public void initialize(URL location, ResourceBundle resources) { +// selectSkin.setOnAction(e -> { +// FileChooser fileChooser = new FileChooser(); +// fileChooser.setTitle("Load Skin"); +// fileChooser +// .getExtensionFilters().add(new FileChooser.ExtensionFilter("Minecraft skin", "*.png")); +// File skinFile = fileChooser.showOpenDialog(getScene().getWindow()); +// if (skinFile != null) { +// // TODO +// //player.entity.setTexture(skinFile.getAbsolutePath()); +// skin.setText(skinFile.getAbsolutePath()); +// redraw(); +// } +// }); +// preview.setOnMousePressed(e -> { +// lastX = e.getX(); +// lastY = e.getY(); +// }); +// preview.setOnMouseDragged(e -> { +// double dx = e.getX() - lastX; +// double dy = e.getY() - lastY; +// lastX = e.getX(); +// lastY = e.getY(); +// direction.setAndUpdate(direction.get() + dx / 20); +// headPitch.setAndUpdate(headPitch.get() - dy / 60); +// }); +// // TODO +// // skin.setText(player.entity.skin); +// pixels = new int[width * height]; +// transform.setIdentity(); +// image = new WritableImage(width, height); +// playerModel.getItems().addAll(PlayerModel.values()); +// // TODO +// //playerModel.getSelectionModel().select(player.entity.model); +// playerModel.getSelectionModel().selectedItemProperty() +// .addListener((observable, oldValue, newValue) -> { +// // TODO +// //player.entity.model = newValue; +// redraw(); +// }); +// direction.setName("Direction"); +// direction.setRange(-Math.PI, Math.PI); +// direction.onValueChange(value -> { +// // TODO +// //player.entity.pose.set("rotation", Json.of(value)); +// redraw(); +// }); +// headYaw.setName("Head yaw"); +// headYaw.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); +// headYaw.onValueChange(value -> { +// // TODO +// //player.entity.headYaw = value; +// redraw(); +// }); +// headPitch.setName("Head pitch"); +// headPitch.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); +// headPitch.onValueChange(value -> { +// // TODO +// //player.entity.pitch = value; +// redraw(); +// }); +// leftArmPose.setName("Left arm pose"); +// leftArmPose.setRange(-Math.PI, Math.PI); +// leftArmPose.onValueChange(value -> { +// // TODO +// //player.entity.leftArmPose = value; +// redraw(); +// }); +// rightArmPose.setName("Right arm pose"); +// rightArmPose.setRange(-Math.PI, Math.PI); +// rightArmPose.onValueChange(value -> { +// // TODO +// //player.entity.rightArmPose = value; +// redraw(); +// }); +// leftLegPose.setName("Left leg pose"); +// leftLegPose.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); +// leftLegPose.onValueChange(value -> { +// // TODO +// //player.entity.leftLegPose = value; +// redraw(); +// }); +// rightLegPose.setName("Right leg pose"); +// rightLegPose.setRange(-QuickMath.HALF_PI, QuickMath.HALF_PI); +// rightLegPose.onValueChange(value -> { +// // TODO +// //player.entity.rightLegPose = value; +// redraw(); +// }); +// redraw(); +// } +// +// private void buildBvh() { +// Vector3 offset = new Vector3(); // Offset to place player in focus. +// // TODO +// //offset.sub(player.entity.position); +// //bvh = new BVH(new LinkedList<>(player.entity.primitives(offset))); +// } +// +// private void redraw() { +// buildBvh(); +// GraphicsContext gc = preview.getGraphicsContext2D(); +// Ray ray = new Ray(); +// double aspect = width / (double) height; +// double fovTan = Camera.clampedFovTan(70); +// camPos.set(0, 1, -2); +// for (int y = 0; y < height; ++y) { +// double rayy = fovTan * (.5 - ((double) y) / height); +// for (int x = 0; x < width; ++x) { +// double rayx = fovTan * aspect * (.5 - ((double) x) / width); +// ray.setDefault(); +// ray.t = Double.MAX_VALUE; +// ray.d.set(rayx, rayy, 1); +// ray.d.normalize(); +// +// ray.o.set(camPos); +// while (true) { +// if (bvh.closestIntersection(ray)) { +// if (ray.color.w > 0.9) { +// break; +// } +// ray.o.scaleAdd(ray.t, ray.d); +// } else { +// if (x % 20 == 0 || y % 20 == 0) { +// ray.color.set(0.7, 0.7, 0.7, 1); +// } else { +// ray.color.set(1, 1, 1, 1); +// } +// break; +// } +// } +// +// ray.color.x = QuickMath.min(1, FastMath.sqrt(ray.color.x)); +// ray.color.y = QuickMath.min(1, FastMath.sqrt(ray.color.y)); +// ray.color.z = QuickMath.min(1, FastMath.sqrt(ray.color.z)); +// pixels[y * width + x] = ColorUtil.getRGB(ray.color); +// } +// } +// image.getPixelWriter().setPixels(0, 0, width, height, PIXEL_FORMAT, pixels, 0, width); +// gc.drawImage(image, 0, 0); +// } } diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java index 7086d60655..2a4df1670a 100644 --- a/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java +++ b/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java @@ -42,6 +42,7 @@ import se.llbit.chunky.ui.render.RenderControlsTab; import se.llbit.json.JsonMember; import se.llbit.json.JsonObject; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -236,7 +237,7 @@ private void updateCameraLocked() { EventHandler positionHandler = e -> { if (e.getCode() == KeyCode.ENTER) { scene.camera() - .setPosition(new Vector3( + .setPosition(new Point3( posX.valueProperty().get(), posY.valueProperty().get(), posZ.valueProperty().get())); @@ -378,7 +379,7 @@ private void updateCameraList() { private void updateCameraPosition() { Camera camera = scene.camera(); - Vector3 pos = camera.getPosition(); + Point3 pos = camera.getPosition(); if (positionOrientation.isExpanded()) { posX.valueProperty().set(pos.x); posY.valueProperty().set(pos.y); diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java index 410e3f2422..9983d219b2 100644 --- a/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java +++ b/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java @@ -60,6 +60,7 @@ import se.llbit.json.JsonObject; import se.llbit.log.Log; import se.llbit.math.ColorUtil; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.util.mojangapi.MinecraftProfile; @@ -96,7 +97,7 @@ public class EntitiesTab extends ScrollPane implements RenderControlsTab, Initia private Scene scene; public interface EntityType { - T createInstance(Vector3 position, Scene scene); + T createInstance(Point3 position, Scene scene); } public static class EntityData { @@ -458,22 +459,22 @@ else if(entity instanceof BeaconBeam) { updatePositionFields(entity); posX.valueProperty().addListener((observable, oldValue, newValue) -> { withEntity(e -> { - Vector3 currentPosition = e.getPosition(); - e.setPosition(new Vector3(newValue.doubleValue(), currentPosition.y, currentPosition.z)); + Point3 currentPosition = e.getPosition(); + e.setPosition(new Point3(newValue.doubleValue(), currentPosition.y, currentPosition.z)); }); scene.rebuildActorBvh(); }); posY.valueProperty().addListener((observable, oldValue, newValue) -> { withEntity(e -> { - Vector3 currentPosition = e.getPosition(); - e.setPosition(new Vector3(currentPosition.x, newValue.doubleValue(), currentPosition.z)); + Point3 currentPosition = e.getPosition(); + e.setPosition(new Point3(currentPosition.x, newValue.doubleValue(), currentPosition.z)); }); scene.rebuildActorBvh(); }); posZ.valueProperty().addListener((observable, oldValue, newValue) -> { withEntity(e -> { - Vector3 currentPosition = e.getPosition(); - e.setPosition(new Vector3(currentPosition.x, currentPosition.y, newValue.doubleValue())); + Point3 currentPosition = e.getPosition(); + e.setPosition(new Point3(currentPosition.x, currentPosition.y, newValue.doubleValue())); }); scene.rebuildActorBvh(); }); @@ -599,9 +600,9 @@ public void initialize(URL location, ResourceBundle resources) { entityType.setValue("Player"); add.setTooltip(new Tooltip("Add an entity at the target position.")); add.setOnAction(e -> { - Vector3 position = scene.getTargetPosition(); + Point3 position = scene.getTargetPosition(); if (position == null) { - position = new Vector3(scene.camera().getPosition()); + position = new Point3(scene.camera().getPosition()); } Entity entity = entityTypes.get(entityType.getValue()).createInstance(position, scene); @@ -652,7 +653,7 @@ public void initialize(URL location, ResourceBundle resources) { })); entityToTarget.setTooltip(new Tooltip("Move the selected entity to the current target.")); entityToTarget.setOnAction(e -> withEntity(player -> { - Vector3 target = scene.getTargetPosition(); + Point3 target = scene.getTargetPosition(); if (target != null) { player.position.set(target); updatePositionFields(player); @@ -669,7 +670,7 @@ public void initialize(URL location, ResourceBundle resources) { })); faceTarget.setTooltip(new Tooltip("Makes the selected player look at the current view target.")); faceTarget.setOnAction(e -> withEntity(entity -> { - Vector3 target = scene.getTargetPosition(); + Point3 target = scene.getTargetPosition(); if (target != null && entity instanceof Poseable) { Poseable player = (Poseable) entity; player.lookAt(target); diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/LightingTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/LightingTab.java index bedf302107..7cc054fb90 100644 --- a/chunky/src/java/se/llbit/chunky/ui/render/tabs/LightingTab.java +++ b/chunky/src/java/se/llbit/chunky/ui/render/tabs/LightingTab.java @@ -48,9 +48,7 @@ public class LightingTab extends ScrollPane implements RenderControlsTab, Initia private RenderControlsFxController controller; private Scene scene; - @FXML private DoubleAdjuster skyExposure; - @FXML private DoubleAdjuster skyIntensity; - @FXML private DoubleAdjuster apparentSkyBrightness; + @FXML private DoubleAdjuster skyEmittance; @FXML private DoubleAdjuster emitterIntensity; @FXML private DoubleAdjuster sunIntensity; @FXML private CheckBox drawSun; @@ -78,26 +76,12 @@ public LightingTab() throws IOException { } @Override public void initialize(URL location, ResourceBundle resources) { - skyExposure.setName("Sky exposure"); - skyExposure.setTooltip("Changes the exposure of the sky."); - skyExposure.setRange(Sky.MIN_INTENSITY, Sky.MAX_INTENSITY); - skyExposure.makeLogarithmic(); - skyExposure.clampMin(); - skyExposure.onValueChange(value -> scene.sky().setSkyExposure(value)); - - skyIntensity.setName("Sky light intensity modifier"); - skyIntensity.setTooltip("Modifies the intensity of the light emitted by the sky."); - skyIntensity.setRange(Sky.MIN_INTENSITY, Sky.MAX_INTENSITY); - skyIntensity.makeLogarithmic(); - skyIntensity.clampMin(); - skyIntensity.onValueChange(value -> scene.sky().setSkyLight(value)); - - apparentSkyBrightness.setName("Apparent sky brightness modifier"); - apparentSkyBrightness.setTooltip("Modifies the apparent brightness of the sky."); - apparentSkyBrightness.setRange(Sky.MIN_APPARENT_INTENSITY, Sky.MAX_APPARENT_INTENSITY); - apparentSkyBrightness.makeLogarithmic(); - apparentSkyBrightness.clampMin(); - apparentSkyBrightness.onValueChange(value -> scene.sky().setApparentSkyLight(value)); + skyEmittance.setName("Sky exposure"); + skyEmittance.setTooltip("Changes the exposure of the sky."); + skyEmittance.setRange(Sky.MIN_INTENSITY, Sky.MAX_INTENSITY); + skyEmittance.makeLogarithmic(); + skyEmittance.clampMin(); + skyEmittance.onValueChange(value -> scene.sky().setSkyEmittance(value)); enableEmitters.setTooltip(new Tooltip("Allow blocks to emit light based on their material settings.")); enableEmitters.selectedProperty().addListener( @@ -190,9 +174,7 @@ public void setController(RenderControlsFxController controller) { } @Override public void update(Scene scene) { - skyExposure.set(scene.sky().getSkyExposure()); - skyIntensity.set(scene.sky().getSkyLight()); - apparentSkyBrightness.set(scene.sky().getApparentSkyLight()); + skyEmittance.set(scene.sky().getSkyEmittance()); emitterIntensity.set(scene.getEmitterIntensity()); sunIntensity.set(scene.sun().getIntensity()); sunLuminosity.set(scene.sun().getLuminosity()); diff --git a/chunky/src/java/se/llbit/chunky/world/Dimension.java b/chunky/src/java/se/llbit/chunky/world/Dimension.java index 6bb5bb7fba..9ce37459aa 100644 --- a/chunky/src/java/se/llbit/chunky/world/Dimension.java +++ b/chunky/src/java/se/llbit/chunky/world/Dimension.java @@ -13,6 +13,7 @@ import se.llbit.chunky.world.listeners.ChunkTopographyListener; import se.llbit.chunky.world.listeners.ChunkUpdateListener; import se.llbit.chunky.world.region.*; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.math.Vector3i; import se.llbit.util.annotation.Nullable; @@ -186,10 +187,10 @@ public synchronized File getRegionDirectory() { * *

The result is empty if this is not a single player world. */ - public synchronized Optional getPlayerPos() { + public synchronized Optional getPlayerPos() { if (!playerEntities.isEmpty()) { PlayerEntityData pos = playerEntities.iterator().next(); - return Optional.of(new Vector3(pos.x, pos.y, pos.z)); + return Optional.of(new Point3(pos.x, pos.y, pos.z)); } else { return Optional.empty(); } diff --git a/chunky/src/java/se/llbit/chunky/world/Material.java b/chunky/src/java/se/llbit/chunky/world/Material.java index 572af56774..f4725485dd 100644 --- a/chunky/src/java/se/llbit/chunky/world/Material.java +++ b/chunky/src/java/se/llbit/chunky/world/Material.java @@ -16,11 +16,19 @@ */ package se.llbit.chunky.world; +import org.apache.commons.math3.util.FastMath; import se.llbit.chunky.resources.Texture; import se.llbit.json.JsonObject; import se.llbit.json.JsonString; import se.llbit.json.JsonValue; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; +import se.llbit.math.QuickMath; import se.llbit.math.Ray; +import se.llbit.math.Ray2; +import se.llbit.math.Vector3; + +import java.util.Random; public abstract class Material { @@ -107,8 +115,8 @@ public void restoreDefaults() { subSurfaceScattering = false; } - public void getColor(Ray ray) { - texture.getColor(ray); + public void getColor(IntersectionRecord intersectionRecord) { + texture.getColor(intersectionRecord); } public float[] getColor(double u, double v) { @@ -146,4 +154,102 @@ public double getPerceptualSmoothness() { public void setPerceptualSmoothness(double perceptualSmoothness) { roughness = (float) Math.pow(1 - perceptualSmoothness, 2); } + + public boolean setOutboundDir(Ray2 ray, IntersectionRecord intersectionRecord, Random random) { + Material currentMat = intersectionRecord.material; + Material prevMat = ray.getCurrentMedium(); + + double pDiffuse = intersectionRecord.color.w; + + float pSpecular = currentMat.specular; + float pMetal = currentMat.metalness; + float roughness = currentMat.roughness; + float n1 = prevMat.ior; + float n2 = currentMat.ior; + + if (pDiffuse + pSpecular < Constants.EPSILON && n1 != n2) { + ray.o.add(ray.d.x * Constants.OFFSET, ray.d.y * Constants.OFFSET, ray.d.z * Constants.OFFSET); + return true; + } + + if (pMetal > Constants.EPSILON && random.nextFloat() < pMetal) { + ray.d.set(specularReflection(ray, intersectionRecord, random)); + } else if (pSpecular > Constants.EPSILON && random.nextFloat() < pSpecular) { + ray.d.set(specularReflection(ray, intersectionRecord, random)); + intersectionRecord.color.set(1, 1, 1, 1); + } else { + ray.d.set(diffuseReflection(intersectionRecord, random)); + } + return false; + } + + private Vector3 randomHemisphereDir(Vector3 normal, Random random) { + double x1 = random.nextDouble(); + double x2 = random.nextDouble(); + double r = FastMath.sqrt(x1); + double theta = 2 * FastMath.PI * x2; + + double tx = r * FastMath.cos(theta); + double ty = r * FastMath.sin(theta); + double tz = FastMath.sqrt(1 - x1); + + // Transform from tangent space to world space + double xx, xy, xz; + double ux, uy, uz; + double vx, vy, vz; + + if (QuickMath.abs(normal.x) > 0.1) { + xx = 0; + xy = 1; + } else { + xx = 1; + xy = 0; + } + xz = 0; + + ux = xy * normal.z - xz * normal.y; + uy = xz * normal.x - xx * normal.z; + uz = xx * normal.y - xy * normal.x; + + r = 1 / FastMath.sqrt(ux*ux + uy*uy + uz*uz); + + ux *= r; + uy *= r; + uz *= r; + + vx = uy * normal.z - uz * normal.y; + vy = uz * normal.x - ux * normal.z; + vz = ux * normal.y - uy * normal.x; + + return new Vector3( + ux * tx + vx * ty + normal.x * tz, + uy * tx + vy * ty + normal.y * tz, + uz * tx + vz * ty + normal.z * tz + ); + } + + private Vector3 diffuseReflection(IntersectionRecord intersectionRecord, Random random) { + return randomHemisphereDir(intersectionRecord.shadeN, random); + } + + private Vector3 specularReflection(Ray2 ray, IntersectionRecord intersectionRecord, Random random) { + Vector3 direction = new Vector3(ray.d); + Vector3 normal = new Vector3(intersectionRecord.shadeN); + normal.scale(-2 * direction.dot(normal)); + direction.add(normal); + + if (intersectionRecord.material.roughness > Constants.EPSILON) { + Vector3 randomHemisphereDir = randomHemisphereDir(intersectionRecord.shadeN, random); + randomHemisphereDir.scale(intersectionRecord.material.roughness); + direction.scale(1 - intersectionRecord.material.roughness); + direction.add(randomHemisphereDir); + } + + if (QuickMath.signum(intersectionRecord.n.dot(direction)) == QuickMath.signum(intersectionRecord.n.dot(ray.d))) { + double factor = QuickMath.signum(intersectionRecord.n.dot(ray.d)) * -Constants.EPSILON - ray.d.dot(direction); + direction.scaleAdd(factor, intersectionRecord.n); + } + direction.normalize(); + return direction; + } } diff --git a/chunky/src/java/se/llbit/chunky/world/SkymapTexture.java b/chunky/src/java/se/llbit/chunky/world/SkymapTexture.java index 4b2500a901..d8b3f1f6aa 100644 --- a/chunky/src/java/se/llbit/chunky/world/SkymapTexture.java +++ b/chunky/src/java/se/llbit/chunky/world/SkymapTexture.java @@ -22,6 +22,8 @@ import se.llbit.chunky.resources.Texture; import se.llbit.log.Log; import se.llbit.math.ColorUtil; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.QuickMath; import se.llbit.math.Ray; import se.llbit.math.Vector4; @@ -128,8 +130,8 @@ public SkymapTexture(BitmapImage image) { } @Override public void getColor(double u, double v, Vector4 c) { - ColorUtil.getRGBComponents(image.getPixel((int) (u * width - Ray.EPSILON), - (int) ((1 - v) * height - Ray.EPSILON)), c); + ColorUtil.getRGBComponents(image.getPixel((int) (u * width - Constants.EPSILON), + (int) ((1 - v) * height - Constants.EPSILON)), c); } /** @@ -139,7 +141,7 @@ public void getColor(int x, int y, Vector4 c) { ColorUtil.getRGBComponents(image.getPixel(x, y), c); } - @Override public void getColor(Ray ray) { + @Override public void getColor(IntersectionRecord intersectionRecord) { throw new UnsupportedOperationException(); } diff --git a/chunky/src/java/se/llbit/chunky/world/material/BeaconBeamMaterial.java b/chunky/src/java/se/llbit/chunky/world/material/BeaconBeamMaterial.java index cb74f4b3dd..bac637df0a 100644 --- a/chunky/src/java/se/llbit/chunky/world/material/BeaconBeamMaterial.java +++ b/chunky/src/java/se/llbit/chunky/world/material/BeaconBeamMaterial.java @@ -4,7 +4,10 @@ import se.llbit.chunky.world.Material; import se.llbit.json.JsonObject; import se.llbit.math.ColorUtil; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; +import se.llbit.math.Ray2; public class BeaconBeamMaterial extends Material { @@ -29,19 +32,19 @@ public int getColorInt() { } @Override - public void getColor(Ray ray) { - super.getColor(ray); - if (ray.color.w > Ray.EPSILON) { - ray.color.x *= beamColor[0]; - ray.color.y *= beamColor[1]; - ray.color.z *= beamColor[2]; + public void getColor(IntersectionRecord intersectionRecord) { + super.getColor(intersectionRecord); + if (intersectionRecord.color.w > Constants.EPSILON) { + intersectionRecord.color.x *= beamColor[0]; + intersectionRecord.color.y *= beamColor[1]; + intersectionRecord.color.z *= beamColor[2]; } } @Override public float[] getColor(double u, double v) { float[] color = super.getColor(u, v); - if (color[3] > Ray.EPSILON) { + if (color[3] > Constants.EPSILON) { color = color.clone(); color[0] *= beamColor[0]; color[1] *= beamColor[1]; diff --git a/chunky/src/java/se/llbit/chunky/world/material/LilyPadMaterial.java b/chunky/src/java/se/llbit/chunky/world/material/LilyPadMaterial.java index 10b4a28c03..e3fccd438f 100644 --- a/chunky/src/java/se/llbit/chunky/world/material/LilyPadMaterial.java +++ b/chunky/src/java/se/llbit/chunky/world/material/LilyPadMaterial.java @@ -19,6 +19,8 @@ import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; import se.llbit.math.ColorUtil; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; public class LilyPadMaterial extends Material { @@ -36,19 +38,19 @@ public LilyPadMaterial() { } @Override - public void getColor(Ray ray) { - super.getColor(ray); - if (ray.color.w > Ray.EPSILON) { - ray.color.x *= lilyPadColor[0]; - ray.color.y *= lilyPadColor[1]; - ray.color.z *= lilyPadColor[2]; + public void getColor(IntersectionRecord intersectionRecord) { + super.getColor(intersectionRecord); + if (intersectionRecord.color.w > Constants.EPSILON) { + intersectionRecord.color.x *= lilyPadColor[0]; + intersectionRecord.color.y *= lilyPadColor[1]; + intersectionRecord.color.z *= lilyPadColor[2]; } } @Override public float[] getColor(double u, double v) { float[] color = super.getColor(u, v); - if (color[3] > Ray.EPSILON) { + if (color[3] > Constants.EPSILON) { color = color.clone(); color[0] *= lilyPadColor[0]; color[1] *= lilyPadColor[1]; diff --git a/chunky/src/java/se/llbit/chunky/world/model/CubeModel.java b/chunky/src/java/se/llbit/chunky/world/model/CubeModel.java index af730a6ed9..f7171ae8f9 100644 --- a/chunky/src/java/se/llbit/chunky/world/model/CubeModel.java +++ b/chunky/src/java/se/llbit/chunky/world/model/CubeModel.java @@ -23,6 +23,7 @@ import se.llbit.chunky.resources.texturepack.SimpleTexture; import se.llbit.chunky.resources.texturepack.TextureLoader; import se.llbit.log.Log; +import se.llbit.math.Constants; import se.llbit.math.Quad; import se.llbit.math.Ray; import se.llbit.math.Vector2; @@ -84,7 +85,7 @@ public CubeModel(Collection cubes, double uvScale, Map te new int[][] { { 0, 0 }, { 0, 1 } }, new int[][] { { 2, 1 }, { 2, 0 } }, uv, - Math.abs(cube.start.y - cube.end.y) > Ray.EPSILON); + Math.abs(cube.start.y - cube.end.y) > Constants.EPSILON); break; case "down": addFace(theFaces, face, @@ -93,7 +94,7 @@ public CubeModel(Collection cubes, double uvScale, Map te new int[][] { { 0, 0 }, { 0, 1 } }, new int[][] { { 2, 0 }, { 2, 1 } }, uv, - Math.abs(cube.start.y - cube.end.y) > Ray.EPSILON); + Math.abs(cube.start.y - cube.end.y) > Constants.EPSILON); break; case "north": addFace(theFaces, face, @@ -102,7 +103,7 @@ public CubeModel(Collection cubes, double uvScale, Map te new int[][] { { 0, 1 }, { 0, 0 } }, new int[][] { { 1, 0 }, { 1, 1 } }, uv, - Math.abs(cube.start.z - cube.end.z) > Ray.EPSILON); + Math.abs(cube.start.z - cube.end.z) > Constants.EPSILON); break; case "south": addFace(theFaces, face, @@ -111,7 +112,7 @@ public CubeModel(Collection cubes, double uvScale, Map te new int[][] { { 0, 0 }, { 0, 1 } }, new int[][] { { 1, 0 }, { 1, 1 } }, uv, - Math.abs(cube.start.z - cube.end.z) > Ray.EPSILON); + Math.abs(cube.start.z - cube.end.z) > Constants.EPSILON); break; case "east": addFace(theFaces, face, @@ -120,7 +121,7 @@ public CubeModel(Collection cubes, double uvScale, Map te new int[][] { { 2, 1 }, { 2, 0 } }, new int[][] { { 1, 0 }, { 1, 1 } }, uv, - Math.abs(cube.start.x - cube.end.x) > Ray.EPSILON); + Math.abs(cube.start.x - cube.end.x) > Constants.EPSILON); break; case "west": addFace(theFaces, face, @@ -129,7 +130,7 @@ public CubeModel(Collection cubes, double uvScale, Map te new int[][] { { 2, 0 }, { 2, 1 } }, new int[][] { { 1, 0 }, { 1, 1 } }, uv, - Math.abs(cube.start.x - cube.end.x) > Ray.EPSILON); + Math.abs(cube.start.x - cube.end.x) > Constants.EPSILON); break; } } diff --git a/chunky/src/java/se/llbit/math/AABB.java b/chunky/src/java/se/llbit/math/AABB.java index 34797d3514..9677bd096e 100644 --- a/chunky/src/java/se/llbit/math/AABB.java +++ b/chunky/src/java/se/llbit/math/AABB.java @@ -93,94 +93,97 @@ public double faceSurfaceArea(int face) { * * @return true if the ray intersects this AABB */ - public boolean intersect(Ray ray) { - double ix = ray.o.x - QuickMath.floor(ray.o.x + ray.d.x * Ray.OFFSET); - double iy = ray.o.y - QuickMath.floor(ray.o.y + ray.d.y * Ray.OFFSET); - double iz = ray.o.z - QuickMath.floor(ray.o.z + ray.d.z * Ray.OFFSET); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { + double ix = ray.o.x - QuickMath.floor(ray.o.x + ray.d.x * Constants.OFFSET); + double iy = ray.o.y - QuickMath.floor(ray.o.y + ray.d.y * Constants.OFFSET); + double iz = ray.o.z - QuickMath.floor(ray.o.z + ray.d.z * Constants.OFFSET); double t; double u, v; boolean hit = false; - ray.tNext = ray.t; + double tNext = Double.POSITIVE_INFINITY; t = (xmin - ix) / ray.d.x; - if (t < ray.tNext && t > -Ray.EPSILON) { + if (t < tNext && t > -Constants.EPSILON) { u = iz + ray.d.z * t; v = iy + ray.d.y * t; if (u >= zmin && u <= zmax && v >= ymin && v <= ymax) { hit = true; - ray.tNext = t; - ray.u = u; - ray.v = v; - ray.setNormal(-1, 0, 0); + tNext = t; + intersectionRecord.uv.x = u; + intersectionRecord.uv.y = v; + intersectionRecord.setNormal(-1, 0, 0); } } t = (xmax - ix) / ray.d.x; - if (t < ray.tNext && t > -Ray.EPSILON) { + if (t < tNext && t > -Constants.EPSILON) { u = iz + ray.d.z * t; v = iy + ray.d.y * t; if (u >= zmin && u <= zmax && v >= ymin && v <= ymax) { hit = true; - ray.tNext = t; - ray.u = 1 - u; - ray.v = v; - ray.setNormal(1, 0, 0); + tNext = t; + intersectionRecord.uv.x = 1 - u; + intersectionRecord.uv.y = v; + intersectionRecord.setNormal(1, 0, 0); } } t = (ymin - iy) / ray.d.y; - if (t < ray.tNext && t > -Ray.EPSILON) { + if (t < tNext && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iz + ray.d.z * t; if (u >= xmin && u <= xmax && v >= zmin && v <= zmax) { hit = true; - ray.tNext = t; - ray.u = u; - ray.v = v; - ray.setNormal(0, -1, 0); + tNext = t; + intersectionRecord.uv.x = u; + intersectionRecord.uv.y = v; + intersectionRecord.setNormal(0, -1, 0); } } t = (ymax - iy) / ray.d.y; - if (t < ray.tNext && t > -Ray.EPSILON) { + if (t < tNext && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iz + ray.d.z * t; if (u >= xmin && u <= xmax && v >= zmin && v <= zmax) { hit = true; - ray.tNext = t; - ray.u = u; - ray.v = v; - ray.setNormal(0, 1, 0); + tNext = t; + intersectionRecord.uv.x = u; + intersectionRecord.uv.y = v; + intersectionRecord.setNormal(0, 1, 0); } } t = (zmin - iz) / ray.d.z; - if (t < ray.tNext && t > -Ray.EPSILON) { + if (t < tNext && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iy + ray.d.y * t; if (u >= xmin && u <= xmax && v >= ymin && v <= ymax) { hit = true; - ray.tNext = t; - ray.u = 1 - u; - ray.v = v; - ray.setNormal(0, 0, -1); + tNext = t; + intersectionRecord.uv.x = 1 - u; + intersectionRecord.uv.y = v; + intersectionRecord.setNormal(0, 0, -1); } } t = (zmax - iz) / ray.d.z; - if (t < ray.tNext && t > -Ray.EPSILON) { + if (t < tNext && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iy + ray.d.y * t; if (u >= xmin && u <= xmax && v >= ymin && v <= ymax) { hit = true; - ray.tNext = t; - ray.u = u; - ray.v = v; - ray.setNormal(0, 0, 1); + tNext = t; + intersectionRecord.uv.x = u; + intersectionRecord.uv.y = v; + intersectionRecord.setNormal(0, 0, 1); } } + if (hit) { + intersectionRecord.distance += tNext; + } return hit; } @@ -249,7 +252,7 @@ public boolean quickIntersect(Ray ray) { } } - if (tNear < tFar + Ray.EPSILON && tNear >= 0 && tNear < ray.t) { + if (tNear < tFar + Constants.EPSILON && tNear >= 0 && tNear < ray.t) { ray.tNext = tNear; return true; } else { @@ -333,7 +336,7 @@ public boolean hitTest(Ray ray) { } } - return tNear < tFar + Ray.EPSILON && tFar > 0; + return tNear < tFar + Constants.EPSILON && tFar > 0; } /** diff --git a/chunky/src/java/se/llbit/math/ColorUtil.java b/chunky/src/java/se/llbit/math/ColorUtil.java index 9d1d01ccd3..736f817a38 100644 --- a/chunky/src/java/se/llbit/math/ColorUtil.java +++ b/chunky/src/java/se/llbit/math/ColorUtil.java @@ -223,7 +223,7 @@ public static int getRGB(double[] frgb) { * Transform from xyY colorspace to XYZ colorspace. */ public static void xyYtoXYZ(Vector3 in, Vector3 out) { - if (in.y <= Ray.EPSILON) { + if (in.y <= Constants.EPSILON) { out.set(0, 0, 0); return; } @@ -282,7 +282,7 @@ public static void RGBtoHSL(Vector3 hsl, double r, double g, double b) { hue = (((r - g) / delta) + 4) / 6.0; } - hsl.set(hue, delta < Ray.EPSILON ? 0 : delta / (1 - FastMath.abs(2*lightness - 1)), lightness); + hsl.set(hue, delta < Constants.EPSILON ? 0 : delta / (1 - FastMath.abs(2*lightness - 1)), lightness); } public static Vector3 RGBtoHSL(double r, double g, double b) { diff --git a/chunky/src/java/se/llbit/math/Constants.java b/chunky/src/java/se/llbit/math/Constants.java index 5aff99ae7e..09328e6f14 100644 --- a/chunky/src/java/se/llbit/math/Constants.java +++ b/chunky/src/java/se/llbit/math/Constants.java @@ -17,6 +17,10 @@ package se.llbit.math; public class Constants { + public static final double EPSILON = 5e-8; + public static final double OFFSET = 1e-6; + + public static final double INV_4_PI = 1 / (4 * Math.PI); public static final double HALF_PI = Math.PI / 2; // TODO INV_TAU public static final double TAU = Math.PI * 2; diff --git a/chunky/src/java/se/llbit/math/Intersectable.java b/chunky/src/java/se/llbit/math/Intersectable.java index 9ecd10a5da..4999196aad 100644 --- a/chunky/src/java/se/llbit/math/Intersectable.java +++ b/chunky/src/java/se/llbit/math/Intersectable.java @@ -26,5 +26,5 @@ public interface Intersectable { * * @return {@code true} if there exists any intersection */ - boolean closestIntersection(Ray ray); + boolean closestIntersection(Ray2 ray, IntersectionRecord intersectionRecord); } diff --git a/chunky/src/java/se/llbit/math/IntersectionRecord.java b/chunky/src/java/se/llbit/math/IntersectionRecord.java new file mode 100644 index 0000000000..a40d79e00f --- /dev/null +++ b/chunky/src/java/se/llbit/math/IntersectionRecord.java @@ -0,0 +1,26 @@ +package se.llbit.math; + +import se.llbit.chunky.block.minecraft.Air; +import se.llbit.chunky.world.Material; +import se.llbit.math.Vector2; +import se.llbit.math.Vector3; +import se.llbit.math.Vector4; + +public class IntersectionRecord { + public double distance = Double.POSITIVE_INFINITY; + public final Vector3 n = new Vector3(0, 1, 0); + public final Vector2 uv = new Vector2(); + public Material material = Air.INSTANCE; + public final Vector3 shadeN = new Vector3(0, 1, 0); + public final Vector4 color = new Vector4(); + + public void setNormal(Vector3 normal) { + n.set(normal); + shadeN.set(normal); + } + + public void setNormal(double x, double y, double z) { + n.set(x, y, z); + shadeN.set(x, y, z); + } +} diff --git a/chunky/src/java/se/llbit/math/Matrix3.java b/chunky/src/java/se/llbit/math/Matrix3.java index fff5bfd3b4..e36ab34e69 100644 --- a/chunky/src/java/se/llbit/math/Matrix3.java +++ b/chunky/src/java/se/llbit/math/Matrix3.java @@ -105,12 +105,20 @@ public final void rotate(double pitch, double yaw, double roll) { m33 = cosb * cosc; } + /** + * Transform a point using this matrix. + */ + public void transform(Point3 o) { + o.set(m11 * o.x + m12 * o.y + m13 * o.z, m21 * o.x + m22 * o.y + m23 * o.z, + m31 * o.x + m32 * o.y + m33 * o.z); + } + /** * Transform a vector using this matrix. */ public void transform(Vector3 o) { o.set(m11 * o.x + m12 * o.y + m13 * o.z, m21 * o.x + m22 * o.y + m23 * o.z, - m31 * o.x + m32 * o.y + m33 * o.z); + m31 * o.x + m32 * o.y + m33 * o.z); } /** diff --git a/chunky/src/java/se/llbit/math/Octree.java b/chunky/src/java/se/llbit/math/Octree.java index 201bdde496..ee968f133c 100644 --- a/chunky/src/java/se/llbit/math/Octree.java +++ b/chunky/src/java/se/llbit/math/Octree.java @@ -35,6 +35,7 @@ import se.llbit.chunky.model.minecraft.WaterModel; import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.chunky.renderer.scene.StillWaterShader; import se.llbit.chunky.world.Material; import se.llbit.log.Log; import se.llbit.util.io.PositionalInputStream; @@ -327,7 +328,7 @@ public static Octree load(String impl, DataInputStream in) throws IOException { * @param o vector * @return {@code true} if the vector is inside the octree */ - public boolean isInside(Vector3 o) { + public boolean isInside(Point3 o) { int depth = implementation.getDepth(); int x = (int) QuickMath.floor(o.x); @@ -346,7 +347,7 @@ public boolean isInside(Vector3 o) { * @param ray Ray that will be moved to the boundary of the octree. The origin, distance and normals will be modified. * @return {@code false} if the ray doesn't intersect the octree. */ - private boolean enterOctree(Ray ray) { + private boolean enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { double nx = 0, ny = 0, nz = 0; double octree_size = 1 << getDepth(); @@ -466,9 +467,9 @@ private boolean enterOctree(Ray ray) { if (tMin < 0) return false; - ray.o.scaleAdd(tMin, ray.d); - ray.setNormal(nx, ny, nz); - ray.distance += tMin; + ray.o.add(ray.d.x * tMin, ray.d.y * tMin, ray.d.z * tMin); + intersectionRecord.setNormal(nx, ny, nz); + intersectionRecord.distance = tMin; return true; } @@ -477,8 +478,8 @@ private boolean enterOctree(Ray ray) { * * @return {@code false} if the ray did not hit the geometry */ - public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) { - if (!isInside(ray.o) && !enterOctree(ray)) + public boolean enterBlock(Scene scene, Ray2 ray, IntersectionRecord intersectionRecord, BlockPalette palette) { + if (!isInside(ray.o) && !enterOctree(ray, intersectionRecord)) return false; int depth = implementation.getDepth(); @@ -503,9 +504,9 @@ public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) { while (true) { // Add small offset past the intersection to avoid // recursion to the same octree node! - int x = (int) Math.floor(ray.o.x + ray.d.x * (distance + Ray.OFFSET)); - int y = (int) Math.floor(ray.o.y + ray.d.y * (distance + Ray.OFFSET)); - int z = (int) Math.floor(ray.o.z + ray.d.z * (distance + Ray.OFFSET)); + int x = (int) Math.floor(ray.o.x + ray.d.x * (distance + Constants.OFFSET)); + int y = (int) Math.floor(ray.o.y + ray.d.y * (distance + Constants.OFFSET)); + int z = (int) Math.floor(ray.o.z + ray.d.z * (distance + Constants.OFFSET)); int lx = x >>> depth; int ly = y >>> depth; @@ -524,10 +525,11 @@ public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) { // Test intersection Block currentBlock = palette.get(type); - Material prevBlock = ray.getCurrentMaterial(); + Material prevBlock = ray.getCurrentMedium(); - ray.setPrevMaterial(prevBlock, ray.getCurrentData()); - ray.setCurrentMaterial(currentBlock); + /*ray.setPrevMaterial(prevBlock, ray.getCurrentData()); + ray.setCurrentMaterial(currentBlock);*/ + intersectionRecord.material = currentBlock; if (currentBlock.localIntersect) { // Other functions expect the ray origin to be in the block they test so here time @@ -535,34 +537,34 @@ public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) { // Updating the origin also means that new offsetX/offsetY/offsetZ must be computed // but that is done a after the intersection test only if necessary // and not if we are leaving the function anyway - ray.o.scaleAdd(distance, ray.d); - ray.distance += distance; + ray.o.add(ray.d.x * distance, ray.d.y * distance, ray.d.z * distance); + intersectionRecord.distance += distance; distance = 0; - if (currentBlock.intersect(ray, scene)) { + if (currentBlock.intersect(ray, intersectionRecord, scene)) { if (prevBlock != currentBlock) return true; - ray.o.scaleAdd(Ray.OFFSET, ray.d); + ray.o.add(ray.d.x * Constants.OFFSET, ray.d.y * Constants.OFFSET, ray.d.z * Constants.OFFSET); offsetX = -ray.o.x * invDx; offsetY = -ray.o.y * invDy; offsetZ = -ray.o.z * invDz; continue; } else { // Exit ray from this local block. - ray.setCurrentMaterial(Air.INSTANCE); // Current material is air. - ray.exitBlock(x, y, z); + //ray.setCurrentMedium(Air.INSTANCE); // Current material is air. + exitBlock(ray, intersectionRecord, x, y, z); offsetX = -ray.o.x * invDx; offsetY = -ray.o.y * invDy; offsetZ = -ray.o.z * invDz; continue; } - } else if (!currentBlock.isSameMaterial(prevBlock) && currentBlock != Air.INSTANCE) { + } else if (!currentBlock.isSameMaterial(prevBlock)) { // Origin and distance of ray need to be updated - ray.o.scaleAdd(distance, ray.d); - ray.distance += distance; - TexturedBlockModel.getIntersectionColor(ray); + // ray.o.scaleAdd(distance, ray.d); + intersectionRecord.distance += distance; + TexturedBlockModel.getIntersectionColor(ray, intersectionRecord); if (currentBlock.opaque) { - ray.color.w = 1; + intersectionRecord.color.w = 1; } return true; } @@ -576,43 +578,43 @@ public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) { // The computation involves a multiplication and an addition so we could use a fma (need java 9+) // but according to measurement, performance are identical double t = (lx << level) * invDx + offsetX; - if (t > distance + Ray.EPSILON) { + if (t > distance + Constants.EPSILON) { tNear = t; nx = 1; } t = ((lx + 1) << level) * invDx + offsetX; - if (t < tNear && t > distance + Ray.EPSILON) { + if (t < tNear && t > distance + Constants.EPSILON) { tNear = t; nx = -1; } t = (ly << level) * invDy + offsetY; - if (t < tNear && t > distance + Ray.EPSILON) { + if (t < tNear && t > distance + Constants.EPSILON) { tNear = t; ny = 1; nx = 0; } t = ((ly + 1) << level) * invDy + offsetY; - if (t < tNear && t > distance + Ray.EPSILON) { + if (t < tNear && t > distance + Constants.EPSILON) { tNear = t; ny = -1; nx = 0; } t = (lz << level) * invDz + offsetZ; - if (t < tNear && t > distance + Ray.EPSILON) { + if (t < tNear && t > distance + Constants.EPSILON) { tNear = t; nz = 1; nx = ny = 0; } t = ((lz + 1) << level) * invDz + offsetZ; - if (t < tNear && t > distance + Ray.EPSILON) { + if (t < tNear && t > distance + Constants.EPSILON) { tNear = t; nz = -1; nx = ny = 0; } - ray.setNormal(nx, ny, nz); + intersectionRecord.setNormal(nx, ny, nz); distance = tNear; } @@ -623,8 +625,8 @@ public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) { * * @return {@code false} if the ray doesn't hit anything */ - public boolean exitWater(Scene scene, Ray ray, BlockPalette palette) { - if (!isInside(ray.o) && !enterOctree(ray)) + public boolean exitWater(Scene scene, Ray2 ray, IntersectionRecord intersectionRecord, BlockPalette palette) { + if (!isInside(ray.o) && !enterOctree(ray, intersectionRecord)) return false; int depth = getDepth(); @@ -636,9 +638,9 @@ public boolean exitWater(Scene scene, Ray ray, BlockPalette palette) { while (true) { // Add small offset past the intersection to avoid // recursion to the same octree node! - int x = (int) QuickMath.floor(ray.o.x + ray.d.x * Ray.OFFSET); - int y = (int) QuickMath.floor(ray.o.y + ray.d.y * Ray.OFFSET); - int z = (int) QuickMath.floor(ray.o.z + ray.d.z * Ray.OFFSET); + int x = (int) QuickMath.floor(ray.o.x + ray.d.x * Constants.OFFSET); + int y = (int) QuickMath.floor(ray.o.y + ray.d.y * Constants.OFFSET); + int z = (int) QuickMath.floor(ray.o.z + ray.d.z * Constants.OFFSET); int lx = x >>> depth; int ly = y >>> depth; @@ -658,34 +660,27 @@ public boolean exitWater(Scene scene, Ray ray, BlockPalette palette) { // Test intersection Block currentBlock = palette.get(type); - Material prevBlock = ray.getCurrentMaterial(); + Material prevBlock = ray.getCurrentMedium(); - ray.setPrevMaterial(prevBlock, ray.getCurrentData()); - ray.setCurrentMaterial(currentBlock); + /*ray.setPrevMaterial(prevBlock, ray.getCurrentData()); + ray.setCurrentMaterial(currentBlock);*/ + intersectionRecord.material = currentBlock; if (!currentBlock.isWater()) { - if (currentBlock.localIntersect) { - if (!currentBlock.intersect(ray, scene)) { - ray.setCurrentMaterial(Air.INSTANCE); - } - return true; - } else if (currentBlock != Air.INSTANCE) { - TexturedBlockModel.getIntersectionColor(ray); - if (currentBlock.opaque) { - ray.color.w = 1; - } - return true; - } else { - return true; - } + return true; } if (!(currentBlock instanceof Water && ((Water) currentBlock).isFullBlock())) { - if (WaterModel.intersectTop(ray)) { - ray.setCurrentMaterial(Air.INSTANCE); + if (WaterModel.intersectTop(ray, intersectionRecord)) { + intersectionRecord.material = Air.INSTANCE; + if (!(scene.getCurrentWaterShader() instanceof StillWaterShader) && intersectionRecord.shadeN.y != 0) { + scene.getCurrentWaterShader().doWaterShading(ray, intersectionRecord, scene.getAnimationTime()); + } + intersectionRecord.shadeN.scale(-1); + intersectionRecord.n.scale(-1); return true; } else { - ray.exitBlock(x, y, z); + exitBlock(ray, intersectionRecord, x, y, z); continue; } } @@ -696,13 +691,13 @@ public boolean exitWater(Scene scene, Ray ray, BlockPalette palette) { // Testing all six sides of the current leaf node and advancing to the closest intersection double t = ((lx << level) - ray.o.x) / ray.d.x; - if (t > Ray.EPSILON) { + if (t > Constants.EPSILON) { tNear = t; nx = 1; ny = nz = 0; } else { t = (((lx + 1) << level) - ray.o.x) / ray.d.x; - if (t < tNear && t > Ray.EPSILON) { + if (t < tNear && t > Constants.EPSILON) { tNear = t; nx = -1; ny = nz = 0; @@ -710,13 +705,13 @@ public boolean exitWater(Scene scene, Ray ray, BlockPalette palette) { } t = ((ly << level) - ray.o.y) / ray.d.y; - if (t < tNear && t > Ray.EPSILON) { + if (t < tNear && t > Constants.EPSILON) { tNear = t; ny = 1; nx = nz = 0; } else { t = (((ly + 1) << level) - ray.o.y) / ray.d.y; - if (t < tNear && t > Ray.EPSILON) { + if (t < tNear && t > Constants.EPSILON) { tNear = t; ny = -1; nx = nz = 0; @@ -724,25 +719,85 @@ public boolean exitWater(Scene scene, Ray ray, BlockPalette palette) { } t = ((lz << level) - ray.o.z) / ray.d.z; - if (t < tNear && t > Ray.EPSILON) { + if (t < tNear && t > Constants.EPSILON) { tNear = t; nz = 1; nx = ny = 0; } else { t = (((lz + 1) << level) - ray.o.z) / ray.d.z; - if (t < tNear && t > Ray.EPSILON) { + if (t < tNear && t > Constants.EPSILON) { tNear = t; nz = -1; nx = ny = 0; } } - ray.o.scaleAdd(tNear, ray.d); - ray.setNormal(nx, ny, nz); - ray.distance += tNear; + ray.o.add(ray.d.x * tNear, ray.d.y * tNear, ray.d.z * tNear); + intersectionRecord.setNormal(nx, ny, nz); + intersectionRecord.distance += tNear; } } + /** + * Find the exit point from the given block for this ray. This marches the ray forward - i.e. + * updates ray origin directly. + * + * @param bx block x coordinate + * @param by block y coordinate + * @param bz block z coordinate + */ + public void exitBlock(Ray2 ray, IntersectionRecord intersectionRecord, int bx, int by, int bz) { + int nx = 0; + int ny = 0; + int nz = 0; + double tNext = Double.POSITIVE_INFINITY; + double t = (bx - ray.o.x) / ray.d.x; + if (t > Constants.EPSILON) { + tNext = t; + nx = 1; + ny = nz = 0; + } else { + t = ((bx + 1) - ray.o.x) / ray.d.x; + if (t < tNext && t > Constants.EPSILON) { + tNext = t; + nx = -1; + ny = nz = 0; + } + } + + t = (by - ray.o.y) / ray.d.y; + if (t < tNext && t > Constants.EPSILON) { + tNext = t; + ny = 1; + nx = nz = 0; + } else { + t = ((by + 1) - ray.o.y) / ray.d.y; + if (t < tNext && t > Constants.EPSILON) { + tNext = t; + ny = -1; + nx = nz = 0; + } + } + + t = (bz - ray.o.z) / ray.d.z; + if (t < tNext && t > Constants.EPSILON) { + tNext = t; + nz = 1; + nx = ny = 0; + } else { + t = ((bz + 1) - ray.o.z) / ray.d.z; + if (t < tNext && t > Constants.EPSILON) { + tNext = t; + nz = -1; + nx = ny = 0; + } + } + + ray.o.add(ray.d.x * tNext, ray.d.y * tNext, ray.d.z * tNext); + intersectionRecord.setNormal(nx, ny, nz); + intersectionRecord.distance += tNext; + } + /** * Update the serialization timestamp. */ diff --git a/chunky/src/java/se/llbit/math/Point3.java b/chunky/src/java/se/llbit/math/Point3.java new file mode 100644 index 0000000000..38210034d7 --- /dev/null +++ b/chunky/src/java/se/llbit/math/Point3.java @@ -0,0 +1,99 @@ +package se.llbit.math; + +import se.llbit.json.JsonObject; + +public class Point3 extends Tuple3 { + + public Point3(Point3 point) { + this.x = point.x; + this.y = point.y; + this.z = point.z; + } + + public Point3(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Point3(double a) { + this.x = a; + this.y = a; + this.z = a; + } + + /** + * Creates a new point at (0, 0, 0). + */ + public Point3() { + this.x = 0d; + this.y = 0d; + this.z = 0d; + } + + public void add(Tuple3 vector) { + this.x += vector.x; + this.y += vector.y; + this.z += vector.z; + } + + public void scaleAdd(double scalar, Vector3 vector) { + this.x += vector.x * scalar; + this.y += vector.y * scalar; + this.z += vector.z * scalar; + } + + public void add(double x, double y, double z) { + this.x += x; + this.y += y; + this.z += z; + } + + public void sub(Point3 point) { + this.x -= point.x; + this.y -= point.y; + this.z -= point.z; + } + + public Vector3 vSub(Point3 point) { + return new Vector3(x - point.x, y - point.y, z - point.z); + } + + public Vector3 asVector() { + return new Vector3(x, y, z); + } + + public void set(Point3 point) { + this.x = point.x; + this.y = point.y; + this.z = point.z; + } + + public void set(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Unmarshals a point from JSON. + */ + public void fromJson(JsonObject object) { + x = object.get("x").doubleValue(0); + y = object.get("y").doubleValue(0); + z = object.get("z").doubleValue(0); + } + + /** + * Serialize to JSON + * + * @return JSON object + */ + public JsonObject toJson() { + JsonObject object = new JsonObject(); + object.add("x", x); + object.add("y", y); + object.add("z", z); + return object; + } +} diff --git a/chunky/src/java/se/llbit/math/Point3i.java b/chunky/src/java/se/llbit/math/Point3i.java new file mode 100644 index 0000000000..8f9197821e --- /dev/null +++ b/chunky/src/java/se/llbit/math/Point3i.java @@ -0,0 +1,88 @@ +package se.llbit.math; + +import se.llbit.json.JsonObject; + +public class Point3i { + public int x; + public int y; + public int z; + + public Point3i(Point3i point) { + this.x = point.x; + this.y = point.y; + this.z = point.z; + } + + public Point3i(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Point3i(int a) { + this.x = a; + this.y = a; + this.z = a; + } + + /** + * Creates a new point at (0, 0, 0). + */ + public Point3i() { + this.x = 0; + this.y = 0; + this.z = 0; + } + + public void add(Point3i point) { + this.x += point.x; + this.y += point.y; + this.z += point.z; + } + + public void add(Vector3i vector) { + this.x += vector.x; + this.y += vector.y; + this.z += vector.z; + } + + public void sub(Point3i point) { + this.x -= point.x; + this.y -= point.y; + this.z -= point.z; + } + + public void set(Point3i point) { + this.x = point.x; + this.y = point.y; + this.z = point.z; + } + + public void set(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Unmarshals a point from JSON. + */ + public void fromJson(JsonObject object) { + x = object.get("x").intValue(0); + y = object.get("y").intValue(0); + z = object.get("z").intValue(0); + } + + /** + * Serialize to JSON + * + * @return JSON object + */ + public JsonObject toJson() { + JsonObject object = new JsonObject(); + object.add("x", x); + object.add("y", y); + object.add("z", z); + return object; + } +} diff --git a/chunky/src/java/se/llbit/math/Quad.java b/chunky/src/java/se/llbit/math/Quad.java index 336ed7a489..00384b41fe 100644 --- a/chunky/src/java/se/llbit/math/Quad.java +++ b/chunky/src/java/se/llbit/math/Quad.java @@ -156,20 +156,20 @@ public void sample(Vector3 loc, Random rand) { * * @return true if the ray intersects this quad */ - public boolean intersect(Ray ray) { + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { double u, v; - double ix = ray.o.x - QuickMath.floor(ray.o.x + ray.d.x * Ray.OFFSET); - double iy = ray.o.y - QuickMath.floor(ray.o.y + ray.d.y * Ray.OFFSET); - double iz = ray.o.z - QuickMath.floor(ray.o.z + ray.d.z * Ray.OFFSET); + double ix = ray.o.x - QuickMath.floor(ray.o.x + ray.d.x * Constants.OFFSET); + double iy = ray.o.y - QuickMath.floor(ray.o.y + ray.d.y * Constants.OFFSET); + double iz = ray.o.z - QuickMath.floor(ray.o.z + ray.d.z * Constants.OFFSET); // Test that the ray is heading toward the plane of this quad. double denom = ray.d.dot(n); - if (denom < -Ray.EPSILON || (doubleSided && denom > Ray.EPSILON)) { + if (denom < -Constants.EPSILON || (doubleSided && denom > Constants.EPSILON)) { // Test for intersection with the plane at origin. double t = -(ix * n.x + iy * n.y + iz * n.z + d) / denom; - if (t > -Ray.EPSILON && t < ray.t) { + if (t > -Constants.EPSILON && t < intersectionRecord.distance) { // Plane intersection confirmed. // Translate to get hit point relative to the quad origin. @@ -181,9 +181,9 @@ public boolean intersect(Ray ray) { v = ix * yv.x + iy * yv.y + iz * yv.z; v *= yvl; if (u >= 0 && u <= 1 && v >= 0 && v <= 1) { - ray.u = uv.x + u * uv.y; - ray.v = uv.z + v * uv.w; - ray.tNext = t; + intersectionRecord.uv.x = uv.x + u * uv.y; + intersectionRecord.uv.y = uv.z + v * uv.w; + intersectionRecord.distance = t; return true; } } diff --git a/chunky/src/java/se/llbit/math/Ray.java b/chunky/src/java/se/llbit/math/Ray.java index 11deb1e4f4..b79bb6ad7a 100644 --- a/chunky/src/java/se/llbit/math/Ray.java +++ b/chunky/src/java/se/llbit/math/Ray.java @@ -32,10 +32,6 @@ */ public class Ray { - public static final double EPSILON = 0.00000005; - - public static final double OFFSET = 0.000001; - /** * Ray direction. */ @@ -189,13 +185,13 @@ public final void exitBlock(int bx, int by, int bz) { int nz = 0; double tNext = Double.POSITIVE_INFINITY; double t = (bx - o.x) / d.x; - if (t > Ray.EPSILON) { + if (t > Constants.EPSILON) { tNext = t; nx = 1; ny = nz = 0; } else { t = ((bx + 1) - o.x) / d.x; - if (t < tNext && t > Ray.EPSILON) { + if (t < tNext && t > Constants.EPSILON) { tNext = t; nx = -1; ny = nz = 0; @@ -203,13 +199,13 @@ public final void exitBlock(int bx, int by, int bz) { } t = (by - o.y) / d.y; - if (t < tNext && t > Ray.EPSILON) { + if (t < tNext && t > Constants.EPSILON) { tNext = t; ny = 1; nx = nz = 0; } else { t = ((by + 1) - o.y) / d.y; - if (t < tNext && t > Ray.EPSILON) { + if (t < tNext && t > Constants.EPSILON) { tNext = t; ny = -1; nx = nz = 0; @@ -217,13 +213,13 @@ public final void exitBlock(int bx, int by, int bz) { } t = (bz - o.z) / d.z; - if (t < tNext && t > Ray.EPSILON) { + if (t < tNext && t > Constants.EPSILON) { tNext = t; nz = 1; nx = ny = 0; } else { t = ((bz + 1) - o.z) / d.z; - if (t < tNext && t > Ray.EPSILON) { + if (t < tNext && t > Constants.EPSILON) { tNext = t; nz = -1; nx = ny = 0; @@ -236,27 +232,6 @@ public final void exitBlock(int bx, int by, int bz) { distance += tNext; } - /** - * @return foliage color for the current block - */ - public float[] getBiomeFoliageColor(Scene scene) { - return scene.getFoliageColor((int) (o.x + d.x * OFFSET), (int) (o.y + d.y * OFFSET), (int) (o.z + d.z * OFFSET)); - } - - /** - * @return grass color for the current block - */ - public float[] getBiomeGrassColor(Scene scene) { - return scene.getGrassColor((int) (o.x + d.x * OFFSET), (int) (o.y + d.y * OFFSET), (int) (o.z + d.z * OFFSET)); - } - - /** - * @return water color for the current block - */ - public float[] getBiomeWaterColor(Scene scene) { - return scene.getWaterColor((int) (o.x + d.x * OFFSET), (int) (o.y + d.y * OFFSET), (int) (o.z + d.z * OFFSET)); - } - /** * Set this ray to a random diffuse reflection of the input ray. */ @@ -307,13 +282,13 @@ public final void diffuseReflection(Ray ray, Random random) { d.y = uy * tx + vy * ty + n.y * tz; d.z = uz * tx + vz * ty + n.z * tz; - o.scaleAdd(Ray.OFFSET, d); + o.scaleAdd(Constants.OFFSET, d); currentMaterial = prevMaterial; specular = false; // See specularReflection for explanation of why this is needed if(QuickMath.signum(geomN.dot(d)) == QuickMath.signum(geomN.dot(ray.d))) { - double factor = QuickMath.signum(geomN.dot(ray.d)) * -Ray.EPSILON - d.dot(geomN); + double factor = QuickMath.signum(geomN.dot(ray.d)) * -Constants.EPSILON - d.dot(geomN); d.scaleAdd(factor, geomN); d.normalize(); } @@ -327,7 +302,7 @@ public final void specularReflection(Ray ray, Random random) { currentMaterial = prevMaterial; double roughness = ray.getCurrentMaterial().roughness; - if (roughness > Ray.EPSILON) { + if (roughness > Constants.EPSILON) { // For rough specular reflections, we interpolate linearly between the diffuse ray direction and the specular direction, // which is inspired by https://blog.demofox.org/2020/06/06/casual-shadertoy-path-tracing-2-image-improvement-and-glossy-reflections/ // This gives good-looking results, although a microfacet-based model would be more physically correct. @@ -408,7 +383,7 @@ public final void specularReflection(Ray ray, Random random) { // This tells us that if we chose `-d.n` as the factor we would have a dot product // equals to 0, as we want something positive or negative, // we will use the factor `-d.n +/- epsilon` - double factor = QuickMath.signum(geomN.dot(ray.d)) * -Ray.EPSILON - d.dot(geomN); + double factor = QuickMath.signum(geomN.dot(ray.d)) * -Constants.EPSILON - d.dot(geomN); d.scaleAdd(factor, geomN); d.normalize(); } diff --git a/chunky/src/java/se/llbit/math/Ray2.java b/chunky/src/java/se/llbit/math/Ray2.java new file mode 100644 index 0000000000..d30c82c79c --- /dev/null +++ b/chunky/src/java/se/llbit/math/Ray2.java @@ -0,0 +1,30 @@ +package se.llbit.math; + +import se.llbit.chunky.block.minecraft.Air; +import se.llbit.chunky.world.Material; + +public class Ray2 { + public Point3 o; + public Vector3 d; + private Material currentMedium; + + public Ray2() { + o = new Point3(); + d = new Vector3(); + currentMedium = Air.INSTANCE; + } + + public Ray2(Ray2 ray) { + o.set(ray.o); + d.set(ray.d); + currentMedium = ray.currentMedium; + } + + public Material getCurrentMedium() { + return currentMedium; + } + + public void setCurrentMedium(Material material) { + this.currentMedium = material; + } +} diff --git a/chunky/src/java/se/llbit/math/Triangle.java b/chunky/src/java/se/llbit/math/Triangle.java index ce6eca7c67..de9f3dabc9 100644 --- a/chunky/src/java/se/llbit/math/Triangle.java +++ b/chunky/src/java/se/llbit/math/Triangle.java @@ -82,18 +82,18 @@ public Triangle(Triangle other, Vector3 offset) { * * @return true if the ray intersects the triangle */ - public boolean intersect(Ray ray) { - double ix = ray.o.x - QuickMath.floor(ray.o.x + ray.d.x * Ray.OFFSET); - double iy = ray.o.y - QuickMath.floor(ray.o.y + ray.d.y * Ray.OFFSET); - double iz = ray.o.z - QuickMath.floor(ray.o.z + ray.d.z * Ray.OFFSET); + public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { + double ix = ray.o.x - QuickMath.floor(ray.o.x + ray.d.x * Constants.OFFSET); + double iy = ray.o.y - QuickMath.floor(ray.o.y + ray.d.y * Constants.OFFSET); + double iz = ray.o.z - QuickMath.floor(ray.o.z + ray.d.z * Constants.OFFSET); // test that the ray is heading toward the plane double denom = ray.d.dot(n); - if (QuickMath.abs(denom) > Ray.EPSILON) { + if (QuickMath.abs(denom) > Constants.EPSILON) { // test for intersection with the plane at origin double t = -(ix * n.x + iy * n.y + iz * n.z + d) / denom; - if (t > -Ray.EPSILON && t < ray.t) { + if (t > -Constants.EPSILON && t < intersectionRecord.distance) { // plane intersection confirmed // translate to get hit point relative to the triangle origin @@ -106,9 +106,9 @@ public boolean intersect(Ray ray) { double si = (uv * wv - vv * wu) / (uv2 - uu * vv); double ti = (uv * wu - uu * wv) / (uv2 - uu * vv); if ((si >= 0) && (ti >= 0) && (si + ti <= 1)) { - ray.tNext = t; - ray.u = si; - ray.v = ti; + intersectionRecord.distance = t; + intersectionRecord.uv.x = si; + intersectionRecord.uv.y = ti; return true; } } diff --git a/chunky/src/java/se/llbit/math/Tuple3.java b/chunky/src/java/se/llbit/math/Tuple3.java new file mode 100644 index 0000000000..3ed3366004 --- /dev/null +++ b/chunky/src/java/se/llbit/math/Tuple3.java @@ -0,0 +1,7 @@ +package se.llbit.math; + +public abstract class Tuple3 { + public double x; + public double y; + public double z; +} diff --git a/chunky/src/java/se/llbit/math/Vector3.java b/chunky/src/java/se/llbit/math/Vector3.java index fbfb6d953f..5a1cff4bff 100644 --- a/chunky/src/java/se/llbit/math/Vector3.java +++ b/chunky/src/java/se/llbit/math/Vector3.java @@ -25,9 +25,7 @@ * * @author Jesper Öqvist */ -public class Vector3 { - - public double x, y, z; +public class Vector3 extends Tuple3 { /** * Creates a new vector (0, 0, 0). @@ -82,7 +80,7 @@ public final double dot(Vector3 o) { /** * Set this vector equal to a-b. */ - public final void sub(Vector3 a, Vector3 b) { + public final void sub(Tuple3 a, Tuple3 b) { x = a.x - b.x; y = a.y - b.y; z = a.z - b.z; @@ -133,7 +131,7 @@ public final void normalize() { /** * Set this vector equal to s*d + o. */ - public final void scaleAdd(double s, Vector3 d, Vector3 o) { + public final void scaleAdd(double s, Vector3 d, Tuple3 o) { x = s * d.x + o.x; y = s * d.y + o.y; z = s * d.z + o.z; diff --git a/chunky/src/java/se/llbit/math/bvh/BVH.java b/chunky/src/java/se/llbit/math/bvh/BVH.java index 2f19317a40..e2090f9f91 100644 --- a/chunky/src/java/se/llbit/math/bvh/BVH.java +++ b/chunky/src/java/se/llbit/math/bvh/BVH.java @@ -19,9 +19,10 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.plugin.PluginApi; +import se.llbit.math.IntersectionRecord; import se.llbit.log.Log; import se.llbit.math.Intersectable; -import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.util.TaskTracker; @@ -33,7 +34,7 @@ * Bounding Volume Hierarchy based on AABBs. */ public interface BVH extends Intersectable { - BVH EMPTY = ray -> false; + BVH EMPTY = (ray, intersectionRecord) -> false; /** * Find closest intersection between the ray and any object in the BVH @@ -41,7 +42,7 @@ public interface BVH extends Intersectable { * @return {@code true} if there exists any intersection */ @Override - boolean closestIntersection(Ray ray); + boolean closestIntersection(Ray2 ray, IntersectionRecord intersectionRecord); final class Factory { diff --git a/chunky/src/java/se/llbit/math/bvh/BinaryBVH.java b/chunky/src/java/se/llbit/math/bvh/BinaryBVH.java index 81287ee9d9..cb3564c32f 100644 --- a/chunky/src/java/se/llbit/math/bvh/BinaryBVH.java +++ b/chunky/src/java/se/llbit/math/bvh/BinaryBVH.java @@ -20,15 +20,17 @@ import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntStack; import org.apache.commons.math3.util.FastMath; +import se.llbit.math.IntersectionRecord; import se.llbit.math.AABB; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.primitive.Primitive; import java.util.ArrayList; import java.util.Comparator; import java.util.Stack; -import static se.llbit.math.Ray.OFFSET; +import static se.llbit.math.Constants.OFFSET; /** * An abstract class for BinaryBVHs. This provides helper methods for packing a node based BVH into a more compact @@ -212,7 +214,7 @@ private void packAabb(AABB box, IntArrayList data) { * @return {@code true} if there exists any intersection */ @Override - public boolean closestIntersection(Ray ray) { + public boolean closestIntersection(Ray2 ray, IntersectionRecord intersectionRecord) { boolean hit = false; int currentNode = 0; IntStack nodesToVisit = new IntArrayList(depth/2); @@ -226,7 +228,7 @@ public boolean closestIntersection(Ray ray) { // Is leaf int primIndex = -packed[currentNode]; for (Primitive primitive : packedPrimitives[primIndex]) { - hit = primitive.intersect(ray) | hit; + hit = primitive.intersect(ray, intersectionRecord) | hit; } if (nodesToVisit.isEmpty()) break; @@ -244,14 +246,14 @@ public boolean closestIntersection(Ray ray) { Float.intBitsToFloat(packed[offset+5]), Float.intBitsToFloat(packed[offset+6]), rx, ry, rz); - if (t1 > ray.t | t1 == -1) { - if (t2 > ray.t | t2 == -1) { + if (t1 > intersectionRecord.distance | t1 == -1) { + if (t2 > intersectionRecord.distance | t2 == -1) { if (nodesToVisit.isEmpty()) break; currentNode = nodesToVisit.popInt(); } else { currentNode = packed[currentNode]; } - } else if (t2 > ray.t | t2 == -1) { + } else if (t2 > intersectionRecord.distance | t2 == -1) { currentNode += 7; } else if (t1 < t2) { nodesToVisit.push(packed[currentNode]); @@ -270,7 +272,7 @@ public boolean closestIntersection(Ray ray) { * Perform a fast AABB intersection with cached reciprocal direction. This is a branchless approach based on: * https://gamedev.stackexchange.com/a/146362 */ - public double quickAabbIntersect(Ray ray, float xmin, float xmax, float ymin, float ymax, float zmin, float zmax, double rx, double ry, double rz) { + public double quickAabbIntersect(Ray2 ray, float xmin, float xmax, float ymin, float ymax, float zmin, float zmax, double rx, double ry, double rz) { double tx1 = (xmin - ray.o.x) * rx; double tx2 = (xmax - ray.o.x) * rx; diff --git a/chunky/src/java/se/llbit/math/primitive/Box.java b/chunky/src/java/se/llbit/math/primitive/Box.java index 45bec12b62..4ab8e93b00 100644 --- a/chunky/src/java/se/llbit/math/primitive/Box.java +++ b/chunky/src/java/se/llbit/math/primitive/Box.java @@ -18,11 +18,12 @@ import java.util.Collection; +import se.llbit.math.IntersectionRecord; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.math.AABB; -import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Transform; import se.llbit.math.Vector2; import se.llbit.math.Vector3; @@ -145,7 +146,7 @@ public void addBottomFaces(Collection primitives, Texture texture, Ve new Vector2(uv.y, uv.z), material)); } - @Override public boolean intersect(Ray ray) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { // TODO Auto-generated method stub return false; } diff --git a/chunky/src/java/se/llbit/math/primitive/MutableAABB.java b/chunky/src/java/se/llbit/math/primitive/MutableAABB.java index c45f385bfe..1af26077e2 100644 --- a/chunky/src/java/se/llbit/math/primitive/MutableAABB.java +++ b/chunky/src/java/se/llbit/math/primitive/MutableAABB.java @@ -16,8 +16,12 @@ */ package se.llbit.math.primitive; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; import se.llbit.math.AABB; +import se.llbit.math.Point3; import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector3; /** @@ -110,15 +114,15 @@ public boolean hitTest(Ray ray) { } } - return tNear < tFar + Ray.EPSILON && tFar > 0; + return tNear < tFar + Constants.EPSILON && tFar > 0; } - @Override public boolean intersect(Ray ray) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { double t1, t2; double tNear = Double.NEGATIVE_INFINITY; double tFar = Double.POSITIVE_INFINITY; Vector3 d = ray.d; - Vector3 o = ray.o; + Point3 o = ray.o; if (d.x != 0) { double rx = 1 / d.x; @@ -173,8 +177,8 @@ public boolean hitTest(Ray ray) { } } - if (tNear < tFar + Ray.EPSILON && tNear >= 0 && tNear < ray.t) { - ray.tNext = tNear; + if (tNear < tFar + Constants.EPSILON && tNear >= 0 && tNear < intersectionRecord.distance) { + intersectionRecord.distance = tNear; return true; } else { return false; diff --git a/chunky/src/java/se/llbit/math/primitive/Primitive.java b/chunky/src/java/se/llbit/math/primitive/Primitive.java index 6e18c1e8d8..a677fe533f 100644 --- a/chunky/src/java/se/llbit/math/primitive/Primitive.java +++ b/chunky/src/java/se/llbit/math/primitive/Primitive.java @@ -16,8 +16,9 @@ */ package se.llbit.math.primitive; +import se.llbit.math.IntersectionRecord; import se.llbit.math.AABB; -import se.llbit.math.Ray; +import se.llbit.math.Ray2; /** * An intersectable primitive piece of geometry @@ -31,7 +32,7 @@ public interface Primitive { * * @return {@code true} if there was an intersection */ - boolean intersect(Ray ray); + boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord); /** * @return axis-aligned bounding box for the primitive diff --git a/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java b/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java index 146e74a4a0..3a915f6311 100644 --- a/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java +++ b/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java @@ -16,9 +16,10 @@ */ package se.llbit.math.primitive; +import se.llbit.math.IntersectionRecord; import se.llbit.chunky.world.Material; import se.llbit.math.AABB; -import se.llbit.math.Ray; +import se.llbit.math.Ray2; import se.llbit.math.Vector2; import se.llbit.math.Vector3; @@ -80,7 +81,7 @@ public TexturedTriangle(Vector3 c1, Vector3 c2, Vector3 c3, Vector2 t1, Vector2 bounds = AABB.bounds(c1, c2, c3); } - @Override public boolean intersect(Ray ray) { + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { // Möller-Trumbore triangle intersection algorithm! Vector3 pvec = new Vector3(); Vector3 qvec = new Vector3(); @@ -115,16 +116,16 @@ public TexturedTriangle(Vector3 c1, Vector3 c2, Vector3 c3, Vector2 t1, Vector2 double t = e2.dot(qvec) * recip; - if (t > EPSILON && t < ray.t) { + if (t > EPSILON && t < intersectionRecord.distance) { double w = 1 - u - v; - ray.u = t1u * u + t2u * v + t3u * w; - ray.v = t1v * u + t2v * v + t3v * w; - float[] color = material.getColor(ray.u, ray.v); + intersectionRecord.uv.x = t1u * u + t2u * v + t3u * w; + intersectionRecord.uv.y = t1v * u + t2v * v + t3v * w; + float[] color = material.getColor(intersectionRecord.uv.x, intersectionRecord.uv.y); if (color[3] > 0) { - ray.color.set(color); - ray.setCurrentMaterial(material); - ray.t = t; - ray.setNormal(n); + intersectionRecord.color.set(color); + intersectionRecord.material = material; + intersectionRecord.distance = t; + intersectionRecord.n.set(n); return true; } } diff --git a/chunky/src/java/se/llbit/util/JsonUtil.java b/chunky/src/java/se/llbit/util/JsonUtil.java index a90431dc19..772175dc05 100644 --- a/chunky/src/java/se/llbit/util/JsonUtil.java +++ b/chunky/src/java/se/llbit/util/JsonUtil.java @@ -21,6 +21,7 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; import se.llbit.nbt.Tag; @@ -41,6 +42,30 @@ public static JsonArray listTagToJson(Tag tag) { return json; } + public static Point3 point3FromJsonArray(JsonValue json) { + JsonArray array = json.array(); + double x = array.size() >= 1 ? array.get(0).asDouble(0) : 0; + double y = array.size() >= 2 ? array.get(1).asDouble(0) : 0; + double z = array.size() >= 3 ? array.get(2).asDouble(0) : 0; + return new Point3(x, y, z); + } + + public static Point3 point3FromJsonObject(JsonValue json) { + JsonObject obj = json.object(); + double x = obj.get("x").asDouble(0); + double y = obj.get("y").asDouble(0); + double z = obj.get("z").asDouble(0); + return new Point3(x, y, z); + } + + public static JsonValue vec3ToJson(Point3 point) { + JsonArray array = new JsonArray(); + array.add(Json.of(point.x)); + array.add(Json.of(point.y)); + array.add(Json.of(point.z)); + return array; + } + public static Vector3 vec3FromJsonArray(JsonValue json) { JsonArray array = json.array(); double x = array.size() >= 1 ? array.get(0).asDouble(0) : 0; diff --git a/chunky/src/java/se/llbit/util/VectorUtil.java b/chunky/src/java/se/llbit/util/VectorUtil.java new file mode 100644 index 0000000000..0a9f0a3c0d --- /dev/null +++ b/chunky/src/java/se/llbit/util/VectorUtil.java @@ -0,0 +1,12 @@ +package se.llbit.util; + +import se.llbit.math.Vector3; + +public class VectorUtil { + public static Vector3 orientNormal(Vector3 direction, Vector3 normal) { + if(direction.dot(normal) > 0) { + normal.set(-normal.x, -normal.y, -normal.z); + } + return normal; + } +} diff --git a/chunky/src/res/se/llbit/chunky/ui/render/tabs/LightingTab.fxml b/chunky/src/res/se/llbit/chunky/ui/render/tabs/LightingTab.fxml index 63708d2812..225e72130c 100644 --- a/chunky/src/res/se/llbit/chunky/ui/render/tabs/LightingTab.fxml +++ b/chunky/src/res/se/llbit/chunky/ui/render/tabs/LightingTab.fxml @@ -15,9 +15,7 @@ - - - + diff --git a/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java b/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java index 581bc0c776..b6cd141d4a 100644 --- a/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java +++ b/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java @@ -21,6 +21,7 @@ import se.llbit.json.Json; import se.llbit.json.JsonArray; import se.llbit.json.JsonValue; +import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -31,7 +32,7 @@ */ public class MarshallingTest { @Test public void testPlayer() { - PlayerEntity entity = new PlayerEntity("1234", new Vector3(100, 200, 300)); + PlayerEntity entity = new PlayerEntity("1234", new Point3(100, 200, 300)); JsonArray headPose = new JsonArray(); headPose.add(Json.of(33)); headPose.add(Json.of(66)); @@ -48,7 +49,7 @@ public class MarshallingTest { } @Test public void testArmorStand() { - ArmorStand entity = new ArmorStand(new Vector3(100, 200, 300), new CompoundTag()); + ArmorStand entity = new ArmorStand(new Point3(100, 200, 300), new CompoundTag()); JsonArray headPose = new JsonArray(); headPose.add(Json.of(33)); headPose.add(Json.of(66)); From ea4b35d5b4ddbecbd42121477899012b0d4b06ff Mon Sep 17 00:00:00 2001 From: Peregrine05 <92183530+Peregrine05@users.noreply.github.com> Date: Sat, 18 Nov 2023 15:00:03 +0100 Subject: [PATCH 02/65] Remove Point3, Point3i, and Tuple3 --- .../src/java/se/llbit/chunky/block/Block.java | 9 +- .../block/legacy/LegacyBlocksFinalizer.java | 4 +- .../block/legacy/blocks/LegacyBanner.java | 3 +- .../block/legacy/blocks/LegacySkull.java | 3 +- .../block/legacy/blocks/LegacyWallBanner.java | 3 +- .../llbit/chunky/block/minecraft/Banner.java | 3 +- .../llbit/chunky/block/minecraft/Beacon.java | 3 +- .../block/minecraft/CakeWithCandle.java | 3 +- .../minecraft/CalibratedSculkSensor.java | 3 +- .../chunky/block/minecraft/Campfire.java | 3 +- .../llbit/chunky/block/minecraft/Candle.java | 3 +- .../chunky/block/minecraft/CoralFan.java | 3 +- .../chunky/block/minecraft/DecoratedPot.java | 3 +- .../block/minecraft/EnchantingTable.java | 5 +- .../chunky/block/minecraft/HangingSign.java | 3 +- .../se/llbit/chunky/block/minecraft/Head.java | 5 +- .../llbit/chunky/block/minecraft/Lectern.java | 3 +- .../llbit/chunky/block/minecraft/LilyPad.java | 3 +- .../se/llbit/chunky/block/minecraft/Sign.java | 3 +- .../chunky/block/minecraft/SporeBlossom.java | 3 +- .../chunky/block/minecraft/WallBanner.java | 3 +- .../chunky/block/minecraft/WallCoralFan.java | 3 +- .../block/minecraft/WallHangingSign.java | 3 +- .../chunky/block/minecraft/WallHead.java | 5 +- .../chunky/block/minecraft/WallSign.java | 3 +- .../se/llbit/chunky/entity/ArmorStand.java | 6 +- .../se/llbit/chunky/entity/BeaconBeam.java | 10 +- .../src/java/se/llbit/chunky/entity/Book.java | 6 +- .../entity/CalibratedSculkSensorAmethyst.java | 4 +- .../java/se/llbit/chunky/entity/Campfire.java | 4 +- .../llbit/chunky/entity/CoralFanEntity.java | 5 +- .../java/se/llbit/chunky/entity/Entity.java | 14 ++- .../llbit/chunky/entity/FlameParticles.java | 14 +-- .../chunky/entity/HangingSignEntity.java | 7 +- .../se/llbit/chunky/entity/HeadEntity.java | 5 +- .../java/se/llbit/chunky/entity/Lectern.java | 9 +- .../se/llbit/chunky/entity/LilyPadEntity.java | 7 +- .../llbit/chunky/entity/PaintingEntity.java | 6 +- .../se/llbit/chunky/entity/PlayerEntity.java | 14 +-- .../java/se/llbit/chunky/entity/Poseable.java | 10 +- .../se/llbit/chunky/entity/SignEntity.java | 6 +- .../se/llbit/chunky/entity/SkullEntity.java | 4 +- .../se/llbit/chunky/entity/SporeBlossom.java | 7 +- .../llbit/chunky/entity/StandingBanner.java | 10 +- .../se/llbit/chunky/entity/WallBanner.java | 7 +- .../chunky/entity/WallCoralFanEntity.java | 5 +- .../chunky/entity/WallHangingSignEntity.java | 7 +- .../llbit/chunky/entity/WallSignEntity.java | 7 +- .../src/java/se/llbit/chunky/map/MapView.java | 3 +- .../llbit/chunky/model/AnimatedQuadModel.java | 5 +- .../model/minecraft/DecoratedPotModel.java | 5 +- .../projection/ApertureProjector.java | 5 +- .../renderer/projection/FisheyeProjector.java | 5 +- .../ForwardDisplacementProjector.java | 7 +- .../projection/PanoramicProjector.java | 5 +- .../projection/PanoramicSlotProjector.java | 5 +- .../projection/ParallelProjector.java | 7 +- .../renderer/projection/PinholeProjector.java | 5 +- .../chunky/renderer/projection/Projector.java | 5 +- .../renderer/projection/ShiftProjector.java | 5 +- .../SphericalApertureProjector.java | 3 +- .../projection/StereographicProjector.java | 5 +- .../stereo/ODSSinglePerspectiveProjector.java | 3 +- .../stereo/ODSVerticalStackedProjector.java | 3 +- .../OmniDirectionalStereoProjector.java | 11 +-- .../llbit/chunky/renderer/scene/Camera.java | 8 +- .../renderer/scene/OctreeFinalizer.java | 7 +- .../renderer/scene/PreviewRayTracer.java | 3 +- .../se/llbit/chunky/renderer/scene/Scene.java | 26 ++--- .../chunky/renderer/scene/SceneEntities.java | 17 ++-- .../src/java/se/llbit/chunky/ui/ChunkMap.java | 14 +-- .../ui/controller/ChunkyFxController.java | 7 +- .../chunky/ui/render/tabs/CameraTab.java | 5 +- .../chunky/ui/render/tabs/EntitiesTab.java | 23 +++-- .../java/se/llbit/chunky/world/Dimension.java | 5 +- chunky/src/java/se/llbit/math/Matrix3.java | 8 -- chunky/src/java/se/llbit/math/Octree.java | 2 +- chunky/src/java/se/llbit/math/Point3.java | 99 ------------------- chunky/src/java/se/llbit/math/Point3i.java | 88 ----------------- chunky/src/java/se/llbit/math/Ray2.java | 4 +- chunky/src/java/se/llbit/math/Tuple3.java | 7 -- chunky/src/java/se/llbit/math/Vector3.java | 9 +- .../se/llbit/math/primitive/MutableAABB.java | 3 +- chunky/src/java/se/llbit/util/JsonUtil.java | 25 ----- .../llbit/chunky/entity/MarshallingTest.java | 5 +- 85 files changed, 201 insertions(+), 513 deletions(-) delete mode 100644 chunky/src/java/se/llbit/math/Point3.java delete mode 100644 chunky/src/java/se/llbit/math/Point3i.java delete mode 100644 chunky/src/java/se/llbit/math/Tuple3.java diff --git a/chunky/src/java/se/llbit/chunky/block/Block.java b/chunky/src/java/se/llbit/chunky/block/Block.java index f8739be65a..26393e4771 100644 --- a/chunky/src/java/se/llbit/chunky/block/Block.java +++ b/chunky/src/java/se/llbit/chunky/block/Block.java @@ -1,7 +1,6 @@ package se.llbit.chunky.block; import se.llbit.chunky.entity.Entity; -import se.llbit.chunky.model.TexturedBlockModel; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; @@ -10,14 +9,12 @@ import se.llbit.math.AABB; import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.nbt.Tag; -import java.util.List; import java.util.Random; public abstract class Block extends Material { @@ -26,7 +23,7 @@ public abstract class Block extends Material { /** * Set to true if there is a local intersection model for this block. If this is set to * false (default), this block is assumed to be an opaque cube block and {@link - * #intersect(Ray, Scene)} will never be called. + * #intersect(Ray2, IntersectionRecord, Scene)} will never be called. */ public boolean localIntersect = false; @@ -104,7 +101,7 @@ public boolean isBlockEntity() { return false; } - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { throw new Error("This block type can not be converted to a block entity: " + getClass().getSimpleName()); } @@ -122,7 +119,7 @@ public boolean isBlockWithEntity() { return false; } - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { throw new Error("This block type can not be converted to an entity: " + getClass().getSimpleName()); } diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java index 88a81693eb..c3d485b416 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java @@ -1,12 +1,10 @@ package se.llbit.chunky.block.legacy; -import se.llbit.chunky.block.FinalizationState; import se.llbit.chunky.block.OctreeFinalizationState; import se.llbit.chunky.chunk.BlockPalette; import se.llbit.chunky.world.ChunkPosition; import se.llbit.chunky.world.Material; import se.llbit.math.Octree; -import se.llbit.math.Point3i; import se.llbit.math.Vector3i; /** @@ -25,7 +23,7 @@ public class LegacyBlocksFinalizer { * @param yMax Max y level to finalize (exclusive) */ public static void finalizeChunk(Octree worldTree, Octree waterTree, BlockPalette palette, - Point3i origin, ChunkPosition cp, int yMin, int yMax) { + Vector3i origin, ChunkPosition cp, int yMin, int yMax) { OctreeFinalizationState finalizerState = new OctreeFinalizationState(worldTree, waterTree, palette, yMin, yMax); for (int cy = yMin; cy < yMax; ++cy) { diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java index 318a2badd6..4e4a3a6edd 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java @@ -9,7 +9,6 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -59,7 +58,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new StandingBanner(position, rotation, parseDesign(entityTag)); } diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java index 4c9d871e66..b611b32ac8 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java @@ -10,7 +10,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -39,7 +38,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { Kind kind = getSkullKind(entityTag.get("SkullType").byteValue(0)); int rotation = entityTag.get("Rot").byteValue(0); if (kind == Kind.PLAYER) { diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java index cc99004167..d51b13429d 100644 --- a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java +++ b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java @@ -6,7 +6,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -35,7 +34,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new WallBanner(position, facing, LegacyBanner.parseDesign(entityTag)); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java index 88a535dfaf..17d683fecd 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java @@ -26,7 +26,6 @@ import se.llbit.json.Json; import se.llbit.json.JsonObject; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -55,7 +54,7 @@ public Banner(String name, Texture texture, int rotation, int color) { return true; } - @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { JsonObject design = StandingBanner.parseDesign(entityTag); design.set("base", Json.of(color)); // Base color is not included in the entity tag in Minecraft 1.13+. return new StandingBanner(position, rotation, design); diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java index 5e464e3a48..3f6949024b 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java @@ -23,7 +23,6 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.model.minecraft.BeaconModel; import se.llbit.chunky.resources.Texture; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -47,7 +46,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { if (entityTag.get("Levels").intValue(0) > 0) { return new BeaconBeam(position); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java index 05d50c5b2f..c6cdb2f976 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java @@ -23,7 +23,6 @@ import se.llbit.chunky.entity.FlameParticles; import se.llbit.chunky.model.minecraft.CakeWithCandleModel; import se.llbit.chunky.resources.Texture; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import java.util.Random; @@ -62,7 +61,7 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { return new FlameParticles(position, entity); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java index 65e884579e..bb4e503651 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java @@ -23,7 +23,6 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.model.minecraft.CalibratedSculkSensorModel; import se.llbit.chunky.resources.Texture; -import se.llbit.math.Point3; import se.llbit.math.Vector3; public class CalibratedSculkSensor extends AbstractModelBlock { @@ -57,7 +56,7 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { return new CalibratedSculkSensorAmethyst(position, this.facing, isActive(), this); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java index 7b10ffd40b..599a347ff8 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java @@ -23,7 +23,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -57,7 +56,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new se.llbit.chunky.entity.Campfire(this.kind, position, this.facing, this.isLit, this); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java index d7b1a90db9..6c41351fcb 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java @@ -25,7 +25,6 @@ import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; import se.llbit.chunky.world.material.TextureMaterial; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import java.util.Random; @@ -90,7 +89,7 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { if (entity != null) { return new FlameParticles(position, entity); } else { diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java index b602bddbb3..51b203b349 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java @@ -24,7 +24,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -75,7 +74,7 @@ public static Texture coralTexture(String coralType) { return true; } - @Override public Entity toEntity(Point3 position) { + @Override public Entity toEntity(Vector3 position) { return new CoralFanEntity(position, coralType); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java b/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java index c1ac753a4b..2d223fdb8c 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java @@ -22,7 +22,6 @@ import se.llbit.chunky.model.minecraft.DecoratedPotModel; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.entity.Entity; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.nbt.StringTag; @@ -65,7 +64,7 @@ public boolean isModifiedByBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new DecoratedPotModel.DecoratedPotSpoutEntity(position, facing); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java b/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java index cffbd14485..7b4a2bf513 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java @@ -23,7 +23,6 @@ import se.llbit.chunky.entity.Entity; import se.llbit.chunky.model.minecraft.EnchantmentTableModel; import se.llbit.chunky.resources.Texture; -import se.llbit.math.Point3; import se.llbit.math.Vector3; public class EnchantingTable extends AbstractModelBlock { @@ -46,8 +45,8 @@ public boolean isBlockWithEntity() { } @Override - public Entity toEntity(Point3 position) { - Point3 newPosition = new Point3(position); + public Entity toEntity(Vector3 position) { + Vector3 newPosition = new Vector3(position); newPosition.add(0, 0.35, 0); Book book = new Book( newPosition, diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java index 7102a496cc..34d1ec338e 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java @@ -23,7 +23,6 @@ import se.llbit.chunky.entity.HangingSignEntity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -55,7 +54,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new HangingSignEntity(position, entityTag, rotation, attached, material); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java index 6deb7f3b54..a16ce81fe8 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java @@ -25,7 +25,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -64,7 +63,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { return new SkullEntity(position, type, rotation, 1); } @@ -74,7 +73,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { if (type == Kind.PLAYER) { String textureUrl = getTextureUrl(entityTag); return textureUrl != null ? new HeadEntity(position, textureUrl, rotation, 1) diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java index ae4afbc16b..4991cb1e47 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java @@ -23,7 +23,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -52,7 +51,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { return new se.llbit.chunky.entity.Lectern(position, this.facing, this.hasBook); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java index 1abd5ce550..4b932906f2 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java @@ -24,7 +24,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -45,7 +44,7 @@ public LilyPad() { return true; } - @Override public Entity toEntity(Point3 position) { + @Override public Entity toEntity(Vector3 position) { return new LilyPadEntity(position); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java index 09d631ec1d..8352c02fe4 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java @@ -23,7 +23,6 @@ import se.llbit.chunky.entity.SignEntity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -50,7 +49,7 @@ public Sign(String name, String material, int rotation) { return true; } - @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new SignEntity(position, entityTag, rotation, material); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java index e5da1231be..4ca1f39bb7 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java @@ -23,7 +23,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -48,7 +47,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { return new se.llbit.chunky.entity.SporeBlossom(position); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java index 785b2d0d97..d7345e21c2 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java @@ -26,7 +26,6 @@ import se.llbit.json.Json; import se.llbit.json.JsonObject; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -66,7 +65,7 @@ public WallBanner(String name, Texture texture, String facing, int color) { return true; } - @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { JsonObject design = StandingBanner.parseDesign(entityTag); design.set("base", Json.of(color)); // Base color is not included in the entity tag in Minecraft 1.13+. return new se.llbit.chunky.entity.WallBanner(position, facing, design); diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java index 4550c8678b..5aa5b8b884 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java @@ -23,7 +23,6 @@ import se.llbit.chunky.entity.WallCoralFanEntity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -50,7 +49,7 @@ public WallCoralFan(String name, String coralType, String facing) { return true; } - @Override public Entity toEntity(Point3 position) { + @Override public Entity toEntity(Vector3 position) { return new WallCoralFanEntity(position, coralType, facing); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java index 6c45f6e8ef..9f06844748 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java @@ -24,7 +24,6 @@ import se.llbit.chunky.entity.WallHangingSignEntity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -54,7 +53,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new WallHangingSignEntity(position, entityTag, facing, material); } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java index 143100ba9e..d2fd0af342 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java @@ -26,7 +26,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -77,7 +76,7 @@ public boolean isEntity() { } @Override - public Entity toEntity(Point3 position) { + public Entity toEntity(Vector3 position) { return new SkullEntity(position, type, 0, facing); } @@ -87,7 +86,7 @@ public boolean isBlockEntity() { } @Override - public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { if (type == Kind.PLAYER) { String textureUrl = Head.getTextureUrl(entityTag); return textureUrl != null ? new HeadEntity(position, textureUrl, 0, facing) diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java index 5b4cc139b2..c1ecf4087d 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java @@ -24,7 +24,6 @@ import se.llbit.chunky.entity.WallSignEntity; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -65,7 +64,7 @@ public WallSign(String name, String material, String facing) { return true; } - @Override public Entity toBlockEntity(Point3 position, CompoundTag entityTag) { + @Override public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) { return new WallSignEntity(position, entityTag, facing, material); } } diff --git a/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java b/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java index afc33317c4..04b6eb5a1d 100644 --- a/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java +++ b/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java @@ -17,13 +17,11 @@ */ package se.llbit.chunky.entity; -import se.llbit.chunky.PersistentSettings; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.QuickMath; import se.llbit.math.Transform; @@ -378,7 +376,7 @@ public class ArmorStand extends Entity implements Poseable, Geared { private final boolean noBasePlate; public ArmorStand(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); this.scale = json.get("scale").asDouble(1.0); this.headScale = json.get("headScale").asDouble(1.0); this.showArms = json.get("showArms").asBoolean(false); @@ -388,7 +386,7 @@ public ArmorStand(JsonObject json) { this.noBasePlate = json.get("noBasePlate").asBoolean(false); } - public ArmorStand(Point3 position, Tag tag) { + public ArmorStand(Vector3 position, Tag tag) { super(position); gear = new JsonObject(); Tag handItems = tag.get("HandItems"); diff --git a/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java b/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java index e6c1d99cb1..9df60b648d 100644 --- a/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java +++ b/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java @@ -12,8 +12,6 @@ import se.llbit.log.Log; import se.llbit.math.ColorUtil; import se.llbit.math.Octree; -import se.llbit.math.Point3; -import se.llbit.math.Point3i; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -62,14 +60,14 @@ public class BeaconBeam extends Entity implements Poseable { private int height = 256; private final Int2ObjectOpenHashMap materials = new Int2ObjectOpenHashMap<>(); - public BeaconBeam(Point3 position) { + public BeaconBeam(Vector3 position) { super(position); this.pose = new JsonObject(); pose.add("all", JsonUtil.vec3ToJson(new Vector3(0, 0, 0))); } public BeaconBeam(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); this.scale = json.get("scale").asDouble(1); this.height = json.get("height").asInt(256); this.pose = json.get("pose").object(); @@ -83,14 +81,14 @@ public BeaconBeam(JsonObject json) { } @Override - public void loadDataFromOctree(Octree octree, BlockPalette palette, Point3i origin) { + public void loadDataFromOctree(Octree octree, BlockPalette palette, Vector3i origin) { int firstColor = BeaconBeamMaterial.DEFAULT_COLOR; boolean foundFirst = false; this.materials.put(0, new BeaconBeamMaterial(BeaconBeamMaterial.DEFAULT_COLOR)); //Start i at 1 so the first beacon block is not checked. This would cause the base beam color to always be white. //Stop iterating if the we get outside octree. - for (int i = 1; i < height && octree.isInside(new Point3((position.x - origin.x), (position.y + i - origin.y), (position.z - origin.z))); i++) { + for (int i = 1; i < height && octree.isInside(new Vector3((position.x - origin.x), (position.y + i - origin.y), (position.z - origin.z))); i++) { Material blockMaterial = octree.getMaterial((int)(position.x - origin.x), (int)(position.y + i - origin.y), (int)(position.z - origin.z), palette); int color = getColorFromBlock((Block)blockMaterial); if(color != -1) { diff --git a/chunky/src/java/se/llbit/chunky/entity/Book.java b/chunky/src/java/se/llbit/chunky/entity/Book.java index 4aeb85b62b..2f2ddc48b2 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Book.java +++ b/chunky/src/java/se/llbit/chunky/entity/Book.java @@ -3,7 +3,6 @@ import java.util.Collection; import java.util.LinkedList; -import se.llbit.chunky.PersistentSettings; import se.llbit.chunky.model.Model; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.material.TextureMaterial; @@ -11,7 +10,6 @@ import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; import se.llbit.math.Constants; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Ray; import se.llbit.math.Transform; @@ -185,7 +183,7 @@ public class Book extends Entity implements Poseable { private final JsonObject pose; private double scale = 1; - public Book(Point3 position, double openAngle, double pageAngleA, double pageAngleB) { + public Book(Vector3 position, double openAngle, double pageAngleA, double pageAngleB) { super(position); this.openAngle = openAngle; this.pageAngleA = Math.max(openAngle, pageAngleA); @@ -195,7 +193,7 @@ public Book(Point3 position, double openAngle, double pageAngleA, double pageAng } public Book(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); this.openAngle = json.get("openAngle").doubleValue(0); this.pageAngleA = json.get("pageAngleA").doubleValue(0); this.pageAngleB = json.get("pageAngleB").doubleValue(0); diff --git a/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java b/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java index 1aae627fd0..b6fe4591e8 100644 --- a/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java +++ b/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java @@ -63,7 +63,7 @@ public class CalibratedSculkSensorAmethyst extends Entity { public static final Material activeMaterial = new TextureMaterial(Texture.calibratedSculkSensorAmethyst); public static final Material inactiveMaterial = new TextureMaterial(Texture.calibratedSculkSensorAmethyst); - public CalibratedSculkSensorAmethyst(Point3 position, String facing, boolean active, CalibratedSculkSensor block) { + public CalibratedSculkSensorAmethyst(Vector3 position, String facing, boolean active, CalibratedSculkSensor block) { super(position); this.facing = facing; this.active = active; @@ -71,7 +71,7 @@ public CalibratedSculkSensorAmethyst(Point3 position, String facing, boolean act } public CalibratedSculkSensorAmethyst(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); this.facing = json.get("facing").stringValue("north"); this.active = json.get("active").boolValue(true); this.block = null; diff --git a/chunky/src/java/se/llbit/chunky/entity/Campfire.java b/chunky/src/java/se/llbit/chunky/entity/Campfire.java index efadc26680..36c8436860 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Campfire.java +++ b/chunky/src/java/se/llbit/chunky/entity/Campfire.java @@ -281,7 +281,7 @@ public static double surfaceArea(int face) { private final boolean isLit; private final Block block; - public Campfire(Campfire.Kind kind, Point3 position, String facing, boolean lit, Block block) { + public Campfire(Campfire.Kind kind, Vector3 position, String facing, boolean lit, Block block) { super(position); this.kind = kind; this.facing = facing; @@ -290,7 +290,7 @@ public Campfire(Campfire.Kind kind, Point3 position, String facing, boolean lit, } public Campfire(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); this.kind = Campfire.Kind.valueOf(json.get("campfireKind").stringValue("CAMPFIRE")); this.facing = json.get("facing").stringValue("north"); this.isLit = json.get("lit").boolValue(true); diff --git a/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java b/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java index 92be967a20..5b39a00c16 100644 --- a/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java @@ -23,7 +23,6 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -80,7 +79,7 @@ public class CoralFanEntity extends Entity { }; private final String coralType; - public CoralFanEntity(Point3 position, String coralType) { + public CoralFanEntity(Vector3 position, String coralType) { super(position); this.coralType = coralType; } @@ -108,7 +107,7 @@ public CoralFanEntity(Point3 position, String coralType) { } public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); return new CoralFanEntity(position, json.get("coral_type").stringValue("tube")); } diff --git a/chunky/src/java/se/llbit/chunky/entity/Entity.java b/chunky/src/java/se/llbit/chunky/entity/Entity.java index 0507af14fb..11d6bd361a 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Entity.java +++ b/chunky/src/java/se/llbit/chunky/entity/Entity.java @@ -25,8 +25,6 @@ import se.llbit.json.JsonValue; import se.llbit.math.Grid; import se.llbit.math.Octree; -import se.llbit.math.Point3; -import se.llbit.math.Point3i; import se.llbit.math.Vector3; import se.llbit.math.Vector3i; import se.llbit.math.primitive.Primitive; @@ -40,10 +38,10 @@ */ abstract public class Entity { - public final Point3 position; + public final Vector3 position; - protected Entity(Point3 position) { - this.position = new Point3(position); + protected Entity(Vector3 position) { + this.position = new Vector3(position); } abstract public Collection primitives(Vector3 offset); @@ -59,7 +57,7 @@ public Grid.EmitterPosition[] getEmitterPosition() { * @param palette The scene's block palate * @param origin The Octree's origin */ - public void loadDataFromOctree(Octree octree, BlockPalette palette, Point3i origin) { + public void loadDataFromOctree(Octree octree, BlockPalette palette, Vector3i origin) { } /** @@ -126,11 +124,11 @@ public static Entity fromJson(JsonObject json) { return null; } - public Point3 getPosition() { + public Vector3 getPosition() { return position; } - public void setPosition(Point3 position) { + public void setPosition(Vector3 position) { this.position.set(position); } } diff --git a/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java b/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java index 5f44efd2f9..1f0945d200 100644 --- a/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java +++ b/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java @@ -53,27 +53,27 @@ public class FlameParticles extends Entity { private final double scale; private final Block block; - public FlameParticles(Point3 position, double scale, Block block, Vector3[] flames) { + public FlameParticles(Vector3 position, double scale, Block block, Vector3[] flames) { super(position); this.flames = flames; this.scale = scale; this.block = block; } - public FlameParticles(Point3 position, Block block, Vector3[] flames) { + public FlameParticles(Vector3 position, Block block, Vector3[] flames) { this(position, 1, block, flames); } public FlameParticles(Block block, Vector3[] flames) { - this(new Point3(0, 0, 0), 1, block, flames); + this(new Vector3(0, 0, 0), 1, block, flames); } - public FlameParticles(Point3 position, FlameParticles other) { + public FlameParticles(Vector3 position, FlameParticles other) { this(position, other.scale, other.block, other.flames); } public FlameParticles(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); this.block = null; this.scale = json.get("scale").asDouble(1.0); if (json.get("particles").isArray()) { @@ -81,7 +81,7 @@ public FlameParticles(JsonObject json) { .map(JsonUtil::vec3FromJsonObject) .toArray(Vector3[]::new); } else { - this.flames = new Vector3[]{position.asVector()}; + this.flames = new Vector3[]{position}; } } @@ -97,7 +97,7 @@ public Collection primitives(Vector3 offset) { .translate(0.5, 1 / 16.0, 0.5) .translate(flameOffset) .translate(offset) - .translate(position.asVector())); + .translate(position)); } } return faces; diff --git a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java index 551d9d10e5..4863ce9bb7 100644 --- a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java @@ -7,7 +7,6 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -261,11 +260,11 @@ public class HangingSignEntity extends Entity { private final Texture texture; private final String material; - public HangingSignEntity(Point3 position, CompoundTag entityTag, int rotation, boolean attached, String material) { + public HangingSignEntity(Vector3 position, CompoundTag entityTag, int rotation, boolean attached, String material) { this(position, SignEntity.getFrontTextLines(entityTag), SignEntity.getFrontDyeColor(entityTag), SignEntity.getFrontGlowing(entityTag), SignEntity.getBackTextLines(entityTag), SignEntity.getBackDyeColor(entityTag), SignEntity.getBackGlowing(entityTag), rotation, attached, material); } - public HangingSignEntity(Point3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, int rotation, boolean attached, String material) { + public HangingSignEntity(Vector3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, int rotation, boolean attached, String material) { super(position); Texture signTexture = HangingSignEntity.textureFromMaterial(material); this.frontText = frontText; @@ -331,7 +330,7 @@ public JsonValue toJson() { * Unmarshalls a sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); JsonArray[] frontText = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java b/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java index 847e83d58c..deec5532b3 100644 --- a/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java @@ -33,7 +33,6 @@ import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; import se.llbit.log.Log; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -66,7 +65,7 @@ public class HeadEntity extends Entity { */ private final String skin; - public HeadEntity(Point3 position, String skin, int rotation, int placement) { + public HeadEntity(Vector3 position, String skin, int rotation, int placement) { super(position); this.skin = skin; this.rotation = rotation; @@ -195,7 +194,7 @@ public JsonValue toJson() { } public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); //int type = json.get("type").intValue(0); int rotation = json.get("rotation").intValue(0); diff --git a/chunky/src/java/se/llbit/chunky/entity/Lectern.java b/chunky/src/java/se/llbit/chunky/entity/Lectern.java index 37b8b5b70b..c2ab652e58 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Lectern.java +++ b/chunky/src/java/se/llbit/chunky/entity/Lectern.java @@ -7,7 +7,6 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -148,7 +147,7 @@ public class Lectern extends Entity implements Poseable { private final String facing; private final Book book; - public Lectern(Point3 position, String facing, boolean hasBook) { + public Lectern(Vector3 position, String facing, boolean hasBook) { super(position); this.facing = facing; if (hasBook) { @@ -159,7 +158,7 @@ public Lectern(Point3 position, String facing, boolean hasBook) { } public Lectern(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); this.facing = json.get("facing").stringValue("north"); if (json.get("book").isObject()) { this.book = Book.fromJson(json.get("book").object()); @@ -246,8 +245,8 @@ private static double getBookYaw(String facing) { } } - private static Book createBookEntity(Point3 position, String facing) { - Point3 bookPosition = new Point3(position); + private static Book createBookEntity(Vector3 position, String facing) { + Vector3 bookPosition = new Vector3(position); bookPosition.add(0, 8.5 / 16.0, 0); switch (facing) { diff --git a/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java b/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java index c012fddcfd..1c934094b9 100644 --- a/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java @@ -20,7 +20,6 @@ import se.llbit.chunky.world.material.LilyPadMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Vector2; import se.llbit.math.Vector3; import se.llbit.math.primitive.Primitive; @@ -34,12 +33,12 @@ public class LilyPadEntity extends Entity { private static final Material lilyMaterial = new LilyPadMaterial(); private final int rotation; - public LilyPadEntity(Point3 position) { + public LilyPadEntity(Vector3 position) { this(position, 3 & (int) (MinecraftPRNG.rand( (long) position.x, (long) position.y, (long) position.z) >> 16)); } - public LilyPadEntity(Point3 position, int rotation) { + public LilyPadEntity(Vector3 position, int rotation) { super(position); this.rotation = rotation; } @@ -91,7 +90,7 @@ public LilyPadEntity(Point3 position, int rotation) { * Unmarshall a lily pad entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); int rotation = json.get("rotation").intValue(0); return new LilyPadEntity(position, rotation); diff --git a/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java b/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java index 385d962230..6e5223da56 100644 --- a/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java @@ -22,13 +22,11 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; -import se.llbit.chunky.PersistentSettings; import se.llbit.chunky.resources.Texture; import se.llbit.chunky.world.Material; import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.QuickMath; import se.llbit.math.Transform; @@ -143,7 +141,7 @@ public Painting(Texture painting, int w, int h) { private final double angle; private final String art; - public PaintingEntity(Point3 position, String art, double angle) { + public PaintingEntity(Vector3 position, String art, double angle) { super(position); this.art = art; this.angle = angle; @@ -184,7 +182,7 @@ public JsonValue toJson() { * @return deserialized entity, or {@code null} if it was not a valid entity */ public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); String art = json.get("art").stringValue(""); double angle = json.get("angle").doubleValue(0.0); diff --git a/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java b/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java index 7b6feca425..97d6920750 100644 --- a/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java @@ -68,16 +68,16 @@ public class PlayerEntity extends Entity implements Poseable, Geared { public String skin = ""; public boolean showOuterLayer = true; - public PlayerEntity(String uuid, Point3 position) { + public PlayerEntity(String uuid, Vector3 position) { this(uuid, position, 0, 0, new JsonObject()); } public PlayerEntity(PlayerEntityData data) { - this(data.uuid, new Point3(data.x, data.y, data.z), data.rotation, data.pitch, + this(data.uuid, new Vector3(data.x, data.y, data.z), data.rotation, data.pitch, buildGear(data)); } - protected PlayerEntity(String uuid, Point3 position, double rotationDegrees, double pitchDegrees, + protected PlayerEntity(String uuid, Vector3 position, double rotationDegrees, double pitchDegrees, JsonObject gear) { super(position); this.uuid = uuid; @@ -96,7 +96,7 @@ protected PlayerEntity(String uuid, Point3 position, double rotationDegrees, dou public PlayerEntity(JsonObject settings) { - super(JsonUtil.point3FromJsonObject(settings.get("position"))); + super(JsonUtil.vec3FromJsonObject(settings.get("position"))); this.model = PlayerModel.get(settings.get("model").stringValue("STEVE")); this.uuid = settings.get("uuid").stringValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); this.skin = settings.get("skin").stringValue(""); @@ -460,7 +460,7 @@ public static void addArmor(Collection faces, .chain(worldTransform); String headItemId = headItem.get("id").asString(""); if (headItemId.equals("minecraft:dragon_head")) { - SkullEntity skull = new SkullEntity(new Point3(), Kind.DRAGON, 0, 1); + SkullEntity skull = new SkullEntity(new Vector3(), Kind.DRAGON, 0, 1); faces.addAll(skull.dragonHeadPrimitives(Transform.NONE.translate(0.5, 0.5, 0.5).scale(1.2).chain(transform))); } else if (headItemId.equals("minecraft:carved_pumpkin")) { Box hat = new Box(-4.25 / 16., 4.25 / 16., -4.25 / 16., 4.25 / 16., -4.25 / 16., 4.25 / 16.); @@ -480,10 +480,10 @@ public static void addArmor(Collection faces, hat.addTopFaces(faces, Texture.pumpkinTop, new Vector4(1, 0, 1, 0)); hat.addBottomFaces(faces, Texture.pumpkinTop, new Vector4(0, 1, 0, 1)); } else if (headItemId.equals("minecraft:player_head")) { - HeadEntity head = new HeadEntity(new Point3(), headItem.get("skin").asString(""), 0, 1); + HeadEntity head = new HeadEntity(new Vector3(), headItem.get("skin").asString(""), 0, 1); faces.addAll(head.primitives(Transform.NONE.scale(1.2).translate(0.5, 0.5, 0.5).chain(transform))); } else if (headItemId.equals("minecraft:piglin_head")) { - SkullEntity skull = new SkullEntity(new Point3(), Kind.PIGLIN, 0, 1); + SkullEntity skull = new SkullEntity(new Vector3(), Kind.PIGLIN, 0, 1); faces.addAll(skull.piglinHeadPrimitives(Transform.NONE.scale(1.2).translate(0.5, 0.5, 0.5).chain(transform))); } else { addModel(faces, getHelmModel(headItem), transform); diff --git a/chunky/src/java/se/llbit/chunky/entity/Poseable.java b/chunky/src/java/se/llbit/chunky/entity/Poseable.java index 4febacea28..090bbbe52c 100644 --- a/chunky/src/java/se/llbit/chunky/entity/Poseable.java +++ b/chunky/src/java/se/llbit/chunky/entity/Poseable.java @@ -20,7 +20,6 @@ import org.apache.commons.math3.util.FastMath; import se.llbit.json.Json; import se.llbit.json.JsonObject; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.util.JsonUtil; @@ -42,12 +41,13 @@ public interface Poseable { default double getHeadScale() { return 1; } default void setHeadScale(double value) {}; - Point3 getPosition(); + Vector3 getPosition(); - default void lookAt(Point3 target) { - Point3 face = new Point3(getPosition()); + default void lookAt(Vector3 target) { + Vector3 dir = new Vector3(target); + Vector3 face = new Vector3(getPosition()); face.add(0, 28 / 16., 0); - Vector3 dir = target.vSub(face); + dir.sub(face); dir.normalize(); double headYaw = getPose("head").y; getPose().set("rotation", Json.of(FastMath.atan2(dir.x, dir.z) + Math.PI - headYaw)); diff --git a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java index 4652869e71..e8524edf81 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java @@ -322,11 +322,11 @@ public Color getGlowingOutlineColor() { private final Texture texture; private final String material; - public SignEntity(Point3 position, CompoundTag entityTag, int blockData, String material) { + public SignEntity(Vector3 position, CompoundTag entityTag, int blockData, String material) { this(position, getFrontTextLines(entityTag), getFrontDyeColor(entityTag), getFrontGlowing(entityTag), getBackTextLines(entityTag), getBackDyeColor(entityTag), getBackGlowing(entityTag), blockData & 0xF, material); } - public SignEntity(Point3 position, JsonArray[] frontText, Color frontDye, boolean frontGlowing, JsonArray[] backText, Color backDye, boolean backGlowing, int direction, String material) { + public SignEntity(Vector3 position, JsonArray[] frontText, Color frontDye, boolean frontGlowing, JsonArray[] backText, Color backDye, boolean backGlowing, int direction, String material) { super(position); Texture signTexture = SignEntity.textureFromMaterial(material); this.frontText = frontText; @@ -571,7 +571,7 @@ public JsonValue toJson() { * Unmarshalls a sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); JsonArray[] frontText = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java b/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java index 21250568dd..32eebab625 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java @@ -501,7 +501,7 @@ public enum Kind { */ private final int placement; - public SkullEntity(Point3 position, Kind type, int rotation, int placement) { + public SkullEntity(Vector3 position, Kind type, int rotation, int placement) { super(position); this.type = type; this.rotation = rotation; @@ -628,7 +628,7 @@ public JsonValue toJson() { } public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); Kind type = Kind.values()[json.get("type").intValue(0)]; int rotation = json.get("rotation").intValue(0); diff --git a/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java b/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java index 2ed235a19b..84646b8dc6 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java +++ b/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java @@ -4,7 +4,6 @@ import se.llbit.chunky.model.minecraft.SporeBlossomModel; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Transform; import se.llbit.math.Vector3; import se.llbit.math.primitive.Primitive; @@ -12,17 +11,17 @@ public class SporeBlossom extends Entity { - public SporeBlossom(Point3 position) { + public SporeBlossom(Vector3 position) { super(position); } public SporeBlossom(JsonObject json) { - super(JsonUtil.point3FromJsonObject(json.get("position"))); + super(JsonUtil.vec3FromJsonObject(json.get("position"))); } @Override public Collection primitives(Vector3 offset) { - return SporeBlossomModel.primitives(Transform.NONE.translate(position.asVector()).translate(offset)); + return SporeBlossomModel.primitives(Transform.NONE.translate(position).translate(offset)); } @Override diff --git a/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java b/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java index 56035ea343..3e16a810ff 100644 --- a/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java +++ b/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java @@ -20,7 +20,6 @@ import se.llbit.chunky.model.Model; import se.llbit.chunky.resources.*; import se.llbit.chunky.resources.texturepack.SimpleTexture; -import se.llbit.chunky.resources.texturepack.TextureLoader; import se.llbit.chunky.world.BlockData; import se.llbit.chunky.world.Material; import se.llbit.chunky.world.material.TextureMaterial; @@ -29,7 +28,6 @@ import se.llbit.json.JsonValue; import se.llbit.log.Log; import se.llbit.math.ColorUtil; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -40,9 +38,7 @@ import se.llbit.nbt.SpecificTag; import java.util.Collection; -import java.util.Collections; import java.util.LinkedList; -import java.util.Map; /** * A mob head (skull) entity. @@ -153,13 +149,13 @@ public class StandingBanner extends Entity { private final int rotation; private final JsonObject design; - public StandingBanner(Point3 position, int rotation, JsonObject design) { + public StandingBanner(Vector3 position, int rotation, JsonObject design) { super(position); this.rotation = rotation; this.design = design; } - public StandingBanner(Point3 position, int rotation, CompoundTag entityTag) { + public StandingBanner(Vector3 position, int rotation, CompoundTag entityTag) { this(position, rotation, parseDesign(entityTag)); } @@ -344,7 +340,7 @@ protected static BitmapImage getPatternBitmap(String pattern) { } public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); int rotation = json.get("rotation").intValue(0); return new StandingBanner(position, rotation, json.get("design").object()); diff --git a/chunky/src/java/se/llbit/chunky/entity/WallBanner.java b/chunky/src/java/se/llbit/chunky/entity/WallBanner.java index 29e37d1a1b..d432ccd19f 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallBanner.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallBanner.java @@ -21,7 +21,6 @@ import se.llbit.chunky.world.Material; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -114,13 +113,13 @@ public class WallBanner extends Entity { private final int rotation; private final JsonObject design; - public WallBanner(Point3 position, int rotation, JsonObject design) { + public WallBanner(Vector3 position, int rotation, JsonObject design) { super(position); this.rotation = rotation; this.design = design; } - public WallBanner(Point3 position, int rotation, CompoundTag entityTag) { + public WallBanner(Vector3 position, int rotation, CompoundTag entityTag) { this(position, rotation, StandingBanner.parseDesign(entityTag)); } @@ -145,7 +144,7 @@ public WallBanner(Point3 position, int rotation, CompoundTag entityTag) { } public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); int rotation = json.get("rotation").intValue(0); return new WallBanner(position, rotation, json.get("design").object()); diff --git a/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java index d450d7147e..c779bf8022 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java @@ -23,7 +23,6 @@ import se.llbit.chunky.world.material.TextureMaterial; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.QuickMath; import se.llbit.math.Transform; @@ -64,7 +63,7 @@ public class WallCoralFanEntity extends Entity { private final String coralType; private final String facing; - public WallCoralFanEntity(Point3 position, String coralType, String facing) { + public WallCoralFanEntity(Vector3 position, String coralType, String facing) { super(position); this.coralType = coralType; this.facing = facing; @@ -106,7 +105,7 @@ public WallCoralFanEntity(Point3 position, String coralType, String facing) { } public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); String coralType = json.get("coral_type").stringValue("tube"); String facing = json.get("facing").stringValue("north"); diff --git a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java index da67704fd7..ab2b75f2a3 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java @@ -8,7 +8,6 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -241,11 +240,11 @@ public class WallHangingSignEntity extends Entity { private final Texture texture; private final String material; - public WallHangingSignEntity(Point3 position, CompoundTag entityTag, WallHangingSign.Facing direction, String material) { + public WallHangingSignEntity(Vector3 position, CompoundTag entityTag, WallHangingSign.Facing direction, String material) { this(position, SignEntity.getFrontTextLines(entityTag), SignEntity.getFrontDyeColor(entityTag), SignEntity.getFrontGlowing(entityTag), SignEntity.getBackTextLines(entityTag), SignEntity.getBackDyeColor(entityTag), SignEntity.getBackGlowing(entityTag), direction, material); } - public WallHangingSignEntity(Point3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, WallHangingSign.Facing direction, String material) { + public WallHangingSignEntity(Vector3 position, JsonArray[] frontText, SignEntity.Color frontDye, boolean frontGlowing, JsonArray[] backText, SignEntity.Color backDye, boolean backGlowing, WallHangingSign.Facing direction, String material) { super(position); Texture signTexture = HangingSignEntity.textureFromMaterial(material); this.frontText = frontText; @@ -309,7 +308,7 @@ public JsonValue toJson() { * Unmarshalls a sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); JsonArray[] frontText = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java index 7b4fcf7d70..336b94965c 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java @@ -24,7 +24,6 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Transform; import se.llbit.math.Vector3; @@ -101,11 +100,11 @@ public class WallSignEntity extends Entity { private final Texture texture; private final String material; - public WallSignEntity(Point3 position, CompoundTag entityTag, int blockData, String material) { + public WallSignEntity(Vector3 position, CompoundTag entityTag, int blockData, String material) { this(position, SignEntity.getFrontTextLines(entityTag), SignEntity.getFrontDyeColor(entityTag), SignEntity.getFrontGlowing(entityTag), blockData % 6, material); } - public WallSignEntity(Point3 position, JsonArray[] text, SignEntity.Color dye, boolean isGlowing, int direction, String material) { + public WallSignEntity(Vector3 position, JsonArray[] text, SignEntity.Color dye, boolean isGlowing, int direction, String material) { super(position); Texture signTexture = SignEntity.textureFromMaterial(material); this.orientation = direction; @@ -156,7 +155,7 @@ public JsonValue toJson() { * Unmarshalls a wall sign entity from JSON data. */ public static Entity fromJson(JsonObject json) { - Point3 position = new Point3(); + Vector3 position = new Vector3(); position.fromJson(json.get("position").object()); JsonArray[] text = null; if (json.get("text").isArray()) { diff --git a/chunky/src/java/se/llbit/chunky/map/MapView.java b/chunky/src/java/se/llbit/chunky/map/MapView.java index c27cc005d6..a1ad9e9202 100644 --- a/chunky/src/java/se/llbit/chunky/map/MapView.java +++ b/chunky/src/java/se/llbit/chunky/map/MapView.java @@ -20,7 +20,6 @@ import javafx.beans.property.SimpleObjectProperty; import se.llbit.chunky.renderer.ChunkViewListener; import se.llbit.chunky.world.ChunkView; -import se.llbit.math.Point3; import se.llbit.math.Vector2; import se.llbit.math.Vector3; @@ -66,7 +65,7 @@ public synchronized void moveView(double dx, double dz) { } /** Set the map view by block coordinates. */ - public void panTo(Point3 pos) { + public void panTo(Vector3 pos) { // Convert from block coordinates to chunk coordinates. panTo(pos.x / 16, pos.z / 16); } diff --git a/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java b/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java index eebe120591..b9e619ff49 100644 --- a/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java +++ b/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java @@ -5,7 +5,6 @@ import se.llbit.chunky.resources.AnimatedTexture; import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Ray; import se.llbit.math.Ray2; @@ -51,8 +50,8 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene // The animation frame to use int j = (int) (scene.getAnimationTime() * animationMode.framerate); if (animationMode.positional) { - Point3 position = new Point3(ray.o); - position.add(ray.d.x * Constants.OFFSET, ray.d.y * Constants.OFFSET, ray.d.z * Constants.OFFSET); + Vector3 position = new Vector3(ray.o); + position.scaleAdd(Constants.OFFSET, ray.d); j += (int) MinecraftPRNG.rand((long) position.x, (long) position.y, (long) position.z); } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java index b3b37e6908..29a72bcd1b 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java @@ -21,7 +21,6 @@ import se.llbit.chunky.model.TopBottomOrientedTexturedBlockModel; import se.llbit.chunky.resources.Texture; import se.llbit.log.Log; -import se.llbit.math.Point3; import se.llbit.math.Quad; import se.llbit.math.Vector3; import se.llbit.math.Vector4; @@ -141,7 +140,7 @@ public static class DecoratedPotSpoutEntity extends Entity { private final Material material = new TextureMaterial(Texture.decoratedPotBase); private final String facing; - public DecoratedPotSpoutEntity(Point3 position, String facing) { + public DecoratedPotSpoutEntity(Vector3 position, String facing) { super(position); this.facing = facing; } @@ -159,7 +158,7 @@ public Collection primitives(Vector3 offset) { public static Entity fromJson(JsonObject json) { return new DecoratedPotSpoutEntity( - JsonUtil.point3FromJsonObject(json.get("position")), + JsonUtil.vec3FromJsonObject(json.get("position")), json.get("facing").stringValue("north") ); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java index 128bd788d0..fc2e3b06ff 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java @@ -24,7 +24,6 @@ import se.llbit.chunky.resources.BitmapImage; import se.llbit.log.Log; import se.llbit.math.Constants; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Vector3; import se.llbit.resources.ImageLoader; @@ -95,7 +94,7 @@ static private BitmapImage loadApertureMask(ApertureShape apertureShape) { return null; } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { wrapped.apply(x, y, random, o, d); d.scale(subjectDistance / d.z); @@ -146,7 +145,7 @@ static private BitmapImage loadApertureMask(ApertureShape apertureShape) { o.add(rx, ry, 0); } - @Override public void apply(double x, double y, Point3 pos, Vector3 direction) { + @Override public void apply(double x, double y, Vector3 pos, Vector3 direction) { wrapped.apply(x, y, pos, direction); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java index 72b1c0aab1..a3786f0129 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java @@ -20,7 +20,6 @@ import org.apache.commons.math3.util.FastMath; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -31,11 +30,11 @@ public FisheyeProjector(double fov) { this.fov = fov; } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Vector3 o, Vector3 d) { double ay = QuickMath.degToRad(y * fov); double ax = QuickMath.degToRad(x * fov); double avSquared = ay * ay + ax * ax; diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java index 51b90273d8..9dc5a2082b 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java @@ -18,7 +18,6 @@ import java.util.Random; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -37,7 +36,7 @@ public ForwardDisplacementProjector(Projector wrapped, double displacement) { this.displacementSign = QuickMath.signum(displacement); } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { wrapped.apply(x, y, random, o, d); d.normalize(); @@ -45,12 +44,12 @@ public ForwardDisplacementProjector(Projector wrapped, double displacement) { o.add(d.x * displacementSign, d.y * displacementSign, d.z * displacementSign); } - @Override public void apply(double x, double y, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Vector3 o, Vector3 d) { wrapped.apply(x, y, o, d); d.normalize(); d.scale(displacementValue); - o.add(d.x * displacementSign, d.y * displacementSign, d.z * displacementSign); + o.scaleAdd(displacementSign, d); } @Override public double getMinRecommendedFoV() { diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java index b2845c4172..7eb825d7dc 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java @@ -20,7 +20,6 @@ import org.apache.commons.math3.util.FastMath; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -35,11 +34,11 @@ public PanoramicProjector(double fov) { this.fov = fov; } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Vector3 o, Vector3 d) { double ay = QuickMath.degToRad(y * fov); double ax = QuickMath.degToRad(x * fov); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java index ad6dccb132..b5c7de1436 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java @@ -21,7 +21,6 @@ import org.apache.commons.math3.util.FastMath; import se.llbit.chunky.renderer.scene.Camera; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -38,11 +37,11 @@ public PanoramicSlotProjector(double fov) { this.fovTan = Camera.clampedFovTan(fov); } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Vector3 o, Vector3 d) { double ax = QuickMath.degToRad(x * fov); double dz = FastMath.cos(ax); double dx = FastMath.sin(ax); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java index 6f863f7c63..fbf0709c0c 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java @@ -20,7 +20,6 @@ import se.llbit.chunky.renderer.scene.Scene; import se.llbit.math.Constants; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -37,11 +36,11 @@ public ParallelProjector(double worldDiagonalSize, double fov) { this.fov = fov; } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Vector3 o, Vector3 d) { o.set(fov * x, fov * y, 0); d.set(0, 0, 1); } @@ -62,7 +61,7 @@ public static void fixRay(Ray2 ray, Scene scene) { // When in parallel projection, push the ray origin back so the // ray start outside the octree to prevent ray spawning inside some blocks int limit = (1 << scene.getWorldOctree().getDepth()); - Point3 o = ray.o; + Vector3 o = ray.o; Vector3 d = ray.d; double t = 0; // simplified intersection test with the 6 planes that form the bounding box of the octree diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java index cf009f6c40..a67b2890b6 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java @@ -19,7 +19,6 @@ import java.util.Random; import se.llbit.chunky.renderer.scene.Camera; -import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -36,11 +35,11 @@ public PinholeProjector(double fov) { this.fovTan = Camera.clampedFovTan(fov); } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Vector3 o, Vector3 d) { o.set(0, 0, 0); d.set(fovTan * x, fovTan * y, 1); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java index 3a1530c7bf..273e16afe5 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java @@ -18,7 +18,6 @@ import java.util.Random; -import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -33,7 +32,7 @@ public interface Projector { * @param direction will be populated with camera-relative ray direction * (not necessarily normalized) */ - void apply(double x, double y, Random random, Point3 pos, Vector3 direction); + void apply(double x, double y, Random random, Vector3 pos, Vector3 direction); /** * @param x pixel X coordinate, where 0 = center and +-0.5 = edges @@ -42,7 +41,7 @@ public interface Projector { * @param direction will be populated with camera-relative ray direction * (not necessarily normalized) */ - void apply(double x, double y, Point3 pos, Vector3 direction); + void apply(double x, double y, Vector3 pos, Vector3 direction); double getMinRecommendedFoV(); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java index 9f9f2eeb4a..620d8059ee 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java @@ -2,7 +2,6 @@ import java.util.Random; -import se.llbit.math.Point3; import se.llbit.math.Vector3; public class ShiftProjector implements Projector { @@ -17,12 +16,12 @@ public ShiftProjector(Projector wrapped, double shiftX, double shiftY) { } @Override - public void apply(double x, double y, Random random, Point3 pos, Vector3 direction) { + public void apply(double x, double y, Random random, Vector3 pos, Vector3 direction) { wrapped.apply(x + shiftX, y - shiftY, random, pos, direction); } @Override - public void apply(double x, double y, Point3 pos, Vector3 direction) { + public void apply(double x, double y, Vector3 pos, Vector3 direction) { wrapped.apply(x + shiftX, y - shiftY, pos, direction); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java index 3e83bed56f..31f2b34af7 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java @@ -19,7 +19,6 @@ import java.util.Random; import se.llbit.math.Constants; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Vector3; @@ -32,7 +31,7 @@ public SphericalApertureProjector(Projector wrapped, double apertureSize, super(wrapped, apertureSize, subjectDistance); } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { wrapped.apply(x, y, random, o, d); d.scale(subjectDistance); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java index c8d3e6f0f4..f77a8838c2 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java @@ -19,7 +19,6 @@ import java.util.Random; import se.llbit.chunky.renderer.scene.Camera; -import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -35,11 +34,11 @@ public StereographicProjector(double fov) { scale = Camera.clampedFovTan(fov); } - @Override public void apply(double x, double y, Random random, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Random random, Vector3 o, Vector3 d) { apply(x, y, o, d); } - @Override public void apply(double x, double y, Point3 o, Vector3 d) { + @Override public void apply(double x, double y, Vector3 o, Vector3 d) { y *= scale; x *= scale; double xx_yy = x * x + y * y; diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java index b0a20a0b6d..7bd004a1b0 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java @@ -16,7 +16,6 @@ */ package se.llbit.chunky.renderer.projection.stereo; -import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -32,7 +31,7 @@ public ODSSinglePerspectiveProjector(Eye eye) { } @Override - public void apply(double x, double y, Point3 pos, Vector3 direction) { + public void apply(double x, double y, Vector3 pos, Vector3 direction) { switch (eye) { case LEFT: applyLeftEye(x + 0.5, y + 0.5, pos, direction); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java index 6aa408d0a5..e21793feba 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java @@ -16,7 +16,6 @@ */ package se.llbit.chunky.renderer.projection.stereo; -import se.llbit.math.Point3; import se.llbit.math.Vector3; /** @@ -27,7 +26,7 @@ */ public class ODSVerticalStackedProjector extends OmniDirectionalStereoProjector { @Override - public void apply(double x, double y, Point3 pos, Vector3 direction) { + public void apply(double x, double y, Vector3 pos, Vector3 direction) { if(y < 0) { // -0.5 - 0.0 applyLeftEye(x*2 + 1, y*2 + 1, pos, direction); diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java index 506cda0538..d9397f4cd7 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java +++ b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java @@ -20,7 +20,6 @@ import se.llbit.chunky.renderer.projection.PanoramicProjector; import se.llbit.chunky.renderer.projection.Projector; import se.llbit.math.Constants; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import java.util.Random; @@ -45,18 +44,18 @@ public abstract class OmniDirectionalStereoProjector implements Projector { private static final double INTERPUPILLARY_DISTANCE = 0.069; @Override - public void apply(double x, double y, Random random, Point3 pos, Vector3 direction) { + public void apply(double x, double y, Random random, Vector3 pos, Vector3 direction) { apply(x, y, pos, direction); } @Override - public abstract void apply(double x, double y, Point3 pos, Vector3 direction); + public abstract void apply(double x, double y, Vector3 pos, Vector3 direction); /** * @param x 0-1 * @param y 0-1 */ - protected void applyLeftEye(double x, double y, Point3 pos, Vector3 direction) { + protected void applyLeftEye(double x, double y, Vector3 pos, Vector3 direction) { apply(x, y, -INTERPUPILLARY_DISTANCE / 2, pos, direction); } @@ -64,7 +63,7 @@ protected void applyLeftEye(double x, double y, Point3 pos, Vector3 direction) { * @param x 0-1 * @param y 0-1 */ - protected void applyRightEye(double x, double y, Point3 pos, Vector3 direction) { + protected void applyRightEye(double x, double y, Vector3 pos, Vector3 direction) { apply(x, y, INTERPUPILLARY_DISTANCE / 2, pos, direction); } @@ -72,7 +71,7 @@ protected void applyRightEye(double x, double y, Point3 pos, Vector3 direction) * @param x 0-1 * @param y 0-1 */ - private void apply(double x, double y, double scale, Point3 pos, Vector3 direction) { + private void apply(double x, double y, double scale, Vector3 pos, Vector3 direction) { double theta = x * Math.PI - Constants.HALF_PI; double phi = Constants.HALF_PI - y * Math.PI; diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java index 298121cbdc..df60ad54e3 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java @@ -40,7 +40,6 @@ import se.llbit.log.Log; import se.llbit.math.IntersectionRecord; import se.llbit.math.Matrix3; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Ray; import se.llbit.math.Ray2; @@ -51,7 +50,6 @@ import java.util.Random; import java.util.function.BiPredicate; -import java.util.function.Function; /** * Camera model for 3D rendering. @@ -100,7 +98,7 @@ public static double clampedFovTan(double fov) { private boolean lockCamera = false; - Point3 pos = new Point3(0, 0, 0); + Vector3 pos = new Vector3(0, 0, 0); /** * Scratch vector used for temporary storage. @@ -269,7 +267,7 @@ private void initProjector() { /** * Set the camera position. */ - public void setPosition(Point3 p) { + public void setPosition(Vector3 p) { pos.set(p); onViewChange(); positionListener.run(); @@ -560,7 +558,7 @@ public void transform(Vector3 d) { /** * @return Current position */ - public Point3 getPosition() { + public Vector3 getPosition() { return pos; } diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java index db9add2533..38e4365e70 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java @@ -22,7 +22,6 @@ import se.llbit.chunky.world.ChunkPosition; import se.llbit.chunky.world.Material; import se.llbit.math.Octree; -import se.llbit.math.Point3i; import se.llbit.math.Vector3i; /** @@ -42,7 +41,7 @@ public class OctreeFinalizer { * @param cp Position of the chunk to finalize */ public static void finalizeChunk(Octree worldTree, Octree waterTree, BlockPalette palette, - Point3i origin, ChunkPosition cp, int yMin, int yMax) { + Vector3i origin, ChunkPosition cp, int yMin, int yMax) { for (int cy = yMin; cy < yMax; ++cy) { for (int cz = 0; cz < 16; ++cz) { int z = cz + cp.z * 16 - origin.z; @@ -59,7 +58,7 @@ public static void finalizeChunk(Octree worldTree, Octree waterTree, BlockPalett } private static void hideBlocks(Octree worldTree, BlockPalette palette, int x, - int cy, int z, int yMin, int yMax, Point3i origin) { + int cy, int z, int yMin, int yMax, Vector3i origin) { // Set non-visible blocks to be any block, in order to merge large patches. int y = cy - origin.y; if (cy > yMin && cy < yMax - 1) { @@ -77,7 +76,7 @@ private static void hideBlocks(Octree worldTree, BlockPalette palette, int x, } private static void processBlock(Octree worldTree, Octree waterTree, BlockPalette palette, int x, - int cy, int z, Point3i origin) { + int cy, int z, Vector3i origin) { int y = cy - origin.y; Material mat = worldTree.getMaterial(x, y, z, palette); Material wmat = waterTree.getMaterial(x, y, z, palette); diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java index 66d100fe26..3f31cb237c 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java @@ -23,7 +23,6 @@ import se.llbit.chunky.renderer.WorkerState; import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -167,7 +166,7 @@ private static boolean mapIntersection(Scene scene, Ray2 ray, IntersectionRecord if (ray.d.y < 0) { // ray going below horizon double t = (scene.yMin - ray.o.y - scene.origin.y) / ray.d.y; if (t > 0 && t < intersectionRecord.distance) { - Point3 point = new Point3(ray.o); + Vector3 point = new Vector3(ray.o); point.scaleAdd(t + Constants.OFFSET, ray.d); // must be submerged if water plane is enabled otherwise ray already had collided with water boolean isSubmerged = scene.isWaterPlaneEnabled(); diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java index bc5fef242f..fd1beaf77f 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java @@ -253,7 +253,7 @@ public class Scene implements JsonSerializable, Refreshable { /** * Octree origin. */ - protected Point3i origin = new Point3i(); + protected Vector3i origin = new Vector3i(); /** * Actual upper y bound (might be lower than yClipMax). @@ -1017,7 +1017,7 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec Block block = palette.get(currentBlock); if(block.isEntity()) { - Point3 position = new Point3(cx + cp.x * 16, y, cz + cp.z * 16); + Vector3 position = new Vector3(cx + cp.x * 16, y, cz + cp.z * 16); Entity entity = block.toEntity(position); if (entities.shouldLoad(entity)) { @@ -1192,7 +1192,7 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec } Block block = palette.get(chunkData.getBlockAt(x, y, z)); // Metadata is the old block data (to be replaced in future Minecraft versions?). - Point3 position = new Point3(x + wx0, y, z + wz0); + Vector3 position = new Vector3(x + wx0, y, z + wz0); if (block.isModifiedByBlockEntity()) { Tag newTag = block.getNewTagWithBlockEntity(palette.getBlockSpec(chunkData.getBlockAt(x, y, z)).getTag(), entityTag); if (newTag != null) { @@ -1514,9 +1514,9 @@ public synchronized boolean haveLoadedChunks() { * * @return The calculated camera position */ - public Point3 calcCenterCamera() { + public Vector3 calcCenterCamera() { if (chunks.isEmpty()) { - return new Point3(0, 128, 0); + return new Vector3(0, 128, 0); } int xmin = Integer.MAX_VALUE; @@ -1550,10 +1550,10 @@ public Point3 calcCenterCamera() { Material block = worldOctree.getMaterial(xcenter - origin.x, y - origin.y, zcenter - origin.z, palette); if (!(block instanceof Air)) { - return new Point3(xcenter, y + 5, zcenter); + return new Vector3(xcenter, y + 5, zcenter); } } - return new Point3(xcenter, 128, zcenter); + return new Vector3(xcenter, 128, zcenter); } /** @@ -1721,13 +1721,13 @@ public void autoFocus() { * * @return {@code null} if the camera is not aiming at some intersectable object */ - public Point3 getTargetPosition() { + public Vector3 getTargetPosition() { Ray2 ray = new Ray2(); IntersectionRecord intersectionRecord = new IntersectionRecord(); if (!traceTarget(ray, intersectionRecord)) { return null; } else { - Point3 target = new Point3(ray.o); + Vector3 target = new Vector3(ray.o); target.add(origin.x, origin.y, origin.z); return target; } @@ -1736,7 +1736,7 @@ public Point3 getTargetPosition() { /** * @return World origin in the Octree */ - public Point3i getOrigin() { + public Vector3i getOrigin() { return origin; } @@ -2350,7 +2350,7 @@ public synchronized String sceneStatus() { } buf.append("\n"); } - Point3 pos = camera.getPosition(); + Vector3 pos = camera.getPosition(); buf.append(String.format("pos: (%.1f, %.1f, %.1f)\n", pos.x, pos.y, pos.z)); buf.append("facing: "); @@ -2519,7 +2519,7 @@ public boolean shouldSaveSnapshots() { return saveSnapshots; } - public Material getWorldMaterial(Point3 point) { + public Material getWorldMaterial(Vector3 point) { int x = (int) QuickMath.floor(point.x); int y = (int) QuickMath.floor(point.y); int z = (int) QuickMath.floor(point.z); @@ -2551,7 +2551,7 @@ public boolean isInWater(Ray2 ray) { return false; } - public boolean isInsideOctree(Point3 point) { + public boolean isInsideOctree(Vector3 point) { return worldOctree.isInside(point); } diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java index 14fd1f6718..74a8e1357d 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java @@ -15,8 +15,6 @@ import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; import se.llbit.math.Octree; -import se.llbit.math.Point3; -import se.llbit.math.Point3i; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -158,13 +156,13 @@ public void loadEntitiesInChunk(Scene scene, ChunkData chunkData) { Tag paintingVariant = NbtUtil.getTagFromNames(tag, "Motive", "variant"); addEntity(new PaintingEntity( - new Point3(x, y, z), + new Vector3(x, y, z), paintingVariant.stringValue(), yaw )); } else if (id.equals("minecraft:armor_stand") && entityLoadingPreferences.shouldLoadClass(ArmorStand.class)) { addActor(new ArmorStand( - new Point3(x, y, z), + new Vector3(x, y, z), tag )); } @@ -185,8 +183,9 @@ public void addActor(Entity entity) { // don't add the actor again if it was already loaded from json if(actors.stream().noneMatch(actor -> { if(actor.getClass().equals(entity.getClass())) { - double distance = actor.position.vSub(entity.position).lengthSquared(); - return distance < Constants.EPSILON; + Vector3 distance = new Vector3(actor.position); + distance.sub(entity.position); + return distance.lengthSquared() < Constants.EPSILON; } return false; })) { @@ -238,7 +237,7 @@ public void setBvhImplementation(String bvhImplementation) { public void loadDataFromOctree( Octree worldOctree, BlockPalette palette, - Point3i origin + Vector3i origin ) { for (Entity entity : actors) { entity.loadDataFromOctree(worldOctree, palette, origin); @@ -248,12 +247,12 @@ public void loadDataFromOctree( } } - public void buildBvh(TaskTracker.Task task, Point3i origin) { + public void buildBvh(TaskTracker.Task task, Vector3i origin) { Vector3 worldOffset = new Vector3(-origin.x, -origin.y, -origin.z); bvh = BVH.Factory.create(bvhImplementation, entities, worldOffset, task); } - public void buildActorBvh(TaskTracker.Task task, Point3i origin) { + public void buildActorBvh(TaskTracker.Task task, Vector3i origin) { Vector3 worldOffset = new Vector3(-origin.x, -origin.y, -origin.z); actorBvh = BVH.Factory.create(bvhImplementation, actors, worldOffset, task); } diff --git a/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java b/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java index 96948180b6..8069479616 100644 --- a/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java +++ b/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java @@ -19,22 +19,16 @@ import javafx.application.Platform; import javafx.geometry.Point2D; -import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.*; -import javafx.scene.control.Button; -import javafx.scene.control.Dialog; import javafx.scene.control.MenuItem; -import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.scene.input.ScrollEvent; -import javafx.scene.layout.Border; -import javafx.scene.layout.GridPane; import javafx.stage.PopupWindow; import se.llbit.chunky.map.MapBuffer; import se.llbit.chunky.map.MapView; @@ -45,7 +39,6 @@ import se.llbit.chunky.renderer.scene.SceneManager; import se.llbit.chunky.ui.controller.ChunkyFxController; import se.llbit.chunky.ui.dialogs.SelectChunksInRadiusDialog; -import se.llbit.chunky.ui.elements.TextFieldLabelWrapper; import se.llbit.chunky.world.Chunk; import se.llbit.chunky.world.ChunkPosition; import se.llbit.chunky.world.ChunkSelectionTracker; @@ -63,7 +56,6 @@ import java.io.File; import java.io.IOException; import java.util.Collection; -import java.util.Optional; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -652,7 +644,7 @@ public void selectVisibleChunks(ChunkView cv, se.llbit.chunky.renderer.scene.Sce double halfWidth = width / (2.0 * height); - Point3 o = new Point3(camera.getPosition()); + Vector3 o = new Vector3(camera.getPosition()); Ray2 ray = new Ray2(); Vector3[] corners = new Vector3[4]; @@ -685,7 +677,7 @@ public void selectVisibleChunks(ChunkView cv, se.llbit.chunky.renderer.scene.Sce for (int z = cv.pz0; z <= cv.pz1; ++z) { // Chunk top center position: Vector3 pos = new Vector3((x + 0.5) * 16, 63, (z + 0.5) * 16); - pos.sub(o.asVector()); + pos.sub(o); if (norm[0].dot(pos) > CHUNK_SELECT_RADIUS && norm[1].dot(pos) > CHUNK_SELECT_RADIUS && norm[2].dot(pos) > CHUNK_SELECT_RADIUS && norm[3].dot(pos) > CHUNK_SELECT_RADIUS) { chunkSelection.selectChunk(currentDimension, x, z); @@ -779,7 +771,7 @@ public static void drawViewBounds(GraphicsContext gc, ChunkView cv, // Draw the camera facing direction indicator. camera.calcViewRay(ray, 0, 0); - Point3 o = new Point3(ray.o); + Vector3 o = new Vector3(ray.o); o.x /= 16; o.z /= 16; o.scaleAdd(1, ray.d); diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java b/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java index 2b66111853..183795726f 100644 --- a/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java +++ b/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java @@ -84,7 +84,6 @@ import se.llbit.fxutil.GroupedChangeListener; import se.llbit.log.Level; import se.llbit.log.Log; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.util.ProgressListener; import se.llbit.util.TaskTracker; @@ -457,13 +456,13 @@ public File getSceneFile(String fileName) { chunkSelection.clearSelection(); } world.currentDimension().addChunkDeletionListener(chunkSelection); - Optional playerPos = world.currentDimension().getPlayerPos(); + Optional playerPos = world.currentDimension().getPlayerPos(); world.currentDimension().addChunkUpdateListener(map); Platform.runLater( () -> { if (!reloaded || trackPlayer.getValue()) { - mapView.panTo(playerPos.orElse(new Point3(0, 0, 0))); + mapView.panTo(playerPos.orElse(new Vector3(0, 0, 0))); } if (!reloaded) { ignoreYUpdate.set(true); @@ -857,7 +856,7 @@ public void panToCamera() { public void moveCameraTo(double x, double z) { chunky.getRenderController().getSceneProvider().withEditSceneProtected(scene -> { Camera camera = scene.camera(); - Point3 pos = new Point3(x, camera.getPosition().y, z); + Vector3 pos = new Vector3(x, camera.getPosition().y, z); camera.setPosition(pos); }); } diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java index 2a4df1670a..7086d60655 100644 --- a/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java +++ b/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java @@ -42,7 +42,6 @@ import se.llbit.chunky.ui.render.RenderControlsTab; import se.llbit.json.JsonMember; import se.llbit.json.JsonObject; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; @@ -237,7 +236,7 @@ private void updateCameraLocked() { EventHandler positionHandler = e -> { if (e.getCode() == KeyCode.ENTER) { scene.camera() - .setPosition(new Point3( + .setPosition(new Vector3( posX.valueProperty().get(), posY.valueProperty().get(), posZ.valueProperty().get())); @@ -379,7 +378,7 @@ private void updateCameraList() { private void updateCameraPosition() { Camera camera = scene.camera(); - Point3 pos = camera.getPosition(); + Vector3 pos = camera.getPosition(); if (positionOrientation.isExpanded()) { posX.valueProperty().set(pos.x); posY.valueProperty().set(pos.y); diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java index 9983d219b2..410e3f2422 100644 --- a/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java +++ b/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java @@ -60,7 +60,6 @@ import se.llbit.json.JsonObject; import se.llbit.log.Log; import se.llbit.math.ColorUtil; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; import se.llbit.util.mojangapi.MinecraftProfile; @@ -97,7 +96,7 @@ public class EntitiesTab extends ScrollPane implements RenderControlsTab, Initia private Scene scene; public interface EntityType { - T createInstance(Point3 position, Scene scene); + T createInstance(Vector3 position, Scene scene); } public static class EntityData { @@ -459,22 +458,22 @@ else if(entity instanceof BeaconBeam) { updatePositionFields(entity); posX.valueProperty().addListener((observable, oldValue, newValue) -> { withEntity(e -> { - Point3 currentPosition = e.getPosition(); - e.setPosition(new Point3(newValue.doubleValue(), currentPosition.y, currentPosition.z)); + Vector3 currentPosition = e.getPosition(); + e.setPosition(new Vector3(newValue.doubleValue(), currentPosition.y, currentPosition.z)); }); scene.rebuildActorBvh(); }); posY.valueProperty().addListener((observable, oldValue, newValue) -> { withEntity(e -> { - Point3 currentPosition = e.getPosition(); - e.setPosition(new Point3(currentPosition.x, newValue.doubleValue(), currentPosition.z)); + Vector3 currentPosition = e.getPosition(); + e.setPosition(new Vector3(currentPosition.x, newValue.doubleValue(), currentPosition.z)); }); scene.rebuildActorBvh(); }); posZ.valueProperty().addListener((observable, oldValue, newValue) -> { withEntity(e -> { - Point3 currentPosition = e.getPosition(); - e.setPosition(new Point3(currentPosition.x, currentPosition.y, newValue.doubleValue())); + Vector3 currentPosition = e.getPosition(); + e.setPosition(new Vector3(currentPosition.x, currentPosition.y, newValue.doubleValue())); }); scene.rebuildActorBvh(); }); @@ -600,9 +599,9 @@ public void initialize(URL location, ResourceBundle resources) { entityType.setValue("Player"); add.setTooltip(new Tooltip("Add an entity at the target position.")); add.setOnAction(e -> { - Point3 position = scene.getTargetPosition(); + Vector3 position = scene.getTargetPosition(); if (position == null) { - position = new Point3(scene.camera().getPosition()); + position = new Vector3(scene.camera().getPosition()); } Entity entity = entityTypes.get(entityType.getValue()).createInstance(position, scene); @@ -653,7 +652,7 @@ public void initialize(URL location, ResourceBundle resources) { })); entityToTarget.setTooltip(new Tooltip("Move the selected entity to the current target.")); entityToTarget.setOnAction(e -> withEntity(player -> { - Point3 target = scene.getTargetPosition(); + Vector3 target = scene.getTargetPosition(); if (target != null) { player.position.set(target); updatePositionFields(player); @@ -670,7 +669,7 @@ public void initialize(URL location, ResourceBundle resources) { })); faceTarget.setTooltip(new Tooltip("Makes the selected player look at the current view target.")); faceTarget.setOnAction(e -> withEntity(entity -> { - Point3 target = scene.getTargetPosition(); + Vector3 target = scene.getTargetPosition(); if (target != null && entity instanceof Poseable) { Poseable player = (Poseable) entity; player.lookAt(target); diff --git a/chunky/src/java/se/llbit/chunky/world/Dimension.java b/chunky/src/java/se/llbit/chunky/world/Dimension.java index 9ce37459aa..6bb5bb7fba 100644 --- a/chunky/src/java/se/llbit/chunky/world/Dimension.java +++ b/chunky/src/java/se/llbit/chunky/world/Dimension.java @@ -13,7 +13,6 @@ import se.llbit.chunky.world.listeners.ChunkTopographyListener; import se.llbit.chunky.world.listeners.ChunkUpdateListener; import se.llbit.chunky.world.region.*; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.math.Vector3i; import se.llbit.util.annotation.Nullable; @@ -187,10 +186,10 @@ public synchronized File getRegionDirectory() { * *

The result is empty if this is not a single player world. */ - public synchronized Optional getPlayerPos() { + public synchronized Optional getPlayerPos() { if (!playerEntities.isEmpty()) { PlayerEntityData pos = playerEntities.iterator().next(); - return Optional.of(new Point3(pos.x, pos.y, pos.z)); + return Optional.of(new Vector3(pos.x, pos.y, pos.z)); } else { return Optional.empty(); } diff --git a/chunky/src/java/se/llbit/math/Matrix3.java b/chunky/src/java/se/llbit/math/Matrix3.java index e36ab34e69..0bf50b5c1d 100644 --- a/chunky/src/java/se/llbit/math/Matrix3.java +++ b/chunky/src/java/se/llbit/math/Matrix3.java @@ -105,14 +105,6 @@ public final void rotate(double pitch, double yaw, double roll) { m33 = cosb * cosc; } - /** - * Transform a point using this matrix. - */ - public void transform(Point3 o) { - o.set(m11 * o.x + m12 * o.y + m13 * o.z, m21 * o.x + m22 * o.y + m23 * o.z, - m31 * o.x + m32 * o.y + m33 * o.z); - } - /** * Transform a vector using this matrix. */ diff --git a/chunky/src/java/se/llbit/math/Octree.java b/chunky/src/java/se/llbit/math/Octree.java index ee968f133c..9afb8cd8e0 100644 --- a/chunky/src/java/se/llbit/math/Octree.java +++ b/chunky/src/java/se/llbit/math/Octree.java @@ -328,7 +328,7 @@ public static Octree load(String impl, DataInputStream in) throws IOException { * @param o vector * @return {@code true} if the vector is inside the octree */ - public boolean isInside(Point3 o) { + public boolean isInside(Vector3 o) { int depth = implementation.getDepth(); int x = (int) QuickMath.floor(o.x); diff --git a/chunky/src/java/se/llbit/math/Point3.java b/chunky/src/java/se/llbit/math/Point3.java deleted file mode 100644 index 38210034d7..0000000000 --- a/chunky/src/java/se/llbit/math/Point3.java +++ /dev/null @@ -1,99 +0,0 @@ -package se.llbit.math; - -import se.llbit.json.JsonObject; - -public class Point3 extends Tuple3 { - - public Point3(Point3 point) { - this.x = point.x; - this.y = point.y; - this.z = point.z; - } - - public Point3(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; - } - - public Point3(double a) { - this.x = a; - this.y = a; - this.z = a; - } - - /** - * Creates a new point at (0, 0, 0). - */ - public Point3() { - this.x = 0d; - this.y = 0d; - this.z = 0d; - } - - public void add(Tuple3 vector) { - this.x += vector.x; - this.y += vector.y; - this.z += vector.z; - } - - public void scaleAdd(double scalar, Vector3 vector) { - this.x += vector.x * scalar; - this.y += vector.y * scalar; - this.z += vector.z * scalar; - } - - public void add(double x, double y, double z) { - this.x += x; - this.y += y; - this.z += z; - } - - public void sub(Point3 point) { - this.x -= point.x; - this.y -= point.y; - this.z -= point.z; - } - - public Vector3 vSub(Point3 point) { - return new Vector3(x - point.x, y - point.y, z - point.z); - } - - public Vector3 asVector() { - return new Vector3(x, y, z); - } - - public void set(Point3 point) { - this.x = point.x; - this.y = point.y; - this.z = point.z; - } - - public void set(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; - } - - /** - * Unmarshals a point from JSON. - */ - public void fromJson(JsonObject object) { - x = object.get("x").doubleValue(0); - y = object.get("y").doubleValue(0); - z = object.get("z").doubleValue(0); - } - - /** - * Serialize to JSON - * - * @return JSON object - */ - public JsonObject toJson() { - JsonObject object = new JsonObject(); - object.add("x", x); - object.add("y", y); - object.add("z", z); - return object; - } -} diff --git a/chunky/src/java/se/llbit/math/Point3i.java b/chunky/src/java/se/llbit/math/Point3i.java deleted file mode 100644 index 8f9197821e..0000000000 --- a/chunky/src/java/se/llbit/math/Point3i.java +++ /dev/null @@ -1,88 +0,0 @@ -package se.llbit.math; - -import se.llbit.json.JsonObject; - -public class Point3i { - public int x; - public int y; - public int z; - - public Point3i(Point3i point) { - this.x = point.x; - this.y = point.y; - this.z = point.z; - } - - public Point3i(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public Point3i(int a) { - this.x = a; - this.y = a; - this.z = a; - } - - /** - * Creates a new point at (0, 0, 0). - */ - public Point3i() { - this.x = 0; - this.y = 0; - this.z = 0; - } - - public void add(Point3i point) { - this.x += point.x; - this.y += point.y; - this.z += point.z; - } - - public void add(Vector3i vector) { - this.x += vector.x; - this.y += vector.y; - this.z += vector.z; - } - - public void sub(Point3i point) { - this.x -= point.x; - this.y -= point.y; - this.z -= point.z; - } - - public void set(Point3i point) { - this.x = point.x; - this.y = point.y; - this.z = point.z; - } - - public void set(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - /** - * Unmarshals a point from JSON. - */ - public void fromJson(JsonObject object) { - x = object.get("x").intValue(0); - y = object.get("y").intValue(0); - z = object.get("z").intValue(0); - } - - /** - * Serialize to JSON - * - * @return JSON object - */ - public JsonObject toJson() { - JsonObject object = new JsonObject(); - object.add("x", x); - object.add("y", y); - object.add("z", z); - return object; - } -} diff --git a/chunky/src/java/se/llbit/math/Ray2.java b/chunky/src/java/se/llbit/math/Ray2.java index d30c82c79c..39d62cd4a0 100644 --- a/chunky/src/java/se/llbit/math/Ray2.java +++ b/chunky/src/java/se/llbit/math/Ray2.java @@ -4,12 +4,12 @@ import se.llbit.chunky.world.Material; public class Ray2 { - public Point3 o; + public Vector3 o; public Vector3 d; private Material currentMedium; public Ray2() { - o = new Point3(); + o = new Vector3(); d = new Vector3(); currentMedium = Air.INSTANCE; } diff --git a/chunky/src/java/se/llbit/math/Tuple3.java b/chunky/src/java/se/llbit/math/Tuple3.java deleted file mode 100644 index 3ed3366004..0000000000 --- a/chunky/src/java/se/llbit/math/Tuple3.java +++ /dev/null @@ -1,7 +0,0 @@ -package se.llbit.math; - -public abstract class Tuple3 { - public double x; - public double y; - public double z; -} diff --git a/chunky/src/java/se/llbit/math/Vector3.java b/chunky/src/java/se/llbit/math/Vector3.java index 5a1cff4bff..ced446d3ae 100644 --- a/chunky/src/java/se/llbit/math/Vector3.java +++ b/chunky/src/java/se/llbit/math/Vector3.java @@ -25,7 +25,10 @@ * * @author Jesper Öqvist */ -public class Vector3 extends Tuple3 { +public class Vector3 { + public double x; + public double y; + public double z; /** * Creates a new vector (0, 0, 0). @@ -80,7 +83,7 @@ public final double dot(Vector3 o) { /** * Set this vector equal to a-b. */ - public final void sub(Tuple3 a, Tuple3 b) { + public final void sub(Vector3 a, Vector3 b) { x = a.x - b.x; y = a.y - b.y; z = a.z - b.z; @@ -131,7 +134,7 @@ public final void normalize() { /** * Set this vector equal to s*d + o. */ - public final void scaleAdd(double s, Vector3 d, Tuple3 o) { + public final void scaleAdd(double s, Vector3 d, Vector3 o) { x = s * d.x + o.x; y = s * d.y + o.y; z = s * d.z + o.z; diff --git a/chunky/src/java/se/llbit/math/primitive/MutableAABB.java b/chunky/src/java/se/llbit/math/primitive/MutableAABB.java index 1af26077e2..08dfbd9180 100644 --- a/chunky/src/java/se/llbit/math/primitive/MutableAABB.java +++ b/chunky/src/java/se/llbit/math/primitive/MutableAABB.java @@ -19,7 +19,6 @@ import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; import se.llbit.math.AABB; -import se.llbit.math.Point3; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -122,7 +121,7 @@ public boolean hitTest(Ray ray) { double tNear = Double.NEGATIVE_INFINITY; double tFar = Double.POSITIVE_INFINITY; Vector3 d = ray.d; - Point3 o = ray.o; + Vector3 o = ray.o; if (d.x != 0) { double rx = 1 / d.x; diff --git a/chunky/src/java/se/llbit/util/JsonUtil.java b/chunky/src/java/se/llbit/util/JsonUtil.java index 772175dc05..a90431dc19 100644 --- a/chunky/src/java/se/llbit/util/JsonUtil.java +++ b/chunky/src/java/se/llbit/util/JsonUtil.java @@ -21,7 +21,6 @@ import se.llbit.json.JsonArray; import se.llbit.json.JsonObject; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.QuickMath; import se.llbit.math.Vector3; import se.llbit.nbt.Tag; @@ -42,30 +41,6 @@ public static JsonArray listTagToJson(Tag tag) { return json; } - public static Point3 point3FromJsonArray(JsonValue json) { - JsonArray array = json.array(); - double x = array.size() >= 1 ? array.get(0).asDouble(0) : 0; - double y = array.size() >= 2 ? array.get(1).asDouble(0) : 0; - double z = array.size() >= 3 ? array.get(2).asDouble(0) : 0; - return new Point3(x, y, z); - } - - public static Point3 point3FromJsonObject(JsonValue json) { - JsonObject obj = json.object(); - double x = obj.get("x").asDouble(0); - double y = obj.get("y").asDouble(0); - double z = obj.get("z").asDouble(0); - return new Point3(x, y, z); - } - - public static JsonValue vec3ToJson(Point3 point) { - JsonArray array = new JsonArray(); - array.add(Json.of(point.x)); - array.add(Json.of(point.y)); - array.add(Json.of(point.z)); - return array; - } - public static Vector3 vec3FromJsonArray(JsonValue json) { JsonArray array = json.array(); double x = array.size() >= 1 ? array.get(0).asDouble(0) : 0; diff --git a/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java b/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java index b6cd141d4a..581bc0c776 100644 --- a/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java +++ b/chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java @@ -21,7 +21,6 @@ import se.llbit.json.Json; import se.llbit.json.JsonArray; import se.llbit.json.JsonValue; -import se.llbit.math.Point3; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -32,7 +31,7 @@ */ public class MarshallingTest { @Test public void testPlayer() { - PlayerEntity entity = new PlayerEntity("1234", new Point3(100, 200, 300)); + PlayerEntity entity = new PlayerEntity("1234", new Vector3(100, 200, 300)); JsonArray headPose = new JsonArray(); headPose.add(Json.of(33)); headPose.add(Json.of(66)); @@ -49,7 +48,7 @@ public class MarshallingTest { } @Test public void testArmorStand() { - ArmorStand entity = new ArmorStand(new Point3(100, 200, 300), new CompoundTag()); + ArmorStand entity = new ArmorStand(new Vector3(100, 200, 300), new CompoundTag()); JsonArray headPose = new JsonArray(); headPose.add(Json.of(33)); headPose.add(Json.of(66)); From 422d7e2c605cb515875dc12cf6ce10201b84f8dc Mon Sep 17 00:00:00 2001 From: Josiah Hillman <92183530+Peregrine05@users.noreply.github.com> Date: Fri, 31 May 2024 22:13:06 -0400 Subject: [PATCH 03/65] Just save changes --- chunky/src/java/se/llbit/chunky/world/MaterialType.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 chunky/src/java/se/llbit/chunky/world/MaterialType.java diff --git a/chunky/src/java/se/llbit/chunky/world/MaterialType.java b/chunky/src/java/se/llbit/chunky/world/MaterialType.java new file mode 100644 index 0000000000..fca2989ebf --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/world/MaterialType.java @@ -0,0 +1,4 @@ +package se.llbit.chunky.world; + +public enum MaterialType { +} From e39d23b0f1f8cfb7adc3875dff5915ac20ed5d80 Mon Sep 17 00:00:00 2001 From: Josiah Hillman <92183530+Peregrine05@users.noreply.github.com> Date: Fri, 31 May 2024 22:34:54 -0400 Subject: [PATCH 04/65] Save changes --- chunky/src/java/.gitattributes | 0 chunky/src/java/se/llbit/chunky/Plugin.java | 0 .../chunky/block/AbstractModelBlock.java | 5 + .../src/java/se/llbit/chunky/block/Block.java | 13 +- .../java/se/llbit/chunky/block/BlockFace.java | 0 .../se/llbit/chunky/block/BlockProvider.java | 0 .../java/se/llbit/chunky/block/BlockSpec.java | 0 .../llbit/chunky/block/FinalizationState.java | 0 .../FixedTopBottomRotatableTexturedBlock.java | 0 .../se/llbit/chunky/block/MinecraftBlock.java | 0 .../chunky/block/MinecraftBlockProvider.java | 0 .../block/MinecraftBlockTranslucent.java | 0 .../se/llbit/chunky/block/ModelBlock.java | 0 .../chunky/block/OctreeFinalizationState.java | 0 .../chunky/block/SolidNonOpaqueBlock.java | 0 .../se/llbit/chunky/block/TexturedBlock.java | 0 .../block/TopBottomOrientedTexturedBlock.java | 0 .../se/llbit/chunky/block/UntintedLeaves.java | 0 .../chunky/block/legacy/LegacyBlockUtils.java | 0 .../chunky/block/legacy/LegacyBlocks.java | 0 .../block/legacy/LegacyBlocksFinalizer.java | 0 .../legacy/LegacyMinecraftBlockProvider.java | 0 .../block/legacy/UnfinalizedLegacyBlock.java | 0 .../block/legacy/blocks/LegacyBanner.java | 0 .../chunky/block/legacy/blocks/LegacyBed.java | 0 .../block/legacy/blocks/LegacyChest.java | 0 .../legacy/blocks/LegacyChorusPlant.java | 0 .../legacy/blocks/LegacyCobblestoneWall.java | 0 .../block/legacy/blocks/LegacyDoorPart.java | 0 .../block/legacy/blocks/LegacyFence.java | 0 .../block/legacy/blocks/LegacyFenceGate.java | 0 .../block/legacy/blocks/LegacyFire.java | 0 .../block/legacy/blocks/LegacyFlowerPot.java | 0 .../block/legacy/blocks/LegacyGlassPane.java | 0 .../block/legacy/blocks/LegacyIronBars.java | 0 .../legacy/blocks/LegacyLargeFlower.java | 0 .../block/legacy/blocks/LegacyMelonStem.java | 0 .../legacy/blocks/LegacyNetherPortal.java | 0 .../legacy/blocks/LegacyPumpkinStem.java | 0 .../legacy/blocks/LegacyRedstoneWire.java | 0 .../block/legacy/blocks/LegacySkull.java | 0 .../blocks/LegacySnowCoverableBlock.java | 0 .../block/legacy/blocks/LegacyStairs.java | 0 .../block/legacy/blocks/LegacyTripwire.java | 0 .../block/legacy/blocks/LegacyVine.java | 0 .../block/legacy/blocks/LegacyWallBanner.java | 0 .../se/llbit/chunky/block/minecraft/Air.java | 0 .../block/minecraft/AmethystCluster.java | 0 .../llbit/chunky/block/minecraft/Anvil.java | 0 .../chunky/block/minecraft/AttachedStem.java | 0 .../llbit/chunky/block/minecraft/Azalea.java | 0 .../llbit/chunky/block/minecraft/Bamboo.java | 0 .../llbit/chunky/block/minecraft/Banner.java | 0 .../llbit/chunky/block/minecraft/Barrel.java | 0 .../llbit/chunky/block/minecraft/Beacon.java | 0 .../se/llbit/chunky/block/minecraft/Bed.java | 0 .../chunky/block/minecraft/Beetroots.java | 0 .../se/llbit/chunky/block/minecraft/Bell.java | 0 .../chunky/block/minecraft/BigDripleaf.java | 0 .../block/minecraft/BigDripleafStem.java | 0 .../chunky/block/minecraft/BlastFurnace.java | 0 .../chunky/block/minecraft/BrewingStand.java | 0 .../llbit/chunky/block/minecraft/Button.java | 0 .../llbit/chunky/block/minecraft/Cactus.java | 0 .../se/llbit/chunky/block/minecraft/Cake.java | 0 .../block/minecraft/CakeWithCandle.java | 0 .../minecraft/CalibratedSculkSensor.java | 0 .../chunky/block/minecraft/Campfire.java | 0 .../llbit/chunky/block/minecraft/Candle.java | 0 .../llbit/chunky/block/minecraft/Carpet.java | 0 .../llbit/chunky/block/minecraft/Carrots.java | 0 .../chunky/block/minecraft/Cauldron.java | 0 .../chunky/block/minecraft/CaveVines.java | 0 .../llbit/chunky/block/minecraft/Chain.java | 0 .../block/minecraft/ChainCommandBlock.java | 0 .../llbit/chunky/block/minecraft/Chest.java | 0 .../block/minecraft/ChiseledBookshelf.java | 0 .../chunky/block/minecraft/ChorusFlower.java | 0 .../chunky/block/minecraft/ChorusPlant.java | 0 .../llbit/chunky/block/minecraft/Cocoa.java | 0 .../chunky/block/minecraft/CommandBlock.java | 0 .../chunky/block/minecraft/Comparator.java | 0 .../chunky/block/minecraft/Composter.java | 0 .../llbit/chunky/block/minecraft/Conduit.java | 0 .../chunky/block/minecraft/CopperBulb.java | 0 .../chunky/block/minecraft/CoralFan.java | 0 .../llbit/chunky/block/minecraft/Crafter.java | 0 .../block/minecraft/DaylightDetector.java | 0 .../chunky/block/minecraft/DecoratedPot.java | 0 .../chunky/block/minecraft/Dispenser.java | 0 .../se/llbit/chunky/block/minecraft/Door.java | 0 .../chunky/block/minecraft/DragonEgg.java | 0 .../llbit/chunky/block/minecraft/Dropper.java | 0 .../block/minecraft/EnchantingTable.java | 0 .../chunky/block/minecraft/EndPortal.java | 0 .../block/minecraft/EndPortalFrame.java | 0 .../llbit/chunky/block/minecraft/EndRod.java | 0 .../chunky/block/minecraft/EnderChest.java | 0 .../chunky/block/minecraft/Farmland.java | 0 .../llbit/chunky/block/minecraft/Fence.java | 0 .../chunky/block/minecraft/FenceGate.java | 0 .../se/llbit/chunky/block/minecraft/Fern.java | 0 .../se/llbit/chunky/block/minecraft/Fire.java | 0 .../chunky/block/minecraft/FlowerPot.java | 0 .../chunky/block/minecraft/Frogspawn.java | 0 .../chunky/block/minecraft/FrostedIce.java | 0 .../llbit/chunky/block/minecraft/Furnace.java | 0 .../llbit/chunky/block/minecraft/Glass.java | 0 .../chunky/block/minecraft/GlassPane.java | 0 .../block/minecraft/GlazedTerracotta.java | 0 .../chunky/block/minecraft/GlowLichen.java | 0 .../llbit/chunky/block/minecraft/Grass.java | 0 .../chunky/block/minecraft/GrassBlock.java | 0 .../chunky/block/minecraft/GrassPath.java | 0 .../chunky/block/minecraft/Grindstone.java | 0 .../chunky/block/minecraft/HangingSign.java | 0 .../se/llbit/chunky/block/minecraft/Head.java | 0 .../llbit/chunky/block/minecraft/Honey.java | 16 +- .../llbit/chunky/block/minecraft/Hopper.java | 0 .../chunky/block/minecraft/IronBars.java | 0 .../chunky/block/minecraft/JigsawBlock.java | 0 .../llbit/chunky/block/minecraft/Ladder.java | 0 .../llbit/chunky/block/minecraft/Lantern.java | 0 .../chunky/block/minecraft/LargeFern.java | 0 .../se/llbit/chunky/block/minecraft/Lava.java | 2 +- .../chunky/block/minecraft/LavaCauldron.java | 0 .../llbit/chunky/block/minecraft/Leaves.java | 0 .../llbit/chunky/block/minecraft/Lectern.java | 0 .../llbit/chunky/block/minecraft/Lever.java | 0 .../chunky/block/minecraft/LightBlock.java | 0 .../chunky/block/minecraft/LightningRod.java | 0 .../llbit/chunky/block/minecraft/LilyPad.java | 0 .../se/llbit/chunky/block/minecraft/Log.java | 0 .../block/minecraft/MangrovePropagule.java | 0 .../chunky/block/minecraft/MangroveRoots.java | 0 .../chunky/block/minecraft/NetherPortal.java | 0 .../chunky/block/minecraft/NetherWart.java | 0 .../chunky/block/minecraft/Observer.java | 0 .../chunky/block/minecraft/PinkPetals.java | 0 .../llbit/chunky/block/minecraft/Piston.java | 0 .../chunky/block/minecraft/PistonHead.java | 0 .../chunky/block/minecraft/PitcherCrop.java | 0 .../chunky/block/minecraft/PitcherPlant.java | 0 .../block/minecraft/PointedDripstone.java | 0 .../chunky/block/minecraft/Potatoes.java | 0 .../block/minecraft/PowderSnowCauldron.java | 0 .../chunky/block/minecraft/PressurePlate.java | 0 .../se/llbit/chunky/block/minecraft/Rail.java | 0 .../chunky/block/minecraft/RedstoneLamp.java | 0 .../chunky/block/minecraft/RedstoneTorch.java | 0 .../block/minecraft/RedstoneWallTorch.java | 0 .../chunky/block/minecraft/RedstoneWire.java | 0 .../chunky/block/minecraft/Repeater.java | 0 .../minecraft/RepeatingCommandBlock.java | 0 .../chunky/block/minecraft/RespawnAnchor.java | 0 .../chunky/block/minecraft/Scaffolding.java | 0 .../chunky/block/minecraft/SculkCatalyst.java | 0 .../chunky/block/minecraft/SculkSensor.java | 0 .../chunky/block/minecraft/SculkShrieker.java | 0 .../chunky/block/minecraft/SculkVein.java | 0 .../chunky/block/minecraft/SeaPickle.java | 0 .../chunky/block/minecraft/ShulkerBox.java | 0 .../se/llbit/chunky/block/minecraft/Sign.java | 0 .../se/llbit/chunky/block/minecraft/Slab.java | 0 .../llbit/chunky/block/minecraft/Slime.java | 17 +- .../chunky/block/minecraft/SmallDripleaf.java | 0 .../llbit/chunky/block/minecraft/Smoker.java | 0 .../chunky/block/minecraft/SnifferEgg.java | 0 .../se/llbit/chunky/block/minecraft/Snow.java | 0 .../chunky/block/minecraft/SoulFire.java | 0 .../chunky/block/minecraft/SporeBlossom.java | 0 .../chunky/block/minecraft/SpriteBlock.java | 0 .../llbit/chunky/block/minecraft/Stairs.java | 0 .../se/llbit/chunky/block/minecraft/Stem.java | 0 .../chunky/block/minecraft/Stonecutter.java | 0 .../chunky/block/minecraft/SugarCane.java | 0 .../chunky/block/minecraft/Sunflower.java | 0 .../block/minecraft/SweetBerryBush.java | 0 .../chunky/block/minecraft/TallGrass.java | 0 .../chunky/block/minecraft/TintedGlass.java | 0 .../llbit/chunky/block/minecraft/Torch.java | 0 .../block/minecraft/TorchflowerCrop.java | 0 .../chunky/block/minecraft/Trapdoor.java | 0 .../chunky/block/minecraft/Tripwire.java | 0 .../chunky/block/minecraft/TripwireHook.java | 0 .../chunky/block/minecraft/TurtleEgg.java | 0 .../chunky/block/minecraft/UnknownBlock.java | 0 .../se/llbit/chunky/block/minecraft/Vine.java | 0 .../se/llbit/chunky/block/minecraft/Wall.java | 0 .../chunky/block/minecraft/WallBanner.java | 0 .../chunky/block/minecraft/WallCoralFan.java | 0 .../block/minecraft/WallHangingSign.java | 0 .../chunky/block/minecraft/WallHead.java | 0 .../chunky/block/minecraft/WallSign.java | 0 .../chunky/block/minecraft/WallTorch.java | 0 .../llbit/chunky/block/minecraft/Water.java | 34 +- .../llbit/chunky/block/minecraft/Wheat.java | 0 .../se/llbit/chunky/chunk/BlockPalette.java | 39 +- .../java/se/llbit/chunky/chunk/ChunkData.java | 0 .../chunky/chunk/ChunkLoadingException.java | 0 .../se/llbit/chunky/chunk/EmptyChunkData.java | 0 .../llbit/chunky/chunk/GenericChunkData.java | 0 .../llbit/chunky/chunk/SimpleChunkData.java | 0 .../llbit/chunky/chunk/TagBlockBuilder.java | 0 .../llbit/chunky/chunk/biome/BiomeData.java | 0 .../llbit/chunky/chunk/biome/BiomeData2d.java | 0 .../chunky/chunk/biome/BiomeDataFactory.java | 0 .../chunk/biome/GenericQuartBiomeData3d.java | 0 .../chunky/chunk/biome/QuartBiomeData3d.java | 0 .../chunky/chunk/biome/UnknownBiomeData.java | 0 .../se/llbit/chunky/entity/ArmorStand.java | 0 .../java/se/llbit/chunky/entity/Armored.java | 0 .../se/llbit/chunky/entity/BeaconBeam.java | 0 .../src/java/se/llbit/chunky/entity/Book.java | 0 .../entity/CalibratedSculkSensorAmethyst.java | 0 .../java/se/llbit/chunky/entity/Campfire.java | 0 .../llbit/chunky/entity/CoralFanEntity.java | 0 .../java/se/llbit/chunky/entity/Entity.java | 0 .../llbit/chunky/entity/FlameParticles.java | 0 .../java/se/llbit/chunky/entity/Geared.java | 0 .../chunky/entity/HangingSignEntity.java | 0 .../se/llbit/chunky/entity/HeadEntity.java | 0 .../java/se/llbit/chunky/entity/Lectern.java | 0 .../se/llbit/chunky/entity/LilyPadEntity.java | 0 .../llbit/chunky/entity/PaintingEntity.java | 0 .../se/llbit/chunky/entity/PlayerEntity.java | 0 .../java/se/llbit/chunky/entity/Poseable.java | 0 .../se/llbit/chunky/entity/SignEntity.java | 0 .../se/llbit/chunky/entity/SkullEntity.java | 0 .../se/llbit/chunky/entity/SporeBlossom.java | 0 .../llbit/chunky/entity/StandingBanner.java | 0 .../se/llbit/chunky/entity/UVMapHelper.java | 0 .../se/llbit/chunky/entity/WallBanner.java | 0 .../chunky/entity/WallCoralFanEntity.java | 0 .../chunky/entity/WallHangingSignEntity.java | 0 .../llbit/chunky/entity/WallSignEntity.java | 0 .../src/java/se/llbit/chunky/main/Chunky.java | 4 +- .../se/llbit/chunky/main/ChunkyOptions.java | 0 .../llbit/chunky/main/CommandLineOptions.java | 0 .../main/HeadlessErrorTrackingLogger.java | 0 .../se/llbit/chunky/main/SceneHelper.java | 0 .../java/se/llbit/chunky/main/Version.java | 0 .../se/llbit/chunky/main/ZipExportJob.java | 0 .../se/llbit/chunky/map/AbstractLayer.java | 0 .../java/se/llbit/chunky/map/BiomeLayer.java | 0 .../java/se/llbit/chunky/map/BitmapLayer.java | 0 .../java/se/llbit/chunky/map/IconLayer.java | 0 .../java/se/llbit/chunky/map/MapBuffer.java | 0 .../src/java/se/llbit/chunky/map/MapTile.java | 0 .../src/java/se/llbit/chunky/map/MapView.java | 0 .../se/llbit/chunky/map/SurfaceLayer.java | 0 .../se/llbit/chunky/map/WorldMapLoader.java | 0 .../java/se/llbit/chunky/model/AABBModel.java | 43 +- .../llbit/chunky/model/AnimatedQuadModel.java | 49 +- .../se/llbit/chunky/model/BlockModel.java | 8 +- .../chunky/model/DirectionalBlockModel.java | 0 ...dTopBottomRotatableTexturedBlockModel.java | 0 .../chunky/model/GrassTintedSpriteModel.java | 0 .../src/java/se/llbit/chunky/model/Model.java | 0 .../java/se/llbit/chunky/model/QuadModel.java | 74 ++- .../chunky/model/RotatableBlockModel.java | 0 .../chunky/model/TexturedBlockModel.java | 0 .../src/java/se/llbit/chunky/model/Tint.java | 18 +- .../TopBottomOrientedTexturedBlockModel.java | 0 .../chunky/model/minecraft/AnvilModel.java | 0 .../model/minecraft/AttachedStemModel.java | 0 .../chunky/model/minecraft/AzaleaModel.java | 0 .../chunky/model/minecraft/BambooModel.java | 0 .../chunky/model/minecraft/BarrelModel.java | 1 + .../chunky/model/minecraft/BeaconModel.java | 6 + .../chunky/model/minecraft/BedModel.java | 0 .../chunky/model/minecraft/BellModel.java | 0 .../model/minecraft/BigDripleafModel.java | 0 .../model/minecraft/BigDripleafStemModel.java | 0 .../model/minecraft/BrewingStandModel.java | 0 .../chunky/model/minecraft/ButtonModel.java | 2 + .../chunky/model/minecraft/CactusModel.java | 0 .../chunky/model/minecraft/CakeModel.java | 61 +- .../model/minecraft/CakeWithCandleModel.java | 0 .../minecraft/CalibratedSculkSensorModel.java | 0 .../chunky/model/minecraft/CandleModel.java | 0 .../chunky/model/minecraft/CarpetModel.java | 0 .../chunky/model/minecraft/CauldronModel.java | 16 +- .../chunky/model/minecraft/ChainModel.java | 0 .../chunky/model/minecraft/ChestModel.java | 0 .../model/minecraft/ChorusFlowerModel.java | 0 .../model/minecraft/ChorusPlantModel.java | 0 .../model/minecraft/CocoaPlantModel.java | 0 .../model/minecraft/ComparatorModel.java | 0 .../model/minecraft/ComposterModel.java | 0 .../chunky/model/minecraft/ConduitModel.java | 4 + .../chunky/model/minecraft/CropsModel.java | 0 .../model/minecraft/DaylightSensorModel.java | 0 .../model/minecraft/DecoratedPotModel.java | 0 .../model/minecraft/DispenserModel.java | 0 .../chunky/model/minecraft/DoorModel.java | 0 .../model/minecraft/DragonEggModel.java | 0 .../minecraft/EnchantmentTableModel.java | 0 .../model/minecraft/EndPortalFrameModel.java | 0 .../model/minecraft/EndPortalModel.java | 0 .../chunky/model/minecraft/EndRodModel.java | 0 .../model/minecraft/FenceGateModel.java | 0 .../chunky/model/minecraft/FenceModel.java | 0 .../chunky/model/minecraft/FireModel.java | 0 .../model/minecraft/FlowerPotModel.java | 0 .../chunky/model/minecraft/Flowerbed.java | 0 .../model/minecraft/FrogspawnModel.java | 0 .../model/minecraft/GlassPaneModel.java | 92 ++- .../model/minecraft/GlowLichenModel.java | 0 .../model/minecraft/GrassBlockModel.java | 60 +- .../model/minecraft/GrassPathModel.java | 0 .../model/minecraft/GrindstoneModel.java | 0 .../model/minecraft/HoneyBlockModel.java | 215 ++++--- .../chunky/model/minecraft/HopperModel.java | 0 .../chunky/model/minecraft/IronBarsModel.java | 0 .../chunky/model/minecraft/JigsawModel.java | 1 + .../chunky/model/minecraft/LadderModel.java | 0 .../chunky/model/minecraft/LanternModel.java | 0 .../chunky/model/minecraft/LeafModel.java | 0 .../chunky/model/minecraft/LeverModel.java | 0 .../model/minecraft/LightBlockModel.java | 0 .../model/minecraft/LightningRodModel.java | 0 .../chunky/model/minecraft/LogModel.java | 1 + .../minecraft/MangrovePropaguleModel.java | 0 .../model/minecraft/MangroveRootsModel.java | 0 .../model/minecraft/NetherPortalModel.java | 0 .../chunky/model/minecraft/ObserverModel.java | 1 + .../model/minecraft/PistonExtensionModel.java | 0 .../chunky/model/minecraft/PistonModel.java | 0 .../minecraft/PitcherCropBottomModel.java | 0 .../model/minecraft/PitcherCropTopModel.java | 0 .../minecraft/PitcherPlantBottomModel.java | 0 .../model/minecraft/PitcherPlantTopModel.java | 0 .../model/minecraft/PressurePlateModel.java | 1 + .../chunky/model/minecraft/RailModel.java | 0 .../minecraft/RedstoneRepeaterModel.java | 0 .../model/minecraft/RedstoneWireModel.java | 0 .../model/minecraft/ScaffoldingModel.java | 0 .../model/minecraft/SculkSensorModel.java | 0 .../model/minecraft/SculkShriekerModel.java | 0 .../model/minecraft/SculkVeinModel.java | 0 .../model/minecraft/SeaPickleModel.java | 0 .../chunky/model/minecraft/SlabModel.java | 0 .../model/minecraft/SlimeBlockModel.java | 219 ++++--- .../model/minecraft/SmallDripleafModel.java | 0 .../model/minecraft/SnifferEggModel.java | 1 + .../chunky/model/minecraft/SnowModel.java | 0 .../model/minecraft/SporeBlossomModel.java | 0 .../chunky/model/minecraft/SpriteModel.java | 6 +- .../chunky/model/minecraft/StairModel.java | 0 .../chunky/model/minecraft/StemModel.java | 0 .../model/minecraft/StonecutterModel.java | 0 .../model/minecraft/SunFlowerModel.java | 0 .../model/minecraft/TerracottaModel.java | 1 + .../chunky/model/minecraft/TorchModel.java | 0 .../chunky/model/minecraft/TrapdoorModel.java | 0 .../model/minecraft/TripwireHookModel.java | 0 .../chunky/model/minecraft/TripwireModel.java | 0 .../model/minecraft/TurtleEggModel.java | 1 + .../chunky/model/minecraft/VineModel.java | 0 .../chunky/model/minecraft/WallModel.java | 0 .../chunky/model/minecraft/WaterModel.java | 2 +- .../se/llbit/chunky/plugin/ChunkyPlugin.java | 0 .../chunky/plugin/ContextMenuTransformer.java | 0 .../se/llbit/chunky/plugin/PluginApi.java | 0 .../llbit/chunky/plugin/TabTransformer.java | 0 .../llbit/chunky/renderer/ApertureShape.java | 0 .../chunky/renderer/CameraViewListener.java | 0 .../chunky/renderer/ChunkViewListener.java | 0 .../renderer/ConsoleProgressListener.java | 0 .../chunky/renderer/DefaultRenderManager.java | 0 .../renderer/EmitterSamplingStrategy.java | 0 .../chunky/renderer/PathTracingRenderer.java | 0 .../se/llbit/chunky/renderer/Postprocess.java | 0 .../chunky/renderer/PreviewRenderer.java | 0 .../chunky/renderer/RayTracerFactory.java | 0 .../se/llbit/chunky/renderer/Refreshable.java | 0 .../llbit/chunky/renderer/RenderContext.java | 0 .../chunky/renderer/RenderContextFactory.java | 0 .../chunky/renderer/RenderController.java | 0 .../llbit/chunky/renderer/RenderManager.java | 0 .../chunky/renderer/RenderManagerFactory.java | 0 .../se/llbit/chunky/renderer/RenderMode.java | 0 .../llbit/chunky/renderer/RenderStatus.java | 0 .../chunky/renderer/RenderStatusListener.java | 0 .../chunky/renderer/RenderWorkerPool.java | 0 .../se/llbit/chunky/renderer/Renderer.java | 0 .../se/llbit/chunky/renderer/Repaintable.java | 0 .../se/llbit/chunky/renderer/ResetReason.java | 0 .../chunky/renderer/SceneIOProvider.java | 0 .../llbit/chunky/renderer/SceneProvider.java | 0 .../chunky/renderer/SceneStatusListener.java | 0 .../chunky/renderer/SnapshotControl.java | 0 .../chunky/renderer/SunSamplingStrategy.java | 0 .../chunky/renderer/TileBasedRenderer.java | 0 .../chunky/renderer/WaterShadingStrategy.java | 0 .../se/llbit/chunky/renderer/WorkerState.java | 0 .../renderer/export/PfmExportFormat.java | 0 .../renderer/export/PictureExportFormat.java | 0 .../renderer/export/PictureExportFormats.java | 0 .../renderer/export/PngExportFormat.java | 0 .../renderer/export/Tiff32ExportFormat.java | 0 .../postprocessing/ACESFilmicFilter.java | 0 .../postprocessing/GammaCorrectionFilter.java | 0 .../HableToneMappingFilter.java | 0 .../renderer/postprocessing/NoneFilter.java | 0 .../PixelPostProcessingFilter.java | 0 .../postprocessing/PostProcessingFilter.java | 0 .../postprocessing/PostProcessingFilters.java | 0 .../postprocessing/PreviewFilter.java | 0 .../SimplePixelPostProcessingFilter.java | 0 .../postprocessing/Tonemap1Filter.java | 0 .../postprocessing/UE4ToneMappingFilter.java | 0 .../projection/ApertureProjector.java | 0 .../renderer/projection/FisheyeProjector.java | 0 .../ForwardDisplacementProjector.java | 0 .../projection/PanoramicProjector.java | 0 .../projection/PanoramicSlotProjector.java | 0 .../projection/ParallelProjector.java | 0 .../renderer/projection/PinholeProjector.java | 0 .../renderer/projection/ProjectionMode.java | 0 .../chunky/renderer/projection/Projector.java | 0 .../renderer/projection/ShiftProjector.java | 0 .../SphericalApertureProjector.java | 0 .../projection/StereographicProjector.java | 0 .../stereo/ODSSinglePerspectiveProjector.java | 0 .../stereo/ODSVerticalStackedProjector.java | 0 .../OmniDirectionalStereoProjector.java | 0 .../renderdump/AbstractDumpFormat.java | 0 .../renderdump/ClassicDumpFormat.java | 0 .../renderer/renderdump/DumpFormat.java | 0 .../FloatingPointCompressorDumpFormat.java | 0 .../renderer/renderdump/GzipDumpFormat.java | 0 .../renderdump/HuffmanDumpFormat.java | 0 .../renderer/renderdump/PixelConsumer.java | 0 .../renderer/renderdump/RenderDump.java | 0 .../renderdump/UncompressedDumpFormat.java | 0 .../chunky/renderer/scene/AlphaBuffer.java | 0 .../scene/AsynchronousSceneManager.java | 0 .../llbit/chunky/renderer/scene/Camera.java | 0 .../chunky/renderer/scene/CameraPreset.java | 0 .../chunky/renderer/scene/ChunkFinalizer.java | 0 .../scene/EntityLoadingPreferences.java | 0 .../se/llbit/chunky/renderer/scene/Fog.java | 0 .../llbit/chunky/renderer/scene/FogLayer.java | 0 .../llbit/chunky/renderer/scene/FogMode.java | 0 .../renderer/scene/LegacyWaterShader.java | 0 .../chunky/renderer/scene/NishitaSky.java | 0 .../renderer/scene/OctreeFinalizer.java | 1 + .../chunky/renderer/scene/PathTracer.java | 24 +- .../chunky/renderer/scene/PlayerModel.java | 0 .../chunky/renderer/scene/PreethamSky.java | 0 .../renderer/scene/PreviewRayTracer.java | 19 +- .../chunky/renderer/scene/RayTracer.java | 0 .../renderer/scene/RenderResetHandler.java | 0 .../se/llbit/chunky/renderer/scene/Scene.java | 106 ++-- .../chunky/renderer/scene/SceneEntities.java | 0 .../chunky/renderer/scene/SceneFactory.java | 0 .../chunky/renderer/scene/SceneManager.java | 0 .../renderer/scene/SimplexWaterShader.java | 0 .../chunky/renderer/scene/SimulatedSky.java | 0 .../se/llbit/chunky/renderer/scene/Sky.java | 0 .../llbit/chunky/renderer/scene/SkyCache.java | 0 .../renderer/scene/StillWaterShader.java | 0 .../se/llbit/chunky/renderer/scene/Sun.java | 0 .../scene/SynchronousSceneManager.java | 0 .../chunky/renderer/scene/WaterShader.java | 0 .../renderer/scene/biome/BiomeStructure.java | 0 .../scene/biome/Trivial2dBiomeStructure.java | 0 .../scene/biome/Trivial3dBiomeStructure.java | 0 .../biome/WorldTexture2dBiomeStructure.java | 0 .../chunky/resources/AbstractHdriTexture.java | 0 .../chunky/resources/AnimatedTexture.java | 0 .../chunky/resources/BinaryBitmapImage.java | 0 .../llbit/chunky/resources/BitmapImage.java | 0 .../resources/ChiseledBookshelfTexture.java | 0 .../llbit/chunky/resources/EntityTexture.java | 0 .../se/llbit/chunky/resources/HDRTexture.java | 0 .../chunky/resources/OctreeFileFormat.java | 0 .../se/llbit/chunky/resources/PFMTexture.java | 0 .../resources/PalettizedBitmapImage.java | 0 .../llbit/chunky/resources/PlayerTexture.java | 0 .../resources/ResourcePackBiomeLoader.java | 0 .../chunky/resources/ResourcePackLoader.java | 0 .../resources/ResourcePackTextureLoader.java | 0 .../chunky/resources/ShulkerTexture.java | 0 .../llbit/chunky/resources/SignTexture.java | 0 .../chunky/resources/SolidColorTexture.java | 0 .../se/llbit/chunky/resources/Texture.java | 0 .../llbit/chunky/resources/TextureCache.java | 0 .../chunky/resources/TexturePackLoader.java | 0 .../resources/texturepack/AllTextures.java | 0 .../texturepack/AlternateTextures.java | 0 .../texturepack/AnimatedTextureLoader.java | 0 .../texturepack/AsciiFontTextureLoader.java | 0 .../texturepack/BedTextureAdapter.java | 0 .../resources/texturepack/ChestTexture.java | 0 .../resources/texturepack/CloudsTexture.java | 0 .../resources/texturepack/ColoredTexture.java | 0 .../texturepack/ConditionalTextures.java | 0 .../texturepack/EntityTextureLoader.java | 0 .../texturepack/FoliageColorTexture.java | 0 .../resources/texturepack/FontTexture.java | 0 .../texturepack/GrassColorTexture.java | 0 .../resources/texturepack/IndexedTexture.java | 0 .../texturepack/JsonFontTextureLoader.java | 0 .../texturepack/LargeChestTexture.java | 0 .../texturepack/LayeredTextureLoader.java | 0 .../texturepack/PaintingBackTexture.java | 0 .../texturepack/PaintingTexture.java | 0 .../texturepack/PaintingTextureAdapter.java | 0 .../texturepack/PlayerTextureLoader.java | 0 .../texturepack/RotatedTextureLoader.java | 0 .../texturepack/ShulkerTextureLoader.java | 0 .../resources/texturepack/SimpleTexture.java | 0 .../texturepack/SplitLargeChestTexture.java | 0 .../texturepack/TextureFormatError.java | 0 .../resources/texturepack/TextureLoader.java | 0 .../resources/texturepack/TexturePath.java | 0 .../src/java/se/llbit/chunky/ui/ChunkMap.java | 0 .../src/java/se/llbit/chunky/ui/ChunkyFx.java | 0 .../se/llbit/chunky/ui/HyperlinkMenuItem.java | 0 chunky/src/java/se/llbit/chunky/ui/Icons.java | 0 .../se/llbit/chunky/ui/ProgressTracker.java | 0 .../se/llbit/chunky/ui/RenderCanvasFx.java | 0 .../chunky/ui/TableSortConfigSerializer.java | 0 .../se/llbit/chunky/ui/UILogReceiver.java | 0 .../ui/controller/ChunkyFxController.java | 0 .../ui/controller/CreditsController.java | 0 .../RenderControlsFxController.java | 0 .../ResourcePackChooserController.java | 0 .../ui/controller/SceneChooserController.java | 0 .../ui/controller/WorldChooserController.java | 0 .../chunky/ui/dialogs/ChunkyErrorDialog.java | 0 .../se/llbit/chunky/ui/dialogs/Credits.java | 0 .../llbit/chunky/ui/dialogs/DialogUtils.java | 0 .../se/llbit/chunky/ui/dialogs/Poser.java | 0 .../ui/dialogs/ResourcePackChooser.java | 0 .../llbit/chunky/ui/dialogs/SceneChooser.java | 0 .../dialogs/SelectChunksInRadiusDialog.java | 0 .../chunky/ui/dialogs/SettingsExport.java | 0 .../chunky/ui/dialogs/ShutdownAlert.java | 0 .../ui/dialogs/ValidatingTextInputDialog.java | 0 .../llbit/chunky/ui/dialogs/WorldChooser.java | 0 .../chunky/ui/elements/AngleAdjuster.java | 0 .../chunky/ui/elements/GradientEditor.java | 0 .../llbit/chunky/ui/elements/SizeInput.java | 0 .../ui/elements/TextFieldLabelWrapper.java | 0 .../chunky/ui/render/RenderControlsTab.java | 0 .../render/RenderControlsTabTransformer.java | 0 .../render/settings/LayeredFogSettings.java | 0 .../ui/render/settings/SkyboxSettings.java | 0 .../ui/render/settings/SkymapSettings.java | 0 .../render/settings/UniformFogSettings.java | 0 .../chunky/ui/render/tabs/AdvancedTab.java | 0 .../chunky/ui/render/tabs/CameraTab.java | 0 .../chunky/ui/render/tabs/EntitiesTab.java | 0 .../chunky/ui/render/tabs/GeneralTab.java | 0 .../llbit/chunky/ui/render/tabs/HelpTab.java | 0 .../chunky/ui/render/tabs/LightingTab.java | 0 .../chunky/ui/render/tabs/MaterialsTab.java | 14 +- .../ui/render/tabs/PostprocessingTab.java | 0 .../llbit/chunky/ui/render/tabs/SkyTab.java | 0 .../chunky/ui/render/tabs/TexturesTab.java | 0 .../llbit/chunky/ui/render/tabs/WaterTab.java | 0 .../java/se/llbit/chunky/world/BlockData.java | 0 .../src/java/se/llbit/chunky/world/Chunk.java | 0 .../llbit/chunky/world/ChunkDataSource.java | 0 .../se/llbit/chunky/world/ChunkHeightmap.java | 0 .../se/llbit/chunky/world/ChunkPosition.java | 0 .../chunky/world/ChunkSelectionListener.java | 0 .../chunky/world/ChunkSelectionTracker.java | 0 .../se/llbit/chunky/world/ChunkTexture.java | 0 .../chunky/world/ChunkTopographyUpdater.java | 0 .../se/llbit/chunky/world/ChunkVersion.java | 0 .../java/se/llbit/chunky/world/ChunkView.java | 0 .../java/se/llbit/chunky/world/Clouds.java | 0 .../se/llbit/chunky/world/CubicDimension.java | 0 .../java/se/llbit/chunky/world/Dimension.java | 0 .../se/llbit/chunky/world/EmptyChunk.java | 0 .../se/llbit/chunky/world/EmptyDimension.java | 0 .../llbit/chunky/world/EmptyRegionChunk.java | 0 .../se/llbit/chunky/world/EmptyWorld.java | 0 .../se/llbit/chunky/world/ExtraMaterials.java | 0 .../java/se/llbit/chunky/world/Heightmap.java | 0 .../src/java/se/llbit/chunky/world/Icon.java | 0 .../chunky/world/ImposterCubicChunk.java | 0 .../java/se/llbit/chunky/world/Material.java | 329 ++++++++-- .../se/llbit/chunky/world/MaterialStore.java | 0 .../se/llbit/chunky/world/MaterialType.java | 31 +- .../llbit/chunky/world/PlayerEntityData.java | 0 .../se/llbit/chunky/world/SkymapTexture.java | 0 .../src/java/se/llbit/chunky/world/World.java | 0 .../se/llbit/chunky/world/WorldScanner.java | 0 .../se/llbit/chunky/world/WorldTexture.java | 0 .../chunky/world/biome/ArrayBiomePalette.java | 0 .../se/llbit/chunky/world/biome/Biome.java | 0 .../chunky/world/biome/BiomeBuilder.java | 0 .../chunky/world/biome/BiomePalette.java | 0 .../se/llbit/chunky/world/biome/Biomes.java | 0 .../chunky/world/biome/MapBiomePalette.java | 0 .../listeners/ChunkDeletionListener.java | 0 .../listeners/ChunkTopographyListener.java | 0 .../world/listeners/ChunkUpdateListener.java | 0 .../world/material/BeaconBeamMaterial.java | 0 .../chunky/world/material/CloudMaterial.java | 0 .../world/material/LilyPadMaterial.java | 0 .../world/material/TextureMaterial.java | 0 .../se/llbit/chunky/world/model/Cube.java | 0 .../llbit/chunky/world/model/CubeModel.java | 0 .../se/llbit/chunky/world/model/Face.java | 0 .../llbit/chunky/world/model/JsonModel.java | 0 .../world/region/ChunkReadException.java | 0 .../chunky/world/region/EmptyRegion.java | 0 .../world/region/ImposterCubicRegion.java | 0 .../llbit/chunky/world/region/MCRegion.java | 0 .../world/region/MCRegionChangeWatcher.java | 0 .../se/llbit/chunky/world/region/Region.java | 0 .../world/region/RegionChangeWatcher.java | 0 .../chunky/world/region/RegionParser.java | 0 .../chunky/world/region/RegionQueue.java | 0 .../se/llbit/fxutil/ColumnsBoxBuilder.java | 0 chunky/src/java/se/llbit/fxutil/Dialogs.java | 0 .../src/java/se/llbit/fxutil/FxImageUtil.java | 0 .../llbit/fxutil/GroupedChangeListener.java | 0 .../llbit/imageformats/pfm/PfmFileWriter.java | 0 .../imageformats/png/CrcOutputStream.java | 0 .../java/se/llbit/imageformats/png/IDAT.java | 0 .../java/se/llbit/imageformats/png/IEND.java | 0 .../java/se/llbit/imageformats/png/IHDR.java | 0 .../java/se/llbit/imageformats/png/ITXT.java | 0 .../se/llbit/imageformats/png/PngChunk.java | 0 .../llbit/imageformats/png/PngFileWriter.java | 0 .../se/llbit/imageformats/tiff/BasicIFD.java | 0 .../imageformats/tiff/CompressionType.java | 0 .../tiff/FinalizableBFCOutputStream.java | 0 .../se/llbit/imageformats/tiff/IFDTag.java | 0 .../imageformats/tiff/ImageFileDirectory.java | 0 .../imageformats/tiff/TiffFileWriter.java | 0 chunky/src/java/se/llbit/math/AABB.java | 58 +- .../java/se/llbit/math/BigPackedOctree.java | 0 chunky/src/java/se/llbit/math/ColorUtil.java | 0 chunky/src/java/se/llbit/math/Constants.java | 0 chunky/src/java/se/llbit/math/Grid.java | 0 .../src/java/se/llbit/math/Intersectable.java | 0 .../se/llbit/math/IntersectionRecord.java | 12 +- chunky/src/java/se/llbit/math/Matrix3.java | 0 .../java/se/llbit/math/NodeBasedOctree.java | 0 chunky/src/java/se/llbit/math/Octree.java | 231 ++++--- .../src/java/se/llbit/math/OctreeVisitor.java | 0 .../src/java/se/llbit/math/PackedOctree.java | 0 chunky/src/java/se/llbit/math/Quad.java | 0 chunky/src/java/se/llbit/math/Ray.java | 0 chunky/src/java/se/llbit/math/Ray2.java | 14 +- .../src/java/se/llbit/math/SimplexNoise.java | 0 chunky/src/java/se/llbit/math/Transform.java | 0 chunky/src/java/se/llbit/math/Triangle.java | 0 chunky/src/java/se/llbit/math/Vector2.java | 2 +- chunky/src/java/se/llbit/math/Vector3.java | 107 +++- chunky/src/java/se/llbit/math/Vector3i.java | 0 chunky/src/java/se/llbit/math/Vector4.java | 0 chunky/src/java/se/llbit/math/bvh/BVH.java | 0 .../src/java/se/llbit/math/bvh/BinaryBVH.java | 0 .../java/se/llbit/math/bvh/MidpointBVH.java | 0 chunky/src/java/se/llbit/math/bvh/SahBVH.java | 0 .../src/java/se/llbit/math/bvh/SahMaBVH.java | 0 .../src/java/se/llbit/math/primitive/Box.java | 0 .../se/llbit/math/primitive/MutableAABB.java | 0 .../se/llbit/math/primitive/Primitive.java | 0 .../math/primitive/TexturedTriangle.java | 2 +- .../structures/Position2IntStructure.java | 0 .../Position2ReferenceStructure.java | 0 .../structures/Position2d2IntPackedArray.java | 0 ...ition2d2ReferencePackedArrayStructure.java | 0 .../structures/Position3d2IntPackedArray.java | 0 ...ition3d2ReferencePackedArrayStructure.java | 0 .../java/se/llbit/resources/ImageLoader.java | 0 chunky/src/java/se/llbit/util/BitBuffer.java | 0 .../src/java/se/llbit/util/Configurable.java | 0 chunky/src/java/se/llbit/util/ImageTools.java | 0 .../java/se/llbit/util/JsonSerializable.java | 0 chunky/src/java/se/llbit/util/JsonUtil.java | 0 .../src/java/se/llbit/util/MinecraftPRNG.java | 0 .../src/java/se/llbit/util/MinecraftText.java | 0 chunky/src/java/se/llbit/util/NbtUtil.java | 0 .../java/se/llbit/util/ProgressListener.java | 0 .../src/java/se/llbit/util/Registerable.java | 0 chunky/src/java/se/llbit/util/RingBuffer.java | 0 chunky/src/java/se/llbit/util/StringUtil.java | 0 .../src/java/se/llbit/util/TaskTracker.java | 0 chunky/src/java/se/llbit/util/VectorUtil.java | 2 +- .../se/llbit/util/annotation/NotNull.java | 0 .../se/llbit/util/annotation/Nullable.java | 0 .../io/BufferedFileChannelOutputStream.java | 0 .../llbit/util/io/IsolatedOutputStream.java | 0 .../llbit/util/io/PositionalInputStream.java | 0 .../llbit/util/io/PositionalOutputStream.java | 0 .../RepositionableMeasurableDataOutput.java | 0 .../src/java/se/llbit/util/io/ZipExport.java | 0 .../util/mojangapi/MinecraftProfile.java | 0 .../llbit/util/mojangapi/MinecraftSkin.java | 0 .../se/llbit/util/mojangapi/MojangApi.java | 0 chunky/src/res/chunky-icon.png | Bin chunky/src/res/icons/1_12.png | Bin chunky/src/res/icons/1_13.png | Bin chunky/src/res/icons/advanced.png | Bin chunky/src/res/icons/bed.png | Bin chunky/src/res/icons/cactus.png | Bin chunky/src/res/icons/cake.png | Bin chunky/src/res/icons/camera.png | Bin chunky/src/res/icons/cauldron.png | Bin chunky/src/res/icons/chunky.png | Bin chunky/src/res/icons/clear.png | Bin chunky/src/res/icons/clock.png | Bin chunky/src/res/icons/colors.png | Bin chunky/src/res/icons/disk.png | Bin chunky/src/res/icons/dragon-egg.png | Bin chunky/src/res/icons/eye.png | Bin chunky/src/res/icons/face.png | Bin chunky/src/res/icons/face_t.png | Bin chunky/src/res/icons/failed.png | Bin chunky/src/res/icons/fence.png | Bin chunky/src/res/icons/gear.png | Bin chunky/src/res/icons/home.png | Bin chunky/src/res/icons/home_t.png | Bin chunky/src/res/icons/iron-door.png | Bin chunky/src/res/icons/iso-ne.png | Bin chunky/src/res/icons/iso-nw.png | Bin chunky/src/res/icons/iso-se.png | Bin chunky/src/res/icons/iso-sw.png | Bin chunky/src/res/icons/jack-o-lantern.png | Bin chunky/src/res/icons/jukebox.png | Bin chunky/src/res/icons/key.png | Bin chunky/src/res/icons/lens.png | Bin chunky/src/res/icons/lever.png | Bin chunky/src/res/icons/light.png | Bin chunky/src/res/icons/load.png | Bin chunky/src/res/icons/lock.png | Bin chunky/src/res/icons/magnify.png | Bin chunky/src/res/icons/map-selected.png | Bin chunky/src/res/icons/map.png | Bin chunky/src/res/icons/minus.png | Bin chunky/src/res/icons/note-block.png | Bin chunky/src/res/icons/pause.png | Bin chunky/src/res/icons/pencil.png | Bin chunky/src/res/icons/photo.png | Bin chunky/src/res/icons/play.png | Bin chunky/src/res/icons/player.png | Bin chunky/src/res/icons/plus.png | Bin chunky/src/res/icons/pumpkin.png | Bin chunky/src/res/icons/question.png | Bin chunky/src/res/icons/redstone-torch-on.png | Bin chunky/src/res/icons/reload.png | Bin chunky/src/res/icons/save.png | Bin chunky/src/res/icons/scale.png | Bin chunky/src/res/icons/sign-post.png | Bin chunky/src/res/icons/sky.png | Bin chunky/src/res/icons/skybox-back.png | Bin chunky/src/res/icons/skybox-down.png | Bin chunky/src/res/icons/skybox-front.png | Bin chunky/src/res/icons/skybox-left.png | Bin chunky/src/res/icons/skybox-right.png | Bin chunky/src/res/icons/skybox-up.png | Bin chunky/src/res/icons/stone-brick-stairs.png | Bin chunky/src/res/icons/stone-button.png | Bin chunky/src/res/icons/stone-pressure-plate.png | Bin chunky/src/res/icons/stone-stairs.png | Bin chunky/src/res/icons/stop.png | Bin chunky/src/res/icons/sun.png | Bin chunky/src/res/icons/unknown.png | Bin chunky/src/res/icons/wall-sign.png | Bin chunky/src/res/icons/water.png | Bin chunky/src/res/icons/wheat.png | Bin chunky/src/res/icons/wooden-door.png | Bin .../src/res/icons/wooden-pressure-plate.png | Bin chunky/src/res/icons/wooden-stairs.png | Bin chunky/src/res/icons/wrench.png | Bin .../se/llbit/chunky/main/Version.properties | 0 .../renderer/projection/gaussian-aperture.png | Bin .../renderer/projection/hexagon-aperture.png | Bin .../renderer/projection/pentagon-aperture.png | Bin .../renderer/projection/star-aperture.png | Bin chunky/src/res/se/llbit/chunky/ui/Chunky.fxml | 348 +++++------ chunky/src/res/se/llbit/chunky/ui/chunky.png | Bin .../se/llbit/chunky/ui/dialogs/Credits.fxml | 582 +++++++++--------- .../llbit/chunky/ui/dialogs/ErrorDialog.fxml | 54 +- .../res/se/llbit/chunky/ui/dialogs/Poser.fxml | 86 +-- .../ui/dialogs/ResourcePackChooser.fxml | 138 ++--- .../llbit/chunky/ui/dialogs/SceneChooser.fxml | 96 +-- .../chunky/ui/dialogs/WarningDialog.fxml | 54 +- .../llbit/chunky/ui/dialogs/WorldChooser.fxml | 60 +- .../chunky/ui/elements/GradientEditor.fxml | 66 +- .../se/llbit/chunky/ui/elements/jog_wheel.png | Bin .../chunky/ui/elements/jog_wheel_dimple.png | Bin .../render/settings/LayeredFogSettings.fxml | 54 +- .../ui/render/settings/SkyboxSettings.fxml | 66 +- .../ui/render/settings/SkymapSettings.fxml | 50 +- .../render/settings/UniformFogSettings.fxml | 36 +- .../chunky/ui/render/tabs/AdvancedTab.fxml | 0 .../chunky/ui/render/tabs/CameraTab.fxml | 270 ++++---- .../chunky/ui/render/tabs/EntitiesTab.fxml | 164 ++--- .../chunky/ui/render/tabs/GeneralTab.fxml | 216 +++---- .../llbit/chunky/ui/render/tabs/HelpTab.fxml | 116 ++-- .../chunky/ui/render/tabs/LightingTab.fxml | 0 .../ui/render/tabs/PostprocessingTab.fxml | 166 ++--- .../llbit/chunky/ui/render/tabs/SkyTab.fxml | 122 ++-- .../chunky/ui/render/tabs/TexturesTab.fxml | 38 +- .../llbit/chunky/ui/render/tabs/WaterTab.fxml | 116 ++-- chunky/src/res/style.css | 252 ++++---- chunky/src/res/textures/air.png | Bin chunky/src/res/textures/bedrock.png | Bin chunky/src/res/textures/bookshelf.png | Bin chunky/src/res/textures/bricks.png | Bin chunky/src/res/textures/brown-mushroom.png | Bin chunky/src/res/textures/chest.png | Bin chunky/src/res/textures/clay.png | Bin chunky/src/res/textures/coal-ore.png | Bin chunky/src/res/textures/cobblestone.png | Bin chunky/src/res/textures/cobweb.png | Bin chunky/src/res/textures/dead-bush.png | Bin chunky/src/res/textures/diamond-block.png | Bin chunky/src/res/textures/diamond-ore.png | Bin chunky/src/res/textures/dirt.png | Bin chunky/src/res/textures/dispenser.png | Bin chunky/src/res/textures/double-stone-slab.png | Bin chunky/src/res/textures/east.png | Bin chunky/src/res/textures/end-portal.png | Bin chunky/src/res/textures/end-stone.png | Bin chunky/src/res/textures/fire.png | Bin chunky/src/res/textures/furnace-lit.png | Bin chunky/src/res/textures/furnace.png | Bin chunky/src/res/textures/glass.png | Bin chunky/src/res/textures/glowstone.png | Bin chunky/src/res/textures/gold-block.png | Bin chunky/src/res/textures/gold-ore.png | Bin .../src/res/textures/grass-side-saturated.png | Bin chunky/src/res/textures/grass.png | Bin chunky/src/res/textures/gravel.png | Bin chunky/src/res/textures/ice.png | Bin chunky/src/res/textures/iron-bars.png | Bin chunky/src/res/textures/iron-block.png | Bin chunky/src/res/textures/iron-ore.png | Bin chunky/src/res/textures/ladder.png | Bin .../src/res/textures/lapis-lazuli-block.png | Bin chunky/src/res/textures/lapis-lazuli-ore.png | Bin chunky/src/res/textures/lava.png | Bin chunky/src/res/textures/leaves.png | Bin chunky/src/res/textures/lily-pad.png | Bin chunky/src/res/textures/melon.png | Bin chunky/src/res/textures/minecart-track.png | Bin chunky/src/res/textures/moss-stone.png | Bin chunky/src/res/textures/nether-portal.png | Bin chunky/src/res/textures/netherrack.png | Bin chunky/src/res/textures/north.png | Bin chunky/src/res/textures/obsidian.png | Bin chunky/src/res/textures/piston-extension.png | Bin chunky/src/res/textures/piston.png | Bin chunky/src/res/textures/red-mushroom.png | Bin chunky/src/res/textures/redstone-lamp-off.png | Bin chunky/src/res/textures/redstone-lamp-on.png | Bin chunky/src/res/textures/redstone-ore.png | Bin .../res/textures/redstone-repeater-off.png | Bin .../src/res/textures/redstone-repeater-on.png | Bin .../src/res/textures/redstone-torch-off.png | Bin chunky/src/res/textures/redstone-torch-on.png | Bin .../textures/redstone-wire-off-intersect.png | Bin chunky/src/res/textures/rose.png | Bin chunky/src/res/textures/sand.png | Bin chunky/src/res/textures/sandstone.png | Bin chunky/src/res/textures/sapling.png | Bin chunky/src/res/textures/snow.png | Bin chunky/src/res/textures/soil.png | Bin chunky/src/res/textures/soul-sand.png | Bin chunky/src/res/textures/south.png | Bin chunky/src/res/textures/spawner.png | Bin chunky/src/res/textures/sponge.png | Bin chunky/src/res/textures/stone-bricks.png | Bin chunky/src/res/textures/stone-slab.png | Bin chunky/src/res/textures/stone.png | Bin chunky/src/res/textures/sugar-canes.png | Bin chunky/src/res/textures/tall-grass.png | Bin chunky/src/res/textures/tnt.png | Bin chunky/src/res/textures/torch.png | Bin chunky/src/res/textures/trapdoor.png | Bin chunky/src/res/textures/unknown.png | Bin chunky/src/res/textures/vines.png | Bin chunky/src/res/textures/water-height.png | Bin chunky/src/res/textures/water.png | Bin chunky/src/res/textures/west.png | Bin chunky/src/res/textures/wood-top.png | Bin chunky/src/res/textures/wood.png | Bin chunky/src/res/textures/wooden-planks.png | Bin chunky/src/res/textures/wool.png | Bin chunky/src/res/textures/workbench.png | Bin chunky/src/res/textures/yellow-flower.png | Bin .../llbit/chunky/block/SkullTextureTest.java | 0 .../llbit/chunky/chunk/BlockPaletteTest.java | 0 .../llbit/chunky/entity/MarshallingTest.java | 0 .../llbit/chunky/main/OptionHandlerTest.java | 0 .../se/llbit/chunky/main/PluginApiTest.java | 0 .../src/test/se/llbit/chunky/nbt/NBTTest.java | 0 .../chunky/renderer/BlankRenderTest.java | 0 .../chunky/renderer/MockSceneProvider.java | 0 .../renderer/renderdump/RenderDumpTest.java | 0 .../renderer/scene/SceneManagerTest.java | 0 .../chunky/renderer/scene/SceneTest.java | 0 .../chunky/resources/AnimatedTextureTest.java | 0 .../fxutil/GroupedChangeListenerTest.java | 0 chunky/src/test/se/llbit/log/LogTest.java | 0 .../test/se/llbit/math/MutableAABBTest.java | 0 .../src/test/se/llbit/math/QuickMathTest.java | 0 .../test/se/llbit/util/RingBufferTest.java | 0 912 files changed, 2905 insertions(+), 2210 deletions(-) mode change 100644 => 100755 chunky/src/java/.gitattributes mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/Plugin.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/Block.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/BlockFace.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/BlockProvider.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/BlockSpec.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/FinalizationState.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/FixedTopBottomRotatableTexturedBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/MinecraftBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/MinecraftBlockTranslucent.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/ModelBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/OctreeFinalizationState.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/SolidNonOpaqueBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/TexturedBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/TopBottomOrientedTexturedBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/UntintedLeaves.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlockUtils.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocks.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/LegacyMinecraftBlockProvider.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/UnfinalizedLegacyBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBed.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyChest.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyChorusPlant.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyCobblestoneWall.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyDoorPart.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFence.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFenceGate.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFlowerPot.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyGlassPane.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyIronBars.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyLargeFlower.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyMelonStem.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyNetherPortal.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyPumpkinStem.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyRedstoneWire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySnowCoverableBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyStairs.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyTripwire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyVine.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Air.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/AmethystCluster.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Anvil.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/AttachedStem.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Azalea.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Bamboo.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Barrel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Bed.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Beetroots.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Bell.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/BigDripleaf.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/BigDripleafStem.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/BlastFurnace.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/BrewingStand.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Button.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Cactus.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Cake.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Carpet.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Carrots.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Cauldron.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/CaveVines.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Chain.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/ChainCommandBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Chest.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/ChiseledBookshelf.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/ChorusFlower.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/ChorusPlant.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Cocoa.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/CommandBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Comparator.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Composter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Conduit.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/CopperBulb.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Crafter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/DaylightDetector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Dispenser.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Door.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/DragonEgg.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Dropper.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/EndPortal.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/EndPortalFrame.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/EndRod.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/EnderChest.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Farmland.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Fence.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/FenceGate.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Fern.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Fire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/FlowerPot.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Frogspawn.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/FrostedIce.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Furnace.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Glass.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/GlassPane.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/GlazedTerracotta.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/GlowLichen.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Grass.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/GrassBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/GrassPath.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Grindstone.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Head.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Hopper.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/IronBars.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/JigsawBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Ladder.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Lantern.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/LargeFern.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/LavaCauldron.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Leaves.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Lever.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/LightBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/LightningRod.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Log.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/MangrovePropagule.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/MangroveRoots.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/NetherPortal.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/NetherWart.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Observer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/PinkPetals.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Piston.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/PistonHead.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/PitcherCrop.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/PitcherPlant.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/PointedDripstone.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Potatoes.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/PowderSnowCauldron.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/PressurePlate.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Rail.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneLamp.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneTorch.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneWallTorch.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneWire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Repeater.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/RepeatingCommandBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/RespawnAnchor.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Scaffolding.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SculkCatalyst.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SculkSensor.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SculkShrieker.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SculkVein.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SeaPickle.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/ShulkerBox.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Slab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SmallDripleaf.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Smoker.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SnifferEgg.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Snow.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SoulFire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SpriteBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Stairs.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Stem.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Stonecutter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SugarCane.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Sunflower.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/SweetBerryBush.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/TallGrass.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/TintedGlass.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Torch.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/TorchflowerCrop.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Trapdoor.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Tripwire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/TripwireHook.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/TurtleEgg.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/UnknownBlock.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Vine.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Wall.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/WallTorch.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Water.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/block/minecraft/Wheat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/ChunkData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/ChunkLoadingException.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/EmptyChunkData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/GenericChunkData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/SimpleChunkData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/TagBlockBuilder.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/biome/BiomeData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/biome/BiomeData2d.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/biome/BiomeDataFactory.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/biome/GenericQuartBiomeData3d.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/biome/QuartBiomeData3d.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/chunk/biome/UnknownBiomeData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/ArmorStand.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/Armored.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/Book.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/Campfire.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/Entity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/FlameParticles.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/Geared.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/HeadEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/Lectern.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/Poseable.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/SignEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/SkullEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/StandingBanner.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/UVMapHelper.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/WallBanner.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/main/Chunky.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/main/ChunkyOptions.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/main/CommandLineOptions.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/main/HeadlessErrorTrackingLogger.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/main/SceneHelper.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/main/Version.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/main/ZipExportJob.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/AbstractLayer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/BiomeLayer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/BitmapLayer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/IconLayer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/MapBuffer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/MapTile.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/MapView.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/SurfaceLayer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/map/WorldMapLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/AABBModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/BlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/DirectionalBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/FixedTopBottomRotatableTexturedBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/GrassTintedSpriteModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/Model.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/QuadModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/RotatableBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/Tint.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/TopBottomOrientedTexturedBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/AnvilModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/AttachedStemModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/AzaleaModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BambooModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BarrelModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BeaconModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BedModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BellModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BigDripleafModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BigDripleafStemModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/BrewingStandModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ButtonModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CactusModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CakeModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CakeWithCandleModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CalibratedSculkSensorModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CandleModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CarpetModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ChainModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ChestModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ChorusFlowerModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ChorusPlantModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CocoaPlantModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ComparatorModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ComposterModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ConduitModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/CropsModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/DaylightSensorModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/DispenserModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/DoorModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/DragonEggModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/EnchantmentTableModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/EndPortalFrameModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/EndPortalModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/EndRodModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/FenceGateModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/FenceModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/FireModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/Flowerbed.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/FrogspawnModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/GlassPaneModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/GlowLichenModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/GrassBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/GrassPathModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/GrindstoneModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/HopperModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/IronBarsModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/JigsawModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/LadderModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/LanternModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/LeafModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/LeverModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/LightBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/LightningRodModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/LogModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/MangrovePropaguleModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/MangroveRootsModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/NetherPortalModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ObserverModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/PistonExtensionModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/PistonModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/PitcherCropBottomModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/PitcherCropTopModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/PitcherPlantBottomModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/PitcherPlantTopModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/PressurePlateModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/RailModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/RedstoneRepeaterModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/RedstoneWireModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/ScaffoldingModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SculkSensorModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SculkShriekerModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SculkVeinModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SeaPickleModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SlabModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SmallDripleafModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SnifferEggModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SnowModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SporeBlossomModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/StairModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/StemModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/StonecutterModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/SunFlowerModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/TerracottaModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/TorchModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/TrapdoorModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/TripwireHookModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/TripwireModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/TurtleEggModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/VineModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/WallModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/plugin/ChunkyPlugin.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/plugin/ContextMenuTransformer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/plugin/PluginApi.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/plugin/TabTransformer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/ApertureShape.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/CameraViewListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/ChunkViewListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/ConsoleProgressListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/DefaultRenderManager.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/EmitterSamplingStrategy.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/PathTracingRenderer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/Postprocess.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/PreviewRenderer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RayTracerFactory.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/Refreshable.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderContext.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderContextFactory.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderController.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderManager.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderManagerFactory.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderMode.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderStatus.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderStatusListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/RenderWorkerPool.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/Renderer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/Repaintable.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/ResetReason.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/SceneIOProvider.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/SceneProvider.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/SceneStatusListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/SnapshotControl.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/SunSamplingStrategy.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/WaterShadingStrategy.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/WorkerState.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/export/PfmExportFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/export/PictureExportFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/export/PictureExportFormats.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/export/PngExportFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/export/Tiff32ExportFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/ACESFilmicFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/GammaCorrectionFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/HableToneMappingFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/NoneFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/PixelPostProcessingFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilters.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/PreviewFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/SimplePixelPostProcessingFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/Tonemap1Filter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/postprocessing/UE4ToneMappingFilter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/ProjectionMode.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/AbstractDumpFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/ClassicDumpFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/DumpFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/FloatingPointCompressorDumpFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/GzipDumpFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/HuffmanDumpFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/PixelConsumer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/RenderDump.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/renderdump/UncompressedDumpFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/AlphaBuffer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/AsynchronousSceneManager.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/CameraPreset.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/ChunkFinalizer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/EntityLoadingPreferences.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/FogLayer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/FogMode.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/LegacyWaterShader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/NishitaSky.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/PlayerModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/PreethamSky.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/RayTracer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/RenderResetHandler.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/SceneFactory.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/SceneManager.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/SimplexWaterShader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/SimulatedSky.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/Sky.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/SkyCache.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/StillWaterShader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/SynchronousSceneManager.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/WaterShader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/biome/BiomeStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/biome/Trivial2dBiomeStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/biome/Trivial3dBiomeStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/renderer/scene/biome/WorldTexture2dBiomeStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/AbstractHdriTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/AnimatedTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/BinaryBitmapImage.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/BitmapImage.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/ChiseledBookshelfTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/EntityTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/HDRTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/OctreeFileFormat.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/PFMTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/PalettizedBitmapImage.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/PlayerTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/ResourcePackBiomeLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/ResourcePackLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/ResourcePackTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/ShulkerTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/SignTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/SolidColorTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/Texture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/TextureCache.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/TexturePackLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/AllTextures.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/AlternateTextures.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/AnimatedTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/AsciiFontTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/BedTextureAdapter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/ChestTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/CloudsTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/ColoredTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/ConditionalTextures.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/EntityTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/FoliageColorTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/FontTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/GrassColorTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/IndexedTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/JsonFontTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/LargeChestTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/LayeredTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingBackTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingTextureAdapter.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/PlayerTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/RotatedTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/ShulkerTextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/SimpleTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/SplitLargeChestTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/TextureFormatError.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/TextureLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/resources/texturepack/TexturePath.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/ChunkMap.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/ChunkyFx.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/HyperlinkMenuItem.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/Icons.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/ProgressTracker.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/RenderCanvasFx.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/TableSortConfigSerializer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/UILogReceiver.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/controller/CreditsController.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/controller/RenderControlsFxController.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/controller/ResourcePackChooserController.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/controller/SceneChooserController.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/controller/WorldChooserController.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/ChunkyErrorDialog.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/Credits.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/DialogUtils.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/Poser.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/ResourcePackChooser.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/SceneChooser.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/SelectChunksInRadiusDialog.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/SettingsExport.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/ShutdownAlert.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/ValidatingTextInputDialog.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/dialogs/WorldChooser.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/elements/AngleAdjuster.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/elements/GradientEditor.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/elements/SizeInput.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/elements/TextFieldLabelWrapper.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/RenderControlsTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/RenderControlsTabTransformer.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/settings/LayeredFogSettings.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/settings/SkyboxSettings.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/settings/SkymapSettings.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/settings/UniformFogSettings.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/AdvancedTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/GeneralTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/HelpTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/LightingTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/MaterialsTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/PostprocessingTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/SkyTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/TexturesTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/ui/render/tabs/WaterTab.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/BlockData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/Chunk.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkDataSource.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkHeightmap.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkPosition.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkSelectionListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkSelectionTracker.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkTopographyUpdater.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkVersion.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ChunkView.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/Clouds.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/CubicDimension.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/Dimension.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/EmptyChunk.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/EmptyDimension.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/EmptyRegionChunk.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/EmptyWorld.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/Heightmap.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/Icon.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/ImposterCubicChunk.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/Material.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/MaterialStore.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/PlayerEntityData.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/SkymapTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/World.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/WorldScanner.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/WorldTexture.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/biome/ArrayBiomePalette.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/biome/Biome.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/biome/BiomeBuilder.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/biome/BiomePalette.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/biome/Biomes.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/biome/MapBiomePalette.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/listeners/ChunkDeletionListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/listeners/ChunkTopographyListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/listeners/ChunkUpdateListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/material/BeaconBeamMaterial.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/material/CloudMaterial.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/material/LilyPadMaterial.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/material/TextureMaterial.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/model/Cube.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/model/CubeModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/model/Face.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/model/JsonModel.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/ChunkReadException.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/EmptyRegion.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/ImposterCubicRegion.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/MCRegion.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/MCRegionChangeWatcher.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/Region.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/RegionChangeWatcher.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/RegionParser.java mode change 100644 => 100755 chunky/src/java/se/llbit/chunky/world/region/RegionQueue.java mode change 100644 => 100755 chunky/src/java/se/llbit/fxutil/ColumnsBoxBuilder.java mode change 100644 => 100755 chunky/src/java/se/llbit/fxutil/Dialogs.java mode change 100644 => 100755 chunky/src/java/se/llbit/fxutil/FxImageUtil.java mode change 100644 => 100755 chunky/src/java/se/llbit/fxutil/GroupedChangeListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/pfm/PfmFileWriter.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/png/CrcOutputStream.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/png/IDAT.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/png/IEND.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/png/IHDR.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/png/ITXT.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/png/PngChunk.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/png/PngFileWriter.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/tiff/BasicIFD.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/tiff/CompressionType.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/tiff/FinalizableBFCOutputStream.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/tiff/IFDTag.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/tiff/ImageFileDirectory.java mode change 100644 => 100755 chunky/src/java/se/llbit/imageformats/tiff/TiffFileWriter.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/AABB.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/BigPackedOctree.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/ColorUtil.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Constants.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Grid.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Intersectable.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/IntersectionRecord.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Matrix3.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/NodeBasedOctree.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Octree.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/OctreeVisitor.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/PackedOctree.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Quad.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Ray.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Ray2.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/SimplexNoise.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Transform.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Triangle.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Vector2.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Vector3.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Vector3i.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/Vector4.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/bvh/BVH.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/bvh/BinaryBVH.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/bvh/MidpointBVH.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/bvh/SahBVH.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/bvh/SahMaBVH.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/primitive/Box.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/primitive/MutableAABB.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/primitive/Primitive.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/structures/Position2IntStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/structures/Position2ReferenceStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/structures/Position2d2IntPackedArray.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/structures/Position2d2ReferencePackedArrayStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/structures/Position3d2IntPackedArray.java mode change 100644 => 100755 chunky/src/java/se/llbit/math/structures/Position3d2ReferencePackedArrayStructure.java mode change 100644 => 100755 chunky/src/java/se/llbit/resources/ImageLoader.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/BitBuffer.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/Configurable.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/ImageTools.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/JsonSerializable.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/JsonUtil.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/MinecraftPRNG.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/MinecraftText.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/NbtUtil.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/ProgressListener.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/Registerable.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/RingBuffer.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/StringUtil.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/TaskTracker.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/VectorUtil.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/annotation/NotNull.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/annotation/Nullable.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/io/BufferedFileChannelOutputStream.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/io/IsolatedOutputStream.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/io/PositionalInputStream.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/io/PositionalOutputStream.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/io/RepositionableMeasurableDataOutput.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/io/ZipExport.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/mojangapi/MinecraftProfile.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/mojangapi/MinecraftSkin.java mode change 100644 => 100755 chunky/src/java/se/llbit/util/mojangapi/MojangApi.java mode change 100644 => 100755 chunky/src/res/chunky-icon.png mode change 100644 => 100755 chunky/src/res/icons/1_12.png mode change 100644 => 100755 chunky/src/res/icons/1_13.png mode change 100644 => 100755 chunky/src/res/icons/advanced.png mode change 100644 => 100755 chunky/src/res/icons/bed.png mode change 100644 => 100755 chunky/src/res/icons/cactus.png mode change 100644 => 100755 chunky/src/res/icons/cake.png mode change 100644 => 100755 chunky/src/res/icons/camera.png mode change 100644 => 100755 chunky/src/res/icons/cauldron.png mode change 100644 => 100755 chunky/src/res/icons/chunky.png mode change 100644 => 100755 chunky/src/res/icons/clear.png mode change 100644 => 100755 chunky/src/res/icons/clock.png mode change 100644 => 100755 chunky/src/res/icons/colors.png mode change 100644 => 100755 chunky/src/res/icons/disk.png mode change 100644 => 100755 chunky/src/res/icons/dragon-egg.png mode change 100644 => 100755 chunky/src/res/icons/eye.png mode change 100644 => 100755 chunky/src/res/icons/face.png mode change 100644 => 100755 chunky/src/res/icons/face_t.png mode change 100644 => 100755 chunky/src/res/icons/failed.png mode change 100644 => 100755 chunky/src/res/icons/fence.png mode change 100644 => 100755 chunky/src/res/icons/gear.png mode change 100644 => 100755 chunky/src/res/icons/home.png mode change 100644 => 100755 chunky/src/res/icons/home_t.png mode change 100644 => 100755 chunky/src/res/icons/iron-door.png mode change 100644 => 100755 chunky/src/res/icons/iso-ne.png mode change 100644 => 100755 chunky/src/res/icons/iso-nw.png mode change 100644 => 100755 chunky/src/res/icons/iso-se.png mode change 100644 => 100755 chunky/src/res/icons/iso-sw.png mode change 100644 => 100755 chunky/src/res/icons/jack-o-lantern.png mode change 100644 => 100755 chunky/src/res/icons/jukebox.png mode change 100644 => 100755 chunky/src/res/icons/key.png mode change 100644 => 100755 chunky/src/res/icons/lens.png mode change 100644 => 100755 chunky/src/res/icons/lever.png mode change 100644 => 100755 chunky/src/res/icons/light.png mode change 100644 => 100755 chunky/src/res/icons/load.png mode change 100644 => 100755 chunky/src/res/icons/lock.png mode change 100644 => 100755 chunky/src/res/icons/magnify.png mode change 100644 => 100755 chunky/src/res/icons/map-selected.png mode change 100644 => 100755 chunky/src/res/icons/map.png mode change 100644 => 100755 chunky/src/res/icons/minus.png mode change 100644 => 100755 chunky/src/res/icons/note-block.png mode change 100644 => 100755 chunky/src/res/icons/pause.png mode change 100644 => 100755 chunky/src/res/icons/pencil.png mode change 100644 => 100755 chunky/src/res/icons/photo.png mode change 100644 => 100755 chunky/src/res/icons/play.png mode change 100644 => 100755 chunky/src/res/icons/player.png mode change 100644 => 100755 chunky/src/res/icons/plus.png mode change 100644 => 100755 chunky/src/res/icons/pumpkin.png mode change 100644 => 100755 chunky/src/res/icons/question.png mode change 100644 => 100755 chunky/src/res/icons/redstone-torch-on.png mode change 100644 => 100755 chunky/src/res/icons/reload.png mode change 100644 => 100755 chunky/src/res/icons/save.png mode change 100644 => 100755 chunky/src/res/icons/scale.png mode change 100644 => 100755 chunky/src/res/icons/sign-post.png mode change 100644 => 100755 chunky/src/res/icons/sky.png mode change 100644 => 100755 chunky/src/res/icons/skybox-back.png mode change 100644 => 100755 chunky/src/res/icons/skybox-down.png mode change 100644 => 100755 chunky/src/res/icons/skybox-front.png mode change 100644 => 100755 chunky/src/res/icons/skybox-left.png mode change 100644 => 100755 chunky/src/res/icons/skybox-right.png mode change 100644 => 100755 chunky/src/res/icons/skybox-up.png mode change 100644 => 100755 chunky/src/res/icons/stone-brick-stairs.png mode change 100644 => 100755 chunky/src/res/icons/stone-button.png mode change 100644 => 100755 chunky/src/res/icons/stone-pressure-plate.png mode change 100644 => 100755 chunky/src/res/icons/stone-stairs.png mode change 100644 => 100755 chunky/src/res/icons/stop.png mode change 100644 => 100755 chunky/src/res/icons/sun.png mode change 100644 => 100755 chunky/src/res/icons/unknown.png mode change 100644 => 100755 chunky/src/res/icons/wall-sign.png mode change 100644 => 100755 chunky/src/res/icons/water.png mode change 100644 => 100755 chunky/src/res/icons/wheat.png mode change 100644 => 100755 chunky/src/res/icons/wooden-door.png mode change 100644 => 100755 chunky/src/res/icons/wooden-pressure-plate.png mode change 100644 => 100755 chunky/src/res/icons/wooden-stairs.png mode change 100644 => 100755 chunky/src/res/icons/wrench.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/main/Version.properties mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/renderer/projection/gaussian-aperture.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/renderer/projection/hexagon-aperture.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/renderer/projection/pentagon-aperture.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/renderer/projection/star-aperture.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/Chunky.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/chunky.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/dialogs/Credits.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/dialogs/ErrorDialog.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/dialogs/Poser.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/dialogs/ResourcePackChooser.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/dialogs/SceneChooser.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/dialogs/WarningDialog.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/dialogs/WorldChooser.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/elements/GradientEditor.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/elements/jog_wheel.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/elements/jog_wheel_dimple.png mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/settings/LayeredFogSettings.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/settings/SkyboxSettings.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/settings/SkymapSettings.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/settings/UniformFogSettings.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/AdvancedTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/CameraTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/EntitiesTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/GeneralTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/HelpTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/LightingTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/PostprocessingTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/SkyTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/TexturesTab.fxml mode change 100644 => 100755 chunky/src/res/se/llbit/chunky/ui/render/tabs/WaterTab.fxml mode change 100644 => 100755 chunky/src/res/style.css mode change 100644 => 100755 chunky/src/res/textures/air.png mode change 100644 => 100755 chunky/src/res/textures/bedrock.png mode change 100644 => 100755 chunky/src/res/textures/bookshelf.png mode change 100644 => 100755 chunky/src/res/textures/bricks.png mode change 100644 => 100755 chunky/src/res/textures/brown-mushroom.png mode change 100644 => 100755 chunky/src/res/textures/chest.png mode change 100644 => 100755 chunky/src/res/textures/clay.png mode change 100644 => 100755 chunky/src/res/textures/coal-ore.png mode change 100644 => 100755 chunky/src/res/textures/cobblestone.png mode change 100644 => 100755 chunky/src/res/textures/cobweb.png mode change 100644 => 100755 chunky/src/res/textures/dead-bush.png mode change 100644 => 100755 chunky/src/res/textures/diamond-block.png mode change 100644 => 100755 chunky/src/res/textures/diamond-ore.png mode change 100644 => 100755 chunky/src/res/textures/dirt.png mode change 100644 => 100755 chunky/src/res/textures/dispenser.png mode change 100644 => 100755 chunky/src/res/textures/double-stone-slab.png mode change 100644 => 100755 chunky/src/res/textures/east.png mode change 100644 => 100755 chunky/src/res/textures/end-portal.png mode change 100644 => 100755 chunky/src/res/textures/end-stone.png mode change 100644 => 100755 chunky/src/res/textures/fire.png mode change 100644 => 100755 chunky/src/res/textures/furnace-lit.png mode change 100644 => 100755 chunky/src/res/textures/furnace.png mode change 100644 => 100755 chunky/src/res/textures/glass.png mode change 100644 => 100755 chunky/src/res/textures/glowstone.png mode change 100644 => 100755 chunky/src/res/textures/gold-block.png mode change 100644 => 100755 chunky/src/res/textures/gold-ore.png mode change 100644 => 100755 chunky/src/res/textures/grass-side-saturated.png mode change 100644 => 100755 chunky/src/res/textures/grass.png mode change 100644 => 100755 chunky/src/res/textures/gravel.png mode change 100644 => 100755 chunky/src/res/textures/ice.png mode change 100644 => 100755 chunky/src/res/textures/iron-bars.png mode change 100644 => 100755 chunky/src/res/textures/iron-block.png mode change 100644 => 100755 chunky/src/res/textures/iron-ore.png mode change 100644 => 100755 chunky/src/res/textures/ladder.png mode change 100644 => 100755 chunky/src/res/textures/lapis-lazuli-block.png mode change 100644 => 100755 chunky/src/res/textures/lapis-lazuli-ore.png mode change 100644 => 100755 chunky/src/res/textures/lava.png mode change 100644 => 100755 chunky/src/res/textures/leaves.png mode change 100644 => 100755 chunky/src/res/textures/lily-pad.png mode change 100644 => 100755 chunky/src/res/textures/melon.png mode change 100644 => 100755 chunky/src/res/textures/minecart-track.png mode change 100644 => 100755 chunky/src/res/textures/moss-stone.png mode change 100644 => 100755 chunky/src/res/textures/nether-portal.png mode change 100644 => 100755 chunky/src/res/textures/netherrack.png mode change 100644 => 100755 chunky/src/res/textures/north.png mode change 100644 => 100755 chunky/src/res/textures/obsidian.png mode change 100644 => 100755 chunky/src/res/textures/piston-extension.png mode change 100644 => 100755 chunky/src/res/textures/piston.png mode change 100644 => 100755 chunky/src/res/textures/red-mushroom.png mode change 100644 => 100755 chunky/src/res/textures/redstone-lamp-off.png mode change 100644 => 100755 chunky/src/res/textures/redstone-lamp-on.png mode change 100644 => 100755 chunky/src/res/textures/redstone-ore.png mode change 100644 => 100755 chunky/src/res/textures/redstone-repeater-off.png mode change 100644 => 100755 chunky/src/res/textures/redstone-repeater-on.png mode change 100644 => 100755 chunky/src/res/textures/redstone-torch-off.png mode change 100644 => 100755 chunky/src/res/textures/redstone-torch-on.png mode change 100644 => 100755 chunky/src/res/textures/redstone-wire-off-intersect.png mode change 100644 => 100755 chunky/src/res/textures/rose.png mode change 100644 => 100755 chunky/src/res/textures/sand.png mode change 100644 => 100755 chunky/src/res/textures/sandstone.png mode change 100644 => 100755 chunky/src/res/textures/sapling.png mode change 100644 => 100755 chunky/src/res/textures/snow.png mode change 100644 => 100755 chunky/src/res/textures/soil.png mode change 100644 => 100755 chunky/src/res/textures/soul-sand.png mode change 100644 => 100755 chunky/src/res/textures/south.png mode change 100644 => 100755 chunky/src/res/textures/spawner.png mode change 100644 => 100755 chunky/src/res/textures/sponge.png mode change 100644 => 100755 chunky/src/res/textures/stone-bricks.png mode change 100644 => 100755 chunky/src/res/textures/stone-slab.png mode change 100644 => 100755 chunky/src/res/textures/stone.png mode change 100644 => 100755 chunky/src/res/textures/sugar-canes.png mode change 100644 => 100755 chunky/src/res/textures/tall-grass.png mode change 100644 => 100755 chunky/src/res/textures/tnt.png mode change 100644 => 100755 chunky/src/res/textures/torch.png mode change 100644 => 100755 chunky/src/res/textures/trapdoor.png mode change 100644 => 100755 chunky/src/res/textures/unknown.png mode change 100644 => 100755 chunky/src/res/textures/vines.png mode change 100644 => 100755 chunky/src/res/textures/water-height.png mode change 100644 => 100755 chunky/src/res/textures/water.png mode change 100644 => 100755 chunky/src/res/textures/west.png mode change 100644 => 100755 chunky/src/res/textures/wood-top.png mode change 100644 => 100755 chunky/src/res/textures/wood.png mode change 100644 => 100755 chunky/src/res/textures/wooden-planks.png mode change 100644 => 100755 chunky/src/res/textures/wool.png mode change 100644 => 100755 chunky/src/res/textures/workbench.png mode change 100644 => 100755 chunky/src/res/textures/yellow-flower.png mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/block/SkullTextureTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/chunk/BlockPaletteTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/entity/MarshallingTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/main/OptionHandlerTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/main/PluginApiTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/nbt/NBTTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/renderer/BlankRenderTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/renderer/MockSceneProvider.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/renderer/renderdump/RenderDumpTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/renderer/scene/SceneManagerTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/renderer/scene/SceneTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/chunky/resources/AnimatedTextureTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/fxutil/GroupedChangeListenerTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/log/LogTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/math/MutableAABBTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/math/QuickMathTest.java mode change 100644 => 100755 chunky/src/test/se/llbit/util/RingBufferTest.java diff --git a/chunky/src/java/.gitattributes b/chunky/src/java/.gitattributes old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/Plugin.java b/chunky/src/java/se/llbit/chunky/Plugin.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java b/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java old mode 100644 new mode 100755 index 328ac02367..7604debf93 --- a/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java +++ b/chunky/src/java/se/llbit/chunky/block/AbstractModelBlock.java @@ -47,4 +47,9 @@ public BlockModel getModel() { public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { return model.intersect(ray, intersectionRecord, scene); } + + @Override + public boolean isInside(Ray2 ray) { + return model.isInside(ray); + } } diff --git a/chunky/src/java/se/llbit/chunky/block/Block.java b/chunky/src/java/se/llbit/chunky/block/Block.java old mode 100644 new mode 100755 index 26393e4771..cd496e1fe8 --- a/chunky/src/java/se/llbit/chunky/block/Block.java +++ b/chunky/src/java/se/llbit/chunky/block/Block.java @@ -9,7 +9,6 @@ import se.llbit.math.AABB; import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; import se.llbit.nbt.CompoundTag; @@ -18,7 +17,7 @@ import java.util.Random; public abstract class Block extends Material { - private final static AABB block = new AABB(0, 1, 0, 1,0, 1); + public static final AABB fullBlock = new AABB(0, 1, 0, 1,0, 1); /** * Set to true if there is a local intersection model for this block. If this is set to @@ -51,14 +50,14 @@ public int faceCount() { * @param rand Random number source. */ public void sample(int face, Vector3 loc, Random rand) { - block.sampleFace(face, loc, rand); + fullBlock.sampleFace(face, loc, rand); } /** * Get the surface area of this face of the block. */ public double surfaceArea(int face) { - return block.faceSurfaceArea(face); + return fullBlock.faceSurfaceArea(face); } /** @@ -71,7 +70,7 @@ public double surfaceArea(int face) { * @return True if the ray hit this block, false if not */ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { - if (block.intersect(ray, intersectionRecord)) { + if (fullBlock.intersect(ray, intersectionRecord)) { float[] color = texture.getColor(intersectionRecord.uv.x, intersectionRecord.uv.y); if (color[3] > Constants.EPSILON) { intersectionRecord.color.set(color); @@ -146,4 +145,8 @@ public boolean isModifiedByBlockEntity() { public Tag getNewTagWithBlockEntity(Tag blockTag, CompoundTag entityTag) { return null; } + + public boolean isInside(Ray2 ray) { + return fullBlock.inside(ray.o); + } } diff --git a/chunky/src/java/se/llbit/chunky/block/BlockFace.java b/chunky/src/java/se/llbit/chunky/block/BlockFace.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/BlockProvider.java b/chunky/src/java/se/llbit/chunky/block/BlockProvider.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/BlockSpec.java b/chunky/src/java/se/llbit/chunky/block/BlockSpec.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/FinalizationState.java b/chunky/src/java/se/llbit/chunky/block/FinalizationState.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/FixedTopBottomRotatableTexturedBlock.java b/chunky/src/java/se/llbit/chunky/block/FixedTopBottomRotatableTexturedBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlock.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockTranslucent.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockTranslucent.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/ModelBlock.java b/chunky/src/java/se/llbit/chunky/block/ModelBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/OctreeFinalizationState.java b/chunky/src/java/se/llbit/chunky/block/OctreeFinalizationState.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/SolidNonOpaqueBlock.java b/chunky/src/java/se/llbit/chunky/block/SolidNonOpaqueBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/TexturedBlock.java b/chunky/src/java/se/llbit/chunky/block/TexturedBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/TopBottomOrientedTexturedBlock.java b/chunky/src/java/se/llbit/chunky/block/TopBottomOrientedTexturedBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/UntintedLeaves.java b/chunky/src/java/se/llbit/chunky/block/UntintedLeaves.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlockUtils.java b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlockUtils.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocks.java b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocks.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyBlocksFinalizer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/LegacyMinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/legacy/LegacyMinecraftBlockProvider.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/UnfinalizedLegacyBlock.java b/chunky/src/java/se/llbit/chunky/block/legacy/UnfinalizedLegacyBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBanner.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBed.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyBed.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyChest.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyChest.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyChorusPlant.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyChorusPlant.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyCobblestoneWall.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyCobblestoneWall.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyDoorPart.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyDoorPart.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFence.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFence.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFenceGate.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFenceGate.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFire.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFlowerPot.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyFlowerPot.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyGlassPane.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyGlassPane.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyIronBars.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyIronBars.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyLargeFlower.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyLargeFlower.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyMelonStem.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyMelonStem.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyNetherPortal.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyNetherPortal.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyPumpkinStem.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyPumpkinStem.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyRedstoneWire.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyRedstoneWire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySkull.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySnowCoverableBlock.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacySnowCoverableBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyStairs.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyStairs.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyTripwire.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyTripwire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyVine.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyVine.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java b/chunky/src/java/se/llbit/chunky/block/legacy/blocks/LegacyWallBanner.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Air.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Air.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/AmethystCluster.java b/chunky/src/java/se/llbit/chunky/block/minecraft/AmethystCluster.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Anvil.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Anvil.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/AttachedStem.java b/chunky/src/java/se/llbit/chunky/block/minecraft/AttachedStem.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Azalea.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Azalea.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Bamboo.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Bamboo.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Banner.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Barrel.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Barrel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Beacon.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Bed.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Bed.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Beetroots.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Beetroots.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Bell.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Bell.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/BigDripleaf.java b/chunky/src/java/se/llbit/chunky/block/minecraft/BigDripleaf.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/BigDripleafStem.java b/chunky/src/java/se/llbit/chunky/block/minecraft/BigDripleafStem.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/BlastFurnace.java b/chunky/src/java/se/llbit/chunky/block/minecraft/BlastFurnace.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/BrewingStand.java b/chunky/src/java/se/llbit/chunky/block/minecraft/BrewingStand.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Button.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Button.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Cactus.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Cactus.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Cake.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Cake.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CakeWithCandle.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CalibratedSculkSensor.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Candle.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Carpet.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Carpet.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Carrots.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Carrots.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Cauldron.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Cauldron.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CaveVines.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CaveVines.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Chain.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Chain.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/ChainCommandBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/ChainCommandBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Chest.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Chest.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/ChiseledBookshelf.java b/chunky/src/java/se/llbit/chunky/block/minecraft/ChiseledBookshelf.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/ChorusFlower.java b/chunky/src/java/se/llbit/chunky/block/minecraft/ChorusFlower.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/ChorusPlant.java b/chunky/src/java/se/llbit/chunky/block/minecraft/ChorusPlant.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Cocoa.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Cocoa.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CommandBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CommandBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Comparator.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Comparator.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Composter.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Composter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Conduit.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Conduit.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CopperBulb.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CopperBulb.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Crafter.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Crafter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/DaylightDetector.java b/chunky/src/java/se/llbit/chunky/block/minecraft/DaylightDetector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java b/chunky/src/java/se/llbit/chunky/block/minecraft/DecoratedPot.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Dispenser.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Dispenser.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Door.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Door.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/DragonEgg.java b/chunky/src/java/se/llbit/chunky/block/minecraft/DragonEgg.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Dropper.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Dropper.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java b/chunky/src/java/se/llbit/chunky/block/minecraft/EnchantingTable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/EndPortal.java b/chunky/src/java/se/llbit/chunky/block/minecraft/EndPortal.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/EndPortalFrame.java b/chunky/src/java/se/llbit/chunky/block/minecraft/EndPortalFrame.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/EndRod.java b/chunky/src/java/se/llbit/chunky/block/minecraft/EndRod.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/EnderChest.java b/chunky/src/java/se/llbit/chunky/block/minecraft/EnderChest.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Farmland.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Farmland.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Fence.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Fence.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/FenceGate.java b/chunky/src/java/se/llbit/chunky/block/minecraft/FenceGate.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Fern.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Fern.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Fire.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Fire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/FlowerPot.java b/chunky/src/java/se/llbit/chunky/block/minecraft/FlowerPot.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Frogspawn.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Frogspawn.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/FrostedIce.java b/chunky/src/java/se/llbit/chunky/block/minecraft/FrostedIce.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Furnace.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Furnace.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Glass.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Glass.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/GlassPane.java b/chunky/src/java/se/llbit/chunky/block/minecraft/GlassPane.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/GlazedTerracotta.java b/chunky/src/java/se/llbit/chunky/block/minecraft/GlazedTerracotta.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/GlowLichen.java b/chunky/src/java/se/llbit/chunky/block/minecraft/GlowLichen.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Grass.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Grass.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/GrassBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/GrassBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/GrassPath.java b/chunky/src/java/se/llbit/chunky/block/minecraft/GrassPath.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Grindstone.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Grindstone.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/HangingSign.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Head.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java old mode 100644 new mode 100755 index fbfcad91b2..dd0b364501 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Honey.java @@ -18,26 +18,18 @@ package se.llbit.chunky.block.minecraft; -import se.llbit.chunky.block.MinecraftBlockTranslucent; +import se.llbit.chunky.block.AbstractModelBlock; import se.llbit.chunky.model.minecraft.HoneyBlockModel; +import se.llbit.chunky.model.minecraft.SlimeBlockModel; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.IntersectionRecord; -import se.llbit.math.Ray; import se.llbit.math.Ray2; -public class Honey extends MinecraftBlockTranslucent { +public class Honey extends AbstractModelBlock { public Honey() { super("honey_block", Texture.honeyBlockSide); - localIntersect = true; - opaque = false; ior = 1.474f; // according to https://study.com/academy/answer/what-is-the-refractive-index-of-honey.html - solid = false; - refractive = true; - } - - @Override - public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { - return HoneyBlockModel.intersect(ray, intersectionRecord); + model = new HoneyBlockModel(); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Hopper.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Hopper.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/IronBars.java b/chunky/src/java/se/llbit/chunky/block/minecraft/IronBars.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/JigsawBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/JigsawBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Ladder.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Ladder.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Lantern.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Lantern.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LargeFern.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LargeFern.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java old mode 100644 new mode 100755 index 1f40d2c8e6..ab87d71ace --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java @@ -181,7 +181,7 @@ public boolean isFullBlock() { texture.getColor(intersectionTest); intersectionRecord.color.set(intersectionTest.color); intersectionRecord.color.w = 1; - intersectionRecord.distance += intersectionTest.distance; + intersectionRecord.distance = intersectionTest.distance; return true; } return false; diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LavaCauldron.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LavaCauldron.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Leaves.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Leaves.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Lever.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Lever.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LightBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LightBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LightningRod.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LightningRod.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java b/chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Log.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Log.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/MangrovePropagule.java b/chunky/src/java/se/llbit/chunky/block/minecraft/MangrovePropagule.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/MangroveRoots.java b/chunky/src/java/se/llbit/chunky/block/minecraft/MangroveRoots.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/NetherPortal.java b/chunky/src/java/se/llbit/chunky/block/minecraft/NetherPortal.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/NetherWart.java b/chunky/src/java/se/llbit/chunky/block/minecraft/NetherWart.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Observer.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Observer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PinkPetals.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PinkPetals.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Piston.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Piston.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PistonHead.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PistonHead.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PitcherCrop.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PitcherCrop.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PitcherPlant.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PitcherPlant.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PointedDripstone.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PointedDripstone.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Potatoes.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Potatoes.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PowderSnowCauldron.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PowderSnowCauldron.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/PressurePlate.java b/chunky/src/java/se/llbit/chunky/block/minecraft/PressurePlate.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Rail.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Rail.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneLamp.java b/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneLamp.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneTorch.java b/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneTorch.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneWallTorch.java b/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneWallTorch.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneWire.java b/chunky/src/java/se/llbit/chunky/block/minecraft/RedstoneWire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Repeater.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Repeater.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/RepeatingCommandBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/RepeatingCommandBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/RespawnAnchor.java b/chunky/src/java/se/llbit/chunky/block/minecraft/RespawnAnchor.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Scaffolding.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Scaffolding.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SculkCatalyst.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SculkCatalyst.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SculkSensor.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SculkSensor.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SculkShrieker.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SculkShrieker.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SculkVein.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SculkVein.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SeaPickle.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SeaPickle.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/ShulkerBox.java b/chunky/src/java/se/llbit/chunky/block/minecraft/ShulkerBox.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Sign.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Slab.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Slab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java old mode 100644 new mode 100755 index cd062672f0..2bdafdcf7b --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Slime.java @@ -18,26 +18,15 @@ package se.llbit.chunky.block.minecraft; -import se.llbit.chunky.block.MinecraftBlockTranslucent; +import se.llbit.chunky.block.AbstractModelBlock; import se.llbit.chunky.model.minecraft.SlimeBlockModel; -import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; -import se.llbit.math.IntersectionRecord; -import se.llbit.math.Ray; -import se.llbit.math.Ray2; -public class Slime extends MinecraftBlockTranslucent { +public class Slime extends AbstractModelBlock { public Slime() { super("slime_block", Texture.slime); - localIntersect = true; - opaque = false; ior = 1.516f; // gelatin, according to https://study.com/academy/answer/what-is-the-refractive-index-of-gelatin.html solid = true; - refractive = true; - } - - @Override - public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { - return SlimeBlockModel.intersect(ray, intersectionRecord); + model = new SlimeBlockModel(); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SmallDripleaf.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SmallDripleaf.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Smoker.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Smoker.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SnifferEgg.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SnifferEgg.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Snow.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Snow.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SoulFire.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SoulFire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SpriteBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SpriteBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Stairs.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Stairs.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Stem.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Stem.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Stonecutter.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Stonecutter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SugarCane.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SugarCane.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Sunflower.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Sunflower.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/SweetBerryBush.java b/chunky/src/java/se/llbit/chunky/block/minecraft/SweetBerryBush.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/TallGrass.java b/chunky/src/java/se/llbit/chunky/block/minecraft/TallGrass.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/TintedGlass.java b/chunky/src/java/se/llbit/chunky/block/minecraft/TintedGlass.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Torch.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Torch.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/TorchflowerCrop.java b/chunky/src/java/se/llbit/chunky/block/minecraft/TorchflowerCrop.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Trapdoor.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Trapdoor.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Tripwire.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Tripwire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/TripwireHook.java b/chunky/src/java/se/llbit/chunky/block/minecraft/TripwireHook.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/TurtleEgg.java b/chunky/src/java/se/llbit/chunky/block/minecraft/TurtleEgg.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/UnknownBlock.java b/chunky/src/java/se/llbit/chunky/block/minecraft/UnknownBlock.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Vine.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Vine.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Wall.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Wall.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallBanner.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHangingSign.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallSign.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/WallTorch.java b/chunky/src/java/se/llbit/chunky/block/minecraft/WallTorch.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java old mode 100644 new mode 100755 index af92eee9dd..a7c785b8bc --- a/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/Water.java @@ -49,7 +49,6 @@ public Water(int level, int data) { localIntersect = true; specular = 0.12f; ior = 1.333f; - refractive = true; } public Water(int level) { @@ -193,7 +192,7 @@ public boolean isFullBlock() { } } - @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + private boolean testIntersect(Ray2 ray, IntersectionRecord intersectionRecord) { IntersectionRecord intersectionTest = new IntersectionRecord(); int data = intersectionRecord.material instanceof Water ? ((Water) intersectionRecord.material).data : 0; @@ -209,7 +208,7 @@ public boolean isFullBlock() { } } if (hit) { - intersectionRecord.distance += intersectionTest.distance; + intersectionRecord.distance = intersectionTest.distance; } return hit; } @@ -284,12 +283,20 @@ public boolean isFullBlock() { intersectionTest.uv.y = 1 - intersectionTest.uv.y; hit = true; } + if (hit) { + intersectionRecord.distance = intersectionTest.distance; + return true; + } + return false; + } + + @Override public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene scene) { + boolean hit = testIntersect(ray, intersectionRecord); if (hit) { if (!(scene.getCurrentWaterShader() instanceof StillWaterShader) && intersectionRecord.shadeN.y != 0) { scene.getCurrentWaterShader().doWaterShading(ray, intersectionRecord, scene.getAnimationTime()); } texture.getAvgColorLinear(intersectionRecord.color); - intersectionRecord.distance += intersectionTest.distance; } return hit; } @@ -297,4 +304,23 @@ public boolean isFullBlock() { @Override public String description() { return String.format("level=%d", level); } + + @Override + public boolean isInside(Ray2 ray) { + if (isFullBlock()) { + return true; + } else { + Ray2 testRay = new Ray2(ray); + testRay.d.set(0, 1, 0); + IntersectionRecord intersectionRecord = new IntersectionRecord(); + return testIntersect(testRay, intersectionRecord); + } + } + + public boolean isInside(double x, double y, double z) { + Ray2 ray = new Ray2(); + ray.o.set(x, y, z); + return isInside(ray); + } + } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/Wheat.java b/chunky/src/java/se/llbit/chunky/block/minecraft/Wheat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java b/chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java old mode 100644 new mode 100755 index 3a39859f5d..72ab81abcf --- a/chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java +++ b/chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java @@ -20,6 +20,7 @@ import se.llbit.chunky.block.minecraft.*; import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.resources.Texture; +import se.llbit.chunky.world.MaterialType; import se.llbit.math.Octree; import se.llbit.nbt.CompoundTag; import se.llbit.nbt.IntTag; @@ -240,7 +241,7 @@ public static Map> getDefaultMaterialProperties() { block -> { block.specular = 0.255f; block.ior = 1.333f; - block.refractive = true; + block.materialType = MaterialType.DIELECTRIC; }); materialProperties.put( "minecraft:lava", @@ -250,7 +251,7 @@ public static Map> getDefaultMaterialProperties() { Consumer glassConfig = block -> { block.ior = 1.52f; - block.refractive = true; + block.materialType = MaterialType.DIELECTRIC; }; materialProperties.put("minecraft:glass", glassConfig); materialProperties.put("minecraft:glass_pane", glassConfig); @@ -287,54 +288,46 @@ public static Map> getDefaultMaterialProperties() { materialProperties.put("minecraft:red_stained_glass_pane", glassConfig); materialProperties.put("minecraft:black_stained_glass_pane", glassConfig); materialProperties.put("minecraft:gold_block", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.9); }); materialProperties.put("minecraft:raw_gold_block", block -> { - block.metalness = 0.8f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.5); }); materialProperties.put("minecraft:diamond_block", block -> { - block.specular = 0.04f; + block.materialType = MaterialType.DIELECTRIC; }); materialProperties.put("minecraft:iron_block", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.9); }); materialProperties.put("minecraft:raw_iron_block", block -> { - block.metalness = 0.66f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.3); }); materialProperties.put("minecraft:iron_bars", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.9); }); materialProperties.put("minecraft:iron_door", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.8); }); materialProperties.put("minecraft:iron_trapdoor", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.8); }); materialProperties.put("minecraft:cauldron", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.7); }); materialProperties.put("minecraft:hopper", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.7); }); materialProperties.put("minecraft:chain", block -> { - block.specular = 0.04f; - block.metalness = 1.0f; + block.materialType = MaterialType.METAL; block.setPerceptualSmoothness(0.9); }); materialProperties.put("minecraft:redstone_torch", block -> { @@ -358,11 +351,9 @@ public static Map> getDefaultMaterialProperties() { }); materialProperties.put("minecraft:ice", block -> { block.ior = 1.31f; - block.refractive = true; }); materialProperties.put("minecraft:frosted_ice", block -> { block.ior = 1.31f; - block.refractive = true; }); materialProperties.put("minecraft:glowstone", block -> { block.emittance = 1.0f; @@ -386,7 +377,7 @@ public static Map> getDefaultMaterialProperties() { } }); materialProperties.put("minecraft:emerald_block", block -> { - block.specular = 0.04f; + block.materialType = MaterialType.DIELECTRIC; }); materialProperties.put("minecraft:sea_lantern", block -> { block.emittance = 1.0f; diff --git a/chunky/src/java/se/llbit/chunky/chunk/ChunkData.java b/chunky/src/java/se/llbit/chunky/chunk/ChunkData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/ChunkLoadingException.java b/chunky/src/java/se/llbit/chunky/chunk/ChunkLoadingException.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/EmptyChunkData.java b/chunky/src/java/se/llbit/chunky/chunk/EmptyChunkData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/GenericChunkData.java b/chunky/src/java/se/llbit/chunky/chunk/GenericChunkData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/SimpleChunkData.java b/chunky/src/java/se/llbit/chunky/chunk/SimpleChunkData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/TagBlockBuilder.java b/chunky/src/java/se/llbit/chunky/chunk/TagBlockBuilder.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/biome/BiomeData.java b/chunky/src/java/se/llbit/chunky/chunk/biome/BiomeData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/biome/BiomeData2d.java b/chunky/src/java/se/llbit/chunky/chunk/biome/BiomeData2d.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/biome/BiomeDataFactory.java b/chunky/src/java/se/llbit/chunky/chunk/biome/BiomeDataFactory.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/biome/GenericQuartBiomeData3d.java b/chunky/src/java/se/llbit/chunky/chunk/biome/GenericQuartBiomeData3d.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/biome/QuartBiomeData3d.java b/chunky/src/java/se/llbit/chunky/chunk/biome/QuartBiomeData3d.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/chunk/biome/UnknownBiomeData.java b/chunky/src/java/se/llbit/chunky/chunk/biome/UnknownBiomeData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java b/chunky/src/java/se/llbit/chunky/entity/ArmorStand.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/Armored.java b/chunky/src/java/se/llbit/chunky/entity/Armored.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java b/chunky/src/java/se/llbit/chunky/entity/BeaconBeam.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/Book.java b/chunky/src/java/se/llbit/chunky/entity/Book.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java b/chunky/src/java/se/llbit/chunky/entity/CalibratedSculkSensorAmethyst.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/Campfire.java b/chunky/src/java/se/llbit/chunky/entity/Campfire.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java b/chunky/src/java/se/llbit/chunky/entity/CoralFanEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/Entity.java b/chunky/src/java/se/llbit/chunky/entity/Entity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java b/chunky/src/java/se/llbit/chunky/entity/FlameParticles.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/Geared.java b/chunky/src/java/se/llbit/chunky/entity/Geared.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java b/chunky/src/java/se/llbit/chunky/entity/HeadEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/Lectern.java b/chunky/src/java/se/llbit/chunky/entity/Lectern.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java b/chunky/src/java/se/llbit/chunky/entity/LilyPadEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java b/chunky/src/java/se/llbit/chunky/entity/PaintingEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java b/chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/Poseable.java b/chunky/src/java/se/llbit/chunky/entity/Poseable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java b/chunky/src/java/se/llbit/chunky/entity/SkullEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java b/chunky/src/java/se/llbit/chunky/entity/SporeBlossom.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java b/chunky/src/java/se/llbit/chunky/entity/StandingBanner.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/UVMapHelper.java b/chunky/src/java/se/llbit/chunky/entity/UVMapHelper.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/WallBanner.java b/chunky/src/java/se/llbit/chunky/entity/WallBanner.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallCoralFanEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/main/Chunky.java b/chunky/src/java/se/llbit/chunky/main/Chunky.java old mode 100644 new mode 100755 index 3dc6eade9c..1dd5bb8913 --- a/chunky/src/java/se/llbit/chunky/main/Chunky.java +++ b/chunky/src/java/se/llbit/chunky/main/Chunky.java @@ -61,9 +61,9 @@ import java.util.concurrent.ForkJoinPool; /** - * Chunky is a Minecraft mapping and rendering tool created byJesper Öqvist (jesper@llbit.se). + * Chunky is a Minecraft mapping and rendering tool created by Jesper Öqvist (jesper@llbit.se). * - *

Read more about Chunky at https://chunky.llbit.se. + *

Read more about Chunky at https://chunky-dev.github.io/docs/. */ public class Chunky { static { diff --git a/chunky/src/java/se/llbit/chunky/main/ChunkyOptions.java b/chunky/src/java/se/llbit/chunky/main/ChunkyOptions.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/main/CommandLineOptions.java b/chunky/src/java/se/llbit/chunky/main/CommandLineOptions.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/main/HeadlessErrorTrackingLogger.java b/chunky/src/java/se/llbit/chunky/main/HeadlessErrorTrackingLogger.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/main/SceneHelper.java b/chunky/src/java/se/llbit/chunky/main/SceneHelper.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/main/Version.java b/chunky/src/java/se/llbit/chunky/main/Version.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/main/ZipExportJob.java b/chunky/src/java/se/llbit/chunky/main/ZipExportJob.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/AbstractLayer.java b/chunky/src/java/se/llbit/chunky/map/AbstractLayer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/BiomeLayer.java b/chunky/src/java/se/llbit/chunky/map/BiomeLayer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/BitmapLayer.java b/chunky/src/java/se/llbit/chunky/map/BitmapLayer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/IconLayer.java b/chunky/src/java/se/llbit/chunky/map/IconLayer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/MapBuffer.java b/chunky/src/java/se/llbit/chunky/map/MapBuffer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/MapTile.java b/chunky/src/java/se/llbit/chunky/map/MapTile.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/MapView.java b/chunky/src/java/se/llbit/chunky/map/MapView.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/SurfaceLayer.java b/chunky/src/java/se/llbit/chunky/map/SurfaceLayer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/map/WorldMapLoader.java b/chunky/src/java/se/llbit/chunky/map/WorldMapLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/AABBModel.java b/chunky/src/java/se/llbit/chunky/model/AABBModel.java old mode 100644 new mode 100755 index e680ffd4ed..85be0aff6b --- a/chunky/src/java/se/llbit/chunky/model/AABBModel.java +++ b/chunky/src/java/se/llbit/chunky/model/AABBModel.java @@ -3,6 +3,7 @@ import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.chunky.world.Material; import se.llbit.math.AABB; import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; @@ -13,6 +14,7 @@ import java.util.Arrays; import java.util.List; import java.util.Random; +import java.util.function.Predicate; /** * A block model that is made out of textured AABBs. @@ -83,7 +85,7 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene for (int i = 0; i < boxes.length; ++i) { if (boxes[i].intersect(ray, intersectionRecord)) { Tint[] tintedFacesBox = tintedFaces != null ? tintedFaces[i] : null; - Vector3 n = intersectionRecord.n; + Vector3 n = intersectionRecord.shadeN; if (n.y > 0) { // top intersectionRecord.uv.x = 1 - intersectionRecord.uv.x; if (intersectFace(intersectionRecord, scene, textures[i][4], @@ -94,7 +96,8 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene } } else if (n.y < 0) { // bottom if (intersectFace(intersectionRecord, scene, textures[i][5], - mapping != null ? mapping[i][5] : null)) { + mapping != null ? mapping[i][5] : null + )) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[5] : Tint.NONE; } @@ -114,13 +117,15 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene } } else if (n.x < 0) { // west if (intersectFace(intersectionRecord, scene, textures[i][3], - mapping != null ? mapping[i][3] : null)) { + mapping != null ? mapping[i][3] : null + )) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[3] : Tint.NONE; } } else if (n.x > 0) { // east if (intersectFace(intersectionRecord, scene, textures[i][1], - mapping != null ? mapping[i][1] : null)) { + mapping != null ? mapping[i][1] : null + )) { hit = true; tint = tintedFacesBox != null ? tintedFacesBox[1] : Tint.NONE; } @@ -128,6 +133,11 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene } } if (hit) { + Vector3 o = new Vector3(ray.o); + o.scaleAdd(intersectionRecord.distance + Constants.OFFSET, ray.d); + if (isInside(o)) { + return false; + } if (intersectionRecord.material.opaque) { intersectionRecord.color.w = 1; } @@ -139,12 +149,13 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene return hit; } - private boolean intersectFace(IntersectionRecord intersectionRecord, Scene scene, Texture texture, UVMapping mapping) { + public boolean intersectFace(IntersectionRecord intersectionRecord, Scene scene, Texture texture, UVMapping mapping) { // This is the method that handles intersecting faces of all AABB-based models. // Do normal mapping, parallax occlusion mapping, specular maps and all the good stuff here! if (texture == null) { - return false; + intersectionRecord.color.set(1, 1, 1, 0); + return true; } double tmp; @@ -176,8 +187,26 @@ private boolean intersectFace(IntersectionRecord intersectionRecord, Scene scene float[] color = texture.getColor(intersectionRecord.uv.x, intersectionRecord.uv.y); if (color[3] > Constants.EPSILON) { intersectionRecord.color.set(color); - return true; + } else { + intersectionRecord.color.set(1, 1, 1, 0); + } + return true; + } + + @Override + public boolean isInside(Ray2 ray) { + AABB[] boxes = getBoxes(); + for (AABB box: boxes) { + if (box.inside(ray.o)) { + return true; + } } return false; } + + public boolean isInside(Vector3 p) { + Ray2 ray = new Ray2(); + ray.o.set(p); + return isInside(ray); + } } diff --git a/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java b/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java old mode 100644 new mode 100755 index b9e619ff49..8b95d143a7 --- a/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java +++ b/chunky/src/java/se/llbit/chunky/model/AnimatedQuadModel.java @@ -58,19 +58,47 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene float[] color = null; Tint tint = Tint.NONE; - for (int i = 0; i < quads.length; ++i) { - Quad quad = quads[i]; - if (quad.intersect(ray, intersectionTest)) { - float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y, j); - if (c[3] > Constants.EPSILON) { - tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; - color = c; - if (quad.doubleSided) { - intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + if (refractive) { + for (int i = 0; i < quads.length; ++i) { + Quad quad = quads[i]; + if (quad.intersect(ray, intersectionTest)) { + if (ray.d.dot(quad.n) < 0) { + float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (c[3] > Constants.EPSILON) { + tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; + color = c; + } else { + tint = Tint.NONE; + color = new float[] {1, 1, 1, 0}; + } } else { - intersectionRecord.setNormal(quad.n); + tint = Tint.NONE; + color = new float[] {1, 1, 1, 0}; } hit = true; + intersectionRecord.setNormal(quad.n); + intersectionRecord.distance = intersectionTest.distance; + } + } + } else { + for (int i = 0; i < quads.length; ++i) { + Quad quad = quads[i]; + double distance = intersectionTest.distance; + if (quad.intersect(ray, intersectionTest)) { + float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (c[3] > Constants.EPSILON) { + tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; + color = c; + if (quad.doubleSided) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + } else { + intersectionRecord.setNormal(quad.n); + } + intersectionRecord.distance = intersectionTest.distance; + hit = true; + } else { + intersectionTest.distance = distance; + } } } } @@ -86,7 +114,6 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene intersectionRecord.color.set(color); tint.tint(intersectionRecord.color, ray, scene); - intersectionRecord.distance += intersectionTest.distance; /*ray.o.scaleAdd(ray.t, ray.d); int x; */ diff --git a/chunky/src/java/se/llbit/chunky/model/BlockModel.java b/chunky/src/java/se/llbit/chunky/model/BlockModel.java old mode 100644 new mode 100755 index 38ee66e0ca..9706231763 --- a/chunky/src/java/se/llbit/chunky/model/BlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/BlockModel.java @@ -2,10 +2,8 @@ import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; -import se.llbit.math.IntersectionRecord; -import se.llbit.math.Ray; -import se.llbit.math.Ray2; -import se.llbit.math.Vector3; +import se.llbit.chunky.world.Material; +import se.llbit.math.*; import java.util.List; import java.util.Random; @@ -20,4 +18,6 @@ public interface BlockModel { void sample(int face, Vector3 loc, Random rand); double faceSurfaceArea(int face); + + boolean isInside(Ray2 ray); } diff --git a/chunky/src/java/se/llbit/chunky/model/DirectionalBlockModel.java b/chunky/src/java/se/llbit/chunky/model/DirectionalBlockModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/FixedTopBottomRotatableTexturedBlockModel.java b/chunky/src/java/se/llbit/chunky/model/FixedTopBottomRotatableTexturedBlockModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/GrassTintedSpriteModel.java b/chunky/src/java/se/llbit/chunky/model/GrassTintedSpriteModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/Model.java b/chunky/src/java/se/llbit/chunky/model/Model.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/QuadModel.java b/chunky/src/java/se/llbit/chunky/model/QuadModel.java old mode 100644 new mode 100755 index deedf4f945..5f871c1fbc --- a/chunky/src/java/se/llbit/chunky/model/QuadModel.java +++ b/chunky/src/java/se/llbit/chunky/model/QuadModel.java @@ -23,9 +23,11 @@ import se.llbit.chunky.plugin.PluginApi; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; +import se.llbit.chunky.world.Material; import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; import se.llbit.math.Quad; +import se.llbit.math.QuickMath; import se.llbit.math.Ray; import se.llbit.math.Ray2; import se.llbit.math.Vector3; @@ -82,6 +84,8 @@ public abstract class QuadModel implements BlockModel { protected static final double E0 = -Constants.EPSILON; protected static final double E1 = 1 + Constants.EPSILON; + public boolean refractive = false; + @PluginApi public abstract Quad[] getQuads(); @@ -119,19 +123,47 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene float[] color = null; Tint tint = Tint.NONE; - for (int i = 0; i < quads.length; ++i) { - Quad quad = quads[i]; - if (quad.intersect(ray, intersectionTest)) { - float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); - if (c[3] > Constants.EPSILON) { - tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; - color = c; - if (quad.doubleSided) { - intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + if (refractive) { + for (int i = 0; i < quads.length; ++i) { + Quad quad = quads[i]; + if (quad.intersect(ray, intersectionTest)) { + if (ray.d.dot(quad.n) < 0) { + float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (c[3] > Constants.EPSILON) { + tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; + color = c; + } else { + tint = Tint.NONE; + color = new float[] {1, 1, 1, 0}; + } } else { - intersectionRecord.setNormal(quad.n); + tint = Tint.NONE; + color = new float[] {1, 1, 1, 0}; } hit = true; + intersectionRecord.setNormal(quad.n); + intersectionRecord.distance = intersectionTest.distance; + } + } + } else { + for (int i = 0; i < quads.length; ++i) { + Quad quad = quads[i]; + double distance = intersectionTest.distance; + if (quad.intersect(ray, intersectionTest)) { + float[] c = textures[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); + if (c[3] > Constants.EPSILON) { + tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; + color = c; + if (quad.doubleSided) { + intersectionRecord.setNormal(VectorUtil.orientNormal(ray.d, quad.n)); + } else { + intersectionRecord.setNormal(quad.n); + } + intersectionRecord.distance = intersectionTest.distance; + hit = true; + } else { + intersectionTest.distance = distance; + } } } } @@ -147,11 +179,31 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Scene intersectionRecord.color.set(color); tint.tint(intersectionRecord.color, ray, scene); - intersectionRecord.distance += intersectionTest.distance; /*ray.o.scaleAdd(ray.t, ray.d); int x; */ } return hit; } + + @Override + public boolean isInside(Ray2 ray) { + if (!refractive) { + return false; + } + + IntersectionRecord intersectionTest = new IntersectionRecord(); + + Quad[] quads = getQuads(); + boolean hit = false; + for (Quad quad : quads) { + if (quad.intersect(ray, intersectionTest)) { + hit = true; + } + } + if (hit) { + return ray.d.dot(intersectionTest.n) > 0; + } + return false; + } } diff --git a/chunky/src/java/se/llbit/chunky/model/RotatableBlockModel.java b/chunky/src/java/se/llbit/chunky/model/RotatableBlockModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java b/chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/Tint.java b/chunky/src/java/se/llbit/chunky/model/Tint.java old mode 100644 new mode 100755 index dbeb5ed3fe..ba468804a3 --- a/chunky/src/java/se/llbit/chunky/model/Tint.java +++ b/chunky/src/java/se/llbit/chunky/model/Tint.java @@ -66,11 +66,23 @@ private float[] getTintColor(Ray2 ray, Scene scene) { case CONSTANT: return this.tint; case BIOME_FOLIAGE: - return scene.getFoliageColor((int) (ray.o.x + ray.d.x * Constants.OFFSET), (int) (ray.o.y + ray.d.y * Constants.OFFSET), (int) (ray.o.z + ray.d.z * Constants.OFFSET)); + return scene.getFoliageColor( + (int) (ray.o.x + ray.d.x * Constants.OFFSET), + (int) (ray.o.y + ray.d.y * Constants.OFFSET), + (int) (ray.o.z + ray.d.z * Constants.OFFSET) + ); case BIOME_GRASS: - return scene.getGrassColor((int) (ray.o.x + ray.d.x * Constants.OFFSET), (int) (ray.o.y + ray.d.y * Constants.OFFSET), (int) (ray.o.z + ray.d.z * Constants.OFFSET)); + return scene.getGrassColor( + (int) (ray.o.x + ray.d.x * Constants.OFFSET), + (int) (ray.o.y + ray.d.y * Constants.OFFSET), + (int) (ray.o.z + ray.d.z * Constants.OFFSET) + ); case BIOME_WATER: - return scene.getWaterColor((int) (ray.o.x + ray.d.x * Constants.OFFSET), (int) (ray.o.y + ray.d.y * Constants.OFFSET), (int) (ray.o.z + ray.d.z * Constants.OFFSET)); + return scene.getWaterColor( + (int) (ray.o.x + ray.d.x * Constants.OFFSET), + (int) (ray.o.y + ray.d.y * Constants.OFFSET), + (int) (ray.o.z + ray.d.z * Constants.OFFSET) + ); default: Log.warn("Unsupported tint type " + type); return null; diff --git a/chunky/src/java/se/llbit/chunky/model/TopBottomOrientedTexturedBlockModel.java b/chunky/src/java/se/llbit/chunky/model/TopBottomOrientedTexturedBlockModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/AnvilModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/AnvilModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/AttachedStemModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/AttachedStemModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/AzaleaModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/AzaleaModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BambooModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BambooModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BarrelModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BarrelModel.java old mode 100644 new mode 100755 index ffe39c462e..3312e592a0 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/BarrelModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/BarrelModel.java @@ -56,6 +56,7 @@ public class BarrelModel extends QuadModel { private final Texture[] textures; public BarrelModel(String facing, String open) { + refractive = true; textures = new Texture[] {Texture.barrelSide, Texture.barrelSide, Texture.barrelSide, Texture.barrelSide, open.equals("true") ? Texture.barrelOpen : Texture.barrelTop, Texture.barrelBottom}; switch (facing) { diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BeaconModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BeaconModel.java old mode 100644 new mode 100755 index 891f67d0ed..11cb97f205 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/BeaconModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/BeaconModel.java @@ -20,6 +20,7 @@ import se.llbit.chunky.model.AABBModel; import se.llbit.chunky.resources.Texture; import se.llbit.math.AABB; +import se.llbit.math.Vector3; /** * Beacon block. @@ -49,4 +50,9 @@ public AABB[] getBoxes() { public Texture[][] getTextures() { return textures; } + + @Override + public boolean isInside(Vector3 p) { + return boxes[0].inside(p) && !boxes[1].inside(p) && boxes[2].inside(p); + } } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BedModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BedModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BellModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BellModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BigDripleafModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BigDripleafModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BigDripleafStemModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BigDripleafStemModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/BrewingStandModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/BrewingStandModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ButtonModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ButtonModel.java old mode 100644 new mode 100755 index 7700865158..151ab8af32 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/ButtonModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/ButtonModel.java @@ -57,6 +57,8 @@ public class ButtonModel extends QuadModel { private final Texture[] textures; public ButtonModel(String face, String facing, Texture tex) { + refractive = true; + textures = new Texture[attachedSouth.length]; Arrays.fill(textures, tex); diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CactusModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CactusModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CakeModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CakeModel.java old mode 100644 new mode 100755 index ecafdafeeb..ba70251d3c --- a/chunky/src/java/se/llbit/chunky/model/minecraft/CakeModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/CakeModel.java @@ -27,33 +27,33 @@ public class CakeModel extends QuadModel { private static final Quad[][] cake = new Quad[7][]; static { - int[] fromX = new int[] {1, 3, 5, 7, 9, 11, 13}; - for (int i = 0; i < 7; i++) { - double xMin = fromX[i] / 16.0; - cake[i] = new Quad[]{ - // front - new Quad(new Vector3(.9375, 0, .0625), new Vector3(xMin, 0, .0625), - new Vector3(.9375, .5, .0625), new Vector4(.9375, xMin, 0, .5)), + int[] fromX = new int[] {1, 3, 5, 7, 9, 11, 13}; + for (int i = 0; i < 7; i++) { + double xMin = fromX[i] / 16.0; + cake[i] = new Quad[]{ + // front + new Quad(new Vector3(.9375, 0, .0625), new Vector3(xMin, 0, .0625), + new Vector3(.9375, .5, .0625), new Vector4(.9375, xMin, 0, .5)), - // back - new Quad(new Vector3(xMin, 0, .9375), new Vector3(.9375, 0, .9375), - new Vector3(xMin, .5, .9375), new Vector4(xMin, .9375, 0, .5)), + // back + new Quad(new Vector3(xMin, 0, .9375), new Vector3(.9375, 0, .9375), + new Vector3(xMin, .5, .9375), new Vector4(xMin, .9375, 0, .5)), - // right - new Quad(new Vector3(xMin, 0, .0625), new Vector3(xMin, 0, .9375), - new Vector3(xMin, .5, .0625), new Vector4(0.0625, .9375, 0, .5)), + // right + new Quad(new Vector3(xMin, 0, .0625), new Vector3(xMin, 0, .9375), + new Vector3(xMin, .5, .0625), new Vector4(0.0625, .9375, 0, .5)), - // left - new Quad(new Vector3(.9375, 0, .9375), new Vector3(.9375, 0, .0625), - new Vector3(.9375, .5, .9375), new Vector4(.9375, 0.0625, 0, .5)), + // left + new Quad(new Vector3(.9375, 0, .9375), new Vector3(.9375, 0, .0625), + new Vector3(.9375, .5, .9375), new Vector4(.9375, 0.0625, 0, .5)), - // top - new Quad(new Vector3(.9375, .5, .0625), new Vector3(xMin, .5, .0625), - new Vector3(.9375, .5, .9375), new Vector4(.9375, xMin, .9375, .0625)), + // top + new Quad(new Vector3(.9375, .5, .0625), new Vector3(xMin, .5, .0625), + new Vector3(.9375, .5, .9375), new Vector4(.9375, xMin, .9375, .0625)), - // bottom - new Quad(new Vector3(xMin, 0, .0625), new Vector3(.9375, 0, .0625), - new Vector3(xMin, 0, .9375), new Vector4(xMin, .9375, .0625, .9375)) + // bottom + new Quad(new Vector3(xMin, 0, .0625), new Vector3(.9375, 0, .0625), + new Vector3(xMin, 0, .9375), new Vector4(xMin, .9375, .0625, .9375)) }; } } @@ -62,22 +62,23 @@ public class CakeModel extends QuadModel { private final Texture[] textures; public CakeModel(int bites) { - this.quads = cake[bites]; + refractive = true; - Texture top = Texture.cakeTop; - Texture side = Texture.cakeSide; - Texture bottom = Texture.cakeBottom; - Texture inside = Texture.cakeInside; - textures = new Texture[]{side, side, bites == 0 ? side : inside, side, top, bottom}; + this.quads = cake[bites]; + Texture top = Texture.cakeTop; + Texture side = Texture.cakeSide; + Texture bottom = Texture.cakeBottom; + Texture inside = Texture.cakeInside; + textures = new Texture[]{side, side, bites == 0 ? side : inside, side, top, bottom}; } @Override public Quad[] getQuads() { - return quads; + return quads; } @Override public Texture[] getTextures() { - return textures; + return textures; } } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CakeWithCandleModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CakeWithCandleModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CalibratedSculkSensorModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CalibratedSculkSensorModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CandleModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CandleModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CarpetModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CarpetModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java old mode 100644 new mode 100755 index 53d5c764cd..8ffba1f9d4 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/CauldronModel.java @@ -338,17 +338,20 @@ public class CauldronModel { new Vector3(2 / 16.0, 9 / 16.0, 14 / 16.0), new Vector3(14 / 16.0, 9 / 16.0, 14 / 16.0), new Vector3(2 / 16.0, 9 / 16.0, 2 / 16.0), - new Vector4(2 / 16.0, 14 / 16.0, 1 - 14 / 16.0, 1 - 2 / 16.0)), + new Vector4(2 / 16.0, 14 / 16.0, 1 - 14 / 16.0, 1 - 2 / 16.0), + true), new Quad( new Vector3(2 / 16.0, 12 / 16.0, 14 / 16.0), new Vector3(14 / 16.0, 12 / 16.0, 14 / 16.0), new Vector3(2 / 16.0, 12 / 16.0, 2 / 16.0), - new Vector4(2 / 16.0, 14 / 16.0, 1 - 14 / 16.0, 1 - 2 / 16.0)), + new Vector4(2 / 16.0, 14 / 16.0, 1 - 14 / 16.0, 1 - 2 / 16.0), + true), new Quad( new Vector3(2 / 16.0, 15 / 16.0, 14 / 16.0), new Vector3(14 / 16.0, 15 / 16.0, 14 / 16.0), new Vector3(2 / 16.0, 15 / 16.0, 2 / 16.0), - new Vector4(2 / 16.0, 14 / 16.0, 1 - 14 / 16.0, 1 - 2 / 16.0)) + new Vector4(2 / 16.0, 14 / 16.0, 1 - 14 / 16.0, 1 - 2 / 16.0), + true) }; private static final Texture top = Texture.cauldronTop; @@ -390,7 +393,7 @@ public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, } if (hit) { - intersectionRecord.distance += intersectionTest.distance; + intersectionRecord.distance = intersectionTest.distance; } return hit; } @@ -419,10 +422,11 @@ public static boolean intersectWithWater(Ray2 ray, IntersectionRecord intersecti intersectionRecord.setNormal(water.n); } intersectionRecord.material = Water.INSTANCE; + Texture.water.getAvgColorLinear(intersectionRecord.color); } if (hit) { - intersectionRecord.distance += intersectionRecord.distance; + intersectionRecord.distance = intersectionTest.distance; /*ray.o.scaleAdd(ray.t, ray.d); int x; */ @@ -459,7 +463,7 @@ public static boolean intersectWithLava(Ray2 ray, IntersectionRecord intersectio } if (hit) { - intersectionRecord.distance += intersectionTest.distance; + intersectionRecord.distance = intersectionTest.distance; /*ray.o.scaleAdd(ray.t, ray.d); int x; */ diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ChainModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ChainModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ChestModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ChestModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ChorusFlowerModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ChorusFlowerModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ChorusPlantModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ChorusPlantModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CocoaPlantModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CocoaPlantModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ComparatorModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ComparatorModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ComposterModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ComposterModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ConduitModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ConduitModel.java old mode 100644 new mode 100755 index 6f0296be17..5f0654b68a --- a/chunky/src/java/se/llbit/chunky/model/minecraft/ConduitModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/ConduitModel.java @@ -69,6 +69,10 @@ public class ConduitModel extends QuadModel { Texture.conduit, Texture.conduit, Texture.conduit }; + public ConduitModel() { + refractive = true; + } + @Override public Quad[] getQuads() { return quads; diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/CropsModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/CropsModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/DaylightSensorModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/DaylightSensorModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/DecoratedPotModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/DispenserModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/DispenserModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/DoorModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/DoorModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/DragonEggModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/DragonEggModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/EnchantmentTableModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/EnchantmentTableModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/EndPortalFrameModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/EndPortalFrameModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/EndPortalModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/EndPortalModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/EndRodModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/EndRodModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FenceGateModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FenceGateModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FenceModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FenceModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FireModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FireModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/Flowerbed.java b/chunky/src/java/se/llbit/chunky/model/minecraft/Flowerbed.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FrogspawnModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FrogspawnModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/GlassPaneModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/GlassPaneModel.java old mode 100644 new mode 100755 index 70fb1ad887..1047216721 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/GlassPaneModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/GlassPaneModel.java @@ -34,7 +34,8 @@ public class GlassPaneModel extends QuadModel { new Vector3(7 / 16.0, 16 / 16.0, 9 / 16.0), new Vector3(9 / 16.0, 16 / 16.0, 9 / 16.0), new Vector3(7 / 16.0, 16 / 16.0, 7 / 16.0), - new Vector4(7 / 16.0, 9 / 16.0, 7 / 16.0, 9 / 16.0) + new Vector4(7 / 16.0, 9 / 16.0, 7 / 16.0, 9 / 16.0), + true ), // Bottom @@ -42,7 +43,8 @@ public class GlassPaneModel extends QuadModel { new Vector3(7 / 16.0, 0 / 16.0, 7 / 16.0), new Vector3(9 / 16.0, 0 / 16.0, 7 / 16.0), new Vector3(7 / 16.0, 0 / 16.0, 9 / 16.0), - new Vector4(7 / 16.0, 9 / 16.0, 7 / 16.0, 9 / 16.0) + new Vector4(7 / 16.0, 9 / 16.0, 7 / 16.0, 9 / 16.0), + true ), // North @@ -50,7 +52,8 @@ public class GlassPaneModel extends QuadModel { new Vector3(7 / 16.0, 16 / 16.0, 7 / 16.0), new Vector3(9 / 16.0, 16 / 16.0, 7 / 16.0), new Vector3(7 / 16.0, 0 / 16.0, 7 / 16.0), - new Vector4(7 / 16.0, 9 / 16.0, 16 / 16.0, 0 / 16.0) + new Vector4(7 / 16.0, 9 / 16.0, 16 / 16.0, 0 / 16.0), + true ), null, // East null, // South @@ -67,39 +70,87 @@ public class GlassPaneModel extends QuadModel { // Front side. { // Left face. - new Quad(new Vector3(7 / 16., 1, 7 / 16.), new Vector3(7 / 16., 1, 0), - new Vector3(7 / 16., 0, 7 / 16.), new Vector4(7 / 16., 0, 1, 0)), + new Quad( + new Vector3(7 / 16., 1, 7 / 16.), + new Vector3(7 / 16., 1, 0), + new Vector3(7 / 16., 0, 7 / 16.), + new Vector4(7 / 16., 0, 1, 0) + ), // Right face. - new Quad(new Vector3(9 / 16., 1, 0), new Vector3(9 / 16., 1, 7 / 16.), - new Vector3(9 / 16., 0, 0), new Vector4(0, 7 / 16., 1, 0)), + new Quad( + new Vector3(9 / 16., 1, 0), + new Vector3(9 / 16., 1, 7 / 16.), + new Vector3(9 / 16., 0, 0), + new Vector4(0, 7 / 16., 1, 0) + ), // Top face. - new Quad(new Vector3(9 / 16., 1, 0), new Vector3(7 / 16., 1, 0), - new Vector3(9 / 16., 1, 7 / 16.), new Vector4(9 / 16., 7 / 16., 0, 7 / 16.)), + new Quad( + new Vector3(9 / 16., 1, 0), + new Vector3(7 / 16., 1, 0), + new Vector3(9 / 16., 1, 7 / 16.), + new Vector4(9 / 16., 7 / 16., 0, 7 / 16.) + ), // Bottom face. - new Quad(new Vector3(7 / 16., 0, 0), new Vector3(9 / 16., 0, 0), - new Vector3(7 / 16., 0, 7 / 16.), new Vector4(7 / 16., 9 / 16., 0, 7 / 16.)), + new Quad( + new Vector3(7 / 16., 0, 0), + new Vector3(9 / 16., 0, 0), + new Vector3(7 / 16., 0, 7 / 16.), + new Vector4(7 / 16., 9 / 16., 0, 7 / 16.) + ), + + // Outside face. + new Quad( + new Vector3(9 / 16., 1, 0), + new Vector3(7 / 16., 1, 0), + new Vector3(9 / 16., 0, 0), + new Vector4(9 / 16., 1, 7 / 16., 0) + ) }, // Back side. { // Left face. - new Quad(new Vector3(7 / 16., 1, 1), new Vector3(7 / 16., 1, 9 / 16.), - new Vector3(7 / 16., 0, 1), new Vector4(1, 9 / 16., 1, 0)), + new Quad( + new Vector3(7 / 16., 1, 1), + new Vector3(7 / 16., 1, 9 / 16.), + new Vector3(7 / 16., 0, 1), + new Vector4(1, 9 / 16., 1, 0) + ), // Right face. - new Quad(new Vector3(9 / 16., 1, 9 / 16.), new Vector3(9 / 16., 1, 1), - new Vector3(9 / 16., 0, 9 / 16.), new Vector4(9 / 16., 1, 1, 0)), + new Quad( + new Vector3(9 / 16., 1, 9 / 16.), + new Vector3(9 / 16., 1, 1), + new Vector3(9 / 16., 0, 9 / 16.), + new Vector4(9 / 16., 1, 1, 0) + ), // Top face. - new Quad(new Vector3(9 / 16., 1, 9 / 16.), new Vector3(7 / 16., 1, 9 / 16.), - new Vector3(9 / 16., 1, 1), new Vector4(9 / 16., 7 / 16., 9 / 16., 1)), + new Quad( + new Vector3(9 / 16., 1, 9 / 16.), + new Vector3(7 / 16., 1, 9 / 16.), + new Vector3(9 / 16., 1, 1), + new Vector4(9 / 16., 7 / 16., 9 / 16., 1) + ), // Bottom face. - new Quad(new Vector3(7 / 16., 0, 9 / 16.), new Vector3(9 / 16., 0, 9 / 16.), - new Vector3(7 / 16., 0, 1), new Vector4(7 / 16., 9 / 16., 9 / 16., 1)), + new Quad( + new Vector3(7 / 16., 0, 9 / 16.), + new Vector3(9 / 16., 0, 9 / 16.), + new Vector3(7 / 16., 0, 1), + new Vector4(7 / 16., 9 / 16., 9 / 16., 1) + ), + + // Outside face. + new Quad( + new Vector3(7 / 16., 1, 1), + new Vector3(9 / 16., 1, 1), + new Vector3(7 / 16., 0, 1), + new Vector4(7 / 16., 0, 9 / 16., 1) + ) }, }; @@ -118,12 +169,13 @@ public class GlassPaneModel extends QuadModel { private final Texture[] textures; public GlassPaneModel(Texture top, Texture side, boolean north, boolean south, boolean east, boolean west) { + refractive = true; ArrayList quads = new ArrayList<>(); ArrayList textures = new ArrayList<>(); Consumer addConnector = qs -> { quads.addAll(Arrays.asList(qs)); - textures.addAll(Arrays.asList(side, side, top, top)); + textures.addAll(Arrays.asList(side, side, top, top, new Texture("air"))); }; // Top and bottom diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/GlowLichenModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/GlowLichenModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/GrassBlockModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/GrassBlockModel.java old mode 100644 new mode 100755 index 22872581bc..73589bce71 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/GrassBlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/GrassBlockModel.java @@ -23,14 +23,17 @@ import se.llbit.chunky.model.AABBModel; import se.llbit.chunky.model.Tint; +import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.AABB; +import se.llbit.math.Constants; +import se.llbit.math.IntersectionRecord; public class GrassBlockModel extends AABBModel { private final static Tint[][] tints = new Tint[][] { - {BIOME_GRASS, BIOME_GRASS, BIOME_GRASS, BIOME_GRASS, NONE, NONE}, - {NONE, NONE, NONE, NONE, BIOME_GRASS, NONE} + {NONE, NONE, NONE, NONE, BIOME_GRASS, NONE}, + {BIOME_GRASS, BIOME_GRASS, BIOME_GRASS, BIOME_GRASS, NONE, NONE} }; private final static AABB[] boxes = new AABB[]{ @@ -39,15 +42,15 @@ public class GrassBlockModel extends AABBModel { }; private static final Texture[][] textures = new Texture[][]{ - { - Texture.grassSide, Texture.grassSide, - Texture.grassSide, Texture.grassSide, - null, null - }, { Texture.grassSideSaturated, Texture.grassSideSaturated, Texture.grassSideSaturated, Texture.grassSideSaturated, Texture.grassTop, Texture.dirt + }, + { + Texture.grassSide, Texture.grassSide, + Texture.grassSide, Texture.grassSide, + null, null } }; @@ -65,4 +68,47 @@ public Texture[][] getTextures() { public Tint[][] getTints() { return tints; } + + @Override + public boolean intersectFace(IntersectionRecord intersectionRecord, Scene scene, Texture texture, UVMapping mapping) { + // This is the method that handles intersecting faces of all AABB-based models. + // Do normal mapping, parallax occlusion mapping, specular maps and all the good stuff here! + + if (texture == null) { + return false; + } + + double tmp; + if (mapping != null) { + switch (mapping) { + case ROTATE_90: + tmp = intersectionRecord.uv.x; + intersectionRecord.uv.x = 1 - intersectionRecord.uv.y; + intersectionRecord.uv.y = tmp; + break; + case ROTATE_180: + intersectionRecord.uv.x = 1 - intersectionRecord.uv.x; + intersectionRecord.uv.y = 1 - intersectionRecord.uv.y; + break; + case ROTATE_270: + tmp = intersectionRecord.uv.y; + intersectionRecord.uv.y = 1 - intersectionRecord.uv.x; + intersectionRecord.uv.x = tmp; + break; + case FLIP_U: + intersectionRecord.uv.x = 1 - intersectionRecord.uv.x; + break; + case FLIP_V: + intersectionRecord.uv.y = 1 - intersectionRecord.uv.y; + break; + } + } + + float[] color = texture.getColor(intersectionRecord.uv.x, intersectionRecord.uv.y); + if (color[3] > Constants.EPSILON) { + intersectionRecord.color.set(color); + return true; + } + return false; + } } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/GrassPathModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/GrassPathModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/GrindstoneModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/GrindstoneModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java old mode 100644 new mode 100755 index 66650b78d9..18e342ab83 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/HoneyBlockModel.java @@ -18,86 +18,99 @@ package se.llbit.chunky.model.minecraft; +import se.llbit.chunky.model.QuadModel; import se.llbit.chunky.resources.Texture; import se.llbit.math.*; -public class HoneyBlockModel { +public class HoneyBlockModel extends QuadModel { private static final Quad[] quads = { - new Quad( - new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), - new Vector4(0, 1, 0, 1) - ), - new Quad( - new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector4(0, 1, 0, 1) - ), - new Quad( - new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), - new Vector4(0, 1, 0, 1) - ), - new Quad( - new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector4(0, 1, 0, 1) - ), - new Quad( - new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector4(0, 1, 0, 1) - ), - new Quad( - new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(0 / 16.0, 16 / 16.0, 16 / 16.0), - new Vector4(0, 1, 0, 1) - ), - new Quad( - new Vector3(15 / 16.0, 15 / 16.0, 1 / 16.0), - new Vector3(1 / 16.0, 15 / 16.0, 1 / 16.0), - new Vector3(15 / 16.0, 15 / 16.0, 15 / 16.0), - new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0) - ), - new Quad( - new Vector3(1 / 16.0, 1 / 16.0, 1 / 16.0), - new Vector3(15 / 16.0, 1 / 16.0, 1 / 16.0), - new Vector3(1 / 16.0, 1 / 16.0, 15 / 16.0), - new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0) - ), - new Quad( - new Vector3(15 / 16.0, 1 / 16.0, 15 / 16.0), - new Vector3(15 / 16.0, 1 / 16.0, 1 / 16.0), - new Vector3(15 / 16.0, 15 / 16.0, 15 / 16.0), - new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0) - ), - new Quad( - new Vector3(1 / 16.0, 1 / 16.0, 1 / 16.0), - new Vector3(1 / 16.0, 1 / 16.0, 15 / 16.0), - new Vector3(1 / 16.0, 15 / 16.0, 1 / 16.0), - new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0) - ), - new Quad( - new Vector3(15 / 16.0, 1 / 16.0, 1 / 16.0), - new Vector3(1 / 16.0, 1 / 16.0, 1 / 16.0), - new Vector3(15 / 16.0, 15 / 16.0, 1 / 16.0), - new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0) - ), - new Quad( - new Vector3(1 / 16.0, 1 / 16.0, 15 / 16.0), - new Vector3(15 / 16.0, 1 / 16.0, 15 / 16.0), - new Vector3(1 / 16.0, 15 / 16.0, 15 / 16.0), - new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0) - ), + new Quad( + new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), + new Vector4(0, 1, 0, 1), + true + ), + new Quad( + new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector4(0, 1, 0, 1), + true + ), + new Quad( + new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), + new Vector4(0, 1, 0, 1), + true + ), + new Quad( + new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector4(0, 1, 0, 1), + true + ), + new Quad( + new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector4(0, 1, 0, 1), + true + ), + new Quad( + new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 16 / 16.0), + new Vector4(0, 1, 0, 1), + true + ), + new Quad( + new Vector3(15 / 16.0, 15 / 16.0, 1 / 16.0), + new Vector3(1 / 16.0, 15 / 16.0, 1 / 16.0), + new Vector3(15 / 16.0, 15 / 16.0, 15 / 16.0), + new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0), + true + ), + new Quad( + new Vector3(1 / 16.0, 1 / 16.0, 1 / 16.0), + new Vector3(15 / 16.0, 1 / 16.0, 1 / 16.0), + new Vector3(1 / 16.0, 1 / 16.0, 15 / 16.0), + new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0), + true + ), + new Quad( + new Vector3(15 / 16.0, 1 / 16.0, 15 / 16.0), + new Vector3(15 / 16.0, 1 / 16.0, 1 / 16.0), + new Vector3(15 / 16.0, 15 / 16.0, 15 / 16.0), + new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0), + true + ), + new Quad( + new Vector3(1 / 16.0, 1 / 16.0, 1 / 16.0), + new Vector3(1 / 16.0, 1 / 16.0, 15 / 16.0), + new Vector3(1 / 16.0, 15 / 16.0, 1 / 16.0), + new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0), + true + ), + new Quad( + new Vector3(15 / 16.0, 1 / 16.0, 1 / 16.0), + new Vector3(1 / 16.0, 1 / 16.0, 1 / 16.0), + new Vector3(15 / 16.0, 15 / 16.0, 1 / 16.0), + new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0), + true + ), + new Quad( + new Vector3(1 / 16.0, 1 / 16.0, 15 / 16.0), + new Vector3(15 / 16.0, 1 / 16.0, 15 / 16.0), + new Vector3(1 / 16.0, 15 / 16.0, 15 / 16.0), + new Vector4(1 / 16.0, 15 / 16.0, 1 / 16.0, 15 / 16.0), + true + ), }; - private static final Texture[] tex = { + private static final Texture[] textures = { Texture.honeyBlockBottom, Texture.honeyBlockBottom, Texture.honeyBlockBottom, Texture.honeyBlockBottom, Texture.honeyBlockBottom, Texture.honeyBlockBottom, @@ -105,44 +118,22 @@ public class HoneyBlockModel { Texture.honeyBlockSide, Texture.honeyBlockSide, Texture.honeyBlockSide }; - public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { - IntersectionRecord intersectionTest = new IntersectionRecord(); - boolean hit = false; - Vector4 oldColor = new Vector4(intersectionRecord.color); - for (int i = 6; i < quads.length; ++i) { - Quad quad = quads[i]; - if (quad.intersect(ray, intersectionTest)) { - float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); - if (color[3] > Constants.EPSILON) { - ColorUtil.overlayColor(intersectionRecord.color, color); - intersectionRecord.setNormal(quad.n); - hit = true; - } - } - } - boolean innerHit = hit; - Vector4 innerColor = hit ? new Vector4(intersectionRecord.color) : null; + public HoneyBlockModel() { + refractive = true; + } - intersectionRecord.color.set(oldColor); - hit = false; + @Override + public Quad[] getQuads() { + return quads; + } - for (int i = 0; i < 6; ++i) { - Quad quad = quads[i]; - if (quad.intersect(ray, intersectionTest)) { - float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); - if (color[3] > Constants.EPSILON) { - ColorUtil.overlayColor(intersectionRecord.color, color); - intersectionRecord.setNormal(quad.n); - hit = true; - } - } - } - if (hit) { - intersectionRecord.distance += intersectionTest.distance; - if (innerHit) { - ColorUtil.overlayColor(intersectionRecord.color, innerColor); - } - } - return hit; - } + @Override + public Texture[] getTextures() { + return textures; + } + + @Override + public boolean isInside(Ray2 ray) { + return true; + } } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/HopperModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/HopperModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/IronBarsModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/IronBarsModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/JigsawModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/JigsawModel.java old mode 100644 new mode 100755 index cfc46cdf5d..c8e25904dc --- a/chunky/src/java/se/llbit/chunky/model/minecraft/JigsawModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/JigsawModel.java @@ -100,6 +100,7 @@ public class JigsawModel extends QuadModel { private final Texture[] textures; public JigsawModel(String orientation) { + refractive = true; switch (orientation) { case "up": textures = textureNoLock; diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LadderModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LadderModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LanternModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LanternModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LeafModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LeafModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LeverModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LeverModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LightBlockModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LightBlockModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LightningRodModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LightningRodModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/LogModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/LogModel.java old mode 100644 new mode 100755 index ab5bad7eed..8d7785de73 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/LogModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/LogModel.java @@ -56,6 +56,7 @@ public class LogModel extends QuadModel { private final Texture[] textures; public LogModel(String facing, Texture side, Texture top) { + refractive = true; switch (facing) { case "x": quads = Model.rotateZ(sides); diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/MangrovePropaguleModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/MangrovePropaguleModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/MangroveRootsModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/MangroveRootsModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/NetherPortalModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/NetherPortalModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ObserverModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ObserverModel.java old mode 100644 new mode 100755 index c6a001a472..918cbf445a --- a/chunky/src/java/se/llbit/chunky/model/minecraft/ObserverModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/ObserverModel.java @@ -91,6 +91,7 @@ public class ObserverModel extends QuadModel { private final Texture[] textures; public ObserverModel(int facing, boolean powered) { + refractive = true; quads = faces[facing]; textures = powered ? texturesOn : texturesOff; } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/PistonExtensionModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/PistonExtensionModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/PistonModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/PistonModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherCropBottomModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherCropBottomModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherCropTopModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherCropTopModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherPlantBottomModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherPlantBottomModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherPlantTopModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/PitcherPlantTopModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/PressurePlateModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/PressurePlateModel.java old mode 100644 new mode 100755 index e2edbcae90..2abda0a4bb --- a/chunky/src/java/se/llbit/chunky/model/minecraft/PressurePlateModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/PressurePlateModel.java @@ -57,6 +57,7 @@ public class PressurePlateModel extends QuadModel { private final Texture[] textures = new Texture[quads.length]; public PressurePlateModel(Texture texture) { + refractive = true; Arrays.fill(textures, texture); } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/RailModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/RailModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/RedstoneRepeaterModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/RedstoneRepeaterModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/RedstoneWireModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/RedstoneWireModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ScaffoldingModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ScaffoldingModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SculkSensorModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SculkSensorModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SculkShriekerModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SculkShriekerModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SculkVeinModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SculkVeinModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SeaPickleModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SeaPickleModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SlabModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SlabModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java old mode 100644 new mode 100755 index 1f0a857572..5123c3dd68 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/SlimeBlockModel.java @@ -18,129 +18,120 @@ package se.llbit.chunky.model.minecraft; +import se.llbit.chunky.model.QuadModel; import se.llbit.chunky.resources.Texture; import se.llbit.math.*; -public class SlimeBlockModel { +public class SlimeBlockModel extends QuadModel { private static final Quad[] quads = { - new Quad( - new Vector3(13 / 16.0, 13 / 16.0, 3 / 16.0), - new Vector3(3 / 16.0, 13 / 16.0, 3 / 16.0), - new Vector3(13 / 16.0, 13 / 16.0, 13 / 16.0), - new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0) - ), - new Quad( - new Vector3(3 / 16.0, 3 / 16.0, 3 / 16.0), - new Vector3(13 / 16.0, 3 / 16.0, 3 / 16.0), - new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0), - new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0) - ), - new Quad( - new Vector3(13 / 16.0, 3 / 16.0, 13 / 16.0), - new Vector3(13 / 16.0, 3 / 16.0, 3 / 16.0), - new Vector3(13 / 16.0, 13 / 16.0, 13 / 16.0), - new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0) - ), - new Quad( - new Vector3(3 / 16.0, 3 / 16.0, 3 / 16.0), - new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0), - new Vector3(3 / 16.0, 13 / 16.0, 3 / 16.0), - new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0) - ), - new Quad( - new Vector3(13 / 16.0, 3 / 16.0, 3 / 16.0), - new Vector3(3 / 16.0, 3 / 16.0, 3 / 16.0), - new Vector3(13 / 16.0, 13 / 16.0, 3 / 16.0), - new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0) - ), - new Quad( - new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0), - new Vector3(13 / 16.0, 3 / 16.0, 13 / 16.0), - new Vector3(3 / 16.0, 13 / 16.0, 13 / 16.0), - new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0) - ), - new Quad( - new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), - new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0) - ), - new Quad( - new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0) - ), - new Quad( - new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), - new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0) - ), - new Quad( - new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0) - ), - new Quad( - new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), - new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0) - ), - new Quad( - new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), - new Vector3(0 / 16.0, 16 / 16.0, 16 / 16.0), - new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0) - ), + new Quad( + new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), + new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0), + true + ), + new Quad( + new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0), + true + ), + new Quad( + new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 16 / 16.0), + new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0), + true + ), + new Quad( + new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0), + true + ), + new Quad( + new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 0 / 16.0), + new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0), + true + ), + new Quad( + new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 16 / 16.0), + new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0), + true + ), + new Quad( + new Vector3(13 / 16.0, 13 / 16.0, 3 / 16.0), + new Vector3(3 / 16.0, 13 / 16.0, 3 / 16.0), + new Vector3(13 / 16.0, 13 / 16.0, 13 / 16.0), + new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0), + true + ), + new Quad( + new Vector3(3 / 16.0, 3 / 16.0, 3 / 16.0), + new Vector3(13 / 16.0, 3 / 16.0, 3 / 16.0), + new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0), + new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0), + true + ), + new Quad( + new Vector3(13 / 16.0, 3 / 16.0, 13 / 16.0), + new Vector3(13 / 16.0, 3 / 16.0, 3 / 16.0), + new Vector3(13 / 16.0, 13 / 16.0, 13 / 16.0), + new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0), + true + ), + new Quad( + new Vector3(3 / 16.0, 3 / 16.0, 3 / 16.0), + new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0), + new Vector3(3 / 16.0, 13 / 16.0, 3 / 16.0), + new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0), + true + ), + new Quad( + new Vector3(13 / 16.0, 3 / 16.0, 3 / 16.0), + new Vector3(3 / 16.0, 3 / 16.0, 3 / 16.0), + new Vector3(13 / 16.0, 13 / 16.0, 3 / 16.0), + new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0), + true + ), + new Quad( + new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0), + new Vector3(13 / 16.0, 3 / 16.0, 13 / 16.0), + new Vector3(3 / 16.0, 13 / 16.0, 13 / 16.0), + new Vector4(3 / 16.0, 13 / 16.0, 3 / 16.0, 13 / 16.0), + true + ) }; - private static final Texture[] tex = { - Texture.slime, Texture.slime, Texture.slime, Texture.slime, Texture.slime, Texture.slime, - - Texture.slime, Texture.slime, Texture.slime, Texture.slime, Texture.slime, Texture.slime + private static final Texture[] textures = new Texture[] { + Texture.slime, Texture.slime, Texture.slime, Texture.slime, + Texture.slime, Texture.slime, Texture.slime, Texture.slime, + Texture.slime, Texture.slime, Texture.slime, Texture.slime }; - public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { - IntersectionRecord intersectionTest = new IntersectionRecord(); - boolean hit = false; - Vector4 oldColor = new Vector4(intersectionRecord.color); - for (int i = 0; i < 6; ++i) { - Quad quad = quads[i]; - if (quad.intersect(ray, intersectionTest)) { - float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); - if (color[3] > Constants.EPSILON) { - ColorUtil.overlayColor(intersectionRecord.color, color); - intersectionRecord.setNormal(quad.n); - hit = true; - } - } - } - boolean innerHit = hit; - Vector4 innerColor = hit ? new Vector4(intersectionRecord.color) : null; + public SlimeBlockModel() { + refractive = true; + } - intersectionRecord.color.set(oldColor); - hit = false; + @Override + public Quad[] getQuads() { + return quads; + } + + @Override + public Texture[] getTextures() { + return textures; + } - for (int i = 6; i < quads.length; ++i) { - Quad quad = quads[i]; - if (quad.intersect(ray, intersectionTest)) { - float[] color = tex[i].getColor(intersectionTest.uv.x, intersectionTest.uv.y); - if (color[3] > Constants.EPSILON) { - ColorUtil.overlayColor(intersectionRecord.color, color); - intersectionRecord.setNormal(quad.n); - hit = true; - } - } - } - if (hit) { - intersectionRecord.distance += intersectionTest.distance; - if (innerHit) { - ColorUtil.overlayColor(intersectionRecord.color, innerColor); - } - } - return hit; + @Override + public boolean isInside(Ray2 ray) { + return true; } } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SmallDripleafModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SmallDripleafModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SnifferEggModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SnifferEggModel.java old mode 100644 new mode 100755 index 496078ead7..c5670d0bb8 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/SnifferEggModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/SnifferEggModel.java @@ -90,6 +90,7 @@ public class SnifferEggModel extends QuadModel { private final int age; public SnifferEggModel(int age) { + refractive = true; this.age = QuickMath.clamp(age, 0, 2); } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SnowModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SnowModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SporeBlossomModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SporeBlossomModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java old mode 100644 new mode 100755 index 31dbd32231..c98efa2019 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/SpriteModel.java @@ -79,6 +79,8 @@ public Texture[] getTextures() { return textures; } + // TODO: Are this method and the one below necessary? + public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, Texture material) { boolean hit = false; IntersectionRecord intersectionTest = new IntersectionRecord(); @@ -99,7 +101,7 @@ public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, } if (hit) { intersectionRecord.color.set(color); - intersectionRecord.distance += intersectionTest.distance; + intersectionRecord.distance = intersectionTest.distance; } return hit; } @@ -124,7 +126,7 @@ public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, } if (hit) { intersectionRecord.color.set(color); - intersectionRecord.distance += intersectionTest.distance; + intersectionRecord.distance = intersectionTest.distance; } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/StairModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/StairModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/StemModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/StemModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/StonecutterModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/StonecutterModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/SunFlowerModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/SunFlowerModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/TerracottaModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/TerracottaModel.java old mode 100644 new mode 100755 index abdbe60310..6cfa789b9d --- a/chunky/src/java/se/llbit/chunky/model/minecraft/TerracottaModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/TerracottaModel.java @@ -78,6 +78,7 @@ public class TerracottaModel extends QuadModel { private final Texture[] textures; public TerracottaModel(Texture texture, int direction) { + refractive = true; quads = faces[direction]; textures = new Texture[quads.length]; Arrays.fill(textures, texture); diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/TorchModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/TorchModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/TrapdoorModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/TrapdoorModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/TripwireHookModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/TripwireHookModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/TripwireModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/TripwireModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/TurtleEggModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/TurtleEggModel.java old mode 100644 new mode 100755 index 14b099489d..faf93f0ae6 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/TurtleEggModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/TurtleEggModel.java @@ -192,6 +192,7 @@ public class TurtleEggModel extends QuadModel { private final Texture[] textures; public TurtleEggModel(int eggs, int hatch) { + refractive = true; eggs = Math.max(1, Math.min(egg_models.length, eggs)); hatch = Math.max(0, Math.min(rot.length, hatch)); ArrayList quads = new ArrayList<>(); diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/VineModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/VineModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/WallModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/WallModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java old mode 100644 new mode 100755 index 9f4847340f..802dfdc9d2 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/WaterModel.java @@ -196,7 +196,7 @@ public static boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord, } } if (hit) { - intersectionRecord.distance += intersectionTest.distance; + intersectionRecord.distance = intersectionTest.distance; } return hit; } diff --git a/chunky/src/java/se/llbit/chunky/plugin/ChunkyPlugin.java b/chunky/src/java/se/llbit/chunky/plugin/ChunkyPlugin.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/plugin/ContextMenuTransformer.java b/chunky/src/java/se/llbit/chunky/plugin/ContextMenuTransformer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/plugin/PluginApi.java b/chunky/src/java/se/llbit/chunky/plugin/PluginApi.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/plugin/TabTransformer.java b/chunky/src/java/se/llbit/chunky/plugin/TabTransformer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/ApertureShape.java b/chunky/src/java/se/llbit/chunky/renderer/ApertureShape.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/CameraViewListener.java b/chunky/src/java/se/llbit/chunky/renderer/CameraViewListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/ChunkViewListener.java b/chunky/src/java/se/llbit/chunky/renderer/ChunkViewListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/ConsoleProgressListener.java b/chunky/src/java/se/llbit/chunky/renderer/ConsoleProgressListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/DefaultRenderManager.java b/chunky/src/java/se/llbit/chunky/renderer/DefaultRenderManager.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/EmitterSamplingStrategy.java b/chunky/src/java/se/llbit/chunky/renderer/EmitterSamplingStrategy.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/PathTracingRenderer.java b/chunky/src/java/se/llbit/chunky/renderer/PathTracingRenderer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/Postprocess.java b/chunky/src/java/se/llbit/chunky/renderer/Postprocess.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/PreviewRenderer.java b/chunky/src/java/se/llbit/chunky/renderer/PreviewRenderer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RayTracerFactory.java b/chunky/src/java/se/llbit/chunky/renderer/RayTracerFactory.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/Refreshable.java b/chunky/src/java/se/llbit/chunky/renderer/Refreshable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderContext.java b/chunky/src/java/se/llbit/chunky/renderer/RenderContext.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderContextFactory.java b/chunky/src/java/se/llbit/chunky/renderer/RenderContextFactory.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderController.java b/chunky/src/java/se/llbit/chunky/renderer/RenderController.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderManager.java b/chunky/src/java/se/llbit/chunky/renderer/RenderManager.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderManagerFactory.java b/chunky/src/java/se/llbit/chunky/renderer/RenderManagerFactory.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderMode.java b/chunky/src/java/se/llbit/chunky/renderer/RenderMode.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderStatus.java b/chunky/src/java/se/llbit/chunky/renderer/RenderStatus.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderStatusListener.java b/chunky/src/java/se/llbit/chunky/renderer/RenderStatusListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/RenderWorkerPool.java b/chunky/src/java/se/llbit/chunky/renderer/RenderWorkerPool.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/Renderer.java b/chunky/src/java/se/llbit/chunky/renderer/Renderer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/Repaintable.java b/chunky/src/java/se/llbit/chunky/renderer/Repaintable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/ResetReason.java b/chunky/src/java/se/llbit/chunky/renderer/ResetReason.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/SceneIOProvider.java b/chunky/src/java/se/llbit/chunky/renderer/SceneIOProvider.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/SceneProvider.java b/chunky/src/java/se/llbit/chunky/renderer/SceneProvider.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/SceneStatusListener.java b/chunky/src/java/se/llbit/chunky/renderer/SceneStatusListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/SnapshotControl.java b/chunky/src/java/se/llbit/chunky/renderer/SnapshotControl.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/SunSamplingStrategy.java b/chunky/src/java/se/llbit/chunky/renderer/SunSamplingStrategy.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java b/chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/WaterShadingStrategy.java b/chunky/src/java/se/llbit/chunky/renderer/WaterShadingStrategy.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/WorkerState.java b/chunky/src/java/se/llbit/chunky/renderer/WorkerState.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/export/PfmExportFormat.java b/chunky/src/java/se/llbit/chunky/renderer/export/PfmExportFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/export/PictureExportFormat.java b/chunky/src/java/se/llbit/chunky/renderer/export/PictureExportFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/export/PictureExportFormats.java b/chunky/src/java/se/llbit/chunky/renderer/export/PictureExportFormats.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/export/PngExportFormat.java b/chunky/src/java/se/llbit/chunky/renderer/export/PngExportFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/export/Tiff32ExportFormat.java b/chunky/src/java/se/llbit/chunky/renderer/export/Tiff32ExportFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/ACESFilmicFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/ACESFilmicFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/GammaCorrectionFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/GammaCorrectionFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/HableToneMappingFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/HableToneMappingFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/NoneFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/NoneFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PixelPostProcessingFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PixelPostProcessingFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilters.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilters.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PreviewFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PreviewFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/SimplePixelPostProcessingFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/SimplePixelPostProcessingFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/Tonemap1Filter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/Tonemap1Filter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/UE4ToneMappingFilter.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/UE4ToneMappingFilter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ApertureProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/FisheyeProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ForwardDisplacementProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PanoramicSlotProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ParallelProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/PinholeProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ProjectionMode.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ProjectionMode.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/Projector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/ShiftProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/SphericalApertureProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/StereographicProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSSinglePerspectiveProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/ODSVerticalStackedProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java b/chunky/src/java/se/llbit/chunky/renderer/projection/stereo/OmniDirectionalStereoProjector.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/AbstractDumpFormat.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/AbstractDumpFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/ClassicDumpFormat.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/ClassicDumpFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/DumpFormat.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/DumpFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/FloatingPointCompressorDumpFormat.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/FloatingPointCompressorDumpFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/GzipDumpFormat.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/GzipDumpFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/HuffmanDumpFormat.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/HuffmanDumpFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/PixelConsumer.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/PixelConsumer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/RenderDump.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/RenderDump.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/renderdump/UncompressedDumpFormat.java b/chunky/src/java/se/llbit/chunky/renderer/renderdump/UncompressedDumpFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/AlphaBuffer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/AlphaBuffer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/AsynchronousSceneManager.java b/chunky/src/java/se/llbit/chunky/renderer/scene/AsynchronousSceneManager.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/CameraPreset.java b/chunky/src/java/se/llbit/chunky/renderer/scene/CameraPreset.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/ChunkFinalizer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/ChunkFinalizer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/EntityLoadingPreferences.java b/chunky/src/java/se/llbit/chunky/renderer/scene/EntityLoadingPreferences.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/FogLayer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/FogLayer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/FogMode.java b/chunky/src/java/se/llbit/chunky/renderer/scene/FogMode.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/LegacyWaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/LegacyWaterShader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/NishitaSky.java b/chunky/src/java/se/llbit/chunky/renderer/scene/NishitaSky.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java old mode 100644 new mode 100755 index 38e4365e70..68db8b3ae0 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java @@ -16,6 +16,7 @@ */ package se.llbit.chunky.renderer.scene; +import se.llbit.chunky.block.Block; import se.llbit.chunky.block.minecraft.Lava; import se.llbit.chunky.block.minecraft.Water; import se.llbit.chunky.chunk.BlockPalette; diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java old mode 100644 new mode 100755 index 1fc9e19138..ededfeffa5 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/PathTracer.java @@ -17,9 +17,11 @@ */ package se.llbit.chunky.renderer.scene; +import se.llbit.chunky.block.Block; import se.llbit.chunky.block.minecraft.Air; import se.llbit.chunky.block.minecraft.Water; import se.llbit.chunky.renderer.WorkerState; +import se.llbit.chunky.world.Material; import se.llbit.math.*; import java.util.Random; @@ -36,8 +38,8 @@ public class PathTracer implements RayTracer { */ @Override public void trace(Scene scene, WorkerState state) { Ray2 ray = state.ray; - ray.setCurrentMedium(scene.getWorldMaterial(ray.o)); - pathTrace(scene, ray, state, true); + ray.setCurrentMedium(scene.getWorldMaterial(ray)); + pathTrace(scene, ray, state); } /** @@ -46,8 +48,7 @@ public class PathTracer implements RayTracer { * @param firstReflection {@code true} if the ray has not yet hit the first * diffuse or specular reflection */ - public static void pathTrace(Scene scene, Ray2 ray, WorkerState state, - boolean firstReflection) { + public static void pathTrace(Scene scene, Ray2 ray, WorkerState state) { Random random = state.random; // Vector3 ox = new Vector3(ray.o); // Vector3 od = new Vector3(ray.d); @@ -62,19 +63,20 @@ public static void pathTrace(Scene scene, Ray2 ray, WorkerState state, if (scene.intersect(ray, intersectionRecord)) { - if (intersectionRecord.material.setOutboundDir(ray, intersectionRecord, random)) { - rayDepth--; + double emittance = intersectionRecord.material.emittance; + ray.o.scaleAdd(intersectionRecord.distance, ray.d); + if (!intersectionRecord.material.scatter(ray, intersectionRecord, random)) { + //rayDepth--; + emittance = 0; } - ray.o.add(ray.d.x * (intersectionRecord.distance - Constants.OFFSET), ray.d.y * (intersectionRecord.distance - Constants.OFFSET), ray.d.z * (intersectionRecord.distance - Constants.OFFSET)); - throughput.x *= intersectionRecord.color.x; throughput.y *= intersectionRecord.color.y; throughput.z *= intersectionRecord.color.z; - cumulativeColor.x += intersectionRecord.color.x * intersectionRecord.material.emittance * scene.emitterIntensity * throughput.x; - cumulativeColor.y += intersectionRecord.color.y * intersectionRecord.material.emittance * scene.emitterIntensity * throughput.y; - cumulativeColor.z += intersectionRecord.color.z * intersectionRecord.material.emittance * scene.emitterIntensity * throughput.z; + cumulativeColor.x += intersectionRecord.color.x * emittance * scene.emitterIntensity * throughput.x; + cumulativeColor.y += intersectionRecord.color.y * emittance * scene.emitterIntensity * throughput.y; + cumulativeColor.z += intersectionRecord.color.z * emittance * scene.emitterIntensity * throughput.z; } else { scene.sky.getSkyColor(ray, intersectionRecord); diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PlayerModel.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PlayerModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PreethamSky.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PreethamSky.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java old mode 100644 new mode 100755 index 3f31cb237c..8db993b73c --- a/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/PreviewRayTracer.java @@ -17,10 +17,12 @@ */ package se.llbit.chunky.renderer.scene; +import se.llbit.chunky.block.Block; import se.llbit.chunky.block.minecraft.Air; import se.llbit.chunky.block.MinecraftBlock; import se.llbit.chunky.block.minecraft.Water; import se.llbit.chunky.renderer.WorkerState; +import se.llbit.chunky.world.Material; import se.llbit.math.Constants; import se.llbit.math.IntersectionRecord; import se.llbit.math.Ray; @@ -39,20 +41,21 @@ public class PreviewRayTracer implements RayTracer { @Override public void trace(Scene scene, WorkerState state) { Ray2 ray = state.ray; IntersectionRecord intersectionRecord; - ray.setCurrentMedium(scene.getWorldMaterial(ray.o)); + ray.setCurrentMedium(scene.getWorldMaterial(ray)); while (true) { - intersectionRecord = new IntersectionRecord(); + intersectionRecord = new IntersectionRecord(); if (!scene.intersect(ray, intersectionRecord)) { - if (mapIntersection(scene, ray, intersectionRecord)) { - break; - } + mapIntersection(scene, ray, intersectionRecord); break; - } else if (intersectionRecord.material != Air.INSTANCE && intersectionRecord.color.w > 0) { + } else if (!intersectionRecord.material.isSameMaterial(ray.getCurrentMedium())) { ray.o.scaleAdd((intersectionRecord.distance), ray.d); break; - } else { + } /*else { ray.o.scaleAdd((intersectionRecord.distance + Constants.OFFSET), ray.d); - } + if (intersectionRecord.material.refractive) { + ray.setCurrentMedium(intersectionRecord.material); + } + }*/ } if (intersectionRecord.material == Air.INSTANCE) { diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/RayTracer.java b/chunky/src/java/se/llbit/chunky/renderer/scene/RayTracer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/RenderResetHandler.java b/chunky/src/java/se/llbit/chunky/renderer/scene/RenderResetHandler.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java old mode 100644 new mode 100755 index fd1beaf77f..919a7ed3ef --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java @@ -693,12 +693,12 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { ray.d.set(0, 1, 0); } +// if (entities.intersect(ray, intersectionRecord)) { +// hit = true; +// } if (worldIntersection(ray, intersectionRecord)) { hit = true; } - if (entities.intersect(ray, intersectionRecord)) { - hit = true; - } if (hit) { /*ray.distance += ray.t; ray.o.scaleAdd(ray.t, ray.d);*/ @@ -711,33 +711,33 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { private boolean worldIntersection(Ray2 ray, IntersectionRecord intersectionRecord) { boolean hit = false; IntersectionRecord intersectionTest = new IntersectionRecord(); - if (worldOctree.enterBlock(this, ray, intersectionTest, palette) - && intersectionTest.distance < intersectionRecord.distance - Constants.EPSILON) { + if (worldOctree.enterBlock(this, ray, intersectionTest, palette)) { intersectionRecord.distance = intersectionTest.distance; intersectionRecord.setNormal(intersectionTest.shadeN); intersectionRecord.color.set(intersectionTest.color); intersectionRecord.material = intersectionTest.material; hit = true; } - intersectionTest = new IntersectionRecord(); - if (ray.getCurrentMedium().isWater()) { - if (waterOctree.exitWater(this, ray, intersectionTest, palette)) { - intersectionRecord.distance = intersectionTest.distance; - intersectionRecord.setNormal(intersectionTest.shadeN); - intersectionRecord.color.set(intersectionTest.color); - intersectionRecord.material = intersectionTest.material; - hit = true; - } - } else { - if (waterOctree.enterBlock(this, ray, intersectionTest, palette) - && intersectionTest.distance < intersectionRecord.distance - Constants.EPSILON) { - intersectionRecord.distance = intersectionTest.distance; - intersectionRecord.setNormal(intersectionTest.shadeN); - intersectionRecord.color.set(intersectionTest.color); - intersectionRecord.material = intersectionTest.material; - hit = true; - } - } +// intersectionTest = new IntersectionRecord(); +// if (ray.getCurrentMedium().isWater()) { +// if (waterOctree.exitWater(this, ray, intersectionTest, palette) +// && intersectionTest.distance < intersectionRecord.distance - Constants.EPSILON) { +// intersectionRecord.distance = intersectionTest.distance; +// intersectionRecord.setNormal(intersectionTest.shadeN); +// intersectionRecord.color.set(intersectionTest.color); +// intersectionRecord.material = intersectionTest.material; +// hit = true; +// } +// } else { +// if (waterOctree.enterBlock(this, ray, intersectionTest, palette) +// && intersectionTest.distance < intersectionRecord.distance - Constants.EPSILON) { +// intersectionRecord.distance = intersectionTest.distance; +// intersectionRecord.setNormal(intersectionTest.shadeN); +// intersectionRecord.color.set(intersectionTest.color); +// intersectionRecord.material = intersectionTest.material; +// hit = true; +// } +// } return hit; } @@ -1689,22 +1689,27 @@ synchronized public void clearResetFlags() { public boolean traceTarget(Ray2 ray, IntersectionRecord intersectionRecord) { WorkerState state = new WorkerState(); state.ray = ray; - if (isInWater(ray)) { - ray.setCurrentMedium(Water.INSTANCE); - } else { - ray.setCurrentMedium(Air.INSTANCE); - } camera.getTargetDirection(ray); ray.o.x -= origin.x; ray.o.y -= origin.y; ray.o.z -= origin.z; - while (intersect(ray, intersectionRecord)) { - if (intersectionRecord.material != Air.INSTANCE) { + ray.setCurrentMedium(getWorldMaterial(ray)); + while (true) { + IntersectionRecord intersectionTest = new IntersectionRecord(); + if (!intersect(ray, intersectionTest)) { + break; + } else if (!intersectionTest.material.isSameMaterial(ray.getCurrentMedium()) && intersectionTest.color.w > Constants.EPSILON) { + ray.o.scaleAdd((intersectionTest.distance), ray.d); + intersectionRecord.material = intersectionTest.material; + intersectionRecord.setNormal(intersectionTest.n); + intersectionRecord.distance = intersectionTest.distance; return true; + } else { + ray.o.scaleAdd((intersectionTest.distance + Constants.OFFSET), ray.d); + if (!intersectionTest.material.isSameMaterial(ray.getCurrentMedium())) { + ray.setCurrentMedium(intersectionTest.material); + } } - ray.o.add(ray.d.x * (intersectionRecord.distance + Constants.OFFSET), - ray.d.x * (intersectionRecord.distance + Constants.OFFSET), - ray.d.x * (intersectionRecord.distance + Constants.OFFSET)); } return false; } @@ -2519,15 +2524,22 @@ public boolean shouldSaveSnapshots() { return saveSnapshots; } - public Material getWorldMaterial(Vector3 point) { - int x = (int) QuickMath.floor(point.x); - int y = (int) QuickMath.floor(point.y); - int z = (int) QuickMath.floor(point.z); - Material material = waterOctree.getMaterial(x, y, z, palette); - if (!material.isWater()) { - material = worldOctree.getMaterial(x, y, z, palette); + public Material getWorldMaterial(Ray2 ray) { + int x = (int) QuickMath.floor(ray.o.x); + int y = (int) QuickMath.floor(ray.o.y); + int z = (int) QuickMath.floor(ray.o.z); + Material waterMat = waterOctree.getMaterial(x, y, z, palette); + Material material = worldOctree.getMaterial(x, y, z, palette); + if (material != Air.INSTANCE && material instanceof Block && ((Block) material).isInside(ray)) { + return material; + } else if (waterMat.isWater()) { + if (((Water) waterMat).isFullBlock()) { + return Water.INSTANCE; + } else if (((Water) waterMat).isInside(ray)) { + return Water.INSTANCE; + } } - return material; + return Air.INSTANCE; } public boolean isInWater(Ray2 ray) { @@ -3246,6 +3258,16 @@ public void setPerceptualSmoothness(String materialName, float value) { refresh(ResetReason.MATERIALS_CHANGED); } + /** + * Modifies the transmission roughness property for the given material. + */ + public void setPerceptualTransmissionSmoothness(String materialName, float value) { + JsonObject material = materials.getOrDefault(materialName, new JsonObject()).object(); + material.set("transmissionRoughness", Json.of(Math.pow(1 - value, 2))); + materials.put(materialName, material); + refresh(ResetReason.MATERIALS_CHANGED); + } + /** * Modifies the metalness property for the given material. */ diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SceneFactory.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SceneFactory.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SceneManager.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SceneManager.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SimplexWaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SimplexWaterShader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SimulatedSky.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SimulatedSky.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Sky.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Sky.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SkyCache.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SkyCache.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/StillWaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/StillWaterShader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/SynchronousSceneManager.java b/chunky/src/java/se/llbit/chunky/renderer/scene/SynchronousSceneManager.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/WaterShader.java b/chunky/src/java/se/llbit/chunky/renderer/scene/WaterShader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/biome/BiomeStructure.java b/chunky/src/java/se/llbit/chunky/renderer/scene/biome/BiomeStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/biome/Trivial2dBiomeStructure.java b/chunky/src/java/se/llbit/chunky/renderer/scene/biome/Trivial2dBiomeStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/biome/Trivial3dBiomeStructure.java b/chunky/src/java/se/llbit/chunky/renderer/scene/biome/Trivial3dBiomeStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/biome/WorldTexture2dBiomeStructure.java b/chunky/src/java/se/llbit/chunky/renderer/scene/biome/WorldTexture2dBiomeStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/AbstractHdriTexture.java b/chunky/src/java/se/llbit/chunky/resources/AbstractHdriTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/AnimatedTexture.java b/chunky/src/java/se/llbit/chunky/resources/AnimatedTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/BinaryBitmapImage.java b/chunky/src/java/se/llbit/chunky/resources/BinaryBitmapImage.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/BitmapImage.java b/chunky/src/java/se/llbit/chunky/resources/BitmapImage.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/ChiseledBookshelfTexture.java b/chunky/src/java/se/llbit/chunky/resources/ChiseledBookshelfTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/EntityTexture.java b/chunky/src/java/se/llbit/chunky/resources/EntityTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/HDRTexture.java b/chunky/src/java/se/llbit/chunky/resources/HDRTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/OctreeFileFormat.java b/chunky/src/java/se/llbit/chunky/resources/OctreeFileFormat.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/PFMTexture.java b/chunky/src/java/se/llbit/chunky/resources/PFMTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/PalettizedBitmapImage.java b/chunky/src/java/se/llbit/chunky/resources/PalettizedBitmapImage.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/PlayerTexture.java b/chunky/src/java/se/llbit/chunky/resources/PlayerTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/ResourcePackBiomeLoader.java b/chunky/src/java/se/llbit/chunky/resources/ResourcePackBiomeLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/ResourcePackLoader.java b/chunky/src/java/se/llbit/chunky/resources/ResourcePackLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/ResourcePackTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/ResourcePackTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/ShulkerTexture.java b/chunky/src/java/se/llbit/chunky/resources/ShulkerTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/SignTexture.java b/chunky/src/java/se/llbit/chunky/resources/SignTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/SolidColorTexture.java b/chunky/src/java/se/llbit/chunky/resources/SolidColorTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/Texture.java b/chunky/src/java/se/llbit/chunky/resources/Texture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/TextureCache.java b/chunky/src/java/se/llbit/chunky/resources/TextureCache.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/TexturePackLoader.java b/chunky/src/java/se/llbit/chunky/resources/TexturePackLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/AllTextures.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/AllTextures.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/AlternateTextures.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/AlternateTextures.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/AnimatedTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/AnimatedTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/AsciiFontTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/AsciiFontTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/BedTextureAdapter.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/BedTextureAdapter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/ChestTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/ChestTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/CloudsTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/CloudsTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/ColoredTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/ColoredTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/ConditionalTextures.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/ConditionalTextures.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/EntityTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/EntityTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/FoliageColorTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/FoliageColorTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/FontTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/FontTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/GrassColorTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/GrassColorTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/IndexedTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/IndexedTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/JsonFontTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/JsonFontTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/LargeChestTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/LargeChestTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/LayeredTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/LayeredTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingBackTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingBackTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingTextureAdapter.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/PaintingTextureAdapter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/PlayerTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/PlayerTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/RotatedTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/RotatedTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/ShulkerTextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/ShulkerTextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/SimpleTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/SimpleTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/SplitLargeChestTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/SplitLargeChestTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/TextureFormatError.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/TextureFormatError.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/TextureLoader.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/TextureLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/TexturePath.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/TexturePath.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java b/chunky/src/java/se/llbit/chunky/ui/ChunkMap.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/ChunkyFx.java b/chunky/src/java/se/llbit/chunky/ui/ChunkyFx.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/HyperlinkMenuItem.java b/chunky/src/java/se/llbit/chunky/ui/HyperlinkMenuItem.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/Icons.java b/chunky/src/java/se/llbit/chunky/ui/Icons.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/ProgressTracker.java b/chunky/src/java/se/llbit/chunky/ui/ProgressTracker.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/RenderCanvasFx.java b/chunky/src/java/se/llbit/chunky/ui/RenderCanvasFx.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/TableSortConfigSerializer.java b/chunky/src/java/se/llbit/chunky/ui/TableSortConfigSerializer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/UILogReceiver.java b/chunky/src/java/se/llbit/chunky/ui/UILogReceiver.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java b/chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/CreditsController.java b/chunky/src/java/se/llbit/chunky/ui/controller/CreditsController.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/RenderControlsFxController.java b/chunky/src/java/se/llbit/chunky/ui/controller/RenderControlsFxController.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/ResourcePackChooserController.java b/chunky/src/java/se/llbit/chunky/ui/controller/ResourcePackChooserController.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/SceneChooserController.java b/chunky/src/java/se/llbit/chunky/ui/controller/SceneChooserController.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/WorldChooserController.java b/chunky/src/java/se/llbit/chunky/ui/controller/WorldChooserController.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/ChunkyErrorDialog.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/ChunkyErrorDialog.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/Credits.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/Credits.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/DialogUtils.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/DialogUtils.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/Poser.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/Poser.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/ResourcePackChooser.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/ResourcePackChooser.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/SceneChooser.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/SceneChooser.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/SelectChunksInRadiusDialog.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/SelectChunksInRadiusDialog.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/SettingsExport.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/SettingsExport.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/ShutdownAlert.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/ShutdownAlert.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/ValidatingTextInputDialog.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/ValidatingTextInputDialog.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/dialogs/WorldChooser.java b/chunky/src/java/se/llbit/chunky/ui/dialogs/WorldChooser.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/elements/AngleAdjuster.java b/chunky/src/java/se/llbit/chunky/ui/elements/AngleAdjuster.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/elements/GradientEditor.java b/chunky/src/java/se/llbit/chunky/ui/elements/GradientEditor.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/elements/SizeInput.java b/chunky/src/java/se/llbit/chunky/ui/elements/SizeInput.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/elements/TextFieldLabelWrapper.java b/chunky/src/java/se/llbit/chunky/ui/elements/TextFieldLabelWrapper.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/RenderControlsTab.java b/chunky/src/java/se/llbit/chunky/ui/render/RenderControlsTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/RenderControlsTabTransformer.java b/chunky/src/java/se/llbit/chunky/ui/render/RenderControlsTabTransformer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/settings/LayeredFogSettings.java b/chunky/src/java/se/llbit/chunky/ui/render/settings/LayeredFogSettings.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/settings/SkyboxSettings.java b/chunky/src/java/se/llbit/chunky/ui/render/settings/SkyboxSettings.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/settings/SkymapSettings.java b/chunky/src/java/se/llbit/chunky/ui/render/settings/SkymapSettings.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/settings/UniformFogSettings.java b/chunky/src/java/se/llbit/chunky/ui/render/settings/UniformFogSettings.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/AdvancedTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/AdvancedTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/CameraTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/GeneralTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/GeneralTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/HelpTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/HelpTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/LightingTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/LightingTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/MaterialsTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/MaterialsTab.java old mode 100644 new mode 100755 index a1644556ee..865aee8834 --- a/chunky/src/java/se/llbit/chunky/ui/render/tabs/MaterialsTab.java +++ b/chunky/src/java/se/llbit/chunky/ui/render/tabs/MaterialsTab.java @@ -53,6 +53,7 @@ public class MaterialsTab extends HBox implements RenderControlsTab, Initializab private final DoubleAdjuster specular = new DoubleAdjuster(); private final DoubleAdjuster ior = new DoubleAdjuster(); private final DoubleAdjuster perceptualSmoothness = new DoubleAdjuster(); + private final DoubleAdjuster perceptualTransmissionSmoothness = new DoubleAdjuster(); private final DoubleAdjuster metalness = new DoubleAdjuster(); private final ListView listView; @@ -66,9 +67,13 @@ public MaterialsTab() { ior.setName("IoR"); ior.setRange(0, 5); ior.setTooltip("Index of Refraction of the selected material."); + ior.setMaximumFractionDigits(6); perceptualSmoothness.setName("Smoothness"); perceptualSmoothness.setRange(0, 1); perceptualSmoothness.setTooltip("Smoothness of the selected material."); + perceptualTransmissionSmoothness.setName("Transmission smoothness"); + perceptualTransmissionSmoothness.setRange(0, 1); + perceptualTransmissionSmoothness.setTooltip("Smoothness of the selected material applied to light transmission."); metalness.setName("Metalness"); metalness.setRange(0, 1); metalness.setTooltip("Metalness (texture-tinted reflectivity) of the selected material."); @@ -87,7 +92,7 @@ public MaterialsTab() { settings.setSpacing(10); settings.getChildren().addAll( new Label("Material Properties"), - emittance, specular, perceptualSmoothness, ior, metalness, + emittance, specular, perceptualSmoothness, perceptualTransmissionSmoothness, ior, metalness, new Label("(set to zero to disable)")); setPadding(new Insets(10)); setSpacing(15); @@ -116,6 +121,7 @@ private void updateSelectedMaterial(String materialName) { double specAcc = 0; double iorAcc = 0; double perceptualSmoothnessAcc = 0; + double perceptualTransmissionSmoothnessAcc = 0; double metalnessAcc = 0; Collection blocks = MaterialStore.collections.get(materialName); for (Block block : blocks) { @@ -123,12 +129,14 @@ private void updateSelectedMaterial(String materialName) { specAcc += block.specular; iorAcc += block.ior; perceptualSmoothnessAcc += block.getPerceptualSmoothness(); + perceptualTransmissionSmoothnessAcc += block.getPerceptualTransmissionSmoothness(); metalnessAcc += block.metalness; } emittance.set(emAcc / blocks.size()); specular.set(specAcc / blocks.size()); ior.set(iorAcc / blocks.size()); perceptualSmoothness.set(perceptualSmoothnessAcc / blocks.size()); + perceptualTransmissionSmoothness.set(perceptualTransmissionSmoothnessAcc / blocks.size()); metalness.set(metalnessAcc / blocks.size()); materialExists = true; } else if (ExtraMaterials.idMap.containsKey(materialName)) { @@ -138,6 +146,7 @@ private void updateSelectedMaterial(String materialName) { specular.set(material.specular); ior.set(material.ior); perceptualSmoothness.set(material.getPerceptualSmoothness()); + perceptualTransmissionSmoothness.set(material.getPerceptualTransmissionSmoothness()); metalness.set(material.metalness); materialExists = true; } @@ -148,6 +157,7 @@ private void updateSelectedMaterial(String materialName) { specular.set(block.specular); ior.set(block.ior); perceptualSmoothness.set(block.getPerceptualSmoothness()); + perceptualTransmissionSmoothness.set(block.getPerceptualTransmissionSmoothness()); metalness.set(block.metalness); materialExists = true; } @@ -156,12 +166,14 @@ private void updateSelectedMaterial(String materialName) { specular.onValueChange(value -> scene.setSpecular(materialName, value.floatValue())); ior.onValueChange(value -> scene.setIor(materialName, value.floatValue())); perceptualSmoothness.onValueChange(value -> scene.setPerceptualSmoothness(materialName, value.floatValue())); + perceptualTransmissionSmoothness.onValueChange(value -> scene.setPerceptualTransmissionSmoothness(materialName, value.floatValue())); metalness.onValueChange(value -> scene.setMetalness(materialName, value.floatValue())); } else { emittance.onValueChange(value -> {}); specular.onValueChange(value -> {}); ior.onValueChange(value -> {}); perceptualSmoothness.onValueChange(value -> {}); + perceptualTransmissionSmoothness.onValueChange(value -> {}); metalness.onValueChange(value -> {}); } } diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/PostprocessingTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/PostprocessingTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/SkyTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/SkyTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/TexturesTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/TexturesTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/WaterTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/WaterTab.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/BlockData.java b/chunky/src/java/se/llbit/chunky/world/BlockData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/Chunk.java b/chunky/src/java/se/llbit/chunky/world/Chunk.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkDataSource.java b/chunky/src/java/se/llbit/chunky/world/ChunkDataSource.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkHeightmap.java b/chunky/src/java/se/llbit/chunky/world/ChunkHeightmap.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkPosition.java b/chunky/src/java/se/llbit/chunky/world/ChunkPosition.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkSelectionListener.java b/chunky/src/java/se/llbit/chunky/world/ChunkSelectionListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkSelectionTracker.java b/chunky/src/java/se/llbit/chunky/world/ChunkSelectionTracker.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkTexture.java b/chunky/src/java/se/llbit/chunky/world/ChunkTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkTopographyUpdater.java b/chunky/src/java/se/llbit/chunky/world/ChunkTopographyUpdater.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkVersion.java b/chunky/src/java/se/llbit/chunky/world/ChunkVersion.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ChunkView.java b/chunky/src/java/se/llbit/chunky/world/ChunkView.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/Clouds.java b/chunky/src/java/se/llbit/chunky/world/Clouds.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/CubicDimension.java b/chunky/src/java/se/llbit/chunky/world/CubicDimension.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/Dimension.java b/chunky/src/java/se/llbit/chunky/world/Dimension.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/EmptyChunk.java b/chunky/src/java/se/llbit/chunky/world/EmptyChunk.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/EmptyDimension.java b/chunky/src/java/se/llbit/chunky/world/EmptyDimension.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/EmptyRegionChunk.java b/chunky/src/java/se/llbit/chunky/world/EmptyRegionChunk.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/EmptyWorld.java b/chunky/src/java/se/llbit/chunky/world/EmptyWorld.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java b/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/Heightmap.java b/chunky/src/java/se/llbit/chunky/world/Heightmap.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/Icon.java b/chunky/src/java/se/llbit/chunky/world/Icon.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/ImposterCubicChunk.java b/chunky/src/java/se/llbit/chunky/world/ImposterCubicChunk.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/Material.java b/chunky/src/java/se/llbit/chunky/world/Material.java old mode 100644 new mode 100755 index f4725485dd..7ca2e65429 --- a/chunky/src/java/se/llbit/chunky/world/Material.java +++ b/chunky/src/java/se/llbit/chunky/world/Material.java @@ -17,6 +17,7 @@ package se.llbit.chunky.world; import org.apache.commons.math3.util.FastMath; +import se.llbit.chunky.block.minecraft.Air; import se.llbit.chunky.resources.Texture; import se.llbit.json.JsonObject; import se.llbit.json.JsonString; @@ -29,9 +30,12 @@ import se.llbit.math.Vector3; import java.util.Random; +import java.util.Vector; public abstract class Material { + public MaterialType materialType = MaterialType.LAMBERTIAN; + /** * Index of refraction of air. */ @@ -58,11 +62,6 @@ public abstract class Material { */ public boolean solid = true; - /** - * The specular coefficient controlling how shiny the block appears. - */ - public float specular = 0; - /** * The amount of light the material emits. */ @@ -74,14 +73,14 @@ public abstract class Material { */ public float roughness = 0f; + public float transmissionRoughness = 0f; + + public Vector3 specularColor = new Vector3(); + /** - * The metalness value controls how metal-y a block appears. In reality this is a boolean value - * but in practice usually a float is used in PBR to allow adding dirt or scratches on metals - * without increasing the texture resolution. - * Metals only do specular reflection for certain wavelengths (effectively tinting the reflection) - * and have no diffuse reflection. The albedo color is used for tinting. + * Texture alpha multiplier. */ - public float metalness = 0; + public float alpha = 1f; /** * Subsurface scattering property. @@ -93,8 +92,6 @@ public abstract class Material { */ public final Texture texture; - public boolean refractive = false; - public boolean waterlogged = false; public Material(String name, Texture texture) { @@ -106,13 +103,15 @@ public Material(String name, Texture texture) { * Restore the default material properties. */ public void restoreDefaults() { + materialType = MaterialType.LAMBERTIAN; ior = DEFAULT_IOR; opaque = false; solid = true; - specular = 0; emittance = 0; roughness = 0; + transmissionRoughness = 0; subSurfaceScattering = false; + alpha = 1; } public void getColor(IntersectionRecord intersectionRecord) { @@ -128,11 +127,12 @@ public JsonValue toJson() { } public void loadMaterialProperties(JsonObject json) { + materialType = MaterialType.valueOf(json.get("materialType").asString(MaterialType.LAMBERTIAN.getId())); ior = json.get("ior").floatValue(ior); - specular = json.get("specular").floatValue(specular); emittance = json.get("emittance").floatValue(emittance); roughness = json.get("roughness").floatValue(roughness); - metalness = json.get("metalness").floatValue(metalness); + transmissionRoughness = json.get("transmissionRoughness").floatValue(transmissionRoughness); + alpha = json.get("alpha").floatValue(alpha); } public boolean isWater() { @@ -155,32 +155,223 @@ public void setPerceptualSmoothness(double perceptualSmoothness) { roughness = (float) Math.pow(1 - perceptualSmoothness, 2); } - public boolean setOutboundDir(Ray2 ray, IntersectionRecord intersectionRecord, Random random) { - Material currentMat = intersectionRecord.material; + public double getPerceptualTransmissionSmoothness() { + return 1 - Math.sqrt(transmissionRoughness); + } + + public void setPerceptualTransmissionSmoothness(double perceptualTransmissionSmoothness) { + transmissionRoughness = (float) Math.pow(1 - perceptualTransmissionSmoothness, 2); + } + + public boolean scatter(Ray2 ray, IntersectionRecord intersectionRecord, Random random) { + + boolean mediumChanged = false; + Vector3 direction = new Vector3(); + + switch (materialType) { + case LAMBERTIAN: { + if (intersectionRecord.color.w < Constants.EPSILON) { + ray.o.scaleAdd(-Constants.OFFSET, intersectionRecord.n); + return false; + } + + direction = intersectionRecord.shadeN.rAdd(Vector3.randomUnitVector(random)); + if (direction.nearZero()) { + direction.set(intersectionRecord.shadeN); + } else { + direction.normalize(); + } + break; + } + + case DIELECTRIC: { + double n2 = intersectionRecord.material.ior; + double n1 = ray.getCurrentMedium().ior; + double ri = (intersectionRecord.shadeN.dot(ray.d) > 0) ? (n1 / n2) : (n2 / n1); + + Vector3 unitDirection = ray.d.normalized(); + double cosTheta = FastMath.min(unitDirection.rScale(-1).dot(intersectionRecord.shadeN), 1.0); + double sinTheta = FastMath.sqrt(1.0 - cosTheta * cosTheta); + + boolean cannotRefract = ri * sinTheta > 1.0; + + if (cannotRefract || schlickReflectance(cosTheta, ri) > random.nextDouble()) { + direction = specularReflection(unitDirection, intersectionRecord.shadeN); + } else { + direction = specularRefraction(unitDirection, intersectionRecord.shadeN, ri); + mediumChanged = true; + } + + break; + } + + case METAL: { + direction = specularReflection(ray.d, intersectionRecord.shadeN); + if (roughness > Constants.EPSILON) { + Vector3 randomDir = randomHemisphereDir(intersectionRecord.shadeN, random); + randomDir.scale(roughness); + randomDir.scaleAdd(1 - roughness, direction); + randomDir.normalize(); + direction.set(randomDir); + } + + if (QuickMath.signum(intersectionRecord.n.dot(direction)) == QuickMath.signum(intersectionRecord.n.dot(ray.d))) { + double factor = QuickMath.signum(intersectionRecord.n.dot(ray.d)) * -Constants.EPSILON - direction.dot(intersectionRecord.n); + direction.scaleAdd(factor, intersectionRecord.n); + direction.normalize(); + } + + break; + } + } + + int sign; + if (mediumChanged) { + sign = -1; + ray.setCurrentMedium(this); + } else { + sign = 1; + } + if (QuickMath.signum(intersectionRecord.n.dot(direction)) == sign * QuickMath.signum(intersectionRecord.n.dot(ray.d))) { + double factor = QuickMath.signum(intersectionRecord.n.dot(ray.d)) * -Constants.EPSILON - direction.dot(intersectionRecord.n); + direction.scaleAdd(factor, intersectionRecord.n); + direction.normalize(); + } + ray.d.set(direction); + + int sign2 = QuickMath.signum(ray.d.dot(intersectionRecord.n)); + ray.o.scaleAdd(sign * sign2 * Constants.OFFSET, intersectionRecord.n); + + return true; + + /*Material currentMat = this; Material prevMat = ray.getCurrentMedium(); double pDiffuse = intersectionRecord.color.w; float pSpecular = currentMat.specular; float pMetal = currentMat.metalness; - float roughness = currentMat.roughness; + float roughness = Math.max(currentMat.roughness, prevMat.roughness); + float transmissionRoughness = Math.max(currentMat.transmissionRoughness, prevMat.transmissionRoughness); float n1 = prevMat.ior; float n2 = currentMat.ior; - if (pDiffuse + pSpecular < Constants.EPSILON && n1 != n2) { - ray.o.add(ray.d.x * Constants.OFFSET, ray.d.y * Constants.OFFSET, ray.d.z * Constants.OFFSET); - return true; - } + Vector3 invDir = new Vector3(ray.d); + invDir.scale(-1); - if (pMetal > Constants.EPSILON && random.nextFloat() < pMetal) { - ray.d.set(specularReflection(ray, intersectionRecord, random)); - } else if (pSpecular > Constants.EPSILON && random.nextFloat() < pSpecular) { - ray.d.set(specularReflection(ray, intersectionRecord, random)); - intersectionRecord.color.set(1, 1, 1, 1); - } else { +// if (pDiffuse + pSpecular < Constants.EPSILON){// && (n1 - n2 <= DEFAULT_IOR)) { +// ray.o.scaleAdd(Constants.OFFSET, ray.d); +// if (currentMat.refractive) { +// ray.setCurrentMedium(currentMat); +// if (currentMat == Air.INSTANCE) { +// intersectionRecord.color.set(1, 0.5, 0.5, 0); +// } +// } +// return true; +// } + + boolean doMetal = pMetal > Constants.EPSILON && random.nextFloat() < pMetal; + + if (doMetal || pSpecular > Constants.EPSILON && random.nextFloat() < pSpecular) { + double sign = QuickMath.signum(ray.d.dot(intersectionRecord.n)); + ray.o.scaleAdd(-sign * Constants.OFFSET, intersectionRecord.n); + + if (!doMetal) { + intersectionRecord.color.set(1, 1, 1, 1); + } + + Vector3 direction = specularReflection(invDir, intersectionRecord.shadeN); + + if (QuickMath.signum(intersectionRecord.n.dot(direction)) == QuickMath.signum(intersectionRecord.n.dot(ray.d))) { + double factor = QuickMath.signum(intersectionRecord.n.dot(ray.d)) * -Constants.EPSILON - ray.d.dot(direction); + direction.scaleAdd(factor, intersectionRecord.n); + } + direction.normalize(); + + ray.d.set(direction); + + } else if (pDiffuse > Constants.EPSILON && random.nextFloat() < pDiffuse) { + ray.o.scaleAdd(Constants.OFFSET, intersectionRecord.n); ray.d.set(diffuseReflection(intersectionRecord, random)); + + } else if (Math.abs(n1 - n2) > DEFAULT_IOR - 1) { + double sign = QuickMath.signum(ray.d.dot(intersectionRecord.n)); + + double eta = n2 / n1; + if (!(pMetal > Constants.EPSILON && random.nextFloat() < pMetal)) { + intersectionRecord.color.set(1, 1, 1, 0); + } + + Vector3 direction = new Vector3(); + + double cosTheta_i = ray.d.dot(intersectionRecord.shadeN); + double factor = FrDielectric(cosTheta_i, eta); + if (specularRefraction(invDir, intersectionRecord.shadeN, eta, direction)) { + if (random.nextDouble() < factor) { + ray.o.scaleAdd(sign * Constants.OFFSET, intersectionRecord.n); + ray.d.set(direction); + intersectionRecord.color.scale(1 - factor); + ray.setCurrentMedium(this); + } else { + ray.o.scaleAdd(-sign * Constants.OFFSET, intersectionRecord.n); + ray.d.set(specularReflection(invDir, intersectionRecord.shadeN)); + intersectionRecord.color.scale(factor); + } + + } else { + ray.o.scaleAdd(-sign * Constants.OFFSET, intersectionRecord.n); + ray.d.set(specularReflection(invDir, intersectionRecord.shadeN)); + intersectionRecord.color.scale(factor); + } + + } else if (pDiffuse > Constants.EPSILON) { + double sign = QuickMath.signum(ray.d.dot(intersectionRecord.n)); + ray.o.scaleAdd(sign * Constants.OFFSET, intersectionRecord.n); + + } else { + double sign = QuickMath.signum(ray.d.dot(intersectionRecord.n)); + ray.o.scaleAdd(sign * Constants.OFFSET, intersectionRecord.n); + intersectionRecord.color.set(1, 1, 1, 0); } - return false; + return false;*/ + } + + private static boolean shouldRefract(Vector3 wi, Vector3 normal, double eta, Vector3 wt) { + double cosTheta_i = normal.dot(wi); + if (cosTheta_i < 0) { + eta = 1 / eta; + cosTheta_i = -cosTheta_i; + normal.scale(-1); + } + double sin2Theta_i = Math.max(0, 1 - cosTheta_i * cosTheta_i); + double sin2Theta_t = sin2Theta_i / (eta * eta); + if (sin2Theta_t >= 1) { + return false; + } + double cosTheta_t = Math.sqrt(Math.max(0.0, 1 - sin2Theta_t)); + wt.x = -wi.x / eta + (cosTheta_i / eta - cosTheta_t) * normal.x; + wt.y = -wi.y / eta + (cosTheta_i / eta - cosTheta_t) * normal.y; + wt.z = -wi.z / eta + (cosTheta_i / eta - cosTheta_t) * normal.z; + return true; + } + + private static double FrDielectric(double cosTheta_i, double eta) { + cosTheta_i = QuickMath.clamp(cosTheta_i, -1, 1); + if (cosTheta_i < 0) { + eta = 1 / eta; + cosTheta_i = -cosTheta_i; + } + + double sin2Theta_i = 1 - cosTheta_i * cosTheta_i; + double sin2Theta_t = sin2Theta_i / (eta * eta); + if (sin2Theta_t >= 1) { + return 1.0; + } + double cosTheta_t = Math.sqrt(Math.max(0.0, 1 - sin2Theta_t)); + + double r_parl = (eta * cosTheta_i - cosTheta_t) / (eta * cosTheta_i + cosTheta_t); + double r_perp = (cosTheta_i - eta * cosTheta_t) / (cosTheta_i + eta * cosTheta_t); + return (r_parl * r_parl + r_perp * r_perp) / 2; } private Vector3 randomHemisphereDir(Vector3 normal, Random random) { @@ -189,6 +380,7 @@ private Vector3 randomHemisphereDir(Vector3 normal, Random random) { double r = FastMath.sqrt(x1); double theta = 2 * FastMath.PI * x2; + // project to point on hemisphere in tangent space double tx = r * FastMath.cos(theta); double ty = r * FastMath.sin(theta); double tz = FastMath.sqrt(1 - x1); @@ -232,24 +424,71 @@ private Vector3 diffuseReflection(IntersectionRecord intersectionRecord, Random return randomHemisphereDir(intersectionRecord.shadeN, random); } - private Vector3 specularReflection(Ray2 ray, IntersectionRecord intersectionRecord, Random random) { - Vector3 direction = new Vector3(ray.d); - Vector3 normal = new Vector3(intersectionRecord.shadeN); - normal.scale(-2 * direction.dot(normal)); - direction.add(normal); + private Vector3 specularReflection(Vector3 v, Vector3 n) { + return v.rSub(n.rScale(2 * v.dot(n))); + } + + private static double schlickReflectance(double cosine, double refractionIndex) { + double r0 = (1 - refractionIndex) / (1 + refractionIndex); + r0 = r0 * r0; + return r0 + (1 - r0) * FastMath.pow((1 - cosine), 5); + } - if (intersectionRecord.material.roughness > Constants.EPSILON) { - Vector3 randomHemisphereDir = randomHemisphereDir(intersectionRecord.shadeN, random); - randomHemisphereDir.scale(intersectionRecord.material.roughness); - direction.scale(1 - intersectionRecord.material.roughness); - direction.add(randomHemisphereDir); + private Vector3 specularRefraction(Vector3 uv, Vector3 n, double etaiOverEtat) { + double cosTheta = FastMath.min(uv.rScale(-1).dot(n), 1.0); + Vector3 rOutPerp = n.rScale(cosTheta).rAdd(uv).rScale(etaiOverEtat); + Vector3 rOutParallel = n.rScale(-FastMath.sqrt(FastMath.abs(1.0 - rOutPerp.lengthSquared()))); + return rOutPerp.rAdd(rOutParallel); + } + + private boolean specularRefraction(Vector3 wi, Vector3 n, double eta, Vector3 wt) { + double cosTheta_i = wi.dot(n); + + if (cosTheta_i < 0) { + eta = 1 / eta; + cosTheta_i = -cosTheta_i; + n.scale(-1); } - if (QuickMath.signum(intersectionRecord.n.dot(direction)) == QuickMath.signum(intersectionRecord.n.dot(ray.d))) { - double factor = QuickMath.signum(intersectionRecord.n.dot(ray.d)) * -Constants.EPSILON - ray.d.dot(direction); - direction.scaleAdd(factor, intersectionRecord.n); + double sin2Theta_i = FastMath.max(0, 1 - cosTheta_i * cosTheta_i); + double sin2Theta_t = sin2Theta_i / (eta * eta); + + if (sin2Theta_t >= 1) { + return false; } - direction.normalize(); - return direction; + + double cosTheta_t = FastMath.sqrt(FastMath.max(0, 1 - sin2Theta_t)); + + Vector3 n2 = new Vector3(n); + Vector3 wi2 = new Vector3(wi); + + n2.scale(eta + (cosTheta_i / eta - cosTheta_t)); + + wi2.scale(-1); + wi2.scale(1 / eta); + + wt.add(n2, wi2); + + return true; + + // double sign = QuickMath.signum(ray.d.dot(intersectionRecord.n)); +// Vector3 invDir = new Vector3(-ray.d.x, -ray.d.y, -ray.d.z); +// Vector3 direction = new Vector3(); +// double factor = FrDielectric(-ray.d.dot(intersectionRecord.shadeN), eta); +// if (!shouldRefract(invDir, intersectionRecord.shadeN, eta, direction)) { +// ray.o.scaleAdd(-sign * Constants.OFFSET, intersectionRecord.n); +// direction.set(specularReflection(ray, intersectionRecord, random, roughness)); +// } else { +// if (random.nextDouble() > factor) { +// ray.o.scaleAdd(-sign * Constants.OFFSET, intersectionRecord.n); +// direction.set(specularReflection(ray, intersectionRecord, random, roughness)); +// intersectionRecord.color.scale(factor); +// } else { +// ray.o.scaleAdd(sign * Constants.OFFSET, intersectionRecord.n); +// intersectionRecord.color.scale(1 - factor); +// ray.setCurrentMedium(this); +// } +// } +// ray.d.set(direction); } } diff --git a/chunky/src/java/se/llbit/chunky/world/MaterialStore.java b/chunky/src/java/se/llbit/chunky/world/MaterialStore.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/MaterialType.java b/chunky/src/java/se/llbit/chunky/world/MaterialType.java index fca2989ebf..d1dc9ff460 100644 --- a/chunky/src/java/se/llbit/chunky/world/MaterialType.java +++ b/chunky/src/java/se/llbit/chunky/world/MaterialType.java @@ -1,4 +1,33 @@ package se.llbit.chunky.world; -public enum MaterialType { +import se.llbit.util.Registerable; + +public enum MaterialType implements Registerable { + + LAMBERTIAN("Lambertian", ""), + DIELECTRIC("Dielectric", ""), + METAL("Metal", ""); + + private final String displayName; + private final String description; + + MaterialType(String displayName, String description) { + this.displayName = displayName; + this.description = description; + } + + @Override + public String getName() { + return this.displayName; + } + + @Override + public String getDescription() { + return this.description; + } + + @Override + public String getId() { + return this.name(); + } } diff --git a/chunky/src/java/se/llbit/chunky/world/PlayerEntityData.java b/chunky/src/java/se/llbit/chunky/world/PlayerEntityData.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/SkymapTexture.java b/chunky/src/java/se/llbit/chunky/world/SkymapTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/World.java b/chunky/src/java/se/llbit/chunky/world/World.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/WorldScanner.java b/chunky/src/java/se/llbit/chunky/world/WorldScanner.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/WorldTexture.java b/chunky/src/java/se/llbit/chunky/world/WorldTexture.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/biome/ArrayBiomePalette.java b/chunky/src/java/se/llbit/chunky/world/biome/ArrayBiomePalette.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/biome/Biome.java b/chunky/src/java/se/llbit/chunky/world/biome/Biome.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/biome/BiomeBuilder.java b/chunky/src/java/se/llbit/chunky/world/biome/BiomeBuilder.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/biome/BiomePalette.java b/chunky/src/java/se/llbit/chunky/world/biome/BiomePalette.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/biome/Biomes.java b/chunky/src/java/se/llbit/chunky/world/biome/Biomes.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/biome/MapBiomePalette.java b/chunky/src/java/se/llbit/chunky/world/biome/MapBiomePalette.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/listeners/ChunkDeletionListener.java b/chunky/src/java/se/llbit/chunky/world/listeners/ChunkDeletionListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/listeners/ChunkTopographyListener.java b/chunky/src/java/se/llbit/chunky/world/listeners/ChunkTopographyListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/listeners/ChunkUpdateListener.java b/chunky/src/java/se/llbit/chunky/world/listeners/ChunkUpdateListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/material/BeaconBeamMaterial.java b/chunky/src/java/se/llbit/chunky/world/material/BeaconBeamMaterial.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/material/CloudMaterial.java b/chunky/src/java/se/llbit/chunky/world/material/CloudMaterial.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/material/LilyPadMaterial.java b/chunky/src/java/se/llbit/chunky/world/material/LilyPadMaterial.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/material/TextureMaterial.java b/chunky/src/java/se/llbit/chunky/world/material/TextureMaterial.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/model/Cube.java b/chunky/src/java/se/llbit/chunky/world/model/Cube.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/model/CubeModel.java b/chunky/src/java/se/llbit/chunky/world/model/CubeModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/model/Face.java b/chunky/src/java/se/llbit/chunky/world/model/Face.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/model/JsonModel.java b/chunky/src/java/se/llbit/chunky/world/model/JsonModel.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/ChunkReadException.java b/chunky/src/java/se/llbit/chunky/world/region/ChunkReadException.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/EmptyRegion.java b/chunky/src/java/se/llbit/chunky/world/region/EmptyRegion.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/ImposterCubicRegion.java b/chunky/src/java/se/llbit/chunky/world/region/ImposterCubicRegion.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/MCRegion.java b/chunky/src/java/se/llbit/chunky/world/region/MCRegion.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/MCRegionChangeWatcher.java b/chunky/src/java/se/llbit/chunky/world/region/MCRegionChangeWatcher.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/Region.java b/chunky/src/java/se/llbit/chunky/world/region/Region.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/RegionChangeWatcher.java b/chunky/src/java/se/llbit/chunky/world/region/RegionChangeWatcher.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/RegionParser.java b/chunky/src/java/se/llbit/chunky/world/region/RegionParser.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/chunky/world/region/RegionQueue.java b/chunky/src/java/se/llbit/chunky/world/region/RegionQueue.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/fxutil/ColumnsBoxBuilder.java b/chunky/src/java/se/llbit/fxutil/ColumnsBoxBuilder.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/fxutil/Dialogs.java b/chunky/src/java/se/llbit/fxutil/Dialogs.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/fxutil/FxImageUtil.java b/chunky/src/java/se/llbit/fxutil/FxImageUtil.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/fxutil/GroupedChangeListener.java b/chunky/src/java/se/llbit/fxutil/GroupedChangeListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/pfm/PfmFileWriter.java b/chunky/src/java/se/llbit/imageformats/pfm/PfmFileWriter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/png/CrcOutputStream.java b/chunky/src/java/se/llbit/imageformats/png/CrcOutputStream.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/png/IDAT.java b/chunky/src/java/se/llbit/imageformats/png/IDAT.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/png/IEND.java b/chunky/src/java/se/llbit/imageformats/png/IEND.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/png/IHDR.java b/chunky/src/java/se/llbit/imageformats/png/IHDR.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/png/ITXT.java b/chunky/src/java/se/llbit/imageformats/png/ITXT.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/png/PngChunk.java b/chunky/src/java/se/llbit/imageformats/png/PngChunk.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/png/PngFileWriter.java b/chunky/src/java/se/llbit/imageformats/png/PngFileWriter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/tiff/BasicIFD.java b/chunky/src/java/se/llbit/imageformats/tiff/BasicIFD.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/tiff/CompressionType.java b/chunky/src/java/se/llbit/imageformats/tiff/CompressionType.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/tiff/FinalizableBFCOutputStream.java b/chunky/src/java/se/llbit/imageformats/tiff/FinalizableBFCOutputStream.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/tiff/IFDTag.java b/chunky/src/java/se/llbit/imageformats/tiff/IFDTag.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/tiff/ImageFileDirectory.java b/chunky/src/java/se/llbit/imageformats/tiff/ImageFileDirectory.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/imageformats/tiff/TiffFileWriter.java b/chunky/src/java/se/llbit/imageformats/tiff/TiffFileWriter.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/AABB.java b/chunky/src/java/se/llbit/math/AABB.java old mode 100644 new mode 100755 index 9677bd096e..e5a2e405f8 --- a/chunky/src/java/se/llbit/math/AABB.java +++ b/chunky/src/java/se/llbit/math/AABB.java @@ -101,89 +101,84 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { double u, v; boolean hit = false; - double tNext = Double.POSITIVE_INFINITY; - t = (xmin - ix) / ray.d.x; - if (t < tNext && t > -Constants.EPSILON) { + if (t < intersectionRecord.distance + Constants.OFFSET && t > -Constants.EPSILON) { u = iz + ray.d.z * t; v = iy + ray.d.y * t; if (u >= zmin && u <= zmax && v >= ymin && v <= ymax) { hit = true; - tNext = t; + intersectionRecord.distance = t; intersectionRecord.uv.x = u; intersectionRecord.uv.y = v; intersectionRecord.setNormal(-1, 0, 0); } } t = (xmax - ix) / ray.d.x; - if (t < tNext && t > -Constants.EPSILON) { + if (t < intersectionRecord.distance + Constants.OFFSET && t > -Constants.EPSILON) { u = iz + ray.d.z * t; v = iy + ray.d.y * t; if (u >= zmin && u <= zmax && v >= ymin && v <= ymax) { hit = true; - tNext = t; + intersectionRecord.distance = t; intersectionRecord.uv.x = 1 - u; intersectionRecord.uv.y = v; intersectionRecord.setNormal(1, 0, 0); } } t = (ymin - iy) / ray.d.y; - if (t < tNext && t > -Constants.EPSILON) { + if (t < intersectionRecord.distance + Constants.OFFSET && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iz + ray.d.z * t; if (u >= xmin && u <= xmax && v >= zmin && v <= zmax) { hit = true; - tNext = t; + intersectionRecord.distance = t; intersectionRecord.uv.x = u; intersectionRecord.uv.y = v; intersectionRecord.setNormal(0, -1, 0); } } t = (ymax - iy) / ray.d.y; - if (t < tNext && t > -Constants.EPSILON) { + if (t < intersectionRecord.distance + Constants.OFFSET && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iz + ray.d.z * t; if (u >= xmin && u <= xmax && v >= zmin && v <= zmax) { hit = true; - tNext = t; + intersectionRecord.distance = t; intersectionRecord.uv.x = u; intersectionRecord.uv.y = v; intersectionRecord.setNormal(0, 1, 0); } } t = (zmin - iz) / ray.d.z; - if (t < tNext && t > -Constants.EPSILON) { + if (t < intersectionRecord.distance + Constants.OFFSET && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iy + ray.d.y * t; if (u >= xmin && u <= xmax && v >= ymin && v <= ymax) { hit = true; - tNext = t; + intersectionRecord.distance = t; intersectionRecord.uv.x = 1 - u; intersectionRecord.uv.y = v; intersectionRecord.setNormal(0, 0, -1); } } t = (zmax - iz) / ray.d.z; - if (t < tNext && t > -Constants.EPSILON) { + if (t < intersectionRecord.distance + Constants.OFFSET && t > -Constants.EPSILON) { u = ix + ray.d.x * t; v = iy + ray.d.y * t; if (u >= xmin && u <= xmax && v >= ymin && v <= ymax) { hit = true; - tNext = t; + intersectionRecord.distance = t; intersectionRecord.uv.x = u; intersectionRecord.uv.y = v; intersectionRecord.setNormal(0, 0, 1); } } - if (hit) { - intersectionRecord.distance += tNext; - } return hit; } @@ -192,8 +187,27 @@ public boolean intersect(Ray2 ray, IntersectionRecord intersectionRecord) { * * @return {@code true} if there is an intersection */ - public boolean quickIntersect(Ray ray) { - double t1, t2; + public double quickIntersect(Ray2 ray) { + double tx1 = (xmin - ray.o.x) / ray.d.x; + double tx2 = (xmax - ray.o.x) / ray.d.x; + + double ty1 = (ymin - ray.o.y) / ray.d.y; + double ty2 = (ymax - ray.o.y) / ray.d.y; + + double tz1 = (zmin - ray.o.z) / ray.d.z; + double tz2 = (zmax - ray.o.z) / ray.d.z; + + double tmin = Math.max(Math.max(Math.min(tx1, tx2), Math.min(ty1, ty2)), Math.min(tz1, tz2)); + double tmax = Math.min(Math.min(Math.max(tx1, tx2), Math.max(ty1, ty2)), Math.max(tz1, tz2)); + + if (tmax < tmin) { + return Double.NaN; + } else { + return tmin; + } + + + /*double t1, t2; double tNear = Double.NEGATIVE_INFINITY; double tFar = Double.POSITIVE_INFINITY; Vector3 d = ray.d; @@ -257,7 +271,7 @@ public boolean quickIntersect(Ray ray) { return true; } else { return false; - } + }*/ } /** @@ -267,8 +281,8 @@ public boolean quickIntersect(Ray ray) { */ public boolean inside(Vector3 p) { return (p.x >= xmin && p.x <= xmax) && - (p.y >= ymin && p.y <= ymax) && - (p.z >= zmin && p.z <= zmax); + (p.y >= ymin && p.y <= ymax) && + (p.z >= zmin && p.z <= zmax); } /** diff --git a/chunky/src/java/se/llbit/math/BigPackedOctree.java b/chunky/src/java/se/llbit/math/BigPackedOctree.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/ColorUtil.java b/chunky/src/java/se/llbit/math/ColorUtil.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Constants.java b/chunky/src/java/se/llbit/math/Constants.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Grid.java b/chunky/src/java/se/llbit/math/Grid.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Intersectable.java b/chunky/src/java/se/llbit/math/Intersectable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/IntersectionRecord.java b/chunky/src/java/se/llbit/math/IntersectionRecord.java old mode 100644 new mode 100755 index a40d79e00f..103228140d --- a/chunky/src/java/se/llbit/math/IntersectionRecord.java +++ b/chunky/src/java/se/llbit/math/IntersectionRecord.java @@ -2,9 +2,6 @@ import se.llbit.chunky.block.minecraft.Air; import se.llbit.chunky.world.Material; -import se.llbit.math.Vector2; -import se.llbit.math.Vector3; -import se.llbit.math.Vector4; public class IntersectionRecord { public double distance = Double.POSITIVE_INFINITY; @@ -14,6 +11,15 @@ public class IntersectionRecord { public final Vector3 shadeN = new Vector3(0, 1, 0); public final Vector4 color = new Vector4(); + public void reset() { + this.distance = Double.POSITIVE_INFINITY; + this.n.set(0, 1, 0); + this.uv.set(0, 0); + this.material = Air.INSTANCE; + this.shadeN.set(0, 1, 0); + this.color.set(0, 0, 0, 0); + } + public void setNormal(Vector3 normal) { n.set(normal); shadeN.set(normal); diff --git a/chunky/src/java/se/llbit/math/Matrix3.java b/chunky/src/java/se/llbit/math/Matrix3.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/NodeBasedOctree.java b/chunky/src/java/se/llbit/math/NodeBasedOctree.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Octree.java b/chunky/src/java/se/llbit/math/Octree.java old mode 100644 new mode 100755 index 9afb8cd8e0..e4a171f199 --- a/chunky/src/java/se/llbit/math/Octree.java +++ b/chunky/src/java/se/llbit/math/Octree.java @@ -347,7 +347,7 @@ public boolean isInside(Vector3 o) { * @param ray Ray that will be moved to the boundary of the octree. The origin, distance and normals will be modified. * @return {@code false} if the ray doesn't intersect the octree. */ - private boolean enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { + private double enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { double nx = 0, ny = 0, nz = 0; double octree_size = 1 << getDepth(); @@ -409,7 +409,7 @@ private boolean enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { } if ((tMin > tXMax) || (tXMin > tMax)) - return false; + return Double.NaN; if (tXMin > tMin) { tMin = tXMin; @@ -432,7 +432,7 @@ private boolean enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { } if ((tMin > tYMax) || (tYMin > tMax)) - return false; + return Double.NaN; if (tYMin > tMin) { tMin = tYMin; @@ -455,7 +455,7 @@ private boolean enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { } if ((tMin > tZMax) || (tZMin > tMax)) - return false; + return Double.NaN; if (tZMin > tMin) { tMin = tZMin; @@ -465,12 +465,10 @@ private boolean enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { } if (tMin < 0) - return false; + return Double.NaN; - ray.o.add(ray.d.x * tMin, ray.d.y * tMin, ray.d.z * tMin); intersectionRecord.setNormal(nx, ny, nz); - intersectionRecord.distance = tMin; - return true; + return tMin; } /** @@ -479,24 +477,38 @@ private boolean enterOctree(Ray2 ray, IntersectionRecord intersectionRecord) { * @return {@code false} if the ray did not hit the geometry */ public boolean enterBlock(Scene scene, Ray2 ray, IntersectionRecord intersectionRecord, BlockPalette palette) { - if (!isInside(ray.o) && !enterOctree(ray, intersectionRecord)) - return false; - - int depth = implementation.getDepth(); - double distance = 0; + IntIntMutablePair typeAndLevel = new IntIntMutablePair(0, 0); + Vector3 invDir = new Vector3( + 1.0 / ray.d.x, + 1.0 / ray.d.y, + 1.0 / ray.d.z + ); + Vector3 offset = new Vector3( + -ray.o.x * invDir.x, + -ray.o.y * invDir.y, + -ray.o.z * invDir.z + ); + Vector3 pos = new Vector3(ray.o); + Ray2 testRay = new Ray2(ray); + + // Check if we are in-bounds + if (!isInside(ray.o)) { + double dist = enterOctree(ray, intersectionRecord); + if (Double.isNaN(dist)) { + return false; + } + distance += dist; + } - // floating point division are slower than multiplication so we cache them + /*int depth = implementation.getDepth();*/ + + /*// floating point division are slower than multiplication so we cache them // We also try to limit the number of time the ray origin is updated // as it would require to recompute those values double invDx = 1 / ray.d.x; double invDy = 1 / ray.d.y; - double invDz = 1 / ray.d.z; - double offsetX = -ray.o.x * invDx; - double offsetY = -ray.o.y * invDy; - double offsetZ = -ray.o.z * invDz; - - IntIntMutablePair typeAndLevel = new IntIntMutablePair(0, 0); + double invDz = 1 / ray.d.z;*/ // Marching is done in a top-down fashion: at each step, the octree is descended from the root to find the leaf // node the ray is in. Terminating the march is then decided based on the block type in that leaf node. Finally the @@ -504,24 +516,30 @@ public boolean enterBlock(Scene scene, Ray2 ray, IntersectionRecord intersection while (true) { // Add small offset past the intersection to avoid // recursion to the same octree node! - int x = (int) Math.floor(ray.o.x + ray.d.x * (distance + Constants.OFFSET)); - int y = (int) Math.floor(ray.o.y + ray.d.y * (distance + Constants.OFFSET)); - int z = (int) Math.floor(ray.o.z + ray.d.z * (distance + Constants.OFFSET)); + pos.set(ray.o); + pos.scaleAdd(distance + Constants.OFFSET, ray.d); + int bx = (int) Math.floor(pos.x); + int by = (int) Math.floor(pos.y); + int bz = (int) Math.floor(pos.z); + + if (!isInside(pos)) { + return false; + } - int lx = x >>> depth; - int ly = y >>> depth; - int lz = z >>> depth; + /*int lx = bx >>> depth; + int ly = by >>> depth; + int lz = bz >>> depth; if (lx != 0 || ly != 0 || lz != 0) - return false; // outside of octree! + return false; // outside of octree!*/ - implementation.getWithLevel(typeAndLevel, x, y, z); + implementation.getWithLevel(typeAndLevel, bx, by, bz); int type = typeAndLevel.leftInt(); int level = typeAndLevel.rightInt(); - lx = x >>> level; - ly = y >>> level; - lz = z >>> level; + int lx = bx >>> level; + int ly = by >>> level; + int lz = bz >>> level; // Test intersection Block currentBlock = palette.get(type); @@ -531,44 +549,87 @@ public boolean enterBlock(Scene scene, Ray2 ray, IntersectionRecord intersection ray.setCurrentMaterial(currentBlock);*/ intersectionRecord.material = currentBlock; - if (currentBlock.localIntersect) { - // Other functions expect the ray origin to be in the block they test so here time - // to update it - // Updating the origin also means that new offsetX/offsetY/offsetZ must be computed - // but that is done a after the intersection test only if necessary - // and not if we are leaving the function anyway - ray.o.add(ray.d.x * distance, ray.d.y * distance, ray.d.z * distance); - intersectionRecord.distance += distance; - distance = 0; - if (currentBlock.intersect(ray, intersectionRecord, scene)) { - if (prevBlock != currentBlock) + if (currentBlock.isSameMaterial(prevBlock)) { + if (currentBlock.localIntersect) { + testRay.o.set(ray.o); + testRay.o.scaleAdd(distance, ray.d); + if (currentBlock.isInside(ray)) { + if (currentBlock.intersect(testRay, intersectionRecord, scene)) { + intersectionRecord.distance += distance; + + Vector3 o = new Vector3(ray.o); + o.scaleAdd(intersectionRecord.distance, ray.d); + + Material mat = scene.getWaterOctree().getMaterial((int) o.x, (int) o.y, (int) o.z, scene.getPalette()); + if (mat.isWater() && ((Water) mat).isInside(o.x, o.y, o.z)) { + intersectionRecord.material = mat; + } else { + intersectionRecord.material = Air.INSTANCE; + } + return true; + } else { + intersectionRecord.distance = Double.POSITIVE_INFINITY; + } + } + } + } else { + testRay.o.set(ray.o); + testRay.o.scaleAdd(distance, ray.d); + if (currentBlock.localIntersect) { + // Other functions expect the ray origin to be in the block they test so here time + // to update it + // Updating the origin also means that new offsetX/offsetY/offsetZ must be computed + // but that is done a after the intersection test only if necessary + // and not if we are leaving the function anyway + + if (currentBlock.intersect(testRay, intersectionRecord, scene)) { + intersectionRecord.distance += distance; return true; - - ray.o.add(ray.d.x * Constants.OFFSET, ray.d.y * Constants.OFFSET, ray.d.z * Constants.OFFSET); - offsetX = -ray.o.x * invDx; - offsetY = -ray.o.y * invDy; - offsetZ = -ray.o.z * invDz; - continue; + } else { + intersectionRecord.distance = Double.POSITIVE_INFINITY; + } } else { - // Exit ray from this local block. - //ray.setCurrentMedium(Air.INSTANCE); // Current material is air. - exitBlock(ray, intersectionRecord, x, y, z); - offsetX = -ray.o.x * invDx; - offsetY = -ray.o.y * invDy; - offsetZ = -ray.o.z * invDz; - continue; - } - } else if (!currentBlock.isSameMaterial(prevBlock)) { - // Origin and distance of ray need to be updated - // ray.o.scaleAdd(distance, ray.d); - intersectionRecord.distance += distance; - TexturedBlockModel.getIntersectionColor(ray, intersectionRecord); - if (currentBlock.opaque) { - intersectionRecord.color.w = 1; + // Origin and distance of ray need to be updated + TexturedBlockModel.getIntersectionColor(testRay, intersectionRecord); + if (currentBlock.opaque) { + intersectionRecord.color.w = 1; + } /*else if (intersectionRecord.color.w < Constants.EPSILON) { + if (currentBlock.refractive) { + intersectionRecord.color.set(1, 1, 1, 0); + } else { + ray.setCurrentMedium(currentBlock); + hit = false; + } + }*/ + intersectionRecord.distance = distance; + return true; } - return true; } + /*// Exit the leaf + double xmin = lx << level; + double xmax = (lx + 1) << level; + double ymin = ly << level; + double ymax = (ly + 1) << level; + double zmin = lz << level; + double zmax = (lz + 1) << level; + + double tx1 = (xmin - ray.o.x) * invDir.x; + double tx2 = (xmax - ray.o.x) * invDir.x; + + double ty1 = (ymin - ray.o.y) * invDir.y; + double ty2 = (ymax - ray.o.y) * invDir.y; + + double tz1 = (zmin - ray.o.z) * invDir.z; + double tz2 = (zmax - ray.o.z) * invDir.z; + + double tmax = Math.min(Math.min( + Math.max(tx1, tx2), + Math.max(ty1, ty2)), + Math.max(tz1, tz2)); + distance = tmax + Constants.OFFSET; + }*/ + // No intersection, exit current octree leaf. int nx = 0, ny = 0, nz = 0; double tNear = Double.POSITIVE_INFINITY; @@ -577,38 +638,38 @@ public boolean enterBlock(Scene scene, Ray2 ray, IntersectionRecord intersection // Every side is unconditionally tested because the origin of the ray can be outside the block // The computation involves a multiplication and an addition so we could use a fma (need java 9+) // but according to measurement, performance are identical - double t = (lx << level) * invDx + offsetX; - if (t > distance + Constants.EPSILON) { + double t = (lx << level) * invDir.x + offset.x; + if (t > distance + Constants.OFFSET) { tNear = t; nx = 1; } - t = ((lx + 1) << level) * invDx + offsetX; - if (t < tNear && t > distance + Constants.EPSILON) { + t = ((lx + 1) << level) * invDir.x + offset.x; + if (t < tNear && t > distance + Constants.OFFSET) { tNear = t; nx = -1; } - t = (ly << level) * invDy + offsetY; - if (t < tNear && t > distance + Constants.EPSILON) { + t = (ly << level) * invDir.y + offset.y; + if (t < tNear && t > distance + Constants.OFFSET) { tNear = t; ny = 1; nx = 0; } - t = ((ly + 1) << level) * invDy + offsetY; - if (t < tNear && t > distance + Constants.EPSILON) { + t = ((ly + 1) << level) * invDir.y + offset.y; + if (t < tNear && t > distance + Constants.OFFSET) { tNear = t; ny = -1; nx = 0; } - t = (lz << level) * invDz + offsetZ; - if (t < tNear && t > distance + Constants.EPSILON) { + t = (lz << level) * invDir.z + offset.z; + if (t < tNear && t > distance + Constants.OFFSET) { tNear = t; nz = 1; nx = ny = 0; } - t = ((lz + 1) << level) * invDz + offsetZ; - if (t < tNear && t > distance + Constants.EPSILON) { + t = ((lz + 1) << level) * invDir.z + offset.z; + if (t < tNear && t > distance + Constants.OFFSET) { tNear = t; nz = -1; nx = ny = 0; @@ -626,8 +687,15 @@ public boolean enterBlock(Scene scene, Ray2 ray, IntersectionRecord intersection * @return {@code false} if the ray doesn't hit anything */ public boolean exitWater(Scene scene, Ray2 ray, IntersectionRecord intersectionRecord, BlockPalette palette) { - if (!isInside(ray.o) && !enterOctree(ray, intersectionRecord)) - return false; + double distance = 0; + + if (!isInside(ray.o)) { + double dist = enterOctree(ray, intersectionRecord); + if (Double.isNaN(dist)) { + return false; + } + distance += dist + Constants.OFFSET; + } int depth = getDepth(); // Marching is done in a top-down fashion: at each step, the octree is descended from the root to find the leaf @@ -732,7 +800,7 @@ public boolean exitWater(Scene scene, Ray2 ray, IntersectionRecord intersectionR } } - ray.o.add(ray.d.x * tNear, ray.d.y * tNear, ray.d.z * tNear); + ray.o.scaleAdd(tNear, ray.d); intersectionRecord.setNormal(nx, ny, nz); intersectionRecord.distance += tNear; } @@ -746,7 +814,7 @@ public boolean exitWater(Scene scene, Ray2 ray, IntersectionRecord intersectionR * @param by block y coordinate * @param bz block z coordinate */ - public void exitBlock(Ray2 ray, IntersectionRecord intersectionRecord, int bx, int by, int bz) { + public double exitBlock(Ray2 ray, IntersectionRecord intersectionRecord, int bx, int by, int bz) { int nx = 0; int ny = 0; int nz = 0; @@ -793,9 +861,8 @@ public void exitBlock(Ray2 ray, IntersectionRecord intersectionRecord, int bx, i } } - ray.o.add(ray.d.x * tNext, ray.d.y * tNext, ray.d.z * tNext); intersectionRecord.setNormal(nx, ny, nz); - intersectionRecord.distance += tNext; + return tNext; } /** diff --git a/chunky/src/java/se/llbit/math/OctreeVisitor.java b/chunky/src/java/se/llbit/math/OctreeVisitor.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/PackedOctree.java b/chunky/src/java/se/llbit/math/PackedOctree.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Quad.java b/chunky/src/java/se/llbit/math/Quad.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Ray.java b/chunky/src/java/se/llbit/math/Ray.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Ray2.java b/chunky/src/java/se/llbit/math/Ray2.java old mode 100644 new mode 100755 index 39d62cd4a0..c6bb1d42f0 --- a/chunky/src/java/se/llbit/math/Ray2.java +++ b/chunky/src/java/se/llbit/math/Ray2.java @@ -4,14 +4,11 @@ import se.llbit.chunky.world.Material; public class Ray2 { - public Vector3 o; - public Vector3 d; - private Material currentMedium; + public Vector3 o = new Vector3(); + public Vector3 d = new Vector3(); + private Material currentMedium = Air.INSTANCE; public Ray2() { - o = new Vector3(); - d = new Vector3(); - currentMedium = Air.INSTANCE; } public Ray2(Ray2 ray) { @@ -20,6 +17,11 @@ public Ray2(Ray2 ray) { currentMedium = ray.currentMedium; } + public Ray2(Vector3 origin, Vector3 direction) { + o.set(origin); + d.set(direction); + } + public Material getCurrentMedium() { return currentMedium; } diff --git a/chunky/src/java/se/llbit/math/SimplexNoise.java b/chunky/src/java/se/llbit/math/SimplexNoise.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Transform.java b/chunky/src/java/se/llbit/math/Transform.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Triangle.java b/chunky/src/java/se/llbit/math/Triangle.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Vector2.java b/chunky/src/java/se/llbit/math/Vector2.java old mode 100644 new mode 100755 index 420892f1f8..7ef93b9b2f --- a/chunky/src/java/se/llbit/math/Vector2.java +++ b/chunky/src/java/se/llbit/math/Vector2.java @@ -31,7 +31,7 @@ public class Vector2 { public double x, y; /** - * Creates a new vector (0, 0, 0) + * Creates a new vector (0, 0) */ public Vector2() { this(0, 0); diff --git a/chunky/src/java/se/llbit/math/Vector3.java b/chunky/src/java/se/llbit/math/Vector3.java old mode 100644 new mode 100755 index ced446d3ae..7d940e8fbd --- a/chunky/src/java/se/llbit/math/Vector3.java +++ b/chunky/src/java/se/llbit/math/Vector3.java @@ -20,6 +20,8 @@ import se.llbit.json.JsonObject; +import java.util.Random; + /** * A 3D vector of doubles. * @@ -55,6 +57,16 @@ public Vector3(Vector3 o) { z = o.z; } + public static Vector3 randomUnitVector(Random random) { + Vector3 randomUnitVector = new Vector3(random.nextDouble(), random.nextDouble(), random.nextDouble()); + randomUnitVector.normalize(); + return randomUnitVector; + } + + public boolean nearZero() { + return (FastMath.abs(x) < Constants.EPSILON) && (FastMath.abs(y) < Constants.EPSILON) && (FastMath.abs(z) < Constants.EPSILON); + } + /** * Set this vector equal to other vector. */ @@ -64,6 +76,15 @@ public final void set(Vector3 o) { z = o.z; } + /** + * Set this vector equal to a. + */ + public final void set(Vector3i o) { + x = o.x; + y = o.y; + z = o.z; + } + /** * Set this vector equal to (d, e, f). */ @@ -73,6 +94,7 @@ public final void set(double d, double e, double f) { z = f; } + /** * @return The dot product of this vector and o vector */ @@ -80,15 +102,6 @@ public final double dot(Vector3 o) { return x * o.x + y * o.y + z * o.z; } - /** - * Set this vector equal to a-b. - */ - public final void sub(Vector3 a, Vector3 b) { - x = a.x - b.x; - y = a.y - b.y; - z = a.z - b.z; - } - /** * @return The length of this vector, squared */ @@ -131,6 +144,11 @@ public final void normalize() { z *= s; } + public final Vector3 normalized() { + double s = 1 / FastMath.sqrt(lengthSquared()); + return new Vector3(x * s, y * s, z * s); + } + /** * Set this vector equal to s*d + o. */ @@ -140,6 +158,10 @@ public final void scaleAdd(double s, Vector3 d, Vector3 o) { z = s * d.z + o.z; } + public final Vector3 rScaleAdd(double s, Vector3 d, Vector3 o) { + return new Vector3(s * d.x + o.x, s * d.y + o.y, s * d.z + o.z); + } + /** * Add s*d to this vector. */ @@ -149,6 +171,10 @@ public final void scaleAdd(double s, Vector3 d) { z += s * d.z; } + public final Vector3 rScaleAdd(double s, Vector3 d) { + return new Vector3(x + s * d.x, y + s * d.y, z + s * d.z); + } + /** * Scale this vector by s. */ @@ -158,6 +184,10 @@ public final void scale(double s) { z *= s; } + public final Vector3 rScale(double s) { + return new Vector3(x * s, y * s, z * s); + } + /** * Set this vector equal to a+b. */ @@ -167,6 +197,10 @@ public final void add(Vector3 a, Vector3 b) { z = a.z + b.z; } + public final Vector3 rAdd(Vector3 a, Vector3 b) { + return new Vector3(a.x + b.x, a.y + b.y, a.z + b.z); + } + /** * Add a to this vector. */ @@ -176,6 +210,10 @@ public final void add(Vector3 a) { z += a.z; } + public final Vector3 rAdd(Vector3 a) { + return new Vector3(x + a.x, y + a.y, z + a.z); + } + /** * Add a to this vector. */ @@ -185,6 +223,10 @@ public final void add(Vector3i a) { z += a.z; } + public final Vector3 rAdd(Vector3i a) { + return new Vector3(x + a.x, y + a.y, z + a.z); + } + /** * Add vector (a, b, c) to this vector. */ @@ -194,6 +236,26 @@ public final void add(double a, double b, double c) { z += c; } + public final Vector3 rAdd(double a, double b, double c) { + return new Vector3(x + a, y + b, z + c); + } + + /** + * Set this vector equal to a-b. + */ + public final void sub(Vector3 a, Vector3 b) { + x = a.x - b.x; + y = a.y - b.y; + z = a.z - b.z; + } + + /** + * @return difference of vector a and b. + */ + public final Vector3 rSub(Vector3 a, Vector3 b) { + return new Vector3(a.x - b.x, a.y - b.y, a.z - b.z); + } + /** * Subtract a from this vector. */ @@ -203,13 +265,8 @@ public final void sub(Vector3 a) { z -= a.z; } - /** - * Subtract vector (a, b, c) from this vector. - */ - public final void sub(double a, double b, double c) { - x -= a; - y -= b; - z -= c; + public final Vector3 rSub(Vector3 a) { + return new Vector3(x - a.x, y - a.y, z - a.z); } /** @@ -221,13 +278,21 @@ public final void sub(Vector3i a) { z -= a.z; } + public final Vector3 rSub(Vector3i a) { + return new Vector3(x - a.x, y - a.y, z - a.z); + } + /** - * Set this vector equal to a. + * Subtract vector (a, b, c) from this vector. */ - public void set(Vector3i a) { - x = a.x; - y = a.y; - z = a.z; + public final void sub(double a, double b, double c) { + x -= a; + y -= b; + z -= c; + } + + public final Vector3 rSub(double a, double b, double c) { + return new Vector3(x - a, y - b, z - c); } @Override public String toString() { diff --git a/chunky/src/java/se/llbit/math/Vector3i.java b/chunky/src/java/se/llbit/math/Vector3i.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/Vector4.java b/chunky/src/java/se/llbit/math/Vector4.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/bvh/BVH.java b/chunky/src/java/se/llbit/math/bvh/BVH.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/bvh/BinaryBVH.java b/chunky/src/java/se/llbit/math/bvh/BinaryBVH.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/bvh/MidpointBVH.java b/chunky/src/java/se/llbit/math/bvh/MidpointBVH.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/bvh/SahBVH.java b/chunky/src/java/se/llbit/math/bvh/SahBVH.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/bvh/SahMaBVH.java b/chunky/src/java/se/llbit/math/bvh/SahMaBVH.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/primitive/Box.java b/chunky/src/java/se/llbit/math/primitive/Box.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/primitive/MutableAABB.java b/chunky/src/java/se/llbit/math/primitive/MutableAABB.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/primitive/Primitive.java b/chunky/src/java/se/llbit/math/primitive/Primitive.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java b/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java old mode 100644 new mode 100755 index 3a915f6311..55bd3ab23f --- a/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java +++ b/chunky/src/java/se/llbit/math/primitive/TexturedTriangle.java @@ -125,7 +125,7 @@ public TexturedTriangle(Vector3 c1, Vector3 c2, Vector3 c3, Vector2 t1, Vector2 intersectionRecord.color.set(color); intersectionRecord.material = material; intersectionRecord.distance = t; - intersectionRecord.n.set(n); + intersectionRecord.setNormal(n); return true; } } diff --git a/chunky/src/java/se/llbit/math/structures/Position2IntStructure.java b/chunky/src/java/se/llbit/math/structures/Position2IntStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/structures/Position2ReferenceStructure.java b/chunky/src/java/se/llbit/math/structures/Position2ReferenceStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/structures/Position2d2IntPackedArray.java b/chunky/src/java/se/llbit/math/structures/Position2d2IntPackedArray.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/structures/Position2d2ReferencePackedArrayStructure.java b/chunky/src/java/se/llbit/math/structures/Position2d2ReferencePackedArrayStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/structures/Position3d2IntPackedArray.java b/chunky/src/java/se/llbit/math/structures/Position3d2IntPackedArray.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/math/structures/Position3d2ReferencePackedArrayStructure.java b/chunky/src/java/se/llbit/math/structures/Position3d2ReferencePackedArrayStructure.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/resources/ImageLoader.java b/chunky/src/java/se/llbit/resources/ImageLoader.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/BitBuffer.java b/chunky/src/java/se/llbit/util/BitBuffer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/Configurable.java b/chunky/src/java/se/llbit/util/Configurable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/ImageTools.java b/chunky/src/java/se/llbit/util/ImageTools.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/JsonSerializable.java b/chunky/src/java/se/llbit/util/JsonSerializable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/JsonUtil.java b/chunky/src/java/se/llbit/util/JsonUtil.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/MinecraftPRNG.java b/chunky/src/java/se/llbit/util/MinecraftPRNG.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/MinecraftText.java b/chunky/src/java/se/llbit/util/MinecraftText.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/NbtUtil.java b/chunky/src/java/se/llbit/util/NbtUtil.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/ProgressListener.java b/chunky/src/java/se/llbit/util/ProgressListener.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/Registerable.java b/chunky/src/java/se/llbit/util/Registerable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/RingBuffer.java b/chunky/src/java/se/llbit/util/RingBuffer.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/StringUtil.java b/chunky/src/java/se/llbit/util/StringUtil.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/TaskTracker.java b/chunky/src/java/se/llbit/util/TaskTracker.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/VectorUtil.java b/chunky/src/java/se/llbit/util/VectorUtil.java old mode 100644 new mode 100755 index 0a9f0a3c0d..7d26413daf --- a/chunky/src/java/se/llbit/util/VectorUtil.java +++ b/chunky/src/java/se/llbit/util/VectorUtil.java @@ -5,7 +5,7 @@ public class VectorUtil { public static Vector3 orientNormal(Vector3 direction, Vector3 normal) { if(direction.dot(normal) > 0) { - normal.set(-normal.x, -normal.y, -normal.z); + return new Vector3(-normal.x, -normal.y, -normal.z); } return normal; } diff --git a/chunky/src/java/se/llbit/util/annotation/NotNull.java b/chunky/src/java/se/llbit/util/annotation/NotNull.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/annotation/Nullable.java b/chunky/src/java/se/llbit/util/annotation/Nullable.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/io/BufferedFileChannelOutputStream.java b/chunky/src/java/se/llbit/util/io/BufferedFileChannelOutputStream.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/io/IsolatedOutputStream.java b/chunky/src/java/se/llbit/util/io/IsolatedOutputStream.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/io/PositionalInputStream.java b/chunky/src/java/se/llbit/util/io/PositionalInputStream.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/io/PositionalOutputStream.java b/chunky/src/java/se/llbit/util/io/PositionalOutputStream.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/io/RepositionableMeasurableDataOutput.java b/chunky/src/java/se/llbit/util/io/RepositionableMeasurableDataOutput.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/io/ZipExport.java b/chunky/src/java/se/llbit/util/io/ZipExport.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/mojangapi/MinecraftProfile.java b/chunky/src/java/se/llbit/util/mojangapi/MinecraftProfile.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/mojangapi/MinecraftSkin.java b/chunky/src/java/se/llbit/util/mojangapi/MinecraftSkin.java old mode 100644 new mode 100755 diff --git a/chunky/src/java/se/llbit/util/mojangapi/MojangApi.java b/chunky/src/java/se/llbit/util/mojangapi/MojangApi.java old mode 100644 new mode 100755 diff --git a/chunky/src/res/chunky-icon.png b/chunky/src/res/chunky-icon.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/1_12.png b/chunky/src/res/icons/1_12.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/1_13.png b/chunky/src/res/icons/1_13.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/advanced.png b/chunky/src/res/icons/advanced.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/bed.png b/chunky/src/res/icons/bed.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/cactus.png b/chunky/src/res/icons/cactus.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/cake.png b/chunky/src/res/icons/cake.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/camera.png b/chunky/src/res/icons/camera.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/cauldron.png b/chunky/src/res/icons/cauldron.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/chunky.png b/chunky/src/res/icons/chunky.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/clear.png b/chunky/src/res/icons/clear.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/clock.png b/chunky/src/res/icons/clock.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/colors.png b/chunky/src/res/icons/colors.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/disk.png b/chunky/src/res/icons/disk.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/dragon-egg.png b/chunky/src/res/icons/dragon-egg.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/eye.png b/chunky/src/res/icons/eye.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/face.png b/chunky/src/res/icons/face.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/face_t.png b/chunky/src/res/icons/face_t.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/failed.png b/chunky/src/res/icons/failed.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/fence.png b/chunky/src/res/icons/fence.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/gear.png b/chunky/src/res/icons/gear.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/home.png b/chunky/src/res/icons/home.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/home_t.png b/chunky/src/res/icons/home_t.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/iron-door.png b/chunky/src/res/icons/iron-door.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/iso-ne.png b/chunky/src/res/icons/iso-ne.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/iso-nw.png b/chunky/src/res/icons/iso-nw.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/iso-se.png b/chunky/src/res/icons/iso-se.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/iso-sw.png b/chunky/src/res/icons/iso-sw.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/jack-o-lantern.png b/chunky/src/res/icons/jack-o-lantern.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/jukebox.png b/chunky/src/res/icons/jukebox.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/key.png b/chunky/src/res/icons/key.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/lens.png b/chunky/src/res/icons/lens.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/lever.png b/chunky/src/res/icons/lever.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/light.png b/chunky/src/res/icons/light.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/load.png b/chunky/src/res/icons/load.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/lock.png b/chunky/src/res/icons/lock.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/magnify.png b/chunky/src/res/icons/magnify.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/map-selected.png b/chunky/src/res/icons/map-selected.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/map.png b/chunky/src/res/icons/map.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/minus.png b/chunky/src/res/icons/minus.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/note-block.png b/chunky/src/res/icons/note-block.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/pause.png b/chunky/src/res/icons/pause.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/pencil.png b/chunky/src/res/icons/pencil.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/photo.png b/chunky/src/res/icons/photo.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/play.png b/chunky/src/res/icons/play.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/player.png b/chunky/src/res/icons/player.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/plus.png b/chunky/src/res/icons/plus.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/pumpkin.png b/chunky/src/res/icons/pumpkin.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/question.png b/chunky/src/res/icons/question.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/redstone-torch-on.png b/chunky/src/res/icons/redstone-torch-on.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/reload.png b/chunky/src/res/icons/reload.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/save.png b/chunky/src/res/icons/save.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/scale.png b/chunky/src/res/icons/scale.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/sign-post.png b/chunky/src/res/icons/sign-post.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/sky.png b/chunky/src/res/icons/sky.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/skybox-back.png b/chunky/src/res/icons/skybox-back.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/skybox-down.png b/chunky/src/res/icons/skybox-down.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/skybox-front.png b/chunky/src/res/icons/skybox-front.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/skybox-left.png b/chunky/src/res/icons/skybox-left.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/skybox-right.png b/chunky/src/res/icons/skybox-right.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/skybox-up.png b/chunky/src/res/icons/skybox-up.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/stone-brick-stairs.png b/chunky/src/res/icons/stone-brick-stairs.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/stone-button.png b/chunky/src/res/icons/stone-button.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/stone-pressure-plate.png b/chunky/src/res/icons/stone-pressure-plate.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/stone-stairs.png b/chunky/src/res/icons/stone-stairs.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/stop.png b/chunky/src/res/icons/stop.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/sun.png b/chunky/src/res/icons/sun.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/unknown.png b/chunky/src/res/icons/unknown.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/wall-sign.png b/chunky/src/res/icons/wall-sign.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/water.png b/chunky/src/res/icons/water.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/wheat.png b/chunky/src/res/icons/wheat.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/wooden-door.png b/chunky/src/res/icons/wooden-door.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/wooden-pressure-plate.png b/chunky/src/res/icons/wooden-pressure-plate.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/wooden-stairs.png b/chunky/src/res/icons/wooden-stairs.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/icons/wrench.png b/chunky/src/res/icons/wrench.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/se/llbit/chunky/main/Version.properties b/chunky/src/res/se/llbit/chunky/main/Version.properties old mode 100644 new mode 100755 diff --git a/chunky/src/res/se/llbit/chunky/renderer/projection/gaussian-aperture.png b/chunky/src/res/se/llbit/chunky/renderer/projection/gaussian-aperture.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/se/llbit/chunky/renderer/projection/hexagon-aperture.png b/chunky/src/res/se/llbit/chunky/renderer/projection/hexagon-aperture.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/se/llbit/chunky/renderer/projection/pentagon-aperture.png b/chunky/src/res/se/llbit/chunky/renderer/projection/pentagon-aperture.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/se/llbit/chunky/renderer/projection/star-aperture.png b/chunky/src/res/se/llbit/chunky/renderer/projection/star-aperture.png old mode 100644 new mode 100755 diff --git a/chunky/src/res/se/llbit/chunky/ui/Chunky.fxml b/chunky/src/res/se/llbit/chunky/ui/Chunky.fxml old mode 100644 new mode 100755 index 10f51f5417..32ece7491e --- a/chunky/src/res/se/llbit/chunky/ui/Chunky.fxml +++ b/chunky/src/res/se/llbit/chunky/ui/Chunky.fxml @@ -1,175 +1,175 @@ - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + +