ID3DXMesh::Optimize method
Generates a new mesh with reordered faces and vertices to optimize drawing performance.
Syntax
HRESULT Optimize(
[in] DWORD Flags,
[in] const DWORD *pAdjacencyIn,
[in, out] DWORD *pAdjacencyOut,
[in, out] DWORD *pFaceRemap,
[out] LPD3DXBUFFER *ppVertexRemap,
[out] LPD3DXMESH *ppOptMesh
);
Parameters
-
Flags [in]
-
Type: DWORD
Specifies the type of optimization to perform. This parameter can be set to a combination of one or more flags from D3DXMESHOPT and D3DXMESH (except D3DXMESH_32BIT, D3DXMESH_IB_WRITEONLY, and D3DXMESH_WRITEONLY).
-
pAdjacencyIn [in]
-
Type: const DWORD*
Pointer to an array of three DWORDs per face that specifies the three neighbors for each face in the source mesh. If the edge has no adjacent faces, the value is 0xffffffff. See Remarks.
-
pAdjacencyOut [in, out]
-
Type: DWORD*
Pointer to an array of three DWORDs per face that specifies the three neighbors for each face in the optimized mesh. If the edge has no adjacent faces, the value is 0xffffffff.
-
pFaceRemap [in, out]
-
Type: DWORD*
An array of DWORDs, one per face, that identifies the original mesh face that corresponds to each face in the optimized mesh. If the value supplied for this argument is NULL, face remap data is not returned.
-
ppVertexRemap [out]
-
Type: LPD3DXBUFFER*
Address of a pointer to an ID3DXBuffer interface, which contains a DWORD for each vertex that specifies how the new vertices map to the old vertices. This remap is useful if you need to alter external data based on the new vertex mapping.
-
ppOptMesh [out]
-
Type: LPD3DXMESH*
Address of a pointer to an ID3DXMesh interface, representing the optimized mesh.
Return value
Type: HRESULT
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, E_OUTOFMEMORY.
Remarks
This method generates a new mesh. Before running Optimize, an application must generate an adjacency buffer by calling ID3DXBaseMesh::GenerateAdjacency. The adjacency buffer contains adjacency data, such as a list of edges and the faces that are adjacent to each other.
This method is very similar to the ID3DXBaseMesh::CloneMesh method, except that it can perform optimization while generating the new clone of the mesh. The output mesh inherits all of the creation parameters of the input mesh.
Requirements
Requirement | Value |
---|---|
Header |
|
Library |
|
See also