-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove VertexViewProvider and VertexViewProvider registry
- Loading branch information
1 parent
c880cdc
commit ee3958b
Showing
34 changed files
with
64 additions
and
480 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
5 changes: 0 additions & 5 deletions
5
common/src/api/java/dev/engine_room/flywheel/api/vertex/VertexViewProvider.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
common/src/api/java/dev/engine_room/flywheel/api/vertex/VertexViewProviderRegistry.java
This file was deleted.
Oops, something went wrong.
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
47 changes: 47 additions & 0 deletions
47
common/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshHelper.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,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); | ||
} | ||
} |
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
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
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: 2 additions & 1 deletion
3
common/src/main/java/dev/engine_room/flywheel/impl/extension/PoseStackExtension.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
18 changes: 0 additions & 18 deletions
18
common/src/main/java/dev/engine_room/flywheel/impl/extension/VertexFormatExtension.java
This file was deleted.
Oops, something went wrong.
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
25 changes: 0 additions & 25 deletions
25
common/src/main/java/dev/engine_room/flywheel/impl/mixin/VertexFormatMixin.java
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.