Nebula* UnitFactory::createNebula( const char *unitfile, bool SubU, int faction, Flightgroup *fg, int fg_snumber, ObjSerial netcreate ) { _Universe->netLock( true ); Nebula *neb = new Nebula( unitfile, SubU, faction, fg, fg_snumber ); _Universe->netLock( false ); if (netcreate) neb->SetSerial( netcreate ); /* * if (!_Universe->netLocked()) { * NetBuffer netbuf; * addNebulaBuffer(netbuf, neb); * endBuffer(netbuf); * VSServer->broadcast( netbuf, 0, _Universe->activeStarSystem()->GetZone(), CMD_ENTERCLIENT, true); * } * VSServer->invalidateSnapshot(); */ return neb; }
void operator()(StelRegionObjectP obj) { Nebula* n = obj.staticCast<Nebula>().data(); if (n->angularSize>angularSizeLimit || (checkMaxMagHints && n->mag <= maxMagHints)) { float refmag_add=0; // value to adjust hints visibility threshold. sPainter->getProjector()->project(n->XYZ,n->XY); n->drawLabel(*sPainter, maxMagLabels-refmag_add); n->drawHints(*sPainter, maxMagHints -refmag_add); } }
void NebulaUpdate( StarSystem * ss) { if (_Universe->AccessCockpit()->activeStarSystem==ss) { Nebula * neb; if ((neb=_Universe->AccessCamera()->GetNebula())) { if (neb->getFade()<=0) { //Update physics should set this _Universe->AccessCamera()->SetNebula(NULL); } } } }
Nebula* UnitFactory::createNebula( const char * unitfile, bool SubU, int faction, Flightgroup* fg, int fg_snumber, ObjSerial netcreate ) { Nebula * neb = new GameNebula( unitfile, SubU, faction, fg, fg_snumber ); if( netcreate) { KillDuplicateUnits( netcreate); neb->SetSerial( netcreate); } return neb; }
void NebulaManager::addNebula(Nebula const & nebula) { IGNORE_RETURN(s_nebulaMap.insert(std::make_pair(nebula.getId(), &nebula))); nebula.setSpatialSubdivisionHandle(s_collisionSphereTree->addObject(&nebula)); }
//#define UPDATEDEBUG //for hard to track down bugs void GameStarSystem::Draw(bool DrawCockpit) { double starttime=queryTime(); GFXEnable (DEPTHTEST); GFXEnable (DEPTHWRITE); saved_interpolation_blend_factor=interpolation_blend_factor = (1./PHY_NUM)*((PHY_NUM*time)/SIMULATION_ATOM+current_stage); GFXColor4f(1,1,1,1); if (DrawCockpit) { AnimatedTexture::UpdateAllFrame(); } for (unsigned int i=0;i<contterrains.size();++i) { contterrains[i]->AdjustTerrain(this); } Unit * par; bool alreadysetviewport=false; if ((par=_Universe->AccessCockpit()->GetParent())==NULL) { _Universe->AccessCamera()->UpdateGFX (GFXTRUE); } else { if (!par->isSubUnit()) { //now we can assume world is topps par-> cumulative_transformation = linear_interpolate (par->prev_physical_state,par->curr_physical_state,interpolation_blend_factor); Unit * targ = par->Target(); if (targ&&!targ->isSubUnit()) { targ-> cumulative_transformation = linear_interpolate (targ->prev_physical_state,targ->curr_physical_state,interpolation_blend_factor); } _Universe->AccessCockpit()->SetupViewPort(true); alreadysetviewport=true; } } double setupdrawtime=queryTime(); { cam_setup_phase=true; //int numships=0; Unit * saveparent=_Universe->AccessCockpit()->GetSaveParent(); Unit * targ=NULL; if (saveparent) { targ=saveparent->Target(); } //Array containing the two interesting units, so as not to have to copy-paste code Unit * camunits[2]={saveparent,targ}; float backup=SIMULATION_ATOM; unsigned int cur_sim_frame = _Universe->activeStarSystem()->getCurrentSimFrame(); for(int i=0;i<2;++i) { Unit *unit=camunits[i]; // Make sure unit is not null; if(unit&&!unit->isSubUnit()) { interpolation_blend_factor=calc_blend_factor(saved_interpolation_blend_factor,unit->sim_atom_multiplier,unit->cur_sim_queue_slot,cur_sim_frame); SIMULATION_ATOM = backup*unit->sim_atom_multiplier; ((GameUnit<Unit> *)unit)->GameUnit<Unit>::Draw(); } } interpolation_blend_factor=saved_interpolation_blend_factor; SIMULATION_ATOM=backup; //printf("Number of insystem ships: %d (%d FPS)\n",numships,(int)(1.f/GetElapsedTime())); ///this is the final, smoothly calculated cam _Universe->AccessCockpit()->SetupViewPort(true); cam_setup_phase=false; } setupdrawtime=queryTime()-setupdrawtime; GFXDisable (LIGHTING); bg->Draw(); double drawtime=queryTime(); double maxdrawtime=0; //Ballpark estimate of when an object of configurable size first becomes one pixel QVector drawstartpos=_Universe->AccessCamera()->GetPosition(); Collidable key_iterator(0,1,drawstartpos); UnitWithinRangeOfPosition<UnitDrawer> drawer(game_options.precull_dist,0,key_iterator); //Need to draw really big stuff (i.e. planets, deathstars, and other mind-bogglingly big things that shouldn't be culled despited extreme distance Unit* unit; if ((drawer.action.parent=_Universe->AccessCockpit()->GetParent())!=NULL) { drawer.action.parenttarget=drawer.action.parent->Target(); } for(un_iter iter=this->GravitationalUnits.createIterator();(unit=*iter)!=NULL;++iter) { float distance = (drawstartpos-unit->Position()).Magnitude()-unit->rSize(); if(distance < game_options.precull_dist) { drawer.action.grav_acquire(unit); } else { drawer.action.draw(unit); } } // Need to get iterator to approx camera position CollideMap::iterator parent=collidemap[Unit::UNIT_ONLY]->lower_bound(key_iterator); findObjectsFromPosition(this->collidemap[Unit::UNIT_ONLY],parent,&drawer,drawstartpos,0,true); drawer.action.drawParents();//draw units targeted by camera //FIXME maybe we could do bolts & units instead of unit only--and avoid bolt drawing step #if 0 for (unsigned int sim_counter=0;sim_counter<=SIM_QUEUE_SIZE;++sim_counter) { double tmp=queryTime(); Unit *unit; UnitCollection::UnitIterator iter = physics_buffer[sim_counter].createIterator(); float backup=SIMULATION_ATOM; unsigned int cur_sim_frame = _Universe->activeStarSystem()->getCurrentSimFrame(); while((unit = iter.current())!=NULL) { interpolation_blend_factor=calc_blend_factor(saved_interpolation_blend_factor,unit->sim_atom_multiplier,unit->cur_sim_queue_slot,cur_sim_frame); //if (par&&par->Target()==unit) { //printf ("i:%f s:%f m:%d c:%d l:%d\n",interpolation_blend_factor,saved_interpolation_blend_factor,unit->sim_atom_multiplier,sim_counter,current_sim_location); //} SIMULATION_ATOM = backup*unit->sim_atom_multiplier; ((GameUnit<Unit> *)unit)->Draw(); iter.advance(); } interpolation_blend_factor=saved_interpolation_blend_factor; SIMULATION_ATOM=backup; tmp=queryTime()-tmp; if (tmp>maxdrawtime)maxdrawtime=tmp; } #endif drawtime=queryTime()-drawtime; WarpTrailDraw(); GFXFogMode (FOG_OFF); GFXColor tmpcol (0,0,0,1); GFXGetLightContextAmbient(tmpcol); double processmesh=queryTime(); if (!game_options.draw_near_stars_in_front_of_planets) stars->Draw(); Mesh::ProcessZFarMeshes(); if (game_options.draw_near_stars_in_front_of_planets) stars->Draw(); GFXEnable (DEPTHTEST); GFXEnable (DEPTHWRITE); //need to wait for lights to finish GamePlanet::ProcessTerrains(); Terrain::RenderAll(); Mesh::ProcessUndrawnMeshes(true); processmesh=queryTime()-processmesh; Nebula * neb; Matrix ident; Identity(ident); //Atmosphere::ProcessDrawQueue(); GFXPopGlobalEffects(); GFXLightContextAmbient(tmpcol); if ((neb = _Universe->AccessCamera()->GetNebula())) { neb->SetFogState(); } Beam::ProcessDrawQueue(); Bolt::Draw(); // if (_Universe->AccessCamera()->GetNebula()!=NULL) GFXFogMode (FOG_OFF); Animation::ProcessDrawQueue(); Halo::ProcessDrawQueue(); particleTrail.DrawAndUpdate(); GameStarSystem::DrawJumpStars(); ConditionalCursorDraw(false); // static bool doInputDFA = XMLSupport::parse_bool (vs_config->getVariable ("graphics","MouseCursor","false")); if (DrawCockpit) { _Universe->AccessCockpit()->Draw(); // if (doInputDFA) { // GFXHudMode (true); // systemInputDFA->Draw(); // GFXHudMode (false); // } } double fintime=queryTime()-starttime; if (debugPerformance()) { printf("draw: %f setup %f units %f maxunit %f processmesh %f ",fintime,setupdrawtime,drawtime,maxdrawtime,processmesh); } }