void Grid::insertParticles(btFluidParticles& particles) { if (particles.size() == 0) return; m_particles = &particles; for(int i = 0; i < particles.size(); ++i) { const btVector3& position = particles.m_pos[i]; CellPosition pos = getCellPosition(position); m_data[pos.x][pos.y][pos.z].indices.push_back(i); } }
void Field::DropJewel(spJewel Target, spJewel Jewel) { if (Jewel->getState()!=jsNormal) return; if (Target->getState()!=jsScored) return; spTween tween = Jewel->DropTo(Target->getPosition()); tween->addEventListener(TweenEvent::DONE, CLOSURE(this, &Field::DropEndCallback)); Target->setPosition(getCellPosition(Jewel->index.x, Jewel->index.y)); ForceSwap(Target,Jewel); droped_count++; }
DiscreteState StateDiscretizer::discretizeState(Pose pose, Velocity vel, int time_step) { DiscreteState state_i; //find cell position state_i.in_map = getCellPosition(pose.getX(), pose.getY(), state_i.x_i, state_i.y_i, state_i.grid_cell); //find the nearest discrete orientation state_i.angle_i = getDiscreteOrientation(pose.getTheta()); //find the discrete representation of the velocity getDiscreteVelocity(vel, state_i.vel_x_i, state_i.vel_w_i); state_i.time_step = time_step; return state_i; }
void Field::FillField(bool first_time) { for (int i=0; i<FIELD_SIZE; i++) for (int j=FIELD_SIZE-1; j>=0; j--) { if (first_time) { jewels[i][j] = new Jewel(rand()%6); jewels[i][j]->setPosition( getCellPosition(i,j) ); jewels[i][j]->index = Point(i,j); addChild(jewels[i][j]); } else jewels[i][j]->Set(rand()%6); } CleanField(); }
void GUIInventory::onRefresh() { _parent->fillRect(_bounds, _vm->_palette->BLACK); //_parent->frameRect(_bounds, _vm->_palette->LIGHT_GRAY); if (_visible) { //kernel_trigger_dispatch(kernel_trigger_create(TRIG_INV_CLICK)); _scrollable = false; // Get to the starting inventory position for display ItemsIterator i = _inventoryItems.begin(); int index = _scrollPosition; while (index-- > 0) ++i; // Loop through displaying entries for (index = 0; (i != _inventoryItems.end()) && (index < _cellCount.x * _cellCount.y); ++index, ++i) { GUIInventoryItem *item = (*i).get(); const Common::Point cellPos = getCellPosition(index); /* Common::Rect cellBounds(_bounds.left + cellPos.x + xOffset, _bounds.top + cellPos.y + yOffset, _bounds.left + cellPos.x + xOffset + _cellSize.x, _bounds.top + cellPos.y + _cellSize.y);*/ Common::Rect cellBounds(_bounds.left + cellPos.x, _bounds.top + cellPos.y, _bounds.left + cellPos.x + _cellSize.x, _bounds.top + cellPos.y + _cellSize.y); Common::Point iconPt( cellBounds.left + (cellBounds.width() - item->icon->width()) / 2, cellBounds.top + (cellBounds.height() - item->icon->height()) / 2); item->icon->copyTo(_parent, iconPt.x, iconPt.y, 0); if (_highlightedIndex == index) _parent->frameRect(Common::Rect(iconPt.x - 2, iconPt.y - 2, iconPt.x + item->icon->width() + 2, iconPt.y + item->icon->height() + 2), _vm->_palette->LIGHT_GRAY); } } }
const GridCell& Grid::getGridCell(const btVector3& position) const { CellPosition pos = getCellPosition(position); return m_data[pos.x][pos.y][pos.z]; }