Christian Costa : 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.

Alexandre Julliard julliard at winehq.org
Thu Oct 25 13:50:45 CDT 2012


Module: wine
Branch: master
Commit: 2978dbea0b382765dbce551bde7f0859c0e40f87
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2978dbea0b382765dbce551bde7f0859c0e40f87

Author: Christian Costa <titan.costa at gmail.com>
Date:   Tue Oct 23 21:28:32 2012 +0200

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.

---

 dlls/d3drm/meshbuilder.c |   22 ++++++++++++++++++++--
 dlls/d3drm/tests/d3drm.c |    4 ++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/dlls/d3drm/meshbuilder.c b/dlls/d3drm/meshbuilder.c
index 4ba29cc..87ff35c 100644
--- a/dlls/d3drm/meshbuilder.c
+++ b/dlls/d3drm/meshbuilder.c
@@ -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))
         {
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 0d600c5..cde1577 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -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);




More information about the wine-cvs mailing list