ReactOS  0.4.14-dev-49-gfb4591c
mesh.c File Reference
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include "d3dx9_private.h"
#include "dxfile.h"
#include "rmxfguid.h"
#include "rmxftmpl.h"
#include "wine/unicode.h"
#include "wine/list.h"
Include dependency graph for mesh.c:

Go to the source code of this file.

Classes

struct  d3dx9_mesh
 
struct  edge_face
 
struct  edge_face_map
 
struct  vertex_metadata
 
struct  mesh_data
 
struct  mesh_container
 
struct  vertex
 
struct  sincos_table
 
struct  point2d
 
struct  dynamic_array
 
struct  outline
 
struct  outline_array
 
struct  face_array
 
struct  point2d_index
 
struct  point2d_index_array
 
struct  glyphinfo
 
struct  word_array
 
struct  triangulation
 
struct  triangulation_array
 
struct  cos_table
 
struct  udec3
 
struct  dec3n
 
struct  frame_node
 

Macros

#define PROVIDE_MATERIALS   0x1
 
#define PROVIDE_SKININFO   0x2
 
#define PROVIDE_ADJACENCY   0x4
 
#define EFFECT_TABLE_ENTRY(str, field)   {str, sizeof(str), sizeof(material_ptr->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}
 
#define FILL_INDEX_BUFFER(indices_var)
 
#define NUM_ELEM   2
 
#define NUM_ELEM   4
 

Typedefs

typedef WORD face[3]
 

Enumerations

