Exemplo n.º 1
0
void GPU::merge(uint32_t *input, size *positions, size n) const
{
    cl::make_kernel<cl::Buffer&,cl::Buffer&,cl::Buffer&> merge(this->kmerge);
    cl::make_kernel<cl::Buffer&,size,size> updatePositions(this->kupdatePositions);
    cl::CommandQueue queue(context,dev);
    size len=positions[n];
    cl::Buffer inputBuffer(context, CL_MEM_READ_WRITE, sizeof(uint32_t)*len);
    queue.enqueueWriteBuffer(inputBuffer, false, 0, sizeof(uint32_t)*len, input);
    cl::Buffer outputBuffer(context, CL_MEM_READ_WRITE, sizeof(uint32_t)*len);
    cl::Buffer positionsBuffer(context, CL_MEM_READ_WRITE, sizeof(size)*(n+1));
    queue.enqueueWriteBuffer(positionsBuffer, false, 0, (n+1)*sizeof(size), positions);
    if(n%2)
        queue.enqueueCopyBuffer(inputBuffer, outputBuffer, sizeof(uint32_t)*positions[n-1],sizeof(uint32_t)*positions[n-1], (positions[n]-positions[n-1])*sizeof(uint32_t));    //kopiowanie ostatniego fragmentu, który przez pewien czas może nie być mergowany (jak długo jest nieparzysta liczba list)
    while(n>1)
    {
//        std::clog<<n<<": ";
//        std::copy(positions,positions+n+1,std::ostream_iterator<size>(std::clog," "));
//        std::clog<<std::endl;
        merge(cl::EnqueueArgs(queue,n/2),inputBuffer,outputBuffer,positionsBuffer);
        size o=n;
        n-=n/2;
        updatePositions(cl::EnqueueArgs(queue,1),positionsBuffer,o,n);
        std::swap(inputBuffer,outputBuffer);
    }
    queue.enqueueReadBuffer(inputBuffer, false, 0, sizeof(uint32_t)*len, input);
    queue.finish();
}
Exemplo n.º 2
0
void System<DataType,Integrator,Potential,Communicator>::simulate(int numIters, std::ostream & output) {
	// MPI Comms. //
	clearBuffers() ;
	appendTransitionsToBuffers() ;
	appendInteractionsToBuffers() ;
	communicateInteractionsTransitions() ;
	// Initialise the forces. //
	updateForces() ;
	// Prime the velocity based on the integration policy. //
	for (unsigned int i = 0 ; i < positions.size() ; i+=2) {
		Integrator::initialise(&positions[i], &velocities[i], &forces[i]) ;
	}
	// Update velocities and positions based on the integration policy. //
	for (int i = 0; i < numIters ; ++i) {
		updateVelocities() ;
		updatePositions() ;
		// MPI Comms. 
		clearBuffers() ;
		appendTransitionsToBuffers() ;
		appendInteractionsToBuffers() ;
		communicateInteractionsTransitions() ;
		updateForces() ;
		printSystem(output,i) ;
		output << std::endl << std::endl ;
	}
}		/* -----  end of member function simulate  ----- */
Exemplo n.º 3
0
void DrawStack3D::draw() {
	updatePositions();

	//al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
	stack.draw();
	//al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
}
	ProjectileOccurrence::ProjectileOccurrence(
		Projectile* projectile,
		const string& textureName, 
		const Vector2f& position, 
		const Vector2f& speed, 
		State state,
		Side side,
		map<ProjectileOccurrence::State, int>& nbSpritesByState,
		map<ProjectileOccurrence::State, int>& frameDelayByState) :
		EntityMovable(textureName, position, speed, side), 
			_sender(GENTILE),
			_state(state),
			_lifeTime(PausableClock()),
			_appearanceTime(PausableClock()),
			_animation(NB_STATES)
	{
		_projectile = projectile;

		/* Initialize animation class */
		_animation.setMapNbSprites(nbSpritesByState);
		_animation.setMapFrameDelay(frameDelayByState);
		_animation.setCurrentState(state);

		/* Hitbox */
		_deltaX = _projectile->getBottomLeft();
		
		_hitboxSize.y = _projectile->getTop();
		_hitboxSize.x = _texture->getSize().x / _animation.getNbSpritesMax() - 2 * _deltaX;
		updatePositions(position.x,  position.y + _texture->getSize().y / nbSpritesByState.size() - _hitboxSize.y);
	}
	void ProjectileOccurrence::updatePhysicData(float time, RenderWindow& app)
	{
		setActivity(app);

		if(_isActive)
		{
			if(_lifeTime.GetElapsedTime() > 0)
			{
				/* Submissions */
				if(_projectile->getSubmission() & PhysicConstants::GRAVITY_SUBMISSION)
					gravity(_speed, time);

				/* Update physic position */
				/* Save actual position in previous position */
				_previousPosition = _position;

				/* Compute new position */
				updatePositions(_hitboxPosition.x + time * _speed.x, _hitboxPosition.y + time * _speed.y);

				/* If it falls in hole */
				/*if(_hitboxPosition.y + _hitboxSize.y < 0)
					_projectile->removeProjectileOccurrence(this);*/
				if(_hitboxPosition.y < 0)
					_hitboxPosition.y = 0;
			}
			else
			{
				//_projectile->removeProjectileOccurrence(this);
			}
		}
	}
