Commit 6787e3c3 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: Implement loading top and frame user data in D3DXLoadMeshHierarchyFromXInMemory().

parent 8be03417
......@@ -3880,7 +3880,7 @@ static HRESULT parse_transform_matrix(ID3DXFileData *filedata, D3DXMATRIX *trans
}
static HRESULT load_frame(struct ID3DXFileData *filedata, DWORD options, struct IDirect3DDevice9 *device,
struct ID3DXAllocateHierarchy *alloc_hier, D3DXFRAME **frame_out)
struct ID3DXAllocateHierarchy *alloc_hier, D3DXFRAME **frame_out, struct ID3DXLoadUserData *load_user_data)
{
HRESULT hr;
GUID type;
......@@ -3923,9 +3923,12 @@ static HRESULT load_frame(struct ID3DXFileData *filedata, DWORD options, struct
} else if (IsEqualGUID(&type, &TID_D3DRMFrameTransformMatrix)) {
hr = parse_transform_matrix(child, &frame->TransformationMatrix);
} else if (IsEqualGUID(&type, &TID_D3DRMFrame)) {
hr = load_frame(child, options, device, alloc_hier, next_child);
hr = load_frame(child, options, device, alloc_hier, next_child, load_user_data);
if (SUCCEEDED(hr))
next_child = &(*next_child)->pFrameSibling;
} else if (load_user_data) {
TRACE("Loading %s as user data.\n", debugstr_guid(&type));
hr = load_user_data->lpVtbl->LoadFrameChildData(load_user_data, frame, child);
}
if (FAILED(hr))
goto err;
......@@ -3961,10 +3964,7 @@ HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory(const void *memory, DWORD memo
if (!memory || !memory_size || !device || !frame_hierarchy || !alloc_hier)
return D3DERR_INVALIDCALL;
if (load_user_data)
{
FIXME("Loading user data not implemented.\n");
return E_NOTIMPL;
}
FIXME("Loading mesh user data not implemented for mesh.\n");
hr = D3DXFileCreate(&d3dxfile);
if (FAILED(hr)) goto cleanup;
......@@ -4001,8 +4001,11 @@ HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory(const void *memory, DWORD memo
hr = load_mesh_container(filedata, options, device, alloc_hier, &(*next_frame)->pMeshContainer);
if (FAILED(hr)) goto cleanup;
} else if (IsEqualGUID(&guid, &TID_D3DRMFrame)) {
hr = load_frame(filedata, options, device, alloc_hier, next_frame);
hr = load_frame(filedata, options, device, alloc_hier, next_frame, load_user_data);
if (FAILED(hr)) goto cleanup;
} else if (load_user_data) {
TRACE("Loading %s as user data.\n", debugstr_guid(&guid));
hr = load_user_data->lpVtbl->LoadTopLevelData(load_user_data, filedata);
}
while (*next_frame)
next_frame = &(*next_frame)->pFrameSibling;
......
......@@ -2136,20 +2136,20 @@ static void check_user_data(struct test_load_user_data *user_data, unsigned int
{
unsigned int i;
ok(user_data->data_count == expected_count, "got %u, expected %u.\n", user_data->data_count, expected_count);
todo_wine ok(user_data->data_count == expected_count, "got %u, expected %u.\n", user_data->data_count, expected_count);
expected_count = min(expected_count, user_data->data_count);
for (i = 0; i < expected_count; ++i)
{
winetest_push_context("i %u", i);
ok(user_data->data[i].data_type == expected[i].data_type, "got %u, expected %u.\n",
todo_wine_if(i == 3) ok(user_data->data[i].data_type == expected[i].data_type, "got %u, expected %u.\n",
user_data->data[i].data_type, expected[i].data_type);
ok(IsEqualGUID(&user_data->guids[i], expected[i].type), "got %s, expected %s.\n",
debugstr_guid(&user_data->guids[i]), debugstr_guid(expected[i].type));
ok(user_data->data[i].size == expected[i].size, "got %Iu, expected %Iu.\n",
user_data->data[i].size, expected[i].size);
ok(user_data->data[i].value == expected[i].value, "got %u, expected %u.\n",
todo_wine_if(i == 3) ok(user_data->data[i].value == expected[i].value, "got %u, expected %u.\n",
user_data->data[i].value, expected[i].value);
ok(user_data->data[i].mesh_container == expected[i].mesh_container, "got %u, expected %u.\n",
todo_wine_if(i == 3) ok(user_data->data[i].mesh_container == expected[i].mesh_container, "got %u, expected %u.\n",
user_data->data[i].mesh_container, expected[i].mesh_container);
ok(user_data->data[i].num_materials == expected[i].num_materials, "got %u, expected %u.\n",
user_data->data[i].num_materials, expected[i].num_materials);
......@@ -2675,15 +2675,12 @@ static void D3DXLoadMeshTest(void)
init_load_user_data(&load_user_data);
hr = D3DXLoadMeshHierarchyFromXInMemory(box_xfile, sizeof(box_xfile) - 1,
D3DXMESH_MANAGED, device, &alloc_hier, &load_user_data.iface, &frame_hier, &controller);
todo_wine ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
if (SUCCEEDED(hr))
{
winetest_push_context("box_xfile");
check_user_data(&load_user_data, ARRAY_SIZE(box_xfile_expected_user_data), box_xfile_expected_user_data);
winetest_pop_context();
hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
}
ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
winetest_push_context("box_xfile");
check_user_data(&load_user_data, ARRAY_SIZE(box_xfile_expected_user_data), box_xfile_expected_user_data);
winetest_pop_context();
hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
frame_hier = NULL;
hr = D3DXLoadMeshHierarchyFromXInMemory(framed_xfile, sizeof(framed_xfile) - 1,
......@@ -2718,15 +2715,12 @@ static void D3DXLoadMeshTest(void)
init_load_user_data(&load_user_data);
hr = D3DXLoadMeshHierarchyFromXInMemory(framed_xfile, sizeof(framed_xfile) - 1,
D3DXMESH_MANAGED, device, &alloc_hier, &load_user_data.iface, &frame_hier, NULL);
todo_wine ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
if (SUCCEEDED(hr))
{
hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
winetest_push_context("framed_xfile");
check_user_data(&load_user_data, ARRAY_SIZE(framed_xfile_expected_user_data), framed_xfile_expected_user_data);
winetest_pop_context();
}
ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
winetest_push_context("framed_xfile");
check_user_data(&load_user_data, ARRAY_SIZE(framed_xfile_expected_user_data), framed_xfile_expected_user_data);
winetest_pop_context();
frame_hier = NULL;
hr = D3DXLoadMeshHierarchyFromXInMemory(framed_xfile_empty, sizeof(framed_xfile_empty) - 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment