From e73d458c32685ab5f4a5bccd327adbd4a451af8c Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 29 Apr 2011 14:46:20 +0200 Subject: [PATCH 01/10] fixed a few warnings on win32 --- src/bsdfs/composite.cpp | 2 +- src/converter/collada.cpp | 12 ++++++------ src/films/pngfilm.cpp | 4 ++-- src/libcore/properties.cpp | 4 ++-- src/libcore/wavelet.cpp | 4 ++-- src/libhw/glrenderer.cpp | 16 ++++++++-------- src/tests/test_quad.cpp | 10 ++++------ src/utils/kdbench.cpp | 6 +++--- src/utils/tonemap.cpp | 4 ++-- src/volume/volcache.cpp | 6 +++--- 10 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/bsdfs/composite.cpp b/src/bsdfs/composite.cpp index c89625ff..ce3a00a5 100644 --- a/src/bsdfs/composite.cpp +++ b/src/bsdfs/composite.cpp @@ -40,7 +40,7 @@ public: Float totalWeight = 0; char *end_ptr = NULL; for (size_t i=0; igetFloat_array()->getValue(); SAssert(stride == 1); for (size_t i=0; isetTime(i, floatArray[i]); + track->setTime(i, (Float) floatArray[i]); } else if (semantic == "OUTPUT") { domListOfFloats &floatArray = source->getFloat_array()->getValue(); if (trackType == VectorTrack::ETranslationXYZ || trackType == VectorTrack::EScaleXYZ) { SAssert(stride == 3); for (size_t i=0; isetValue(i, - Vector(floatArray[i*3+0], floatArray[i*3+1], - floatArray[i*3+2])); + Vector((Float) floatArray[i*3+0], (Float) floatArray[i*3+1], + (Float) floatArray[i*3+2])); } else { SAssert(stride == 1); for (size_t i=0; isetValue(i, floatArray[i]); + ((FloatTrack *) track)->setValue(i, (Float) floatArray[i]); } } else if (semantic == "INTERPOLATION") { /// Ignored for now @@ -1537,8 +1537,8 @@ GLvoid __stdcall tessCombine(GLdouble coords[3], void *vertex_data[4], // this will be very slow -- let's hope that it happens rarely Vec4 *oldVec = tess_vdata->data[offset]; - Vec4 *newVec = new Vec4[size+1]; - memcpy(newVec, oldVec, size * sizeof(Vec4)); + Vec4 *newVec = new Vec4[(size_t) size + 1]; + memcpy(newVec, oldVec, (size_t) size * sizeof(Vec4)); newVec[size] = Vec4(0.0f); for (int j=0; j<4; ++j) { diff --git a/src/films/pngfilm.cpp b/src/films/pngfilm.cpp index 23c5e898..3711f2cb 100644 --- a/src/films/pngfilm.cpp +++ b/src/films/pngfilm.cpp @@ -261,7 +261,7 @@ public: Float Lp = Y * reinhardKey; Y = Lp * (1.0f + Lp*invWpSqr) / (1.0f + Lp); X = x * (Y/y); - Z = (Y/y) * (1.0 - x - y); + Z = (Y/y) * (1.0f - x - y); spec.fromXYZ(X, Y, Z); } @@ -310,7 +310,7 @@ public: Float Lp = Y * reinhardKey; Y = Lp * (1.0f + Lp*invWpSqr) / (1.0f + Lp); X = x * (Y/y); - Z = (Y/y) * (1.0 - x - y); + Z = (Y/y) * (1.0f - x - y); spec.fromXYZ(X, Y, Z); } diff --git a/src/libcore/properties.cpp b/src/libcore/properties.cpp index a1c25648..f702b935 100644 --- a/src/libcore/properties.cpp +++ b/src/libcore/properties.cpp @@ -137,7 +137,7 @@ size_t Properties::getSize(const std::string &name) const { if ((*it).second.v_long < 0) SLog(EError, "Size property \"%s\": expected a nonnegative value!"); (*it).second.queried = true; - return (*it).second.v_long; + return (size_t) (*it).second.v_long; } size_t Properties::getSize(const std::string &name, size_t defVal) const { @@ -149,7 +149,7 @@ size_t Properties::getSize(const std::string &name, size_t defVal) const { if ((*it).second.v_long < 0) SLog(EError, "Size property \"%s\": expected a nonnegative value!"); (*it).second.queried = true; - return (*it).second.v_long; + return (size_t) (*it).second.v_long; } diff --git a/src/libcore/wavelet.cpp b/src/libcore/wavelet.cpp index 971b953e..40f9fa8e 100644 --- a/src/libcore/wavelet.cpp +++ b/src/libcore/wavelet.cpp @@ -343,7 +343,7 @@ SparseWavelet2D::SparseWavelet2D(Stream *stream, InstanceManager *Manager) { m_data.set_empty_key(0xFFFFFFFFFFFFFFFFULL); #endif for (size_t i=0; ireadSize(); + uint64_t key = stream->readULong(); m_data[key] = stream->readSingle(); } m_maxLevel = log2i(m_size)-1; @@ -382,7 +382,7 @@ void SparseWavelet2D::serialize(Stream *stream, InstanceManager *Manager) const stream->writeSize(m_data.size()); for (CoefficientIterator it = m_data.begin(); it != m_data.end(); ++it) { - stream->writeSize((*it).first); + stream->writeULong((*it).first); stream->writeSingle((*it).second); } } diff --git a/src/libhw/glrenderer.cpp b/src/libhw/glrenderer.cpp index 00b15d14..12b9b843 100644 --- a/src/libhw/glrenderer.cpp +++ b/src/libhw/glrenderer.cpp @@ -654,13 +654,13 @@ void GLRenderer::blitTexture(const GPUTexture *tex, bool flipVertically, const float zDepth = -1.0f; // just before the far plane glTexCoord2f(0.0f, 0.0f); - glVertex3f(upperLeft.x, upperLeft.y, zDepth); + glVertex3f((float) upperLeft.x, (float) upperLeft.y, zDepth); glTexCoord2f(1.0f, 0.0f); - glVertex3f(lowerRight.x, upperLeft.y, zDepth); + glVertex3f((float) lowerRight.x, (float) upperLeft.y, zDepth); glTexCoord2f(1.0f, 1.0f); - glVertex3f(lowerRight.x, lowerRight.y, zDepth); + glVertex3f((float) lowerRight.x, (float) lowerRight.y, zDepth); glTexCoord2f(0.0f, 1.0f); - glVertex3f(upperLeft.x, lowerRight.y, zDepth); + glVertex3f((float) upperLeft.x, (float) lowerRight.y, zDepth); glEnd(); } else if (tex->getType() == GPUTexture::ETextureCubeMap) { glMatrixMode(GL_PROJECTION); @@ -737,7 +737,7 @@ void GLRenderer::blitTexture(const GPUTexture *tex, bool flipVertically, void GLRenderer::blitQuad(bool flipVertically) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); - Vector2 scrSize(viewport[2], viewport[3]); + Vector2 scrSize((float) viewport[2], (float) viewport[3]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, scrSize.x, scrSize.y, 0, -1, 1); @@ -830,11 +830,11 @@ void GLRenderer::drawText(const Point2i &_pos, const Font::Glyph &glyph = font->getGlyph(character); - Point2i start = pos + Vector2i( + Point2 start = Point2(pos + Vector2i( glyph.horizontalBearing, font->getMaxVerticalBearing() - glyph.verticalBearing - ); - Point2i end = start + glyph.size; + )); + Point2 end = start + Vector2(glyph.size); Point2 txStart = glyph.tx; Point2 txEnd = txStart + glyph.ts; diff --git a/src/tests/test_quad.cpp b/src/tests/test_quad.cpp index 868b4026..c3b498d0 100644 --- a/src/tests/test_quad.cpp +++ b/src/tests/test_quad.cpp @@ -71,9 +71,8 @@ public: NDIntegrator quad(1, 1, 1024, 0, 1e-5f); Float min = 0, max = 10, result, err; size_t evals; - assertEquals(quad.integrate(boost::bind( - &TestQuadrature::testF2, this, _1, _2), &min, &max, &result, &err, evals), - NDIntegrator::ESuccess); + assertTrue(quad.integrate(boost::bind( + &TestQuadrature::testF2, this, _1, _2), &min, &max, &result, &err, evals) == NDIntegrator::ESuccess); Float ref = 2 * std::pow(std::sin(5.0f), 2.0f); Log(EInfo, "test02_nD_01(): used " SIZE_T_FMT " function evaluations, " "error=%f", evals, err); @@ -84,9 +83,8 @@ public: NDIntegrator quad(2, 3, 1000000, 0, 1e-5f); size_t evals; Float min[3] = { -1, -1, -1 } , max[3] = { 1, 1, 1 }, result[2], err[2]; - assertEquals(quad.integrateVectorized(boost::bind( - &TestQuadrature::testF3, this, _1, _2, _3), min, max, result, err, evals), - NDIntegrator::ESuccess); + assertTrue(quad.integrateVectorized(boost::bind( + &TestQuadrature::testF3, this, _1, _2, _3), min, max, result, err, evals) == NDIntegrator::ESuccess); Log(EInfo, "test02_nD_02(): used " SIZE_T_FMT " function evaluations, " "error=[%f, %f]", evals, err[0], err[1]); assertEqualsEpsilon(result[0], 1, 1e-5f); diff --git a/src/utils/kdbench.cpp b/src/utils/kdbench.cpp index a37d5208..74f20908 100644 --- a/src/utils/kdbench.cpp +++ b/src/utils/kdbench.cpp @@ -84,17 +84,17 @@ public: fitParameters = true; break; case 'i': - intersectionCost = strtod(optarg, &end_ptr); + intersectionCost = (Float) strtod(optarg, &end_ptr); if (*end_ptr != '\0') SLog(EError, "Could not parse the intersection cost!"); break; case 't': - traversalCost = strtod(optarg, &end_ptr); + traversalCost = (Float) strtod(optarg, &end_ptr); if (*end_ptr != '\0') SLog(EError, "Could not parse the traversal cost!"); break; case 'e': - emptySpaceBonus = strtod(optarg, &end_ptr); + emptySpaceBonus = (Float) strtod(optarg, &end_ptr); if (*end_ptr != '\0') SLog(EError, "Could not parse the empty space bonus!"); break; diff --git a/src/utils/tonemap.cpp b/src/utils/tonemap.cpp index 822313f1..d372f657 100644 --- a/src/utils/tonemap.cpp +++ b/src/utils/tonemap.cpp @@ -62,12 +62,12 @@ public: } break; case 'g': - gamma = strtod(optarg, &end_ptr); + gamma = (Float) strtod(optarg, &end_ptr); if (*end_ptr != '\0') SLog(EError, "Could not parse the gamma value!"); break; case 'm': - multiplier = strtod(optarg, &end_ptr); + multiplier = (Float) strtod(optarg, &end_ptr); if (*end_ptr != '\0') SLog(EError, "Could not parse the multiplier!"); break; diff --git a/src/volume/volcache.cpp b/src/volume/volcache.cpp index 68e6150e..c5e2abad 100644 --- a/src/volume/volcache.cpp +++ b/src/volume/volcache.cpp @@ -131,8 +131,8 @@ public: Log(EInfo, " Memory limit per core = %s", memString(memoryLimitPerCore).c_str()); Log(EInfo, " Max. blocks per core = %i", m_blocksPerCore); Log(EInfo, " Effective resolution = %s", totalCells.toString().c_str()); - Log(EInfo, " Effective storage = %s", memString( - totalCells[0]*totalCells[1]*totalCells[2]*sizeof(float)*m_channels).c_str()); + Log(EInfo, " Effective storage = %s", memString((size_t) + (totalCells[0]*totalCells[1]*totalCells[2]*sizeof(float)*m_channels)).c_str()); } Float lookupFloat(const Point &_p) const { @@ -263,7 +263,7 @@ public: for (int z = 0; zlookupFloat(p); result[idx++] = value; nonempty |= (value != 0); From 7ea86fd591ab3c831180c14fc590534cbb3e3b79 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 29 Apr 2011 16:15:33 +0200 Subject: [PATCH 02/10] win32 crash bugfix --- src/integrators/path/ptracer.cpp | 2 +- src/integrators/photonmapper/ppm.cpp | 2 +- src/librender/integrator.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/integrators/path/ptracer.cpp b/src/integrators/path/ptracer.cpp index b0f1b253..5dc4141c 100644 --- a/src/integrators/path/ptracer.cpp +++ b/src/integrators/path/ptracer.cpp @@ -100,7 +100,7 @@ public: const Film *film = camera->getFilm(); size_t sampleCount = scene->getSampler()->getSampleCount(); size_t nCores = scheduler->getCoreCount(); - Log(EInfo, "Starting render job (%ix%i, %lld samples, " SIZE_T_FMT + Log(EInfo, "Starting render job (%ix%i, " SIZE_T_FMT " samples, " SIZE_T_FMT " %s, " SSE_STR ") ..", film->getCropSize().x, film->getCropSize().y, sampleCount, nCores, nCores == 1 ? "core" : "cores"); diff --git a/src/integrators/photonmapper/ppm.cpp b/src/integrators/photonmapper/ppm.cpp index 7479dcce..9d294492 100644 --- a/src/integrators/photonmapper/ppm.cpp +++ b/src/integrators/photonmapper/ppm.cpp @@ -116,7 +116,7 @@ public: Sampler *cameraSampler = (Sampler *) sched->getResource(samplerResID, 0); size_t sampleCount = cameraSampler->getSampleCount(); - Log(EInfo, "Starting render job (%ix%i, %lld %s, " SIZE_T_FMT + Log(EInfo, "Starting render job (%ix%i, " SIZE_T_FMT " %s, " SIZE_T_FMT " %s, " SSE_STR ") ..", film->getCropSize().x, film->getCropSize().y, sampleCount, sampleCount == 1 ? "sample" : "samples", nCores, nCores == 1 ? "core" : "cores"); diff --git a/src/librender/integrator.cpp b/src/librender/integrator.cpp index f806a232..b8ca5a60 100644 --- a/src/librender/integrator.cpp +++ b/src/librender/integrator.cpp @@ -95,7 +95,7 @@ bool SampleIntegrator::render(Scene *scene, const Sampler *sampler = static_cast(sched->getResource(samplerResID, 0)); size_t sampleCount = sampler->getSampleCount(); - Log(EInfo, "Starting render job (%ix%i, %lld %s, " SIZE_T_FMT + Log(EInfo, "Starting render job (%ix%i, " SIZE_T_FMT " %s, " SIZE_T_FMT " %s, " SSE_STR ") ..", film->getCropSize().x, film->getCropSize().y, sampleCount, sampleCount == 1 ? "sample" : "samples", nCores, nCores == 1 ? "core" : "cores"); From 9ef616245d4b87d10e798c574a69d44f8d654835 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 29 Apr 2011 16:25:09 +0200 Subject: [PATCH 03/10] removed more win32 warnings --- src/integrators/photonmapper/ppm.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/integrators/photonmapper/ppm.cpp b/src/integrators/photonmapper/ppm.cpp index 9d294492..72b43d95 100644 --- a/src/integrators/photonmapper/ppm.cpp +++ b/src/integrators/photonmapper/ppm.cpp @@ -189,7 +189,7 @@ public: camera->generateRayDifferential(sample, lensSample, timeSample, eyeRay); size_t offset = gatherPoints.size(); - int count = createGatherPoints(scene, eyeRay, sample, + Float count = (Float) createGatherPoints(scene, eyeRay, sample, cameraSampler, Spectrum(1.0f), gatherPoints, 1); if (count > 1) { // necessary because of filter weight computation @@ -311,8 +311,9 @@ public: continue; } - Float M = photonMap->estimateRadianceRaw( - g.its, g.radius, flux, m_maxDepth == -1 ? INT_MAX : (m_maxDepth-g.depth)), N = g.N; + Float M = (Float) photonMap->estimateRadianceRaw( + g.its, g.radius, flux, m_maxDepth == -1 ? INT_MAX : (m_maxDepth-g.depth)); + Float N = g.N; if (N+M == 0) { g.flux = contrib = Spectrum(0.0f); From 7557927f6975edb527e1dd4f849e8b5515405e94 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2011 17:56:19 +0200 Subject: [PATCH 04/10] removed a few win32 compilation warnings --- include/mitsuba/hw/gputexture.h | 6 +++--- src/integrators/photonmapper/sppm.cpp | 4 ++-- src/libhw/gltexture.cpp | 2 +- src/luminaires/spot.cpp | 8 ++++---- src/shapes/sphere.cpp | 2 +- src/textures/ldrtexture.cpp | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/mitsuba/hw/gputexture.h b/include/mitsuba/hw/gputexture.h index 0026cb31..c1d91f7b 100644 --- a/include/mitsuba/hw/gputexture.h +++ b/include/mitsuba/hw/gputexture.h @@ -214,7 +214,7 @@ public: inline void setSize(const Point3i &size) { m_size = size; } /// Get the maximal anisotropy - inline float getMaxAnisotropy() const { return m_maxAnisotropy; } + inline Float getMaxAnisotropy() const { return m_maxAnisotropy; } /** \brief Set the maximal anisotropy. * @@ -222,7 +222,7 @@ public: * texture filtering. A value of 0 (default) will * use the global max. anisotropy value */ - inline void setMaxAnisotropy(float maxAnisotropy) { m_maxAnisotropy = maxAnisotropy; } + inline void setMaxAnisotropy(Float maxAnisotropy) { m_maxAnisotropy = maxAnisotropy; } /// Return whether mipmapping is enabled inline bool isMipMapped() const { return m_mipmapped; } @@ -363,7 +363,7 @@ protected: EDepthMode m_depthMode; bool m_mipmapped; mutable PrimitiveThreadLocal > m_textureUnits; - float m_maxAnisotropy; + Float m_maxAnisotropy; int m_samples; std::vector m_bitmaps; Point3i m_size; diff --git a/src/integrators/photonmapper/sppm.cpp b/src/integrators/photonmapper/sppm.cpp index f95858e1..8d8c764a 100644 --- a/src/integrators/photonmapper/sppm.cpp +++ b/src/integrators/photonmapper/sppm.cpp @@ -293,7 +293,7 @@ public: Spectrum flux, contrib; if (gp.depth != -1) { - M = photonMap->estimateRadianceRaw( + M = (Float) photonMap->estimateRadianceRaw( gp.its, gp.radius, flux, m_maxDepth-gp.depth); } else { M = 0; @@ -305,7 +305,7 @@ public: } else { Float ratio = (N + m_alpha * M) / (N + M); gp.flux = (gp.flux + gp.weight * (flux + - gp.emission * proc->getShotParticles() * M_PI * gp.radius*gp.radius)) * ratio; + gp.emission * (Float) proc->getShotParticles() * M_PI * gp.radius*gp.radius)) * ratio; gp.radius = gp.radius * std::sqrt(ratio); gp.N = N + m_alpha * M; contrib = gp.flux / ((Float) m_totalEmitted * gp.radius*gp.radius * M_PI); diff --git a/src/libhw/gltexture.cpp b/src/libhw/gltexture.cpp index f1388620..2ae35b61 100644 --- a/src/libhw/gltexture.cpp +++ b/src/libhw/gltexture.cpp @@ -242,7 +242,7 @@ void GLTexture::refresh() { //Assert(m_size.x == m_size.y); /* Anisotropic texture filtering */ - float anisotropy = getMaxAnisotropy(); + float anisotropy = (float) getMaxAnisotropy(); if (anisotropy > 1.0f) { if (isMipMapped() && m_filterType == EMipMapLinear) { /* Only use anisotropy when it makes sense - otherwise some diff --git a/src/luminaires/spot.cpp b/src/luminaires/spot.cpp index 72f49fc7..c27b602a 100644 --- a/src/luminaires/spot.cpp +++ b/src/luminaires/spot.cpp @@ -34,7 +34,7 @@ public: SpotLuminaire(const Properties &props) : Luminaire(props) { m_intensity = props.getSpectrum("intensity", Spectrum(1.0f)); m_cutoffAngle = props.getFloat("cutoffAngle", 20); - m_beamWidth = props.getFloat("beamWidth", m_cutoffAngle * 3.0/4.0); + m_beamWidth = props.getFloat("beamWidth", m_cutoffAngle * 3.0f/4.0f); m_beamWidth = degToRad(m_beamWidth); m_cutoffAngle = degToRad(m_cutoffAngle); Assert(m_cutoffAngle >= m_beamWidth); @@ -57,7 +57,7 @@ public: m_cosCutoffAngle = std::cos(m_cutoffAngle); m_position = m_luminaireToWorld(Point(0, 0, 0)); m_uvFactor = std::tan(m_beamWidth/2); - m_invTransitionWidth = 1.0 / (m_cutoffAngle - m_beamWidth); + m_invTransitionWidth = 1.0f / (m_cutoffAngle - m_beamWidth); } void serialize(Stream *stream, InstanceManager *manager) const { @@ -91,8 +91,8 @@ public: if (m_texture->getClass() != MTS_CLASS(ConstantTexture)) { Intersection its; its.hasUVPartials = false; - its.uv.x = .5+localDir.x / (localDir.z / m_uvFactor); - its.uv.y = .5+localDir.y / (localDir.z / m_uvFactor); + its.uv.x = 0.5f + localDir.x / (localDir.z / m_uvFactor); + its.uv.y = 0.5f + localDir.y / (localDir.z / m_uvFactor); result *= m_texture->getValue(its); } diff --git a/src/shapes/sphere.cpp b/src/shapes/sphere.cpp index 8231e81f..555592f5 100644 --- a/src/shapes/sphere.cpp +++ b/src/shapes/sphere.cpp @@ -141,7 +141,7 @@ public: if (phi < 0) phi += 2*M_PI; - its.uv.x = phi * (0.5 * INV_PI); + its.uv.x = phi * (0.5f * INV_PI); its.uv.y = theta * INV_PI; its.dpdu = m_objectToWorld(Vector(-local.y, local.x, 0) * (2*M_PI)); its.geoFrame.n = normalize(its.p - m_center); diff --git a/src/textures/ldrtexture.cpp b/src/textures/ldrtexture.cpp index fceb9f37..1906023a 100644 --- a/src/textures/ldrtexture.cpp +++ b/src/textures/ldrtexture.cpp @@ -293,7 +293,7 @@ public: m_gpuTexture->setWrapType(GPUTexture::ERepeat); else m_gpuTexture->setWrapType(GPUTexture::EClampToEdge); - m_gpuTexture->setMaxAnisotropy((int) maxAnisotropy); + m_gpuTexture->setMaxAnisotropy(maxAnisotropy); m_gpuTexture->init(); /* Release the memory on the host side */ m_gpuTexture->setBitmap(0, NULL); From b203e2079b3f7f6da251d2a3709974a58034cf17 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2011 12:54:56 -0700 Subject: [PATCH 05/10] removed many win64 compilation warnings --- include/mitsuba/core/brent.h | 4 +-- include/mitsuba/core/random.h | 5 ++- include/mitsuba/core/util.h | 4 +-- src/bsdfs/composite.cpp | 46 ++++++++++++++-------------- src/converter/collada.cpp | 4 +-- src/integrators/photonmapper/bre.h | 8 ++--- src/integrators/photonmapper/ppm.cpp | 3 +- src/libcore/random.cpp | 18 +++++++++++ src/libcore/thread.cpp | 2 +- src/libcore/util.cpp | 14 ++++----- src/libcore/wavelet.cpp | 22 ++++++------- src/libhw/glgeometry.cpp | 4 +-- src/librender/gatherproc.cpp | 4 +-- src/librender/irrcache.cpp | 6 ++-- src/librender/sampler.cpp | 12 ++++---- src/librender/subsurface.cpp | 6 ++-- src/librender/trimesh.cpp | 4 +-- src/qtgui/common.h | 3 +- src/qtgui/mainwindow.cpp | 2 +- src/qtgui/preview.h | 3 +- src/qtgui/programsettingsdlg.h | 2 +- src/samplers/ldsampler.cpp | 4 +-- src/shapes/cylinder.cpp | 4 +-- src/shapes/hair.cpp | 10 +++--- src/shapes/obj.cpp | 2 +- src/shapes/sphere.cpp | 24 +++++++-------- src/subsurface/dipole.cpp | 2 +- src/tests/test_kd.cpp | 2 +- src/textures/exrtexture.cpp | 4 +-- 29 files changed, 126 insertions(+), 102 deletions(-) diff --git a/include/mitsuba/core/brent.h b/include/mitsuba/core/brent.h index 8f01851c..83501eaa 100644 --- a/include/mitsuba/core/brent.h +++ b/include/mitsuba/core/brent.h @@ -38,12 +38,12 @@ public: /// Return value of \ref BrentSolver::solve() struct Result { bool success; - int iterations; + size_t iterations; Float x; Float y; /// Create a new result instance - inline Result(bool success, int iterations, Float x, Float y) + inline Result(bool success, size_t iterations, Float x, Float y) : success(success), iterations(iterations), x(x), y(y) { } /// Return a string representation of the result diff --git a/include/mitsuba/core/random.h b/include/mitsuba/core/random.h index 80434c6a..faeea48a 100644 --- a/include/mitsuba/core/random.h +++ b/include/mitsuba/core/random.h @@ -130,6 +130,9 @@ public: /// Return an integer on the [0, n)-interval uint32_t nextUInt(uint32_t n); + /// Return an integer on the [0, n)-interval + size_t nextSize(size_t n); + /// Return a floating point value on the [0, 1) interval Float nextFloat(); @@ -141,7 +144,7 @@ public: */ template void shuffle(Iterator it1, Iterator it2) { for (Iterator it = it2 - 1; it > it1; --it) - std::iter_swap(it, it1 + nextUInt((uint32_t) (it-it1))); + std::iter_swap(it, it1 + nextSize((size_t) (it-it1))); } /// Serialize a random generator to a binary data stream diff --git a/include/mitsuba/core/util.h b/include/mitsuba/core/util.h index 3d1098cb..9cf5cd93 100644 --- a/include/mitsuba/core/util.h +++ b/include/mitsuba/core/util.h @@ -277,7 +277,7 @@ extern MTS_EXPORT_CORE bool solveQuadratic(Float a, Float b, * in Computer Graphics Proceedings, Annual Conference Series, * SIGGRAPH 97, pp. 49-56. */ -extern MTS_EXPORT_CORE Float radicalInverse(int b, int i); +extern MTS_EXPORT_CORE Float radicalInverse(int b, size_t i); /** * Incrementally calculate the radical inverse function @@ -386,7 +386,7 @@ extern MTS_EXPORT_CORE void stratifiedSample2D(Random *random, Point2 *dest, int countX, int countY, bool jitter); /// Generate latin hypercube samples -extern MTS_EXPORT_CORE void latinHypercube(Random *random, Float *dest, int nSamples, int nDim); +extern MTS_EXPORT_CORE void latinHypercube(Random *random, Float *dest, size_t nSamples, size_t nDim); /// Convert spherical coordinates to a direction extern MTS_EXPORT_CORE Vector sphericalDirection(Float theta, Float phi); diff --git a/src/bsdfs/composite.cpp b/src/bsdfs/composite.cpp index ce3a00a5..763718ec 100644 --- a/src/bsdfs/composite.cpp +++ b/src/bsdfs/composite.cpp @@ -29,7 +29,7 @@ MTS_NAMESPACE_BEGIN class Composite : public BSDF { public: Composite(const Properties &props) - : BSDF(props), m_bsdfCount(0), m_bsdfWeight(NULL) { + : BSDF(props), m_bsdfWeight(NULL) { /* Parse the weight parameter */ std::vector weights = tokenize(props.getString("weights", ""), " ,;"); @@ -54,11 +54,11 @@ public: } Composite(Stream *stream, InstanceManager *manager) - : BSDF(stream, manager), m_bsdfCount(0), m_bsdfWeight(NULL) { - m_bsdfCount = stream->readInt(); + : BSDF(stream, manager), m_bsdfWeight(NULL) { + m_bsdfCount = stream->readSize(); m_bsdfWeight = new Float[m_bsdfCount]; m_bsdfOffset = new int[m_bsdfCount]; - for (int i=0; ireadFloat(); BSDF *bsdf = static_cast(manager->getInstance(stream)); bsdf->incRef(); @@ -81,8 +81,8 @@ public: void serialize(Stream *stream, InstanceManager *manager) const { BSDF::serialize(stream, manager); - stream->writeInt(m_bsdfCount); - for (int i=0; iwriteSize(m_bsdfCount); + for (size_t i=0; iwriteFloat(m_bsdfWeight[i]); manager->serialize(stream, m_bsdfs[i]); } @@ -95,18 +95,18 @@ public: m_usesRayDifferentials = false; m_componentCount = 0; - if ((int) m_bsdfs.size() != m_bsdfCount) - Log(EError, "BSDF count mismatch: %i bsdfs, but specified %i weights", - (int) m_bsdfs.size(), m_bsdfCount); + if (m_bsdfs.size() != m_bsdfCount) + Log(EError, "BSDF count mismatch: " SIZE_T_FMT " bsdfs, but specified " SIZE_T_FMT " weights", + m_bsdfs.size(), m_bsdfCount); int offset = 0; - for (int i=0; igetComponentCount(); m_pdf = DiscretePDF(m_bsdfs.size()); m_type = new unsigned int[m_componentCount]; - for (int i=0; igetComponentCount(); ++j) { @@ -123,7 +123,7 @@ public: Spectrum getDiffuseReflectance(const Intersection &its) const { Spectrum result(0.0f); - for (int i=0; igetDiffuseReflectance(its) * m_bsdfWeight[i]; return result; } @@ -132,11 +132,11 @@ public: Spectrum result(0.0f); if (bRec.component == -1) { - for (int i=0; if(bRec) * m_bsdfWeight[i]; } else { /* Pick out an individual component */ - for (int i=0; i= m_bsdfs[i]->getComponentCount()) continue; @@ -154,11 +154,11 @@ public: Spectrum result(0.0f); if (bRec.component == -1) { - for (int i=0; ifDelta(bRec) * m_bsdfWeight[i]; } else { /* Pick out an individual component */ - for (int i=0; i= m_bsdfs[i]->getComponentCount()) continue; @@ -176,11 +176,11 @@ public: Float result = 0.0f; if (bRec.component == -1) { - for (int i=0; ipdf(bRec) * m_pdf[i]; } else { /* Pick out an individual component */ - for (int i=0; i= m_bsdfs[i]->getComponentCount()) continue; @@ -198,11 +198,11 @@ public: Float result = 0.0f; if (bRec.component == -1) { - for (int i=0; ipdfDelta(bRec) * m_pdf[i]; } else { /* Pick out an individual component */ - for (int i=0; i= m_bsdfs[i]->getComponentCount()) continue; @@ -227,7 +227,7 @@ public: return result * m_bsdfWeight[entry]; } else { /* Pick out an individual component */ - for (int i=0; i= m_bsdfs[i]->getComponentCount()) continue; @@ -255,7 +255,7 @@ public: return result * m_bsdfWeight[entry]; } else { /* Pick out an individual component */ - for (int i=0; i= m_bsdfs[i]->getComponentCount()) continue; @@ -298,7 +298,7 @@ public: MTS_DECLARE_CLASS() private: - int m_bsdfCount; + size_t m_bsdfCount; Float *m_bsdfWeight; int *m_bsdfOffset; std::vector m_bsdfs; diff --git a/src/converter/collada.cpp b/src/converter/collada.cpp index a4491866..95b8b87b 100644 --- a/src/converter/collada.cpp +++ b/src/converter/collada.cpp @@ -175,7 +175,7 @@ VertexData *fetchVertexData(Transform transform, semantic = vertInputs[vertInputIndex]->getSemantic(); if (vertInputIndex > 0) { - offset = result->data.size(); + offset = (int) result->data.size(); result->data.push_back(NULL); } @@ -466,7 +466,7 @@ void writeGeometry(ColladaContext &ctx, const std::string &prefixName, std::stri stream->close(); filename = "meshes/" + filename; } else { - ctx.cvt->m_geometryDict.push_back(ctx.cvt->m_geometryFile->getPos()); + ctx.cvt->m_geometryDict.push_back((uint32_t) ctx.cvt->m_geometryFile->getPos()); mesh->serialize(ctx.cvt->m_geometryFile); filename = ctx.cvt->m_geometryFileName.filename(); } diff --git a/src/integrators/photonmapper/bre.h b/src/integrators/photonmapper/bre.h index c041257a..64def59b 100644 --- a/src/integrators/photonmapper/bre.h +++ b/src/integrators/photonmapper/bre.h @@ -58,10 +58,10 @@ protected: AABB buildHierarchy(size_t index); /// Heap convenience routines - inline size_t leftChild(size_t index) const { return 2*index; } - inline size_t rightChild(size_t index) const { return 2*index + 1; } - inline bool isInnerNode(size_t index) const { return index <= m_lastInnerNode; } - inline bool hasRightChild(size_t index) const { return index <= m_lastRChildNode; } + inline uint32_t leftChild(uint32_t index) const { return 2*index; } + inline uint32_t rightChild(uint32_t index) const { return 2*index + 1; } + inline bool isInnerNode(uint32_t index) const { return index <= m_lastInnerNode; } + inline bool hasRightChild(uint32_t index) const { return index <= m_lastRChildNode; } private: struct BRENode { AABB aabb; diff --git a/src/integrators/photonmapper/ppm.cpp b/src/integrators/photonmapper/ppm.cpp index 72b43d95..74f1d11e 100644 --- a/src/integrators/photonmapper/ppm.cpp +++ b/src/integrators/photonmapper/ppm.cpp @@ -347,7 +347,8 @@ private: ref m_mutex; Float m_initialRadius, m_alpha; int m_photonCount, m_granularity; - int m_maxDepth, m_rrDepth, m_totalEmitted; + int m_maxDepth, m_rrDepth; + size_t m_totalEmitted; int m_blockSize; bool m_running; }; diff --git a/src/libcore/random.cpp b/src/libcore/random.cpp index 3246b87a..7cfbac5c 100644 --- a/src/libcore/random.cpp +++ b/src/libcore/random.cpp @@ -189,6 +189,24 @@ uint32_t Random::nextUInt(uint32_t n) { return result; } +size_t Random::nextSize(size_t n) { + /* Determine a bit mask */ + size_t result, bitmask = n; + bitmask |= bitmask >> 1; + bitmask |= bitmask >> 2; + bitmask |= bitmask >> 4; + bitmask |= bitmask >> 8; + bitmask |= bitmask >> 16; + if (sizeof(size_t) == 8) + bitmask |= bitmask >> 32; + + /* Generate numbers until one in [0, n) is found */ + while ((result = (size_t) (nextULong() & bitmask)) >= n) + ; + + return result; +} + #if defined(DOUBLE_PRECISION) Float Random::nextFloat() { return (Float) ((nextULong() >> 11) * (1.0/9007199254740992.0)); diff --git a/src/libcore/thread.cpp b/src/libcore/thread.cpp index 167be62e..4996682a 100644 --- a/src/libcore/thread.cpp +++ b/src/libcore/thread.cpp @@ -303,7 +303,7 @@ void Thread::initializeOpenMP(size_t threadCount) { ref logger = Thread::getThread()->getLogger(); ref fResolver = Thread::getThread()->getFileResolver(); - omp_set_num_threads(threadCount); + omp_set_num_threads((int) threadCount); #pragma omp parallel { diff --git a/src/libcore/util.cpp b/src/libcore/util.cpp index bf8e9f90..f52bc7dd 100644 --- a/src/libcore/util.cpp +++ b/src/libcore/util.cpp @@ -526,14 +526,14 @@ void stratifiedSample2D(Random *random, Point2 *dest, int countX, int countY, bo } } -void latinHypercube(Random *random, Float *dest, int nSamples, int nDim) { +void latinHypercube(Random *random, Float *dest, size_t nSamples, size_t nDim) { Float delta = 1 / (Float) nSamples; - for (int i = 0; i < nSamples; ++i) - for (int j = 0; j < nDim; ++j) + for (size_t i = 0; i < nSamples; ++i) + for (size_t j = 0; j < nDim; ++j) dest[nDim * i + j] = (i + random->nextFloat()) * delta; - for (int i = 0; i < nDim; ++i) { - for (int j = 0; j < nSamples; ++j) { - int other = random->nextUInt(nSamples); + for (size_t i = 0; i < nDim; ++i) { + for (size_t j = 0; j < nSamples; ++j) { + size_t other = random->nextSize(nSamples); std::swap(dest[nDim * j + i], dest[nDim * other + i]); } } @@ -725,7 +725,7 @@ Float fresnel(Float cosTheta1, Float etaExt, Float etaInt) { etaInt, etaExt); } -Float radicalInverse(int b, int i) { +Float radicalInverse(int b, size_t i) { Float invB = (Float) 1 / (Float) b; Float x = 0.0f, f = invB; diff --git a/src/libcore/wavelet.cpp b/src/libcore/wavelet.cpp index 40f9fa8e..29b72070 100644 --- a/src/libcore/wavelet.cpp +++ b/src/libcore/wavelet.cpp @@ -70,19 +70,19 @@ Wavelet2D::Wavelet2D(const SparseWavelet2D *sw) { m_data[0] = sw->getScalingFunction(); /* Loop over the resolution hierarchy and extract the coefficients */ - size_t level = 0; - size_t size = 1, offset = 1; + uint8_t level = 0; + uint16_t size = 1, offset = 1; while (size < m_size) { /* Loop over the different types of differentiation */ - for (int type=0; type<3; type++) { + for (uint8_t type=0; type<3; type++) { size_t offsetX = 0, offsetY = 0; switch (type) { case 0: offsetX = offset; break; case 1: offsetY = offset; break; case 2: offsetX = offset; offsetY = offset; break; } - for (size_t j=0; jget(SparseWavelet2D::Key::create(level, type, i, j)); @@ -100,8 +100,8 @@ SparseWavelet2D *Wavelet2D::toSparseWavelet() const { sparse->setScalingFunction(m_data[0]); /* Loop over the resolution hierarchy and extract the coefficients */ - size_t level = 0; - size_t size = 1, offset = 1; + uint8_t level = 0; + uint16_t size = 1, offset = 1; while (size < m_size) { /* Loop over the different types of differentiation */ @@ -113,8 +113,8 @@ SparseWavelet2D *Wavelet2D::toSparseWavelet() const { case 2: offsetX = offset; offsetY = offset; break; } - for (size_t j=0; jgetVertexCount() * m_stride; - m_indexSize = m_mesh->getTriangleCount() * sizeof(GLuint) * 3; + m_vertexSize = (GLuint) (m_mesh->getVertexCount() * m_stride); + m_indexSize = (GLuint) (m_mesh->getTriangleCount() * sizeof(GLuint) * 3); Log(ETrace, "Uploading a GPU geometry object (\"%s\", " SIZE_T_FMT " vertices, " SIZE_T_FMT " triangles, %s)", diff --git a/src/librender/gatherproc.cpp b/src/librender/gatherproc.cpp index 71613080..8024ac22 100644 --- a/src/librender/gatherproc.cpp +++ b/src/librender/gatherproc.cpp @@ -106,7 +106,7 @@ public: GatherPhotonWorker(Stream *stream, InstanceManager *manager) : ParticleTracer(stream, manager) { m_type = (GatherPhotonProcess::EGatherType) stream->readInt(); - m_granularity = stream->readUInt(); + m_granularity = stream->readSize(); } ref clone() const { @@ -117,7 +117,7 @@ public: void serialize(Stream *stream, InstanceManager *manager) const { ParticleTracer::serialize(stream, manager); stream->writeInt(m_type); - stream->writeUInt(m_granularity); + stream->writeSize(m_granularity); } ref createWorkResult() const { diff --git a/src/librender/irrcache.cpp b/src/librender/irrcache.cpp index 05d99e79..287601a7 100644 --- a/src/librender/irrcache.cpp +++ b/src/librender/irrcache.cpp @@ -239,9 +239,9 @@ IrradianceCache::IrradianceCache(Stream *stream, InstanceManager *manager) : m_clampScreen = stream->readBool(); m_clampNeighbor = stream->readBool(); m_useGradients = stream->readBool(); - uint32_t recordCount = stream->readUInt(); + size_t recordCount = stream->readSize(); m_records.reserve(recordCount); - for (uint32_t i=0; iR0 / (2*m_kappa); m_octree.insert(sample, AABB( @@ -266,7 +266,7 @@ void IrradianceCache::serialize(Stream *stream, InstanceManager *manager) const stream->writeBool(m_clampScreen); stream->writeBool(m_clampNeighbor); stream->writeBool(m_useGradients); - stream->writeUInt(m_records.size()); + stream->writeSize(m_records.size()); for (uint32_t i=0; iserialize(stream); } diff --git a/src/librender/sampler.cpp b/src/librender/sampler.cpp index 5e823d26..cb4fc5b0 100644 --- a/src/librender/sampler.cpp +++ b/src/librender/sampler.cpp @@ -27,11 +27,11 @@ Sampler::Sampler(const Properties &props) Sampler::Sampler(Stream *stream, InstanceManager *manager) : ConfigurableObject(stream, manager) { m_sampleCount = stream->readSize(); - uint32_t n1DArrays = stream->readUInt(); - for (uint32_t i=0; ireadSize(); + for (size_t i=0; ireadUInt()); - uint32_t n2DArrays = stream->readUInt(); - for (uint32_t i=0; ireadSize(); + for (size_t i=0; ireadUInt()); } @@ -39,10 +39,10 @@ void Sampler::serialize(Stream *stream, InstanceManager *manager) const { ConfigurableObject::serialize(stream, manager); stream->writeSize(m_sampleCount); - stream->writeUInt(m_req1D.size()); + stream->writeSize(m_req1D.size()); for (size_t i=0; iwriteUInt(m_req1D[i]); - stream->writeUInt(m_req2D.size()); + stream->writeSize(m_req2D.size()); for (size_t i=0; iwriteUInt(m_req2D[i]); } diff --git a/src/librender/subsurface.cpp b/src/librender/subsurface.cpp index 7aad4b7c..1aeba827 100644 --- a/src/librender/subsurface.cpp +++ b/src/librender/subsurface.cpp @@ -53,9 +53,9 @@ Subsurface::Subsurface(Stream *stream, InstanceManager *manager) : m_sigmaA = Spectrum(stream); m_eta = stream->readFloat(); m_densityMultiplier = stream->readFloat(); - unsigned int shapeCount = stream->readUInt(); + size_t shapeCount = stream->readSize(); - for (unsigned int i=0; i(manager->getInstance(stream)); m_shapes.push_back(shape); } @@ -86,7 +86,7 @@ void Subsurface::serialize(Stream *stream, InstanceManager *manager) const { m_sigmaA.serialize(stream); stream->writeFloat(m_eta); stream->writeFloat(m_densityMultiplier); - stream->writeUInt(m_shapes.size()); + stream->writeSize(m_shapes.size()); for (unsigned int i=0; iserialize(stream, m_shapes[i]); } diff --git a/src/librender/trimesh.cpp b/src/librender/trimesh.cpp index 8037a757..679ec849 100644 --- a/src/librender/trimesh.cpp +++ b/src/librender/trimesh.cpp @@ -335,10 +335,10 @@ struct vertex_key_order : public /// Used in \ref TriMesh::rebuildTopology() struct TopoData { - uint32_t idx; /// Triangle index + size_t idx; /// Triangle index bool clustered; /// Has the tri-vert. pair been assigned to a cluster? inline TopoData() { } - inline TopoData(uint32_t idx, bool clustered) + inline TopoData(size_t idx, bool clustered) : idx(idx), clustered(clustered) { } }; diff --git a/src/qtgui/common.h b/src/qtgui/common.h index 8055c02e..5181efd7 100644 --- a/src/qtgui/common.h +++ b/src/qtgui/common.h @@ -129,7 +129,8 @@ namespace mitsuba { }; struct PreviewQueueEntry { - int id, vplSampleOffset; + int id; + size_t vplSampleOffset; GPUTexture *buffer; GPUSync *sync; diff --git a/src/qtgui/mainwindow.cpp b/src/qtgui/mainwindow.cpp index 4c5802c6..2a9f5fb5 100644 --- a/src/qtgui/mainwindow.cpp +++ b/src/qtgui/mainwindow.cpp @@ -1057,7 +1057,7 @@ void MainWindow::on_actionSettings_triggered() { size_t workerCount = sched->getWorkerCount(); for (size_t i=0; igetWorker(i); + Worker *worker = sched->getWorker((int) i); if (worker->getClass()->derivesFrom(MTS_CLASS(LocalWorker))) localWorkers.push_back(worker); } diff --git a/src/qtgui/preview.h b/src/qtgui/preview.h index 5ac19808..2c0a7a71 100644 --- a/src/qtgui/preview.h +++ b/src/qtgui/preview.h @@ -94,7 +94,8 @@ private: ref m_started; std::list m_readyQueue, m_recycleQueue; SceneContext *m_context; - int m_vplSampleOffset, m_minVPLs, m_vplCount; + size_t m_vplSampleOffset; + int m_minVPLs, m_vplCount; int m_vplsPerSecond, m_raysPerSecond; int m_bufferCount, m_queueEntryIndex; std::deque m_vpls; diff --git a/src/qtgui/programsettingsdlg.h b/src/qtgui/programsettingsdlg.h index 00397f02..070cdd87 100644 --- a/src/qtgui/programsettingsdlg.h +++ b/src/qtgui/programsettingsdlg.h @@ -71,7 +71,7 @@ public: } inline void setLocalWorkerCount(size_t count) { - ui->localWorkerBox->setValue(count); + ui->localWorkerBox->setValue((int) count); } inline int getLocalWorkerCount() { diff --git a/src/samplers/ldsampler.cpp b/src/samplers/ldsampler.cpp index adfd2495..f260423a 100644 --- a/src/samplers/ldsampler.cpp +++ b/src/samplers/ldsampler.cpp @@ -125,7 +125,7 @@ public: inline void generate1D(Float *samples, size_t sampleCount) { uint32_t scramble = m_random->nextULong() & 0xFFFFFFFF; for (size_t i = 0; i < sampleCount; ++i) - samples[i] = vanDerCorput(i, scramble); + samples[i] = vanDerCorput((uint32_t) i, scramble); m_random->shuffle(samples, samples + sampleCount); } @@ -136,7 +136,7 @@ public: } scramble; scramble.qword = m_random->nextULong(); for (size_t i = 0; i < sampleCount; ++i) - sample02(i, scramble.dword, samples[i]); + sample02((uint32_t) i, scramble.dword, samples[i]); m_random->shuffle(samples, samples + sampleCount); } diff --git a/src/shapes/cylinder.cpp b/src/shapes/cylinder.cpp index 5e28c40a..38b113f8 100644 --- a/src/shapes/cylinder.cpp +++ b/src/shapes/cylinder.cpp @@ -390,8 +390,8 @@ public: for (size_t phi=0; phitangent(iv); @@ -682,8 +682,8 @@ public: normals[vertexIdx] = normal; vertices[vertexIdx++] = m_kdtree->secondVertex(iv) + radius*dir - tangent*t2; - int idx0 = 2*(phi + hairIdx*phiSteps), idx1 = idx0+1; - int idx2 = (2*phi+2) % (2*phiSteps) + 2*hairIdx*phiSteps, idx3 = idx2+1; + uint32_t idx0 = 2*(phi + hairIdx*phiSteps), idx1 = idx0+1; + uint32_t idx2 = (2*phi+2) % (2*phiSteps) + 2*hairIdx*phiSteps, idx3 = idx2+1; triangles[triangleIdx].idx[0] = idx0; triangles[triangleIdx].idx[1] = idx2; triangles[triangleIdx].idx[2] = idx1; diff --git a/src/shapes/obj.cpp b/src/shapes/obj.cpp index ddf2fab7..57ec94e4 100644 --- a/src/shapes/obj.cpp +++ b/src/shapes/obj.cpp @@ -45,7 +45,7 @@ public: return false; if (line == "") return true; - int lastCharacter = line.size()-1; + int lastCharacter = (int) line.size() - 1; while (lastCharacter >= 0 && (line[lastCharacter] == '\r' || line[lastCharacter] == '\n' || diff --git a/src/shapes/sphere.cpp b/src/shapes/sphere.cpp index 555592f5..738e337a 100644 --- a/src/shapes/sphere.cpp +++ b/src/shapes/sphere.cpp @@ -247,16 +247,16 @@ public: ref createTriMesh() { /// Choice of discretization - const size_t thetaSteps = 20; - const size_t phiSteps = thetaSteps * 2; + const uint32_t thetaSteps = 20; + const uint32_t phiSteps = thetaSteps * 2; const Float dTheta = M_PI / (thetaSteps-1); const Float dPhi = (2*M_PI) / phiSteps; - size_t topIdx = (thetaSteps-2) * phiSteps, botIdx = topIdx+1; + uint32_t topIdx = (thetaSteps-2) * phiSteps, botIdx = topIdx+1; /// Precompute cosine and sine tables Float *cosPhi = new Float[phiSteps]; Float *sinPhi = new Float[phiSteps]; - for (size_t i=0; igetVertexPositions(); Normal *normals = mesh->getVertexNormals(); Triangle *triangles = mesh->getTriangles(); - size_t vertexIdx = 0; - for (size_t theta=1; thetareadString(); Log(EInfo, "Unserializing texture \"%s\"", m_filename.leaf().c_str()); - int size = stream->readInt(); + size_t size = stream->readSize(); ref mStream = new MemoryStream(size); stream->copyTo(mStream, size); mStream->setPos(0); @@ -62,7 +62,7 @@ public: Texture2D::serialize(stream, manager); stream->writeString(m_filename.file_string()); ref is = new FileStream(m_filename, FileStream::EReadOnly); - stream->writeInt(is->getSize()); + stream->writeSize(is->getSize()); is->copyTo(stream); } From 1d7d3547d1b699cfd09b549568620843cac25072 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2011 22:16:27 +0200 Subject: [PATCH 06/10] linux compilation fix --- src/shapes/hair.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/shapes/hair.cpp b/src/shapes/hair.cpp index 7924b79b..7f4e56f8 100644 --- a/src/shapes/hair.cpp +++ b/src/shapes/hair.cpp @@ -41,6 +41,8 @@ class HairKDTree : public SAHKDTree3D { friend class GenericKDTree; friend class SAHKDTree3D; public: + using SAHKDTree3D::index_type; + HairKDTree(std::vector &vertices, std::vector &vertexStartsFiber, Float radius) : m_radius(radius) { @@ -581,7 +583,7 @@ public: Hair(Stream *stream, InstanceManager *manager) : Shape(stream, manager) { Float radius = stream->readFloat(); - size_t vertexCount = (size_t) stream->readUInt(); + size_t vertexCount = stream->readSize(); std::vector vertices(vertexCount); std::vector vertexStartsFiber(vertexCount+1); @@ -601,7 +603,7 @@ public: const std::vector &vertexStartsFiber = m_kdtree->getStartFiber(); stream->writeFloat(m_kdtree->getRadius()); - stream->writeUInt((uint32_t) vertices.size()); + stream->writeSize(vertices.size()); stream->writeFloatArray((Float *) &vertices[0], vertices.size() * 3); for (size_t i=0; iwriteBool(vertexStartsFiber[i]); @@ -665,7 +667,7 @@ public: } size_t hairIdx = 0; - for (index_type iv=0; iv<(index_type) hairVertices.size()-1; iv++) { + for (HairKDTree::index_type iv=0; iv<(HairKDTree::index_type) hairVertices.size()-1; iv++) { if (!vertexStartsFiber[iv+1]) { for (size_t phi=0; phitangent(iv); From 3e561b24865a1912c7c84669a27506b903cfb944 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2011 13:37:04 -0700 Subject: [PATCH 07/10] removed further win64 warnings --- src/converter/obj.cpp | 2 +- src/integrators/photonmapper/bre.cpp | 12 ++++++------ src/integrators/photonmapper/bre.h | 8 ++++---- src/integrators/photonmapper/sppm.cpp | 3 ++- src/shapes/hair.cpp | 11 ++++++----- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/converter/obj.cpp b/src/converter/obj.cpp index e249e414..4fe3a894 100644 --- a/src/converter/obj.cpp +++ b/src/converter/obj.cpp @@ -193,7 +193,7 @@ void GeometryConverter::convertOBJ(const fs::path &inputFile, stream->close(); os << "\t\t" << endl; } else { - m_geometryDict.push_back(m_geometryFile->getPos()); + m_geometryDict.push_back((uint32_t) m_geometryFile->getPos()); SLog(EInfo, "Saving mesh \"%s\"", mesh->getName().c_str()); mesh->serialize(m_geometryFile); os << "\t\t" << endl; diff --git a/src/integrators/photonmapper/bre.cpp b/src/integrators/photonmapper/bre.cpp index 025f072d..8cc7f3ec 100644 --- a/src/integrators/photonmapper/bre.cpp +++ b/src/integrators/photonmapper/bre.cpp @@ -25,10 +25,10 @@ MTS_NAMESPACE_BEGIN BeamRadianceEstimator::BeamRadianceEstimator(const PhotonMap *pmap, size_t lookupSize) { - size_t reducedLookupSize = (size_t) std::sqrt((Float) lookupSize); + uint32_t reducedLookupSize = (uint32_t) std::sqrt((Float) lookupSize); Float sizeFactor = (Float) lookupSize/ (Float) reducedLookupSize; - m_photonCount = pmap->getPhotonCount(); + m_photonCount = (uint32_t) pmap->getPhotonCount(); m_scaleFactor = pmap->getScaleFactor(); m_lastInnerNode = m_photonCount/2; m_lastRChildNode = (m_photonCount-1)/2; @@ -73,7 +73,7 @@ BeamRadianceEstimator::BeamRadianceEstimator(const PhotonMap *pmap, size_t looku } BeamRadianceEstimator::BeamRadianceEstimator(Stream *stream, InstanceManager *manager) { - m_photonCount = stream->readSize(); + m_photonCount = stream->readUInt(); m_scaleFactor = stream->readFloat(); m_lastInnerNode = m_photonCount/2; m_lastRChildNode = (m_photonCount-1)/2; @@ -88,7 +88,7 @@ BeamRadianceEstimator::BeamRadianceEstimator(Stream *stream, InstanceManager *ma } void BeamRadianceEstimator::serialize(Stream *stream, InstanceManager *manager) const { - stream->writeSize(m_photonCount); + stream->writeUInt(m_photonCount); stream->writeFloat(m_scaleFactor); for (size_t i=1; i<=m_photonCount; ++i) { BRENode &node = m_nodes[i]; @@ -98,7 +98,7 @@ void BeamRadianceEstimator::serialize(Stream *stream, InstanceManager *manager) } } -AABB BeamRadianceEstimator::buildHierarchy(size_t index) { +AABB BeamRadianceEstimator::buildHierarchy(uint32_t index) { BRENode &node = m_nodes[index]; if (isInnerNode(index)) { @@ -127,7 +127,7 @@ Spectrum BeamRadianceEstimator::query(const Ray &r, const Medium *medium) const uint32_t *stack = (uint32_t *) alloca((m_depth+1) * sizeof(uint32_t)); uint32_t index = 1, stackPos = 1; Spectrum result(0.0f); - size_t nNodes = 0; + uint32_t nNodes = 0; const Spectrum &sigmaT = medium->getSigmaT(); const PhaseFunction *phase = medium->getPhaseFunction(); diff --git a/src/integrators/photonmapper/bre.h b/src/integrators/photonmapper/bre.h index 64def59b..f01677b6 100644 --- a/src/integrators/photonmapper/bre.h +++ b/src/integrators/photonmapper/bre.h @@ -55,7 +55,7 @@ protected: virtual ~BeamRadianceEstimator(); /// Fit a hierarchy of bounding boxes to the stored photons - AABB buildHierarchy(size_t index); + AABB buildHierarchy(uint32_t index); /// Heap convenience routines inline uint32_t leftChild(uint32_t index) const { return 2*index; } @@ -70,9 +70,9 @@ private: }; BRENode *m_nodes; - size_t m_photonCount; - size_t m_lastInnerNode; - size_t m_lastRChildNode; + uint32_t m_photonCount; + uint32_t m_lastInnerNode; + uint32_t m_lastRChildNode; int m_depth; Float m_scaleFactor; }; diff --git a/src/integrators/photonmapper/sppm.cpp b/src/integrators/photonmapper/sppm.cpp index 8d8c764a..1e93deab 100644 --- a/src/integrators/photonmapper/sppm.cpp +++ b/src/integrators/photonmapper/sppm.cpp @@ -335,7 +335,8 @@ private: ref m_bitmap; Float m_initialRadius, m_alpha; int m_photonCount, m_granularity; - int m_maxDepth, m_rrDepth, m_totalEmitted; + int m_maxDepth, m_rrDepth; + size_t m_totalEmitted; int m_blockSize; bool m_running; }; diff --git a/src/shapes/hair.cpp b/src/shapes/hair.cpp index 7f4e56f8..d7a858ad 100644 --- a/src/shapes/hair.cpp +++ b/src/shapes/hair.cpp @@ -42,6 +42,7 @@ class HairKDTree : public SAHKDTree3D { friend class SAHKDTree3D; public: using SAHKDTree3D::index_type; + using SAHKDTree3D::size_type; HairKDTree(std::vector &vertices, std::vector &vertexStartsFiber, Float radius) @@ -403,8 +404,8 @@ public: #endif /// Return the total number of segments - inline size_t getPrimitiveCount() const { - return m_segIndex.size(); + inline size_type getPrimitiveCount() const { + return (size_type) m_segIndex.size(); } inline bool intersect(const Ray &ray, index_type iv, @@ -645,7 +646,7 @@ public: ref createTriMesh() { size_t nSegments = m_kdtree->getSegmentCount(); /// Use very approximate geometry for large hair meshes - const size_t phiSteps = (nSegments > 100000) ? 4 : 10; + const uint32_t phiSteps = (nSegments > 100000) ? 4 : 10; const Float dPhi = (2*M_PI) / phiSteps; ref mesh = new TriMesh("Hair mesh approximation", @@ -666,10 +667,10 @@ public: cosPhi[i] = std::cos(i*dPhi); } - size_t hairIdx = 0; + uint32_t hairIdx = 0; for (HairKDTree::index_type iv=0; iv<(HairKDTree::index_type) hairVertices.size()-1; iv++) { if (!vertexStartsFiber[iv+1]) { - for (size_t phi=0; phitangent(iv); Vector dir = Frame(tangent).toWorld( Vector(cosPhi[phi], sinPhi[phi], 0)); From 56429cc1305e2f42f2f0071c0820dabf5cdb30ed Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2011 14:12:00 -0700 Subject: [PATCH 08/10] minor win32 warning removed --- src/libcore/random.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcore/random.cpp b/src/libcore/random.cpp index 7cfbac5c..0f968059 100644 --- a/src/libcore/random.cpp +++ b/src/libcore/random.cpp @@ -197,8 +197,11 @@ size_t Random::nextSize(size_t n) { bitmask |= bitmask >> 4; bitmask |= bitmask >> 8; bitmask |= bitmask >> 16; - if (sizeof(size_t) == 8) + +#if defined(WIN64) || defined(__LINUX__) || defined(__OSX__) + if (sizeof(size_t) > 4) bitmask |= bitmask >> 32; +#endif /* Generate numbers until one in [0, n) is found */ while ((result = (size_t) (nextULong() & bitmask)) >= n) From 6ad224eeb83442cc47e369e801f1409b0c6ae1ca Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2011 14:26:19 -0700 Subject: [PATCH 09/10] fixed a stupid bug in hg.cpp, which affected the volpath integrator (volpath_simple was unaffacted) --- src/phase/hg.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/phase/hg.cpp b/src/phase/hg.cpp index fd3a52a9..687fa8f2 100644 --- a/src/phase/hg.cpp +++ b/src/phase/hg.cpp @@ -77,7 +77,8 @@ public: Float sample(PhaseFunctionQueryRecord &pRec, Float &pdf, Sampler *sampler) const { HGPhaseFunction::sample(pRec, sampler); - return HGPhaseFunction::f(pRec); + pdf = HGPhaseFunction::f(pRec); + return pdf; } From 20e66965f69c844d2c0362d049b97b4d2f87331d Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 20 May 2011 03:17:53 +0200 Subject: [PATCH 10/10] latin-1 error messages in the PLY parser --- src/shapes/ply/ply/ply_parser.hpp | 4 ++-- src/shapes/ply/ply_parser.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shapes/ply/ply/ply_parser.hpp b/src/shapes/ply/ply/ply_parser.hpp index a125d776..1e14b2cd 100644 --- a/src/shapes/ply/ply/ply_parser.hpp +++ b/src/shapes/ply/ply/ply_parser.hpp @@ -392,7 +392,7 @@ inline void ply::ply_parser::parse_scalar_property_definition(const std::string& } if (!scalar_property_callback) { if (warning_callback_) { - warning_callback_(line_number_, "property ‘" + std::string(type_traits::name()) + " " + property_name + "’ of element ‘" + current_element_->name + "’ is not handled"); + warning_callback_(line_number_, "property '" + std::string(type_traits::name()) + " " + property_name + "' of element '" + current_element_->name + "' is not handled"); } } current_element_->properties.push_back(std::tr1::shared_ptr(new scalar_property(property_name, scalar_property_callback))); @@ -416,7 +416,7 @@ inline void ply::ply_parser::parse_list_property_definition(const std::string& p } if (!std::tr1::get<0>(list_property_callbacks) || !std::tr1::get<1>(list_property_callbacks) || !std::tr1::get<2>(list_property_callbacks)) { if (warning_callback_) { - warning_callback_(line_number_, "property ‘list " + std::string(type_traits::name()) + " " + std::string(type_traits::name()) + " " + property_name + "’ of element ‘" + current_element_->name + "’ is not handled"); + warning_callback_(line_number_, "property 'list " + std::string(type_traits::name()) + " " + std::string(type_traits::name()) + " " + property_name + "' of element '" + current_element_->name + "' is not handled"); } } current_element_->properties.push_back(std::tr1::shared_ptr(new list_property(property_name, std::tr1::get<0>(list_property_callbacks), std::tr1::get<1>(list_property_callbacks), std::tr1::get<2>(list_property_callbacks)))); diff --git a/src/shapes/ply/ply_parser.cpp b/src/shapes/ply/ply_parser.cpp index 59635d92..c791925c 100644 --- a/src/shapes/ply/ply_parser.cpp +++ b/src/shapes/ply/ply_parser.cpp @@ -39,7 +39,7 @@ bool ply::ply_parser::parse(std::istream& istream) stringstream >> std::ws; if (stringstream.eof()) { if (warning_callback_) { - warning_callback_(line_number_, "ignoring line ‘" + line + "’"); + warning_callback_(line_number_, "ignoring line '" + line + "'"); } } else { @@ -74,7 +74,7 @@ bool ply::ply_parser::parse(std::istream& istream) } if (version != "1.0") { if (error_callback_) { - error_callback_(line_number_, "version ‘" + version + "’ is not supported"); + error_callback_(line_number_, "version '" + version + "' is not supported"); } return false; } @@ -375,7 +375,7 @@ bool ply::ply_parser::parse(std::istream& istream) // unknown keyword else { if (warning_callback_) { - warning_callback_(line_number_, "ignoring line ‘" + line + "’"); + warning_callback_(line_number_, "ignoring line '" + line + "'"); } }