Exemplo n.º 6
0
bool GamePromptCenter::initialize()
{
	m_pNotice1 = gCtrlAllocator->LoadCtrl("Notice1");
	m_pNotice2 = Layout::create();
	m_pPrompt = Layout::create();
	m_pNormal = Layout::create();
	m_pIconsFrame = Layout::create();

	if ( !m_pNotice1 || !m_pNotice2 || !m_pPrompt || !m_pNormal || !m_pIconsFrame )
	{
		return false;
	}

	m_pNotice1->retain();
	m_pNotice2->retain();
	m_pPrompt->retain();
	m_pNormal->retain();
	m_pIconsFrame->retain();
	m_pIconsFrame->setEnabled(false);

	m_pNotice1->setTouchEnabled(false);
	m_pIconsFrame->setTouchEnabled(false);

	initSystemIcons();

	updatePositions();

	m_pNotice1Frame = dynamic_cast<Layout*>(m_pNotice1->getChildByName("Panel_Clip"));
	if ( m_pNotice1Frame )
	{
		m_pNotice1Frame->setClippingEnabled(true);
	}

	return true;
}
Exemplo n.º 7
0
LedManager::LedManager()
{
	
	numHubs = 0;

	dragging = false;

	//string comPorts[3] = {"COM17","COM18","COM13"}; //must initialized with same length as numHubs
	ofColor colors[3] = {ofColor::orangeRed,ofColor::aliceBlue,ofColor::forestGreen};
	
	//for(int i=0;i<1;i++) addHub(comPorts[i],460800,colors[i]);
	
	
	fbo.allocate(256,256);
	ledShader.load("LedShader/shader");
	
	ledMapImage.allocate(256,256,ofImageType::OF_IMAGE_COLOR);

	ledMapPixels.allocate(256,256,ofImageType::OF_IMAGE_COLOR);
	ledPixels.allocate(256,256,ofImageType::OF_IMAGE_COLOR_ALPHA);

	int imgSize = ledMapImage.width*ledMapImage.height;

	updateLedMap();

	setSendRate(50);
	updatePositions();
	ofAddListener(timer.TIMER_REACHED,this,&LedManager::onUpdateTimer);
}
Exemplo n.º 8
0
 void HUD::setHmsVisible(bool visible)
 {
     mHealth->setVisible(visible);
     mMagicka->setVisible(visible);
     mStamina->setVisible(visible);
     updatePositions();
 }
