use of codechicken.lib.render.buffer.BakingVertexBuffer in project LogisticsPipes by RS485.
the class Model3D method renderToQuads.
@Override
@SideOnly(Side.CLIENT)
@SneakyThrows({ IllegalAccessException.class })
public List<BakedQuad> renderToQuads(VertexFormat format, I3DOperation... i3dOperations) {
List<IVertexOperation> list = new ArrayList<>();
Set<String> hash = new HashSet<>();
hash.add(String.valueOf(format.hashCode()));
boolean cachable = true;
for (I3DOperation op : i3dOperations) {
IVertexOperation iVertexOperation = (IVertexOperation) op.getOriginal();
list.add(iVertexOperation);
if (iVertexOperation instanceof IconTransformation) {
hash.add(((IconTransformation) iVertexOperation).icon.toString());
} else if (iVertexOperation instanceof Rotation) {
hash.add(iVertexOperation.toString());
} else if (iVertexOperation instanceof Scale) {
hash.add(iVertexOperation.toString());
} else if (iVertexOperation instanceof Translation) {
hash.add(iVertexOperation.toString());
} else {
cachable = false;
}
}
if (cachable) {
List<BakedQuad> content = renderCache.getIfPresent(hash.hashCode());
if (content != null) {
return content;
}
}
BakingVertexBuffer buffer = BakingVertexBuffer.create();
CCRenderState ccrs = CCRenderState.instance();
ccrs.reset();
ccrs.startDrawing(0x7, format, buffer);
model.render(ccrs, list.toArray(new IVertexOperation[0]));
buffer.finishDrawing();
emptyHashMap.clear();
if (spiteMap != null) {
spiteMap.set(buffer, emptyHashMap);
}
List<BakedQuad> quads = buffer.bake();
if (cachable) {
renderCache.put(hash.hashCode(), quads);
}
return quads;
}
Aggregations