enum  pointtype {
  POINTTYPE_CURVE = 0, POINTTYPE_CORNER, POINTTYPE_CURVE_START, POINTTYPE_CURVE_END,
  POINTTYPE_CURVE_MIDDLE
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static struct d3dx9_meshimpl_from_ID3DXMesh (ID3DXMesh *iface)
 
static HRESULT WINAPI d3dx9_mesh_QueryInterface (ID3DXMesh *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3dx9_mesh_AddRef (ID3DXMesh *iface)
 
static ULONG WINAPI d3dx9_mesh_Release (ID3DXMesh *iface)
 
static HRESULT WINAPI d3dx9_mesh_DrawSubset (ID3DXMesh *iface, DWORD attrib_id)
 
static DWORD WINAPI d3dx9_mesh_GetNumFaces (ID3DXMesh *iface)
 
static DWORD WINAPI d3dx9_mesh_GetNumVertices (ID3DXMesh *iface)
 
static DWORD WINAPI d3dx9_mesh_GetFVF (ID3DXMesh *iface)
 
static void copy_declaration (D3DVERTEXELEMENT9 *dst, const D3DVERTEXELEMENT9 *src, UINT num_elem)
 
static HRESULT WINAPI d3dx9_mesh_GetDeclaration (ID3DXMesh *iface, D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
 
static DWORD WINAPI d3dx9_mesh_GetNumBytesPerVertex (ID3DXMesh *iface)
 
static DWORD WINAPI d3dx9_mesh_GetOptions (ID3DXMesh *iface)
 
static HRESULT WINAPI d3dx9_mesh_GetDevice (struct ID3DXMesh *iface, struct IDirect3DDevice9 **device)
 
static HRESULT WINAPI d3dx9_mesh_CloneMeshFVF (struct ID3DXMesh *iface, DWORD options, DWORD fvf, struct IDirect3DDevice9 *device, struct ID3DXMesh **clone_mesh)
 
static FLOAT scale_clamp_ubyten (FLOAT value)
 
static FLOAT scale_clamp_shortn (FLOAT value)
 
static FLOAT scale_clamp_ushortn (FLOAT value)
 
static INT simple_round (FLOAT value)
 
static void convert_float4 (BYTE *dst, const D3DXVECTOR4 *src, D3DDECLTYPE type_dst)
 
static void convert_component (BYTE *dst, BYTE *src, D3DDECLTYPE type_dst, D3DDECLTYPE type_src)
 
static INT get_equivalent_declaration_index (D3DVERTEXELEMENT9 orig_declaration, D3DVERTEXELEMENT9 *declaration)
 
static HRESULT convert_vertex_buffer (ID3DXMesh *mesh_dst, ID3DXMesh *mesh_src)
 
static BOOL declaration_equals (const D3DVERTEXELEMENT9 *declaration1, const D3DVERTEXELEMENT9 *declaration2)
 
static HRESULT WINAPI d3dx9_mesh_CloneMesh (struct ID3DXMesh *iface, DWORD options, const D3DVERTEXELEMENT9 *declaration, struct IDirect3DDevice9 *device, struct ID3DXMesh **clone_mesh_out)
 
static HRESULT WINAPI d3dx9_mesh_GetVertexBuffer (struct ID3DXMesh *iface, struct IDirect3DVertexBuffer9 **vertex_buffer)
 
static HRESULT WINAPI d3dx9_mesh_GetIndexBuffer (struct ID3DXMesh *iface, struct IDirect3DIndexBuffer9 **index_buffer)
 
static HRESULT WINAPI d3dx9_mesh_LockVertexBuffer (ID3DXMesh *iface, DWORD flags, void **data)
 
static HRESULT WINAPI d3dx9_mesh_UnlockVertexBuffer (ID3DXMesh *iface)
 
static HRESULT WINAPI d3dx9_mesh_LockIndexBuffer (ID3DXMesh *iface, DWORD flags, void **data)
 
static HRESULT WINAPI d3dx9_mesh_UnlockIndexBuffer (ID3DXMesh *iface)
 
static HRESULT WINAPI d3dx9_mesh_GetAttributeTable (ID3DXMesh *iface, D3DXATTRIBUTERANGE *attrib_table, DWORD *attrib_table_size)
 
static HRESULT init_edge_face_map (struct edge_face_map *edge_face_map, const DWORD *index_buffer, const DWORD *point_reps, DWORD num_faces)
 
static DWORD find_adjacent_face (struct edge_face_map *edge_face_map, DWORD vertex1, DWORD vertex2, DWORD num_faces)
 
static DWORDgenerate_identity_point_reps (DWORD num_vertices)
 
static HRESULT WINAPI d3dx9_mesh_ConvertPointRepsToAdjacency (ID3DXMesh *iface, const DWORD *point_reps, DWORD *adjacency)
 
static HRESULT propagate_face_vertices (const DWORD *adjacency, DWORD *point_reps, const DWORD *indices, DWORD *new_indices, DWORD face, DWORD numfaces)
 
static HRESULT WINAPI d3dx9_mesh_ConvertAdjacencyToPointReps (ID3DXMesh *iface, const DWORD *adjacency, DWORD *point_reps)
 
static int compare_vertex_keys (const void *a, const void *b)
 
static HRESULT WINAPI d3dx9_mesh_GenerateAdjacency (ID3DXMesh *iface, float epsilon, DWORD *adjacency)
 
static HRESULT WINAPI d3dx9_mesh_UpdateSemantics (ID3DXMesh *iface, D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
 
static HRESULT WINAPI d3dx9_mesh_LockAttributeBuffer (ID3DXMesh *iface, DWORD flags, DWORD **data)
 
static HRESULT WINAPI d3dx9_mesh_UnlockAttributeBuffer (ID3DXMesh *iface)
 
static HRESULT WINAPI d3dx9_mesh_Optimize (ID3DXMesh *iface, DWORD flags, const DWORD *adjacency_in, DWORD *adjacency_out, DWORD *face_remap, ID3DXBuffer **vertex_remap, ID3DXMesh **opt_mesh)
 
static HRESULT compact_mesh (struct d3dx9_mesh *This, DWORD *indices, DWORD *new_num_vertices, ID3DXBuffer **vertex_remap)
 
static DWORD count_attributes (const DWORD *attrib_buffer, DWORD numfaces)
 
static void fill_attribute_table (DWORD *attrib_buffer, DWORD numfaces, void *indices, BOOL is_32bit_indices, D3DXATTRIBUTERANGE *attrib_table)
 
static int attrib_entry_compare (const DWORD **a, const DWORD **b)
 
static HRESULT remap_faces_for_attrsort (struct d3dx9_mesh *This, const DWORD *indices, DWORD *attrib_buffer, DWORD **sorted_attrib_buffer, DWORD **face_remap)
 
static HRESULT WINAPI d3dx9_mesh_OptimizeInplace (ID3DXMesh *iface, DWORD flags, const DWORD *adjacency_in, DWORD *adjacency_out, DWORD *face_remap_out, ID3DXBuffer **vertex_remap_out)
 
static HRESULT WINAPI d3dx9_mesh_SetAttributeTable (ID3DXMesh *iface, const D3DXATTRIBUTERANGE *attrib_table, DWORD attrib_table_size)
 
BOOL WINAPI D3DXBoxBoundProbe (const D3DXVECTOR3 *pmin, const D3DXVECTOR3 *pmax, const D3DXVECTOR3 *prayposition, const D3DXVECTOR3 *praydirection)
 
HRESULT WINAPI D3DXComputeBoundingBox (const D3DXVECTOR3 *pfirstposition, DWORD numvertices, DWORD dwstride, D3DXVECTOR3 *pmin, D3DXVECTOR3 *pmax)
 
HRESULT WINAPI D3DXComputeBoundingSphere (const D3DXVECTOR3 *pfirstposition, DWORD numvertices, DWORD dwstride, D3DXVECTOR3 *pcenter, float *pradius)
 
static void append_decl_element (D3DVERTEXELEMENT9 *declaration, UINT *idx, UINT *offset, D3DDECLTYPE type, D3DDECLUSAGE usage, UINT usage_idx)
 
HRESULT WINAPI D3DXDeclaratorFromFVF (DWORD fvf, D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
 
HRESULT WINAPI D3DXFVFFromDeclarator (const D3DVERTEXELEMENT9 *declaration, DWORD *fvf)
 
static UINT Get_TexCoord_Size_From_FVF (DWORD FVF, int tex_num)
 
UINT WINAPI D3DXGetFVFVertexSize (DWORD FVF)
 
UINT WINAPI D3DXGetDeclVertexSize (const D3DVERTEXELEMENT9 *decl, DWORD stream_idx)
 
UINT WINAPI D3DXGetDeclLength (const D3DVERTEXELEMENT9 *decl)
 
BOOL WINAPI D3DXIntersectTri (const D3DXVECTOR3 *p0, const D3DXVECTOR3 *p1, const D3DXVECTOR3 *p2, const D3DXVECTOR3 *praypos, const D3DXVECTOR3 *praydir, float *pu, float *pv, float *pdist)
 
BOOL WINAPI D3DXSphereBoundProbe (const D3DXVECTOR3 *pcenter, float radius, const D3DXVECTOR3 *prayposition, const D3DXVECTOR3 *praydirection)
 
HRESULT WINAPI D3DXCreateMesh (DWORD numfaces, DWORD numvertices, DWORD options, const D3DVERTEXELEMENT9 *declaration, struct IDirect3DDevice9 *device, struct ID3DXMesh **mesh)
 
HRESULT WINAPI D3DXCreateMeshFVF (DWORD numfaces, DWORD numvertices, DWORD options, DWORD fvf, struct IDirect3DDevice9 *device, struct ID3DXMesh **mesh)
 
static HRESULT parse_texture_filename (ID3DXFileData *filedata, char **filename_out)
 
static HRESULT parse_material (ID3DXFileData *filedata, D3DXMATERIAL *material)
 
static void destroy_materials (struct mesh_data *mesh)
 
static HRESULT parse_material_list (ID3DXFileData *filedata, struct mesh_data *mesh)
 
static HRESULT parse_texture_coords (ID3DXFileData *filedata, struct mesh_data *mesh)
 
static HRESULT parse_vertex_colors (ID3DXFileData *filedata, struct mesh_data *mesh)
 
static HRESULT parse_normals (ID3DXFileData *filedata, struct mesh_data *mesh)
 
static HRESULT parse_skin_mesh_info (ID3DXFileData *filedata, struct mesh_data *mesh_data, DWORD index)
 
static HRESULT parse_mesh (ID3DXFileData *filedata, struct mesh_data *mesh_data, DWORD provide_flags)
 
static HRESULT generate_effects (ID3DXBuffer *materials, DWORD num_materials, ID3DXBuffer **effects)
 
HRESULT WINAPI D3DXLoadSkinMeshFromXof (struct ID3DXFileData *filedata, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency_out, struct ID3DXBuffer **materials_out, struct ID3DXBuffer **effects_out, DWORD *num_materials_out, struct ID3DXSkinInfo **skin_info_out, struct ID3DXMesh **mesh_out)
 
HRESULT WINAPI D3DXLoadMeshHierarchyFromXA (const char *filename, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXAllocateHierarchy *alloc_hier, struct ID3DXLoadUserData *load_user_data, D3DXFRAME **frame_hierarchy, struct ID3DXAnimationController **anim_controller)
 
HRESULT WINAPI D3DXLoadMeshHierarchyFromXW (const WCHAR *filename, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXAllocateHierarchy *alloc_hier, struct ID3DXLoadUserData *load_user_data, D3DXFRAME **frame_hierarchy, struct ID3DXAnimationController **anim_controller)
 
static HRESULT filedata_get_name (ID3DXFileData *filedata, char **name)
 
static HRESULT load_mesh_container (struct ID3DXFileData *filedata, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXAllocateHierarchy *alloc_hier, D3DXMESHCONTAINER **mesh_container)
 
static HRESULT parse_transform_matrix (ID3DXFileData *filedata, D3DXMATRIX *transform)
 
static HRESULT load_frame (struct ID3DXFileData *filedata, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXAllocateHierarchy *alloc_hier, D3DXFRAME **frame_out)
 
HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory (const void *memory, DWORD memory_size, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXAllocateHierarchy *alloc_hier, struct ID3DXLoadUserData *load_user_data, D3DXFRAME **frame_hierarchy, struct ID3DXAnimationController **anim_controller)
 
HRESULT WINAPI D3DXCleanMesh (D3DXCLEANTYPE clean_type, ID3DXMesh *mesh_in, const DWORD *adjacency_in, ID3DXMesh **mesh_out, DWORD *adjacency_out, ID3DXBuffer **errors_and_warnings)
 
HRESULT WINAPI D3DXFrameDestroy (D3DXFRAME *frame, ID3DXAllocateHierarchy *alloc_hier)
 
HRESULT WINAPI D3DXLoadMeshFromXA (const char *filename, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency, struct ID3DXBuffer **materials, struct ID3DXBuffer **effect_instances, DWORD *num_materials, struct ID3DXMesh **mesh)
 
HRESULT WINAPI D3DXLoadMeshFromXW (const WCHAR *filename, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency, struct ID3DXBuffer **materials, struct ID3DXBuffer **effect_instances, DWORD *num_materials, struct ID3DXMesh **mesh)
 
HRESULT WINAPI D3DXLoadMeshFromXResource (HMODULE module, const char *name, const char *type, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency, struct ID3DXBuffer **materials, struct ID3DXBuffer **effect_instances, DWORD *num_materials, struct ID3DXMesh **mesh)
 
static HRESULT parse_frame (struct ID3DXFileData *filedata, DWORD options, struct IDirect3DDevice9 *device, const D3DXMATRIX *parent_transform, struct list *container_list, DWORD provide_flags)
 
HRESULT WINAPI D3DXLoadMeshFromXInMemory (const void *memory, DWORD memory_size, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency_out, struct ID3DXBuffer **materials_out, struct ID3DXBuffer **effects_out, DWORD *num_materials_out, struct ID3DXMesh **mesh_out)
 
HRESULT WINAPI D3DXCreatePolygon (struct IDirect3DDevice9 *device, float length, UINT sides, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
 
HRESULT WINAPI D3DXCreateBox (struct IDirect3DDevice9 *device, float width, float height, float depth, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
 
static void free_sincos_table (struct sincos_table *sincos_table)
 
static BOOL compute_sincos_table (struct sincos_table *sincos_table, float angle_start, float angle_step, int n)
 
static WORD vertex_index (UINT slices, int slice, int stack)
 
HRESULT WINAPI D3DXCreateSphere (struct IDirect3DDevice9 *device, float radius, UINT slices, UINT stacks, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
 
HRESULT WINAPI D3DXCreateCylinder (struct IDirect3DDevice9 *device, float radius1, float radius2, float length, UINT slices, UINT stacks, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
 
HRESULT WINAPI D3DXCreateTeapot (struct IDirect3DDevice9 *device, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
 
HRESULT WINAPI D3DXCreateTextA (struct IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, float extrusion, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency, GLYPHMETRICSFLOAT *glyphmetrics)
 
HRESULT WINAPI D3DXCreateTorus (struct IDirect3DDevice9 *device, float innerradius, float outerradius, UINT sides, UINT rings, struct ID3DXMesh **mesh, ID3DXBuffer **adjacency)
 
static BOOL reserve (struct dynamic_array *array, int count, int itemsize)
 
static struct point2dadd_points (struct outline *array, int num)
 
static struct outlineadd_outline (struct outline_array *array)
 
static faceadd_face (struct face_array *array)
 
static struct triangulationadd_triangulation (struct triangulation_array *array)
 
static HRESULT add_vertex_index (struct word_array *array, WORD vertex_index)
 
 C_ASSERT (sizeof(FIXED)==sizeof(float))
 
 C_ASSERT (sizeof(POINTFX)==sizeof(D3DXVECTOR2))
 
static D3DXVECTOR2convert_fixed_to_float (POINTFX *pt, int count, unsigned int emsquare)
 
static HRESULT add_bezier_points (struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation_sq)
 
static BOOL is_direction_similar (D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
 
static D3DXVECTOR2unit_vec2 (D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
 
static BOOL attempt_line_merge (struct outline *outline, int pt_index, const D3DXVECTOR2 *nextpt, BOOL to_curve, const struct cos_table *table)
 
static HRESULT create_outline (struct glyphinfo *glyph, void *raw_outline, int datasize, float max_deviation_sq, unsigned int emsquare, const struct cos_table *cos_table)
 
static float get_line_to_point_y_distance (D3DXVECTOR2 *line_pt1, D3DXVECTOR2 *line_pt2, D3DXVECTOR2 *point)
 
static D3DXVECTOR2get_indexed_point (struct point2d_index *pt_idx)
 
static D3DXVECTOR2get_ordered_vertex (struct glyphinfo *glyph, WORD index)
 
static void remove_triangulation (struct triangulation_array *array, struct triangulation *item)
 
static HRESULT triangulation_add_point (struct triangulation **t_ptr, struct triangulation_array *triangulations, WORD vtx_idx, BOOL to_top)
 
static D3DXVECTOR2triangulation_get_next_point (struct triangulation *t, struct glyphinfo *glyph, BOOL on_top)
 
static int compare_vertex_indices (const void *a, const void *b)
 
static HRESULT triangulate (struct triangulation_array *triangulations)
 
HRESULT WINAPI D3DXCreateTextW (struct IDirect3DDevice9 *device, HDC hdc, const WCHAR *text, float deviation, float extrusion, struct ID3DXMesh **mesh_ptr, struct ID3DXBuffer **adjacency, GLYPHMETRICSFLOAT *glyphmetrics)
 
HRESULT WINAPI D3DXValidMesh (ID3DXMesh *mesh, const DWORD *adjacency, ID3DXBuffer **errors_and_warnings)
 
static BOOL weld_float1 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_float2 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_float3 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_float4 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_ubyte4 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_ubyte4n (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_d3dcolor (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_short2 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_short2n (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_short4 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_short4n (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_ushort2n (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_ushort4n (void *to, void *from, FLOAT epsilon)
 
static struct udec3 dword_to_udec3 (DWORD d)
 
static BOOL weld_udec3 (void *to, void *from, FLOAT epsilon)
 
static struct dec3n dword_to_dec3n (DWORD d)
 
static BOOL weld_dec3n (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_float16_2 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_float16_4 (void *to, void *from, FLOAT epsilon)
 
static BOOL weld_component (void *to, void *from, D3DDECLTYPE type, FLOAT epsilon)
 
static FLOAT get_component_epsilon (const D3DVERTEXELEMENT9 *decl_ptr, const D3DXWELDEPSILONS *epsilons)
 
static DWORD read_ib (void *index_buffer, BOOL indices_are_32bit, DWORD index)
 
static void write_ib (void *index_buffer, BOOL indices_are_32bit, DWORD index, DWORD value)
 
HRESULT WINAPI D3DXWeldVertices (ID3DXMesh *mesh, DWORD flags, const D3DXWELDEPSILONS *epsilons, const DWORD *adjacency, DWORD *adjacency_out, DWORD *face_remap_out, ID3DXBuffer **vertex_remap_out)
 
HRESULT WINAPI D3DXOptimizeVertices (const void *indices, UINT num_faces, UINT num_vertices, BOOL indices_are_32bit, DWORD *vertex_remap)
 
HRESULT WINAPI D3DXOptimizeFaces (const void *indices, UINT num_faces, UINT num_vertices, BOOL indices_are_32bit, DWORD *face_remap)
 
static D3DXVECTOR3vertex_element_vec3 (BYTE *vertices, const D3DVERTEXELEMENT9 *declaration, DWORD vertex_stride, DWORD index)
 
static D3DXVECTOR3 read_vec3 (BYTE *vertices, const D3DVERTEXELEMENT9 *declaration, DWORD vertex_stride, DWORD index)
 
HRESULT WINAPI D3DXComputeTangentFrameEx (ID3DXMesh *mesh, DWORD texture_in_semantic, DWORD texture_in_index, DWORD u_partial_out_semantic, DWORD u_partial_out_index, DWORD v_partial_out_semantic, DWORD v_partial_out_index, DWORD normal_out_semantic, DWORD normal_out_index, DWORD options, const DWORD *adjacency, float partial_edge_threshold, float singular_point_threshold, float normal_edge_threshold, ID3DXMesh **mesh_out, ID3DXBuffer **vertex_mapping)
 
HRESULT WINAPI D3DXComputeTangent (ID3DXMesh *mesh, DWORD stage_idx, DWORD tangent_idx, DWORD binorm_idx, DWORD wrap, const DWORD *adjacency)
 
HRESULT WINAPI D3DXComputeNormals (struct ID3DXBaseMesh *mesh, const DWORD *adjacency)
 
HRESULT WINAPI D3DXIntersect (ID3DXBaseMesh *mesh, const D3DXVECTOR3 *ray_pos, const D3DXVECTOR3 *ray_dir, BOOL *hit, DWORD *face_index, float *u, float *v, float *distance, ID3DXBuffer **all_hits, DWORD *count_of_hits)
 
HRESULT WINAPI D3DXTessellateNPatches (ID3DXMesh *mesh, const DWORD *adjacency_in, float num_segs, BOOL quadratic_normals, ID3DXMesh **mesh_out, ID3DXBuffer **adjacency_out)
 
HRESULT WINAPI D3DXConvertMeshSubsetToSingleStrip (struct ID3DXBaseMesh *mesh_in, DWORD attribute_id, DWORD ib_flags, struct IDirect3DIndexBuffer9 **index_buffer, DWORD *index_count)
 
static BOOL queue_frame_node (struct list *queue, D3DXFRAME *frame)
 
static void empty_frame_queue (struct list *queue)
 
D3DXFRAME *WINAPI D3DXFrameFind (const D3DXFRAME *root, const char *name)
 

Variables

static const UINT d3dx_decltype_size []
 
static const struct ID3DXMeshVtbl D3DXMesh_Vtbl
 

Macro Definition Documentation

◆ EFFECT_TABLE_ENTRY

#define EFFECT_TABLE_ENTRY (   str,
  field 
)    {str, sizeof(str), sizeof(material_ptr->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}

◆ FILL_INDEX_BUFFER

#define FILL_INDEX_BUFFER (   indices_var)
Value:
for (i = 0; i < mesh_data.num_poly_faces; i++) \
{ \
WORD first_index = *index_in_ptr++; \
while (count--) { \
*indices_var++ = first_index; \
*indices_var++ = *index_in_ptr; \
index_in_ptr++; \
*indices_var++ = *index_in_ptr; \
} \
index_in_ptr++; \
}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD * num_tri_per_face
Definition: mesh.c:2616
DWORD num_poly_faces
Definition: mesh.c:2613

◆ NUM_ELEM [1/2]

#define NUM_ELEM   2

◆ NUM_ELEM [2/2]

#define NUM_ELEM   4

◆ PROVIDE_ADJACENCY

#define PROVIDE_ADJACENCY   0x4

Definition at line 3165 of file mesh.c.

◆ PROVIDE_MATERIALS

#define PROVIDE_MATERIALS   0x1

Definition at line 3163 of file mesh.c.

◆ PROVIDE_SKININFO

#define PROVIDE_SKININFO   0x2

Definition at line 3164 of file mesh.c.

Typedef Documentation

◆ face

Definition at line 4747 of file mesh.c.

Enumeration Type Documentation

◆ pointtype

Enumerator
POINTTYPE_CURVE 
POINTTYPE_CORNER 
POINTTYPE_CURVE_START 
POINTTYPE_CURVE_END 
POINTTYPE_CURVE_MIDDLE 

Definition at line 5308 of file mesh.c.

Function Documentation

◆ add_bezier_points()

static HRESULT add_bezier_points ( struct outline outline,
const D3DXVECTOR2 p1,
const D3DXVECTOR2 p2,
const D3DXVECTOR2 p3,
float  max_deviation_sq 
)
static

Definition at line 5478 of file mesh.c.

5481 {
5482  D3DXVECTOR2 split1 = {0, 0}, split2 = {0, 0}, middle, vec;
5483  float deviation_sq;
5484 
5485  D3DXVec2Scale(&split1, D3DXVec2Add(&split1, p1, p2), 0.5f);
5486  D3DXVec2Scale(&split2, D3DXVec2Add(&split2, p2, p3), 0.5f);
5487  D3DXVec2Scale(&middle, D3DXVec2Add(&middle, &split1, &split2), 0.5f);
5488 
5489  deviation_sq = D3DXVec2LengthSq(D3DXVec2Subtract(&vec, &middle, p2));
5490  if (deviation_sq < max_deviation_sq) {
5491  struct point2d *pt = add_points(outline, 1);
5492  if (!pt) return E_OUTOFMEMORY;
5493  pt->pos = *p2;
5494  pt->corner = POINTTYPE_CURVE;
5495  /* the end point is omitted because the end line merges into the next segment of
5496  * the split bezier curve, and the end of the split bezier curve is added outside
5497  * this recursive function. */
5498  } else {
5499  HRESULT hr = add_bezier_points(outline, p1, &split1, &middle, max_deviation_sq);
5500  if (hr != S_OK) return hr;
5501  hr = add_bezier_points(outline, &middle, &split2, p3, max_deviation_sq);
5502  if (hr != S_OK) return hr;
5503  }
5504 
5505  return S_OK;
5506 }
HRESULT hr
Definition: shlfolder.c:183
#define pt(x, y)
Definition: drawing.c:79
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static struct point2d * add_points(struct outline *array, int num)
Definition: mesh.c:5412
GLfloat f
Definition: glext.h:7540
LONG HRESULT
Definition: typedefs.h:77
Definition: mesh.c:5316
FT_Vector * vec
Definition: ftbbox.c:448
Definition: mesh.c:5329
#define S_OK
Definition: intsafe.h:59
static HRESULT add_bezier_points(struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation_sq)
Definition: mesh.c:5478

Referenced by create_outline().

◆ add_face()

static face* add_face ( struct face_array array)
inlinestatic

Definition at line 5436 of file mesh.c.

5437 {
5438  return &array->items[array->count++];
5439 }

Referenced by triangulation_add_point().

◆ add_outline()

static struct outline* add_outline ( struct outline_array array)
static

Definition at line 5424 of file mesh.c.

5425 {
5426  struct outline *item;
5427 
5428  if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
5429  return NULL;
5430 
5431  item = &array->items[array->count++];
5432  ZeroMemory(item, sizeof(*item));
5433  return item;
5434 }
#define ZeroMemory
Definition: winbase.h:1635
smooth NULL
Definition: ftsmooth.c:416
Definition: mesh.c:5329
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5392
static ATOM item
Definition: dde.c:856

Referenced by create_outline().

◆ add_points()

static struct point2d* add_points ( struct outline array,
int  num 
)
static

Definition at line 5412 of file mesh.c.

5413 {
5414  struct point2d *item;
5415 
5416  if (!reserve((struct dynamic_array *)array, array->count + num, sizeof(array->items[0])))
5417  return NULL;
5418 
5419  item = &array->items[array->count];
5420  array->count += num;
5421  return item;
5422 }
smooth NULL
Definition: ftsmooth.c:416
GLuint GLuint num
Definition: glext.h:9618
Definition: mesh.c:5316
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5392
static ATOM item
Definition: dde.c:856

Referenced by add_bezier_points(), and create_outline().

◆ add_triangulation()

static struct triangulation* add_triangulation ( struct triangulation_array array)
static

Definition at line 5441 of file mesh.c.

5442 {
5443  struct triangulation *item;
5444 
5445  if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
5446  return NULL;
5447 
5448  item = &array->items[array->count++];
5449  ZeroMemory(item, sizeof(*item));
5450  return item;
5451 }
#define ZeroMemory
Definition: winbase.h:1635
smooth NULL
Definition: ftsmooth.c:416
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5392
static ATOM item
Definition: dde.c:856

Referenced by triangulate().

◆ add_vertex_index()

static HRESULT add_vertex_index ( struct word_array array,
WORD  vertex_index 
)
static

Definition at line 5453 of file mesh.c.

5454 {
5455  if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
5456  return E_OUTOFMEMORY;
5457 
5458  array->items[array->count++] = vertex_index;
5459  return S_OK;
5460 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static WORD vertex_index(UINT slices, int slice, int stack)
Definition: mesh.c:4790
#define S_OK
Definition: intsafe.h:59
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5392

Referenced by triangulate(), and triangulation_add_point().

◆ append_decl_element()

static void append_decl_element ( D3DVERTEXELEMENT9 declaration,
UINT idx,
UINT offset,
D3DDECLTYPE  type,
D3DDECLUSAGE  usage,
UINT  usage_idx 
)
static

Definition at line 2020 of file mesh.c.

2022 {
2023  declaration[*idx].Stream = 0;
2024  declaration[*idx].Offset = *offset;
2025  declaration[*idx].Type = type;
2027  declaration[*idx].Usage = usage;
2028  declaration[*idx].UsageIndex = usage_idx;
2029 
2031  ++(*idx);
2032 }
GLintptr offset
Definition: glext.h:5920
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned int idx
Definition: utils.c:41
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static const UINT d3dx_decltype_size[]
Definition: mesh.c:67
BYTE usage_idx

Referenced by D3DXDeclaratorFromFVF().

◆ attempt_line_merge()

static BOOL attempt_line_merge ( struct outline outline,
int  pt_index,
const D3DXVECTOR2 nextpt,
BOOL  to_curve,
const struct cos_table table 
)
static

Definition at line 5526 of file mesh.c.

5531 {
5532  D3DXVECTOR2 curdir, lastdir;
5533  struct point2d *prevpt, *pt;
5534  BOOL ret = FALSE;
5535 
5536  pt = &outline->items[pt_index];
5537  pt_index = (pt_index - 1 + outline->count) % outline->count;
5538  prevpt = &outline->items[pt_index];
5539 
5540  if (to_curve)
5542 
5543  if (outline->count < 2)
5544  return FALSE;
5545 
5546  /* remove last point if the next line continues the last line */
5547  unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
5548  unit_vec2(&curdir, &pt->pos, nextpt);
5549  if (is_direction_similar(&lastdir, &curdir, table->cos_half))
5550  {
5551  outline->count--;
5552  if (pt->corner == POINTTYPE_CURVE_END)
5553  prevpt->corner = pt->corner;
5554  if (prevpt->corner == POINTTYPE_CURVE_END && to_curve)
5555  prevpt->corner = POINTTYPE_CURVE_MIDDLE;
5556  pt = prevpt;
5557 
5558  ret = TRUE;
5559  if (outline->count < 2)
5560  return ret;
5561 
5562  pt_index = (pt_index - 1 + outline->count) % outline->count;
5563  prevpt = &outline->items[pt_index];
5564  unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
5565  unit_vec2(&curdir, &pt->pos, nextpt);
5566  }
5567  return ret;
5568 }
int count
Definition: mesh.c:5331
#define pt(x, y)
Definition: drawing.c:79
enum pointtype corner
Definition: mesh.c:5319
D3DXVECTOR2 pos
Definition: mesh.c:5318
unsigned int BOOL
Definition: ntddk_ex.h:94
if(!(yy_init))
Definition: macro.lex.yy.c:714
Definition: mesh.c:5316
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:5514
int ret
Definition: mesh.c:5329
struct point2d * items
Definition: mesh.c:5332
#define TRUE
Definition: mesh.c:42
static BOOL is_direction_similar(D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
Definition: mesh.c:5508

Referenced by create_outline().

◆ attrib_entry_compare()

static int attrib_entry_compare ( const DWORD **  a,
const DWORD **  b 
)
static

Definition at line 1593 of file mesh.c.

1594 {
1595  const DWORD *ptr_a = *a;
1596  const DWORD *ptr_b = *b;
1597  int delta = *ptr_a - *ptr_b;
1598 
1599  if (delta)
1600  return delta;
1601 
1602  delta = ptr_a - ptr_b; /* for stable sort */
1603  return delta;
1604 }
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by remap_faces_for_attrsort().

◆ C_ASSERT() [1/2]

C_ASSERT ( sizeof(FIXED = =sizeof(float))

◆ C_ASSERT() [2/2]

C_ASSERT ( sizeof(POINTFX = =sizeof(D3DXVECTOR2))

◆ compact_mesh()

static HRESULT compact_mesh ( struct d3dx9_mesh This,
DWORD indices,
DWORD new_num_vertices,
ID3DXBuffer **  vertex_remap 
)
static

Definition at line 1497 of file mesh.c.

1499 {
1500  HRESULT hr;
1501  DWORD *vertex_remap_ptr;
1502  DWORD num_used_vertices;
1503  DWORD i;
1504 
1505  hr = D3DXCreateBuffer(This->numvertices * sizeof(DWORD), vertex_remap);
1506  if (FAILED(hr)) return hr;
1507  vertex_remap_ptr = ID3DXBuffer_GetBufferPointer(*vertex_remap);
1508 
1509  for (i = 0; i < This->numfaces * 3; i++)
1510  vertex_remap_ptr[indices[i]] = 1;
1511 
1512  /* create old->new vertex mapping */
1513  num_used_vertices = 0;
1514  for (i = 0; i < This->numvertices; i++) {
1515  if (vertex_remap_ptr[i])
1516  vertex_remap_ptr[i] = num_used_vertices++;
1517  else
1518  vertex_remap_ptr[i] = -1;
1519  }
1520  /* convert indices */
1521  for (i = 0; i < This->numfaces * 3; i++)
1522  indices[i] = vertex_remap_ptr[indices[i]];
1523 
1524  /* create new->old vertex mapping */
1525  num_used_vertices = 0;
1526  for (i = 0; i < This->numvertices; i++) {
1527  if (vertex_remap_ptr[i] != -1)
1528  vertex_remap_ptr[num_used_vertices++] = i;
1529  }
1530  for (i = num_used_vertices; i < This->numvertices; i++)
1531  vertex_remap_ptr[i] = -1;
1532 
1533  *new_num_vertices = num_used_vertices;
1534 
1535  return D3D_OK;
1536 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
HRESULT hr
Definition: shlfolder.c:183
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3D_OK
Definition: d3d.h:106
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:129
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85

Referenced by d3dx9_mesh_OptimizeInplace().

◆ compare_vertex_indices()

static int compare_vertex_indices ( const void a,
const void b 
)
static

Definition at line 5845 of file mesh.c.

5846 {
5847  const struct point2d_index *idx1 = a, *idx2 = b;
5848  const D3DXVECTOR2 *p1 = &idx1->outline->items[idx1->vertex].pos;
5849  const D3DXVECTOR2 *p2 = &idx2->outline->items[idx2->vertex].pos;
5850  float diff = p1->x - p2->x;
5851 
5852  if (diff == 0.0f)
5853  diff = p1->y - p2->y;
5854 
5855  return diff == 0.0f ? 0 : (diff > 0.0f ? -1 : 1);
5856 }
FLOAT y
Definition: d3dx9math.h:64
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLfloat f
Definition: glext.h:7540
FLOAT x
Definition: d3dx9math.h:64
int vertex
Definition: mesh.c:5351
struct outline * outline
Definition: mesh.c:5350

Referenced by triangulate().

◆ compare_vertex_keys()

static int compare_vertex_keys ( const void a,
const void b 
)
static

Definition at line 1215 of file mesh.c.

1216 {
1217  const struct vertex_metadata *left = a;
1218  const struct vertex_metadata *right = b;
1219  if (left->key == right->key)
1220  return 0;
1221  return left->key < right->key ? -1 : 1;
1222 }
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859

Referenced by d3dx9_mesh_GenerateAdjacency().

◆ compute_sincos_table()

static BOOL compute_sincos_table ( struct sincos_table sincos_table,
float  angle_start,
float  angle_step,
int  n 
)
static

Definition at line 4762 of file mesh.c.

4763 {
4764  float angle;
4765  int i;
4766 
4767  sincos_table->sin = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->sin));
4768  if (!sincos_table->sin)
4769  {
4770  return FALSE;
4771  }
4772  sincos_table->cos = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->cos));
4773  if (!sincos_table->cos)
4774  {
4776  return FALSE;
4777  }
4778 
4779  angle = angle_start;
4780  for (i = 0; i < n; i++)
4781  {
4782  sincos_table->sin[i] = sinf(angle);
4783  sincos_table->cos[i] = cosf(angle);
4784  angle += angle_step;
4785  }
4786 
4787  return TRUE;
4788 }
GLdouble n
Definition: glext.h:7729
GLfloat angle
Definition: glext.h:10853
#define cosf
Definition: cosf.c:6
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
float * cos
Definition: mesh.c:4752
float * sin
Definition: mesh.c:4751
#define sinf
Definition: sinf.c:6
#define TRUE
Definition: mesh.c:42
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by D3DXCreateCylinder(), and D3DXCreateSphere().

◆ convert_component()

static void convert_component ( BYTE dst,
BYTE src,
D3DDECLTYPE  type_dst,
D3DDECLTYPE  type_src 
)
static

Definition at line 469 of file mesh.c.

470 {
471  BOOL fixme_once = FALSE;
472 
473  switch (type_src)
474  {
475  case D3DDECLTYPE_FLOAT1:
476  {
477  FLOAT *src_ptr = (FLOAT*)src;
478  D3DXVECTOR4 src_float4 = {*src_ptr, 0.0f, 0.0f, 1.0f};
479  convert_float4(dst, &src_float4, type_dst);
480  break;
481  }
482  case D3DDECLTYPE_FLOAT2:
483  {
484  D3DXVECTOR2 *src_ptr = (D3DXVECTOR2*)src;
485  D3DXVECTOR4 src_float4 = {src_ptr->x, src_ptr->y, 0.0f, 1.0f};
486  convert_float4(dst, &src_float4, type_dst);
487  break;
488  }
489  case D3DDECLTYPE_FLOAT3:
490  {
491  D3DXVECTOR3 *src_ptr = (D3DXVECTOR3*)src;
492  D3DXVECTOR4 src_float4 = {src_ptr->x, src_ptr->y, src_ptr->z, 1.0f};
493  convert_float4(dst, &src_float4, type_dst);
494  break;
495  }
496  case D3DDECLTYPE_FLOAT4:
497  {
498  D3DXVECTOR4 *src_ptr = (D3DXVECTOR4*)src;
499  D3DXVECTOR4 src_float4 = {src_ptr->x, src_ptr->y, src_ptr->z, src_ptr->w};
500  convert_float4(dst, &src_float4, type_dst);
501  break;
502  }
504  {
505  D3DXVECTOR4 src_float4 =
506  {
507  (FLOAT)src[2]/UCHAR_MAX,
508  (FLOAT)src[1]/UCHAR_MAX,
509  (FLOAT)src[0]/UCHAR_MAX,
510  (FLOAT)src[3]/UCHAR_MAX
511  };
512  convert_float4(dst, &src_float4, type_dst);
513  break;
514  }
515  case D3DDECLTYPE_UBYTE4:
516  {
517  D3DXVECTOR4 src_float4 = {src[0], src[1], src[2], src[3]};
518  convert_float4(dst, &src_float4, type_dst);
519  break;
520  }
521  case D3DDECLTYPE_SHORT2:
522  {
523  SHORT *src_ptr = (SHORT*)src;
524  D3DXVECTOR4 src_float4 = {src_ptr[0], src_ptr[1], 0.0f, 1.0f};
525  convert_float4(dst, &src_float4, type_dst);
526  break;
527  }
528  case D3DDECLTYPE_SHORT4:
529  {
530  SHORT *src_ptr = (SHORT*)src;
531  D3DXVECTOR4 src_float4 = {src_ptr[0], src_ptr[1], src_ptr[2], src_ptr[3]};
532  convert_float4(dst, &src_float4, type_dst);
533  break;
534  }
535  case D3DDECLTYPE_UBYTE4N:
536  {
537  D3DXVECTOR4 src_float4 =
538  {
539  (FLOAT)src[0]/UCHAR_MAX,
540  (FLOAT)src[1]/UCHAR_MAX,
541  (FLOAT)src[2]/UCHAR_MAX,
542  (FLOAT)src[3]/UCHAR_MAX
543  };
544  convert_float4(dst, &src_float4, type_dst);
545  break;
546  }
547  case D3DDECLTYPE_SHORT2N:
548  {
549  SHORT *src_ptr = (SHORT*)src;
550  D3DXVECTOR4 src_float4 = {(FLOAT)src_ptr[0]/SHRT_MAX, (FLOAT)src_ptr[1]/SHRT_MAX, 0.0f, 1.0f};
551  convert_float4(dst, &src_float4, type_dst);
552  break;
553  }
554  case D3DDECLTYPE_SHORT4N:
555  {
556  SHORT *src_ptr = (SHORT*)src;
557  D3DXVECTOR4 src_float4 =
558  {
559  (FLOAT)src_ptr[0]/SHRT_MAX,
560  (FLOAT)src_ptr[1]/SHRT_MAX,
561  (FLOAT)src_ptr[2]/SHRT_MAX,
562  (FLOAT)src_ptr[3]/SHRT_MAX
563  };
564  convert_float4(dst, &src_float4, type_dst);
565  break;
566  }
568  {
569  D3DXVECTOR4 src_float4 = {0.0f, 0.0f, 0.0f, 1.0f};
570  D3DXFloat16To32Array((FLOAT*)&src_float4, (D3DXFLOAT16*)src, 2);
571  convert_float4(dst, &src_float4, type_dst);
572  break;
573  }
575  {
576  D3DXVECTOR4 src_float4;
577  D3DXFloat16To32Array((FLOAT*)&src_float4, (D3DXFLOAT16*)src, 4);
578  convert_float4(dst, &src_float4, type_dst);
579  break;
580  }
581  default:
582  if (!fixme_once++)
583  FIXME("Conversion of D3DDECLTYPE %d to %d not implemented.\n", type_src, type_dst);
584  break;
585  }
586 }
FLOAT y
Definition: d3dx9math.h:64
#define FLOAT
Definition: i386-dis.c:516
FLOAT *WINAPI D3DXFloat16To32Array(FLOAT *pout, const D3DXFLOAT16 *pin, UINT n)
Definition: math.c:2265
static void convert_float4(BYTE *dst, const D3DXVECTOR4 *src, D3DDECLTYPE type_dst)
Definition: mesh.c:344
unsigned int BOOL
Definition: ntddk_ex.h:94
short SHORT
Definition: pedump.c:59
#define FIXME(fmt,...)
Definition: debug.h:110
FLOAT x
Definition: d3dx9math.h:64
GLenum src
Definition: glext.h:6340
#define UCHAR_MAX
Definition: limits.h:25
GLenum GLenum dst
Definition: glext.h:6340
float FLOAT
Definition: typedefs.h:67
#define SHRT_MAX
Definition: limits.h:37

Referenced by convert_vertex_buffer().

◆ convert_fixed_to_float()

static D3DXVECTOR2* convert_fixed_to_float ( POINTFX pt,
int  count,
unsigned int  emsquare 
)
inlinestatic

Definition at line 5466 of file mesh.c.

5467 {
5469  while (count--) {
5470  D3DXVECTOR2 *pt_flt = (D3DXVECTOR2*)pt;
5471  pt_flt->x = (pt->x.value + pt->x.fract / (float)0x10000) / emsquare;
5472  pt_flt->y = (pt->y.value + pt->y.fract / (float)0x10000) / emsquare;
5473  pt++;
5474  }
5475  return ret;
5476 }
FLOAT y
Definition: d3dx9math.h:64
#define pt(x, y)
Definition: drawing.c:79
GLuint GLuint GLsizei count
Definition: gl.h:1545
char * value
Definition: wpp.c:37
FLOAT x
Definition: d3dx9math.h:64
int ret

Referenced by create_outline().

◆ convert_float4()

static void convert_float4 ( BYTE dst,
const D3DXVECTOR4 src,
D3DDECLTYPE  type_dst 
)
static

Definition at line 344 of file mesh.c.

345 {
346  BOOL fixme_once = FALSE;
347 
348  switch (type_dst)
349  {
350  case D3DDECLTYPE_FLOAT1:
351  {
352  FLOAT *dst_ptr = (FLOAT*)dst;
353  *dst_ptr = src->x;
354  break;
355  }
356  case D3DDECLTYPE_FLOAT2:
357  {
358  D3DXVECTOR2 *dst_ptr = (D3DXVECTOR2*)dst;
359  dst_ptr->x = src->x;
360  dst_ptr->y = src->y;
361  break;
362  }
363  case D3DDECLTYPE_FLOAT3:
364  {
365  D3DXVECTOR3 *dst_ptr = (D3DXVECTOR3*)dst;
366  dst_ptr->x = src->x;
367  dst_ptr->y = src->y;
368  dst_ptr->z = src->z;
369  break;
370  }
371  case D3DDECLTYPE_FLOAT4:
372  {
373  D3DXVECTOR4 *dst_ptr = (D3DXVECTOR4*)dst;
374  dst_ptr->x = src->x;
375  dst_ptr->y = src->y;
376  dst_ptr->z = src->z;
377  dst_ptr->w = src->w;
378  break;
379  }
381  {
386  break;
387  }
388  case D3DDECLTYPE_UBYTE4:
389  {
390  dst[0] = src->x < 0.0f ? 0 : (BYTE)simple_round(src->x);
391  dst[1] = src->y < 0.0f ? 0 : (BYTE)simple_round(src->y);
392  dst[2] = src->z < 0.0f ? 0 : (BYTE)simple_round(src->z);
393  dst[3] = src->w < 0.0f ? 0 : (BYTE)simple_round(src->w);
394  break;
395  }
396  case D3DDECLTYPE_SHORT2:
397  {
398  SHORT *dst_ptr = (SHORT*)dst;
399  dst_ptr[0] = (SHORT)simple_round(src->x);
400  dst_ptr[1] = (SHORT)simple_round(src->y);
401  break;
402  }
403  case D3DDECLTYPE_SHORT4:
404  {
405  SHORT *dst_ptr = (SHORT*)dst;
406  dst_ptr[0] = (SHORT)simple_round(src->x);
407  dst_ptr[1] = (SHORT)simple_round(src->y);
408  dst_ptr[2] = (SHORT)simple_round(src->z);
409  dst_ptr[3] = (SHORT)simple_round(src->w);
410  break;
411  }
412  case D3DDECLTYPE_UBYTE4N:
413  {
418  break;
419  }
420  case D3DDECLTYPE_SHORT2N:
421  {
422  SHORT *dst_ptr = (SHORT*)dst;
423  dst_ptr[0] = (SHORT)simple_round(scale_clamp_shortn(src->x));
424  dst_ptr[1] = (SHORT)simple_round(scale_clamp_shortn(src->y));
425  break;
426  }
427  case D3DDECLTYPE_SHORT4N:
428  {
429  SHORT *dst_ptr = (SHORT*)dst;
430  dst_ptr[0] = (SHORT)simple_round(scale_clamp_shortn(src->x));
431  dst_ptr[1] = (SHORT)simple_round(scale_clamp_shortn(src->y));
432  dst_ptr[2] = (SHORT)simple_round(scale_clamp_shortn(src->z));
433  dst_ptr[3] = (SHORT)simple_round(scale_clamp_shortn(src->w));
434  break;
435  }
437  {
438  USHORT *dst_ptr = (USHORT*)dst;
439  dst_ptr[0] = (USHORT)simple_round(scale_clamp_ushortn(src->x));
440  dst_ptr[1] = (USHORT)simple_round(scale_clamp_ushortn(src->y));
441  break;
442  }
444  {
445  USHORT *dst_ptr = (USHORT*)dst;
446  dst_ptr[0] = (USHORT)simple_round(scale_clamp_ushortn(src->x));
447  dst_ptr[1] = (USHORT)simple_round(scale_clamp_ushortn(src->y));
448  dst_ptr[2] = (USHORT)simple_round(scale_clamp_ushortn(src->z));
449  dst_ptr[3] = (USHORT)simple_round(scale_clamp_ushortn(src->w));
450  break;
451  }
453  {
455  break;
456  }
458  {
460  break;
461  }
462  default:
463  if (!fixme_once++)
464  FIXME("Conversion from D3DDECLTYPE_FLOAT4 to %d not implemented.\n", type_dst);
465  break;
466  }
467 }
FLOAT y
Definition: d3dx9math.h:64
D3DXFLOAT16 *WINAPI D3DXFloat32To16Array(D3DXFLOAT16 *pout, const FLOAT *pin, UINT n)
Definition: math.c:2231
unsigned int BOOL
Definition: ntddk_ex.h:94
short SHORT
Definition: pedump.c:59
#define FIXME(fmt,...)
Definition: debug.h:110
static FLOAT scale_clamp_shortn(FLOAT value)
Definition: mesh.c:301
static INT simple_round(FLOAT value)
Definition: mesh.c:337
FLOAT x
Definition: d3dx9math.h:64
static FLOAT scale_clamp_ubyten(FLOAT value)
Definition: mesh.c:284
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
static FLOAT scale_clamp_ushortn(FLOAT value)
Definition: mesh.c:320
unsigned short USHORT
Definition: pedump.c:61
GLenum GLenum dst
Definition: glext.h:6340
float FLOAT
Definition: typedefs.h:67

Referenced by convert_component().

◆ convert_vertex_buffer()

static HRESULT convert_vertex_buffer ( ID3DXMesh *  mesh_dst,
ID3DXMesh *  mesh_src 
)
static

Definition at line 604 of file mesh.c.

605 {
606  HRESULT hr;
607  D3DVERTEXELEMENT9 orig_declaration[MAX_FVF_DECL_SIZE] = {D3DDECL_END()};
609  BYTE *vb_dst = NULL;
610  BYTE *vb_src = NULL;
611  UINT i;
612  UINT num_vertices = mesh_src->lpVtbl->GetNumVertices(mesh_src);
613  UINT dst_vertex_size = mesh_dst->lpVtbl->GetNumBytesPerVertex(mesh_dst);
614  UINT src_vertex_size = mesh_src->lpVtbl->GetNumBytesPerVertex(mesh_src);
615 
616  hr = mesh_src->lpVtbl->GetDeclaration(mesh_src, orig_declaration);
617  if (FAILED(hr)) return hr;
618  hr = mesh_dst->lpVtbl->GetDeclaration(mesh_dst, declaration);
619  if (FAILED(hr)) return hr;
620 
621  hr = mesh_src->lpVtbl->LockVertexBuffer(mesh_src, D3DLOCK_READONLY, (void**)&vb_src);
622  if (FAILED(hr)) goto cleanup;
623  hr = mesh_dst->lpVtbl->LockVertexBuffer(mesh_dst, 0, (void**)&vb_dst);
624  if (FAILED(hr)) goto cleanup;
625 
626  /* Clear all new fields by clearing the entire vertex buffer. */
627  memset(vb_dst, 0, num_vertices * dst_vertex_size);
628 
629  for (i = 0; orig_declaration[i].Stream != 0xff; i++)
630  {
631  INT eq_idx = get_equivalent_declaration_index(orig_declaration[i], declaration);
632 
633  if (eq_idx >= 0)
634  {
635  UINT j;
636  for (j = 0; j < num_vertices; j++)
637  {
638  UINT idx_dst = dst_vertex_size * j + declaration[eq_idx].Offset;
639  UINT idx_src = src_vertex_size * j + orig_declaration[i].Offset;
640  UINT type_size = d3dx_decltype_size[orig_declaration[i].Type];
641 
642  if (orig_declaration[i].Type == declaration[eq_idx].Type)
643  memcpy(&vb_dst[idx_dst], &vb_src[idx_src], type_size);
644  else
645  convert_component(&vb_dst[idx_dst], &vb_src[idx_src], declaration[eq_idx].Type, orig_declaration[i].Type);
646  }
647  }
648  }
649 
650  hr = D3D_OK;
651 cleanup:
652  if (vb_dst) mesh_dst->lpVtbl->UnlockVertexBuffer(mesh_dst);
653  if (vb_src) mesh_src->lpVtbl->UnlockVertexBuffer(mesh_src);
654 
655  return hr;
656 }
Type
Definition: Type.h:6
HRESULT hr
Definition: shlfolder.c:183
static void convert_component(BYTE *dst, BYTE *src, D3DDECLTYPE type_dst, D3DDECLTYPE type_src)
Definition: mesh.c:469
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
LONG HRESULT
Definition: typedefs.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define D3DDECL_END()
Definition: d3d9types.h:311
static const UINT d3dx_decltype_size[]
Definition: mesh.c:67
#define D3D_OK
Definition: d3d.h:106
unsigned int UINT
Definition: ndis.h:50
char * cleanup(char *str)
Definition: wpickclick.c:99
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define memset(x, y, z)
Definition: compat.h:39
static INT get_equivalent_declaration_index(D3DVERTEXELEMENT9 orig_declaration, D3DVERTEXELEMENT9 *declaration)
Definition: mesh.c:588

Referenced by d3dx9_mesh_CloneMesh().

◆ copy_declaration()

static void copy_declaration ( D3DVERTEXELEMENT9 dst,
const D3DVERTEXELEMENT9 src,
UINT  num_elem 
)
static

Definition at line 218 of file mesh.c.

219 {
220  memcpy(dst, src, num_elem * sizeof(*src));
221 }
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by d3dx9_mesh_GetDeclaration(), d3dx9_mesh_UpdateSemantics(), and D3DXCreateMesh().

◆ count_attributes()

static DWORD count_attributes ( const DWORD attrib_buffer,
DWORD  numfaces 
)
static

Definition at line 1539 of file mesh.c.

1540 {
1541  DWORD last_attribute = attrib_buffer[0];
1542  DWORD attrib_table_size = 1;
1543  DWORD i;
1544  for (i = 1; i < numfaces; i++) {
1545  if (attrib_buffer[i] != last_attribute) {
1546  last_attribute = attrib_buffer[i];
1547  attrib_table_size++;
1548  }
1549  }
1550  return attrib_table_size;
1551 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by d3dx9_mesh_OptimizeInplace().

◆ create_outline()

static HRESULT create_outline ( struct glyphinfo glyph,
void raw_outline,
int  datasize,
float  max_deviation_sq,
unsigned int  emsquare,
const struct cos_table cos_table 
)
static

Definition at line 5570 of file mesh.c.

5573 {
5574  TTPOLYGONHEADER *header = (TTPOLYGONHEADER *)raw_outline;
5575 
5576  while ((char *)header < (char *)raw_outline + datasize)
5577  {
5578  TTPOLYCURVE *curve = (TTPOLYCURVE *)(header + 1);
5579  struct point2d *lastpt, *pt;
5580  D3DXVECTOR2 lastdir;
5581  D3DXVECTOR2 *pt_flt;
5582  int j;
5583  struct outline *outline = add_outline(&glyph->outlines);
5584 
5585  if (!outline)
5586  return E_OUTOFMEMORY;
5587 
5588  pt = add_points(outline, 1);
5589  if (!pt)
5590  return E_OUTOFMEMORY;
5591  pt_flt = convert_fixed_to_float(&header->pfxStart, 1, emsquare);
5592  pt->pos = *pt_flt;
5593  pt->corner = POINTTYPE_CORNER;
5594 
5595  if (header->dwType != TT_POLYGON_TYPE)
5596  FIXME("Unknown header type %d\n", header->dwType);
5597 
5598  while ((char *)curve < (char *)header + header->cb)
5599  {
5600  D3DXVECTOR2 bezier_start = outline->items[outline->count - 1].pos;
5601  BOOL to_curve = curve->wType != TT_PRIM_LINE && curve->cpfx > 1;
5602  unsigned int j2 = 0;
5603 
5604  if (!curve->cpfx) {
5605  curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
5606  continue;
5607  }
5608 
5609  pt_flt = convert_fixed_to_float(curve->apfx, curve->cpfx, emsquare);
5610 
5611  attempt_line_merge(outline, outline->count - 1, &pt_flt[0], to_curve, cos_table);
5612 
5613  if (to_curve)
5614  {
5615  HRESULT hr;
5616  int count = curve->cpfx;
5617 
5618  while (count > 2)
5619  {
5620  D3DXVECTOR2 bezier_end;
5621 
5622  D3DXVec2Scale(&bezier_end, D3DXVec2Add(&bezier_end, &pt_flt[j2], &pt_flt[j2+1]), 0.5f);
5623  hr = add_bezier_points(outline, &bezier_start, &pt_flt[j2], &bezier_end, max_deviation_sq);
5624  if (hr != S_OK)
5625  return hr;
5626  bezier_start = bezier_end;
5627  count--;
5628  j2++;
5629  }
5630  hr = add_bezier_points(outline, &bezier_start, &pt_flt[j2], &pt_flt[j2+1], max_deviation_sq);
5631  if (hr != S_OK)
5632  return hr;
5633 
5634  pt = add_points(outline, 1);
5635  if (!pt)
5636  return E_OUTOFMEMORY;
5637  j2++;
5638  pt->pos = pt_flt[j2];
5639  pt->corner = POINTTYPE_CURVE_END;
5640  } else {
5641  pt = add_points(outline, curve->cpfx);
5642  if (!pt)
5643  return E_OUTOFMEMORY;
5644  for (j2 = 0; j2 < curve->cpfx; j2++)
5645  {
5646  pt->pos = pt_flt[j2];
5647  pt->corner = POINTTYPE_CORNER;
5648  pt++;
5649  }
5650  }
5651 
5652  curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
5653  }
5654 
5655  /* remove last point if the next line continues the last line */
5656  if (outline->count >= 3) {
5657  BOOL to_curve;
5658 
5659  lastpt = &outline->items[outline->count - 1];
5660  pt = &outline->items[0];
5661  if (pt->pos.x == lastpt->pos.x && pt->pos.y == lastpt->pos.y) {
5662  if (lastpt->corner == POINTTYPE_CURVE_END)
5663  {
5664  if (pt->corner == POINTTYPE_CURVE_START)
5665  pt->corner = POINTTYPE_CURVE_MIDDLE;
5666  else
5667  pt->corner = POINTTYPE_CURVE_END;
5668  }
5669  outline->count--;
5670  } else {
5671  /* outline closed with a line from end to start point */
5673  }
5674  lastpt = &outline->items[0];
5675  to_curve = lastpt->corner != POINTTYPE_CORNER && lastpt->corner != POINTTYPE_CURVE_END;
5676  if (lastpt->corner == POINTTYPE_CURVE_START)
5677  lastpt->corner = POINTTYPE_CORNER;
5678  pt = &outline->items[1];
5679  if (attempt_line_merge(outline, 0, &pt->pos, to_curve, cos_table))
5680  *lastpt = outline->items[outline->count];
5681  }
5682 
5683  lastpt = &outline->items[outline->count - 1];
5684  pt = &outline->items[0];
5685  unit_vec2(&lastdir, &lastpt->pos, &pt->pos);
5686  for (j = 0; j < outline->count; j++)
5687  {
5688  D3DXVECTOR2 curdir;
5689 
5690  lastpt = pt;
5691  pt = &outline->items[(j + 1) % outline->count];
5692  unit_vec2(&curdir, &lastpt->pos, &pt->pos);
5693 
5694  switch (lastpt->corner)
5695  {
5696  case POINTTYPE_CURVE_START:
5697  case POINTTYPE_CURVE_END:
5698  if (!is_direction_similar(&lastdir, &curdir, cos_table->cos_45))
5699  lastpt->corner = POINTTYPE_CORNER;
5700  break;
5702  if (!is_direction_similar(&lastdir, &curdir, cos_table->cos_90))
5703  lastpt->corner = POINTTYPE_CORNER;
5704  else
5705  lastpt->corner = POINTTYPE_CURVE;
5706  break;
5707  default:
5708  break;
5709  }
5710  lastdir = curdir;
5711  }
5712 
5713  header = (TTPOLYGONHEADER *)((char *)header + header->cb);
5714  }
5715  return S_OK;
5716 }
int count
Definition: mesh.c:5331
HRESULT hr
Definition: shlfolder.c:183
FLOAT y
Definition: d3dx9math.h:64
#define TT_POLYGON_TYPE
Definition: wingdi.h:1317
#define pt(x, y)
Definition: drawing.c:79
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct outline_array outlines
Definition: mesh.c:5362
static struct outline * add_outline(struct outline_array *array)
Definition: mesh.c:5424
enum pointtype corner
Definition: mesh.c:5319
D3DXVECTOR2 pos
Definition: mesh.c:5318
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
static D3DXVECTOR2 * convert_fixed_to_float(POINTFX *pt, int count, unsigned int emsquare)
Definition: mesh.c:5466
static struct point2d * add_points(struct outline *array, int num)
Definition: mesh.c:5412
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLfloat f
Definition: glext.h:7540
if(!(yy_init))
Definition: macro.lex.yy.c:714
POINTFX apfx[1]
Definition: wingdi.h:2709
LONG HRESULT
Definition: typedefs.h:77
FLOAT x
Definition: d3dx9math.h:64
Definition: mesh.c:5316
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:5514
Definition: mesh.c:5329
struct point2d * items
Definition: mesh.c:5332
#define S_OK
Definition: intsafe.h:59
float cos_90
Definition: mesh.c:5523
static HRESULT add_bezier_points(struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation_sq)
Definition: mesh.c:5478
float cos_45
Definition: mesh.c:5522
static BOOL attempt_line_merge(struct outline *outline, int pt_index, const D3DXVECTOR2 *nextpt, BOOL to_curve, const struct cos_table *table)
Definition: mesh.c:5526
#define TT_PRIM_LINE
Definition: wingdi.h:1318
struct CFHEADER header
Definition: fdi.c:109
static BOOL is_direction_similar(D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
Definition: mesh.c:5508

Referenced by D3DXCreateTextW().

◆ d3dx9_mesh_AddRef()

static ULONG WINAPI d3dx9_mesh_AddRef ( ID3DXMesh *  iface)
static

Definition at line 111 of file mesh.c.

112 {
113  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
114  ULONG refcount = InterlockedIncrement(&mesh->ref);
115 
116  TRACE("%p increasing refcount to %u.\n", mesh, refcount);
117 
118  return refcount;
119 }
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
LONG ref
Definition: mesh.c:48
unsigned int ULONG
Definition: retypes.h:1

◆ d3dx9_mesh_CloneMesh()

static HRESULT WINAPI d3dx9_mesh_CloneMesh ( struct ID3DXMesh *  iface,
DWORD  options,
const D3DVERTEXELEMENT9 declaration,
struct IDirect3DDevice9 *  device,
struct ID3DXMesh **  clone_mesh_out 
)
static

Definition at line 677 of file mesh.c.

679 {
680  struct d3dx9_mesh *This = impl_from_ID3DXMesh(iface);
681  struct d3dx9_mesh *cloned_this;
682  ID3DXMesh *clone_mesh;
683  D3DVERTEXELEMENT9 orig_declaration[MAX_FVF_DECL_SIZE] = { D3DDECL_END() };
684  void *data_in, *data_out;
685  DWORD vertex_size;
686  HRESULT hr;
687  BOOL same_declaration;
688 
689  TRACE("iface %p, options %#x, declaration %p, device %p, clone_mesh_out %p.\n",
690  iface, options, declaration, device, clone_mesh_out);
691 
692  if (!clone_mesh_out)
693  return D3DERR_INVALIDCALL;
694 
695  hr = iface->lpVtbl->GetDeclaration(iface, orig_declaration);
696  if (FAILED(hr)) return hr;
697 
698  hr = D3DXCreateMesh(This->numfaces, This->numvertices, options & ~D3DXMESH_VB_SHARE,
699  declaration, device, &clone_mesh);
700  if (FAILED(hr)) return hr;
701 
702  cloned_this = impl_from_ID3DXMesh(clone_mesh);
703  vertex_size = clone_mesh->lpVtbl->GetNumBytesPerVertex(clone_mesh);
704  same_declaration = declaration_equals(declaration, orig_declaration);
705 
706  if (options & D3DXMESH_VB_SHARE) {
707  if (!same_declaration) {
709  goto error;
710  }
711  IDirect3DVertexBuffer9_AddRef(This->vertex_buffer);
712  /* FIXME: refactor to avoid creating a new vertex buffer */
714  cloned_this->vertex_buffer = This->vertex_buffer;
715  } else if (same_declaration) {
716  hr = iface->lpVtbl->LockVertexBuffer(iface, D3DLOCK_READONLY, &data_in);
717  if (FAILED(hr)) goto error;
718  hr = clone_mesh->lpVtbl->LockVertexBuffer(clone_mesh, 0, &data_out);
719  if (FAILED(hr)) {
720  iface->lpVtbl->UnlockVertexBuffer(iface);
721  goto error;
722  }
723  memcpy(data_out, data_in, This->numvertices * vertex_size);
724  clone_mesh->lpVtbl->UnlockVertexBuffer(clone_mesh);
725  iface->lpVtbl->UnlockVertexBuffer(iface);
726  } else {
727  hr = convert_vertex_buffer(clone_mesh, iface);
728  if (FAILED(hr)) goto error;
729  }
730 
731  hr = iface->lpVtbl->LockIndexBuffer(iface, D3DLOCK_READONLY, &data_in);
732  if (FAILED(hr)) goto error;
733  hr = clone_mesh->lpVtbl->LockIndexBuffer(clone_mesh, 0, &data_out);
734  if (FAILED(hr)) {
735  iface->lpVtbl->UnlockIndexBuffer(iface);
736  goto error;
737  }
738  if ((options ^ This->options) & D3DXMESH_32BIT) {
739  DWORD i;
740  if (options & D3DXMESH_32BIT) {
741  for (i = 0; i < This->numfaces * 3; i++)
742  ((DWORD*)data_out)[i] = ((WORD*)data_in)[i];
743  } else {
744  for (i = 0; i < This->numfaces * 3; i++)
745  ((WORD*)data_out)[i] = ((DWORD*)data_in)[i];
746  }
747  } else {
748  memcpy(data_out, data_in, This->numfaces * 3 * (options & D3DXMESH_32BIT ? 4 : 2));
749  }
750  clone_mesh->lpVtbl->UnlockIndexBuffer(clone_mesh);
751  iface->lpVtbl->UnlockIndexBuffer(iface);
752 
753  memcpy(cloned_this->attrib_buffer, This->attrib_buffer, This->numfaces * sizeof(*This->attrib_buffer));
754 
755  if (This->attrib_table_size)
756  {
757  cloned_this->attrib_table_size = This->attrib_table_size;
758  cloned_this->attrib_table = HeapAlloc(GetProcessHeap(), 0, This->attrib_table_size * sizeof(*This->attrib_table));
759  if (!cloned_this->attrib_table) {
760  hr = E_OUTOFMEMORY;
761  goto error;
762  }
763  memcpy(cloned_this->attrib_table, This->attrib_table, This->attrib_table_size * sizeof(*This->attrib_table));
764  }
765 
766  *clone_mesh_out = clone_mesh;
767 
768  return D3D_OK;
769 error:
770  IUnknown_Release(clone_mesh);
771  return hr;
772 }
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
D3DXATTRIBUTERANGE * attrib_table
Definition: mesh.c:64
#define D3DERR_INVALIDCALL
static BOOL declaration_equals(const D3DVERTEXELEMENT9 *declaration1, const D3DVERTEXELEMENT9 *declaration2)
Definition: mesh.c:658
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define IDirect3DVertexBuffer9_AddRef(p)
Definition: d3d9.h:695
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
IDirect3DVertexBuffer9 * vertex_buffer
Definition: mesh.c:59
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirect3DVertexBuffer9_Release(p)
Definition: d3d9.h:696
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD * attrib_buffer
Definition: mesh.c:61
#define D3DDECL_END()
Definition: d3d9types.h:311
HRESULT WINAPI D3DXCreateMesh(DWORD numfaces, DWORD numvertices, DWORD options, const D3DVERTEXELEMENT9 *declaration, struct IDirect3DDevice9 *device, struct ID3DXMesh **mesh)
Definition: mesh.c:2433
#define D3D_OK
Definition: d3d.h:106
static HRESULT convert_vertex_buffer(ID3DXMesh *mesh_dst, ID3DXMesh *mesh_src)
Definition: mesh.c:604
DWORD attrib_table_size
Definition: mesh.c:63
#define D3DLOCK_READONLY
Definition: d3d8types.h:69

◆ d3dx9_mesh_CloneMeshFVF()

static HRESULT WINAPI d3dx9_mesh_CloneMeshFVF ( struct ID3DXMesh *  iface,
DWORD  options,
DWORD  fvf,
struct IDirect3DDevice9 *  device,
struct ID3DXMesh **  clone_mesh 
)
static

Definition at line 269 of file mesh.c.

271 {
272  HRESULT hr;
274 
275  TRACE("iface %p, options %#x, fvf %#x, device %p, clone_mesh %p.\n",
276  iface, options, fvf, device, clone_mesh);
277 
279  return hr;
280 
281  return iface->lpVtbl->CloneMesh(iface, options, declaration, device, clone_mesh);
282 }
HRESULT hr
Definition: shlfolder.c:183
DWORD fvf
Definition: mesh.c:53
Definition: devices.h:37
HRESULT WINAPI D3DXDeclaratorFromFVF(DWORD fvf, D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
Definition: mesh.c:2037
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77

◆ d3dx9_mesh_ConvertAdjacencyToPointReps()

static HRESULT WINAPI d3dx9_mesh_ConvertAdjacencyToPointReps ( ID3DXMesh *  iface,
const DWORD adjacency,
DWORD point_reps 
)
static

Definition at line 1103 of file mesh.c.

1105 {
1106  struct d3dx9_mesh *This = impl_from_ID3DXMesh(iface);
1107  HRESULT hr;
1108  DWORD face;
1109  DWORD i;
1110  DWORD *indices = NULL;
1111  WORD *indices_16bit = NULL;
1112  DWORD *new_indices = NULL;
1113  const unsigned int VERTS_PER_FACE = 3;
1114 
1115  TRACE("iface %p, adjacency %p, point_reps %p.\n", iface, adjacency, point_reps);
1116 
1117  if (!adjacency)
1118  {
1119  WARN("NULL adjacency.\n");
1121  goto cleanup;
1122  }
1123 
1124  if (!point_reps)
1125  {
1126  WARN("NULL point_reps.\n");
1128  goto cleanup;
1129  }
1130 
1131  /* Should never happen as CreateMesh does not allow meshes with 0 faces */
1132  if (This->numfaces == 0)
1133  {
1134  ERR("Number of faces was zero.\n");
1136  goto cleanup;
1137  }
1138 
1139  new_indices = HeapAlloc(GetProcessHeap(), 0, VERTS_PER_FACE * This->numfaces * sizeof(*indices));
1140  if (!new_indices)
1141  {
1142  hr = E_OUTOFMEMORY;
1143  goto cleanup;
1144  }
1145 
1146  if (This->options & D3DXMESH_32BIT)
1147  {
1148  hr = iface->lpVtbl->LockIndexBuffer(iface, D3DLOCK_READONLY, (void**)&indices);
1149  if (FAILED(hr)) goto cleanup;
1150  memcpy(new_indices, indices, VERTS_PER_FACE * This->numfaces * sizeof(*indices));
1151  }
1152  else
1153  {
1154  /* Make a widening copy of indices_16bit into indices and new_indices
1155  * in order to re-use the helper function */
1156  hr = iface->lpVtbl->LockIndexBuffer(iface, D3DLOCK_READONLY, (void**)&indices_16bit);
1157  if (FAILED(hr)) goto cleanup;
1158  indices = HeapAlloc(GetProcessHeap(), 0, VERTS_PER_FACE * This->numfaces * sizeof(*indices));
1159  if (!indices)
1160  {
1161  hr = E_OUTOFMEMORY;
1162  goto cleanup;
1163  }
1164  for (i = 0; i < VERTS_PER_FACE * This->numfaces; i++)
1165  {
1166  new_indices[i] = indices_16bit[i];
1167  indices[i] = indices_16bit[i];
1168  }
1169  }
1170 
1171  /* Vertices are ordered sequentially in the point representation. */
1172  for (i = 0; i < This->numvertices; i++)
1173  {
1174  point_reps[i] = i;
1175  }
1176 
1177  /* Propagate vertices with low indices so as few vertices as possible
1178  * are used in the mesh.
1179  */
1180  for (face = 0; face < This->numfaces; face++)
1181  {
1182  hr = propagate_face_vertices(adjacency, point_reps, indices, new_indices, face, This->numfaces);
1183  if (FAILED(hr)) goto cleanup;
1184  }
1185  /* Go in opposite direction to catch all face orderings */
1186  for (face = 0; face < This->numfaces; face++)
1187  {
1188  hr = propagate_face_vertices(adjacency, point_reps,
1189  indices, new_indices,
1190  (This->numfaces - 1) - face, This->numfaces);
1191  if (FAILED(hr)) goto cleanup;
1192  }
1193 
1194  hr = D3D_OK;
1195 cleanup:
1196  if (This->options & D3DXMESH_32BIT)
1197  {
1198  if (indices) iface->lpVtbl->UnlockIndexBuffer(iface);
1199  }
1200  else
1201  {
1202  if (indices_16bit) iface->lpVtbl->UnlockIndexBuffer(iface);
1204  }
1205  HeapFree(GetProcessHeap(), 0, new_indices);
1206  return hr;
1207 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
#define D3DERR_INVALIDCALL
WORD face[3]
Definition: mesh.c:4747
static HRESULT propagate_face_vertices(const DWORD *adjacency, DWORD *point_reps, const DWORD *indices, DWORD *new_indices, DWORD face, DWORD numfaces)
Definition: mesh.c:1054
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
#define D3D_OK
Definition: d3d.h:106
char * cleanup(char *str)
Definition: wpickclick.c:99
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define HeapFree(x, y, z)
Definition: compat.h:394
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ d3dx9_mesh_ConvertPointRepsToAdjacency()

static HRESULT WINAPI d3dx9_mesh_ConvertPointRepsToAdjacency ( ID3DXMesh *  iface,
const DWORD point_reps,
DWORD adjacency 
)
static

Definition at line 953 of file mesh.c.

955 {
956  HRESULT hr;
957  DWORD num_faces = iface->lpVtbl->GetNumFaces(iface);
958  DWORD num_vertices = iface->lpVtbl->GetNumVertices(iface);
959  DWORD options = iface->lpVtbl->GetOptions(iface);
960  BOOL indices_are_16_bit = !(options & D3DXMESH_32BIT);
961  DWORD *ib = NULL;
962  void *ib_ptr = NULL;
963  DWORD face;
964  DWORD edge;
965  struct edge_face_map edge_face_map = {0};
966  const DWORD *point_reps_ptr = NULL;
967  DWORD *id_point_reps = NULL;
968 
969  TRACE("iface %p, point_reps %p, adjacency %p.\n", iface, point_reps, adjacency);
970 
971  if (!adjacency) return D3DERR_INVALIDCALL;
972 
973  if (!point_reps) /* Identity point reps */
974  {
975  id_point_reps = generate_identity_point_reps(num_vertices);
976  if (!id_point_reps)
977  {
978  hr = E_OUTOFMEMORY;
979  goto cleanup;
980  }
981 
982  point_reps_ptr = id_point_reps;
983  }
984  else
985  {
986  point_reps_ptr = point_reps;
987  }
988 
989  hr = iface->lpVtbl->LockIndexBuffer(iface, D3DLOCK_READONLY, &ib_ptr);
990  if (FAILED(hr)) goto cleanup;
991 
992  if (indices_are_16_bit)
993  {
994  /* Widen 16 bit to 32 bit */
995  DWORD i;
996  WORD *ib_16bit = ib_ptr;
997  ib = HeapAlloc(GetProcessHeap(), 0, 3 * num_faces * sizeof(DWORD));
998  if (!ib)
999  {
1000  hr = E_OUTOFMEMORY;
1001  goto cleanup;
1002  }
1003  for (i = 0; i < 3 * num_faces; i++)
1004  {
1005  ib[i] = ib_16bit[i];
1006  }
1007  }
1008  else
1009  {
1010  ib = ib_ptr;
1011  }
1012 
1013  hr = init_edge_face_map(&edge_face_map, ib, point_reps_ptr, num_faces);
1014  if (FAILED(hr)) goto cleanup;
1015 
1016  /* Create adjacency */
1017  for (face = 0; face < num_faces; face++)
1018  {
1019  for (edge = 0; edge < 3; edge++)
1020  {
1021  DWORD v1 = ib[3*face + edge];
1022  DWORD v2 = ib[3*face + (edge+1)%3];
1023  DWORD new_v1 = point_reps_ptr[v1];
1024  DWORD new_v2 = point_reps_ptr[v2];
1025  DWORD adj_face;
1026 
1027  adj_face = find_adjacent_face(&edge_face_map, new_v1, new_v2, num_faces);
1028  adjacency[3*face + edge] = adj_face;
1029  }
1030  }
1031 
1032  hr = D3D_OK;
1033 cleanup:
1034  HeapFree(GetProcessHeap(), 0, id_point_reps);
1035  if (indices_are_16_bit) HeapFree(GetProcessHeap(), 0, ib);
1038  if(ib_ptr) iface->lpVtbl->UnlockIndexBuffer(iface);
1039  return hr;
1040 }
static HRESULT init_edge_face_map(struct edge_face_map *edge_face_map, const DWORD *index_buffer, const DWORD *point_reps, DWORD num_faces)
Definition: mesh.c:882
struct list * lists
Definition: mesh.c:868
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
WORD face[3]
Definition: mesh.c:4747
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD find_adjacent_face(struct edge_face_map *edge_face_map, DWORD vertex1, DWORD vertex2, DWORD num_faces)
Definition: mesh.c:923
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
#define D3D_OK
Definition: d3d.h:106
struct edge_face * entries
Definition: mesh.c:869
char * cleanup(char *str)
Definition: wpickclick.c:99
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
GLfloat GLfloat v1
Definition: glext.h:6062
static DWORD * generate_identity_point_reps(DWORD num_vertices)
Definition: mesh.c:936
#define HeapFree(x, y, z)
Definition: compat.h:394
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ d3dx9_mesh_DrawSubset()

static HRESULT WINAPI d3dx9_mesh_DrawSubset ( ID3DXMesh *  iface,
DWORD  attrib_id 
)
static

Definition at line 143 of file mesh.c.

144 {
145  struct d3dx9_mesh *This = impl_from_ID3DXMesh(iface);
146  HRESULT hr;
147  DWORD face_start;
148  DWORD face_end = 0;
149  DWORD vertex_size;
150 
151  TRACE("iface %p, attrib_id %u.\n", iface, attrib_id);
152 
153  if (!This->vertex_declaration)
154  {
155  WARN("Can't draw a mesh with an invalid vertex declaration.\n");
156  return E_FAIL;
157  }
158 
159  vertex_size = iface->lpVtbl->GetNumBytesPerVertex(iface);
160 
161  hr = IDirect3DDevice9_SetVertexDeclaration(This->device, This->vertex_declaration);
162  if (FAILED(hr)) return hr;
163  hr = IDirect3DDevice9_SetStreamSource(This->device, 0, This->vertex_buffer, 0, vertex_size);
164  if (FAILED(hr)) return hr;
165  hr = IDirect3DDevice9_SetIndices(This->device, This->index_buffer);
166  if (FAILED(hr)) return hr;
167 
168  while (face_end < This->numfaces)
169  {
170  for (face_start = face_end; face_start < This->numfaces; face_start++)
171  {
172  if (This->attrib_buffer[face_start] == attrib_id)
173  break;
174  }
175  if (face_start >= This->numfaces)
176  break;
177  for (face_end = face_start + 1; face_end < This->numfaces; face_end++)
178  {
179  if (This->attrib_buffer[face_end] != attrib_id)
180  break;
181  }
182 
184  0, 0, This->numvertices, face_start * 3, face_end - face_start);
185  if (FAILED(hr)) return hr;
186  }
187 
188  return D3D_OK;
189 }
DWORD numfaces
Definition: mesh.c:50
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DDevice9_DrawIndexedPrimitive(p, a, b, c, d, e, f)
Definition: d3d9.h:1589
#define WARN(fmt,...)
Definition: debug.h:111
#define E_FAIL
Definition: ddrawi.h:102
#define IDirect3DDevice9_SetStreamSource(p, a, b, c, d)
Definition: d3d9.h:1607
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_SetIndices(p, a)
Definition: d3d9.h:1611
#define IDirect3DDevice9_SetVertexDeclaration(p, a)
Definition: d3d9.h:1594

◆ d3dx9_mesh_GenerateAdjacency()

static HRESULT WINAPI d3dx9_mesh_GenerateAdjacency ( ID3DXMesh *  iface,
float  epsilon,
DWORD adjacency 
)
static

Definition at line 1224 of file mesh.c.

1225 {
1226  struct d3dx9_mesh *This = impl_from_ID3DXMesh(iface);
1227  HRESULT hr;
1228  BYTE *vertices = NULL;
1229  const DWORD *indices = NULL;
1230  DWORD vertex_size;
1232  /* sort the vertices by (x + y + z) to quickly find coincident vertices */
1233  struct vertex_metadata *sorted_vertices;
1234  /* shared_indices links together identical indices in the index buffer so
1235  * that adjacency checks can be limited to faces sharing a vertex */
1236  DWORD *shared_indices = NULL;
1237  const FLOAT epsilon_sq = epsilon * epsilon;
1238  DWORD i;
1239 
1240  TRACE("iface %p, epsilon %.8e, adjacency %p.\n", iface, epsilon, adjacency);
1241 
1242  if (!adjacency)
1243  return D3DERR_INVALIDCALL;
1244 
1245  buffer_size = This->numfaces * 3 * sizeof(*shared_indices) + This->numvertices * sizeof(*sorted_vertices);
1246  if (!(This->options & D3DXMESH_32BIT))
1247  buffer_size += This->numfaces * 3 * sizeof(*indices);
1248  shared_indices = HeapAlloc(GetProcessHeap(), 0, buffer_size);
1249  if (!shared_indices)
1250  return E_OUTOFMEMORY;
1251  sorted_vertices = (struct vertex_metadata*)(shared_indices + This->numfaces * 3);
1252 
1253  hr = iface->lpVtbl->LockVertexBuffer(iface, D3DLOCK_READONLY, (void**)&vertices);
1254  if (FAILED(hr)) goto cleanup;
1255  hr = iface->lpVtbl->LockIndexBuffer(iface, D3DLOCK_READONLY, (void**)&indices);
1256  if (FAILED(hr)) goto cleanup;
1257 
1258  if (!(This->options & D3DXMESH_32BIT)) {
1259  const WORD *word_indices = (const WORD*)indices;
1260  DWORD *dword_indices = (DWORD*)(sorted_vertices + This->numvertices);
1261  indices = dword_indices;
1262  for (i = 0; i < This->numfaces * 3; i++)
1263  *dword_indices++ = *word_indices++;
1264  }
1265 
1266  vertex_size = iface->lpVtbl->GetNumBytesPerVertex(iface);
1267  for (i = 0; i < This->numvertices; i++) {
1268  D3DXVECTOR3 *vertex = (D3DXVECTOR3*)(vertices + vertex_size * i);
1269  sorted_vertices[i].first_shared_index = -1;
1270  sorted_vertices[i].key = vertex->x + vertex->y + vertex->z;
1271  sorted_vertices[i].vertex_index = i;
1272  }
1273  for (i = 0; i < This->numfaces * 3; i++) {
1274  DWORD *first_shared_index = &sorted_vertices[indices[i]].first_shared_index;
1275  shared_indices[i] = *first_shared_index;
1276  *first_shared_index = i;
1277  adjacency[i] = -1;
1278  }
1279  qsort(sorted_vertices, This->numvertices, sizeof(*sorted_vertices), compare_vertex_keys);
1280 
1281  for (i = 0; i < This->numvertices; i++) {
1282  struct vertex_metadata *sorted_vertex_a = &sorted_vertices[i];
1283  D3DXVECTOR3 *vertex_a = (D3DXVECTOR3*)(vertices + sorted_vertex_a->vertex_index * vertex_size);
1284  DWORD shared_index_a = sorted_vertex_a->first_shared_index;
1285 
1286  while (shared_index_a != -1) {
1287  DWORD j = i;
1288  DWORD shared_index_b = shared_indices[shared_index_a];
1289  struct vertex_metadata *sorted_vertex_b = sorted_vertex_a;
1290 
1291  while (TRUE) {
1292  while (shared_index_b != -1) {
1293  /* faces are adjacent if they have another coincident vertex */
1294  DWORD base_a = (shared_index_a / 3) * 3;
1295  DWORD base_b = (shared_index_b / 3) * 3;
1296  BOOL adjacent = FALSE;
1297  int k;
1298 
1299  for (k = 0; k < 3; k++) {
1300  if (adjacency[base_b + k] == shared_index_a / 3) {
1301  adjacent = TRUE;
1302  break;
1303  }
1304  }
1305  if (!adjacent) {
1306  for (k = 1; k <= 2; k++) {
1307  DWORD vertex_index_a = base_a + (shared_index_a + k) % 3;
1308  DWORD vertex_index_b = base_b + (shared_index_b + (3 - k)) % 3;
1309  adjacent = indices[vertex_index_a] == indices[vertex_index_b];
1310  if (!adjacent && epsilon >= 0.0f) {
1311  D3DXVECTOR3 delta = {0.0f, 0.0f, 0.0f};
1312  FLOAT length_sq;
1313 
1314  D3DXVec3Subtract(&delta,
1315  (D3DXVECTOR3*)(vertices + indices[vertex_index_a] * vertex_size),
1316  (D3DXVECTOR3*)(vertices + indices[vertex_index_b] * vertex_size));
1317  length_sq = D3DXVec3LengthSq(&delta);
1318  adjacent = epsilon == 0.0f ? length_sq == 0.0f : length_sq < epsilon_sq;
1319  }
1320  if (adjacent) {
1321  DWORD adj_a = base_a + 2 - (vertex_index_a + shared_index_a + 1) % 3;
1322  DWORD adj_b = base_b + 2 - (vertex_index_b + shared_index_b + 1) % 3;
1323  if (adjacency[adj_a] == -1 && adjacency[adj_b] == -1) {
1324  adjacency[adj_a] = base_b / 3;
1325  adjacency[adj_b] = base_a / 3;
1326  break;
1327  }
1328  }
1329  }
1330  }
1331 
1332  shared_index_b = shared_indices[shared_index_b];
1333  }
1334  while (++j < This->numvertices) {
1335  D3DXVECTOR3 *vertex_b;
1336 
1337  sorted_vertex_b++;
1338  if (sorted_vertex_b->key - sorted_vertex_a->key > epsilon * 3.0f) {
1339  /* no more coincident vertices to try */
1340  j = This->numvertices;
1341  break;
1342  }
1343  /* check for coincidence */
1344  vertex_b = (D3DXVECTOR3*)(vertices + sorted_vertex_b->vertex_index * vertex_size);
1345  if (fabsf(vertex_a->x - vertex_b->x) <= epsilon &&
1346  fabsf(vertex_a->y - vertex_b->y) <= epsilon &&
1347  fabsf(vertex_a->z - vertex_b->z) <= epsilon)
1348  {
1349  break;
1350  }
1351  }
1352  if (j >= This->numvertices)
1353  break;
1354  shared_index_b = sorted_vertex_b->first_shared_index;
1355  }
1356 
1357  sorted_vertex_a->first_shared_index = shared_indices[sorted_vertex_a->first_shared_index];
1358  shared_index_a = sorted_vertex_a->first_shared_index;
1359  }
1360  }
1361 
1362  hr = D3D_OK;
1363 cleanup:
1364  if (indices) iface->lpVtbl->UnlockIndexBuffer(iface);
1365  if (vertices) iface->lpVtbl->UnlockVertexBuffer(iface);
1366  HeapFree(GetProcessHeap(), 0, shared_indices);
1367  return hr;
1368 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
Definition: mesh.c:4557
HRESULT hr
Definition: shlfolder.c:183
float key
Definition: mesh.c:1210
#define D3DERR_INVALIDCALL
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
smooth NULL
Definition: ftsmooth.c:416
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD vertex_index
Definition: mesh.c:1211
unsigned char BYTE
Definition: mem.h:68
DWORD first_shared_index
Definition: mesh.c:1212
#define D3D_OK
Definition: d3d.h:106
float FLOAT
Definition: typedefs.h:67
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
Definition: math.h:164
char * cleanup(char *str)
Definition: wpickclick.c:99
#define TRUE
Definition: mesh.c:42
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
int k
Definition: mpi.c:3369
#define HeapFree(x, y, z)
Definition: compat.h:394
static int compare_vertex_keys(const void *a, const void *b)
Definition: mesh.c:1215

◆ d3dx9_mesh_GetAttributeTable()

static HRESULT WINAPI d3dx9_mesh_GetAttributeTable ( ID3DXMesh *  iface,
D3DXATTRIBUTERANGE attrib_table,
DWORD attrib_table_size 
)
static

Definition at line 842 of file mesh.c.

844 {
845  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
846 
847  TRACE("iface %p, attrib_table %p, attrib_table_size %p.\n",
849 
850  if (attrib_table_size)
852 
853  if (attrib_table)
855 
856  return D3D_OK;
857 }
D3DXATTRIBUTERANGE * attrib_table
Definition: mesh.c:64
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define D3D_OK
Definition: d3d.h:106
DWORD attrib_table_size
Definition: mesh.c:63

◆ d3dx9_mesh_GetDeclaration()

static HRESULT WINAPI d3dx9_mesh_GetDeclaration ( ID3DXMesh *  iface,
D3DVERTEXELEMENT9  declaration[MAX_FVF_DECL_SIZE] 
)
static

Definition at line 223 of file mesh.c.

224 {
225  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
226 
227  TRACE("iface %p, declaration %p.\n", iface, declaration);
228 
229  if (!declaration)
230  return D3DERR_INVALIDCALL;
231 
233 
234  return D3D_OK;
235 }
#define D3DERR_INVALIDCALL
static void copy_declaration(D3DVERTEXELEMENT9 *dst, const D3DVERTEXELEMENT9 *src, UINT num_elem)
Definition: mesh.c:218
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
UINT num_elem
Definition: mesh.c:58
D3DVERTEXELEMENT9 cached_declaration[MAX_FVF_DECL_SIZE]
Definition: mesh.c:55
#define D3D_OK
Definition: d3d.h:106

◆ d3dx9_mesh_GetDevice()

static HRESULT WINAPI d3dx9_mesh_GetDevice ( struct ID3DXMesh *  iface,
struct IDirect3DDevice9 **  device 
)
static

Definition at line 255 of file mesh.c.

256 {
257  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
258 
259  TRACE("iface %p, device %p.\n", iface, device);
260 
261  if (!device)
262  return D3DERR_INVALIDCALL;
263  *device = mesh->device;
265 
266  return D3D_OK;
267 }
#define D3DERR_INVALIDCALL
Definition: devices.h:37
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
IDirect3DDevice9 * device
Definition: mesh.c:54
#define D3D_OK
Definition: d3d.h:106

◆ d3dx9_mesh_GetFVF()

static DWORD WINAPI d3dx9_mesh_GetFVF ( ID3DXMesh *  iface)
static

Definition at line 209 of file mesh.c.

210 {
211  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
212 
213  TRACE("iface %p.\n", iface);
214 
215  return mesh->fvf;
216 }
DWORD fvf
Definition: mesh.c:53
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4

◆ d3dx9_mesh_GetIndexBuffer()

static HRESULT WINAPI d3dx9_mesh_GetIndexBuffer ( struct ID3DXMesh *  iface,
struct IDirect3DIndexBuffer9 **  index_buffer 
)
static

Definition at line 789 of file mesh.c.

791 {
792  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
793 
794  TRACE("iface %p, index_buffer %p.\n", iface, index_buffer);
795 
796  if (!index_buffer)
797  return D3DERR_INVALIDCALL;
798  *index_buffer = mesh->index_buffer;
800 
801  return D3D_OK;
802 }
#define D3DERR_INVALIDCALL
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define D3D_OK
Definition: d3d.h:106
IDirect3DIndexBuffer9 * index_buffer
Definition: mesh.c:60
#define IDirect3DIndexBuffer9_AddRef(p)
Definition: d3d9.h:763

◆ d3dx9_mesh_GetNumBytesPerVertex()

static DWORD WINAPI d3dx9_mesh_GetNumBytesPerVertex ( ID3DXMesh *  iface)
static

Definition at line 237 of file mesh.c.

238 {
239  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
240 
241  TRACE("iface %p.\n", iface);
242 
243  return mesh->vertex_declaration_size;
244 }
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
UINT vertex_declaration_size
Definition: mesh.c:57

◆ d3dx9_mesh_GetNumFaces()

static DWORD WINAPI d3dx9_mesh_GetNumFaces ( ID3DXMesh *  iface)
static

Definition at line 191 of file mesh.c.

192 {
193  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
194 
195  TRACE("iface %p.\n", iface);
196 
197  return mesh->numfaces;
198 }
DWORD numfaces
Definition: mesh.c:50
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4

◆ d3dx9_mesh_GetNumVertices()

static DWORD WINAPI d3dx9_mesh_GetNumVertices ( ID3DXMesh *  iface)
static

Definition at line 200 of file mesh.c.

201 {
202  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
203 
204  TRACE("iface %p.\n", iface);
205 
206  return mesh->numvertices;
207 }
DWORD numvertices
Definition: mesh.c:51
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4

◆ d3dx9_mesh_GetOptions()

static DWORD WINAPI d3dx9_mesh_GetOptions ( ID3DXMesh *  iface)
static

Definition at line 246 of file mesh.c.

247 {
248  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
249 
250  TRACE("iface %p.\n", iface);
251 
252  return mesh->options;
253 }
DWORD options
Definition: mesh.c:52
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4

◆ d3dx9_mesh_GetVertexBuffer()

static HRESULT WINAPI d3dx9_mesh_GetVertexBuffer ( struct ID3DXMesh *  iface,
struct IDirect3DVertexBuffer9 **  vertex_buffer 
)
static

Definition at line 774 of file mesh.c.

776 {
777  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
778 
779  TRACE("iface %p, vertex_buffer %p.\n", iface, vertex_buffer);
780 
781  if (!vertex_buffer)
782  return D3DERR_INVALIDCALL;
783  *vertex_buffer = mesh->vertex_buffer;
785 
786  return D3D_OK;
787 }
#define D3DERR_INVALIDCALL
#define IDirect3DVertexBuffer9_AddRef(p)
Definition: d3d9.h:695
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
IDirect3DVertexBuffer9 * vertex_buffer
Definition: mesh.c:59
#define D3D_OK
Definition: d3d.h:106

◆ d3dx9_mesh_LockAttributeBuffer()

static HRESULT WINAPI d3dx9_mesh_LockAttributeBuffer ( ID3DXMesh *  iface,
DWORD  flags,
DWORD **  data 
)
static

Definition at line 1429 of file mesh.c.

1430 {
1431  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
1432 
1433  TRACE("iface %p, flags %#x, data %p.\n", iface, flags, data);
1434 
1436 
1437  if (!(flags & D3DLOCK_READONLY))
1438  {
1440  mesh->attrib_table_size = 0;
1441  mesh->attrib_table = NULL;
1443  }
1444 
1445  *data = mesh->attrib_buffer;
1446 
1447  return D3D_OK;
1448 }
D3DXATTRIBUTERANGE * attrib_table
Definition: mesh.c:64
smooth NULL
Definition: ftsmooth.c:416
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
DWORD * attrib_buffer
Definition: mesh.c:61
int attrib_buffer_lock_count
Definition: mesh.c:62
#define D3D_OK
Definition: d3d.h:106
#define InterlockedIncrement
Definition: armddk.h:53
DWORD attrib_table_size
Definition: mesh.c:63
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ d3dx9_mesh_LockIndexBuffer()

static HRESULT WINAPI d3dx9_mesh_LockIndexBuffer ( ID3DXMesh *  iface,
DWORD  flags,
void **  data 
)
static

Definition at line 822 of file mesh.c.

823 {
824  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
825 
826  TRACE("iface %p, flags %#x, data %p.\n", iface, flags, data);
827 
828  return IDirect3DIndexBuffer9_Lock(mesh->index_buffer, 0, 0, data, flags);
829 }
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define IDirect3DIndexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:775
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
IDirect3DIndexBuffer9 * index_buffer
Definition: mesh.c:60

◆ d3dx9_mesh_LockVertexBuffer()

static HRESULT WINAPI d3dx9_mesh_LockVertexBuffer ( ID3DXMesh *  iface,
DWORD  flags,
void **  data 
)
static

Definition at line 804 of file mesh.c.

805 {
806  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
807 
808  TRACE("iface %p, flags %#x, data %p.\n", iface, flags, data);
809 
810  return IDirect3DVertexBuffer9_Lock(mesh->vertex_buffer, 0, 0, data, flags);
811 }
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
IDirect3DVertexBuffer9 * vertex_buffer
Definition: mesh.c:59
#define IDirect3DVertexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:707
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161

◆ d3dx9_mesh_Optimize()

static HRESULT WINAPI d3dx9_mesh_Optimize ( ID3DXMesh *  iface,
DWORD  flags,
const DWORD adjacency_in,
DWORD adjacency_out,
DWORD face_remap,
ID3DXBuffer **  vertex_remap,
ID3DXMesh **  opt_mesh 
)
static

Definition at line 1467 of file mesh.c.

1469 {
1470  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
1471  HRESULT hr;
1473  ID3DXMesh *optimized_mesh;
1474 
1475  TRACE("iface %p, flags %#x, adjacency_in %p, adjacency_out %p, face_remap %p, vertex_remap %p, opt_mesh %p.\n",
1476  iface, flags, adjacency_in, adjacency_out, face_remap, vertex_remap, opt_mesh);
1477 
1478  if (!opt_mesh)
1479  return D3DERR_INVALIDCALL;
1480 
1481  hr = iface->lpVtbl->GetDeclaration(iface, declaration);
1482  if (FAILED(hr)) return hr;
1483 
1484  if (FAILED(hr = iface->lpVtbl->CloneMesh(iface, mesh->options, declaration, mesh->device, &optimized_mesh)))
1485  return hr;
1486 
1487  hr = optimized_mesh->lpVtbl->OptimizeInplace(optimized_mesh, flags, adjacency_in, adjacency_out, face_remap, vertex_remap);
1488  if (SUCCEEDED(hr))
1489  *opt_mesh = optimized_mesh;
1490  else
1491  IUnknown_Release(optimized_mesh);
1492  return hr;
1493 }
DWORD options
Definition: mesh.c:52
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
#define D3DDECL_END()
Definition: d3d9types.h:311
IDirect3DDevice9 * device
Definition: mesh.c:54
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ d3dx9_mesh_OptimizeInplace()

static HRESULT WINAPI d3dx9_mesh_OptimizeInplace ( ID3DXMesh *  iface,
DWORD  flags,
const DWORD adjacency_in,
DWORD adjacency_out,
DWORD face_remap_out,
ID3DXBuffer **  vertex_remap_out 
)
static

Definition at line 1643 of file mesh.c.

1645 {
1646  struct d3dx9_mesh *This = impl_from_ID3DXMesh(iface);
1647  void *indices = NULL;
1649  HRESULT hr;
1650  ID3DXBuffer *vertex_remap = NULL;
1651  DWORD *face_remap = NULL; /* old -> new mapping */
1652  DWORD *dword_indices = NULL;
1653  DWORD new_num_vertices = 0;
1654  DWORD new_num_alloc_vertices = 0;
1655  IDirect3DVertexBuffer9 *vertex_buffer = NULL;
1656  DWORD *sorted_attrib_buffer = NULL;
1657  DWORD i;
1658 
1659  TRACE("iface %p, flags %#x, adjacency_in %p, adjacency_out %p, face_remap_out %p, vertex_remap_out %p.\n",
1660  iface, flags, adjacency_in, adjacency_out, face_remap_out, vertex_remap_out);
1661 
1662  if (!flags)
1663  return D3DERR_INVALIDCALL;
1664  if (!adjacency_in && (flags & (D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_STRIPREORDER)))
1665  return D3DERR_INVALIDCALL;
1667  return D3DERR_INVALIDCALL;
1668 
1670  {
1672  FIXME("D3DXMESHOPT_VERTEXCACHE not implemented.\n");
1674  FIXME("D3DXMESHOPT_STRIPREORDER not implemented.\n");
1675  return E_NOTIMPL;
1676  }
1677 
1678  hr = iface->lpVtbl->LockIndexBuffer(iface, 0, &indices);
1679  if (FAILED(hr)) goto cleanup;
1680 
1681  dword_indices = HeapAlloc(GetProcessHeap(), 0, This->numfaces * 3 * sizeof(DWORD));
1682  if (!dword_indices) return E_OUTOFMEMORY;
1683  if (This->options & D3DXMESH_32BIT) {
1684  memcpy(dword_indices, indices, This->numfaces * 3 * sizeof(DWORD));
1685  } else {
1686  WORD *word_indices = indices;
1687  for (i = 0; i < This->numfaces * 3; i++)
1688  dword_indices[i] = *word_indices++;
1689  }
1690 
1692  {
1693  new_num_alloc_vertices = This->numvertices;
1694  hr = compact_mesh(This, dword_indices, &new_num_vertices, &vertex_remap);
1695  if (FAILED(hr)) goto cleanup;
1696  } else if (flags & D3DXMESHOPT_ATTRSORT) {
1697  if (!(flags & D3DXMESHOPT_IGNOREVERTS))
1698  FIXME("D3DXMESHOPT_ATTRSORT vertex reordering not implemented.\n");
1699 
1700  hr = iface->lpVtbl->LockAttributeBuffer(iface, 0, &attrib_buffer);
1701  if (FAILED(hr)) goto cleanup;
1702 
1703  hr = remap_faces_for_attrsort(This, dword_indices, attrib_buffer, &sorted_attrib_buffer, &face_remap);
1704  if (FAILED(hr)) goto cleanup;
1705  }
1706 
1707  if (vertex_remap)
1708  {
1709  /* reorder the vertices using vertex_remap */
1710  D3DVERTEXBUFFER_DESC vertex_desc;
1711  DWORD *vertex_remap_ptr = ID3DXBuffer_GetBufferPointer(vertex_remap);
1712  DWORD vertex_size = iface->lpVtbl->GetNumBytesPerVertex(iface);
1713  BYTE *orig_vertices;
1714  BYTE *new_vertices;
1715 
1716  hr = IDirect3DVertexBuffer9_GetDesc(This->vertex_buffer, &vertex_desc);
1717  if (FAILED(hr)) goto cleanup;
1718 
1719  hr = IDirect3DDevice9_CreateVertexBuffer(This->device, new_num_alloc_vertices * vertex_size,
1720  vertex_desc.Usage, This->fvf, vertex_desc.Pool, &vertex_buffer, NULL);
1721  if (FAILED(hr)) goto cleanup;
1722 
1723  hr = IDirect3DVertexBuffer9_Lock(This->vertex_buffer, 0, 0, (void**)&orig_vertices, D3DLOCK_READONLY);
1724  if (FAILED(hr)) goto cleanup;
1725 
1726  hr = IDirect3DVertexBuffer9_Lock(vertex_buffer, 0, 0, (void**)&new_vertices, 0);
1727  if (FAILED(hr)) {
1728  IDirect3DVertexBuffer9_Unlock(This->vertex_buffer);
1729  goto cleanup;
1730  }
1731 
1732  for (i = 0; i < new_num_vertices; i++)
1733  memcpy(new_vertices + i * vertex_size, orig_vertices + vertex_remap_ptr[i] * vertex_size, vertex_size);
1734 
1735  IDirect3DVertexBuffer9_Unlock(This->vertex_buffer);
1737  } else if (vertex_remap_out) {
1738  DWORD *vertex_remap_ptr;
1739 
1740  hr = D3DXCreateBuffer(This->numvertices * sizeof(DWORD), &vertex_remap);
1741  if (FAILED(hr)) goto cleanup;
1742  vertex_remap_ptr = ID3DXBuffer_GetBufferPointer(vertex_remap);
1743  for (i = 0; i < This->numvertices; i++)
1744  *vertex_remap_ptr++ = i;
1745  }
1746 
1748  {
1751 
1752  attrib_table_size = count_attributes(sorted_attrib_buffer, This->numfaces);
1754  if (!attrib_table) {
1755  hr = E_OUTOFMEMORY;
1756  goto cleanup;
1757  }
1758 
1759  memcpy(attrib_buffer, sorted_attrib_buffer, This->numfaces * sizeof(*attrib_buffer));
1760 
1761  /* reorder the indices using face_remap */
1762  if (This->options & D3DXMESH_32BIT) {
1763  for (i = 0; i < This->numfaces; i++)
1764  memcpy((DWORD*)indices + face_remap[i] * 3, dword_indices + i * 3, 3 * sizeof(DWORD));
1765  } else {
1766  WORD *word_indices = indices;
1767  for (i = 0; i < This->numfaces; i++) {
1768  DWORD new_pos = face_remap[i] * 3;
1769  DWORD old_pos = i * 3;
1770  word_indices[new_pos++] = dword_indices[old_pos++];
1771  word_indices[new_pos++] = dword_indices[old_pos++];
1772  word_indices[new_pos] = dword_indices[old_pos];
1773  }
1774  }
1775 
1777  This->options & D3DXMESH_32BIT, attrib_table);
1778 
1779  HeapFree(GetProcessHeap(), 0, This->attrib_table);
1780  This->attrib_table = attrib_table;
1781  This->attrib_table_size = attrib_table_size;
1782  } else {
1783  if (This->options & D3DXMESH_32BIT) {
1784  memcpy(indices, dword_indices, This->numfaces * 3 * sizeof(DWORD));
1785  } else {
1786  WORD *word_indices = indices;
1787  for (i = 0; i < This->numfaces * 3; i++)
1788  *word_indices++ = dword_indices[i];
1789  }
1790  }
1791 
1792  if (adjacency_out) {
1793  if (face_remap) {
1794  for (i = 0; i < This->numfaces; i++) {
1795  DWORD old_pos = i * 3;
1796  DWORD new_pos = face_remap[i] * 3;
1797  adjacency_out[new_pos++] = face_remap[adjacency_in[old_pos++]];
1798  adjacency_out[new_pos++] = face_remap[adjacency_in[old_pos++]];
1799  adjacency_out[new_pos++] = face_remap[adjacency_in[old_pos++]];
1800  }
1801  } else {
1802  memcpy(adjacency_out, adjacency_in, This->numfaces * 3 * sizeof(*adjacency_out));
1803  }
1804  }
1805  if (face_remap_out) {
1806  if (face_remap) {
1807  for (i = 0; i < This->numfaces; i++)
1808  face_remap_out[face_remap[i]] = i;
1809  } else {
1810  for (i = 0; i < This->numfaces; i++)
1811  face_remap_out[i] = i;
1812  }
1813  }
1814  if (vertex_remap_out)
1815  *vertex_remap_out = vertex_remap;
1816  vertex_remap = NULL;
1817 
1818  if (vertex_buffer) {
1819  IDirect3DVertexBuffer9_Release(This->vertex_buffer);
1820  This->vertex_buffer = vertex_buffer;
1821  vertex_buffer = NULL;
1822  This->numvertices = new_num_vertices;
1823  }
1824 
1825  hr = D3D_OK;
1826 cleanup:
1827  HeapFree(GetProcessHeap(), 0, sorted_attrib_buffer);
1828  HeapFree(GetProcessHeap(), 0, face_remap);
1829  HeapFree(GetProcessHeap(), 0, dword_indices);
1830  if (vertex_remap) ID3DXBuffer_Release(vertex_remap);
1832  if (attrib_buffer) iface->lpVtbl->UnlockAttributeBuffer(iface);
1833  if (indices) iface->lpVtbl->UnlockIndexBuffer(iface);
1834  return hr;
1835 }
#define IDirect3DDevice9_CreateVertexBuffer(p, a, b, c, d, e, f)
Definition: d3d9.h:1533
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
HRESULT hr
Definition: shlfolder.c:183
D3DXATTRIBUTERANGE * attrib_table
Definition: mesh.c:64
#define IDirect3DVertexBuffer9_Unlock(p)
Definition: d3d9.h:708
static HRESULT compact_mesh(struct d3dx9_mesh *This, DWORD *indices, DWORD *new_num_vertices, ID3DXBuffer **vertex_remap)
Definition: mesh.c:1497
#define D3DERR_INVALIDCALL
#define IDirect3DVertexBuffer9_GetDesc(p, a)
Definition: d3d9.h:709
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
static void fill_attribute_table(DWORD *attrib_buffer, DWORD numfaces, void *indices, BOOL is_32bit_indices, D3DXATTRIBUTERANGE *attrib_table)
Definition: mesh.c:1553
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
IDirect3DVertexBuffer9 * vertex_buffer
Definition: mesh.c:59
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirect3DVertexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:707
GLbitfield flags
Definition: glext.h:7161
#define IDirect3DVertexBuffer9_Release(p)
Definition: d3d9.h:696
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
DWORD * attrib_buffer
Definition: mesh.c:61
#define D3D_OK
Definition: d3d.h:106
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define E_NOTIMPL
Definition: ddrawi.h:99
DWORD attrib_table_size
Definition: mesh.c:63
char * cleanup(char *str)
Definition: wpickclick.c:99
static HRESULT remap_faces_for_attrsort(struct d3dx9_mesh *This, const DWORD *indices, DWORD *attrib_buffer, DWORD **sorted_attrib_buffer, DWORD **face_remap)
Definition: mesh.c:1607
static DWORD count_attributes(const DWORD *attrib_buffer, DWORD numfaces)
Definition: mesh.c:1539
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define HeapFree(x, y, z)
Definition: compat.h:394
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:129
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85

◆ d3dx9_mesh_QueryInterface()

static HRESULT WINAPI d3dx9_mesh_QueryInterface ( ID3DXMesh *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 93 of file mesh.c.

94 {
95  TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
96 
97  if (IsEqualGUID(riid, &IID_IUnknown) ||
98  IsEqualGUID(riid, &IID_ID3DXBaseMesh) ||
99  IsEqualGUID(riid, &IID_ID3DXMesh))
100  {
101  iface->lpVtbl->AddRef(iface);
102  *out = iface;
103  return S_OK;
104  }
105 
106  WARN("Interface %s not found.\n", debugstr_guid(riid));
107 
108  return E_NOINTERFACE;
109 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
static FILE * out
Definition: regtests2xml.c:44
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

◆ d3dx9_mesh_Release()

static ULONG WINAPI d3dx9_mesh_Release ( ID3DXMesh *  iface)
static

Definition at line 121 of file mesh.c.

122 {
123  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
124  ULONG refcount = InterlockedDecrement(&mesh->ref);
125 
126  TRACE("%p decreasing refcount to %u.\n", mesh, refcount);
127 
128  if (!refcount)
129  {
132  if (mesh->vertex_declaration)
136  HeapFree(GetProcessHeap(), 0, mesh->attrib_table);
137  HeapFree(GetProcessHeap(), 0, mesh);
138  }
139 
140  return refcount;
141 }
D3DXATTRIBUTERANGE * attrib_table
Definition: mesh.c:64
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
IDirect3DVertexBuffer9 * vertex_buffer
Definition: mesh.c:59
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DVertexBuffer9_Release(p)
Definition: d3d9.h:696
DWORD * attrib_buffer
Definition: mesh.c:61
IDirect3DDevice9 * device
Definition: mesh.c:54
#define IDirect3DIndexBuffer9_Release(p)
Definition: d3d9.h:764
LONG ref
Definition: mesh.c:48
IDirect3DIndexBuffer9 * index_buffer
Definition: mesh.c:60
IDirect3DVertexDeclaration9 * vertex_declaration
Definition: mesh.c:56
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
#define IDirect3DVertexDeclaration9_Release(p)
Definition: d3d9.h:1185

◆ d3dx9_mesh_SetAttributeTable()

static HRESULT WINAPI d3dx9_mesh_SetAttributeTable ( ID3DXMesh *  iface,
const D3DXATTRIBUTERANGE attrib_table,
DWORD  attrib_table_size 
)
static

Definition at line 1837 of file mesh.c.

1839 {
1840  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
1841  D3DXATTRIBUTERANGE *new_table = NULL;
1842 
1843  TRACE("iface %p, attrib_table %p, attrib_table_size %u.\n", iface, attrib_table, attrib_table_size);
1844 
1845  if (attrib_table_size) {
1846  size_t size = attrib_table_size * sizeof(*attrib_table);
1847 
1848  new_table = HeapAlloc(GetProcessHeap(), 0, size);
1849  if (!new_table)
1850  return E_OUTOFMEMORY;
1851 
1852  CopyMemory(new_table, attrib_table, size);
1853  } else if (attrib_table) {
1854  return D3DERR_INVALIDCALL;
1855  }
1856  HeapFree(GetProcessHeap(), 0, mesh->attrib_table);
1857  mesh->attrib_table = new_table;
1859 
1860  return D3D_OK;
1861 }
D3DXATTRIBUTERANGE * attrib_table
Definition: mesh.c:64
#define D3DERR_INVALIDCALL
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CopyMemory
Definition: winbase.h:1633
#define D3D_OK
Definition: d3d.h:106
DWORD attrib_table_size
Definition: mesh.c:63
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ d3dx9_mesh_UnlockAttributeBuffer()

static HRESULT WINAPI d3dx9_mesh_UnlockAttributeBuffer ( ID3DXMesh *  iface)
static

Definition at line 1450 of file mesh.c.

1451 {
1452  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
1453  int lock_count;
1454 
1455  TRACE("iface %p.\n", iface);
1456 
1457  lock_count = InterlockedDecrement(&mesh->attrib_buffer_lock_count);
1458  if (lock_count < 0)
1459  {
1461  return D3DERR_INVALIDCALL;
1462  }
1463 
1464  return D3D_OK;
1465 }
#define D3DERR_INVALIDCALL
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
int attrib_buffer_lock_count
Definition: mesh.c:62
#define D3D_OK
Definition: d3d.h:106
#define InterlockedIncrement
Definition: armddk.h:53

◆ d3dx9_mesh_UnlockIndexBuffer()

static HRESULT WINAPI d3dx9_mesh_UnlockIndexBuffer ( ID3DXMesh *  iface)
static

Definition at line 831 of file mesh.c.

832 {
833  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
834 
835  TRACE("iface %p.\n", iface);
836 
838 }
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
IDirect3DIndexBuffer9 * index_buffer
Definition: mesh.c:60
#define IDirect3DIndexBuffer9_Unlock(p)
Definition: d3d9.h:776

◆ d3dx9_mesh_UnlockVertexBuffer()

static HRESULT WINAPI d3dx9_mesh_UnlockVertexBuffer ( ID3DXMesh *  iface)
static

Definition at line 813 of file mesh.c.

814 {
815  struct d3dx9_mesh *mesh = impl_from_ID3DXMesh(iface);
816 
817  TRACE("iface %p.\n", iface);
818 
820 }
#define IDirect3DVertexBuffer9_Unlock(p)
Definition: d3d9.h:708
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
IDirect3DVertexBuffer9 * vertex_buffer
Definition: mesh.c:59

◆ d3dx9_mesh_UpdateSemantics()

static HRESULT WINAPI d3dx9_mesh_UpdateSemantics ( ID3DXMesh *  iface,
D3DVERTEXELEMENT9  declaration[MAX_FVF_DECL_SIZE] 
)
static

Definition at line 1370 of file mesh.c.

1371 {
1372  struct d3dx9_mesh *This = impl_from_ID3DXMesh(iface);
1373  HRESULT hr;
1375  int i;
1376 
1377  TRACE("iface %p, declaration %p.\n", iface, declaration);
1378 
1379  if (!declaration)
1380  {
1381  WARN("Invalid declaration. Can't use NULL declaration.\n");
1382  return D3DERR_INVALIDCALL;
1383  }
1384 
1385  /* New declaration must be same size as original */
1387  if (vertex_declaration_size != This->vertex_declaration_size)
1388  {
1389  WARN("Invalid declaration. New vertex size does not match the original vertex size.\n");
1390  return D3DERR_INVALIDCALL;
1391  }
1392 
1393  /* New declaration must not contain non-zero Stream value */
1394  for (i = 0; declaration[i].Stream != 0xff; i++)
1395  {
1396  if (declaration[i].Stream != 0)
1397  {
1398  WARN("Invalid declaration. New declaration contains non-zero Stream value.\n");
1399  return D3DERR_INVALIDCALL;
1400  }
1401  }
1402 
1403  This->num_elem = i + 1;
1404  copy_declaration(This->cached_declaration, declaration, This->num_elem);
1405 
1406  if (This->vertex_declaration)
1407  IDirect3DVertexDeclaration9_Release(This->vertex_declaration);
1408 
1409  /* An application can pass an invalid declaration to UpdateSemantics and
1410  * still expect D3D_OK (see tests). If the declaration is invalid, then
1411  * subsequent calls to DrawSubset will fail. This is handled by setting the
1412  * vertex declaration to NULL.
1413  * GetDeclaration, GetNumBytesPerVertex must, however, use the new
1414  * invalid declaration. This is handled by them using the cached vertex
1415  * declaration instead of the actual vertex declaration.
1416  */
1418  declaration,
1419  &This->vertex_declaration);
1420  if (FAILED(hr))
1421  {
1422  WARN("Using invalid declaration. Calls to DrawSubset will fail.\n");
1423  This->vertex_declaration = NULL;
1424  }
1425 
1426  return D3D_OK;
1427 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
#define D3DERR_INVALIDCALL
#define IDirect3DDevice9_CreateVertexDeclaration(p, a, b)
Definition: d3d9.h:1593
static void copy_declaration(D3DVERTEXELEMENT9 *dst, const D3DVERTEXELEMENT9 *src, UINT num_elem)
Definition: mesh.c:218
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
static struct d3dx9_mesh * impl_from_ID3DXMesh(ID3DXMesh *iface)
Definition: mesh.c:88
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define D3D_OK
Definition: d3d.h:106
unsigned int UINT
Definition: ndis.h:50
UINT vertex_declaration_size
Definition: mesh.c:57
UINT WINAPI D3DXGetDeclVertexSize(const D3DVERTEXELEMENT9 *decl, DWORD stream_idx)
Definition: mesh.c:2324
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092
#define IDirect3DVertexDeclaration9_Release(p)
Definition: d3d9.h:1185

◆ D3DXBoxBoundProbe()

BOOL WINAPI D3DXBoxBoundProbe ( const D3DXVECTOR3 pmin,
const D3DXVECTOR3 pmax,
const D3DXVECTOR3 prayposition,
const D3DXVECTOR3 praydirection 
)

Definition at line 1912 of file mesh.c.

1914 {
1915  FLOAT div, tmin, tmax, tymin, tymax, tzmin, tzmax;
1916 
1917  div = 1.0f / praydirection->x;
1918  if ( div >= 0.0f )
1919  {
1920  tmin = ( pmin->x - prayposition->x ) * div;
1921  tmax = ( pmax->x - prayposition->x ) * div;
1922  }
1923  else
1924  {
1925  tmin = ( pmax->x - prayposition->x ) * div;
1926  tmax = ( pmin->x - prayposition->x ) * div;
1927  }
1928 
1929  if ( tmax < 0.0f ) return FALSE;
1930 
1931  div = 1.0f / praydirection->y;
1932  if ( div >= 0.0f )
1933  {
1934  tymin = ( pmin->y - prayposition->y ) * div;
1935  tymax = ( pmax->y - prayposition->y ) * div;
1936  }
1937  else
1938  {
1939  tymin = ( pmax->y - prayposition->y ) * div;
1940  tymax = ( pmin->y - prayposition->y ) * div;
1941  }
1942 
1943  if ( ( tymax < 0.0f ) || ( tmin > tymax ) || ( tymin > tmax ) ) return FALSE;
1944 
1945  if ( tymin > tmin ) tmin = tymin;
1946  if ( tymax < tmax ) tmax = tymax;
1947 
1948  div = 1.0f / praydirection->z;
1949  if ( div >= 0.0f )
1950  {
1951  tzmin = ( pmin->z - prayposition->z ) * div;
1952  tzmax = ( pmax->z - prayposition->z ) * div;
1953  }
1954  else
1955  {
1956  tzmin = ( pmax->z - prayposition->z ) * div;
1957  tzmax = ( pmin->z - prayposition->z ) * div;
1958  }
1959 
1960  if ( (tzmax < 0.0f ) || ( tmin > tzmax ) || ( tzmin > tmax ) ) return FALSE;
1961 
1962  return TRUE;
1963 }
GLfloat f
Definition: glext.h:7540
_STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y)
Definition: _cstdlib.h:137
float FLOAT
Definition: typedefs.h:67
#define TRUE
Definition: mesh.c:42

◆ D3DXCleanMesh()

HRESULT WINAPI D3DXCleanMesh ( D3DXCLEANTYPE  clean_type,
ID3DXMesh *  mesh_in,
const DWORD adjacency_in,
ID3DXMesh **  mesh_out,
DWORD adjacency_out,
ID3DXBuffer **  errors_and_warnings 
)

Definition at line 4002 of file mesh.c.

4004 {
4005  FIXME("(%u, %p, %p, %p, %p, %p)\n", clean_type, mesh_in, adjacency_in, mesh_out, adjacency_out, errors_and_warnings);
4006 
4007  return E_NOTIMPL;
4008 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ D3DXComputeBoundingBox()

HRESULT WINAPI D3DXComputeBoundingBox ( const D3DXVECTOR3 pfirstposition,
DWORD  numvertices,
DWORD  dwstride,
D3DXVECTOR3 pmin,
D3DXVECTOR3 pmax 
)

Definition at line 1965 of file mesh.c.

1967 {
1968  D3DXVECTOR3 vec;
1969  unsigned int i;
1970 
1971  if( !pfirstposition || !pmin || !pmax ) return D3DERR_INVALIDCALL;
1972 
1973  *pmin = *pfirstposition;
1974  *pmax = *pmin;
1975 
1976  for(i=0; i<numvertices; i++)
1977  {
1978  vec = *( (const D3DXVECTOR3*)((const char*)pfirstposition + dwstride * i) );
1979 
1980  if ( vec.x < pmin->x ) pmin->x = vec.x;
1981  if ( vec.x > pmax->x ) pmax->x = vec.x;
1982 
1983  if ( vec.y < pmin->y ) pmin->y = vec.y;
1984  if ( vec.y > pmax->y ) pmax->y = vec.y;
1985 
1986  if ( vec.z < pmin->z ) pmin->z = vec.z;
1987  if ( vec.z > pmax->z ) pmax->z = vec.z;
1988  }
1989 
1990  return D3D_OK;
1991 }
FT_Pos y
Definition: ftimage.h:77
FT_Pos x
Definition: ftimage.h:76
#define D3DERR_INVALIDCALL
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD numvertices
Definition: mesh.c:51
FT_Vector * vec
Definition: ftbbox.c:448
#define D3D_OK
Definition: d3d.h:106

◆ D3DXComputeBoundingSphere()

HRESULT WINAPI D3DXComputeBoundingSphere ( const D3DXVECTOR3 pfirstposition,
DWORD  numvertices,
DWORD  dwstride,
D3DXVECTOR3 pcenter,
float *  pradius 
)

Definition at line 1993 of file mesh.c.

1995 {
1996  D3DXVECTOR3 temp;
1997  FLOAT d;
1998  unsigned int i;
1999 
2000  if( !pfirstposition || !pcenter || !pradius ) return D3DERR_INVALIDCALL;
2001 
2002  temp.x = 0.0f;
2003  temp.y = 0.0f;
2004  temp.z = 0.0f;
2005  *pradius = 0.0f;
2006 
2007  for(i=0; i<numvertices; i++)
2008  D3DXVec3Add(&temp, &temp, (const D3DXVECTOR3*)((const char*)pfirstposition + dwstride * i));
2009 
2010  D3DXVec3Scale(pcenter, &temp, 1.0f / numvertices);
2011 
2012  for(i=0; i<numvertices; i++)
2013  {
2014  d = D3DXVec3Length(D3DXVec3Subtract(&temp, (const D3DXVECTOR3*)((const char*)pfirstposition + dwstride * i), pcenter));
2015  if ( d > *pradius ) *pradius = d;
2016  }
2017  return D3D_OK;
2018 }
#define D3DERR_INVALIDCALL
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD numvertices
Definition: mesh.c:51
GLfloat f
Definition: glext.h:7540
#define d
Definition: ke_i.h:81
#define D3D_OK
Definition: d3d.h:106
static calc_node_t temp
Definition: rpn_ieee.c:38
float FLOAT
Definition: typedefs.h:67

◆ D3DXComputeNormals()

HRESULT WINAPI D3DXComputeNormals ( struct ID3DXBaseMesh *  mesh,
const DWORD adjacency 
)

Definition at line 7563 of file mesh.c.

7564 {
7565  TRACE("mesh %p, adjacency %p\n", mesh, adjacency);
7566 
7567  if (mesh && (ID3DXMeshVtbl *)mesh->lpVtbl != &D3DXMesh_Vtbl)
7568  {
7569  ERR("Invalid virtual table\n");
7570  return D3DERR_INVALIDCALL;
7571  }
7572 
7573  return D3DXComputeTangentFrameEx((ID3DXMesh *)mesh, D3DX_DEFAULT, 0,
7576  adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL);
7577 }
static const struct ID3DXMeshVtbl D3DXMesh_Vtbl
Definition: mesh.c:1863
#define D3DERR_INVALIDCALL
#define D3DX_DEFAULT
Definition: d3dx9.h:24
smooth NULL
Definition: ftsmooth.c:416
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4