瀏覽代碼

fix bounding volume bug after flatten

David Rose 19 年之前
父節點
當前提交
700051ff5f
共有 2 個文件被更改,包括 11 次插入0 次删除
  1. 4 0
      panda/src/gobj/geom.cxx
  2. 7 0
      panda/src/pgraph/geomNode.cxx

+ 4 - 0
panda/src/gobj/geom.cxx

@@ -342,6 +342,7 @@ set_primitive(int i, const GeomPrimitive *primitive) {
   cdata->_got_usage_hint = false;
   cdata->_modified = Geom::get_next_modified();
   clear_cache_stage(current_thread);
+  mark_internal_bounds_stale(cdata);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -387,6 +388,7 @@ add_primitive(const GeomPrimitive *primitive) {
   cdata->_got_usage_hint = false;
   cdata->_modified = Geom::get_next_modified();
   clear_cache_stage(current_thread);
+  mark_internal_bounds_stale(cdata);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -412,6 +414,7 @@ remove_primitive(int i) {
   cdata->_got_usage_hint = false;
   cdata->_modified = Geom::get_next_modified();
   clear_cache_stage(current_thread);
+  mark_internal_bounds_stale(cdata);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -435,6 +438,7 @@ clear_primitives() {
   cdata->_shade_model = SM_uniform;
   reset_geom_rendering(cdata);
   clear_cache_stage(current_thread);
+  mark_internal_bounds_stale(cdata);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 7 - 0
panda/src/pgraph/geomNode.cxx

@@ -484,6 +484,8 @@ check_valid() const {
 ////////////////////////////////////////////////////////////////////
 void GeomNode::
 unify(int max_indices) {
+  bool any_changed = false;
+
   Thread *current_thread = Thread::get_current_thread();
   OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) {
     CDStageWriter cdata(_cycler, pipeline_stage, current_thread);
@@ -507,6 +509,7 @@ unify(int max_indices) {
           if (new_entry._geom->copy_primitives_from(entry._geom)) {
             // Successfully combined!
             unified = true;
+            any_changed = true;
           }
         }
       }
@@ -528,6 +531,10 @@ unify(int max_indices) {
     }
   }
   CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler);
+
+  if (any_changed) {
+    mark_internal_bounds_stale();
+  }
 }
 
 ////////////////////////////////////////////////////////////////////