mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-26 15:13:01 +00:00
The Mergening (#13)
* ThreadedTessellator -> RenderBlocks instance Tessellator * Plus a CME workaround until I can figure out why it's happening * One inject with multiple methods instead of two injects * Add AF's Tessellator#reset mixin Fixes screen flashing when chunks are being built * Thread Saftey * Make each tesselator use its own ByteBuffer * Don't make RecyclingList a static variable 🤦 * Add some additions via ITessellatorInstance * Stop using builtin updateRenderers * Remove a few unused things in MixinTessellator * Remove useless casting due to implementing the interface * Overwrite some more rendering methods to ensure they're not used * Implement IBlockAccess on WorldSlice * Currently just proxies to the World... need to get it to use the local cache * Make WorldSlice use its copied values instead of using the world * block, meta, and light. Still need TODO biome * Finish making WorldSlice thread safe * Remove last unsafe this.world accesses * Copy biomeData * Implement getTileEntity(), and getBiomeGenForCoords() * Remove unused 1.16+ classes - Biome, Colorizer, and ColorBlender related * Cache worldHeight instead of asking the provider every time * Debug Screen updates * Disable Culling for now (until it works) * Tessellator Updates * Use one instance on the main thread, and individual instances on every other thread * Prevent draw() and buffer.reset() on non singleton instance * Misc cleanup, maybe better growBuffer? * Fixing splash screen and GUI issues by excluding SplashProgress from GLStateManager transformer * Update docs * Fixing a one line in SodiumWorldRenderer that allows the game setting for the distance at which entities will render. Hope it's not too bad mitch :) * TileEntites now render * Less silly transparency * Removing clamp implementation because I missed the one in mathhelper * Initial sodium entity smooth lighting * Fix entity smooth lighting * Fix lerp uses and use render layers properly (#17) * Remove some uses of blockstate + patch FluidState * Fix lerp * Enable Sodium fluid rendering * Update FluidRenderer.java * Rewind buffers when copying * Fix multidraw * Force cutout on all non-translucent blocks * Let vanilla handle render pass state * Rewrite render layer check to use Forge 1.7 hook * Fix skylight handling * Fix flickering * Clone TEs correctly * Fixing entityDistMulti (I think) * Fix TEs rendering on the wrong pass * Buff max render distance to 32 Pretty useless since the integrated server stalls instantly, but our renderer supports it * Fix fog * Fix render distance changes being ignored * Implement entity culling * Block face culling * Re-enable occlusion culling * Fix x/z coordinate mixup when indexing biome arrays Partially fixes wrong biome colors, but at chunk edges it's still wrong because neighboring chunks aren't accessed * Make a copy of biome data The old code seemed to work fine but this should be safer * Make CompatMemoryUtil#memReallocDirect preserve buffer position LWJGL3's MemoryUtil#memRealloc does this, see its javadoc. Fixes screen flashing and this error getting printed when indirect buffer grows: GL_INVALID_OPERATION error generated. Bound draw indirect buffer is not large enough. * Use biome data of neighboring chunk sections Fixes wrong colors at chunk edges * Re-enable fog culling * Tile entity culling * Remove some unneeded Sodium code * Massive code cleanup * Avoids errors when usin lwjglxdebug * Bump hodgepodge dep * Add AngelicaConfig * Add Mixin to disable MC's builtin checkGLError * Add configs for iris/sodium * Iris work * Move some StateNotifiers to GLStateManager * Remove some redundant mixins based on sodium/angelica work and rendering state captures * Add Iris DebugScreenHandler * rm archaicfix's occlusion renderer and threaded updates * Implemented Sodium's GUI and a couple of setting fixes (#20) * Ported Sodium's GUI * Correct AO * Fixed Vignette * Re-enable DirectMemoryAccess * Adds some code from lwjgl3 in CompatMemoryUtil.java * Re-add *Unsafe classes * Remove MixinWorldRenderer * Add NEID (mixin pr) support * Only shadow runtime module of antlr4 Reduces jar size by 11 mb * Update NotFine * Make LongHashMap actually perform like a hash map * Options GUI Fixes and some option implementations (#22) * Correct useNoErrorGLContext option * Added translucency sorting option * Implemented Particle Culling gives real fps boost, however, it's not as big as i thought * Begin implementing animateOnlyVisibleTextures * Correct Donation page opening * Fixed Shift + P Now it uses NotFine's GUI, but it think that NotFine's GUI should be rewrited for using other config options * Correct URL's for Linux * second code cleanup in particle culling * Fix incorrect TE map population * Add optional assertMainThread behind `-Dangelica.assertMainThread=true` * Add back air optimization, but only apply to vanilla air * Implement more options (#23) * Combine free regions in GlBufferArena * Clear global block entity list when initializing renderer * AF, CompileStubs, and SplashProgress Remove most of ArchaicFix * Move a few mixins over to angelica * Disable if org.lwjgl.util.Debug is set * Only enable Iris/lwjgl debug callbacks if org.lwjgl.util.Debug is set * Rewrite Tessellator hacks - now using a ThreadLocal instead of only patching RenderBlocks * Reenable AF mixins, switch to cached debug var, disable incompatible mixins * Remove AF deps and a late mixin that was missed * Add Iris Sodium Compat impl * Fix Sodium GLProgram to use ResourceLocation instead of Identifier * Start applying Iris -> Sodium Mixins * Make NotFine menu open if holding shift * Fixed Tessellators in production env * Finish Sodium Fluid Renderer (#24) * Init and pass Sodium LightPipelines * Remove registry lookup and refactor WorldUtil * Hook up lighting pipeline * Patch fluid velocity * It's alive! Sodium Fluid Renderer is alive! * Fix face culling not taking third person camera offset into account * rewrite ACTEntityRenderer to stop transforming ALL the classes * use ClassConstantPoolParser in TessellatorTransformer to speed up search for Tessellator references * use ClassConstantPoolParser in GLStateManagerTransformer to speed up search for class references * rewrite GLStateManagerTransformer and TessellatorTransformer * merge GLStateManagerTransfor and TessellatorTransformer into one Transformer * Fixed smooth lighting rendering * Iris block_id Mixins & BlockStateIdMap initial impl for 1.7.10 * Fix running with lwjgl debug flag & Cleanup old ShadersMod transformers * Initialize GLStateManager via Mixins instead of all in the static block * Clean up chunk load/unload tracking, fix chunks rendering without neighbors sometimes * Fix occlusion culler not re-running after important uploads Backport of https://github.com/CaffeineMC/sodium-fabric/pull/755 * Add chunks to queues without going through occlusion culler Partially reverts the previous chunk tracking commit, because that logic will reintroduce https://github.com/CaffeineMC/sodium-fabric/issues/605 As long as we only rebuild with neighbors present, we shouldn't see the visual seams * Extremely primitive synchronization approach for ISBRH * Use factory for Spdium menu createElement outputs This will allow NotFine to use Sodium menu elements and vice versa in a future commit. * Splash Screen Compat * Separate remaining NamedState enums * NotFine but it loads Sodium pages * Hook up NotFine optimizations * Hook up some NotFine features * copy over hud caching code from hodgepodge * backport glstatemanager mixin * Track thread that currently owns the GL Context in addition to the main thread. * First pass over FontRenderer, 1300->1400 FPS on my GPU when showing F3 Done: - A batching vertex buffer builder for font output - Reduction in drawcalls from 1-3 per character to 1 per font atlas switch - Mixin to draw the entire F3 screen in one batch, instead of separate batches per line TODO: - Switch drawing to a VBO - Cache string meshes across frames - Cache string width calculations used for layouts - Multidraw to reduce draw calls even further * Add JVM flag to bypass GL state caching * Push/Pop Attrib Hacks -- to be evolved later * Fix FontRenderer+SplashScreen combo * HUDCaching tweaks * Add license * Jabba Compat, and reset tesselator state even if the chunk render thread blows up * Initial Xaero's World Map + Minimap Support * Disable Fastcraft & Optifine if present * Iris Progress * Wire up more Iris mixins, informing pipeline stages. Still not rendering anything visible. * Don't try to transform the server * Avoid running biome generator on client in singleplayer * Call world biome retrieval methods instead of copying array directly (#25) * Shaders now do something! * Shadow Pass work * First shadow pass renders; however it moves all around when moving the camera... * Second shadow pass not running because it makes everything very very dark instead of just rendering translucents * Actually use the ShadowRenderer Model View when running the shadow pass... * Enable Sodium SmoothLightPipeline & Iris useSeparateAo * Avoid repeatedly copying biome data on each Y level (#27) * Celestial Rotation fixes * Water progress * Uniforms audit * Lightmap workaround * PBR compiling, stuck on Normal and Specular textures being added in * Shaderpack selection "works"; ShaderOptions TODO * Hud caching angelica (#28) * Potential hud-caching fix * Shader Options almost working ** Clicking on everything doesn't yet work, and the visuals are slightly off * Entity shadows seem to be working * Move glint fix to Mixin * Rework mouse handling for ShaderPackConfig * Stop centering shader options vertically * Angelica pbr (#31) * Only use Sodium light pipeline if useSeparateAo is on Sodium pipeline is still very buggy, so isolate it to Iris-only for now * Fix region sorting for translucency * Open Shaderpack now works on Linux * RM Shadersmod * Initial iris scrollbar clicking * Punt unsupported ISBRHs to the main thread * Delete the ISBRH lock, shouldn't be needed anymore * Render GT blocks on main thread * Require CCC 1.2.0+ * Depend on CCC 1.2 * Fix TESRs not being tracked for blocks rendered on main thread * Cut down number of runtime dependencies, enable CoreTweaks in dev by default * Add modern F3 background * Pull over some hodgepodge mixins --------- Co-authored-by: makamys <[email protected]> Co-authored-by: embeddedt <[email protected]> Co-authored-by: rjnasers <[email protected]> Co-authored-by: ah-OOG-ah <[email protected]> Co-authored-by: Ryan Nasers <[email protected]> Co-authored-by: Rad <[email protected]> Co-authored-by: Bogdan <[email protected]> Co-authored-by: Caedis <[email protected]> Co-authored-by: jss2a98aj <[email protected]> Co-authored-by: Alexdoru <[email protected]> Co-authored-by: Raven Szewczyk <[email protected]> Co-authored-by: mist475 <[email protected]> Co-authored-by: Ryan Nasers <[email protected]>
This commit is contained in:
942 files changed
+65828
-8640
No files matched your search
+17
@@ -0,0 +1,17 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public class BatchingDebugMessageHelper {
|
||||
public static String getDebugMessage(DrawCallTrackingRenderBuffers drawTracker) {
|
||||
int drawCalls = drawTracker.getDrawCalls();
|
||||
int renderTypes = drawTracker.getRenderTypes();
|
||||
|
||||
if (drawCalls > 0) {
|
||||
int effectivenessTimes10 = renderTypes * 1000 / drawCalls;
|
||||
float effectiveness = effectivenessTimes10 / 10.0F;
|
||||
|
||||
return drawCalls + " draw calls / " + renderTypes + " render types = " + effectiveness + "% effective";
|
||||
} else {
|
||||
return "(no draw calls)";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public interface BlendingStateHolder {
|
||||
TransparencyType getTransparencyType();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DrawState;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public interface BufferBuilderExt {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DrawState;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BufferSegment {
|
||||
private final ByteBuffer slice;
|
||||
@Getter
|
||||
private final DrawState drawState;
|
||||
private final RenderLayer type;
|
||||
|
||||
public BufferSegment(ByteBuffer slice, DrawState drawState, RenderLayer type) {
|
||||
this.slice = slice;
|
||||
this.drawState = drawState;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ByteBuffer getSlice() {
|
||||
return slice;
|
||||
}
|
||||
|
||||
public RenderLayer getRenderType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public interface DrawCallTrackingRenderBuffers {
|
||||
int getDrawCalls();
|
||||
int getRenderTypes();
|
||||
void resetDrawCounts();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public interface FlushableMultiBufferSource {
|
||||
void flushNonTranslucentContent();
|
||||
void flushTranslucentContent();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public interface Groupable {
|
||||
void startGroup();
|
||||
boolean maybeStartGroup();
|
||||
void endGroup();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public interface MemoryTrackingBuffer {
|
||||
int getAllocatedSize();
|
||||
int getUsedSize();
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public interface MemoryTrackingRenderBuffers {
|
||||
int getEntityBufferAllocatedSize();
|
||||
int getMiscBufferAllocatedSize();
|
||||
int getMaxBegins();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public interface RenderBuffersExt {
|
||||
void beginLevelRendering();
|
||||
void endLevelRendering();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
public enum TransparencyType {
|
||||
/**
|
||||
* Opaque, non transparent content.
|
||||
*/
|
||||
OPAQUE,
|
||||
/**
|
||||
* Generally transparent / translucent content.
|
||||
*/
|
||||
GENERAL_TRANSPARENT,
|
||||
/**
|
||||
* Enchantment glint and crumbling blocks
|
||||
* These *must* be rendered after their corresponding opaque / transparent parts.
|
||||
*/
|
||||
DECAL,
|
||||
/**
|
||||
* Water mask, should be drawn after pretty much everything except for translucent terrain and lines.
|
||||
* Prevents water from appearing inside of boats.
|
||||
*/
|
||||
WATER_MASK,
|
||||
/**
|
||||
* Block outlines and other debug things that are overlaid on to the world.
|
||||
* Should be drawn last to avoid weirdness with entity shadows / banners.
|
||||
*/
|
||||
LINES
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.coderbot.batchedentityrendering.impl;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
|
||||
public interface WrappableRenderType {
|
||||
/**
|
||||
* Returns the underlying wrapped RenderType. Might return itself if this RenderType doesn't wrap anything.
|
||||
*/
|
||||
RenderLayer unwrap();
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package net.coderbot.batchedentityrendering.impl.ordering;
|
||||
|
||||
import de.odysseus.ithaka.digraph.Digraph;
|
||||
import de.odysseus.ithaka.digraph.Digraphs;
|
||||
import de.odysseus.ithaka.digraph.MapDigraph;
|
||||
import de.odysseus.ithaka.digraph.util.fas.FeedbackArcSet;
|
||||
import de.odysseus.ithaka.digraph.util.fas.FeedbackArcSetPolicy;
|
||||
import de.odysseus.ithaka.digraph.util.fas.FeedbackArcSetProvider;
|
||||
import de.odysseus.ithaka.digraph.util.fas.SimpleFeedbackArcSetProvider;
|
||||
import net.coderbot.batchedentityrendering.impl.BlendingStateHolder;
|
||||
import net.coderbot.batchedentityrendering.impl.TransparencyType;
|
||||
import net.coderbot.batchedentityrendering.impl.WrappableRenderType;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
public class GraphTranslucencyRenderOrderManager implements RenderOrderManager {
|
||||
private final FeedbackArcSetProvider feedbackArcSetProvider;
|
||||
private final EnumMap<TransparencyType, Digraph<RenderLayer>> types;
|
||||
|
||||
private boolean inGroup = false;
|
||||
private final EnumMap<TransparencyType, RenderLayer> currentTypes;
|
||||
|
||||
public GraphTranslucencyRenderOrderManager() {
|
||||
feedbackArcSetProvider = new SimpleFeedbackArcSetProvider();
|
||||
types = new EnumMap<>(TransparencyType.class);
|
||||
currentTypes = new EnumMap<>(TransparencyType.class);
|
||||
|
||||
for (TransparencyType type : TransparencyType.values()) {
|
||||
types.put(type, new MapDigraph<>());
|
||||
}
|
||||
}
|
||||
|
||||
private static TransparencyType getTransparencyType(RenderLayer type) {
|
||||
while (type instanceof WrappableRenderType) {
|
||||
type = ((WrappableRenderType) type).unwrap();
|
||||
}
|
||||
|
||||
if (type instanceof BlendingStateHolder blendingState) {
|
||||
return blendingState.getTransparencyType();
|
||||
}
|
||||
|
||||
// Default to "generally transparent" if we can't figure it out.
|
||||
return TransparencyType.GENERAL_TRANSPARENT;
|
||||
}
|
||||
|
||||
public void begin(RenderLayer renderType) {
|
||||
TransparencyType transparencyType = getTransparencyType(renderType);
|
||||
Digraph<RenderLayer> graph = types.get(transparencyType);
|
||||
graph.add(renderType);
|
||||
|
||||
if (inGroup) {
|
||||
RenderLayer previous = currentTypes.put(transparencyType, renderType);
|
||||
|
||||
if (previous == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int weight = graph.get(previous, renderType).orElse(0);
|
||||
weight += 1;
|
||||
graph.put(previous, renderType, weight);
|
||||
}
|
||||
}
|
||||
|
||||
public void startGroup() {
|
||||
if (inGroup) {
|
||||
throw new IllegalStateException("Already in a group");
|
||||
}
|
||||
|
||||
currentTypes.clear();
|
||||
inGroup = true;
|
||||
}
|
||||
|
||||
public boolean maybeStartGroup() {
|
||||
if (inGroup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
currentTypes.clear();
|
||||
inGroup = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void endGroup() {
|
||||
if (!inGroup) {
|
||||
throw new IllegalStateException("Not in a group");
|
||||
}
|
||||
|
||||
currentTypes.clear();
|
||||
inGroup = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
// TODO: Is reallocation efficient?
|
||||
types.clear();
|
||||
|
||||
for (TransparencyType type : TransparencyType.values()) {
|
||||
types.put(type, new MapDigraph<>());
|
||||
}
|
||||
}
|
||||
|
||||
public Iterable<RenderLayer> getRenderOrder() {
|
||||
int layerCount = 0;
|
||||
|
||||
for (Digraph<RenderLayer> graph : types.values()) {
|
||||
layerCount += graph.getVertexCount();
|
||||
}
|
||||
|
||||
List<RenderLayer> allLayers = new ArrayList<>(layerCount);
|
||||
|
||||
for (Digraph<RenderLayer> graph : types.values()) {
|
||||
// TODO: Make sure that FAS can't become a bottleneck!
|
||||
// Running NP-hard algorithms in a real time rendering loop might not be an amazing idea.
|
||||
// This shouldn't be necessary in sane scenes, though, and if there aren't cycles,
|
||||
// then this *should* be relatively inexpensive, since it'll bail out and return an empty set.
|
||||
FeedbackArcSet<RenderLayer> arcSet =
|
||||
feedbackArcSetProvider.getFeedbackArcSet(graph, graph, FeedbackArcSetPolicy.MIN_WEIGHT);
|
||||
|
||||
if (arcSet.getEdgeCount() > 0) {
|
||||
// This means that our dependency graph had cycles!!!
|
||||
// This is very weird and isn't expected - but we try to handle it gracefully anyways.
|
||||
|
||||
// Our feedback arc set algorithm finds some dependency links that can be removed hopefully
|
||||
// without disrupting the overall order too much. Hopefully it isn't too slow!
|
||||
for (RenderLayer source : arcSet.vertices()) {
|
||||
for (RenderLayer target : arcSet.targets(source)) {
|
||||
graph.remove(source, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allLayers.addAll(Digraphs.toposort(graph, false));
|
||||
}
|
||||
|
||||
return allLayers;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package net.coderbot.batchedentityrendering.impl.ordering;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
|
||||
public interface RenderOrderManager {
|
||||
void begin(RenderLayer type);
|
||||
void startGroup();
|
||||
boolean maybeStartGroup();
|
||||
void endGroup();
|
||||
void reset();
|
||||
Iterable<RenderLayer> getRenderOrder();
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package net.coderbot.batchedentityrendering.impl.ordering;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class SimpleRenderOrderManager implements RenderOrderManager {
|
||||
private final LinkedHashSet<RenderLayer> renderTypes;
|
||||
|
||||
public SimpleRenderOrderManager() {
|
||||
renderTypes = new LinkedHashSet<>();
|
||||
}
|
||||
|
||||
public void begin(RenderLayer type) {
|
||||
renderTypes.add(type);
|
||||
}
|
||||
|
||||
public void startGroup() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public boolean maybeStartGroup() {
|
||||
// no-op
|
||||
return false;
|
||||
}
|
||||
|
||||
public void endGroup() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
renderTypes.clear();
|
||||
}
|
||||
|
||||
public Iterable<RenderLayer> getRenderOrder() {
|
||||
return renderTypes;
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package net.coderbot.batchedentityrendering.impl.ordering;
|
||||
|
||||
import net.coderbot.batchedentityrendering.impl.BlendingStateHolder;
|
||||
import net.coderbot.batchedentityrendering.impl.TransparencyType;
|
||||
import net.coderbot.batchedentityrendering.impl.WrappableRenderType;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class TranslucencyRenderOrderManager implements RenderOrderManager {
|
||||
private final EnumMap<TransparencyType, LinkedHashSet<RenderLayer>> renderTypes;
|
||||
|
||||
public TranslucencyRenderOrderManager() {
|
||||
renderTypes = new EnumMap<>(TransparencyType.class);
|
||||
|
||||
for (TransparencyType type : TransparencyType.values()) {
|
||||
renderTypes.put(type, new LinkedHashSet<>());
|
||||
}
|
||||
}
|
||||
|
||||
private static TransparencyType getTransparencyType(RenderLayer type) {
|
||||
while (type instanceof WrappableRenderType) {
|
||||
type = ((WrappableRenderType) type).unwrap();
|
||||
}
|
||||
|
||||
if (type instanceof BlendingStateHolder) {
|
||||
return ((BlendingStateHolder) type).getTransparencyType();
|
||||
}
|
||||
|
||||
// Default to "generally transparent" if we can't figure it out.
|
||||
return TransparencyType.GENERAL_TRANSPARENT;
|
||||
}
|
||||
|
||||
public void begin(RenderLayer type) {
|
||||
renderTypes.get(getTransparencyType(type)).add(type);
|
||||
}
|
||||
|
||||
public void startGroup() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public boolean maybeStartGroup() {
|
||||
// no-op
|
||||
return false;
|
||||
}
|
||||
|
||||
public void endGroup() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
renderTypes.forEach((type, set) -> {
|
||||
set.clear();
|
||||
});
|
||||
}
|
||||
|
||||
public Iterable<RenderLayer> getRenderOrder() {
|
||||
int layerCount = 0;
|
||||
|
||||
for (LinkedHashSet<RenderLayer> set : renderTypes.values()) {
|
||||
layerCount += set.size();
|
||||
}
|
||||
|
||||
List<RenderLayer> allRenderTypes = new ArrayList<>(layerCount);
|
||||
|
||||
for (LinkedHashSet<RenderLayer> set : renderTypes.values()) {
|
||||
allRenderTypes.addAll(set);
|
||||
}
|
||||
|
||||
return allRenderTypes;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user