From 00de2771fcf33cd0896ff48f90524703c6538fe6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 22 Oct 2022 10:31:26 +0200 Subject: [PATCH 1/4] dcparser: fix Python 3 regression unpacking uint types Backport of d1d0dab9900c65aad7617e709428c812c6b56b37 (#1380) Co-authored-by: Nat <56046513+NathaanTFM@users.noreply.github.com> --- direct/src/dcparser/dcPacker.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index 4ba255a78c..544c9d2fd1 100644 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -847,7 +847,7 @@ unpack_object() { { unsigned int value = unpack_uint(); #if PY_MAJOR_VERSION >= 3 - object = PyLong_FromLong(value); + object = PyLong_FromUnsignedLong(value); #else if (value & 0x80000000) { object = PyLong_FromUnsignedLong(value); From 8bed85740f62e59c393a53c0de6661a5528f5931 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 22 Oct 2022 15:36:14 +0200 Subject: [PATCH 2/4] pgraph: Fix race condition when destructing/constructing NodePaths Fixes #1366 --- panda/src/pgraph/pandaNode.cxx | 36 ++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 0baf30c7dd..e332ef18f5 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -2898,11 +2898,21 @@ get_component(NodePathComponent *parent, PandaNode *child_node, // First, walk through the list of NodePathComponents we already have on the // child, looking for one that already exists, referencing the indicated // parent component. - Paths::const_iterator pi; - for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { - if ((*pi)->get_next(pipeline_stage, current_thread) == parent) { + for (NodePathComponent *child : child_node->_paths) { + if (child->get_next(pipeline_stage, current_thread) == parent) { // If we already have such a component, just return it. - return (*pi); + // But before we do, we have to make sure it's not in the middle of being + // destructed. +#ifdef HAVE_THREADS + if (child->ref_if_nonzero()) { + PT(NodePathComponent) result; + result.cheat() = child; + return result; + } +#else + // If we're not building with threading, increment as normal. + return child; +#endif } } @@ -2940,11 +2950,21 @@ get_top_component(PandaNode *child_node, bool force, int pipeline_stage, // Walk through the list of NodePathComponents we already have on the child, // looking for one that already exists as a top node. - Paths::const_iterator pi; - for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { - if ((*pi)->is_top_node(pipeline_stage, current_thread)) { + for (NodePathComponent *child : child_node->_paths) { + if (child->is_top_node(pipeline_stage, current_thread)) { // If we already have such a component, just return it. - return (*pi); + // But before we do, we have to make sure it's not in the middle of being + // destructed. +#ifdef HAVE_THREADS + if (child->ref_if_nonzero()) { + PT(NodePathComponent) result; + result.cheat() = child; + return result; + } +#else + // If we're not building with threading, increment as normal. + return child; +#endif } } From d0b7574384d0615b594d1f441836cdfd00c1954c Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 22 Oct 2022 15:49:40 +0200 Subject: [PATCH 3/4] pgraph: Add missing `PandaNodePipelineReader::get_into_collide_mask()` --- panda/src/pgraph/pandaNode.I | 8 ++++++++ panda/src/pgraph/pandaNode.h | 1 + 2 files changed, 9 insertions(+) diff --git a/panda/src/pgraph/pandaNode.I b/panda/src/pgraph/pandaNode.I index 8cbea5c871..00944599d0 100644 --- a/panda/src/pgraph/pandaNode.I +++ b/panda/src/pgraph/pandaNode.I @@ -1476,6 +1476,14 @@ has_tag(const std::string &key) const { return _cdata->_tag_data.find(key) >= 0; } +/** + * Returns the "into" collide mask for this node. + */ +INLINE CollideMask PandaNodePipelineReader:: +get_into_collide_mask() const { + return _cdata->_into_collide_mask; +} + /** * Returns the union of all into_collide_mask() values set at CollisionNodes * at this level and below. diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index cec5e220a2..325b5ea508 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -880,6 +880,7 @@ public: INLINE std::string get_tag(const std::string &key) const; INLINE bool has_tag(const std::string &key) const; + INLINE CollideMask get_into_collide_mask() const; INLINE CollideMask get_net_collide_mask() const; INLINE const RenderAttrib *get_off_clip_planes() const; INLINE const BoundingVolume *get_bounds() const; From 6fe25d3edcb7863c7344e84d96d8c333c786291e Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 22 Oct 2022 16:03:52 +0200 Subject: [PATCH 4/4] shader: Fix attr_fogcolor not picking up inter-frame changes Fixes shader generator not responding to fog color changes --- panda/src/gobj/shader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index ee26438d4c..a586a4e928 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -391,7 +391,7 @@ cp_dependency(ShaderMatInput inp) { dep |= SSD_colorscale; } if (inp == SMO_attr_fog || inp == SMO_attr_fogcolor) { - dep |= SSD_fog; + dep |= SSD_fog | SSD_frame; } if ((inp == SMO_model_to_view) || (inp == SMO_view_to_model) ||