void Body::UpdateFrame() { if (!(m_flags & FLAG_CAN_MOVE_FRAME)) return; // falling out of frames if (m_frame->GetRadius() < GetPosition().Length()) { Frame *newFrame = GetFrame()->GetParent(); if (newFrame) { // don't fall out of root frame Output("%s leaves frame %s\n", GetLabel().c_str(), GetFrame()->GetLabel().c_str()); SwitchToFrame(newFrame); return; } } // entering into frames for (Frame* kid : m_frame->GetChildren()) { vector3d pos = GetPositionRelTo(kid); if (pos.Length() >= kid->GetRadius()) continue; SwitchToFrame(kid); Output("%s enters frame %s\n", GetLabel().c_str(), kid->GetLabel().c_str()); break; } }
void Body::UpdateFrame() { if (!(m_flags & FLAG_CAN_MOVE_FRAME)) return; // falling out of frames if (m_frame->GetRadius() < GetPosition().Length()) { Frame *newFrame = GetFrame()->GetParent(); if (newFrame) { // don't fall out of root frame printf("%s leaves frame %s\n", GetLabel().c_str(), GetFrame()->GetLabel().c_str()); SwitchToFrame(newFrame); return; } } // entering into frames for (Frame::ChildIterator it = m_frame->BeginChildren(); it != m_frame->EndChildren(); ++it) { vector3d pos = GetPositionRelTo(*it); if (pos.Length() >= (*it)->GetRadius()) continue; SwitchToFrame(*it); printf("%s enters frame %s\n", GetLabel().c_str(), (*it)->GetLabel().c_str()); break; } }