示例#1
0
文件: nmethod.cpp 项目: ardeujho/self
bool nmethod::shouldNotRecompile() {
# ifdef SIC_COMPILER
  if (compiler() == NIC) return false;
  if (level() == MaxRecompilationLevels - 1)
    return true;                // no optimizable sends
  if (isYoung()) {
    if (invocationCount() > agingLimit() &&
        flags.trapCount < MapLoadTrapLimit) {
      // isn't really young anymore (but didn't trigger counter because it
      // has several callers)
      makeOld();
    } else if (nsends() > max(recompileLimit(0), 4 * agingLimit())) {
      // does a lot of sends - give it a chance anyway
    } else {
      // don't recompile yet - too young
      // but mark it for later recompilation
      makeToBeRecompiled();
      return true;
    }
  }
# endif
  return false; 
}
示例#2
0
void FlowContainer::drawShape( QPainter &p )
{
	if (b_deleted)
		return;

	if ( !m_sizeRect.isValid() )
		return;
	
	const int _x = (int)x()+offsetX();
	const int _y = (int)y()+offsetY();
	
	int col = 0xef + level()*0x6;
	if ( col > 0xff ) col = 0xff;
	p.setBrush( QColor( col, 0xff, col ) );
	if( b_expanded )
	{
		p.setPen(Qt::DotLine);
		p.drawRoundRect( _x, _y, width(), topStrip, 1500/width(), 1500/topStrip );
		p.drawRoundRect( _x, _y+height()-botStrip, width(), botStrip, 1500/width(), 1500/botStrip );
	}
	else
	{
		p.setPen(QPen((isSelected()?m_selectedCol:Qt::black),1,Qt::SolidLine));
		p.drawRoundRect( _x, _y, width(), topStrip, 1500/width(), 1500/topStrip );
	}
	
	p.setPen( Qt::black );
	p.setFont( font() );
	p.drawText( QRect( 22 + _x+8, _y, width()-8, topStrip ), Qt::AlignLeft | Qt::AlignVCenter,  m_caption );
	
	if( b_expanded )
	{
		p.setPen(Qt::SolidLine);
		p.setBrush( Qt::NoBrush );
		p.drawRoundRect( _x, _y, width(), height(), 1500/width(), 1500/height() );
	}
}
示例#3
0
文件: Game.cpp 项目: zsebastian/Floof
Game::Game()
	:mBoxWorld(b2Vec2(0.f, 10.f))
{

	LevelCreator level(20, 9, mBoxWorld);
	
	for (auto iter = level.iterBegin(); iter != level.iterEnd(); ++iter)
	{
		objects.push_back(*iter);
	}

	objects.push_back(new Player(Input(new StrategyKeysAndMouse()), 400, 400, 1, mBoxWorld));
	//objects.push_back(new Player(Input(new StrategyKeys()), 700, 400, 0, mBoxWorld));

	//objects.push_back(new Box(500, 300, 1));
	objects.push_back(new Box(600, 400, 1, mBoxWorld));

	for (int i=0; i<10; i++)
	{
	//	objects.push_back(new Border(i*64, false)); 
//		objects.push_back(new Border(i*64, true)); 
	}

}
示例#4
0
std::unique_ptr<EditorLevel>
EditorLevel::from_prefab_file(const Pathname& pathname)
{
  log_info("%1%", pathname.str());

  // Load the level from the file - we don't care what it's res_name is.
  PrefabFile prefab = PrefabFile::from_path(pathname);

  std::unique_ptr<EditorLevel> level(new EditorLevel);

  // FIMXE: there would be better way to handle prefab size, but it's
  // probably not worth the effort
  level->impl->size.width  = 1920;
  level->impl->size.height = 1200;

  // FIXME: overrides are getting ignored

  // Get the objects
  auto objs = prefab.get_objects();
  for (auto i = objs.begin(); i != objs.end(); i++)
  {
    LevelObjPtr obj = LevelObjFactory::create(*i);
    if (obj)
    {
      // move origin of the level to the center of it
      obj->set_pos(obj->get_pos() + Vector3f(static_cast<float>(level->impl->size.width)/2.0f,
                                             static_cast<float>(level->impl->size.height)/2.0f));

      level->add_object(obj);
    }
  }

  level->sort();

  return level;
}
示例#5
0
void StateGraph::writeDOT(std::ostream& out) const
{
  IntNodeMap level(_G, 0);
  lemon::bfs(_G).distMap(level).run(_toNode[1][1][0][0]);
  
  out << "digraph G {" << std::endl;
  
  for (NodeIt v(_G); v != lemon::INVALID; ++v)
  {
    out << "\t" << _G.id(v) << " [label=\"("
        << _x[v] << "," << _y[v] << ","
        << _xbar[v] << "," << _ybar[v] << ")\\n" << level[v] << "\"]" << std::endl;
  }
  
  for (ArcIt a(_G); a != lemon::INVALID; ++a)
  {
    Node v = _G.source(a);
    Node w = _G.target(a);
    
    out << "\t" << _G.id(v) << " -> " << _G.id(w) << " [color=";
    switch (_type[a])
    {
      case MUTATION:
        out << "black";
        break;
      case AMPLIFICATION:
        out << "green";
        break;
      case DELETION:
        out << "red";
        break;
    }
    out << "]" << std::endl;
  }
  out << "}" << std::endl;
}
示例#6
0
void randomTree(Graph &G, int n, int maxDeg, int maxWidth)
{
	G.clear();

	if (n <= 0) return;
	if (maxDeg   <= 0) maxDeg   = n;
	if (maxWidth <= 0) maxWidth = n;

	int max = 0;
	Array<node> possible(n);
	Array<int> width(0,n,0);
	NodeArray<int> level(G,0);

	level[possible[0] = G.newNode()] = 0;
	--n;

	while(n > 0) {
		int  i = randomNumber(0,max);
		node v = possible[i];

		if (width[level[v]+1] == maxWidth) {
			possible[i] = possible[max--];
			continue;
		}

		if (v->outdeg()+1 == maxDeg)
			possible[i] = possible[max--];

		node w = G.newNode();
		possible[++max] = w;
		G.newEdge(v,w);
		width[level[w] = level[v]+1]++;

		--n;
	}
}
示例#7
0
文件: level.cpp 项目: pazthor/lean
level mk_max(level const & l1, level const & l2)  {
    if (is_explicit(l1) && is_explicit(l2)) {
        return get_depth(l1) >= get_depth(l2) ? l1 : l2;
    } else if (l1 == l2) {
        return l1;
    } else if (is_zero(l1)) {
        return l2;
    } else if (is_zero(l2)) {
        return l1;
    } else if (is_max(l2) && (max_lhs(l2) == l1 || max_rhs(l2) == l1)) {
        return l2;  // if l2 == (max l1 l'), then max l1 l2 == l2
    } else if (is_max(l1) && (max_lhs(l1) == l2 || max_rhs(l1) == l2)) {
        return l1;  // if l1 == (max l2 l'), then max l1 l2 == l1
    } else {
        auto p1 = to_offset(l1);
        auto p2 = to_offset(l2);
        if (p1.first == p2.first) {
            lean_assert(p1.second != p2.second);
            return p1.second > p2.second ? l1 : l2;
        } else {
            return cache(level(new level_max_core(false, l1, l2)));
        }
    }
}
示例#8
0
文件: expr.c 项目: opiumpoppyjin/NEMU
static int find_op(int p, int q) {
	switch (tokens[p].type) {
		case NOT:case NEG:case BIT_NOT:case POINTER:return p;
	}
	int minlevel = -1,thislevel;
	int op=-1;
	int i;
	for (i=p;i<=q;i++){
		if (tokens[i].type==LB){
			i=pair_of_LB[i];

		}
		thislevel=level(tokens[i].type);
		if (thislevel>=minlevel){
				op=i;
				minlevel=thislevel;
		}
		else if(thislevel!=0){
			return op;
		}

	}
	return op;
}
示例#9
0
 vector<vector<int>> zigzagLevelOrder(TreeNode* root) {
     // no reverse operation
     
     vector<vector<int> > res;
     if(root == NULL) {
         return res;
     }
     
     queue<TreeNode*> q;
     q.push(root);
     bool isLeft = true;
     while(!q.empty()) {
         int sz = q.size();
         vector<int> level(sz, 0);
         for(int i=0; i<sz; i++) {
             
             TreeNode* tmp = q.front();
             q.pop();
             if(isLeft) {
                 level[i] = tmp->val;
             }
             else {
                 level[sz-i-1] = tmp->val;
             }
             if(tmp->left) {
                 q.push(tmp->left);
             }
             if(tmp->right) {
                 q.push(tmp->right);
             }
         }
         res.push_back(level);
         isLeft = !isLeft;
     }
     return res;
 }
