Exemplo n.º 1
0
// Pack rectangles into box with dimensions sizeOfPackxsizeOfPack. Packed outputs new rectangles
void CRectPacker::pack(const irr::core::array<irr::core::rect<irr::u32> > &rects, irr::core::array<irr::core::array<SPacked>> &packed, irr::u32 sizeOfPack) {
	clear();
	mPackSize = sizeOfPack;
	for (int x = 0; x < rects.size(); x++) {
		SRect addRect;
		addRect.pos = rects[x];
		addRect.id = x;
		addRect.packed = false;
		mRects.push_back(addRect);
	}
	mRects.sort();

	while (mNumPacked < mRects.size()) {
		SRect empty;
		empty.id = -1;
		empty.children[0] = -1;
		empty.children[1] = -1;
		empty.pos = irr::core::rect<irr::u32>(0,0,mPackSize,mPackSize);
		int oldSize = mPacks.size();
		mPacks.push_back(empty);
		mRoots.push_back(oldSize);
		fill(oldSize);
	}


	
	for (int x = 0; x < mRoots.size(); x++) {
		irr::core::array<SPacked> arr;
		packed.push_back(arr);
		packed[x].clear();
		addPackToArray(mRoots[x],packed[x]);
	}
}
Exemplo n.º 2
0
// Fill arrays with packs from root
void CRectPacker::addPackToArray(int pack, irr::core::array<SPacked> &addArray) const {
	if (isPackValid(pack)) {
		if (mPacks[pack].id != -1) {

			SPacked packed;
			packed.id = mPacks[pack].id;
			packed.pos = mPacks[pack].pos;
			addArray.push_back(packed);
			if (mPacks[pack].children[0] != -1)
				addPackToArray(mPacks[pack].children[0], addArray);
			if (mPacks[pack].children[1] != -1)
				addPackToArray(mPacks[pack].children[1], addArray);
		}
	}
}
Exemplo n.º 3
0
    CRunner() : IRunner(L"IrrOde Testbed") {
      m_pReceiver=NULL;
      m_iActive=0;
      m_iRet=0;

      m_aStates.push_back(new CMenuState      (m_pDevice,this,&m_aStates));
      m_aStates.push_back(new CTestHelloWorld (m_pDevice,this));
      m_aStates.push_back(new CTestCloneRemove(m_pDevice,this));
      m_aStates.push_back(new CTestBoxPile    (m_pDevice,this));
      m_aStates.push_back(new CTestTrigger    (m_pDevice,this));
      m_aStates.push_back(new CTestSlipstream (m_pDevice,this));
      //m_aStates.push_back(new CTestFastMoving (m_pDevice,this));
      m_aStates.push_back(new CTestHeli       (m_pDevice,this));
      m_aStates.push_back(new CTestPlane      (m_pDevice,this));
      m_aStates.push_back(new CTestCar        (m_pDevice,this));
      m_aStates.push_back(new CTestTank       (m_pDevice,this));
      m_aStates.push_back(new CTestCapsule    (m_pDevice,this));

      m_pDevice->setEventReceiver(this);
    }