void KNewStuff2Test::providerTest() { kDebug() << "-- test kns2 provider class"; QDomDocument doc; QFile f(QString("%1/testdata/provider.xml").arg(KNSSRCDIR)); if (!f.open(QIODevice::ReadOnly)) { kDebug() << "Error loading provider file."; quitTest(); } if (!doc.setContent(&f)) { kDebug() << "Error parsing provider file."; f.close(); quitTest(); } f.close(); KNS::ProviderHandler ph(doc.documentElement()); KNS::Provider p = ph.provider(); kDebug() << "-- xml->provider test result: " << ph.isValid(); KNS::ProviderHandler ph2(p); QDomElement pxml = ph2.providerXML(); kDebug() << "-- provider->xml test result: " << ph.isValid(); if (!ph.isValid()) { quitTest(); } else { QTextStream out(stdout); out << pxml; } }
void Base::execute() { a(); ph1(); c(); ph2(); e(); }
void execute(){ a(); ph1(); c(); ph2(); e(); }
Color trace(Ray& ray, int i){ if(!i) return Color(0,0,0); Obj* o; Vector x; Vector n; if(firstIntersect(ray, x, n, &o)<0) return La; Color c=directLight(ray.dir,x,n,o->mat); if(!o->mat.reflective&&!o->mat.refractive){ double px=(x.x/4+0.5)*phms; double py=(x.y/4+0.5)*phms; double u=px-(int)px; double v=py-(int)py; Color f=ph2((int)px, (int)py)*(1-u)*(1-v)+ ph2((int)px+1, (int)py)*(u)*(1-v)+ ph2((int)px, (int)py+1)*(1-u)*(v)+ ph2((int)px+1, (int)py+1)*(u)*(v); c=c+f*(5000./phLim); } if(o->mat.reflective) { Vector refd=reflectDir(ray.dir,n)+x; Ray ref(x,refd); if(o->mat.refractive){ bool valid=true; Vector refrd=refractDir(ray.dir,n,o->mat.n.r,valid); if(valid){ c=c+fresnel(ray.dir,n,o->mat,false)*trace(ref,i-1); } else { c=c+trace(ref,i-1); } } else { c=c+fresnel(ray.dir,n,o->mat,false)*trace(ref,i-1); } } if(o->mat.refractive){ bool valid=true; Vector refrd=refractDir(ray.dir,n,o->mat.n.r,valid)+x; if(valid){ Ray refr(x,refrd); c=c+fresnel(ray.dir,n,o->mat,true)*trace(refr,i-1); } } return c; }
ListNode* partition(ListNode* head, int x) { ListNode ph1(0), *pre1 = &ph1, ph2(0), *pre2 = &ph2; while (head) { ListNode *&min = head->val < x ? pre1 : pre2; min->next = head; min = min->next; head = head->next; } pre1->next = ph2.next; pre2->next = nullptr; return ph1.next; }
/* * Diagram "B1", SQED, broken SUSY, * Gauge sector. */ main() { page pg; FeynDiagram fd(pg); #define RAD 2.5 fd.line_thickness.set(0.15); fd.vertex_thickness.set(0.15); /* define the left and the right external points */ xy el(-6, 0), er(6, 0); /* the SB vertex */ xy sb_coord(0, -RAD); vertex_box sb(fd, sb_coord); sb.fill.setfalse(); vertex_cross sb_cross(fd, sb_coord); sb.radius.scale(SB_RADIUS_SCALE); sb_cross.radius.scale(SB_RADIUS_SCALE); /* the LV vertex */ xy lv_coord(RAD, 0); lv_coord.rotate(-45); vertex_circlecross lv(fd, lv_coord); xy arcpt1(0, RAD); xy arcpt2(RAD, 0); arcpt2.rotate(-20); xy arcpt3(RAD, 0); arcpt3.rotate(-60); xy arcpt4(RAD, 0); arcpt4.rotate(-135); /* the ordinary SQED vertex */ vertex v1(fd, -RAD, 0); vertex v2(fd, RAD, 0); /* photon line propagators */ line_wiggle ph1(fd, el, v1), ph2(fd, v2, er); line_plain f1(fd, v1, v2); line_plain f2(fd, v2, lv); f2.arrowon.setfalse(); line_plain f3(fd, lv, sb); f3.arrowon.setfalse(); line_plain f4(fd, sb, v1); /* stretch it to be an arc */ f1.arcthru(arcpt1); f2.arcthru(arcpt2); f3.arcthru(arcpt3); f4.arcthru(arcpt4); pg.output(); return 0; }
static bool check_model_collisions(Player& plyr, const ppogl::Vec3d& pos, ppogl::Vec3d *tree_loc, float *tree_diam) { if(GameConfig::disableCollisionDetection){ return false; } if(modelLocs.empty()){ //no models? what a boring course... return false; } pp::Matrix mat; bool hit = false; ppogl::Vec3d distvec; float squared_dist; /* These variables are used to cache collision detection results */ static bool last_collision = false; static ppogl::Vec3d last_collision_tree_loc( -999, -999, -999 ); static double last_collision_tree_diam = 0; static ppogl::Vec3d last_collision_pos( -999, -999, -999 ); /* If we haven't moved very much since the last call, we re-use the results of the last call (significant speed-up) */ ppogl::Vec3d dist_vec = pos - last_collision_pos; if ( dist_vec.length2() < COLLISION_TOLERANCE ) { if ( last_collision ) { if ( tree_loc != NULL ) { *tree_loc = last_collision_tree_loc; } if ( tree_diam != NULL ) { *tree_diam = last_collision_tree_diam; } return true; } else { return false; } } ppogl::RefPtr<ModelType> model_type = (*modelLocs.begin()).getType(); ppogl::Polyhedron *ph = model_type->ph; float diam=0.0; float height; ppogl::Vec3d loc; std::list<Model>::iterator it; for(it=modelLocs.begin();it!=modelLocs.end();it++) { diam = (*it).getDiameter(); height = (*it).getHeight(); loc = (*it).getPosition(); distvec = ppogl::Vec3d( loc.x() - pos.x(), 0.0, loc.z() - pos.z() ); /* check distance from tree; .6 is the radius of a bounding sphere around tux (approximate) */ squared_dist = ( diam/2. + 0.6 ); squared_dist *= squared_dist; if ( distvec.length2() > squared_dist ) { continue; } /* have to look at polyhedron - switch to correct one if necessary */ if ( model_type != ((*it).getType()) ) { model_type = (*it).getType(); ph = model_type->ph; } ppogl::Polyhedron ph2(*ph); mat.makeScaling( diam, diam, diam ); trans_polyhedron( mat, ph2 ); mat.makeTranslation( loc.x(), loc.y(), loc.z() ); trans_polyhedron( mat, ph2 ); const std::string& tux_root = tux[plyr.num].getRootNode(); reset_scene_node( tux_root ); translate_scene_node( tux_root, ppogl::Vec3d( pos.x(), pos.y(), pos.z() ) ); hit = collide( tux_root, ph2 ); if ( hit == true ) { if ( tree_loc != NULL ) { *tree_loc = loc; } if ( tree_diam != NULL ) { *tree_diam = diam; } break; } } last_collision_tree_loc = loc; last_collision_tree_diam = diam; last_collision_pos = pos; if(hit){ last_collision = true; // Record collision in player data so that health can be adjusted plyr.collision = true; }else{ last_collision = false; } return hit; }