Panda3D
Loading...
Searching...
No Matches
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"
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;
31TypeHandle OdeGeom::_type_handle;
32
33OdeGeom::
34OdeGeom(dGeomID id) :
35 _id(id) {
36 if (odegeom_cat.is_debug()) {
37 odegeom_cat.debug() << get_type() << "(" << _id << ")\n";
38 }
39}
40
41OdeGeom::
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/*
60int OdeGeom::
61get_surface_type()
62{
63 return get_space().get_surface_type(this->get_id());
64}
65
66int OdeGeom::
67get_collide_id()
68{
69 return get_space().get_collide_id(this->get_id());
70}
71
72void OdeGeom::
73set_surface_type(int surface_type)
74{
75 get_space().set_surface_type(surface_type, this->get_id());
76}
77
78int OdeGeom::
79set_collide_id(int collide_id)
80{
81 return get_space().set_collide_id(collide_id, this->get_id());
82}
83
84
85int OdeGeom::
86test_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
99void OdeGeom::
100destroy() {
101 if (get_class() == OdeTriMeshGeom::get_geom_class()) {
102 OdeTriMeshData::unlink_data(_id);
103 }
104 dGeomDestroy(_id);
105}
106
107OdeSpace OdeGeom::
108get_space() const {
109 return OdeSpace(dGeomGetSpace(_id));
110}
111
112
113void OdeGeom::
114write(std::ostream &out, unsigned int indent) const {
115 out.width(indent);
116 out << get_type() << "(id = " << _id << ")";
117}
118
119OdeBoxGeom OdeGeom::
120convert_to_box() const {
121 nassertr(_id != nullptr, OdeBoxGeom(nullptr));
122 nassertr(get_class() == GC_box, OdeBoxGeom(nullptr));
123 return OdeBoxGeom(_id);
124}
125
126OdeCappedCylinderGeom OdeGeom::
127convert_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/*
134OdeConvexGeom OdeGeom::
135convert_to_convex() const {
136 nassertr(_id != nullptr, OdeConvexGeom(nullptr));
137 nassertr(get_class() == GC_convex, OdeConvexGeom(nullptr));
138 return OdeConvexGeom(_id);
139}
140*/
141
142OdeCylinderGeom OdeGeom::
143convert_to_cylinder() const {
144 nassertr(_id != nullptr, OdeCylinderGeom(nullptr));
145 nassertr(get_class() == GC_cylinder, OdeCylinderGeom(nullptr));
146 return OdeCylinderGeom(_id);
147}
148
149/*
150OdeHeightfieldGeom OdeGeom::
151convert_to_heightfield() const {
152 nassertr(_id != nullptr, OdeHeightfieldGeom(nullptr));
153 nassertr(get_class() == GC_heightfield, OdeHeightfieldGeom(nullptr));
154 return OdeHeightfieldGeom(_id);
155}
156*/
157
158OdePlaneGeom OdeGeom::
159convert_to_plane() const {
160 nassertr(_id != nullptr, OdePlaneGeom(nullptr));
161 nassertr(get_class() == GC_plane, OdePlaneGeom(nullptr));
162 return OdePlaneGeom(_id);
163}
164
165OdeRayGeom OdeGeom::
166convert_to_ray() const {
167 nassertr(_id != nullptr, OdeRayGeom(nullptr));
168 nassertr(get_class() == GC_ray, OdeRayGeom(nullptr));
169 return OdeRayGeom(_id);
170}
171
172OdeSphereGeom OdeGeom::
173convert_to_sphere() const {
174 nassertr(_id != nullptr, OdeSphereGeom(nullptr));
175 nassertr(get_class() == GC_sphere, OdeSphereGeom(nullptr));
176 return OdeSphereGeom(_id);
177}
178
179OdeTriMeshGeom OdeGeom::
180convert_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
186OdeSimpleSpace OdeGeom::
187convert_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
193OdeHashSpace OdeGeom::
194convert_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
200OdeQuadTreeSpace OdeGeom::
201convert_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
207OdeGeom::
208operator bool () const {
209 return (_id != nullptr);
210}
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
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.
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.