diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 61efa2b17..1baf4bc9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -75,7 +75,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, text: Any, scale: Flo poseStack.translate(-translation) poseStack.scale(scale, scale, scale) val inv = 1f / scale - poseStack.translate(-translation * inv) + poseStack.translate(translation * inv) val size = drawDuckTyped(poseStack, text, x * inv, y * inv, color) poseStack.popPose() @@ -89,7 +89,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo poseStack.translate(-translation) poseStack.scale(scale, scale, scale) val inv = 1f / scale - poseStack.translate(-translation * inv) + poseStack.translate(translation * inv) val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, seeThrough, packedLightCoords, effectColor) poseStack.popPose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index c6306278d..12c565310 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -163,7 +163,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context poseStack.pushPose() poseStack.translate(0.5, 0.75, 0.5) - poseStack.translate(ang.forward() * tile.gravitationStrength * 0.6) + poseStack.translate(ang.forward() * tile.gravitationStrength.pow(0.5)) poseStack.rotateAroundPoint(poseStack.translation(), ang) val scale = (distance.coerceAtLeast(8.0) / 168.0).toFloat() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index bd1389ce6..fc56109ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -148,7 +148,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter()), TextAlign.TOP_CENTER, 1f, -font.lineHeight.toFloat() / 2f + 1f, 0) font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 1f, font.lineHeight.toFloat() / 2f + 1f, 0) - poseStack.translate(facing.opposite.normal * 0.02) + poseStack.translate(0.2f, 0f, -0.5f) font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter()), TextAlign.TOP_CENTER, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt index fc6a940dc..1c9d2d084 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt @@ -61,13 +61,10 @@ fun Vector3f.rotationDegrees(degrees: Float): Quaternionf { } operator fun Vector3f.unaryMinus(): Vector3f { - x = -x - y = -y - z = -z - return this + return Vector3f(-x, -y, -z) } -operator fun Vector3f.times(v: Float): Vector3f = mul(v) +operator fun Vector3f.times(v: Float): Vector3f = Vector3f(v).mul(v) operator fun Vector3f.component1() = x() operator fun Vector3f.component2() = y() @@ -131,9 +128,9 @@ fun Vector.rotateAroundAxis(axis: Vector, rotation: Double): Vector { fun Vector.rotate(angle: IAngle): Vector { val rotation = angle.rotationXYZ() - val newx = x * rotation[0, 0] + y * rotation[0, 1] + z * rotation[0, 2] - val newy = x * rotation[1, 0] + y * rotation[1, 1] + z * rotation[1, 2] - val newz = x * rotation[2, 0] + y * rotation[2, 1] + z * rotation[2, 2] + val newx = x * rotation[0, 0,] + y * rotation[1, 0] + z * rotation[2, 0] + val newy = x * rotation[0, 1,] + y * rotation[1, 1] + z * rotation[2, 1] + val newz = x * rotation[0, 2,] + y * rotation[1, 2] + z * rotation[2, 2] return Vector(newx, newy, newz) } @@ -220,9 +217,11 @@ interface IAngle { val c = cos(roll).toFloat() it[0, 0] = 1f + it[1, 1] = c - it[1, 2] = -s - it[2, 1] = s + it[2, 1] = -s + + it[1, 2] = s it[2, 2] = c } } @@ -237,9 +236,11 @@ interface IAngle { val c = cos(pitch).toFloat() it[0, 0] = c - it[0, 1] = -s - it[1, 0] = s + it[1, 0] = -s + + it[0, 1] = s it[1, 1] = c + it[2, 2] = 1f } } @@ -253,13 +254,13 @@ interface IAngle { val s = sin(yaw).toFloat() val c = cos(yaw).toFloat() - it[0, 0] = c - it[0, 2] = s + it[0, 0,] = c + it[2, 0,] = s - it[2, 0] = -s - it[2, 2] = c + it[0, 2,] = -s + it[2, 2,] = c - it[1, 1] = 1f + it[1, 1,] = 1f } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt index 770b60ec1..e6e1281fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt @@ -21,39 +21,39 @@ fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isD val p = point.asVector3f() translate(-p) rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 - translate(-p) + translate(p) } fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { val p = point.asVector3f() translate(-p) rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 - translate(-p) + translate(p) } fun Matrix4f.rotateAroundPoint(point: Vector, rotation: IAngle) { val p = point.asVector3f() translate(-p) mul(rotation.rotationXYZW()) - translate(-p) + translate(p) } fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { translate(-point) rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 - translate(-point) + translate(point) } fun Matrix4f.rotateAroundPoint(point: Vector3f, rotation: IAngle) { translate(-point) mul(rotation.rotationXYZW()) - translate(-point) + translate(point) } fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { translate(-point) rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 - translate(-point) + translate(point) } fun Matrix3f.toMatrix4f(): Matrix4f { @@ -76,7 +76,7 @@ fun Matrix3f.toMatrix4f(): Matrix4f { var Matrix4f.translation: Vector3f get() { - return Vector3f(this[3, 0], this[3, 1], this[3, 2]) + return Vector3f(this[0, 3], this[1, 3], this[2, 3]) } set(value) { @@ -92,7 +92,7 @@ var Matrix4f.translation: Vector3f var Matrix4f.translation4: Vector4f get() { - return Vector4f(this[3, 0], this[3, 1], this[3, 2], this[3, 3]) + return Vector4f(this[0, 3], this[1, 3], this[2, 3], this[3, 3]) } set(value) {