bullet: support Plane class in BulletPlaneShape

This commit is contained in:
rdb 2018-07-08 21:13:13 +02:00
parent cf451bde23
commit eda47c7f3b
2 changed files with 26 additions and 0 deletions

View File

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

View File

@ -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 &copy);
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);