Browse Source

Merge branch 'release/1.10.x'

rdb 3 years ago
parent
commit
9bd66baa1c

+ 11 - 0
direct/src/dist/commands.py

@@ -1710,3 +1710,14 @@ class bdist_apps(setuptools.Command):
                     continue
                     continue
 
 
                 self.installer_functions[installer](self, basename, build_dir)
                 self.installer_functions[installer](self, basename, build_dir)
+
+
+def finalize_distribution_options(dist):
+    """Entry point for compatibility with setuptools>=61, see #1394."""
+
+    options = dist.get_option_dict('build_apps')
+    if options.get('gui_apps') or options.get('console_apps'):
+        # Make sure this is set to avoid auto-discovery taking place.
+        if getattr(dist.metadata, 'py_modules', None) is None and \
+           getattr(dist.metadata, 'packages', None) is None:
+            dist.py_modules = []

+ 3 - 0
makepanda/makepanda.py

@@ -2885,6 +2885,9 @@ Author-email: [email protected]
 ENTRY_POINTS = """[distutils.commands]
 ENTRY_POINTS = """[distutils.commands]
 build_apps = direct.dist.commands:build_apps
 build_apps = direct.dist.commands:build_apps
 bdist_apps = direct.dist.commands:bdist_apps
 bdist_apps = direct.dist.commands:bdist_apps
+
+[setuptools.finalize_distribution_options]
+build_apps = direct.dist.commands:finalize_distribution_options
 """
 """
 
 
 if not PkgSkip("DIRECT"):
 if not PkgSkip("DIRECT"):

+ 2 - 0
makepanda/makewheel.py

@@ -887,6 +887,8 @@ if __debug__:
     entry_points += '[distutils.commands]\n'
     entry_points += '[distutils.commands]\n'
     entry_points += 'build_apps = direct.dist.commands:build_apps\n'
     entry_points += 'build_apps = direct.dist.commands:build_apps\n'
     entry_points += 'bdist_apps = direct.dist.commands:bdist_apps\n'
     entry_points += 'bdist_apps = direct.dist.commands:bdist_apps\n'
+    entry_points += '[setuptools.finalize_distribution_options]\n'
+    entry_points += 'build_apps = direct.dist.commands:finalize_distribution_options\n'
 
 
     whl.write_file_data('panda3d_tools/__init__.py', PANDA3D_TOOLS_INIT.format(tools_init))
     whl.write_file_data('panda3d_tools/__init__.py', PANDA3D_TOOLS_INIT.format(tools_init))
 
 

+ 3 - 0
panda/CMakeLists.txt

@@ -148,6 +148,9 @@ from .interrogatedb import *
   set(entry_points_file "[distutils.commands]
   set(entry_points_file "[distutils.commands]
 build_apps = direct.dist.commands:build_apps
 build_apps = direct.dist.commands:build_apps
 bdist_apps = direct.dist.commands:bdist_apps
 bdist_apps = direct.dist.commands:bdist_apps
+
+[setuptools.finalize_distribution_options]
+build_apps = direct.dist.commands:finalize_distribution_options
 ")
 ")
 
 
   configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/METADATA.in"
   configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/METADATA.in"

+ 6 - 0
panda/src/gobj/preparedGraphicsObjects.cxx

@@ -1582,6 +1582,12 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) {
   }
   }
 
 
   _enqueued_index_buffers.clear();
   _enqueued_index_buffers.clear();
