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