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