[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14983] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: soc-2008-mxcurioni: Freestyle compiles but crashes at runtime because of the Python environment .

Maxime Curioni maxime.curioni at gmail.com
Mon May 26 18:19:30 CEST 2008


Revision: 14983
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14983
Author:   mxcurioni
Date:     2008-05-26 18:19:30 +0200 (Mon, 26 May 2008)

Log Message:
-----------
soc-2008-mxcurioni: Freestyle compiles but crashes at runtime because of the Python environment.

I analyzed the crash with gdb and PyImport_AddModule ("__main__") in Python/import.c:320 seems responsible for the crash: apparently, "__main__" is not found and causes the error "No such file or directory".

I have to figure out what's wrong with the current configuration, especially whether Freestyle's PythonInterpreter can be used as is. I am going to see whether it's just quicker to use Blender's functions.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h

Added Paths:
-----------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_config.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_constraint.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_frame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_frame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedCameraFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedCameraFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_point.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_quaternion.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_quaternion.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_vec.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_vec.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/test_config.h

Removed Paths:
-------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/camera.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/camera.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/config.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/constraint.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/frame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/frame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedCameraFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedCameraFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/old_camera_vec_quaternion.txt
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/point.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/quaternion.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/quaternion.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/vec.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/vec.h

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp	2008-05-26 15:12:20 UTC (rev 14982)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp	2008-05-26 16:19:30 UTC (rev 14983)
@@ -18,6 +18,8 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include "test_config.h"
+
 #include "AppConfig.h"
 #include <iostream>
 
@@ -33,8 +35,7 @@
     // get the root directory
 	//soc
 	//setRootDir(getEnvVar("FREESTYLE_BLENDER_DIR"));
-	setRootDir("/Users/mx/Documents/work/GSoC_2008/bf-blender/branches/soc-2008-mxcurioni/source/blender/freestyle");
-	cout << _PythonPath << endl;
+	setRootDir( TEST_ROOT_DIR );
 
 //setRootDir(QString("."));
     _pInstance = this;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h	2008-05-26 15:12:20 UTC (rev 14982)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h	2008-05-26 16:19:30 UTC (rev 14983)
@@ -48,9 +48,9 @@
 //# include <QGLViewer/qglviewer.h>
 
 //soc
-#include "camera.h"
-#include "vec.h"
-#include "quaternion.h"
+#include "AppGLWidget_camera.h"
+#include "AppGLWidget_vec.h"
+#include "AppGLWidget_quaternion.h"
 
 using namespace Geometry;
 

