Browse Source

vb setup fixes

cxgeorge 24 years ago
parent
commit
daf12a57de
2 changed files with 14 additions and 12 deletions
  1. 1 1
      panda/src/dxgsg/dxGeomNodeContext.h
  2. 13 11
      panda/src/dxgsg/dxGraphicsStateGuardian.cxx

+ 1 - 1
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<PT(dDrawable) > 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

+ 13 - 11
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);
   }
-
-#if 0 //def DO_PSTATS
-    DO_PSTATS_STUFF(PStatTimer timer(_draw_primitive_pcollector));
-    _vertices_display_list_pcollector.add_level(dx_gnc->_num_verts);
-#endif
-
+  // unset the flag above
 
   // Also draw all the dynamic Geoms.
-  for (i = 0; i < num_geoms; i++) {
+  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
 }
 
 ////////////////////////////////////////////////////////////////////