当前位置: 首页>>代码示例>>C++>>正文


C++ AABB::add方法代码示例

本文整理汇总了C++中AABB::add方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::add方法的具体用法?C++ AABB::add怎么用?C++ AABB::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AABB的用法示例。


在下文中一共展示了AABB::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BeginModel

/**
 * @brief Sets up a new brush model
 * @sa EndModel
 */
void BeginModel (int entityNum)
{
	dBspModel_t* mod;
	int start, end;
	int j;
	const entity_t* e;

	if (curTile->nummodels == MAX_MAP_MODELS)
		Sys_Error("MAX_MAP_MODELS (%i)", curTile->nummodels);
	mod = &curTile->models[curTile->nummodels];

	mod->firstface = curTile->numfaces;

	firstmodeledge = curTile->numedges;

	/* bound the brushes */
	e = &entities[entityNum];

	start = e->firstbrush;
	end = start + e->numbrushes;
	AABB modBox;
	modBox.setNegativeVolume();

	for (j = start; j < end; j++) {
		const mapbrush_t* b = &mapbrushes[j];
		/* not a real brush (origin brush) - e.g. func_door */
		if (!b->numsides)
			continue;
		modBox.add(b->mbBox);
	}

	VectorCopy(modBox.mins, mod->mins);
	VectorCopy(modBox.maxs, mod->maxs);
}
开发者ID:nicogiraldi,项目名称:ufoai,代码行数:38,代码来源:writebsp.cpp

示例2: init

void PhotonMap::init() {
   // build the underlying balanced kd-Tree
   if (size() > 1) {
      Photon **orig = (Photon **) malloc(sizeof(Photon*) * (size() + 1));
      Photon **tree = (Photon **) malloc(sizeof(Photon*) * (size() + 1));
      AABB aabb;
      
      // add all photons
      for (unsigned i = 1; i <= size(); ++i) {
         orig[i] = &m_photons[i];
         m_photons[i].plane = 0;
         
         aabb.add(m_photons[i].position);
         tree[i] = NULL;
      }
      
      // recursively balance tree
      _balance(tree, orig, 1, 1, size(), aabb);
      
      free(orig);
      
      unsigned d, j = 1, temp = 1;
      Photon temp_photon = m_photons[j];
      
      // update internal bookkeeping
      for (unsigned i = 1; i <= size(); ++i) {
         d = tree[j] - &m_photons[0];
         tree[j] = NULL;
         
         if (d != temp) {
            m_photons[j] = m_photons[d];
         } else {
            m_photons[j] = temp_photon;

            if (i < size()) {
               for (; temp <= size(); ++temp) 
                  if (tree[temp] != NULL)
                     break;
               
               temp_photon = m_photons[temp];
               j = temp;
            }
            
            continue;
         }
         
         j = d;
      }
      
      free(tree);
   }
   
   m_halfPhotons = m_size / 2 - 1;
}
开发者ID:fisch0920,项目名称:Milton,代码行数:54,代码来源:PhotonMap.cpp

示例3: Check_MapSize

/** needs to be done here, on map brushes as worldMins and worldMaxs from levels.c
 * are only calculated on BSPing
 * @param[out] mapSize the returned size in map units
 */
static void Check_MapSize (vec3_t mapSize)
{
	AABB mapBox;

	mapBox.setNegativeVolume();

	for (int i = 0; i < nummapbrushes; i++) {
		const mapbrush_t* brush = &mapbrushes[i];

		for (int bi = 0; bi < brush->numsides; bi++) {
			const winding_t* winding = brush->original_sides[bi].winding;

			for (int vi = 0; vi < winding->numpoints; vi++)
				mapBox.add(winding->p[vi]);
		}
	}
	mapBox.getDiagonal(mapSize);
}
开发者ID:Ed-von-Schleck,项目名称:ufoai,代码行数:22,代码来源:checkentities.cpp