示例#10
0
void GameScene::updateLevelTime() {
    setLevelTime(levelTime() - 1);
    if(levelTime() < 1) {
        setLevelUpgrade(true);
        setGameState(GamePaused);
        setLevel(m_level + 1);
        if(highestLevel() < level()) {
            setHighestLevel(level());
        }
        if(gameMode() == GameScene::ModeClassic) {
            if(settings.value("highestLevel", 1).toInt() < level()) {
                settings.setValue("highestLevel", level());
            }
        } else {
            if(settings.value("highestLevelParty", 1).toInt() < level()) {
                settings.setValue("highestLevelParty", level());
            }
        }
#ifdef OS_IS_ANDROID
        qDebug() << "Force syncing settings";
        settings.sync();
#endif
    }
}
示例#11
0
expr mk_type() {
    static thread_local expr r = mk_type(level());
    return r;
}
示例#12
0
文件: plane.cpp 项目: rsnemmen/Chombo
int main (int argc, char** argv)
{
#ifdef CH_MPI
  MPI_Init(&argc,&argv);
#endif

  // Begin forever present scoping trick
  {
    const char* in_file = "plane.inputs";

    if (argc > 1)
    {
      in_file = argv[1];
    }

    // Parse input file
    ParmParse pp(0,NULL,NULL,in_file);

    Box domain;
    RealVect origin;
    Real dx;

    BaseIF* implicit;

    // Make geometry
    implicit = makeGeometry(domain,origin,dx);

    // Make grids
    DisjointBoxLayout grids;
    makeLayout(grids,domain);

    // Create ebislayout
    int nghost = 0;
    EBISLayout ebisl;
    makeEBISL(ebisl,grids,domain,nghost);

    // Make a LevelData
    int nComps = 1;

    IntVect ghost = IntVect::Unit;
    ghost *= nghost;

    RefCountedPtr<DataFactory<EBCellFAB> > rcpFactory(new EBCellFactory(ebisl));
    LevelData<EBCellFAB> level(grids,nComps,ghost,*rcpFactory);

    // Put some data in the data holders
    fillData(level,origin,dx,*implicit);

    // Done with this object
    delete implicit;

    // Write the data and the EB out
    const char* basename = "plane";

    char name[1000];
    sprintf(name,"%s%dd.hdf5",basename,SpaceDim);
#ifdef CH_USE_HDF5
    writeEBLevelname(&level,name);
#endif
  } // End scoping trick

  // Clean up
  EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();

  CH_TIMER_REPORT();

#ifdef CH_MPI
  MPI_Finalize();
#endif

  return 0;
}
示例#13
0
void Water::drawTile( const RenderInfo& rinfo, Tile& tile)
{
  bool needDrawAnimations = false;
  Size areaSize = Size::square(1);

  if( tile.overlay().isNull() )
  {
    drawLandTile( rinfo, tile );
  }
  else
  {
    OverlayPtr overlay = tile.overlay();
    if( _isVisibleObject( overlay->type() ) )
    {
      // Base set of visible objects
      needDrawAnimations = true;
      areaSize = overlay->size();
    }
    else
    {
      int tileNumber = 0;
      bool haveWater = tile.param( Tile::pFountainWater ) > 0 || tile.param( Tile::pWellWater ) > 0;
      needDrawAnimations = false;

      if ( overlay->type() == object::house )
      {
        auto house = overlay.as<House>();
        needDrawAnimations = (house->level() <= HouseLevel::hovel) && house->habitants().empty();

        tileNumber = config::tile.house-1;
        haveWater = haveWater || house->hasServiceAccess(Service::fountain) || house->hasServiceAccess(Service::well);
      }

      if( !needDrawAnimations )
      {
        tileNumber += (haveWater ? config::layer.haveWater : 0);
        tileNumber += tile.param( Tile::pReservoirWater ) > 0 ? config::layer.reservoirRange : 0;

        drawArea( rinfo, overlay->area(), config::layer.water, config::tile.constr + tileNumber );

        areaSize = Size::zero;
      }
    }

    if ( needDrawAnimations )
    {
      Point screenPos = tile.mappos() + rinfo.offset;
      Layer::drawTile( rinfo, tile );

      if( _d->showWaterValue )
      {
        auto aqueduct = tile.overlay<Aqueduct>();
        if( aqueduct.isValid() )
        {
          Font f = Font::create( "FONT_2" ).withColor( ColorList::red );
          int df = aqueduct->water();
          f.draw( rinfo.engine.screen(), utils::format( 0xff, "%x", df), screenPos + Point( 20, -80 ), false );
        }

        int wellValue = tile.param( Tile::pWellWater );
        int fountainValue = tile.param( Tile::pFountainWater );
        int reservoirWater = tile.param( Tile::pReservoirWater );

        if( wellValue > 0 || fountainValue > 0 || reservoirWater > 0 )
        {
          std::string text = utils::format( 0xff, "%d/%d/%d", wellValue, fountainValue, reservoirWater );
          Font f = Font::create( "FONT_2" ).withColor( ColorList::red );
          f.draw( rinfo.engine.screen(), text, screenPos + Point( 20, -80 ), false );
        }
      }
      registerTileForRendering( tile );
    }
  }

  if( !needDrawAnimations && ( tile.isWalkable(true) || tile.getFlag( Tile::tlOverlay ) ) )
  {
    _drawLandTile( rinfo, tile, areaSize );
  }

  tile.setRendered();
}
示例#14
0
QString Headline::description() const
{
    return tr("%1 %3").arg(QString(), level(), QLatin1Char('*')).arg(caption());
}
示例#15
0
bool
brain::ck_trail(){	
#ifdef FULL_DEBUG
	bj_ostream& os = bj_dbg;
	brain& brn = *this;

	row_quanton_t& the_trl = br_tmp_trail;
	br_charge_trail.get_all_ordered_quantons(the_trl);

	long num_null_src = 0;
	quanton* last_choice = NULL_PT;
	quanton* prev_qua = NULL_PT;
	MARK_USED(prev_qua);
	
	ch_string ab_mm;	
	long ch_idx = 0;
	long prev_tier = INVALID_TIER;
	for(long ii = 0; ii < the_trl.size(); ii++){
		quanton* qua = the_trl[ii];

		if(qua == NULL_PT){
			ab_mm = "NULL qua !!." + br_file_name;
			abort_func(-1, ab_mm.c_str());
		}
		if((prev_tier != INVALID_TIER) && (prev_tier > qua->qu_tier)){
			os << "qua= " << qua << bj_eol;
			print_trail(os);
			ab_mm = "case0." + br_file_name;
			abort_func(-1, ab_mm.c_str());
		}
		prev_tier = qua->qu_tier;
		
		//if((qua->qu_source == NULL) && (qua->qlevel() != ROOT_LEVEL)){
		if(qua->is_lv_choice(brn)){
			num_null_src++;
		}
		if(qua->get_charge() == cg_neutral){
			print_trail(os);
			ab_mm = "case2." + br_file_name;
			abort_func(-1, ab_mm.c_str());
		}
		if(qua->has_note0()){
			print_trail(os);
			ab_mm = "case3." + br_file_name;
			abort_func(-1, ab_mm.c_str());
		}
		qua->ck_charge(brn);

		bool cho = qua->is_choice();
		if(cho){
			last_choice = qua;
			if((ch_idx >= br_chosen.size()) || (br_chosen[ch_idx] != qua)){
				os << "qua= " << qua << bj_eol;
				if(ch_idx < br_chosen.size()){
					os << "chosen= " << br_chosen[ch_idx] << bj_eol;
				}
				print_trail(os);
				os << "chosen" << bj_eol;
				os << br_chosen << bj_eol;
			}
			BRAIN_CK_0(ch_idx < br_chosen.size());
			BRAIN_CK_0(br_chosen[ch_idx] == qua);
			ch_idx++;
		}

		if(	!cho && ! qua->has_source())
		{
			quanton* cls = qua;
			BRAIN_CK_0(cls->qlevel() == qua->qlevel());
			if((cls != last_choice) && (cls->qlevel() != 0)){
				print_trail(os);
				ab_mm = "case5." + br_file_name;
				abort_func(-1, ab_mm.c_str());
			}
		}
		prev_qua = qua;
		//prev_tk = qua->qu_charge_tk;
	}

	if((num_null_src != level()) && ((num_null_src + 1) != level())){
		os << "num_null_src=" << num_null_src << bj_eol;
		os << "lv=" << level() << bj_eol;
		print_trail(os);
		dbg_prt_lvs_cho(os);
		ab_mm = "case6." + br_file_name;
		abort_func(-1, ab_mm.c_str());
	}
#endif
	return true;
}
示例#16
0
void PokeTeam::loadFromXml(const QDomElement &poke, int version)
{
    if (poke.hasAttribute("Gen")) {
        setGen(Pokemon::gen(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt(),
                            poke.attribute("SubGen", QString::number(GenInfo::NumberOfSubgens(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt())-1)).toInt()));
    }

    reset();

    /* Code to import old teams which had different formes registered as different pokemon numbers */
    int num = poke.attribute("Num").toInt();
    int forme = poke.attribute("Forme").toInt();

    if (gen().num == 4 && num > 493 && forme == 0 && !PokemonInfo::Exists(Pokemon::uniqueId(num, 0), 4)) {
        //Old way
        int indexes[] = {
            479,479,479,479,479,386,386,386,413,413,492,487
        };
        int formes[] = {
            1,2,3,4,5,1,2,3,1,2,1,1
        };

        int i = num - 494;

        setNum(Pokemon::uniqueId(indexes[i], formes[i]));
    } else {
        setNum(Pokemon::uniqueId(num, forme));
    }

    bool outdated = gen() < 5 && version < 1;

    load();
    nickname() = poke.attribute("Nickname");
    item() = poke.attribute("Item").toInt();
    ability() = poke.attribute("Ability").toInt();
    if (outdated) {
        ability() = AbilityInfo::ConvertFromOldAbility(ability());
    }
    nature() = poke.attribute("Nature").toInt();
    gender() = poke.attribute("Gender").toInt();
    shiny() = QVariant(poke.attribute("Shiny")).toBool();
    happiness() = poke.attribute("Happiness").toInt();
    level() = poke.attribute("Lvl").toInt();

    int cptMove=0;

    QDomElement moveElement = poke.firstChildElement("Move");
    while(!moveElement.isNull())
    {
        int movenum = moveElement.text().toInt();
        if (outdated) {
            movenum = MoveInfo::ConvertFromOldMove(movenum);
        }
        setMove(movenum,cptMove,false);
        cptMove++;
        moveElement = moveElement.nextSiblingElement("Move");
    }
    int cptDV=0;
    QDomElement DVElement = poke.firstChildElement("DV");
    while(!DVElement.isNull())
    {
        setDV(outdated ? NatureInfo::ConvertToStat(cptDV) : cptDV,DVElement.text().toInt());
        cptDV++;
        DVElement = DVElement.nextSiblingElement("DV");
    }
    int cptEV=0;
    QDomElement EVElement = poke.firstChildElement("EV");
    while(!EVElement.isNull())
    {
        setEV(outdated ? NatureInfo::ConvertToStat(cptEV) : cptEV,EVElement.text().toInt());
        cptEV++;
        EVElement = EVElement.nextSiblingElement("EV");
    }
}
示例#17
0
bool Headline::isElementValid() const
{
    return level() > 0;
}
示例#18
0
Level Level::levelFor(int number) {
	Level level(number);
	return level;
}
示例#19
0
FlowPart* FlowPart::endPart(QStringList ids, FlowPartList *previousParts) {
	if (ids.empty()) {
		const NodeInfoMap::iterator end = m_nodeMap.end();
		for (NodeInfoMap::iterator it = m_nodeMap.begin(); it != end; ++it) {
			ids.append(it.key());
		}

		filterEndPartIDs(&ids);
	}

	const bool createdList = (!previousParts);

	if (createdList) {
		previousParts = new FlowPartList;
	} else if (previousParts->contains(this)) {
		return 0l;
	}

	previousParts->append(this);

	if (ids.empty()) {
		return 0;
	}

	if (ids.size() == 1) {
		return outputPart(*(ids.begin()));
	}

	typedef QValueList<FlowPartList>  ValidPartsList;

	ValidPartsList validPartsList;

	const QStringList::iterator idsEnd = ids.end();
	for (QStringList::iterator it = ids.begin(); it != idsEnd; ++it) {
		int prevLevel = level();
		FlowPartList validParts;
		FlowPart *part = outputPart(*it);

		while (part) {
			if (!validParts.contains(part)) {
				validParts.append(part);
// 				if ( part->level() >= level() ) {
				const int _l = part->level();
				part = part->endPart(QStringList(), previousParts);
				prevLevel = _l;
// 				} else {
// 					part = 0l;
// 				}
			} else {
				part = 0;
			}
		}

		if (!validParts.empty()) {
			validPartsList.append(validParts);
		}
	}

	if (createdList) {
		delete previousParts;
		previousParts = 0;
	}

	if (validPartsList.empty()) return 0;

	FlowPartList firstList = *(validPartsList.begin());

	const FlowPartList::iterator flEnd = firstList.end();
	const ValidPartsList::iterator vplEnd = validPartsList.end();
	for (FlowPartList::iterator it = firstList.begin(); it != flEnd; ++it) {
		bool ok = true;

		for (ValidPartsList::iterator vplit = validPartsList.begin(); vplit != vplEnd; ++vplit) {
			if (!(*vplit).contains(*it)) ok = false;
		}

		if (ok) return *it;
	}

	return 0l;
}
示例#20
0
void nmethod::print() {
  ResourceMark rm;
  printIndent();
  lprintf("(nmethod*)%#lx", this);
  if (scopes->root()->isDataAccessScope()) {
    lprintf(" (data access)");
  } else if (scopes->root()->isDataAssignmentScope()) {
    lprintf(" (data assignment)");
  } else {
    lprintf(" for method %#lx", method());
  }
  lprintf(" { ");
  if (isYoung()) lprintf("YOUNG ");
  switch (compiler()) {
   case NIC: lprintf("NIC "); if (isImpureNIC()) lprintf("impure "); break;
   case SIC: lprintf("SIC level %ld ", level()); break;
   default:  lprintf("!?!unknown compiler!?! "); break;
  }
  if (version())           lprintf("v%d ", version());
  if (isDI())              lprintf("DI ");
  if (isZombie())          lprintf("zombie ");
  if (isInvalid())         lprintf("INVALID ");
  if (isDebug())           lprintf("DEBUG ");
  if (isToBeRecompiled())  lprintf("TBR ");
  if (isUncommon() || isUncommonRecompiled()) lprintf("UNCOMMON ");
  lprintf("}:\n");
 
  lprintf( "incoming_arg_count = %d\n", incoming_arg_count() );
  
  print_platform_specific_data();
  
  Indent ++;
  
  key.print();
  
  printIndent();
  lprintf("code table link: %#lx\n", codeTableLink);
  
  printIndent();
  lprintf("remember link: ");
  rememberLink.print();
  lprintf("\n");
  
  printIndent();
  lprintf("linked sends: ");
  linkedSends.print();
  lprintf("\n");
  
  printIndent();
  lprintf("di link: ");
  diLink.print();
  lprintf("\n");
  
  printIndent();
  lprintf("instructions (%ld bytes): %#lx,%#lx/i / x/%ldi %#lx\n",
         instsLen(), 
         insts(),
         instsEnd() - oopSize,
         instsLen() / oopSize,
         insts());
  printIndent(); lprintf("p ((nmethod*)%#lx)->printCode() \n", this);
  scopes->print();
  // printLocs();
  // printDeps();
  Indent --;
}
示例#21
0
文件: One.cpp 项目: alviano/wasp
bool
One::processCoreOne(
    vector< Literal >& literals,
    vector< uint64_t >& weights,
    uint64_t minWeight,
    unsigned int& n )
{
    trace_msg( weakconstraints, 2, "Processing core for algorithm One" );
    
    bool trivial = false;
    Clause* clause = new Clause();
    unsigned int originalSize = solver.numberOfOptimizationLiterals( level() );
    for( unsigned int i = 0; i < originalSize; i++ )
    {
        OptimizationLiteralData& optLitData = solver.getOptimizationLiteral( level(), i );        
        if( optLitData.isRemoved() )
            continue;

        Literal lit = optLitData.lit;
        trace_msg( weakconstraints, 3, "Considering literal " << lit << " - weight " << optLitData.weight );
        Var v = lit.getVariable();
        if( visited( v ) )
        {
            trace_msg( weakconstraints, 4, "is in unsat core" );
            literals.push_back( lit );
//            weights.push_back( optLitData.weight );
            weights.push_back( 1 );
            optLitData.remove();
            
            if( solver.isTrue( lit ) )
                trivial = true;
            
            if( !solver.isFalse( lit ) )
                clause->addLiteral( lit );
            
            if( optLitData.weight > minWeight )
                solver.addOptimizationLiteral( lit, optLitData.weight - minWeight, level(), true );            
        }
    }
    
    n = literals.size();
    vector< Var > newVars;
    for( unsigned int i = 0; i < n - 1; i++ )
    {
        Var auxVar = addAuxVariable();
        literals.push_back( Literal( auxVar, POSITIVE ) );
        weights.push_back( 1 );
        solver.addOptimizationLiteral( Literal( auxVar, NEGATIVE ), minWeight, level(), true );
        newVars.push_back( auxVar );
    }
    
    for( int i = newVars.size() - 1; i >= 1; i-- )
    {
        Clause* c = new Clause();
        c->addLiteral( Literal( newVars[ i ], NEGATIVE ) );
        c->addLiteral( Literal( newVars[ i - 1 ], POSITIVE ) );
        solver.addClauseRuntime( c );        
    }
    
    if( trivial )
    {
        delete clause;
        return true;
    }

    return solver.addClauseRuntime( clause );
}
void DefNewGeneration::compute_new_size() {
  // This is called after a gc that includes the following generation
  // (which is required to exist.)  So from-space will normally be empty.
  // Note that we check both spaces, since if scavenge failed they revert roles.
  // If not we bail out (otherwise we would have to relocate the objects)
  if (!from()->is_empty() || !to()->is_empty()) {
    return;
  }

  int next_level = level() + 1;
  GenCollectedHeap* gch = GenCollectedHeap::heap();
  assert(next_level < gch->_n_gens,
         "DefNewGeneration cannot be an oldest gen");

  Generation* next_gen = gch->_gens[next_level];
  size_t old_size = next_gen->capacity();
  size_t new_size_before = _virtual_space.committed_size();
  size_t min_new_size = spec()->init_size();
  size_t max_new_size = reserved().byte_size();
  assert(min_new_size <= new_size_before &&
         new_size_before <= max_new_size,
         "just checking");
  // All space sizes must be multiples of Generation::GenGrain.
  size_t alignment = Generation::GenGrain;

  // Compute desired new generation size based on NewRatio and
  // NewSizeThreadIncrease
  size_t desired_new_size = old_size/NewRatio;
  int threads_count = Threads::number_of_non_daemon_threads();
  size_t thread_increase_size = threads_count * NewSizeThreadIncrease;
  desired_new_size = align_size_up(desired_new_size + thread_increase_size, alignment);

  // Adjust new generation size
  desired_new_size = MAX2(MIN2(desired_new_size, max_new_size), min_new_size);
  assert(desired_new_size <= max_new_size, "just checking");

  bool changed = false;
  if (desired_new_size > new_size_before) {
    size_t change = desired_new_size - new_size_before;
    assert(change % alignment == 0, "just checking");
    if (expand(change)) {
       changed = true;
    }
    // If the heap failed to expand to the desired size,
    // "changed" will be false.  If the expansion failed
    // (and at this point it was expected to succeed),
    // ignore the failure (leaving "changed" as false).
  }
  if (desired_new_size < new_size_before && eden()->is_empty()) {
    // bail out of shrinking if objects in eden
    size_t change = new_size_before - desired_new_size;
    assert(change % alignment == 0, "just checking");
    _virtual_space.shrink_by(change);
    changed = true;
  }
  if (changed) {
    // The spaces have already been mangled at this point but
    // may not have been cleared (set top = bottom) and should be.
    // Mangling was done when the heap was being expanded.
    compute_space_boundaries(eden()->used(),
                             SpaceDecorator::Clear,
                             SpaceDecorator::DontMangle);
    MemRegion cmr((HeapWord*)_virtual_space.low(),
                  (HeapWord*)_virtual_space.high());
    Universe::heap()->barrier_set()->resize_covered_region(cmr);
    if (Verbose && PrintGC) {
      size_t new_size_after  = _virtual_space.committed_size();
      size_t eden_size_after = eden()->capacity();
      size_t survivor_size_after = from()->capacity();
      gclog_or_tty->print("New generation size " SIZE_FORMAT "K->"
        SIZE_FORMAT "K [eden="
        SIZE_FORMAT "K,survivor=" SIZE_FORMAT "K]",
        new_size_before/K, new_size_after/K,
        eden_size_after/K, survivor_size_after/K);
      if (WizardMode) {
        gclog_or_tty->print("[allowed " SIZE_FORMAT "K extra for %d threads]",
          thread_increase_size/K, threads_count);
      }
      gclog_or_tty->cr();
    }
  }
}
示例#23
0
bool RoomAndCorridorMap::TryBuildMap(const Point& size, bool verbose) {
  size_ = size;
  tileset_.reset(new DefaultTileset());

  Level level(size_);
  vector<Rect> rects;

  const int min_size = 6;
  const int max_size = 8;
  const int separation = 3;
  const int tries = size_.x*size_.y/(min_size*min_size);
  int tries_left = tries;

  while (tries_left > 0) {
    const Point size{RandInt(min_size, max_size),
                     RandInt(min_size/2, max_size/2)};
    const Rect rect{size, {RandInt(1, size_.x - size.x - 1),
                           RandInt(1, size_.y - size.y - 1)}};
    if (!level.PlaceRectangularRoom(rect, separation, &rects)) {
      tries_left -= 1;
    }
  }
  const int n = rects.size();
  ASSERT(n > 0);
  MAYBE_DEBUG("Placed " << IntToString(n) << " rectangular rooms after "
              << IntToString(tries) << " attempts.");

  Array2d<double> graph = ConstructArray2d<double>(Point(n, n), 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      graph[i][j] = RectToRectDistance(rects[i], rects[j]);
      ASSERT((i == j) == (graph[i][j] == 0));
    }
  }
  vector<Point> edges = MinimumSpanningTree(graph);
  MAYBE_DEBUG("Computed a minimal spanning tree with "
              << IntToString(edges.size()) << " edges.");

  int loop_edges = 0;
  Array2d<double> distances = ComputeTreeDistances(graph, edges);
  while (true) {
    Point best_edge;
    double best_ratio = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        double ratio = distances[i][j]/graph[i][j];
        if (ratio > best_ratio) {
          best_edge = Point(i, j);
          best_ratio = ratio;
        }
      }
    }
    if (best_ratio < 2.0) {
      break;
    }
    edges.push_back(best_edge);
    double distance = graph[best_edge.x][best_edge.y];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        distances[i][j] = min(distances[i][j], min(
            distances[i][best_edge.x] + distance + distances[best_edge.y][j],
            distances[i][best_edge.y] + distance + distances[best_edge.x][j]));
      }
    }
    loop_edges += 1;
  }
  MAYBE_DEBUG("Added " << IntToString(loop_edges) << " high-ratio loop edges.");

  const double islandness = rand() % 3;
  for (int i = 0; i < 3; i++) {
    level.Erode(islandness);
  }
  level.ExtractFinalRooms(n, &rooms_);

  const double windiness = 1.0;
  for (const Point& edge : edges) {
    ASSERT(edge.x != edge.y);
    if (!level.DigCorridor(rooms_, edge.x, edge.y, windiness)) {
      MAYBE_DEBUG("Failed to dig corridor. Retrying...");
      return false;
    }
  }
  MAYBE_DEBUG("Dug " << IntToString(edges.size()) << " corridors.");

  level.AddWalls();
  starting_square_ = rooms_[0].GetRandomSquare();
  MAYBE_DEBUG("Final map:" << level.ToDebugString());
  PackTiles(level.tiles);
  return true;
}
示例#24
0
void
PlayField::keyPressEvent(QKeyEvent * e) {
  int x=levelMap_->xpos();
  int y=levelMap_->ypos();

  switch (e->key()) {
  case Qt::Key_Up:
    if (e->state() & Qt::ControlModifier) step(x, 0);
    else if (e->state() & Qt::ShiftModifier) push(x, 0);
    else push(x, y-1);
    break;
  case Qt::Key_Down:
    if (e->state() & Qt::ControlModifier) step(x, MAX_Y);
    else if (e->state() & Qt::ShiftModifier) push(x, MAX_Y);
    else push(x, y+1);
    break;
  case Qt::Key_Left:
    if (e->state() & Qt::ControlModifier) step(0, y);
    else if (e->state() & Qt::ShiftModifier) push(0, y);
    else push(x-1, y);
    break;
  case Qt::Key_Right:
    if (e->state() & Qt::ControlModifier) step(MAX_X, y);
    else if (e->state() & Qt::ShiftModifier) push(MAX_X, y);
    else push(x+1, y);
    break;

  case Qt::Key_Q:
    KApplication::kApplication()->closeAllWindows();
    break;

  case Qt::Key_Backspace:
  case Qt::Key_Delete:
    if (e->state() & Qt::ControlModifier) redo();
    else undo();
    break;

#if 0
  case Qt::Key_X:
    levelMap_->random();
    levelChange();
    repaint(false);
    break;

  case Qt::Key_R:
    level(levelMap_->level());
    return;
    break;
  case Qt::Key_N:
    nextLevel();
    return;
    break;
  case Qt::Key_P:
    previousLevel();
    return;
    break;
  case Qt::Key_U:
    undo();
    return;
    break;
  case Qt::Key_I:
    history_->redo(levelMap_);
    repaint(false);
    return;
    break;

  case Qt::Key_S:
    {
      QString buf;
      history_->save(buf);
      printf("%s\n", (char *) buf);
    }
    return;
    break;

  case Qt::Key_L:
    stopMoving();
    history_->clear();
    level(levelMap_->level());
    {
      char buf[4096]="r1*D1*D1*r1*@r1*D1*";
      //scanf("%s", buf);
      history_->load(levelMap_, buf);
    }
    updateStepsXpm();
    updatePushesXpm();
    repaint(false);
    return;
    break;
#endif


  case Qt::Key_Print:
    HtmlPrinter::printHtml(levelMap_);
    break;

  default:
    e->ignore();
    return;
    break;
  }
}
示例#25
0
文件: TowerD.cpp 项目: rich98521/FYP
int main()
{
	Config::Init();
	curl_global_init(CURL_GLOBAL_ALL);
	Network::Init();
	sf::RenderWindow window(sf::VideoMode(Config::ScreenWidth(), Config::ScreenHeight(), 32), "TowerDefense");
	srand(time(NULL));
	const int tileSize = 32;
	Renderer r = Renderer();
	SoundManager snd;
	snd.Init();
	Level level(tileSize, sf::Vector2i(Config::ScreenWidth(), Config::ScreenHeight()), &r);
	Menu menu(&r, &window, &level, level.GetCam());
	sf::Clock clock;
	float drawInterval = 0.0166f, updateInterval = 0.0043f;
	float drawTime = 0, updateTime = 0;
	bool ctrl = false, shft = false , alt = false;
	unsigned int modifierKeys = 0;
	
	while (window.isOpen())
	{
		sf::Event Event;
		while (window.pollEvent(Event))
		{
			if (Event.type == sf::Event::KeyPressed)
			{
				if (Event.key.code == sf::Keyboard::LControl || Event.key.code == sf::Keyboard::RControl)
					ctrl = true;
				else if (Event.key.code == sf::Keyboard::LShift || Event.key.code == sf::Keyboard::RShift)
					shft = true;
				else if (Event.key.code == sf::Keyboard::LAlt || Event.key.code == sf::Keyboard::RAlt)
					alt = true;
			}
			else if (Event.type == sf::Event::KeyReleased)
			{
				if (Event.key.code == sf::Keyboard::LControl || Event.key.code == sf::Keyboard::RControl)
					ctrl = false;
				else if (Event.key.code == sf::Keyboard::LShift || Event.key.code == sf::Keyboard::RShift)
					shft = false;
				else if (Event.key.code == sf::Keyboard::LAlt || Event.key.code == sf::Keyboard::RAlt)
					alt = false;
			}
			modifierKeys = (ctrl ? ModifierKeys::Control : 0) | (shft ? ModifierKeys::Shift : 0) | (alt ? ModifierKeys::Alt : 0);
			if (Event.type == sf::Event::Closed)
				window.close();
			else if (Event.type == sf::Event::KeyPressed)
			{
				menu.ProcessInput(Event, modifierKeys);
				if (!menu.GamePaused())
					level.ProcessInput(Event, modifierKeys);
			}
			else if (Event.type == sf::Event::MouseButtonPressed || Event.type == sf::Event::JoystickButtonPressed || Event.type == sf::Event::JoystickMoved || Event.type == sf::Event::MouseMoved)
			{
				if (!menu.ProcessInput(Event, modifierKeys))
					level.ProcessInput(Event, modifierKeys);
			}
			else if (Event.type == sf::Event::KeyReleased || Event.type == sf::Event::MouseButtonReleased || Event.type == sf::Event::JoystickButtonReleased)
			{
				menu.ProcessInput(Event, modifierKeys);
				level.ProcessInput(Event, modifierKeys);
			}
		}
		float time = clock.getElapsedTime().asSeconds();
		clock.restart();
		drawTime += time;
		updateTime += time;

		menu.Update();
		if (!menu.GamePaused())
		{
			if (updateTime > updateInterval)
			{
				level.Update(time);
				level.CheckCollision();
				updateTime = 0;
			}
		}

		if (drawTime > drawInterval)
		{
			window.clear();

			level.Draw(&window);
			r.Draw(&window);

			window.display();
			drawTime -= drawInterval;
		}
	}

	return EXIT_SUCCESS;
}
示例#26
0
int main (int argc, char** argv)
{
#ifdef CH_MPI
  MPI_Init(&argc,&argv);
#endif

  // begin forever present scoping trick
  {
    const char* in_file = "impFuncTest.inputs";

    // parse input file
    ParmParse pp(0,NULL,NULL,in_file);

    RealVect center;
    Real radius;

    bool insideRegular;

    RealVect origin;
    Real dx;

    Box domain;

    int eekflag = 0;

    // make geometry
    eekflag = makeGeometry(domain,
                           dx,
                           origin,
                           center,
                           radius,
                           insideRegular);

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in makeGeometry");
    }

    // make grids
    DisjointBoxLayout grids;
    eekflag = makeLayout(grids,domain);

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in makeLayouts");
    }

    // create ebislayout
    int nghost = 2;
    EBISLayout ebisl;
    eekflag = makeEBISL(ebisl,grids,domain,nghost);

    // make a LevelData
    int nComps = 2;

    IntVect ghost = IntVect::Unit;
    ghost *= nghost;

    RefCountedPtr<DataFactory<EBCellFAB> > rcpFactory(new EBCellFactory(ebisl));
    LevelData<EBCellFAB> level(grids,nComps,ghost,*rcpFactory);

    // writeEBLevelname(&level,"level.hdf5");

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in makeEBISL");
    }

    // check volume and surface area of approximate sphere
    eekflag = checkEBISL(ebisl,
                         grids,
                         domain,
                         dx,
                         origin,
                         radius,
                         center,
                         insideRegular);

    if (eekflag != 0)
    {
      pout() << "non zero eek detected = " << eekflag << endl;
      MayDay::Error("problem in checkEBISL");
    }

    pout() << "implicit function test passed" << endl;
  } // end scoping trick

  CH_XD::EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
  ebisPtr->clear();

