Alistair Leslie-Hughes : d3dx9: Don' t always fail if an ID3DXAnimationController pointer is passed to D3DXLoadMeshHierarchyFromXInMemory.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Nov 3 09:21:42 CST 2015
Module: wine
Branch: master
Commit: 418a7c6c7316f3803c38b1e2b6bdfe4a5347b7f5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=418a7c6c7316f3803c38b1e2b6bdfe4a5347b7f5
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri Oct 30 00:52:30 2015 +0100
d3dx9: Don't always fail if an ID3DXAnimationController pointer is passed to D3DXLoadMeshHierarchyFromXInMemory.
D3DXLoadMeshHierarchyFromXInMemory will only return an AnimationController
when the xfile has an AnimationSet.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3dx9_36/mesh.c | 14 +++--
dlls/d3dx9_36/tests/mesh.c | 145 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 152 insertions(+), 7 deletions(-)
diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c
index 6294036..c597e8e 100644
--- a/dlls/d3dx9_36/mesh.c
+++ b/dlls/d3dx9_36/mesh.c
@@ -3912,11 +3912,9 @@ HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory(const void *memory, DWORD memo
if (!memory || !memory_size || !device || !frame_hierarchy || !alloc_hier)
return D3DERR_INVALIDCALL;
- if (load_user_data || anim_controller) {
- if (load_user_data)
- FIXME("Loading user data not implemented\n");
- if (anim_controller)
- FIXME("Animation controller creation not implemented\n");
+ if (load_user_data)
+ {
+ FIXME("Loading user data not implemented.\n");
return E_NOTIMPL;
}
@@ -3986,6 +3984,12 @@ HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory(const void *memory, DWORD memo
hr = D3D_OK;
}
+ if (anim_controller)
+ {
+ *anim_controller = NULL;
+ FIXME("Animation controller creation not implemented.\n");
+ }
+
cleanup:
if (FAILED(hr) && first_frame) D3DXFrameDestroy(first_frame, alloc_hier);
if (filedata) filedata->lpVtbl->Release(filedata);
diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c
index 3b1fafa..588654d 100644
--- a/dlls/d3dx9_36/tests/mesh.c
+++ b/dlls/d3dx9_36/tests/mesh.c
@@ -2205,6 +2205,127 @@ static void D3DXLoadMeshTest(void)
(char *)"texture.jpg", /* pTextureFilename */
},
};
+ static const char box_anim_xfile[] =
+ "xof 0303txt 0032"
+ "Mesh CubeMesh {"
+ "8;" /* DWORD nVertices; */
+ /* array Vector vertices[nVertices]; */
+ "0.0; 0.0; 0.0;,"
+ "0.0; 0.0; 1.0;,"
+ "0.0; 1.0; 0.0;,"
+ "0.0; 1.0; 1.0;,"
+ "1.0; 0.0; 0.0;,"
+ "1.0; 0.0; 1.0;,"
+ "1.0; 1.0; 0.0;,"
+ "1.0; 1.0; 1.0;;"
+ "6;" /* DWORD nFaces; */
+ /* array MeshFace faces[nFaces]; */
+ "4; 0, 1, 3, 2;," /* left side */
+ "4; 2, 3, 7, 6;," /* top side */
+ "4; 6, 7, 5, 4;," /* right side */
+ "4; 1, 0, 4, 5;," /* bottom side */
+ "4; 1, 5, 7, 3;," /* back side */
+ "4; 0, 2, 6, 4;;" /* front side */
+ "MeshNormals {"
+ "6;" /* DWORD nNormals; */
+ /* array Vector normals[nNormals]; */
+ "-1.0; 0.0; 0.0;,"
+ "0.0; 1.0; 0.0;,"
+ "1.0; 0.0; 0.0;,"
+ "0.0; -1.0; 0.0;,"
+ "0.0; 0.0; 1.0;,"
+ "0.0; 0.0; -1.0;;"
+ "6;" /* DWORD nFaceNormals; */
+ /* array MeshFace faceNormals[nFaceNormals]; */
+ "4; 0, 0, 0, 0;,"
+ "4; 1, 1, 1, 1;,"
+ "4; 2, 2, 2, 2;,"
+ "4; 3, 3, 3, 3;,"
+ "4; 4, 4, 4, 4;,"
+ "4; 5, 5, 5, 5;;"
+ "}"
+ "MeshMaterialList materials {"
+ "2;" /* DWORD nMaterials; */
+ "6;" /* DWORD nFaceIndexes; */
+ /* array DWORD faceIndexes[nFaceIndexes]; */
+ "0, 0, 0, 1, 1, 1;;"
+ "Material {"
+ /* ColorRGBA faceColor; */
+ "0.0; 0.0; 1.0; 1.0;;"
+ /* FLOAT power; */
+ "0.5;"
+ /* ColorRGB specularColor; */
+ "1.0; 1.0; 1.0;;"
+ /* ColorRGB emissiveColor; */
+ "0.0; 0.0; 0.0;;"
+ "}"
+ "Material {"
+ /* ColorRGBA faceColor; */
+ "1.0; 1.0; 1.0; 1.0;;"
+ /* FLOAT power; */
+ "1.0;"
+ /* ColorRGB specularColor; */
+ "1.0; 1.0; 1.0;;"
+ /* ColorRGB emissiveColor; */
+ "0.0; 0.0; 0.0;;"
+ "TextureFilename { \"texture.jpg\"; }"
+ "}"
+ "}"
+ "MeshVertexColors {"
+ "8;" /* DWORD nVertexColors; */
+ /* array IndexedColor vertexColors[nVertexColors]; */
+ "0; 0.0; 0.0; 0.0; 0.0;;"
+ "1; 0.0; 0.0; 1.0; 0.1;;"
+ "2; 0.0; 1.0; 0.0; 0.2;;"
+ "3; 0.0; 1.0; 1.0; 0.3;;"
+ "4; 1.0; 0.0; 0.0; 0.4;;"
+ "5; 1.0; 0.0; 1.0; 0.5;;"
+ "6; 1.0; 1.0; 0.0; 0.6;;"
+ "7; 1.0; 1.0; 1.0; 0.7;;"
+ "}"
+ "MeshTextureCoords {"
+ "8;" /* DWORD nTextureCoords; */
+ /* array Coords2d textureCoords[nTextureCoords]; */
+ "0.0; 1.0;,"
+ "1.0; 1.0;,"
+ "0.0; 0.0;,"
+ "1.0; 0.0;,"
+ "1.0; 1.0;,"
+ "0.0; 1.0;,"
+ "1.0; 0.0;,"
+ "0.0; 0.0;;"
+ "}"
+ "}"
+ "Frame CubeFrame {"
+ "FrameTransformMatrix {"
+ /* Matrix4x4 frameMatrix; */
+ "1.0, 0.0, 0.0, 0.0,"
+ "0.0, 1.0, 0.0, 0.0,"
+ "0.0, 0.0, 1.0, 0.0,"
+ "0.0, 0.0, 0.0, 1.0;;"
+ "}"
+ "{CubeMesh}"
+ "}"
+ "AnimationSet AnimationSet0 {"
+ "Animation Animation0 {"
+ "{CubeFrame}"
+ "AnimationKey {"
+ "2;" /* DWORD keyType; */
+ "9;" /* DWORD nKeys; */
+ /* array TimedFloatKeys keys[nKeys]; */
+ "10; 3; -100.0, 0.0, 0.0;;,"
+ "20; 3; -75.0, 0.0, 0.0;;,"
+ "30; 3; -50.0, 0.0, 0.0;;,"
+ "40; 3; -25.5, 0.0, 0.0;;,"
+ "50; 3; 0.0, 0.0, 0.0;;,"
+ "60; 3; 25.5, 0.0, 0.0;;,"
+ "70; 3; 50.0, 0.0, 0.0;;,"
+ "80; 3; 75.5, 0.0, 0.0;;,"
+ "90; 3; 100.0, 0.0, 0.0;;;"
+ "}"
+ "}"
+ "}";
+
const DWORD box_fvf = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1;
/*________________________*/
static const D3DXMATERIAL default_materials[] = {
@@ -2225,6 +2346,7 @@ static void D3DXLoadMeshTest(void)
D3DXFRAME *frame_hier = NULL;
D3DXMATRIX transform;
struct test_context *test_context;
+ ID3DXAnimationController *controller;
if (!(test_context = new_test_context()))
{
@@ -2281,12 +2403,31 @@ static void D3DXLoadMeshTest(void)
frame_hier = NULL;
}
+ controller = (ID3DXAnimationController *)0xdeadbeef;
+ hr = D3DXLoadMeshHierarchyFromXInMemory(box_anim_xfile, sizeof(box_anim_xfile) - 1,
+ D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, &controller);
+ todo_wine ok(hr == D3D_OK, "Expected D3D_OK, got %#x.\n", hr);
+ if (SUCCEEDED(hr))
+ {
+ ok(controller != NULL, "Animation Controller NULL.\n");
+
+ hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
+ ok(hr == D3D_OK, "Expected D3D_OK, got %#x.\n", hr);
+ if (controller)
+ controller->lpVtbl->Release(controller);
+
+ frame_hier = NULL;
+ }
+
+ controller = (ID3DXAnimationController *)0xdeadbeef;
hr = D3DXLoadMeshHierarchyFromXInMemory(box_xfile, sizeof(box_xfile) - 1,
- D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, NULL);
+ D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, &controller);
ok(hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
- if (SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr))
+ {
D3DXMESHCONTAINER *container = frame_hier->pMeshContainer;
+ ok(!controller, "Animation Controller returned.\n");
ok(frame_hier->Name == NULL, "Expected NULL, got '%s'\n", frame_hier->Name);
D3DXMatrixIdentity(&transform);
check_matrix(&frame_hier->TransformationMatrix, &transform);
More information about the wine-cvs
mailing list