add sdo support for bbb models

This commit is contained in:
aronwk-aaron 2022-10-24 20:57:04 -05:00
parent 3fa8bd4651
commit 000a8c47bf

View File

@ -411,10 +411,20 @@ def download_model(id):
def ugc(content): def ugc(content):
ugc_data = UGC.query.filter(UGC.id == content.ugc_id).first() ugc_data = UGC.query.filter(UGC.id == content.ugc_id).first()
uncompressed_lxfml = zlib.decompress(ugc_data.lxfml) uncompressed_lxfml = decompress(ugc_data.lxfml)
response = make_response(uncompressed_lxfml) response = make_response(uncompressed_lxfml)
return response, ugc_data.filename return response, ugc_data.filename
def decompress(data):
assert data[:5] == b"sd0\x01\xff"
pos = 5
out = b""
while pos < len(data):
length = int.from_bytes(data[pos:pos+4], "little")
pos += 4
out += zlib.decompress(data[pos:pos+length])
pos += length
return out
def prebuilt(content, file_format, lod): def prebuilt(content, file_format, lod):
# translate LOT to component id # translate LOT to component id