#ifdef CH_MPI
  MPI_Finalize();
#endif

  return 0;
}
示例#27
0
QString FileNode::indention() const
{
    QString indent;
    indent.fill(' ', level()*2);
    return indent;
}
示例#28
0
int main()
{
	// Set display options.
	// DCNT_MODE0 sets mode 0, which provides four tiled backgrounds.
	// DCNT_OBJ enables objects.
	// DCNT_OBJ_1D make object tiles mapped in 1D (which makes life easier).
	REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_OBJ;
	
	REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32 | BG_PRIO(0);
	
	REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32 | BG_PRIO(1);
	
	REG_BG2CNT = BG_CBB(0) | BG_SBB(25) | BG_8BPP | BG_REG_64x64 | BG_PRIO(2);
	REG_BG2HOFS = 0;
	REG_BG2VOFS = 0;
	
	ClearObjects();
	
	SetPaletteBG(1, RGB(31, 31, 31)); // white
	
	//Load each tile in font_bold into it's corresponding position in charblock 0
	for (int i = 0; i < 128; i++)
	{
		LoadTile8(0, i, font_bold[i]);
	}
	
	DrawText(5, (SCREEN_HEIGHT / 16) - 2, "DECEPTIVE DIMENSIONS");
	DrawText(5, (SCREEN_HEIGHT / 16), "Press start to begin");
	
	Buttons buttons;
	int framecounter = 0;
	
	//Title screen (under construction)
	while (true)
	{
		buttons.Update();
		
		if (buttons.StartJustPressed())
		{
			break;
		}
		
		WaitVSync();	
	}
	
	while (true)
	{
		//Load Custom spritesheet
		LoadPaletteObjData(0, spritesheet4Pal, sizeof spritesheet4Pal);
		LoadPaletteBGData(0, backgroundnewnewPal, sizeof backgroundnewnewPal);
		LoadTileData(4, 0, spritesheet4Tiles, sizeof spritesheet4Tiles);
		LoadTileData(0, 0, backgroundnewnewTiles, sizeof backgroundnewnewTiles);
		
		int levelnumber = 1;
		
		Level level(levelnumber);
		
		for (int screenblock = 21; screenblock < 31; screenblock++)
		{
			level.FillScreenblock(screenblock, 0);
		}
		
		level.DrawBackground(level.curdimension);
		
		bool gamerunning = true;
		
		//Main game loop
		while (gamerunning)
		{
			buttons.Update();
			
			gamerunning = level.CheckIfLevelComplete();
			level.TakeInput(buttons);
			level.MoveObjects();
			level.Draw();
			level.UpdateLevelObjects(framecounter);

			framecounter++;
			
			WaitVSync();
			FlipBuffers();
		}
		
		//Reload each tile in font_bold into it's corresponding position in charblock 0
		for (int i = 0; i < 128; i++)
		{
			LoadTile8(0, i, font_bold[i]);
		}
		
		SetPaletteBG(0, RGB(0, 0, 0)); // black
		SetPaletteBG(1, RGB(31, 31, 31)); // white		
		
		for (int screenblock = 25; screenblock < 31; screenblock++)
		{
			for (int y = 0; y < 32; y++)
			{
				for (int x = 0; x < 32; x++)
				{
					SetTile(screenblock, x, y, 0);
				}
			}
		}
		
		level.player.drawx = SCREEN_WIDTH;
		
		SetObject(level.player.GetObjNum(),
		  ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_HIDE,
		  ATTR1_SIZE(2) | ATTR1_X(level.player.drawx),
		  ATTR2_ID8(0) | ATTR2_PRIO(2));
		
		UpdateObjects();
		
		DrawText(6, (SCREEN_HEIGHT / 16) - 2, "That's all folks!!");
		DrawText(3, (SCREEN_HEIGHT / 16), "Press start to try again");
		
		while (true)
		{
			buttons.Update();
			
			if (buttons.StartJustPressed())
			{
				break;
			}
			
			WaitVSync();
		}
	}
}
示例#29
0
// -----------------------------------------------------------------------------
void LLViewerJoystick::moveFlycam(bool reset)
{
	static LLQuaternion 		sFlycamRotation;
	static LLVector3    		sFlycamPosition;
	static F32          		sFlycamZoom;
	
	if (!gFocusMgr.getAppHasFocus() || mDriverState != JDS_INITIALIZED
		|| !gSavedSettings.getBOOL("JoystickEnabled") || !gSavedSettings.getBOOL("JoystickFlycamEnabled"))
	{
		return;
	}

	S32 axis[] = 
	{
		gSavedSettings.getS32("JoystickAxis0"),
		gSavedSettings.getS32("JoystickAxis1"),
		gSavedSettings.getS32("JoystickAxis2"),
		gSavedSettings.getS32("JoystickAxis3"),
		gSavedSettings.getS32("JoystickAxis4"),
		gSavedSettings.getS32("JoystickAxis5"),
		gSavedSettings.getS32("JoystickAxis6")
	};

	bool in_build_mode = LLToolMgr::getInstance()->inBuildMode();
	if (reset || mResetFlag)
	{
		sFlycamPosition = LLViewerCamera::getInstance()->getOrigin();
		sFlycamRotation = LLViewerCamera::getInstance()->getQuaternion();
		sFlycamZoom = LLViewerCamera::getInstance()->getView();
		
		resetDeltas(axis);

		return;
	}

	F32 axis_scale[] =
	{
		gSavedSettings.getF32("FlycamAxisScale0"),
		gSavedSettings.getF32("FlycamAxisScale1"),
		gSavedSettings.getF32("FlycamAxisScale2"),
		gSavedSettings.getF32("FlycamAxisScale3"),
		gSavedSettings.getF32("FlycamAxisScale4"),
		gSavedSettings.getF32("FlycamAxisScale5"),
		gSavedSettings.getF32("FlycamAxisScale6")
	};

	F32 dead_zone[] =
	{
		gSavedSettings.getF32("FlycamAxisDeadZone0"),
		gSavedSettings.getF32("FlycamAxisDeadZone1"),
		gSavedSettings.getF32("FlycamAxisDeadZone2"),
		gSavedSettings.getF32("FlycamAxisDeadZone3"),
		gSavedSettings.getF32("FlycamAxisDeadZone4"),
		gSavedSettings.getF32("FlycamAxisDeadZone5"),
		gSavedSettings.getF32("FlycamAxisDeadZone6")
	};

	F32 time = gFrameIntervalSeconds;

	// avoid making ridiculously big movements if there's a big drop in fps 
	if (time > .2f)
	{
		time = .2f;
	}

	F32 cur_delta[7];
	F32 feather = gSavedSettings.getF32("FlycamFeathering");
	bool absolute = gSavedSettings.getBOOL("Cursor3D");
	bool is_zero = true;

	for (U32 i = 0; i < 7; i++)
	{
		cur_delta[i] = -getJoystickAxis(axis[i]);


		F32 tmp = cur_delta[i];
		if (absolute)
		{
			cur_delta[i] = cur_delta[i] - sLastDelta[i];
		}
		sLastDelta[i] = tmp;

		if (cur_delta[i] > 0)
		{
			cur_delta[i] = llmax(cur_delta[i]-dead_zone[i], 0.f);
		}
		else
		{
			cur_delta[i] = llmin(cur_delta[i]+dead_zone[i], 0.f);
		}

		// we need smaller camera movements in build mode
		// NOTE: this needs to remain after the deadzone calculation, otherwise
		// we have issues with flycam "jumping" when the build dialog is opened/closed  -Nyx
		if (in_build_mode)
		{
			if (i == X_I || i == Y_I || i == Z_I)
			{
				cur_delta[i] /= BUILDMODE_FLYCAM_T_SCALE;
			}
		}

		cur_delta[i] *= axis_scale[i];
		
		if (!absolute)
		{
			cur_delta[i] *= time;
		}

		sDelta[i] = sDelta[i] + (cur_delta[i]-sDelta[i])*time*feather;

		is_zero = is_zero && (cur_delta[i] == 0.f);

	}
	
	// Clear AFK state if moved beyond the deadzone
	if (!is_zero && gAwayTimer.getElapsedTimeF32() > MIN_AFK_TIME)
	{
		gAgent.clearAFK();
	}
	
	sFlycamPosition += LLVector3(sDelta) * sFlycamRotation;

	LLMatrix3 rot_mat(sDelta[3], sDelta[4], sDelta[5]);
	sFlycamRotation = LLQuaternion(rot_mat)*sFlycamRotation;

	if (gSavedSettings.getBOOL("AutoLeveling"))
	{
		LLMatrix3 level(sFlycamRotation);

		LLVector3 x = LLVector3(level.mMatrix[0]);
		LLVector3 y = LLVector3(level.mMatrix[1]);
		LLVector3 z = LLVector3(level.mMatrix[2]);

		y.mV[2] = 0.f;
		y.normVec();

		level.setRows(x,y,z);
		level.orthogonalize();
				
		LLQuaternion quat(level);
		sFlycamRotation = nlerp(llmin(feather*time,1.f), sFlycamRotation, quat);
	}

	if (gSavedSettings.getBOOL("ZoomDirect"))
	{
		sFlycamZoom = sLastDelta[6]*axis_scale[6]+dead_zone[6];
	}
	else
	{
		sFlycamZoom += sDelta[6];
	}

	LLMatrix3 mat(sFlycamRotation);

	LLViewerCamera::getInstance()->setView(sFlycamZoom);
	LLViewerCamera::getInstance()->setOrigin(sFlycamPosition);
	LLViewerCamera::getInstance()->mXAxis = LLVector3(mat.mMatrix[0]);
	LLViewerCamera::getInstance()->mYAxis = LLVector3(mat.mMatrix[1]);
	LLViewerCamera::getInstance()->mZAxis = LLVector3(mat.mMatrix[2]);
}
示例#30
0
GenerationSpec* Generation::spec() {
    GenCollectedHeap* gch = GenCollectedHeap::heap();
    assert(0 <= level() && level() < gch->_n_gens, "Bad gen level");
    return gch->_gen_specs[level()];
}