示例4: df

void collision_detection::StaticDistanceField::initialize(
      const bodies::Body& body,
      double resolution,
      double space_around_body,
      bool save_points)
{
  points_.clear();
  inv_twice_resolution_ = 1.0 / (2.0 * resolution);


  logInform("    create points at res=%f",resolution);
  EigenSTL::vector_Vector3d points;
  determineCollisionPoints(body, resolution, points);

  if (points.empty())
  {
    logWarn("    StaticDistanceField::initialize: No points in body. Using origin.");
    points.push_back(body.getPose().translation());

    if (body.getType() == shapes::MESH)
    {
      const bodies::ConvexMesh& mesh = dynamic_cast<const bodies::ConvexMesh&>(body);
      const EigenSTL::vector_Vector3d& verts = mesh.getVertices();
      logWarn("    StaticDistanceField::initialize: also using %d vertices.", int(verts.size()));

      EigenSTL::vector_Vector3d::const_iterator it = verts.begin();
      EigenSTL::vector_Vector3d::const_iterator it_end = verts.end();
      for ( ; it != it_end ; ++it)
      {
        points.push_back(*it);
      }
    }
  }
  logInform("    StaticDistanceField::initialize: Using %d points.", points.size());

  AABB aabb;
  aabb.add(points);

  logInform("    space_around_body = %f",space_around_body);
  logInform("    DF: min=(%7.3f %7.3f %7.3f)  max=(%7.3f %7.3f %7.3f) (pre-space)",
                              aabb.min_.x(),
                              aabb.min_.y(),
                              aabb.min_.z(),
                              aabb.max_.x(),
                              aabb.max_.y(),
                              aabb.max_.z());

  aabb.min_ -= Eigen::Vector3d(space_around_body, space_around_body, space_around_body);
  aabb.max_ += Eigen::Vector3d(space_around_body, space_around_body, space_around_body);

  logInform("    DF: min=(%7.3f %7.3f %7.3f)  max=(%7.3f %7.3f %7.3f) (pre-adjust)",
                              aabb.min_.x(),
                              aabb.min_.y(),
                              aabb.min_.z(),
                              aabb.max_.x(),
                              aabb.max_.y(),
                              aabb.max_.z());

  aabb.min_.x() = std::floor(aabb.min_.x() / resolution) * resolution;
  aabb.min_.y() = std::floor(aabb.min_.y() / resolution) * resolution;
  aabb.min_.z() = std::floor(aabb.min_.z() / resolution) * resolution;

  logInform("    DF: min=(%7.3f %7.3f %7.3f)  max=(%7.3f %7.3f %7.3f) (post-adjust)",
                              aabb.min_.x(),
                              aabb.min_.y(),
                              aabb.min_.z(),
                              aabb.max_.x(),
                              aabb.max_.y(),
                              aabb.max_.z());

  Eigen::Vector3d size = aabb.max_ - aabb.min_;

  double diagonal = size.norm();

  logInform("    DF: sz=(%7.3f %7.3f %7.3f) cnt=(%d %d %d) diag=%f",
                              size.x(),
                              size.y(),
                              size.z(),
                              int(size.x()/resolution),
                              int(size.y()/resolution),
                              int(size.z()/resolution),
                              diagonal);


  distance_field::PropagationDistanceField df(
                              size.x(),
                              size.y(),
                              size.z(),
                              resolution,
                              aabb.min_.x(),
                              aabb.min_.y(),
                              aabb.min_.z(),
                              diagonal * 2.0,
                              true);
  df.addPointsToField(points);

  DistPosEntry default_entry;
  default_entry.distance_ = diagonal * 2.0;
  default_entry.cell_id_ = -1;

//.........这里部分代码省略.........
开发者ID:team-vigir,项目名称:vigir_moveit_advanced,代码行数:101,代码来源:static_distance_field.cpp


注:本文中的AABB::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。