As the title suggests, I'm thinking about trying to read / write to the vertex buffer directly to avoid the function calling overhead.
I know the function returns a pointer to the sMesh structure:
struct sMesh
{
// stores mesh information
char* m_Name; // mesh name
ID3DXMesh* m_Mesh; // mesh object
ID3DXSkinMesh* m_SkinMesh; // skinned mesh object
DWORD m_NumMaterials; // number of materials in mesh
D3DMATERIAL8* m_Materials; // array of materials
IDirect3DTexture8** m_Textures; // array of textures
char m_TextureName [ 256 ];
DWORD m_NumBones; // number of bones
ID3DXBuffer* m_BoneNames; // names of bones
ID3DXBuffer* m_BoneTransforms; // internal transformations
D3DXMATRIX* m_Matrices; // bone matrices
D3DXMATRIX** m_FrameMatrices; // pointers to frame matrices
D3DXMATRIX* m_BoneMatrices; // x file bone matrices
D3DXVECTOR3 m_Min; // min bounds
D3DXVECTOR3 m_Max; // max bounds
float m_Radius; // Bounding sphere
D3DPRIMITIVETYPE m_iPrimType; // when mesh modifying, this is required
sMesh* m_Next; // Next mesh in list
D3DXATTRIBUTERANGE* m_pAttributeTable;
DWORD m_dwAttributeTableSize;
#if DEBUG_MODE_MESH
LPD3DXMESH m_pMeshBox;
D3DXMATRIX m_matBox;
#endif
D3DXVECTOR3 m_vecMin;
D3DXVECTOR3 m_vecMax;
// functions in structure
sMesh ( ); // constructor
~sMesh ( ); // destructor
sMesh* FindMesh ( char* Name ); // gets a pointer to a mesh
DWORD GetNumMaterials ( void ); // get the number of materials used
D3DMATERIAL8* GetMaterial ( unsigned long Num ); // get material data
IDirect3DTexture8* GetTexture ( unsigned long Num ); // get a pointer to a texture
void CopyFrameToBoneMatrices ( void ); // copy frame matrices
};
However when browsing through the first few bytes of the pointer, it seems to hold 4 reserved bytes first and then the standard "memblock mesh" header (fvf format, fvf size...), none of which I can find directly in the above sMesh struct.
sMesh seems to be defined in multiple files (not just forward declared but actually redefined); is it possible that the various structs differ from each other?
Maybe someone have some experience with this already (IanM?) and can shed some light on the situation?
Thanks in advance,
Rudolpho
Edit: For anyone reading this considering going down this route I certainly recommend it.
My benchmarking test went up in running speed slightly above 200% when doing this (from 174 FPS using the built-in functions to 395 using the buffer directly).
"Why do programmers get Halloween and Christmas mixed up?" Because Oct(31) = Dec(25)