diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index 0d1a97fd4e..98dce53577 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -15,6 +15,18 @@ TypeHandle BulletPlaneShape::_type_handle; +/** + * Creates a plane shape from a plane definition. + */ +BulletPlaneShape:: +BulletPlaneShape(LPlane plane) { + + btVector3 btNormal = LVecBase3_to_btVector3(plane.get_normal()); + + _shape = new btStaticPlaneShape(btNormal, plane.get_w()); + _shape->setUserPointer(this); +} + /** * */ @@ -50,6 +62,17 @@ ptr() const { return _shape; } +/** + * + */ +LPlane BulletPlaneShape:: +get_plane() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + btVector3 normal = _shape->getPlaneNormal(); + return LPlane(normal[0], normal[1], normal[2], (PN_stdfloat)_shape->getPlaneConstant()); +} + /** * */ diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index 95aa16d9ef..4521007ecb 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -32,15 +32,18 @@ private: INLINE BulletPlaneShape() : _shape(nullptr) {}; PUBLISHED: + explicit BulletPlaneShape(LPlane plane); explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); BulletPlaneShape(const BulletPlaneShape ©); INLINE ~BulletPlaneShape(); + LPlane get_plane() const; LVector3 get_plane_normal() const; PN_stdfloat get_plane_constant() const; static BulletPlaneShape *make_from_solid(const CollisionPlane *solid); + MAKE_PROPERTY(plane, get_plane); MAKE_PROPERTY(plane_normal, get_plane_normal); MAKE_PROPERTY(plane_constant, get_plane_constant);