|
@@ -20,7 +20,9 @@ OdeTriMeshData::TriMeshDataMap *OdeTriMeshData::_tri_mesh_data_map = nullptr;
|
|
|
|
|
|
|
|
void OdeTriMeshData::
|
|
void OdeTriMeshData::
|
|
|
link_data(dGeomID id, PT(OdeTriMeshData) data) {
|
|
link_data(dGeomID id, PT(OdeTriMeshData) data) {
|
|
|
- odetrimeshdata_cat.debug() << get_class_type() << "::link_data(" << id << "->" << data << ")" << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << get_class_type() << "::link_data(" << id << "->" << data << ")" << "\n";
|
|
|
|
|
+ }
|
|
|
get_tri_mesh_data_map()[id] = data;
|
|
get_tri_mesh_data_map()[id] = data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -36,7 +38,9 @@ get_data(dGeomID id) {
|
|
|
|
|
|
|
|
void OdeTriMeshData::
|
|
void OdeTriMeshData::
|
|
|
unlink_data(dGeomID id) {
|
|
unlink_data(dGeomID id) {
|
|
|
- odetrimeshdata_cat.debug() << get_class_type() << "::unlink_data(" << id << ")" << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << get_class_type() << "::unlink_data(" << id << ")" << "\n";
|
|
|
|
|
+ }
|
|
|
nassertv(_tri_mesh_data_map != nullptr);
|
|
nassertv(_tri_mesh_data_map != nullptr);
|
|
|
TriMeshDataMap::iterator iter = _tri_mesh_data_map->find(id);
|
|
TriMeshDataMap::iterator iter = _tri_mesh_data_map->find(id);
|
|
|
if (iter != _tri_mesh_data_map->end()) {
|
|
if (iter != _tri_mesh_data_map->end()) {
|
|
@@ -46,11 +50,13 @@ unlink_data(dGeomID id) {
|
|
|
|
|
|
|
|
void OdeTriMeshData::
|
|
void OdeTriMeshData::
|
|
|
print_data(const std::string &marker) {
|
|
print_data(const std::string &marker) {
|
|
|
- odetrimeshdata_cat.debug() << get_class_type() << "::print_data(" << marker << ")\n";
|
|
|
|
|
- const TriMeshDataMap &data_map = get_tri_mesh_data_map();
|
|
|
|
|
- TriMeshDataMap::const_iterator iter = data_map.begin();
|
|
|
|
|
- for (;iter != data_map.end(); ++iter) {
|
|
|
|
|
- odetrimeshdata_cat.debug() << "\t" << iter->first << " : " << iter->second << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << get_class_type() << "::print_data(" << marker << ")\n";
|
|
|
|
|
+ const TriMeshDataMap &data_map = get_tri_mesh_data_map();
|
|
|
|
|
+ TriMeshDataMap::const_iterator iter = data_map.begin();
|
|
|
|
|
+ for (;iter != data_map.end(); ++iter) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << "\t" << iter->first << " : " << iter->second << "\n";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -95,11 +101,15 @@ OdeTriMeshData(const NodePath& model, bool use_normals) :
|
|
|
_normals(nullptr),
|
|
_normals(nullptr),
|
|
|
_num_vertices(0),
|
|
_num_vertices(0),
|
|
|
_num_faces(0) {
|
|
_num_faces(0) {
|
|
|
- odetrimeshdata_cat.debug() << get_type() << "(" << _id << ")" << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << get_type() << "(" << _id << ")" << "\n";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
process_model(model, use_normals);
|
|
process_model(model, use_normals);
|
|
|
|
|
|
|
|
- write_faces(odetrimeshdata_cat.debug());
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ write_faces(odetrimeshdata_cat.debug());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
#ifdef dSINGLE
|
|
#ifdef dSINGLE
|
|
|
if (!use_normals) {
|
|
if (!use_normals) {
|
|
@@ -131,7 +141,9 @@ OdeTriMeshData(const OdeTriMeshData &other) {
|
|
|
|
|
|
|
|
OdeTriMeshData::
|
|
OdeTriMeshData::
|
|
|
~OdeTriMeshData() {
|
|
~OdeTriMeshData() {
|
|
|
- odetrimeshdata_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n";
|
|
|
|
|
+ }
|
|
|
destroy();
|
|
destroy();
|
|
|
if (_vertices != nullptr) {
|
|
if (_vertices != nullptr) {
|
|
|
PANDA_FREE_ARRAY(_vertices);
|
|
PANDA_FREE_ARRAY(_vertices);
|
|
@@ -152,7 +164,9 @@ OdeTriMeshData::
|
|
|
|
|
|
|
|
void OdeTriMeshData::
|
|
void OdeTriMeshData::
|
|
|
destroy() {
|
|
destroy() {
|
|
|
- odetrimeshdata_cat.debug() << get_type() << "::destroy(" << _id << ")" << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << get_type() << "::destroy(" << _id << ")" << "\n";
|
|
|
|
|
+ }
|
|
|
if (_id != nullptr) {
|
|
if (_id != nullptr) {
|
|
|
dGeomTriMeshDataDestroy(_id);
|
|
dGeomTriMeshDataDestroy(_id);
|
|
|
remove_data(this);
|
|
remove_data(this);
|
|
@@ -185,8 +199,10 @@ process_model(const NodePath& model, bool &use_normals) {
|
|
|
analyze((GeomNode*)geomNodePaths[i].node());
|
|
analyze((GeomNode*)geomNodePaths[i].node());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- odetrimeshdata_cat.debug() << "Found " << _num_vertices << " vertices.\n";
|
|
|
|
|
- odetrimeshdata_cat.debug() << "Found " << _num_faces << " faces.\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << "Found " << _num_vertices << " vertices.\n";
|
|
|
|
|
+ odetrimeshdata_cat.debug() << "Found " << _num_faces << " faces.\n";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
_vertices = (StridedVertex *)PANDA_MALLOC_ARRAY(_num_vertices * sizeof(StridedVertex));
|
|
_vertices = (StridedVertex *)PANDA_MALLOC_ARRAY(_num_vertices * sizeof(StridedVertex));
|
|
|
_faces = (StridedTri *)PANDA_MALLOC_ARRAY(_num_faces * sizeof(StridedTri));
|
|
_faces = (StridedTri *)PANDA_MALLOC_ARRAY(_num_faces * sizeof(StridedTri));
|
|
@@ -195,17 +211,23 @@ process_model(const NodePath& model, bool &use_normals) {
|
|
|
|
|
|
|
|
for (int i = 0; i < geomNodePaths.get_num_paths(); ++i) {
|
|
for (int i = 0; i < geomNodePaths.get_num_paths(); ++i) {
|
|
|
process_geom_node((GeomNode*)geomNodePaths[i].node());
|
|
process_geom_node((GeomNode*)geomNodePaths[i].node());
|
|
|
- odetrimeshdata_cat.debug() << "_num_vertices now at " << _num_vertices << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug() << "_num_vertices now at " << _num_vertices << "\n";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- odetrimeshdata_cat.debug() << "Filled " << _num_faces << " triangles(" \
|
|
|
|
|
- << _num_vertices << " vertices)\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ odetrimeshdata_cat.debug()
|
|
|
|
|
+ << "Filled " << _num_faces << " triangles(" << _num_vertices << " vertices)\n";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void OdeTriMeshData::
|
|
void OdeTriMeshData::
|
|
|
process_geom_node(const GeomNode *geomNode) {
|
|
process_geom_node(const GeomNode *geomNode) {
|
|
|
- ostream &out = odetrimeshdata_cat.debug();
|
|
|
|
|
- out.width(2); out << "" << "process_geom_node(" << *geomNode << ")" << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ ostream &out = odetrimeshdata_cat.debug();
|
|
|
|
|
+ out.width(2); out << "" << "process_geom_node(" << *geomNode << ")" << "\n";
|
|
|
|
|
+ }
|
|
|
for (int i = 0; i < geomNode->get_num_geoms(); ++i) {
|
|
for (int i = 0; i < geomNode->get_num_geoms(); ++i) {
|
|
|
process_geom(geomNode->get_geom(i));
|
|
process_geom(geomNode->get_geom(i));
|
|
|
}
|
|
}
|
|
@@ -213,8 +235,10 @@ process_geom_node(const GeomNode *geomNode) {
|
|
|
|
|
|
|
|
void OdeTriMeshData::
|
|
void OdeTriMeshData::
|
|
|
process_geom(const Geom *geom) {
|
|
process_geom(const Geom *geom) {
|
|
|
- ostream &out = odetrimeshdata_cat.debug();
|
|
|
|
|
- out.width(4); out << "" << "process_geom(" << *geom << ")" << "\n";
|
|
|
|
|
|
|
+ if (odetrimeshdata_cat.is_debug()) {
|
|
|
|
|
+ ostream &out = odetrimeshdata_cat.debug();
|
|
|
|
|
+ out.width(4); out << "" << "process_geom(" << *geom << ")" << "\n";
|
|
|
|
|
+ }
|
|
|
if (geom->get_primitive_type() != Geom::PT_polygons) {
|
|
if (geom->get_primitive_type() != Geom::PT_polygons) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|