-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
6 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
35 changes: 35 additions & 0 deletions
35
src/main/java/me/jellysquid/mods/sodium/client/render/texture/ParticleTextureRegistry.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,35 @@ | ||
package me.jellysquid.mods.sodium.client.render.texture; | ||
|
||
import it.unimi.dsi.fastutil.floats.FloatFloatImmutablePair; | ||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class ParticleTextureRegistry { | ||
private final Object2IntOpenHashMap<FloatFloatImmutablePair> uvToIndex = new Object2IntOpenHashMap<>(); | ||
|
||
private ArrayList<FloatFloatImmutablePair> toAdd = new ArrayList<>(); | ||
|
||
private int currentIndex = 0; | ||
|
||
public int get(float u, float v) { | ||
FloatFloatImmutablePair key = new FloatFloatImmutablePair(u, v); | ||
return uvToIndex.computeIfAbsent(key, pairKey -> { | ||
toAdd.add((FloatFloatImmutablePair) pairKey); | ||
return currentIndex++; | ||
}); | ||
} | ||
|
||
public boolean isDirty() { | ||
return !toAdd.isEmpty(); | ||
} | ||
|
||
public List<FloatFloatImmutablePair> flushUpdates() { | ||
var ret = this.toAdd; | ||
this.toAdd = new ArrayList<>(); | ||
return ret; | ||
} | ||
} |
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