From: Alistair Leslie-Hughes Subject: [PATCH] d3dx9_36: Supplying a AnimationController isn't an error (try 2) Message-Id: Date: Thu, 29 Oct 2015 19:11:26 +1100 D3DXLoadMeshHierarchyFromXInMemory will only return an AnimationController when the xfile has an AnimationSet. Signed-off-by: Alistair Leslie-Hughes --- dlls/d3dx9_36/mesh.c | 10 +++- dlls/d3dx9_36/tests/mesh.c | 139 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 145 insertions(+), 4 deletions(-) diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c index 6294036..7c68d29 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) { if (load_user_data) FIXME("Loading user data not implemented\n"); - if (anim_controller) - FIXME("Animation controller creation 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 4186e19..8f57560 100644 --- a/dlls/d3dx9_36/tests/mesh.c +++ b/dlls/d3dx9_36/tests/mesh.c @@ -2205,6 +2205,125 @@ 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 {" + "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;" + "9;" + "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 +2344,7 @@ static void D3DXLoadMeshTest(void) D3DXFRAME *frame_hier = NULL; D3DXMATRIX transform; struct test_context *test_context; + struct ID3DXAnimationController *controller; if (!(test_context = new_test_context())) { @@ -2281,12 +2401,29 @@ static void D3DXLoadMeshTest(void) frame_hier = NULL; } + controller = (void *)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 = (void *)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)) { 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); -- 1.9.1