Refactor raw data ReadSttream and WriteStream to have easier to use API with more features
This commit is contained in:
@@ -578,15 +578,15 @@ bool Mesh::DownloadDataCPU(MeshBufferType type, BytesContainer& result, int32& c
|
||||
LOG(Error, "Invalid mesh data.");
|
||||
return true;
|
||||
}
|
||||
auto vb0 = stream.Read<VB0ElementType>(vertices);
|
||||
auto vb1 = stream.Read<VB1ElementType>(vertices);
|
||||
auto vb0 = stream.Move<VB0ElementType>(vertices);
|
||||
auto vb1 = stream.Move<VB1ElementType>(vertices);
|
||||
bool hasColors = stream.ReadBool();
|
||||
VB2ElementType18* vb2 = nullptr;
|
||||
if (hasColors)
|
||||
{
|
||||
vb2 = stream.Read<VB2ElementType18>(vertices);
|
||||
vb2 = stream.Move<VB2ElementType18>(vertices);
|
||||
}
|
||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
||||
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||
|
||||
if (i != _index)
|
||||
continue;
|
||||
|
||||
@@ -22,15 +22,15 @@ bool ModelLOD::Load(MemoryReadStream& stream)
|
||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||
if (vertices == 0 || triangles == 0)
|
||||
return true;
|
||||
auto vb0 = stream.Read<VB0ElementType>(vertices);
|
||||
auto vb1 = stream.Read<VB1ElementType>(vertices);
|
||||
auto vb0 = stream.Move<VB0ElementType>(vertices);
|
||||
auto vb1 = stream.Move<VB1ElementType>(vertices);
|
||||
bool hasColors = stream.ReadBool();
|
||||
VB2ElementType18* vb2 = nullptr;
|
||||
if (hasColors)
|
||||
{
|
||||
vb2 = stream.Read<VB2ElementType18>(vertices);
|
||||
vb2 = stream.Move<VB2ElementType18>(vertices);
|
||||
}
|
||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
||||
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||
|
||||
// Setup GPU resources
|
||||
if (Meshes[i].Load(vertices, triangles, vb0, vb1, vb2, ib, use16BitIndexBuffer))
|
||||
|
||||
@@ -289,7 +289,7 @@ bool SkinnedMesh::DownloadDataCPU(MeshBufferType type, BytesContainer& result, i
|
||||
stream.ReadUint32(&maxVertexIndex);
|
||||
uint32 blendShapeVertices;
|
||||
stream.ReadUint32(&blendShapeVertices);
|
||||
auto blendShapeVerticesData = stream.Read<byte>(blendShapeVertices * sizeof(BlendShapeVertex));
|
||||
auto blendShapeVerticesData = stream.Move<byte>(blendShapeVertices * sizeof(BlendShapeVertex));
|
||||
}
|
||||
uint32 indicesCount = triangles * 3;
|
||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||
@@ -299,8 +299,8 @@ bool SkinnedMesh::DownloadDataCPU(MeshBufferType type, BytesContainer& result, i
|
||||
LOG(Error, "Invalid mesh data.");
|
||||
return true;
|
||||
}
|
||||
auto vb0 = stream.Read<VB0SkinnedElementType>(vertices);
|
||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
||||
auto vb0 = stream.Move<VB0SkinnedElementType>(vertices);
|
||||
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||
|
||||
if (i != _index)
|
||||
continue;
|
||||
|
||||
@@ -45,8 +45,8 @@ bool SkinnedModelLOD::Load(MemoryReadStream& stream)
|
||||
const uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||
if (vertices == 0 || triangles == 0)
|
||||
return true;
|
||||
const auto vb0 = stream.Read<VB0SkinnedElementType>(vertices);
|
||||
const auto ib = stream.Read<byte>(indicesCount * ibStride);
|
||||
const auto vb0 = stream.Move<VB0SkinnedElementType>(vertices);
|
||||
const auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||
|
||||
// Setup GPU resources
|
||||
if (mesh.Load(vertices, triangles, vb0, ib, use16BitIndexBuffer))
|
||||
|
||||
Reference in New Issue
Block a user