Exemplo n.º 9
0
int main(int argc, char *argv[])
{
    param params;
    AABB water_volume;
    AABB boundary_volume;
    fluid_particle *fluid_particles = NULL;
    boundary_particle *boundary_particles = NULL;
    initParams(&water_volume, &boundary_volume, &params);

    initParticles(&fluid_particles, &boundary_particles, &water_volume,
                  &boundary_volume, &params);

    eulerStart(fluid_particles, boundary_particles, &params);

    // Main simulation loop
    // Hint: Copy fluid_particles(params.number_fluid_particles), boundary_particles(params.number_boundary_particles), and params(1)
    for(int n=0; n<params.number_steps; n++) {
        updatePressures(fluid_particles, &params);

        updateAccelerations(fluid_particles, boundary_particles, &params);

        updatePositions(fluid_particles, &params);

        if (n % params.steps_per_frame == 0) {
            // Hint: Make sure to update the host fluid_particle data
            writeFile(fluid_particles, &params);
        }
    }

    // Hint: delete any acc data allocated
    finalizeParticles(fluid_particles, boundary_particles);
    return 0;
}
Exemplo n.º 10
0
int main(int argc, char *argv[])
{
    param params;
    AABB water_volume;
    AABB boundary_volume;
    fluid_particle *fluid_particles = NULL;
    boundary_particle *boundary_particles = NULL;
    initParams(&water_volume, &boundary_volume, &params);

    initParticles(&fluid_particles, &boundary_particles, &water_volume,
                  &boundary_volume, &params);

    eulerStart(fluid_particles, boundary_particles, &params);

    // Main simulation loop
    #pragma acc enter data copyin(fluid_particles[0:params.number_fluid_particles], boundary_particles[0:params.number_boundary_particles],params[0:1])
    for(int n=0; n<params.number_steps; n++) {
        updatePressures(fluid_particles, &params);

        updateAccelerations(fluid_particles, boundary_particles, &params);

        updatePositions(fluid_particles, &params);

        if (n % params.steps_per_frame == 0) {
            #pragma acc update host(fluid_particles[0:params.number_fluid_particles])
            writeFile(fluid_particles, &params);
       }
    }

    #pragma acc exit data delete(fluid_particles[0:params.number_fluid_particles],boundary_particles[0:params.number_boundary_particles],params[0:1])
    finalizeParticles(fluid_particles, boundary_particles);
    return 0;
}
Exemplo n.º 11
0
void AudioBody::setOrientation (const Quaternion& v)
{
    if (destroyed) THROW_DEAD(className);
    if (ambient) return;
    orientation = v;
    updatePositions();
}
Exemplo n.º 12
0
void Sprite::setTextureRect(const Rect &rect) {
	if (rect != mTextureRect) {
		mTextureRect = rect;
		updatePositions();
		updateTexCoords();
	}
}
Exemplo n.º 13
0
void AudioBody::setSeparation (float v)
{
    if (destroyed) THROW_DEAD(className);
    if (ambient) return;
    separation = v;
    updatePositions();
}
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
    param params;
    AABB water_volume;
    AABB boundary_volume;
    fluid_particle *fluid_particles = NULL;
    boundary_particle *boundary_particles = NULL;
    initParams(&water_volume, &boundary_volume, &params);

    initParticles(&fluid_particles, &boundary_particles, &water_volume,
                  &boundary_volume, &params);

    eulerStart(fluid_particles, boundary_particles, &params);

    // Main simulation loop
    for(int n=0; n<params.number_steps; n++) {
        updatePressures(fluid_particles, &params);

        updateAccelerations(fluid_particles, boundary_particles, &params);

        updatePositions(fluid_particles, &params);

        if (n % params.steps_per_frame == 0) {
            writeFile(fluid_particles, &params);
        }
    }

    finalizeParticles(fluid_particles, boundary_particles);
    return 0;
}
Exemplo n.º 15
0
GraphicNetCloud::GraphicNetCloud(raw_address address, QList<GraphicNetNode*> nodes, QGraphicsItem* parent) :
	QGraphicsObject(parent)
{
	this->address = address;
	this->nodes = nodes;
	addressText = new QGraphicsSimpleTextItem(address.toString().c_str(), this);

	QFont textFont;
	textFont.setPixelSize(20);
	addressText->setFont(textFont);

	QBrush brush(Qt::black);

	addressText->setBrush(brush);

	QPixmap pic(":/media/cloudIcon");
	icon = new QGraphicsPixmapItem(pic, this);
	//icon->scale(0.75, 0.75);

	//QRectF bounds = boundingRect();

	for(int i=0; i<nodes.size(); i++){
		nodes[i]->setParentItem(this);
	}

	updatePositions();
}
Exemplo n.º 16
0
/**************************************************************************//**
 * @author Jaysen Spurlock, Joe Manke
 *
 * @brief This is the heart of the Pong application. It controls the frame rate
 * of the game, ensuring the updates seem appropriate to the user. This function
 * is in charge of updating objects' positions on screen, detecting collisions,
 * and checking for end-game status.
 *
 * @param value Unused variable required by GLUT
 *****************************************************************************/
