Terasology icon indicating copy to clipboard operation
Terasology copied to clipboard

Don't send CharacterMoveInputEvent if I don't input anything

Open jdrueckert opened this issue 2 years ago • 5 comments

Motivation

During a debugging session I noticed, that the LocalPlayerSystem sends a CharacterMoveInputEvent every tick, even if I'm not pressing any key and not moving the mouse at all.

See https://github.com/MovingBlocks/Terasology/blob/develop/engine/src/main/java/org/terasology/engine/logic/players/LocalPlayerSystem.java#L175-L176

This does IMO not only create a lot of unnecessary events that might negatively impact, but it also creates a lot of "noise" and makes it harder to debug.

Proposal

Exit early from LocalPlayerSystem#processInput if there is no input, e.g. no keyboard input creating movement and no mouse or VR input creating view rotation.

My hope would be that this improves performance and reduces unnecessary noise.

jdrueckert avatar Jan 25 '22 22:01 jdrueckert

@pollend @keturn @DarkWeird I have no clue whether or not this is a low-hanging fruit - might be. If I missed any other inputs this might try to process, I'd be interested to learn which.

jdrueckert avatar Jan 25 '22 22:01 jdrueckert

This does seem worth looking in to. Good catch.

#4586 may have some other ideas to keep in mind while working on this.

keturn avatar Jan 25 '22 23:01 keturn

Irc, CharacterPredictionSystem send this event too. Noticed for mob, while working with FlexableMovement

DarkWeird avatar Jan 26 '22 05:01 DarkWeird

A wild guess on this: gravity on characters seems to come from apply downwards pull on every (affected) movement event. Therefore, might it be necessary to send "dummy no-change events" just to have the gravity be applied to characters each tick?

And since we only do this repeatedly for the player characters, NPCs are affected by gravitiy as soon as they move (e.g., walk or jump), but are not affected by gravity if just standing around... 🤔

skaldarnar avatar Jan 27 '22 16:01 skaldarnar

That actually makes sense :see_no_evil: I would argue that this should ideally be done separate from actual movements, but guess it's quite entangled at the moment and hard to "unfiddle"

jdrueckert avatar Jan 30 '22 11:01 jdrueckert