コード例 #1
0
ファイル: KdNode.cpp プロジェクト: latuya23/rt2
bool KdNode::IntersectsKDTree(Ray* ray, Intersection* isect){
  if (m_boxBV->IntersectsP(ray)){
    bool foundAny = false;
    Intersection closest = Intersection(glm::dvec3(0),tempM,
					10000.0,glm::dvec3(0));
    Intersection temp;
    if (leftChild->m_triangles.size() > 0 ||
	rightChild->m_triangles.size() > 0 ){
      bool foundAnyLeft = leftChild->IntersectsKDTree(ray,&temp);
      if (IsCloser(temp,closest)){
	closest = temp;
      }
      bool foundAnyRight = rightChild->IntersectsKDTree(ray,&temp);
      if (IsCloser(temp,closest)){
	closest = temp;
      }
      *isect = closest;
      return foundAnyLeft || foundAnyRight;
    }
    else {
      //leaves
      for (unsigned int i=0; i < m_triangles.size(); i++){
	if(m_triangles[i]->Intersects(ray,&temp)){
	  foundAny = true;
	  if (IsCloser(temp,closest)){
	    closest = temp;
	  }
	}
      }
      *isect = closest;
      return foundAny;
    }
  }
  return false;
}
コード例 #2
0
ファイル: scidoc.cpp プロジェクト: yetanothergeek/fxite
void SciDoc::MatchBrace()
{
  int mode=SettingsBase::instance()->BraceMatch;
  long CurrPos=sendMessage(SCI_GETCURRENTPOS,0,0);
  if ((CurrPos>0)&&(mode==BRACEMATCH_EITHER)) {
    char ThisChar=sendMessage(SCI_GETCHARAT,CurrPos,0);
    if (IsCloser(ThisChar)||IsOpener(ThisChar)) {
      long PrevPos=sendMessage(SCI_POSITIONBEFORE,CurrPos,0);
      char PrevChar=sendMessage(SCI_GETCHARAT,PrevPos,0);
      if (IsCloser(PrevChar)||IsOpener(PrevChar)) { CurrPos=PrevPos; }
    }
  }
  if (IsBrace(CurrPos,mode)) {
    int ThatBrace=sendMessage(SCI_BRACEMATCH,CurrPos,0);
    if ((ThatBrace>=0)&&(StyleAt(ThatBrace)!=StyleAt(CurrPos))) {
      sendMessage(SCI_COLOURISE,0,-1);
      ThatBrace=sendMessage(SCI_BRACEMATCH,CurrPos,0);
    }
    if (ThatBrace>=0) {
      sendMessage(SCI_BRACEHIGHLIGHT,CurrPos,ThatBrace);
    } else {
      sendMessage(SCI_BRACEBADLIGHT,CurrPos,0);
    }
  } else {
    sendMessage(SCI_BRACEHIGHLIGHT,INVALID_RANGE,INVALID_RANGE);
  }
}
コード例 #3
0
ファイル: scidoc.cpp プロジェクト: yetanothergeek/fxite
inline bool SciDoc::IsAfterBrace(long &pos)
{
  if (pos<=0) { return false; }
  char ThisBrace=sendMessage(SCI_GETCHARAT,pos-1,0);
  if (IsOpener(ThisBrace)||IsCloser(ThisBrace)) {
    pos--;
  } else {
    return false;
  }
  int charwidth = sendMessage(SCI_POSITIONAFTER,pos,0)-sendMessage(SCI_POSITIONBEFORE,pos,0);
  return ((charwidth>=2)||((pos==0)&&(charwidth==1)));
}
コード例 #4
0
ファイル: scidoc.cpp プロジェクト: yetanothergeek/fxite
inline bool SciDoc::IsOutsideBrace(long &pos)
{
  char ThisBrace=sendMessage(SCI_GETCHARAT,pos-1,0);
  if (IsCloser(ThisBrace)) {
    if (sendMessage(SCI_GETCURRENTPOS,0,0)==pos) { pos--; }
  } else {
    ThisBrace=sendMessage(SCI_GETCHARAT,pos,0);
    if (!IsOpener(ThisBrace)) {
      return false;
    }
  }
  int charwidth = sendMessage(SCI_POSITIONAFTER,pos,0)-sendMessage(SCI_POSITIONBEFORE,pos,0);
  return ((charwidth>=2)||((pos==0)&&(charwidth==1)));
}
コード例 #5
0
ファイル: Model.cpp プロジェクト: latuya23/rt2
bool Model::IntersectsTriangles(Ray* ray, Intersection* inters){
  bool foundAny = false;
  Intersection temp;
  Intersection closest = Intersection(glm::dvec3(0),m_material ,
			 100000.0, glm::dvec3(0));
  for (unsigned int i = 0; i < m_triangles->size(); i++){
    if ((*m_triangles)[i]->Intersects(ray,&temp)){
      foundAny = true;
      //std::cout << "the intersect happened at: " << i << std::endl;
      //temp.Print();
      //(*m_triangles)[i]->Print();
      if(IsCloser(temp,closest)){
	closest = temp;
      }
    }
  }
  //std::cout << "the intersect happened at: " << std::endl;
  //closest.Print();
  //std::cout << "found " << foundAny << " intersections"<<std::endl;
  *inters = closest;
  return foundAny;
}