Panda3D
Loading...
Searching...
No Matches
odeBody.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 odeBody.cxx
10 * @author joswilso
11 * @date 2006-12-27
12 */
13
14#include "config_ode.h"
15#include "odeBody.h"
16#include "odeJoint.h"
17
18TypeHandle OdeBody::_type_handle;
19
20OdeBody::
21OdeBody(dBodyID id) :
22 _id(id) {
23}
24
25OdeBody::
26OdeBody(OdeWorld &world) :
27 _id(dBodyCreate(world.get_id())) {
28 world.add_body_dampening(*this, 0);
29}
30
31OdeBody::
32~OdeBody() {
33}
34
35void OdeBody::
36destroy() {
37 if (_destroy_callback != nullptr) {
38 _destroy_callback(*this);
39 _destroy_callback = nullptr;
40 }
41 nassertv(_id);
42 dBodyDestroy(_id);
43}
44
45OdeJoint OdeBody::
46get_joint(int index) const {
47 nassertr(_id != nullptr, OdeJoint(nullptr));
48 nassertr(index < get_num_joints(), OdeJoint(nullptr));
49 return OdeJoint(dBodyGetJoint(_id, index));
50}
51
52void OdeBody::
53write(std::ostream &out, unsigned int indent) const {
54 out.width(indent); out << "" << get_type() \
55 << "(id = " << _id \
56 << ")";
57}
58
59OdeBody::
60operator bool () const {
61 return (_id != nullptr);
62}
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.