Beispiel #1
0
Array<TV> SurfacePins::closest_points(Array<const TV> X) {
  update_position(X,false);
  Array<TV> closest(particles.size(),uninit);
  for (int i=0;i<particles.size();i++)
    closest[i] = X[particles[i]]-info[i].phi*info[i].normal;
  return closest;
}
Beispiel #2
0
static void
run(LV2_Handle instance, uint32_t sample_count)
{
	Metro*           self = (Metro*)instance;
	const MetroURIs* uris = &self->uris;

	// Work forwards in time frame by frame, handling events as we go
	const LV2_Atom_Sequence* in     = self->ports.control;
	uint32_t                 last_t = 0;
	for (const LV2_Atom_Event* ev = lv2_atom_sequence_begin(&in->body);
	     !lv2_atom_sequence_is_end(&in->body, in->atom.size, ev);
	     ev = lv2_atom_sequence_next(ev)) {

		// Play the click for the time slice from last_t until now
		play(self, last_t, ev->time.frames);

		// Check if this event is an Object
		// (or deprecated Blank to tolerate old hosts)
		if (ev->body.type == uris->atom_Object ||
		    ev->body.type == uris->atom_Blank) {
			const LV2_Atom_Object* obj = (const LV2_Atom_Object*)&ev->body;
			if (obj->body.otype == uris->time_Position) {
				// Received position information, update
				update_position(self, obj);
			}
		}

		// Update time for next iteration and move to next event
		last_t = ev->time.frames;
	}

	// Play for remainder of cycle
	play(self, last_t, sample_count);
}
Beispiel #3
0
DLL_EXPORT void
SafeMoveWindow(unsigned int serial, HWND hwnd, int x, int y, int width, int height)
{
	RECT rect;

	if (IsZoomed(hwnd))
		return;

	WaitForSingleObject(g_mutex, INFINITE);
	g_block_move_hwnd = hwnd;
	g_block_move_serial = serial;
	g_block_move.left = x;
	g_block_move.top = y;
	g_block_move.right = x + width;
	g_block_move.bottom = y + height;
	ReleaseMutex(g_mutex);

	SetWindowPos(hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER);

	vchannel_write("ACK", "%u", serial);

	if (!GetWindowRect(hwnd, &rect))
		debug("GetWindowRect failed!\n");
	else if ((rect.left != x) || (rect.top != y) || (rect.right != x + width)
		 || (rect.bottom != y + height))
		update_position(hwnd);
	else if (! IsIconic(hwnd))
		vchannel_write("POSITION", "0x%08lx,%d,%d,%d,%d,0x%08x", hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0);

	WaitForSingleObject(g_mutex, INFINITE);
	g_block_move_hwnd = NULL;
	memset(&g_block_move, 0, sizeof(RECT));
	ReleaseMutex(g_mutex);
}
Beispiel #4
0
static void handle_resize(struct view_handler * handler,
                          uint32_t old_width, uint32_t old_height)
{
    struct panel * panel = wl_container_of(handler, panel, view_handler);

    update_position(panel);
}
Beispiel #5
0
/************************************************************
Main Loop
************************************************************/
int main(void)
{
	/* Confirm Power */
	m_red(ON);

	/* Initializations */
	initialize_robockey();
	pause();
	play();
	
	/* Confirm successful initialization(s) */
	m_green(ON);

	/* Run */
	while (1){
		update_position();
		if (check(ADCSRA,ADIF)){adc_update();} // Check if ADC conversion has completed
		bot_behavior_update();
		if (check(TIFR3,OCF3A)){motor_update();}	// Check if timestep has completed
		if (wifi_flag) {
			wifi_flag = 0;
			m_red(TOGGLE);
			wireless_recieve();
			
		}
	}
}
Beispiel #6
0
void utf8iterator_next(Utf8Iterator* iter) {
  // We update positions based on the *last* character read, so that the first
  // character following a newline is at column 1 in the next line.
  update_position(iter);
  iter->_start += iter->_width;
  read_char(iter);
}
static gboolean update_position_idle(NotifyStack* stack)
{
	update_position(stack);

	stack->update_id = 0;
	return FALSE;
}
Beispiel #8
0
void	CPs2NewParticle::plat_update( void )
{
	if (m_params.m_LocalCoord)
	{
		update_position();
	}
}
Beispiel #9
0
int  
SKY_BOX::DrawGradient(CVIEWptr &v)
{
   //DebugBreak();
   update_position(); //center at the eye position
   
      
   Patch* p = get_patch();
   assert(p);
   Skybox_Texture* tex = get_tex<Skybox_Texture>(p);
   assert(tex);

   glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT );
   glEnable(GL_DEPTH_TEST);

   // set xform:
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glMultMatrixd(xform().transpose().matrix());
 
   // draw the mesh normally:
   int ret= tex->draw(v);
          
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();

   glPopAttrib();

   GL_VIEW_PRINT_GL_ERRORS("(regular) : ");

   return ret;
}
Beispiel #10
0
void VWindow::change_source(EDL *edl)
{
//printf("VWindow::change_source(EDL *edl) 1\n");
//printf("VWindow::change_source %p\n", edl);
// EDLs are identical
	if(edl && mwindow->edl->vwindow_edl && 
		edl->id == mwindow->edl->vwindow_edl->id) return;

	delete_edl();

	if(edl)
	{
		this->asset = 0;
		mwindow->edl->vwindow_edl = edl;
// in order not to later delete edl if it is shared
		mwindow->edl->vwindow_edl_shared = 1;

// Update GUI
		gui->change_source(edl, edl->local_session->clip_title);
		update_position(CHANGE_ALL, 1, 1);

// Update master session
		strcpy(mwindow->edl->session->vwindow_folder, CLIP_FOLDER);
		mwindow->edl->session->vwindow_source = 
			mwindow->edl->clips.number_of(edl);
	}
	else
		gui->change_source(edl, _("Viewer"));
}
Beispiel #11
0
/*
 * Move robot forward, update current position and perform adjustments if the cell has been visited before
 */
