Commit 2978dbea authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

d3drm: When creating a mesh, if all faces have the same number of vertex, set…

d3drm: When creating a mesh, if all faces have the same number of vertex, set vertex_per_face and don't put nb indices in face data.
parent 58de52a9
......@@ -2063,6 +2063,7 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuil
IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
HRESULT hr;
D3DRMGROUPINDEX group;
ULONG vertex_per_face = 0;
TRACE("(%p)->(%p)\n", This, mesh);
......@@ -2089,10 +2090,27 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuil
}
out_ptr = face_data;
/* If all faces have the same number of vertex, set vertex_per_face */
for (i = 0; i < This->nb_faces; i++)
{
if (vertex_per_face && (vertex_per_face != *in_ptr))
break;
vertex_per_face = *in_ptr;
in_ptr += 1 + *in_ptr * 2;
}
if (i != This->nb_faces)
vertex_per_face = 0;
/* Put only vertex indices */
in_ptr = This->pFaceData;
for (i = 0; i < This->nb_faces; i++)
{
DWORD nb_indices = *out_ptr++ = *in_ptr++;
DWORD nb_indices = *in_ptr++;
/* Don't put nb indices when vertex_per_face is set */
if (vertex_per_face)
*out_ptr++ = nb_indices;
for (j = 0; j < nb_indices; j++)
{
*out_ptr++ = *in_ptr++;
......@@ -2101,7 +2119,7 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuil
}
}
hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, 0, face_data, &group);
hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, vertex_per_face, face_data, &group);
HeapFree(GetProcessHeap(), 0, face_data);
if (SUCCEEDED(hr))
{
......
......@@ -402,8 +402,8 @@ static void test_MeshBuilder(void)
ok(hr == D3DRM_OK, "GetCroup failed returning hr = %x\n", hr);
ok(nb_vertices == 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices);
ok(nb_faces == 1, "Wrong number of faces %u (must be 1)\n", nb_faces);
todo_wine ok(nb_face_vertices == 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices);
todo_wine ok(data_size == 3, "Wrong number of face data bytes %u (must be 3)\n", data_size);
ok(nb_face_vertices == 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices);
ok(data_size == 3, "Wrong number of face data bytes %u (must be 3)\n", data_size);
color = IDirect3DRMMesh_GetGroupColor(mesh, 0);
ok(color == 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color, 0xff00ff00);
hr = IDirect3DRMMesh_GetGroupTexture(mesh, 0, &texture);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment