Browse Source

fix scene_graph_color to work with PER_PRIM geom color

cxgeorge 23 years ago
parent
commit
bd7f313b91
1 changed files with 26 additions and 0 deletions
  1. 26 0
      panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

+ 26 - 0
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -2445,6 +2445,19 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
 
 
         size_t vertex_size = draw_prim_setup(geom);
         size_t vertex_size = draw_prim_setup(geom);
 
 
+        // Note: draw_prim_setup could unset color flags if global color is set, so must
+        //       recheck this flag here!
+        bPerPrimColor=(_perPrim & PER_COLOR)!=0x0;
+
+        #ifdef _DEBUG
+          // is it Ok not to recompute bUseTexCoordOnlyLoop even if draw_prim_setup unsets color flags?
+          // add this check to make sure
+           bool bNewUseTexCoordOnlyLoop = (((_perVertex & PER_COLOR)==0x0) &&
+                                           ((_CurFVFType & D3DFVF_NORMAL)==0x0) &&
+                                           ((_CurFVFType & D3DFVF_TEX1)!=0x0));
+           assert(bNewUseTexCoordOnlyLoop == bUseTexCoordOnlyLoop);
+        #endif
+
         nassertv(_pCurFvfBufPtr == NULL);    // make sure the storage pointer is clean.
         nassertv(_pCurFvfBufPtr == NULL);    // make sure the storage pointer is clean.
         nassertv(nPrims * 3 * vertex_size < VERT_BUFFER_SIZE);
         nassertv(nPrims * 3 * vertex_size < VERT_BUFFER_SIZE);
         _pCurFvfBufPtr = _pFvfBufBasePtr;          // _pCurFvfBufPtr changes,  _pFvfBufBasePtr doesn't
         _pCurFvfBufPtr = _pFvfBufBasePtr;          // _pCurFvfBufPtr changes,  _pFvfBufBasePtr doesn't
@@ -2619,6 +2632,19 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
 
 
         size_t vertex_size = draw_prim_setup(geom);
         size_t vertex_size = draw_prim_setup(geom);
 
 
+        // Note: draw_prim_setup could unset color flags if global color is set, so must
+        //       recheck this flag here!
+        bPerPrimColor=(_perPrim & PER_COLOR)!=0;
+
+        #ifdef _DEBUG
+          // is it Ok not to recompute bUseTexCoordOnlyLoop even if draw_prim_setup unsets color flags?
+          // add this check to make sure.  texcoordonly needs input that with unchanging color, except per-prim
+           bool bNewUseTexCoordOnlyLoop = ((((_perComp|_perVertex) & PER_COLOR)==0x0) &&
+                                           ((_CurFVFType & D3DFVF_NORMAL)==0x0) &&
+                                           ((_CurFVFType & D3DFVF_TEX1)!=0x0));
+           assert(bNewUseTexCoordOnlyLoop == bUseTexCoordOnlyLoop);
+        #endif
+
         // iterate through the triangle primitives
         // iterate through the triangle primitives
 
 
         int nVerts;
         int nVerts;