فهرست منبع

bullet: Fix assertion when reconstructing BulletConvexHullShape from bam

Fixes #1251
Closes #1252
Stephen A. Imhoff 3 سال پیش
والد
کامیت
33691d72ec
2فایلهای تغییر یافته به همراه21 افزوده شده و 1 حذف شده
  1. 1 1
      panda/src/bullet/bulletConvexHullShape.cxx
  2. 20 0
      tests/bullet/test_bullet_bam.py

+ 1 - 1
panda/src/bullet/bulletConvexHullShape.cxx

@@ -194,7 +194,7 @@ make_from_bam(const FactoryParams &params) {
 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();

+ 20 - 0
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")