Microsoft DirectX 9.0

ID3DXMesh::Optimize Method

Controls the reordering of mesh faces and vertices to optimize performance, generating an output mesh.


HRESULT Optimize(      

    DWORD Flags,     CONST DWORD *pAdjacencyIn,     DWORD *pAdjacencyOut,     DWORD *pFaceRemap,     LPD3DXBUFFER *ppVertexRemap,     LPD3DXMESH *ppOptMesh );


[in] 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 D3DXMESH32_BIT, D3DXMESH_IB_WRITEONLY, and D3DXMESH_WRITEONLY).
[in] Pointer to an array of three DWORDs per face that specify the three neighbors for each face in the source mesh. If the edge has no adjacent faces, the value is 0xffffffff.
[in, out] Pointer to a destination buffer for the face adjacency array of the optimized mesh. The face adjacency is stored as an array of arrays. The innermost array is three indices of adjacent triangles, and the outer array is one set of face adjacency per triangle in the mesh.
[in, out] Pointer to a destination buffer containing the new index for each face.
[out] Address of a pointer to an ID3DXBuffer interface; containing the new index for each vertex.
[out] Address of a pointer to an ID3DXMesh interface, representing the optimized mesh.

Return Value

If the method succeeds, the return value is D3D_OK.

If the method fails, the return value can be one of the following values.

D3DERR_INVALIDCALLThe method call is invalid. For example, a method's parameter may have an invalid value.
E_OUTOFMEMORYMicrosoft?Direct3D?could not allocate sufficient memory to complete the call.


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.

© 2002 Microsoft Corporation. All rights reserved.