Skip to content

Commit

Permalink
Remove VertexViewProvider and VertexViewProvider registry
Browse files Browse the repository at this point in the history
  • Loading branch information
PepperCode1 committed May 31, 2024
1 parent c880cdc commit ee3958b
Show file tree
Hide file tree
Showing 34 changed files with 64 additions and 480 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import org.jetbrains.annotations.Nullable;

import com.mojang.blaze3d.vertex.VertexFormat;

import dev.engine_room.flywheel.api.backend.Backend;
import dev.engine_room.flywheel.api.layout.LayoutBuilder;
import dev.engine_room.flywheel.api.registry.IdRegistry;
import dev.engine_room.flywheel.api.registry.Registry;
import dev.engine_room.flywheel.api.vertex.VertexViewProvider;
import dev.engine_room.flywheel.api.visualization.BlockEntityVisualizer;
import dev.engine_room.flywheel.api.visualization.EntityVisualizer;
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
Expand All @@ -35,10 +32,6 @@ public interface FlwApiLink {

LayoutBuilder createLayoutBuilder();

VertexViewProvider getVertexViewProvider(VertexFormat format);

void setVertexViewProvider(VertexFormat format, VertexViewProvider provider);

boolean supportsVisualization(@Nullable LevelAccessor level);

@Nullable
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package dev.engine_room.flywheel.lib.model;

import java.nio.ByteBuffer;
import java.util.Collection;

import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;
import org.joml.Vector4f;
import org.lwjgl.system.MemoryUtil;

import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferBuilder.DrawState;
import com.mojang.blaze3d.vertex.VertexFormat;

import dev.engine_room.flywheel.api.material.Material;
import dev.engine_room.flywheel.api.model.Mesh;
import dev.engine_room.flywheel.api.model.Model;
import dev.engine_room.flywheel.api.vertex.VertexList;
import dev.engine_room.flywheel.api.vertex.VertexView;
import dev.engine_room.flywheel.api.vertex.VertexViewProviderRegistry;
import dev.engine_room.flywheel.lib.internal.FlwLibXplat;
import dev.engine_room.flywheel.lib.material.Materials;
import dev.engine_room.flywheel.lib.memory.MemoryBlock;
Expand All @@ -36,27 +28,6 @@ public final class ModelUtil {
private ModelUtil() {
}

public static MemoryBlock convertVanillaBuffer(BufferBuilder.RenderedBuffer buffer, VertexView vertexView) {
DrawState drawState = buffer.drawState();
int vertexCount = drawState.vertexCount();
VertexFormat srcFormat = drawState.format();

ByteBuffer src = buffer.vertexBuffer();
MemoryBlock dst = MemoryBlock.malloc((long) vertexCount * vertexView.stride());
long srcPtr = MemoryUtil.memAddress(src);
long dstPtr = dst.ptr();

VertexView srcView = VertexViewProviderRegistry.getProvider(srcFormat).createVertexView();
srcView.ptr(srcPtr);
vertexView.ptr(dstPtr);
srcView.vertexCount(vertexCount);
vertexView.vertexCount(vertexCount);

srcView.writeAll(vertexView);

return dst;
}

@Nullable
public static Material getMaterial(RenderType chunkRenderType, boolean shaded) {
if (chunkRenderType == RenderType.solid()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dev.engine_room.flywheel.lib.model.baked;

import java.nio.ByteBuffer;

import org.jetbrains.annotations.Nullable;
import org.lwjgl.system.MemoryUtil;

import com.mojang.blaze3d.vertex.BufferBuilder;

import dev.engine_room.flywheel.api.vertex.VertexView;
import dev.engine_room.flywheel.lib.memory.MemoryBlock;
import dev.engine_room.flywheel.lib.model.SimpleMesh;
import dev.engine_room.flywheel.lib.vertex.NoOverlayVertexView;

final class MeshHelper {
private MeshHelper() {
}

public static SimpleMesh blockVerticesToMesh(BufferBuilder.RenderedBuffer buffer, @Nullable String meshDescriptor) {
BufferBuilder.DrawState drawState = buffer.drawState();
int vertexCount = drawState.vertexCount();
long srcStride = drawState.format().getVertexSize();

VertexView vertexView = new NoOverlayVertexView();
long dstStride = vertexView.stride();

ByteBuffer src = buffer.vertexBuffer();
MemoryBlock dst = MemoryBlock.malloc((long) vertexCount * dstStride);
long srcPtr = MemoryUtil.memAddress(src);
long dstPtr = dst.ptr();
// The first 31 bytes of each vertex in a block vertex buffer are guaranteed to contain the same data in the
// same order regardless of whether the format is extended by mods like Iris or OptiFine. Copy these bytes and
// ignore the rest.
long bytesToCopy = Math.min(dstStride, 31);

for (int i = 0; i < vertexCount; i++) {
// It is safe to copy bytes directly since the NoOverlayVertexView uses the same memory layout as the first
// 31 bytes of the block vertex format, vanilla or otherwise.
MemoryUtil.memCopy(srcPtr + srcStride * i, dstPtr + dstStride * i, bytesToCopy);
}

vertexView.ptr(dstPtr);
vertexView.vertexCount(vertexCount);

return new SimpleMesh(vertexView, dst, meshDescriptor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ default float x(int index) {
}

@Override
default float y(int index){
default float y(int index) {
return 0.0f;
}

@Override
default float z(int index){
default float z(int index) {
return 0.0f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.List;

import dev.engine_room.flywheel.api.visualization.VisualizationContext;

import net.minecraft.world.entity.Entity;

public class SimpleEntityVisual<T extends Entity> extends AbstractEntityVisual<T> implements SimpleDynamicVisual {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import dev.engine_room.flywheel.api.visualization.EntityVisualizer;
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
import dev.engine_room.flywheel.api.visualization.VisualizerRegistry;

import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import dev.engine_room.flywheel.api.visualization.EntityVisualizer;
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
import dev.engine_room.flywheel.api.visualization.VisualizerRegistry;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.Level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@

import org.jetbrains.annotations.Nullable;

import com.mojang.blaze3d.vertex.VertexFormat;

import dev.engine_room.flywheel.api.backend.Backend;
import dev.engine_room.flywheel.api.internal.FlwApiLink;
import dev.engine_room.flywheel.api.layout.LayoutBuilder;
import dev.engine_room.flywheel.api.registry.IdRegistry;
import dev.engine_room.flywheel.api.registry.Registry;
import dev.engine_room.flywheel.api.vertex.VertexViewProvider;
import dev.engine_room.flywheel.api.visualization.BlockEntityVisualizer;
import dev.engine_room.flywheel.api.visualization.EntityVisualizer;
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
import dev.engine_room.flywheel.impl.layout.LayoutBuilderImpl;
import dev.engine_room.flywheel.impl.registry.IdRegistryImpl;
import dev.engine_room.flywheel.impl.registry.RegistryImpl;
import dev.engine_room.flywheel.impl.vertex.VertexViewProviderRegistryImpl;
import dev.engine_room.flywheel.impl.visualization.VisualizationManagerImpl;
import dev.engine_room.flywheel.impl.visualization.VisualizerRegistryImpl;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -61,16 +57,6 @@ public LayoutBuilder createLayoutBuilder() {
return new LayoutBuilderImpl();
}

@Override
public VertexViewProvider getVertexViewProvider(VertexFormat format) {
return VertexViewProviderRegistryImpl.getProvider(format);
}

@Override
public void setVertexViewProvider(VertexFormat format, VertexViewProvider provider) {
VertexViewProviderRegistryImpl.setProvider(format, provider);
}

@Override
public boolean supportsVisualization(@Nullable LevelAccessor level) {
return VisualizationManagerImpl.supportsVisualization(level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import org.joml.Matrix4f;

import dev.engine_room.flywheel.api.event.RenderContext;
import com.mojang.blaze3d.vertex.PoseStack;

import dev.engine_room.flywheel.api.event.RenderContext;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.jetbrains.annotations.Nullable;

import dev.engine_room.flywheel.api.visualization.BlockEntityVisualizer;

import net.minecraft.world.level.block.entity.BlockEntity;

public interface BlockEntityTypeExtension<T extends BlockEntity> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.jetbrains.annotations.Nullable;

import dev.engine_room.flywheel.api.visualization.EntityVisualizer;

import net.minecraft.world.entity.Entity;

public interface EntityTypeExtension<T extends Entity> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package dev.engine_room.flywheel.impl.extension;

import dev.engine_room.flywheel.lib.transform.PoseTransformStack;
import com.mojang.blaze3d.vertex.PoseStack;

import dev.engine_room.flywheel.lib.transform.PoseTransformStack;

/**
* An extension interface for {@link PoseStack} that provides a {@link PoseTransformStack} wrapper.
* <br>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import dev.engine_room.flywheel.api.layout.ValueRepr;
import dev.engine_room.flywheel.impl.layout.LayoutImpl.ElementImpl;
import dev.engine_room.flywheel.lib.math.MoreMath;

import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import dev.engine_room.flywheel.api.layout.ElementType;
import dev.engine_room.flywheel.api.layout.Layout;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

final class LayoutImpl implements Layout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import dev.engine_room.flywheel.api.visualization.BlockEntityVisualizer;
import dev.engine_room.flywheel.impl.extension.BlockEntityTypeExtension;

import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import dev.engine_room.flywheel.api.visualization.VisualizationManager;

import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import dev.engine_room.flywheel.api.visualization.VisualizationManager;

import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.chunk.LevelChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import dev.engine_room.flywheel.api.visualization.VisualizationManager;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.core.BlockPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import dev.engine_room.flywheel.lib.visual.VisualizationHelper;

import net.minecraft.world.level.block.entity.BlockEntity;

@Mixin(targets = "net.minecraft.client.renderer.chunk.ChunkRenderDispatcher$RenderChunk$RebuildTask")
Expand Down
Loading

0 comments on commit ee3958b

Please sign in to comment.