-
Notifications
You must be signed in to change notification settings - Fork 21
1.21.3 notable changes
Let's see the IAnimation#get3DTransform
function. It gets a model part string in prior versions.
Mods should store string to data maps, and animation is played using those. This is a lot of string compare in a single frame.
String hashing and compare on the render thread. And a lot of it.
To avoid losing performance, but still have the possibility of custom models, I've replaced the key with a PartKey type. Designed to be fast in maps and compares.
Migration: If you have any entry, just replace it with a constant
- Vec3f someVector = animation.get3DTransform("head", TransformType.SCALE, 0, Vec3f.ZERO);
+ Vec3f someVector = animation.get3DTransform(PartKey.HEAD, TransformType.SCALE, 0, Vec3f.ZERO);
If you use custom keys, no worries, you can use PartKey.keyForId(String id)
function to cache a key.
private static final PartKey tailKey = PartKey.keyForId("tail");
private void fun(...) {
... animation.get3DTransform(tailKey, ...);
Also, the keyForId doesn't break if you invoke it multiple times with the same strings (for example two mods want to have tails)
If that happens, the keyForId will simply return the same object for both mods as many times as needed.
Comparing two keys is also easier: you can simply use identity equals:
if (partKey == PartKey.BODY) {...}
Identity comparison is actually the fastest possible, and the keyForId function will ensure that the same instance will be returned for the same key, even if someone retrieves a "head" instead of using the static PartKey.HEAD field.
performance note:
for 10'000 string hashmap gets, the gain is approximately 30% or instead of 300 us, it only took 200.
But I believe, in real tests, the new implementation will gain a bit more for not needing data compare.
Prior to 1.21.3, the common code (which use bendy stuff for player animations) were in player-animator (this) mod. Because of maintainability, this code is being moved into bendy-lib.
Other than this note, it won't change much anything.
TBA