示例#1
0
// Avatar parameter and texture definitions can change over time.
// This function returns true if parameters or textures have been added or removed
// since this wearable was created.
BOOL LLWearable::isOldVersion()
{
	LLVOAvatar* avatar = gAgent.getAvatarObject();
	llassert( avatar );
	if( !avatar )
	{
		return FALSE;
	}

	if( LLWearable::sCurrentDefinitionVersion < mDefinitionVersion )
	{
		llwarns << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLWearable::sCurrentDefinitionVersion << ")" << llendl;
		llassert(0);
	}

	if( LLWearable::sCurrentDefinitionVersion != mDefinitionVersion )
	{
		return TRUE;
	}

	S32 param_count = 0;
	for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam(); 
		param;
		param = (LLViewerVisualParam*) avatar->getNextVisualParam() )
	{
		if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
		{
			param_count++;
			if( !is_in_map(mVisualParamMap, param->getID() ) )
			{
				return TRUE;
			}
		}
	}
	if( param_count != mVisualParamMap.size() )
	{
		return TRUE;
	}


	S32 te_count = 0;
	for( S32 te = 0; te < LLVOAvatar::TEX_NUM_ENTRIES; te++ )
	{
		if( LLVOAvatar::getTEWearableType( te ) == mType )
		{
			te_count++;
			if( !is_in_map(mTEMap, te ) )
			{
				return TRUE;
			}
		}
	}
	if( te_count != mTEMap.size() )
	{
		return TRUE;
	}

	return FALSE;
}
示例#2
0
static void 
add_clear_point(int x, int y, carmen_map_p true_map, carmen_map_p modify_map) 
{
  int num_points = scan_size[current_data_set];
  grid_cell_p cell_list;
  double value;

  if (!is_in_map(x, y, modify_map))
    return;

  value = true_map->map[x][y];

  /*   if (is_empty(value))  */
  /* 		return; */
		
  if (point_exists(x, y, EMPTY))
    return;

  if (num_points == max_scan_size[current_data_set]) {
    max_scan_size[current_data_set] *= 2;
    laser_scan[current_data_set] = 
      realloc(laser_scan[current_data_set], 
	      max_scan_size[current_data_set]*sizeof(grid_cell_t));
    carmen_test_alloc(laser_scan[current_data_set]);
  }

  cell_list = laser_scan[current_data_set];
  value = EMPTY;
  cell_list[num_points].x = x;
  cell_list[num_points].y = y;
  cell_list[num_points].value = value;
  scan_size[current_data_set]++;
  modify_map->map[x][y] = value;
}
//-----------------------------------------------------------------------------
// addMotion()
//-----------------------------------------------------------------------------
BOOL LLMotionRegistry::registerMotion( const LLUUID& id, LLMotionConstructor constructor )
{
	//	llinfos << "Registering motion: " << name << llendl;
	if (!is_in_map(mMotionTable, id))
	{
		mMotionTable[id] = constructor;
		return TRUE;
	}
	
	return FALSE;
}
示例#4
0
int is_entity_ok (int x, int y)
{
    // On vérifie si aucune autre entité n'est sur la case visée
    if (is_occupied(x, y))
        return 0;

    // On vérifie si le personnage n'essaye pas de sortir de la map
    if (!is_in_map(x, y))
        return 0;

    // On vérifie si le personnage peut marcher si le tile visé
    if (is_bloquant(x, y))
        return 0;

    if (is_object(x, y))
        return 0;

    return 1;
}
示例#5
0
void 
trace_laser(int x_1, int y_1, int x_2, int y_2, carmen_map_p true_map, 
	    carmen_map_p modify_map) 
{
  carmen_bresenham_param_t params;
  int X, Y;
  double true_map_value;
  double modified_map_value;

  carmen_get_bresenham_parameters(x_1, y_1, x_2, y_2, &params);
  
  do {
    carmen_get_current_point(&params, &X, &Y);
    if (!is_in_map(X, Y, modify_map))
      break;
    true_map_value = true_map->map[X][Y];
    modified_map_value = modify_map->map[X][Y];
    
    if (!is_empty(modified_map_value)  &&   is_empty(true_map_value)) 
      add_clear_point(X, Y, true_map, modify_map);
  } while (carmen_get_next_point(&params));
}
示例#6
0
// returns 1 if point is in map
static int map_filter(double x, double y, double r) {

  carmen_world_point_t wp;
  carmen_map_point_t mp;
  double d;
  int md, i, j;

  wp.map = &static_map;
  wp.pose.x = x;
  wp.pose.y = y;

  carmen_world_to_map(&wp, &mp);

  d = (map_diff_threshold + r*map_diff_threshold_scalar)/static_map.config.resolution;
  md = carmen_round(d);
  
  for (i = mp.x-md; i <= mp.x+md; i++)
    for (j = mp.y-md; j <= mp.y+md; j++)
      if (is_in_map(i, j) && dist(i-mp.x, j-mp.y) <= d &&
	  exp(localize_map.gprob[i][j]) >= map_occupied_threshold)
	return 1;

  return 0;
}
示例#7
0
static void 
add_filled_point(int x, int y, carmen_map_p true_map, carmen_map_p modify_map) 
{
  int num_points;
  grid_cell_p cell_list;
  double value;

  if (!is_in_map(x, y, modify_map))
    return;

  value = true_map->map[x][y];  
  if (is_filled(value))
    return;

  /*   if (point_exists(x, y, FILLED)) */
  /*     return; */

  num_points = scan_size[current_data_set];
  if (num_points == max_scan_size[current_data_set]) {
    max_scan_size[current_data_set] *= 2;
    laser_scan[current_data_set] = 
      realloc(laser_scan[current_data_set], 
	      max_scan_size[current_data_set]*sizeof(grid_cell_t));
    carmen_test_alloc(laser_scan[current_data_set]);
  }

  cell_list = laser_scan[current_data_set];
  value = FILLED;
  /*      carmen_warn("Filling point %d (%d) %d %d\n", num_points, */
  /*  	 current_data_set, x, y); */
  cell_list[num_points].x = x;
  cell_list[num_points].y = y;
  cell_list[num_points].value = value;
  scan_size[current_data_set]++;
  modify_map->map[x][y] = 2.0;
}
示例#8
0
void 
map_modify_update(carmen_robot_laser_message *laser_msg, 
		  carmen_navigator_config_t *config,
		  carmen_world_point_p world_point, 
		  carmen_map_p true_map, 
		  carmen_map_p modify_map) 
{
  int index;
  double angle, separation;
  int laser_x, laser_y;
  double dist;
  int increment;
  carmen_map_point_t map_point;  
  int count;
  
  int maxrange_beam;

  if (!config->map_update_freespace &&  !config->map_update_obstacles)
    return;

  if (true_map == NULL || modify_map == NULL)
    {
      carmen_warn("%s called with NULL map argument.\n", __FUNCTION__);
      return;
    }

  if (laser_scan == NULL) {
    laser_scan = (grid_cell_p *)calloc(LASER_HISTORY_LENGTH, sizeof(grid_cell_p));
    carmen_test_alloc(laser_scan);

    scan_size = (int *)calloc(LASER_HISTORY_LENGTH, sizeof(int));
    carmen_test_alloc(scan_size);

    max_scan_size = (int *)calloc(LASER_HISTORY_LENGTH, sizeof(int));
    carmen_test_alloc(max_scan_size);
  }

  update_existing_data(true_map, modify_map);

  if (laser_msg->num_readings < config->num_lasers_to_use)   {
    increment = 1;
    separation = laser_msg->config.angular_resolution;
  } 
  else  {
    increment = laser_msg->num_readings / config->num_lasers_to_use;
    if (increment != 1) 
      separation = carmen_normalize_theta(laser_msg->config.fov / (config->num_lasers_to_use+1));
    else
      separation = laser_msg->config.angular_resolution;
  }

  angle = carmen_normalize_theta(world_point->pose.theta + 
				 laser_msg->config.start_angle);
  carmen_world_to_map(world_point, &map_point); 
  
  count = 0;
  for (index = 0; index < laser_msg->num_readings; index += increment) {    

    if (laser_msg->range[index] < laser_msg->config.maximum_range  )
      maxrange_beam = 0;
    else
      maxrange_beam = 1;

    if (config->map_update_freespace) {

      dist = laser_msg->range[index] - modify_map->config.resolution;
      if (dist < 0)
	dist = 0;
      if (dist > config->map_update_radius)
	dist = config->map_update_radius;
      
      laser_x = carmen_round(map_point.x + (cos(angle)*dist)/
			     modify_map->config.resolution);
      laser_y = carmen_round(map_point.y + (sin(angle)*dist)/
			     modify_map->config.resolution);    
      
      trace_laser(map_point.x, map_point.y, laser_x, laser_y, true_map, modify_map);
    }

    if (config->map_update_obstacles) {

      // add obstacle only if it is not a maxrange reading!
      if (!maxrange_beam) {
	
	dist = laser_msg->range[index];
	
	
	laser_x = carmen_round(map_point.x + (cos(angle)*dist)/
			       modify_map->config.resolution);
	laser_y = carmen_round(map_point.y + (sin(angle)*dist)/
			       modify_map->config.resolution);

	if (is_in_map(laser_x, laser_y, modify_map) && 
	    dist < config->map_update_radius &&
	    dist < (laser_msg->config.maximum_range - 2*modify_map->config.resolution)) {
	  count++;
	  add_filled_point(laser_x, laser_y, true_map, modify_map);
	}
      }
    }
    angle += separation;
  }
}