bullet: Fix assertion when reconstructing BulletConvexHullShape from bam

Fixes #1251
Closes #1252
This commit is contained in:
Stephen A. Imhoff 2022-06-29 17:06:19 +02:00 committed by rdb
parent 3fc579c7d4
commit 33691d72ec
2 changed files with 21 additions and 1 deletions

View File

@ -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();

View File

@ -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")