rendering: fix slow movement speed while looking at a high angle

This commit is contained in:
Lukas 2021-02-23 17:25:37 +01:00
parent 5226a26aa5
commit c67965f40b
2 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/*
* 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.
*
@ -113,17 +113,18 @@ class Camera(private val connection: Connection, private var fov: Float) {
fun handleInput(deltaTime: Double) {
var cameraSpeed = movementSpeed * deltaTime
val movementFront = Vec3(cameraFront)
movementFront.y = 0f
movementFront.normalizeAssign() // when moving forwards, do not move down
if (keySprintDown) {
cameraSpeed *= 5
}
val lastPosition = cameraPosition
val currentY = cameraPosition.y
if (keyForwardDown) {
cameraPosition = cameraPosition + cameraFront * cameraSpeed
cameraPosition = cameraPosition + movementFront * cameraSpeed
}
if (keyBackDown) {
cameraPosition = cameraPosition - cameraFront * cameraSpeed
cameraPosition = cameraPosition - movementFront * cameraSpeed
}
if (keyLeftDown) {
cameraPosition = cameraPosition - cameraRight * cameraSpeed
@ -131,7 +132,6 @@ class Camera(private val connection: Connection, private var fov: Float) {
if (keyRightDown) {
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) {
cameraPosition = cameraPosition - CAMERA_UP_VEC3 * cameraSpeed
}

View File

@ -112,6 +112,9 @@ class ElementRenderer(element: BlockModelElement, rotation: Vec3, uvlock: Boolea
val uvlock = state["uvlock"]?.asBoolean ?: false
val rescale = state["rescale"]?.asBoolean ?: false
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()
for (parentElement in parentElements) {
result.add(ElementRenderer(parentElement, rotation, true, rescale)) // uvlock is not yet implemented in the data generator