diff --git a/Engine.cc b/Engine.cc index f2d9451..34e3a91 100644 --- a/Engine.cc +++ b/Engine.cc @@ -89,7 +89,6 @@ Engine::Engine(const string & path, AV & av) : m_av(av) { m_next_object_index = 1; - m_next_joint_index = 1; m_eye[0] = 0; m_eye[1] = -1; m_eye[2] = 0; @@ -311,9 +310,7 @@ int Engine::addAMotor(Object * o1, Object * o2) if (o2 != NULL) b2 = o2->getBody(); dJointID jid = m_world.createAMotor(b1, b2); - int id = m_next_joint_index++; - m_joints[id] = jid; - return id; + return m_joints.add(jid); } int Engine::addHinge(Object * o1, Object * o2, @@ -329,15 +326,13 @@ int Engine::addHinge(Object * o1, Object * o2, dJointID jid = m_world.createHinge(b1, b2, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z); - int id = m_next_joint_index++; - m_joints[id] = jid; - return id; + return m_joints.add(jid); } void Engine::setAMotorAxis(int jid, int anum, int rel, dReal x, dReal y, dReal z) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorAxis(m_joints[jid], anum, rel, x, y, z); } @@ -345,7 +340,7 @@ void Engine::setAMotorAxis(int jid, int anum, int rel, void Engine::setAMotorNumAxes(int jid, int num_axes) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorNumAxes(m_joints[jid], num_axes); } @@ -353,7 +348,7 @@ void Engine::setAMotorNumAxes(int jid, int num_axes) void Engine::setAMotorAngle(int jid, int anum, dReal val) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorAngle(m_joints[jid], anum, val); } @@ -361,7 +356,7 @@ void Engine::setAMotorAngle(int jid, int anum, dReal val) void Engine::setAMotorLoStop(int jid, dReal val) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorLoStop(m_joints[jid], val); } @@ -369,7 +364,7 @@ void Engine::setAMotorLoStop(int jid, dReal val) void Engine::setAMotorHiStop(int jid, dReal val) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorHiStop(m_joints[jid], val); } @@ -377,7 +372,7 @@ void Engine::setAMotorHiStop(int jid, dReal val) void Engine::setAMotorVel(int jid, dReal val) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorVel(m_joints[jid], val); } @@ -385,7 +380,7 @@ void Engine::setAMotorVel(int jid, dReal val) void Engine::setAMotorFMax(int jid, dReal val) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorFMax(m_joints[jid], val); } @@ -393,7 +388,7 @@ void Engine::setAMotorFMax(int jid, dReal val) void Engine::setAMotorBounce(int jid, dReal val) { - if (m_joints.find(jid) != m_joints.end()) + if (m_joints.contains(jid)) { m_world.setAMotorBounce(m_joints[jid], val); } diff --git a/Engine.h b/Engine.h index 2b2ddc9..6898730 100644 --- a/Engine.h +++ b/Engine.h @@ -266,9 +266,8 @@ class Engine OdeWorld m_world; std::map m_objects; IDSet< refptr > m_sounds; - std::map m_joints; + IDSet m_joints; int m_next_object_index; - int m_next_joint_index; GLdouble m_eye[3]; GLdouble m_center[3]; GLdouble m_up[3];