I’ve decided to go the spatial hashing route, but there’s some things I wanted to know if you had an opinion on.
tldr: Filtering positions with spatial hashing works great! What about rotation and velocity?
My Current Solution
The main method I’ve explored is fast. I use spatial hashing to create a grid space around the player and find which grid cell the object, or hands in this case, are in.
Users can record these gestures in the editor. Then when loading the game, these recorded gestures can be scaled according to player sizes and other specifications, then stored in a hash table.
While I haven’t implemented it yet, I plan to be able to allow storage of a gesture in a neighboring cell if it’s within a radius tolerance of the recorded position.
This works quite fast. Even with a quickly thrown together Blueprint implementation, ticking on every frame, I didn’t notice more than an average of 5 fps drop (at around 140 fps). Keep in mind this was also drawing debug squares for the cell each hand is reading from. The grid size was 40 * 40 * 40 for a total of 64,000 grid squares.
Of course I am aware that this type of thing should be done on a timer rather than in a frame tick, but I want it to be a plausible option.
The Problem
The current solution works great for positions, but I’m uncertain as to how well it will work on rotation and velocity. At first I thought I would just make position a requirement, then once the best gesture has been decided, see if the other values work well enough.
But what if a user wants to capture purely a flicking motion in any arbitrary direction? Or a rotation and angular velocity at any arbitrary location?
I thought then, that velocity and rotation and everything are all just 3d vectors, so maybe they could be hashed the same way. The rotation may not be so troublesome. I just have to convert any rotations axis to be from 0 - 360 degrees. But velocity may be a little more troublesome if the player is capable of producing extreme values that are out of the range of the grid, since the grid is a fixed size.
Plus, the performance impact may actually start to be a problem if I’m calculating 3 or 4 different keys every frame. And of course I’d have to triple or quadruple the amount of for loops that check between each gesture stored in these cells.
Wrap up and big questions
Is there a better way of filtering these other values? Or a better way to compare all values including position quickly and efficiently every frame? Or is such a thing completely out of my scope?
Thank you for reading this far into the post, and any help or insight on the matter would be greatly appreciated