void move()
{

    move_forward();
    update_position();

    int i = find_current_cell();
    int k = find_prev_cell();

    if (cells[i].visited == 0) {
        check_walls();
        determ_type(i);
        checked_walls = 1;
        drive_through = 0;
    }

    else {
        checked_walls = 1;
        check_wall_weights();
        printf("Attempting adjustment...\n");
        drive_through = 1;
        perform_angle_adjustment(k, i);
        perform_one_wall_adjustment(i);

    }

    update_visited();
}
Beispiel #12
0
EXTERN void
SafeMoveWindow(unsigned int serial, HWND hwnd, int x, int y, int width,
               int height)
{
    RECT rect;

    if (!g_wm_seamless_focus)
        return;

    WaitForSingleObject(g_mutex, INFINITE);
    g_shdata->block_move_hwnd = hwnd_to_long(hwnd);
    g_shdata->block_move_serial = serial;
    g_shdata->block_move.left = x;
    g_shdata->block_move.top = y;
    g_shdata->block_move.right = x + width;
    g_shdata->block_move.bottom = y + height;
    ReleaseMutex(g_mutex);

    SetWindowPos(hwnd, NULL, x, y, width, height,
                 SWP_NOACTIVATE | SWP_NOZORDER);

    vchannel_write("ACK", "%u", serial);

    if (!GetWindowRect(hwnd, &rect))
        debug("GetWindowRect failed!");
    else if ((rect.left != x) || (rect.top != y) || (rect.right != x + width)
             || (rect.bottom != y + height))
        update_position(hwnd);

    WaitForSingleObject(g_mutex, INFINITE);
    g_shdata->block_move_hwnd = 0;
    memset(&g_shdata->block_move, 0, sizeof(RECT));
    ReleaseMutex(g_mutex);
}
Beispiel #13
0
Datei: ocl.c Projekt: Thundzz/GPU
void ocl_one_step_move(sotl_device_t *dev)
{
  if (gravity_enabled)
    gravity (dev);

#ifdef _SPHERE_MODE_
  if (eating_enabled)
    eating_pacman (dev);

  if (growing_enabled)
    growing_ghost (dev);
#endif

  if (force_enabled)
    // Classic n^2 compute force version
    n2_lennard_jones (dev);

  if(detect_collision)
    atom_collision (dev);

  if(borders_enabled)
    border_collision (dev);

  update_position (dev);

#ifdef HAVE_LIBGL
  if (dev->display)
    update_vertices (dev);
#endif
}
Beispiel #14
0
void SoundPlayer::init(float volume, float x, float y, float z) {
	stop = true;
	paused = true;
	pthread_mutex_init(&player_mutex, NULL);
	pthread_mutex_init(&control_mutex, NULL);
	update_volume(volume);
	update_position(x, y, z);
}
Beispiel #15
0
 bool handle_event(mouse_position npos){
   int dx = npos.x - 200;
   int dy = npos.y - 200;
   SetMousePosition(200,200);
   r1 += dx;
   r2 += dy;
   update_position(0,0,dx,dy);
   return true;
 }
