-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt # src/integration-test/kotlin/de/bixilon/minosoft/data/physics/PhysicsTestUtil.kt # src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt # src/main/java/de/bixilon/minosoft/data/registries/blocks/properties/BlockProperties.kt # src/main/java/de/bixilon/minosoft/data/registries/blocks/types/pixlyzer/PixLyzerBlock.kt # src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedFace.kt # src/main/java/de/bixilon/minosoft/gui/rendering/system/base/texture/dynamic/DynamicTextureListener.kt # src/main/java/de/bixilon/minosoft/protocol/protocol/ProtocolVersions.kt # src/main/java/de/bixilon/minosoft/util/collections/floats/FragmentedArrayFloatList.kt # src/main/resources/assets/minosoft/mapping/assets_properties.json # src/main/resources/assets/minosoft/mapping/versions.json
- Loading branch information
Showing
680 changed files
with
14,828 additions
and
7,341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Entity rendering | ||
|
||
Entity rendering is a quite hard topic. | ||
|
||
## Classes | ||
|
||
- Player renderer | ||
- player model | ||
- feature renderer: | ||
- armor | ||
- stuck arrows | ||
|
||
## Skeletal models | ||
|
||
- SkeletalModel (raw data) | ||
- BakedSkeletalModel (baked mesh) | ||
- SkeletalInstance (renders baked mesh, contains transform values) | ||
- Wrapper (indirectly accesses skeletal instance transforms) | ||
|
||
## Model designing | ||
|
||
### Entities | ||
|
||
Entities are always designed without any rotation (i.e. `yaw`=`0`) | ||
|
||
## Things to consider | ||
|
||
- name rendering (without culling and visible through walls) (and scoreboard objective) | ||
- hitbox rendering | ||
- entity model itself | ||
- player with arms, legs, ... | ||
- has animations, ... | ||
- different poses (sneaking, etc) | ||
- yaw vs head yaw | ||
- "features" | ||
- armor (and armor trims) | ||
- elytra | ||
- stuck arrows (and bee stingers) | ||
- cape | ||
- shoulder entities (parrots) | ||
- held item | ||
- light (shade and lightmap) | ||
|
||
## General | ||
|
||
- render layers (opaque -> transparent -> translucent -> ...) (but face culling enabled) | ||
- sort in layers after distance (or -distance) | ||
- there are also invisible renderers (like AreaEffectCloud is just emitting particles) | ||
- update all models async (with their visibility, etc) | ||
- queue for unloading and loading meshes before draw (better while async preparing to save time. Maybe port that system to block entities) | ||
- Loop over all visible entity renderers and work on the entity layer as needed | ||
- update visible and not visible | ||
- entity name is also visible through walls, rest not | ||
- also with frustum (no need to update renderers that are out of the frustum) | ||
- -> handle occlusion differently from visibility | ||
- option to turn on/off "features" | ||
- how to register entity models? | ||
- loop over all entity (and block entity) types and register? | ||
- store entities in octree like structure | ||
- ways faster collisions with them -> physics | ||
- way faster getInRadius -> particles, maybe entities in the future | ||
|
||
## Hitboxes | ||
|
||
- Create line mesh with default aabb | ||
- interpolate | ||
- aabb (not at all, taken from renderInfo) | ||
- color: 0.5s | ||
- velocity (ticks) | ||
- direction (taken from renderInfo) | ||
- eye height (taken from renderInfo) | ||
- they must alight with the matrix handler -> mustn't be a frame too late/early | ||
- Store offset and rotation as uniform | ||
- Make hitbox a default feature of entity renderer | ||
- highest priority (enables cheap gpu clipping) | ||
- dynamic enabling and disabling (hitbox manager, keybinding) | ||
|
||
## Tests | ||
|
||
- hitbox (data, loading, unloading) | ||
- collect visible meshes (with sorting, priority type and distance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
src/integration-test/kotlin/de/bixilon/minosoft/commands/nodes/ChatNodeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Minosoft | ||
* Copyright (C) 2020-2023 Moritz Zwerger | ||
* | ||
* 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 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* This software is not affiliated with Mojang AB, the original developer of Minecraft. | ||
*/ | ||
|
||
package de.bixilon.minosoft.commands.nodes | ||
|
||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet | ||
import de.bixilon.minosoft.commands.stack.CommandStack | ||
import de.bixilon.minosoft.commands.suggestion.Suggestion | ||
import de.bixilon.minosoft.commands.util.CommandReader | ||
import de.bixilon.minosoft.data.chat.signature.signer.DummyMessageSigner | ||
import de.bixilon.minosoft.modding.event.master.EventMaster | ||
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertPacket | ||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection | ||
import de.bixilon.minosoft.protocol.network.connection.play.util.ConnectionUtil | ||
import de.bixilon.minosoft.protocol.network.network.client.test.TestNetwork | ||
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.ChatMessageC2SP | ||
import de.bixilon.minosoft.protocol.versions.Versions | ||
import de.bixilon.minosoft.terminal.cli.CLI | ||
import de.bixilon.minosoft.test.ITUtil.allocate | ||
import org.testng.Assert.assertEquals | ||
import org.testng.Assert.assertTrue | ||
import org.testng.annotations.Test | ||
import java.security.SecureRandom | ||
|
||
@Test(groups = ["brigadier"]) | ||
class ChatNodeTest { | ||
private var cmd = 0 | ||
private var cmi = 0 | ||
private val root = ConnectionNode().apply { addChild(LiteralNode("cmd", executor = { cmd++ })) } | ||
|
||
init { | ||
CLI.commands.addChild(LiteralNode("cmi", executor = { cmi++ })) | ||
} | ||
|
||
private fun create(cli: Boolean): ChatNode { | ||
return ChatNode("", allowCLI = cli) | ||
} | ||
|
||
private fun ChatNode.execute(command: String): CommandStack { | ||
val connection = PlayConnection::class.java.allocate() | ||
connection::version.forceSet(Versions.AUTOMATIC) | ||
connection::events.forceSet(EventMaster()) | ||
val util = ConnectionUtil::class.java.allocate() | ||
util::signer.forceSet(DummyMessageSigner) | ||
util::class.java.getDeclaredField("connection").apply { isAccessible = true }.forceSet(util, connection) | ||
util::class.java.getDeclaredField("random").apply { isAccessible = true }.forceSet(util, SecureRandom()) | ||
connection::util.forceSet(util) | ||
connection::network.forceSet(TestNetwork()) | ||
connection.commands = root | ||
val stack = CommandStack(connection) | ||
execute(CommandReader(command), stack) | ||
return stack | ||
} | ||
|
||
private fun ChatNode.suggest(command: String): Collection<Suggestion> { | ||
val connection = PlayConnection::class.java.allocate() | ||
connection.commands = root | ||
val stack = CommandStack(connection) | ||
return getSuggestions(CommandReader(command), stack) | ||
} | ||
|
||
fun `normal chat sending`() { | ||
val node = create(true) | ||
val stack = node.execute("chat message") | ||
val packet: ChatMessageC2SP = stack.connection.assertPacket(ChatMessageC2SP::class.java) | ||
assertEquals(packet.message, "chat message") | ||
} | ||
|
||
fun `command chat sending`() { | ||
val node = create(true) | ||
val previous = cmd | ||
val stack = node.execute("/cmd") | ||
assertTrue(cmd == previous + 1) | ||
val packet: ChatMessageC2SP = stack.connection.assertPacket(ChatMessageC2SP::class.java) // old version | ||
assertEquals(packet.message, "/cmd") | ||
} | ||
|
||
fun `internal execution`() { | ||
val node = create(true) | ||
val previous = cmi | ||
val stack = node.execute(".cmi") | ||
assertTrue(cmi == previous + 1) | ||
} | ||
|
||
fun `chat suggestions`() { | ||
val node = create(true) | ||
val suggestions = node.suggest("message") | ||
assertEquals(suggestions.size, 0) | ||
} | ||
|
||
fun `command suggestions`() { | ||
val node = create(true) | ||
val suggestions = node.suggest("/cm") | ||
assertEquals(suggestions.toSet(), setOf( | ||
Suggestion(1, "cmd"), | ||
)) | ||
} | ||
|
||
fun `internal suggestions`() { | ||
val node = create(true) | ||
val suggestions = node.suggest(".cm") | ||
assertEquals(suggestions.toSet(), setOf( | ||
Suggestion(1, "cmi"), | ||
)) | ||
} | ||
|
||
fun `prefix suggestions`() { | ||
val node = create(true) | ||
val suggestions = node.suggest("") | ||
assertEquals(suggestions.toSet(), setOf( | ||
Suggestion(0, "."), | ||
Suggestion(0, "/"), | ||
)) | ||
} | ||
} |
Oops, something went wrong.