From b1942e8065390c82048b0e64220df5fe0dd102c8 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jan 2021 13:52:03 +0100 Subject: [PATCH 01/11] collide: Add wires to CollisionBox viz This should make it a lot easier to see the box as opposed to looking at a continuous white shape. --- panda/src/collide/collisionBox.cxx | 35 ++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index 2f5385b9bf..168844f37a 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -29,6 +29,7 @@ #include "cmath.h" #include "mathNumbers.h" #include "geom.h" +#include "geomLines.h" #include "geomTriangles.h" #include "geomVertexWriter.h" #include "config_mathutil.h" @@ -947,11 +948,37 @@ fill_viz_geom() { tris->add_vertices(3, 7, 0); tris->add_vertices(0, 7, 4); - PT(Geom) geom = new Geom(vdata); - geom->add_primitive(tris); + PT(GeomLines) lines = new GeomLines(Geom::UH_static); - _viz_geom->add_geom(geom, get_solid_viz_state()); - _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); + // Bottom + lines->add_vertices(0, 1); + lines->add_vertices(1, 2); + lines->add_vertices(0, 3); + lines->add_vertices(2, 3); + + // Top + lines->add_vertices(4, 5); + lines->add_vertices(5, 6); + lines->add_vertices(4, 7); + lines->add_vertices(6, 7); + + // Sides + lines->add_vertices(0, 4); + lines->add_vertices(1, 5); + lines->add_vertices(2, 6); + lines->add_vertices(3, 7); + + PT(Geom) geom1 = new Geom(vdata); + geom1->add_primitive(tris); + + PT(Geom) geom2 = new Geom(vdata); + geom2->add_primitive(lines); + + _viz_geom->add_geom(geom1, get_solid_viz_state()); + _viz_geom->add_geom(geom2, get_wireframe_viz_state()); + + _bounds_viz_geom->add_geom(geom1, get_solid_bounds_viz_state()); + _bounds_viz_geom->add_geom(geom2, get_wireframe_viz_state()); } /** From 79dae16a2c6a7c01f37280045af55a10a5ae653d Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jan 2021 20:05:36 +0100 Subject: [PATCH 02/11] glgsg: Show error for unrecognized p3d_TextureXYZ input --- panda/src/glstuff/glShaderContext_src.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 424cf2ca83..8b253eab72 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1007,6 +1007,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { else if (noprefix.compare(7, string::npos, "Emission") == 0) { bind._part = Shader::STO_stage_emission_i; } + else { + GLCAT.error() + << "Unrecognized shader input name: p3d_" << noprefix << "\n"; + } for (bind._stage = 0; bind._stage < param_size; ++bind._stage) { _glgsg->_glUniform1i(p + bind._stage, _shader->_tex_spec.size()); From 60f3ac5163b96b7ab4ab06c57a2ce60679e4e5e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jan 2021 20:06:32 +0100 Subject: [PATCH 03/11] gobj: Assert instead of crash when printing unresolved GV(A)D --- panda/src/gobj/geomVertexArrayData.cxx | 10 +++++++--- panda/src/gobj/geomVertexData.I | 1 + panda/src/gobj/geomVertexData.cxx | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index 4ab1baf165..75a9a5db20 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -59,8 +59,10 @@ ALLOC_DELETED_CHAIN_DEF(GeomVertexArrayDataHandle); * file. */ GeomVertexArrayData:: -GeomVertexArrayData() : SimpleLruPage(0) { - _contexts = nullptr; +GeomVertexArrayData() : + SimpleLruPage(0), + _array_format(nullptr), + _contexts(nullptr) { // Can't put it in the LRU until it has been read in and made valid. } @@ -180,7 +182,8 @@ set_usage_hint(GeomVertexArrayData::UsageHint usage_hint) { */ void GeomVertexArrayData:: output(std::ostream &out) const { - out << get_num_rows() << " rows: " << *get_array_format(); + nassertv(_array_format != nullptr); + out << get_num_rows() << " rows: " << *_array_format; } /** @@ -188,6 +191,7 @@ output(std::ostream &out) const { */ void GeomVertexArrayData:: write(std::ostream &out, int indent_level) const { + nassertv(_array_format != nullptr); _array_format->write_with_data(out, indent_level, this); } diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index d0c6bba632..f2edebdeaa 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -582,6 +582,7 @@ CacheEntry(GeomVertexData *source, CacheKey &&key) noexcept : */ INLINE GeomVertexData::CData:: CData() : + _format(nullptr), _usage_hint(UH_unspecified) { } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index d77ca492a1..5eb3ac6352 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -1268,7 +1268,9 @@ output(ostream &out) const { if (!get_name().empty()) { out << get_name() << " "; } - out << get_num_rows() << " rows: " << *get_format(); + const GeomVertexFormat *format = get_format(); + nassertv(format != nullptr); + out << get_num_rows() << " rows: " << *format; } /** @@ -1279,8 +1281,15 @@ write(ostream &out, int indent_level) const { if (!get_name().empty()) { indent(out, indent_level) << get_name() << "\n"; } - get_format()->write_with_data(out, indent_level + 2, this); - CPT(TransformBlendTable) table = get_transform_blend_table(); + CPT(TransformBlendTable) table; + const GeomVertexFormat *format = nullptr; + { + CDReader cdata(_cycler); + format = cdata->_format; + table = cdata->_transform_blend_table.get_read_pointer(); + } + nassertv(format != nullptr); + format->write_with_data(out, indent_level + 2, this); if (table != nullptr) { indent(out, indent_level) << "Transform blend table:\n"; From a1e4cf059ff95c8f265d58132c39e648d4388831 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 31 Jan 2021 18:12:43 +0100 Subject: [PATCH 04/11] glgsg: Fix attempt to detect glTexStorage1D in OpenGL ES --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 12 +++++++++--- panda/src/glstuff/glGraphicsStateGuardian_src.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 45eac22e9e..bd6112107a 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1030,8 +1030,10 @@ reset() { #endif _supports_tex_storage = true; +#ifndef OPENGLES _glTexStorage1D = (PFNGLTEXSTORAGE1DPROC) get_extension_func("glTexStorage1D"); +#endif _glTexStorage2D = (PFNGLTEXSTORAGE2DPROC) get_extension_func("glTexStorage2D"); _glTexStorage3D = (PFNGLTEXSTORAGE3DPROC) @@ -1041,8 +1043,6 @@ reset() { else if (has_extension("GL_EXT_texture_storage")) { _supports_tex_storage = true; - _glTexStorage1D = (PFNGLTEXSTORAGE1DPROC) - get_extension_func("glTexStorage1DEXT"); _glTexStorage2D = (PFNGLTEXSTORAGE2DPROC) get_extension_func("glTexStorage2DEXT"); _glTexStorage3D = (PFNGLTEXSTORAGE3DPROC) @@ -1051,7 +1051,11 @@ reset() { #endif if (_supports_tex_storage) { - if (_glTexStorage1D == nullptr || _glTexStorage2D == nullptr || _glTexStorage3D == nullptr) { + if ( +#ifndef OPENGLES + _glTexStorage1D == nullptr || +#endif + _glTexStorage2D == nullptr || _glTexStorage3D == nullptr) { GLCAT.warning() << "Immutable texture storage advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_tex_storage = false; @@ -13005,8 +13009,10 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { case Texture::TT_buffer_texture: // Won't get here, but squelch compiler warning case Texture::TT_1d_texture: +#ifndef OPENGLES _glTexStorage1D(target, num_levels, internal_format, width); break; +#endif case Texture::TT_2d_texture: case Texture::TT_cube_map: case Texture::TT_1d_texture_array: diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 4fa16e067e..b3974522ea 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -785,7 +785,9 @@ public: #endif bool _supports_tex_storage; +#ifndef OPENGLES PFNGLTEXSTORAGE1DPROC _glTexStorage1D; +#endif PFNGLTEXSTORAGE2DPROC _glTexStorage2D; PFNGLTEXSTORAGE3DPROC _glTexStorage3D; From 25e7e20ccd0e02873c576cda990da33883348028 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 5 Feb 2021 01:33:26 +0100 Subject: [PATCH 05/11] Update BACKERS.md [skip ci] --- BACKERS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BACKERS.md b/BACKERS.md index 82715b9749..637d15c598 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -15,6 +15,7 @@ This is a list of all the people who are contributing financially to Panda3D. I * [Mitchell Stokes](https://opencollective.com/mitchell-stokes) * [Daniel Stokes](https://opencollective.com/daniel-stokes) * [David Rose](https://opencollective.com/david-rose) +* [Robert Clarke](https://opencollective.com/robert-clarke) ## Benefactors From a9f3940577af112faea08194ffeb7d063ccfab6f Mon Sep 17 00:00:00 2001 From: Stephen Imhoff Date: Fri, 5 Feb 2021 19:38:27 +0000 Subject: [PATCH 06/11] Add bullet ghost node test --- tests/bullet/test_bullet_bam.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/bullet/test_bullet_bam.py b/tests/bullet/test_bullet_bam.py index 386e044f9f..ae20f2d47a 100644 --- a/tests/bullet/test_bullet_bam.py +++ b/tests/bullet/test_bullet_bam.py @@ -131,3 +131,12 @@ def test_sphere_shape(): assert shape.margin == shape2.margin assert shape.name == shape2.name assert shape.radius == shape2.radius + + +def test_ghost(): + node = bullet.BulletGhostNode("some ghost node") + + node2 = reconstruct(node) + + assert type(node) is type(node2) + assert node.name == node2.name From cc4701d2996a52468dfe224f9b1abe475320109c Mon Sep 17 00:00:00 2001 From: Stephen Imhoff Date: Fri, 5 Feb 2021 20:28:17 +0000 Subject: [PATCH 07/11] Add ability to persist ghost nodes. --- panda/src/bullet/bulletGhostNode.cxx | 24 ++++++++++++++++++++++++ panda/src/bullet/bulletGhostNode.h | 6 ++++++ panda/src/bullet/config_bullet.cxx | 1 + 3 files changed, 31 insertions(+) diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index d3dcb7aaf5..38ccb1811c 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -171,3 +171,27 @@ do_sync_b2p() { _sync_disable = false; } } + +/** + * Tells the BamReader how to create objects of type BulletGhostNode. + */ +void BulletGhostNode:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); +} + +/** + * This function is called by the BamReader's factory when a new object of + * this type is encountered in the Bam file. It should create the ghost node. + */ +TypedWritable *BulletGhostNode:: +make_from_bam(const FactoryParams ¶ms) { + BulletGhostNode *param = new BulletGhostNode; + DatagramIterator scan; + BamReader *manager; + + parse_params(params, scan, manager); + param->fillin(scan, manager); + + return param; +} diff --git a/panda/src/bullet/bulletGhostNode.h b/panda/src/bullet/bulletGhostNode.h index a76c0ce8a1..1efc47a484 100644 --- a/panda/src/bullet/bulletGhostNode.h +++ b/panda/src/bullet/bulletGhostNode.h @@ -59,6 +59,12 @@ private: void do_transform_changed(); +public: + static void register_with_read_factory(); + +protected: + static TypedWritable *make_from_bam(const FactoryParams ¶ms); + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 140c7d0efc..e4627c931e 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -189,6 +189,7 @@ init_libbullet() { BulletDebugNode::register_with_read_factory(); BulletPlaneShape::register_with_read_factory(); BulletRigidBodyNode::register_with_read_factory(); + BulletGhostNode::register_with_read_factory(); BulletSphereShape::register_with_read_factory(); BulletTriangleMesh::register_with_read_factory(); BulletTriangleMeshShape::register_with_read_factory(); From 642f4a4e55ed76124264d7fb6a10e4a327d05efe Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 5 Feb 2021 23:48:41 +0100 Subject: [PATCH 08/11] bullet: Implement make_copy() for BulletGhostNode --- panda/src/bullet/bulletGhostNode.cxx | 33 ++++++++++++++++++++++++++++ panda/src/bullet/bulletGhostNode.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index 38ccb1811c..d86dd59598 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -41,6 +41,39 @@ BulletGhostNode(const char *name) : BulletBodyNode(name) { _ghost->setCollisionShape(_shape); } +/** + * Do not call the copy constructor directly; instead, use make_copy() or + * copy_subgraph() to make a copy of a node. + */ +BulletGhostNode:: +BulletGhostNode(const BulletGhostNode ©) : + BulletBodyNode(copy), + _sync(TransformState::make_identity()), + _sync_disable(false), + _sync_local(false) +{ + // Initial transform - the node has no parent yet, so this is the local one + btTransform trans = TransformState_to_btTrans(get_transform()); + + // Ghost object + _ghost = new btPairCachingGhostObject(); + _ghost->setUserPointer(this); + _ghost->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE); + _ghost->setWorldTransform(trans); + _ghost->setInterpolationWorldTransform(trans); + _ghost->setCollisionShape(_shape); +} + +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ +PandaNode *BulletGhostNode:: +make_copy() const { + return new BulletGhostNode(*this); +} + /** * */ diff --git a/panda/src/bullet/bulletGhostNode.h b/panda/src/bullet/bulletGhostNode.h index 1efc47a484..3c12ff0201 100644 --- a/panda/src/bullet/bulletGhostNode.h +++ b/panda/src/bullet/bulletGhostNode.h @@ -61,8 +61,10 @@ private: public: static void register_with_read_factory(); + virtual PandaNode *make_copy() const; protected: + BulletGhostNode(const BulletGhostNode ©); static TypedWritable *make_from_bam(const FactoryParams ¶ms); public: From c89631488b16265f22919be8f79b24a24e986c6a Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 5 Feb 2021 23:49:15 +0100 Subject: [PATCH 09/11] prc: Add properties to ConfigPageManager --- dtool/src/prc/configPageManager.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dtool/src/prc/configPageManager.h b/dtool/src/prc/configPageManager.h index 5afba59796..9a775f7b63 100644 --- a/dtool/src/prc/configPageManager.h +++ b/dtool/src/prc/configPageManager.h @@ -63,6 +63,16 @@ PUBLISHED: static ConfigPageManager *get_global_ptr(); +PUBLISHED: + MAKE_PROPERTY(search_path, get_search_path); + + MAKE_SEQ_PROPERTY(prc_patterns, get_num_prc_patterns, get_prc_pattern); + MAKE_SEQ_PROPERTY(prc_encrypted_patterns, get_num_prc_encrypted_patterns, get_prc_encrypted_pattern); + MAKE_SEQ_PROPERTY(prc_executable_patterns, get_num_prc_executable_patterns, get_prc_executable_pattern); + + MAKE_SEQ_PROPERTY(implicit_pages, get_num_implicit_pages, get_implicit_page); + MAKE_SEQ_PROPERTY(explicit_pages, get_num_explicit_pages, get_explicit_page); + public: INLINE void mark_unsorted(); From 5095778324e3621222ed941ab98f38f11fbfb0f5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 6 Feb 2021 01:19:00 +0100 Subject: [PATCH 10/11] Update BACKERS.md [skip ci] --- BACKERS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BACKERS.md b/BACKERS.md index 637d15c598..7f34cbabbe 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -10,12 +10,12 @@ This is a list of all the people who are contributing financially to Panda3D. I ## Bronze Sponsors -![Bronze Sponsors](https://opencollective.com/panda3d/tiers/bronze-sponsor.svg?avatarHeight=48&width=600) +[ChangeCrab](https://changecrab.com/) ![Bronze Sponsors](https://opencollective.com/panda3d/tiers/bronze-sponsor.svg?avatarHeight=48&width=600) * [Mitchell Stokes](https://opencollective.com/mitchell-stokes) * [Daniel Stokes](https://opencollective.com/daniel-stokes) * [David Rose](https://opencollective.com/david-rose) -* [Robert Clarke](https://opencollective.com/robert-clarke) +* [ChangeCrab](https://changecrab.com) ## Benefactors From 068ceaaf588a15dcc73da71a9806d0bbda99903a Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 6 Feb 2021 01:21:52 +0100 Subject: [PATCH 11/11] event: Clear exception flag after trying asyncio exception import --- panda/src/event/asyncFuture_ext.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/panda/src/event/asyncFuture_ext.cxx b/panda/src/event/asyncFuture_ext.cxx index 5bf7cb3c94..9754142ae3 100644 --- a/panda/src/event/asyncFuture_ext.cxx +++ b/panda/src/event/asyncFuture_ext.cxx @@ -125,6 +125,9 @@ static PyObject *get_done_result(const AsyncFuture *future) { exc_type = PyObject_GetAttrString(module, "CancelledError"); Py_DECREF(module); } + else { + PyErr_Clear(); + } // If we can't get that, we should pretend and make our own. if (exc_type == nullptr) { exc_type = PyErr_NewExceptionWithDoc((char*)"concurrent.futures._base.CancelledError", @@ -218,6 +221,9 @@ result(PyObject *timeout) const { exc_type = PyObject_GetAttrString(module, "TimeoutError"); Py_DECREF(module); } + else { + PyErr_Clear(); + } // If we can't get that, we should pretend and make our own. if (exc_type == nullptr) { exc_type = PyErr_NewExceptionWithDoc((char*)"concurrent.futures._base.TimeoutError",