mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Fix(?) for crunched cubemaps
This commit is contained in:
parent
4bae98813b
commit
43fa0ac820
@ -21,14 +21,43 @@ bool crunch_unpack_level(const uint8_t* data, uint32_t data_size, uint32_t level
|
|||||||
const crn_uint32 blocks_x = std::max(1U, (width + 3) >> 2);
|
const crn_uint32 blocks_x = std::max(1U, (width + 3) >> 2);
|
||||||
const crn_uint32 blocks_y = std::max(1U, (height + 3) >> 2);
|
const crn_uint32 blocks_y = std::max(1U, (height + 3) >> 2);
|
||||||
const crn_uint32 row_pitch = blocks_x * crnd::crnd_get_bytes_per_dxt_block(tex_info.m_format);
|
const crn_uint32 row_pitch = blocks_x * crnd::crnd_get_bytes_per_dxt_block(tex_info.m_format);
|
||||||
const crn_uint32 total_face_size = row_pitch * blocks_y;
|
const crn_uint32 face_count = tex_info.m_faces;
|
||||||
*ret = new uint8_t[total_face_size];
|
const crn_uint32 face_size = row_pitch * blocks_y;
|
||||||
*ret_size = total_face_size;
|
const crn_uint32 total_face_size = face_size * face_count;
|
||||||
if (!crnd::crnd_unpack_level(pContext, ret, total_face_size, row_pitch, level_index))
|
|
||||||
|
void* out_ptrs[cCRNMaxFaces]{};
|
||||||
|
if (face_count == 1)
|
||||||
|
{
|
||||||
|
out_ptrs[0] = new uint8_t[face_size]{};
|
||||||
|
*ret_size = face_size;
|
||||||
|
}
|
||||||
|
else if (1 < face_count < 7)
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < face_count; i++)
|
||||||
|
{
|
||||||
|
out_ptrs[i] = new uint8_t[face_size]{};
|
||||||
|
}
|
||||||
|
*ret_size = total_face_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!crnd::crnd_unpack_level(pContext, out_ptrs, face_size, row_pitch, level_index))
|
||||||
{
|
{
|
||||||
crnd::crnd_unpack_end(pContext);
|
crnd::crnd_unpack_end(pContext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t* buff = new uint8_t[total_face_size]{};
|
||||||
|
for (uint8_t i = 0; i < face_count; i++)
|
||||||
|
{
|
||||||
|
memcpy(buff + (face_size * i), out_ptrs[i], face_size);
|
||||||
|
free(out_ptrs[i]);
|
||||||
|
}
|
||||||
|
*ret = buff;
|
||||||
|
|
||||||
crnd::crnd_unpack_end(pContext);
|
crnd::crnd_unpack_end(pContext);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -21,14 +21,43 @@ bool unity_crunch_unpack_level(const uint8_t* data, uint32_t data_size, uint32_t
|
|||||||
const crn_uint32 blocks_x = std::max(1U, (width + 3) >> 2);
|
const crn_uint32 blocks_x = std::max(1U, (width + 3) >> 2);
|
||||||
const crn_uint32 blocks_y = std::max(1U, (height + 3) >> 2);
|
const crn_uint32 blocks_y = std::max(1U, (height + 3) >> 2);
|
||||||
const crn_uint32 row_pitch = blocks_x * unitycrnd::crnd_get_bytes_per_dxt_block(tex_info.m_format);
|
const crn_uint32 row_pitch = blocks_x * unitycrnd::crnd_get_bytes_per_dxt_block(tex_info.m_format);
|
||||||
const crn_uint32 total_face_size = row_pitch * blocks_y;
|
const crn_uint32 face_count = tex_info.m_faces;
|
||||||
*ret = new uint8_t[total_face_size];
|
const crn_uint32 face_size = row_pitch * blocks_y;
|
||||||
*ret_size = total_face_size;
|
const crn_uint32 total_face_size = face_size * face_count;
|
||||||
if (!unitycrnd::crnd_unpack_level(pContext, ret, total_face_size, row_pitch, level_index))
|
|
||||||
|
void* out_ptrs[cCRNMaxFaces]{};
|
||||||
|
if (face_count == 1)
|
||||||
|
{
|
||||||
|
out_ptrs[0] = new uint8_t[face_size]{};
|
||||||
|
*ret_size = face_size;
|
||||||
|
}
|
||||||
|
else if (1 < face_count < 7)
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < face_count; i++)
|
||||||
|
{
|
||||||
|
out_ptrs[i] = new uint8_t[face_size]{};
|
||||||
|
}
|
||||||
|
*ret_size = total_face_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!unitycrnd::crnd_unpack_level(pContext, out_ptrs, face_size, row_pitch, level_index))
|
||||||
{
|
{
|
||||||
unitycrnd::crnd_unpack_end(pContext);
|
unitycrnd::crnd_unpack_end(pContext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t* buff = new uint8_t[total_face_size]{};
|
||||||
|
for (uint8_t i = 0; i < face_count; i++)
|
||||||
|
{
|
||||||
|
memcpy(buff + (face_size * i), out_ptrs[i], face_size);
|
||||||
|
free(out_ptrs[i]);
|
||||||
|
}
|
||||||
|
*ret = buff;
|
||||||
|
|
||||||
unitycrnd::crnd_unpack_end(pContext);
|
unitycrnd::crnd_unpack_end(pContext);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user