From 33691d72ecc04d450b9a8a5e6114b8341fafe77a Mon Sep 17 00:00:00 2001 From: "Stephen A. Imhoff" Date: Wed, 29 Jun 2022 17:06:19 +0200 Subject: [PATCH] bullet: Fix assertion when reconstructing BulletConvexHullShape from bam Fixes #1251 Closes #1252 --- panda/src/bullet/bulletConvexHullShape.cxx | 2 +- tests/bullet/test_bullet_bam.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index b61722e773..89ec5b2034 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -194,7 +194,7 @@ make_from_bam(const FactoryParams ¶ms) { void BulletConvexHullShape:: fillin(DatagramIterator &scan, BamReader *manager) { BulletShape::fillin(scan, manager); - nassertv(_shape == nullptr); + nassertv(_shape); _shape->setMargin(scan.get_stdfloat()); unsigned int num_points = scan.get_uint32(); diff --git a/tests/bullet/test_bullet_bam.py b/tests/bullet/test_bullet_bam.py index ae20f2d47a..d26a6c4117 100644 --- a/tests/bullet/test_bullet_bam.py +++ b/tests/bullet/test_bullet_bam.py @@ -133,6 +133,26 @@ def test_sphere_shape(): assert shape.radius == shape2.radius +def test_convex_shape(): + shape = bullet.BulletConvexHullShape() + shape.add_array([ + (-1.0, -1.0, -1.0), + (1.0, -1.0, -1.0), + (-1.0, 1.0, -1.0), + (-1.0, -1.0, 1.0), + (1.0, 1.0, -1.0), + (1.0, -1.0, 1.0), + (-1.0, 1.0, 1.0), + (1.0, 1.0, 1.0), + ]) + shape.margin = 0.5 + + shape2 = reconstruct(shape) + + assert type(shape) is type(shape2) + assert shape.margin == shape2.margin + + def test_ghost(): node = bullet.BulletGhostNode("some ghost node")