| 243 | } |
| 244 | |
| 245 | bool MeshAccessor::LoadFromMeshData(const void* meshDataPtr) |
| 246 | { |
| 247 | if (!meshDataPtr) |
| 248 | return true; |
| 249 | const auto& meshData = *(const ModelBase::MeshData*)meshDataPtr; |
| 250 | if (meshData.VBData.Count() != meshData.VBLayout.Count()) |
| 251 | return true; |
| 252 | _data[(int32)MeshBufferType::Index].Link((const byte*)meshData.IBData, meshData.IBStride * meshData.Triangles * 3); |
| 253 | if (meshData.VBData.Count() > 0 && meshData.VBLayout[0]) |
| 254 | { |
| 255 | constexpr int32 idx = (int32)MeshBufferType::Vertex0; |
| 256 | _data[idx].Link((const byte*)meshData.VBData[0], meshData.VBLayout[0]->GetStride() * meshData.Vertices); |
| 257 | _layouts[idx] = meshData.VBLayout[0]; |
| 258 | } |
| 259 | if (meshData.VBData.Count() > 1 && meshData.VBLayout[1]) |
| 260 | { |
| 261 | constexpr int32 idx = (int32)MeshBufferType::Vertex1; |
| 262 | _data[idx].Link((const byte*)meshData.VBData[1], meshData.VBLayout[1]->GetStride() * meshData.Vertices); |
| 263 | _layouts[idx] = meshData.VBLayout[1]; |
| 264 | } |
| 265 | if (meshData.VBData.Count() > 2 && meshData.VBLayout[2]) |
| 266 | { |
| 267 | constexpr int32 idx = (int32)MeshBufferType::Vertex2; |
| 268 | _data[idx].Link((const byte*)meshData.VBData[2], meshData.VBLayout[2]->GetStride() * meshData.Vertices); |
| 269 | _layouts[idx] = meshData.VBLayout[2]; |
| 270 | } |
| 271 | return false; |
| 272 | } |
| 273 | |
| 274 | bool MeshAccessor::AllocateBuffer(MeshBufferType bufferType, int32 count, GPUVertexLayout* layout) |
| 275 | { |
no test coverage detected