Panda3D
odeGeom.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file odeGeom.cxx
10  * @author joswilso
11  * @date 2006-12-27
12  */
13 
14 #include "config_ode.h"
15 #include "odeGeom.h"
16 #include "odeSimpleSpace.h"
17 #include "odeQuadTreeSpace.h"
18 #include "odeHashSpace.h"
19 
20 #include "odeTriMeshGeom.h"
21 #include "odeTriMeshData.h"
22 #include "odeBoxGeom.h"
23 #include "odeCappedCylinderGeom.h"
24 #include "odeCylinderGeom.h"
25 #include "odePlaneGeom.h"
26 #include "odeRayGeom.h"
27 #include "odeSphereGeom.h"
28 
29 // OdeGeom::GeomSurfaceMap OdeGeom::_geom_surface_map;
30 // OdeGeom::GeomCollideIdMap OdeGeom::_geom_collide_id_map;
31 TypeHandle OdeGeom::_type_handle;
32 
33 OdeGeom::
34 OdeGeom(dGeomID id) :
35  _id(id) {
36  odegeom_cat.debug() << get_type() << "(" << _id << ")\n";
37 }
38 
39 OdeGeom::
40 ~OdeGeom() {
41  odegeom_cat.debug() << "~" << get_type() << "(" << _id << ")\n";
42  /*
43  GeomSurfaceMap::iterator iter = _geom_surface_map.find(this->get_id());
44  if (iter != _geom_surface_map.end()) {
45  _geom_surface_map.erase(iter);
46  }
47 
48  GeomCollideIdMap::iterator iter2 = _geom_collide_id_map.find(this->get_id());
49  if (iter2 != _geom_collide_id_map.end()) {
50  _geom_collide_id_map.erase(iter2);
51  }
52  */
53 }
54 
55 /*
56 int OdeGeom::
57 get_surface_type()
58 {
59  return get_space().get_surface_type(this->get_id());
60 }
61 
62 int OdeGeom::
63 get_collide_id()
64 {
65  return get_space().get_collide_id(this->get_id());
66 }
67 
68 void OdeGeom::
69 set_surface_type(int surface_type)
70 {
71  get_space().set_surface_type(surface_type, this->get_id());
72 }
73 
74 int OdeGeom::
75 set_collide_id(int collide_id)
76 {
77  return get_space().set_collide_id(collide_id, this->get_id());
78 }
79 
80 
81 int OdeGeom::
82 test_collide_id(int collide_id)
83 {
84 
85  odegeom_cat.debug() << "test_collide_id start" << "\n";
86  int first = get_space().set_collide_id(collide_id, this->get_id());
87  odegeom_cat.debug() << "returns" << first << "\n";
88  odegeom_cat.debug() << "test_collide_id middle" << "\n";
89  int test = get_space().get_collide_id(this->get_id());
90  odegeom_cat.debug() << "test_collide_id stop" << "\n";
91  return test;
92 }
93 */
94 
95 void OdeGeom::
96 destroy() {
97  if (get_class() == OdeTriMeshGeom::get_geom_class()) {
98  OdeTriMeshData::unlink_data(_id);
99  }
100  dGeomDestroy(_id);
101 }
102 
103 OdeSpace OdeGeom::
104 get_space() const {
105  return OdeSpace(dGeomGetSpace(_id));
106 }
107 
108 
109 void OdeGeom::
110 write(std::ostream &out, unsigned int indent) const {
111  out.width(indent);
112  out << get_type() << "(id = " << _id << ")";
113 }
114 
115 OdeBoxGeom OdeGeom::
116 convert_to_box() const {
117  nassertr(_id != nullptr, OdeBoxGeom(nullptr));
118  nassertr(get_class() == GC_box, OdeBoxGeom(nullptr));
119  return OdeBoxGeom(_id);
120 }
121 
122 OdeCappedCylinderGeom OdeGeom::
123 convert_to_capped_cylinder() const {
124  nassertr(_id != nullptr, OdeCappedCylinderGeom(nullptr));
125  nassertr(get_class() == GC_capped_cylinder, OdeCappedCylinderGeom(nullptr));
126  return OdeCappedCylinderGeom(_id);
127 }
128 
129 /*
130 OdeConvexGeom OdeGeom::
131 convert_to_convex() const {
132  nassertr(_id != nullptr, OdeConvexGeom(nullptr));
133  nassertr(get_class() == GC_convex, OdeConvexGeom(nullptr));
134  return OdeConvexGeom(_id);
135 }
136 */
137 
138 OdeCylinderGeom OdeGeom::
139 convert_to_cylinder() const {
140  nassertr(_id != nullptr, OdeCylinderGeom(nullptr));
141  nassertr(get_class() == GC_cylinder, OdeCylinderGeom(nullptr));
142  return OdeCylinderGeom(_id);
143 }
144 
145 /*
146 OdeHeightfieldGeom OdeGeom::
147 convert_to_heightfield() const {
148  nassertr(_id != nullptr, OdeHeightfieldGeom(nullptr));
149  nassertr(get_class() == GC_heightfield, OdeHeightfieldGeom(nullptr));
150  return OdeHeightfieldGeom(_id);
151 }
152 */
153 
154 OdePlaneGeom OdeGeom::
155 convert_to_plane() const {
156  nassertr(_id != nullptr, OdePlaneGeom(nullptr));
157  nassertr(get_class() == GC_plane, OdePlaneGeom(nullptr));
158  return OdePlaneGeom(_id);
159 }
160 
161 OdeRayGeom OdeGeom::
162 convert_to_ray() const {
163  nassertr(_id != nullptr, OdeRayGeom(nullptr));
164  nassertr(get_class() == GC_ray, OdeRayGeom(nullptr));
165  return OdeRayGeom(_id);
166 }
167 
168 OdeSphereGeom OdeGeom::
169 convert_to_sphere() const {
170  nassertr(_id != nullptr, OdeSphereGeom(nullptr));
171  nassertr(get_class() == GC_sphere, OdeSphereGeom(nullptr));
172  return OdeSphereGeom(_id);
173 }
174 
175 OdeTriMeshGeom OdeGeom::
176 convert_to_tri_mesh() const {
177  nassertr(_id != nullptr, OdeTriMeshGeom(nullptr));
178  nassertr(get_class() == GC_tri_mesh, OdeTriMeshGeom(nullptr));
179  return OdeTriMeshGeom(_id);
180 }
181 
182 OdeSimpleSpace OdeGeom::
183 convert_to_simple_space() const {
184  nassertr(_id != nullptr, OdeSimpleSpace(nullptr));
185  nassertr(get_class() == GC_simple_space, OdeSimpleSpace(nullptr));
186  return OdeSimpleSpace((dSpaceID)_id);
187 }
188 
189 OdeHashSpace OdeGeom::
190 convert_to_hash_space() const {
191  nassertr(_id != nullptr, OdeHashSpace(nullptr));
192  nassertr(get_class() == GC_hash_space, OdeHashSpace(nullptr));
193  return OdeHashSpace((dSpaceID)_id);
194 }
195 
196 OdeQuadTreeSpace OdeGeom::
197 convert_to_quad_tree_space() const {
198  nassertr(_id != nullptr, OdeQuadTreeSpace(nullptr));
199  nassertr(get_class() == GC_quad_tree_space, OdeQuadTreeSpace(nullptr));
200  return OdeQuadTreeSpace((dSpaceID)_id);
201 }
202 
203 OdeGeom::
204 operator bool () const {
205  return (_id != nullptr);
206 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81