Skip to content

Commit

Permalink
Courier transformed
Browse files Browse the repository at this point in the history
- SimpleQuadMesh holds a reference to its backing MemoryBlock so the
  cleaner doesn't drop it
- Fixes issue where meshes suddenly start rendering garbage
  • Loading branch information
Jozufozu committed Jul 28, 2024
1 parent 69411fb commit fe89e00
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@

import dev.engine_room.flywheel.api.vertex.MutableVertexList;
import dev.engine_room.flywheel.api.vertex.VertexList;
import dev.engine_room.flywheel.lib.memory.MemoryBlock;

public final class SimpleQuadMesh implements QuadMesh {
private final VertexList vertexList;
// Unused but we need to hold on to a reference so the cleaner doesn't nuke us.
private final MemoryBlock data;
private final Vector4f boundingSphere;
@Nullable
private final String descriptor;

public SimpleQuadMesh(VertexList vertexList, @Nullable String descriptor) {
public SimpleQuadMesh(VertexList vertexList, MemoryBlock data, @Nullable String descriptor) {
this.vertexList = vertexList;
this.data = data;
boundingSphere = ModelUtil.computeBoundingSphere(vertexList);
this.descriptor = descriptor;
}

public SimpleQuadMesh(VertexList vertexList) {
this(vertexList, null);
public SimpleQuadMesh(VertexList vertexList, MemoryBlock data) {
this(vertexList, data, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public static SimpleQuadMesh blockVerticesToMesh(BufferBuilder.RenderedBuffer bu
vertexView.ptr(dstPtr);
vertexView.vertexCount(vertexCount);

return new SimpleQuadMesh(vertexView, meshDescriptor);
return new SimpleQuadMesh(vertexView, dst, meshDescriptor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static Mesh convert(ModelPart modelPart, @Nullable PoseStack poseStack, @

VertexView vertexView = new PosTexNormalVertexView();
vertexView.load(data);
return new SimpleQuadMesh(vertexView, "source=ModelPartConverter");
return new SimpleQuadMesh(vertexView, data, "source=ModelPartConverter");
}

public static Mesh convert(ModelLayerLocation layer, @Nullable TextureAtlasSprite sprite, String... childPath) {
Expand Down

0 comments on commit fe89e00

Please sign in to comment.