+
+  for (ShaderBuffer *buffer : _enqueued_shader_buffers) {
+    buffer->prepare_now(this, gsg);
+  }
+
+  _enqueued_shader_buffers.clear();
 }
 }
 
 
 /**
 /**

+ 1 - 1
panda/src/gobj/shader.cxx

@@ -2943,7 +2943,7 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
             source_dir = full_fn.get_dirname();
             source_dir = full_fn.get_dirname();
             incfn = incfile;
             incfn = incfile;
 
 
-          } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\>]> %zn", incfile, &nread) == 1
+          } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^>]> %zn", incfile, &nread) == 1
               && nread == line.size()) {
               && nread == line.size()) {
             // Angled includes are also OK, but we don't search in the directory
             // Angled includes are also OK, but we don't search in the directory
             // of the source file.
             // of the source file.

+ 1 - 1
panda/src/pgraph/light.I

@@ -71,8 +71,8 @@ INLINE void Light::
 set_color(const LColor &color) {
 set_color(const LColor &color) {
   CDWriter cdata(_cycler);
   CDWriter cdata(_cycler);
   cdata->_color = color;
   cdata->_color = color;
+  cdata->_viz_geom_stale = true;
   _has_color_temperature = false;
   _has_color_temperature = false;
-  mark_viz_stale();
 }
 }
 
 
 /**
 /**

+ 1 - 1
panda/src/pgraph/light.cxx

@@ -125,7 +125,7 @@ set_color_temperature(PN_stdfloat temperature) {
 
 
   CDWriter cdata(_cycler);
   CDWriter cdata(_cycler);
   cdata->_color = color;
   cdata->_color = color;
-  mark_viz_stale();
+  cdata->_viz_geom_stale = true;
 }
 }
 
 
 /**
 /**

+ 36 - 0
panda/src/pipeline/pipeline.cxx

@@ -357,6 +357,42 @@ add_cycler(PipelineCyclerTrueImpl *cycler) {
 }
 }
 #endif  // THREADED_PIPELINE
 #endif  // THREADED_PIPELINE
 
 
+#ifdef THREADED_PIPELINE
+/**
+ * Adds the indicated cycler to the list of cyclers associated with the
+ * pipeline.  This method only exists when true pipelining is configured on.
+ *
+ * If the dirty flag is true, it will be marked as dirty in addition, as though
+ * add_dirty_cycler() were called immediately afterward.
+ */
+void Pipeline::
+add_cycler(PipelineCyclerTrueImpl *cycler, bool dirty) {
+  // It's safe to add it to the list while cycling, since the _clean list is
+  // not touched during the cycle loop.
+  MutexHolder holder(_lock);
+  nassertv(!cycler->_dirty);
+
+  if (!dirty) {
+    cycler->insert_before(&_clean);
+  }
+  else {
+    nassertv(_num_stages != 1);
+    cycler->insert_before(&_dirty);
+    cycler->_dirty = _next_cycle_seq;
+    ++_num_dirty_cyclers;
+
+#ifdef DEBUG_THREADS
+    inc_cycler_type(_dirty_cycler_types, cycler->get_parent_type(), 1);
+#endif
+  }
+  ++_num_cyclers;
+
+#ifdef DEBUG_THREADS
+  inc_cycler_type(_all_cycler_types, cycler->get_parent_type(), 1);
+#endif
+}
+#endif  // THREADED_PIPELINE
+
 #ifdef THREADED_PIPELINE
 #ifdef THREADED_PIPELINE
 /**
 /**
  * Marks the indicated cycler as "dirty", meaning it will need to be cycled
  * Marks the indicated cycler as "dirty", meaning it will need to be cycled

+ 1 - 0
panda/src/pipeline/pipeline.h

@@ -50,6 +50,7 @@ public:
 
 
 #ifdef THREADED_PIPELINE
 #ifdef THREADED_PIPELINE
   void add_cycler(PipelineCyclerTrueImpl *cycler);
   void add_cycler(PipelineCyclerTrueImpl *cycler);
+  void add_cycler(PipelineCyclerTrueImpl *cycler, bool dirty);
   void add_dirty_cycler(PipelineCyclerTrueImpl *cycler);
   void add_dirty_cycler(PipelineCyclerTrueImpl *cycler);
   void remove_cycler(PipelineCyclerTrueImpl *cycler);
   void remove_cycler(PipelineCyclerTrueImpl *cycler);
 
 

+ 17 - 15
panda/src/pipeline/pipelineCyclerTrueImpl.cxx

@@ -56,24 +56,26 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl &copy) :
   nassertv(_num_stages == copy._num_stages);
   nassertv(_num_stages == copy._num_stages);
   _data = new CycleDataNode[_num_stages];
   _data = new CycleDataNode[_num_stages];
 
 
-  // It's no longer critically important that we preserve pointerwise
-  // equivalence between different stages in the copy, but it doesn't cost
-  // much and might be a little more efficient, so we do it anyway.
-  typedef pmap<CycleData *, PT(CycleData) > Pointers;
-  Pointers pointers;
-
-  for (int i = 0; i < _num_stages; ++i) {
-    PT(CycleData) &new_pt = pointers[copy._data[i]._cdata];
-    if (new_pt == nullptr) {
-      new_pt = copy._data[i]._cdata->make_copy();
+  if (_num_stages == 1) {
+    _data[0]._cdata = copy._data[0]._cdata->make_copy();
+  }
+  else {
+    // It's no longer critically important that we preserve pointerwise
+    // equivalence between different stages in the copy, but it doesn't cost
+    // much and might be a little more efficient, so we do it anyway.
+    typedef pmap<CycleData *, PT(CycleData) > Pointers;
+    Pointers pointers;
+
+    for (int i = 0; i < _num_stages; ++i) {
+      PT(CycleData) &new_pt = pointers[copy._data[i]._cdata];
+      if (new_pt == nullptr) {
+        new_pt = copy._data[i]._cdata->make_copy();
+      }
+      _data[i]._cdata = new_pt.p();
     }
     }
-    _data[i]._cdata = new_pt.p();
   }
   }
 
 
-  _pipeline->add_cycler(this);
-  if (copy._dirty) {
-    _pipeline->add_dirty_cycler(this);
-  }
+  _pipeline->add_cycler(this, copy._dirty != 0);
 }
 }
 
 
 /**
 /**

+ 1 - 1
panda/src/vision/arToolKit.cxx

@@ -423,7 +423,7 @@ analyze(Texture *tex, bool do_flip_texture) {
 
 
   if (arDetectMarker(data, _threshold * 256, &marker_info, &marker_num) < 0) {
   if (arDetectMarker(data, _threshold * 256, &marker_info, &marker_num) < 0) {
     vision_cat.error() << "ARToolKit detection error.\n";
     vision_cat.error() << "ARToolKit detection error.\n";
-    delete data;
+    delete[] data;
     return;
     return;
   }
   }
 
 

+ 54 - 28
pandatool/src/assimp/assimpLoader.cxx

@@ -215,9 +215,7 @@ build_graph() {
   }
   }
 
 
   // And then the meshes.
   // And then the meshes.
-  _geoms = new PT(Geom)[_scene->mNumMeshes];
-  _geom_matindices = new unsigned int[_scene->mNumMeshes];
-  _characters = new PT(Character)[_scene->mNumMeshes];
+  _geoms = new Geoms[_scene->mNumMeshes];
   for (size_t i = 0; i < _scene->mNumMeshes; ++i) {
   for (size_t i = 0; i < _scene->mNumMeshes; ++i) {
     load_mesh(i);
     load_mesh(i);
   }
   }
@@ -235,8 +233,6 @@ build_graph() {
   delete[] _textures;
   delete[] _textures;
   delete[] _mat_states;
   delete[] _mat_states;
   delete[] _geoms;
   delete[] _geoms;
-  delete[] _geom_matindices;
-  delete[] _characters;
 }
 }
 
 
 /**
 /**
@@ -1022,25 +1018,35 @@ load_mesh(size_t index) {
   }
   }
 
 
   // Create a geom and add the primitives to it.
   // Create a geom and add the primitives to it.
-  PT(Geom) geom = new Geom(vdata);
+  Geoms &geoms = _geoms[index];
+  geoms._mat_index = mesh.mMaterialIndex;
+
   if (points->get_num_primitives() > 0) {
   if (points->get_num_primitives() > 0) {
-    geom->add_primitive(points);
+    geoms._points = new Geom(vdata);
+    geoms._points->add_primitive(points);
   }
   }
   if (lines->get_num_primitives() > 0) {
   if (lines->get_num_primitives() > 0) {
-    geom->add_primitive(lines);
+    geoms._lines = new Geom(vdata);
+    geoms._lines->add_primitive(lines);
   }
   }
   if (triangles->get_num_primitives() > 0) {
   if (triangles->get_num_primitives() > 0) {
-    geom->add_primitive(triangles);
+    geoms._triangles = new Geom(vdata);
+    geoms._triangles->add_primitive(triangles);
   }
   }
 
 
-  _geoms[index] = geom;
-  _geom_matindices[index] = mesh.mMaterialIndex;
-
   if (character) {
   if (character) {
-    _characters[index] = character;
+    geoms._character = character;
 
 
     PT(GeomNode) gnode = new GeomNode("");
     PT(GeomNode) gnode = new GeomNode("");
-    gnode->add_geom(geom);
+    if (geoms._points != nullptr) {
+      gnode->add_geom(geoms._points);
+    }
+    if (geoms._lines != nullptr) {
+      gnode->add_geom(geoms._lines);
+    }
+    if (geoms._triangles != nullptr) {
+      gnode->add_geom(geoms._triangles);
+    }
     gnode->set_state(_mat_states[mesh.mMaterialIndex]);
     gnode->set_state(_mat_states[mesh.mMaterialIndex]);
     character->add_child(gnode);
     character->add_child(gnode);
   }
   }
@@ -1081,21 +1087,32 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
   }
   }
   else if (node.mNumMeshes == 1) {
   else if (node.mNumMeshes == 1) {
     size_t meshIndex = node.mMeshes[0];
     size_t meshIndex = node.mMeshes[0];
+    const Geoms &geoms = _geoms[meshIndex];
 
 
-    Character *character = _characters[meshIndex];
-    if (character != nullptr) {
+    if (geoms._character != nullptr) {
       pnode = new PandaNode(name);
       pnode = new PandaNode(name);
-      pnode->add_child(character);
-    } else {
-      const RenderState *state = _mat_states[_geom_matindices[meshIndex]];
+      pnode->add_child(geoms._character);
+    }
+    else {
       PT(GeomNode) gnode = new GeomNode(name);
       PT(GeomNode) gnode = new GeomNode(name);
-      gnode->add_geom(_geoms[meshIndex]);
+      const RenderState *state = _mat_states[geoms._mat_index];
+      if (geoms._points != nullptr) {
+        gnode->add_geom(geoms._points);
+      }
+      if (geoms._lines != nullptr) {
+        gnode->add_geom(geoms._lines);
+      }
+      if (geoms._triangles != nullptr) {
+        gnode->add_geom(geoms._triangles);
+      }
       if (state != nullptr) {
       if (state != nullptr) {
         // Only set the state on the GeomNode if there are no child nodes.
         // Only set the state on the GeomNode if there are no child nodes.
         if (node.mNumChildren == 0) {
         if (node.mNumChildren == 0) {
           gnode->set_state(state);
           gnode->set_state(state);
         } else {
         } else {
-          gnode->set_geom_state(0, state);
+          for (int i = 0; i < gnode->get_num_geoms(); ++i) {
+            gnode->set_geom_state(i, state);
+          }
         }
         }
       }
       }
       pnode = gnode;
       pnode = gnode;
@@ -1109,7 +1126,7 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
     for (size_t i = 0; i < node.mNumMeshes; ++i) {
     for (size_t i = 0; i < node.mNumMeshes; ++i) {
       size_t meshIndex = node.mMeshes[i];
       size_t meshIndex = node.mMeshes[i];
 
 
-      if (_characters[meshIndex] == nullptr) {
+      if (_geoms[meshIndex]._character == nullptr) {
         character_only = false;
         character_only = false;
         break;
         break;
       }
       }
@@ -1125,16 +1142,25 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
 
 
     for (size_t i = 0; i < node.mNumMeshes; ++i) {
     for (size_t i = 0; i < node.mNumMeshes; ++i) {
       size_t meshIndex = node.mMeshes[i];
       size_t meshIndex = node.mMeshes[i];
+      const Geoms &geoms = _geoms[meshIndex];
 
 
-      Character *character = _characters[meshIndex];
-      if (character != nullptr) {
+      if (geoms._character != nullptr) {
         // An animated mesh, which already is converted as Character with an
         // An animated mesh, which already is converted as Character with an
         // attached GeomNode.
         // attached GeomNode.
-        pnode->add_child(character);
-      } else {
+        pnode->add_child(geoms._character);
+      }
+      else {
         // A non-animated mesh.
         // A non-animated mesh.
-        gnode->add_geom(_geoms[node.mMeshes[i]],
-          _mat_states[_geom_matindices[meshIndex]]);
+        const RenderState *state = _mat_states[geoms._mat_index];
+        if (geoms._points != nullptr) {
+          gnode->add_geom(geoms._points, state);
+        }
+        if (geoms._lines != nullptr) {
+          gnode->add_geom(geoms._lines, state);
+        }
+        if (geoms._triangles != nullptr) {
+          gnode->add_geom(geoms._triangles, state);
+        }
       }
       }
     }
     }
   }
   }

+ 9 - 3
pandatool/src/assimp/assimpLoader.h

@@ -61,13 +61,19 @@ private:
   Assimp::Importer _importer;
   Assimp::Importer _importer;
   const aiScene *_scene;
   const aiScene *_scene;
 
 
+  struct Geoms {
+    PT(Geom) _points;
+    PT(Geom) _lines;
+    PT(Geom) _triangles;
+    PT(Character) _character;
+    unsigned int _mat_index = 0;
+  };
+
   // These arrays are temporarily used during the build_graph run.
   // These arrays are temporarily used during the build_graph run.
   PT(Texture) *_textures;
   PT(Texture) *_textures;
   CPT(RenderState) *_mat_states;
   CPT(RenderState) *_mat_states;
-  PT(Geom) *_geoms;
-  unsigned int *_geom_matindices;
+  Geoms *_geoms;
   BoneMap _bonemap;
   BoneMap _bonemap;
-  PT(Character) *_characters;
 
 
   const aiNode *find_node(const aiNode &root, const aiString &name);
   const aiNode *find_node(const aiNode &root, const aiString &name);