Microsoft DirectX 8.1 (Visual Basic)

D3DXMesh.OptimizeInplace

Controls the reordering of mesh faces and vertices to optimize performance.

object.OptimizeInplace( _ 
    Flags As Long, _ 
    AdjacencyIn As Any, _ 
    AdjacencyOut As Any, _ 
    FaceRemap As Any, _ 
    VertexRemapOut As D3DXBuffer)

Parts

object
Object expression that resolves to a D3DXMesh object.
Flags
A combination of one or more flags defined by the CONST_D3DXMESHOPT enumeration, specifying the type of optimization to perform.

Note that the D3DXMESHOPT_STRIPREORDER and D3DXMESHOPT_VERTEXCACHE optimization flags are mutually exclusive.

AdjacencyIn
First element of an array of three Long values per face that specify the three neighbors for each face in the source mesh.
AdjacencyOut
First element of an array, representing the 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.
FaceRemap
First element of an array, representing the destination buffer containing the new index for each face.
VertexRemapOut
D3DXBuffer object, containing the new index for each vertex.

Error Codes

If the method fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
D3DXERR_CANNOTATTRSORT
E_OUTOFMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

The output mesh inherits all of the creation parameters of the input mesh.

The following code fragment shows how to use a D3DXBuffer object to pass adjacency information.

Dim Opts As Long
Dim D3DXbAdjacencyIn As D3DXBuffer
Dim D3DXbAdjacencyOut As Any
Dim FaceRemap As Any
Dim FaceRemap As D3DXBuffer

' This code fragment assumes that all arguments
' have been properly initialized.
Call D3DX8.OptimizeInPlace( Opts, ByVal D3DXbAdjacencyIn.GetBufferPointer, D3DXbAdjacencyOut, _ 
                                            FaceRemap, FaceRemap )

Note  This method fails if the mesh is sharing its vertex buffer with another mesh, unless the D3DXMESHOPT_IGNOREVERTS flag is set in the Flags parameter.