IGroupPtr IGroup::getGroup(Alembic::Util::uint64_t iIndex, bool iLight, std::size_t iThreadIndex) { IGroupPtr child; if (isLight()) { if (iIndex < mData->numChildren) { Alembic::Util::uint64_t childPos = 0; mData->streams->read(iThreadIndex, mData->pos + 8 * iIndex + 8, 8, &childPos); // top bit should not be set for groups if ((childPos & EMPTY_DATA) == 0) { child.reset(new IGroup(mData->streams, childPos, iLight, iThreadIndex)); } } } else if (isChildGroup(iIndex)) { child.reset(new IGroup(mData->streams, mData->childVec[iIndex], iLight, iThreadIndex)); } return child; }
void SceneManager::removeSceneNode(SceneNode *node) { assert(node != NULL); { std::vector<SceneNode*>::iterator iter = std::find(m_nodes.begin(), m_nodes.end(), node); if (iter == m_nodes.end()) return; m_nodes.erase(iter); } for (int i = 0; i < (int)node->getAttachedObjs().size(); ++i) { SceneObj* obj = node->getAttachedObjs()[i]; if (isCamera(obj->getObjType())) { assert(m_camera == obj); m_camera = NULL; } else if (isLight(obj->getObjType())) { assert(m_light == obj); m_light = NULL; } else if (isEntity(obj->getObjType())) { m_entitys.erase(std::find(m_entitys.begin(), m_entitys.end(), obj)); } else assert(0); } }
IDataPtr IGroup::getData(Alembic::Util::uint64_t iIndex, std::size_t iThreadIndex) { IDataPtr child; if (isLight()) { if (iIndex < mData->numChildren) { Alembic::Util::uint64_t childPos = 0; mData->streams->read(iThreadIndex, mData->pos + 8 * iIndex + 8, 8, &childPos); // top bit should be set for data if ((childPos & EMPTY_DATA) != 0) { child.reset(new IData(mData->streams, childPos, iThreadIndex)); } } } else if (isChildData(iIndex)) { child.reset(new IData(mData->streams, mData->childVec[iIndex], iThreadIndex)); } return child; }
std::string Material::dumpInformation() const { std::stringstream stream; stream << std::boolalpha << "<Material> [" << mID << "]: " << std::endl << " IsLight: " << isLight() << std::endl << " IsShadeable: " << canBeShaded() << std::endl << " IsCameraVisible: " << isCameraVisible() << std::endl << " SelfShadowing: " << allowsSelfShadow() << std::endl << " Shadows: " << allowsShadow() << std::endl << " PathCount: " << samplePathCount() << std::endl; return stream.str(); }
void weather::printData() { fprintf(stdout,"Sunset time: %i:%.2i\n",sunset->tm_hour,sunset->tm_min); fprintf(stdout,"Sunrise time: %i:%.2i\n",sunrise->tm_hour,sunrise->tm_min); if(isDark()) { fprintf(stdout,"It is dark\n"); } else { fprintf(stdout,"It is not dark\n"); } if(isLight()) { fprintf(stdout, "It is Light\n"); } else { fprintf(stdout, "It is not light\n"); } fprintf(stdout,"It is %.1fF degrees outside\n",temp); fprintf(stdout,"There is %.1fmph of wind outside\n",wind_mph); fprintf(stdout,"The weather outside is %s\n",observedWeather.c_str()); }
bool CaveRendermode::isHidden(const mc::BlockPos& pos, uint16_t id, uint16_t data) { mc::BlockPos directions[6] = { mc::DIR_NORTH, mc::DIR_SOUTH, mc::DIR_EAST, mc::DIR_WEST, mc::DIR_TOP, mc::DIR_BOTTOM }; // check if this block touches sky light for (int i = 0; i < 6; i++) { if (isLight(pos + directions[i])) return true; } // water and blocks under water are a special case // because water is transparent, the renderer thinks this is a visible part of a cave // we need to check if there is sunlight on the surface of the water // if yes => no cave, hide block // if no => lake in a cave, show it mc::Block top = state.getBlock(pos + mc::DIR_TOP, mc::GET_ID | mc::GET_DATA | mc::GET_SKY_LIGHT); if (id == 8 || id == 9 || top.id == 8 || top.id == 9) { mc::BlockPos p = pos + mc::DIR_TOP; mc::Block block(top.id, top.data, 0, 0, top.sky_light); while (block.id == 8 || block.id == 9) { block = state.getBlock(p, mc::GET_ID | mc::GET_DATA | mc::GET_SKY_LIGHT); p.y++; } if (block.sky_light > 0) return true; } mc::Block south, west; south = state.getBlock(pos + mc::DIR_SOUTH); west = state.getBlock(pos + mc::DIR_WEST); // show all blocks, which don't touch sunlight // and have a transparent block on the south, west or top side // south, west and top, because with this you can look in the caves if (isTransparentBlock(south) || isTransparentBlock(west) || isTransparentBlock(top)) { return false; } return true; }
F32 LLDrawable::getVisibilityRadius() const { if (isDead()) { return 0.f; } else if (isLight()) { const LLVOVolume *vov = getVOVolume(); if (vov) { return llmax(getRadius(), vov->getLightRadius()); } else { // llwarns ? } } return getRadius(); }
bool SceneManager::load(const std::string& fname) { clear(); std::ifstream fi(fname.c_str()); int sceneObjCnt = 0; { StreamBlockReader r("SceneDescription", fi); if (!r.read("sceneObjCount", &sceneObjCnt)) assert(0); } while (sceneObjCnt-- > 0) { SceneNode *node = new SceneNode(); fi >> *node; SceneObj* obj = NULL; fi >> obj; assert(obj != NULL); node->attachSceneObj(obj); m_nodes.push_back(node); if (isEntity(obj->getObjType())) { m_entitys.push_back((Entity*)obj); } else if (isCamera(obj->getObjType())) { assert(m_camera == NULL); m_camera = (Camera*)obj; } else if (isLight(obj->getObjType())) { assert(m_light == NULL); m_light = (Light*)obj; } else assert(0); } assert(m_camera != NULL); assert(m_light != NULL); assert(!m_entitys.empty()); m_terrain = new FlatTerrain(0); m_cameraController = new FPSCameraController(m_camera, m_terrain); m_entController = new EntityController_Rotator(this); return !!fi; }
void SceneManager::addSceneNode(SceneNode *node) { assert(node != NULL); assert(find(m_nodes.begin(), m_nodes.end(), node) == m_nodes.end()); m_nodes.push_back(node); for (int i = 0; i < (int)node->getAttachedObjs().size(); ++i) { SceneObj* obj = node->getAttachedObjs()[i]; if (isCamera(obj->getObjType())) { assert(m_camera == NULL); m_camera = (Camera*)obj; } else if (isLight(obj->getObjType())) { assert(m_light == NULL); m_light = (Light*)obj; } else if (isEntity(obj->getObjType())) { assert(find(m_entitys.begin(), m_entitys.end(), obj) == m_entitys.end()); m_entitys.push_back((Entity*)obj); } else assert(0); } }
int RefinerTemp::refine() { #ifdef TEMP_LDB int i; int finish = 1; maxHeap *heavyProcessors = new maxHeap(P); Set *lightProcessors = new Set(); for (i=0; i<P; i++) { if (isHeavy(&processors[i])) { // CPrintf("Processor %d is HEAVY: load:%f averageLoad:%f!\n", // i, processors[i].load, averageLoad); heavyProcessors->insert((InfoRecord *) &(processors[i])); } else if (isLight(&processors[i])) { // CkPrintf("Processor %d is LIGHT: load:%f averageLoad:%f!\n", // i, processors[i].load, averageLoad); lightProcessors->insert((InfoRecord *) &(processors[i])); } } int done = 0; while (!done) { double bestSize; computeInfo *bestCompute; processorInfo *bestP; processorInfo *donor = (processorInfo *) heavyProcessors->deleteMax(); if (!donor) break; //find the best pair (c,receiver) Iterator nextProcessor; processorInfo *p = (processorInfo *) lightProcessors->iterator((Iterator *) &nextProcessor); bestSize = 0; bestP = 0; bestCompute = 0; while (p) { Iterator nextCompute; nextCompute.id = 0; computeInfo *c = (computeInfo *) donor->computeSet->iterator((Iterator *)&nextCompute); // iout << iINFO << "Considering Procsessor : " // << p->Id << "\n" << endi; while (c) { int ind1 = c->id.getID()[0]; int ind2 = c->id.getID()[1]; if (!c->migratable) { nextCompute.id++; c = (computeInfo *) donor->computeSet->next((Iterator *)&nextCompute); continue; } // else CkPrintf("c->id:%f\n",c->load); // CkPrintf("c->load: %f p->load:%f overLoad*averageLoad:%f \n", // c->load, p->load, overLoad*averageLoad); // if ( c->load + p->load < overLoad*averageLoad) { if ( c->load*procFreq[c->oldProcessor] + p->load < overLoad*(totalInst*procFreqNew[p->Id]/sumFreqs) && ind1!=0 && ind2!=0/* && ind2>=10*/) { // iout << iINFO << "Considering Compute : " // << c->Id << " with load " // << c->load << "\n" << endi; // if(c->load > bestSize) { if(c->load*procFreq[c->oldProcessor] > bestSize/* && (c->omid==10 && procFreq[donor->Id]>procFreqNew[donor->Id])*/) { // CkPrintf("c:%d is going to PE%d load:%d\n",c->Id,p->Id,c->load); bestSize = c->load*procFreq[c->oldProcessor]; bestCompute = c; bestP = p; } } nextCompute.id++; c = (computeInfo *) donor->computeSet->next((Iterator *)&nextCompute); } p = (processorInfo *) lightProcessors->next((Iterator *) &nextProcessor); } // CkPrintf("best load:%f\n",bestCompute->load); if (bestCompute) { //CkPrintf("best load:%f\n",bestCompute->load); //CkPrintf("TTT c->omid:%d c->load:%f P#%d -> P#%d %d -> %d\n",bestCompute->omid,bestCompute->load,donor->Id,bestP->Id,procFreq[donor->Id],procFreqNew[donor->Id]); // CkPrintf("Assign: [%d] with load: %f from %d to %d \n", // bestCompute->id.id[0], bestCompute->load, // donor->Id, bestP->Id); deAssign(bestCompute, donor); assign(bestCompute, bestP); } else { finish = 0; break; } // if (bestP->load > averageLoad) if(bestP->load > totalInst*procFreqNew[bestP->Id]/sumFreqs) lightProcessors->remove(bestP); if (isHeavy(donor)) heavyProcessors->insert((InfoRecord *) donor); else if (isLight(donor)) lightProcessors->insert((InfoRecord *) donor); } delete heavyProcessors; delete lightProcessors; return finish; #else return 0; #endif }
int Refiner::refine() { int i; int finish = 1; maxHeap *heavyProcessors = new maxHeap(P); Set *lightProcessors = new Set(); for (i=0; i<P; i++) { if (isHeavy(&processors[i])) { // CkPrintf("Processor %d is HEAVY: load:%f averageLoad:%f!\n", // i, processors[i].load, averageLoad); heavyProcessors->insert((InfoRecord *) &(processors[i])); } else if (isLight(&processors[i])) { // CkPrintf("Processor %d is LIGHT: load:%f averageLoad:%f!\n", // i, processors[i].load, averageLoad); lightProcessors->insert((InfoRecord *) &(processors[i])); } } int done = 0; while (!done) { double bestSize; computeInfo *bestCompute; processorInfo *bestP; processorInfo *donor = (processorInfo *) heavyProcessors->deleteMax(); if (!donor) break; //find the best pair (c,receiver) Iterator nextProcessor; processorInfo *p = (processorInfo *) lightProcessors->iterator((Iterator *) &nextProcessor); bestSize = 0; bestP = 0; bestCompute = 0; while (p) { Iterator nextCompute; nextCompute.id = 0; computeInfo *c = (computeInfo *) donor->computeSet->iterator((Iterator *)&nextCompute); // iout << iINFO << "Considering Procsessor : " // << p->Id << "\n" << endi; while (c) { if (!c->migratable) { nextCompute.id++; c = (computeInfo *) donor->computeSet->next((Iterator *)&nextCompute); continue; } double speed_ratio = processors[c->oldProcessor].pe_speed / p->pe_speed; //CkPrintf("c->load: %f p->load:%f overLoad*averageLoad:%f \n", //c->load, p->load, overLoad*averageLoad); if ( c->load * speed_ratio + p->load < overLoad*averageLoad) { // iout << iINFO << "Considering Compute : " // << c->Id << " with load " // << c->load << "\n" << endi; if(c->load > bestSize) { bestSize = c->load; bestCompute = c; bestP = p; } } nextCompute.id++; c = (computeInfo *) donor->computeSet->next((Iterator *)&nextCompute); } p = (processorInfo *) lightProcessors->next((Iterator *) &nextProcessor); } if (bestCompute) { // CkPrintf("Assign: [%d] with load: %f from %d to %d \n", // bestCompute->id.id[0], bestCompute->load, // donor->Id, bestP->Id); deAssign(bestCompute, donor); assign(bestCompute, bestP); } else { finish = 0; break; } if (bestP->load > averageLoad) lightProcessors->remove(bestP); if (isHeavy(donor)) heavyProcessors->insert((InfoRecord *) donor); else if (isLight(donor)) lightProcessors->insert((InfoRecord *) donor); } delete heavyProcessors; delete lightProcessors; return finish; }
static void computeViolationMarks (OTGrammarCandidate me) { #define isHeavy(s) ((s) == 'H' || (s) == 'J') #define isLight(s) ((s) == 'L' || (s) == 'K') #define isSyllable(s) (isHeavy (s) || isLight (s)) #define isStress(s) ((s) == '1' || (s) == '2') int depth; wchar_t *firstSlash = wcschr (my output, '/'); wchar_t *lastSlash = & my output [wcslen (my output) - 1]; my marks = NUMvector <int> (1, my numberOfConstraints = NUMBER_OF_CONSTRAINTS); /* Violations of WSP: count all H not followed by 1 or 2. */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isHeavy (p [0]) && ! isStress (p [1])) my marks [WSP] ++; } /* Violations of FtNonfinal: count all heads followed by ). */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isStress (p [0]) && p [1] == ')') my marks [FtNonfinal] ++; } /* Violations of Iambic: count all heads not followed by ). */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isStress (p [0]) && p [1] != ')') my marks [Iambic] ++; } /* Violations of Parse and Peripheral: count all syllables not between (). */ depth = 0; for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (p [0] == '(') depth ++; else if (p [0] == ')') depth --; else if (isSyllable (p [0]) && depth != 1) { my marks [Parse] ++; if (p != firstSlash + 1 && p != lastSlash - 1) my marks [Peripheral] ++; } } /* Violations of FootBin: count all (L1) and (L2). */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isLight (p [0]) && p [-1] == '(' && isStress (p [1]) && p [2] == ')') my marks [FootBin] ++; } /* Violations of WFL: count all initial / not followed by (. */ if (firstSlash [1] != '(') my marks [WFL] = 1; /* Violations of WFR: count all final / not preceded by ). */ if (lastSlash [-1] != ')') my marks [WFR] = 1; /* Violations of Main_L: count syllables from foot containing X1 to left edge. */ { wchar_t *p = wcschr (firstSlash, '1'); for (; *p != '('; p --) { } for (; p != firstSlash; p --) { if (isSyllable (p [0])) my marks [Main_L] ++; } } /* Violations of Main_R: count syllables from foot containing X1 to right edge. */ { wchar_t *p = wcschr (firstSlash, '1'); for (; *p != ')'; p ++) { } for (; p != lastSlash; p ++) { if (isSyllable (p [0])) my marks [Main_R] ++; } } /* Violations of AFL: count syllables from every foot to left edge. */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (p [0] == '(') { for (wchar_t *q = p; q != firstSlash; q --) { if (isSyllable (q [0])) my marks [AFL] ++; } } } /* Violations of AFR: count syllables from every foot to right edge. */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (p [0] == ')') { for (wchar_t *q = p; q != lastSlash; q ++) { if (isSyllable (q [0])) my marks [AFR] ++; } } } /* Violations of Nonfinal: count all final / preceded by ). */ if (lastSlash [-1] == ')') my marks [Nonfinal] = 1; /* Violations of Trochaic: count all heads not preceded by (. */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isStress (p [0]) && p [-2] != '(') my marks [Trochaic] ++; } /* Violations of FootBimoraic: count weight between (). */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (p [0] == '(') { int weight = 0; for (p ++; p [0] != ')'; p ++) { if (isHeavy (p [0])) weight += 2; else if (isLight (p [0])) weight += 1; } if (weight != 2) my marks [FootBimoraic] ++; } } /* Violations of FootBisyllabic: count all (X1) and (X2). */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isSyllable (p [0]) && p [-1] == '(' && isStress (p [1]) && p [2] == ')') my marks [FootBisyllabic] ++; } /* Violations of MainNonfinal: count all final / preceded by ) preceded by 1 in the same foot. */ if (lastSlash [-1] == ')') { for (wchar_t *p = lastSlash - 2; ; p --) { if (p [0] == '2') break; if (p [0] == '1') { my marks [MainNonfinal] = 1; break; } } } /* Violations of HeadNonfinal: count all final / preceded by ) directly preceded by 1, plus MainNonfinal. */ if (lastSlash [-1] == ')') { if (lastSlash [-2] == '1') { my marks [HeadNonfinal] = 2; } else { for (wchar_t *p = lastSlash - 2; ; p --) { if (p [0] == '2') break; if (p [0] == '1') { my marks [HeadNonfinal] = 1; break; } } } } /* Violations of *Clash: count all 1 and 2 followed by an 1 or 2 after the next L or H. */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isStress (p [0])) { for (wchar_t *q = p + 1; q != lastSlash; q ++) { if (isSyllable (q [0])) { if (isStress (q [1])) { my marks [Clash] ++; } break; } } } } /* Violations of *Lapse: count all sequences of three unstressed syllables. */ depth = 0; for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (isSyllable (p [0])) { if (isStress (p [1])) { depth = 0; } else { if (++ depth > 2) { my marks [Lapse] ++; } } } } /* Violations of WeightByPosition: count all K. */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (p [0] == 'K') my marks [WeightByPosition] ++; } /* Violations of *MoraicConsonant: count all J. */ for (wchar_t *p = firstSlash + 1; p != lastSlash; p ++) { if (p [0] == 'J') my marks [MoraicConsonant] ++; } }