xui_method_explain(xui_border, on_mouserise, void)( xui_method_mouse& args ) { xui_component::on_mouserise(args); if (args.mouse == MB_L && m_parent) { xui_vector<s32> pt = m_parent->get_renderpt(); xui_vector<s32> sz = m_parent->get_rendersz(); xui_vector<s32> deltapt(0); xui_vector<s32> deltasz(0); switch (m_resize) { case RESIZEFLAG_L: deltasz.w = m_downpt.x - args.point.x; break; case RESIZEFLAG_T: deltasz.h = m_downpt.y - args.point.y; break; case RESIZEFLAG_R: deltasz.w = args.point.x - m_downpt.x; break; case RESIZEFLAG_B: deltasz.h = args.point.y - m_downpt.y; break; } switch (m_resize) { case RESIZEFLAG_L: deltapt.x = args.point.x - m_downpt.x; break; case RESIZEFLAG_T: deltapt.y = args.point.y - m_downpt.y; break; } m_parent->set_renderpt(pt+deltapt); m_parent->set_rendersz(sz+deltasz); } }
bool Agent::validInRoomSystem(Point p, float w, float h, int testperm) { // Return true if this agent is inside the world room system at the specified point, or false if it isn't. MetaRoom *m = world.map.metaRoomAt(p.x, p.y); if (!m) return false; for (unsigned int i = 0; i < 4; i++) { Point src, dest; switch (i) { case 0: src = boundingBoxPoint(0, p, w, h); dest = boundingBoxPoint(3, p, w, h); break; // left to bottom case 1: src = boundingBoxPoint(1, p, w, h); dest = boundingBoxPoint(3, p, w, h); break; // right to bottom case 2: src = boundingBoxPoint(2, p, w, h); dest = boundingBoxPoint(0, p, w, h); break; // top to left case 3: src = boundingBoxPoint(2, p, w, h); dest = boundingBoxPoint(1, p, w, h); break; // top to right } if (engine.version == 2) { // Creatures 2 physics int dx = dest.x - src.x; int dy = dest.y - src.y; Point deltapt(0,0); double delta = 1000000000; bool collided = false; // TODO: check suffercollisions? // TODO: muh, provided direction here is kinda a hack findCollisionInDirection((i < 2) ? 3 : 2, m, src, dx, dy, deltapt, delta, collided, true); if (collided) return false; } else { // Creatures 3 physics float srcx = src.x, srcy = src.y; shared_ptr<Room> ourRoom = m->roomAt(srcx, srcy); if (!ourRoom) return false; unsigned int dir; Line wall; world.map.collideLineWithRoomSystem(src, dest, ourRoom, src, wall, dir, testperm); if (src != dest) return false; } } return true; }
void Agent::physicsTickC2() { int dx = velx.getInt(), dy = vely.getInt(); if (dx != 0 || dy != 0) falling = true; if (falling && sufferphysics()) { dy += accg.getInt(); } falling = true; if (dy == 0 && dx == 0) { // nothing to do if (vely.getInt() == 0) { // really no motion falling = false; } else { // y motion cancelled by gravity vely.setInt(dy); } return; } vely.setInt(dy); Point deltapt(0,0); double delta = 1000000000; bool collided = false; if (suffercollisions()) { MetaRoom *m = world.map.metaRoomAt(x, y); if (!m) { if (!displaycore) unhandledException(boost::str(boost::format("out of room system at (%f, %f)") % x % y), false); falling = false; displaycore = true; return; } for (unsigned int i = 0; i < 4; i++) { Point src = boundingBoxPoint(i); findCollisionInDirection(i, m, src, dx, dy, deltapt, delta, collided, true); } } else { deltapt.x = dx; deltapt.y = dy; } if (collided && (velx.getInt() != 0 || vely.getInt() != 0) && moved_last_tick) { if (lastcollidedirection >= 2) // up and down vely.setInt(-(vely.getInt() - (rest.getInt() * vely.getInt()) / 100)); else velx.setInt(-(velx.getInt() - (rest.getInt() * velx.getInt()) / 100)); queueScript(6, 0); } if ((int)deltapt.x == 0 && (int)deltapt.y == 0) { if (!moved_last_tick) { falling = false; velx.setInt(0); vely.setInt(0); } moved_last_tick = false; } else { moved_last_tick = true; moveTo(x + (int)deltapt.x, y + (int)deltapt.y); if (sufferphysics()) { int fricx = (aero.getInt() * velx.getInt()) / 100; int fricy = (aero.getInt() * vely.getInt()) / 100; if (abs(velx.getInt()) > 0 && fricx == 0) fricx = (velx.getInt() < 0) ? -1 : 1; if (abs(vely.getInt()) > 0 && fricy == 0) fricy = (vely.getInt() < 0) ? -1 : 1; velx.setInt(velx.getInt() - fricx); vely.setInt(vely.getInt() - fricy); } } }
void combination() { gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(1111111); // Show overflow, underflow + SumOfWeights // gStyle->SetStatStyle(0); // for a completely transparent stat box gStyle->SetOptFit(111110); gStyle->SetOptFile(1); gStyle->SetMarkerStyle(20); gStyle->SetMarkerSize(.3); gStyle->SetMarkerColor(1); gStyle->SetTitleBorderSize(0); // no border around histogram title (font size can't be calculated anyways ...) gROOT->ForceStyle(); TCanvas *c0 = new TCanvas("c0","--c0--",472,0,800,800); gStyle->SetOptStat(0); TFile resojet("resojetvspt.root"); TFile resophot("resophotvspt.root"); TFile deltapt("deltaptnormvspt.root"); TFile deltaptjet("deltaptjetnormvspt.root"); TFile ratiopt("ratioptnormvspt.root"); deltapt.cd(); resosum->SetMaximum(30); resosum->SetAxisRange(40.,700.); resosum->SetMarkerSize(.7); resosum->SetTitle(""); resosum->SetXTitle("p_{T}[GeV/c]"); resosum->SetYTitle("resolution(p_{T})%"); resosum->SetTitleOffset(1.,"Y"); resosum->Draw(); deltaptjet.cd(); resosum->SetLineColor(kBlue); resosum->SetMarkerColor(kBlue); resosum->SetMarkerSize(.7); resosum->Draw("same"); resojet.cd(); resosum->SetLineColor(kRed); resosum->SetMarkerColor(kRed); resosum->SetMarkerSize(.7); resosum->SetMaximum(30); resosum->SetAxisRange(40.,700.); resosum->SetTitle(""); resosum->SetXTitle("p_{T}[GeV/c]"); resosum->SetYTitle("resolution(p_{T})%"); resosum->SetTitleOffset(1.,"Y"); resosum->Draw("same"); resophot.cd(); resosum->SetLineColor(kGreen); resosum->SetMarkerColor(kGreen); resosum->SetMarkerSize(.7); resosum->Draw("same"); deltapt.cd(); resosum->Draw("same"); TH1D p1; TH1D p2; TH1D p3; TH1D p4; p1.SetMarkerStyle(8); p1.SetMarkerSize(1.4); p2.SetLineColor(kBlue); p2.SetMarkerColor(kBlue); p2.SetMarkerStyle(8); p2.SetMarkerSize(1.4); p3.SetLineColor(kRed); p3.SetMarkerColor(kRed); p3.SetMarkerStyle(8); p3.SetMarkerSize(1.4); p4.SetLineColor(kGreen); p4.SetMarkerColor(kGreen); p4.SetMarkerStyle(8); p4.SetMarkerSize(1.4); TLegendEntry *legge; TLegend *leg; leg = new TLegend(0.3,0.65,0.65,0.85); leg->SetFillStyle(0); leg->SetBorderSize(0.); leg->SetTextSize(0.035); leg->SetFillColor(0); legge = leg->AddEntry(&p1, "jet-gamma", "p"); legge = leg->AddEntry(&p2, "gamma(MC)-jet(MC)", "p"); legge = leg->AddEntry(&p3, "jet-jet(MC)", "p"); legge = leg->AddEntry(&p4, "gamma-gamma(MC)", "p"); leg->Draw(); c0->SaveAs("reso_combination.eps"); c0->SaveAs("reso_combination.gif"); resojet.cd(); resosum->Draw(); c0->SaveAs("resojetonly_combination.eps"); c0->SaveAs("resojetonly_combination.gif"); deltapt.cd(); biassum->SetMaximum(15); biassum->SetAxisRange(40.,700.); biassum->SetMarkerSize(.7); biassum->SetTitle(""); biassum->SetXTitle("p_{T}[GeV/c]"); biassum->SetYTitle("peak position(p_{T})%"); biassum->SetTitleOffset(1.,"Y"); biassum->Draw(); deltaptjet.cd(); biassum->SetLineColor(kBlue); biassum->SetMarkerColor(kBlue); biassum->SetMarkerSize(.7); biassum->Draw("same"); resojet.cd(); biassum->SetMaximum(15); biassum->SetAxisRange(40.,700.); biassum->SetMarkerSize(.7); biassum->SetTitle(""); biassum->SetXTitle("p_{T}[GeV/c]"); biassum->SetYTitle("peak position(p_{T})%"); biassum->SetTitleOffset(1.,"Y"); biassum->SetLineColor(kRed); biassum->SetMarkerColor(kRed); biassum->SetMarkerSize(.7); biassum->Draw("same"); resophot.cd(); biassum->SetLineColor(kGreen); biassum->SetMarkerColor(kGreen); biassum->SetMarkerSize(.7); biassum->Draw("same"); deltapt.cd(); biassum->Draw("same"); TLegendEntry * legge2; TLegend leg2(0.33,0.15,0.65,0.35);; leg2.SetFillStyle(0); leg2.SetBorderSize(0.); leg2.SetTextSize(0.035); leg2.SetFillColor(0); legge2 = leg2.AddEntry(&p1, "jet-gamma", "p"); legge2 = leg2.AddEntry(&p2, "gamma(MC)-jet(MC)", "p"); legge2 = leg2.AddEntry(&p3, "jet-jet(MC)", "p"); legge2 = leg2.AddEntry(&p4, "gamma-gamma(MC)", "p"); leg2.Draw(); c0->SaveAs("bias_combination.eps"); // c0->SaveAs("bias_combination.gif"); deltapt.cd(); biassum->Draw(); c0->SaveAs("biasonly_combination.eps"); // c0->SaveAs("biasonly_combination.gif"); resojet.cd(); biassum->Draw(); c0->SaveAs("biasjetonly_combination.eps"); // c0->SaveAs("biasjetonly_combination.gif"); ratiopt.cd(); biassum->SetMaximum(1.0999); biassum->SetMinimum(0.3); biassum->SetAxisRange(40.,700.); biassum->SetMarkerSize(.7); biassum->SetTitle(""); biassum->SetXTitle("p_{T}(#gamma)[GeV/c]"); biassum->SetYTitle("#frac{p_{T}(jet)}{p_{T}(#gamma)}"); biassum->SetTitleOffset(.8,"Y"); biassum->Draw(); c0->SaveAs("ratioonly_combination.eps"); // c0->SaveAs("ratioonly_combination.gif"); }