/** * \brief Get the epsilon to apply when the item is aligned. */ bear::universe::coordinate_type bear::universe::physical_item::get_align_epsilon() const { if ( has_owner() ) return get_owner().get_position_epsilon(); else return 0; } // physical_item::get_align_epsilon()
/** * \brief Test if the item is in a given environment. * \param e The considered environment. */ bool bear::universe::physical_item::is_in_environment (const universe::environment_type e) const { bool result = false; if ( has_owner() ) { std::set<universe::environment_type> environments; get_owner().get_environments(get_bounding_box(), environments); result = ( environments.find(e) != environments.end()); } return result; } // physical_item::is_in_environment()
/** * \brief Test if the item is only in a given environment. * \param e The considered environment. */ bool bear::universe::physical_item::is_only_in_environment (const universe::environment_type e) const { bool result = false; if ( has_owner() ) { std::set<universe::environment_type> environments; get_owner().get_environments(get_bounding_box(), environments); if ( environments.size() == 1 ) result = ( *(environments.begin()) == e ); } return result; } // physical_item::is_only_in_environment()
/** * \brief Calculate the new acceleration of the item. */ void bear::universe::physical_item::adjust_cinetic() { speed_type s( get_speed() ); if ( has_owner() ) { const speed_type eps(get_owner().get_speed_epsilon()); if ( (s.x < eps.x) && (s.x > -eps.x) ) s.x = 0; if ( (s.y < eps.y) && (s.y > -eps.y) ) s.y = 0; set_speed(s); if ( (get_angular_speed() < get_owner().get_angular_speed_epsilon()) && (get_angular_speed() > -get_owner().get_angular_speed_epsilon()) ) set_angular_speed(0); } } // physical_item::adjust_cinetic()
bool is_yokeable(const ObjectID& id, const ObjectManager *objectManager) { return !has_owner(id, objectManager) && objectManager->get_component<ICmpYoke>(id) != NULL; }
bool is_renderable(const ObjectID& id, const ObjectManager *objectManager) { return !has_owner(id, objectManager) && objectManager->get_component<ICmpRender>(id) != NULL; }
/** * \brief Get the world that owns this item. * \pre has_owner() == true */ bear::universe::world& bear::universe::physical_item::get_owner() const { CLAW_PRECOND( has_owner() ); return *m_owner; } // physical_item::get_owner()
/** * \brief Tell this item which world owns him. * \param The world that owns this item. */ void bear::universe::physical_item::set_owner(world& owner) { CLAW_PRECOND( !has_owner() ); m_owner = &owner; } // physical_item::set_owner()