//struct sphere move_on_curve( struct sphere *ball ) {
void move_on_curve( struct sphere *ball ) {
	point3f temp;
	temp = ball->pos;
	// store previous position
	ball->previous_pos = temp;
	ball->interval =( current - ball->start_time )/
		( CLOCKS_PER_SEC * ball->curve_time );
	update_position( ball );
}
Beispiel #17
0
/*
 * advances the sphere along the curved path
 */
void Sphere::move_on_curve(double current) {
	point3f temp;
	temp = pos;
	// store previous position
	previous_pos = temp;
	interval =( current - start_time )/
		( CLOCKS_PER_SEC * curve_time );
	update_position();
}
Beispiel #18
0
/*
  update the Gazebo simulation by one time step
 */
void Gazebo::update(const struct sitl_input &input)
{
    send_servos(input);
    recv_fdm(input);
    update_position();

    // update magnetic field
    update_mag_field_bf();
}
Beispiel #19
0
int play_game(){
  draw_border();
  update_position();
  draw_snake();


  usleep(get_speed());
  return 1;
}
Beispiel #20
0
int pSim::Update()
{
#ifdef VERBOSE
	update_log << "Update no contact" << endl;
#endif
#ifdef TIMING_CHECK
	update_start_time = MPI_Wtime();
#endif
#ifdef PSIM_TEST
	max_condition_number = -1.0;
	max_sigma_ratio = -1.0;
	max_condition_number_joint = 0;
	max_sigma_ratio_joint = 0;
	condition_numbers.resize(n_dof);
	sigma_ratios.resize(n_dof);
	condition_numbers.zero();
	sigma_ratios.zero();
	total_gamma_error = 0.0;
#endif
	/**** assembly ****/
	// position-dependent variables
	update_position();
#if 1
	if(do_connect)
	{
		//
		// do collision computation if needed
		//
		update_collision();
		// don't forget to recompute link velocities
		CalcVelocity();
		do_connect = false;
	}
#endif
	// velocity-dependent variables
	update_velocity();

#ifdef TIMING_CHECK
	cerr << "[" << rank << "] disassembly t = " << MPI_Wtime()-update_start_time << endl;
#endif
	/**** disassembly ****/
	disassembly();
	
#ifdef PSIM_TEST
	cerr << "--- max condition number = " << max_condition_number << " at " << max_condition_number_joint->name << endl;
	cerr << "--- max sigma ratio = " << max_sigma_ratio << " at " << max_sigma_ratio_joint->name << endl;
	cerr << "--- total_gamma_error = " << total_gamma_error << endl;
//	cerr << "condition_numbers = " << tran(condition_numbers) << endl;
//	cerr << "sigma_ratios = " << tran(sigma_ratios) << endl;
#endif
#ifdef USE_MPI
	// scatter results
	scatter_acc();
#endif
	return 0;
}
Beispiel #21
0
static void set_offset(struct wl_client * client, struct wl_resource * resource,
                       uint32_t offset)
{
    struct panel * panel = wl_resource_get_user_data(resource);

    panel->offset = offset;

    if (panel->docked)
        update_position(panel);
}
Beispiel #22
0
int write_data(databuf_t* db, int pos) {
    update_position(&track);

    pos = race_write_short(db,pos,TRACK_MSG);
    pos = race_write_short(db,pos,1);  // we only send one track (for now)
    pos = race_write_track_data(db, pos,
                             track.id, track.time_msec, track.lat_deg, track.lon_deg, 
                             track.alt_m, track.heading_deg, track.speed_m_sec);
    return pos;
}
Beispiel #23
0
/*
  update the last_letter simulation by one time step
 */
