[Performance] Replace Removing & Adding entities with Updating entities #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently cultivation whenever harvesting from a plant, will remove the entities representing the item, and when they grow it adds the entities. This is quite laggy when done many many times a second, which can be easily achieved with a macro on an afk player. To combat this, this PR replaces that system with its own. It hides the entities by setting the scale to be 0, 0, 0 when harvested, and then to its normal size when grown. Unintentionally this also fixes a couple bugs with the bushes, as they did not use the proper transformations or methods that were created for them. I have also included interpolation, so the drops actually "grow" and "harvest", its a nice visual touch that has no impact on the server as interpolation is purely client sided.
Below are some profiles with and without the changes:
With: https://spark.lucko.me/lXZ2NaOQZx
Without: https://spark.lucko.me/RJYgpWhhBL
This was also only done on a local test server, so the differences would be more dramatic on a production server. I say this cause on Meta tps would be at 20, and then 2 people would be macro farming cultivation (10 10 10 plants) and tps would drop to 8-12.