skadistats / clarity

Comically fast Dota 2, CSGO, CS2 and Deadlock replay parser written in Java.
BSD 3-Clause "New" or "Revised" License
663 stars 122 forks source link

Event to detect camera edge pan/drag? #301

Closed aeviou closed 1 year ago

aeviou commented 1 year ago

Is there an event that detects the camera itself moving? I see on #133 that you can obtain the camera from CDOTAPlayer and CDOTAUserMsg_SpectatorPlayerClick but I'm not sure if there's a way to detect screen moves. It's hard to find an approach that accounts for screen drag or WASD camera movement.

My goal is to detect the mouse movement that occurs between player clicks and removing any data that involves camera movement. I'm thinking of calculating the distance between the two points that are clicked and if the distance of the mouse coordinate aren't identical to the distances calculated from CDOTAUserMsg_SpectatorPlayerClick then I assume the camera has moved.

Do you have any ideas or thoughts? Any help would be appreciated!

spheenik commented 1 year ago

Hmm. First of all, there is no event for that.

Sceen moves can be detected by listening to entity updates on CDOTAPlayer, for the respective properties. I am not sure what exactly you mean by "removing any data that involves camera movement".

Can you rephrase what exactly you're trying to achieve?

aeviou commented 1 year ago

I'm trying to find the pathing of a player's mouse movement in between two clicks (player movement or ability/spell casting). my goal is to track the speed and precision that a player is able to move their mouse between two points. I'm trying to do this by tracking m_iCursor and collecting that tick data that occurs between a player orders.

My issue is that if a player uses edge pan then there won't be a direct path between point A and point B, as the player will move their mouse to the edge of the screen. This would be similar for camera dragging.

spheenik commented 1 year ago

So, basically the following:

  1. Player issues a move order to point A
  2. Player uses edge pan to move the screen a bit
  3. Player issues a spell cast to point B

And now you want the "distance of A and B" in m_iCursor units?

aeviou commented 1 year ago

Hmm. My goal is to record the pathing of all mouse movements between any two given clicks for each player.

  1. Player issues a command to point A 1A. Begin recording m_iCursor
  2. Player issues a command to point B 2A. End recording m_iCursor

However I am only interested in recording pathing where the player intended to move their mouse from Point A to point B directly. So I want to be able to identify the following scenario in order to avoid recording it:

  1. Player issues a command to point A
  2. Player edge pans/drag scrolls
  3. Player issues a command to point B
spheenik commented 1 year ago

Ok, that makes it clear. Generally, you should be able to find out if scrolling happened between time of A and time of B, if the viewport changes. That will include both edge pan and middle mouse pan. Maybe you can throw out data points where

  1. viewport change happened
  2. m_iCursor was detected to be "on the edge" during that time?

This will throw out a few false positives for middle mouse scrollers clicking something on the edge of the screen. But shouldn't be too many, I guess.

aeviou commented 1 year ago

Great, thanks so much!

  1. How does one go about detecting the viewport change?
  2. In order to check this, for both x and y I want to check m_iCursor == 0 and if m_iCursor == xUpperBound and m_iCursor == yUpperBound. How would you go about calculating these upperBounds?

I can probably figure the latter one out myself but I have no clue on where the viewport information is located.

spheenik commented 1 year ago
  1. By looking at CDOTAPlayer entities: position is CBodyComponent.m_cell[XY] and CBodyComponent.m_vec[XY], they are the camera position of the player.
  2. I'm unsure what the upper bounds of m_iCursor are. I would just write a little test that goes over a replay and records the maximum values.
aeviou commented 1 year ago

Thanks! Really appreciate it.

spheenik commented 1 year ago

Good luck!