Optimise mobs #3720

Merged
ancientmarinerdev merged 7 commits from optimise_mobs into master 2023-05-15 16:03:57 +02:00

Fixes #3686

Optimisations conducted based on profiling from Solo un altro clone

  1. env_danger_movement_checks only called in range now. The mobs are already stopped out of range
  2. can_jump_cliff only called once in the on_step. Can be called multiple times from multiple places so makes sense to set it on the mob and access it that way.
  3. Attack, follow and runaway mob_step functions called 5 times a second now, which is enough without being excessive
  4. Check mob can fly (self.fly) before conducting a self:flight_check() unnecessarily when setting animations
  5. Looking at check ineffectively restricted. Changed this.
  6. Water check was copied from cliff check. Unneccessary duplicated code. Called every mob_step without question. Very expensive. Cliff check is called for attack, and before walking and during attack code. Didn't need to be called again for every state. Also do not execute this code for mobs that aren't affected by water. Don't execute code if already in unsafe water and shouldn't stop.
  7. Only make a mob stand if not standing to avoid unnecessary state calls send to client
  8. If outside of active range, mob shouldn't be made to walk only to stop again.
  9. Falling code cleaned up, and duplicate expensive node_ok call removed
  10. Added some vectors in various code
  11. Mobs less jittery now at edges/water (they used to change yaw in do_states_stand, after cliff danger check and after water change) so would try to change their yaw multiple times a method and on every tick.
  12. check_suspend calls falling which is called twice.

Testing

/spawn_mob llama
/spawn_mob parrot

  • Do many times. Close game and open, close and open. Check they don't lose their set texture.
  • Check mobs far away don't move but yaw around
  • Check mobs close by move
  • Check mobs still mostly try and stay away from water (still needs to be improved, but efficiently)
  • Sheep still try to avoid suiciding off posts
  • Mobs still follow
  • Mobs runaway
  • Mobs fight
  • Mobs still fall out of range
Fixes #3686 Optimisations conducted based on profiling from Solo un altro clone 1. env_danger_movement_checks only called in range now. The mobs are already stopped out of range 2. can_jump_cliff only called once in the on_step. Can be called multiple times from multiple places so makes sense to set it on the mob and access it that way. 3. Attack, follow and runaway mob_step functions called 5 times a second now, which is enough without being excessive 4. Check mob can fly (self.fly) before conducting a self:flight_check() unnecessarily when setting animations 5. Looking at check ineffectively restricted. Changed this. 6. Water check was copied from cliff check. Unneccessary duplicated code. Called every mob_step without question. Very expensive. Cliff check is called for attack, and before walking and during attack code. Didn't need to be called again for every state. Also do not execute this code for mobs that aren't affected by water. Don't execute code if already in unsafe water and shouldn't stop. 7. Only make a mob stand if not standing to avoid unnecessary state calls send to client 8. If outside of active range, mob shouldn't be made to walk only to stop again. 9. Falling code cleaned up, and duplicate expensive node_ok call removed 10. Added some vectors in various code 11. Mobs less jittery now at edges/water (they used to change yaw in do_states_stand, after cliff danger check and after water change) so would try to change their yaw multiple times a method and on every tick. 12. check_suspend calls falling which is called twice. ### Testing /spawn_mob llama /spawn_mob parrot * Do many times. Close game and open, close and open. Check they don't lose their set texture. * Check mobs far away don't move but yaw around * Check mobs close by move * Check mobs still mostly try and stay away from water (still needs to be improved, but efficiently) * Sheep still try to avoid suiciding off posts * Mobs still follow * Mobs runaway * Mobs fight * Mobs still fall out of range
ancientmarinerdev changed title from Optimise mobs to WIP: Optimise mobs 2023-05-12 15:30:41 +02:00
ancientmarinerdev added the
mobs
performance
labels 2023-05-12 22:55:33 +02:00
Author
Owner

Master are the before, optimised is the after.

Between 6-10% improvement in performance.

Master are the before, optimised is the after. Between 6-10% improvement in performance.
ancientmarinerdev changed title from WIP: Optimise mobs to Optimise mobs 2023-05-12 23:17:02 +02:00
ancientmarinerdev force-pushed optimise_mobs from a3c393af70 to 5a059379b2 2023-05-15 15:54:32 +02:00 Compare
ancientmarinerdev added this to the 0.84.0 - Very Nice milestone 2023-05-15 16:03:49 +02:00
ancientmarinerdev merged commit 6ded4d2322 into master 2023-05-15 16:03:57 +02:00
ancientmarinerdev deleted branch optimise_mobs 2023-05-15 16:04:12 +02:00
Sign in to join this conversation.
No reviewers
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#3720
No description provided.