void last_letter::update(const struct sitl_input &input)
{
    send_servos(input);
    recv_fdm(input);
    sync_frame_time();

    update_position();
    // update magnetic field
    update_mag_field_bf();
}
Beispiel #24
0
void collision_avoided(double direction, struct timeval time){
	running = 0;
	current.timer = time;
	free(route.path);
	compare_tile();
	current.current_destination.angle = direction;
	update_position(&current);
	compare_tile();
	recalc();
}
Beispiel #25
0
void VWindow::goto_start()
{
	if(get_edl())
	{
		get_edl()->local_session->set_selectionstart(0);
		get_edl()->local_session->set_selectionend(0);
		update_position(CHANGE_NONE, 
			0, 
			1);
	}
}
Beispiel #26
0
int 
SKY_BOX::draw_color_ref(int i)
{  
   if (i != 0)
      return 0;

   update_position(); 

   // XXX - probably wrong...
   return DrawGradient(VIEW::peek());
}
Beispiel #27
0
void reduction_entropy::
update_surfel_attributes(shared_surfel target_surfel_ptr, 
                         shared_entropy_surfel_vector const invalidated_neighbours) const {

    update_normal(target_surfel_ptr, invalidated_neighbours);
    update_color(target_surfel_ptr, invalidated_neighbours);

    // position needs to be updated before the radius is updated
    update_position(target_surfel_ptr, invalidated_neighbours);
    update_radius(target_surfel_ptr, invalidated_neighbours);
}
Beispiel #28
0
void utf8iterator_next(Utf8Iterator* iter) {
    iter->_start += iter->_width;
    // We update positions based on the *last* character read, so that the first
    // character following a newline is at column 1 in the next line.
    update_position(iter);
    if (iter->_start < iter->_end) {
        read_char(iter);
    } else {  // EOF
        iter->_current = -1;
    }
}
//struct sphere move_on_curve( struct sphere *ball ) {
void move_on_curve( struct sphere *ball ) {
	struct point2f temp;
	temp = ball->pos;
	// store previous position
	ball->previous_pos = temp;
	ball->interval =( current - ball->start_time )/
		( CLOCKS_PER_SEC * ball->curve_time );
	//printf("before update: %f %f || %f %f\n", ball->previous_pos.x, ball->previous_pos.y, ball->pos.x, ball->pos.y);
	update_position( ball );
	//printf("after update: %f %f || %f %f\n", ball->previous_pos.x, ball->previous_pos.y, ball->pos.x, ball->pos.y);
}
Beispiel #30
0
void CombatGameInst::attempt_move_to_position(GameState* gs, float& newx,
		float& newy) {

	float dx = newx - rx, dy = newy - ry;
	float dist = sqrt(dx * dx + dy * dy);

	bool collided = gs->tile_radius_test(round(newx), round(newy), 20);

	if (!collided) {
		rx = newx, ry = newy;
	} else {
		float nx = round(rx + vx), ny = round(ry + vy);
		bool collided = gs->tile_radius_test(nx, ny, radius);
		if (collided) {
			bool hitsx = gs->tile_radius_test(nx, y, radius);
			bool hitsy = gs->tile_radius_test(x, ny, radius);
			if (hitsy || hitsx || collided) {
				if (hitsx) {
					vx = 0;
				}
				if (hitsy) {
					vy = 0;
				}
				if (!hitsy && !hitsx) {
					vx = -vx;
					vy = -vy;
				}
			}
		}
//		else {
//			if (in_corridor_heurestic(gs,
//					Pos(rx / TILE_SIZE, ry / TILE_SIZE))) {
//				float proportion = proportion_in_same_dir(dx, dy, vx, vy);
//				if (!gs->tile_radius_test(round(rx + vx * proportion),
//						round(ry + vy * proportion), radius)) {
//					vx *= proportion, vy *= proportion;
//				} else {
//					vx = 0.0f, vy = 0.0f;
//				}
//			}
//		}

//		normalize(nx, ny, effective_stats().movespeed);

		vx = round(vx * ROUNDING_MULTIPLE) / ROUNDING_MULTIPLE;
		vy = round(vy * ROUNDING_MULTIPLE) / ROUNDING_MULTIPLE;
		rx += vx;
		ry += vy;
	}
	newx = rx, newy = ry;

	update_position();
}