PatHightree / SpaceNavigator

SpaceNavigator driver for Unity3D
MIT License
170 stars 55 forks source link

Little expensive at runtime #18

Closed AdamFrisby closed 3 years ago

AdamFrisby commented 5 years ago

Hi - thankyou for this, we've been using it for a while and it's a fantastic driver.

One thing I have however noticed is it is a bit expensive at runtime ~0.5ms/call, I suspect that's the GetObjectForIUnknown call happening each frame (I think within TDx.TDInput?) which must be doing some kind of uncached reflection.

E.g. image

Is there any way to speed that up a bit?

AdamFrisby commented 5 years ago

Follow-up, a quick bit of reflection says the 'Rotation' returned is actually an interface which fetches it each time it is accessed. Caching this might help.

PatHightree commented 5 years ago

Hi Adam, Great to hear that the driver is appreciated :) I'm afraid that anything in TDx.TDInput is out of my juristiction, as it is inside the 3dconnexion dll that I've used to get the communication to work. That dll is end of life by now, as it has been depricated by 3dconnexion and also because Unity does not allow dll's to be included in the asset store build process. (at least, I can't make new asset store builds of the current github code) To get around this, I've done some research into alternative communication methods and found a windows hook to work. You can check out this research on this github branch https://github.com/PatHightree/SpaceNavigator/tree/research/3dconnexion-connection Unfortunately, this only works on windows (duh) and I have no clue on how this would work on a mac. So that's the state of the driver right now.

Assuming you're using windows, you could fork the repo and use the windows hook approach to get the driver to run completely without 3rd party code. That would give you the control to score that runtime performance.

I have no direct plans to push the driver forward at this time. As in, it is not high on my list of priorities.

Ciao, Patrick

On Fri, Apr 12, 2019 at 3:23 PM Adam Frisby notifications@github.com wrote:

Follow-up, a quick bit of reflection says the 'Rotation' returned is actually an interface which fetches it each time it is accessed. Caching this might help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PatHightree/SpaceNavigator/issues/18#issuecomment-482572807, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP7KKa5Br1LmBWyEdOBYVYy1A_nNSi-ks5vgIjggaJpZM4csHJG .

AdamFrisby commented 5 years ago

Hey thanks for the update - I actually did manage to solve this. I'll put in a PR in a bit once I've cleaned it up - it's a small patch.

PatHightree commented 3 years ago

Closing this issue as with version 2.0.0, the driver has moved away from dll based communication to Unity's new Input System.