Simple |
public bool SortTrianglesByCameraDistance( Vector3 cameraPosition, Matrix meshWorldTransformMatrix, bool transformCamera, bool updateDirectXBuffer = true )
SortTrianglesByCameraDistance method sorts the triangle indices so that the triangles are sorted by camera distance - triangles that are farther away are rendered first.
When the updateDirectXBuffer parameter is set to true (by default) and when the sort order was changed, then the RecreateMesh(Boolean, Boolean, Boolean) method is called to update the DirectX buffer.
When using this method it is highly recommended to set CreateDynamicIndexBuffer to true.
When the objects' world transformation is usually changed, then it is recommended to call this method with transformCamera parameter set to true. This transforms the camera's position by inverted world matrix and does not require to transform all positions. When objects' world transformation is not changed, then it is recommended to set transformCamera to false. This transforms all positions by world transform once and does not require to calculate the inverted world matrix.