From d612e23971dcb5782bbff1c8ea9828ebdc992e94 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 10 Apr 2011 22:07:08 +0200 Subject: [PATCH] minor improvements --- data/blender/mitsuba/export/__init__.py | 8 ++++++-- data/blender/mitsuba/properties/integrator.py | 14 +++++++++++++- include/mitsuba/core/object.h | 4 ++++ include/mitsuba/core/statistics.h | 7 +++++++ include/mitsuba/core/transform.h | 4 ++-- include/mitsuba/render/luminaire.h | 3 +++ schema/scene.xsd | 2 ++ src/libcore/properties.cpp | 4 ++-- src/librender/luminaire.cpp | 10 ++++++++++ src/librender/shape.cpp | 2 +- 10 files changed, 50 insertions(+), 8 deletions(-) diff --git a/data/blender/mitsuba/export/__init__.py b/data/blender/mitsuba/export/__init__.py index b2b1ffb4..3c9bf365 100644 --- a/data/blender/mitsuba/export/__init__.py +++ b/data/blender/mitsuba/export/__init__.py @@ -302,6 +302,8 @@ class MtsExporter: ltype = lamp.data.type name = translate_id(lamp.data.name) mult = lamp.data.mitsuba_lamp.intensity + if lamp.data.mitsuba_lamp.inside_medium: + self.exportMedium(scene.mitsuba_media.media[lamp.data.mitsuba_lamp.lamp_medium]) if ltype == 'POINT': self.openElement('luminaire', { 'type' : 'point', 'id' : '%s-light' % name }) self.exportWorldTrafo(lamp.matrix_world) @@ -309,9 +311,8 @@ class MtsExporter: "%f %f %f" % (lamp.data.color.r*mult, lamp.data.color.g*mult, lamp.data.color.b*mult)}) self.parameter('float', 'samplingWeight', {'value' : '%f' % lamp.data.mitsuba_lamp.samplingWeight}) - if lamp.data.mitsuba_lamp.inside_medium: - self.exportMediumReference(scene, lamp, None, lamp.data.mitsuba_lamp.lamp_medium) + self.element('ref', {'id' : lamp.data.mitsuba_lamp.lamp_medium}) self.closeElement() elif ltype == 'AREA': self.element('remove', { 'id' : '%s-light' % name}) @@ -360,6 +361,8 @@ class MtsExporter: self.parameter('float', 'cutoffAngle', {'value' : '%f' % (lamp.data.spot_size * 180 / (math.pi * 2))}) self.parameter('float', 'beamWidth', {'value' : '%f' % (lamp.data.spot_blend * lamp.data.spot_size * 180 / (math.pi * 2))}) self.parameter('float', 'samplingWeight', {'value' : '%f' % lamp.data.mitsuba_lamp.samplingWeight}) + if lamp.data.mitsuba_lamp.inside_medium: + self.element('ref', {'id' : lamp.data.mitsuba_lamp.lamp_medium}) self.closeElement() elif ltype == 'HEMI': if lamp.data.mitsuba_lamp.envmap_type == 'constant': @@ -378,6 +381,7 @@ class MtsExporter: def exportIntegrator(self, integrator): self.openElement('integrator', { 'id' : 'integrator', 'type' : integrator.type}) + self.parameter('integer', 'maxDepth', { 'value' : str(integrator.maxdepth)}) self.closeElement() def exportSampler(self, sampler): diff --git a/data/blender/mitsuba/properties/integrator.py b/data/blender/mitsuba/properties/integrator.py index 4d552474..2f199508 100644 --- a/data/blender/mitsuba/properties/integrator.py +++ b/data/blender/mitsuba/properties/integrator.py @@ -32,6 +32,7 @@ class mitsuba_integrator(declarative_property_group): controls = [ 'type', + 'maxdepth', ['motionblur', 'shuttertime'] ] @@ -50,7 +51,8 @@ class mitsuba_integrator(declarative_property_group): 'items': [ ('volpath', 'Volumetric path tracer', 'volpath'), ('path', 'Path tracer', 'path'), - ('direct', 'Direct Illumination', 'direct') + ('direct', 'Direct Illumination', 'direct'), + ('ptracer', 'Adjoint Particle Tracer', 'ptracer') ], 'save_in_preset': True }, @@ -71,6 +73,16 @@ class mitsuba_integrator(declarative_property_group): 'min': 0, 'max': 100, 'default': 1 + }, + { + 'type': 'int', + 'attr': 'maxdepth', + 'name': 'Max. path depth', + 'description': 'Maximum path depth to be rendered. 2 corresponds to direct illumination, 3 is 1-bounce indirect illumination, etc.', + 'save_in_preset': True, + 'min': 2, + 'max': 100, + 'default': 4 } ] diff --git a/include/mitsuba/core/object.h b/include/mitsuba/core/object.h index cf01d481..facb3947 100644 --- a/include/mitsuba/core/object.h +++ b/include/mitsuba/core/object.h @@ -76,7 +76,11 @@ protected: public: static Class *m_theClass; ///< Pointer to the object's class descriptor private: +#ifndef WIN32 volatile mutable int m_refCount; +#else + volatile mutable LONG m_refCount; +#endif }; inline int Object::getRefCount() const { diff --git a/include/mitsuba/core/statistics.h b/include/mitsuba/core/statistics.h index 51d3e011..2740bb14 100644 --- a/include/mitsuba/core/statistics.h +++ b/include/mitsuba/core/statistics.h @@ -186,6 +186,13 @@ public: } #endif + /// Reset the stored counter values + inline void reset() { + for (int i=0; i Epsilon) + if (i == j && std::abs(sum-1) > 1e-3f) return true; - else if (i != j && std::abs(sum) > Epsilon) + else if (i != j && std::abs(sum) > 1e-3f) return true; } } diff --git a/include/mitsuba/render/luminaire.h b/include/mitsuba/render/luminaire.h index 953aded9..05e1bcb8 100644 --- a/include/mitsuba/render/luminaire.h +++ b/include/mitsuba/render/luminaire.h @@ -348,6 +348,9 @@ public: /// Optional pre-process step before rendering starts virtual void preprocess(const Scene *scene); + /// Add a child (e.g. a medium reference) to this luminaire + void addChild(const std::string &name, ConfigurableObject *child); + //! @} // ============================================================= diff --git a/schema/scene.xsd b/schema/scene.xsd index 1fef217c..10ac544a 100644 --- a/schema/scene.xsd +++ b/schema/scene.xsd @@ -111,6 +111,8 @@ + + diff --git a/src/libcore/properties.cpp b/src/libcore/properties.cpp index dddc7650..bcac7e2a 100644 --- a/src/libcore/properties.cpp +++ b/src/libcore/properties.cpp @@ -363,8 +363,8 @@ void ConfigurableObject::serialize(Stream *stream, InstanceManager *manager) con } void ConfigurableObject::addChild(const std::string &name, ConfigurableObject *child) { - SLog(EError, "ConfigurableObject::addChild(\"%s\") not implemented in \"%s\"", - name.c_str(), toString().c_str()); + SLog(EError, "ConfigurableObject::addChild(\"%s\", %s) not implemented in \"%s\"", + name.c_str(), child->toString().c_str(), toString().c_str()); } void NetworkedObject::serialize(Stream *stream, InstanceManager *manager) const { diff --git a/src/librender/luminaire.cpp b/src/librender/luminaire.cpp index 550bd08e..8f858a4f 100644 --- a/src/librender/luminaire.cpp +++ b/src/librender/luminaire.cpp @@ -53,6 +53,16 @@ Luminaire::Luminaire(Stream *stream, InstanceManager *manager) Luminaire::~Luminaire() { } +void Luminaire::addChild(const std::string &name, ConfigurableObject *child) { + const Class *cClass = child->getClass(); + if (cClass->derivesFrom(MTS_CLASS(Medium))) { + Assert(m_medium == NULL); + m_medium = static_cast(child); + } else { + ConfigurableObject::addChild(name, child); + } +} + void Luminaire::serialize(Stream *stream, InstanceManager *manager) const { ConfigurableObject::serialize(stream, manager); manager->serialize(stream, m_medium.get()); diff --git a/src/librender/shape.cpp b/src/librender/shape.cpp index 9daa3f2b..8481e0c5 100644 --- a/src/librender/shape.cpp +++ b/src/librender/shape.cpp @@ -109,7 +109,7 @@ void Shape::addChild(const std::string &name, ConfigurableObject *child) { "'interiorMedium' or 'exteriorMedium')!"); } } else { - Log(EError, "Shape: Invalid child node!"); + ConfigurableObject::addChild(name, child); } }