mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 02:45:13 -04:00
rendering: fix slow movement speed while looking at a high angle
This commit is contained in:
parent
5226a26aa5
commit
c67965f40b
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
* Copyright (C) 2020 Moritz Zwerger, Lukas Eisenhauer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -113,17 +113,18 @@ class Camera(private val connection: Connection, private var fov: Float) {
|
|||||||
|
|
||||||
fun handleInput(deltaTime: Double) {
|
fun handleInput(deltaTime: Double) {
|
||||||
var cameraSpeed = movementSpeed * deltaTime
|
var cameraSpeed = movementSpeed * deltaTime
|
||||||
|
val movementFront = Vec3(cameraFront)
|
||||||
|
movementFront.y = 0f
|
||||||
|
movementFront.normalizeAssign() // when moving forwards, do not move down
|
||||||
if (keySprintDown) {
|
if (keySprintDown) {
|
||||||
cameraSpeed *= 5
|
cameraSpeed *= 5
|
||||||
}
|
}
|
||||||
val lastPosition = cameraPosition
|
val lastPosition = cameraPosition
|
||||||
val currentY = cameraPosition.y
|
|
||||||
if (keyForwardDown) {
|
if (keyForwardDown) {
|
||||||
cameraPosition = cameraPosition + cameraFront * cameraSpeed
|
cameraPosition = cameraPosition + movementFront * cameraSpeed
|
||||||
}
|
}
|
||||||
if (keyBackDown) {
|
if (keyBackDown) {
|
||||||
cameraPosition = cameraPosition - cameraFront * cameraSpeed
|
cameraPosition = cameraPosition - movementFront * cameraSpeed
|
||||||
}
|
}
|
||||||
if (keyLeftDown) {
|
if (keyLeftDown) {
|
||||||
cameraPosition = cameraPosition - cameraRight * cameraSpeed
|
cameraPosition = cameraPosition - cameraRight * cameraSpeed
|
||||||
@ -131,7 +132,6 @@ class Camera(private val connection: Connection, private var fov: Float) {
|
|||||||
if (keyRightDown) {
|
if (keyRightDown) {
|
||||||
cameraPosition = cameraPosition + cameraRight * cameraSpeed
|
cameraPosition = cameraPosition + cameraRight * cameraSpeed
|
||||||
}
|
}
|
||||||
this.cameraPosition.y = currentY // stay on xz line when moving (aka. no clip): ToDo: make movement not slower when you look up
|
|
||||||
if (keyFlyDown) {
|
if (keyFlyDown) {
|
||||||
cameraPosition = cameraPosition - CAMERA_UP_VEC3 * cameraSpeed
|
cameraPosition = cameraPosition - CAMERA_UP_VEC3 * cameraSpeed
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,9 @@ class ElementRenderer(element: BlockModelElement, rotation: Vec3, uvlock: Boolea
|
|||||||
val uvlock = state["uvlock"]?.asBoolean ?: false
|
val uvlock = state["uvlock"]?.asBoolean ?: false
|
||||||
val rescale = state["rescale"]?.asBoolean ?: false
|
val rescale = state["rescale"]?.asBoolean ?: false
|
||||||
val parentElements = mapping.blockModels[ModIdentifier(state["model"].asString.replace("block/", ""))]!!.elements
|
val parentElements = mapping.blockModels[ModIdentifier(state["model"].asString.replace("block/", ""))]!!.elements
|
||||||
|
if (state["model"].asString.contains("stairs")) {
|
||||||
|
val breakpoint = null
|
||||||
|
}
|
||||||
val result: MutableList<ElementRenderer> = mutableListOf()
|
val result: MutableList<ElementRenderer> = mutableListOf()
|
||||||
for (parentElement in parentElements) {
|
for (parentElement in parentElements) {
|
||||||
result.add(ElementRenderer(parentElement, rotation, true, rescale)) // uvlock is not yet implemented in the data generator
|
result.add(ElementRenderer(parentElement, rotation, true, rescale)) // uvlock is not yet implemented in the data generator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user