Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
6348888a
Commit
6348888a
authored
Nov 21, 2023
by
Paul Gofman
Committed by
Alexandre Julliard
Nov 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Unify calling parse_mesh helper functions.
parent
6787e3c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
42 deletions
+50
-42
mesh.c
dlls/d3dx9_36/mesh.c
+50
-42
No files found.
dlls/d3dx9_36/mesh.c
View file @
6348888a
...
...
@@ -37,6 +37,11 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
d3dx
);
/* for provide_flags parameters */
#define PROVIDE_MATERIALS 0x1
#define PROVIDE_SKININFO 0x2
#define PROVIDE_ADJACENCY 0x4
struct
d3dx9_mesh
{
ID3DXMesh
ID3DXMesh_iface
;
...
...
@@ -2611,6 +2616,7 @@ struct mesh_data {
struct
ID3DXSkinInfo
*
skin_info
;
unsigned
int
bone_count
;
unsigned
int
skin_weights_info_count
;
};
static
HRESULT
parse_texture_filename
(
ID3DXFileData
*
filedata
,
char
**
filename_out
)
...
...
@@ -2752,7 +2758,7 @@ static void destroy_materials(struct mesh_data *mesh)
mesh
->
material_indices
=
NULL
;
}
static
HRESULT
parse_material_list
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
)
static
HRESULT
parse_material_list
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
,
DWORD
flags
)
{
ID3DXFileData
*
child
=
NULL
;
unsigned
int
material_count
;
...
...
@@ -2764,6 +2770,9 @@ static HRESULT parse_material_list(ID3DXFileData *filedata, struct mesh_data *me
HRESULT
hr
;
GUID
type
;
if
(
!
(
flags
&
PROVIDE_MATERIALS
))
return
S_OK
;
destroy_materials
(
mesh
);
hr
=
filedata
->
lpVtbl
->
Lock
(
filedata
,
&
data_size
,
&
data
);
...
...
@@ -2867,7 +2876,7 @@ end:
return
hr
;
}
static
HRESULT
parse_texture_coords
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
)
static
HRESULT
parse_texture_coords
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
,
DWORD
flags
)
{
const
uint32_t
*
data
;
SIZE_T
data_size
;
...
...
@@ -2925,7 +2934,7 @@ end:
return
hr
;
}
static
HRESULT
parse_vertex_colors
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
)
static
HRESULT
parse_vertex_colors
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
,
DWORD
flags
)
{
unsigned
int
color_count
,
i
;
const
uint32_t
*
data
;
...
...
@@ -3004,7 +3013,7 @@ end:
return
hr
;
}
static
HRESULT
parse_normals
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
)
static
HRESULT
parse_normals
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh
,
DWORD
flags
)
{
unsigned
int
num_face_indices
=
mesh
->
num_poly_faces
*
2
+
mesh
->
num_tri_faces
;
DWORD
*
index_out_ptr
;
...
...
@@ -3110,7 +3119,7 @@ end:
return
hr
;
}
static
HRESULT
parse_skin_mesh_header
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh_data
)
static
HRESULT
parse_skin_mesh_header
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh_data
,
DWORD
flags
)
{
const
BYTE
*
data
;
SIZE_T
data_size
;
...
...
@@ -3118,6 +3127,15 @@ static HRESULT parse_skin_mesh_header(ID3DXFileData *filedata, struct mesh_data
TRACE
(
"filedata %p, mesh_data %p.
\n
"
,
filedata
,
mesh_data
);
if
(
!
(
flags
&
PROVIDE_SKININFO
))
return
S_OK
;
if
(
mesh_data
->
skin_info
)
{
WARN
(
"Skin mesh header already encountered
\n
"
);
return
E_FAIL
;
}
if
(
FAILED
(
hr
=
filedata
->
lpVtbl
->
Lock
(
filedata
,
&
data_size
,
(
const
void
**
)
&
data
)))
return
hr
;
...
...
@@ -3136,8 +3154,9 @@ static HRESULT parse_skin_mesh_header(ID3DXFileData *filedata, struct mesh_data
return
hr
;
}
static
HRESULT
parse_skin_weights_info
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh_data
,
unsigned
int
index
)
static
HRESULT
parse_skin_weights_info
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh_data
,
DWORD
flags
)
{
unsigned
int
index
=
mesh_data
->
skin_weights_info_count
;
unsigned
int
influence_count
;
const
char
*
name
;
const
BYTE
*
data
;
...
...
@@ -3146,6 +3165,15 @@ static HRESULT parse_skin_weights_info(ID3DXFileData *filedata, struct mesh_data
TRACE
(
"filedata %p, mesh_data %p, index %u.
\n
"
,
filedata
,
mesh_data
,
index
);
if
(
!
(
flags
&
PROVIDE_SKININFO
))
return
S_OK
;
if
(
!
mesh_data
->
skin_info
)
{
WARN
(
"Skin weights found but skin mesh header not encountered yet.
\n
"
);
return
E_FAIL
;
}
if
(
FAILED
(
hr
=
filedata
->
lpVtbl
->
Lock
(
filedata
,
&
data_size
,
(
const
void
**
)
&
data
)))
return
hr
;
...
...
@@ -3173,17 +3201,13 @@ static HRESULT parse_skin_weights_info(ID3DXFileData *filedata, struct mesh_data
hr
=
mesh_data
->
skin_info
->
lpVtbl
->
SetBoneOffsetMatrix
(
mesh_data
->
skin_info
,
index
,
(
const
D3DMATRIX
*
)(
data
+
influence_count
*
(
sizeof
(
uint32_t
)
+
sizeof
(
float
))));
if
(
SUCCEEDED
(
hr
))
++
mesh_data
->
skin_weights_info_count
;
return
hr
;
}
/* for provide_flags parameters */
#define PROVIDE_MATERIALS 0x1
#define PROVIDE_SKININFO 0x2
#define PROVIDE_ADJACENCY 0x4
static
HRESULT
parse_mesh
(
ID3DXFileData
*
filedata
,
struct
mesh_data
*
mesh_data
,
DWORD
provide_flags
)
{
unsigned
int
skin_weights_info_count
=
0
;
ID3DXFileData
*
child
=
NULL
;
const
BYTE
*
data
,
*
in_ptr
;
DWORD
*
index_out_ptr
;
...
...
@@ -3203,6 +3227,8 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data,
* }
*/
mesh_data
->
skin_weights_info_count
=
0
;
hr
=
filedata
->
lpVtbl
->
Lock
(
filedata
,
&
data_size
,
(
const
void
**
)
&
data
);
if
(
FAILED
(
hr
))
return
hr
;
...
...
@@ -3308,37 +3334,19 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data,
goto
end
;
if
(
IsEqualGUID
(
&
type
,
&
TID_D3DRMMeshNormals
))
{
hr
=
parse_normals
(
child
,
mesh_data
);
hr
=
parse_normals
(
child
,
mesh_data
,
provide_flags
);
}
else
if
(
IsEqualGUID
(
&
type
,
&
TID_D3DRMMeshVertexColors
))
{
hr
=
parse_vertex_colors
(
child
,
mesh_data
);
hr
=
parse_vertex_colors
(
child
,
mesh_data
,
provide_flags
);
}
else
if
(
IsEqualGUID
(
&
type
,
&
TID_D3DRMMeshTextureCoords
))
{
hr
=
parse_texture_coords
(
child
,
mesh_data
);
}
else
if
(
IsEqualGUID
(
&
type
,
&
TID_D3DRMMeshMaterialList
)
&&
(
provide_flags
&
PROVIDE_MATERIALS
))
{
hr
=
parse_material_list
(
child
,
mesh_data
);
}
else
if
(
provide_flags
&
PROVIDE_SKININFO
)
{
if
(
IsEqualGUID
(
&
type
,
&
DXFILEOBJ_XSkinMeshHeader
))
{
if
(
mesh_data
->
skin_info
)
{
WARN
(
"Skin mesh header already encountered
\n
"
);
hr
=
E_FAIL
;
goto
end
;
}
hr
=
parse_skin_mesh_header
(
child
,
mesh_data
);
if
(
FAILED
(
hr
))
goto
end
;
}
else
if
(
IsEqualGUID
(
&
type
,
&
DXFILEOBJ_SkinWeights
))
{
if
(
!
mesh_data
->
skin_info
)
{
WARN
(
"Skin weights found but skin mesh header not encountered yet
\n
"
);
hr
=
E_FAIL
;
goto
end
;
}
hr
=
parse_skin_weights_info
(
child
,
mesh_data
,
skin_weights_info_count
);
if
(
FAILED
(
hr
))
goto
end
;
skin_weights_info_count
++
;
}
hr
=
parse_texture_coords
(
child
,
mesh_data
,
provide_flags
);
}
else
if
(
IsEqualGUID
(
&
type
,
&
TID_D3DRMMeshMaterialList
))
{
hr
=
parse_material_list
(
child
,
mesh_data
,
provide_flags
);
}
else
if
(
IsEqualGUID
(
&
type
,
&
DXFILEOBJ_XSkinMeshHeader
))
{
hr
=
parse_skin_mesh_header
(
child
,
mesh_data
,
provide_flags
);
}
else
if
(
IsEqualGUID
(
&
type
,
&
DXFILEOBJ_SkinWeights
))
{
hr
=
parse_skin_weights_info
(
child
,
mesh_data
,
provide_flags
);
}
if
(
FAILED
(
hr
))
goto
end
;
...
...
@@ -3346,10 +3354,10 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data,
child
=
NULL
;
}
if
(
mesh_data
->
skin_info
&&
(
skin_weights_info_count
!=
mesh_data
->
bone_count
))
if
(
mesh_data
->
skin_info
&&
(
mesh_data
->
skin_weights_info_count
!=
mesh_data
->
bone_count
))
{
WARN
(
"Mismatch between skin weights info count %u and bones count %u from skin mesh header.
\n
"
,
skin_weights_info_count
,
mesh_data
->
bone_count
);
mesh_data
->
skin_weights_info_count
,
mesh_data
->
bone_count
);
hr
=
E_FAIL
;
goto
end
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment