MCPcopy Create free account
hub / github.com/baldurk/renderdoc / getIndices

Function getIndices

docs/python_api/examples/renderdoc/decode_mesh.py:170–194  ·  view source on GitHub ↗
(controller, mesh)

Source from the content-addressed store, hash-verified

168 return meshOutputs
169
170def getIndices(controller, mesh):
171 # Get the character for the width of index
172 indexFormat = 'B'
173 if mesh.indexByteStride == 2:
174 indexFormat = 'H'
175 elif mesh.indexByteStride == 4:
176 indexFormat = 'I'
177
178 # Duplicate the format by the number of indices
179 indexFormat = str(mesh.numIndices) + indexFormat
180
181 # If we have an index buffer
182 if mesh.indexResourceId != rd.ResourceId.Null():
183 # Fetch the data
184 ibdata = controller.GetBufferData(mesh.indexResourceId, mesh.indexByteOffset, 0)
185
186 # Unpack all the indices, starting from the first index to fetch
187 offset = mesh.indexOffset * mesh.indexByteStride
188 indices = struct.unpack_from(indexFormat, ibdata, offset)
189
190 # Apply the baseVertex offset
191 return [i + mesh.baseVertex for i in indices]
192 else:
193 # With no index buffer, just generate a range
194 return tuple(range(mesh.numIndices))
195
196def printMeshData(controller, meshData):
197 indices = getIndices(controller, meshData[0])

Callers 1

printMeshDataFunction · 0.85

Calls 2

rangeFunction · 0.50
GetBufferDataMethod · 0.45

Tested by

no test coverage detected