void Pickable::init_sprites() { Sprite& item_sprite = create_sprite("pickables.txt"); item_sprite.set_current_animation(treasure.get_item_name()); item_sprite.set_current_direction(0); set_bounding_box(item_sprite); }
void Object::update_bounding_box() { BoundingBox bounding_box; get_mesh()->get_bounding_box(get_world_transformation(), bounding_box); set_bounding_box(bounding_box); }
Chest::Chest(const std::string& name, int x, int y) : Detector(CollisionMode::COLLISION_RECTANGLE, name, x, y, 16, 16), open(false), opening_finished_date(0) { Sprite& sprite = create_sprite("chest.txt"); std::string animation = is_open() ? "open" : "closed"; sprite.set_current_animation(animation); set_bounding_box(sprite); }
void Light::update_bounding_box(const float scale) { BoundingBox bounding_box; bounding_box.set_center(get_position()); bounding_box.set_half_size(glm::vec3(get_radius())); bounding_box.scale(scale); set_bounding_box(bounding_box); }
void RStarTreeNode::update_enclosing_bounding_box() { BoundingBox bounding_box; Uint32 i; assert(get_count() > 0); bounding_box = get_element_bounding_box(0); for (i = 1; i < get_count(); i++) { bounding_box.merge(get_element_bounding_box(i)); } bounding_box.scale(1.00001f); set_bounding_box(bounding_box); }
void TerrainPage::update_bounding_box() { BoundingBox bounding_box; glm::vec3 min, max; get_mesh()->get_bounding_box(Transformation(), bounding_box); min = bounding_box.get_min(); max = bounding_box.get_max(); min.z = get_min_z(); max.z = get_max_z(); bounding_box.set_min_max(min, max); set_bounding_box(bounding_box.transform( get_world_transformation())); }
void set_size(const size& aSize) { set_bounding_box(rect{ origin() - (aSize / size{ 2.0 }), aSize }); }
// 左对齐 PBLOBNBOX LineFinder::findAlignedBlob(const AlignedBlobParams& p, std::set<PBLOBNBOX, BoxCmp_LT<BLOBNBOX>>& bset, PBLOBNBOX bbox){ if (bbox == nullptr) return nullptr; int dx = p.vertical.x, dy = p.vertical.y; int dir_y = dy < 0 ? -1 : 1; int skew_tolerance = p.max_v_gap / jun::kMaxSkewFactor; int x2 = (p.max_v_gap*dx + dy / 2) / dy; Rect box = bbox->bounding_box(); int x_start = box.x; x2 += x_start; int xmin, xmax, ymin, ymax; if (x2 < x_start){ //向左 xmin = x2; xmax = x_start; } else{ xmin = x_start; xmax = x2; } if (dy > 0){ //向下 ymin = box.ylast(); ymax = ymin + p.max_v_gap; } else{ ymax = box.y; ymin = ymax - p.max_v_gap; } xmin -= skew_tolerance - p.min_gutter; xmax += skew_tolerance + p.r_align_tolerance; logger()->debug("Starting {} {} search at {}-{},{} dy={} search_size={}, gutter={}\n", p.ragged ? "Ragged" : "Aligned", "Left", xmin, xmax, box.ylast(), dir_y, p.max_v_gap, p.min_gutter ); auto begin_blob = std::make_shared<BLOBNBOX>(); begin_blob->set_bounding_box(Rect{ xmin, ymin, 1, 1 }); auto end_blob = std::make_shared<BLOBNBOX>(); end_blob->set_bounding_box(Rect{ xmax, ymax, 1, 1 }); auto beginIter = bset.lower_bound(begin_blob); auto endIter = bset.upper_bound(end_blob); PBLOBNBOX result = nullptr; int min_dist = std::numeric_limits<int>::max(); for (auto iter = beginIter; iter != endIter; ++iter){ Rect nbox = (*iter)->bounding_box(); int n_y = (nbox.y + nbox.ylast()) / 2; if ((dy > 0) && (n_y<ymin || n_y>ymax)) continue; if (dy < 0 && (n_y < ymin || n_y > ymax)) continue; int x_at_ny = x_start + (n_y - ymin)*dx / dy; int n_x = nbox.x; //aligned so keep it. if (n_x <= x_at_ny + p.r_align_tolerance&&n_x >= x_at_ny - p.l_align_tolerance){ logger()->debug("aligned, seeking left, box={}\n", nbox); TabType n_type = (*iter)->left_tab_type; if (n_type != TabType::TT_NONE && (p.ragged || n_type != TabType::TT_MAYBE_RAGGED)){ int x_dist = n_x - x_at_ny; int y_dist = n_y - ymin; int new_dist = x_dist*x_dist + y_dist*y_dist; if (new_dist < min_dist) { min_dist = new_dist; result = (*iter); } } } } return result; }
List::List() { init(); set_bounding_box(NULL); }
List::List(BBox * bbox_) { init(); set_bounding_box(bbox_); }