mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-12 21:43:56 +01:00
Courier transformed
- SimpleQuadMesh holds a reference to its backing MemoryBlock so the cleaner doesn't drop it - Fixes issue where meshes suddenly start rendering garbage
This commit is contained in:
parent
69411fb36f
commit
fe89e0024a
@ -6,21 +6,25 @@ import org.joml.Vector4fc;
|
|||||||
|
|
||||||
import dev.engine_room.flywheel.api.vertex.MutableVertexList;
|
import dev.engine_room.flywheel.api.vertex.MutableVertexList;
|
||||||
import dev.engine_room.flywheel.api.vertex.VertexList;
|
import dev.engine_room.flywheel.api.vertex.VertexList;
|
||||||
|
import dev.engine_room.flywheel.lib.memory.MemoryBlock;
|
||||||
|
|
||||||
public final class SimpleQuadMesh implements QuadMesh {
|
public final class SimpleQuadMesh implements QuadMesh {
|
||||||
private final VertexList vertexList;
|
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;
|
private final Vector4f boundingSphere;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String descriptor;
|
private final String descriptor;
|
||||||
|
|
||||||
public SimpleQuadMesh(VertexList vertexList, @Nullable String descriptor) {
|
public SimpleQuadMesh(VertexList vertexList, MemoryBlock data, @Nullable String descriptor) {
|
||||||
this.vertexList = vertexList;
|
this.vertexList = vertexList;
|
||||||
|
this.data = data;
|
||||||
boundingSphere = ModelUtil.computeBoundingSphere(vertexList);
|
boundingSphere = ModelUtil.computeBoundingSphere(vertexList);
|
||||||
this.descriptor = descriptor;
|
this.descriptor = descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleQuadMesh(VertexList vertexList) {
|
public SimpleQuadMesh(VertexList vertexList, MemoryBlock data) {
|
||||||
this(vertexList, null);
|
this(vertexList, data, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,6 +42,6 @@ final class MeshHelper {
|
|||||||
vertexView.ptr(dstPtr);
|
vertexView.ptr(dstPtr);
|
||||||
vertexView.vertexCount(vertexCount);
|
vertexView.vertexCount(vertexCount);
|
||||||
|
|
||||||
return new SimpleQuadMesh(vertexView, meshDescriptor);
|
return new SimpleQuadMesh(vertexView, dst, meshDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public final class ModelPartConverter {
|
|||||||
|
|
||||||
VertexView vertexView = new PosTexNormalVertexView();
|
VertexView vertexView = new PosTexNormalVertexView();
|
||||||
vertexView.load(data);
|
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) {
|
public static Mesh convert(ModelLayerLocation layer, @Nullable TextureAtlasSprite sprite, String... childPath) {
|
||||||
|
Loading…
Reference in New Issue
Block a user