further refine previous changes

This commit is contained in:
cxgeorge 2001-11-20 22:09:52 +00:00
parent 67855e3fa7
commit 10694d29a1
2 changed files with 62 additions and 62 deletions

View File

@ -1787,6 +1787,30 @@ transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
OutRGBAColor = Colorf_to_D3DCOLOR(out_color); OutRGBAColor = Colorf_to_D3DCOLOR(out_color);
} }
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::wants_colors
// Access: Public, Virtual
// Description: Returns true if the GSG should issue geometry color
// commands, false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool DXGraphicsStateGuardian::
wants_colors() const {
// If we have scene graph color enabled, return false to indicate we
// shouldn't bother issuing geometry color commands.
const ColorTransition *catt;
if (!get_attribute_into(catt, this)) {
// No scene graph color at all.
return true;
}
// We should issue geometry colors only if the scene graph color is off.
if (catt->is_off() || (!catt->is_real()))
return true;
return false;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::draw_prim_setup // Function: DXGraphicsStateGuardian::draw_prim_setup
// Access: Private // Access: Private
@ -1815,12 +1839,16 @@ draw_prim_setup(const Geom *geom) {
//////// ////////
// this stuff should eventually replace the iterators below // this stuff should eventually replace the iterators below
geom->get_coords(_coords,_vindexes); PTA_Vertexf coords;
if(_vindexes!=NULL) { PTA_ushort vindexes;
_pCurCoordIndex = &_vindexes[0];
geom->get_coords(coords,vindexes);
if(vindexes!=NULL) {
_pCurCoordIndex = _coordindex_array = &vindexes[0];
} else { } else {
_pCurCoord = &_coords[0]; _pCurCoordIndex = _coordindex_array = NULL;
} }
_pCurCoord = _coord_array = &coords[0];
/////////////// ///////////////
@ -1862,15 +1890,18 @@ draw_prim_setup(const Geom *geom) {
GeomBindType TexCoordBinding; GeomBindType TexCoordBinding;
geom->get_texcoords(_texcoords,TexCoordBinding,_texcoord_indexes); PTA_TexCoordf texcoords;
PTA_ushort tindexes;
geom->get_texcoords(texcoords,TexCoordBinding,tindexes);
if (TexCoordBinding != G_OFF) { if (TexCoordBinding != G_OFF) {
// used by faster path // used by faster path
if(_texcoord_indexes!=NULL) { if(tindexes!=NULL) {
_pCurTexCoordIndex = &_texcoord_indexes[0]; _pCurTexCoordIndex = _texcoordindex_array = &tindexes[0];
} else { } else {
_pCurTexCoord = &_texcoords[0]; _pCurTexCoordIndex = _texcoordindex_array = NULL;
} }
_pCurTexCoord = _texcoord_array = &texcoords[0];
//////
ti = geom->make_texcoord_iterator(); ti = geom->make_texcoord_iterator();
_curFVFflags |= (D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0)); _curFVFflags |= (D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0));
@ -1897,30 +1928,6 @@ draw_prim_setup(const Geom *geom) {
return vertex_size; return vertex_size;
} }
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::wants_colors
// Access: Public, Virtual
// Description: Returns true if the GSG should issue geometry color
// commands, false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool DXGraphicsStateGuardian::
wants_colors() const {
// If we have scene graph color enabled, return false to indicate we
// shouldn't bother issuing geometry color commands.
const ColorTransition *catt;
if (!get_attribute_into(catt, this)) {
// No scene graph color at all.
return true;
}
// We should issue geometry colors only if the scene graph color is off.
if (catt->is_off() || (!catt->is_real()))
return true;
return false;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::draw_prim_inner_loop // Function: DXGraphicsStateGuardian::draw_prim_inner_loop
// Access: Private // Access: Private
@ -1977,31 +1984,28 @@ draw_prim_inner_loop(int nVerts, const Geom *geom, ushort perFlags) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void DXGraphicsStateGuardian:: void DXGraphicsStateGuardian::
draw_prim_inner_loop_coordtexonly(int nVerts, const Geom *geom) { draw_prim_inner_loop_coordtexonly(int nVerts, const Geom *geom) {
// inc'ing local ptrs avoids 'this' ptr derefs for member fields // assumes coord and texcoord data is per-vertex, color is not per-vert, and no normal data
// this should be common situation for animated character data
// inc'ing local ptrs instead of member ones, seems to optimize better
// bypass all the slow vertex iterator stuff // bypass all the slow vertex iterator stuff
Vertexf *pCurVert = _pCurCoord; Vertexf *pCurCoord = _pCurCoord;
ushort *pCurVertIndex = _pCurCoordIndex; ushort *pCurCoordIndex = _pCurCoordIndex;
TexCoordf *pCurTexCoord = _pCurTexCoord; TexCoordf *pCurTexCoord = _pCurTexCoord;
ushort *pCurTexCoordIndex = _pCurTexCoordIndex; ushort *pCurTexCoordIndex = _pCurTexCoordIndex;
char *LocalFvfBufPtr = _pCurFvfBufPtr; char *LocalFvfBufPtr = _pCurFvfBufPtr;
DWORD cur_color = _curD3Dcolor; DWORD cur_color = _curD3Dcolor;
bool bDoIndexedTexCoords = (_texcoord_indexes != NULL); bool bDoIndexedTexCoords = (_texcoordindex_array != NULL);
bool bDoIndexedCoords = (_vindexes != NULL); bool bDoIndexedCoords = (_coordindex_array != NULL);
if(bDoIndexedTexCoords)
pCurTexCoord=&_texcoords[0];
if(bDoIndexedCoords)
pCurVert=&_coords[0];
for(;nVerts>0;nVerts--) { for(;nVerts>0;nVerts--) {
if(bDoIndexedCoords) { if(bDoIndexedCoords) {
memcpy(LocalFvfBufPtr,(void*)&pCurVert[*pCurVertIndex],sizeof(D3DVECTOR)); memcpy(LocalFvfBufPtr,(void*)&_coord_array[*pCurCoordIndex],sizeof(D3DVECTOR));
pCurVertIndex++; pCurCoordIndex++;
} else { } else {
memcpy(LocalFvfBufPtr,(void*)pCurVert,sizeof(D3DVECTOR)); memcpy(LocalFvfBufPtr,(void*)pCurCoord,sizeof(D3DVECTOR));
pCurVert++; pCurCoord++;
} }
LocalFvfBufPtr+=sizeof(D3DVECTOR); LocalFvfBufPtr+=sizeof(D3DVECTOR);
@ -2010,7 +2014,7 @@ draw_prim_inner_loop_coordtexonly(int nVerts, const Geom *geom) {
LocalFvfBufPtr += sizeof(DWORD); LocalFvfBufPtr += sizeof(DWORD);
if(bDoIndexedTexCoords) { if(bDoIndexedTexCoords) {
memcpy(LocalFvfBufPtr,(void*)&pCurTexCoord[*pCurTexCoordIndex],sizeof(TexCoordf)); memcpy(LocalFvfBufPtr,(void*)&_texcoord_array[*pCurTexCoordIndex],sizeof(TexCoordf));
pCurTexCoordIndex++; pCurTexCoordIndex++;
} else { } else {
memcpy(LocalFvfBufPtr,(void*)pCurTexCoord,sizeof(TexCoordf)); memcpy(LocalFvfBufPtr,(void*)pCurTexCoord,sizeof(TexCoordf));
@ -2020,8 +2024,8 @@ draw_prim_inner_loop_coordtexonly(int nVerts, const Geom *geom) {
} }
_pCurFvfBufPtr=LocalFvfBufPtr; _pCurFvfBufPtr=LocalFvfBufPtr;
_pCurCoord = pCurVert; _pCurCoord = pCurCoord;
_pCurCoordIndex = pCurVertIndex; _pCurCoordIndex = pCurCoordIndex;
_pCurTexCoord = pCurTexCoord; _pCurTexCoord = pCurTexCoord;
_pCurTexCoordIndex = pCurTexCoordIndex; _pCurTexCoordIndex = pCurTexCoordIndex;
} }

View File

@ -343,17 +343,13 @@ protected:
// these are used for fastpaths that bypass the iterators above // these are used for fastpaths that bypass the iterators above
// pointers to arrays in current geom, used to traverse indexed and non-indexed arrays // pointers to arrays in current geom, used to traverse indexed and non-indexed arrays
PTA_Vertexf _coords; Vertexf *_coord_array,*_pCurCoord;
Vertexf *_pCurCoord; ushort *_coordindex_array,*_pCurCoordIndex;
PTA_ushort _vindexes;
ushort *_pCurCoordIndex;
PTA_TexCoordf _texcoords; TexCoordf *_texcoord_array,*_pCurTexCoord;
TexCoordf *_pCurTexCoord; ushort *_texcoordindex_array,*_pCurTexCoordIndex;
PTA_ushort _texcoord_indexes;
ushort *_pCurTexCoordIndex;
/* not used yet /*
PTA_Normalf _norms; PTA_Normalf _norms;
PTA_Colorf _colors; PTA_Colorf _colors;
PTA_ushort _cindexes,_nindexes; PTA_ushort _cindexes,_nindexes;