diff --git a/panda/src/dxgsg/dxGeomNodeContext.h b/panda/src/dxgsg/dxGeomNodeContext.h index 4d436ea192..31c7cf2ba3 100644 --- a/panda/src/dxgsg/dxGeomNodeContext.h +++ b/panda/src/dxgsg/dxGeomNodeContext.h @@ -52,7 +52,7 @@ public: // A list of the dynamic Geoms within the GeomNode; these aren't // part of the above display list and must be drawn separately typedef pvector Geoms; - Geoms _other_geoms; + Geoms _cached_geoms,_other_geoms; // VB's are already reference-counted by D3D, no need to make separate panda object to do that // but we will want a way to know if VB has already been xformed by ProcessVerts this frame diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index 3fd550569a..be17fb0206 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -6542,9 +6542,10 @@ prepare_geom_node(GeomNode *node) { } assert(pVertData!=NULL); + _pCurrentGeomContext = dx_gnc; _pCurrentGeomContext->_pEndofVertData=(BYTE*)pVertData; _bDrawPrimDoSetupVertexBuffer = true; - _pCurrentGeomContext = dx_gnc; + for (i = 0; (i < num_geoms); i++) { dDrawable *drawable1 = node->get_geom(i); @@ -6557,13 +6558,14 @@ prepare_geom_node(GeomNode *node) { if(geom->is_dynamic()) { dx_gnc->_other_geoms.push_back(geom); } else { + dx_gnc->_cached_geoms.push_back(geom); node->get_geom(i)->draw(this); } } _bDrawPrimDoSetupVertexBuffer = false; - _pCurrentGeomContext = NULL; _pCurrentGeomContext->_pEndofVertData=NULL; + _pCurrentGeomContext = NULL; hr=dx_gnc->_pVB->Unlock(); if(FAILED(hr)) { @@ -6654,22 +6656,22 @@ draw_geom_node(GeomNode *node, GeomNodeContext *gnc) { } } + // need to tell draw_prims to use DrawPrimitiveVB with current vertex buffer - for (i = 0; i < num_geoms; i++) { - node->get_geom(i)->draw(this); + for (i = 0; i < dx_gnc->_cached_geoms.size(); i++) { + dx_gnc->_cached_geoms[i]->draw(this); + } + // unset the flag above + + // Also draw all the dynamic Geoms. + for (i = 0; i < dx_gnc->_other_geoms.size(); i++) { + dx_gnc->_other_geoms[i]->draw(this); } #if 0 //def DO_PSTATS DO_PSTATS_STUFF(PStatTimer timer(_draw_primitive_pcollector)); _vertices_display_list_pcollector.add_level(dx_gnc->_num_verts); #endif - - - // Also draw all the dynamic Geoms. - for (i = 0; i < num_geoms; i++) { - dx_gnc->_other_geoms[i]->draw(this); - } - } ////////////////////////////////////////////////////////////////////