17 OdeJointCollection() {
22 _joints(copy._joints) {
25 void OdeJointCollection::
27 _joints = copy._joints;
30 void OdeJointCollection::
36 if (_joints.get_ref_count() > 1) {
37 Joints old_joints = _joints;
38 _joints = Joints::empty_array(0);
39 _joints.v() = old_joints.v();
42 _joints.push_back(joint);
45 bool OdeJointCollection::
46 remove_joint(
const OdeJoint &joint) {
48 for (
int i = 0; joint_index == -1 && i < (int)_joints.size(); i++) {
49 if (_joints[i] == joint) {
54 if (joint_index == -1) {
63 if (_joints.get_ref_count() > 1) {
64 Joints old_joints = _joints;
65 _joints = Joints::empty_array(0);
66 _joints.v() = old_joints.v();
69 _joints.erase(_joints.begin() + joint_index);
73 void OdeJointCollection::
75 int other_num_joints = other.get_num_joints();
76 for (
int i = 0; i < other_num_joints; i++) {
77 add_joint(other.get_joint(i));
81 void OdeJointCollection::
84 int num_joints = get_num_joints();
85 for (
int i = 0; i < num_joints; i++) {
87 if (!other.has_joint(joint)) {
88 new_joints.push_back(joint);
94 void OdeJointCollection::
95 remove_duplicate_joints() {
98 int num_joints = get_num_joints();
99 for (
int i = 0; i < num_joints; i++) {
101 bool duplicated =
false;
103 for (
int j = 0; j < i && !duplicated; j++) {
104 duplicated = (joint == get_joint(j));
108 new_joints.push_back(joint);
112 _joints = new_joints;
115 bool OdeJointCollection::
116 has_joint(
const OdeJoint &joint)
const {
117 for (
int i = 0; i < get_num_joints(); i++) {
118 if (joint == get_joint(i)) {
125 void OdeJointCollection::
130 bool OdeJointCollection::
132 return _joints.empty();
135 int OdeJointCollection::
136 get_num_joints()
const {
137 return _joints.size();
141 get_joint(
int index)
const {
142 nassertr(index >= 0 && index < (
int)_joints.size(),
OdeJoint());
143 return _joints[index];
147 operator [] (
int index)
const {
148 return get_joint(index);
157 return _joints.size();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int size() const
Returns the number of joints in the collection.