void timer( int value )
{
    // Check for a winner
    if( LEFT_SCORE >= 10 || RIGHT_SCORE >= 10 )
    {
        glutLeaveMainLoop();
        return;
    }

    accelerateFromGravity();

    // Check for collision with top or bottom wall
    if( ( BALL.velocity.y > 0 && BALL.center.y > 1.0f - PBall::BALL_RADIUS )
        || ( BALL.velocity.y < 0 && BALL.center.y < PBall::BALL_RADIUS ) )
    {
        BALL.velocity.y = -BALL.velocity.y;
    }

    // Only consider one side of the screen at a time
    if( BALL.center.x > 1.0f )
    {
        rightSideCollisionCheck();
    }
    else
    {
        leftSideCollisionCheck();
    }

    updatePositions();

    glutPostRedisplay();
    glutTimerFunc( 30, timer, 0 );
}
Exemplo n.º 17
0
void PerlinFace::update() {
    if (!_initialized) {
        init();
    }

    updatePositions();
    updateVertices();

    glBindBuffer(GL_ARRAY_BUFFER, _vboID);
    glBufferData(GL_ARRAY_BUFFER,
                 FLOAT_PER_VERTEX * VERTEX_PER_TRIANGLE  * _trianglesCount * sizeof(GLfloat),
                 _triangles,
                 GL_DYNAMIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, _nboID);
    glBufferData(GL_ARRAY_BUFFER,
                 FLOAT_PER_VERTEX * VERTEX_PER_TRIANGLE  * _trianglesCount * sizeof(GLfloat),
                 _normals,
                 GL_DYNAMIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, _cboID);
    glBufferData(GL_ARRAY_BUFFER,
                 FLOAT_PER_VERTEX * VERTEX_PER_TRIANGLE  * _trianglesCount * sizeof(GLubyte),
                 _colors,
                 GL_DYNAMIC_DRAW);
}
Exemplo n.º 18
0
void AudioBody::setPosition (const Vector3& v)
{
    if (destroyed) THROW_DEAD(className);
    if (ambient) return;
    position = v;
    updatePositions();
}
Exemplo n.º 19
0
EqTitleBar::EqTitleBar(QWidget *parent)
        : PixmapWidget(parent)
{
    m_volumeBar = 0;
    m_balanceBar = 0;
    m_shade2 = 0;
    m_left = 0;
    m_right = 0;
    m_shaded = false;
    m_align = false;
    m_skin = Skin::instance();
    m_eq = parentWidget();
    m_mw = qobject_cast<MainWindow*>(m_eq->parent());
    m_close = new Button(this, Skin::EQ_BT_CLOSE_N, Skin::EQ_BT_CLOSE_P, Skin::CUR_EQCLOSE);
    connect(m_close, SIGNAL(clicked()),m_eq, SIGNAL(closed()));
    m_shade = new Button(this, Skin::EQ_BT_SHADE1_N, Skin::EQ_BT_SHADE1_P, Skin::CUR_EQNORMAL);
    connect(m_shade, SIGNAL(clicked()), SLOT(shade()));
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    if (settings.value("Skinned/eq_shaded", false).toBool())
        shade();
    m_align = true;
    setActive(false);
    setCursor(m_skin->getCursor(Skin::CUR_EQTITLE));
    connect(m_skin, SIGNAL(skinChanged()), SLOT(updateSkin()));
    updatePositions();
}
Exemplo n.º 20
0
/** Intializes the PartResizerWidget
	@param d the Device the Partition is on
	@param p the Partition to show and/or resize
	@param minFirst the minimum value for the first sector
	@param maxLast the maximum value for the last sector
*/
void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only, bool move_allowed)
{
    setDevice(d);
    setPartition(p);

    setMinimumFirstSector(minFirst);
    setMaximumLastSector(maxLast);

    setReadOnly(read_only);
    setMoveAllowed(move_allowed);

    setMinimumLength(qMax(partition().sectorsUsed(), partition().minimumSectors()));
    setMaximumLength(qMin(totalSectors(), partition().maximumSectors()));

    // set margins to accommodate to top/bottom button asymmetric layouts
    QStyleOptionButton bOpt;
    bOpt.initFrom(this);

    QRect buttonRect(style()->subElementRect(QStyle::SE_PushButtonContents, &bOpt));

    int asym = (rect().bottom() - buttonRect.bottom()) - (buttonRect.top() - rect().top());
    if (asym > 0)
        setContentsMargins(0, asym, 0, 0);
    else
        setContentsMargins(0, 0, 0, asym);

    if (!readOnly())
    {
        QPixmap pixmap(handleWidth(), handleHeight());
        pixmap.fill(Qt::transparent);
        QPainter p(&pixmap);
        QStyleOption opt;
        opt.state |= QStyle::State_Horizontal;
        opt.rect = pixmap.rect().adjusted(0, 2, 0, -2);
        style()->drawControl(QStyle::CE_Splitter, &opt, &p, this);

        leftHandle().setPixmap(pixmap);
        rightHandle().setPixmap(pixmap);

        leftHandle().setFixedSize(handleWidth(), handleHeight());
        rightHandle().setFixedSize(handleWidth(), handleHeight());
    }

    delete m_PartWidget;
    m_PartWidget = new PartWidget(this, &partition());

    if (!readOnly())
    {
        leftHandle().setCursor(Qt::SizeHorCursor);
        rightHandle().setCursor(Qt::SizeHorCursor);
    }

    if (moveAllowed())
        partWidget().setCursor(Qt::SizeAllCursor);

    partWidget().setToolTip(QString());

    updatePositions();
}
Exemplo n.º 21
0
int ofxTextObject::wrapTextX(float lineWidth)	 
{  
	columnWidth = lineWidth; //soso
    
    if (words.size() > 0) {
        
        float   runningWidth = 0.0f;
        
        lines.clear();
        
        bool        newLine = true;
        lineBlock   tmpLine;
        tmpLine.wordsID.clear();
        int         activeLine = 0;
        
        for(int i=0;i < words.size(); i++)
        {
            runningWidth += (words[i].width);	
            
            
            //soso - check for new line word			
			if (words[i].isNewLine)
			{
				//printf("New Line \n");
				newLine = true;
                lines.push_back(tmpLine);
                tmpLine.wordsID.clear();
                //runningWidth = 0.0f + words[i].width;
                runningWidth = 0.0f + scaleFactor*words[i].width;   //Account for scaleFactor.
                activeLine++;
			}
			//else if (runningWidth <= (lineWidth)) {	
            else if ((scaleFactor*runningWidth) <= lineWidth) {	  //Account for scaleFactor here when wrapping lines.
                newLine = false;
            }
            else {
				//printf("Wrap New Line \n");
                newLine = true;
                lines.push_back(tmpLine);
                tmpLine.wordsID.clear();
                runningWidth = 0.0f + words[i].width;	
                activeLine++;
            }
            
            tmpLine.wordsID.push_back(i);
        }
        
        //Push in the final line.
        lines.push_back(tmpLine);
        _trimLineSpaces(); //Trim the leading and trailing spaces.
    }
    
	updatePositions(lineWidth);	//All other wrap calls eventually boil down to this wrap method, so we only have to call this once here.
    
    renderDirty = true;
    
    return lines.size();
    
}
Exemplo n.º 22
0
void GraphicNetCloud::addNode(GraphicNetNode* node){
	if(!nodes.contains(node)){
		nodes.push_back(node);
		node->setParentItem(this);
	}

	updatePositions();
}
Exemplo n.º 23
0
bool playGame(Affichage A, Damier *map, Snake *snake, Sound sound)
{
	int end = 0;
	bool win = FALSE;
	Position newPos = initPosition();
	Input input = initInput();
	Chrono chrono = initChrono();
	Timer timer = initTimer();
	
	
	setProiesToMap(map);
	
	drawTile(A, TILE_TITLE);
	drawTextChrono(chrono, A);
	drawMap(A, *map, newPosition(MAXCASES/2 + 3,MAXCASES/2), *snake);

	startChrono(&chrono);
	while (1)
	{
		
		setTimer(&timer);
		newPos = updatePositions(map, snake, &input);
		
		if (input.end)
			break;

		if (testPosMap(newPos))
		{
			end = addPositionSnake(map, snake, newPos, sound);
			if (end)
			{
				win = FALSE;
				break;
			}
		}
		
		setPositionsToMap(map, snake);
		drawChrono(chrono, A);
		drawMap(A, *map, newPos, *snake);
		
		if(endChrono(chrono))
		{
			win = FALSE;
			break;
		}
		
		if (endGame(map))
		{
			win = TRUE;
			break;
		}
		
		reguleFPS(&timer);
	}
	
	deleteChrono(&chrono);
	return win;
}
Exemplo n.º 24
0
void Sprite::setTextureRect(const IntRect& rectangle)
{
    if (rectangle != m_textureRect)
    {
        m_textureRect = rectangle;
        updatePositions();
        updateTexCoords();
    }
}
Exemplo n.º 25
0
    void takeCard(Card& c){
	Card * temp = new Card(c);
	Cards.push_back(temp);
	Cards.back()->rotate((horizontal?0.0f:90.0f));
	Cards.back()->setFaceUp(visible);
	std::sort(Cards.begin(), Cards.end(), CardCompare(kozer));
	scale(area);
	updatePositions();
    }
