00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "config_ode.h"
00016 #include "odeBody.h"
00017
00018 TypeHandle OdeBody::_type_handle;
00019
00020 OdeBody::
00021 OdeBody(dBodyID id) :
00022 _id(id) {
00023 }
00024
00025 OdeBody::
00026 OdeBody(OdeWorld &world) :
00027 _id(dBodyCreate(world.get_id())) {
00028 world.add_body_dampening(*this, 0);
00029 }
00030
00031 OdeBody::
00032 ~OdeBody() {
00033 }
00034
00035 void OdeBody::
00036 destroy() {
00037 #ifdef HAVE_PYTHON
00038 Py_XDECREF((PyObject*) dBodyGetData(_id));
00039 #endif
00040 nassertv(_id);
00041 dBodyDestroy(_id);
00042 }
00043
00044 OdeJoint OdeBody::
00045 get_joint(int index) const {
00046 nassertr(_id != 0, OdeJoint(0));
00047 nassertr(index < get_num_joints(), OdeJoint(0));
00048 return OdeJoint(dBodyGetJoint(_id, index));
00049 }
00050
00051 void OdeBody::
00052 write(ostream &out, unsigned int indent) const {
00053 out.width(indent); out << "" << get_type() \
00054 << "(id = " << _id \
00055 << ")";
00056 }
00057
00058 OdeBody::
00059 operator bool () const {
00060 return (_id != NULL);
00061 }