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.
This commit is contained in:
parent
58de52a956
commit
2978dbea0b
@ -2063,6 +2063,7 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuil
|
|||||||
IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
|
IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
D3DRMGROUPINDEX group;
|
D3DRMGROUPINDEX group;
|
||||||
|
ULONG vertex_per_face = 0;
|
||||||
|
|
||||||
TRACE("(%p)->(%p)\n", This, mesh);
|
TRACE("(%p)->(%p)\n", This, mesh);
|
||||||
|
|
||||||
@ -2089,10 +2090,27 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuil
|
|||||||
}
|
}
|
||||||
out_ptr = face_data;
|
out_ptr = face_data;
|
||||||
|
|
||||||
/* Put only vertex indices */
|
/* If all faces have the same number of vertex, set vertex_per_face */
|
||||||
for (i = 0; i < This->nb_faces; i++)
|
for (i = 0; i < This->nb_faces; i++)
|
||||||
{
|
{
|
||||||
DWORD nb_indices = *out_ptr++ = *in_ptr++;
|
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 = *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++)
|
for (j = 0; j < nb_indices; j++)
|
||||||
{
|
{
|
||||||
*out_ptr++ = *in_ptr++;
|
*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);
|
HeapFree(GetProcessHeap(), 0, face_data);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
@ -402,8 +402,8 @@ static void test_MeshBuilder(void)
|
|||||||
ok(hr == D3DRM_OK, "GetCroup failed returning hr = %x\n", hr);
|
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_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);
|
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);
|
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(data_size == 3, "Wrong number of face data bytes %u (must be 3)\n", data_size);
|
||||||
color = IDirect3DRMMesh_GetGroupColor(mesh, 0);
|
color = IDirect3DRMMesh_GetGroupColor(mesh, 0);
|
||||||
ok(color == 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color, 0xff00ff00);
|
ok(color == 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color, 0xff00ff00);
|
||||||
hr = IDirect3DRMMesh_GetGroupTexture(mesh, 0, &texture);
|
hr = IDirect3DRMMesh_GetGroupTexture(mesh, 0, &texture);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user