diff --git a/data/blender/mitsuba/operators/__init__.py b/data/blender/mitsuba/operators/__init__.py index 4f9f82f1..de2c38b9 100644 --- a/data/blender/mitsuba/operators/__init__.py +++ b/data/blender/mitsuba/operators/__init__.py @@ -125,7 +125,7 @@ class EXPORT_OT_mitsuba(bpy.types.Operator): bl_idname = 'export.mitsuba' bl_label = 'Export Mitsuba Scene (.xml)' - filename = bpy.props.StringProperty(name='Target filename') + filename = bpy.props.StringProperty(name='Target filename', subtype = 'FILE_PATH') directory = bpy.props.StringProperty(name='Target directory') scene = bpy.props.StringProperty(options={'HIDDEN'}, default='') @@ -150,6 +150,9 @@ class EXPORT_OT_mitsuba(bpy.types.Operator): mts_basename = os.path.join( self.properties.directory, self.properties.filename) + (path, ext) = os.path.splitext(mts_basename) + if ext == '.xml': + mts_basename = path mts_dae_file = mts_basename + ".dae" mts_xml_file = mts_basename + ".xml" mts_adj_file = mts_basename + "_adjustments.xml" @@ -206,7 +209,10 @@ class EXPORT_OT_mitsuba(bpy.types.Operator): MtsLog("Caught exception: %s" % ''.join(elist)) return {'CANCELLED'} -menu_func = lambda self, context: self.layout.operator("export.mitsuba", text="Export Mitsuba scene...") +def menu_func(self, context): + default_path = os.path.splitext(os.path.basename(bpy.data.filepath))[0] + ".xml" + self.layout.operator("export.mitsuba", text="Export Mitsuba scene...").filename = default_path + bpy.types.INFO_MT_file_export.append(menu_func) class MITSUBA_OT_material_slot_move(bpy.types.Operator): diff --git a/include/mitsuba/render/kdtree.h b/include/mitsuba/render/kdtree.h index 182d95b8..e3ec83a9 100644 --- a/include/mitsuba/render/kdtree.h +++ b/include/mitsuba/render/kdtree.h @@ -109,6 +109,10 @@ public: void rayIntersectPacketIncoherent(const RayPacket4 &packet, const RayInterval4 &interval, Intersection4 &its, void *temp) const; #endif + + FINLINE size_type getPrimitiveCount() const { + return m_shapeMap[m_shapeMap.size()-1]; + } MTS_DECLARE_CLASS() protected: @@ -149,10 +153,6 @@ protected: } } - FINLINE size_type getPrimitiveCount() const { - return m_shapeMap[m_shapeMap.size()-1]; - } - /// Temporarily holds some intersection information struct IntersectionCache { size_type shapeIndex; diff --git a/src/qtgui/glwidget.cpp b/src/qtgui/glwidget.cpp index e8bae554..11bcf1bb 100644 --- a/src/qtgui/glwidget.cpp +++ b/src/qtgui/glwidget.cpp @@ -50,7 +50,7 @@ GLWidget::GLWidget(QWidget *parent) : connect(m_preview, SIGNAL(statusMessage(const QString &)), this, SIGNAL(statusMessage(const QString &)), Qt::QueuedConnection); m_invertMouse = false; - m_navigationMode = EFlythroughFixedYaw; + m_navigationMode = EFlythrough; m_ignoreMouseEvent = QPoint(0, 0); m_didSetCursor = false; m_softwareFallback = false; @@ -406,7 +406,12 @@ void GLWidget::downloadFramebuffer() { createdFramebuffer = true; } - PreviewQueueEntry entry = m_preview->acquireBuffer(); + PreviewQueueEntry entry = m_preview->acquireBuffer(1000); + if (entry.buffer == NULL) { + if (createdFramebuffer) + m_framebuffer->init(); + return; + } Point3i size = entry.buffer->getSize(); ref sourceBitmap = new Bitmap(size.x, size.y, 128); diff --git a/src/qtgui/logwidget.h b/src/qtgui/logwidget.h index 0d9eec11..110994e1 100644 --- a/src/qtgui/logwidget.h +++ b/src/qtgui/logwidget.h @@ -38,7 +38,8 @@ public: void append(ELogLevel level, const std::string &message) { if (!m_ignoreMessages) { emit textMessage(level, QString::fromLatin1(message.c_str())); - floodCheck(); + if (level >= EWarn) + floodCheck(); } } diff --git a/src/qtgui/mainwindow.cpp b/src/qtgui/mainwindow.cpp index 3eb4a57e..ce28b02d 100644 --- a/src/qtgui/mainwindow.cpp +++ b/src/qtgui/mainwindow.cpp @@ -141,7 +141,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->glView->setInvertMouse(settings.value("invertMouse", false).toBool()); ui->glView->setMouseSensitivity(settings.value("mouseSensitivity", 3).toInt()); ui->glView->setNavigationMode((ENavigationMode) settings.value("navigationMode", - EFlythroughFixedYaw).toInt()); + EFlythrough).toInt()); m_searchPaths = settings.value("searchPaths", QStringList()).toStringList(); m_blockSize = settings.value("blockSize", 32).toInt(); m_listenPort = settings.value("listenPort", MTS_DEFAULT_PORT).toInt(); diff --git a/src/shapes/instance.cpp b/src/shapes/instance.cpp index 36d8fa8f..c999f3be 100644 --- a/src/shapes/instance.cpp +++ b/src/shapes/instance.cpp @@ -48,6 +48,8 @@ public: AABB getAABB() const { const KDTree *kdtree = m_shapeGroup->getKDTree(); const AABB &aabb = kdtree->getAABB(); + if (!aabb.isValid()) // the geometry group is empty + return aabb; AABB result; for (int i=0; i<8; ++i) result.expandBy(m_objectToWorld(aabb.getCorner(i))); diff --git a/src/shapes/shapegroup.cpp b/src/shapes/shapegroup.cpp index 066cd904..1b62de33 100644 --- a/src/shapes/shapegroup.cpp +++ b/src/shapes/shapegroup.cpp @@ -22,6 +22,7 @@ MTS_NAMESPACE_BEGIN ShapeGroup::ShapeGroup(const Properties &props) : Shape(props) { m_kdtree = new KDTree(); + m_name = props.getID(); } ShapeGroup::ShapeGroup(Stream *stream, InstanceManager *manager) @@ -85,6 +86,19 @@ bool ShapeGroup::isCompound() const { return true; } +std::string ShapeGroup::getName() const { + return m_name; +} + +std::string ShapeGroup::toString() const { + std::ostringstream oss; + oss << "ShapeGroup[" << endl + << " name = \"" << m_name << "\", " << endl + << " primCount = " << m_kdtree->getPrimitiveCount() << endl + << "]"; + return oss.str(); +} + MTS_IMPLEMENT_CLASS_S(ShapeGroup, false, Shape) MTS_EXPORT_PLUGIN(ShapeGroup, "Grouped geometry for instancing"); MTS_NAMESPACE_END diff --git a/src/shapes/shapegroup.h b/src/shapes/shapegroup.h index a304701e..b313bcd2 100644 --- a/src/shapes/shapegroup.h +++ b/src/shapes/shapegroup.h @@ -59,9 +59,16 @@ public: /// Return a pointer to the internal KD-tree inline const KDTree *getKDTree() const { return m_kdtree.get(); } + /// Return the name of the geometry group + std::string getName() const; + + /// Return a string representation + std::string toString() const; + MTS_DECLARE_CLASS() private: ref m_kdtree; + std::string m_name; }; MTS_NAMESPACE_END