Color3 BidirPathTracing::getLightRadiance(AbstractLight *light , BidirPathState& cameraState , const Vector3& hitPos , const Vector3& rayDir) { int lightCount = scene.lights.size(); Real lightPickProb = 1.f / lightCount; Real directPdfArea , emissionPdf; Color3 radiance = light->getRadiance(scene.sceneSphere , rayDir , hitPos , &directPdfArea , &emissionPdf); Color3 res(0); if (radiance.isBlack()) return res; if (cameraState.pathLength == 1) return radiance; directPdfArea *= lightPickProb; emissionPdf *= lightPickProb; Real wCamera = mis(directPdfArea) * cameraState.dVCM + mis(emissionPdf) * cameraState.dVC; Real weight = 1.f / (1.f + wCamera); return radiance * weight; }
inline Vec3f connectVertices( const BDPTPathVertex& lightVertex, const SensorVertex& eyeVertex, const Scene& scene, size_t pathCount, // The number of paths sampled for the strategy s = lightVertex.m_nDepth + 1, t = 1 MisFunctor&& mis) { RaySample shadowRaySample; float revPdfWrtArea; auto We = eyeVertex.m_pSensor->sampleDirectImportance(scene, eyeVertex.m_PositionSample, lightVertex.m_Intersection, shadowRaySample, nullptr, nullptr, nullptr, &revPdfWrtArea, nullptr); if(shadowRaySample.pdf == 0.f || We == zero<Vec3f>()) { return zero<Vec3f>(); } float cosThetaOutDir; float bsdfRevPdfW; const auto fr = lightVertex.m_BSDF.eval(shadowRaySample.value.dir, cosThetaOutDir, nullptr, &bsdfRevPdfW); if(cosThetaOutDir == 0.f || fr == zero<Vec3f>() || scene.occluded(shadowRaySample.value)) { return zero<Vec3f>(); } We /= shadowRaySample.pdf; const float wLight = mis(revPdfWrtArea / pathCount) * (lightVertex.m_fdVCM + mis(bsdfRevPdfW) * lightVertex.m_fdVC); const float misWeight = 1.f / (wLight + 1.f); return misWeight * lightVertex.m_Power * fr * abs(cosThetaOutDir) * We; }
Color3 BidirPathTracing::connectToCamera(BidirPathState& lightState , const Vector3& hitPos , BSDF& bsdf) { Color3 res(0); Camera& camera = scene.camera; Vector3 dirToCamera = camera.pos - hitPos; if (((-dirToCamera) ^ camera.forward) <= 0) return res; Real distEye2 = dirToCamera.sqrLength(); Real dist = std::sqrt(distEye2); dirToCamera = dirToCamera / dist; Real cosToCamera , bsdfDirPdf , bsdfRevPdf; Color3 bsdfFactor = bsdf.f(scene , dirToCamera , cosToCamera , &bsdfDirPdf , &bsdfRevPdf); if (bsdfFactor.isBlack()) return res; bsdfRevPdf *= bsdf.continueProb; Real cosAtCamera = ((-dirToCamera) ^ camera.forward); Real imagePointToCameraDist = camera.imagePlaneDist / cosAtCamera; Real imageToSolidAngleFactor = SQR(imagePointToCameraDist) / cosAtCamera; Real imageToSurfaceFactor = imageToSolidAngleFactor * std::abs(cosToCamera) / distEye2; Real cameraPdfA = imageToSurfaceFactor /* * 1.f */; // pixel area is 1 Real surfaceToImageFactor = 1.f / imageToSurfaceFactor; // We divide the contribution by surfaceToImageFactor to convert the (already // divided) pdf from surface area to image plane area, w.r.t. which the // pixel integral is actually defined. We also divide by the number of samples // this technique makes res = (lightState.throughput | bsdfFactor) / (lightPathNum * surfaceToImageFactor); if (res.isBlack()) return res; if (scene.occluded(hitPos , dirToCamera , camera.pos)) return Color3(0); Real wLight = mis(cameraPdfA / lightPathNum) * (lightState.dVCM + mis(bsdfRevPdf) * lightState.dVC); Real weight = 1.f / (wLight + 1.f); //fprintf(fp , "weight = %.6f\n" , weight); return res * weight; }
// we force to connect eye path to light path Color3 BidirPathTracing::connectVertices(BidirPathState& lightState , BSDF& cameraBsdf , const Vector3& hitPos , BidirPathState& cameraState) { Vector3 dir = lightState.pos - hitPos; Real dist2 = dir.sqrLength(); Real dist = std::sqrt(dist2); dir = dir / dist; Color3 res(0); Real cosAtCamera , cameraBsdfDirPdf , cameraBsdfRevPdf; Color3 cameraBsdfFactor = cameraBsdf.f(scene , dir , cosAtCamera , &cameraBsdfDirPdf , &cameraBsdfRevPdf); if (cameraBsdfFactor.isBlack()) return res; Real cameraContProb = cameraBsdf.continueProb; cameraBsdfDirPdf *= cameraContProb; cameraBsdfRevPdf *= cameraContProb; Real cosAtLight , lightBsdfDirPdf , lightBsdfRevPdf; Color3 lightBsdfFactor = lightState.bsdf.f(scene , -dir , cosAtLight , &lightBsdfDirPdf , &lightBsdfRevPdf); if (lightBsdfFactor.isBlack()) return res; Real lightContProb = lightState.bsdf.continueProb; lightBsdfDirPdf *= lightContProb; lightBsdfRevPdf *= lightContProb; Real geometryTerm = cosAtLight * cosAtCamera / dist2; if (cmp(geometryTerm) < 0) return res; Real cameraBsdfDirPdfArea = pdfWtoA(cameraBsdfDirPdf , dist , cosAtLight); Real lightBsdfDirPdfArea = pdfWtoA(lightBsdfDirPdf , dist , cosAtCamera); res = (cameraBsdfFactor | lightBsdfFactor) * geometryTerm; if (res.isBlack() || scene.occluded(hitPos , dir , hitPos + dir * dist)) return Color3(0); Real wLight = mis(cameraBsdfDirPdfArea) * (lightState.dVCM + mis(lightBsdfRevPdf) * lightState.dVC); Real wCamera = mis(lightBsdfDirPdfArea) * (cameraState.dVCM + mis(cameraBsdfRevPdf) * cameraState.dVC); Real weight = 1.f / (wLight + 1.f + wCamera); return res * weight; }
BDPTPathVertex(const Scene& scene, const PowerBasedLightSampler& sampler, float lightSample, const Vec2f& positionSample, const Vec2f& directionSample, const Light*& pLight, float& lightPdf, uint32_t pathCount, MisFunctor&& mis) { pLight = sampler.sample(scene, lightSample, lightPdf); if(!pLight) { lightPdf = 0.f; m_Power = zero<Vec3f>(); m_fPathPdf = 0.f; m_nDepth = 0u; return; } RaySample raySample; float rayOriginPdf, intersectionPdfWrtArea, rayOriginToIncidentDirJacobian; auto Le = pLight->sampleExitantRay(scene, positionSample, directionSample, raySample, rayOriginPdf, m_Intersection, rayOriginToIncidentDirJacobian, intersectionPdfWrtArea); if(Le == zero<Vec3f>() || raySample.pdf == 0.f) { m_Power = Le; m_fPathPdf = 0.f; m_nDepth = 0u; return; } raySample.pdf *= lightPdf; Le /= raySample.pdf; m_Power = Le; m_nDepth = 1u; if(!m_Intersection) { m_fPathPdf = 0.f; m_fPdfWrtArea = 0.f; m_fdVC = 0.f; m_fdVCM = 0.f; } else { m_BSDF.init(-raySample.value.dir, m_Intersection, scene); m_fPathPdf = rayOriginPdf * intersectionPdfWrtArea; m_fPdfWrtArea = intersectionPdfWrtArea; m_fdVCM = mis(pathCount / m_fPdfWrtArea); m_fdVC = mis(pathCount * rayOriginToIncidentDirJacobian / m_fPathPdf); } }
inline Vec3f connectVertices( const BDPTPathVertex& eyeVertex, const EmissionVertex& lightVertex, const Scene& scene, size_t pathCount, // The number of paths sampled for the strategy s = 1, t = eyeVertex.m_nDepth + 1 MisFunctor&& mis) { if(!lightVertex.m_pLight || !lightVertex.m_fLightPdf) { return zero<Vec3f>(); } float sampledPointPdfWrtArea, sampledPointToIncidentDirectionJacobian, revPdfWrtArea; RaySample shadowRay; auto Le = lightVertex.m_pLight->sampleDirectIllumination(scene, lightVertex.m_PositionSample, eyeVertex.m_Intersection, shadowRay, sampledPointToIncidentDirectionJacobian, sampledPointPdfWrtArea, revPdfWrtArea); if(Le == zero<Vec3f>() || shadowRay.pdf == 0.f) { return zero<Vec3f>(); } shadowRay.pdf *= lightVertex.m_fLightPdf; sampledPointPdfWrtArea *= lightVertex.m_fLightPdf; Le /= shadowRay.pdf; float cosAtEyeVertex; float eyeDirPdf, eyeRevPdf; auto fr = eyeVertex.m_BSDF.eval(shadowRay.value.dir, cosAtEyeVertex, &eyeDirPdf, &eyeRevPdf); if(fr == zero<Vec3f>() || scene.occluded(shadowRay.value)) { return zero<Vec3f>(); } auto contrib = eyeVertex.m_Power * Le * fr * abs(cosAtEyeVertex); auto rcpWeight = 1.f; { // Evaluate the pdf of sampling the light vertex by sampling the brdf of the eye vertex auto pdfWrtArea = eyeDirPdf * sampledPointToIncidentDirectionJacobian; rcpWeight += mis(pdfWrtArea / (pathCount * sampledPointPdfWrtArea)); } rcpWeight += mis(revPdfWrtArea / pathCount) * (eyeVertex.m_fdVCM + mis(eyeRevPdf) * eyeVertex.m_fdVC); auto weight = 1.f / rcpWeight; return weight * contrib; }
void MissileBoss::Update() { static const float MOVE_SPEED = 100.0f; if (m_moving) { juzutil::Vector3 dir = (MISSILEBOSS_DEST_ORIGIN - m_origin); dir.Normalize(); m_origin += dir * (MOVE_SPEED * GAME.GetFrameTime()); m_moving = !m_origin.Equals(MISSILEBOSS_DEST_ORIGIN, MISSILEBOSS_DEST_EPSILON); if (!m_moving) { m_phrase.Reset(GAME.GetPhrase(PhraseBook::PL_MEDIUM)); m_nextMissileFireTime = GAME.GetTime(); } } else { if (m_nextMissileFireTime <= GAME.GetTime()) { MissilePtr mis(new Missile(GAME.GetPhrase(PhraseBook::PL_SINGLE), m_origin)); GAME.AddEntity(mis); if (++m_currentWaveMissilesFired >= MISSILEBOSS_WAVE_MISSILE_COUNT) { m_nextMissileFireTime = GAME.GetTime() + MISSILEBOSS_WAVE_GAP; m_currentWaveMissilesFired = 0; } else { m_nextMissileFireTime = GAME.GetTime() + MISSILEBOSS_MISSILE_GAP; } } } }
void About::OnButtonTest(wxCommandEvent &event) { wxString InputName = ((wxTextCtrl *)FindWindow(ID_ABOUT_TESTNAME))->GetValue(); if (1|(InputName == wxT("Lucy"))) { // wxMessageBox(wxT("隐藏的功能被启动."), wxT("老邪淫_死呃")); HiddenFunc hf(m_parent); hf.ShowModal(); } else { DWORD dwAscii = 0; for(size_t ix = 0;ix != InputName.Len(); ++ix) { dwAscii += (DWORD)InputName.GetChar(ix); } dwAscii %= 40; wxMemoryInputStream mis(pimages[dwAscii].pimage, pimages[dwAscii].dwSize); wxImage image; image.LoadFile(mis); wxRect rect = FindWindow(ID_ABOUT_WHORU)->GetRect(); wxPoint point(rect.GetRight() - 150, rect.GetTop() + 15); if (TestResultImage) { TestResultImage->Destroy(); TestResultImage = NULL; } TestResultImage = new wxStaticBitmap(this, ID_ABOUT_TESTRESULT, wxBitmap(image), point, wxSize(image.GetWidth(), image.GetHeight())); // TestResultImage->Refresh(); } }
void PakFileDialog::update_preview( const wxString& loc ) { if( !she::is_image_ext(she::file_ext(loc)) ) { m_preview->SetBitmap(wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(64, 64))); m_infolabel->SetLabel(wxT("")); return; } char *buf; size_t size; if( !PakManager::load_from_location( &buf, loc, &size ) ) { wxLogError(_("Failed reading preview: %s"), loc.c_str()); return; } wxMemoryInputStream mis( buf, size ); wxImage img; if( !img.LoadFile(mis, she::bitmap_type_by_ext(she::file_ext(loc))) ) { wxLogError(_("Failed loading image: %s"), loc.c_str()); delete [] buf; return; } img.Rescale(64, 64); m_preview->SetBitmap(wxBitmap(img)); delete [] buf; }
Vector3 BidirPathTracing::generateCameraSample(const int pathIndex , BidirPathState& cameraState) { Camera& camera = scene.camera; int y = pathIndex % width; int x = pathIndex / width; Vector3 jitter = rng.randVector3(); Vector3 sample = Vector3((Real)x + jitter.x , (Real)y + jitter.y , 0.f); Ray ray = camera.generateRay(sample.x , sample.y); Real cosAtCamera = camera.forward ^ ray.dir; Real imagePointToCameraDist = camera.imagePlaneDist / cosAtCamera; Real imageToSolidAngleFactor = SQR(imagePointToCameraDist) / cosAtCamera; Real cameraPdf = imageToSolidAngleFactor; cameraState.origin = ray.origin; cameraState.dir = ray.dir; cameraState.pathLength = 1; cameraState.specularPath = 1; cameraState.specularVertexNum = 0; cameraState.throughput = Color3(1); cameraState.dVCM = mis(lightPathNum / cameraPdf); cameraState.dVC = 0.f; return sample; }
bool BidirPathTracing::sampleScattering(BSDF& bsdf , const Vector3& hitPos , BidirPathState& pathState) { Real bsdfDirPdf , cosWo; int sampledBSDFType; Color3 bsdfFactor = bsdf.sample(scene , rng.randVector3() , pathState.dir , bsdfDirPdf , cosWo , &sampledBSDFType); if (bsdfFactor.isBlack()) return 0; Real bsdfRevPdf = bsdfDirPdf; if ((sampledBSDFType & BSDF_SPECULAR) == 0) bsdfRevPdf = bsdf.pdf(scene , pathState.dir , 1); Real contProb = bsdf.continueProb; if (rng.randFloat() > contProb) return 0; bsdfDirPdf *= contProb; bsdfRevPdf *= contProb; // Partial sub-path MIS quantities // the evaluation is completed when the actual hit point is known! // i.e. after tracing the ray, out of the procedure if (sampledBSDFType & BSDF_SPECULAR) { pathState.specularVertexNum++; pathState.dVCM = 0.f; pathState.dVC *= mis(cosWo); } else { pathState.specularPath &= 0; pathState.dVC = mis(1.f / bsdfDirPdf) * (pathState.dVCM + pathState.dVC * mis(bsdfRevPdf)); pathState.dVCM = mis(1.f / bsdfDirPdf); } pathState.origin = hitPos; pathState.throughput = (pathState.throughput | bsdfFactor) * (cosWo / bsdfDirPdf); return 1; }
std::string Binary::toString() const { std::ostringstream oss; Base64Encoder encoder(oss); MemoryInputStream mis((const char*) _buffer.begin(), _buffer.size()); StreamCopier::copyStream(mis, encoder); return oss.str(); }
void BidirPathTracing::generateLightSample(BidirPathState& lightState) { int lightNum = scene.lights.size(); Real lightPickProb = 1.f / lightNum; int lightId = (int)(rng.randFloat() * lightNum); AbstractLight *light = scene.lights[lightId]; Real emissionPdf , directPdf , cosAtLight; Color3 radiance; for (;;) { radiance = light->emit(scene.sceneSphere , rng.randVector3() , rng.randVector3() , lightState.origin , lightState.dir , emissionPdf , &directPdf , &cosAtLight); if (emissionPdf > 1e-7f) break; } lightState.throughput = radiance; emissionPdf *= lightPickProb; directPdf *= lightPickProb; lightState.throughput = lightState.throughput / emissionPdf; lightState.pathLength = 1; lightState.isFiniteLight = light->isFinite(); lightState.specularPath = 1; lightState.specularVertexNum = 0; lightState.throughput = lightState.throughput; lightState.dVCM = mis(directPdf / emissionPdf); if (!light->isDelta()) { lightState.dVC = mis(1.f / emissionPdf); } else { lightState.dVC = 0.f; } }
wxByte* BCRYPT::Deflate(wxByte* buffer, wxUint32 sizeCompressed, wxUint32 sizeDecompressed) { wxByte* out = new wxByte[sizeDecompressed]; wxMemoryInputStream mis(buffer, sizeCompressed); wxZlibInputStream* zis = new wxZlibInputStream(mis); zis->Read(out, sizeDecompressed); wxDELETE(zis); return out; }
void POP3ClientSession::retrieveMessage(int id, std::ostream& ostr) { std::string response; sendCommand("RETR", NumberFormatter::format(id), response); if (!isPositive(response)) throw POP3Exception("Cannot get message list", response); DialogInputStream sis(_socket); MailInputStream mis(sis); StreamCopier::copyStream(mis, ostr); }
inline Vec3f computeEmittedRadiance( const BDPTPathVertex& eyeVertex, const Scene& scene, const PowerBasedLightSampler& lightSampler, size_t pathCount, // The number of paths sampled for the strategy s = 0, t = eyeVertex.m_nDepth + 1 MisFunctor&& mis) { if(eyeVertex.m_Intersection.Le == zero<Vec3f>()) { return zero<Vec3f>(); } auto contrib = eyeVertex.m_Power * eyeVertex.m_Intersection.Le; // Compute MIS weight auto rcpWeight = 1.f; if(eyeVertex.m_nDepth > 1u) { // Quick fix since we dont connect emission vertex with sensor vertex if(!eyeVertex.m_Intersection) { // Hit on environment map (if present) should be handled here float pointPdfWrtArea, directionPdfWrtSolidAngle; lightSampler.computeEnvironmentLightsPdf(scene, -eyeVertex.m_BSDF.getIncidentDirection(), pointPdfWrtArea, directionPdfWrtSolidAngle); rcpWeight += mis(pointPdfWrtArea / pathCount) * (eyeVertex.m_fdVCM + mis(directionPdfWrtSolidAngle) * eyeVertex.m_fdVC); } else { auto meshID = eyeVertex.m_Intersection.meshID; auto lightID = scene.getGeometry().getMesh(meshID).m_nLightID; const auto& pLight = scene.getLightContainer().getLight(lightID); const auto* pAreaLight = static_cast<const AreaLight*>(pLight.get()); // Evaluate the pdf of sampling the ray (eyeVertex.m_Intersection, eyeVertex.m_BSDF.getIncidentDirection()) on the area light: float pointPdfWrtArea, directionPdfWrtSolidAngle; pAreaLight->pdf(eyeVertex.m_Intersection, eyeVertex.m_BSDF.getIncidentDirection(), scene, pointPdfWrtArea, directionPdfWrtSolidAngle); pointPdfWrtArea *= lightSampler.pdf(lightID); // Scale by the pdf of chosing the area light rcpWeight += mis(pointPdfWrtArea / pathCount) * (eyeVertex.m_fdVCM + mis(directionPdfWrtSolidAngle) * eyeVertex.m_fdVC); } } auto weight = 1.f / rcpWeight; return weight * contrib; }
AudioWindowButton::AudioWindowButton() : Button("AudioWindowButton") { setClickingTogglesState(true); MemoryInputStream mis(BinaryData::silkscreenserialized, BinaryData::silkscreenserializedSize, false); Typeface::Ptr typeface = new CustomTypeface(mis); font = Font(typeface); font.setHeight(12); }
void POP3ClientSession::retrieveMessage(int id, MailMessage& message, PartHandler& handler) { std::string response; sendCommand("RETR", NumberFormatter::format(id), response); if (!isPositive(response)) throw POP3Exception("Cannot get message list", response); DialogInputStream sis(_socket); MailInputStream mis(sis); message.read(mis, handler); while (mis.good()) mis.get(); // read any remaining junk }
inline Vec3f connectVertices( const BDPTPathVertex& eyeVertex, const BDPTPathVertex& lightVertex, const Scene& scene, size_t pathCount, // The number of paths sampled for the strategy s = lightVertex.m_nDepth + 1, t = eyeVertex.m_nDepth + 1 MisFunctor&& mis) { Vec3f incidentDirection; float dist; auto G = geometricFactor(eyeVertex.m_Intersection, lightVertex.m_Intersection, incidentDirection, dist); if(dist == 0.f) { return zero<Vec3f>(); } Ray incidentRay(eyeVertex.m_Intersection, lightVertex.m_Intersection, incidentDirection, dist); float cosAtLightVertex, cosAtEyeVertex; float lightDirPdf, lightRevPdf; float eyeDirPdf, eyeRevPdf; auto M = lightVertex.m_BSDF.eval(-incidentDirection, cosAtLightVertex, &lightDirPdf, &lightRevPdf) * eyeVertex.m_BSDF.eval(incidentDirection, cosAtEyeVertex, &eyeDirPdf, &eyeRevPdf); if(G > 0.f && M != zero<Vec3f>() && !scene.occluded(incidentRay)) { auto rcpWeight = 1.f; { auto pdfWrtArea = eyeDirPdf * abs(cosAtLightVertex) / sqr(dist); rcpWeight += mis(pdfWrtArea / pathCount) * (lightVertex.m_fdVCM + mis(lightRevPdf) * lightVertex.m_fdVC); } { auto pdfWrtArea = lightDirPdf * abs(cosAtEyeVertex) / sqr(dist); rcpWeight += mis(pdfWrtArea / pathCount) * (eyeVertex.m_fdVCM + mis(eyeRevPdf) * eyeVertex.m_fdVC); } auto weight = 1.f / rcpWeight; auto contrib = eyeVertex.m_Power * lightVertex.m_Power * G * M; return weight * contrib; } return zero<Vec3f>(); }
void POP3ClientSession::retrieveHeader(int id, MessageHeader& header) { std::string response; sendCommand("TOP", NumberFormatter::format(id), "0", response); if (!isPositive(response)) throw POP3Exception("Cannot get message list", response); DialogInputStream sis(_socket); MailInputStream mis(sis); header.read(mis); // skip stuff following header mis.get(); // \r mis.get(); // \n }
// {{{ wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size) wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size) { #ifdef BUILTIN_IMAGES const Images::Image *img = Images::GetImage(id); if (img == NULL) { return wxNullBitmap; } wxMemoryInputStream mis(img->image, img->size); wxImage image(mis, wxBITMAP_TYPE_PNG); #elif __WXMAC__ wxString path(wxGetCwd()); path << wxT("/Dubnium.app/Contents/Resources/") << id << wxT(".png"); if (!wxFileExists(path)) { return wxNullBitmap; } wxImage image(path, wxBITMAP_TYPE_PNG); #elif DUBNIUM_DEBUG wxString path(wxT(__FILE__)); path = wxPathOnly(path); path << wxT("/../../images/") << id << wxT(".png"); if (!wxFileExists(path)) { /* This is a debug message only, since for built-in IDs like * wxART_DELETE this will just fall through to the wxWidgets * default provider and isn't an error. */ wxLogDebug(wxT("Requested image ID: %s; NOT FOUND as %s"), id.c_str(), path.c_str()); return wxNullBitmap; } wxLogDebug(wxT("Requested image ID: %s; found as %s"), id.c_str(), path.c_str()); wxImage image(path, wxBITMAP_TYPE_PNG); #else wxString path; path << wxT(PREFIX) << wxT("/share/dubnium/") << id << wxT(".png"); if (!wxFileExists(path)) { return wxNullBitmap; } wxImage image(path, wxBITMAP_TYPE_PNG); #endif /* There seems to be a tendency for wxArtProvider to request images of * size (-1, -1), so we need to avoid trying to rescale for them. */ if (wxSize(image.GetWidth(), image.GetHeight()) != size && size.GetWidth() > 0 && size.GetHeight() > 0) { wxLogDebug(wxT("Requested width: %d; height: %d"), size.GetWidth(), size.GetHeight()); image.Rescale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH); } return wxBitmap(image); }
extern "C" int LLVMFuzzerTestOneInput(const wxUint8 *data, size_t size) { wxLogNull noLog; wxMemoryInputStream mis(data, size); wxZipInputStream zis(mis); while ( wxZipEntry* const ze = zis.GetNextEntry() ) { zis.OpenEntry(*ze); delete ze; } return 0; }
BDPTPathVertex(const Scene& scene, const Sensor& sensor, const Vec2f& lensSample, const Vec2f& imageSample, uint32_t pathCount, MisFunctor&& mis) { RaySample raySample; float rayOriginPdf, rayDirectionPdf, intersectionPdfWrtArea, rayOriginToIncidentDirJacobian; auto We = sensor.sampleExitantRay(scene, lensSample, imageSample, raySample, rayOriginPdf, rayDirectionPdf, m_Intersection, rayOriginToIncidentDirJacobian, intersectionPdfWrtArea); if(We == zero<Vec3f>() || raySample.pdf == 0.f) { m_Power = We; m_fPathPdf = 0.f; m_nDepth = 0u; return; } We /= raySample.pdf; m_Power = We; m_nDepth = 1u; if(!m_Intersection) { m_fPathPdf = raySample.pdf; m_fPdfWrtArea = 0.f; m_fdVC = 0.f; m_fdVCM = 0.f; } else { m_BSDF.init(-raySample.value.dir, m_Intersection, scene); m_fPathPdf = rayOriginPdf * intersectionPdfWrtArea; m_fPdfWrtArea = intersectionPdfWrtArea; m_fdVCM = mis(pathCount / m_fPdfWrtArea); m_fdVC = mis(pathCount * rayOriginToIncidentDirJacobian / m_fPathPdf); } }
DWORD UncompressNSave(LPCTSTR szFileName, BYTE* compr, size_t comprLen) { wxMemoryInputStream mis(compr, comprLen); wxZlibInputStream zis(mis, wxZLIB_ZLIB); wxFile file; if ( file.Create(szFileName, true) == false ) { wxRemoveFile(szFileName); return wxSysErrorCode(); } wxFileOutputStream fos(file); zis.Read(fos); return ERROR_SUCCESS; }
GenericEditor::GenericEditor (GenericProcessor* owner) : AudioProcessorEditor (owner), isSelected(false), desiredWidth(150), tNum(-1), isEnabled(true), accumulator(0.0), isFading(false), drawerButton(0), channelSelector(0) { name = getAudioProcessor()->getName(); nodeId = owner->getNodeId(); MemoryInputStream mis(BinaryData::silkscreenserialized, BinaryData::silkscreenserializedSize, false); Typeface::Ptr typeface = new CustomTypeface(mis); titleFont = Font(typeface); if (!owner->isMerger() && !owner->isSplitter()) { drawerButton = new DrawerButton("name"); drawerButton->addListener(this); addAndMakeVisible(drawerButton); if (!owner->isSink()) { channelSelector = new ChannelSelector(true, titleFont); } else { channelSelector = new ChannelSelector(false, titleFont); } addChildComponent(channelSelector); channelSelector->setVisible(false); } backgroundGradient = ColourGradient(Colour(190, 190, 190), 0.0f, 0.0f, Colour(185, 185, 185), 0.0f, 120.0f, false); backgroundGradient.addColour(0.2f, Colour(155, 155, 155)); addParameterEditors(); backgroundColor = Colour(10,10,10); //fadeIn(); }
bool AlmostEqual(string const & str1, string const & str2, size_t mismatchedCount) { pair<string::const_iterator, string::const_iterator> mis(str1.begin(), str2.begin()); auto const str1End = str1.end(); auto const str2End = str2.end(); for (size_t i = 0; i <= mismatchedCount; ++i) { auto const end = mis.first + min(distance(mis.first, str1End), distance(mis.second, str2End)); mis = mismatch(mis.first, end, mis.second); if (mis.first == str1End && mis.second == str2End) return true; if (mis.first != str1End) ++mis.first; if (mis.second != str2End) ++mis.second; } return false; }
__forceinline Col3f BRDF_sample(const Ref<BackendScene>& scene, Col3f c, DifferentialGeometry dg,const Sample3f wi, float epsilon) { if (wi.pdf <= 0.0f) return zero; Ray r( dg.P, wi.value, dg.error*epsilon, inf ); DifferentialGeometry diff; scene->accel->intersect( r, diff ); scene->postIntersect( r, diff ); Col3f radiance = Col3f( 0.0f,0.0f,0.0f ); float pdflight = 0.0f; if ( diff.light ) { radiance = diff.light->Le(diff, -wi.value ); pdflight = diff.light->pdf( dg, wi ); } float weight = mis(wi.pdf, pdflight); if ( dot( diff.Ng, -r.dir ) > 0 ) return radiance * c * weight / wi.pdf; }
TEST(AliasClass, SpecializedUnions) { IRUnit unit{test_context}; auto const marker = BCMarker::Dummy(); auto const FP = unit.gen(DefFP, marker)->dst(); AliasClass const stk = AStack { FP, -10, 3 }; AliasClass const unrelated_stk = AStack { FP, -14, 1 }; AliasClass const related_stk = AStack { FP, -11, 2 }; auto const stk_and_frame = stk | AFrameAny; EXPECT_TRUE(!stk_and_frame.is_stack()); EXPECT_TRUE(AFrameAny <= stk_and_frame); EXPECT_TRUE(stk <= stk_and_frame); EXPECT_TRUE(AStackAny.maybe(stk_and_frame)); EXPECT_TRUE(AFrameAny.maybe(stk_and_frame)); EXPECT_FALSE(unrelated_stk <= stk_and_frame); EXPECT_FALSE(stk_and_frame.maybe(unrelated_stk)); auto const stk_and_prop = stk | APropAny; EXPECT_TRUE(stk_and_prop.maybe(stk_and_frame)); EXPECT_TRUE(stk_and_frame.maybe(stk_and_prop)); EXPECT_FALSE(stk_and_prop <= stk_and_frame); EXPECT_FALSE(stk_and_frame <= stk_and_prop); EXPECT_TRUE(APropAny.maybe(stk_and_prop)); EXPECT_TRUE(AStackAny.maybe(stk_and_prop)); auto const unrelated_stk_and_prop = unrelated_stk | APropAny; EXPECT_FALSE(stk_and_frame.maybe(unrelated_stk_and_prop)); EXPECT_FALSE(unrelated_stk_and_prop.maybe(stk_and_frame)); EXPECT_TRUE(unrelated_stk_and_prop.maybe(stk_and_prop)); // because of prop EXPECT_FALSE(unrelated_stk_and_prop <= stk_and_prop); EXPECT_FALSE(stk_and_prop <= unrelated_stk_and_prop); EXPECT_FALSE(unrelated_stk_and_prop <= stk_and_frame); EXPECT_FALSE(stk_and_frame <= unrelated_stk_and_prop); EXPECT_FALSE(stk_and_prop <= AHeapAny); EXPECT_TRUE(stk_and_prop.maybe(AHeapAny)); EXPECT_FALSE(stk_and_frame <= AHeapAny); EXPECT_FALSE(stk_and_frame.maybe(AHeapAny)); auto const rel_stk_and_frame = related_stk | AFrameAny; EXPECT_TRUE(stk_and_frame.maybe(rel_stk_and_frame)); EXPECT_TRUE(rel_stk_and_frame.maybe(stk_and_frame)); EXPECT_TRUE(related_stk <= stk); EXPECT_TRUE(rel_stk_and_frame <= stk_and_frame); EXPECT_FALSE(stk_and_frame <= rel_stk_and_frame); EXPECT_TRUE(rel_stk_and_frame.maybe(stk_and_prop)); EXPECT_TRUE(stk_and_prop.maybe(rel_stk_and_frame)); EXPECT_FALSE(rel_stk_and_frame <= stk_and_prop); auto const some_mis = AMIStateTvRef; { auto const some_heap = AElemIAny; auto const u1 = some_heap | some_mis; auto const u2 = AFrameAny | u1; EXPECT_TRUE((AHeapAny | some_heap) == AHeapAny); EXPECT_TRUE(AHeapAny <= (AHeapAny | u1)); EXPECT_TRUE(AHeapAny <= (AHeapAny | u2)); } auto const mis_stk = some_mis | stk; auto const mis_stk_any = AStackAny | mis_stk; EXPECT_EQ(some_mis, AliasClass{*mis_stk_any.mis()}); EXPECT_NE(mis_stk_any, AStackAny | AMIStateAny); auto const other_mis = AMIStateBase; EXPECT_LE(some_mis, some_mis | other_mis); EXPECT_LE(other_mis, some_mis | other_mis); EXPECT_NE(some_mis, some_mis | other_mis); EXPECT_NE(other_mis, some_mis | other_mis); }
MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size ) : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ) , m_bmpSmileXpm(smile_xpm) , m_iconSmileXpm(smile_xpm) { my_horse_ani = NULL; m_ani_images = 0 ; SetBackgroundColour(* wxWHITE); wxBitmap bitmap( 100, 100 ); wxMemoryDC dc; dc.SelectObject( bitmap ); dc.SetBrush( wxBrush( wxT("orange"), wxSOLID ) ); dc.SetPen( *wxBLACK_PEN ); dc.DrawRectangle( 0, 0, 100, 100 ); dc.SetBrush( *wxWHITE_BRUSH ); dc.DrawRectangle( 20, 20, 60, 60 ); dc.SelectObject( wxNullBitmap ); // try to find the directory with our images wxString dir; if ( wxFile::Exists(wxT("./horse.png")) ) dir = wxT("./"); else if ( wxFile::Exists(wxT("../horse.png")) ) dir = wxT("../"); else wxLogWarning(wxT("Can't find image files in either '.' or '..'!")); wxImage image = bitmap.ConvertToImage(); #if wxUSE_LIBPNG if ( !image.SaveFile( dir + wxT("test.png"), wxBITMAP_TYPE_PNG )) { wxLogError(wxT("Can't save file")); } image.Destroy(); if ( image.LoadFile( dir + wxT("test.png") ) ) my_square = wxBitmap( image ); image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.png")) ) { wxLogError(wxT("Can't load PNG image")); } else { my_horse_png = wxBitmap( image ); } if ( !image.LoadFile( dir + wxT("toucan.png")) ) { wxLogError(wxT("Can't load PNG image")); } else { my_toucan = wxBitmap(image); } my_toucan_flipped_horiz = wxBitmap(image.Mirror(true)); my_toucan_flipped_vert = wxBitmap(image.Mirror(false)); my_toucan_flipped_both = wxBitmap(image.Mirror(true).Mirror(false)); my_toucan_grey = wxBitmap(image.ConvertToGreyscale()); my_toucan_head = wxBitmap(image.GetSubImage(wxRect(40, 7, 80, 60))); my_toucan_scaled_normal = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_NORMAL)); my_toucan_scaled_high = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_HIGH)); my_toucan_blur = wxBitmap(image.Blur(10)); #endif // wxUSE_LIBPNG #if wxUSE_LIBJPEG image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.jpg")) ) { wxLogError(wxT("Can't load JPG image")); } else { my_horse_jpeg = wxBitmap( image ); // Colorize by rotating green hue to red wxImage::HSVValue greenHSV = wxImage::RGBtoHSV(wxImage::RGBValue(0, 255, 0)); wxImage::HSVValue redHSV = wxImage::RGBtoHSV(wxImage::RGBValue(255, 0, 0)); image.RotateHue(redHSV.hue - greenHSV.hue); colorized_horse_jpeg = wxBitmap( image ); } if ( !image.LoadFile( dir + wxT("cmyk.jpg")) ) { wxLogError(wxT("Can't load CMYK JPG image")); } else { my_cmyk_jpeg = wxBitmap(image); } #endif // wxUSE_LIBJPEG #if wxUSE_GIF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.gif" )) ) { wxLogError(wxT("Can't load GIF image")); } else { my_horse_gif = wxBitmap( image ); } #endif #if wxUSE_PCX image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.pcx"), wxBITMAP_TYPE_PCX ) ) { wxLogError(wxT("Can't load PCX image")); } else { my_horse_pcx = wxBitmap( image ); } #endif image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.bmp"), wxBITMAP_TYPE_BMP ) ) { wxLogError(wxT("Can't load BMP image")); } else { my_horse_bmp = wxBitmap( image ); } #if wxUSE_XPM image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.xpm"), wxBITMAP_TYPE_XPM ) ) { wxLogError(wxT("Can't load XPM image")); } else { my_horse_xpm = wxBitmap( image ); } if ( !image.SaveFile( dir + wxT("test.xpm"), wxBITMAP_TYPE_XPM )) { wxLogError(wxT("Can't save file")); } #endif #if wxUSE_PNM image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_pnm = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse_ag.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_asciigrey_pnm = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse_rg.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_rawgrey_pnm = wxBitmap( image ); } #endif #if wxUSE_LIBTIFF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.tif"), wxBITMAP_TYPE_TIF ) ) { wxLogError(wxT("Can't load TIFF image")); } else { my_horse_tiff = wxBitmap( image ); } #endif #if wxUSE_LIBTIFF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.tga"), wxBITMAP_TYPE_TGA ) ) { wxLogError(wxT("Can't load TGA image")); } else { my_horse_tga = wxBitmap( image ); } #endif CreateAntiAliasedBitmap(); my_smile_xbm = wxBitmap( (const char*)smile_bits, smile_width, smile_height, 1 ); // demonstrates XPM automatically using the mask when saving if ( m_bmpSmileXpm.Ok() ) m_bmpSmileXpm.SaveFile(wxT("saved.xpm"), wxBITMAP_TYPE_XPM); #if wxUSE_ICO_CUR image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 0 ) ) { wxLogError(wxT("Can't load first ICO image")); } else { my_horse_ico32 = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 1 ) ) { wxLogError(wxT("Can't load second ICO image")); } else { my_horse_ico16 = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico") ) ) { wxLogError(wxT("Can't load best ICO image")); } else { my_horse_ico = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.cur"), wxBITMAP_TYPE_CUR ) ) { wxLogError(wxT("Can't load best ICO image")); } else { my_horse_cur = wxBitmap( image ); xH = 30 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X) ; yH = 2420 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y) ; } m_ani_images = wxImage::GetImageCount ( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI ); if (m_ani_images==0) { wxLogError(wxT("No ANI-format images found")); } else { my_horse_ani = new wxBitmap [m_ani_images]; } int i; for (i=0; i < m_ani_images; i++) { image.Destroy(); if (!image.LoadFile( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI, i )) { wxString tmp = wxT("Can't load image number "); tmp << i ; wxLogError(tmp); } else my_horse_ani [i] = wxBitmap( image ); } #endif // wxUSE_ICO_CUR image.Destroy(); // test image loading from stream wxFile file(dir + wxT("horse.bmp")); if ( file.IsOpened() ) { wxFileOffset len = file.Length(); size_t dataSize = (size_t)len; void *data = malloc(dataSize); if ( file.Read(data, dataSize) != len ) { wxLogError(wxT("Reading bitmap file failed")); } else { wxMemoryInputStream mis(data, dataSize); if ( !image.LoadFile(mis) ) { wxLogError(wxT("Can't load BMP image from stream")); } else { my_horse_bmp2 = wxBitmap( image ); } } free(data); } }
About::About(wxNotebook *notebook, long ID, MyFrame *parent) : wxPanel(notebook, ID, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN | wxTAB_TRAVERSAL) { m_sQuesNum = sizeof(DamnQuestions) / sizeof(QUESTION); m_parent = parent; TestResultImage = NULL; m_bShowTestBox = false; grid = new wxGridSizer(1, 2, 0, 0); LSizer = new wxBoxSizer(wxVERTICAL); RSizer = new wxBoxSizer(wxVERTICAL); boxLeftSizer = new wxBoxSizer(wxVERTICAL); boxRightSizer = new wxBoxSizer(wxVERTICAL); title.Printf(wxT("改之理·集成修改器")); thank.Printf(wxT(" 话说改之理也出了这么多版,有必要感谢一下所有为这个修") wxT("改器做过贡献的人了,感谢为我修改器测试的fish·改、邪神怀") wxT("斯曼、BUG报告员、climb_it、ICE等等,感谢提供技术支持的博") wxT("士、邪恶正太、KawashimaAmi、lv_a等,感谢广告的和美姐和爱保长翻页2、") wxT("忆菱芷菡、绝·漆黑の牙等,感谢做图的小猫(赶紧自爆!),少了谁么?") wxT("赶紧告诉我吧。")); wxStaticText *thanktitle = new wxStaticText(this, ID_ABOUT_THANKTITLE, title, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER); wxStaticText *thanktext = new wxStaticText(this, ID_ABOUT_THANKTEXT, thank, wxDefaultPosition, wxSize(330, 90), wxALIGN_LEFT); wxFont titlefont( 20, // font size wxMODERN, // font family wxNORMAL, // style wxNORMAL, // weight false, // underline wxT("宋体"), // face name wxFONTENCODING_SYSTEM); thanktitle->SetFont(titlefont); RSizer->Add(thanktitle, 0, wxTOP|wxALIGN_CENTRE_HORIZONTAL, 15); RSizer->Add(thanktext, 0, wxALL|wxALIGN_CENTRE_HORIZONTAL, 20); wxImage::AddHandler(new wxJPEGHandler); wxImage image; wxMemoryInputStream mis(_IMG_About_jpg, sizeof(_IMG_About_jpg)); image.LoadFile(mis, wxBITMAP_TYPE_JPEG); wxStaticBitmap *about_img = new wxStaticBitmap(this, ID_ABOUT_IMAGE, wxBitmap(image), wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER); about_img->Connect(ID_ABOUT_IMAGE, wxEVT_LEFT_UP, wxMouseEventHandler(About::OnImageLeftDown), NULL, this); about_img->Connect(ID_ABOUT_IMAGE, wxEVT_RIGHT_UP, wxMouseEventHandler(About::OnImageLeftDown), NULL, this); LSizer->Add(about_img, 0, wxLEFT|wxTOP, 5); grid->Add(LSizer); grid->Add(RSizer); SetSizer(grid); }