예제 #1
0
int MakeNodes(Node** output)
{
	if(rand() % 2)
	{
		*output = new Node();
		return MakeNodes(&( *output )->left) + MakeNodes(&( *output )->right) + 1;
	}
	return 0;
}
예제 #2
0
void NodeTest()
{
	Node* root = new Node();
	int realCount = MakeNodes(&root);
	int testCount = Count(root);
	printf("RealCount : %d , TestCount : %d\n", realCount, testCount);
}
void MainWindow::MakeFreqMap(){
	m_pFreqMap = new QHash<QChar,int>(); 
	QString plainText = m_pTextEdit->toPlainText() ; 
	if(!plainText.isEmpty())
	{
		QChar * data = plainText.data();
		while(!data->isNull())
		{
			//iterate through string, adding and incrementing frequencies.
			QHash<QChar, int>::iterator iter = m_pFreqMap->find(*data); 
			if(iter.key() == m_pFreqMap->end().key()){
				//key not found, insert new key and set its value to 1
				m_pFreqMap->insert(*data,1);
			}
			else{
				//the value was found, increment its frequency
				//this is an inefficient way to do this, consider redoing it.
				int newFreq = m_pFreqMap->take(*data) + 1; 
				m_pFreqMap->insert(*data,newFreq);		
			}
			//lastly, move one position through the string. 
			data++;
		}
	}
//Make Nodes from the freq map
	MakeNodes(m_pFreqMap);
	RunBST(); 
}
예제 #4
0
void RayBVHEngineBuilder::Build(shared_ptr<InstanceGroup> surface, const Intervalf& time, int timeSamples, vector<RayEngine*> &es)
{
    if (shared_ptr<MeshShape> shape = dynamic_pointer_cast<MeshShape>(surface->ShapeRef()))
    {
        MakeNodes(shape, surface->MaterialArray(), surface->XformArray(), es);
    }
    else if (shared_ptr<SphereShape> shape = dynamic_pointer_cast<SphereShape>(surface->ShapeRef()))
    {
        MakeNodes(shape, surface->MaterialArray(), surface->XformArray(), es);
    }
    else if (shared_ptr<CurveShape> shape = dynamic_pointer_cast<CurveShape>(surface->ShapeRef()))
    {
        MakeNodes(shape, surface->MaterialArray(), surface->XformArray(), es);
    }
    else
    {
        cerr << "shape type not supported" << endl;
    }
}
예제 #5
0
파일: kdbuild.c 프로젝트: lukaszdk/lzrt
int main(unsigned long long spu_id __attribute__ ((unused)), unsigned long long parm)
{
	init_spu_abs();
	init_memcpy();

	uint tag_id = mfc_tag_reserve();
	jobtag = mfc_tag_reserve();

	memcpy_tag_ppe[0] = mfc_tag_reserve();
	memcpy_tag_ppe[1] = mfc_tag_reserve();

	// Transfer arg
	spu_mfcdma32(&arg, (unsigned int)parm, (unsigned int)sizeof(kdbuild_arg_t), tag_id, MFC_GET_CMD);
	DmaWait(tag_id);

	nsamplepoints = arg.nsamplepoints;
	nsplitaxises = arg.nsplitaxises;

	curleaf = arg.curleaf;
	curjob = 0;

	total_leaf_size = 0;

	MakeNodes();	

	DmaWaitAll();

	MakeLeaves();

	DmaWaitAll();

	spu_mfcdma32(&numleafpolys, (unsigned int)arg.numleafpolys, sizeof(int), tag_id, MFC_PUT_CMD);
	
	DmaWait(tag_id);	


	

	return 0;
}
예제 #6
0
void RNFR067_IsoSplash::Prepare(Wz4RenderContext *ctx)
{
  for(sInt i=0;i<4;i++)
  {
    if(Mtrl[i]) 
      Mtrl[i]->BeforeFrame(Para.LightEnv);
  }

  SphereEnable = (Para.SphereAmp!=0.0f);
  SphereAmp.x = 1.0f / Para.SphereDirections.x;
  SphereAmp.y = 1.0f / Para.SphereDirections.y;
  SphereAmp.z = 1.0f / Para.SphereDirections.z;
  SphereAmp = SphereAmp * SphereAmp;

  CubeEnable = (Para.CubeAmp!=0.0f);
  CubeAmp.x = 1.0f / Para.CubeDirections.x;
  CubeAmp.y = 1.0f / Para.CubeDirections.y;
  CubeAmp.z = 1.0f / Para.CubeDirections.z;

  NoiseEnable = (Para.NoiseAmp1!=0.0f) || (Para.NoiseAmp2!=0.0f);
  NoiseFreq1 = Para.NoiseFreq1*0x10000;
  NoisePhase1 = Para.NoisePhase1*0x10000;
  NoiseAmp1 = Para.NoiseAmp1;
  NoiseFreq2 = Para.NoiseFreq2*0x10000;
  NoisePhase2 = Para.NoisePhase2*0x10000;
  NoiseAmp2 = Para.NoiseAmp2;

  RotEnable = 0;
  RubberEnable = 0;
  if(Para.Rot.x!=0 || Para.Rot.y!=0 || Para.Rot.z!=0)
    RotEnable = 1;
  if(Para.Rubber.x!=0 || Para.Rubber.y!=0 || Para.Rubber.z!=0)
    RotEnable = RubberEnable = 1;

  PolarEnable = (Para.PolarAmp!=0.0f);


  for(sInt i=0;i<Size;i++)
  {
    sF32 py = sF32(i-1)/sF32((1<<Para.OctreeDivisions)*8);
    RubberMat[i].EulerXYZ((Para.Rot.x+Para.Rubber.x*py)*sPI2F,
                          (Para.Rot.y+Para.Rubber.y*py)*sPI2F,
                          (Para.Rot.z+Para.Rubber.z*py)*sPI2F);
  }

  sF32 f = 1.0f/((1<<Para.OctreeDivisions)*8);
  for(sInt y=0;y<Size;y++)
  {
    for(sInt x=0;x<Size;x++)
    {
      sF32 px = (x-1)*f*2-1;
      sF32 py = (y-1)*f*2-1;

      NoiseXY[Size*y+x] = NoiseAmp1*sPerlin2D(sInt(px*NoiseFreq1.x+NoisePhase1.x),
                                              sInt(py*NoiseFreq1.y+NoisePhase1.y),255,Para.NoiseSeed1)
                        + NoiseAmp2*sPerlin2D(sInt(px*NoiseFreq2.x+NoisePhase2.x),
                                              sInt(py*NoiseFreq2.y+NoisePhase2.y),255,Para.NoiseSeed2);

      NoiseYZ[Size*y+x] = NoiseAmp1*sPerlin2D(sInt(px*NoiseFreq1.y+NoisePhase1.y),
                                              sInt(py*NoiseFreq1.z+NoisePhase1.z),255,Para.NoiseSeed1)
                        + NoiseAmp2*sPerlin2D(sInt(px*NoiseFreq2.y+NoisePhase2.y),
                                              sInt(py*NoiseFreq2.z+NoisePhase2.z),255,Para.NoiseSeed2);

      NoiseZX[Size*y+x] = NoiseAmp1*sPerlin2D(sInt(px*NoiseFreq1.z+NoisePhase1.z),
                                              sInt(py*NoiseFreq1.x+NoisePhase1.x),255,Para.NoiseSeed1)
                        + NoiseAmp2*sPerlin2D(sInt(px*NoiseFreq2.z+NoisePhase2.z),
                                              sInt(py*NoiseFreq2.x+NoisePhase2.x),255,Para.NoiseSeed2);

      PolarPhi[Size*y+x] = sFSin(sATan2(px,py)*Para.PolarXZ*0.5f);
    }
  }



  // do it

  MakeNodes();

  March();

  sAABBoxC box;
  sF32 s = Para.GridSize/2.0f;
  box.Radius.Init(s,s,s);
  box.Center.Init(0,0,0);
  for(sInt i=0;i<4;i++)
    if(Mtrl[i])
      Mtrl[i]->BeforeFrame(Para.LightEnv,1,&box,Matrices.GetCount(),Matrices.GetData());
}