Exemplo n.º 26
0
void GraphicNetCloud::removeNode(GraphicNetNode* node){
	nodes.removeAt(nodes.indexOf(node));
	if(node->parentItem() == this){
		qDebug() << "GraphicNetCloud::removeNode - Cloud " << address.toString().c_str() <<" parent of node";
		node->setParentItem(NULL);
	}

	updatePositions();
}
Exemplo n.º 27
0
void CListBox::reset()
{
	size_t current = first;
	for (std::list<CIntObject*>::iterator it = items.begin(); it!=items.end(); it++)
	{
		deleteItem(*it);
		*it = createItem(current++);
	}
	updatePositions();
}
Exemplo n.º 28
0
void PatchMap::fill(){
	if(lut.isEmpty())
		std::cout << "Warning: no fragments available. Ensure maps are in the correct input location.\n";

	for(unsigned int i = 0; i < xTiles * yTiles; ++i)
		step();
	
	updatePositions();
	updateEdges();
};
Exemplo n.º 29
0
void ParticleEmitter::update(float time_delta)
{
	spawnParticles(time_delta);
	updateLives(time_delta);
	updatePositions(time_delta);
	updateRotations(time_delta);
	for (auto* module : m_modules)
	{
		module->update(time_delta);
	}
}
Exemplo n.º 30
0
void KBBGraphicsItemCursor::setBoardSize(const int columns, const int rows)
{
	m_columns = columns;
	m_rows = rows;
	
	m_boxPosition = 0;
	m_borderPosition = NO_POSITION;
	
	updatePositions();
	hide();
}