-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from KosmX/dev
Small performance tweak backport
- Loading branch information
Showing
14 changed files
with
103 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
coreLib/src/test/java/dev/kosmx/playerAnim/core/data/KeyframeAnimationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dev.kosmx.playerAnim.core.data; | ||
|
||
import dev.kosmx.playerAnim.core.util.Ease; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Random; | ||
|
||
public class KeyframeAnimationTest { | ||
@Test | ||
public void testKeyframeAnimation() { | ||
KeyframeAnimation.StateCollection.State state = new KeyframeAnimation.StateCollection(0).x; | ||
// Easy case | ||
state.addKeyFrame(1, 0, Ease.CONSTANT); | ||
state.addKeyFrame(5, 0, Ease.CONSTANT); | ||
state.addKeyFrame(10, 10, Ease.CONSTANT); | ||
state.addKeyFrame(10, 10, Ease.CONSTANT); | ||
|
||
state.addKeyFrame(15, 10, Ease.CONSTANT); | ||
|
||
verify(state); | ||
state.getKeyFrames().clear(); | ||
|
||
|
||
// random case | ||
Random random = new Random(); | ||
|
||
for (int i = 0; i < 10000; i += random.nextInt(100)) { | ||
state.addKeyFrame(i, i, Ease.CONSTANT); | ||
} | ||
|
||
verify(state); | ||
} | ||
|
||
public static void verify(KeyframeAnimation.StateCollection.State state) { | ||
|
||
for (int t = 0; t < state.getKeyFrames().size(); t++) { | ||
// Iterative, 100% works algorithm | ||
|
||
int i = -1; | ||
while (state.getKeyFrames().size() > i + 1 && state.getKeyFrames().get(i + 1).tick <= t) { | ||
i++; | ||
} | ||
|
||
Assertions.assertEquals(i, state.findAtTick(t), "KeyframeAnimationTest failed at tick " + t); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
minecraft/fabric/src/main/resources/assets/player-animator/lang/tt_ru.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"modmenu.descriptionTranslation.player-animator": "Уенчыны гади анимацияләү өчен җиңел (авырлык буенча) китапханә" | ||
} |
2 changes: 2 additions & 0 deletions
2
minecraft/fabric/src/testmod/java/dev/kosmx/animatorTestmod/CodedAnimation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package dev.kosmx.animatorTestmod;public class CodedAnimation { | ||
} |
10 changes: 0 additions & 10 deletions
10
minecraft/fabric/src/testmod/java/dev/kosmx/animatorTestmod/SomeString.java
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...ft/fabric/src/testmod/java/dev/kosmx/animatorTestmod/mixin/AbstractClientPlayerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package dev.kosmx.animatorTestmod.mixin;public class AbstractClientPlayerMixin { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters