Esempio n. 1
0
/**
 * Проверяет потенциальное совпадение двух элементов массива
 * Значения индексов для этой процедуры считаются окончательными
 * даже если граф строится для итерации (проверяется только 1 итерация 
 * а не их последовательность).
 */
bool equal(const TParam &in, const TParam &out)
{
    // FIXME - only for non scalar value
    if (in. getName() != out. getName())
        return false;
    if (!in. isArrayElement() || !out. isArrayElement())
        return true; // array  and subarray
    // the dimension must be equal - fixme
    int dim1 = in. getDimension();
    int dim2 = out.getDimension();
    int common = (dim1 >= dim2) ? dim2 : dim1;

    TIndex *ind_in = in. getIndexes();
    TIndex *ind_out = out. getIndexes();

    for (int i = 0; i < common; i++)
    {
        if (ind_in[i]. isAtom() || ind_out[i]. isAtom())
            continue;
        if (isIntersect(ind_in[i].diap, ind_out[i].diap))
        {
            continue;
        }
        else
        {
            delete[] ind_in;
            delete[] ind_out;
            return false;
        }
    }
    delete[] ind_in;
    delete[] ind_out;
    return true;
}
Esempio n. 2
0
bool Field::toRight(){
    if(_figure==0)return false;
    _figure->moveToRight();
    if(     _figure->x()+_figure->width()>_width||
            isIntersect()){
        _figure->moveToLeft();
        return false;
    }
    return true;
}
Esempio n. 3
0
bool Field::toDown(){
    if(_figure==0)return false;
    _figure->moveToDown();
    if(_figure->y()+_figure->height()>_height||
            isIntersect()){
        _figure->moveToUp();
        dropFigure();
        return false;
    }
    return true;
}
Esempio n. 4
0
// WARNING: ASSUME NORMALIZED RAY
// Compute the intersection ray / scene.
// Returns true if intersection
// t is defined as the abscisce along the ray (i.e
//             p = r.o + t * r.d
// id is the id of the intersected object
Object* intersect (const Ray & r, float &t)
{
    t = noIntersect;
    Object *ret = nullptr;

    for(auto &object : scene::objects)
    {
        float d = object->intersect(r);
        if (isIntersect(d) && d < t)
        {
            t = d;
            ret = object.get();
        }
    }

    return ret;
}
Esempio n. 5
0
void Triangle::restrictMove( Vector3* v, const Vector3& p ) const {
	//まず判定
	bool r = isIntersect( p, *v );
	if ( !r ){
		return; //当たらないのでそのまま終わる
	}
	//さて当たっているならば、ベクタを修正する。
	//式は法線nを使って以下のように書ける
	//a = v - dot( n, v ) * n / |n|^2
	Vector3 d, e, n;
	d.setSub( mPosition[ 1 ], mPosition[ 0 ] );
	e.setSub( mPosition[ 2 ], mPosition[ 0 ] );
	n.setCross( d, e );

	n *= n.dot( *v ) / n.squareLength();
	*v -= n;
}
Esempio n. 6
0
// WARNING: ASSUME NORMALIZED RAY
// Compute the intersection ray / scene.
// Returns true if intersection
// t is defined as the abscisce along the ray (i.e
//             p = r.o + t * r.d
// id is the id of the intersected object
Object* intersect (const Ray & r, float &t, glm::vec3 &normale)
{
    t = noIntersect;
    Object *ret = nullptr;

    for(auto &object : scene::objects)
    {
        float d = object->intersect(r);
        if (isIntersect(d) && d < t)
        {
            t = d;
            ret = object.get();
        }
    }
    if (ret != nullptr)
        normale = ret->normale(r.origin + t*r.direction);
    return ret;
}
void BaseTower::moveTower(Vec2 pos)
{
	//具体的移动
	this->setPosition(pos);
	//是否可以放置炮塔的位置check
	int type = this->getTowerType();

	//log("type %d", type);

	bool is = isIntersect();

	GameManager * instance = GameManager::getInstance();
	//得到map的大小:以格子数计算
	auto mapSize = instance->map->getMapSize();
	//log("mapSize : %f %f", mapSize.width, mapSize.height);
	// 将position转化为地图坐标
	auto tilePos = this->convertTotileCoord(pos-Point(0,this->towerSprite->getBoundingBox().size.height/2)+Point(0,16)); //加上地图格子的一半长度,不是全部长度
	//log("tilePos : %f %f", tilePos.x, tilePos.y);
	// canBliud是用于判断是否可生成瓦片的变量

	int gid = instance->map->getLayer("bg")->getTileGIDAt(tilePos);

	if (!is && gid != ROAD) //无交集,可以建造
	{

		this->towerSprite->setTexture(move_texture[type]);
		buildIcon->setTexture("canBuild.png");
		canPutDown = true;

	}
	else //有交集,显示红色炮塔
	{
		this->towerSprite->setTexture(move_texture_en[type]);
		buildIcon->setTexture("cannotBuild.png");
		canPutDown = false;

	}


}
int RegisterAllocator::allocateBlockedReg(int i) {
    std::vector<int> nextUsePos (NUM_REGS, INT_MAX);
    // FOR EACH active interval
    int cur_iid = iid_start_pairs[i].first;
    int cur_start = iid_start_pairs[i].second;
    for (int iid : active) {
        std::cout << "[active] findNextUse: iid=" << iid 
            << ", cur_start: " << cur_start << std::endl;
        int potential = findNextUse(cur_iid, iid, cur_start);
        nextUsePos[virtual2machine[iid]] = std::min(nextUsePos[virtual2machine[iid]], potential);
    }
    // FOR EACH inactive interval
    for (int iid : inactive) {
        std::cout << "[inactive] findNextUse: iid=" << iid 
            << ", cur_start: " << cur_start << std::endl;
        if (isIntersect(all_intervals[iid], all_intervals[cur_iid])) {
            int potential = findNextUse(cur_iid, iid, cur_start);
            nextUsePos[virtual2machine[iid]] = std::min(nextUsePos[virtual2machine[iid]], potential);
        }
    }
    return maxIndexVector(nextUsePos);
}
void FrameBuffer::fillPolygon(Polygon* polygon, int yMin, int yMax){
  
  int nLine = polygon->getPointCount();
  for (int yScanline = yMin; yScanline <= yMax; ++yScanline) {

    // printf("y: %d\n", yScanline);    
    // fflush(stdout);

    std::vector<intersection> intersectEdge; 
    for (int e = 0; e < nLine; ++e) {
      if (isIntersect(polygon, e, yScanline)) {
        int type = isHorizontalLine(polygon, e);
        int x;
        if (type) {
          x = getMiddleX(polygon, e);
        } else {
          x = xIntersect(polygon, e, yScanline);
        }
        intersectEdge.push_back(intersection(e, x, type));
      }
    }

    std::sort(intersectEdge.begin(), intersectEdge.end());

    std::vector<intersection>::iterator i = intersectEdge.begin(), j;

    if (i!=intersectEdge.end()) {
      while ((i+1) != intersectEdge.end()) {
        if ((((i+1)->x - i->x) < 5) &&
          (!isCriticalPoint(polygon, (*i).edge,(*(i+1)).edge, yScanline))) {
          
          i = intersectEdge.erase(i);

        } else {
          if ((i+1)->type == 1) {

            // warning: this conditional maybe cause a bug
            if ((i+2) != intersectEdge.end()) {
              if (isCriticalPoint(polygon, (*i).edge,(*(i+2)).edge, yScanline)) {
                i++;
                i = intersectEdge.erase(i);
              } else {
                i++;
                i->x = (i+1)->x;
                i++;
              }
            } else {
              i++;
            }

          } else {
            i++;
          }
        }
      }
    }


    int fillRed = polygon->getColorRed();
    int fillGreen = polygon->getColorGreen();
    int fillBlue = polygon->getColorBlue();

    for (int i = 0; i+1 < intersectEdge.size(); i+=2) {
      int e = intersectEdge[i].edge;
      for (int x = intersectEdge[i].x; x < intersectEdge[i+1].x; x++) {
        plot(x, yScanline, fillRed, fillGreen, fillBlue);
      }
    }

  }
}
Esempio n. 10
0
bool isOutwardDepend(const stringSet &out1, const stringSet &out2)
{
    return isIntersect(out1, out2);
}
Esempio n. 11
0
bool isBackwardDepend(const stringSet &out, const stringSet &in)
{
    return isIntersect(out, in);
}
Esempio n. 12
0
bool isForwardDepend(const stringSet &in, const stringSet &out)
{
    return isIntersect(in, out);
}