瀏覽代碼

fix egg-flat-shading 0 when color is only on vertices

David Rose 19 年之前
父節點
當前提交
9ab698c9b3
共有 3 個文件被更改,包括 21 次插入20 次删除
  1. 2 2
      panda/src/egg/eggCompositePrimitive.cxx
  2. 17 16
      panda/src/egg/eggGroupNode.cxx
  3. 2 2
      panda/src/egg/eggPrimitive.cxx

+ 2 - 2
panda/src/egg/eggCompositePrimitive.cxx

@@ -50,8 +50,8 @@ EggCompositePrimitive::
 //               To get the most accurate results, you should call
 //               clear_shading() on all connected primitives (or on
 //               all primitives in the egg file), followed by
-//               determine_shading() on each primitive.  You may find
-//               it easiest to call these methods on the EggData root
+//               get_shading() on each primitive.  You may find it
+//               easiest to call these methods on the EggData root
 //               node (they are defined on EggGroupNode).
 ////////////////////////////////////////////////////////////////////
 EggPrimitive::Shading EggCompositePrimitive::

+ 17 - 16
panda/src/egg/eggGroupNode.cxx

@@ -1069,14 +1069,14 @@ rebuild_vertex_pool(EggVertexPool *vertex_pool, bool recurse) {
 //               polygons; otherwise, each polygon is considered
 //               individually.
 //
-//               If allow_per_primitive is false, S_per_face will
-//               treated like S_per_vertex: normals and colors will
-//               always be assigned to the vertices.  In this case,
-//               there will never be per-primitive colors or normals
-//               after this call returns.  On the other hand, if
-//               allow_per_primitive is true, then S_per_face means
-//               that normals and colors should be assigned to the
-//               primitives, and removed from the vertices, as
+//               If allow_per_primitive is false, S_per_face or
+//               S_overall will treated like S_per_vertex: normals and
+//               colors will always be assigned to the vertices.  In
+//               this case, there will never be per-primitive colors
+//               or normals after this call returns.  On the other
+//               hand, if allow_per_primitive is true, then S_per_face
+//               means that normals and colors should be assigned to
+//               the primitives, and removed from the vertices, as
 //               described above.
 //
 //               This may create redundant vertices in the vertex
@@ -1085,20 +1085,21 @@ rebuild_vertex_pool(EggVertexPool *vertex_pool, bool recurse) {
 ////////////////////////////////////////////////////////////////////
 void EggGroupNode::
 unify_attributes(bool use_connected_shading, bool allow_per_primitive,
-		 bool recurse) {
+                 bool recurse) {
   Children::iterator ci;
   for (ci = _children.begin(); ci != _children.end(); ++ci) {
     EggNode *child = *ci;
 
     if (child->is_of_type(EggPrimitive::get_class_type())) {
       EggPrimitive *prim = DCAST(EggPrimitive, child);
-      EggPrimitive::Shading shading = prim->get_shading();
-      if (use_connected_shading) {
-        shading = prim->get_connected_shading();
-      }
 
-      if (!allow_per_primitive && shading == EggPrimitive::S_per_face) {
-	shading = EggPrimitive::S_per_vertex;
+      EggPrimitive::Shading shading = EggPrimitive::S_per_vertex;
+
+      if (allow_per_primitive) {
+        shading = prim->get_shading();
+        if (use_connected_shading) {
+          shading = prim->get_connected_shading();
+        }
       }
 
       prim->unify_attributes(shading);
@@ -1106,7 +1107,7 @@ unify_attributes(bool use_connected_shading, bool allow_per_primitive,
     } else if (child->is_of_type(EggGroupNode::get_class_type())) {
       if (recurse) {
         DCAST(EggGroupNode, child)->unify_attributes
-	  (use_connected_shading, allow_per_primitive, recurse);
+          (use_connected_shading, allow_per_primitive, recurse);
       }
     }
   }

+ 2 - 2
panda/src/egg/eggPrimitive.cxx

@@ -215,8 +215,8 @@ determine_bin() {
 //               To get the most accurate results, you should call
 //               clear_shading() on all connected primitives (or on
 //               all primitives in the egg file), followed by
-//               determine_shading() on each primitive.  You may find
-//               it easiest to call these methods on the EggData root
+//               get_shading() on each primitive.  You may find it
+//               easiest to call these methods on the EggData root
 //               node (they are defined on EggGroupNode).
 ////////////////////////////////////////////////////////////////////
 EggPrimitive::Shading EggPrimitive::