Fix crash that happens when using OdeTriMeshData incorrectly

This commit is contained in:
rdb 2016-09-11 12:23:28 +02:00
parent 558f84a95f
commit a0b2a98178

View File

@ -55,10 +55,15 @@ print_data(const string &marker) {
void OdeTriMeshData:: void OdeTriMeshData::
remove_data(OdeTriMeshData *data) { remove_data(OdeTriMeshData *data) {
odetrimeshdata_cat.debug() << get_class_type() << "::remove_data(" << data->get_id() << ")" << "\n"; if (odetrimeshdata_cat.is_debug()) {
nassertv(_tri_mesh_data_map != (TriMeshDataMap *)NULL); odetrimeshdata_cat.debug()
TriMeshDataMap::iterator iter; << get_class_type() << "::remove_data(" << data->get_id() << ")" << "\n";
}
if (_tri_mesh_data_map == (TriMeshDataMap *)NULL) {
return;
}
TriMeshDataMap::iterator iter;
for (iter = _tri_mesh_data_map->begin(); for (iter = _tri_mesh_data_map->begin();
iter != _tri_mesh_data_map->end(); iter != _tri_mesh_data_map->end();
++iter) { ++iter) {
@ -154,8 +159,13 @@ operator = (const OdeTriMeshData &other) {
void OdeTriMeshData:: void OdeTriMeshData::
process_model(const NodePath& model, bool &use_normals) { process_model(const NodePath& model, bool &use_normals) {
// TODO: assert if _vertices is something other than 0. // TODO: assert if _vertices is something other than 0.
ostream &out = odetrimeshdata_cat.debug(); if (odetrimeshdata_cat.is_debug()) {
out << "process_model(" << model << ")" << "\n"; odetrimeshdata_cat.debug()
<< "process_model(" << model << ")" << "\n";
}
if (model.is_empty()) {
return;
}
NodePathCollection geomNodePaths = model.find_all_matches("**/+GeomNode"); NodePathCollection geomNodePaths = model.find_all_matches("**/+GeomNode");
if (model.node()->get_type() == GeomNode::get_class_type()) { if (model.node()->get_type() == GeomNode::get_class_type()) {