diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index 1d60a7a8b2..323d11b255 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -1710,3 +1710,14 @@ class bdist_apps(setuptools.Command): continue 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 = [] diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index fec8f7856c..0fe083fea7 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2885,6 +2885,9 @@ Author-email: etc-panda3d@lists.andrew.cmu.edu ENTRY_POINTS = """[distutils.commands] build_apps = direct.dist.commands:build_apps bdist_apps = direct.dist.commands:bdist_apps + +[setuptools.finalize_distribution_options] +build_apps = direct.dist.commands:finalize_distribution_options """ if not PkgSkip("DIRECT"): diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index b4049a06df..50388be112 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -887,6 +887,8 @@ if __debug__: entry_points += '[distutils.commands]\n' entry_points += 'build_apps = direct.dist.commands:build_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)) diff --git a/panda/CMakeLists.txt b/panda/CMakeLists.txt index e52d0f940c..a49a9b664a 100644 --- a/panda/CMakeLists.txt +++ b/panda/CMakeLists.txt @@ -148,6 +148,9 @@ from .interrogatedb import * set(entry_points_file "[distutils.commands] build_apps = direct.dist.commands:build_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" diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 46cb1fcbad..93a5f5c655 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -1582,6 +1582,12 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { } _enqueued_index_buffers.clear(); + + for (ShaderBuffer *buffer : _enqueued_shader_buffers) { + buffer->prepare_now(this, gsg); + } + + _enqueued_shader_buffers.clear(); } /** diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index d84c74f659..e8a1e973ac 100644 --- a/panda/src/gobj/shader.cxx +++ b/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(); 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()) { // Angled includes are also OK, but we don't search in the directory // of the source file. diff --git a/panda/src/pgraph/light.I b/panda/src/pgraph/light.I index 6dd0428836..d173740607 100644 --- a/panda/src/pgraph/light.I +++ b/panda/src/pgraph/light.I @@ -71,8 +71,8 @@ INLINE void Light:: set_color(const LColor &color) { CDWriter cdata(_cycler); cdata->_color = color; + cdata->_viz_geom_stale = true; _has_color_temperature = false; - mark_viz_stale(); } /** diff --git a/panda/src/pgraph/light.cxx b/panda/src/pgraph/light.cxx index 8631cb5b0b..d70a83c195 100644 --- a/panda/src/pgraph/light.cxx +++ b/panda/src/pgraph/light.cxx @@ -125,7 +125,7 @@ set_color_temperature(PN_stdfloat temperature) { CDWriter cdata(_cycler); cdata->_color = color; - mark_viz_stale(); + cdata->_viz_geom_stale = true; } /** diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 30c1c33b5e..5cd3aa1bd5 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -357,6 +357,42 @@ add_cycler(PipelineCyclerTrueImpl *cycler) { } #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 /** * Marks the indicated cycler as "dirty", meaning it will need to be cycled diff --git a/panda/src/pipeline/pipeline.h b/panda/src/pipeline/pipeline.h index c06bb2ffef..10fec52b60 100644 --- a/panda/src/pipeline/pipeline.h +++ b/panda/src/pipeline/pipeline.h @@ -50,6 +50,7 @@ public: #ifdef THREADED_PIPELINE void add_cycler(PipelineCyclerTrueImpl *cycler); + void add_cycler(PipelineCyclerTrueImpl *cycler, bool dirty); void add_dirty_cycler(PipelineCyclerTrueImpl *cycler); void remove_cycler(PipelineCyclerTrueImpl *cycler); diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx index 714e61c0e4..3378b479e2 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx @@ -56,24 +56,26 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©) : nassertv(_num_stages == copy._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 Pointers; - Pointers pointers; + 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 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(); + 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); } /** diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index 4208ba6eee..ed7d019680 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/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) { vision_cat.error() << "ARToolKit detection error.\n"; - delete data; + delete[] data; return; } diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index 5b022dc83b..80b94a7ca3 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -215,9 +215,7 @@ build_graph() { } // 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) { load_mesh(i); } @@ -235,8 +233,6 @@ build_graph() { delete[] _textures; delete[] _mat_states; 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. - PT(Geom) geom = new Geom(vdata); + Geoms &geoms = _geoms[index]; + geoms._mat_index = mesh.mMaterialIndex; + 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) { - geom->add_primitive(lines); + geoms._lines = new Geom(vdata); + geoms._lines->add_primitive(lines); } 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) { - _characters[index] = character; + geoms._character = character; 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]); character->add_child(gnode); } @@ -1081,21 +1087,32 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) { } else if (node.mNumMeshes == 1) { 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->add_child(character); - } else { - const RenderState *state = _mat_states[_geom_matindices[meshIndex]]; + pnode->add_child(geoms._character); + } + else { 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) { // Only set the state on the GeomNode if there are no child nodes. if (node.mNumChildren == 0) { gnode->set_state(state); } 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; @@ -1109,7 +1126,7 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) { for (size_t i = 0; i < node.mNumMeshes; ++i) { size_t meshIndex = node.mMeshes[i]; - if (_characters[meshIndex] == nullptr) { + if (_geoms[meshIndex]._character == nullptr) { character_only = false; break; } @@ -1125,16 +1142,25 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) { for (size_t i = 0; i < node.mNumMeshes; ++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 // attached GeomNode. - pnode->add_child(character); - } else { + pnode->add_child(geoms._character); + } + else { // 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); + } } } } diff --git a/pandatool/src/assimp/assimpLoader.h b/pandatool/src/assimp/assimpLoader.h index 906a9b5fa9..e323cb1e94 100644 --- a/pandatool/src/assimp/assimpLoader.h +++ b/pandatool/src/assimp/assimpLoader.h @@ -61,13 +61,19 @@ private: Assimp::Importer _importer; 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. PT(Texture) *_textures; CPT(RenderState) *_mat_states; - PT(Geom) *_geoms; - unsigned int *_geom_matindices; + Geoms *_geoms; BoneMap _bonemap; - PT(Character) *_characters; const aiNode *find_node(const aiNode &root, const aiString &name);