Panda3D
odeBody.cxx
1 // Filename: odeBody.cxx
2 // Created by: joswilso (27Dec06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_ode.h"
16 #include "odeBody.h"
17 #include "odeJoint.h"
18 
19 TypeHandle OdeBody::_type_handle;
20 
21 OdeBody::
22 OdeBody(dBodyID id) :
23  _id(id) {
24 }
25 
26 OdeBody::
27 OdeBody(OdeWorld &world) :
28  _id(dBodyCreate(world.get_id())) {
29  world.add_body_dampening(*this, 0);
30 }
31 
32 OdeBody::
33 ~OdeBody() {
34 }
35 
36 void OdeBody::
37 destroy() {
38 #ifdef HAVE_PYTHON
39  Py_XDECREF((PyObject*) dBodyGetData(_id));
40 #endif
41  nassertv(_id);
42  dBodyDestroy(_id);
43 }
44 
45 OdeJoint OdeBody::
46 get_joint(int index) const {
47  nassertr(_id != 0, OdeJoint(0));
48  nassertr(index < get_num_joints(), OdeJoint(0));
49  return OdeJoint(dBodyGetJoint(_id, index));
50 }
51 
52 void OdeBody::
53 write(ostream &out, unsigned int indent) const {
54  out.width(indent); out << "" << get_type() \
55  << "(id = " << _id \
56  << ")";
57 }
58 
59 OdeBody::
60 operator bool () const {
61  return (_id != NULL);
62 }
dJointID get_id() const
Returns the underlying dJointID.
Definition: odeJoint.I:34
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85