stujones11 / shooter

First Person Shooter Mod for Minetest
Other
30 stars 18 forks source link

Use Raycast object instead of custom vector calculations #26

Closed ClobberXD closed 5 years ago

ClobberXD commented 6 years ago

This would result in cleaner code and possibly more efficiency.

Also prepares the mod for 5.0.0

stujones11 commented 6 years ago

This is something I plan to look into for MT 5.0.0 but I doubt that it will be much, if any more efficient. The Lua raycasting method I use is really quite efficient as dot products are not computationally expensive. It also saves a lot of the Lua to C++ communication which itself carries significant overhead.

However, the in-built raycasting will be a lot more accurate than my current method so if the performance is not made worse by any noticeable amount then I will likely switch to using that.

For now the raycasting is partly broken in 0.4.16-stable and I'm not sure whether the fix was back-ported to 0.4.17.x

ClobberXD commented 6 years ago

Here are a couple of important reasons to switch to Raycast:

stujones11 commented 5 years ago

I have decided to go with minetest.raycast since it does simplify the code significantly. It also much improves the mob-mod compatibility. My guess is there should be a slight increase in performance with PVE, though there may be a very slight decrease for pure PVP mode (no entity or node detection) however, I hope this should be compensated by the other optimisations I have made.

https://github.com/stujones11/shooter/tree/0.6.0-dev

ClobberXD commented 5 years ago

Great to know, thanks! :)

stujones11 commented 5 years ago

No problem, this can be closed now since this part is now completed in the development version.