Copied: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.cpp (from rev 14967, branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/camera.cpp)
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.cpp	                        (rev 0)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.cpp	2008-05-26 16:19:30 UTC (rev 14983)
@@ -0,0 +1,1799 @@
+/****************************************************************************
+
+ Copyright (C) 2002-2007 Gilles Debunne (Gilles.Debunne at imag.fr)
+
+ This file is part of the QGLViewer library.
+ Version 2.2.6-3, released on August 28, 2007.
+
+ http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer
+
+ libQGLViewer is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ libQGLViewer is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libQGLViewer; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*****************************************************************************/
+
+#include "AppGLWidget_camera.h"
+//#include "qglviewer.h"
+
+using namespace std;
+//using namespace qglviewer;
+
+/*! Default constructor.
+
+ sceneCenter() is set to (0,0,0) and sceneRadius() is set to 1.0. type() is Camera::PERSPECTIVE,
+ with a \c M_PI/4 fieldOfView().
+
+ See IODistance(), physicalDistanceToScreen(), physicalScreenWidth() and focusDistance()
+ documentations for default stereo parameter values. */
+Camera::Camera()
+  : fieldOfView_(M_PI/4.0f)
+{
+  // #CONNECTION# Camera copy constructor
+  //interpolationKfi_ = new KeyFrameInterpolator;
+  // Requires the interpolationKfi_
+  setFrame(new ManipulatedCameraFrame());
+
+  // #CONNECTION# All these default values identical in initFromDOMElement.
+
+  // Requires fieldOfView() to define focusDistance()
+  setSceneRadius(1.0);
+
+  // Initial value (only scaled after this)
+  orthoCoef_ = tan(fieldOfView()/2.0);
+
+  // Also defines the revolveAroundPoint(), which changes orthoCoef_. Requires a frame().
+  setSceneCenter(Vec(0.0, 0.0, 0.0));
+
+  // Requires fieldOfView() when called with ORTHOGRAPHIC. Attention to projectionMatrix_ below.
+  setType(PERSPECTIVE);
+
+  // #CONNECTION# initFromDOMElement default values
+  setZNearCoefficient(0.005f);
+  setZClippingCoefficient(sqrt(3.0));
+
+  // Dummy values
+  setScreenWidthAndHeight(600, 400);
+
+  // Stereo parameters
+  setIODistance(0.062f);
+  setPhysicalDistanceToScreen(0.5f);
+  setPhysicalScreenWidth(0.4f);
+  // focusDistance is set from setFieldOfView()
+
+  // #CONNECTION# Camera copy constructor
+  for (unsigned short j=0; j<16; ++j)
+    {
+      modelViewMatrix_[j] = ((j%5 == 0) ? 1.0 : 0.0);
+      // #CONNECTION# computeProjectionMatrix() is lazy and assumes 0.0 almost everywhere.
+      projectionMatrix_[j] = 0.0;
+    }
+  computeProjectionMatrix();
+}
+
+/*! Virtual destructor.
+
+ The frame() is deleted, but the different keyFrameInterpolator() are \e not deleted (in case they
+ are shared). */
+Camera::~Camera()
+{
+  delete frame_;
+  //delete interpolationKfi_;
+}
+
+
+/*! Copy constructor. Performs a deep copy using operator=(). */
+Camera::Camera(const Camera& camera)
+{
+  // #CONNECTION# Camera constructor
+  //interpolationKfi_ = new KeyFrameInterpolator;
+  // Requires the interpolationKfi_
+  setFrame(new ManipulatedCameraFrame());
+
+  for (unsigned short j=0; j<16; ++j)
+    {
+      modelViewMatrix_[j] = ((j%5 == 0) ? 1.0 : 0.0);
+      // #CONNECTION# computeProjectionMatrix() is lazy and assumes 0.0 almost everywhere.
+      projectionMatrix_[j] = 0.0;
+    }
+
+  (*this)=camera;
+}
+
+/*! Equal operator.
+
+ All the parameters of \p camera are copied. The frame() pointer is not modified, but its
+ Frame::position() and Frame::orientation() are set to those of \p camera.
+
+ \attention The Camera screenWidth() and screenHeight() are set to those of \p camera. If your
+ Camera is associated with a QGLViewer, you should update these value after the call to this method:
+ \code
+ *(camera()) = otherCamera;
+ camera()->setScreenWidthAndHeight(width(), height());
+ \endcode
+ The same applies to sceneCenter() and sceneRadius(), if needed. */
+Camera& Camera::operator=(const Camera& camera)
+{
+  setScreenWidthAndHeight(camera.screenWidth(), camera.screenHeight());
+  setFieldOfView(camera.fieldOfView());
+  setSceneRadius(camera.sceneRadius());
+  setSceneCenter(camera.sceneCenter());
+  setZNearCoefficient(camera.zNearCoefficient());
+  setZClippingCoefficient(camera.zClippingCoefficient());
+  setType(camera.type());
+
+  // Stereo parameters
+  setIODistance(camera.IODistance());
+  setFocusDistance(camera.focusDistance());
+  setPhysicalScreenWidth(camera.physicalScreenWidth());
+  setPhysicalDistanceToScreen(camera.physicalDistanceToScreen());
+
+  orthoCoef_ = camera.orthoCoef_;
+
+  // frame_ and interpolationKfi_ pointers are not shared.
+  frame_->setReferenceFrame(NULL);
+  frame_->setPosition(camera.position());
+  frame_->setOrientation(camera.orientation());
+
+  //interpolationKfi_->resetInterpolation();
+
+  //kfi_ = camera.kfi_;
+
+  computeProjectionMatrix();
+  computeModelViewMatrix();
+
+  return *this;
+}
+
+/*! Sets Camera screenWidth() and screenHeight() (expressed in pixels).
+
+You should not call this method when the Camera is associated with a QGLViewer, since the
+latter automatically updates these values when it is resized (hence overwritting your values).
+
+Non-positive dimension are silently replaced by a 1 pixel value to ensure frustrum coherence.
+
+If your Camera is used without a QGLViewer (offscreen rendering, shadow maps), use setAspectRatio()
+instead to define the projection matrix. */
+void Camera::setScreenWidthAndHeight(int width, int height)
+{
+  // Prevent negative and zero dimensions that would cause divisions by zero.
+	screenWidth_  = width > 0 ? width : 1;
+	screenHeight_ = height > 0 ? height : 1;
+}
+
+/*! Returns the near clipping plane distance used by the Camera projection matrix.
+
+ The clipping planes' positions depend on the sceneRadius() and sceneCenter() rather than being fixed
+ small-enough and large-enough values. A good scene dimension approximation will hence result in an
+ optimal precision of the z-buffer.
+
+ The near clipping plane is positioned at a distance equal to zClippingCoefficient() * sceneRadius()
+ in front of the sceneCenter():
+ \code
+ zNear = distanceToSceneCenter() - zClippingCoefficient()*sceneRadius();
+ \endcode
+
+ In order to prevent negative or too small zNear() values (which would degrade the z precision),
+ zNearCoefficient() is used when the Camera is inside the sceneRadius() sphere:
+ \code
+ const float zMin = zNearCoefficient() * zClippingCoefficient() * sceneRadius();
+ if (zNear < zMin)
+   zNear = zMin;
+ // With an ORTHOGRAPHIC type, the value is simply clamped to 0.0
+ \endcode
+
+ See also the zFar(), zClippingCoefficient() and zNearCoefficient() documentations.
+
+ If you need a completely different zNear computation, overload the zNear() and zFar() methods in a
+ new class that publicly inherits from Camera and use QGLViewer::setCamera():
+ \code
+ class myCamera :: public qglviewer::Camera
+ {
+   virtual float Camera::zNear() const { return 0.001; };
+   virtual float Camera::zFar() const { return 100.0; };
+ }
+ \endcode
+
+ See the <a href="../examples/standardCamera.html">standardCamera example</a> for an application.
+
+ \attention The value is always positive although the clipping plane is positioned at a negative z
+ value in the Camera coordinate system. This follows the \c gluPerspective standard. */
+float Camera::zNear() const
+{
+  float z = distanceToSceneCenter() - zClippingCoefficient()*sceneRadius();
+
+  // Prevents negative or null zNear values.
+  const float zMin = zNearCoefficient() * zClippingCoefficient() * sceneRadius();
+  if (z < zMin)
+    switch (type())
+      {
+      case Camera::PERSPECTIVE  : z = zMin; break;
+      case Camera::ORTHOGRAPHIC : z = 0.0;  break;
+      }
+  return z;
+}
+
+/*! Returns the far clipping plane distance used by the Camera projection matrix.
+
+The far clipping plane is positioned at a distance equal to zClippingCoefficient() * sceneRadius()
+behind the sceneCenter():
+\code

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list