From 71a98a1bc771aa0c0b2969db6878134e5022fb28 Mon Sep 17 00:00:00 2001 From: Michael Pollind Date: Tue, 14 Dec 2021 22:53:23 -0800 Subject: [PATCH 1/2] chore: remove deprecated method in Block (#4965) * chore: remove deprecated method in Block * chore: update documenation Co-authored-by: Nail Khanipov --- .../terasology/engine/world/block/Block.java | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/engine/src/main/java/org/terasology/engine/world/block/Block.java b/engine/src/main/java/org/terasology/engine/world/block/Block.java index bec04067833..8eacf8610bd 100644 --- a/engine/src/main/java/org/terasology/engine/world/block/Block.java +++ b/engine/src/main/java/org/terasology/engine/world/block/Block.java @@ -14,15 +14,12 @@ import org.terasology.engine.math.Rotation; import org.terasology.engine.math.Side; import org.terasology.engine.physics.shapes.CollisionShape; -import org.terasology.engine.rendering.assets.mesh.Mesh; import org.terasology.engine.rendering.primitives.BlockMeshGenerator; import org.terasology.engine.rendering.primitives.BlockMeshGeneratorSingleShape; -import org.terasology.engine.rendering.primitives.Tessellator; import org.terasology.engine.world.block.family.BlockFamily; import org.terasology.engine.world.block.shapes.BlockMeshPart; import org.terasology.engine.world.block.sounds.BlockSounds; import org.terasology.engine.world.chunks.Chunks; -import org.terasology.gestalt.assets.ResourceUrn; import org.terasology.joml.geom.AABBf; import org.terasology.math.TeraMath; import org.terasology.nui.Color; @@ -225,15 +222,17 @@ public void setTranslucent(boolean translucent) { } /** - * @return The BlockMeshGenerator that is used in rendering, null if invisible. + * MeshGenerator drives how the mesh is produced for this single block. + * by default this uses {@link BlockMeshGeneratorSingleShape} and can't be set to null. + * + * @return The BlockMeshGenerator that is used in rendering. */ public BlockMeshGenerator getMeshGenerator() { return meshGenerator; } /** - * @param meshGenerator The new BlockMeshGenerator to use in rendering this block. - * If meshGenerator is null then this block is invisible. + * @param meshGenerator The new {@link BlockMeshGenerator} to use in rendering this block. */ public void setMeshGenerator(BlockMeshGenerator meshGenerator) { Preconditions.checkNotNull(meshGenerator); @@ -524,18 +523,6 @@ public void setColorOffsets(Colorc color) { } } - /** - * @return Standalone mesh - * @deprecated Use getMeshGenerator() instead. - */ - @Deprecated - public Mesh getMesh() { - if (meshGenerator != null) { - return meshGenerator.getStandaloneMesh(); - } - return new Tessellator().generateMesh(new ResourceUrn("engine", "blockmesh", uri.toString())); - } - public BlockMeshPart getLowLiquidMesh(Side side) { return lowLiquidMesh[side.ordinal()]; } From 7583454e62c856ef7e7b09b8265b1afe01cdf0bd Mon Sep 17 00:00:00 2001 From: Michael Pollind Date: Sun, 19 Dec 2021 10:04:18 -0800 Subject: [PATCH 2/2] bugfix: resolve BlockSelectionRenderer (#4973) Co-authored-by: Tobias Nett --- .../rendering/world/selection/BlockSelectionRenderer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/src/main/java/org/terasology/engine/rendering/world/selection/BlockSelectionRenderer.java b/engine/src/main/java/org/terasology/engine/rendering/world/selection/BlockSelectionRenderer.java index 8df42a2f3f5..dca0d75263b 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/world/selection/BlockSelectionRenderer.java +++ b/engine/src/main/java/org/terasology/engine/rendering/world/selection/BlockSelectionRenderer.java @@ -55,7 +55,7 @@ private static void buildBlockMesh(StandardMeshData mesh, float size, Rectanglef Vector3f pos = new Vector3f(); Vector3f norm = new Vector3f(); Vector2f texCoord = new Vector2f(); - final float sizeHalf = size / 2; + final float sizeHalf = (size / 2) + .001f; int firstIndex = mesh.position.getPosition(); @@ -81,7 +81,7 @@ private static void buildBlockMesh(StandardMeshData mesh, float size, Rectanglef mesh.uv0.put(texCoord.set(texRect.minX, texRect.maxY)); mesh.uv0.put(texCoord.set(texRect.maxX, texRect.maxY)); mesh.uv0.put(texCoord.set(texRect.maxX, texRect.minY)); - mesh.uv0.put(texCoord.set(texRect.minY, texRect.minY)); + mesh.uv0.put(texCoord.set(texRect.minX, texRect.minY)); for (int i = 0; i < 4; i++) { mesh.normal.put(norm.set(-1.0f, 0, 0)); mesh.color0.put(c); @@ -123,7 +123,7 @@ private static void buildBlockMesh(StandardMeshData mesh, float size, Rectanglef mesh.uv0.put(texCoord.set(texRect.minX, texRect.maxY)); mesh.uv0.put(texCoord.set(texRect.maxX, texRect.maxY)); mesh.uv0.put(texCoord.set(texRect.maxX, texRect.minY)); - mesh.uv0.put(texCoord.set(texRect.minY, texRect.minY)); + mesh.uv0.put(texCoord.set(texRect.minX, texRect.minY)); for (int i = 0; i < 4; i++) { mesh.normal.put(norm.set(0, 0, 1.0f)); mesh.color0.put(c);