| 182 | { |
| 183 | #if WITH_GRANNY |
| 184 | ALResult ReverseIndexBuffer( TriGeometryResLodData& lod, granny_mesh& grannyMesh, Tr2RenderContext& renderContext ) |
| 185 | { |
| 186 | uint32_t bytesPerIndex = 2; |
| 187 | auto indexCount = grannyMesh.PrimaryTopology->Index16Count; |
| 188 | if( indexCount == 0 ) |
| 189 | { |
| 190 | indexCount = grannyMesh.PrimaryTopology->IndexCount; |
| 191 | if( indexCount == 0 ) |
| 192 | { |
| 193 | return S_OK; |
| 194 | } |
| 195 | if( grannyMesh.PrimaryVertexData->VertexCount > 65535 ) |
| 196 | { |
| 197 | bytesPerIndex = 4; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | std::vector<uint8_t> tempBuffer( indexCount * bytesPerIndex ); |
| 202 | GrannyCopyMeshIndices( &grannyMesh, bytesPerIndex, tempBuffer.data() ); |
| 203 | |
| 204 | if( bytesPerIndex == 2 ) |
| 205 | { |
| 206 | std::reverse( reinterpret_cast<uint16_t*>( tempBuffer.data() ), reinterpret_cast<uint16_t*>( tempBuffer.data() + tempBuffer.size() ) ); |
| 207 | } |
| 208 | else |
| 209 | { |
| 210 | std::reverse( reinterpret_cast<uint32_t*>( tempBuffer.data() ), reinterpret_cast<uint32_t*>( tempBuffer.data() + tempBuffer.size() ) ); |
| 211 | } |
| 212 | |
| 213 | CR_RETURN_HR( g_sharedBuffer.Allocate( bytesPerIndex, indexCount, tempBuffer.data(), renderContext, lod.m_reversedIndexAllocation ) ); |
| 214 | lod.m_reversedIndicesValid = true; |
| 215 | return S_OK; |
| 216 | } |
| 217 | #endif |
| 218 | |
| 219 | ALResult ReverseIndexBuffer( TriGeometryResLodData& lod, const void* ibData, const cmf::MeshLod& cmfMeshLod, Tr2RenderContext& renderContext ) |
no test coverage detected