Christian Costa : d3drm: Fix normals computation and add according tests.
Alexandre Julliard
julliard at winehq.org
Mon Oct 22 13:42:45 CDT 2012
Module: wine
Branch: master
Commit: cb131bf03032663fa9712bcdd83012b4eb487d26
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb131bf03032663fa9712bcdd83012b4eb487d26
Author: Christian Costa <titan.costa at gmail.com>
Date: Sun Oct 21 18:11:03 2012 +0200
d3drm: Fix normals computation and add according tests.
---
dlls/d3drm/meshbuilder.c | 2 +-
dlls/d3drm/tests/d3drm.c | 23 ++++++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/d3drm/meshbuilder.c b/dlls/d3drm/meshbuilder.c
index 22efb00..4ba29cc 100644
--- a/dlls/d3drm/meshbuilder.c
+++ b/dlls/d3drm/meshbuilder.c
@@ -1419,7 +1419,7 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
D3DVECTOR a, b;
D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
- D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[1]], &This->pVertices[faces_vertex_idx_ptr[0]]);
+ D3DRMVectorSubtract(&b, &This->pVertices[faces_vertex_idx_ptr[0]], &This->pVertices[faces_vertex_idx_ptr[1]]);
D3DRMVectorCrossProduct(&face_normal, &a, &b);
D3DRMVectorNormalize(&face_normal);
}
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index a257aea..0d600c5 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -64,6 +64,11 @@ static int get_refcount(IUnknown *object)
return IUnknown_Release( object );
}
+static BOOL match_float(float a, float b)
+{
+ return (a - b) < 0.000001f;
+}
+
static D3DRMMATRIX4D identity = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
@@ -186,7 +191,7 @@ static void test_MeshBuilder(void)
DWORD val1, val2, val3;
D3DVALUE valu, valv;
D3DVECTOR v[3];
- D3DVECTOR n[3];
+ D3DVECTOR n[4];
DWORD f[8];
char name[10];
DWORD size;
@@ -259,6 +264,22 @@ static void test_MeshBuilder(void)
ok(val2 == 4, "Wrong number of normals %d (must be 4)\n", val2);
ok(val3 == 22, "Wrong number of face data bytes %d (must be 22)\n", val3);
+ /* Check that Load method generated default normals */
+ hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, NULL, &val2, n, NULL, NULL);
+ ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
+ ok(match_float(U1(n[0]).x, 0.577350f), "Wrong component n[0].x = %f (expected %f)\n", U1(n[0]).x, 0.577350f);
+ ok(match_float(U2(n[0]).y, 0.577350f), "Wrong component n[0].y = %f (expected %f)\n", U2(n[0]).y, 0.577350f);
+ ok(match_float(U3(n[0]).z, 0.577350f), "Wrong component n[0].z = %f (expected %f)\n", U3(n[0]).z, 0.577350f);
+ ok(match_float(U1(n[1]).x, -0.229416f), "Wrong component n[1].x = %f (expected %f)\n", U1(n[1]).x, -0.229416f);
+ ok(match_float(U2(n[1]).y, 0.688247f), "Wrong component n[1].y = %f (expected %f)\n", U2(n[1]).y, 0.688247f);
+ ok(match_float(U3(n[1]).z, 0.688247f), "Wrong component n[1].z = %f (expected %f)\n", U3(n[1]).z, 0.688247f);
+ ok(match_float(U1(n[2]).x, -0.229416f), "Wrong component n[2].x = %f (expected %f)\n", U1(n[2]).x, -0.229416f);
+ ok(match_float(U2(n[2]).y, 0.688247f), "Wrong component n[2].y = %f (expected %f)\n", U2(n[2]).y, 0.688247f);
+ ok(match_float(U3(n[2]).z, 0.688247f), "Wrong component n[2].z = %f (expected %f)\n", U3(n[2]).z, 0.688247f);
+ ok(match_float(U1(n[3]).x, -0.577350f), "Wrong component n[3].x = %f (expected %f)\n", U1(n[3]).x, -0.577350f);
+ ok(match_float(U2(n[3]).y, 0.577350f), "Wrong component n[3].y = %f (expected %f)\n", U2(n[3]).y, 0.577350f);
+ ok(match_float(U3(n[3]).z, 0.577350f), "Wrong component n[3].z = %f (expected %f)\n", U3(n[3]).z, 0.577350f);
+
/* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
valu = 1.23f;
valv = 3.21f;
More information about the wine-cvs
mailing list