Added guardiang to BulletTriangleMeshShape CTOR which asserts that meshes have at least one triangle.

This commit is contained in:
enn0x 2011-07-31 19:57:28 +00:00
parent 7ee4f338ac
commit da7458efce
2 changed files with 16 additions and 28 deletions

View File

@ -170,6 +170,8 @@ draw_mask_changed() {
if (_verbose) {
_drawer.setDebugMode(DebugDraw::DBG_DrawWireframe |
DebugDraw::DBG_DrawAabb |
DebugDraw::DBG_DrawText |
DebugDraw::DBG_DrawFeaturesText |
DebugDraw::DBG_DrawContactPoints |
DebugDraw::DBG_DrawConstraints |
DebugDraw::DBG_DrawConstraintLimits);
@ -183,23 +185,6 @@ draw_mask_changed() {
}
}
/*
DBG_DrawWireframe
DBG_DrawAabb
DBG_DrawText
DBG_DrawFeaturesText
DBG_DrawContactPoints
DBG_DrawConstraints
DBG_DrawConstraintLimits
DBG_NoDeactivation
DBG_NoHelpText
DBG_EnableSatComparison
DBG_DisableBulletLCP
DBG_ProfileTimings
DBG_EnableCCD
DBG_FastWireframe
*/
////////////////////////////////////////////////////////////////////
// Function: BulletDebugNode::post_step
// Access: Private
@ -261,17 +246,8 @@ post_step(btDynamicsWorld *world) {
_drawer._triangles.clear();
// Force recompute of bounds
int num_geoms = this->get_num_geoms();
for (int i = 0; i < num_geoms; i++) {
const Geom *geom = this->get_geom(i);
geom->mark_bounds_stale();
}
this->mark_bounds_stale();
// Alternate way, probably a little bit slower
//NodePath np = NodePath::any_path(this);
//np.force_recompute_bounds();
NodePath np = NodePath::any_path(this);
np.force_recompute_bounds();
}
////////////////////////////////////////////////////////////////////

View File

@ -30,6 +30,18 @@ TypeHandle BulletTriangleMeshShape::_type_handle;
BulletTriangleMeshShape::
BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, bool bvh) {
// Assert that mesh is not NULL
if (!mesh) {
bullet_cat.warning() << "mesh is NULL! creating new mesh." << endl;
mesh = new BulletTriangleMesh();
}
// Assert that mesh has at least one triangle
if (mesh->get_num_triangles() == 0) {
bullet_cat.warning() << "mesh has zero triangles! adding degenerated triangle." << endl;
mesh->add_triangle(LPoint3f::zero(), LPoint3f::zero(), LPoint3f::zero());
}
// Retain a pointer to the mesh, to prevent it from being deleted
_mesh = mesh;